diff --git a/CHANGELOG.md b/CHANGELOG.md index aa92b22..e70b57f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.19.12(2023-10-30) +1. 修复 + - 自动全埋点和手动全埋点共存的时候,手动全埋点 pageShow 的 referrer 不准确 + ## 1.19.11(2023-10-23) 1. 新增 - 数据发送国密加密插件 diff --git a/dist/wechat/plugin/abtesting-sdk-miniprogram/alipay/abtest.cmd.min.js b/dist/wechat/plugin/abtesting-sdk-miniprogram/alipay/abtest.cmd.min.js index b4750f6..3ed480c 100644 --- a/dist/wechat/plugin/abtesting-sdk-miniprogram/alipay/abtest.cmd.min.js +++ b/dist/wechat/plugin/abtesting-sdk-miniprogram/alipay/abtest.cmd.min.js @@ -1 +1 @@ -"use strict";var hasOwnProperty=Object.prototype.hasOwnProperty;function extend(e){return each(Array.prototype.slice.call(arguments,1),function(t){for(var r in t)void 0!==t[r]&&(e[r]=t[r])}),e}function each(e,t,r){var a=Array.prototype.forEach,i={};if(null==e)return!1;if(a&&e.forEach===a)e.forEach(t,r);else if(e.length===+e.length){for(var n=0,s=e.length;n-1?t.system.split(" ")[1]:t.system}catch(e){log("get system fails")}}function getAppId(){var e;if(my.getAccountInfoSync&&(e=my.getAppIdSync()),isObject(e))return e.appId||""}_.getSystemInfo=getSystemInfo,_.getAppId=getAppId;var para={url:"",project_key:"",retry_times:3,timeout_milliseconds:3e3,update_interval:6e5},info={scene:"",lib_version:"1.19.11",plugin_version:"1.19.11",platform:"AlipayMini",storage_key:"sensorsdata2015_ABTest",lib_plugin_name:"alipaymini_abtesting",platform_obj:my},props={$manufacturer:"",$model:"",$os:"",$os_version:""},state={inited:!1,fetchInterval:null,test_list:{},trigger_list:[]};function mixinConfig(e){e.para=para,e.info=info,e.state=state,e.props=props,e.plugin_name="ABTestingAlipay"}function mixinStore(e){var t=e.info.platform_obj;if(!t||isEmptyObject(t))return!1;e.store={getStorage:function(e){var r="";try{a=r=t.getStorageSync({key:e}),r=isString(a)?(-1!==a.indexOf("data:enc;")&&(a=rot13defs(a=a.substring("data:enc;".length))),a):a}catch(e){log("\u83b7\u53d6 storage \u5931\u8d25\uff01")}var a;return isJSONString(r)&&(r=JSON.parse(r)),r},setStorage:function(r,a){var i;try{n=i=JSON.stringify(a),s=!1,e&&e._sa&&e._sa.para&&(s=e._sa.para.encrypt_storage),s&&(isObject(n)&&(n=JSON.stringify(n)),n="data:enc;"+rot13obfs(n)),i=n}catch(e){log("\u5e8f\u5217\u5316\u7f13\u5b58\u5bf9\u8c61\u5931\u8d25\uff01")}var n,s;try{t.setStorageSync({key:r,data:i})}catch(e){log("set Storage fail again --",e)}}}}function mixinRequest(e){var t,r=e.info.platform_obj;isObject(r)&&(t=function(e){var t=e.url,a="GET",i=null;e.method&&(a=e.method),e.data&&(i=e.data),r.request({url:t,method:a,data:i,timeout:e.timeout,success:function(t){e.suc(t.data)},fail:function(t){e.fail(t)}})}),e.request=t}function mixinFetch(e){e.fetchTest=function(){var t=0,r=!1,a=e.creatRequestData();function i(t){_.log("\u8bf7\u6c42\u6570\u636e\u7ed3\u679c\u6210\u529f: ",t),r=!0,e.updateData(t),e.state.fetchInterval&&clearTimeout(e.state.fetchInterval),e.state.fetchInterval=setTimeout(function(){e.request({url:e.para.url,method:"POST",data:JSON.stringify(a),timeout:e.para.timeout_milliseconds,suc:i,fail:n})},e.para.update_interval)}function n(s){return _.log("\u8bf7\u6c42\u6570\u636e\u7ed3\u679c\u5931\u8d25: ",s),t++,!r&&t0||(_.log(e+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0cparam_name\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e\uff01param_name:",t.param_name),a=!1);break;case"value_type":_.isString(t.value_type)&&-1!==_.indexOf(VALUE_TYPE_LIST,t.value_type)||(_.log(e+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0cvalue_type\u914d\u7f6e\u9519\u8bef",t.value_type),a=!1);break;case"default_value":void 0===t.default_value?(_.log(e+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0cdefault_value\u53c2\u6570\u672a\u914d\u7f6e"),a=!1):verifyStore.valueType(t.default_value,t.value_type)||(_.log(e+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0cdefault_value\u7c7b\u578b\u5fc5\u987b\u4e0evalue_type\u4e00\u81f4\uff01",t.default_value,t.value_type),a=!1);break;case"callback":_.isFunction(t.callback)||(_.log(e+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0ccallback\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e"),a=!1)}}),a},resolveCustomProperties:function(e){var t={verify_success:!0,para:null},r=e.custom_properties;if(!_.isObject(r)||_.isEmptyObject(r))return delete e.custom_properties,t.para=e,t;if(_.each(r,function(e,r){if((!_.isString(r)||!regName.test(r)||r.length>100)&&(_.log(" property name [ "+r+" ] is not invalid "),t.verify_success=!1),(_.isString(e)||_.isNumber(e)||_.isBoolean(e)||_.isArray(e)||_.isDate(e))&&!(_.isString(e)&&e.length>500)||(_.log("property [ "+r+" ] of value [ "+JSON.stringify(e)+" ] is not invalid"),t.verify_success=!1),_.isArray(e)){var a=!0;_.each(e,function(e){!1!==a&&(_.isString(e)||(a=!1))}),a||(_.log("property value type can be array, but only allow string item. property [ "+r+" ] of value "+JSON.stringify(e)+" is not invalid"),t.verify_success=!1)}}),!0===t.verify_success){var a={};_.each(r,function(e,t){_.isDate(e)?a[t]=_.formatDate(e):_.isString(e)?a[t]=e:a[t]=JSON.stringify(e)}),e.custom_properties=a}return t.para=e,t}};function defineApi(e,t){for(var r of t)e[r]="fetchCacheABTest"===r?function(e){if(_.log("\u8c03\u7528\u5206\u6d41 API --- A/B Testing \u63d2\u4ef6\u5c1a\u672a\u521d\u59cb\u5316\uff01"),Object.prototype.hasOwnProperty.call(e,"default_value"))return e.default_value}:function(e){_.log("\u8c03\u7528\u5206\u6d41 API --- A/B Testing \u63d2\u4ef6\u5c1a\u672a\u521d\u59cb\u5316\uff01"),e&&_.isFunction(e.callback)&&Object.prototype.hasOwnProperty.call(e,"default_value")&&e.callback(e.default_value)}}function initAPI(e){e.setPara=function(t){if(!_.isString(t.url)||"http"!==t.url.slice(0,4))return _.log("A/B Testing SDK \u521d\u59cb\u5316\u5931\u8d25\uff0c\u8bf7\u4f7f\u7528\u6b63\u786e\u7684 URL\uff01"),!1;e.para.url=t.url;var r=_.getQueryParam(t.url,"project-key");return r?(e.para.project_key=r,_.isNumber(t.timeout_milliseconds)&&(t.timeout_milliseconds<200?e.para.timeout_milliseconds=200:e.para.timeout_milliseconds=t.timeout_milliseconds),_.isNumber(t.update_interval)&&(e.para.update_interval=t.update_interval),!0):(_.log("A/B Testing SDK \u521d\u59cb\u5316\u5931\u8d25\uff0c\u8bf7\u4f7f\u7528\u6b63\u786e\u7684 URL\uff08\u5fc5\u987b\u5305\u542b project-key\uff09\uff01"),!1)},e.asyncFetchABTest=function(t){if(!_.isObject(t))return _.log("asyncFetchABTest\u8c03\u7528\u5931\u8d25\uff0c\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e"),!1;if(!verifyStore.para("asyncFetchABTest",t,["param_name","value_type","default_value","callback"]))return!1;var r=verifyStore.resolveCustomProperties(t);r.verify_success?(t=r.para,_.validTimeout(t),e.asyncFetch(t)):t.callback(t.default_value)},e.fastFetchABTest=function(t){if(!_.isObject(t))return _.log("fastFetchABTest \u8c03\u7528\u5931\u8d25\uff0c\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e"),!1;if(!verifyStore.para("fastFetchABTest",t,["param_name","value_type","default_value","callback"]))return!1;var r=verifyStore.resolveCustomProperties(t);if(r.verify_success){t=r.para,_.validTimeout(t);var a=e.searchLocalExp(t.param_name);if(_.isObject(a)){var i=e.getExpResult(t,a);t.callback(i)}else _.log("fastFetchABTest \u7f13\u5b58\u4e2d\u672a\u8bfb\u53d6\u5230\u6570\u636e\uff0c\u53d1\u8d77\u8bf7\u6c42"),e.asyncFetch(t)}else t.callback(t.default_value)},e.fetchCacheABTest=function(t){if(_.isObject(t))return!!verifyStore.para("fetchCacheABTest",t,["param_name","value_type","default_value"])&&e.getExpResult(t);_.log("fetchCacheABTest\u8c03\u7528\u5931\u8d25\uff0c\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e")},e.asyncFetch=function(t){e.getResultFromServer({para:t,suc:function(r){if(_.isObject(r)&&"SUCCESS"===r.status){_.log("\u83b7\u53d6\u5230\u670d\u52a1\u7aef\u8bd5\u9a8c\u7ed3\u679c\u6570\u636e: ",r),e.updateData(r);var a=e.getExpResult(t);t.callback(a)}else t.callback(t.default_value)},fail:function(e){_.log("\u83b7\u53d6\u670d\u52a1\u7aef\u6570\u636e\u5931\u8d25: ",e),t.callback(t.default_value)}})},e.searchLocalExp=function(t){return!!e.state.test_list[t]&&e.state.test_list[t]},e.getExpResult=function(t,r){var a=t.default_value,i=r||e.searchLocalExp(t.param_name);return _.isObject(i)?_.isObject(i.config)&&(i.config.type===t.value_type?(a=i.config.value,e.trackTestTrigger(i)):_.log("\u8bd5\u9a8c\u7ed3\u679c\u7c7b\u578b\u4e0e\u671f\u671b\u7c7b\u578b\u4e0d\u4e00\u81f4\uff0cparam_name\uff1a"+t.param_name+"\uff0c\u5f53\u524d\u8fd4\u56de\u7c7b\u578b\u4e3a\uff1a"+i.config.type+"\uff0c\u671f\u671b\u7c7b\u578b\u4e3a\uff1a"+t.value_type)):_.log("\u672c\u5730\u672a\u67e5\u8be2\u5230\u8bd5\u9a8c\u6570\u636e\uff0c\u8bd5\u9a8c\u53c2\u6570\u540d\u79f0\uff1a"+t.param_name),a},e.getResultFromServer=function(t){var r=(t=_.isObject(t)?t:{}).para||{},a=t.suc,i=t.fail,n=e.creatRequestData(r);e.request({url:e.para.url,method:"POST",data:JSON.stringify(n),contentType:"application/json",timeout:r.timeout_milliseconds||e.para.timeout_milliseconds,suc:a,fail:i}),_.log("\u5411\u670d\u52a1\u7aef\u53d1\u8d77\u8bd5\u9a8c\u8bf7\u6c42")}}var getDistinctId=function(e){var t="";return e._sa&&e._sa.store&&(t=e._sa.store.getDistinctId()),t};function mixinTrack(e){e.trackTestTrigger=function(t){var r=!1,a=!0;if(t.is_white_list)return!1;var i=t.abtest_experiment_group_id,n=getDistinctId(e),s=t.abtest_experiment_id,o=e.store.getStorage("sensorsdata_abtest_trigger")||{};function c(){a=!1,o[n][s]=i,e.store.setStorage("sensorsdata_abtest_trigger",o)}if(o[n]&&(r=!0),o&&o[n]){var l=o[n];l[s]?l[s]!==i&&(delete l[s],c()):c()}else o[n]={},c();if(!a){var u={$abtest_experiment_id:s,$abtest_experiment_group_id:i};if(!r){var _=e.info.lib_plugin_name+":"+e.info.lib_version;u.$lib_plugin_version=[_]}e._sa.track("$ABTestTrigger",u)}}}var ABTest={};mixinConfig(ABTest),mixinFetch(ABTest),mixinTrack(ABTest),mixinRequest(ABTest),mixinStore(ABTest),ABTest.init=function(e,t){if(_.log("\u521d\u59cb\u5316 ABTest \u63d2\u4ef6"),this.state.inited)return!1;if(initAPI(ABTest),!this.setPara(t))return!1;this.state.inited=!0,this._sa=e,this.subId=new e.eventSub(this.handleIdChange);var r=ABTest.store.getStorage(this.info.storage_key);_.isObject(r)?this.state.test_list=r:this.state.test_list={},_.getSystemInfo(this),this.subId.isReady(),this.listenAppLaunch()},ABTest.handleIdChange=function(e){"changeDistinctId"===e&&(ABTest.state.test_list={},ABTest.state.trigger_list=[],ABTest.store.setStorage(ABTest.info.storage_key,ABTest.state.test_list),ABTest.fetchTest())},ABTest.listenAppLaunch=function(){var e=my.getLaunchOptionsSync();e&&e.scene&&(this.info.scene="ali-"+e.scene),this.fetchTest()},defineApi(ABTest,["asyncFetchABTest","fastFetchABTest","fetchCacheABTest"]),module.exports=ABTest; \ No newline at end of file +"use strict";var hasOwnProperty=Object.prototype.hasOwnProperty;function extend(e){return each(Array.prototype.slice.call(arguments,1),function(t){for(var r in t)void 0!==t[r]&&(e[r]=t[r])}),e}function each(e,t,r){var a=Array.prototype.forEach,i={};if(null==e)return!1;if(a&&e.forEach===a)e.forEach(t,r);else if(e.length===+e.length){for(var n=0,s=e.length;n-1?t.system.split(" ")[1]:t.system}catch(e){log("get system fails")}}function getAppId(){var e;if(my.getAccountInfoSync&&(e=my.getAppIdSync()),isObject(e))return e.appId||""}_.getSystemInfo=getSystemInfo,_.getAppId=getAppId;var para={url:"",project_key:"",retry_times:3,timeout_milliseconds:3e3,update_interval:6e5},info={scene:"",lib_version:"1.19.12",plugin_version:"1.19.12",platform:"AlipayMini",storage_key:"sensorsdata2015_ABTest",lib_plugin_name:"alipaymini_abtesting",platform_obj:my},props={$manufacturer:"",$model:"",$os:"",$os_version:""},state={inited:!1,fetchInterval:null,test_list:{},trigger_list:[]};function mixinConfig(e){e.para=para,e.info=info,e.state=state,e.props=props,e.plugin_name="ABTestingAlipay"}function mixinStore(e){var t=e.info.platform_obj;if(!t||isEmptyObject(t))return!1;e.store={getStorage:function(e){var r="";try{a=r=t.getStorageSync({key:e}),r=isString(a)?(-1!==a.indexOf("data:enc;")&&(a=rot13defs(a=a.substring("data:enc;".length))),a):a}catch(e){log("\u83b7\u53d6 storage \u5931\u8d25\uff01")}var a;return isJSONString(r)&&(r=JSON.parse(r)),r},setStorage:function(r,a){var i;try{n=i=JSON.stringify(a),s=!1,e&&e._sa&&e._sa.para&&(s=e._sa.para.encrypt_storage),s&&(isObject(n)&&(n=JSON.stringify(n)),n="data:enc;"+rot13obfs(n)),i=n}catch(e){log("\u5e8f\u5217\u5316\u7f13\u5b58\u5bf9\u8c61\u5931\u8d25\uff01")}var n,s;try{t.setStorageSync({key:r,data:i})}catch(e){log("set Storage fail again --",e)}}}}function mixinRequest(e){var t,r=e.info.platform_obj;isObject(r)&&(t=function(e){var t=e.url,a="GET",i=null;e.method&&(a=e.method),e.data&&(i=e.data),r.request({url:t,method:a,data:i,timeout:e.timeout,success:function(t){e.suc(t.data)},fail:function(t){e.fail(t)}})}),e.request=t}function mixinFetch(e){e.fetchTest=function(){var t=0,r=!1,a=e.creatRequestData();function i(t){_.log("\u8bf7\u6c42\u6570\u636e\u7ed3\u679c\u6210\u529f: ",t),r=!0,e.updateData(t),e.state.fetchInterval&&clearTimeout(e.state.fetchInterval),e.state.fetchInterval=setTimeout(function(){e.request({url:e.para.url,method:"POST",data:JSON.stringify(a),timeout:e.para.timeout_milliseconds,suc:i,fail:n})},e.para.update_interval)}function n(s){return _.log("\u8bf7\u6c42\u6570\u636e\u7ed3\u679c\u5931\u8d25: ",s),t++,!r&&t0||(_.log(e+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0cparam_name\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e\uff01param_name:",t.param_name),a=!1);break;case"value_type":_.isString(t.value_type)&&-1!==_.indexOf(VALUE_TYPE_LIST,t.value_type)||(_.log(e+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0cvalue_type\u914d\u7f6e\u9519\u8bef",t.value_type),a=!1);break;case"default_value":void 0===t.default_value?(_.log(e+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0cdefault_value\u53c2\u6570\u672a\u914d\u7f6e"),a=!1):verifyStore.valueType(t.default_value,t.value_type)||(_.log(e+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0cdefault_value\u7c7b\u578b\u5fc5\u987b\u4e0evalue_type\u4e00\u81f4\uff01",t.default_value,t.value_type),a=!1);break;case"callback":_.isFunction(t.callback)||(_.log(e+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0ccallback\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e"),a=!1)}}),a},resolveCustomProperties:function(e){var t={verify_success:!0,para:null},r=e.custom_properties;if(!_.isObject(r)||_.isEmptyObject(r))return delete e.custom_properties,t.para=e,t;if(_.each(r,function(e,r){if((!_.isString(r)||!regName.test(r)||r.length>100)&&(_.log(" property name [ "+r+" ] is not invalid "),t.verify_success=!1),(_.isString(e)||_.isNumber(e)||_.isBoolean(e)||_.isArray(e)||_.isDate(e))&&!(_.isString(e)&&e.length>500)||(_.log("property [ "+r+" ] of value [ "+JSON.stringify(e)+" ] is not invalid"),t.verify_success=!1),_.isArray(e)){var a=!0;_.each(e,function(e){!1!==a&&(_.isString(e)||(a=!1))}),a||(_.log("property value type can be array, but only allow string item. property [ "+r+" ] of value "+JSON.stringify(e)+" is not invalid"),t.verify_success=!1)}}),!0===t.verify_success){var a={};_.each(r,function(e,t){_.isDate(e)?a[t]=_.formatDate(e):_.isString(e)?a[t]=e:a[t]=JSON.stringify(e)}),e.custom_properties=a}return t.para=e,t}};function defineApi(e,t){for(var r of t)e[r]="fetchCacheABTest"===r?function(e){if(_.log("\u8c03\u7528\u5206\u6d41 API --- A/B Testing \u63d2\u4ef6\u5c1a\u672a\u521d\u59cb\u5316\uff01"),Object.prototype.hasOwnProperty.call(e,"default_value"))return e.default_value}:function(e){_.log("\u8c03\u7528\u5206\u6d41 API --- A/B Testing \u63d2\u4ef6\u5c1a\u672a\u521d\u59cb\u5316\uff01"),e&&_.isFunction(e.callback)&&Object.prototype.hasOwnProperty.call(e,"default_value")&&e.callback(e.default_value)}}function initAPI(e){e.setPara=function(t){if(!_.isString(t.url)||"http"!==t.url.slice(0,4))return _.log("A/B Testing SDK \u521d\u59cb\u5316\u5931\u8d25\uff0c\u8bf7\u4f7f\u7528\u6b63\u786e\u7684 URL\uff01"),!1;e.para.url=t.url;var r=_.getQueryParam(t.url,"project-key");return r?(e.para.project_key=r,_.isNumber(t.timeout_milliseconds)&&(t.timeout_milliseconds<200?e.para.timeout_milliseconds=200:e.para.timeout_milliseconds=t.timeout_milliseconds),_.isNumber(t.update_interval)&&(e.para.update_interval=t.update_interval),!0):(_.log("A/B Testing SDK \u521d\u59cb\u5316\u5931\u8d25\uff0c\u8bf7\u4f7f\u7528\u6b63\u786e\u7684 URL\uff08\u5fc5\u987b\u5305\u542b project-key\uff09\uff01"),!1)},e.asyncFetchABTest=function(t){if(!_.isObject(t))return _.log("asyncFetchABTest\u8c03\u7528\u5931\u8d25\uff0c\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e"),!1;if(!verifyStore.para("asyncFetchABTest",t,["param_name","value_type","default_value","callback"]))return!1;var r=verifyStore.resolveCustomProperties(t);r.verify_success?(t=r.para,_.validTimeout(t),e.asyncFetch(t)):t.callback(t.default_value)},e.fastFetchABTest=function(t){if(!_.isObject(t))return _.log("fastFetchABTest \u8c03\u7528\u5931\u8d25\uff0c\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e"),!1;if(!verifyStore.para("fastFetchABTest",t,["param_name","value_type","default_value","callback"]))return!1;var r=verifyStore.resolveCustomProperties(t);if(r.verify_success){t=r.para,_.validTimeout(t);var a=e.searchLocalExp(t.param_name);if(_.isObject(a)){var i=e.getExpResult(t,a);t.callback(i)}else _.log("fastFetchABTest \u7f13\u5b58\u4e2d\u672a\u8bfb\u53d6\u5230\u6570\u636e\uff0c\u53d1\u8d77\u8bf7\u6c42"),e.asyncFetch(t)}else t.callback(t.default_value)},e.fetchCacheABTest=function(t){if(_.isObject(t))return!!verifyStore.para("fetchCacheABTest",t,["param_name","value_type","default_value"])&&e.getExpResult(t);_.log("fetchCacheABTest\u8c03\u7528\u5931\u8d25\uff0c\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e")},e.asyncFetch=function(t){e.getResultFromServer({para:t,suc:function(r){if(_.isObject(r)&&"SUCCESS"===r.status){_.log("\u83b7\u53d6\u5230\u670d\u52a1\u7aef\u8bd5\u9a8c\u7ed3\u679c\u6570\u636e: ",r),e.updateData(r);var a=e.getExpResult(t);t.callback(a)}else t.callback(t.default_value)},fail:function(e){_.log("\u83b7\u53d6\u670d\u52a1\u7aef\u6570\u636e\u5931\u8d25: ",e),t.callback(t.default_value)}})},e.searchLocalExp=function(t){return!!e.state.test_list[t]&&e.state.test_list[t]},e.getExpResult=function(t,r){var a=t.default_value,i=r||e.searchLocalExp(t.param_name);return _.isObject(i)?_.isObject(i.config)&&(i.config.type===t.value_type?(a=i.config.value,e.trackTestTrigger(i)):_.log("\u8bd5\u9a8c\u7ed3\u679c\u7c7b\u578b\u4e0e\u671f\u671b\u7c7b\u578b\u4e0d\u4e00\u81f4\uff0cparam_name\uff1a"+t.param_name+"\uff0c\u5f53\u524d\u8fd4\u56de\u7c7b\u578b\u4e3a\uff1a"+i.config.type+"\uff0c\u671f\u671b\u7c7b\u578b\u4e3a\uff1a"+t.value_type)):_.log("\u672c\u5730\u672a\u67e5\u8be2\u5230\u8bd5\u9a8c\u6570\u636e\uff0c\u8bd5\u9a8c\u53c2\u6570\u540d\u79f0\uff1a"+t.param_name),a},e.getResultFromServer=function(t){var r=(t=_.isObject(t)?t:{}).para||{},a=t.suc,i=t.fail,n=e.creatRequestData(r);e.request({url:e.para.url,method:"POST",data:JSON.stringify(n),contentType:"application/json",timeout:r.timeout_milliseconds||e.para.timeout_milliseconds,suc:a,fail:i}),_.log("\u5411\u670d\u52a1\u7aef\u53d1\u8d77\u8bd5\u9a8c\u8bf7\u6c42")}}var getDistinctId=function(e){var t="";return e._sa&&e._sa.store&&(t=e._sa.store.getDistinctId()),t};function mixinTrack(e){e.trackTestTrigger=function(t){var r=!1,a=!0;if(t.is_white_list)return!1;var i=t.abtest_experiment_group_id,n=getDistinctId(e),s=t.abtest_experiment_id,o=e.store.getStorage("sensorsdata_abtest_trigger")||{};function c(){a=!1,o[n][s]=i,e.store.setStorage("sensorsdata_abtest_trigger",o)}if(o[n]&&(r=!0),o&&o[n]){var l=o[n];l[s]?l[s]!==i&&(delete l[s],c()):c()}else o[n]={},c();if(!a){var u={$abtest_experiment_id:s,$abtest_experiment_group_id:i};if(!r){var _=e.info.lib_plugin_name+":"+e.info.lib_version;u.$lib_plugin_version=[_]}e._sa.track("$ABTestTrigger",u)}}}var ABTest={};mixinConfig(ABTest),mixinFetch(ABTest),mixinTrack(ABTest),mixinRequest(ABTest),mixinStore(ABTest),ABTest.init=function(e,t){if(_.log("\u521d\u59cb\u5316 ABTest \u63d2\u4ef6"),this.state.inited)return!1;if(initAPI(ABTest),!this.setPara(t))return!1;this.state.inited=!0,this._sa=e,this.subId=new e.eventSub(this.handleIdChange);var r=ABTest.store.getStorage(this.info.storage_key);_.isObject(r)?this.state.test_list=r:this.state.test_list={},_.getSystemInfo(this),this.subId.isReady(),this.listenAppLaunch()},ABTest.handleIdChange=function(e){"changeDistinctId"===e&&(ABTest.state.test_list={},ABTest.state.trigger_list=[],ABTest.store.setStorage(ABTest.info.storage_key,ABTest.state.test_list),ABTest.fetchTest())},ABTest.listenAppLaunch=function(){var e=my.getLaunchOptionsSync();e&&e.scene&&(this.info.scene="ali-"+e.scene),this.fetchTest()},defineApi(ABTest,["asyncFetchABTest","fastFetchABTest","fetchCacheABTest"]),module.exports=ABTest; \ No newline at end of file diff --git a/dist/wechat/plugin/abtesting-sdk-miniprogram/alipay/abtest.esm.min.js b/dist/wechat/plugin/abtesting-sdk-miniprogram/alipay/abtest.esm.min.js index 36c97de..2a7526d 100644 --- a/dist/wechat/plugin/abtesting-sdk-miniprogram/alipay/abtest.esm.min.js +++ b/dist/wechat/plugin/abtesting-sdk-miniprogram/alipay/abtest.esm.min.js @@ -1 +1 @@ -var hasOwnProperty=Object.prototype.hasOwnProperty;function extend(e){return each(Array.prototype.slice.call(arguments,1),function(t){for(var r in t)void 0!==t[r]&&(e[r]=t[r])}),e}function each(e,t,r){var a=Array.prototype.forEach,i={};if(null==e)return!1;if(a&&e.forEach===a)e.forEach(t,r);else if(e.length===+e.length){for(var n=0,s=e.length;n-1?t.system.split(" ")[1]:t.system}catch(e){log("get system fails")}}function getAppId(){var e;if(my.getAccountInfoSync&&(e=my.getAppIdSync()),isObject(e))return e.appId||""}_.getSystemInfo=getSystemInfo,_.getAppId=getAppId;var para={url:"",project_key:"",retry_times:3,timeout_milliseconds:3e3,update_interval:6e5},info={scene:"",lib_version:"1.19.11",plugin_version:"1.19.11",platform:"AlipayMini",storage_key:"sensorsdata2015_ABTest",lib_plugin_name:"alipaymini_abtesting",platform_obj:my},props={$manufacturer:"",$model:"",$os:"",$os_version:""},state={inited:!1,fetchInterval:null,test_list:{},trigger_list:[]};function mixinConfig(e){e.para=para,e.info=info,e.state=state,e.props=props,e.plugin_name="ABTestingAlipay"}function mixinStore(e){var t=e.info.platform_obj;if(!t||isEmptyObject(t))return!1;e.store={getStorage:function(e){var r="";try{a=r=t.getStorageSync({key:e}),r=isString(a)?(-1!==a.indexOf("data:enc;")&&(a=rot13defs(a=a.substring("data:enc;".length))),a):a}catch(e){log("\u83b7\u53d6 storage \u5931\u8d25\uff01")}var a;return isJSONString(r)&&(r=JSON.parse(r)),r},setStorage:function(r,a){var i;try{n=i=JSON.stringify(a),s=!1,e&&e._sa&&e._sa.para&&(s=e._sa.para.encrypt_storage),s&&(isObject(n)&&(n=JSON.stringify(n)),n="data:enc;"+rot13obfs(n)),i=n}catch(e){log("\u5e8f\u5217\u5316\u7f13\u5b58\u5bf9\u8c61\u5931\u8d25\uff01")}var n,s;try{t.setStorageSync({key:r,data:i})}catch(e){log("set Storage fail again --",e)}}}}function mixinRequest(e){var t,r=e.info.platform_obj;isObject(r)&&(t=function(e){var t=e.url,a="GET",i=null;e.method&&(a=e.method),e.data&&(i=e.data),r.request({url:t,method:a,data:i,timeout:e.timeout,success:function(t){e.suc(t.data)},fail:function(t){e.fail(t)}})}),e.request=t}function mixinFetch(e){e.fetchTest=function(){var t=0,r=!1,a=e.creatRequestData();function i(t){_.log("\u8bf7\u6c42\u6570\u636e\u7ed3\u679c\u6210\u529f: ",t),r=!0,e.updateData(t),e.state.fetchInterval&&clearTimeout(e.state.fetchInterval),e.state.fetchInterval=setTimeout(function(){e.request({url:e.para.url,method:"POST",data:JSON.stringify(a),timeout:e.para.timeout_milliseconds,suc:i,fail:n})},e.para.update_interval)}function n(s){return _.log("\u8bf7\u6c42\u6570\u636e\u7ed3\u679c\u5931\u8d25: ",s),t++,!r&&t0||(_.log(e+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0cparam_name\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e\uff01param_name:",t.param_name),a=!1);break;case"value_type":_.isString(t.value_type)&&-1!==_.indexOf(VALUE_TYPE_LIST,t.value_type)||(_.log(e+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0cvalue_type\u914d\u7f6e\u9519\u8bef",t.value_type),a=!1);break;case"default_value":void 0===t.default_value?(_.log(e+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0cdefault_value\u53c2\u6570\u672a\u914d\u7f6e"),a=!1):verifyStore.valueType(t.default_value,t.value_type)||(_.log(e+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0cdefault_value\u7c7b\u578b\u5fc5\u987b\u4e0evalue_type\u4e00\u81f4\uff01",t.default_value,t.value_type),a=!1);break;case"callback":_.isFunction(t.callback)||(_.log(e+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0ccallback\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e"),a=!1)}}),a},resolveCustomProperties:function(e){var t={verify_success:!0,para:null},r=e.custom_properties;if(!_.isObject(r)||_.isEmptyObject(r))return delete e.custom_properties,t.para=e,t;if(_.each(r,function(e,r){if((!_.isString(r)||!regName.test(r)||r.length>100)&&(_.log(" property name [ "+r+" ] is not invalid "),t.verify_success=!1),(_.isString(e)||_.isNumber(e)||_.isBoolean(e)||_.isArray(e)||_.isDate(e))&&!(_.isString(e)&&e.length>500)||(_.log("property [ "+r+" ] of value [ "+JSON.stringify(e)+" ] is not invalid"),t.verify_success=!1),_.isArray(e)){var a=!0;_.each(e,function(e){!1!==a&&(_.isString(e)||(a=!1))}),a||(_.log("property value type can be array, but only allow string item. property [ "+r+" ] of value "+JSON.stringify(e)+" is not invalid"),t.verify_success=!1)}}),!0===t.verify_success){var a={};_.each(r,function(e,t){_.isDate(e)?a[t]=_.formatDate(e):_.isString(e)?a[t]=e:a[t]=JSON.stringify(e)}),e.custom_properties=a}return t.para=e,t}};function defineApi(e,t){for(var r of t)e[r]="fetchCacheABTest"===r?function(e){if(_.log("\u8c03\u7528\u5206\u6d41 API --- A/B Testing \u63d2\u4ef6\u5c1a\u672a\u521d\u59cb\u5316\uff01"),Object.prototype.hasOwnProperty.call(e,"default_value"))return e.default_value}:function(e){_.log("\u8c03\u7528\u5206\u6d41 API --- A/B Testing \u63d2\u4ef6\u5c1a\u672a\u521d\u59cb\u5316\uff01"),e&&_.isFunction(e.callback)&&Object.prototype.hasOwnProperty.call(e,"default_value")&&e.callback(e.default_value)}}function initAPI(e){e.setPara=function(t){if(!_.isString(t.url)||"http"!==t.url.slice(0,4))return _.log("A/B Testing SDK \u521d\u59cb\u5316\u5931\u8d25\uff0c\u8bf7\u4f7f\u7528\u6b63\u786e\u7684 URL\uff01"),!1;e.para.url=t.url;var r=_.getQueryParam(t.url,"project-key");return r?(e.para.project_key=r,_.isNumber(t.timeout_milliseconds)&&(t.timeout_milliseconds<200?e.para.timeout_milliseconds=200:e.para.timeout_milliseconds=t.timeout_milliseconds),_.isNumber(t.update_interval)&&(e.para.update_interval=t.update_interval),!0):(_.log("A/B Testing SDK \u521d\u59cb\u5316\u5931\u8d25\uff0c\u8bf7\u4f7f\u7528\u6b63\u786e\u7684 URL\uff08\u5fc5\u987b\u5305\u542b project-key\uff09\uff01"),!1)},e.asyncFetchABTest=function(t){if(!_.isObject(t))return _.log("asyncFetchABTest\u8c03\u7528\u5931\u8d25\uff0c\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e"),!1;if(!verifyStore.para("asyncFetchABTest",t,["param_name","value_type","default_value","callback"]))return!1;var r=verifyStore.resolveCustomProperties(t);r.verify_success?(t=r.para,_.validTimeout(t),e.asyncFetch(t)):t.callback(t.default_value)},e.fastFetchABTest=function(t){if(!_.isObject(t))return _.log("fastFetchABTest \u8c03\u7528\u5931\u8d25\uff0c\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e"),!1;if(!verifyStore.para("fastFetchABTest",t,["param_name","value_type","default_value","callback"]))return!1;var r=verifyStore.resolveCustomProperties(t);if(r.verify_success){t=r.para,_.validTimeout(t);var a=e.searchLocalExp(t.param_name);if(_.isObject(a)){var i=e.getExpResult(t,a);t.callback(i)}else _.log("fastFetchABTest \u7f13\u5b58\u4e2d\u672a\u8bfb\u53d6\u5230\u6570\u636e\uff0c\u53d1\u8d77\u8bf7\u6c42"),e.asyncFetch(t)}else t.callback(t.default_value)},e.fetchCacheABTest=function(t){if(_.isObject(t))return!!verifyStore.para("fetchCacheABTest",t,["param_name","value_type","default_value"])&&e.getExpResult(t);_.log("fetchCacheABTest\u8c03\u7528\u5931\u8d25\uff0c\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e")},e.asyncFetch=function(t){e.getResultFromServer({para:t,suc:function(r){if(_.isObject(r)&&"SUCCESS"===r.status){_.log("\u83b7\u53d6\u5230\u670d\u52a1\u7aef\u8bd5\u9a8c\u7ed3\u679c\u6570\u636e: ",r),e.updateData(r);var a=e.getExpResult(t);t.callback(a)}else t.callback(t.default_value)},fail:function(e){_.log("\u83b7\u53d6\u670d\u52a1\u7aef\u6570\u636e\u5931\u8d25: ",e),t.callback(t.default_value)}})},e.searchLocalExp=function(t){return!!e.state.test_list[t]&&e.state.test_list[t]},e.getExpResult=function(t,r){var a=t.default_value,i=r||e.searchLocalExp(t.param_name);return _.isObject(i)?_.isObject(i.config)&&(i.config.type===t.value_type?(a=i.config.value,e.trackTestTrigger(i)):_.log("\u8bd5\u9a8c\u7ed3\u679c\u7c7b\u578b\u4e0e\u671f\u671b\u7c7b\u578b\u4e0d\u4e00\u81f4\uff0cparam_name\uff1a"+t.param_name+"\uff0c\u5f53\u524d\u8fd4\u56de\u7c7b\u578b\u4e3a\uff1a"+i.config.type+"\uff0c\u671f\u671b\u7c7b\u578b\u4e3a\uff1a"+t.value_type)):_.log("\u672c\u5730\u672a\u67e5\u8be2\u5230\u8bd5\u9a8c\u6570\u636e\uff0c\u8bd5\u9a8c\u53c2\u6570\u540d\u79f0\uff1a"+t.param_name),a},e.getResultFromServer=function(t){var r=(t=_.isObject(t)?t:{}).para||{},a=t.suc,i=t.fail,n=e.creatRequestData(r);e.request({url:e.para.url,method:"POST",data:JSON.stringify(n),contentType:"application/json",timeout:r.timeout_milliseconds||e.para.timeout_milliseconds,suc:a,fail:i}),_.log("\u5411\u670d\u52a1\u7aef\u53d1\u8d77\u8bd5\u9a8c\u8bf7\u6c42")}}var getDistinctId=function(e){var t="";return e._sa&&e._sa.store&&(t=e._sa.store.getDistinctId()),t};function mixinTrack(e){e.trackTestTrigger=function(t){var r=!1,a=!0;if(t.is_white_list)return!1;var i=t.abtest_experiment_group_id,n=getDistinctId(e),s=t.abtest_experiment_id,o=e.store.getStorage("sensorsdata_abtest_trigger")||{};function c(){a=!1,o[n][s]=i,e.store.setStorage("sensorsdata_abtest_trigger",o)}if(o[n]&&(r=!0),o&&o[n]){var l=o[n];l[s]?l[s]!==i&&(delete l[s],c()):c()}else o[n]={},c();if(!a){var u={$abtest_experiment_id:s,$abtest_experiment_group_id:i};if(!r){var _=e.info.lib_plugin_name+":"+e.info.lib_version;u.$lib_plugin_version=[_]}e._sa.track("$ABTestTrigger",u)}}}var ABTest={};mixinConfig(ABTest),mixinFetch(ABTest),mixinTrack(ABTest),mixinRequest(ABTest),mixinStore(ABTest),ABTest.init=function(e,t){if(_.log("\u521d\u59cb\u5316 ABTest \u63d2\u4ef6"),this.state.inited)return!1;if(initAPI(ABTest),!this.setPara(t))return!1;this.state.inited=!0,this._sa=e,this.subId=new e.eventSub(this.handleIdChange);var r=ABTest.store.getStorage(this.info.storage_key);_.isObject(r)?this.state.test_list=r:this.state.test_list={},_.getSystemInfo(this),this.subId.isReady(),this.listenAppLaunch()},ABTest.handleIdChange=function(e){"changeDistinctId"===e&&(ABTest.state.test_list={},ABTest.state.trigger_list=[],ABTest.store.setStorage(ABTest.info.storage_key,ABTest.state.test_list),ABTest.fetchTest())},ABTest.listenAppLaunch=function(){var e=my.getLaunchOptionsSync();e&&e.scene&&(this.info.scene="ali-"+e.scene),this.fetchTest()},defineApi(ABTest,["asyncFetchABTest","fastFetchABTest","fetchCacheABTest"]);export default ABTest; \ No newline at end of file +var hasOwnProperty=Object.prototype.hasOwnProperty;function extend(e){return each(Array.prototype.slice.call(arguments,1),function(t){for(var r in t)void 0!==t[r]&&(e[r]=t[r])}),e}function each(e,t,r){var a=Array.prototype.forEach,i={};if(null==e)return!1;if(a&&e.forEach===a)e.forEach(t,r);else if(e.length===+e.length){for(var n=0,s=e.length;n-1?t.system.split(" ")[1]:t.system}catch(e){log("get system fails")}}function getAppId(){var e;if(my.getAccountInfoSync&&(e=my.getAppIdSync()),isObject(e))return e.appId||""}_.getSystemInfo=getSystemInfo,_.getAppId=getAppId;var para={url:"",project_key:"",retry_times:3,timeout_milliseconds:3e3,update_interval:6e5},info={scene:"",lib_version:"1.19.12",plugin_version:"1.19.12",platform:"AlipayMini",storage_key:"sensorsdata2015_ABTest",lib_plugin_name:"alipaymini_abtesting",platform_obj:my},props={$manufacturer:"",$model:"",$os:"",$os_version:""},state={inited:!1,fetchInterval:null,test_list:{},trigger_list:[]};function mixinConfig(e){e.para=para,e.info=info,e.state=state,e.props=props,e.plugin_name="ABTestingAlipay"}function mixinStore(e){var t=e.info.platform_obj;if(!t||isEmptyObject(t))return!1;e.store={getStorage:function(e){var r="";try{a=r=t.getStorageSync({key:e}),r=isString(a)?(-1!==a.indexOf("data:enc;")&&(a=rot13defs(a=a.substring("data:enc;".length))),a):a}catch(e){log("\u83b7\u53d6 storage \u5931\u8d25\uff01")}var a;return isJSONString(r)&&(r=JSON.parse(r)),r},setStorage:function(r,a){var i;try{n=i=JSON.stringify(a),s=!1,e&&e._sa&&e._sa.para&&(s=e._sa.para.encrypt_storage),s&&(isObject(n)&&(n=JSON.stringify(n)),n="data:enc;"+rot13obfs(n)),i=n}catch(e){log("\u5e8f\u5217\u5316\u7f13\u5b58\u5bf9\u8c61\u5931\u8d25\uff01")}var n,s;try{t.setStorageSync({key:r,data:i})}catch(e){log("set Storage fail again --",e)}}}}function mixinRequest(e){var t,r=e.info.platform_obj;isObject(r)&&(t=function(e){var t=e.url,a="GET",i=null;e.method&&(a=e.method),e.data&&(i=e.data),r.request({url:t,method:a,data:i,timeout:e.timeout,success:function(t){e.suc(t.data)},fail:function(t){e.fail(t)}})}),e.request=t}function mixinFetch(e){e.fetchTest=function(){var t=0,r=!1,a=e.creatRequestData();function i(t){_.log("\u8bf7\u6c42\u6570\u636e\u7ed3\u679c\u6210\u529f: ",t),r=!0,e.updateData(t),e.state.fetchInterval&&clearTimeout(e.state.fetchInterval),e.state.fetchInterval=setTimeout(function(){e.request({url:e.para.url,method:"POST",data:JSON.stringify(a),timeout:e.para.timeout_milliseconds,suc:i,fail:n})},e.para.update_interval)}function n(s){return _.log("\u8bf7\u6c42\u6570\u636e\u7ed3\u679c\u5931\u8d25: ",s),t++,!r&&t0||(_.log(e+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0cparam_name\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e\uff01param_name:",t.param_name),a=!1);break;case"value_type":_.isString(t.value_type)&&-1!==_.indexOf(VALUE_TYPE_LIST,t.value_type)||(_.log(e+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0cvalue_type\u914d\u7f6e\u9519\u8bef",t.value_type),a=!1);break;case"default_value":void 0===t.default_value?(_.log(e+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0cdefault_value\u53c2\u6570\u672a\u914d\u7f6e"),a=!1):verifyStore.valueType(t.default_value,t.value_type)||(_.log(e+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0cdefault_value\u7c7b\u578b\u5fc5\u987b\u4e0evalue_type\u4e00\u81f4\uff01",t.default_value,t.value_type),a=!1);break;case"callback":_.isFunction(t.callback)||(_.log(e+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0ccallback\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e"),a=!1)}}),a},resolveCustomProperties:function(e){var t={verify_success:!0,para:null},r=e.custom_properties;if(!_.isObject(r)||_.isEmptyObject(r))return delete e.custom_properties,t.para=e,t;if(_.each(r,function(e,r){if((!_.isString(r)||!regName.test(r)||r.length>100)&&(_.log(" property name [ "+r+" ] is not invalid "),t.verify_success=!1),(_.isString(e)||_.isNumber(e)||_.isBoolean(e)||_.isArray(e)||_.isDate(e))&&!(_.isString(e)&&e.length>500)||(_.log("property [ "+r+" ] of value [ "+JSON.stringify(e)+" ] is not invalid"),t.verify_success=!1),_.isArray(e)){var a=!0;_.each(e,function(e){!1!==a&&(_.isString(e)||(a=!1))}),a||(_.log("property value type can be array, but only allow string item. property [ "+r+" ] of value "+JSON.stringify(e)+" is not invalid"),t.verify_success=!1)}}),!0===t.verify_success){var a={};_.each(r,function(e,t){_.isDate(e)?a[t]=_.formatDate(e):_.isString(e)?a[t]=e:a[t]=JSON.stringify(e)}),e.custom_properties=a}return t.para=e,t}};function defineApi(e,t){for(var r of t)e[r]="fetchCacheABTest"===r?function(e){if(_.log("\u8c03\u7528\u5206\u6d41 API --- A/B Testing \u63d2\u4ef6\u5c1a\u672a\u521d\u59cb\u5316\uff01"),Object.prototype.hasOwnProperty.call(e,"default_value"))return e.default_value}:function(e){_.log("\u8c03\u7528\u5206\u6d41 API --- A/B Testing \u63d2\u4ef6\u5c1a\u672a\u521d\u59cb\u5316\uff01"),e&&_.isFunction(e.callback)&&Object.prototype.hasOwnProperty.call(e,"default_value")&&e.callback(e.default_value)}}function initAPI(e){e.setPara=function(t){if(!_.isString(t.url)||"http"!==t.url.slice(0,4))return _.log("A/B Testing SDK \u521d\u59cb\u5316\u5931\u8d25\uff0c\u8bf7\u4f7f\u7528\u6b63\u786e\u7684 URL\uff01"),!1;e.para.url=t.url;var r=_.getQueryParam(t.url,"project-key");return r?(e.para.project_key=r,_.isNumber(t.timeout_milliseconds)&&(t.timeout_milliseconds<200?e.para.timeout_milliseconds=200:e.para.timeout_milliseconds=t.timeout_milliseconds),_.isNumber(t.update_interval)&&(e.para.update_interval=t.update_interval),!0):(_.log("A/B Testing SDK \u521d\u59cb\u5316\u5931\u8d25\uff0c\u8bf7\u4f7f\u7528\u6b63\u786e\u7684 URL\uff08\u5fc5\u987b\u5305\u542b project-key\uff09\uff01"),!1)},e.asyncFetchABTest=function(t){if(!_.isObject(t))return _.log("asyncFetchABTest\u8c03\u7528\u5931\u8d25\uff0c\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e"),!1;if(!verifyStore.para("asyncFetchABTest",t,["param_name","value_type","default_value","callback"]))return!1;var r=verifyStore.resolveCustomProperties(t);r.verify_success?(t=r.para,_.validTimeout(t),e.asyncFetch(t)):t.callback(t.default_value)},e.fastFetchABTest=function(t){if(!_.isObject(t))return _.log("fastFetchABTest \u8c03\u7528\u5931\u8d25\uff0c\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e"),!1;if(!verifyStore.para("fastFetchABTest",t,["param_name","value_type","default_value","callback"]))return!1;var r=verifyStore.resolveCustomProperties(t);if(r.verify_success){t=r.para,_.validTimeout(t);var a=e.searchLocalExp(t.param_name);if(_.isObject(a)){var i=e.getExpResult(t,a);t.callback(i)}else _.log("fastFetchABTest \u7f13\u5b58\u4e2d\u672a\u8bfb\u53d6\u5230\u6570\u636e\uff0c\u53d1\u8d77\u8bf7\u6c42"),e.asyncFetch(t)}else t.callback(t.default_value)},e.fetchCacheABTest=function(t){if(_.isObject(t))return!!verifyStore.para("fetchCacheABTest",t,["param_name","value_type","default_value"])&&e.getExpResult(t);_.log("fetchCacheABTest\u8c03\u7528\u5931\u8d25\uff0c\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e")},e.asyncFetch=function(t){e.getResultFromServer({para:t,suc:function(r){if(_.isObject(r)&&"SUCCESS"===r.status){_.log("\u83b7\u53d6\u5230\u670d\u52a1\u7aef\u8bd5\u9a8c\u7ed3\u679c\u6570\u636e: ",r),e.updateData(r);var a=e.getExpResult(t);t.callback(a)}else t.callback(t.default_value)},fail:function(e){_.log("\u83b7\u53d6\u670d\u52a1\u7aef\u6570\u636e\u5931\u8d25: ",e),t.callback(t.default_value)}})},e.searchLocalExp=function(t){return!!e.state.test_list[t]&&e.state.test_list[t]},e.getExpResult=function(t,r){var a=t.default_value,i=r||e.searchLocalExp(t.param_name);return _.isObject(i)?_.isObject(i.config)&&(i.config.type===t.value_type?(a=i.config.value,e.trackTestTrigger(i)):_.log("\u8bd5\u9a8c\u7ed3\u679c\u7c7b\u578b\u4e0e\u671f\u671b\u7c7b\u578b\u4e0d\u4e00\u81f4\uff0cparam_name\uff1a"+t.param_name+"\uff0c\u5f53\u524d\u8fd4\u56de\u7c7b\u578b\u4e3a\uff1a"+i.config.type+"\uff0c\u671f\u671b\u7c7b\u578b\u4e3a\uff1a"+t.value_type)):_.log("\u672c\u5730\u672a\u67e5\u8be2\u5230\u8bd5\u9a8c\u6570\u636e\uff0c\u8bd5\u9a8c\u53c2\u6570\u540d\u79f0\uff1a"+t.param_name),a},e.getResultFromServer=function(t){var r=(t=_.isObject(t)?t:{}).para||{},a=t.suc,i=t.fail,n=e.creatRequestData(r);e.request({url:e.para.url,method:"POST",data:JSON.stringify(n),contentType:"application/json",timeout:r.timeout_milliseconds||e.para.timeout_milliseconds,suc:a,fail:i}),_.log("\u5411\u670d\u52a1\u7aef\u53d1\u8d77\u8bd5\u9a8c\u8bf7\u6c42")}}var getDistinctId=function(e){var t="";return e._sa&&e._sa.store&&(t=e._sa.store.getDistinctId()),t};function mixinTrack(e){e.trackTestTrigger=function(t){var r=!1,a=!0;if(t.is_white_list)return!1;var i=t.abtest_experiment_group_id,n=getDistinctId(e),s=t.abtest_experiment_id,o=e.store.getStorage("sensorsdata_abtest_trigger")||{};function c(){a=!1,o[n][s]=i,e.store.setStorage("sensorsdata_abtest_trigger",o)}if(o[n]&&(r=!0),o&&o[n]){var l=o[n];l[s]?l[s]!==i&&(delete l[s],c()):c()}else o[n]={},c();if(!a){var u={$abtest_experiment_id:s,$abtest_experiment_group_id:i};if(!r){var _=e.info.lib_plugin_name+":"+e.info.lib_version;u.$lib_plugin_version=[_]}e._sa.track("$ABTestTrigger",u)}}}var ABTest={};mixinConfig(ABTest),mixinFetch(ABTest),mixinTrack(ABTest),mixinRequest(ABTest),mixinStore(ABTest),ABTest.init=function(e,t){if(_.log("\u521d\u59cb\u5316 ABTest \u63d2\u4ef6"),this.state.inited)return!1;if(initAPI(ABTest),!this.setPara(t))return!1;this.state.inited=!0,this._sa=e,this.subId=new e.eventSub(this.handleIdChange);var r=ABTest.store.getStorage(this.info.storage_key);_.isObject(r)?this.state.test_list=r:this.state.test_list={},_.getSystemInfo(this),this.subId.isReady(),this.listenAppLaunch()},ABTest.handleIdChange=function(e){"changeDistinctId"===e&&(ABTest.state.test_list={},ABTest.state.trigger_list=[],ABTest.store.setStorage(ABTest.info.storage_key,ABTest.state.test_list),ABTest.fetchTest())},ABTest.listenAppLaunch=function(){var e=my.getLaunchOptionsSync();e&&e.scene&&(this.info.scene="ali-"+e.scene),this.fetchTest()},defineApi(ABTest,["asyncFetchABTest","fastFetchABTest","fetchCacheABTest"]);export default ABTest; \ No newline at end of file diff --git a/dist/wechat/plugin/abtesting-sdk-miniprogram/quickapp/abtest.esm.min.js b/dist/wechat/plugin/abtesting-sdk-miniprogram/quickapp/abtest.esm.min.js index ff643fe..7374193 100644 --- a/dist/wechat/plugin/abtesting-sdk-miniprogram/quickapp/abtest.esm.min.js +++ b/dist/wechat/plugin/abtesting-sdk-miniprogram/quickapp/abtest.esm.min.js @@ -1 +1 @@ -import device from"@system.device";import storage from"@system.storage";import fetch from"@system.fetch";var hasOwnProperty=Object.prototype.hasOwnProperty;function extend(e){return each(Array.prototype.slice.call(arguments,1),function(t){for(var r in t)void 0!==t[r]&&(e[r]=t[r])}),e}function each(e,t,r){var a=Array.prototype.forEach,i={};if(null==e)return!1;if(a&&e.forEach===a)e.forEach(t,r);else if(e.length===+e.length){for(var s=0,n=e.length;s0||(_.log(e+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0cparam_name\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e\uff01param_name:",t.param_name),a=!1);break;case"value_type":_.isString(t.value_type)&&-1!==_.indexOf(VALUE_TYPE_LIST,t.value_type)||(_.log(e+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0cvalue_type\u914d\u7f6e\u9519\u8bef",t.value_type),a=!1);break;case"default_value":void 0===t.default_value?(_.log(e+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0cdefault_value\u53c2\u6570\u672a\u914d\u7f6e"),a=!1):verifyStore.valueType(t.default_value,t.value_type)||(_.log(e+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0cdefault_value\u7c7b\u578b\u5fc5\u987b\u4e0evalue_type\u4e00\u81f4\uff01",t.default_value,t.value_type),a=!1);break;case"callback":_.isFunction(t.callback)||(_.log(e+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0ccallback\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e"),a=!1)}}),a},resolveCustomProperties:function(e){var t={verify_success:!0,para:null},r=e.custom_properties;if(!_.isObject(r)||_.isEmptyObject(r))return delete e.custom_properties,t.para=e,t;if(_.each(r,function(e,r){if((!_.isString(r)||!regName.test(r)||r.length>100)&&(_.log(" property name [ "+r+" ] is not invalid "),t.verify_success=!1),(_.isString(e)||_.isNumber(e)||_.isBoolean(e)||_.isArray(e)||_.isDate(e))&&!(_.isString(e)&&e.length>500)||(_.log("property [ "+r+" ] of value [ "+JSON.stringify(e)+" ] is not invalid"),t.verify_success=!1),_.isArray(e)){var a=!0;_.each(e,function(e){!1!==a&&(_.isString(e)||(a=!1))}),a||(_.log("property value type can be array, but only allow string item. property [ "+r+" ] of value "+JSON.stringify(e)+" is not invalid"),t.verify_success=!1)}}),!0===t.verify_success){var a={};_.each(r,function(e,t){_.isDate(e)?a[t]=_.formatDate(e):_.isString(e)?a[t]=e:a[t]=JSON.stringify(e)}),e.custom_properties=a}return t.para=e,t}};function defineApi(e,t){for(var r of t)e[r]="fetchCacheABTest"===r?function(e){if(_.log("\u8c03\u7528\u5206\u6d41 API --- A/B Testing \u63d2\u4ef6\u5c1a\u672a\u521d\u59cb\u5316\uff01"),Object.prototype.hasOwnProperty.call(e,"default_value"))return e.default_value}:function(e){_.log("\u8c03\u7528\u5206\u6d41 API --- A/B Testing \u63d2\u4ef6\u5c1a\u672a\u521d\u59cb\u5316\uff01"),e&&_.isFunction(e.callback)&&Object.prototype.hasOwnProperty.call(e,"default_value")&&e.callback(e.default_value)}}function initAPI(e){e.setPara=function(t){if(!_.isString(t.url)||"http"!==t.url.slice(0,4))return _.log("A/B Testing SDK \u521d\u59cb\u5316\u5931\u8d25\uff0c\u8bf7\u4f7f\u7528\u6b63\u786e\u7684 URL\uff01"),!1;e.para.url=t.url;var r=_.getQueryParam(t.url,"project-key");return r?(e.para.project_key=r,_.isNumber(t.timeout_milliseconds)&&(t.timeout_milliseconds<200?e.para.timeout_milliseconds=200:e.para.timeout_milliseconds=t.timeout_milliseconds),_.isNumber(t.update_interval)&&(e.para.update_interval=t.update_interval),!0):(_.log("A/B Testing SDK \u521d\u59cb\u5316\u5931\u8d25\uff0c\u8bf7\u4f7f\u7528\u6b63\u786e\u7684 URL\uff08\u5fc5\u987b\u5305\u542b project-key\uff09\uff01"),!1)},e.asyncFetchABTest=function(t){if(!_.isObject(t))return _.log("asyncFetchABTest\u8c03\u7528\u5931\u8d25\uff0c\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e"),!1;if(!verifyStore.para("asyncFetchABTest",t,["param_name","value_type","default_value","callback"]))return!1;var r=verifyStore.resolveCustomProperties(t);r.verify_success?(t=r.para,_.validTimeout(t),e.asyncFetch(t)):t.callback(t.default_value)},e.fastFetchABTest=function(t){if(!_.isObject(t))return _.log("fastFetchABTest \u8c03\u7528\u5931\u8d25\uff0c\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e"),!1;if(!verifyStore.para("fastFetchABTest",t,["param_name","value_type","default_value","callback"]))return!1;var r=verifyStore.resolveCustomProperties(t);if(r.verify_success){t=r.para,_.validTimeout(t);var a=e.searchLocalExp(t.param_name);if(_.isObject(a)){var i=e.getExpResult(t,a);t.callback(i)}else _.log("fastFetchABTest \u7f13\u5b58\u4e2d\u672a\u8bfb\u53d6\u5230\u6570\u636e\uff0c\u53d1\u8d77\u8bf7\u6c42"),e.asyncFetch(t)}else t.callback(t.default_value)},e.fetchCacheABTest=function(t){if(_.isObject(t))return!!verifyStore.para("fetchCacheABTest",t,["param_name","value_type","default_value"])&&e.getExpResult(t);_.log("fetchCacheABTest\u8c03\u7528\u5931\u8d25\uff0c\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e")},e.asyncFetch=function(t){e.getResultFromServer({para:t,suc:function(r){if(_.isObject(r)&&"SUCCESS"===r.status){_.log("\u83b7\u53d6\u5230\u670d\u52a1\u7aef\u8bd5\u9a8c\u7ed3\u679c\u6570\u636e: ",r),e.updateData(r);var a=e.getExpResult(t);t.callback(a)}else t.callback(t.default_value)},fail:function(e){_.log("\u83b7\u53d6\u670d\u52a1\u7aef\u6570\u636e\u5931\u8d25: ",e),t.callback(t.default_value)}})},e.searchLocalExp=function(t){return!!e.state.test_list[t]&&e.state.test_list[t]},e.getExpResult=function(t,r){var a=t.default_value,i=r||e.searchLocalExp(t.param_name);return _.isObject(i)?_.isObject(i.config)&&(i.config.type===t.value_type?(a=i.config.value,e.trackTestTrigger(i)):_.log("\u8bd5\u9a8c\u7ed3\u679c\u7c7b\u578b\u4e0e\u671f\u671b\u7c7b\u578b\u4e0d\u4e00\u81f4\uff0cparam_name\uff1a"+t.param_name+"\uff0c\u5f53\u524d\u8fd4\u56de\u7c7b\u578b\u4e3a\uff1a"+i.config.type+"\uff0c\u671f\u671b\u7c7b\u578b\u4e3a\uff1a"+t.value_type)):_.log("\u672c\u5730\u672a\u67e5\u8be2\u5230\u8bd5\u9a8c\u6570\u636e\uff0c\u8bd5\u9a8c\u53c2\u6570\u540d\u79f0\uff1a"+t.param_name),a},e.getResultFromServer=function(t){var r=(t=_.isObject(t)?t:{}).para||{},a=t.suc,i=t.fail,s=e.creatRequestData(r);e.request({url:e.para.url,method:"POST",data:JSON.stringify(s),contentType:"application/json",timeout:r.timeout_milliseconds||e.para.timeout_milliseconds,suc:a,fail:i}),_.log("\u5411\u670d\u52a1\u7aef\u53d1\u8d77\u8bd5\u9a8c\u8bf7\u6c42")}}var para={url:"",project_key:"",retry_times:3,timeout_milliseconds:3e3,update_interval:6e5},info={lib_version:"1.19.11",plugin_version:"1.19.11",platform:"QuickApp",storage_key:"sensorsdata2015_ABTest",lib_plugin_name:"quickapp_abtesting"},props={$manufacturer:"",$model:"",$brand:"",$os:"",$os_version:""},state={inited:!1,fetchInterval:null,test_list:{},trigger_list:[],store_inited:!1,fetch_queue:[]};function mixinConfig(e){e.para=para,e.info=info,e.state=state,e.props=props,e.plugin_name="ABTestingQuickApp"}var getDistinctId=function(e){var t="";return e._sa&&e._sa.store&&(t=e._sa.store.getDistinctId()),t};function mixinTrack(e){e.trackTestTrigger=function(t){var r=!1,a=!0;if(t.is_white_list)return!1;var i=t.abtest_experiment_group_id,s=getDistinctId(e),n=t.abtest_experiment_id,o=e.store.getStorage("sensorsdata_abtest_trigger")||{};function c(){a=!1,o[s][n]=i,e.store.setStorage("sensorsdata_abtest_trigger",o)}if(o[s]&&(r=!0),o&&o[s]){var u=o[s];u[n]?u[n]!==i&&(delete u[n],c()):c()}else o[s]={},c();if(!a){var l={$abtest_experiment_id:n,$abtest_experiment_group_id:i};if(!r){var _=e.info.lib_plugin_name+":"+e.info.lib_version;l.$lib_plugin_version=[_]}e._sa.track("$ABTestTrigger",l)}}}var request=function(e){var t=e.url,r="GET",a=null;e.method&&(r=e.method),e.data&&(a=e.data),fetch.fetch({data:a,responseType:"Object",method:r,url:t,success:function(t){var r={};if(t.data)try{r=JSON.parse(t.data)}catch(e){r={}}e.suc(r)},fail:e.fail})};function mixinRequest(e){e.request=request}var ABTest={};mixinConfig(ABTest),mixinFetch(ABTest),mixinTrack(ABTest),mixinRequest(ABTest),mixinStore(ABTest),ABTest.init=function(e,t){return _.isObject(t.app)?t.app.sensorsABTest=ABTest:_.log("\u8bf7\u4f20\u5165\u6b63\u786e\u7684 App \u5bf9\u8c61\uff01"),_.log("\u521d\u59cb\u5316 ABTest \u63d2\u4ef6"),!this.state.inited&&(initAPI(ABTest),!!this.setPara(t)&&(this.state.inited=!0,this._sa=e,this.subId=new e.eventSub(this.handleEvents),this.subId.isReady(),void getStorage(ABTest.info.storage_key,ABTest.getTestList)))},ABTest.handleEvents=function(e){if("changeDistinctId"===e&&(ABTest.state.test_list={},ABTest.state.trigger_list=[],setStorage(ABTest.info.storage_key,ABTest.state.test_list),ABTest.fetchTest()),"initStore"===e){if(ABTest.state.store_inited)return!1;ABTest.state.store_inited=!0,_.getSystemInfo(ABTest,ABTest.fetchTest),ABTest.state.fetch_queue.length>0&&_.each(ABTest.state.fetch_queue,function(e){ABTest[e.event].apply(ABTest,e.arg)})}},ABTest.getTestList=function(e){_.isObject(e)?ABTest.state.test_list=e:ABTest.state.test_list={}},_.each(["fetchTest","asyncFetch"],function(e){var t=ABTest[e];ABTest[e]=function(){ABTest.state.store_inited?t.apply(ABTest,arguments):ABTest.state.fetch_queue.push({event:e,arg:arguments})}}),defineApi(ABTest,["asyncFetchABTest","fastFetchABTest","fetchCacheABTest"]);export default ABTest; \ No newline at end of file +import device from"@system.device";import storage from"@system.storage";import fetch from"@system.fetch";var hasOwnProperty=Object.prototype.hasOwnProperty;function extend(e){return each(Array.prototype.slice.call(arguments,1),function(t){for(var r in t)void 0!==t[r]&&(e[r]=t[r])}),e}function each(e,t,r){var a=Array.prototype.forEach,i={};if(null==e)return!1;if(a&&e.forEach===a)e.forEach(t,r);else if(e.length===+e.length){for(var s=0,n=e.length;s0||(_.log(e+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0cparam_name\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e\uff01param_name:",t.param_name),a=!1);break;case"value_type":_.isString(t.value_type)&&-1!==_.indexOf(VALUE_TYPE_LIST,t.value_type)||(_.log(e+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0cvalue_type\u914d\u7f6e\u9519\u8bef",t.value_type),a=!1);break;case"default_value":void 0===t.default_value?(_.log(e+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0cdefault_value\u53c2\u6570\u672a\u914d\u7f6e"),a=!1):verifyStore.valueType(t.default_value,t.value_type)||(_.log(e+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0cdefault_value\u7c7b\u578b\u5fc5\u987b\u4e0evalue_type\u4e00\u81f4\uff01",t.default_value,t.value_type),a=!1);break;case"callback":_.isFunction(t.callback)||(_.log(e+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0ccallback\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e"),a=!1)}}),a},resolveCustomProperties:function(e){var t={verify_success:!0,para:null},r=e.custom_properties;if(!_.isObject(r)||_.isEmptyObject(r))return delete e.custom_properties,t.para=e,t;if(_.each(r,function(e,r){if((!_.isString(r)||!regName.test(r)||r.length>100)&&(_.log(" property name [ "+r+" ] is not invalid "),t.verify_success=!1),(_.isString(e)||_.isNumber(e)||_.isBoolean(e)||_.isArray(e)||_.isDate(e))&&!(_.isString(e)&&e.length>500)||(_.log("property [ "+r+" ] of value [ "+JSON.stringify(e)+" ] is not invalid"),t.verify_success=!1),_.isArray(e)){var a=!0;_.each(e,function(e){!1!==a&&(_.isString(e)||(a=!1))}),a||(_.log("property value type can be array, but only allow string item. property [ "+r+" ] of value "+JSON.stringify(e)+" is not invalid"),t.verify_success=!1)}}),!0===t.verify_success){var a={};_.each(r,function(e,t){_.isDate(e)?a[t]=_.formatDate(e):_.isString(e)?a[t]=e:a[t]=JSON.stringify(e)}),e.custom_properties=a}return t.para=e,t}};function defineApi(e,t){for(var r of t)e[r]="fetchCacheABTest"===r?function(e){if(_.log("\u8c03\u7528\u5206\u6d41 API --- A/B Testing \u63d2\u4ef6\u5c1a\u672a\u521d\u59cb\u5316\uff01"),Object.prototype.hasOwnProperty.call(e,"default_value"))return e.default_value}:function(e){_.log("\u8c03\u7528\u5206\u6d41 API --- A/B Testing \u63d2\u4ef6\u5c1a\u672a\u521d\u59cb\u5316\uff01"),e&&_.isFunction(e.callback)&&Object.prototype.hasOwnProperty.call(e,"default_value")&&e.callback(e.default_value)}}function initAPI(e){e.setPara=function(t){if(!_.isString(t.url)||"http"!==t.url.slice(0,4))return _.log("A/B Testing SDK \u521d\u59cb\u5316\u5931\u8d25\uff0c\u8bf7\u4f7f\u7528\u6b63\u786e\u7684 URL\uff01"),!1;e.para.url=t.url;var r=_.getQueryParam(t.url,"project-key");return r?(e.para.project_key=r,_.isNumber(t.timeout_milliseconds)&&(t.timeout_milliseconds<200?e.para.timeout_milliseconds=200:e.para.timeout_milliseconds=t.timeout_milliseconds),_.isNumber(t.update_interval)&&(e.para.update_interval=t.update_interval),!0):(_.log("A/B Testing SDK \u521d\u59cb\u5316\u5931\u8d25\uff0c\u8bf7\u4f7f\u7528\u6b63\u786e\u7684 URL\uff08\u5fc5\u987b\u5305\u542b project-key\uff09\uff01"),!1)},e.asyncFetchABTest=function(t){if(!_.isObject(t))return _.log("asyncFetchABTest\u8c03\u7528\u5931\u8d25\uff0c\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e"),!1;if(!verifyStore.para("asyncFetchABTest",t,["param_name","value_type","default_value","callback"]))return!1;var r=verifyStore.resolveCustomProperties(t);r.verify_success?(t=r.para,_.validTimeout(t),e.asyncFetch(t)):t.callback(t.default_value)},e.fastFetchABTest=function(t){if(!_.isObject(t))return _.log("fastFetchABTest \u8c03\u7528\u5931\u8d25\uff0c\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e"),!1;if(!verifyStore.para("fastFetchABTest",t,["param_name","value_type","default_value","callback"]))return!1;var r=verifyStore.resolveCustomProperties(t);if(r.verify_success){t=r.para,_.validTimeout(t);var a=e.searchLocalExp(t.param_name);if(_.isObject(a)){var i=e.getExpResult(t,a);t.callback(i)}else _.log("fastFetchABTest \u7f13\u5b58\u4e2d\u672a\u8bfb\u53d6\u5230\u6570\u636e\uff0c\u53d1\u8d77\u8bf7\u6c42"),e.asyncFetch(t)}else t.callback(t.default_value)},e.fetchCacheABTest=function(t){if(_.isObject(t))return!!verifyStore.para("fetchCacheABTest",t,["param_name","value_type","default_value"])&&e.getExpResult(t);_.log("fetchCacheABTest\u8c03\u7528\u5931\u8d25\uff0c\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e")},e.asyncFetch=function(t){e.getResultFromServer({para:t,suc:function(r){if(_.isObject(r)&&"SUCCESS"===r.status){_.log("\u83b7\u53d6\u5230\u670d\u52a1\u7aef\u8bd5\u9a8c\u7ed3\u679c\u6570\u636e: ",r),e.updateData(r);var a=e.getExpResult(t);t.callback(a)}else t.callback(t.default_value)},fail:function(e){_.log("\u83b7\u53d6\u670d\u52a1\u7aef\u6570\u636e\u5931\u8d25: ",e),t.callback(t.default_value)}})},e.searchLocalExp=function(t){return!!e.state.test_list[t]&&e.state.test_list[t]},e.getExpResult=function(t,r){var a=t.default_value,i=r||e.searchLocalExp(t.param_name);return _.isObject(i)?_.isObject(i.config)&&(i.config.type===t.value_type?(a=i.config.value,e.trackTestTrigger(i)):_.log("\u8bd5\u9a8c\u7ed3\u679c\u7c7b\u578b\u4e0e\u671f\u671b\u7c7b\u578b\u4e0d\u4e00\u81f4\uff0cparam_name\uff1a"+t.param_name+"\uff0c\u5f53\u524d\u8fd4\u56de\u7c7b\u578b\u4e3a\uff1a"+i.config.type+"\uff0c\u671f\u671b\u7c7b\u578b\u4e3a\uff1a"+t.value_type)):_.log("\u672c\u5730\u672a\u67e5\u8be2\u5230\u8bd5\u9a8c\u6570\u636e\uff0c\u8bd5\u9a8c\u53c2\u6570\u540d\u79f0\uff1a"+t.param_name),a},e.getResultFromServer=function(t){var r=(t=_.isObject(t)?t:{}).para||{},a=t.suc,i=t.fail,s=e.creatRequestData(r);e.request({url:e.para.url,method:"POST",data:JSON.stringify(s),contentType:"application/json",timeout:r.timeout_milliseconds||e.para.timeout_milliseconds,suc:a,fail:i}),_.log("\u5411\u670d\u52a1\u7aef\u53d1\u8d77\u8bd5\u9a8c\u8bf7\u6c42")}}var para={url:"",project_key:"",retry_times:3,timeout_milliseconds:3e3,update_interval:6e5},info={lib_version:"1.19.12",plugin_version:"1.19.12",platform:"QuickApp",storage_key:"sensorsdata2015_ABTest",lib_plugin_name:"quickapp_abtesting"},props={$manufacturer:"",$model:"",$brand:"",$os:"",$os_version:""},state={inited:!1,fetchInterval:null,test_list:{},trigger_list:[],store_inited:!1,fetch_queue:[]};function mixinConfig(e){e.para=para,e.info=info,e.state=state,e.props=props,e.plugin_name="ABTestingQuickApp"}var getDistinctId=function(e){var t="";return e._sa&&e._sa.store&&(t=e._sa.store.getDistinctId()),t};function mixinTrack(e){e.trackTestTrigger=function(t){var r=!1,a=!0;if(t.is_white_list)return!1;var i=t.abtest_experiment_group_id,s=getDistinctId(e),n=t.abtest_experiment_id,o=e.store.getStorage("sensorsdata_abtest_trigger")||{};function c(){a=!1,o[s][n]=i,e.store.setStorage("sensorsdata_abtest_trigger",o)}if(o[s]&&(r=!0),o&&o[s]){var u=o[s];u[n]?u[n]!==i&&(delete u[n],c()):c()}else o[s]={},c();if(!a){var l={$abtest_experiment_id:n,$abtest_experiment_group_id:i};if(!r){var _=e.info.lib_plugin_name+":"+e.info.lib_version;l.$lib_plugin_version=[_]}e._sa.track("$ABTestTrigger",l)}}}var request=function(e){var t=e.url,r="GET",a=null;e.method&&(r=e.method),e.data&&(a=e.data),fetch.fetch({data:a,responseType:"Object",method:r,url:t,success:function(t){var r={};if(t.data)try{r=JSON.parse(t.data)}catch(e){r={}}e.suc(r)},fail:e.fail})};function mixinRequest(e){e.request=request}var ABTest={};mixinConfig(ABTest),mixinFetch(ABTest),mixinTrack(ABTest),mixinRequest(ABTest),mixinStore(ABTest),ABTest.init=function(e,t){return _.isObject(t.app)?t.app.sensorsABTest=ABTest:_.log("\u8bf7\u4f20\u5165\u6b63\u786e\u7684 App \u5bf9\u8c61\uff01"),_.log("\u521d\u59cb\u5316 ABTest \u63d2\u4ef6"),!this.state.inited&&(initAPI(ABTest),!!this.setPara(t)&&(this.state.inited=!0,this._sa=e,this.subId=new e.eventSub(this.handleEvents),this.subId.isReady(),void getStorage(ABTest.info.storage_key,ABTest.getTestList)))},ABTest.handleEvents=function(e){if("changeDistinctId"===e&&(ABTest.state.test_list={},ABTest.state.trigger_list=[],setStorage(ABTest.info.storage_key,ABTest.state.test_list),ABTest.fetchTest()),"initStore"===e){if(ABTest.state.store_inited)return!1;ABTest.state.store_inited=!0,_.getSystemInfo(ABTest,ABTest.fetchTest),ABTest.state.fetch_queue.length>0&&_.each(ABTest.state.fetch_queue,function(e){ABTest[e.event].apply(ABTest,e.arg)})}},ABTest.getTestList=function(e){_.isObject(e)?ABTest.state.test_list=e:ABTest.state.test_list={}},_.each(["fetchTest","asyncFetch"],function(e){var t=ABTest[e];ABTest[e]=function(){ABTest.state.store_inited?t.apply(ABTest,arguments):ABTest.state.fetch_queue.push({event:e,arg:arguments})}}),defineApi(ABTest,["asyncFetchABTest","fastFetchABTest","fetchCacheABTest"]);export default ABTest; \ No newline at end of file diff --git a/dist/wechat/plugin/abtesting-sdk-miniprogram/wechat/abtest.cmd.min.js b/dist/wechat/plugin/abtesting-sdk-miniprogram/wechat/abtest.cmd.min.js index 2160679..e4068ed 100644 --- a/dist/wechat/plugin/abtesting-sdk-miniprogram/wechat/abtest.cmd.min.js +++ b/dist/wechat/plugin/abtesting-sdk-miniprogram/wechat/abtest.cmd.min.js @@ -1 +1 @@ -"use strict";var hasOwnProperty=Object.prototype.hasOwnProperty;function extend(t){return each(Array.prototype.slice.call(arguments,1),function(e){for(var r in e)void 0!==e[r]&&(t[r]=e[r])}),t}function each(t,e,r){var a=Array.prototype.forEach,i={};if(null==t)return!1;if(a&&t.forEach===a)t.forEach(e,r);else if(t.length===+t.length){for(var s=0,n=t.length;s-1?e.system.split(" ")[1]:e.system}catch(t){log("get system fails")}}function getAppId(){var t;if(wx.getAccountInfoSync&&(t=wx.getAccountInfoSync()),isObject(t)&&isObject(t.miniProgram))return t.miniProgram.appId}_.getSystemInfo=getSystemInfo,_.getAppId=getAppId;var para={url:"",project_key:"",retry_times:3,timeout_milliseconds:3e3,update_interval:6e5},info={scene:"",lib_version:"1.19.11",platform:"MiniProgram",storage_key:"sensorsdata2015_ABTest",storage_out_list_key:"sensorsdata_abtest_out_list",storage_triggered_map_key:"sensorsdata_abtest_triggered_map",storage_out_triggered_map_key:"sensorsdata_abtest_out_triggered_map",storage_track_config_key:"sensorsdata_abtest_track_config",lib_plugin_name:"miniprogram_abtesting",platform_obj:wx,track_config:{},default_track_config:{trigger_switch:!0,property_set_switch:!1,trigger_content_ext:["abtest_experiment_version","abtest_experiment_result_id"]}},props={$manufacturer:"",$model:"",$os:"",$os_version:""},state={inited:!1,fetchInterval:null,test_list:{},out_triggered_map:{},triggered_map:{},out_list:[]};function mixinConfig(t){t.para=para,t.info=info,t.state=state,t.props=props,t.plugin_name="ABTestingWechat",t.plugin_version="1.19.11"}function mixinStore(t){var e=t.info.platform_obj;if(!e||isEmptyObject(e))return!1;t.store={getStorage:function(t){var r="";try{a=r=e.getStorageSync(t),r=isString(a)?(-1!==a.indexOf("data:enc;")&&(a=rot13defs(a=a.substring("data:enc;".length))),a):a}catch(t){log("\u83b7\u53d6 storage \u5931\u8d25\uff01")}var a;return isJSONString(r)&&(r=JSON.parse(r)),r},setStorage:function(r,a){var i;try{s=i=JSON.stringify(a),n=!1,t&&t._sa&&t._sa.para&&(n=t._sa.para.encrypt_storage),n&&(isObject(s)&&(s=JSON.stringify(s)),s="data:enc;"+rot13obfs(s)),i=s}catch(t){log("\u5e8f\u5217\u5316\u7f13\u5b58\u5bf9\u8c61\u5931\u8d25\uff01")}var s,n;try{e.setStorageSync(r,i)}catch(t){log("set Storage fail again --",t)}}}}function mixinRequest(t){var e,r=t.info.platform_obj;isObject(r)&&(e=function(t){var e=t.url,a="GET",i=null;t.method&&(a=t.method),t.data&&(i=t.data),r.request({url:e,method:a,data:i,timeout:t.timeout,success:function(e){t.suc(e.data)},fail:function(e){t.fail(e)}})}),t.request=e}function mixinFetch(t){t.fetchTest=function(){var e=0,r=!1,a=t.creatRequestData();function i(e){_.log("\u8bf7\u6c42\u6570\u636e\u7ed3\u679c\u6210\u529f: ",e),r=!0,t.updateData(e),t.state.fetchInterval&&clearTimeout(t.state.fetchInterval),t.state.fetchInterval=setTimeout(function(){t.request({url:t.para.url,method:"POST",data:JSON.stringify(a),timeout:t.para.timeout_milliseconds,suc:i,fail:s})},t.para.update_interval)}function s(n){return _.log("\u8bf7\u6c42\u6570\u636e\u7ed3\u679c\u5931\u8d25: ",n),e++,!r&&e0&&t._sa.registerApp({abtest_result:i}),s.length>0&&t._sa.registerApp({abtest_dispatch_result:s})}else t._sa.clearAppRegister(["abtest_result","abtest_dispatch_result"])},t.saveData=function(){t.store.setStorage(t.info.storage_key,t.state.test_list),t.store.setStorage(t.info.storage_out_list_key,t.state.out_list),t.store.setStorage(t.info.storage_track_config_key,t.info.track_config)},t.updateData=function(e){t.resolveData(e),t.saveData(),_.log("\u66f4\u65b0\u8bd5\u9a8c\u6570\u636e"),t.registerProperty()},t.resolveData=function(e){if(!_.isObject(e)||!_.isArray(e.results))return _.log("\u89e3\u6790——\u6570\u636e\u683c\u5f0f\u9519\u8bef",e),!1;var r=e.results;t.state.test_list={},_.isArray(r)&&_.each(r,function(e){_.isObject(e)&&e.variables&&_.isArray(e.variables)&&_.each(e.variables,function(r){_.isObject(r)&&!t.state.test_list[r.name]&&(t.state.test_list[r.name]=_.extend({},e),t.state.test_list[r.name].config=_.getRelativeValue(r.value,r.type))})}),t.state.out_list=_.isArray(e.out_list)?e.out_list:[],t.info.track_config=_.isObject(e.track_config)?e.track_config:t.info.default_track_config}}var VALUE_TYPE_LIST=["Number","String","Object","Boolean"],regName=/^((?!^distinct_id$|^original_id$|^time$|^properties$|^id$|^first_id$|^second_id$|^users$|^events$|^event$|^user_id$|^date$|^datetime$|^user_tag.*|^user_group.*)[a-zA-Z_][a-zA-Z\d_]*)$/i,verifyStore={valueType:function(t,e){switch(e){case"Number":if(_.isNumber(t))return!0;break;case"String":if(_.isString(t))return!0;break;case"Object":if(_.isObject(t))return!0;break;case"Boolean":if(!0===t||!1===t)return!0;break;default:return!1}return!1},para:function(t,e,r){var a=!0;return _.each(r,function(r){switch(r){case"param_name":e.param_name&&_.isString(e.param_name)&&e.param_name.length>0||(_.log(t+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0cparam_name\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e\uff01param_name:",e.param_name),a=!1);break;case"value_type":_.isString(e.value_type)&&-1!==_.indexOf(VALUE_TYPE_LIST,e.value_type)||(_.log(t+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0cvalue_type\u914d\u7f6e\u9519\u8bef",e.value_type),a=!1);break;case"default_value":void 0===e.default_value?(_.log(t+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0cdefault_value\u53c2\u6570\u672a\u914d\u7f6e"),a=!1):verifyStore.valueType(e.default_value,e.value_type)||(_.log(t+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0cdefault_value\u7c7b\u578b\u5fc5\u987b\u4e0evalue_type\u4e00\u81f4\uff01",e.default_value,e.value_type),a=!1);break;case"callback":_.isFunction(e.callback)||(_.log(t+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0ccallback\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e"),a=!1)}}),a},resolveCustomProperties:function(t){var e={verify_success:!0,para:null},r=t.custom_properties;if(!_.isObject(r)||_.isEmptyObject(r))return delete t.custom_properties,e.para=t,e;if(_.each(r,function(t,r){if((!_.isString(r)||!regName.test(r)||r.length>100)&&(_.log(" property name [ "+r+" ] is not invalid "),e.verify_success=!1),(_.isString(t)||_.isNumber(t)||_.isBoolean(t)||_.isArray(t)||_.isDate(t))&&!(_.isString(t)&&t.length>500)||(_.log("property [ "+r+" ] of value [ "+JSON.stringify(t)+" ] is not invalid"),e.verify_success=!1),_.isArray(t)){var a=!0;_.each(t,function(t){!1!==a&&(_.isString(t)||(a=!1))}),a||(_.log("property value type can be array, but only allow string item. property [ "+r+" ] of value "+JSON.stringify(t)+" is not invalid"),e.verify_success=!1)}}),!0===e.verify_success){var a={};_.each(r,function(t,e){_.isDate(t)?a[e]=_.formatDate(t):_.isString(t)?a[e]=t:a[e]=JSON.stringify(t)}),t.custom_properties=a}return e.para=t,e}};function defineApi(t,e){for(var r of e)t[r]="fetchCacheABTest"===r?function(t){if(_.log("\u8c03\u7528\u5206\u6d41 API --- A/B Testing \u63d2\u4ef6\u5c1a\u672a\u521d\u59cb\u5316\uff01"),Object.prototype.hasOwnProperty.call(t,"default_value"))return t.default_value}:function(t){_.log("\u8c03\u7528\u5206\u6d41 API --- A/B Testing \u63d2\u4ef6\u5c1a\u672a\u521d\u59cb\u5316\uff01"),t&&_.isFunction(t.callback)&&Object.prototype.hasOwnProperty.call(t,"default_value")&&t.callback(t.default_value)}}function initAPI(t){t.setPara=function(e){if(!_.isString(e.url)||"http"!==e.url.slice(0,4))return _.log("A/B Testing SDK \u521d\u59cb\u5316\u5931\u8d25\uff0c\u8bf7\u4f7f\u7528\u6b63\u786e\u7684 URL\uff01"),!1;t.para.url=e.url;var r=_.getQueryParam(e.url,"project-key");return r?(t.para.project_key=r,_.isNumber(e.timeout_milliseconds)&&(e.timeout_milliseconds<200?t.para.timeout_milliseconds=200:t.para.timeout_milliseconds=e.timeout_milliseconds),_.isNumber(e.update_interval)&&(t.para.update_interval=e.update_interval),!0):(_.log("A/B Testing SDK \u521d\u59cb\u5316\u5931\u8d25\uff0c\u8bf7\u4f7f\u7528\u6b63\u786e\u7684 URL\uff08\u5fc5\u987b\u5305\u542b project-key\uff09\uff01"),!1)},t.asyncFetchABTest=function(e){if(!_.isObject(e))return _.log("asyncFetchABTest\u8c03\u7528\u5931\u8d25\uff0c\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e"),!1;if(!verifyStore.para("asyncFetchABTest",e,["param_name","value_type","default_value","callback"]))return!1;var r=verifyStore.resolveCustomProperties(e);r.verify_success?(e=r.para,_.validTimeout(e),t.asyncFetch(e)):e.callback(e.default_value)},t.fastFetchABTest=function(e){if(!_.isObject(e))return _.log("fastFetchABTest \u8c03\u7528\u5931\u8d25\uff0c\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e"),!1;if(!verifyStore.para("fastFetchABTest",e,["param_name","value_type","default_value","callback"]))return!1;var r=verifyStore.resolveCustomProperties(e);if(r.verify_success){e=r.para,_.validTimeout(e);var a=t.searchLocalExp(e.param_name);if(_.isObject(a)){var i=t.getExpResult(e,a);e.callback(i)}else _.log("fastFetchABTest \u7f13\u5b58\u4e2d\u672a\u8bfb\u53d6\u5230\u6570\u636e\uff0c\u53d1\u8d77\u8bf7\u6c42"),t.asyncFetch(e)}else e.callback(e.default_value)},t.fetchCacheABTest=function(e){if(_.isObject(e))return!!verifyStore.para("fetchCacheABTest",e,["param_name","value_type","default_value"])&&t.getExpResult(e);_.log("fetchCacheABTest\u8c03\u7528\u5931\u8d25\uff0c\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e")},t.asyncFetch=function(e){t.getResultFromServer({para:e,suc:function(r){if(_.isObject(r)&&"SUCCESS"===r.status){_.log("\u83b7\u53d6\u5230\u670d\u52a1\u7aef\u8bd5\u9a8c\u7ed3\u679c\u6570\u636e: ",r),t.updateData(r);var a=t.getExpResult(e);e.callback(a)}else e.callback(e.default_value)},fail:function(t){_.log("\u83b7\u53d6\u670d\u52a1\u7aef\u6570\u636e\u5931\u8d25: ",t),e.callback(e.default_value)}})},t.searchLocalExp=function(e){return!!t.state.test_list[e]&&t.state.test_list[e]},t.getExpResult=function(e,r){var a=e.default_value,i=r||t.searchLocalExp(e.param_name);return _.isObject(i)?_.isObject(i.config)&&(i.config.type===e.value_type?(a=i.config.value,t.trackTestTrigger(i)):_.log("\u8bd5\u9a8c\u7ed3\u679c\u7c7b\u578b\u4e0e\u671f\u671b\u7c7b\u578b\u4e0d\u4e00\u81f4\uff0cparam_name\uff1a"+e.param_name+"\uff0c\u5f53\u524d\u8fd4\u56de\u7c7b\u578b\u4e3a\uff1a"+i.config.type+"\uff0c\u671f\u671b\u7c7b\u578b\u4e3a\uff1a"+e.value_type)):_.log("\u672c\u5730\u672a\u67e5\u8be2\u5230\u8bd5\u9a8c\u6570\u636e\uff0c\u8bd5\u9a8c\u53c2\u6570\u540d\u79f0\uff1a"+e.param_name),a},t.getResultFromServer=function(e){var r=(e=_.isObject(e)?e:{}).para||{},a=e.suc,i=e.fail,s=t.creatRequestData(r);t.request({url:t.para.url,method:"POST",data:JSON.stringify(s),contentType:"application/json",timeout:r.timeout_milliseconds||t.para.timeout_milliseconds,suc:a,fail:i}),_.log("\u5411\u670d\u52a1\u7aef\u53d1\u8d77\u8bd5\u9a8c\u8bf7\u6c42")}}function mixinAPI(t){initAPI(t);var e=t.getExpResult;t.getExpResult=function(r,a){var i=e(r,a);return t.trackOutTestTrigger(r),i}}function formatTriggerStorage(t){var e=t.state.triggered_map;if(!_.isEmptyObject(e)){var r={},a=!1;_.each(e,function(t,e){_.isArray(t)?r[e]=t:(a=!0,r[e]=[],_.isObject(t)&&_.each(t,function(t,a){r[e].push({abtest_experiment_id:a,group_id:t})}))}),a&&(t.state.triggered_map=r,t.store.setStorage(t.info.storage_triggered_map_key,r))}}function mixinTrack(t){function e(e,r){var a=function(e){var r=t._sa.store.getDistinctId();return e.subject_id&&e.subject_name&&(r=e.subject_name+e.subject_id),r}(r),i=t.info.track_config.trigger_switch,s=!0,n=t.state[e];n&&_.isObject(n)&&n[a]&&_.each(n[a],function(t){t.experiment_id===r.abtest_experiment_id&&t.group_id===r.abtest_experiment_group_id&&t.result_id===r.abtest_experiment_result_id&&(s=!1)}),t.state[e][a]=function(t,e){var r=[],a=e.abtest_experiment_id;if(_.isString(a)){var i={experiment_id:a,group_id:e.abtest_experiment_group_id,result_id:e.abtest_experiment_result_id};if(t&&_.isArray(t)){var s=!1;_.each(t,function(e,r){e.experiment_id===a&&(t.splice(r,1,i),s=!0)}),s||t.push(i)}else t=[i];r=t}return r}(n[a],r),t.store.setStorage(t.info.storage_triggered_map_key,t.state.triggered_map),t.store.setStorage(t.info.storage_out_triggered_map_key,t.state.out_triggered_map),t.registerProperty(a);var o=function(e){var r={},a=t.state.triggered_map;if("{}"!==JSON.stringify(a)){var i=t.info.lib_plugin_name+":"+t.info.lib_version;r.$lib_plugin_version=[i]}var s={$abtest_experiment_id:e.abtest_experiment_id,$abtest_experiment_group_id:e.abtest_experiment_group_id},n=t.info.track_config.trigger_content_ext;return _.each(n,function(t){void 0!==e[t]&&(r["$"+t]=e[t])}),r=_.extend(s,r)}(r);return s&&i&&t._sa.track("$ABTestTrigger",o),s}t.trackTestTrigger=function(r){if(r.is_white_list)return!1;formatTriggerStorage(t),e("triggered_map",r)},t.trackOutTestTrigger=function(r){var a=t.state.out_list,i=!1,s={};_.isArray(a)&&a.length>0&&(_.each(a,function(t){_.isObject(t)&&!i&&_.isObject(t)&&t.variables&&_.isArray(t.variables)&&_.each(t.variables,function(e){var a=_.getRelativeValue(e.value,e.type);!i&&a&&_.isObject(e)&&r.param_name===e.name&&a.type===r.value_type&&(i=!0,s=t)})}),i&&e("out_triggered_map",s))}}var ABTest={};mixinConfig(ABTest),mixinFetch$1(ABTest),mixinTrack(ABTest),mixinRequest(ABTest),mixinStore(ABTest),ABTest.init=function(t,e){if(_.log("\u521d\u59cb\u5316 ABTest \u63d2\u4ef6"),this.state.inited)return!1;if(mixinAPI(ABTest),!this.setPara(e))return!1;var r,a,i,s,n;this.state.inited=!0,this._sa=t,this.subId=new t.eventSub(this.handleIdChange),r=ABTest.store.getStorage(ABTest.info.storage_key),a=ABTest.store.getStorage(ABTest.info.storage_out_list_key),i=ABTest.store.getStorage(ABTest.info.storage_triggered_map_key),s=ABTest.store.getStorage(ABTest.info.storage_out_triggered_map_key),n=ABTest.store.getStorage(ABTest.info.storage_track_config_key),ABTest.state.test_list=_.isObject(r)?r:{},ABTest.state.out_list=_.isArray(a)?a:[],ABTest.state.triggered_map=_.isObject(i)?i:{},ABTest.state.out_triggered_map=_.isObject(s)?s:{},ABTest.info.track_config=_.isObject(n)?n:ABTest.info.default_track_config,ABTest.registerProperty(),_.getSystemInfo(this),this.subId.isReady(),this.listenAppLaunch()},ABTest.handleIdChange=function(t){"changeDistinctId"===t&&(ABTest.state.test_list={},ABTest.state.out_list=[],ABTest.info.track_config=ABTest.info.default_track_config,ABTest.saveData(),ABTest.fetchTest())},ABTest.listenAppLaunch=function(){var t=wx.getLaunchOptionsSync();t&&t.scene&&(this.info.scene="wx-"+t.scene),this.fetchTest()},defineApi(ABTest,["asyncFetchABTest","fastFetchABTest","fetchCacheABTest"]),module.exports=ABTest; \ No newline at end of file +"use strict";var hasOwnProperty=Object.prototype.hasOwnProperty;function extend(t){return each(Array.prototype.slice.call(arguments,1),function(e){for(var r in e)void 0!==e[r]&&(t[r]=e[r])}),t}function each(t,e,r){var a=Array.prototype.forEach,i={};if(null==t)return!1;if(a&&t.forEach===a)t.forEach(e,r);else if(t.length===+t.length){for(var s=0,n=t.length;s-1?e.system.split(" ")[1]:e.system}catch(t){log("get system fails")}}function getAppId(){var t;if(wx.getAccountInfoSync&&(t=wx.getAccountInfoSync()),isObject(t)&&isObject(t.miniProgram))return t.miniProgram.appId}_.getSystemInfo=getSystemInfo,_.getAppId=getAppId;var para={url:"",project_key:"",retry_times:3,timeout_milliseconds:3e3,update_interval:6e5},info={scene:"",lib_version:"1.19.12",platform:"MiniProgram",storage_key:"sensorsdata2015_ABTest",storage_out_list_key:"sensorsdata_abtest_out_list",storage_triggered_map_key:"sensorsdata_abtest_triggered_map",storage_out_triggered_map_key:"sensorsdata_abtest_out_triggered_map",storage_track_config_key:"sensorsdata_abtest_track_config",lib_plugin_name:"miniprogram_abtesting",platform_obj:wx,track_config:{},default_track_config:{trigger_switch:!0,property_set_switch:!1,trigger_content_ext:["abtest_experiment_version","abtest_experiment_result_id"]}},props={$manufacturer:"",$model:"",$os:"",$os_version:""},state={inited:!1,fetchInterval:null,test_list:{},out_triggered_map:{},triggered_map:{},out_list:[]};function mixinConfig(t){t.para=para,t.info=info,t.state=state,t.props=props,t.plugin_name="ABTestingWechat",t.plugin_version="1.19.12"}function mixinStore(t){var e=t.info.platform_obj;if(!e||isEmptyObject(e))return!1;t.store={getStorage:function(t){var r="";try{a=r=e.getStorageSync(t),r=isString(a)?(-1!==a.indexOf("data:enc;")&&(a=rot13defs(a=a.substring("data:enc;".length))),a):a}catch(t){log("\u83b7\u53d6 storage \u5931\u8d25\uff01")}var a;return isJSONString(r)&&(r=JSON.parse(r)),r},setStorage:function(r,a){var i;try{s=i=JSON.stringify(a),n=!1,t&&t._sa&&t._sa.para&&(n=t._sa.para.encrypt_storage),n&&(isObject(s)&&(s=JSON.stringify(s)),s="data:enc;"+rot13obfs(s)),i=s}catch(t){log("\u5e8f\u5217\u5316\u7f13\u5b58\u5bf9\u8c61\u5931\u8d25\uff01")}var s,n;try{e.setStorageSync(r,i)}catch(t){log("set Storage fail again --",t)}}}}function mixinRequest(t){var e,r=t.info.platform_obj;isObject(r)&&(e=function(t){var e=t.url,a="GET",i=null;t.method&&(a=t.method),t.data&&(i=t.data),r.request({url:e,method:a,data:i,timeout:t.timeout,success:function(e){t.suc(e.data)},fail:function(e){t.fail(e)}})}),t.request=e}function mixinFetch(t){t.fetchTest=function(){var e=0,r=!1,a=t.creatRequestData();function i(e){_.log("\u8bf7\u6c42\u6570\u636e\u7ed3\u679c\u6210\u529f: ",e),r=!0,t.updateData(e),t.state.fetchInterval&&clearTimeout(t.state.fetchInterval),t.state.fetchInterval=setTimeout(function(){t.request({url:t.para.url,method:"POST",data:JSON.stringify(a),timeout:t.para.timeout_milliseconds,suc:i,fail:s})},t.para.update_interval)}function s(n){return _.log("\u8bf7\u6c42\u6570\u636e\u7ed3\u679c\u5931\u8d25: ",n),e++,!r&&e0&&t._sa.registerApp({abtest_result:i}),s.length>0&&t._sa.registerApp({abtest_dispatch_result:s})}else t._sa.clearAppRegister(["abtest_result","abtest_dispatch_result"])},t.saveData=function(){t.store.setStorage(t.info.storage_key,t.state.test_list),t.store.setStorage(t.info.storage_out_list_key,t.state.out_list),t.store.setStorage(t.info.storage_track_config_key,t.info.track_config)},t.updateData=function(e){t.resolveData(e),t.saveData(),_.log("\u66f4\u65b0\u8bd5\u9a8c\u6570\u636e"),t.registerProperty()},t.resolveData=function(e){if(!_.isObject(e)||!_.isArray(e.results))return _.log("\u89e3\u6790——\u6570\u636e\u683c\u5f0f\u9519\u8bef",e),!1;var r=e.results;t.state.test_list={},_.isArray(r)&&_.each(r,function(e){_.isObject(e)&&e.variables&&_.isArray(e.variables)&&_.each(e.variables,function(r){_.isObject(r)&&!t.state.test_list[r.name]&&(t.state.test_list[r.name]=_.extend({},e),t.state.test_list[r.name].config=_.getRelativeValue(r.value,r.type))})}),t.state.out_list=_.isArray(e.out_list)?e.out_list:[],t.info.track_config=_.isObject(e.track_config)?e.track_config:t.info.default_track_config}}var VALUE_TYPE_LIST=["Number","String","Object","Boolean"],regName=/^((?!^distinct_id$|^original_id$|^time$|^properties$|^id$|^first_id$|^second_id$|^users$|^events$|^event$|^user_id$|^date$|^datetime$|^user_tag.*|^user_group.*)[a-zA-Z_][a-zA-Z\d_]*)$/i,verifyStore={valueType:function(t,e){switch(e){case"Number":if(_.isNumber(t))return!0;break;case"String":if(_.isString(t))return!0;break;case"Object":if(_.isObject(t))return!0;break;case"Boolean":if(!0===t||!1===t)return!0;break;default:return!1}return!1},para:function(t,e,r){var a=!0;return _.each(r,function(r){switch(r){case"param_name":e.param_name&&_.isString(e.param_name)&&e.param_name.length>0||(_.log(t+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0cparam_name\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e\uff01param_name:",e.param_name),a=!1);break;case"value_type":_.isString(e.value_type)&&-1!==_.indexOf(VALUE_TYPE_LIST,e.value_type)||(_.log(t+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0cvalue_type\u914d\u7f6e\u9519\u8bef",e.value_type),a=!1);break;case"default_value":void 0===e.default_value?(_.log(t+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0cdefault_value\u53c2\u6570\u672a\u914d\u7f6e"),a=!1):verifyStore.valueType(e.default_value,e.value_type)||(_.log(t+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0cdefault_value\u7c7b\u578b\u5fc5\u987b\u4e0evalue_type\u4e00\u81f4\uff01",e.default_value,e.value_type),a=!1);break;case"callback":_.isFunction(e.callback)||(_.log(t+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0ccallback\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e"),a=!1)}}),a},resolveCustomProperties:function(t){var e={verify_success:!0,para:null},r=t.custom_properties;if(!_.isObject(r)||_.isEmptyObject(r))return delete t.custom_properties,e.para=t,e;if(_.each(r,function(t,r){if((!_.isString(r)||!regName.test(r)||r.length>100)&&(_.log(" property name [ "+r+" ] is not invalid "),e.verify_success=!1),(_.isString(t)||_.isNumber(t)||_.isBoolean(t)||_.isArray(t)||_.isDate(t))&&!(_.isString(t)&&t.length>500)||(_.log("property [ "+r+" ] of value [ "+JSON.stringify(t)+" ] is not invalid"),e.verify_success=!1),_.isArray(t)){var a=!0;_.each(t,function(t){!1!==a&&(_.isString(t)||(a=!1))}),a||(_.log("property value type can be array, but only allow string item. property [ "+r+" ] of value "+JSON.stringify(t)+" is not invalid"),e.verify_success=!1)}}),!0===e.verify_success){var a={};_.each(r,function(t,e){_.isDate(t)?a[e]=_.formatDate(t):_.isString(t)?a[e]=t:a[e]=JSON.stringify(t)}),t.custom_properties=a}return e.para=t,e}};function defineApi(t,e){for(var r of e)t[r]="fetchCacheABTest"===r?function(t){if(_.log("\u8c03\u7528\u5206\u6d41 API --- A/B Testing \u63d2\u4ef6\u5c1a\u672a\u521d\u59cb\u5316\uff01"),Object.prototype.hasOwnProperty.call(t,"default_value"))return t.default_value}:function(t){_.log("\u8c03\u7528\u5206\u6d41 API --- A/B Testing \u63d2\u4ef6\u5c1a\u672a\u521d\u59cb\u5316\uff01"),t&&_.isFunction(t.callback)&&Object.prototype.hasOwnProperty.call(t,"default_value")&&t.callback(t.default_value)}}function initAPI(t){t.setPara=function(e){if(!_.isString(e.url)||"http"!==e.url.slice(0,4))return _.log("A/B Testing SDK \u521d\u59cb\u5316\u5931\u8d25\uff0c\u8bf7\u4f7f\u7528\u6b63\u786e\u7684 URL\uff01"),!1;t.para.url=e.url;var r=_.getQueryParam(e.url,"project-key");return r?(t.para.project_key=r,_.isNumber(e.timeout_milliseconds)&&(e.timeout_milliseconds<200?t.para.timeout_milliseconds=200:t.para.timeout_milliseconds=e.timeout_milliseconds),_.isNumber(e.update_interval)&&(t.para.update_interval=e.update_interval),!0):(_.log("A/B Testing SDK \u521d\u59cb\u5316\u5931\u8d25\uff0c\u8bf7\u4f7f\u7528\u6b63\u786e\u7684 URL\uff08\u5fc5\u987b\u5305\u542b project-key\uff09\uff01"),!1)},t.asyncFetchABTest=function(e){if(!_.isObject(e))return _.log("asyncFetchABTest\u8c03\u7528\u5931\u8d25\uff0c\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e"),!1;if(!verifyStore.para("asyncFetchABTest",e,["param_name","value_type","default_value","callback"]))return!1;var r=verifyStore.resolveCustomProperties(e);r.verify_success?(e=r.para,_.validTimeout(e),t.asyncFetch(e)):e.callback(e.default_value)},t.fastFetchABTest=function(e){if(!_.isObject(e))return _.log("fastFetchABTest \u8c03\u7528\u5931\u8d25\uff0c\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e"),!1;if(!verifyStore.para("fastFetchABTest",e,["param_name","value_type","default_value","callback"]))return!1;var r=verifyStore.resolveCustomProperties(e);if(r.verify_success){e=r.para,_.validTimeout(e);var a=t.searchLocalExp(e.param_name);if(_.isObject(a)){var i=t.getExpResult(e,a);e.callback(i)}else _.log("fastFetchABTest \u7f13\u5b58\u4e2d\u672a\u8bfb\u53d6\u5230\u6570\u636e\uff0c\u53d1\u8d77\u8bf7\u6c42"),t.asyncFetch(e)}else e.callback(e.default_value)},t.fetchCacheABTest=function(e){if(_.isObject(e))return!!verifyStore.para("fetchCacheABTest",e,["param_name","value_type","default_value"])&&t.getExpResult(e);_.log("fetchCacheABTest\u8c03\u7528\u5931\u8d25\uff0c\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e")},t.asyncFetch=function(e){t.getResultFromServer({para:e,suc:function(r){if(_.isObject(r)&&"SUCCESS"===r.status){_.log("\u83b7\u53d6\u5230\u670d\u52a1\u7aef\u8bd5\u9a8c\u7ed3\u679c\u6570\u636e: ",r),t.updateData(r);var a=t.getExpResult(e);e.callback(a)}else e.callback(e.default_value)},fail:function(t){_.log("\u83b7\u53d6\u670d\u52a1\u7aef\u6570\u636e\u5931\u8d25: ",t),e.callback(e.default_value)}})},t.searchLocalExp=function(e){return!!t.state.test_list[e]&&t.state.test_list[e]},t.getExpResult=function(e,r){var a=e.default_value,i=r||t.searchLocalExp(e.param_name);return _.isObject(i)?_.isObject(i.config)&&(i.config.type===e.value_type?(a=i.config.value,t.trackTestTrigger(i)):_.log("\u8bd5\u9a8c\u7ed3\u679c\u7c7b\u578b\u4e0e\u671f\u671b\u7c7b\u578b\u4e0d\u4e00\u81f4\uff0cparam_name\uff1a"+e.param_name+"\uff0c\u5f53\u524d\u8fd4\u56de\u7c7b\u578b\u4e3a\uff1a"+i.config.type+"\uff0c\u671f\u671b\u7c7b\u578b\u4e3a\uff1a"+e.value_type)):_.log("\u672c\u5730\u672a\u67e5\u8be2\u5230\u8bd5\u9a8c\u6570\u636e\uff0c\u8bd5\u9a8c\u53c2\u6570\u540d\u79f0\uff1a"+e.param_name),a},t.getResultFromServer=function(e){var r=(e=_.isObject(e)?e:{}).para||{},a=e.suc,i=e.fail,s=t.creatRequestData(r);t.request({url:t.para.url,method:"POST",data:JSON.stringify(s),contentType:"application/json",timeout:r.timeout_milliseconds||t.para.timeout_milliseconds,suc:a,fail:i}),_.log("\u5411\u670d\u52a1\u7aef\u53d1\u8d77\u8bd5\u9a8c\u8bf7\u6c42")}}function mixinAPI(t){initAPI(t);var e=t.getExpResult;t.getExpResult=function(r,a){var i=e(r,a);return t.trackOutTestTrigger(r),i}}function formatTriggerStorage(t){var e=t.state.triggered_map;if(!_.isEmptyObject(e)){var r={},a=!1;_.each(e,function(t,e){_.isArray(t)?r[e]=t:(a=!0,r[e]=[],_.isObject(t)&&_.each(t,function(t,a){r[e].push({abtest_experiment_id:a,group_id:t})}))}),a&&(t.state.triggered_map=r,t.store.setStorage(t.info.storage_triggered_map_key,r))}}function mixinTrack(t){function e(e,r){var a=function(e){var r=t._sa.store.getDistinctId();return e.subject_id&&e.subject_name&&(r=e.subject_name+e.subject_id),r}(r),i=t.info.track_config.trigger_switch,s=!0,n=t.state[e];n&&_.isObject(n)&&n[a]&&_.each(n[a],function(t){t.experiment_id===r.abtest_experiment_id&&t.group_id===r.abtest_experiment_group_id&&t.result_id===r.abtest_experiment_result_id&&(s=!1)}),t.state[e][a]=function(t,e){var r=[],a=e.abtest_experiment_id;if(_.isString(a)){var i={experiment_id:a,group_id:e.abtest_experiment_group_id,result_id:e.abtest_experiment_result_id};if(t&&_.isArray(t)){var s=!1;_.each(t,function(e,r){e.experiment_id===a&&(t.splice(r,1,i),s=!0)}),s||t.push(i)}else t=[i];r=t}return r}(n[a],r),t.store.setStorage(t.info.storage_triggered_map_key,t.state.triggered_map),t.store.setStorage(t.info.storage_out_triggered_map_key,t.state.out_triggered_map),t.registerProperty(a);var o=function(e){var r={},a=t.state.triggered_map;if("{}"!==JSON.stringify(a)){var i=t.info.lib_plugin_name+":"+t.info.lib_version;r.$lib_plugin_version=[i]}var s={$abtest_experiment_id:e.abtest_experiment_id,$abtest_experiment_group_id:e.abtest_experiment_group_id},n=t.info.track_config.trigger_content_ext;return _.each(n,function(t){void 0!==e[t]&&(r["$"+t]=e[t])}),r=_.extend(s,r)}(r);return s&&i&&t._sa.track("$ABTestTrigger",o),s}t.trackTestTrigger=function(r){if(r.is_white_list)return!1;formatTriggerStorage(t),e("triggered_map",r)},t.trackOutTestTrigger=function(r){var a=t.state.out_list,i=!1,s={};_.isArray(a)&&a.length>0&&(_.each(a,function(t){_.isObject(t)&&!i&&_.isObject(t)&&t.variables&&_.isArray(t.variables)&&_.each(t.variables,function(e){var a=_.getRelativeValue(e.value,e.type);!i&&a&&_.isObject(e)&&r.param_name===e.name&&a.type===r.value_type&&(i=!0,s=t)})}),i&&e("out_triggered_map",s))}}var ABTest={};mixinConfig(ABTest),mixinFetch$1(ABTest),mixinTrack(ABTest),mixinRequest(ABTest),mixinStore(ABTest),ABTest.init=function(t,e){if(_.log("\u521d\u59cb\u5316 ABTest \u63d2\u4ef6"),this.state.inited)return!1;if(mixinAPI(ABTest),!this.setPara(e))return!1;var r,a,i,s,n;this.state.inited=!0,this._sa=t,this.subId=new t.eventSub(this.handleIdChange),r=ABTest.store.getStorage(ABTest.info.storage_key),a=ABTest.store.getStorage(ABTest.info.storage_out_list_key),i=ABTest.store.getStorage(ABTest.info.storage_triggered_map_key),s=ABTest.store.getStorage(ABTest.info.storage_out_triggered_map_key),n=ABTest.store.getStorage(ABTest.info.storage_track_config_key),ABTest.state.test_list=_.isObject(r)?r:{},ABTest.state.out_list=_.isArray(a)?a:[],ABTest.state.triggered_map=_.isObject(i)?i:{},ABTest.state.out_triggered_map=_.isObject(s)?s:{},ABTest.info.track_config=_.isObject(n)?n:ABTest.info.default_track_config,ABTest.registerProperty(),_.getSystemInfo(this),this.subId.isReady(),this.listenAppLaunch()},ABTest.handleIdChange=function(t){"changeDistinctId"===t&&(ABTest.state.test_list={},ABTest.state.out_list=[],ABTest.info.track_config=ABTest.info.default_track_config,ABTest.saveData(),ABTest.fetchTest())},ABTest.listenAppLaunch=function(){var t=wx.getLaunchOptionsSync();t&&t.scene&&(this.info.scene="wx-"+t.scene),this.fetchTest()},defineApi(ABTest,["asyncFetchABTest","fastFetchABTest","fetchCacheABTest"]),module.exports=ABTest; \ No newline at end of file diff --git a/dist/wechat/plugin/abtesting-sdk-miniprogram/wechat/abtest.esm.min.js b/dist/wechat/plugin/abtesting-sdk-miniprogram/wechat/abtest.esm.min.js index 78620a3..6fec98a 100644 --- a/dist/wechat/plugin/abtesting-sdk-miniprogram/wechat/abtest.esm.min.js +++ b/dist/wechat/plugin/abtesting-sdk-miniprogram/wechat/abtest.esm.min.js @@ -1 +1 @@ -var hasOwnProperty=Object.prototype.hasOwnProperty;function extend(t){return each(Array.prototype.slice.call(arguments,1),function(e){for(var r in e)void 0!==e[r]&&(t[r]=e[r])}),t}function each(t,e,r){var a=Array.prototype.forEach,i={};if(null==t)return!1;if(a&&t.forEach===a)t.forEach(e,r);else if(t.length===+t.length){for(var s=0,n=t.length;s-1?e.system.split(" ")[1]:e.system}catch(t){log("get system fails")}}function getAppId(){var t;if(wx.getAccountInfoSync&&(t=wx.getAccountInfoSync()),isObject(t)&&isObject(t.miniProgram))return t.miniProgram.appId}_.getSystemInfo=getSystemInfo,_.getAppId=getAppId;var para={url:"",project_key:"",retry_times:3,timeout_milliseconds:3e3,update_interval:6e5},info={scene:"",lib_version:"1.19.11",platform:"MiniProgram",storage_key:"sensorsdata2015_ABTest",storage_out_list_key:"sensorsdata_abtest_out_list",storage_triggered_map_key:"sensorsdata_abtest_triggered_map",storage_out_triggered_map_key:"sensorsdata_abtest_out_triggered_map",storage_track_config_key:"sensorsdata_abtest_track_config",lib_plugin_name:"miniprogram_abtesting",platform_obj:wx,track_config:{},default_track_config:{trigger_switch:!0,property_set_switch:!1,trigger_content_ext:["abtest_experiment_version","abtest_experiment_result_id"]}},props={$manufacturer:"",$model:"",$os:"",$os_version:""},state={inited:!1,fetchInterval:null,test_list:{},out_triggered_map:{},triggered_map:{},out_list:[]};function mixinConfig(t){t.para=para,t.info=info,t.state=state,t.props=props,t.plugin_name="ABTestingWechat",t.plugin_version="1.19.11"}function mixinStore(t){var e=t.info.platform_obj;if(!e||isEmptyObject(e))return!1;t.store={getStorage:function(t){var r="";try{a=r=e.getStorageSync(t),r=isString(a)?(-1!==a.indexOf("data:enc;")&&(a=rot13defs(a=a.substring("data:enc;".length))),a):a}catch(t){log("\u83b7\u53d6 storage \u5931\u8d25\uff01")}var a;return isJSONString(r)&&(r=JSON.parse(r)),r},setStorage:function(r,a){var i;try{s=i=JSON.stringify(a),n=!1,t&&t._sa&&t._sa.para&&(n=t._sa.para.encrypt_storage),n&&(isObject(s)&&(s=JSON.stringify(s)),s="data:enc;"+rot13obfs(s)),i=s}catch(t){log("\u5e8f\u5217\u5316\u7f13\u5b58\u5bf9\u8c61\u5931\u8d25\uff01")}var s,n;try{e.setStorageSync(r,i)}catch(t){log("set Storage fail again --",t)}}}}function mixinRequest(t){var e,r=t.info.platform_obj;isObject(r)&&(e=function(t){var e=t.url,a="GET",i=null;t.method&&(a=t.method),t.data&&(i=t.data),r.request({url:e,method:a,data:i,timeout:t.timeout,success:function(e){t.suc(e.data)},fail:function(e){t.fail(e)}})}),t.request=e}function mixinFetch(t){t.fetchTest=function(){var e=0,r=!1,a=t.creatRequestData();function i(e){_.log("\u8bf7\u6c42\u6570\u636e\u7ed3\u679c\u6210\u529f: ",e),r=!0,t.updateData(e),t.state.fetchInterval&&clearTimeout(t.state.fetchInterval),t.state.fetchInterval=setTimeout(function(){t.request({url:t.para.url,method:"POST",data:JSON.stringify(a),timeout:t.para.timeout_milliseconds,suc:i,fail:s})},t.para.update_interval)}function s(n){return _.log("\u8bf7\u6c42\u6570\u636e\u7ed3\u679c\u5931\u8d25: ",n),e++,!r&&e0&&t._sa.registerApp({abtest_result:i}),s.length>0&&t._sa.registerApp({abtest_dispatch_result:s})}else t._sa.clearAppRegister(["abtest_result","abtest_dispatch_result"])},t.saveData=function(){t.store.setStorage(t.info.storage_key,t.state.test_list),t.store.setStorage(t.info.storage_out_list_key,t.state.out_list),t.store.setStorage(t.info.storage_track_config_key,t.info.track_config)},t.updateData=function(e){t.resolveData(e),t.saveData(),_.log("\u66f4\u65b0\u8bd5\u9a8c\u6570\u636e"),t.registerProperty()},t.resolveData=function(e){if(!_.isObject(e)||!_.isArray(e.results))return _.log("\u89e3\u6790——\u6570\u636e\u683c\u5f0f\u9519\u8bef",e),!1;var r=e.results;t.state.test_list={},_.isArray(r)&&_.each(r,function(e){_.isObject(e)&&e.variables&&_.isArray(e.variables)&&_.each(e.variables,function(r){_.isObject(r)&&!t.state.test_list[r.name]&&(t.state.test_list[r.name]=_.extend({},e),t.state.test_list[r.name].config=_.getRelativeValue(r.value,r.type))})}),t.state.out_list=_.isArray(e.out_list)?e.out_list:[],t.info.track_config=_.isObject(e.track_config)?e.track_config:t.info.default_track_config}}var VALUE_TYPE_LIST=["Number","String","Object","Boolean"],regName=/^((?!^distinct_id$|^original_id$|^time$|^properties$|^id$|^first_id$|^second_id$|^users$|^events$|^event$|^user_id$|^date$|^datetime$|^user_tag.*|^user_group.*)[a-zA-Z_][a-zA-Z\d_]*)$/i,verifyStore={valueType:function(t,e){switch(e){case"Number":if(_.isNumber(t))return!0;break;case"String":if(_.isString(t))return!0;break;case"Object":if(_.isObject(t))return!0;break;case"Boolean":if(!0===t||!1===t)return!0;break;default:return!1}return!1},para:function(t,e,r){var a=!0;return _.each(r,function(r){switch(r){case"param_name":e.param_name&&_.isString(e.param_name)&&e.param_name.length>0||(_.log(t+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0cparam_name\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e\uff01param_name:",e.param_name),a=!1);break;case"value_type":_.isString(e.value_type)&&-1!==_.indexOf(VALUE_TYPE_LIST,e.value_type)||(_.log(t+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0cvalue_type\u914d\u7f6e\u9519\u8bef",e.value_type),a=!1);break;case"default_value":void 0===e.default_value?(_.log(t+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0cdefault_value\u53c2\u6570\u672a\u914d\u7f6e"),a=!1):verifyStore.valueType(e.default_value,e.value_type)||(_.log(t+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0cdefault_value\u7c7b\u578b\u5fc5\u987b\u4e0evalue_type\u4e00\u81f4\uff01",e.default_value,e.value_type),a=!1);break;case"callback":_.isFunction(e.callback)||(_.log(t+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0ccallback\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e"),a=!1)}}),a},resolveCustomProperties:function(t){var e={verify_success:!0,para:null},r=t.custom_properties;if(!_.isObject(r)||_.isEmptyObject(r))return delete t.custom_properties,e.para=t,e;if(_.each(r,function(t,r){if((!_.isString(r)||!regName.test(r)||r.length>100)&&(_.log(" property name [ "+r+" ] is not invalid "),e.verify_success=!1),(_.isString(t)||_.isNumber(t)||_.isBoolean(t)||_.isArray(t)||_.isDate(t))&&!(_.isString(t)&&t.length>500)||(_.log("property [ "+r+" ] of value [ "+JSON.stringify(t)+" ] is not invalid"),e.verify_success=!1),_.isArray(t)){var a=!0;_.each(t,function(t){!1!==a&&(_.isString(t)||(a=!1))}),a||(_.log("property value type can be array, but only allow string item. property [ "+r+" ] of value "+JSON.stringify(t)+" is not invalid"),e.verify_success=!1)}}),!0===e.verify_success){var a={};_.each(r,function(t,e){_.isDate(t)?a[e]=_.formatDate(t):_.isString(t)?a[e]=t:a[e]=JSON.stringify(t)}),t.custom_properties=a}return e.para=t,e}};function defineApi(t,e){for(var r of e)t[r]="fetchCacheABTest"===r?function(t){if(_.log("\u8c03\u7528\u5206\u6d41 API --- A/B Testing \u63d2\u4ef6\u5c1a\u672a\u521d\u59cb\u5316\uff01"),Object.prototype.hasOwnProperty.call(t,"default_value"))return t.default_value}:function(t){_.log("\u8c03\u7528\u5206\u6d41 API --- A/B Testing \u63d2\u4ef6\u5c1a\u672a\u521d\u59cb\u5316\uff01"),t&&_.isFunction(t.callback)&&Object.prototype.hasOwnProperty.call(t,"default_value")&&t.callback(t.default_value)}}function initAPI(t){t.setPara=function(e){if(!_.isString(e.url)||"http"!==e.url.slice(0,4))return _.log("A/B Testing SDK \u521d\u59cb\u5316\u5931\u8d25\uff0c\u8bf7\u4f7f\u7528\u6b63\u786e\u7684 URL\uff01"),!1;t.para.url=e.url;var r=_.getQueryParam(e.url,"project-key");return r?(t.para.project_key=r,_.isNumber(e.timeout_milliseconds)&&(e.timeout_milliseconds<200?t.para.timeout_milliseconds=200:t.para.timeout_milliseconds=e.timeout_milliseconds),_.isNumber(e.update_interval)&&(t.para.update_interval=e.update_interval),!0):(_.log("A/B Testing SDK \u521d\u59cb\u5316\u5931\u8d25\uff0c\u8bf7\u4f7f\u7528\u6b63\u786e\u7684 URL\uff08\u5fc5\u987b\u5305\u542b project-key\uff09\uff01"),!1)},t.asyncFetchABTest=function(e){if(!_.isObject(e))return _.log("asyncFetchABTest\u8c03\u7528\u5931\u8d25\uff0c\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e"),!1;if(!verifyStore.para("asyncFetchABTest",e,["param_name","value_type","default_value","callback"]))return!1;var r=verifyStore.resolveCustomProperties(e);r.verify_success?(e=r.para,_.validTimeout(e),t.asyncFetch(e)):e.callback(e.default_value)},t.fastFetchABTest=function(e){if(!_.isObject(e))return _.log("fastFetchABTest \u8c03\u7528\u5931\u8d25\uff0c\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e"),!1;if(!verifyStore.para("fastFetchABTest",e,["param_name","value_type","default_value","callback"]))return!1;var r=verifyStore.resolveCustomProperties(e);if(r.verify_success){e=r.para,_.validTimeout(e);var a=t.searchLocalExp(e.param_name);if(_.isObject(a)){var i=t.getExpResult(e,a);e.callback(i)}else _.log("fastFetchABTest \u7f13\u5b58\u4e2d\u672a\u8bfb\u53d6\u5230\u6570\u636e\uff0c\u53d1\u8d77\u8bf7\u6c42"),t.asyncFetch(e)}else e.callback(e.default_value)},t.fetchCacheABTest=function(e){if(_.isObject(e))return!!verifyStore.para("fetchCacheABTest",e,["param_name","value_type","default_value"])&&t.getExpResult(e);_.log("fetchCacheABTest\u8c03\u7528\u5931\u8d25\uff0c\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e")},t.asyncFetch=function(e){t.getResultFromServer({para:e,suc:function(r){if(_.isObject(r)&&"SUCCESS"===r.status){_.log("\u83b7\u53d6\u5230\u670d\u52a1\u7aef\u8bd5\u9a8c\u7ed3\u679c\u6570\u636e: ",r),t.updateData(r);var a=t.getExpResult(e);e.callback(a)}else e.callback(e.default_value)},fail:function(t){_.log("\u83b7\u53d6\u670d\u52a1\u7aef\u6570\u636e\u5931\u8d25: ",t),e.callback(e.default_value)}})},t.searchLocalExp=function(e){return!!t.state.test_list[e]&&t.state.test_list[e]},t.getExpResult=function(e,r){var a=e.default_value,i=r||t.searchLocalExp(e.param_name);return _.isObject(i)?_.isObject(i.config)&&(i.config.type===e.value_type?(a=i.config.value,t.trackTestTrigger(i)):_.log("\u8bd5\u9a8c\u7ed3\u679c\u7c7b\u578b\u4e0e\u671f\u671b\u7c7b\u578b\u4e0d\u4e00\u81f4\uff0cparam_name\uff1a"+e.param_name+"\uff0c\u5f53\u524d\u8fd4\u56de\u7c7b\u578b\u4e3a\uff1a"+i.config.type+"\uff0c\u671f\u671b\u7c7b\u578b\u4e3a\uff1a"+e.value_type)):_.log("\u672c\u5730\u672a\u67e5\u8be2\u5230\u8bd5\u9a8c\u6570\u636e\uff0c\u8bd5\u9a8c\u53c2\u6570\u540d\u79f0\uff1a"+e.param_name),a},t.getResultFromServer=function(e){var r=(e=_.isObject(e)?e:{}).para||{},a=e.suc,i=e.fail,s=t.creatRequestData(r);t.request({url:t.para.url,method:"POST",data:JSON.stringify(s),contentType:"application/json",timeout:r.timeout_milliseconds||t.para.timeout_milliseconds,suc:a,fail:i}),_.log("\u5411\u670d\u52a1\u7aef\u53d1\u8d77\u8bd5\u9a8c\u8bf7\u6c42")}}function mixinAPI(t){initAPI(t);var e=t.getExpResult;t.getExpResult=function(r,a){var i=e(r,a);return t.trackOutTestTrigger(r),i}}function formatTriggerStorage(t){var e=t.state.triggered_map;if(!_.isEmptyObject(e)){var r={},a=!1;_.each(e,function(t,e){_.isArray(t)?r[e]=t:(a=!0,r[e]=[],_.isObject(t)&&_.each(t,function(t,a){r[e].push({abtest_experiment_id:a,group_id:t})}))}),a&&(t.state.triggered_map=r,t.store.setStorage(t.info.storage_triggered_map_key,r))}}function mixinTrack(t){function e(e,r){var a=function(e){var r=t._sa.store.getDistinctId();return e.subject_id&&e.subject_name&&(r=e.subject_name+e.subject_id),r}(r),i=t.info.track_config.trigger_switch,s=!0,n=t.state[e];n&&_.isObject(n)&&n[a]&&_.each(n[a],function(t){t.experiment_id===r.abtest_experiment_id&&t.group_id===r.abtest_experiment_group_id&&t.result_id===r.abtest_experiment_result_id&&(s=!1)}),t.state[e][a]=function(t,e){var r=[],a=e.abtest_experiment_id;if(_.isString(a)){var i={experiment_id:a,group_id:e.abtest_experiment_group_id,result_id:e.abtest_experiment_result_id};if(t&&_.isArray(t)){var s=!1;_.each(t,function(e,r){e.experiment_id===a&&(t.splice(r,1,i),s=!0)}),s||t.push(i)}else t=[i];r=t}return r}(n[a],r),t.store.setStorage(t.info.storage_triggered_map_key,t.state.triggered_map),t.store.setStorage(t.info.storage_out_triggered_map_key,t.state.out_triggered_map),t.registerProperty(a);var o=function(e){var r={},a=t.state.triggered_map;if("{}"!==JSON.stringify(a)){var i=t.info.lib_plugin_name+":"+t.info.lib_version;r.$lib_plugin_version=[i]}var s={$abtest_experiment_id:e.abtest_experiment_id,$abtest_experiment_group_id:e.abtest_experiment_group_id},n=t.info.track_config.trigger_content_ext;return _.each(n,function(t){void 0!==e[t]&&(r["$"+t]=e[t])}),r=_.extend(s,r)}(r);return s&&i&&t._sa.track("$ABTestTrigger",o),s}t.trackTestTrigger=function(r){if(r.is_white_list)return!1;formatTriggerStorage(t),e("triggered_map",r)},t.trackOutTestTrigger=function(r){var a=t.state.out_list,i=!1,s={};_.isArray(a)&&a.length>0&&(_.each(a,function(t){_.isObject(t)&&!i&&_.isObject(t)&&t.variables&&_.isArray(t.variables)&&_.each(t.variables,function(e){var a=_.getRelativeValue(e.value,e.type);!i&&a&&_.isObject(e)&&r.param_name===e.name&&a.type===r.value_type&&(i=!0,s=t)})}),i&&e("out_triggered_map",s))}}var ABTest={};mixinConfig(ABTest),mixinFetch$1(ABTest),mixinTrack(ABTest),mixinRequest(ABTest),mixinStore(ABTest),ABTest.init=function(t,e){if(_.log("\u521d\u59cb\u5316 ABTest \u63d2\u4ef6"),this.state.inited)return!1;if(mixinAPI(ABTest),!this.setPara(e))return!1;var r,a,i,s,n;this.state.inited=!0,this._sa=t,this.subId=new t.eventSub(this.handleIdChange),r=ABTest.store.getStorage(ABTest.info.storage_key),a=ABTest.store.getStorage(ABTest.info.storage_out_list_key),i=ABTest.store.getStorage(ABTest.info.storage_triggered_map_key),s=ABTest.store.getStorage(ABTest.info.storage_out_triggered_map_key),n=ABTest.store.getStorage(ABTest.info.storage_track_config_key),ABTest.state.test_list=_.isObject(r)?r:{},ABTest.state.out_list=_.isArray(a)?a:[],ABTest.state.triggered_map=_.isObject(i)?i:{},ABTest.state.out_triggered_map=_.isObject(s)?s:{},ABTest.info.track_config=_.isObject(n)?n:ABTest.info.default_track_config,ABTest.registerProperty(),_.getSystemInfo(this),this.subId.isReady(),this.listenAppLaunch()},ABTest.handleIdChange=function(t){"changeDistinctId"===t&&(ABTest.state.test_list={},ABTest.state.out_list=[],ABTest.info.track_config=ABTest.info.default_track_config,ABTest.saveData(),ABTest.fetchTest())},ABTest.listenAppLaunch=function(){var t=wx.getLaunchOptionsSync();t&&t.scene&&(this.info.scene="wx-"+t.scene),this.fetchTest()},defineApi(ABTest,["asyncFetchABTest","fastFetchABTest","fetchCacheABTest"]);export default ABTest; \ No newline at end of file +var hasOwnProperty=Object.prototype.hasOwnProperty;function extend(t){return each(Array.prototype.slice.call(arguments,1),function(e){for(var r in e)void 0!==e[r]&&(t[r]=e[r])}),t}function each(t,e,r){var a=Array.prototype.forEach,i={};if(null==t)return!1;if(a&&t.forEach===a)t.forEach(e,r);else if(t.length===+t.length){for(var s=0,n=t.length;s-1?e.system.split(" ")[1]:e.system}catch(t){log("get system fails")}}function getAppId(){var t;if(wx.getAccountInfoSync&&(t=wx.getAccountInfoSync()),isObject(t)&&isObject(t.miniProgram))return t.miniProgram.appId}_.getSystemInfo=getSystemInfo,_.getAppId=getAppId;var para={url:"",project_key:"",retry_times:3,timeout_milliseconds:3e3,update_interval:6e5},info={scene:"",lib_version:"1.19.12",platform:"MiniProgram",storage_key:"sensorsdata2015_ABTest",storage_out_list_key:"sensorsdata_abtest_out_list",storage_triggered_map_key:"sensorsdata_abtest_triggered_map",storage_out_triggered_map_key:"sensorsdata_abtest_out_triggered_map",storage_track_config_key:"sensorsdata_abtest_track_config",lib_plugin_name:"miniprogram_abtesting",platform_obj:wx,track_config:{},default_track_config:{trigger_switch:!0,property_set_switch:!1,trigger_content_ext:["abtest_experiment_version","abtest_experiment_result_id"]}},props={$manufacturer:"",$model:"",$os:"",$os_version:""},state={inited:!1,fetchInterval:null,test_list:{},out_triggered_map:{},triggered_map:{},out_list:[]};function mixinConfig(t){t.para=para,t.info=info,t.state=state,t.props=props,t.plugin_name="ABTestingWechat",t.plugin_version="1.19.12"}function mixinStore(t){var e=t.info.platform_obj;if(!e||isEmptyObject(e))return!1;t.store={getStorage:function(t){var r="";try{a=r=e.getStorageSync(t),r=isString(a)?(-1!==a.indexOf("data:enc;")&&(a=rot13defs(a=a.substring("data:enc;".length))),a):a}catch(t){log("\u83b7\u53d6 storage \u5931\u8d25\uff01")}var a;return isJSONString(r)&&(r=JSON.parse(r)),r},setStorage:function(r,a){var i;try{s=i=JSON.stringify(a),n=!1,t&&t._sa&&t._sa.para&&(n=t._sa.para.encrypt_storage),n&&(isObject(s)&&(s=JSON.stringify(s)),s="data:enc;"+rot13obfs(s)),i=s}catch(t){log("\u5e8f\u5217\u5316\u7f13\u5b58\u5bf9\u8c61\u5931\u8d25\uff01")}var s,n;try{e.setStorageSync(r,i)}catch(t){log("set Storage fail again --",t)}}}}function mixinRequest(t){var e,r=t.info.platform_obj;isObject(r)&&(e=function(t){var e=t.url,a="GET",i=null;t.method&&(a=t.method),t.data&&(i=t.data),r.request({url:e,method:a,data:i,timeout:t.timeout,success:function(e){t.suc(e.data)},fail:function(e){t.fail(e)}})}),t.request=e}function mixinFetch(t){t.fetchTest=function(){var e=0,r=!1,a=t.creatRequestData();function i(e){_.log("\u8bf7\u6c42\u6570\u636e\u7ed3\u679c\u6210\u529f: ",e),r=!0,t.updateData(e),t.state.fetchInterval&&clearTimeout(t.state.fetchInterval),t.state.fetchInterval=setTimeout(function(){t.request({url:t.para.url,method:"POST",data:JSON.stringify(a),timeout:t.para.timeout_milliseconds,suc:i,fail:s})},t.para.update_interval)}function s(n){return _.log("\u8bf7\u6c42\u6570\u636e\u7ed3\u679c\u5931\u8d25: ",n),e++,!r&&e0&&t._sa.registerApp({abtest_result:i}),s.length>0&&t._sa.registerApp({abtest_dispatch_result:s})}else t._sa.clearAppRegister(["abtest_result","abtest_dispatch_result"])},t.saveData=function(){t.store.setStorage(t.info.storage_key,t.state.test_list),t.store.setStorage(t.info.storage_out_list_key,t.state.out_list),t.store.setStorage(t.info.storage_track_config_key,t.info.track_config)},t.updateData=function(e){t.resolveData(e),t.saveData(),_.log("\u66f4\u65b0\u8bd5\u9a8c\u6570\u636e"),t.registerProperty()},t.resolveData=function(e){if(!_.isObject(e)||!_.isArray(e.results))return _.log("\u89e3\u6790——\u6570\u636e\u683c\u5f0f\u9519\u8bef",e),!1;var r=e.results;t.state.test_list={},_.isArray(r)&&_.each(r,function(e){_.isObject(e)&&e.variables&&_.isArray(e.variables)&&_.each(e.variables,function(r){_.isObject(r)&&!t.state.test_list[r.name]&&(t.state.test_list[r.name]=_.extend({},e),t.state.test_list[r.name].config=_.getRelativeValue(r.value,r.type))})}),t.state.out_list=_.isArray(e.out_list)?e.out_list:[],t.info.track_config=_.isObject(e.track_config)?e.track_config:t.info.default_track_config}}var VALUE_TYPE_LIST=["Number","String","Object","Boolean"],regName=/^((?!^distinct_id$|^original_id$|^time$|^properties$|^id$|^first_id$|^second_id$|^users$|^events$|^event$|^user_id$|^date$|^datetime$|^user_tag.*|^user_group.*)[a-zA-Z_][a-zA-Z\d_]*)$/i,verifyStore={valueType:function(t,e){switch(e){case"Number":if(_.isNumber(t))return!0;break;case"String":if(_.isString(t))return!0;break;case"Object":if(_.isObject(t))return!0;break;case"Boolean":if(!0===t||!1===t)return!0;break;default:return!1}return!1},para:function(t,e,r){var a=!0;return _.each(r,function(r){switch(r){case"param_name":e.param_name&&_.isString(e.param_name)&&e.param_name.length>0||(_.log(t+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0cparam_name\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e\uff01param_name:",e.param_name),a=!1);break;case"value_type":_.isString(e.value_type)&&-1!==_.indexOf(VALUE_TYPE_LIST,e.value_type)||(_.log(t+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0cvalue_type\u914d\u7f6e\u9519\u8bef",e.value_type),a=!1);break;case"default_value":void 0===e.default_value?(_.log(t+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0cdefault_value\u53c2\u6570\u672a\u914d\u7f6e"),a=!1):verifyStore.valueType(e.default_value,e.value_type)||(_.log(t+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0cdefault_value\u7c7b\u578b\u5fc5\u987b\u4e0evalue_type\u4e00\u81f4\uff01",e.default_value,e.value_type),a=!1);break;case"callback":_.isFunction(e.callback)||(_.log(t+"\u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0ccallback\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e"),a=!1)}}),a},resolveCustomProperties:function(t){var e={verify_success:!0,para:null},r=t.custom_properties;if(!_.isObject(r)||_.isEmptyObject(r))return delete t.custom_properties,e.para=t,e;if(_.each(r,function(t,r){if((!_.isString(r)||!regName.test(r)||r.length>100)&&(_.log(" property name [ "+r+" ] is not invalid "),e.verify_success=!1),(_.isString(t)||_.isNumber(t)||_.isBoolean(t)||_.isArray(t)||_.isDate(t))&&!(_.isString(t)&&t.length>500)||(_.log("property [ "+r+" ] of value [ "+JSON.stringify(t)+" ] is not invalid"),e.verify_success=!1),_.isArray(t)){var a=!0;_.each(t,function(t){!1!==a&&(_.isString(t)||(a=!1))}),a||(_.log("property value type can be array, but only allow string item. property [ "+r+" ] of value "+JSON.stringify(t)+" is not invalid"),e.verify_success=!1)}}),!0===e.verify_success){var a={};_.each(r,function(t,e){_.isDate(t)?a[e]=_.formatDate(t):_.isString(t)?a[e]=t:a[e]=JSON.stringify(t)}),t.custom_properties=a}return e.para=t,e}};function defineApi(t,e){for(var r of e)t[r]="fetchCacheABTest"===r?function(t){if(_.log("\u8c03\u7528\u5206\u6d41 API --- A/B Testing \u63d2\u4ef6\u5c1a\u672a\u521d\u59cb\u5316\uff01"),Object.prototype.hasOwnProperty.call(t,"default_value"))return t.default_value}:function(t){_.log("\u8c03\u7528\u5206\u6d41 API --- A/B Testing \u63d2\u4ef6\u5c1a\u672a\u521d\u59cb\u5316\uff01"),t&&_.isFunction(t.callback)&&Object.prototype.hasOwnProperty.call(t,"default_value")&&t.callback(t.default_value)}}function initAPI(t){t.setPara=function(e){if(!_.isString(e.url)||"http"!==e.url.slice(0,4))return _.log("A/B Testing SDK \u521d\u59cb\u5316\u5931\u8d25\uff0c\u8bf7\u4f7f\u7528\u6b63\u786e\u7684 URL\uff01"),!1;t.para.url=e.url;var r=_.getQueryParam(e.url,"project-key");return r?(t.para.project_key=r,_.isNumber(e.timeout_milliseconds)&&(e.timeout_milliseconds<200?t.para.timeout_milliseconds=200:t.para.timeout_milliseconds=e.timeout_milliseconds),_.isNumber(e.update_interval)&&(t.para.update_interval=e.update_interval),!0):(_.log("A/B Testing SDK \u521d\u59cb\u5316\u5931\u8d25\uff0c\u8bf7\u4f7f\u7528\u6b63\u786e\u7684 URL\uff08\u5fc5\u987b\u5305\u542b project-key\uff09\uff01"),!1)},t.asyncFetchABTest=function(e){if(!_.isObject(e))return _.log("asyncFetchABTest\u8c03\u7528\u5931\u8d25\uff0c\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e"),!1;if(!verifyStore.para("asyncFetchABTest",e,["param_name","value_type","default_value","callback"]))return!1;var r=verifyStore.resolveCustomProperties(e);r.verify_success?(e=r.para,_.validTimeout(e),t.asyncFetch(e)):e.callback(e.default_value)},t.fastFetchABTest=function(e){if(!_.isObject(e))return _.log("fastFetchABTest \u8c03\u7528\u5931\u8d25\uff0c\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e"),!1;if(!verifyStore.para("fastFetchABTest",e,["param_name","value_type","default_value","callback"]))return!1;var r=verifyStore.resolveCustomProperties(e);if(r.verify_success){e=r.para,_.validTimeout(e);var a=t.searchLocalExp(e.param_name);if(_.isObject(a)){var i=t.getExpResult(e,a);e.callback(i)}else _.log("fastFetchABTest \u7f13\u5b58\u4e2d\u672a\u8bfb\u53d6\u5230\u6570\u636e\uff0c\u53d1\u8d77\u8bf7\u6c42"),t.asyncFetch(e)}else e.callback(e.default_value)},t.fetchCacheABTest=function(e){if(_.isObject(e))return!!verifyStore.para("fetchCacheABTest",e,["param_name","value_type","default_value"])&&t.getExpResult(e);_.log("fetchCacheABTest\u8c03\u7528\u5931\u8d25\uff0c\u53c2\u6570\u672a\u6b63\u786e\u914d\u7f6e")},t.asyncFetch=function(e){t.getResultFromServer({para:e,suc:function(r){if(_.isObject(r)&&"SUCCESS"===r.status){_.log("\u83b7\u53d6\u5230\u670d\u52a1\u7aef\u8bd5\u9a8c\u7ed3\u679c\u6570\u636e: ",r),t.updateData(r);var a=t.getExpResult(e);e.callback(a)}else e.callback(e.default_value)},fail:function(t){_.log("\u83b7\u53d6\u670d\u52a1\u7aef\u6570\u636e\u5931\u8d25: ",t),e.callback(e.default_value)}})},t.searchLocalExp=function(e){return!!t.state.test_list[e]&&t.state.test_list[e]},t.getExpResult=function(e,r){var a=e.default_value,i=r||t.searchLocalExp(e.param_name);return _.isObject(i)?_.isObject(i.config)&&(i.config.type===e.value_type?(a=i.config.value,t.trackTestTrigger(i)):_.log("\u8bd5\u9a8c\u7ed3\u679c\u7c7b\u578b\u4e0e\u671f\u671b\u7c7b\u578b\u4e0d\u4e00\u81f4\uff0cparam_name\uff1a"+e.param_name+"\uff0c\u5f53\u524d\u8fd4\u56de\u7c7b\u578b\u4e3a\uff1a"+i.config.type+"\uff0c\u671f\u671b\u7c7b\u578b\u4e3a\uff1a"+e.value_type)):_.log("\u672c\u5730\u672a\u67e5\u8be2\u5230\u8bd5\u9a8c\u6570\u636e\uff0c\u8bd5\u9a8c\u53c2\u6570\u540d\u79f0\uff1a"+e.param_name),a},t.getResultFromServer=function(e){var r=(e=_.isObject(e)?e:{}).para||{},a=e.suc,i=e.fail,s=t.creatRequestData(r);t.request({url:t.para.url,method:"POST",data:JSON.stringify(s),contentType:"application/json",timeout:r.timeout_milliseconds||t.para.timeout_milliseconds,suc:a,fail:i}),_.log("\u5411\u670d\u52a1\u7aef\u53d1\u8d77\u8bd5\u9a8c\u8bf7\u6c42")}}function mixinAPI(t){initAPI(t);var e=t.getExpResult;t.getExpResult=function(r,a){var i=e(r,a);return t.trackOutTestTrigger(r),i}}function formatTriggerStorage(t){var e=t.state.triggered_map;if(!_.isEmptyObject(e)){var r={},a=!1;_.each(e,function(t,e){_.isArray(t)?r[e]=t:(a=!0,r[e]=[],_.isObject(t)&&_.each(t,function(t,a){r[e].push({abtest_experiment_id:a,group_id:t})}))}),a&&(t.state.triggered_map=r,t.store.setStorage(t.info.storage_triggered_map_key,r))}}function mixinTrack(t){function e(e,r){var a=function(e){var r=t._sa.store.getDistinctId();return e.subject_id&&e.subject_name&&(r=e.subject_name+e.subject_id),r}(r),i=t.info.track_config.trigger_switch,s=!0,n=t.state[e];n&&_.isObject(n)&&n[a]&&_.each(n[a],function(t){t.experiment_id===r.abtest_experiment_id&&t.group_id===r.abtest_experiment_group_id&&t.result_id===r.abtest_experiment_result_id&&(s=!1)}),t.state[e][a]=function(t,e){var r=[],a=e.abtest_experiment_id;if(_.isString(a)){var i={experiment_id:a,group_id:e.abtest_experiment_group_id,result_id:e.abtest_experiment_result_id};if(t&&_.isArray(t)){var s=!1;_.each(t,function(e,r){e.experiment_id===a&&(t.splice(r,1,i),s=!0)}),s||t.push(i)}else t=[i];r=t}return r}(n[a],r),t.store.setStorage(t.info.storage_triggered_map_key,t.state.triggered_map),t.store.setStorage(t.info.storage_out_triggered_map_key,t.state.out_triggered_map),t.registerProperty(a);var o=function(e){var r={},a=t.state.triggered_map;if("{}"!==JSON.stringify(a)){var i=t.info.lib_plugin_name+":"+t.info.lib_version;r.$lib_plugin_version=[i]}var s={$abtest_experiment_id:e.abtest_experiment_id,$abtest_experiment_group_id:e.abtest_experiment_group_id},n=t.info.track_config.trigger_content_ext;return _.each(n,function(t){void 0!==e[t]&&(r["$"+t]=e[t])}),r=_.extend(s,r)}(r);return s&&i&&t._sa.track("$ABTestTrigger",o),s}t.trackTestTrigger=function(r){if(r.is_white_list)return!1;formatTriggerStorage(t),e("triggered_map",r)},t.trackOutTestTrigger=function(r){var a=t.state.out_list,i=!1,s={};_.isArray(a)&&a.length>0&&(_.each(a,function(t){_.isObject(t)&&!i&&_.isObject(t)&&t.variables&&_.isArray(t.variables)&&_.each(t.variables,function(e){var a=_.getRelativeValue(e.value,e.type);!i&&a&&_.isObject(e)&&r.param_name===e.name&&a.type===r.value_type&&(i=!0,s=t)})}),i&&e("out_triggered_map",s))}}var ABTest={};mixinConfig(ABTest),mixinFetch$1(ABTest),mixinTrack(ABTest),mixinRequest(ABTest),mixinStore(ABTest),ABTest.init=function(t,e){if(_.log("\u521d\u59cb\u5316 ABTest \u63d2\u4ef6"),this.state.inited)return!1;if(mixinAPI(ABTest),!this.setPara(e))return!1;var r,a,i,s,n;this.state.inited=!0,this._sa=t,this.subId=new t.eventSub(this.handleIdChange),r=ABTest.store.getStorage(ABTest.info.storage_key),a=ABTest.store.getStorage(ABTest.info.storage_out_list_key),i=ABTest.store.getStorage(ABTest.info.storage_triggered_map_key),s=ABTest.store.getStorage(ABTest.info.storage_out_triggered_map_key),n=ABTest.store.getStorage(ABTest.info.storage_track_config_key),ABTest.state.test_list=_.isObject(r)?r:{},ABTest.state.out_list=_.isArray(a)?a:[],ABTest.state.triggered_map=_.isObject(i)?i:{},ABTest.state.out_triggered_map=_.isObject(s)?s:{},ABTest.info.track_config=_.isObject(n)?n:ABTest.info.default_track_config,ABTest.registerProperty(),_.getSystemInfo(this),this.subId.isReady(),this.listenAppLaunch()},ABTest.handleIdChange=function(t){"changeDistinctId"===t&&(ABTest.state.test_list={},ABTest.state.out_list=[],ABTest.info.track_config=ABTest.info.default_track_config,ABTest.saveData(),ABTest.fetchTest())},ABTest.listenAppLaunch=function(){var t=wx.getLaunchOptionsSync();t&&t.scene&&(this.info.scene="wx-"+t.scene),this.fetchTest()},defineApi(ABTest,["asyncFetchABTest","fastFetchABTest","fetchCacheABTest"]);export default ABTest; \ No newline at end of file diff --git a/dist/wechat/plugin/ad-channel-h5-linker/index.cmd.js b/dist/wechat/plugin/ad-channel-h5-linker/index.cmd.js index fce4089..1d0f04d 100644 --- a/dist/wechat/plugin/ad-channel-h5-linker/index.cmd.js +++ b/dist/wechat/plugin/ad-channel-h5-linker/index.cmd.js @@ -1 +1 @@ -"use strict";var base={plugin_version:"1.19.11"};function createPlugin(e){if("object"==typeof e&&"string"==typeof e.plugin_name&&""!==e.plugin_name)return e.plugin_version=base.plugin_version,e.log=e.log||function(){"object"==typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)},e;"object"==typeof console&&"function"==typeof console.error&&console.error('plugin must contain proprerty "plugin_name"')}var h5Linker={is_ready:!1},log=console&&console.log||function(){};h5Linker.getSasdkValue=function(){var e=this.store.getDistinctId()||"",t=this.store.getFirstId()||"";return this._.urlSafeBase64&&this._.urlSafeBase64.encode?e=e?this._.urlSafeBase64.trim(this._.urlSafeBase64.encode(this._.base64Encode(e))):"":this._.rot13obfs&&(e=e?this._.rot13obfs(e):""),encodeURIComponent(t?"f"+e:"d"+e)},h5Linker.rewriteUrl=function(e,t){if(!this.is_ready)return this.log("h5Linker plugin not initialized"),e;var n=this,i=/([^?#]+)(\?[^#]*)?(#.*)?/.exec(e),s="";if(!i)return e;var r,a=i[1]||"",o=i[2]||"",l=i[3]||"",c="_sasdk="+this.getSasdkValue(),u=function(e){var t=e.split("&"),i=[];return n._.each(t,function(e){e.indexOf("_sasdk=")>-1?i.push(c):i.push(e)}),i.join("&")};(t=!!this._.isBoolean(t)&&t)?(r=l.indexOf("_sasdk"),s=l.indexOf("?")>-1?r>-1?a+o+"#"+l.substring(1,r)+u(l.substring(r,l.length)):a+o+l+"&"+c:a+o+"#"+l.substring(1)+"?"+c):(r=o.indexOf("_sasdk"),s=/^\?(\w)+/.test(o)?r>-1?a+"?"+u(o.substring(1))+l:a+o+"&"+c+l:a+"?"+c+l);return s},h5Linker.init=function(e){e?(this._=e._,this.store=e.store,this.log=e._.logger.info||log,this.is_ready=!0):log("H5Linker plugin initialization failed")},h5Linker.plugin_name="H5Linker";var hasOwnProperty=Object.prototype.hasOwnProperty;function isFunction(e){if(!e)return!1;var t=Object.prototype.toString.call(e);return"[object Function]"==t||"[object AsyncFunction]"==t}function isObject(e){return null!=e&&"[object Object]"==Object.prototype.toString.call(e)}function isString(e){return"[object String]"==toString.call(e)}function log$1(){if("object"==typeof console&&console.log){isString(arguments[0])&&(arguments[0]="sensors registerProperties————"+arguments[0]);try{return console.log.apply(console,arguments)}catch(e){console.log("sensors registerProperties————",arguments[0])}}}function extend(e){return each(Array.prototype.slice.call(arguments,1),function(t){for(var n in t)void 0!==t[n]&&(e[n]=t[n])}),e}function each(e,t,n){var i=Array.prototype.forEach,s={};if(null==e)return!1;if(i&&e.forEach===i)e.forEach(t,n);else if(e.length===+e.length){for(var r=0,a=e.length;r0&®ister_list.push(e):_.log("参数错误!")},RegisterProperties.hookRegister=function(e){_.isFunction(e)&®ister_list.push(e)};var sa,registerProperties=createPlugin(RegisterProperties),customEventList=[],maxSaveTime=2592e6,latestEventInitialTime=null;function decodeURI(e){var t="";try{t=decodeURIComponent(e)}catch(n){t=e}return t}function getQueryString(e,t){if(e[t])return decodeURI(e[t]);var n=e.scene||"";if(n){var i=decodeURI(n),s=new RegExp("(^|&)"+t+"=([^&]*)(&|$)","i"),r=i.match(s);if(null!==r)return decodeURI(r[2])}return null}function isSatCfLegal(e){return""!==e&&"''"!==e&&'""'!==e}var AdChannel={plugin_name:"ADChannel",init:function(e){if(!(sa=e))return console.log("当前主sdk 初始化失败,请传入正确的 sensors 对象!"),!1;var t=sa.usePlugin(registerProperties);this.eventList.init(),this.listenAppLaunch(),this.addIsChannelCallbackEvent(t)},getChannelQuery:function(e){var t=sa._.deepCopy(e).query;if(sa._.isObject(t)){var n=getQueryString(t,"sat_cf"),i=isSatCfLegal(n);if(n&&i){var s={};e.scene?s.$scene=sa._.getMPScene(e.scene):s.$scene="未取到值";var r=t.scene||"",a="";r&&(a=decodeURI(r),delete t.scene);var o=sa._.setQuery(t);if(a&&(o+=(o?"&":"")+a),e.path){s.$url_path=sa._.getPath(e.path),s.$title=sa._.getPageTitle(e.path);var l=o?"?"+o:"";s.$url=s.$url_path+l}t._sfs&&(s.$sf_source=t._sfs,s.$latest_sf_source=s.$sf_source);var c=sa._.setUtm(e,s);sa._.setLatestChannel(c.pre2),s.$latest_scene=s.$scene,s.$url_query=o,this.trackChannel(s)}}},trackChannel:function(e){sa.track("$ChannelLinkReaching",e),this.setEventQueue()},setEventQueue:function(){var e,t=[];try{for(var n=0;n0&&sa.initialState.queue.splice(e,0,t)}catch(e){sa._.logger.info("渠道插件事件发送排序: "+e)}},addIsChannelCallbackEvent:function(e){var t=this,n=["$MPLaunch","$ABTestTrigger","$PlanPopupDisplay","$PlanPopupClick","$ChannelLinkReaching","$MPShow","$MPHide","$MPViewScreen","$MPClick","$MPShare","$MPAddFavorites","$MPPageLeave","$SignUp","$UnbindID","$BindID"];e.hookRegister(function(e){var i={};if(e&&e.event){var s=e.event,r=!0;n.indexOf(s)<0&&(t.eventList.hasEvent(s)?r=!1:t.eventList.add(s),i.$is_channel_callback_event=r)}return i})},eventList:{init:function(){var e=sa._.getStorageSync("saminiprogramchannel"),t=(new Date).getTime();if(e&&sa._.isNumber(e.latest_event_initial_time)&&sa._.isArray(e.event_list)){var n=t-e.latest_event_initial_time;n>0&&n-1?r>-1?a+o+"#"+l.substring(1,r)+u(l.substring(r,l.length)):a+o+l+"&"+c:a+o+"#"+l.substring(1)+"?"+c):(r=o.indexOf("_sasdk"),s=/^\?(\w)+/.test(o)?r>-1?a+"?"+u(o.substring(1))+l:a+o+"&"+c+l:a+"?"+c+l);return s},h5Linker.init=function(e){e?(this._=e._,this.store=e.store,this.log=e._.logger.info||log,this.is_ready=!0):log("H5Linker plugin initialization failed")},h5Linker.plugin_name="H5Linker";var hasOwnProperty=Object.prototype.hasOwnProperty;function isFunction(e){if(!e)return!1;var t=Object.prototype.toString.call(e);return"[object Function]"==t||"[object AsyncFunction]"==t}function isObject(e){return null!=e&&"[object Object]"==Object.prototype.toString.call(e)}function isString(e){return"[object String]"==toString.call(e)}function log$1(){if("object"==typeof console&&console.log){isString(arguments[0])&&(arguments[0]="sensors registerProperties————"+arguments[0]);try{return console.log.apply(console,arguments)}catch(e){console.log("sensors registerProperties————",arguments[0])}}}function extend(e){return each(Array.prototype.slice.call(arguments,1),function(t){for(var n in t)void 0!==t[n]&&(e[n]=t[n])}),e}function each(e,t,n){var i=Array.prototype.forEach,s={};if(null==e)return!1;if(i&&e.forEach===i)e.forEach(t,n);else if(e.length===+e.length){for(var r=0,a=e.length;r0&®ister_list.push(e):_.log("参数错误!")},RegisterProperties.hookRegister=function(e){_.isFunction(e)&®ister_list.push(e)};var sa,registerProperties=createPlugin(RegisterProperties),customEventList=[],maxSaveTime=2592e6,latestEventInitialTime=null;function decodeURI(e){var t="";try{t=decodeURIComponent(e)}catch(n){t=e}return t}function getQueryString(e,t){if(e[t])return decodeURI(e[t]);var n=e.scene||"";if(n){var i=decodeURI(n),s=new RegExp("(^|&)"+t+"=([^&]*)(&|$)","i"),r=i.match(s);if(null!==r)return decodeURI(r[2])}return null}function isSatCfLegal(e){return""!==e&&"''"!==e&&'""'!==e}var AdChannel={plugin_name:"ADChannel",init:function(e){if(!(sa=e))return console.log("当前主sdk 初始化失败,请传入正确的 sensors 对象!"),!1;var t=sa.usePlugin(registerProperties);this.eventList.init(),this.listenAppLaunch(),this.addIsChannelCallbackEvent(t)},getChannelQuery:function(e){var t=sa._.deepCopy(e).query;if(sa._.isObject(t)){var n=getQueryString(t,"sat_cf"),i=isSatCfLegal(n);if(n&&i){var s={};e.scene?s.$scene=sa._.getMPScene(e.scene):s.$scene="未取到值";var r=t.scene||"",a="";r&&(a=decodeURI(r),delete t.scene);var o=sa._.setQuery(t);if(a&&(o+=(o?"&":"")+a),e.path){s.$url_path=sa._.getPath(e.path),s.$title=sa._.getPageTitle(e.path);var l=o?"?"+o:"";s.$url=s.$url_path+l}t._sfs&&(s.$sf_source=t._sfs,s.$latest_sf_source=s.$sf_source);var c=sa._.setUtm(e,s);sa._.setLatestChannel(c.pre2),s.$latest_scene=s.$scene,s.$url_query=o,this.trackChannel(s)}}},trackChannel:function(e){sa.track("$ChannelLinkReaching",e),this.setEventQueue()},setEventQueue:function(){var e,t=[];try{for(var n=0;n0&&sa.initialState.queue.splice(e,0,t)}catch(e){sa._.logger.info("渠道插件事件发送排序: "+e)}},addIsChannelCallbackEvent:function(e){var t=this,n=["$MPLaunch","$ABTestTrigger","$PlanPopupDisplay","$PlanPopupClick","$ChannelLinkReaching","$MPShow","$MPHide","$MPViewScreen","$MPClick","$MPShare","$MPAddFavorites","$MPPageLeave","$SignUp","$UnbindID","$BindID"];e.hookRegister(function(e){var i={};if(e&&e.event){var s=e.event,r=!0;n.indexOf(s)<0&&(t.eventList.hasEvent(s)?r=!1:t.eventList.add(s),i.$is_channel_callback_event=r)}return i})},eventList:{init:function(){var e=sa._.getStorageSync("saminiprogramchannel"),t=(new Date).getTime();if(e&&sa._.isNumber(e.latest_event_initial_time)&&sa._.isArray(e.event_list)){var n=t-e.latest_event_initial_time;n>0&&n-1?s>-1?a+o+"#"+l.substring(1,s)+u(l.substring(s,l.length)):a+o+l+"&"+c:a+o+"#"+l.substring(1)+"?"+c):(s=o.indexOf("_sasdk"),r=/^\?(\w)+/.test(o)?s>-1?a+"?"+u(o.substring(1))+l:a+o+"&"+c+l:a+"?"+c+l);return r},h5Linker.init=function(e){e?(this._=e._,this.store=e.store,this.log=e._.logger.info||log,this.is_ready=!0):log("H5Linker plugin initialization failed")},h5Linker.plugin_name="H5Linker";var hasOwnProperty=Object.prototype.hasOwnProperty;function isFunction(e){if(!e)return!1;var t=Object.prototype.toString.call(e);return"[object Function]"==t||"[object AsyncFunction]"==t}function isObject(e){return null!=e&&"[object Object]"==Object.prototype.toString.call(e)}function isString(e){return"[object String]"==toString.call(e)}function log$1(){if("object"==typeof console&&console.log){isString(arguments[0])&&(arguments[0]="sensors registerProperties————"+arguments[0]);try{return console.log.apply(console,arguments)}catch(e){console.log("sensors registerProperties————",arguments[0])}}}function extend(e){return each(Array.prototype.slice.call(arguments,1),function(t){for(var n in t)void 0!==t[n]&&(e[n]=t[n])}),e}function each(e,t,n){var i=Array.prototype.forEach,r={};if(null==e)return!1;if(i&&e.forEach===i)e.forEach(t,n);else if(e.length===+e.length){for(var s=0,a=e.length;s0&®ister_list.push(e):_.log("参数错误!")},RegisterProperties.hookRegister=function(e){_.isFunction(e)&®ister_list.push(e)};var sa,registerProperties=createPlugin(RegisterProperties),customEventList=[],maxSaveTime=2592e6,latestEventInitialTime=null;function decodeURI(e){var t="";try{t=decodeURIComponent(e)}catch(n){t=e}return t}function getQueryString(e,t){if(e[t])return decodeURI(e[t]);var n=e.scene||"";if(n){var i=decodeURI(n),r=new RegExp("(^|&)"+t+"=([^&]*)(&|$)","i"),s=i.match(r);if(null!==s)return decodeURI(s[2])}return null}function isSatCfLegal(e){return""!==e&&"''"!==e&&'""'!==e}var AdChannel={plugin_name:"ADChannel",init:function(e){if(!(sa=e))return console.log("当前主sdk 初始化失败,请传入正确的 sensors 对象!"),!1;var t=sa.usePlugin(registerProperties);this.eventList.init(),this.listenAppLaunch(),this.addIsChannelCallbackEvent(t)},getChannelQuery:function(e){var t=sa._.deepCopy(e).query;if(sa._.isObject(t)){var n=getQueryString(t,"sat_cf"),i=isSatCfLegal(n);if(n&&i){var r={};e.scene?r.$scene=sa._.getMPScene(e.scene):r.$scene="未取到值";var s=t.scene||"",a="";s&&(a=decodeURI(s),delete t.scene);var o=sa._.setQuery(t);if(a&&(o+=(o?"&":"")+a),e.path){r.$url_path=sa._.getPath(e.path),r.$title=sa._.getPageTitle(e.path);var l=o?"?"+o:"";r.$url=r.$url_path+l}t._sfs&&(r.$sf_source=t._sfs,r.$latest_sf_source=r.$sf_source);var c=sa._.setUtm(e,r);sa._.setLatestChannel(c.pre2),r.$latest_scene=r.$scene,r.$url_query=o,this.trackChannel(r)}}},trackChannel:function(e){sa.track("$ChannelLinkReaching",e),this.setEventQueue()},setEventQueue:function(){var e,t=[];try{for(var n=0;n0&&sa.initialState.queue.splice(e,0,t)}catch(e){sa._.logger.info("渠道插件事件发送排序: "+e)}},addIsChannelCallbackEvent:function(e){var t=this,n=["$MPLaunch","$ABTestTrigger","$PlanPopupDisplay","$PlanPopupClick","$ChannelLinkReaching","$MPShow","$MPHide","$MPViewScreen","$MPClick","$MPShare","$MPAddFavorites","$MPPageLeave","$SignUp","$UnbindID","$BindID"];e.hookRegister(function(e){var i={};if(e&&e.event){var r=e.event,s=!0;n.indexOf(r)<0&&(t.eventList.hasEvent(r)?s=!1:t.eventList.add(r),i.$is_channel_callback_event=s)}return i})},eventList:{init:function(){var e=sa._.getStorageSync("saminiprogramchannel"),t=(new Date).getTime();if(e&&sa._.isNumber(e.latest_event_initial_time)&&sa._.isArray(e.event_list)){var n=t-e.latest_event_initial_time;n>0&&n-1?s>-1?a+o+"#"+l.substring(1,s)+u(l.substring(s,l.length)):a+o+l+"&"+c:a+o+"#"+l.substring(1)+"?"+c):(s=o.indexOf("_sasdk"),r=/^\?(\w)+/.test(o)?s>-1?a+"?"+u(o.substring(1))+l:a+o+"&"+c+l:a+"?"+c+l);return r},h5Linker.init=function(e){e?(this._=e._,this.store=e.store,this.log=e._.logger.info||log,this.is_ready=!0):log("H5Linker plugin initialization failed")},h5Linker.plugin_name="H5Linker";var hasOwnProperty=Object.prototype.hasOwnProperty;function isFunction(e){if(!e)return!1;var t=Object.prototype.toString.call(e);return"[object Function]"==t||"[object AsyncFunction]"==t}function isObject(e){return null!=e&&"[object Object]"==Object.prototype.toString.call(e)}function isString(e){return"[object String]"==toString.call(e)}function log$1(){if("object"==typeof console&&console.log){isString(arguments[0])&&(arguments[0]="sensors registerProperties————"+arguments[0]);try{return console.log.apply(console,arguments)}catch(e){console.log("sensors registerProperties————",arguments[0])}}}function extend(e){return each(Array.prototype.slice.call(arguments,1),function(t){for(var n in t)void 0!==t[n]&&(e[n]=t[n])}),e}function each(e,t,n){var i=Array.prototype.forEach,r={};if(null==e)return!1;if(i&&e.forEach===i)e.forEach(t,n);else if(e.length===+e.length){for(var s=0,a=e.length;s0&®ister_list.push(e):_.log("参数错误!")},RegisterProperties.hookRegister=function(e){_.isFunction(e)&®ister_list.push(e)};var sa,registerProperties=createPlugin(RegisterProperties),customEventList=[],maxSaveTime=2592e6,latestEventInitialTime=null;function decodeURI(e){var t="";try{t=decodeURIComponent(e)}catch(n){t=e}return t}function getQueryString(e,t){if(e[t])return decodeURI(e[t]);var n=e.scene||"";if(n){var i=decodeURI(n),r=new RegExp("(^|&)"+t+"=([^&]*)(&|$)","i"),s=i.match(r);if(null!==s)return decodeURI(s[2])}return null}function isSatCfLegal(e){return""!==e&&"''"!==e&&'""'!==e}var AdChannel={plugin_name:"ADChannel",init:function(e){if(!(sa=e))return console.log("当前主sdk 初始化失败,请传入正确的 sensors 对象!"),!1;var t=sa.usePlugin(registerProperties);this.eventList.init(),this.listenAppLaunch(),this.addIsChannelCallbackEvent(t)},getChannelQuery:function(e){var t=sa._.deepCopy(e).query;if(sa._.isObject(t)){var n=getQueryString(t,"sat_cf"),i=isSatCfLegal(n);if(n&&i){var r={};e.scene?r.$scene=sa._.getMPScene(e.scene):r.$scene="未取到值";var s=t.scene||"",a="";s&&(a=decodeURI(s),delete t.scene);var o=sa._.setQuery(t);if(a&&(o+=(o?"&":"")+a),e.path){r.$url_path=sa._.getPath(e.path),r.$title=sa._.getPageTitle(e.path);var l=o?"?"+o:"";r.$url=r.$url_path+l}t._sfs&&(r.$sf_source=t._sfs,r.$latest_sf_source=r.$sf_source);var c=sa._.setUtm(e,r);sa._.setLatestChannel(c.pre2),r.$latest_scene=r.$scene,r.$url_query=o,this.trackChannel(r)}}},trackChannel:function(e){sa.track("$ChannelLinkReaching",e),this.setEventQueue()},setEventQueue:function(){var e,t=[];try{for(var n=0;n0&&sa.initialState.queue.splice(e,0,t)}catch(e){sa._.logger.info("渠道插件事件发送排序: "+e)}},addIsChannelCallbackEvent:function(e){var t=this,n=["$MPLaunch","$ABTestTrigger","$PlanPopupDisplay","$PlanPopupClick","$ChannelLinkReaching","$MPShow","$MPHide","$MPViewScreen","$MPClick","$MPShare","$MPAddFavorites","$MPPageLeave","$SignUp","$UnbindID","$BindID"];e.hookRegister(function(e){var i={};if(e&&e.event){var r=e.event,s=!0;n.indexOf(r)<0&&(t.eventList.hasEvent(r)?s=!1:t.eventList.add(r),i.$is_channel_callback_event=s)}return i})},eventList:{init:function(){var e=sa._.getStorageSync("saminiprogramchannel"),t=(new Date).getTime();if(e&&sa._.isNumber(e.latest_event_initial_time)&&sa._.isArray(e.event_list)){var n=t-e.latest_event_initial_time;n>0&&n0&®ister_list.push(e):_.log("参数错误!")},RegisterProperties.hookRegister=function(e){_.isFunction(e)&®ister_list.push(e)};var sa,registerProperties=createPlugin(RegisterProperties),customEventList=[],maxSaveTime=2592e6,latestEventInitialTime=null;function decodeURI(e){var t="";try{t=decodeURIComponent(e)}catch(n){t=e}return t}function getQueryString(e,t){if(e[t])return decodeURI(e[t]);var n=e.scene||"";if(n){var i=decodeURI(n),r=new RegExp("(^|&)"+t+"=([^&]*)(&|$)","i"),s=i.match(r);if(null!==s)return decodeURI(s[2])}return null}function isSatCfLegal(e){return""!==e&&"''"!==e&&'""'!==e}var AdChannel={plugin_name:"ADChannel",init:function(e){if(!(sa=e))return console.log("当前主sdk 初始化失败,请传入正确的 sensors 对象!"),!1;var t=sa.usePlugin(registerProperties);this.eventList.init(),this.listenAppLaunch(),this.addIsChannelCallbackEvent(t)},getChannelQuery:function(e){var t=sa._.deepCopy(e).query;if(sa._.isObject(t)){var n=getQueryString(t,"sat_cf"),i=isSatCfLegal(n);if(n&&i){var r={};e.scene?r.$scene=sa._.getMPScene(e.scene):r.$scene="未取到值";var s=t.scene||"",a="";s&&(a=decodeURI(s),delete t.scene);var o=sa._.setQuery(t);if(a&&(o+=(o?"&":"")+a),e.path){r.$url_path=sa._.getPath(e.path),r.$title=sa._.getPageTitle(e.path);var c=o?"?"+o:"";r.$url=r.$url_path+c}t._sfs&&(r.$sf_source=t._sfs,r.$latest_sf_source=r.$sf_source);var l=sa._.setUtm(e,r);sa._.setLatestChannel(l.pre2),r.$latest_scene=r.$scene,r.$url_query=o,this.trackChannel(r)}}},trackChannel:function(e){sa.track("$ChannelLinkReaching",e),this.setEventQueue()},setEventQueue:function(){var e,t=[];try{for(var n=0;n0&&sa.initialState.queue.splice(e,0,t)}catch(e){sa._.logger.info("渠道插件事件发送排序: "+e)}},addIsChannelCallbackEvent:function(e){var t=this,n=["$MPLaunch","$ABTestTrigger","$PlanPopupDisplay","$PlanPopupClick","$ChannelLinkReaching","$MPShow","$MPHide","$MPViewScreen","$MPClick","$MPShare","$MPAddFavorites","$MPPageLeave","$SignUp","$UnbindID","$BindID"];e.hookRegister(function(e){var i={};if(e&&e.event){var r=e.event,s=!0;n.indexOf(r)<0&&(t.eventList.hasEvent(r)?s=!1:t.eventList.add(r),i.$is_channel_callback_event=s)}return i})},eventList:{init:function(){var e=sa._.getStorageSync("saminiprogramchannel"),t=(new Date).getTime();if(e&&sa._.isNumber(e.latest_event_initial_time)&&sa._.isArray(e.event_list)){var n=t-e.latest_event_initial_time;n>0&&n0&®ister_list.push(e):_.log("参数错误!")},RegisterProperties.hookRegister=function(e){_.isFunction(e)&®ister_list.push(e)};var sa,registerProperties=createPlugin(RegisterProperties),customEventList=[],maxSaveTime=2592e6,latestEventInitialTime=null;function decodeURI(e){var t="";try{t=decodeURIComponent(e)}catch(n){t=e}return t}function getQueryString(e,t){if(e[t])return decodeURI(e[t]);var n=e.scene||"";if(n){var i=decodeURI(n),r=new RegExp("(^|&)"+t+"=([^&]*)(&|$)","i"),s=i.match(r);if(null!==s)return decodeURI(s[2])}return null}function isSatCfLegal(e){return""!==e&&"''"!==e&&'""'!==e}var AdChannel={plugin_name:"ADChannel",init:function(e){if(!(sa=e))return console.log("当前主sdk 初始化失败,请传入正确的 sensors 对象!"),!1;var t=sa.usePlugin(registerProperties);this.eventList.init(),this.listenAppLaunch(),this.addIsChannelCallbackEvent(t)},getChannelQuery:function(e){var t=sa._.deepCopy(e).query;if(sa._.isObject(t)){var n=getQueryString(t,"sat_cf"),i=isSatCfLegal(n);if(n&&i){var r={};e.scene?r.$scene=sa._.getMPScene(e.scene):r.$scene="未取到值";var s=t.scene||"",a="";s&&(a=decodeURI(s),delete t.scene);var o=sa._.setQuery(t);if(a&&(o+=(o?"&":"")+a),e.path){r.$url_path=sa._.getPath(e.path),r.$title=sa._.getPageTitle(e.path);var c=o?"?"+o:"";r.$url=r.$url_path+c}t._sfs&&(r.$sf_source=t._sfs,r.$latest_sf_source=r.$sf_source);var l=sa._.setUtm(e,r);sa._.setLatestChannel(l.pre2),r.$latest_scene=r.$scene,r.$url_query=o,this.trackChannel(r)}}},trackChannel:function(e){sa.track("$ChannelLinkReaching",e),this.setEventQueue()},setEventQueue:function(){var e,t=[];try{for(var n=0;n0&&sa.initialState.queue.splice(e,0,t)}catch(e){sa._.logger.info("渠道插件事件发送排序: "+e)}},addIsChannelCallbackEvent:function(e){var t=this,n=["$MPLaunch","$ABTestTrigger","$PlanPopupDisplay","$PlanPopupClick","$ChannelLinkReaching","$MPShow","$MPHide","$MPViewScreen","$MPClick","$MPShare","$MPAddFavorites","$MPPageLeave","$SignUp","$UnbindID","$BindID"];e.hookRegister(function(e){var i={};if(e&&e.event){var r=e.event,s=!0;n.indexOf(r)<0&&(t.eventList.hasEvent(r)?s=!1:t.eventList.add(r),i.$is_channel_callback_event=s)}return i})},eventList:{init:function(){var e=sa._.getStorageSync("saminiprogramchannel"),t=(new Date).getTime();if(e&&sa._.isNumber(e.latest_event_initial_time)&&sa._.isArray(e.event_list)){var n=t-e.latest_event_initial_time;n>0&&n0&®ister_list.push(e):_.log("参数错误!")},RegisterProperties.hookRegister=function(e){_.isFunction(e)&®ister_list.push(e)};var sa,registerProperties=createPlugin(RegisterProperties),customEventList=[],maxSaveTime=2592e6,latestEventInitialTime=null;function decodeURI(e){var t="";try{t=decodeURIComponent(e)}catch(n){t=e}return t}function getQueryString(e,t){if(e[t])return decodeURI(e[t]);var n=e.scene||"";if(n){var i=decodeURI(n),r=new RegExp("(^|&)"+t+"=([^&]*)(&|$)","i"),s=i.match(r);if(null!==s)return decodeURI(s[2])}return null}function isSatCfLegal(e){return""!==e&&"''"!==e&&'""'!==e}var AdChannel={plugin_name:"ADChannel",init:function(e){if(!(sa=e))return console.log("当前主sdk 初始化失败,请传入正确的 sensors 对象!"),!1;var t=sa.usePlugin(registerProperties);this.eventList.init(),this.listenAppLaunch(),this.addIsChannelCallbackEvent(t)},getChannelQuery:function(e){var t=sa._.deepCopy(e).query;if(sa._.isObject(t)){var n=getQueryString(t,"sat_cf"),i=isSatCfLegal(n);if(n&&i){var r={};e.scene?r.$scene=sa._.getMPScene(e.scene):r.$scene="未取到值";var s=t.scene||"",a="";s&&(a=decodeURI(s),delete t.scene);var o=sa._.setQuery(t);if(a&&(o+=(o?"&":"")+a),e.path){r.$url_path=sa._.getPath(e.path),r.$title=sa._.getPageTitle(e.path);var c=o?"?"+o:"";r.$url=r.$url_path+c}t._sfs&&(r.$sf_source=t._sfs,r.$latest_sf_source=r.$sf_source);var l=sa._.setUtm(e,r);sa._.setLatestChannel(l.pre2),r.$latest_scene=r.$scene,r.$url_query=o,this.trackChannel(r)}}},trackChannel:function(e){sa.track("$ChannelLinkReaching",e),this.setEventQueue()},setEventQueue:function(){var e,t=[];try{for(var n=0;n0&&sa.initialState.queue.splice(e,0,t)}catch(e){sa._.logger.info("渠道插件事件发送排序: "+e)}},addIsChannelCallbackEvent:function(e){var t=this,n=["$MPLaunch","$ABTestTrigger","$PlanPopupDisplay","$PlanPopupClick","$ChannelLinkReaching","$MPShow","$MPHide","$MPViewScreen","$MPClick","$MPShare","$MPAddFavorites","$MPPageLeave","$SignUp","$UnbindID","$BindID"];e.hookRegister(function(e){var i={};if(e&&e.event){var r=e.event,s=!0;n.indexOf(r)<0&&(t.eventList.hasEvent(r)?s=!1:t.eventList.add(r),i.$is_channel_callback_event=s)}return i})},eventList:{init:function(){var e=sa._.getStorageSync("saminiprogramchannel"),t=(new Date).getTime();if(e&&sa._.isNumber(e.latest_event_initial_time)&&sa._.isArray(e.event_list)){var n=t-e.latest_event_initial_time;n>0&&n0&®ister_list.push(e):_.log("参数错误!")},RegisterProperties.hookRegister=function(e){_.isFunction(e)&®ister_list.push(e)};var sa,registerProperties=createPlugin(RegisterProperties),customEventList=[],maxSaveTime=2592e6,latestEventInitialTime=null;function decodeURI(e){var t="";try{t=decodeURIComponent(e)}catch(n){t=e}return t}function getQueryString(e,t){if(e[t])return decodeURI(e[t]);var n=e.scene||"";if(n){var i=decodeURI(n),r=new RegExp("(^|&)"+t+"=([^&]*)(&|$)","i"),s=i.match(r);if(null!==s)return decodeURI(s[2])}return null}function isSatCfLegal(e){return""!==e&&"''"!==e&&'""'!==e}var AdChannel={plugin_name:"ADChannel",init:function(e){if(!(sa=e))return console.log("当前主sdk 初始化失败,请传入正确的 sensors 对象!"),!1;var t=sa.usePlugin(registerProperties);this.eventList.init(),this.listenAppLaunch(),this.addIsChannelCallbackEvent(t)},getChannelQuery:function(e){var t=sa._.deepCopy(e).query;if(sa._.isObject(t)){var n=getQueryString(t,"sat_cf"),i=isSatCfLegal(n);if(n&&i){var r={};e.scene?r.$scene=sa._.getMPScene(e.scene):r.$scene="未取到值";var s=t.scene||"",a="";s&&(a=decodeURI(s),delete t.scene);var o=sa._.setQuery(t);if(a&&(o+=(o?"&":"")+a),e.path){r.$url_path=sa._.getPath(e.path),r.$title=sa._.getPageTitle(e.path);var c=o?"?"+o:"";r.$url=r.$url_path+c}t._sfs&&(r.$sf_source=t._sfs,r.$latest_sf_source=r.$sf_source);var l=sa._.setUtm(e,r);sa._.setLatestChannel(l.pre2),r.$latest_scene=r.$scene,r.$url_query=o,this.trackChannel(r)}}},trackChannel:function(e){sa.track("$ChannelLinkReaching",e),this.setEventQueue()},setEventQueue:function(){var e,t=[];try{for(var n=0;n0&&sa.initialState.queue.splice(e,0,t)}catch(e){sa._.logger.info("渠道插件事件发送排序: "+e)}},addIsChannelCallbackEvent:function(e){var t=this,n=["$MPLaunch","$ABTestTrigger","$PlanPopupDisplay","$PlanPopupClick","$ChannelLinkReaching","$MPShow","$MPHide","$MPViewScreen","$MPClick","$MPShare","$MPAddFavorites","$MPPageLeave","$SignUp","$UnbindID","$BindID"];e.hookRegister(function(e){var i={};if(e&&e.event){var r=e.event,s=!0;n.indexOf(r)<0&&(t.eventList.hasEvent(r)?s=!1:t.eventList.add(r),i.$is_channel_callback_event=s)}return i})},eventList:{init:function(){var e=sa._.getStorageSync("saminiprogramchannel"),t=(new Date).getTime();if(e&&sa._.isNumber(e.latest_event_initial_time)&&sa._.isArray(e.event_list)){var n=t-e.latest_event_initial_time;n>0&&n>>2]>>>24-o%4*8&255;e[n+o>>>2]|=a<<24-(n+o)%4*8}else for(var c=0;c>>2]=r[c>>>2];return this.sigBytes+=i,this},clamp:function(){var e=this.words,r=this.sigBytes;e[r>>>2]&=4294967295<<32-r%4*8,e.length=t.ceil(r/4)},clone:function(){var t=c.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],r=0;r>>2]>>>24-i%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n>>3]|=parseInt(t.substr(n,2),16)<<24-n%8*4;return new s.init(r,e/2)}},p=u.Latin1={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],i=0;i>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(o))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;return new s.init(r,e)}},h=u.Utf8={stringify:function(t){try{return decodeURIComponent(escape(p.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return p.parse(unescape(encodeURIComponent(t)))}},d=a.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=h.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var r,n=this._data,i=n.words,o=n.sigBytes,a=this.blockSize,c=o/(4*a),u=(c=e?t.ceil(c):t.max((0|c)-this._minBufferSize,0))*a,f=t.min(4*u,o);if(u){for(var p=0;p>>24)|4278255360&(i<<24|i>>>8)}var o=this._hash.words,c=t[e+0],h=t[e+1],d=t[e+2],l=t[e+3],y=t[e+4],_=t[e+5],g=t[e+6],v=t[e+7],S=t[e+8],m=t[e+9],k=t[e+10],C=t[e+11],B=t[e+12],x=t[e+13],D=t[e+14],w=t[e+15],b=o[0],E=o[1],z=o[2],J=o[3];b=s(b,E,z,J,c,7,a[0]),J=s(J,b,E,z,h,12,a[1]),z=s(z,J,b,E,d,17,a[2]),E=s(E,z,J,b,l,22,a[3]),b=s(b,E,z,J,y,7,a[4]),J=s(J,b,E,z,_,12,a[5]),z=s(z,J,b,E,g,17,a[6]),E=s(E,z,J,b,v,22,a[7]),b=s(b,E,z,J,S,7,a[8]),J=s(J,b,E,z,m,12,a[9]),z=s(z,J,b,E,k,17,a[10]),E=s(E,z,J,b,C,22,a[11]),b=s(b,E,z,J,B,7,a[12]),J=s(J,b,E,z,x,12,a[13]),z=s(z,J,b,E,D,17,a[14]),b=u(b,E=s(E,z,J,b,w,22,a[15]),z,J,h,5,a[16]),J=u(J,b,E,z,g,9,a[17]),z=u(z,J,b,E,C,14,a[18]),E=u(E,z,J,b,c,20,a[19]),b=u(b,E,z,J,_,5,a[20]),J=u(J,b,E,z,k,9,a[21]),z=u(z,J,b,E,w,14,a[22]),E=u(E,z,J,b,y,20,a[23]),b=u(b,E,z,J,m,5,a[24]),J=u(J,b,E,z,D,9,a[25]),z=u(z,J,b,E,l,14,a[26]),E=u(E,z,J,b,S,20,a[27]),b=u(b,E,z,J,x,5,a[28]),J=u(J,b,E,z,d,9,a[29]),z=u(z,J,b,E,v,14,a[30]),b=f(b,E=u(E,z,J,b,B,20,a[31]),z,J,_,4,a[32]),J=f(J,b,E,z,S,11,a[33]),z=f(z,J,b,E,C,16,a[34]),E=f(E,z,J,b,D,23,a[35]),b=f(b,E,z,J,h,4,a[36]),J=f(J,b,E,z,y,11,a[37]),z=f(z,J,b,E,v,16,a[38]),E=f(E,z,J,b,k,23,a[39]),b=f(b,E,z,J,x,4,a[40]),J=f(J,b,E,z,c,11,a[41]),z=f(z,J,b,E,l,16,a[42]),E=f(E,z,J,b,g,23,a[43]),b=f(b,E,z,J,m,4,a[44]),J=f(J,b,E,z,B,11,a[45]),z=f(z,J,b,E,w,16,a[46]),b=p(b,E=f(E,z,J,b,d,23,a[47]),z,J,c,6,a[48]),J=p(J,b,E,z,v,10,a[49]),z=p(z,J,b,E,D,15,a[50]),E=p(E,z,J,b,_,21,a[51]),b=p(b,E,z,J,B,6,a[52]),J=p(J,b,E,z,l,10,a[53]),z=p(z,J,b,E,k,15,a[54]),E=p(E,z,J,b,h,21,a[55]),b=p(b,E,z,J,S,6,a[56]),J=p(J,b,E,z,w,10,a[57]),z=p(z,J,b,E,g,15,a[58]),E=p(E,z,J,b,x,21,a[59]),b=p(b,E,z,J,y,6,a[60]),J=p(J,b,E,z,C,10,a[61]),z=p(z,J,b,E,d,15,a[62]),E=p(E,z,J,b,m,21,a[63]),o[0]=o[0]+b|0,o[1]=o[1]+E|0,o[2]=o[2]+z|0,o[3]=o[3]+J|0},_doFinalize:function(){var e=this._data,r=e.words,n=8*this._nDataBytes,i=8*e.sigBytes;r[i>>>5]|=128<<24-i%32;var o=t.floor(n/4294967296),a=n;r[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),r[14+(i+64>>>9<<4)]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),e.sigBytes=4*(r.length+1),this._process();for(var c=this._hash,s=c.words,u=0;u<4;u++){var f=s[u];s[u]=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8)}return c},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});function s(t,e,r,n,i,o,a){var c=t+(e&r|~e&n)+i+a;return(c<>>32-o)+e}function u(t,e,r,n,i,o,a){var c=t+(e&n|r&~n)+i+a;return(c<>>32-o)+e}function f(t,e,r,n,i,o,a){var c=t+(e^r^n)+i+a;return(c<>>32-o)+e}function p(t,e,r,n,i,o,a){var c=t+(r^(e|~n))+i+a;return(c<>>32-o)+e}e.MD5=i._createHelper(c),e.HmacMD5=i._createHmacHelper(c)}(Math),function(){var t=_CryptoJS.CryptoJS,e=t.lib,r=e.Base,n=e.WordArray,i=t.algo,o=i.MD5,a=i.EvpKDF=r.extend({cfg:r.extend({keySize:4,hasher:o,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){for(var r,i=this.cfg,o=i.hasher.create(),a=n.create(),c=a.words,s=i.keySize,u=i.iterations;c.length>>2]>>>24-o%4*8&255)<<16|(e[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|e[o+2>>>2]>>>24-(o+2)%4*8&255,c=0;c<4&&o+.75*c>>6*(3-c)&63));var s=n.charAt(64);if(s)for(;i.length%4;)i.push(s);return i.join("")},parse:function(t){var r=t.length,n=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var o=0;o>>6-a%4*2,u=c|s;i[o>>>2]|=u<<24-o%4*8,o++}return e.create(i,o)}(t,r,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),_CryptoJS.CryptoJS.lib.Cipher||function(t){var e=_CryptoJS.CryptoJS,r=e.lib,n=r.Base,i=r.WordArray,o=r.BufferedBlockAlgorithm,a=e.enc,c=(a.Utf8,a.Base64),s=e.algo.EvpKDF,u=r.Cipher=o.extend({cfg:n.extend(),createEncryptor:function(t,e){return this.create(this._ENC_XFORM_MODE,t,e)},createDecryptor:function(t,e){return this.create(this._DEC_XFORM_MODE,t,e)},init:function(t,e,r){this.cfg=this.cfg.extend(r),this._xformMode=t,this._key=e,this.reset()},reset:function(){o.reset.call(this),this._doReset()},process:function(t){return this._append(t),this._process()},finalize:function(t){return t&&this._append(t),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function t(t){return"string"==typeof t?v:_}return function(e){return{encrypt:function(r,n,i){return t(n).encrypt(e,r,n,i)},decrypt:function(r,n,i){return t(n).decrypt(e,r,n,i)}}}}()}),f=(r.StreamCipher=u.extend({_doFinalize:function(){return this._process(!0)},blockSize:1}),e.mode={}),p=r.BlockCipherMode=n.extend({createEncryptor:function(t,e){return this.Encryptor.create(t,e)},createDecryptor:function(t,e){return this.Decryptor.create(t,e)},init:function(t,e){this._cipher=t,this._iv=e}}),h=f.CBC=function(){var e=p.extend();function r(e,r,n){var i,o=this._iv;o?(i=o,this._iv=t):i=this._prevBlock;for(var a=0;a>>2];t.sigBytes-=e}},l=(r.BlockCipher=u.extend({cfg:u.cfg.extend({mode:h,padding:d}),reset:function(){var t;u.reset.call(this);var e=this.cfg,r=e.iv,n=e.mode;this._xformMode==this._ENC_XFORM_MODE?t=n.createEncryptor:(t=n.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==t?this._mode.init(this,r&&r.words):(this._mode=t.call(n,this,r&&r.words),this._mode.__creator=t)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t,e=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(e.pad(this._data,this.blockSize),t=this._process(!0)):(t=this._process(!0),e.unpad(t)),t},blockSize:4}),r.CipherParams=n.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}})),y=(e.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext,r=t.salt;return(r?i.create([1398893684,1701076831]).concat(r).concat(e):e).toString(c)},parse:function(t){var e,r=c.parse(t),n=r.words;return 1398893684==n[0]&&1701076831==n[1]&&(e=i.create(n.slice(2,4)),n.splice(0,4),r.sigBytes-=16),l.create({ciphertext:r,salt:e})}},_=r.SerializableCipher=n.extend({cfg:n.extend({format:y}),encrypt:function(t,e,r,n){n=this.cfg.extend(n);var i=t.createEncryptor(r,n),o=i.finalize(e),a=i.cfg;return l.create({ciphertext:o,key:r,iv:a.iv,algorithm:t,mode:a.mode,padding:a.padding,blockSize:t.blockSize,formatter:n.format})},decrypt:function(t,e,r,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),t.createDecryptor(r,n).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}}),g=(e.kdf={}).OpenSSL={execute:function(t,e,r,n){n||(n=i.random(8));var o=s.create({keySize:e+r}).compute(t,n),a=i.create(o.words.slice(e),4*r);return o.sigBytes=4*e,l.create({key:o,iv:a,salt:n})}},v=r.PasswordBasedCipher=_.extend({cfg:_.cfg.extend({kdf:g}),encrypt:function(t,e,r,n){var i=(n=this.cfg.extend(n)).kdf.execute(r,t.keySize,t.ivSize);n.iv=i.iv;var o=_.encrypt.call(this,t,e,i.key,n);return o.mixIn(i),o},decrypt:function(t,e,r,n){n=this.cfg.extend(n),e=this._parse(e,n.format);var i=n.kdf.execute(r,t.keySize,t.ivSize,e.salt);return n.iv=i.iv,_.decrypt.call(this,t,e,i.key,n)}})}(),function(){var t=_CryptoJS.CryptoJS,e=t.lib.BlockCipher,r=t.algo,n=[],i=[],o=[],a=[],c=[],s=[],u=[],f=[],p=[],h=[];!function(){for(var t=[],e=0;e<256;e++)t[e]=e<128?e<<1:e<<1^283;var r=0,d=0;for(e=0;e<256;e++){var l=d^d<<1^d<<2^d<<3^d<<4;l=l>>>8^255&l^99,n[r]=l,i[l]=r;var y=t[r],_=t[y],g=t[_],v=257*t[l]^16843008*l;o[r]=v<<24|v>>>8,a[r]=v<<16|v>>>16,c[r]=v<<8|v>>>24,s[r]=v;v=16843009*g^65537*_^257*y^16843008*r;u[l]=v<<24|v>>>8,f[l]=v<<16|v>>>16,p[l]=v<<8|v>>>24,h[l]=v,r?(r=y^t[t[t[g^y]]],d^=t[t[d]]):r=d=1}}();var d=[0,1,2,4,8,16,32,64,128,27,54],l=r.AES=e.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var t=this._keyPriorReset=this._key,e=t.words,r=t.sigBytes/4,i=4*((this._nRounds=r+6)+1),o=this._keySchedule=[],a=0;a6&&a%r==4&&(l=n[l>>>24]<<24|n[l>>>16&255]<<16|n[l>>>8&255]<<8|n[255&l]):(l=n[(l=l<<8|l>>>24)>>>24]<<24|n[l>>>16&255]<<16|n[l>>>8&255]<<8|n[255&l],l^=d[a/r|0]<<24),o[a]=o[a-r]^l);for(var c=this._invKeySchedule=[],s=0;s>>24]]^f[n[l>>>16&255]]^p[n[l>>>8&255]]^h[n[255&l]]}}},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,o,a,c,s,n)},decryptBlock:function(t,e){var r=t[e+1];t[e+1]=t[e+3],t[e+3]=r,this._doCryptBlock(t,e,this._invKeySchedule,u,f,p,h,i);r=t[e+1];t[e+1]=t[e+3],t[e+3]=r},_doCryptBlock:function(t,e,r,n,i,o,a,c){for(var s=this._nRounds,u=t[e]^r[0],f=t[e+1]^r[1],p=t[e+2]^r[2],h=t[e+3]^r[3],d=4,l=1;l>>24]^i[f>>>16&255]^o[p>>>8&255]^a[255&h]^r[d++],_=n[f>>>24]^i[p>>>16&255]^o[h>>>8&255]^a[255&u]^r[d++],g=n[p>>>24]^i[h>>>16&255]^o[u>>>8&255]^a[255&f]^r[d++],v=n[h>>>24]^i[u>>>16&255]^o[f>>>8&255]^a[255&p]^r[d++];u=y,f=_,p=g,h=v}y=(c[u>>>24]<<24|c[f>>>16&255]<<16|c[p>>>8&255]<<8|c[255&h])^r[d++],_=(c[f>>>24]<<24|c[p>>>16&255]<<16|c[h>>>8&255]<<8|c[255&u])^r[d++],g=(c[p>>>24]<<24|c[h>>>16&255]<<16|c[u>>>8&255]<<8|c[255&f])^r[d++],v=(c[h>>>24]<<24|c[u>>>16&255]<<16|c[f>>>8&255]<<8|c[255&p])^r[d++];t[e]=y,t[e+1]=_,t[e+2]=g,t[e+3]=v},keySize:8});t.AES=e._createHelper(l)}();var _iv,_sa,_config,_oldOnceData,CryptoJS=_CryptoJS.CryptoJS,getRandomBasic=function(){var t=(new Date).getTime();return function(e){return Math.ceil((t=(9301*t+49297)%233280)/233280*e)}}();function isObject(t){return null!=t&&"[object Object]"==toString.call(t)}function getRandom(){if("function"==typeof Uint32Array){var t="";if("undefined"!=typeof crypto?t=crypto:"undefined"!=typeof msCrypto&&(t=msCrypto),isObject(t)&&t.getRandomValues){var e=new Uint32Array(1);return t.getRandomValues(e)[0]/Math.pow(2,32)}}return getRandomBasic(1e19)/1e19}function buildAESOption(t){return{mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7,iv:t||generateIVData()}}function encryptData(t,e,r,n){var i=buildAESOption(r),o=t;"string"!=typeof t&&(o=JSON.stringify(t)),n||(e=CryptoJS.enc.Base64.parse(e));var a=CryptoJS.enc.Utf8.parse(o),c=CryptoJS.AES.encrypt(a,e,i).toString();return i.iv.clone().concat(CryptoJS.enc.Base64.parse(c)).toString(CryptoJS.enc.Base64)}function decryptData(t,e,r){var n=CryptoJS.enc.Base64.parse(t).toString(),i=n.substr(0,32),o=CryptoJS.enc.Hex.parse(n.substr(32)).toString(CryptoJS.enc.Base64),a=buildAESOption(CryptoJS.enc.Hex.parse(i));return r||(e=CryptoJS.enc.Base64.parse(e)),CryptoJS.AES.decrypt(o,e,a).toString(CryptoJS.enc.Utf8)}function generateIVData(t){t=t||16;for(var e="";t-- >0;){var r=Math.ceil(127*getRandom()).toString(16);e+=2===r.length?r:"0"+r}return CryptoJS.enc.Hex.parse(e)}var _log=console&&console.log||function(){};function isTruthy(t,e){return!!t||(_log(e+"不能为空。"),!1)}function matchType(t,e,r){return typeof t===r||(_log("参数类型错误,"+e+"必须为"+r),!1)}function aesEncrypt(t){try{return encryptData(t,_config.k,_iv)}catch(e){return _log("数据加密异常:"+e),_sa.para.batch_send?"":_oldOnceData.call(_sa.kit,t)}}function formatData(t){var e={key_id:_config.kid,key_hash:_config.khash,nc:1},r="payload";return _sa.para.batch_send&&(e.flush_time=Date.now(),r="payloads"),e[r]=t,e}function encodeTrackData(t){var e="";_sa.para.batch_send?e=formatData(t):e=formatData(aesEncrypt(t));var r=JSON.stringify(e);return"data="+encodeURIComponent(r)+"&gzip=9"}function isObject$1(t){return null!=t&&"[object Object]"==toString.call(t)}function encryptStoreData(t){var e=t.length;if(e>0){for(var r=0;r>>2]>>>24-o%4*8&255;e[n+o>>>2]|=a<<24-(n+o)%4*8}else for(var c=0;c>>2]=r[c>>>2];return this.sigBytes+=i,this},clamp:function(){var e=this.words,r=this.sigBytes;e[r>>>2]&=4294967295<<32-r%4*8,e.length=t.ceil(r/4)},clone:function(){var t=c.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],r=0;r>>2]>>>24-i%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n>>3]|=parseInt(t.substr(n,2),16)<<24-n%8*4;return new s.init(r,e/2)}},p=u.Latin1={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],i=0;i>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(o))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;return new s.init(r,e)}},h=u.Utf8={stringify:function(t){try{return decodeURIComponent(escape(p.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return p.parse(unescape(encodeURIComponent(t)))}},d=a.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=h.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var r,n=this._data,i=n.words,o=n.sigBytes,a=this.blockSize,c=o/(4*a),u=(c=e?t.ceil(c):t.max((0|c)-this._minBufferSize,0))*a,f=t.min(4*u,o);if(u){for(var p=0;p>>24)|4278255360&(i<<24|i>>>8)}var o=this._hash.words,c=t[e+0],h=t[e+1],d=t[e+2],l=t[e+3],y=t[e+4],_=t[e+5],g=t[e+6],v=t[e+7],S=t[e+8],m=t[e+9],k=t[e+10],C=t[e+11],B=t[e+12],x=t[e+13],D=t[e+14],w=t[e+15],b=o[0],E=o[1],z=o[2],J=o[3];b=s(b,E,z,J,c,7,a[0]),J=s(J,b,E,z,h,12,a[1]),z=s(z,J,b,E,d,17,a[2]),E=s(E,z,J,b,l,22,a[3]),b=s(b,E,z,J,y,7,a[4]),J=s(J,b,E,z,_,12,a[5]),z=s(z,J,b,E,g,17,a[6]),E=s(E,z,J,b,v,22,a[7]),b=s(b,E,z,J,S,7,a[8]),J=s(J,b,E,z,m,12,a[9]),z=s(z,J,b,E,k,17,a[10]),E=s(E,z,J,b,C,22,a[11]),b=s(b,E,z,J,B,7,a[12]),J=s(J,b,E,z,x,12,a[13]),z=s(z,J,b,E,D,17,a[14]),b=u(b,E=s(E,z,J,b,w,22,a[15]),z,J,h,5,a[16]),J=u(J,b,E,z,g,9,a[17]),z=u(z,J,b,E,C,14,a[18]),E=u(E,z,J,b,c,20,a[19]),b=u(b,E,z,J,_,5,a[20]),J=u(J,b,E,z,k,9,a[21]),z=u(z,J,b,E,w,14,a[22]),E=u(E,z,J,b,y,20,a[23]),b=u(b,E,z,J,m,5,a[24]),J=u(J,b,E,z,D,9,a[25]),z=u(z,J,b,E,l,14,a[26]),E=u(E,z,J,b,S,20,a[27]),b=u(b,E,z,J,x,5,a[28]),J=u(J,b,E,z,d,9,a[29]),z=u(z,J,b,E,v,14,a[30]),b=f(b,E=u(E,z,J,b,B,20,a[31]),z,J,_,4,a[32]),J=f(J,b,E,z,S,11,a[33]),z=f(z,J,b,E,C,16,a[34]),E=f(E,z,J,b,D,23,a[35]),b=f(b,E,z,J,h,4,a[36]),J=f(J,b,E,z,y,11,a[37]),z=f(z,J,b,E,v,16,a[38]),E=f(E,z,J,b,k,23,a[39]),b=f(b,E,z,J,x,4,a[40]),J=f(J,b,E,z,c,11,a[41]),z=f(z,J,b,E,l,16,a[42]),E=f(E,z,J,b,g,23,a[43]),b=f(b,E,z,J,m,4,a[44]),J=f(J,b,E,z,B,11,a[45]),z=f(z,J,b,E,w,16,a[46]),b=p(b,E=f(E,z,J,b,d,23,a[47]),z,J,c,6,a[48]),J=p(J,b,E,z,v,10,a[49]),z=p(z,J,b,E,D,15,a[50]),E=p(E,z,J,b,_,21,a[51]),b=p(b,E,z,J,B,6,a[52]),J=p(J,b,E,z,l,10,a[53]),z=p(z,J,b,E,k,15,a[54]),E=p(E,z,J,b,h,21,a[55]),b=p(b,E,z,J,S,6,a[56]),J=p(J,b,E,z,w,10,a[57]),z=p(z,J,b,E,g,15,a[58]),E=p(E,z,J,b,x,21,a[59]),b=p(b,E,z,J,y,6,a[60]),J=p(J,b,E,z,C,10,a[61]),z=p(z,J,b,E,d,15,a[62]),E=p(E,z,J,b,m,21,a[63]),o[0]=o[0]+b|0,o[1]=o[1]+E|0,o[2]=o[2]+z|0,o[3]=o[3]+J|0},_doFinalize:function(){var e=this._data,r=e.words,n=8*this._nDataBytes,i=8*e.sigBytes;r[i>>>5]|=128<<24-i%32;var o=t.floor(n/4294967296),a=n;r[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),r[14+(i+64>>>9<<4)]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),e.sigBytes=4*(r.length+1),this._process();for(var c=this._hash,s=c.words,u=0;u<4;u++){var f=s[u];s[u]=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8)}return c},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});function s(t,e,r,n,i,o,a){var c=t+(e&r|~e&n)+i+a;return(c<>>32-o)+e}function u(t,e,r,n,i,o,a){var c=t+(e&n|r&~n)+i+a;return(c<>>32-o)+e}function f(t,e,r,n,i,o,a){var c=t+(e^r^n)+i+a;return(c<>>32-o)+e}function p(t,e,r,n,i,o,a){var c=t+(r^(e|~n))+i+a;return(c<>>32-o)+e}e.MD5=i._createHelper(c),e.HmacMD5=i._createHmacHelper(c)}(Math),function(){var t=_CryptoJS.CryptoJS,e=t.lib,r=e.Base,n=e.WordArray,i=t.algo,o=i.MD5,a=i.EvpKDF=r.extend({cfg:r.extend({keySize:4,hasher:o,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){for(var r,i=this.cfg,o=i.hasher.create(),a=n.create(),c=a.words,s=i.keySize,u=i.iterations;c.length>>2]>>>24-o%4*8&255)<<16|(e[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|e[o+2>>>2]>>>24-(o+2)%4*8&255,c=0;c<4&&o+.75*c>>6*(3-c)&63));var s=n.charAt(64);if(s)for(;i.length%4;)i.push(s);return i.join("")},parse:function(t){var r=t.length,n=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var o=0;o>>6-a%4*2,u=c|s;i[o>>>2]|=u<<24-o%4*8,o++}return e.create(i,o)}(t,r,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),_CryptoJS.CryptoJS.lib.Cipher||function(t){var e=_CryptoJS.CryptoJS,r=e.lib,n=r.Base,i=r.WordArray,o=r.BufferedBlockAlgorithm,a=e.enc,c=(a.Utf8,a.Base64),s=e.algo.EvpKDF,u=r.Cipher=o.extend({cfg:n.extend(),createEncryptor:function(t,e){return this.create(this._ENC_XFORM_MODE,t,e)},createDecryptor:function(t,e){return this.create(this._DEC_XFORM_MODE,t,e)},init:function(t,e,r){this.cfg=this.cfg.extend(r),this._xformMode=t,this._key=e,this.reset()},reset:function(){o.reset.call(this),this._doReset()},process:function(t){return this._append(t),this._process()},finalize:function(t){return t&&this._append(t),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function t(t){return"string"==typeof t?v:_}return function(e){return{encrypt:function(r,n,i){return t(n).encrypt(e,r,n,i)},decrypt:function(r,n,i){return t(n).decrypt(e,r,n,i)}}}}()}),f=(r.StreamCipher=u.extend({_doFinalize:function(){return this._process(!0)},blockSize:1}),e.mode={}),p=r.BlockCipherMode=n.extend({createEncryptor:function(t,e){return this.Encryptor.create(t,e)},createDecryptor:function(t,e){return this.Decryptor.create(t,e)},init:function(t,e){this._cipher=t,this._iv=e}}),h=f.CBC=function(){var e=p.extend();function r(e,r,n){var i,o=this._iv;o?(i=o,this._iv=t):i=this._prevBlock;for(var a=0;a>>2];t.sigBytes-=e}},l=(r.BlockCipher=u.extend({cfg:u.cfg.extend({mode:h,padding:d}),reset:function(){var t;u.reset.call(this);var e=this.cfg,r=e.iv,n=e.mode;this._xformMode==this._ENC_XFORM_MODE?t=n.createEncryptor:(t=n.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==t?this._mode.init(this,r&&r.words):(this._mode=t.call(n,this,r&&r.words),this._mode.__creator=t)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t,e=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(e.pad(this._data,this.blockSize),t=this._process(!0)):(t=this._process(!0),e.unpad(t)),t},blockSize:4}),r.CipherParams=n.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}})),y=(e.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext,r=t.salt;return(r?i.create([1398893684,1701076831]).concat(r).concat(e):e).toString(c)},parse:function(t){var e,r=c.parse(t),n=r.words;return 1398893684==n[0]&&1701076831==n[1]&&(e=i.create(n.slice(2,4)),n.splice(0,4),r.sigBytes-=16),l.create({ciphertext:r,salt:e})}},_=r.SerializableCipher=n.extend({cfg:n.extend({format:y}),encrypt:function(t,e,r,n){n=this.cfg.extend(n);var i=t.createEncryptor(r,n),o=i.finalize(e),a=i.cfg;return l.create({ciphertext:o,key:r,iv:a.iv,algorithm:t,mode:a.mode,padding:a.padding,blockSize:t.blockSize,formatter:n.format})},decrypt:function(t,e,r,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),t.createDecryptor(r,n).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}}),g=(e.kdf={}).OpenSSL={execute:function(t,e,r,n){n||(n=i.random(8));var o=s.create({keySize:e+r}).compute(t,n),a=i.create(o.words.slice(e),4*r);return o.sigBytes=4*e,l.create({key:o,iv:a,salt:n})}},v=r.PasswordBasedCipher=_.extend({cfg:_.cfg.extend({kdf:g}),encrypt:function(t,e,r,n){var i=(n=this.cfg.extend(n)).kdf.execute(r,t.keySize,t.ivSize);n.iv=i.iv;var o=_.encrypt.call(this,t,e,i.key,n);return o.mixIn(i),o},decrypt:function(t,e,r,n){n=this.cfg.extend(n),e=this._parse(e,n.format);var i=n.kdf.execute(r,t.keySize,t.ivSize,e.salt);return n.iv=i.iv,_.decrypt.call(this,t,e,i.key,n)}})}(),function(){var t=_CryptoJS.CryptoJS,e=t.lib.BlockCipher,r=t.algo,n=[],i=[],o=[],a=[],c=[],s=[],u=[],f=[],p=[],h=[];!function(){for(var t=[],e=0;e<256;e++)t[e]=e<128?e<<1:e<<1^283;var r=0,d=0;for(e=0;e<256;e++){var l=d^d<<1^d<<2^d<<3^d<<4;l=l>>>8^255&l^99,n[r]=l,i[l]=r;var y=t[r],_=t[y],g=t[_],v=257*t[l]^16843008*l;o[r]=v<<24|v>>>8,a[r]=v<<16|v>>>16,c[r]=v<<8|v>>>24,s[r]=v;v=16843009*g^65537*_^257*y^16843008*r;u[l]=v<<24|v>>>8,f[l]=v<<16|v>>>16,p[l]=v<<8|v>>>24,h[l]=v,r?(r=y^t[t[t[g^y]]],d^=t[t[d]]):r=d=1}}();var d=[0,1,2,4,8,16,32,64,128,27,54],l=r.AES=e.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var t=this._keyPriorReset=this._key,e=t.words,r=t.sigBytes/4,i=4*((this._nRounds=r+6)+1),o=this._keySchedule=[],a=0;a6&&a%r==4&&(l=n[l>>>24]<<24|n[l>>>16&255]<<16|n[l>>>8&255]<<8|n[255&l]):(l=n[(l=l<<8|l>>>24)>>>24]<<24|n[l>>>16&255]<<16|n[l>>>8&255]<<8|n[255&l],l^=d[a/r|0]<<24),o[a]=o[a-r]^l);for(var c=this._invKeySchedule=[],s=0;s>>24]]^f[n[l>>>16&255]]^p[n[l>>>8&255]]^h[n[255&l]]}}},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,o,a,c,s,n)},decryptBlock:function(t,e){var r=t[e+1];t[e+1]=t[e+3],t[e+3]=r,this._doCryptBlock(t,e,this._invKeySchedule,u,f,p,h,i);r=t[e+1];t[e+1]=t[e+3],t[e+3]=r},_doCryptBlock:function(t,e,r,n,i,o,a,c){for(var s=this._nRounds,u=t[e]^r[0],f=t[e+1]^r[1],p=t[e+2]^r[2],h=t[e+3]^r[3],d=4,l=1;l>>24]^i[f>>>16&255]^o[p>>>8&255]^a[255&h]^r[d++],_=n[f>>>24]^i[p>>>16&255]^o[h>>>8&255]^a[255&u]^r[d++],g=n[p>>>24]^i[h>>>16&255]^o[u>>>8&255]^a[255&f]^r[d++],v=n[h>>>24]^i[u>>>16&255]^o[f>>>8&255]^a[255&p]^r[d++];u=y,f=_,p=g,h=v}y=(c[u>>>24]<<24|c[f>>>16&255]<<16|c[p>>>8&255]<<8|c[255&h])^r[d++],_=(c[f>>>24]<<24|c[p>>>16&255]<<16|c[h>>>8&255]<<8|c[255&u])^r[d++],g=(c[p>>>24]<<24|c[h>>>16&255]<<16|c[u>>>8&255]<<8|c[255&f])^r[d++],v=(c[h>>>24]<<24|c[u>>>16&255]<<16|c[f>>>8&255]<<8|c[255&p])^r[d++];t[e]=y,t[e+1]=_,t[e+2]=g,t[e+3]=v},keySize:8});t.AES=e._createHelper(l)}();var _iv,_sa,_config,_oldOnceData,CryptoJS=_CryptoJS.CryptoJS,getRandomBasic=function(){var t=(new Date).getTime();return function(e){return Math.ceil((t=(9301*t+49297)%233280)/233280*e)}}();function isObject(t){return null!=t&&"[object Object]"==toString.call(t)}function getRandom(){if("function"==typeof Uint32Array){var t="";if("undefined"!=typeof crypto?t=crypto:"undefined"!=typeof msCrypto&&(t=msCrypto),isObject(t)&&t.getRandomValues){var e=new Uint32Array(1);return t.getRandomValues(e)[0]/Math.pow(2,32)}}return getRandomBasic(1e19)/1e19}function buildAESOption(t){return{mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7,iv:t||generateIVData()}}function encryptData(t,e,r,n){var i=buildAESOption(r),o=t;"string"!=typeof t&&(o=JSON.stringify(t)),n||(e=CryptoJS.enc.Base64.parse(e));var a=CryptoJS.enc.Utf8.parse(o),c=CryptoJS.AES.encrypt(a,e,i).toString();return i.iv.clone().concat(CryptoJS.enc.Base64.parse(c)).toString(CryptoJS.enc.Base64)}function decryptData(t,e,r){var n=CryptoJS.enc.Base64.parse(t).toString(),i=n.substr(0,32),o=CryptoJS.enc.Hex.parse(n.substr(32)).toString(CryptoJS.enc.Base64),a=buildAESOption(CryptoJS.enc.Hex.parse(i));return r||(e=CryptoJS.enc.Base64.parse(e)),CryptoJS.AES.decrypt(o,e,a).toString(CryptoJS.enc.Utf8)}function generateIVData(t){t=t||16;for(var e="";t-- >0;){var r=Math.ceil(127*getRandom()).toString(16);e+=2===r.length?r:"0"+r}return CryptoJS.enc.Hex.parse(e)}var _log=console&&console.log||function(){};function isTruthy(t,e){return!!t||(_log(e+"不能为空。"),!1)}function matchType(t,e,r){return typeof t===r||(_log("参数类型错误,"+e+"必须为"+r),!1)}function aesEncrypt(t){try{return encryptData(t,_config.k,_iv)}catch(e){return _log("数据加密异常:"+e),_sa.para.batch_send?"":_oldOnceData.call(_sa.kit,t)}}function formatData(t){var e={key_id:_config.kid,key_hash:_config.khash,nc:1},r="payload";return _sa.para.batch_send&&(e.flush_time=Date.now(),r="payloads"),e[r]=t,e}function encodeTrackData(t){var e="";_sa.para.batch_send?e=formatData(t):e=formatData(aesEncrypt(t));var r=JSON.stringify(e);return"data="+encodeURIComponent(r)+"&gzip=9"}function isObject$1(t){return null!=t&&"[object Object]"==toString.call(t)}function encryptStoreData(t){var e=t.length;if(e>0){for(var r=0;r>>2]>>>24-o%4*8&255;e[n+o>>>2]|=a<<24-(n+o)%4*8}else for(var c=0;c>>2]=r[c>>>2];return this.sigBytes+=i,this},clamp:function(){var e=this.words,r=this.sigBytes;e[r>>>2]&=4294967295<<32-r%4*8,e.length=t.ceil(r/4)},clone:function(){var t=c.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],r=0;r>>2]>>>24-i%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n>>3]|=parseInt(t.substr(n,2),16)<<24-n%8*4;return new s.init(r,e/2)}},p=u.Latin1={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],i=0;i>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(o))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;return new s.init(r,e)}},h=u.Utf8={stringify:function(t){try{return decodeURIComponent(escape(p.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return p.parse(unescape(encodeURIComponent(t)))}},d=a.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=h.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var r,n=this._data,i=n.words,o=n.sigBytes,a=this.blockSize,c=o/(4*a),u=(c=e?t.ceil(c):t.max((0|c)-this._minBufferSize,0))*a,f=t.min(4*u,o);if(u){for(var p=0;p>>24)|4278255360&(i<<24|i>>>8)}var o=this._hash.words,c=t[e+0],h=t[e+1],d=t[e+2],l=t[e+3],y=t[e+4],_=t[e+5],g=t[e+6],v=t[e+7],S=t[e+8],m=t[e+9],k=t[e+10],C=t[e+11],B=t[e+12],x=t[e+13],D=t[e+14],w=t[e+15],b=o[0],E=o[1],z=o[2],J=o[3];b=s(b,E,z,J,c,7,a[0]),J=s(J,b,E,z,h,12,a[1]),z=s(z,J,b,E,d,17,a[2]),E=s(E,z,J,b,l,22,a[3]),b=s(b,E,z,J,y,7,a[4]),J=s(J,b,E,z,_,12,a[5]),z=s(z,J,b,E,g,17,a[6]),E=s(E,z,J,b,v,22,a[7]),b=s(b,E,z,J,S,7,a[8]),J=s(J,b,E,z,m,12,a[9]),z=s(z,J,b,E,k,17,a[10]),E=s(E,z,J,b,C,22,a[11]),b=s(b,E,z,J,B,7,a[12]),J=s(J,b,E,z,x,12,a[13]),z=s(z,J,b,E,D,17,a[14]),b=u(b,E=s(E,z,J,b,w,22,a[15]),z,J,h,5,a[16]),J=u(J,b,E,z,g,9,a[17]),z=u(z,J,b,E,C,14,a[18]),E=u(E,z,J,b,c,20,a[19]),b=u(b,E,z,J,_,5,a[20]),J=u(J,b,E,z,k,9,a[21]),z=u(z,J,b,E,w,14,a[22]),E=u(E,z,J,b,y,20,a[23]),b=u(b,E,z,J,m,5,a[24]),J=u(J,b,E,z,D,9,a[25]),z=u(z,J,b,E,l,14,a[26]),E=u(E,z,J,b,S,20,a[27]),b=u(b,E,z,J,x,5,a[28]),J=u(J,b,E,z,d,9,a[29]),z=u(z,J,b,E,v,14,a[30]),b=f(b,E=u(E,z,J,b,B,20,a[31]),z,J,_,4,a[32]),J=f(J,b,E,z,S,11,a[33]),z=f(z,J,b,E,C,16,a[34]),E=f(E,z,J,b,D,23,a[35]),b=f(b,E,z,J,h,4,a[36]),J=f(J,b,E,z,y,11,a[37]),z=f(z,J,b,E,v,16,a[38]),E=f(E,z,J,b,k,23,a[39]),b=f(b,E,z,J,x,4,a[40]),J=f(J,b,E,z,c,11,a[41]),z=f(z,J,b,E,l,16,a[42]),E=f(E,z,J,b,g,23,a[43]),b=f(b,E,z,J,m,4,a[44]),J=f(J,b,E,z,B,11,a[45]),z=f(z,J,b,E,w,16,a[46]),b=p(b,E=f(E,z,J,b,d,23,a[47]),z,J,c,6,a[48]),J=p(J,b,E,z,v,10,a[49]),z=p(z,J,b,E,D,15,a[50]),E=p(E,z,J,b,_,21,a[51]),b=p(b,E,z,J,B,6,a[52]),J=p(J,b,E,z,l,10,a[53]),z=p(z,J,b,E,k,15,a[54]),E=p(E,z,J,b,h,21,a[55]),b=p(b,E,z,J,S,6,a[56]),J=p(J,b,E,z,w,10,a[57]),z=p(z,J,b,E,g,15,a[58]),E=p(E,z,J,b,x,21,a[59]),b=p(b,E,z,J,y,6,a[60]),J=p(J,b,E,z,C,10,a[61]),z=p(z,J,b,E,d,15,a[62]),E=p(E,z,J,b,m,21,a[63]),o[0]=o[0]+b|0,o[1]=o[1]+E|0,o[2]=o[2]+z|0,o[3]=o[3]+J|0},_doFinalize:function(){var e=this._data,r=e.words,n=8*this._nDataBytes,i=8*e.sigBytes;r[i>>>5]|=128<<24-i%32;var o=t.floor(n/4294967296),a=n;r[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),r[14+(i+64>>>9<<4)]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),e.sigBytes=4*(r.length+1),this._process();for(var c=this._hash,s=c.words,u=0;u<4;u++){var f=s[u];s[u]=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8)}return c},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});function s(t,e,r,n,i,o,a){var c=t+(e&r|~e&n)+i+a;return(c<>>32-o)+e}function u(t,e,r,n,i,o,a){var c=t+(e&n|r&~n)+i+a;return(c<>>32-o)+e}function f(t,e,r,n,i,o,a){var c=t+(e^r^n)+i+a;return(c<>>32-o)+e}function p(t,e,r,n,i,o,a){var c=t+(r^(e|~n))+i+a;return(c<>>32-o)+e}e.MD5=i._createHelper(c),e.HmacMD5=i._createHmacHelper(c)}(Math),function(){var t=_CryptoJS.CryptoJS,e=t.lib,r=e.Base,n=e.WordArray,i=t.algo,o=i.MD5,a=i.EvpKDF=r.extend({cfg:r.extend({keySize:4,hasher:o,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){for(var r,i=this.cfg,o=i.hasher.create(),a=n.create(),c=a.words,s=i.keySize,u=i.iterations;c.length>>2]>>>24-o%4*8&255)<<16|(e[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|e[o+2>>>2]>>>24-(o+2)%4*8&255,c=0;c<4&&o+.75*c>>6*(3-c)&63));var s=n.charAt(64);if(s)for(;i.length%4;)i.push(s);return i.join("")},parse:function(t){var r=t.length,n=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var o=0;o>>6-a%4*2,u=c|s;i[o>>>2]|=u<<24-o%4*8,o++}return e.create(i,o)}(t,r,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),_CryptoJS.CryptoJS.lib.Cipher||function(t){var e=_CryptoJS.CryptoJS,r=e.lib,n=r.Base,i=r.WordArray,o=r.BufferedBlockAlgorithm,a=e.enc,c=(a.Utf8,a.Base64),s=e.algo.EvpKDF,u=r.Cipher=o.extend({cfg:n.extend(),createEncryptor:function(t,e){return this.create(this._ENC_XFORM_MODE,t,e)},createDecryptor:function(t,e){return this.create(this._DEC_XFORM_MODE,t,e)},init:function(t,e,r){this.cfg=this.cfg.extend(r),this._xformMode=t,this._key=e,this.reset()},reset:function(){o.reset.call(this),this._doReset()},process:function(t){return this._append(t),this._process()},finalize:function(t){return t&&this._append(t),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function t(t){return"string"==typeof t?v:_}return function(e){return{encrypt:function(r,n,i){return t(n).encrypt(e,r,n,i)},decrypt:function(r,n,i){return t(n).decrypt(e,r,n,i)}}}}()}),f=(r.StreamCipher=u.extend({_doFinalize:function(){return this._process(!0)},blockSize:1}),e.mode={}),p=r.BlockCipherMode=n.extend({createEncryptor:function(t,e){return this.Encryptor.create(t,e)},createDecryptor:function(t,e){return this.Decryptor.create(t,e)},init:function(t,e){this._cipher=t,this._iv=e}}),h=f.CBC=function(){var e=p.extend();function r(e,r,n){var i,o=this._iv;o?(i=o,this._iv=t):i=this._prevBlock;for(var a=0;a>>2];t.sigBytes-=e}},l=(r.BlockCipher=u.extend({cfg:u.cfg.extend({mode:h,padding:d}),reset:function(){var t;u.reset.call(this);var e=this.cfg,r=e.iv,n=e.mode;this._xformMode==this._ENC_XFORM_MODE?t=n.createEncryptor:(t=n.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==t?this._mode.init(this,r&&r.words):(this._mode=t.call(n,this,r&&r.words),this._mode.__creator=t)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t,e=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(e.pad(this._data,this.blockSize),t=this._process(!0)):(t=this._process(!0),e.unpad(t)),t},blockSize:4}),r.CipherParams=n.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}})),y=(e.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext,r=t.salt;return(r?i.create([1398893684,1701076831]).concat(r).concat(e):e).toString(c)},parse:function(t){var e,r=c.parse(t),n=r.words;return 1398893684==n[0]&&1701076831==n[1]&&(e=i.create(n.slice(2,4)),n.splice(0,4),r.sigBytes-=16),l.create({ciphertext:r,salt:e})}},_=r.SerializableCipher=n.extend({cfg:n.extend({format:y}),encrypt:function(t,e,r,n){n=this.cfg.extend(n);var i=t.createEncryptor(r,n),o=i.finalize(e),a=i.cfg;return l.create({ciphertext:o,key:r,iv:a.iv,algorithm:t,mode:a.mode,padding:a.padding,blockSize:t.blockSize,formatter:n.format})},decrypt:function(t,e,r,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),t.createDecryptor(r,n).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}}),g=(e.kdf={}).OpenSSL={execute:function(t,e,r,n){n||(n=i.random(8));var o=s.create({keySize:e+r}).compute(t,n),a=i.create(o.words.slice(e),4*r);return o.sigBytes=4*e,l.create({key:o,iv:a,salt:n})}},v=r.PasswordBasedCipher=_.extend({cfg:_.cfg.extend({kdf:g}),encrypt:function(t,e,r,n){var i=(n=this.cfg.extend(n)).kdf.execute(r,t.keySize,t.ivSize);n.iv=i.iv;var o=_.encrypt.call(this,t,e,i.key,n);return o.mixIn(i),o},decrypt:function(t,e,r,n){n=this.cfg.extend(n),e=this._parse(e,n.format);var i=n.kdf.execute(r,t.keySize,t.ivSize,e.salt);return n.iv=i.iv,_.decrypt.call(this,t,e,i.key,n)}})}(),function(){var t=_CryptoJS.CryptoJS,e=t.lib.BlockCipher,r=t.algo,n=[],i=[],o=[],a=[],c=[],s=[],u=[],f=[],p=[],h=[];!function(){for(var t=[],e=0;e<256;e++)t[e]=e<128?e<<1:e<<1^283;var r=0,d=0;for(e=0;e<256;e++){var l=d^d<<1^d<<2^d<<3^d<<4;l=l>>>8^255&l^99,n[r]=l,i[l]=r;var y=t[r],_=t[y],g=t[_],v=257*t[l]^16843008*l;o[r]=v<<24|v>>>8,a[r]=v<<16|v>>>16,c[r]=v<<8|v>>>24,s[r]=v;v=16843009*g^65537*_^257*y^16843008*r;u[l]=v<<24|v>>>8,f[l]=v<<16|v>>>16,p[l]=v<<8|v>>>24,h[l]=v,r?(r=y^t[t[t[g^y]]],d^=t[t[d]]):r=d=1}}();var d=[0,1,2,4,8,16,32,64,128,27,54],l=r.AES=e.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var t=this._keyPriorReset=this._key,e=t.words,r=t.sigBytes/4,i=4*((this._nRounds=r+6)+1),o=this._keySchedule=[],a=0;a6&&a%r==4&&(l=n[l>>>24]<<24|n[l>>>16&255]<<16|n[l>>>8&255]<<8|n[255&l]):(l=n[(l=l<<8|l>>>24)>>>24]<<24|n[l>>>16&255]<<16|n[l>>>8&255]<<8|n[255&l],l^=d[a/r|0]<<24),o[a]=o[a-r]^l);for(var c=this._invKeySchedule=[],s=0;s>>24]]^f[n[l>>>16&255]]^p[n[l>>>8&255]]^h[n[255&l]]}}},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,o,a,c,s,n)},decryptBlock:function(t,e){var r=t[e+1];t[e+1]=t[e+3],t[e+3]=r,this._doCryptBlock(t,e,this._invKeySchedule,u,f,p,h,i);r=t[e+1];t[e+1]=t[e+3],t[e+3]=r},_doCryptBlock:function(t,e,r,n,i,o,a,c){for(var s=this._nRounds,u=t[e]^r[0],f=t[e+1]^r[1],p=t[e+2]^r[2],h=t[e+3]^r[3],d=4,l=1;l>>24]^i[f>>>16&255]^o[p>>>8&255]^a[255&h]^r[d++],_=n[f>>>24]^i[p>>>16&255]^o[h>>>8&255]^a[255&u]^r[d++],g=n[p>>>24]^i[h>>>16&255]^o[u>>>8&255]^a[255&f]^r[d++],v=n[h>>>24]^i[u>>>16&255]^o[f>>>8&255]^a[255&p]^r[d++];u=y,f=_,p=g,h=v}y=(c[u>>>24]<<24|c[f>>>16&255]<<16|c[p>>>8&255]<<8|c[255&h])^r[d++],_=(c[f>>>24]<<24|c[p>>>16&255]<<16|c[h>>>8&255]<<8|c[255&u])^r[d++],g=(c[p>>>24]<<24|c[h>>>16&255]<<16|c[u>>>8&255]<<8|c[255&f])^r[d++],v=(c[h>>>24]<<24|c[u>>>16&255]<<16|c[f>>>8&255]<<8|c[255&p])^r[d++];t[e]=y,t[e+1]=_,t[e+2]=g,t[e+3]=v},keySize:8});t.AES=e._createHelper(l)}();var _iv,_sa,_config,_oldOnceData,CryptoJS=_CryptoJS.CryptoJS,getRandomBasic=function(){var t=(new Date).getTime();return function(e){return Math.ceil((t=(9301*t+49297)%233280)/233280*e)}}();function isObject(t){return null!=t&&"[object Object]"==toString.call(t)}function getRandom(){if("function"==typeof Uint32Array){var t="";if("undefined"!=typeof crypto?t=crypto:"undefined"!=typeof msCrypto&&(t=msCrypto),isObject(t)&&t.getRandomValues){var e=new Uint32Array(1);return t.getRandomValues(e)[0]/Math.pow(2,32)}}return getRandomBasic(1e19)/1e19}function buildAESOption(t){return{mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7,iv:t||generateIVData()}}function encryptData(t,e,r,n){var i=buildAESOption(r),o=t;"string"!=typeof t&&(o=JSON.stringify(t)),n||(e=CryptoJS.enc.Base64.parse(e));var a=CryptoJS.enc.Utf8.parse(o),c=CryptoJS.AES.encrypt(a,e,i).toString();return i.iv.clone().concat(CryptoJS.enc.Base64.parse(c)).toString(CryptoJS.enc.Base64)}function decryptData(t,e,r){var n=CryptoJS.enc.Base64.parse(t).toString(),i=n.substr(0,32),o=CryptoJS.enc.Hex.parse(n.substr(32)).toString(CryptoJS.enc.Base64),a=buildAESOption(CryptoJS.enc.Hex.parse(i));return r||(e=CryptoJS.enc.Base64.parse(e)),CryptoJS.AES.decrypt(o,e,a).toString(CryptoJS.enc.Utf8)}function generateIVData(t){t=t||16;for(var e="";t-- >0;){var r=Math.ceil(127*getRandom()).toString(16);e+=2===r.length?r:"0"+r}return CryptoJS.enc.Hex.parse(e)}var _log=console&&console.log||function(){};function isTruthy(t,e){return!!t||(_log(e+"不能为空。"),!1)}function matchType(t,e,r){return typeof t===r||(_log("参数类型错误,"+e+"必须为"+r),!1)}function aesEncrypt(t){try{return encryptData(t,_config.k,_iv)}catch(e){return _log("数据加密异常:"+e),_sa.para.batch_send?"":_oldOnceData.call(_sa.kit,t)}}function formatData(t){var e={key_id:_config.kid,key_hash:_config.khash,nc:1},r="payload";return _sa.para.batch_send&&(e.flush_time=Date.now(),r="payloads"),e[r]=t,e}function encodeTrackData(t){var e="";_sa.para.batch_send?e=formatData(t):e=formatData(aesEncrypt(t));var r=JSON.stringify(e);return"data="+encodeURIComponent(r)+"&gzip=9"}function isObject$1(t){return null!=t&&"[object Object]"==toString.call(t)}function encryptStoreData(t){var e=t.length;if(e>0){for(var r=0;r>>2]>>>24-o%4*8&255;e[n+o>>>2]|=a<<24-(n+o)%4*8}else for(var c=0;c>>2]=r[c>>>2];return this.sigBytes+=i,this},clamp:function(){var e=this.words,r=this.sigBytes;e[r>>>2]&=4294967295<<32-r%4*8,e.length=t.ceil(r/4)},clone:function(){var t=c.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],r=0;r>>2]>>>24-i%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n>>3]|=parseInt(t.substr(n,2),16)<<24-n%8*4;return new s.init(r,e/2)}},p=u.Latin1={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],i=0;i>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(o))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;return new s.init(r,e)}},h=u.Utf8={stringify:function(t){try{return decodeURIComponent(escape(p.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return p.parse(unescape(encodeURIComponent(t)))}},d=a.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=h.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var r,n=this._data,i=n.words,o=n.sigBytes,a=this.blockSize,c=o/(4*a),u=(c=e?t.ceil(c):t.max((0|c)-this._minBufferSize,0))*a,f=t.min(4*u,o);if(u){for(var p=0;p>>24)|4278255360&(i<<24|i>>>8)}var o=this._hash.words,c=t[e+0],h=t[e+1],d=t[e+2],l=t[e+3],y=t[e+4],_=t[e+5],g=t[e+6],v=t[e+7],S=t[e+8],m=t[e+9],k=t[e+10],C=t[e+11],B=t[e+12],x=t[e+13],D=t[e+14],w=t[e+15],b=o[0],E=o[1],z=o[2],J=o[3];b=s(b,E,z,J,c,7,a[0]),J=s(J,b,E,z,h,12,a[1]),z=s(z,J,b,E,d,17,a[2]),E=s(E,z,J,b,l,22,a[3]),b=s(b,E,z,J,y,7,a[4]),J=s(J,b,E,z,_,12,a[5]),z=s(z,J,b,E,g,17,a[6]),E=s(E,z,J,b,v,22,a[7]),b=s(b,E,z,J,S,7,a[8]),J=s(J,b,E,z,m,12,a[9]),z=s(z,J,b,E,k,17,a[10]),E=s(E,z,J,b,C,22,a[11]),b=s(b,E,z,J,B,7,a[12]),J=s(J,b,E,z,x,12,a[13]),z=s(z,J,b,E,D,17,a[14]),b=u(b,E=s(E,z,J,b,w,22,a[15]),z,J,h,5,a[16]),J=u(J,b,E,z,g,9,a[17]),z=u(z,J,b,E,C,14,a[18]),E=u(E,z,J,b,c,20,a[19]),b=u(b,E,z,J,_,5,a[20]),J=u(J,b,E,z,k,9,a[21]),z=u(z,J,b,E,w,14,a[22]),E=u(E,z,J,b,y,20,a[23]),b=u(b,E,z,J,m,5,a[24]),J=u(J,b,E,z,D,9,a[25]),z=u(z,J,b,E,l,14,a[26]),E=u(E,z,J,b,S,20,a[27]),b=u(b,E,z,J,x,5,a[28]),J=u(J,b,E,z,d,9,a[29]),z=u(z,J,b,E,v,14,a[30]),b=f(b,E=u(E,z,J,b,B,20,a[31]),z,J,_,4,a[32]),J=f(J,b,E,z,S,11,a[33]),z=f(z,J,b,E,C,16,a[34]),E=f(E,z,J,b,D,23,a[35]),b=f(b,E,z,J,h,4,a[36]),J=f(J,b,E,z,y,11,a[37]),z=f(z,J,b,E,v,16,a[38]),E=f(E,z,J,b,k,23,a[39]),b=f(b,E,z,J,x,4,a[40]),J=f(J,b,E,z,c,11,a[41]),z=f(z,J,b,E,l,16,a[42]),E=f(E,z,J,b,g,23,a[43]),b=f(b,E,z,J,m,4,a[44]),J=f(J,b,E,z,B,11,a[45]),z=f(z,J,b,E,w,16,a[46]),b=p(b,E=f(E,z,J,b,d,23,a[47]),z,J,c,6,a[48]),J=p(J,b,E,z,v,10,a[49]),z=p(z,J,b,E,D,15,a[50]),E=p(E,z,J,b,_,21,a[51]),b=p(b,E,z,J,B,6,a[52]),J=p(J,b,E,z,l,10,a[53]),z=p(z,J,b,E,k,15,a[54]),E=p(E,z,J,b,h,21,a[55]),b=p(b,E,z,J,S,6,a[56]),J=p(J,b,E,z,w,10,a[57]),z=p(z,J,b,E,g,15,a[58]),E=p(E,z,J,b,x,21,a[59]),b=p(b,E,z,J,y,6,a[60]),J=p(J,b,E,z,C,10,a[61]),z=p(z,J,b,E,d,15,a[62]),E=p(E,z,J,b,m,21,a[63]),o[0]=o[0]+b|0,o[1]=o[1]+E|0,o[2]=o[2]+z|0,o[3]=o[3]+J|0},_doFinalize:function(){var e=this._data,r=e.words,n=8*this._nDataBytes,i=8*e.sigBytes;r[i>>>5]|=128<<24-i%32;var o=t.floor(n/4294967296),a=n;r[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),r[14+(i+64>>>9<<4)]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),e.sigBytes=4*(r.length+1),this._process();for(var c=this._hash,s=c.words,u=0;u<4;u++){var f=s[u];s[u]=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8)}return c},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});function s(t,e,r,n,i,o,a){var c=t+(e&r|~e&n)+i+a;return(c<>>32-o)+e}function u(t,e,r,n,i,o,a){var c=t+(e&n|r&~n)+i+a;return(c<>>32-o)+e}function f(t,e,r,n,i,o,a){var c=t+(e^r^n)+i+a;return(c<>>32-o)+e}function p(t,e,r,n,i,o,a){var c=t+(r^(e|~n))+i+a;return(c<>>32-o)+e}e.MD5=i._createHelper(c),e.HmacMD5=i._createHmacHelper(c)}(Math),function(){var t=_CryptoJS.CryptoJS,e=t.lib,r=e.Base,n=e.WordArray,i=t.algo,o=i.MD5,a=i.EvpKDF=r.extend({cfg:r.extend({keySize:4,hasher:o,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){for(var r,i=this.cfg,o=i.hasher.create(),a=n.create(),c=a.words,s=i.keySize,u=i.iterations;c.length>>2]>>>24-o%4*8&255)<<16|(e[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|e[o+2>>>2]>>>24-(o+2)%4*8&255,c=0;c<4&&o+.75*c>>6*(3-c)&63));var s=n.charAt(64);if(s)for(;i.length%4;)i.push(s);return i.join("")},parse:function(t){var r=t.length,n=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var o=0;o>>6-a%4*2,u=c|s;i[o>>>2]|=u<<24-o%4*8,o++}return e.create(i,o)}(t,r,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),_CryptoJS.CryptoJS.lib.Cipher||function(t){var e=_CryptoJS.CryptoJS,r=e.lib,n=r.Base,i=r.WordArray,o=r.BufferedBlockAlgorithm,a=e.enc,c=(a.Utf8,a.Base64),s=e.algo.EvpKDF,u=r.Cipher=o.extend({cfg:n.extend(),createEncryptor:function(t,e){return this.create(this._ENC_XFORM_MODE,t,e)},createDecryptor:function(t,e){return this.create(this._DEC_XFORM_MODE,t,e)},init:function(t,e,r){this.cfg=this.cfg.extend(r),this._xformMode=t,this._key=e,this.reset()},reset:function(){o.reset.call(this),this._doReset()},process:function(t){return this._append(t),this._process()},finalize:function(t){return t&&this._append(t),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function t(t){return"string"==typeof t?v:_}return function(e){return{encrypt:function(r,n,i){return t(n).encrypt(e,r,n,i)},decrypt:function(r,n,i){return t(n).decrypt(e,r,n,i)}}}}()}),f=(r.StreamCipher=u.extend({_doFinalize:function(){return this._process(!0)},blockSize:1}),e.mode={}),p=r.BlockCipherMode=n.extend({createEncryptor:function(t,e){return this.Encryptor.create(t,e)},createDecryptor:function(t,e){return this.Decryptor.create(t,e)},init:function(t,e){this._cipher=t,this._iv=e}}),h=f.CBC=function(){var e=p.extend();function r(e,r,n){var i,o=this._iv;o?(i=o,this._iv=t):i=this._prevBlock;for(var a=0;a>>2];t.sigBytes-=e}},l=(r.BlockCipher=u.extend({cfg:u.cfg.extend({mode:h,padding:d}),reset:function(){var t;u.reset.call(this);var e=this.cfg,r=e.iv,n=e.mode;this._xformMode==this._ENC_XFORM_MODE?t=n.createEncryptor:(t=n.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==t?this._mode.init(this,r&&r.words):(this._mode=t.call(n,this,r&&r.words),this._mode.__creator=t)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t,e=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(e.pad(this._data,this.blockSize),t=this._process(!0)):(t=this._process(!0),e.unpad(t)),t},blockSize:4}),r.CipherParams=n.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}})),y=(e.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext,r=t.salt;return(r?i.create([1398893684,1701076831]).concat(r).concat(e):e).toString(c)},parse:function(t){var e,r=c.parse(t),n=r.words;return 1398893684==n[0]&&1701076831==n[1]&&(e=i.create(n.slice(2,4)),n.splice(0,4),r.sigBytes-=16),l.create({ciphertext:r,salt:e})}},_=r.SerializableCipher=n.extend({cfg:n.extend({format:y}),encrypt:function(t,e,r,n){n=this.cfg.extend(n);var i=t.createEncryptor(r,n),o=i.finalize(e),a=i.cfg;return l.create({ciphertext:o,key:r,iv:a.iv,algorithm:t,mode:a.mode,padding:a.padding,blockSize:t.blockSize,formatter:n.format})},decrypt:function(t,e,r,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),t.createDecryptor(r,n).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}}),g=(e.kdf={}).OpenSSL={execute:function(t,e,r,n){n||(n=i.random(8));var o=s.create({keySize:e+r}).compute(t,n),a=i.create(o.words.slice(e),4*r);return o.sigBytes=4*e,l.create({key:o,iv:a,salt:n})}},v=r.PasswordBasedCipher=_.extend({cfg:_.cfg.extend({kdf:g}),encrypt:function(t,e,r,n){var i=(n=this.cfg.extend(n)).kdf.execute(r,t.keySize,t.ivSize);n.iv=i.iv;var o=_.encrypt.call(this,t,e,i.key,n);return o.mixIn(i),o},decrypt:function(t,e,r,n){n=this.cfg.extend(n),e=this._parse(e,n.format);var i=n.kdf.execute(r,t.keySize,t.ivSize,e.salt);return n.iv=i.iv,_.decrypt.call(this,t,e,i.key,n)}})}(),function(){var t=_CryptoJS.CryptoJS,e=t.lib.BlockCipher,r=t.algo,n=[],i=[],o=[],a=[],c=[],s=[],u=[],f=[],p=[],h=[];!function(){for(var t=[],e=0;e<256;e++)t[e]=e<128?e<<1:e<<1^283;var r=0,d=0;for(e=0;e<256;e++){var l=d^d<<1^d<<2^d<<3^d<<4;l=l>>>8^255&l^99,n[r]=l,i[l]=r;var y=t[r],_=t[y],g=t[_],v=257*t[l]^16843008*l;o[r]=v<<24|v>>>8,a[r]=v<<16|v>>>16,c[r]=v<<8|v>>>24,s[r]=v;v=16843009*g^65537*_^257*y^16843008*r;u[l]=v<<24|v>>>8,f[l]=v<<16|v>>>16,p[l]=v<<8|v>>>24,h[l]=v,r?(r=y^t[t[t[g^y]]],d^=t[t[d]]):r=d=1}}();var d=[0,1,2,4,8,16,32,64,128,27,54],l=r.AES=e.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var t=this._keyPriorReset=this._key,e=t.words,r=t.sigBytes/4,i=4*((this._nRounds=r+6)+1),o=this._keySchedule=[],a=0;a6&&a%r==4&&(l=n[l>>>24]<<24|n[l>>>16&255]<<16|n[l>>>8&255]<<8|n[255&l]):(l=n[(l=l<<8|l>>>24)>>>24]<<24|n[l>>>16&255]<<16|n[l>>>8&255]<<8|n[255&l],l^=d[a/r|0]<<24),o[a]=o[a-r]^l);for(var c=this._invKeySchedule=[],s=0;s>>24]]^f[n[l>>>16&255]]^p[n[l>>>8&255]]^h[n[255&l]]}}},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,o,a,c,s,n)},decryptBlock:function(t,e){var r=t[e+1];t[e+1]=t[e+3],t[e+3]=r,this._doCryptBlock(t,e,this._invKeySchedule,u,f,p,h,i);r=t[e+1];t[e+1]=t[e+3],t[e+3]=r},_doCryptBlock:function(t,e,r,n,i,o,a,c){for(var s=this._nRounds,u=t[e]^r[0],f=t[e+1]^r[1],p=t[e+2]^r[2],h=t[e+3]^r[3],d=4,l=1;l>>24]^i[f>>>16&255]^o[p>>>8&255]^a[255&h]^r[d++],_=n[f>>>24]^i[p>>>16&255]^o[h>>>8&255]^a[255&u]^r[d++],g=n[p>>>24]^i[h>>>16&255]^o[u>>>8&255]^a[255&f]^r[d++],v=n[h>>>24]^i[u>>>16&255]^o[f>>>8&255]^a[255&p]^r[d++];u=y,f=_,p=g,h=v}y=(c[u>>>24]<<24|c[f>>>16&255]<<16|c[p>>>8&255]<<8|c[255&h])^r[d++],_=(c[f>>>24]<<24|c[p>>>16&255]<<16|c[h>>>8&255]<<8|c[255&u])^r[d++],g=(c[p>>>24]<<24|c[h>>>16&255]<<16|c[u>>>8&255]<<8|c[255&f])^r[d++],v=(c[h>>>24]<<24|c[u>>>16&255]<<16|c[f>>>8&255]<<8|c[255&p])^r[d++];t[e]=y,t[e+1]=_,t[e+2]=g,t[e+3]=v},keySize:8});t.AES=e._createHelper(l)}();var _iv,_sa,_config,_oldOnceData,CryptoJS=_CryptoJS.CryptoJS,getRandomBasic=function(){var t=(new Date).getTime();return function(e){return Math.ceil((t=(9301*t+49297)%233280)/233280*e)}}();function isObject(t){return null!=t&&"[object Object]"==toString.call(t)}function getRandom(){if("function"==typeof Uint32Array){var t="";if("undefined"!=typeof crypto?t=crypto:"undefined"!=typeof msCrypto&&(t=msCrypto),isObject(t)&&t.getRandomValues){var e=new Uint32Array(1);return t.getRandomValues(e)[0]/Math.pow(2,32)}}return getRandomBasic(1e19)/1e19}function buildAESOption(t){return{mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7,iv:t||generateIVData()}}function encryptData(t,e,r,n){var i=buildAESOption(r),o=t;"string"!=typeof t&&(o=JSON.stringify(t)),n||(e=CryptoJS.enc.Base64.parse(e));var a=CryptoJS.enc.Utf8.parse(o),c=CryptoJS.AES.encrypt(a,e,i).toString();return i.iv.clone().concat(CryptoJS.enc.Base64.parse(c)).toString(CryptoJS.enc.Base64)}function decryptData(t,e,r){var n=CryptoJS.enc.Base64.parse(t).toString(),i=n.substr(0,32),o=CryptoJS.enc.Hex.parse(n.substr(32)).toString(CryptoJS.enc.Base64),a=buildAESOption(CryptoJS.enc.Hex.parse(i));return r||(e=CryptoJS.enc.Base64.parse(e)),CryptoJS.AES.decrypt(o,e,a).toString(CryptoJS.enc.Utf8)}function generateIVData(t){t=t||16;for(var e="";t-- >0;){var r=Math.ceil(127*getRandom()).toString(16);e+=2===r.length?r:"0"+r}return CryptoJS.enc.Hex.parse(e)}var _log=console&&console.log||function(){};function isTruthy(t,e){return!!t||(_log(e+"不能为空。"),!1)}function matchType(t,e,r){return typeof t===r||(_log("参数类型错误,"+e+"必须为"+r),!1)}function aesEncrypt(t){try{return encryptData(t,_config.k,_iv)}catch(e){return _log("数据加密异常:"+e),_sa.para.batch_send?"":_oldOnceData.call(_sa.kit,t)}}function formatData(t){var e={key_id:_config.kid,key_hash:_config.khash,nc:1},r="payload";return _sa.para.batch_send&&(e.flush_time=Date.now(),r="payloads"),e[r]=t,e}function encodeTrackData(t){var e="";_sa.para.batch_send?e=formatData(t):e=formatData(aesEncrypt(t));var r=JSON.stringify(e);return"data="+encodeURIComponent(r)+"&gzip=9"}function isObject$1(t){return null!=t&&"[object Object]"==toString.call(t)}function encryptStoreData(t){var e=t.length;if(e>0){for(var r=0;r-1&&0==s.repeated||a.indexOf(p)<0))if(c)if(t.intersectionRatio>=r){var d=s.stay_duration;clearDelay(e,p);var u=function(){var a=tagConfigMap[e].listener,t=a&&a.shouldExpose,r=a&&a.didExpose,o={event_name:c,properties:g};if(t&&_.isFunction(t))try{if(!1===t(e,o))return}catch(e){}if(sa.track(c,g),r&&_.isFunction(r))try{r(e,o)}catch(e){}tagExposedViewIdMap[e].push(p)};d>0?(delayTagViewIdTimerMap[e]||(delayTagViewIdTimerMap[e]={}),delayTagViewIdTimerMap[e][p]=setTimeout(function(){clearDelay(e,p),u()},1e3*d)):u()}else clearDelay(e,p);else _.log("the view event_name error, exposure failed")}})}function checkView(e,a){(a.component||platform_obj).createSelectorQuery().selectAll("."+e).boundingClientRect(function(t){if(_.isArray(t)&&t.length>0){var r={};_.each(t,function(t){var o=getProps(t),n=(_.isEmptyObject(o.config)?a:mergeConfig(o.config,a)).area_rate,i=!1;tagObserveViewIdMap[e]||(tagObserveViewIdMap[e]=[]),_.each(tagObserveViewIdMap[e],function(e){e===o.id&&(i=!0)}),!1===i&&(r[n]||(r[n]=[]),r[n].push(o.id),tagObserveViewIdMap[e].push(o.id))}),_.each(r,function(t,r){observeView(e,t,{area_rate:r,component:a.component})})}}).exec()}function addPageExposure(){isTaroVue3&&setTaroViews(),_.each(tagConfigMap,function(e,a){checkView(a,e)})}function removePageExposure(){_.each(tagsIntersectionMap,function(e){_.each(e,function(e){e.disconnect()})}),_.each(delayTagViewIdTimerMap,function(e){_.each(e,function(e){clearTimeout(e)})}),tagsIntersectionMap={},delayTagViewIdTimerMap={},tagExposedViewIdMap={},tagObserveViewIdMap={},isTaroVue3&&(taroViews=[])}function formatConfig(e){var a={};return _.each(e,function(t,r){switch(r){case"area_rate":t=Number(t),!isNaN(t)&&t>=0&&t<=1?a.area_rate=t:_.log("parameter config.area_rate error. config:",e);break;case"stay_duration":t=Number(t),!isNaN(t)&&t>=0?a.stay_duration=t:_.log("parameter config.stay_duration error. config:",e);break;case"repeated":"false"===t||!1===t||"true"===t||!0===t?a.repeated="false"!==t&&Boolean(t):_.log("parameter config.repeated error. config:",e)}}),a}function mergeClassTag(e,a){return _.isArray(e)?a.concat(e):a}function mergeConfig(e,a){return a=a||{},e=e||{},{area_rate:_.isNumber(e.area_rate)&&e.area_rate>0&&e.area_rate<=1?e.area_rate:a.area_rate,stay_duration:_.isNumber(e.stay_duration)&&e.stay_duration>0?e.stay_duration:a.stay_duration,repeated:_.isBoolean(e.repeated)?e.repeated:a.repeated}}function initClassTagsConfig(e,a){var t={};return _.each(e,function(e){t[e]={area_rate:a.area_rate,stay_duration:a.stay_duration,repeated:a.repeated}}),t}function isComponent(e){return!!(_.isObject(e)&&_.isFunction(e.createSelectorQuery)&&_.isFunction(e.createIntersectionObserver))}var Exposure={plugin_name:"Exposure",config:{class_tags:["sensors-exposure-track"],area_rate:0,stay_duration:0,repeated:!0},isReady:!1,init:function(e,a){if(!e||sa)return!1;_=(sa=e)._,platform_obj=wx;var t=sa.ee;if(_.isObject(a)){var r=this.config.class_tags;this.config=mergeConfig(a,this.config||{}),this.config.class_tags=mergeClassTag(a.class_tags,r),isTaroVue3=a.framework&&a.framework.taro||!1}tagConfigMap=initClassTagsConfig(this.config.class_tags,this.config),t.page.replay("pageShow",addPageExposure),t.page.replay("pageHide",removePageExposure),this.isReady=!0},addObserverByClassName:function(e,a,t){if(!1!==this.isReady)if(_.isString(e)){var r;_.isObject(a)?(a.component&&!isComponent(a.component)&&(_.log("parameter config.component error. config.component:"+a.component),delete a.component),tagConfigMap[e]=tagConfigMap[e]?mergeConfig(a,tagConfigMap[e]):mergeConfig(a,this.config)):tagConfigMap[e]=this.config,_.isObject(t)?tagConfigMap[e].listener=t:t&&_.log("parameter listener error. listener:"+t),r=a&&a.component?_.extend(tagConfigMap[e],{component:a.component}):tagConfigMap[e],isTaroVue3&&setTaroViews(),checkView(e,r)}else _.log("parameter tag error. tag:"+e)},removeObserverByClassName:function(e){!1!==this.isReady&&(_.isString(e)?(tagsIntersectionMap[e]&&(_.each(tagsIntersectionMap[e],function(e){e.disconnect()}),delete tagsIntersectionMap[e]),clearDelay(e),tagConfigMap[e]&&delete tagConfigMap[e],tagExposedViewIdMap[e]&&delete tagExposedViewIdMap[e],tagObserveViewIdMap[e]&&delete tagObserveViewIdMap[e],isTaroVue3&&(taroViews=[])):_.log("parameter tag error. tag:"+e))}},index=createPlugin(Exposure);module.exports=index; \ No newline at end of file +"use strict";var base={plugin_version:"1.19.12"};function createPlugin(e){if("object"==typeof e&&"string"==typeof e.plugin_name&&""!==e.plugin_name)return e.plugin_version=base.plugin_version,e.log=e.log||function(){"object"==typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)},e;"object"==typeof console&&"function"==typeof console.error&&console.error('plugin must contain proprerty "plugin_name"')}var sa=null,_=null,platform_obj=null,isTaroVue3=!1,tagConfigMap={},tagsIntersectionMap={},delayTagViewIdTimerMap={},tagExposedViewIdMap={},tagObserveViewIdMap={},taroViews=[];function createObserver(e,a){var t,r=e.area_rate,o=getCurrentPages(),n=o[o.length-1],i={observeAll:!0,thresholds:[r]};return t=e.component?e.component.createIntersectionObserver(i):platform_obj.createIntersectionObserver(n,i),tagsIntersectionMap[a]||(tagsIntersectionMap[a]=[]),tagsIntersectionMap[a].push(t),t}function getBaseProps(e){var a=e.dataset,t={};return e.id&&(t.$element_id=e.id),a.type&&(t.$element_type=a.type),a.content&&(t.$element_content=a.content),a.name&&(t.$element_name=a.name),t.$url_path=_.getCurrentPath(),t}function getTaro3Dataset(e){var a=_.isEmptyObject(e.dataset)?e.id:e.dataset.sid,t={};return _.each(taroViews,function(e){a===e.uid&&(t=e.dataset)}),t}function getNodesViews(e){var a=[];return _.each(e.childNodes,function(e){a.push({dataset:e.dataset||{},props:e.props||{},uid:e.uid}),e.childNodes&&e.childNodes.length&&(a=a.concat(getNodesViews(e)))}),a}function setTaroViews(){taroViews=[];try{var e=document.body;e&&(taroViews=getNodesViews(e))}catch(e){}}function getProps(e){var a=isTaroVue3?getTaro3Dataset(e):e.dataset,t={},r={},o=null;_.each(a,function(e,a){if("sensorsExposureOption"===a)try{var n=_.isObject(e)?e:JSON.parse(e);o=_.isString(n.event_name)?n.event_name:o,t=_.isObject(n.config)?n.config:t,r=_.isObject(n.properties)?n.properties:r}catch(a){_.log("view attribute data-sensors-exposure-option error. value:",e)}}),_.each(a,function(e,a){if(a.startsWith("sensorsExposureConfig")){var n=a.replace(/^sensorsExposureConfig(.*)/,function(e,a){return a.replace(a[0],a[0].toLocaleLowerCase())});t[n]=e}if(a.startsWith("sensorsExposureProperty")){var i=a.replace(/^sensorsExposureProperty(.*)/,function(e,a){return a.replace(a[0],a[0].toLocaleLowerCase())});r[i]=e}"sensorsExposureEventName"===a&&(o=e)});var n=e.id||_.base64Encode(JSON.stringify({a:r,n:o}));return r=_.extend(getBaseProps({id:e.id,dataset:a}),r),{config:formatConfig(t),props:r,event_name:o,id:n}}function clearDelay(e,a){delayTagViewIdTimerMap[e]&&(a?delayTagViewIdTimerMap[e][a]&&(clearTimeout(delayTagViewIdTimerMap[e][a]),delete delayTagViewIdTimerMap[e][a]):_.each(delayTagViewIdTimerMap[e],function(a,t){clearTimeout(a),delete delayTagViewIdTimerMap[e][t]}))}function observeView(e,a,t){var r=t.area_rate;createObserver(t,e).relativeToViewport().observe("."+e,function(t){var o=t.boundingClientRect,n=t.intersectionRect;if(o.width&&o.height&&(0!==Number(r)||0!==n.bottom||0!==n.top||0!==n.right||0!==n.left)){var i=getProps(t),s=_.isEmptyObject(i.config)?tagConfigMap[e]:mergeConfig(i.config,tagConfigMap[e]),c=i.event_name,p=i.id,g=i.props;if(tagExposedViewIdMap[e]||(tagExposedViewIdMap[e]=[]),!(_.isArray(tagExposedViewIdMap[e])&&tagExposedViewIdMap[e].indexOf(p)>-1&&0==s.repeated||a.indexOf(p)<0))if(c)if(t.intersectionRatio>=r){var d=s.stay_duration;clearDelay(e,p);var u=function(){var a=tagConfigMap[e].listener,t=a&&a.shouldExpose,r=a&&a.didExpose,o={event_name:c,properties:g};if(t&&_.isFunction(t))try{if(!1===t(e,o))return}catch(e){}if(sa.track(c,g),r&&_.isFunction(r))try{r(e,o)}catch(e){}tagExposedViewIdMap[e].push(p)};d>0?(delayTagViewIdTimerMap[e]||(delayTagViewIdTimerMap[e]={}),delayTagViewIdTimerMap[e][p]=setTimeout(function(){clearDelay(e,p),u()},1e3*d)):u()}else clearDelay(e,p);else _.log("the view event_name error, exposure failed")}})}function checkView(e,a){(a.component||platform_obj).createSelectorQuery().selectAll("."+e).boundingClientRect(function(t){if(_.isArray(t)&&t.length>0){var r={};_.each(t,function(t){var o=getProps(t),n=(_.isEmptyObject(o.config)?a:mergeConfig(o.config,a)).area_rate,i=!1;tagObserveViewIdMap[e]||(tagObserveViewIdMap[e]=[]),_.each(tagObserveViewIdMap[e],function(e){e===o.id&&(i=!0)}),!1===i&&(r[n]||(r[n]=[]),r[n].push(o.id),tagObserveViewIdMap[e].push(o.id))}),_.each(r,function(t,r){observeView(e,t,{area_rate:r,component:a.component})})}}).exec()}function addPageExposure(){isTaroVue3&&setTaroViews(),_.each(tagConfigMap,function(e,a){checkView(a,e)})}function removePageExposure(){_.each(tagsIntersectionMap,function(e){_.each(e,function(e){e.disconnect()})}),_.each(delayTagViewIdTimerMap,function(e){_.each(e,function(e){clearTimeout(e)})}),tagsIntersectionMap={},delayTagViewIdTimerMap={},tagExposedViewIdMap={},tagObserveViewIdMap={},isTaroVue3&&(taroViews=[])}function formatConfig(e){var a={};return _.each(e,function(t,r){switch(r){case"area_rate":t=Number(t),!isNaN(t)&&t>=0&&t<=1?a.area_rate=t:_.log("parameter config.area_rate error. config:",e);break;case"stay_duration":t=Number(t),!isNaN(t)&&t>=0?a.stay_duration=t:_.log("parameter config.stay_duration error. config:",e);break;case"repeated":"false"===t||!1===t||"true"===t||!0===t?a.repeated="false"!==t&&Boolean(t):_.log("parameter config.repeated error. config:",e)}}),a}function mergeClassTag(e,a){return _.isArray(e)?a.concat(e):a}function mergeConfig(e,a){return a=a||{},e=e||{},{area_rate:_.isNumber(e.area_rate)&&e.area_rate>0&&e.area_rate<=1?e.area_rate:a.area_rate,stay_duration:_.isNumber(e.stay_duration)&&e.stay_duration>0?e.stay_duration:a.stay_duration,repeated:_.isBoolean(e.repeated)?e.repeated:a.repeated}}function initClassTagsConfig(e,a){var t={};return _.each(e,function(e){t[e]={area_rate:a.area_rate,stay_duration:a.stay_duration,repeated:a.repeated}}),t}function isComponent(e){return!!(_.isObject(e)&&_.isFunction(e.createSelectorQuery)&&_.isFunction(e.createIntersectionObserver))}var Exposure={plugin_name:"Exposure",config:{class_tags:["sensors-exposure-track"],area_rate:0,stay_duration:0,repeated:!0},isReady:!1,init:function(e,a){if(!e||sa)return!1;_=(sa=e)._,platform_obj=wx;var t=sa.ee;if(_.isObject(a)){var r=this.config.class_tags;this.config=mergeConfig(a,this.config||{}),this.config.class_tags=mergeClassTag(a.class_tags,r),isTaroVue3=a.framework&&a.framework.taro||!1}tagConfigMap=initClassTagsConfig(this.config.class_tags,this.config),t.page.replay("pageShow",addPageExposure),t.page.replay("pageHide",removePageExposure),this.isReady=!0},addObserverByClassName:function(e,a,t){if(!1!==this.isReady)if(_.isString(e)){var r;_.isObject(a)?(a.component&&!isComponent(a.component)&&(_.log("parameter config.component error. config.component:"+a.component),delete a.component),tagConfigMap[e]=tagConfigMap[e]?mergeConfig(a,tagConfigMap[e]):mergeConfig(a,this.config)):tagConfigMap[e]=this.config,_.isObject(t)?tagConfigMap[e].listener=t:t&&_.log("parameter listener error. listener:"+t),r=a&&a.component?_.extend(tagConfigMap[e],{component:a.component}):tagConfigMap[e],isTaroVue3&&setTaroViews(),checkView(e,r)}else _.log("parameter tag error. tag:"+e)},removeObserverByClassName:function(e){!1!==this.isReady&&(_.isString(e)?(tagsIntersectionMap[e]&&(_.each(tagsIntersectionMap[e],function(e){e.disconnect()}),delete tagsIntersectionMap[e]),clearDelay(e),tagConfigMap[e]&&delete tagConfigMap[e],tagExposedViewIdMap[e]&&delete tagExposedViewIdMap[e],tagObserveViewIdMap[e]&&delete tagObserveViewIdMap[e],isTaroVue3&&(taroViews=[])):_.log("parameter tag error. tag:"+e))}},index=createPlugin(Exposure);module.exports=index; \ No newline at end of file diff --git a/dist/wechat/plugin/exposure/index.esm.js b/dist/wechat/plugin/exposure/index.esm.js index f546897..e90e9cf 100644 --- a/dist/wechat/plugin/exposure/index.esm.js +++ b/dist/wechat/plugin/exposure/index.esm.js @@ -1 +1 @@ -var base={plugin_version:"1.19.11"};function createPlugin(e){if("object"==typeof e&&"string"==typeof e.plugin_name&&""!==e.plugin_name)return e.plugin_version=base.plugin_version,e.log=e.log||function(){"object"==typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)},e;"object"==typeof console&&"function"==typeof console.error&&console.error('plugin must contain proprerty "plugin_name"')}var sa=null,_=null,platform_obj=null,isTaroVue3=!1,tagConfigMap={},tagsIntersectionMap={},delayTagViewIdTimerMap={},tagExposedViewIdMap={},tagObserveViewIdMap={},taroViews=[];function createObserver(e,a){var t,r=e.area_rate,o=getCurrentPages(),n=o[o.length-1],i={observeAll:!0,thresholds:[r]};return t=e.component?e.component.createIntersectionObserver(i):platform_obj.createIntersectionObserver(n,i),tagsIntersectionMap[a]||(tagsIntersectionMap[a]=[]),tagsIntersectionMap[a].push(t),t}function getBaseProps(e){var a=e.dataset,t={};return e.id&&(t.$element_id=e.id),a.type&&(t.$element_type=a.type),a.content&&(t.$element_content=a.content),a.name&&(t.$element_name=a.name),t.$url_path=_.getCurrentPath(),t}function getTaro3Dataset(e){var a=_.isEmptyObject(e.dataset)?e.id:e.dataset.sid,t={};return _.each(taroViews,function(e){a===e.uid&&(t=e.dataset)}),t}function getNodesViews(e){var a=[];return _.each(e.childNodes,function(e){a.push({dataset:e.dataset||{},props:e.props||{},uid:e.uid}),e.childNodes&&e.childNodes.length&&(a=a.concat(getNodesViews(e)))}),a}function setTaroViews(){taroViews=[];try{var e=document.body;e&&(taroViews=getNodesViews(e))}catch(e){}}function getProps(e){var a=isTaroVue3?getTaro3Dataset(e):e.dataset,t={},r={},o=null;_.each(a,function(e,a){if("sensorsExposureOption"===a)try{var n=_.isObject(e)?e:JSON.parse(e);o=_.isString(n.event_name)?n.event_name:o,t=_.isObject(n.config)?n.config:t,r=_.isObject(n.properties)?n.properties:r}catch(a){_.log("view attribute data-sensors-exposure-option error. value:",e)}}),_.each(a,function(e,a){if(a.startsWith("sensorsExposureConfig")){var n=a.replace(/^sensorsExposureConfig(.*)/,function(e,a){return a.replace(a[0],a[0].toLocaleLowerCase())});t[n]=e}if(a.startsWith("sensorsExposureProperty")){var i=a.replace(/^sensorsExposureProperty(.*)/,function(e,a){return a.replace(a[0],a[0].toLocaleLowerCase())});r[i]=e}"sensorsExposureEventName"===a&&(o=e)});var n=e.id||_.base64Encode(JSON.stringify({a:r,n:o}));return r=_.extend(getBaseProps({id:e.id,dataset:a}),r),{config:formatConfig(t),props:r,event_name:o,id:n}}function clearDelay(e,a){delayTagViewIdTimerMap[e]&&(a?delayTagViewIdTimerMap[e][a]&&(clearTimeout(delayTagViewIdTimerMap[e][a]),delete delayTagViewIdTimerMap[e][a]):_.each(delayTagViewIdTimerMap[e],function(a,t){clearTimeout(a),delete delayTagViewIdTimerMap[e][t]}))}function observeView(e,a,t){var r=t.area_rate;createObserver(t,e).relativeToViewport().observe("."+e,function(t){var o=t.boundingClientRect,n=t.intersectionRect;if(o.width&&o.height&&(0!==Number(r)||0!==n.bottom||0!==n.top||0!==n.right||0!==n.left)){var i=getProps(t),s=_.isEmptyObject(i.config)?tagConfigMap[e]:mergeConfig(i.config,tagConfigMap[e]),c=i.event_name,p=i.id,g=i.props;if(tagExposedViewIdMap[e]||(tagExposedViewIdMap[e]=[]),!(_.isArray(tagExposedViewIdMap[e])&&tagExposedViewIdMap[e].indexOf(p)>-1&&0==s.repeated||a.indexOf(p)<0))if(c)if(t.intersectionRatio>=r){var d=s.stay_duration;clearDelay(e,p);var u=function(){var a=tagConfigMap[e].listener,t=a&&a.shouldExpose,r=a&&a.didExpose,o={event_name:c,properties:g};if(t&&_.isFunction(t))try{if(!1===t(e,o))return}catch(e){}if(sa.track(c,g),r&&_.isFunction(r))try{r(e,o)}catch(e){}tagExposedViewIdMap[e].push(p)};d>0?(delayTagViewIdTimerMap[e]||(delayTagViewIdTimerMap[e]={}),delayTagViewIdTimerMap[e][p]=setTimeout(function(){clearDelay(e,p),u()},1e3*d)):u()}else clearDelay(e,p);else _.log("the view event_name error, exposure failed")}})}function checkView(e,a){(a.component||platform_obj).createSelectorQuery().selectAll("."+e).boundingClientRect(function(t){if(_.isArray(t)&&t.length>0){var r={};_.each(t,function(t){var o=getProps(t),n=(_.isEmptyObject(o.config)?a:mergeConfig(o.config,a)).area_rate,i=!1;tagObserveViewIdMap[e]||(tagObserveViewIdMap[e]=[]),_.each(tagObserveViewIdMap[e],function(e){e===o.id&&(i=!0)}),!1===i&&(r[n]||(r[n]=[]),r[n].push(o.id),tagObserveViewIdMap[e].push(o.id))}),_.each(r,function(t,r){observeView(e,t,{area_rate:r,component:a.component})})}}).exec()}function addPageExposure(){isTaroVue3&&setTaroViews(),_.each(tagConfigMap,function(e,a){checkView(a,e)})}function removePageExposure(){_.each(tagsIntersectionMap,function(e){_.each(e,function(e){e.disconnect()})}),_.each(delayTagViewIdTimerMap,function(e){_.each(e,function(e){clearTimeout(e)})}),tagsIntersectionMap={},delayTagViewIdTimerMap={},tagExposedViewIdMap={},tagObserveViewIdMap={},isTaroVue3&&(taroViews=[])}function formatConfig(e){var a={};return _.each(e,function(t,r){switch(r){case"area_rate":t=Number(t),!isNaN(t)&&t>=0&&t<=1?a.area_rate=t:_.log("parameter config.area_rate error. config:",e);break;case"stay_duration":t=Number(t),!isNaN(t)&&t>=0?a.stay_duration=t:_.log("parameter config.stay_duration error. config:",e);break;case"repeated":"false"===t||!1===t||"true"===t||!0===t?a.repeated="false"!==t&&Boolean(t):_.log("parameter config.repeated error. config:",e)}}),a}function mergeClassTag(e,a){return _.isArray(e)?a.concat(e):a}function mergeConfig(e,a){return a=a||{},e=e||{},{area_rate:_.isNumber(e.area_rate)&&e.area_rate>0&&e.area_rate<=1?e.area_rate:a.area_rate,stay_duration:_.isNumber(e.stay_duration)&&e.stay_duration>0?e.stay_duration:a.stay_duration,repeated:_.isBoolean(e.repeated)?e.repeated:a.repeated}}function initClassTagsConfig(e,a){var t={};return _.each(e,function(e){t[e]={area_rate:a.area_rate,stay_duration:a.stay_duration,repeated:a.repeated}}),t}function isComponent(e){return!!(_.isObject(e)&&_.isFunction(e.createSelectorQuery)&&_.isFunction(e.createIntersectionObserver))}var Exposure={plugin_name:"Exposure",config:{class_tags:["sensors-exposure-track"],area_rate:0,stay_duration:0,repeated:!0},isReady:!1,init:function(e,a){if(!e||sa)return!1;_=(sa=e)._,platform_obj=wx;var t=sa.ee;if(_.isObject(a)){var r=this.config.class_tags;this.config=mergeConfig(a,this.config||{}),this.config.class_tags=mergeClassTag(a.class_tags,r),isTaroVue3=a.framework&&a.framework.taro||!1}tagConfigMap=initClassTagsConfig(this.config.class_tags,this.config),t.page.replay("pageShow",addPageExposure),t.page.replay("pageHide",removePageExposure),this.isReady=!0},addObserverByClassName:function(e,a,t){if(!1!==this.isReady)if(_.isString(e)){var r;_.isObject(a)?(a.component&&!isComponent(a.component)&&(_.log("parameter config.component error. config.component:"+a.component),delete a.component),tagConfigMap[e]=tagConfigMap[e]?mergeConfig(a,tagConfigMap[e]):mergeConfig(a,this.config)):tagConfigMap[e]=this.config,_.isObject(t)?tagConfigMap[e].listener=t:t&&_.log("parameter listener error. listener:"+t),r=a&&a.component?_.extend(tagConfigMap[e],{component:a.component}):tagConfigMap[e],isTaroVue3&&setTaroViews(),checkView(e,r)}else _.log("parameter tag error. tag:"+e)},removeObserverByClassName:function(e){!1!==this.isReady&&(_.isString(e)?(tagsIntersectionMap[e]&&(_.each(tagsIntersectionMap[e],function(e){e.disconnect()}),delete tagsIntersectionMap[e]),clearDelay(e),tagConfigMap[e]&&delete tagConfigMap[e],tagExposedViewIdMap[e]&&delete tagExposedViewIdMap[e],tagObserveViewIdMap[e]&&delete tagObserveViewIdMap[e],isTaroVue3&&(taroViews=[])):_.log("parameter tag error. tag:"+e))}},index=createPlugin(Exposure);export default index; \ No newline at end of file +var base={plugin_version:"1.19.12"};function createPlugin(e){if("object"==typeof e&&"string"==typeof e.plugin_name&&""!==e.plugin_name)return e.plugin_version=base.plugin_version,e.log=e.log||function(){"object"==typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)},e;"object"==typeof console&&"function"==typeof console.error&&console.error('plugin must contain proprerty "plugin_name"')}var sa=null,_=null,platform_obj=null,isTaroVue3=!1,tagConfigMap={},tagsIntersectionMap={},delayTagViewIdTimerMap={},tagExposedViewIdMap={},tagObserveViewIdMap={},taroViews=[];function createObserver(e,a){var t,r=e.area_rate,o=getCurrentPages(),n=o[o.length-1],i={observeAll:!0,thresholds:[r]};return t=e.component?e.component.createIntersectionObserver(i):platform_obj.createIntersectionObserver(n,i),tagsIntersectionMap[a]||(tagsIntersectionMap[a]=[]),tagsIntersectionMap[a].push(t),t}function getBaseProps(e){var a=e.dataset,t={};return e.id&&(t.$element_id=e.id),a.type&&(t.$element_type=a.type),a.content&&(t.$element_content=a.content),a.name&&(t.$element_name=a.name),t.$url_path=_.getCurrentPath(),t}function getTaro3Dataset(e){var a=_.isEmptyObject(e.dataset)?e.id:e.dataset.sid,t={};return _.each(taroViews,function(e){a===e.uid&&(t=e.dataset)}),t}function getNodesViews(e){var a=[];return _.each(e.childNodes,function(e){a.push({dataset:e.dataset||{},props:e.props||{},uid:e.uid}),e.childNodes&&e.childNodes.length&&(a=a.concat(getNodesViews(e)))}),a}function setTaroViews(){taroViews=[];try{var e=document.body;e&&(taroViews=getNodesViews(e))}catch(e){}}function getProps(e){var a=isTaroVue3?getTaro3Dataset(e):e.dataset,t={},r={},o=null;_.each(a,function(e,a){if("sensorsExposureOption"===a)try{var n=_.isObject(e)?e:JSON.parse(e);o=_.isString(n.event_name)?n.event_name:o,t=_.isObject(n.config)?n.config:t,r=_.isObject(n.properties)?n.properties:r}catch(a){_.log("view attribute data-sensors-exposure-option error. value:",e)}}),_.each(a,function(e,a){if(a.startsWith("sensorsExposureConfig")){var n=a.replace(/^sensorsExposureConfig(.*)/,function(e,a){return a.replace(a[0],a[0].toLocaleLowerCase())});t[n]=e}if(a.startsWith("sensorsExposureProperty")){var i=a.replace(/^sensorsExposureProperty(.*)/,function(e,a){return a.replace(a[0],a[0].toLocaleLowerCase())});r[i]=e}"sensorsExposureEventName"===a&&(o=e)});var n=e.id||_.base64Encode(JSON.stringify({a:r,n:o}));return r=_.extend(getBaseProps({id:e.id,dataset:a}),r),{config:formatConfig(t),props:r,event_name:o,id:n}}function clearDelay(e,a){delayTagViewIdTimerMap[e]&&(a?delayTagViewIdTimerMap[e][a]&&(clearTimeout(delayTagViewIdTimerMap[e][a]),delete delayTagViewIdTimerMap[e][a]):_.each(delayTagViewIdTimerMap[e],function(a,t){clearTimeout(a),delete delayTagViewIdTimerMap[e][t]}))}function observeView(e,a,t){var r=t.area_rate;createObserver(t,e).relativeToViewport().observe("."+e,function(t){var o=t.boundingClientRect,n=t.intersectionRect;if(o.width&&o.height&&(0!==Number(r)||0!==n.bottom||0!==n.top||0!==n.right||0!==n.left)){var i=getProps(t),s=_.isEmptyObject(i.config)?tagConfigMap[e]:mergeConfig(i.config,tagConfigMap[e]),c=i.event_name,p=i.id,g=i.props;if(tagExposedViewIdMap[e]||(tagExposedViewIdMap[e]=[]),!(_.isArray(tagExposedViewIdMap[e])&&tagExposedViewIdMap[e].indexOf(p)>-1&&0==s.repeated||a.indexOf(p)<0))if(c)if(t.intersectionRatio>=r){var d=s.stay_duration;clearDelay(e,p);var u=function(){var a=tagConfigMap[e].listener,t=a&&a.shouldExpose,r=a&&a.didExpose,o={event_name:c,properties:g};if(t&&_.isFunction(t))try{if(!1===t(e,o))return}catch(e){}if(sa.track(c,g),r&&_.isFunction(r))try{r(e,o)}catch(e){}tagExposedViewIdMap[e].push(p)};d>0?(delayTagViewIdTimerMap[e]||(delayTagViewIdTimerMap[e]={}),delayTagViewIdTimerMap[e][p]=setTimeout(function(){clearDelay(e,p),u()},1e3*d)):u()}else clearDelay(e,p);else _.log("the view event_name error, exposure failed")}})}function checkView(e,a){(a.component||platform_obj).createSelectorQuery().selectAll("."+e).boundingClientRect(function(t){if(_.isArray(t)&&t.length>0){var r={};_.each(t,function(t){var o=getProps(t),n=(_.isEmptyObject(o.config)?a:mergeConfig(o.config,a)).area_rate,i=!1;tagObserveViewIdMap[e]||(tagObserveViewIdMap[e]=[]),_.each(tagObserveViewIdMap[e],function(e){e===o.id&&(i=!0)}),!1===i&&(r[n]||(r[n]=[]),r[n].push(o.id),tagObserveViewIdMap[e].push(o.id))}),_.each(r,function(t,r){observeView(e,t,{area_rate:r,component:a.component})})}}).exec()}function addPageExposure(){isTaroVue3&&setTaroViews(),_.each(tagConfigMap,function(e,a){checkView(a,e)})}function removePageExposure(){_.each(tagsIntersectionMap,function(e){_.each(e,function(e){e.disconnect()})}),_.each(delayTagViewIdTimerMap,function(e){_.each(e,function(e){clearTimeout(e)})}),tagsIntersectionMap={},delayTagViewIdTimerMap={},tagExposedViewIdMap={},tagObserveViewIdMap={},isTaroVue3&&(taroViews=[])}function formatConfig(e){var a={};return _.each(e,function(t,r){switch(r){case"area_rate":t=Number(t),!isNaN(t)&&t>=0&&t<=1?a.area_rate=t:_.log("parameter config.area_rate error. config:",e);break;case"stay_duration":t=Number(t),!isNaN(t)&&t>=0?a.stay_duration=t:_.log("parameter config.stay_duration error. config:",e);break;case"repeated":"false"===t||!1===t||"true"===t||!0===t?a.repeated="false"!==t&&Boolean(t):_.log("parameter config.repeated error. config:",e)}}),a}function mergeClassTag(e,a){return _.isArray(e)?a.concat(e):a}function mergeConfig(e,a){return a=a||{},e=e||{},{area_rate:_.isNumber(e.area_rate)&&e.area_rate>0&&e.area_rate<=1?e.area_rate:a.area_rate,stay_duration:_.isNumber(e.stay_duration)&&e.stay_duration>0?e.stay_duration:a.stay_duration,repeated:_.isBoolean(e.repeated)?e.repeated:a.repeated}}function initClassTagsConfig(e,a){var t={};return _.each(e,function(e){t[e]={area_rate:a.area_rate,stay_duration:a.stay_duration,repeated:a.repeated}}),t}function isComponent(e){return!!(_.isObject(e)&&_.isFunction(e.createSelectorQuery)&&_.isFunction(e.createIntersectionObserver))}var Exposure={plugin_name:"Exposure",config:{class_tags:["sensors-exposure-track"],area_rate:0,stay_duration:0,repeated:!0},isReady:!1,init:function(e,a){if(!e||sa)return!1;_=(sa=e)._,platform_obj=wx;var t=sa.ee;if(_.isObject(a)){var r=this.config.class_tags;this.config=mergeConfig(a,this.config||{}),this.config.class_tags=mergeClassTag(a.class_tags,r),isTaroVue3=a.framework&&a.framework.taro||!1}tagConfigMap=initClassTagsConfig(this.config.class_tags,this.config),t.page.replay("pageShow",addPageExposure),t.page.replay("pageHide",removePageExposure),this.isReady=!0},addObserverByClassName:function(e,a,t){if(!1!==this.isReady)if(_.isString(e)){var r;_.isObject(a)?(a.component&&!isComponent(a.component)&&(_.log("parameter config.component error. config.component:"+a.component),delete a.component),tagConfigMap[e]=tagConfigMap[e]?mergeConfig(a,tagConfigMap[e]):mergeConfig(a,this.config)):tagConfigMap[e]=this.config,_.isObject(t)?tagConfigMap[e].listener=t:t&&_.log("parameter listener error. listener:"+t),r=a&&a.component?_.extend(tagConfigMap[e],{component:a.component}):tagConfigMap[e],isTaroVue3&&setTaroViews(),checkView(e,r)}else _.log("parameter tag error. tag:"+e)},removeObserverByClassName:function(e){!1!==this.isReady&&(_.isString(e)?(tagsIntersectionMap[e]&&(_.each(tagsIntersectionMap[e],function(e){e.disconnect()}),delete tagsIntersectionMap[e]),clearDelay(e),tagConfigMap[e]&&delete tagConfigMap[e],tagExposedViewIdMap[e]&&delete tagExposedViewIdMap[e],tagObserveViewIdMap[e]&&delete tagObserveViewIdMap[e],isTaroVue3&&(taroViews=[])):_.log("parameter tag error. tag:"+e))}},index=createPlugin(Exposure);export default index; \ No newline at end of file diff --git a/dist/wechat/plugin/general-encryption/index.cmd.js b/dist/wechat/plugin/general-encryption/index.cmd.js index 9eac4bd..8713a97 100644 --- a/dist/wechat/plugin/general-encryption/index.cmd.js +++ b/dist/wechat/plugin/general-encryption/index.cmd.js @@ -1 +1 @@ -"use strict";var sd,_,_oldOnceData,_log,option,base={plugin_version:"1.19.11"};function createPlugin(t){if("object"==typeof t&&"string"==typeof t.plugin_name&&""!==t.plugin_name)return t.plugin_version=base.plugin_version,t.log=t.log||function(){"object"==typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)},t;"object"==typeof console&&"function"==typeof console.error&&console.error('plugin must contain proprerty "plugin_name"')}function formatData(t){try{var n=option.encrypt_utils.encryptSymmetricKeyWithPublicKey(option.pub_key),e={pkv:option.pkv,ekey:n};return sd.para.batch_send?e.flush_time=Date.now():t=[t],e.payloads=t,e}catch(n){return t}}function encodeTrackData(t){var n="";sd.para.batch_send?n=formatData(t):n=formatData(smEncrypt(t));var e=JSON.stringify(n);return"data="+encodeURIComponent(e)}function encryptData(t){try{var n=option.encrypt_utils.encryptEvent;if(sd._.isFunction(n)){var e=n(t);return sd._.base64Encode(e)}return t}catch(n){return _log("Encrypted data exception:"+n),t}}function encryptStoreData(t){var n=t.length;if(n>0){for(var e=0;e0){for(var e=0;e0){for(var e=0;e0){for(var e=0;e-1?o>-1?s+l+"#"+a.substring(1,o)+g(a.substring(o,a.length)):s+l+a+"&"+u:s+l+"#"+a.substring(1)+"?"+u):(o=l.indexOf("_sasdk"),r=/^\?(\w)+/.test(l)?o>-1?s+"?"+g(l.substring(1))+a:s+l+"&"+u+a:s+"?"+u+a);return r},h5Linker.init=function(i){i?(this._=i._,this.store=i.store,this.log=i._.logger.info||log,this.is_ready=!0):log("H5Linker plugin initialization failed")},h5Linker.plugin_name="H5Linker",h5Linker.addDistinctIdToUrl=function(i,e){return this.is_ready?this._.isString(i)&&""!==i&&/^http(s)?:\/\//.test(i)?h5Linker.rewriteUrl(i,e):(this.log("error: URL format error"),i):(this.log("H5Linker plugin not initialized"),i)};var index=createPlugin(h5Linker);module.exports=index; \ No newline at end of file +"use strict";var base={plugin_version:"1.19.12"};function createPlugin(i){if("object"==typeof i&&"string"==typeof i.plugin_name&&""!==i.plugin_name)return i.plugin_version=base.plugin_version,i.log=i.log||function(){"object"==typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)},i;"object"==typeof console&&"function"==typeof console.error&&console.error('plugin must contain proprerty "plugin_name"')}var h5Linker={is_ready:!1},log=console&&console.log||function(){};h5Linker.getSasdkValue=function(){var i=this.store.getDistinctId()||"",e=this.store.getFirstId()||"";return this._.urlSafeBase64&&this._.urlSafeBase64.encode?i=i?this._.urlSafeBase64.trim(this._.urlSafeBase64.encode(this._.base64Encode(i))):"":this._.rot13obfs&&(i=i?this._.rot13obfs(i):""),encodeURIComponent(e?"f"+i:"d"+i)},h5Linker.rewriteUrl=function(i,e){if(!this.is_ready)return this.log("h5Linker plugin not initialized"),i;var n=this,t=/([^?#]+)(\?[^#]*)?(#.*)?/.exec(i),r="";if(!t)return i;var o,s=t[1]||"",l=t[2]||"",a=t[3]||"",u="_sasdk="+this.getSasdkValue(),g=function(i){var e=i.split("&"),t=[];return n._.each(e,function(i){i.indexOf("_sasdk=")>-1?t.push(u):t.push(i)}),t.join("&")};(e=!!this._.isBoolean(e)&&e)?(o=a.indexOf("_sasdk"),r=a.indexOf("?")>-1?o>-1?s+l+"#"+a.substring(1,o)+g(a.substring(o,a.length)):s+l+a+"&"+u:s+l+"#"+a.substring(1)+"?"+u):(o=l.indexOf("_sasdk"),r=/^\?(\w)+/.test(l)?o>-1?s+"?"+g(l.substring(1))+a:s+l+"&"+u+a:s+"?"+u+a);return r},h5Linker.init=function(i){i?(this._=i._,this.store=i.store,this.log=i._.logger.info||log,this.is_ready=!0):log("H5Linker plugin initialization failed")},h5Linker.plugin_name="H5Linker",h5Linker.addDistinctIdToUrl=function(i,e){return this.is_ready?this._.isString(i)&&""!==i&&/^http(s)?:\/\//.test(i)?h5Linker.rewriteUrl(i,e):(this.log("error: URL format error"),i):(this.log("H5Linker plugin not initialized"),i)};var index=createPlugin(h5Linker);module.exports=index; \ No newline at end of file diff --git a/dist/wechat/plugin/h5-linker/index.esm.js b/dist/wechat/plugin/h5-linker/index.esm.js index a9db592..81009ed 100644 --- a/dist/wechat/plugin/h5-linker/index.esm.js +++ b/dist/wechat/plugin/h5-linker/index.esm.js @@ -1 +1 @@ -var base={plugin_version:"1.19.11"};function createPlugin(i){if("object"==typeof i&&"string"==typeof i.plugin_name&&""!==i.plugin_name)return i.plugin_version=base.plugin_version,i.log=i.log||function(){"object"==typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)},i;"object"==typeof console&&"function"==typeof console.error&&console.error('plugin must contain proprerty "plugin_name"')}var h5Linker={is_ready:!1},log=console&&console.log||function(){};h5Linker.getSasdkValue=function(){var i=this.store.getDistinctId()||"",e=this.store.getFirstId()||"";return this._.urlSafeBase64&&this._.urlSafeBase64.encode?i=i?this._.urlSafeBase64.trim(this._.urlSafeBase64.encode(this._.base64Encode(i))):"":this._.rot13obfs&&(i=i?this._.rot13obfs(i):""),encodeURIComponent(e?"f"+i:"d"+i)},h5Linker.rewriteUrl=function(i,e){if(!this.is_ready)return this.log("h5Linker plugin not initialized"),i;var n=this,t=/([^?#]+)(\?[^#]*)?(#.*)?/.exec(i),r="";if(!t)return i;var o,s=t[1]||"",l=t[2]||"",a=t[3]||"",u="_sasdk="+this.getSasdkValue(),g=function(i){var e=i.split("&"),t=[];return n._.each(e,function(i){i.indexOf("_sasdk=")>-1?t.push(u):t.push(i)}),t.join("&")};(e=!!this._.isBoolean(e)&&e)?(o=a.indexOf("_sasdk"),r=a.indexOf("?")>-1?o>-1?s+l+"#"+a.substring(1,o)+g(a.substring(o,a.length)):s+l+a+"&"+u:s+l+"#"+a.substring(1)+"?"+u):(o=l.indexOf("_sasdk"),r=/^\?(\w)+/.test(l)?o>-1?s+"?"+g(l.substring(1))+a:s+l+"&"+u+a:s+"?"+u+a);return r},h5Linker.init=function(i){i?(this._=i._,this.store=i.store,this.log=i._.logger.info||log,this.is_ready=!0):log("H5Linker plugin initialization failed")},h5Linker.plugin_name="H5Linker",h5Linker.addDistinctIdToUrl=function(i,e){return this.is_ready?this._.isString(i)&&""!==i&&/^http(s)?:\/\//.test(i)?h5Linker.rewriteUrl(i,e):(this.log("error: URL format error"),i):(this.log("H5Linker plugin not initialized"),i)};var index=createPlugin(h5Linker);export default index; \ No newline at end of file +var base={plugin_version:"1.19.12"};function createPlugin(i){if("object"==typeof i&&"string"==typeof i.plugin_name&&""!==i.plugin_name)return i.plugin_version=base.plugin_version,i.log=i.log||function(){"object"==typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)},i;"object"==typeof console&&"function"==typeof console.error&&console.error('plugin must contain proprerty "plugin_name"')}var h5Linker={is_ready:!1},log=console&&console.log||function(){};h5Linker.getSasdkValue=function(){var i=this.store.getDistinctId()||"",e=this.store.getFirstId()||"";return this._.urlSafeBase64&&this._.urlSafeBase64.encode?i=i?this._.urlSafeBase64.trim(this._.urlSafeBase64.encode(this._.base64Encode(i))):"":this._.rot13obfs&&(i=i?this._.rot13obfs(i):""),encodeURIComponent(e?"f"+i:"d"+i)},h5Linker.rewriteUrl=function(i,e){if(!this.is_ready)return this.log("h5Linker plugin not initialized"),i;var n=this,t=/([^?#]+)(\?[^#]*)?(#.*)?/.exec(i),r="";if(!t)return i;var o,s=t[1]||"",l=t[2]||"",a=t[3]||"",u="_sasdk="+this.getSasdkValue(),g=function(i){var e=i.split("&"),t=[];return n._.each(e,function(i){i.indexOf("_sasdk=")>-1?t.push(u):t.push(i)}),t.join("&")};(e=!!this._.isBoolean(e)&&e)?(o=a.indexOf("_sasdk"),r=a.indexOf("?")>-1?o>-1?s+l+"#"+a.substring(1,o)+g(a.substring(o,a.length)):s+l+a+"&"+u:s+l+"#"+a.substring(1)+"?"+u):(o=l.indexOf("_sasdk"),r=/^\?(\w)+/.test(l)?o>-1?s+"?"+g(l.substring(1))+a:s+l+"&"+u+a:s+"?"+u+a);return r},h5Linker.init=function(i){i?(this._=i._,this.store=i.store,this.log=i._.logger.info||log,this.is_ready=!0):log("H5Linker plugin initialization failed")},h5Linker.plugin_name="H5Linker",h5Linker.addDistinctIdToUrl=function(i,e){return this.is_ready?this._.isString(i)&&""!==i&&/^http(s)?:\/\//.test(i)?h5Linker.rewriteUrl(i,e):(this.log("error: URL format error"),i):(this.log("H5Linker plugin not initialized"),i)};var index=createPlugin(h5Linker);export default index; \ No newline at end of file diff --git a/dist/wechat/plugin/register-properties/index.cmd.js b/dist/wechat/plugin/register-properties/index.cmd.js index 76220f0..57e2f41 100644 --- a/dist/wechat/plugin/register-properties/index.cmd.js +++ b/dist/wechat/plugin/register-properties/index.cmd.js @@ -1 +1 @@ -"use strict";var base={plugin_version:"1.19.11"};function createPlugin(e){if("object"==typeof e&&"string"==typeof e.plugin_name&&""!==e.plugin_name)return e.plugin_version=base.plugin_version,e.log=e.log||function(){"object"==typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)},e;"object"==typeof console&&"function"==typeof console.error&&console.error('plugin must contain proprerty "plugin_name"')}var hasOwnProperty=Object.prototype.hasOwnProperty;function isFunction(e){if(!e)return!1;var t=Object.prototype.toString.call(e);return"[object Function]"==t||"[object AsyncFunction]"==t}function isObject(e){return null!=e&&"[object Object]"==Object.prototype.toString.call(e)}function isString(e){return"[object String]"==toString.call(e)}function log(){if("object"==typeof console&&console.log){isString(arguments[0])&&(arguments[0]="sensors registerProperties————"+arguments[0]);try{return console.log.apply(console,arguments)}catch(e){console.log("sensors registerProperties————",arguments[0])}}}function extend(e){return each(Array.prototype.slice.call(arguments,1),function(t){for(var r in t)void 0!==t[r]&&(e[r]=t[r])}),e}function each(e,t,r){var o=Array.prototype.forEach,n={};if(null==e)return!1;if(o&&e.forEach===o)e.forEach(t,r);else if(e.length===+e.length){for(var i=0,s=e.length;i0&®ister_list.push(e):_.log("参数错误!")},RegisterProperties.hookRegister=function(e){_.isFunction(e)&®ister_list.push(e)};var index=createPlugin(RegisterProperties);module.exports=index; \ No newline at end of file +"use strict";var base={plugin_version:"1.19.12"};function createPlugin(e){if("object"==typeof e&&"string"==typeof e.plugin_name&&""!==e.plugin_name)return e.plugin_version=base.plugin_version,e.log=e.log||function(){"object"==typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)},e;"object"==typeof console&&"function"==typeof console.error&&console.error('plugin must contain proprerty "plugin_name"')}var hasOwnProperty=Object.prototype.hasOwnProperty;function isFunction(e){if(!e)return!1;var t=Object.prototype.toString.call(e);return"[object Function]"==t||"[object AsyncFunction]"==t}function isObject(e){return null!=e&&"[object Object]"==Object.prototype.toString.call(e)}function isString(e){return"[object String]"==toString.call(e)}function log(){if("object"==typeof console&&console.log){isString(arguments[0])&&(arguments[0]="sensors registerProperties————"+arguments[0]);try{return console.log.apply(console,arguments)}catch(e){console.log("sensors registerProperties————",arguments[0])}}}function extend(e){return each(Array.prototype.slice.call(arguments,1),function(t){for(var r in t)void 0!==t[r]&&(e[r]=t[r])}),e}function each(e,t,r){var o=Array.prototype.forEach,n={};if(null==e)return!1;if(o&&e.forEach===o)e.forEach(t,r);else if(e.length===+e.length){for(var i=0,s=e.length;i0&®ister_list.push(e):_.log("参数错误!")},RegisterProperties.hookRegister=function(e){_.isFunction(e)&®ister_list.push(e)};var index=createPlugin(RegisterProperties);module.exports=index; \ No newline at end of file diff --git a/dist/wechat/plugin/register-properties/index.esm.js b/dist/wechat/plugin/register-properties/index.esm.js index 8f84670..eeb402f 100644 --- a/dist/wechat/plugin/register-properties/index.esm.js +++ b/dist/wechat/plugin/register-properties/index.esm.js @@ -1 +1 @@ -var base={plugin_version:"1.19.11"};function createPlugin(e){if("object"==typeof e&&"string"==typeof e.plugin_name&&""!==e.plugin_name)return e.plugin_version=base.plugin_version,e.log=e.log||function(){"object"==typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)},e;"object"==typeof console&&"function"==typeof console.error&&console.error('plugin must contain proprerty "plugin_name"')}var hasOwnProperty=Object.prototype.hasOwnProperty;function isFunction(e){if(!e)return!1;var t=Object.prototype.toString.call(e);return"[object Function]"==t||"[object AsyncFunction]"==t}function isObject(e){return null!=e&&"[object Object]"==Object.prototype.toString.call(e)}function isString(e){return"[object String]"==toString.call(e)}function log(){if("object"==typeof console&&console.log){isString(arguments[0])&&(arguments[0]="sensors registerProperties————"+arguments[0]);try{return console.log.apply(console,arguments)}catch(e){console.log("sensors registerProperties————",arguments[0])}}}function extend(e){return each(Array.prototype.slice.call(arguments,1),function(t){for(var r in t)void 0!==t[r]&&(e[r]=t[r])}),e}function each(e,t,r){var o=Array.prototype.forEach,n={};if(null==e)return!1;if(o&&e.forEach===o)e.forEach(t,r);else if(e.length===+e.length){for(var i=0,s=e.length;i0&®ister_list.push(e):_.log("参数错误!")},RegisterProperties.hookRegister=function(e){_.isFunction(e)&®ister_list.push(e)};var index=createPlugin(RegisterProperties);export default index; \ No newline at end of file +var base={plugin_version:"1.19.12"};function createPlugin(e){if("object"==typeof e&&"string"==typeof e.plugin_name&&""!==e.plugin_name)return e.plugin_version=base.plugin_version,e.log=e.log||function(){"object"==typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)},e;"object"==typeof console&&"function"==typeof console.error&&console.error('plugin must contain proprerty "plugin_name"')}var hasOwnProperty=Object.prototype.hasOwnProperty;function isFunction(e){if(!e)return!1;var t=Object.prototype.toString.call(e);return"[object Function]"==t||"[object AsyncFunction]"==t}function isObject(e){return null!=e&&"[object Object]"==Object.prototype.toString.call(e)}function isString(e){return"[object String]"==toString.call(e)}function log(){if("object"==typeof console&&console.log){isString(arguments[0])&&(arguments[0]="sensors registerProperties————"+arguments[0]);try{return console.log.apply(console,arguments)}catch(e){console.log("sensors registerProperties————",arguments[0])}}}function extend(e){return each(Array.prototype.slice.call(arguments,1),function(t){for(var r in t)void 0!==t[r]&&(e[r]=t[r])}),e}function each(e,t,r){var o=Array.prototype.forEach,n={};if(null==e)return!1;if(o&&e.forEach===o)e.forEach(t,r);else if(e.length===+e.length){for(var i=0,s=e.length;i0&®ister_list.push(e):_.log("参数错误!")},RegisterProperties.hookRegister=function(e){_.isFunction(e)&®ister_list.push(e)};var index=createPlugin(RegisterProperties);export default index; \ No newline at end of file diff --git a/dist/wechat/plugin/session-event/index.cmd.js b/dist/wechat/plugin/session-event/index.cmd.js index c1101f6..89e1dc4 100644 --- a/dist/wechat/plugin/session-event/index.cmd.js +++ b/dist/wechat/plugin/session-event/index.cmd.js @@ -1 +1 @@ -"use strict";var base={plugin_version:"1.19.11"};function createPlugin(e){if("object"==typeof e&&"string"==typeof e.plugin_name&&""!==e.plugin_name)return e.plugin_version=base.plugin_version,e.log=e.log||function(){"object"==typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)},e;"object"==typeof console&&"function"==typeof console.error&&console.error('plugin must contain proprerty "plugin_name"')}var hasOwnProperty=Object.prototype.hasOwnProperty;function isFunction(e){if(!e)return!1;var t=Object.prototype.toString.call(e);return"[object Function]"==t||"[object AsyncFunction]"==t}function isObject(e){return null!=e&&"[object Object]"==Object.prototype.toString.call(e)}function isString(e){return"[object String]"==toString.call(e)}function log(){if("object"==typeof console&&console.log){isString(arguments[0])&&(arguments[0]="sensors registerProperties————"+arguments[0]);try{return console.log.apply(console,arguments)}catch(e){console.log("sensors registerProperties————",arguments[0])}}}function extend(e){return each(Array.prototype.slice.call(arguments,1),function(t){for(var s in t)void 0!==t[s]&&(e[s]=t[s])}),e}function each(e,t,s){var r=Array.prototype.forEach,o={};if(null==e)return!1;if(r&&e.forEach===r)e.forEach(t,s);else if(e.length===+e.length){for(var n=0,i=e.length;n0&®ister_list.push(e):_.log("参数错误!")},RegisterProperties.hookRegister=function(e){_.isFunction(e)&®ister_list.push(e)};var registerProperties=createPlugin(RegisterProperties),flag="data:enc;",store={_sa:null,readObjectVal:function(e){try{var t=store._sa._.getStorageSync(e)||"";return store._sa._.isString(t)&&-1!==t.indexOf(flag)&&(t=t.substring(flag.length),t=JSON.parse(store._sa._.rot13defs(t))),t}catch(e){return null}},saveObjectVal:function(e,t){var s="";store._sa._.isObject(t)?s=flag+store._sa._.rot13obfs(JSON.stringify(t)):store._sa._.isString(t)&&-1===t.indexOf(flag)&&(s=flag+store._sa._.rot13obfs(t)),store._sa._.setStorageSync(e,s)}},_sa$1=null,_$1={isObject:function(e){return null!=e&&"[object Object]"==toString.call(e)},log:function(){if("object"==typeof console&&console.log)try{return console.log.apply(console,arguments)}catch(e){console.log("sensors sessionEvent---",arguments[0])}}},STORAGE_NAME="sensorsdata2015_wechat_session",SessionEvent={plugin_name:"SessionEvent",version:"props_sdk_version",storage_name:STORAGE_NAME,init:function(e){if(!e||"object"!=typeof e)return _$1.log("请传入正确的 sensors 对象!"),!1;_sa$1=e,store._sa=e,_$1.log=e._.logger,registerProperties.init(e),registerProperties.hookRegister(SessionEvent.addSessionID)},addSessionID:function(){var e=+new Date,t=store.readObjectVal(SessionEvent.storage_name)||{},s=t.first_session_time,r=t.latest_session_time;!s||!r||s>e||r>e||e-s>432e5||e-r>18e5?t={session_id:_sa$1.store.getUUID().replace(/-/g,""),first_session_time:e,latest_session_time:e}:t.latest_session_time=e;return store.saveObjectVal(SessionEvent.storage_name,t),{$event_session_id:t.session_id}}},index=createPlugin(SessionEvent);module.exports=index; \ No newline at end of file +"use strict";var base={plugin_version:"1.19.12"};function createPlugin(e){if("object"==typeof e&&"string"==typeof e.plugin_name&&""!==e.plugin_name)return e.plugin_version=base.plugin_version,e.log=e.log||function(){"object"==typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)},e;"object"==typeof console&&"function"==typeof console.error&&console.error('plugin must contain proprerty "plugin_name"')}var hasOwnProperty=Object.prototype.hasOwnProperty;function isFunction(e){if(!e)return!1;var t=Object.prototype.toString.call(e);return"[object Function]"==t||"[object AsyncFunction]"==t}function isObject(e){return null!=e&&"[object Object]"==Object.prototype.toString.call(e)}function isString(e){return"[object String]"==toString.call(e)}function log(){if("object"==typeof console&&console.log){isString(arguments[0])&&(arguments[0]="sensors registerProperties————"+arguments[0]);try{return console.log.apply(console,arguments)}catch(e){console.log("sensors registerProperties————",arguments[0])}}}function extend(e){return each(Array.prototype.slice.call(arguments,1),function(t){for(var s in t)void 0!==t[s]&&(e[s]=t[s])}),e}function each(e,t,s){var r=Array.prototype.forEach,o={};if(null==e)return!1;if(r&&e.forEach===r)e.forEach(t,s);else if(e.length===+e.length){for(var n=0,i=e.length;n0&®ister_list.push(e):_.log("参数错误!")},RegisterProperties.hookRegister=function(e){_.isFunction(e)&®ister_list.push(e)};var registerProperties=createPlugin(RegisterProperties),flag="data:enc;",store={_sa:null,readObjectVal:function(e){try{var t=store._sa._.getStorageSync(e)||"";return store._sa._.isString(t)&&-1!==t.indexOf(flag)&&(t=t.substring(flag.length),t=JSON.parse(store._sa._.rot13defs(t))),t}catch(e){return null}},saveObjectVal:function(e,t){var s="";store._sa._.isObject(t)?s=flag+store._sa._.rot13obfs(JSON.stringify(t)):store._sa._.isString(t)&&-1===t.indexOf(flag)&&(s=flag+store._sa._.rot13obfs(t)),store._sa._.setStorageSync(e,s)}},_sa$1=null,_$1={isObject:function(e){return null!=e&&"[object Object]"==toString.call(e)},log:function(){if("object"==typeof console&&console.log)try{return console.log.apply(console,arguments)}catch(e){console.log("sensors sessionEvent---",arguments[0])}}},STORAGE_NAME="sensorsdata2015_wechat_session",SessionEvent={plugin_name:"SessionEvent",version:"props_sdk_version",storage_name:STORAGE_NAME,init:function(e){if(!e||"object"!=typeof e)return _$1.log("请传入正确的 sensors 对象!"),!1;_sa$1=e,store._sa=e,_$1.log=e._.logger,registerProperties.init(e),registerProperties.hookRegister(SessionEvent.addSessionID)},addSessionID:function(){var e=+new Date,t=store.readObjectVal(SessionEvent.storage_name)||{},s=t.first_session_time,r=t.latest_session_time;!s||!r||s>e||r>e||e-s>432e5||e-r>18e5?t={session_id:_sa$1.store.getUUID().replace(/-/g,""),first_session_time:e,latest_session_time:e}:t.latest_session_time=e;return store.saveObjectVal(SessionEvent.storage_name,t),{$event_session_id:t.session_id}}},index=createPlugin(SessionEvent);module.exports=index; \ No newline at end of file diff --git a/dist/wechat/plugin/session-event/index.esm.js b/dist/wechat/plugin/session-event/index.esm.js index cf0fe46..d2bd7eb 100644 --- a/dist/wechat/plugin/session-event/index.esm.js +++ b/dist/wechat/plugin/session-event/index.esm.js @@ -1 +1 @@ -var base={plugin_version:"1.19.11"};function createPlugin(e){if("object"==typeof e&&"string"==typeof e.plugin_name&&""!==e.plugin_name)return e.plugin_version=base.plugin_version,e.log=e.log||function(){"object"==typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)},e;"object"==typeof console&&"function"==typeof console.error&&console.error('plugin must contain proprerty "plugin_name"')}var hasOwnProperty=Object.prototype.hasOwnProperty;function isFunction(e){if(!e)return!1;var t=Object.prototype.toString.call(e);return"[object Function]"==t||"[object AsyncFunction]"==t}function isObject(e){return null!=e&&"[object Object]"==Object.prototype.toString.call(e)}function isString(e){return"[object String]"==toString.call(e)}function log(){if("object"==typeof console&&console.log){isString(arguments[0])&&(arguments[0]="sensors registerProperties————"+arguments[0]);try{return console.log.apply(console,arguments)}catch(e){console.log("sensors registerProperties————",arguments[0])}}}function extend(e){return each(Array.prototype.slice.call(arguments,1),function(t){for(var s in t)void 0!==t[s]&&(e[s]=t[s])}),e}function each(e,t,s){var r=Array.prototype.forEach,o={};if(null==e)return!1;if(r&&e.forEach===r)e.forEach(t,s);else if(e.length===+e.length){for(var n=0,i=e.length;n0&®ister_list.push(e):_.log("参数错误!")},RegisterProperties.hookRegister=function(e){_.isFunction(e)&®ister_list.push(e)};var registerProperties=createPlugin(RegisterProperties),flag="data:enc;",store={_sa:null,readObjectVal:function(e){try{var t=store._sa._.getStorageSync(e)||"";return store._sa._.isString(t)&&-1!==t.indexOf(flag)&&(t=t.substring(flag.length),t=JSON.parse(store._sa._.rot13defs(t))),t}catch(e){return null}},saveObjectVal:function(e,t){var s="";store._sa._.isObject(t)?s=flag+store._sa._.rot13obfs(JSON.stringify(t)):store._sa._.isString(t)&&-1===t.indexOf(flag)&&(s=flag+store._sa._.rot13obfs(t)),store._sa._.setStorageSync(e,s)}},_sa$1=null,_$1={isObject:function(e){return null!=e&&"[object Object]"==toString.call(e)},log:function(){if("object"==typeof console&&console.log)try{return console.log.apply(console,arguments)}catch(e){console.log("sensors sessionEvent---",arguments[0])}}},STORAGE_NAME="sensorsdata2015_wechat_session",SessionEvent={plugin_name:"SessionEvent",version:"props_sdk_version",storage_name:STORAGE_NAME,init:function(e){if(!e||"object"!=typeof e)return _$1.log("请传入正确的 sensors 对象!"),!1;_sa$1=e,store._sa=e,_$1.log=e._.logger,registerProperties.init(e),registerProperties.hookRegister(SessionEvent.addSessionID)},addSessionID:function(){var e=+new Date,t=store.readObjectVal(SessionEvent.storage_name)||{},s=t.first_session_time,r=t.latest_session_time;!s||!r||s>e||r>e||e-s>432e5||e-r>18e5?t={session_id:_sa$1.store.getUUID().replace(/-/g,""),first_session_time:e,latest_session_time:e}:t.latest_session_time=e;return store.saveObjectVal(SessionEvent.storage_name,t),{$event_session_id:t.session_id}}},index=createPlugin(SessionEvent);export default index; \ No newline at end of file +var base={plugin_version:"1.19.12"};function createPlugin(e){if("object"==typeof e&&"string"==typeof e.plugin_name&&""!==e.plugin_name)return e.plugin_version=base.plugin_version,e.log=e.log||function(){"object"==typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)},e;"object"==typeof console&&"function"==typeof console.error&&console.error('plugin must contain proprerty "plugin_name"')}var hasOwnProperty=Object.prototype.hasOwnProperty;function isFunction(e){if(!e)return!1;var t=Object.prototype.toString.call(e);return"[object Function]"==t||"[object AsyncFunction]"==t}function isObject(e){return null!=e&&"[object Object]"==Object.prototype.toString.call(e)}function isString(e){return"[object String]"==toString.call(e)}function log(){if("object"==typeof console&&console.log){isString(arguments[0])&&(arguments[0]="sensors registerProperties————"+arguments[0]);try{return console.log.apply(console,arguments)}catch(e){console.log("sensors registerProperties————",arguments[0])}}}function extend(e){return each(Array.prototype.slice.call(arguments,1),function(t){for(var s in t)void 0!==t[s]&&(e[s]=t[s])}),e}function each(e,t,s){var r=Array.prototype.forEach,o={};if(null==e)return!1;if(r&&e.forEach===r)e.forEach(t,s);else if(e.length===+e.length){for(var n=0,i=e.length;n0&®ister_list.push(e):_.log("参数错误!")},RegisterProperties.hookRegister=function(e){_.isFunction(e)&®ister_list.push(e)};var registerProperties=createPlugin(RegisterProperties),flag="data:enc;",store={_sa:null,readObjectVal:function(e){try{var t=store._sa._.getStorageSync(e)||"";return store._sa._.isString(t)&&-1!==t.indexOf(flag)&&(t=t.substring(flag.length),t=JSON.parse(store._sa._.rot13defs(t))),t}catch(e){return null}},saveObjectVal:function(e,t){var s="";store._sa._.isObject(t)?s=flag+store._sa._.rot13obfs(JSON.stringify(t)):store._sa._.isString(t)&&-1===t.indexOf(flag)&&(s=flag+store._sa._.rot13obfs(t)),store._sa._.setStorageSync(e,s)}},_sa$1=null,_$1={isObject:function(e){return null!=e&&"[object Object]"==toString.call(e)},log:function(){if("object"==typeof console&&console.log)try{return console.log.apply(console,arguments)}catch(e){console.log("sensors sessionEvent---",arguments[0])}}},STORAGE_NAME="sensorsdata2015_wechat_session",SessionEvent={plugin_name:"SessionEvent",version:"props_sdk_version",storage_name:STORAGE_NAME,init:function(e){if(!e||"object"!=typeof e)return _$1.log("请传入正确的 sensors 对象!"),!1;_sa$1=e,store._sa=e,_$1.log=e._.logger,registerProperties.init(e),registerProperties.hookRegister(SessionEvent.addSessionID)},addSessionID:function(){var e=+new Date,t=store.readObjectVal(SessionEvent.storage_name)||{},s=t.first_session_time,r=t.latest_session_time;!s||!r||s>e||r>e||e-s>432e5||e-r>18e5?t={session_id:_sa$1.store.getUUID().replace(/-/g,""),first_session_time:e,latest_session_time:e}:t.latest_session_time=e;return store.saveObjectVal(SessionEvent.storage_name,t),{$event_session_id:t.session_id}}},index=createPlugin(SessionEvent);export default index; \ No newline at end of file diff --git a/dist/wechat/plugin/set-referrer-path/index.cmd.js b/dist/wechat/plugin/set-referrer-path/index.cmd.js index 890245c..e4b0ca2 100644 --- a/dist/wechat/plugin/set-referrer-path/index.cmd.js +++ b/dist/wechat/plugin/set-referrer-path/index.cmd.js @@ -1 +1 @@ -"use strict";var base={plugin_version:"1.19.11"};function createPlugin(e){if("object"==typeof e&&"string"==typeof e.plugin_name&&""!==e.plugin_name)return e.plugin_version=base.plugin_version,e.log=e.log||function(){"object"==typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)},e;"object"==typeof console&&"function"==typeof console.error&&console.error('plugin must contain proprerty "plugin_name"')}var hasOwnProperty=Object.prototype.hasOwnProperty;function isFunction(e){if(!e)return!1;var r=Object.prototype.toString.call(e);return"[object Function]"==r||"[object AsyncFunction]"==r}function isObject(e){return null!=e&&"[object Object]"==Object.prototype.toString.call(e)}function isString(e){return"[object String]"==toString.call(e)}function log(){if("object"==typeof console&&console.log){isString(arguments[0])&&(arguments[0]="sensors registerProperties————"+arguments[0]);try{return console.log.apply(console,arguments)}catch(e){console.log("sensors registerProperties————",arguments[0])}}}function extend(e){return each(Array.prototype.slice.call(arguments,1),function(r){for(var t in r)void 0!==r[t]&&(e[t]=r[t])}),e}function each(e,r,t){var n=Array.prototype.forEach,i={};if(null==e)return!1;if(n&&e.forEach===n)e.forEach(r,t);else if(e.length===+e.length){for(var o=0,s=e.length;o0&®ister_list.push(e):_.log("参数错误!")},RegisterProperties.hookRegister=function(e){_.isFunction(e)&®ister_list.push(e)};var sa,registerProperties=createPlugin(RegisterProperties),setReferrerPath={plugin_name:"SetReferrerPath",init:function(e){if(!(sa=e))return console.log("当前主sdk 初始化失败,请传入正确的 sensors 对象!"),!1;this.setRefPath()},setRefPath:function(){registerProperties.init(sa),registerProperties.hookRegister(function(e){var r="",t={};if(e&&e.properties&&(r=e.properties.$referrer||"",sa._.isString(r))){var n=r.indexOf("?");t={referrer_path:n>0?r.substring(0,n):r}}return t})}},index=createPlugin(setReferrerPath);module.exports=index; \ No newline at end of file +"use strict";var base={plugin_version:"1.19.12"};function createPlugin(e){if("object"==typeof e&&"string"==typeof e.plugin_name&&""!==e.plugin_name)return e.plugin_version=base.plugin_version,e.log=e.log||function(){"object"==typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)},e;"object"==typeof console&&"function"==typeof console.error&&console.error('plugin must contain proprerty "plugin_name"')}var hasOwnProperty=Object.prototype.hasOwnProperty;function isFunction(e){if(!e)return!1;var r=Object.prototype.toString.call(e);return"[object Function]"==r||"[object AsyncFunction]"==r}function isObject(e){return null!=e&&"[object Object]"==Object.prototype.toString.call(e)}function isString(e){return"[object String]"==toString.call(e)}function log(){if("object"==typeof console&&console.log){isString(arguments[0])&&(arguments[0]="sensors registerProperties————"+arguments[0]);try{return console.log.apply(console,arguments)}catch(e){console.log("sensors registerProperties————",arguments[0])}}}function extend(e){return each(Array.prototype.slice.call(arguments,1),function(r){for(var t in r)void 0!==r[t]&&(e[t]=r[t])}),e}function each(e,r,t){var n=Array.prototype.forEach,i={};if(null==e)return!1;if(n&&e.forEach===n)e.forEach(r,t);else if(e.length===+e.length){for(var o=0,s=e.length;o0&®ister_list.push(e):_.log("参数错误!")},RegisterProperties.hookRegister=function(e){_.isFunction(e)&®ister_list.push(e)};var sa,registerProperties=createPlugin(RegisterProperties),setReferrerPath={plugin_name:"SetReferrerPath",init:function(e){if(!(sa=e))return console.log("当前主sdk 初始化失败,请传入正确的 sensors 对象!"),!1;this.setRefPath()},setRefPath:function(){registerProperties.init(sa),registerProperties.hookRegister(function(e){var r="",t={};if(e&&e.properties&&(r=e.properties.$referrer||"",sa._.isString(r))){var n=r.indexOf("?");t={referrer_path:n>0?r.substring(0,n):r}}return t})}},index=createPlugin(setReferrerPath);module.exports=index; \ No newline at end of file diff --git a/dist/wechat/plugin/set-referrer-path/index.esm.js b/dist/wechat/plugin/set-referrer-path/index.esm.js index e4117fc..bd3ca96 100644 --- a/dist/wechat/plugin/set-referrer-path/index.esm.js +++ b/dist/wechat/plugin/set-referrer-path/index.esm.js @@ -1 +1 @@ -var base={plugin_version:"1.19.11"};function createPlugin(e){if("object"==typeof e&&"string"==typeof e.plugin_name&&""!==e.plugin_name)return e.plugin_version=base.plugin_version,e.log=e.log||function(){"object"==typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)},e;"object"==typeof console&&"function"==typeof console.error&&console.error('plugin must contain proprerty "plugin_name"')}var hasOwnProperty=Object.prototype.hasOwnProperty;function isFunction(e){if(!e)return!1;var r=Object.prototype.toString.call(e);return"[object Function]"==r||"[object AsyncFunction]"==r}function isObject(e){return null!=e&&"[object Object]"==Object.prototype.toString.call(e)}function isString(e){return"[object String]"==toString.call(e)}function log(){if("object"==typeof console&&console.log){isString(arguments[0])&&(arguments[0]="sensors registerProperties————"+arguments[0]);try{return console.log.apply(console,arguments)}catch(e){console.log("sensors registerProperties————",arguments[0])}}}function extend(e){return each(Array.prototype.slice.call(arguments,1),function(r){for(var t in r)void 0!==r[t]&&(e[t]=r[t])}),e}function each(e,r,t){var n=Array.prototype.forEach,i={};if(null==e)return!1;if(n&&e.forEach===n)e.forEach(r,t);else if(e.length===+e.length){for(var o=0,s=e.length;o0&®ister_list.push(e):_.log("参数错误!")},RegisterProperties.hookRegister=function(e){_.isFunction(e)&®ister_list.push(e)};var sa,registerProperties=createPlugin(RegisterProperties),setReferrerPath={plugin_name:"SetReferrerPath",init:function(e){if(!(sa=e))return console.log("当前主sdk 初始化失败,请传入正确的 sensors 对象!"),!1;this.setRefPath()},setRefPath:function(){registerProperties.init(sa),registerProperties.hookRegister(function(e){var r="",t={};if(e&&e.properties&&(r=e.properties.$referrer||"",sa._.isString(r))){var n=r.indexOf("?");t={referrer_path:n>0?r.substring(0,n):r}}return t})}},index=createPlugin(setReferrerPath);export default index; \ No newline at end of file +var base={plugin_version:"1.19.12"};function createPlugin(e){if("object"==typeof e&&"string"==typeof e.plugin_name&&""!==e.plugin_name)return e.plugin_version=base.plugin_version,e.log=e.log||function(){"object"==typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)},e;"object"==typeof console&&"function"==typeof console.error&&console.error('plugin must contain proprerty "plugin_name"')}var hasOwnProperty=Object.prototype.hasOwnProperty;function isFunction(e){if(!e)return!1;var r=Object.prototype.toString.call(e);return"[object Function]"==r||"[object AsyncFunction]"==r}function isObject(e){return null!=e&&"[object Object]"==Object.prototype.toString.call(e)}function isString(e){return"[object String]"==toString.call(e)}function log(){if("object"==typeof console&&console.log){isString(arguments[0])&&(arguments[0]="sensors registerProperties————"+arguments[0]);try{return console.log.apply(console,arguments)}catch(e){console.log("sensors registerProperties————",arguments[0])}}}function extend(e){return each(Array.prototype.slice.call(arguments,1),function(r){for(var t in r)void 0!==r[t]&&(e[t]=r[t])}),e}function each(e,r,t){var n=Array.prototype.forEach,i={};if(null==e)return!1;if(n&&e.forEach===n)e.forEach(r,t);else if(e.length===+e.length){for(var o=0,s=e.length;o0&®ister_list.push(e):_.log("参数错误!")},RegisterProperties.hookRegister=function(e){_.isFunction(e)&®ister_list.push(e)};var sa,registerProperties=createPlugin(RegisterProperties),setReferrerPath={plugin_name:"SetReferrerPath",init:function(e){if(!(sa=e))return console.log("当前主sdk 初始化失败,请传入正确的 sensors 对象!"),!1;this.setRefPath()},setRefPath:function(){registerProperties.init(sa),registerProperties.hookRegister(function(e){var r="",t={};if(e&&e.properties&&(r=e.properties.$referrer||"",sa._.isString(r))){var n=r.indexOf("?");t={referrer_path:n>0?r.substring(0,n):r}}return t})}},index=createPlugin(setReferrerPath);export default index; \ No newline at end of file diff --git a/dist/wechat/plugin/sf-sdk-miniprogram/popup.cmd.min.js b/dist/wechat/plugin/sf-sdk-miniprogram/popup.cmd.min.js index f4954dd..8e33bf0 100644 --- a/dist/wechat/plugin/sf-sdk-miniprogram/popup.cmd.min.js +++ b/dist/wechat/plugin/sf-sdk-miniprogram/popup.cmd.min.js @@ -1 +1 @@ -"use strict";var popup={plugin_name:"PopupWechat",plugin_version:"1.19.11",sa:{},info:{app_id:"",show_log:!0},campaign_listener:{},lib_version:"1.19.11",defaultPara:{platform:"MINIPROGRAM",preload_image:!0,defer_render:!1},serverData:{},localData:{},event_list:[],popuping:!1,convertPlans:[],eventRule:{},popupTree:{},log:function(){if(popup.info.show_log&&"object"==typeof console&&console.log)try{return console.log.apply(console,arguments)}catch(t){console.log(arguments[0])}},CAMPAIGN_ERROR:{}},getRandomBasic=function(){var t=(new Date).getTime();return function(e){return Math.ceil((t=(9301*t+49297)%233280)/233280*e)}}(),_={getRgba:function(t){return"object"!=typeof t?t:"rgba("+t.r+","+t.g+","+t.b+","+t.a+")"},getRpx:function(t){if(t){if(/^[0|1]?\.\d+$/.test(t))return 100*Number(t)+"%";var e=/^(-?\d+(\.\d+)?)px$/.exec(t);return e?2*Number(e[1])+"rpx":t}},extend:function(t){var e=Array.prototype.slice;return _.each(e.call(arguments,1),function(e){for(var p in e)void 0!==e[p]&&(t[p]=e[p])}),t},each:function(t,e,p){var n=Array.prototype.forEach,o={};if(null==t)return!1;if(n&&t.forEach===n)t.forEach(e,p);else if(t.length===+t.length){for(var i=0,r=t.length;i0&&(r[n[0]]||(r[n[0]]=1));return _.each(r,function(t,e){u.push(e)}),u},_.getConvertNumberValue=function(t){return _.isString(t)&&(t=Number(t)),Math.floor(1e3*t)/1e3},_.wxrequest=function(t){var e=wx.request(t);setTimeout(function(){_.isObject(e)&&_.isFunction(e.abort)&&e.abort()},3e4)},_.getProject=function(t){if(t&&t.split("?")[1]){var e=decodeURIComponent(t.split("?")[1]);return _.getURLSearchParams(e).project||"default"}return"default"},_.getCurrentPage=function(){var t=getCurrentPages(),e=t[t.length-1];return!!_.isObject(e)&&e},_.getPropertiesValue=function(t,e){var p=t[e];return"$event_duration"===e&&void 0===p&&(p=t.event_duration),p},popup._=_,popup.handleEvents=function(t,e){if("send"===t){if(popup.popuping)return popup.event_list.push(e),!1;e.event&&popup.eventRule[e.event]&&popup.eventTriggerProcess(popup.eventRule[e.event],e)}if("changeDistinctId"===t&&popup.updateAndListenPlan.changeId(),"popup_display"===t){popup.popuping=!0;try{popup.info.popup_listener.onLoadSuccess(e.plan.plan_id)}catch(t){popup.log("popup_listener.onLoad error",t)}}if("popup_load_fail"===t){var p=e.plan_id,n=e.fail_code,o=e.fail_reason;try{popup.info.popup_listener.onLoadFailed(p,n,o)}catch(t){popup.log("popup_listener.onLoad error",t)}}if("popup_click"===t&&popup.track.popupClick(e),"popup_end"===t){popup.popuping=!1;var i={name:e.plan.cname,plan_id:e.plan.plan_id,content:e.plan.popup_window_content?e.plan.popup_window_content.content:"",type:e.plan.popup_window_content?e.plan.popup_window_content.popup_type:""};popup.CAMPAIGN_ERROR.onEnd||popup.campaign_listener.onEnd(i);try{popup.info.popup_listener.onClose(e.plan.plan_id)}catch(t){popup.log("popup_listener.onLoad error",t)}popup.updateGlobalCount(),popup.updatePlanInterval(e.plan),_.each(popup.event_list,function(t){t.event&&popup.eventRule[t.event]&&popup.eventTriggerProcess(popup.eventRule[t.event],t)}),popup.event_list=[]}},popup.setPara=function(t){if(_.isObject(t)||(t={}),popup.info=_.extend(popup.info,popup.defaultPara,t),popup.info.app_id||popup.log("\u521d\u59cb\u5316\u53c2\u6570 appid \u6821\u9a8c\u5931\u8d25\uff0c\u65e0\u6cd5\u62c9\u53d6\u5f39\u7a97\u8ba1\u5212!"),_.isString(popup.info.api_base_url)&&"http"===popup.info.api_base_url.slice(0,4)||popup.log("popup \u5fc5\u987b\u586b\u5199\u6709\u6548 api_base_url"),popup.info.project||(popup.info.project=_.getProject(popup.sa.para.server_url)),_.isObject(popup.info.popup_listener)){var e=popup.info.popup_listener;_.isFunction(e.onClick)||(popup.info.popup_listener.onClick=function(){}),_.isFunction(e.onLoadSuccess)||(popup.info.popup_listener.onLoadSuccess=function(){}),_.isFunction(e.onLoadFailed)||(popup.info.popup_listener.onLoadFailed=function(){}),_.isFunction(e.onClose)||(popup.info.popup_listener.onClose=function(){})}else popup.info.popup_listener={onClick:function(){},onLoadSuccess:function(){},onLoadFailed:function(){},onClose:function(){}};_.isObject(t.campaign_listener)?(popup.campaign_listener=_.extend({},t.campaign_listener),popup.campaign_listener.shouldStart&&_.isFunction(popup.campaign_listener.shouldStart)||(popup.campaign_listener.shouldStart=function(){return!0},popup.CAMPAIGN_ERROR.shouldStart={error_code:"4001",reeor_txt:"NOT_DEFINED OR DEFINED_ERROR"}),popup.campaign_listener.onClick?_.isFunction(popup.campaign_listener.onClick)||(popup.CAMPAIGN_ERROR.onClick={error_code:"4002",reeor_txt:"DEFINED_TYPE_ERROR"}):popup.CAMPAIGN_ERROR.onClick={error_code:"4001",reeor_txt:"NOT_DEFINED"},popup.campaign_listener.onStart?_.isFunction(popup.campaign_listener.onStart)||(popup.CAMPAIGN_ERROR.onStart={error_code:"4002",reeor_txt:"DEFINED_TYPE_ERROR"}):popup.CAMPAIGN_ERROR.onStart={error_code:"4001",reeor_txt:"NOT_DEFINED"},popup.campaign_listener.onEnd?_.isFunction(popup.campaign_listener.onEnd)||(popup.CAMPAIGN_ERROR.onEnd={error_code:"4002",reeor_txt:"DEFINED_TYPE_ERROR"}):popup.CAMPAIGN_ERROR.onEnd={error_code:"4001",reeor_txt:"NOT_DEFINED"},popup.campaign_listener.onFailed?_.isFunction(popup.campaign_listener.onFailed)||(popup.CAMPAIGN_ERROR.onFailed={error_code:"4002",reeor_txt:"DEFINED_TYPE_ERROR"}):popup.CAMPAIGN_ERROR.onFailed={error_code:"4001",reeor_txt:"NOT_DEFINED"}):(popup.campaign_listener.shouldStart=function(){return!0},popup.CAMPAIGN_ERROR.shouldStart={error_code:"4001",reeor_txt:"NOT_DEFINED"},popup.CAMPAIGN_ERROR.onClick={error_code:"4001",reeor_txt:"NOT_DEFINED"},popup.CAMPAIGN_ERROR.onStart={error_code:"4001",reeor_txt:"NOT_DEFINED"},popup.CAMPAIGN_ERROR.onEnd={error_code:"4001",reeor_txt:"NOT_DEFINED"},popup.CAMPAIGN_ERROR.onFailed={error_code:"4001",reeor_txt:"NOT_DEFINED"},popup.CAMPAIGN_ERROR.campaign_listener={error_code:"4003",errot_txt:"CAMPAIGN_CUSTOMIZED_NULL_LISTENER OR DEFINED ERROR"})},popup.dataRender={that:null,queue:[],notify:function(t){_.isFunction(this.handle)?this.handle(this.that,t):this.queue.push(t)}},popup.popupEmitter={image_list:[],loaded:!1,notify:function(t){var e=_.getCurrentPage(),p=this;e&&_.isObject(e)&&_.isFunction(e.selectComponent)&&(popup.info.defer_render?setTimeout(function(){p.renderPopup(e,t)},0):p.renderPopup(e,t))},renderPopup:function(t,e){var p=t.selectComponent("#sensors_popup");if(_.isObject(p)&&_.isFunction(p.handle))p.handle(e);else{var n="";try{var o=_.getCurrentPage();n=o?o.route:""}catch(t){}popup.log("\u5f53\u524d\u9875\u9762 "+n+" \u672a\u96c6\u6210\u5f39\u7a97\u7ec4\u4ef6")}},loadImage:function(t){if(JSON.stringify(t)!==JSON.stringify(this.image_list)&&(this.loaded=!1,this.image_list=t),!this.loaded){var e=_.getCurrentPage();if(e&&_.isObject(e)&&_.isFunction(e.selectComponent)){var p=e.selectComponent("#sensors_popup");_.isObject(p)&&_.isFunction(p.loadImage)&&(p.loadImage(t),this.loaded=!0)}}},attached:function(){this.loaded||this.loadImage(this.image_list)}},popup.testPopup=function(){wx.onAppShow(function(t){popup.updateAndListenPlan.pullPlan(),popup.testSend.start(t)})},popup.updateGlobalCount=function(){var t=popup.sa.store.getDistinctId(),e=popup.localData.user_list[t],p=(new Date).getTime();if(!_.isArray(popup.localData.plan_list[e].global_popup_count))return popup.localData.plan_list[e].global_popup_count=[],popup.localData.plan_list[e].global_popup_count.unshift(p),!1;popup.localData.plan_list[e].global_popup_count.shift(),popup.localData.plan_list[e].global_popup_count.unshift(p)},popup.updatePlanInterval=function(t){var e=(new Date).getTime();_.isObject(t)&&_.isObject(t.popup_interval)&&t.popup_interval.value&&(t.is_in_popup_interval_window=popup.ruleTime.getExpire(t.popup_interval,e))},popup.init=function(t,e){popup.log("\u5f39\u7a97\u5f00\u59cb\u521d\u59cb\u5316\uff01"),this.sa=t,this.setPara(e),this.sub=new t.eventSub(this.handleEvents),popup.updateAndListenPlan.initial(),popup.testPopup(),t.popupEmitter=popup.popupEmitter},popup.changeCovertStatus=function(t){var e=JSON.parse(JSON.stringify(popup.convertPlans));_.each(e,function(p,n){var o=p.is_in_convert_window.step,i=p.is_in_convert_window.uuid;if(popup.convertPlans[n].is_in_convert_window.step=Math.min(2*o,6e5),!t||!_.isArray(t)||0===t.length)return!1;_.each(t,function(t){t.popup_display_uuid===i&&t.convert_time&&(delete popup.convertPlans[n].is_in_convert_window,popup.convertPlans.splice(n,1),e.splice(n,1),n--)})}),popup.updateAndListenPlan.updateData()},popup.asyncConvert=function(t){var e=popup.info.project,p=!1;if(!t&&0===popup.convertPlans.length)return!1;t&&(_.each(popup.convertPlans,function(e){e.plan_id===t.plan_id&&(p=!0)}),p||popup.convertPlans.push(t)),function t(){if(_.isEmptyObject(popup.localData)||!_.isArray(popup.convertPlans)||0===popup.convertPlans.length)return!1;var p=popup.convertPlans,n=p[0].is_in_convert_window&&p[0].is_in_convert_window.step||5e3,o=[],i=Date.now();_.each(p,function(t){var e=t.is_in_convert_window;if(!e)return!1;e.step||(e.step=5e3),n>e.step&&(n=e.step)}),_.each(p,function(t){if(!t.is_in_convert_window)return!1;var e=t.is_in_convert_window.expire_time;if(i>e||n>e-i)return delete t.is_in_convert_window,!1;o.push(t.is_in_convert_window.uuid)});var r=_.filter(p,function(t){return!!t.is_in_convert_window&&i11?(r.setFullYear(r.getFullYear()+parseInt(t/12)),r.setMonth(t%12)):r.setMonth(t),r.setDate(1),r.setHours(0),r.setMinutes(0),r.setSeconds(0),r.setMilliseconds(0),r.getTime()},second:function(t){var e={month:2592e6,week:6048e5,day:864e5,hour:36e5,minute:6e4,second:1e3},o=null;return r=new Date(p),t in e&&(o=e[t]*n),r.getTime()+o}};return!0!==t.natural?a.second(i):i in a?a[i]():void 0},getLast:function(t,e){var p=Number(t.value)||0,n=Number(t.value)-1||0,o=String(t.unit).toLowerCase(),i=null,r={day:function(){return(i=new Date(e)).setHours(0),i.setMinutes(0),i.setSeconds(0),i.setMilliseconds(0),i=i.getTime()-864e5*n},week:function(){var t=(i=new Date(e)).getDay();return 0===t&&(t=7),--t,i.setHours(0),i.setMinutes(0),i.setSeconds(0),i.setMilliseconds(0),i=i.getTime()-(24*t*60*60*1e3+7*n*24*60*60*1e3)},month:function(){var t=(i=new Date(e)).getMonth()+1-n;return t<=0?(i.setFullYear(i.getFullYear()+(parseInt(t/12)-1)),i.setMonth(12+t%12-1)):i.setMonth(t-1),i.setDate(1),i.setHours(0),i.setMinutes(0),i.setSeconds(0),i.setMilliseconds(0),i.getTime()},second:function(t){var n={month:2592e6,week:6048e5,day:864e5,hour:36e5,minute:6e4,second:1e3},o=null;return i=new Date(e),t in n&&(o=n[t]*p),i.getTime()-o}};return!0!==t.natural?r.second(o):o in r?r[o]():void 0},getArrMatchCount:function(t,e){var p=0;for(p=0;p=t[p])return p;return t.length},checkRule:function(t,e){var p=new Date,n=e,o=Number(t.value)||0,i=Number(t.value)-1||0,r=String(t.unit).toLowerCase(),a=null,u={day:function(){return(a=new Date(n)).setHours(23),a.setMinutes(59),a.setSeconds(59),a.setMilliseconds(999),a=a.getTime()+864e5*i,p>a},week:function(){var t=(a=new Date(n)).getDay();0===t&&(t=7);var e=7-t;return a.setHours(23),a.setMinutes(59),a.setSeconds(59),a.setMilliseconds(999),a=a.getTime()+24*e*60*60*1e3+7*i*24*60*60*1e3,p>a},month:function(){var t=(a=new Date(n)).getMonth()+i;return t>=11?(a.setFullYear(a.getFullYear()+t/11),a.setMonth(t%11)):a.setMonth(t),a.setDate(1),a.setHours(0),a.setMinutes(0),a.setSeconds(0),a.setMilliseconds(0),p>a},second:function(t){return a=new Date(n),t in inteval&&(interval_time={month:2592e6,week:6048e5,day:864e5,hour:36e5,minute:6e4,second:1e3}[t]*o),p>a+null}};return!0!==t.natural?u.second(r):r in u?u[r]():void 0}},popup.eventTriggerProcess=function(t,e){var p=!1;_.isArray(t)&&t.length>0&&_.isObject(t[0])&&(popup.log("--------------------\u89e6\u53d1\u4e8b\u4ef6\u5f00\u59cb--------------------"),_.each(t,function(t){_.isObject(t)&&void 0!==t.match_state&&delete t.match_state,new popup.RuleCheck(t,e)}),_.each(t,function(t){!0===t.match_state?!1===p?(p=!0,popup.log("\u68c0\u67e5\u5b8c\u6bd5-\u4f18\u5148\u5f39\u7a97-\u5f00\u59cb",t.plan.cname),new popup.PopupCheck(t,!0)):!0===p&&(popup.log("\u68c0\u67e5\u5b8c\u6bd5-\u975e\u4f18\u5148\u5f39\u7a97-\u4e0d\u6e32\u67d3",t.plan.cname),new popup.PopupCheck(t,!1)):popup.log("\u68c0\u67e5\u5b8c\u6bd5-\u8ba1\u5212-\u4e0d\u6ee1\u8db3",t.plan.cname)}),popup.log("--------------------\u89e6\u53d1\u4e8b\u4ef6\u7ed3\u675f--------------------"))},popup.PopupCheck=function(t,e){this.plan=t.plan,this.current_time=(new Date).getTime(),e?this.displayPopup():this.hidePopup()},popup.PopupCheck.prototype.displayPopup=function(){var t=_.getUuid()(),e={props:{$sf_succeed:!0}};popup.popupTree={},e.uuid=t,e.plan=this.plan;var p=this.plan.popup_window_content,n="",o=!0;if(p&&p.content)try{n=JSON.parse(p.content),new popup.parseTree(n)}catch(t){n=!1,o=!1}else popup.log("\u8ba1\u5212\u65e0\u7a97\u4f53\u5185\u5bb9\uff01"),o=!1;e.popupTree=popup.popupTree;var i={name:this.plan.cname,plan_id:this.plan.plan_id,content:this.plan.popup_window_content?this.plan.popup_window_content.content:"",type:this.plan.popup_window_content?this.plan.popup_window_content.popup_type:""};this.plan.hasOwnProperty("strategy_id")?this.plan.is_trigger?popup.campaign_listener.shouldStart(i)?p?"CUSTOMIZED"===p.popup_type?(e.popupTree={},popup.CAMPAIGN_ERROR.onStart?(e.props={$sf_fail_reason:"onStart \u672a\u5b9a\u4e49",$sf_succeed:!1},popup.track.popupDisplay(e),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,1004,"onStart \u672a\u5b9a\u4e49")):p.content?(popup.track.popupDisplay(e),popup.campaign_listener.onStart(i),popup.info.popup_listener.onLoadSuccess(this.plan.plan_id)):(e.props={$sf_fail_reason:"\u5f39\u7a97\u5185\u5bb9\u9519\u8bef",$sf_succeed:!1},popup.track.popupDisplay(e),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,1001,"\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e"))):o?(popup.track.popupDisplay(e),popup.CAMPAIGN_ERROR.onStart||popup.campaign_listener.onStart(i),this.renderPopup(e)):(e.props={$sf_fail_reason:"\u5f39\u7a97\u5185\u5bb9\u9519\u8bef",$sf_succeed:!1},popup.track.popupDisplay(e),popup.info.popup_listener.onLoadFailed(this.plan.plan_id,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e"),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e")):(e.props={$sf_fail_reason:"\u5f39\u7a97\u5185\u5bb9\u9519\u8bef",$sf_succeed:!1},popup.track.popupDisplay(e),popup.info.popup_listener.onLoadFailed(this.plan.plan_id,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e"),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e")):(e.props={$sf_fail_reason:"shouldStart \u63a5\u53e3\u8fd4\u56de false",$sf_succeed:!1},popup.track.popupDisplay(e),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,"1004","shouldStart \u63a5\u53e3\u8fd4\u56de false")):(e.props={$sf_fail_reason:"\u8ba1\u5212\u4e0b\u53d1 is_trigger \u4e3a false",$sf_succeed:!1},popup.track.popupDisplay(e),p&&"PRESET"===p.popup_type&&popup.info.popup_listener.onLoadFailed(this.plan.plan_id,"1005","\u8ba1\u5212\u4e0b\u53d1 is_trigger \u4e3a false"),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,"1005","\u8ba1\u5212\u4e0b\u53d1 is_trigger \u4e3a false")):this.plan.is_control_group?(e.props={$sf_fail_reason:"\u5bf9\u7167\u7ec4",$sf_succeed:!1},popup.track.popupDisplay(e),popup.info.popup_listener.onLoadFailed(this.plan.plan_id,"2000","\u5bf9\u7167\u7ec4"),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,"2000","\u5bf9\u7167\u7ec4")):popup.campaign_listener.shouldStart(i)?o?(popup.track.popupDisplay(e),popup.CAMPAIGN_ERROR.onStart||popup.campaign_listener.onStart(i),this.renderPopup(e)):(e.props={$sf_fail_reason:"\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e",$sf_succeed:!1},popup.track.popupDisplay(e),popup.info.popup_listener.onLoadFailed(this.plan.plan_id,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e"),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e")):(e.props={$sf_fail_reason:"shouldStart \u63a5\u53e3\u8fd4\u56de false",$sf_succeed:!1},popup.track.popupDisplay(e),popup.info.popup_listener.onLoadFailed(this.plan.plan_id,"1004","shouldStart \u63a5\u53e3\u8fd4\u56de false"),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,"1004","shouldStart \u63a5\u53e3\u8fd4\u56de false"));this.startConvertWindow(t),this.startPopupIntervalWindow(),this.startPopupLimitWindow(),this.setGlobalLimit(),this.deletePlanAllWindow(),popup.updateAndListenPlan.updateData()},popup.PopupCheck.prototype.hidePopup=function(){this.deletePlanAllWindow(),popup.updateAndListenPlan.updateData()},popup.PopupCheck.prototype.renderPopup=function(t){popup.log("\u6e32\u67d3\u5f39\u7a97"),popup.popupEmitter.notify(t)},popup.PopupCheck.prototype.startConvertWindow=function(t){popup.log("--\u5f39\u7a97\u5c55\u793a-\u8f6c\u5316\u7a97\u53e3\u8bbe\u7f6e"),_.isObject(this.plan.convert_window)&&this.plan.convert_window.value&&(this.plan.is_in_convert_window={expire_time:popup.ruleTime.getExpire(this.plan.convert_window,this.current_time),start_time:this.current_time,uuid:t},popup.asyncConvert(this.plan))},popup.PopupCheck.prototype.startPopupIntervalWindow=function(){_.isObject(this.plan.popup_interval)&&this.plan.popup_interval.value&&(this.plan.is_in_popup_interval_window=popup.ruleTime.getExpire(this.plan.popup_interval,this.current_time))},popup.PopupCheck.prototype.startPopupLimitWindow=function(){popup.log("--\u5f39\u7a97\u5c55\u793a-\u53c2\u4e0e\u9650\u5236\u7a97\u53e3\u8bbe\u7f6e\u91cd\u7f6e"),_.isObject(this.plan.re_enter)&&this.plan.re_enter.value&&(_.isObject(this.plan.is_in_popup_limit_window)?this.plan.is_in_popup_limit_window.count++:this.plan.is_in_popup_limit_window={expire_time:popup.ruleTime.getExpire(this.plan.re_enter,this.current_time),count:1})},popup.PopupCheck.prototype.setGlobalLimit=function(){popup.log("--\u5f39\u7a97\u5c55\u793a-\u5168\u5c40\u5f39\u7a97\u6b21\u6570\u8bbe\u7f6e");var t=popup.store.getCurrentUserPlanList();_.isArray(t.global_popup_count)||(t.global_popup_count=[]),t.global_popup_count.unshift(this.current_time);for(var e=t.global_popup_count,p=e[e.length-1];p+7776e63e3;)e.pop(),p=e[e.length-1]},popup.PopupCheck.prototype.deletePlanAllWindow=function(){var t=this.plan.pattern_popup.matcher_list;_.isArray(t)&&_.each(t,function(t){t.is_in_window&&(popup.log("--\u5f39\u7a97\u5c55\u793a-\u91cd\u7f6e\u5404\u4e2a\u89c4\u5219\u7684\u7a97\u53e3\u8ba1\u7b97-\u6210\u529f"),delete t.is_in_window)})},popup.RuleCheck=function(t,e){this.plan_match=t,this.plan=t.plan,this.rule_arr=t.rule,this.event_data=e,this.current_time=(new Date).getTime();var p="-------------\u68c0\u67e5-\u8ba1\u5212-("+this.plan.cname+")";_.each(this.rule_arr,function(t){p+="--\u5305\u542b\u89c4\u5219-("+t.event_name+"\uff09-\u89e6\u53d1"+t.params[0]+"\u6b21"}),popup.log(p),popup.log(this.plan),this.checkPlanIsExpire(),popup.updateAndListenPlan.updateData()},popup.RuleCheck.prototype.checkPlanIsExpire=function(){!this.plan.expire_at||_.isNumber(this.plan.expire_at)&&this.current_timethis.current_time?popup.log("--\u5b58\u5728\u8f6c\u5316\u7a97\u53e3 - \u4e0d\u6ee1\u8db3",this.plan.is_in_convert_window):(popup.log("--\u4e0d\u5b58\u5728\u8f6c\u5316\u7a97\u53e3\u6216\u8005\u7a97\u53e3\u8d85\u65f6\u5df2\u7ecf\u8fc7\u671f - \u6ee1\u8db3",this.plan.is_in_convert_window),this.checkGlobalPopupInterval())},popup.RuleCheck.prototype.checkGlobalPopupInterval=function(){var t=popup.store.getCurrentUserPlanList(),e=t.global_popup_count;if(_.isArray(e)&&e.length>=1){var p=popup.ruleTime.getLast(t.popup_interval_global,this.current_time);p>e[0]?(popup.log("--\u5168\u5c40\u5f39\u7a97\u95f4\u9694-\u6ee1\u8db3-"+p+">\u4e0a\u6b21\u5f39\u7a97\u65f6\u95f4"+e[0]),this.checkPopupInterval()):popup.log("\u68c0\u67e5-\u5168\u5c40\u5f39\u7a97\u95f4\u9694-\u4e0d\u6ee1\u8db3-"+p+"<\u4e0a\u6b21\u5f39\u7a97\u65f6\u95f4"+e[0])}else popup.log("--\u5168\u5c40\u5f39\u7a97\u95f4\u9694-\u6ca1\u6709\u5f39\u8fc7\u7a97-\u6ee1\u8db3"),this.checkPopupInterval()},popup.RuleCheck.prototype.checkPopupInterval=function(){_.isNumber(this.plan.is_in_popup_interval_window)?this.current_time>this.plan.is_in_popup_interval_window?(popup.log("--\u5f39\u7a97\u95f4\u9694-\u5f53\u524d\u65f6\u95f4\u5927\u4e8e\u56fa\u5b9a\u5f39\u7a97\u95f4\u9694-\u6ee1\u8db3"),this.plan.is_in_popup_interval_window=null,this.checkPermission()&&this.checkProperties()):popup.log("--\u5f39\u7a97\u95f4\u9694-\u5f53\u524d\u65f6\u95f4\u5c0f\u4e8e\u56fa\u5b9a\u5f39\u7a97\u95f4\u9694-\u4e0d\u6ee1\u8db3"):(popup.log("--\u5f39\u7a97\u95f4\u9694-\u7a97\u53e3\u4e0d\u5b58\u5728-\u65b0\u5f00"),this.plan.is_in_popup_interval_window=null,this.checkPermission()&&this.checkProperties())},popup.RuleCheck.prototype.isMatched=function(t){var e={equal:function(t,e){if(!_.isNumber(t)&&!_.isString(t))return!1;for(var p=0,n=e.length;p=0},notContain:function(t,e){return!!_.isString(t)&&-1===t.indexOf(e[0])},isTrue:function(t){return!0===t},isFalse:function(t){return!1===t},isSet:function(t){return void 0!==t},notSet:function(t){return void 0===t},isEmpty:function(t){if(!_.isString(t)&&!_.isArray(t))return!1;if(_.isString(t))return""===t;for(var e=0;eNumber(e[0])},between:function(t,e){return!!_.isNumber(t)&&(t>=Number(e[0])&&t<=Number(e[1]))},in:function(t,e){if(!_.isArray(t))return!1;for(var p=0;p=0)return!0;return!1},notInclude:function(t,e){if(!_.isArray(t))return!1;for(var p=0;p=p&&o<=n}catch(t){popup.log("absolute_between Error",t)}},absoluteBetween:function(t,e){try{var p=new Date(e[0]),n=new Date(e[1]),o=new Date(t);return o>=p&&o<=n}catch(t){popup.log("absolute_between Error",t)}}},p=this,n=t.relation,o="or"===String(n).toLowerCase(),i="and"===String(n).toLowerCase(),r=!!i,a=!0;return _.each(t.conditions,function(t){if(!a)return!1;if(!t.field)return!1;var n=t.field.lastIndexOf("."),u=t.params,s=t.function;if(!e[s])return r=!1,a=!1,!1;if(n<0)return!1;var l=t.field.slice(n+1),c=p.event_data.properties,d=_.getPropertiesValue(c,l),g=e[s](d,u);o&&g&&(r=!0,a=!1),i&&!g&&(r=!1,a=!1)}),r},popup.RuleCheck.prototype.checkPermission=function(){var t=this.plan.event_permission;if(!_.isObject(t)||_.isEmptyObject(t))return!0;var e=this,p=[],n=function(t){return _.filter(t,function(t){return!(t&&t.conditions&&(!t.conditions||0!==t.conditions.length))||e.isMatched(t)})};return function t(e,o){_.each(e,function(e){if(p=n([e]),_.isArray(p)&&p.length>0){var i=e[o]||[];i&&i.length>0&&t(i,o)}})}([t],"filters"),_.isArray(p)&&p.length>0?(popup.log("--\u89d2\u8272\u5c5e\u6027\u5339\u914d-\u6ee1\u8db3",p),!0):(popup.log("--\u89d2\u8272\u5c5e\u6027\u5339\u914d-\u4e0d\u6ee1\u8db3"),!1)},popup.RuleCheck.prototype.checkProperties=function(){var t=this,e=_.filter(this.rule_arr,function(e){var p=e.multi_filter?e.multi_filter:e.filter;return!(p&&(!p.conditions||0!==p.conditions.length))||t.isMatched(p)});_.isArray(e)&&e.length>0?(this.checkWindowAndMatch(e),popup.log("--\u5c5e\u6027\u5339\u914d-\u6ee1\u8db3",e)):popup.log("--\u5c5e\u6027\u5339\u914d-\u4e0d\u6ee1\u8db3")},popup.RuleCheck.prototype.checkWindowAndMatch=function(t){var e=this,p=[];_.each(t,function(t){if(!t.params||!t.params[0])return popup.log("--\u7a97\u53e3\u671f\u548c\u6b21\u6570-\u89c4\u5219\u6570\u636e\u5f02\u5e38"),!1;var n=Number(t.params[0]);1===n?p.push(t):n>1&&_.isObject(t.window)&&t.window.value>0&&(!_.isObject(t.is_in_window)||!_.isNumber(t.is_in_window.expire_time)||t.is_in_window.expire_time=n?p.push(t):popup.log("--\u7a97\u53e3\u671f\u548c\u6b21\u6570-\u89c4\u5219\u6570",t.is_in_window.count,"\u4e0d\u5339\u914d\u5f53\u524d\u6b21\u6570",n))}),p.length>0?(popup.log("--\u7a97\u53e3\u671f\u548c\u6b21\u6570-\u6709\u5339\u914d\u6210\u529f\u7684\u89c4\u5219",p),this.checkGlobalPopupLimit()):popup.log("--\u7a97\u53e3\u671f\u548c\u6b21\u6570-\u6ca1\u6709\u5339\u914d\u6210\u529f\u7684\u89c4\u5219",p)},popup.RuleCheck.prototype.checkGlobalPopupLimit=function(){var t=popup.store.getCurrentUserPlanList(),e=t.msg_limit_global,p=!0,n=this;_.isObject(e)&&!0===e.is_in_use&&_.isArray(e.limits)&&_.isArray(t.global_popup_count)&&!0===this.plan.global_msg_limit_enabled?(_.each(e.limits,function(e){if(_.isObject(e)&&_.isNumber(e.limit)){var o=popup.ruleTime.getLast(e,n.current_time),i=popup.ruleTime.getArrMatchCount(t.global_popup_count,o);popup.log("--\u5168\u5c40\u5f39\u7a97\u9650\u5236-\u5df2\u7ecf\u5f39\u7a97\u6b21\u6570-"+i+"-\u9650\u5236\u7684\u6b21\u6570"+e.limit+"-\u9650\u5236\u65f6\u95f4-"+o),p=i=2592e6&&delete popup.localData.plan_list[p]})},updateUserPlans:function(){var t=popup.serverData,e=popup.sa.store.getDistinctId();t.user_id?(popup.localData.user_list[e]=t.user_id,popup.localData.plan_list[t.user_id]||popup.localData.plan_list[e]&&(popup.localData.plan_list[t.user_id]=popup.localData.plan_list[e],delete popup.localData.plan_list[e])):popup.localData.user_list[e]||(popup.localData.user_list[e]=e)}};var IMAGE_MAP={close:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFoAAABaCAMAAAAPdrEwAAAAe1BMVEUAAAD////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////NgkbwAAAAKHRSTlMA5if6t/B0UjMSxpAtJB4MBfTr30oY6NjV0r2loZ6XkoaBenFp3UA/LNePaQAAAsxJREFUWMOsltlygzAMRRXMZsAsAZJmX9v6/7+wg1QXpjGxCDkvyWTIQZauDcCgzKLrPtnUSyGW9SbZX6OshDcQh36lH6j8MJ7pTZd6lGX6sr0IP7SDj7CA6chLoBkEFzm14nM1/P/2eGti1RZFq+LmdtwGw7afJ1Ue1dogcGCW4QptqCO2OPe1IbnL0Y7dE23wc2bJgSn44MFTvIMwLeMUXqZGfGKUkp+MPC2dwUjMGhWwUL7pnXRUsdbIIpow84VG1k9Xmf1e5U8Kq/R/68memAPqcggTCQUNc9SdL+iCL5jMd0B1j/RErh3LYrRyLa2po2x8KngJ9Uk5sWUwpZoVvIiiulNLhMwgHDhDED2MEH8X3zCDL4HV/R8lRTOEWYS0KWzt8GEm/mNLihpHKOeqJY6yLqDnbO42F1r9eXCzitMOfkuqfvkXTId6h1phSi5/ncbgneAtnDCAxTAzIn+POhfDFOObzAEsNLu0HXO06a4BCwd89wEk1h2ezdwl0rObvS5nNreHurg/lxKwsNPoHjXrHVhI+lMK3xjvMH4YelYzCSzc8V3zrx9CWtu5MG67eWEdhBSmI+GT7eIZt+Nny7YJ+y8ON9/cF1tWVL7LzTdTi6sSMtw9AE432wwl7u6MzqotMNwcM7Glc/TafRyB4+aa4dhdcoV993EDlptphlt3zZ72TgM8N88MDe3vDQWE5V6tWGaKyAbwqaiA5+aZQeETkk6QFtxuvhlaOkVwwxfgdq/IvHKbocBj6ac5OzYCIASBKGo10n+HBgakMswbaYDgTmX3fzgafhD4G+Hhg1cGXnT4PMFHVayCdVcBXGBu7cKwACOOC2YwTsIQ7KI7LBywJrlyByupK9Kw/lto4VFLAqLdmRwJiBDWwjDOI0QPPhPXRn3yTlyrILND4w7oOw3h5AlTPk5U/ddrZSk4RWW+C9hp2rgru6GiP/678n2UFPV1AAAAAElFTkSuQmCC"};popup.parseTree=function(t){this.img=void 0,this.content=void 0,this.title=void 0,this.button=[],this.image_button=void 0,this.buttonStyle={},this.view={},this.parseView(t.template),this.properties={maskCloseEnabled:t.properties.maskCloseEnabled,maskActionId:t.properties.maskActionId,maskColor:_.getRgba(t.properties.maskColor),maskAction:t.properties.maskAction},popup.popupTree.properties=this.properties},popup.parseTree.prototype={parseView:function(t){switch(t.type){case"column":case"row":this.getViewProp(t);break;case"image":this.getImg(t);break;case"label":this.getLabel(t);break;case"button":this.getButton(t);break;case"link":this.getLink(t);break;case"image_button":this.getImgButton(t)}this.img&&!_.isEmptyObject(this.img)&&(popup.popupTree.img=this.img),this.title&&!_.isEmptyObject(this.title)&&(popup.popupTree.title=this.title,popup.popupTree.diverseModule=!0),this.content&&!_.isEmptyObject(this.content)&&(popup.popupTree.content=this.content,popup.popupTree.diverseModule=!0),this.image_button&&!_.isEmptyObject(this.image_button)&&(popup.popupTree.image_button=this.image_button),this.buttonStyle&&!_.isEmptyObject(this.buttonStyle)&&(popup.popupTree.buttonStyle=this.buttonStyle),this.boxStyle&&!_.isEmptyObject(this.boxStyle)&&(popup.popupTree.boxStyle=this.boxStyle),this.container&&!_.isEmptyObject(this.container)&&(popup.popupTree.container=this.container),this.button&&!_.isEmptyObject(this.button)&&this.button.length>0&&(popup.popupTree.button=this.button,popup.popupTree.diverseModule=!0),this.view&&!_.isEmptyObject(this.view)&&(popup.popupTree.view=this.view),t.GRADE||(t.GRADE=0,this.view.container=Object.assign({},this.getViewProp(t))),t.subviews&&t.subviews.length>0&&_.each(t.subviews,function(e){e.GRADE=t.GRADE+1,this.parseView(e)},this)},getViewProp:function(t){switch(t.GRADE){case 0:return{style:"width: "+_.getRpx(t.layout.width)+";"};case 1:if(t.subviews.length>0){var e=Object.assign({},{backgroundImage:t.properties.backgroundImage?t.properties.backgroundImage:"",style:this.getStyle(t)}),p='background: url("'+e.backgroundImage+'");background-size: 100% 100%;'+e.style;this.view.content=Object.assign({},{style:p})}break;case 2:t.subviews&&t.subviews.length>0?this.view.button=Object.assign({},{type:t.type}):this.view.padding=Object.assign({},{style:"margin-top: "+_.getRpx(t.layout.margin.top)+";",type:t.type})}},isButtonBranch:function(t){var e=!0,p={image_button:1,link:1,button:1};return _.each(t,function(t,n){p[n]||(e=!1)}),e},getImg:function(t){this.img=_.extend({},this.getAttr(t.properties),this.getAction(t.action)),this.img.style=this.getStyle(t)},getImgButton:function(t){var e={};"close"===t.properties.msgType?t.properties.isHidden||(this.image_button=_.extend({},this.getAction(t.action),this.getAttr(t.properties)),t.layout.align&&(this.image_button.aligin=t.layout.align),this.image_button.style=this.getStyle(t),this.image_button.type=t.type):((e=_.extend({},this.getAction(t.action),this.getAttr(t.properties))).style=this.getStyle(t),e.type=t.type),_.isEmptyObject(e)||this.button.push(e)},getLabel:function(t){"title"===t.properties.msgType?(this.title=_.extend({},this.getAttr(t.properties)),this.title.style=this.getStyle(t)):"content"===t.properties.msgType&&(this.content=_.extend({},this.getAttr(t.properties)),this.content.style=this.getStyle(t))},getButton:function(t){var e={};(e=_.extend({},this.getAction(t.action),this.getAttr(t.properties))).style=this.getStyle(t),e.type=t.type,_.isEmptyObject(e)||this.button.push(e)},getLink:function(t){var e={};(e=_.extend({},this.getAction(t.action),this.getAttr(t.properties))).style=this.getStyle(t),e.type=t.type,_.isEmptyObject(e)||this.button.push(e)},getAttr:function(t){var e={};return t.text?e.innerText=t.text:t.image&&(t.localImageName?(e.src=IMAGE_MAP[t.localImageName],e.useLocalImage=!0):e.src=t.image),e},getAction:function(t){var e={};return t&&t.MINIPROGRAM&&(t=t.MINIPROGRAM[0],e.id=t.id,e.closeable=t.closeable,e.action_type=t.type,e.$sf_close_type=t.$sf_close_type,t.value&&(e.value=t.value),t.path&&(e.path=t.path),t.appid&&(e.appid=t.appid)),e},getStyle:function(t){var e,p={textAlign:"text-align",font:"font-size",backgroundColor:"background-color",borderWidth:function(t){return"border-width: "+t+";border-style: solid;"},borderColor:"border-color",cornerRadius:"border-radius",backgroundImage:function(t){return""},margin:this.boxModel("margin"),padding:this.boxModel("padding"),maxHeight:"max-height",maxWidth:"max-width"},n=["msgType","text","image","name","isHidden","align","localImageName"],o="";return e=_.extend({},t.layout,t.properties),_.each(e,function(t,e){t=_.getRpx(t);var i=p[e];if(n.indexOf(e)>=0)return!1;_.isString(i)?o+=i+":"+_.getRgba(t)+";":_.isFunction(i)?o+=i(t)+";":o+=e+":"+_.getRgba(t)+";"}),o},boxModel:function(t){return function(e){if("object"!=typeof e)return e;var p="";for(var n in e)p+=t+"-"+n+":"+_.getRpx(e[n]);return p}}};var QRCode={1011:1,1012:1,1013:1,1017:1,1047:1,1048:1,1049:1};popup.testSend={getPopupId:function(t){var e=0,p=t.query.scene;if(p){var n=decodeURIComponent(p).split("=");e="sf_test_id"===n[0]&&n[1]?n[1]:0}return e},start:function(t){if(!QRCode[t.scene])return!1;var e=this.getPopupId(t);if(!e)return!1;var p=popup.info.project,n=popup.info.platform,o=popup.sa.store.getDistinctId();_.wxrequest({url:popup.info.api_base_url+"/sfo/popup_windows/"+e+"?distinct_id="+encodeURIComponent(o)+"&app_id="+encodeURIComponent(popup.info.app_id)+"&project="+encodeURIComponent(p)+"&platform="+encodeURIComponent(n)+"&sdk_version="+encodeURIComponent(popup.lib_version)+"&time="+(new Date).getTime(),type:"GET",success:function(t){var e,p=t.data,n={content:p.content,type:p.popup_type,name:p.name||""},o=!0,i=_.getUuid()();try{e=JSON.parse(p.content)}catch(t){o=!1}var r={props:{$sf_succeed:!0},plan:{}};if(r.uuid=i,popup.popupTree={},"CUSTOMIZED"===p.popup_type)r.popupTree={},popup.CAMPAIGN_ERROR.onStart?(r.props={$sf_fail_reason:"onStart \u65b9\u6cd5\u672a\u5b9a\u4e49",$sf_succeed:!1},popup.track.popupDisplay(r),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(n,"1004","onStart \u65b9\u6cd5\u672a\u5b9a\u4e49")):p.content?(popup.campaign_listener.onStart(n),popup.track.popupDisplay(r)):(r.props={$sf_fail_reason:"\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e",$sf_succeed:!1},popup.track.popupDisplay(r),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(n,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e"));else{try{new popup.parseTree(e),r.popupTree=popup.popupTree,r.plan={popup_window_content:p}}catch(t){popup.log("--\u6d4b\u8bd5\u5f39\u7a97-\u89e3\u6790\u9519\u8bef",t),o=!1}o?(popup.track.popupDisplay(r),popup.CAMPAIGN_ERROR.onStart||popup.campaign_listener.onStart(n),popup.popupEmitter.notify(r)):(r.props={$sf_fail_reason:"\u5f39\u7a97\u5185\u5bb9\u5f02\u5e38",$sf_succeed:!1},popup.track.popupDisplay(r),popup.info.popup_listener.onLoadFailed(void 0,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e"),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(n,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e"))}}})}},popup.track={getPublicProps:function(){return{$sf_lib_version:popup.lib_version,$sf_plan_type:"\u8fd0\u8425\u8ba1\u5212",$sf_channel_service_name:"SENSORS_FOCUS",$sf_channel_category:"POPUP",$sf_platform_tag:popup.info.platform}},removeEmpty:function(t){_.each(t,function(e,p){""!==e&&void 0!==e||delete t[p]})},popupDisplay:function(t){var e=popup.track.getPublicProps(),p=popup.track.getPlanProps(t);_.extend(e,t.props,p),this.removeEmpty(e),popup.sa.track("$PlanPopupDisplay",e)},popupClick:function(t){var e=popup.track.getPublicProps(),p=popup.track.getPlanProps(t),n={type:t.props.$sf_msg_element_action,value:t.props.action_value||"",extra:t.props.action_value||""};try{if(popup.info.popup_listener.onClick(t.plan.plan_id,n),!popup.CAMPAIGN_ERROR.onClick){var o={name:t.plan.cname,plan_id:t.plan.plan_id,content:t.plan.popup_window_content?t.plan.popup_window_content.content:"",type:t.plan.popup_window_content?t.plan.popup_window_content.popup_type:"",action:n};popup.campaign_listener.onClick(o)}}catch(t){popup.log("popup_listener.onClick error",t)}delete t.props.action_value,_.extend(e,t.props,p),e.$sf_plan_id||delete e.$sf_plan_id,this.removeEmpty(e),popup.sa.track("$PlanPopupClick",e)},getPlanProps(t){var e={};if(!_.isObject(t))return e;var p=t.popupTree;if(e.$sf_msg_id=t.uuid,e.$sf_msg_title=p.title?p.title.innerText:"",e.$sf_msg_content=p.content?p.content.innerText:"",e.$sf_msg_image_url=p.img?p.img.src:"",e.$sf_plan_id=t.plan&&t.plan.plan_id||"",e.$sf_audience_id=t.plan&&t.plan.audience_id||"",t.plan.strategy_id?e.$sf_plan_strategy_id=t.plan.strategy_id:_.isBoolean(t.plan.is_control_group)&&(t.plan.is_control_group?e.$sf_plan_strategy_id=-1:e.$sf_plan_strategy_id=0),_.isObject(t.plan)){var n=t.plan.section_id;n&&(e.$sf_section_id=String(n),e.$sf_plan_type="\u65b0\u8d44\u6e90\u4f4d")}return e}},module.exports=popup; \ No newline at end of file +"use strict";var popup={plugin_name:"PopupWechat",plugin_version:"1.19.12",sa:{},info:{app_id:"",show_log:!0},campaign_listener:{},lib_version:"1.19.12",defaultPara:{platform:"MINIPROGRAM",preload_image:!0,defer_render:!1},serverData:{},localData:{},event_list:[],popuping:!1,convertPlans:[],eventRule:{},popupTree:{},log:function(){if(popup.info.show_log&&"object"==typeof console&&console.log)try{return console.log.apply(console,arguments)}catch(t){console.log(arguments[0])}},CAMPAIGN_ERROR:{}},getRandomBasic=function(){var t=(new Date).getTime();return function(e){return Math.ceil((t=(9301*t+49297)%233280)/233280*e)}}(),_={getRgba:function(t){return"object"!=typeof t?t:"rgba("+t.r+","+t.g+","+t.b+","+t.a+")"},getRpx:function(t){if(t){if(/^[0|1]?\.\d+$/.test(t))return 100*Number(t)+"%";var e=/^(-?\d+(\.\d+)?)px$/.exec(t);return e?2*Number(e[1])+"rpx":t}},extend:function(t){var e=Array.prototype.slice;return _.each(e.call(arguments,1),function(e){for(var p in e)void 0!==e[p]&&(t[p]=e[p])}),t},each:function(t,e,p){var n=Array.prototype.forEach,o={};if(null==t)return!1;if(n&&t.forEach===n)t.forEach(e,p);else if(t.length===+t.length){for(var i=0,r=t.length;i0&&(r[n[0]]||(r[n[0]]=1));return _.each(r,function(t,e){u.push(e)}),u},_.getConvertNumberValue=function(t){return _.isString(t)&&(t=Number(t)),Math.floor(1e3*t)/1e3},_.wxrequest=function(t){var e=wx.request(t);setTimeout(function(){_.isObject(e)&&_.isFunction(e.abort)&&e.abort()},3e4)},_.getProject=function(t){if(t&&t.split("?")[1]){var e=decodeURIComponent(t.split("?")[1]);return _.getURLSearchParams(e).project||"default"}return"default"},_.getCurrentPage=function(){var t=getCurrentPages(),e=t[t.length-1];return!!_.isObject(e)&&e},_.getPropertiesValue=function(t,e){var p=t[e];return"$event_duration"===e&&void 0===p&&(p=t.event_duration),p},popup._=_,popup.handleEvents=function(t,e){if("send"===t){if(popup.popuping)return popup.event_list.push(e),!1;e.event&&popup.eventRule[e.event]&&popup.eventTriggerProcess(popup.eventRule[e.event],e)}if("changeDistinctId"===t&&popup.updateAndListenPlan.changeId(),"popup_display"===t){popup.popuping=!0;try{popup.info.popup_listener.onLoadSuccess(e.plan.plan_id)}catch(t){popup.log("popup_listener.onLoad error",t)}}if("popup_load_fail"===t){var p=e.plan_id,n=e.fail_code,o=e.fail_reason;try{popup.info.popup_listener.onLoadFailed(p,n,o)}catch(t){popup.log("popup_listener.onLoad error",t)}}if("popup_click"===t&&popup.track.popupClick(e),"popup_end"===t){popup.popuping=!1;var i={name:e.plan.cname,plan_id:e.plan.plan_id,content:e.plan.popup_window_content?e.plan.popup_window_content.content:"",type:e.plan.popup_window_content?e.plan.popup_window_content.popup_type:""};popup.CAMPAIGN_ERROR.onEnd||popup.campaign_listener.onEnd(i);try{popup.info.popup_listener.onClose(e.plan.plan_id)}catch(t){popup.log("popup_listener.onLoad error",t)}popup.updateGlobalCount(),popup.updatePlanInterval(e.plan),_.each(popup.event_list,function(t){t.event&&popup.eventRule[t.event]&&popup.eventTriggerProcess(popup.eventRule[t.event],t)}),popup.event_list=[]}},popup.setPara=function(t){if(_.isObject(t)||(t={}),popup.info=_.extend(popup.info,popup.defaultPara,t),popup.info.app_id||popup.log("\u521d\u59cb\u5316\u53c2\u6570 appid \u6821\u9a8c\u5931\u8d25\uff0c\u65e0\u6cd5\u62c9\u53d6\u5f39\u7a97\u8ba1\u5212!"),_.isString(popup.info.api_base_url)&&"http"===popup.info.api_base_url.slice(0,4)||popup.log("popup \u5fc5\u987b\u586b\u5199\u6709\u6548 api_base_url"),popup.info.project||(popup.info.project=_.getProject(popup.sa.para.server_url)),_.isObject(popup.info.popup_listener)){var e=popup.info.popup_listener;_.isFunction(e.onClick)||(popup.info.popup_listener.onClick=function(){}),_.isFunction(e.onLoadSuccess)||(popup.info.popup_listener.onLoadSuccess=function(){}),_.isFunction(e.onLoadFailed)||(popup.info.popup_listener.onLoadFailed=function(){}),_.isFunction(e.onClose)||(popup.info.popup_listener.onClose=function(){})}else popup.info.popup_listener={onClick:function(){},onLoadSuccess:function(){},onLoadFailed:function(){},onClose:function(){}};_.isObject(t.campaign_listener)?(popup.campaign_listener=_.extend({},t.campaign_listener),popup.campaign_listener.shouldStart&&_.isFunction(popup.campaign_listener.shouldStart)||(popup.campaign_listener.shouldStart=function(){return!0},popup.CAMPAIGN_ERROR.shouldStart={error_code:"4001",reeor_txt:"NOT_DEFINED OR DEFINED_ERROR"}),popup.campaign_listener.onClick?_.isFunction(popup.campaign_listener.onClick)||(popup.CAMPAIGN_ERROR.onClick={error_code:"4002",reeor_txt:"DEFINED_TYPE_ERROR"}):popup.CAMPAIGN_ERROR.onClick={error_code:"4001",reeor_txt:"NOT_DEFINED"},popup.campaign_listener.onStart?_.isFunction(popup.campaign_listener.onStart)||(popup.CAMPAIGN_ERROR.onStart={error_code:"4002",reeor_txt:"DEFINED_TYPE_ERROR"}):popup.CAMPAIGN_ERROR.onStart={error_code:"4001",reeor_txt:"NOT_DEFINED"},popup.campaign_listener.onEnd?_.isFunction(popup.campaign_listener.onEnd)||(popup.CAMPAIGN_ERROR.onEnd={error_code:"4002",reeor_txt:"DEFINED_TYPE_ERROR"}):popup.CAMPAIGN_ERROR.onEnd={error_code:"4001",reeor_txt:"NOT_DEFINED"},popup.campaign_listener.onFailed?_.isFunction(popup.campaign_listener.onFailed)||(popup.CAMPAIGN_ERROR.onFailed={error_code:"4002",reeor_txt:"DEFINED_TYPE_ERROR"}):popup.CAMPAIGN_ERROR.onFailed={error_code:"4001",reeor_txt:"NOT_DEFINED"}):(popup.campaign_listener.shouldStart=function(){return!0},popup.CAMPAIGN_ERROR.shouldStart={error_code:"4001",reeor_txt:"NOT_DEFINED"},popup.CAMPAIGN_ERROR.onClick={error_code:"4001",reeor_txt:"NOT_DEFINED"},popup.CAMPAIGN_ERROR.onStart={error_code:"4001",reeor_txt:"NOT_DEFINED"},popup.CAMPAIGN_ERROR.onEnd={error_code:"4001",reeor_txt:"NOT_DEFINED"},popup.CAMPAIGN_ERROR.onFailed={error_code:"4001",reeor_txt:"NOT_DEFINED"},popup.CAMPAIGN_ERROR.campaign_listener={error_code:"4003",errot_txt:"CAMPAIGN_CUSTOMIZED_NULL_LISTENER OR DEFINED ERROR"})},popup.dataRender={that:null,queue:[],notify:function(t){_.isFunction(this.handle)?this.handle(this.that,t):this.queue.push(t)}},popup.popupEmitter={image_list:[],loaded:!1,notify:function(t){var e=_.getCurrentPage(),p=this;e&&_.isObject(e)&&_.isFunction(e.selectComponent)&&(popup.info.defer_render?setTimeout(function(){p.renderPopup(e,t)},0):p.renderPopup(e,t))},renderPopup:function(t,e){var p=t.selectComponent("#sensors_popup");if(_.isObject(p)&&_.isFunction(p.handle))p.handle(e);else{var n="";try{var o=_.getCurrentPage();n=o?o.route:""}catch(t){}popup.log("\u5f53\u524d\u9875\u9762 "+n+" \u672a\u96c6\u6210\u5f39\u7a97\u7ec4\u4ef6")}},loadImage:function(t){if(JSON.stringify(t)!==JSON.stringify(this.image_list)&&(this.loaded=!1,this.image_list=t),!this.loaded){var e=_.getCurrentPage();if(e&&_.isObject(e)&&_.isFunction(e.selectComponent)){var p=e.selectComponent("#sensors_popup");_.isObject(p)&&_.isFunction(p.loadImage)&&(p.loadImage(t),this.loaded=!0)}}},attached:function(){this.loaded||this.loadImage(this.image_list)}},popup.testPopup=function(){wx.onAppShow(function(t){popup.updateAndListenPlan.pullPlan(),popup.testSend.start(t)})},popup.updateGlobalCount=function(){var t=popup.sa.store.getDistinctId(),e=popup.localData.user_list[t],p=(new Date).getTime();if(!_.isArray(popup.localData.plan_list[e].global_popup_count))return popup.localData.plan_list[e].global_popup_count=[],popup.localData.plan_list[e].global_popup_count.unshift(p),!1;popup.localData.plan_list[e].global_popup_count.shift(),popup.localData.plan_list[e].global_popup_count.unshift(p)},popup.updatePlanInterval=function(t){var e=(new Date).getTime();_.isObject(t)&&_.isObject(t.popup_interval)&&t.popup_interval.value&&(t.is_in_popup_interval_window=popup.ruleTime.getExpire(t.popup_interval,e))},popup.init=function(t,e){popup.log("\u5f39\u7a97\u5f00\u59cb\u521d\u59cb\u5316\uff01"),this.sa=t,this.setPara(e),this.sub=new t.eventSub(this.handleEvents),popup.updateAndListenPlan.initial(),popup.testPopup(),t.popupEmitter=popup.popupEmitter},popup.changeCovertStatus=function(t){var e=JSON.parse(JSON.stringify(popup.convertPlans));_.each(e,function(p,n){var o=p.is_in_convert_window.step,i=p.is_in_convert_window.uuid;if(popup.convertPlans[n].is_in_convert_window.step=Math.min(2*o,6e5),!t||!_.isArray(t)||0===t.length)return!1;_.each(t,function(t){t.popup_display_uuid===i&&t.convert_time&&(delete popup.convertPlans[n].is_in_convert_window,popup.convertPlans.splice(n,1),e.splice(n,1),n--)})}),popup.updateAndListenPlan.updateData()},popup.asyncConvert=function(t){var e=popup.info.project,p=!1;if(!t&&0===popup.convertPlans.length)return!1;t&&(_.each(popup.convertPlans,function(e){e.plan_id===t.plan_id&&(p=!0)}),p||popup.convertPlans.push(t)),function t(){if(_.isEmptyObject(popup.localData)||!_.isArray(popup.convertPlans)||0===popup.convertPlans.length)return!1;var p=popup.convertPlans,n=p[0].is_in_convert_window&&p[0].is_in_convert_window.step||5e3,o=[],i=Date.now();_.each(p,function(t){var e=t.is_in_convert_window;if(!e)return!1;e.step||(e.step=5e3),n>e.step&&(n=e.step)}),_.each(p,function(t){if(!t.is_in_convert_window)return!1;var e=t.is_in_convert_window.expire_time;if(i>e||n>e-i)return delete t.is_in_convert_window,!1;o.push(t.is_in_convert_window.uuid)});var r=_.filter(p,function(t){return!!t.is_in_convert_window&&i11?(r.setFullYear(r.getFullYear()+parseInt(t/12)),r.setMonth(t%12)):r.setMonth(t),r.setDate(1),r.setHours(0),r.setMinutes(0),r.setSeconds(0),r.setMilliseconds(0),r.getTime()},second:function(t){var e={month:2592e6,week:6048e5,day:864e5,hour:36e5,minute:6e4,second:1e3},o=null;return r=new Date(p),t in e&&(o=e[t]*n),r.getTime()+o}};return!0!==t.natural?a.second(i):i in a?a[i]():void 0},getLast:function(t,e){var p=Number(t.value)||0,n=Number(t.value)-1||0,o=String(t.unit).toLowerCase(),i=null,r={day:function(){return(i=new Date(e)).setHours(0),i.setMinutes(0),i.setSeconds(0),i.setMilliseconds(0),i=i.getTime()-864e5*n},week:function(){var t=(i=new Date(e)).getDay();return 0===t&&(t=7),--t,i.setHours(0),i.setMinutes(0),i.setSeconds(0),i.setMilliseconds(0),i=i.getTime()-(24*t*60*60*1e3+7*n*24*60*60*1e3)},month:function(){var t=(i=new Date(e)).getMonth()+1-n;return t<=0?(i.setFullYear(i.getFullYear()+(parseInt(t/12)-1)),i.setMonth(12+t%12-1)):i.setMonth(t-1),i.setDate(1),i.setHours(0),i.setMinutes(0),i.setSeconds(0),i.setMilliseconds(0),i.getTime()},second:function(t){var n={month:2592e6,week:6048e5,day:864e5,hour:36e5,minute:6e4,second:1e3},o=null;return i=new Date(e),t in n&&(o=n[t]*p),i.getTime()-o}};return!0!==t.natural?r.second(o):o in r?r[o]():void 0},getArrMatchCount:function(t,e){var p=0;for(p=0;p=t[p])return p;return t.length},checkRule:function(t,e){var p=new Date,n=e,o=Number(t.value)||0,i=Number(t.value)-1||0,r=String(t.unit).toLowerCase(),a=null,u={day:function(){return(a=new Date(n)).setHours(23),a.setMinutes(59),a.setSeconds(59),a.setMilliseconds(999),a=a.getTime()+864e5*i,p>a},week:function(){var t=(a=new Date(n)).getDay();0===t&&(t=7);var e=7-t;return a.setHours(23),a.setMinutes(59),a.setSeconds(59),a.setMilliseconds(999),a=a.getTime()+24*e*60*60*1e3+7*i*24*60*60*1e3,p>a},month:function(){var t=(a=new Date(n)).getMonth()+i;return t>=11?(a.setFullYear(a.getFullYear()+t/11),a.setMonth(t%11)):a.setMonth(t),a.setDate(1),a.setHours(0),a.setMinutes(0),a.setSeconds(0),a.setMilliseconds(0),p>a},second:function(t){return a=new Date(n),t in inteval&&(interval_time={month:2592e6,week:6048e5,day:864e5,hour:36e5,minute:6e4,second:1e3}[t]*o),p>a+null}};return!0!==t.natural?u.second(r):r in u?u[r]():void 0}},popup.eventTriggerProcess=function(t,e){var p=!1;_.isArray(t)&&t.length>0&&_.isObject(t[0])&&(popup.log("--------------------\u89e6\u53d1\u4e8b\u4ef6\u5f00\u59cb--------------------"),_.each(t,function(t){_.isObject(t)&&void 0!==t.match_state&&delete t.match_state,new popup.RuleCheck(t,e)}),_.each(t,function(t){!0===t.match_state?!1===p?(p=!0,popup.log("\u68c0\u67e5\u5b8c\u6bd5-\u4f18\u5148\u5f39\u7a97-\u5f00\u59cb",t.plan.cname),new popup.PopupCheck(t,!0)):!0===p&&(popup.log("\u68c0\u67e5\u5b8c\u6bd5-\u975e\u4f18\u5148\u5f39\u7a97-\u4e0d\u6e32\u67d3",t.plan.cname),new popup.PopupCheck(t,!1)):popup.log("\u68c0\u67e5\u5b8c\u6bd5-\u8ba1\u5212-\u4e0d\u6ee1\u8db3",t.plan.cname)}),popup.log("--------------------\u89e6\u53d1\u4e8b\u4ef6\u7ed3\u675f--------------------"))},popup.PopupCheck=function(t,e){this.plan=t.plan,this.current_time=(new Date).getTime(),e?this.displayPopup():this.hidePopup()},popup.PopupCheck.prototype.displayPopup=function(){var t=_.getUuid()(),e={props:{$sf_succeed:!0}};popup.popupTree={},e.uuid=t,e.plan=this.plan;var p=this.plan.popup_window_content,n="",o=!0;if(p&&p.content)try{n=JSON.parse(p.content),new popup.parseTree(n)}catch(t){n=!1,o=!1}else popup.log("\u8ba1\u5212\u65e0\u7a97\u4f53\u5185\u5bb9\uff01"),o=!1;e.popupTree=popup.popupTree;var i={name:this.plan.cname,plan_id:this.plan.plan_id,content:this.plan.popup_window_content?this.plan.popup_window_content.content:"",type:this.plan.popup_window_content?this.plan.popup_window_content.popup_type:""};this.plan.hasOwnProperty("strategy_id")?this.plan.is_trigger?popup.campaign_listener.shouldStart(i)?p?"CUSTOMIZED"===p.popup_type?(e.popupTree={},popup.CAMPAIGN_ERROR.onStart?(e.props={$sf_fail_reason:"onStart \u672a\u5b9a\u4e49",$sf_succeed:!1},popup.track.popupDisplay(e),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,1004,"onStart \u672a\u5b9a\u4e49")):p.content?(popup.track.popupDisplay(e),popup.campaign_listener.onStart(i),popup.info.popup_listener.onLoadSuccess(this.plan.plan_id)):(e.props={$sf_fail_reason:"\u5f39\u7a97\u5185\u5bb9\u9519\u8bef",$sf_succeed:!1},popup.track.popupDisplay(e),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,1001,"\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e"))):o?(popup.track.popupDisplay(e),popup.CAMPAIGN_ERROR.onStart||popup.campaign_listener.onStart(i),this.renderPopup(e)):(e.props={$sf_fail_reason:"\u5f39\u7a97\u5185\u5bb9\u9519\u8bef",$sf_succeed:!1},popup.track.popupDisplay(e),popup.info.popup_listener.onLoadFailed(this.plan.plan_id,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e"),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e")):(e.props={$sf_fail_reason:"\u5f39\u7a97\u5185\u5bb9\u9519\u8bef",$sf_succeed:!1},popup.track.popupDisplay(e),popup.info.popup_listener.onLoadFailed(this.plan.plan_id,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e"),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e")):(e.props={$sf_fail_reason:"shouldStart \u63a5\u53e3\u8fd4\u56de false",$sf_succeed:!1},popup.track.popupDisplay(e),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,"1004","shouldStart \u63a5\u53e3\u8fd4\u56de false")):(e.props={$sf_fail_reason:"\u8ba1\u5212\u4e0b\u53d1 is_trigger \u4e3a false",$sf_succeed:!1},popup.track.popupDisplay(e),p&&"PRESET"===p.popup_type&&popup.info.popup_listener.onLoadFailed(this.plan.plan_id,"1005","\u8ba1\u5212\u4e0b\u53d1 is_trigger \u4e3a false"),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,"1005","\u8ba1\u5212\u4e0b\u53d1 is_trigger \u4e3a false")):this.plan.is_control_group?(e.props={$sf_fail_reason:"\u5bf9\u7167\u7ec4",$sf_succeed:!1},popup.track.popupDisplay(e),popup.info.popup_listener.onLoadFailed(this.plan.plan_id,"2000","\u5bf9\u7167\u7ec4"),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,"2000","\u5bf9\u7167\u7ec4")):popup.campaign_listener.shouldStart(i)?o?(popup.track.popupDisplay(e),popup.CAMPAIGN_ERROR.onStart||popup.campaign_listener.onStart(i),this.renderPopup(e)):(e.props={$sf_fail_reason:"\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e",$sf_succeed:!1},popup.track.popupDisplay(e),popup.info.popup_listener.onLoadFailed(this.plan.plan_id,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e"),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e")):(e.props={$sf_fail_reason:"shouldStart \u63a5\u53e3\u8fd4\u56de false",$sf_succeed:!1},popup.track.popupDisplay(e),popup.info.popup_listener.onLoadFailed(this.plan.plan_id,"1004","shouldStart \u63a5\u53e3\u8fd4\u56de false"),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,"1004","shouldStart \u63a5\u53e3\u8fd4\u56de false"));this.startConvertWindow(t),this.startPopupIntervalWindow(),this.startPopupLimitWindow(),this.setGlobalLimit(),this.deletePlanAllWindow(),popup.updateAndListenPlan.updateData()},popup.PopupCheck.prototype.hidePopup=function(){this.deletePlanAllWindow(),popup.updateAndListenPlan.updateData()},popup.PopupCheck.prototype.renderPopup=function(t){popup.log("\u6e32\u67d3\u5f39\u7a97"),popup.popupEmitter.notify(t)},popup.PopupCheck.prototype.startConvertWindow=function(t){popup.log("--\u5f39\u7a97\u5c55\u793a-\u8f6c\u5316\u7a97\u53e3\u8bbe\u7f6e"),_.isObject(this.plan.convert_window)&&this.plan.convert_window.value&&(this.plan.is_in_convert_window={expire_time:popup.ruleTime.getExpire(this.plan.convert_window,this.current_time),start_time:this.current_time,uuid:t},popup.asyncConvert(this.plan))},popup.PopupCheck.prototype.startPopupIntervalWindow=function(){_.isObject(this.plan.popup_interval)&&this.plan.popup_interval.value&&(this.plan.is_in_popup_interval_window=popup.ruleTime.getExpire(this.plan.popup_interval,this.current_time))},popup.PopupCheck.prototype.startPopupLimitWindow=function(){popup.log("--\u5f39\u7a97\u5c55\u793a-\u53c2\u4e0e\u9650\u5236\u7a97\u53e3\u8bbe\u7f6e\u91cd\u7f6e"),_.isObject(this.plan.re_enter)&&this.plan.re_enter.value&&(_.isObject(this.plan.is_in_popup_limit_window)?this.plan.is_in_popup_limit_window.count++:this.plan.is_in_popup_limit_window={expire_time:popup.ruleTime.getExpire(this.plan.re_enter,this.current_time),count:1})},popup.PopupCheck.prototype.setGlobalLimit=function(){popup.log("--\u5f39\u7a97\u5c55\u793a-\u5168\u5c40\u5f39\u7a97\u6b21\u6570\u8bbe\u7f6e");var t=popup.store.getCurrentUserPlanList();_.isArray(t.global_popup_count)||(t.global_popup_count=[]),t.global_popup_count.unshift(this.current_time);for(var e=t.global_popup_count,p=e[e.length-1];p+7776e63e3;)e.pop(),p=e[e.length-1]},popup.PopupCheck.prototype.deletePlanAllWindow=function(){var t=this.plan.pattern_popup.matcher_list;_.isArray(t)&&_.each(t,function(t){t.is_in_window&&(popup.log("--\u5f39\u7a97\u5c55\u793a-\u91cd\u7f6e\u5404\u4e2a\u89c4\u5219\u7684\u7a97\u53e3\u8ba1\u7b97-\u6210\u529f"),delete t.is_in_window)})},popup.RuleCheck=function(t,e){this.plan_match=t,this.plan=t.plan,this.rule_arr=t.rule,this.event_data=e,this.current_time=(new Date).getTime();var p="-------------\u68c0\u67e5-\u8ba1\u5212-("+this.plan.cname+")";_.each(this.rule_arr,function(t){p+="--\u5305\u542b\u89c4\u5219-("+t.event_name+"\uff09-\u89e6\u53d1"+t.params[0]+"\u6b21"}),popup.log(p),popup.log(this.plan),this.checkPlanIsExpire(),popup.updateAndListenPlan.updateData()},popup.RuleCheck.prototype.checkPlanIsExpire=function(){!this.plan.expire_at||_.isNumber(this.plan.expire_at)&&this.current_timethis.current_time?popup.log("--\u5b58\u5728\u8f6c\u5316\u7a97\u53e3 - \u4e0d\u6ee1\u8db3",this.plan.is_in_convert_window):(popup.log("--\u4e0d\u5b58\u5728\u8f6c\u5316\u7a97\u53e3\u6216\u8005\u7a97\u53e3\u8d85\u65f6\u5df2\u7ecf\u8fc7\u671f - \u6ee1\u8db3",this.plan.is_in_convert_window),this.checkGlobalPopupInterval())},popup.RuleCheck.prototype.checkGlobalPopupInterval=function(){var t=popup.store.getCurrentUserPlanList(),e=t.global_popup_count;if(_.isArray(e)&&e.length>=1){var p=popup.ruleTime.getLast(t.popup_interval_global,this.current_time);p>e[0]?(popup.log("--\u5168\u5c40\u5f39\u7a97\u95f4\u9694-\u6ee1\u8db3-"+p+">\u4e0a\u6b21\u5f39\u7a97\u65f6\u95f4"+e[0]),this.checkPopupInterval()):popup.log("\u68c0\u67e5-\u5168\u5c40\u5f39\u7a97\u95f4\u9694-\u4e0d\u6ee1\u8db3-"+p+"<\u4e0a\u6b21\u5f39\u7a97\u65f6\u95f4"+e[0])}else popup.log("--\u5168\u5c40\u5f39\u7a97\u95f4\u9694-\u6ca1\u6709\u5f39\u8fc7\u7a97-\u6ee1\u8db3"),this.checkPopupInterval()},popup.RuleCheck.prototype.checkPopupInterval=function(){_.isNumber(this.plan.is_in_popup_interval_window)?this.current_time>this.plan.is_in_popup_interval_window?(popup.log("--\u5f39\u7a97\u95f4\u9694-\u5f53\u524d\u65f6\u95f4\u5927\u4e8e\u56fa\u5b9a\u5f39\u7a97\u95f4\u9694-\u6ee1\u8db3"),this.plan.is_in_popup_interval_window=null,this.checkPermission()&&this.checkProperties()):popup.log("--\u5f39\u7a97\u95f4\u9694-\u5f53\u524d\u65f6\u95f4\u5c0f\u4e8e\u56fa\u5b9a\u5f39\u7a97\u95f4\u9694-\u4e0d\u6ee1\u8db3"):(popup.log("--\u5f39\u7a97\u95f4\u9694-\u7a97\u53e3\u4e0d\u5b58\u5728-\u65b0\u5f00"),this.plan.is_in_popup_interval_window=null,this.checkPermission()&&this.checkProperties())},popup.RuleCheck.prototype.isMatched=function(t){var e={equal:function(t,e){if(!_.isNumber(t)&&!_.isString(t))return!1;for(var p=0,n=e.length;p=0},notContain:function(t,e){return!!_.isString(t)&&-1===t.indexOf(e[0])},isTrue:function(t){return!0===t},isFalse:function(t){return!1===t},isSet:function(t){return void 0!==t},notSet:function(t){return void 0===t},isEmpty:function(t){if(!_.isString(t)&&!_.isArray(t))return!1;if(_.isString(t))return""===t;for(var e=0;eNumber(e[0])},between:function(t,e){return!!_.isNumber(t)&&(t>=Number(e[0])&&t<=Number(e[1]))},in:function(t,e){if(!_.isArray(t))return!1;for(var p=0;p=0)return!0;return!1},notInclude:function(t,e){if(!_.isArray(t))return!1;for(var p=0;p=p&&o<=n}catch(t){popup.log("absolute_between Error",t)}},absoluteBetween:function(t,e){try{var p=new Date(e[0]),n=new Date(e[1]),o=new Date(t);return o>=p&&o<=n}catch(t){popup.log("absolute_between Error",t)}}},p=this,n=t.relation,o="or"===String(n).toLowerCase(),i="and"===String(n).toLowerCase(),r=!!i,a=!0;return _.each(t.conditions,function(t){if(!a)return!1;if(!t.field)return!1;var n=t.field.lastIndexOf("."),u=t.params,s=t.function;if(!e[s])return r=!1,a=!1,!1;if(n<0)return!1;var l=t.field.slice(n+1),c=p.event_data.properties,d=_.getPropertiesValue(c,l),g=e[s](d,u);o&&g&&(r=!0,a=!1),i&&!g&&(r=!1,a=!1)}),r},popup.RuleCheck.prototype.checkPermission=function(){var t=this.plan.event_permission;if(!_.isObject(t)||_.isEmptyObject(t))return!0;var e=this,p=[],n=function(t){return _.filter(t,function(t){return!(t&&t.conditions&&(!t.conditions||0!==t.conditions.length))||e.isMatched(t)})};return function t(e,o){_.each(e,function(e){if(p=n([e]),_.isArray(p)&&p.length>0){var i=e[o]||[];i&&i.length>0&&t(i,o)}})}([t],"filters"),_.isArray(p)&&p.length>0?(popup.log("--\u89d2\u8272\u5c5e\u6027\u5339\u914d-\u6ee1\u8db3",p),!0):(popup.log("--\u89d2\u8272\u5c5e\u6027\u5339\u914d-\u4e0d\u6ee1\u8db3"),!1)},popup.RuleCheck.prototype.checkProperties=function(){var t=this,e=_.filter(this.rule_arr,function(e){var p=e.multi_filter?e.multi_filter:e.filter;return!(p&&(!p.conditions||0!==p.conditions.length))||t.isMatched(p)});_.isArray(e)&&e.length>0?(this.checkWindowAndMatch(e),popup.log("--\u5c5e\u6027\u5339\u914d-\u6ee1\u8db3",e)):popup.log("--\u5c5e\u6027\u5339\u914d-\u4e0d\u6ee1\u8db3")},popup.RuleCheck.prototype.checkWindowAndMatch=function(t){var e=this,p=[];_.each(t,function(t){if(!t.params||!t.params[0])return popup.log("--\u7a97\u53e3\u671f\u548c\u6b21\u6570-\u89c4\u5219\u6570\u636e\u5f02\u5e38"),!1;var n=Number(t.params[0]);1===n?p.push(t):n>1&&_.isObject(t.window)&&t.window.value>0&&(!_.isObject(t.is_in_window)||!_.isNumber(t.is_in_window.expire_time)||t.is_in_window.expire_time=n?p.push(t):popup.log("--\u7a97\u53e3\u671f\u548c\u6b21\u6570-\u89c4\u5219\u6570",t.is_in_window.count,"\u4e0d\u5339\u914d\u5f53\u524d\u6b21\u6570",n))}),p.length>0?(popup.log("--\u7a97\u53e3\u671f\u548c\u6b21\u6570-\u6709\u5339\u914d\u6210\u529f\u7684\u89c4\u5219",p),this.checkGlobalPopupLimit()):popup.log("--\u7a97\u53e3\u671f\u548c\u6b21\u6570-\u6ca1\u6709\u5339\u914d\u6210\u529f\u7684\u89c4\u5219",p)},popup.RuleCheck.prototype.checkGlobalPopupLimit=function(){var t=popup.store.getCurrentUserPlanList(),e=t.msg_limit_global,p=!0,n=this;_.isObject(e)&&!0===e.is_in_use&&_.isArray(e.limits)&&_.isArray(t.global_popup_count)&&!0===this.plan.global_msg_limit_enabled?(_.each(e.limits,function(e){if(_.isObject(e)&&_.isNumber(e.limit)){var o=popup.ruleTime.getLast(e,n.current_time),i=popup.ruleTime.getArrMatchCount(t.global_popup_count,o);popup.log("--\u5168\u5c40\u5f39\u7a97\u9650\u5236-\u5df2\u7ecf\u5f39\u7a97\u6b21\u6570-"+i+"-\u9650\u5236\u7684\u6b21\u6570"+e.limit+"-\u9650\u5236\u65f6\u95f4-"+o),p=i=2592e6&&delete popup.localData.plan_list[p]})},updateUserPlans:function(){var t=popup.serverData,e=popup.sa.store.getDistinctId();t.user_id?(popup.localData.user_list[e]=t.user_id,popup.localData.plan_list[t.user_id]||popup.localData.plan_list[e]&&(popup.localData.plan_list[t.user_id]=popup.localData.plan_list[e],delete popup.localData.plan_list[e])):popup.localData.user_list[e]||(popup.localData.user_list[e]=e)}};var IMAGE_MAP={close:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFoAAABaCAMAAAAPdrEwAAAAe1BMVEUAAAD////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////NgkbwAAAAKHRSTlMA5if6t/B0UjMSxpAtJB4MBfTr30oY6NjV0r2loZ6XkoaBenFp3UA/LNePaQAAAsxJREFUWMOsltlygzAMRRXMZsAsAZJmX9v6/7+wg1QXpjGxCDkvyWTIQZauDcCgzKLrPtnUSyGW9SbZX6OshDcQh36lH6j8MJ7pTZd6lGX6sr0IP7SDj7CA6chLoBkEFzm14nM1/P/2eGti1RZFq+LmdtwGw7afJ1Ue1dogcGCW4QptqCO2OPe1IbnL0Y7dE23wc2bJgSn44MFTvIMwLeMUXqZGfGKUkp+MPC2dwUjMGhWwUL7pnXRUsdbIIpow84VG1k9Xmf1e5U8Kq/R/68memAPqcggTCQUNc9SdL+iCL5jMd0B1j/RErh3LYrRyLa2po2x8KngJ9Uk5sWUwpZoVvIiiulNLhMwgHDhDED2MEH8X3zCDL4HV/R8lRTOEWYS0KWzt8GEm/mNLihpHKOeqJY6yLqDnbO42F1r9eXCzitMOfkuqfvkXTId6h1phSi5/ncbgneAtnDCAxTAzIn+POhfDFOObzAEsNLu0HXO06a4BCwd89wEk1h2ezdwl0rObvS5nNreHurg/lxKwsNPoHjXrHVhI+lMK3xjvMH4YelYzCSzc8V3zrx9CWtu5MG67eWEdhBSmI+GT7eIZt+Nny7YJ+y8ON9/cF1tWVL7LzTdTi6sSMtw9AE432wwl7u6MzqotMNwcM7Glc/TafRyB4+aa4dhdcoV993EDlptphlt3zZ72TgM8N88MDe3vDQWE5V6tWGaKyAbwqaiA5+aZQeETkk6QFtxuvhlaOkVwwxfgdq/IvHKbocBj6ac5OzYCIASBKGo10n+HBgakMswbaYDgTmX3fzgafhD4G+Hhg1cGXnT4PMFHVayCdVcBXGBu7cKwACOOC2YwTsIQ7KI7LBywJrlyByupK9Kw/lto4VFLAqLdmRwJiBDWwjDOI0QPPhPXRn3yTlyrILND4w7oOw3h5AlTPk5U/ddrZSk4RWW+C9hp2rgru6GiP/678n2UFPV1AAAAAElFTkSuQmCC"};popup.parseTree=function(t){this.img=void 0,this.content=void 0,this.title=void 0,this.button=[],this.image_button=void 0,this.buttonStyle={},this.view={},this.parseView(t.template),this.properties={maskCloseEnabled:t.properties.maskCloseEnabled,maskActionId:t.properties.maskActionId,maskColor:_.getRgba(t.properties.maskColor),maskAction:t.properties.maskAction},popup.popupTree.properties=this.properties},popup.parseTree.prototype={parseView:function(t){switch(t.type){case"column":case"row":this.getViewProp(t);break;case"image":this.getImg(t);break;case"label":this.getLabel(t);break;case"button":this.getButton(t);break;case"link":this.getLink(t);break;case"image_button":this.getImgButton(t)}this.img&&!_.isEmptyObject(this.img)&&(popup.popupTree.img=this.img),this.title&&!_.isEmptyObject(this.title)&&(popup.popupTree.title=this.title,popup.popupTree.diverseModule=!0),this.content&&!_.isEmptyObject(this.content)&&(popup.popupTree.content=this.content,popup.popupTree.diverseModule=!0),this.image_button&&!_.isEmptyObject(this.image_button)&&(popup.popupTree.image_button=this.image_button),this.buttonStyle&&!_.isEmptyObject(this.buttonStyle)&&(popup.popupTree.buttonStyle=this.buttonStyle),this.boxStyle&&!_.isEmptyObject(this.boxStyle)&&(popup.popupTree.boxStyle=this.boxStyle),this.container&&!_.isEmptyObject(this.container)&&(popup.popupTree.container=this.container),this.button&&!_.isEmptyObject(this.button)&&this.button.length>0&&(popup.popupTree.button=this.button,popup.popupTree.diverseModule=!0),this.view&&!_.isEmptyObject(this.view)&&(popup.popupTree.view=this.view),t.GRADE||(t.GRADE=0,this.view.container=Object.assign({},this.getViewProp(t))),t.subviews&&t.subviews.length>0&&_.each(t.subviews,function(e){e.GRADE=t.GRADE+1,this.parseView(e)},this)},getViewProp:function(t){switch(t.GRADE){case 0:return{style:"width: "+_.getRpx(t.layout.width)+";"};case 1:if(t.subviews.length>0){var e=Object.assign({},{backgroundImage:t.properties.backgroundImage?t.properties.backgroundImage:"",style:this.getStyle(t)}),p='background: url("'+e.backgroundImage+'");background-size: 100% 100%;'+e.style;this.view.content=Object.assign({},{style:p})}break;case 2:t.subviews&&t.subviews.length>0?this.view.button=Object.assign({},{type:t.type}):this.view.padding=Object.assign({},{style:"margin-top: "+_.getRpx(t.layout.margin.top)+";",type:t.type})}},isButtonBranch:function(t){var e=!0,p={image_button:1,link:1,button:1};return _.each(t,function(t,n){p[n]||(e=!1)}),e},getImg:function(t){this.img=_.extend({},this.getAttr(t.properties),this.getAction(t.action)),this.img.style=this.getStyle(t)},getImgButton:function(t){var e={};"close"===t.properties.msgType?t.properties.isHidden||(this.image_button=_.extend({},this.getAction(t.action),this.getAttr(t.properties)),t.layout.align&&(this.image_button.aligin=t.layout.align),this.image_button.style=this.getStyle(t),this.image_button.type=t.type):((e=_.extend({},this.getAction(t.action),this.getAttr(t.properties))).style=this.getStyle(t),e.type=t.type),_.isEmptyObject(e)||this.button.push(e)},getLabel:function(t){"title"===t.properties.msgType?(this.title=_.extend({},this.getAttr(t.properties)),this.title.style=this.getStyle(t)):"content"===t.properties.msgType&&(this.content=_.extend({},this.getAttr(t.properties)),this.content.style=this.getStyle(t))},getButton:function(t){var e={};(e=_.extend({},this.getAction(t.action),this.getAttr(t.properties))).style=this.getStyle(t),e.type=t.type,_.isEmptyObject(e)||this.button.push(e)},getLink:function(t){var e={};(e=_.extend({},this.getAction(t.action),this.getAttr(t.properties))).style=this.getStyle(t),e.type=t.type,_.isEmptyObject(e)||this.button.push(e)},getAttr:function(t){var e={};return t.text?e.innerText=t.text:t.image&&(t.localImageName?(e.src=IMAGE_MAP[t.localImageName],e.useLocalImage=!0):e.src=t.image),e},getAction:function(t){var e={};return t&&t.MINIPROGRAM&&(t=t.MINIPROGRAM[0],e.id=t.id,e.closeable=t.closeable,e.action_type=t.type,e.$sf_close_type=t.$sf_close_type,t.value&&(e.value=t.value),t.path&&(e.path=t.path),t.appid&&(e.appid=t.appid)),e},getStyle:function(t){var e,p={textAlign:"text-align",font:"font-size",backgroundColor:"background-color",borderWidth:function(t){return"border-width: "+t+";border-style: solid;"},borderColor:"border-color",cornerRadius:"border-radius",backgroundImage:function(t){return""},margin:this.boxModel("margin"),padding:this.boxModel("padding"),maxHeight:"max-height",maxWidth:"max-width"},n=["msgType","text","image","name","isHidden","align","localImageName"],o="";return e=_.extend({},t.layout,t.properties),_.each(e,function(t,e){t=_.getRpx(t);var i=p[e];if(n.indexOf(e)>=0)return!1;_.isString(i)?o+=i+":"+_.getRgba(t)+";":_.isFunction(i)?o+=i(t)+";":o+=e+":"+_.getRgba(t)+";"}),o},boxModel:function(t){return function(e){if("object"!=typeof e)return e;var p="";for(var n in e)p+=t+"-"+n+":"+_.getRpx(e[n]);return p}}};var QRCode={1011:1,1012:1,1013:1,1017:1,1047:1,1048:1,1049:1};popup.testSend={getPopupId:function(t){var e=0,p=t.query.scene;if(p){var n=decodeURIComponent(p).split("=");e="sf_test_id"===n[0]&&n[1]?n[1]:0}return e},start:function(t){if(!QRCode[t.scene])return!1;var e=this.getPopupId(t);if(!e)return!1;var p=popup.info.project,n=popup.info.platform,o=popup.sa.store.getDistinctId();_.wxrequest({url:popup.info.api_base_url+"/sfo/popup_windows/"+e+"?distinct_id="+encodeURIComponent(o)+"&app_id="+encodeURIComponent(popup.info.app_id)+"&project="+encodeURIComponent(p)+"&platform="+encodeURIComponent(n)+"&sdk_version="+encodeURIComponent(popup.lib_version)+"&time="+(new Date).getTime(),type:"GET",success:function(t){var e,p=t.data,n={content:p.content,type:p.popup_type,name:p.name||""},o=!0,i=_.getUuid()();try{e=JSON.parse(p.content)}catch(t){o=!1}var r={props:{$sf_succeed:!0},plan:{}};if(r.uuid=i,popup.popupTree={},"CUSTOMIZED"===p.popup_type)r.popupTree={},popup.CAMPAIGN_ERROR.onStart?(r.props={$sf_fail_reason:"onStart \u65b9\u6cd5\u672a\u5b9a\u4e49",$sf_succeed:!1},popup.track.popupDisplay(r),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(n,"1004","onStart \u65b9\u6cd5\u672a\u5b9a\u4e49")):p.content?(popup.campaign_listener.onStart(n),popup.track.popupDisplay(r)):(r.props={$sf_fail_reason:"\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e",$sf_succeed:!1},popup.track.popupDisplay(r),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(n,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e"));else{try{new popup.parseTree(e),r.popupTree=popup.popupTree,r.plan={popup_window_content:p}}catch(t){popup.log("--\u6d4b\u8bd5\u5f39\u7a97-\u89e3\u6790\u9519\u8bef",t),o=!1}o?(popup.track.popupDisplay(r),popup.CAMPAIGN_ERROR.onStart||popup.campaign_listener.onStart(n),popup.popupEmitter.notify(r)):(r.props={$sf_fail_reason:"\u5f39\u7a97\u5185\u5bb9\u5f02\u5e38",$sf_succeed:!1},popup.track.popupDisplay(r),popup.info.popup_listener.onLoadFailed(void 0,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e"),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(n,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e"))}}})}},popup.track={getPublicProps:function(){return{$sf_lib_version:popup.lib_version,$sf_plan_type:"\u8fd0\u8425\u8ba1\u5212",$sf_channel_service_name:"SENSORS_FOCUS",$sf_channel_category:"POPUP",$sf_platform_tag:popup.info.platform}},removeEmpty:function(t){_.each(t,function(e,p){""!==e&&void 0!==e||delete t[p]})},popupDisplay:function(t){var e=popup.track.getPublicProps(),p=popup.track.getPlanProps(t);_.extend(e,t.props,p),this.removeEmpty(e),popup.sa.track("$PlanPopupDisplay",e)},popupClick:function(t){var e=popup.track.getPublicProps(),p=popup.track.getPlanProps(t),n={type:t.props.$sf_msg_element_action,value:t.props.action_value||"",extra:t.props.action_value||""};try{if(popup.info.popup_listener.onClick(t.plan.plan_id,n),!popup.CAMPAIGN_ERROR.onClick){var o={name:t.plan.cname,plan_id:t.plan.plan_id,content:t.plan.popup_window_content?t.plan.popup_window_content.content:"",type:t.plan.popup_window_content?t.plan.popup_window_content.popup_type:"",action:n};popup.campaign_listener.onClick(o)}}catch(t){popup.log("popup_listener.onClick error",t)}delete t.props.action_value,_.extend(e,t.props,p),e.$sf_plan_id||delete e.$sf_plan_id,this.removeEmpty(e),popup.sa.track("$PlanPopupClick",e)},getPlanProps(t){var e={};if(!_.isObject(t))return e;var p=t.popupTree;if(e.$sf_msg_id=t.uuid,e.$sf_msg_title=p.title?p.title.innerText:"",e.$sf_msg_content=p.content?p.content.innerText:"",e.$sf_msg_image_url=p.img?p.img.src:"",e.$sf_plan_id=t.plan&&t.plan.plan_id||"",e.$sf_audience_id=t.plan&&t.plan.audience_id||"",t.plan.strategy_id?e.$sf_plan_strategy_id=t.plan.strategy_id:_.isBoolean(t.plan.is_control_group)&&(t.plan.is_control_group?e.$sf_plan_strategy_id=-1:e.$sf_plan_strategy_id=0),_.isObject(t.plan)){var n=t.plan.section_id;n&&(e.$sf_section_id=String(n),e.$sf_plan_type="\u65b0\u8d44\u6e90\u4f4d")}return e}},module.exports=popup; \ No newline at end of file diff --git a/dist/wechat/plugin/sf-sdk-miniprogram/popup.esm.min.js b/dist/wechat/plugin/sf-sdk-miniprogram/popup.esm.min.js index bea44f5..9b17dd1 100644 --- a/dist/wechat/plugin/sf-sdk-miniprogram/popup.esm.min.js +++ b/dist/wechat/plugin/sf-sdk-miniprogram/popup.esm.min.js @@ -1 +1 @@ -var popup={plugin_name:"PopupWechat",plugin_version:"1.19.11",sa:{},info:{app_id:"",show_log:!0},campaign_listener:{},lib_version:"1.19.11",defaultPara:{platform:"MINIPROGRAM",preload_image:!0,defer_render:!1},serverData:{},localData:{},event_list:[],popuping:!1,convertPlans:[],eventRule:{},popupTree:{},log:function(){if(popup.info.show_log&&"object"==typeof console&&console.log)try{return console.log.apply(console,arguments)}catch(t){console.log(arguments[0])}},CAMPAIGN_ERROR:{}},getRandomBasic=function(){var t=(new Date).getTime();return function(e){return Math.ceil((t=(9301*t+49297)%233280)/233280*e)}}(),_={getRgba:function(t){return"object"!=typeof t?t:"rgba("+t.r+","+t.g+","+t.b+","+t.a+")"},getRpx:function(t){if(t){if(/^[0|1]?\.\d+$/.test(t))return 100*Number(t)+"%";var e=/^(-?\d+(\.\d+)?)px$/.exec(t);return e?2*Number(e[1])+"rpx":t}},extend:function(t){var e=Array.prototype.slice;return _.each(e.call(arguments,1),function(e){for(var p in e)void 0!==e[p]&&(t[p]=e[p])}),t},each:function(t,e,p){var n=Array.prototype.forEach,o={};if(null==t)return!1;if(n&&t.forEach===n)t.forEach(e,p);else if(t.length===+t.length){for(var i=0,r=t.length;i0&&(r[n[0]]||(r[n[0]]=1));return _.each(r,function(t,e){u.push(e)}),u},_.getConvertNumberValue=function(t){return _.isString(t)&&(t=Number(t)),Math.floor(1e3*t)/1e3},_.wxrequest=function(t){var e=wx.request(t);setTimeout(function(){_.isObject(e)&&_.isFunction(e.abort)&&e.abort()},3e4)},_.getProject=function(t){if(t&&t.split("?")[1]){var e=decodeURIComponent(t.split("?")[1]);return _.getURLSearchParams(e).project||"default"}return"default"},_.getCurrentPage=function(){var t=getCurrentPages(),e=t[t.length-1];return!!_.isObject(e)&&e},_.getPropertiesValue=function(t,e){var p=t[e];return"$event_duration"===e&&void 0===p&&(p=t.event_duration),p},popup._=_,popup.handleEvents=function(t,e){if("send"===t){if(popup.popuping)return popup.event_list.push(e),!1;e.event&&popup.eventRule[e.event]&&popup.eventTriggerProcess(popup.eventRule[e.event],e)}if("changeDistinctId"===t&&popup.updateAndListenPlan.changeId(),"popup_display"===t){popup.popuping=!0;try{popup.info.popup_listener.onLoadSuccess(e.plan.plan_id)}catch(t){popup.log("popup_listener.onLoad error",t)}}if("popup_load_fail"===t){var p=e.plan_id,n=e.fail_code,o=e.fail_reason;try{popup.info.popup_listener.onLoadFailed(p,n,o)}catch(t){popup.log("popup_listener.onLoad error",t)}}if("popup_click"===t&&popup.track.popupClick(e),"popup_end"===t){popup.popuping=!1;var i={name:e.plan.cname,plan_id:e.plan.plan_id,content:e.plan.popup_window_content?e.plan.popup_window_content.content:"",type:e.plan.popup_window_content?e.plan.popup_window_content.popup_type:""};popup.CAMPAIGN_ERROR.onEnd||popup.campaign_listener.onEnd(i);try{popup.info.popup_listener.onClose(e.plan.plan_id)}catch(t){popup.log("popup_listener.onLoad error",t)}popup.updateGlobalCount(),popup.updatePlanInterval(e.plan),_.each(popup.event_list,function(t){t.event&&popup.eventRule[t.event]&&popup.eventTriggerProcess(popup.eventRule[t.event],t)}),popup.event_list=[]}},popup.setPara=function(t){if(_.isObject(t)||(t={}),popup.info=_.extend(popup.info,popup.defaultPara,t),popup.info.app_id||popup.log("\u521d\u59cb\u5316\u53c2\u6570 appid \u6821\u9a8c\u5931\u8d25\uff0c\u65e0\u6cd5\u62c9\u53d6\u5f39\u7a97\u8ba1\u5212!"),_.isString(popup.info.api_base_url)&&"http"===popup.info.api_base_url.slice(0,4)||popup.log("popup \u5fc5\u987b\u586b\u5199\u6709\u6548 api_base_url"),popup.info.project||(popup.info.project=_.getProject(popup.sa.para.server_url)),_.isObject(popup.info.popup_listener)){var e=popup.info.popup_listener;_.isFunction(e.onClick)||(popup.info.popup_listener.onClick=function(){}),_.isFunction(e.onLoadSuccess)||(popup.info.popup_listener.onLoadSuccess=function(){}),_.isFunction(e.onLoadFailed)||(popup.info.popup_listener.onLoadFailed=function(){}),_.isFunction(e.onClose)||(popup.info.popup_listener.onClose=function(){})}else popup.info.popup_listener={onClick:function(){},onLoadSuccess:function(){},onLoadFailed:function(){},onClose:function(){}};_.isObject(t.campaign_listener)?(popup.campaign_listener=_.extend({},t.campaign_listener),popup.campaign_listener.shouldStart&&_.isFunction(popup.campaign_listener.shouldStart)||(popup.campaign_listener.shouldStart=function(){return!0},popup.CAMPAIGN_ERROR.shouldStart={error_code:"4001",reeor_txt:"NOT_DEFINED OR DEFINED_ERROR"}),popup.campaign_listener.onClick?_.isFunction(popup.campaign_listener.onClick)||(popup.CAMPAIGN_ERROR.onClick={error_code:"4002",reeor_txt:"DEFINED_TYPE_ERROR"}):popup.CAMPAIGN_ERROR.onClick={error_code:"4001",reeor_txt:"NOT_DEFINED"},popup.campaign_listener.onStart?_.isFunction(popup.campaign_listener.onStart)||(popup.CAMPAIGN_ERROR.onStart={error_code:"4002",reeor_txt:"DEFINED_TYPE_ERROR"}):popup.CAMPAIGN_ERROR.onStart={error_code:"4001",reeor_txt:"NOT_DEFINED"},popup.campaign_listener.onEnd?_.isFunction(popup.campaign_listener.onEnd)||(popup.CAMPAIGN_ERROR.onEnd={error_code:"4002",reeor_txt:"DEFINED_TYPE_ERROR"}):popup.CAMPAIGN_ERROR.onEnd={error_code:"4001",reeor_txt:"NOT_DEFINED"},popup.campaign_listener.onFailed?_.isFunction(popup.campaign_listener.onFailed)||(popup.CAMPAIGN_ERROR.onFailed={error_code:"4002",reeor_txt:"DEFINED_TYPE_ERROR"}):popup.CAMPAIGN_ERROR.onFailed={error_code:"4001",reeor_txt:"NOT_DEFINED"}):(popup.campaign_listener.shouldStart=function(){return!0},popup.CAMPAIGN_ERROR.shouldStart={error_code:"4001",reeor_txt:"NOT_DEFINED"},popup.CAMPAIGN_ERROR.onClick={error_code:"4001",reeor_txt:"NOT_DEFINED"},popup.CAMPAIGN_ERROR.onStart={error_code:"4001",reeor_txt:"NOT_DEFINED"},popup.CAMPAIGN_ERROR.onEnd={error_code:"4001",reeor_txt:"NOT_DEFINED"},popup.CAMPAIGN_ERROR.onFailed={error_code:"4001",reeor_txt:"NOT_DEFINED"},popup.CAMPAIGN_ERROR.campaign_listener={error_code:"4003",errot_txt:"CAMPAIGN_CUSTOMIZED_NULL_LISTENER OR DEFINED ERROR"})},popup.dataRender={that:null,queue:[],notify:function(t){_.isFunction(this.handle)?this.handle(this.that,t):this.queue.push(t)}},popup.popupEmitter={image_list:[],loaded:!1,notify:function(t){var e=_.getCurrentPage(),p=this;e&&_.isObject(e)&&_.isFunction(e.selectComponent)&&(popup.info.defer_render?setTimeout(function(){p.renderPopup(e,t)},0):p.renderPopup(e,t))},renderPopup:function(t,e){var p=t.selectComponent("#sensors_popup");if(_.isObject(p)&&_.isFunction(p.handle))p.handle(e);else{var n="";try{var o=_.getCurrentPage();n=o?o.route:""}catch(t){}popup.log("\u5f53\u524d\u9875\u9762 "+n+" \u672a\u96c6\u6210\u5f39\u7a97\u7ec4\u4ef6")}},loadImage:function(t){if(JSON.stringify(t)!==JSON.stringify(this.image_list)&&(this.loaded=!1,this.image_list=t),!this.loaded){var e=_.getCurrentPage();if(e&&_.isObject(e)&&_.isFunction(e.selectComponent)){var p=e.selectComponent("#sensors_popup");_.isObject(p)&&_.isFunction(p.loadImage)&&(p.loadImage(t),this.loaded=!0)}}},attached:function(){this.loaded||this.loadImage(this.image_list)}},popup.testPopup=function(){wx.onAppShow(function(t){popup.updateAndListenPlan.pullPlan(),popup.testSend.start(t)})},popup.updateGlobalCount=function(){var t=popup.sa.store.getDistinctId(),e=popup.localData.user_list[t],p=(new Date).getTime();if(!_.isArray(popup.localData.plan_list[e].global_popup_count))return popup.localData.plan_list[e].global_popup_count=[],popup.localData.plan_list[e].global_popup_count.unshift(p),!1;popup.localData.plan_list[e].global_popup_count.shift(),popup.localData.plan_list[e].global_popup_count.unshift(p)},popup.updatePlanInterval=function(t){var e=(new Date).getTime();_.isObject(t)&&_.isObject(t.popup_interval)&&t.popup_interval.value&&(t.is_in_popup_interval_window=popup.ruleTime.getExpire(t.popup_interval,e))},popup.init=function(t,e){popup.log("\u5f39\u7a97\u5f00\u59cb\u521d\u59cb\u5316\uff01"),this.sa=t,this.setPara(e),this.sub=new t.eventSub(this.handleEvents),popup.updateAndListenPlan.initial(),popup.testPopup(),t.popupEmitter=popup.popupEmitter},popup.changeCovertStatus=function(t){var e=JSON.parse(JSON.stringify(popup.convertPlans));_.each(e,function(p,n){var o=p.is_in_convert_window.step,i=p.is_in_convert_window.uuid;if(popup.convertPlans[n].is_in_convert_window.step=Math.min(2*o,6e5),!t||!_.isArray(t)||0===t.length)return!1;_.each(t,function(t){t.popup_display_uuid===i&&t.convert_time&&(delete popup.convertPlans[n].is_in_convert_window,popup.convertPlans.splice(n,1),e.splice(n,1),n--)})}),popup.updateAndListenPlan.updateData()},popup.asyncConvert=function(t){var e=popup.info.project,p=!1;if(!t&&0===popup.convertPlans.length)return!1;t&&(_.each(popup.convertPlans,function(e){e.plan_id===t.plan_id&&(p=!0)}),p||popup.convertPlans.push(t)),function t(){if(_.isEmptyObject(popup.localData)||!_.isArray(popup.convertPlans)||0===popup.convertPlans.length)return!1;var p=popup.convertPlans,n=p[0].is_in_convert_window&&p[0].is_in_convert_window.step||5e3,o=[],i=Date.now();_.each(p,function(t){var e=t.is_in_convert_window;if(!e)return!1;e.step||(e.step=5e3),n>e.step&&(n=e.step)}),_.each(p,function(t){if(!t.is_in_convert_window)return!1;var e=t.is_in_convert_window.expire_time;if(i>e||n>e-i)return delete t.is_in_convert_window,!1;o.push(t.is_in_convert_window.uuid)});var r=_.filter(p,function(t){return!!t.is_in_convert_window&&i11?(r.setFullYear(r.getFullYear()+parseInt(t/12)),r.setMonth(t%12)):r.setMonth(t),r.setDate(1),r.setHours(0),r.setMinutes(0),r.setSeconds(0),r.setMilliseconds(0),r.getTime()},second:function(t){var e={month:2592e6,week:6048e5,day:864e5,hour:36e5,minute:6e4,second:1e3},o=null;return r=new Date(p),t in e&&(o=e[t]*n),r.getTime()+o}};return!0!==t.natural?a.second(i):i in a?a[i]():void 0},getLast:function(t,e){var p=Number(t.value)||0,n=Number(t.value)-1||0,o=String(t.unit).toLowerCase(),i=null,r={day:function(){return(i=new Date(e)).setHours(0),i.setMinutes(0),i.setSeconds(0),i.setMilliseconds(0),i=i.getTime()-864e5*n},week:function(){var t=(i=new Date(e)).getDay();return 0===t&&(t=7),--t,i.setHours(0),i.setMinutes(0),i.setSeconds(0),i.setMilliseconds(0),i=i.getTime()-(24*t*60*60*1e3+7*n*24*60*60*1e3)},month:function(){var t=(i=new Date(e)).getMonth()+1-n;return t<=0?(i.setFullYear(i.getFullYear()+(parseInt(t/12)-1)),i.setMonth(12+t%12-1)):i.setMonth(t-1),i.setDate(1),i.setHours(0),i.setMinutes(0),i.setSeconds(0),i.setMilliseconds(0),i.getTime()},second:function(t){var n={month:2592e6,week:6048e5,day:864e5,hour:36e5,minute:6e4,second:1e3},o=null;return i=new Date(e),t in n&&(o=n[t]*p),i.getTime()-o}};return!0!==t.natural?r.second(o):o in r?r[o]():void 0},getArrMatchCount:function(t,e){var p=0;for(p=0;p=t[p])return p;return t.length},checkRule:function(t,e){var p=new Date,n=e,o=Number(t.value)||0,i=Number(t.value)-1||0,r=String(t.unit).toLowerCase(),a=null,u={day:function(){return(a=new Date(n)).setHours(23),a.setMinutes(59),a.setSeconds(59),a.setMilliseconds(999),a=a.getTime()+864e5*i,p>a},week:function(){var t=(a=new Date(n)).getDay();0===t&&(t=7);var e=7-t;return a.setHours(23),a.setMinutes(59),a.setSeconds(59),a.setMilliseconds(999),a=a.getTime()+24*e*60*60*1e3+7*i*24*60*60*1e3,p>a},month:function(){var t=(a=new Date(n)).getMonth()+i;return t>=11?(a.setFullYear(a.getFullYear()+t/11),a.setMonth(t%11)):a.setMonth(t),a.setDate(1),a.setHours(0),a.setMinutes(0),a.setSeconds(0),a.setMilliseconds(0),p>a},second:function(t){return a=new Date(n),t in inteval&&(interval_time={month:2592e6,week:6048e5,day:864e5,hour:36e5,minute:6e4,second:1e3}[t]*o),p>a+null}};return!0!==t.natural?u.second(r):r in u?u[r]():void 0}},popup.eventTriggerProcess=function(t,e){var p=!1;_.isArray(t)&&t.length>0&&_.isObject(t[0])&&(popup.log("--------------------\u89e6\u53d1\u4e8b\u4ef6\u5f00\u59cb--------------------"),_.each(t,function(t){_.isObject(t)&&void 0!==t.match_state&&delete t.match_state,new popup.RuleCheck(t,e)}),_.each(t,function(t){!0===t.match_state?!1===p?(p=!0,popup.log("\u68c0\u67e5\u5b8c\u6bd5-\u4f18\u5148\u5f39\u7a97-\u5f00\u59cb",t.plan.cname),new popup.PopupCheck(t,!0)):!0===p&&(popup.log("\u68c0\u67e5\u5b8c\u6bd5-\u975e\u4f18\u5148\u5f39\u7a97-\u4e0d\u6e32\u67d3",t.plan.cname),new popup.PopupCheck(t,!1)):popup.log("\u68c0\u67e5\u5b8c\u6bd5-\u8ba1\u5212-\u4e0d\u6ee1\u8db3",t.plan.cname)}),popup.log("--------------------\u89e6\u53d1\u4e8b\u4ef6\u7ed3\u675f--------------------"))},popup.PopupCheck=function(t,e){this.plan=t.plan,this.current_time=(new Date).getTime(),e?this.displayPopup():this.hidePopup()},popup.PopupCheck.prototype.displayPopup=function(){var t=_.getUuid()(),e={props:{$sf_succeed:!0}};popup.popupTree={},e.uuid=t,e.plan=this.plan;var p=this.plan.popup_window_content,n="",o=!0;if(p&&p.content)try{n=JSON.parse(p.content),new popup.parseTree(n)}catch(t){n=!1,o=!1}else popup.log("\u8ba1\u5212\u65e0\u7a97\u4f53\u5185\u5bb9\uff01"),o=!1;e.popupTree=popup.popupTree;var i={name:this.plan.cname,plan_id:this.plan.plan_id,content:this.plan.popup_window_content?this.plan.popup_window_content.content:"",type:this.plan.popup_window_content?this.plan.popup_window_content.popup_type:""};this.plan.hasOwnProperty("strategy_id")?this.plan.is_trigger?popup.campaign_listener.shouldStart(i)?p?"CUSTOMIZED"===p.popup_type?(e.popupTree={},popup.CAMPAIGN_ERROR.onStart?(e.props={$sf_fail_reason:"onStart \u672a\u5b9a\u4e49",$sf_succeed:!1},popup.track.popupDisplay(e),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,1004,"onStart \u672a\u5b9a\u4e49")):p.content?(popup.track.popupDisplay(e),popup.campaign_listener.onStart(i),popup.info.popup_listener.onLoadSuccess(this.plan.plan_id)):(e.props={$sf_fail_reason:"\u5f39\u7a97\u5185\u5bb9\u9519\u8bef",$sf_succeed:!1},popup.track.popupDisplay(e),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,1001,"\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e"))):o?(popup.track.popupDisplay(e),popup.CAMPAIGN_ERROR.onStart||popup.campaign_listener.onStart(i),this.renderPopup(e)):(e.props={$sf_fail_reason:"\u5f39\u7a97\u5185\u5bb9\u9519\u8bef",$sf_succeed:!1},popup.track.popupDisplay(e),popup.info.popup_listener.onLoadFailed(this.plan.plan_id,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e"),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e")):(e.props={$sf_fail_reason:"\u5f39\u7a97\u5185\u5bb9\u9519\u8bef",$sf_succeed:!1},popup.track.popupDisplay(e),popup.info.popup_listener.onLoadFailed(this.plan.plan_id,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e"),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e")):(e.props={$sf_fail_reason:"shouldStart \u63a5\u53e3\u8fd4\u56de false",$sf_succeed:!1},popup.track.popupDisplay(e),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,"1004","shouldStart \u63a5\u53e3\u8fd4\u56de false")):(e.props={$sf_fail_reason:"\u8ba1\u5212\u4e0b\u53d1 is_trigger \u4e3a false",$sf_succeed:!1},popup.track.popupDisplay(e),p&&"PRESET"===p.popup_type&&popup.info.popup_listener.onLoadFailed(this.plan.plan_id,"1005","\u8ba1\u5212\u4e0b\u53d1 is_trigger \u4e3a false"),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,"1005","\u8ba1\u5212\u4e0b\u53d1 is_trigger \u4e3a false")):this.plan.is_control_group?(e.props={$sf_fail_reason:"\u5bf9\u7167\u7ec4",$sf_succeed:!1},popup.track.popupDisplay(e),popup.info.popup_listener.onLoadFailed(this.plan.plan_id,"2000","\u5bf9\u7167\u7ec4"),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,"2000","\u5bf9\u7167\u7ec4")):popup.campaign_listener.shouldStart(i)?o?(popup.track.popupDisplay(e),popup.CAMPAIGN_ERROR.onStart||popup.campaign_listener.onStart(i),this.renderPopup(e)):(e.props={$sf_fail_reason:"\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e",$sf_succeed:!1},popup.track.popupDisplay(e),popup.info.popup_listener.onLoadFailed(this.plan.plan_id,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e"),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e")):(e.props={$sf_fail_reason:"shouldStart \u63a5\u53e3\u8fd4\u56de false",$sf_succeed:!1},popup.track.popupDisplay(e),popup.info.popup_listener.onLoadFailed(this.plan.plan_id,"1004","shouldStart \u63a5\u53e3\u8fd4\u56de false"),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,"1004","shouldStart \u63a5\u53e3\u8fd4\u56de false"));this.startConvertWindow(t),this.startPopupIntervalWindow(),this.startPopupLimitWindow(),this.setGlobalLimit(),this.deletePlanAllWindow(),popup.updateAndListenPlan.updateData()},popup.PopupCheck.prototype.hidePopup=function(){this.deletePlanAllWindow(),popup.updateAndListenPlan.updateData()},popup.PopupCheck.prototype.renderPopup=function(t){popup.log("\u6e32\u67d3\u5f39\u7a97"),popup.popupEmitter.notify(t)},popup.PopupCheck.prototype.startConvertWindow=function(t){popup.log("--\u5f39\u7a97\u5c55\u793a-\u8f6c\u5316\u7a97\u53e3\u8bbe\u7f6e"),_.isObject(this.plan.convert_window)&&this.plan.convert_window.value&&(this.plan.is_in_convert_window={expire_time:popup.ruleTime.getExpire(this.plan.convert_window,this.current_time),start_time:this.current_time,uuid:t},popup.asyncConvert(this.plan))},popup.PopupCheck.prototype.startPopupIntervalWindow=function(){_.isObject(this.plan.popup_interval)&&this.plan.popup_interval.value&&(this.plan.is_in_popup_interval_window=popup.ruleTime.getExpire(this.plan.popup_interval,this.current_time))},popup.PopupCheck.prototype.startPopupLimitWindow=function(){popup.log("--\u5f39\u7a97\u5c55\u793a-\u53c2\u4e0e\u9650\u5236\u7a97\u53e3\u8bbe\u7f6e\u91cd\u7f6e"),_.isObject(this.plan.re_enter)&&this.plan.re_enter.value&&(_.isObject(this.plan.is_in_popup_limit_window)?this.plan.is_in_popup_limit_window.count++:this.plan.is_in_popup_limit_window={expire_time:popup.ruleTime.getExpire(this.plan.re_enter,this.current_time),count:1})},popup.PopupCheck.prototype.setGlobalLimit=function(){popup.log("--\u5f39\u7a97\u5c55\u793a-\u5168\u5c40\u5f39\u7a97\u6b21\u6570\u8bbe\u7f6e");var t=popup.store.getCurrentUserPlanList();_.isArray(t.global_popup_count)||(t.global_popup_count=[]),t.global_popup_count.unshift(this.current_time);for(var e=t.global_popup_count,p=e[e.length-1];p+7776e63e3;)e.pop(),p=e[e.length-1]},popup.PopupCheck.prototype.deletePlanAllWindow=function(){var t=this.plan.pattern_popup.matcher_list;_.isArray(t)&&_.each(t,function(t){t.is_in_window&&(popup.log("--\u5f39\u7a97\u5c55\u793a-\u91cd\u7f6e\u5404\u4e2a\u89c4\u5219\u7684\u7a97\u53e3\u8ba1\u7b97-\u6210\u529f"),delete t.is_in_window)})},popup.RuleCheck=function(t,e){this.plan_match=t,this.plan=t.plan,this.rule_arr=t.rule,this.event_data=e,this.current_time=(new Date).getTime();var p="-------------\u68c0\u67e5-\u8ba1\u5212-("+this.plan.cname+")";_.each(this.rule_arr,function(t){p+="--\u5305\u542b\u89c4\u5219-("+t.event_name+"\uff09-\u89e6\u53d1"+t.params[0]+"\u6b21"}),popup.log(p),popup.log(this.plan),this.checkPlanIsExpire(),popup.updateAndListenPlan.updateData()},popup.RuleCheck.prototype.checkPlanIsExpire=function(){!this.plan.expire_at||_.isNumber(this.plan.expire_at)&&this.current_timethis.current_time?popup.log("--\u5b58\u5728\u8f6c\u5316\u7a97\u53e3 - \u4e0d\u6ee1\u8db3",this.plan.is_in_convert_window):(popup.log("--\u4e0d\u5b58\u5728\u8f6c\u5316\u7a97\u53e3\u6216\u8005\u7a97\u53e3\u8d85\u65f6\u5df2\u7ecf\u8fc7\u671f - \u6ee1\u8db3",this.plan.is_in_convert_window),this.checkGlobalPopupInterval())},popup.RuleCheck.prototype.checkGlobalPopupInterval=function(){var t=popup.store.getCurrentUserPlanList(),e=t.global_popup_count;if(_.isArray(e)&&e.length>=1){var p=popup.ruleTime.getLast(t.popup_interval_global,this.current_time);p>e[0]?(popup.log("--\u5168\u5c40\u5f39\u7a97\u95f4\u9694-\u6ee1\u8db3-"+p+">\u4e0a\u6b21\u5f39\u7a97\u65f6\u95f4"+e[0]),this.checkPopupInterval()):popup.log("\u68c0\u67e5-\u5168\u5c40\u5f39\u7a97\u95f4\u9694-\u4e0d\u6ee1\u8db3-"+p+"<\u4e0a\u6b21\u5f39\u7a97\u65f6\u95f4"+e[0])}else popup.log("--\u5168\u5c40\u5f39\u7a97\u95f4\u9694-\u6ca1\u6709\u5f39\u8fc7\u7a97-\u6ee1\u8db3"),this.checkPopupInterval()},popup.RuleCheck.prototype.checkPopupInterval=function(){_.isNumber(this.plan.is_in_popup_interval_window)?this.current_time>this.plan.is_in_popup_interval_window?(popup.log("--\u5f39\u7a97\u95f4\u9694-\u5f53\u524d\u65f6\u95f4\u5927\u4e8e\u56fa\u5b9a\u5f39\u7a97\u95f4\u9694-\u6ee1\u8db3"),this.plan.is_in_popup_interval_window=null,this.checkPermission()&&this.checkProperties()):popup.log("--\u5f39\u7a97\u95f4\u9694-\u5f53\u524d\u65f6\u95f4\u5c0f\u4e8e\u56fa\u5b9a\u5f39\u7a97\u95f4\u9694-\u4e0d\u6ee1\u8db3"):(popup.log("--\u5f39\u7a97\u95f4\u9694-\u7a97\u53e3\u4e0d\u5b58\u5728-\u65b0\u5f00"),this.plan.is_in_popup_interval_window=null,this.checkPermission()&&this.checkProperties())},popup.RuleCheck.prototype.isMatched=function(t){var e={equal:function(t,e){if(!_.isNumber(t)&&!_.isString(t))return!1;for(var p=0,n=e.length;p=0},notContain:function(t,e){return!!_.isString(t)&&-1===t.indexOf(e[0])},isTrue:function(t){return!0===t},isFalse:function(t){return!1===t},isSet:function(t){return void 0!==t},notSet:function(t){return void 0===t},isEmpty:function(t){if(!_.isString(t)&&!_.isArray(t))return!1;if(_.isString(t))return""===t;for(var e=0;eNumber(e[0])},between:function(t,e){return!!_.isNumber(t)&&(t>=Number(e[0])&&t<=Number(e[1]))},in:function(t,e){if(!_.isArray(t))return!1;for(var p=0;p=0)return!0;return!1},notInclude:function(t,e){if(!_.isArray(t))return!1;for(var p=0;p=p&&o<=n}catch(t){popup.log("absolute_between Error",t)}},absoluteBetween:function(t,e){try{var p=new Date(e[0]),n=new Date(e[1]),o=new Date(t);return o>=p&&o<=n}catch(t){popup.log("absolute_between Error",t)}}},p=this,n=t.relation,o="or"===String(n).toLowerCase(),i="and"===String(n).toLowerCase(),r=!!i,a=!0;return _.each(t.conditions,function(t){if(!a)return!1;if(!t.field)return!1;var n=t.field.lastIndexOf("."),u=t.params,s=t.function;if(!e[s])return r=!1,a=!1,!1;if(n<0)return!1;var l=t.field.slice(n+1),c=p.event_data.properties,d=_.getPropertiesValue(c,l),g=e[s](d,u);o&&g&&(r=!0,a=!1),i&&!g&&(r=!1,a=!1)}),r},popup.RuleCheck.prototype.checkPermission=function(){var t=this.plan.event_permission;if(!_.isObject(t)||_.isEmptyObject(t))return!0;var e=this,p=[],n=function(t){return _.filter(t,function(t){return!(t&&t.conditions&&(!t.conditions||0!==t.conditions.length))||e.isMatched(t)})};return function t(e,o){_.each(e,function(e){if(p=n([e]),_.isArray(p)&&p.length>0){var i=e[o]||[];i&&i.length>0&&t(i,o)}})}([t],"filters"),_.isArray(p)&&p.length>0?(popup.log("--\u89d2\u8272\u5c5e\u6027\u5339\u914d-\u6ee1\u8db3",p),!0):(popup.log("--\u89d2\u8272\u5c5e\u6027\u5339\u914d-\u4e0d\u6ee1\u8db3"),!1)},popup.RuleCheck.prototype.checkProperties=function(){var t=this,e=_.filter(this.rule_arr,function(e){var p=e.multi_filter?e.multi_filter:e.filter;return!(p&&(!p.conditions||0!==p.conditions.length))||t.isMatched(p)});_.isArray(e)&&e.length>0?(this.checkWindowAndMatch(e),popup.log("--\u5c5e\u6027\u5339\u914d-\u6ee1\u8db3",e)):popup.log("--\u5c5e\u6027\u5339\u914d-\u4e0d\u6ee1\u8db3")},popup.RuleCheck.prototype.checkWindowAndMatch=function(t){var e=this,p=[];_.each(t,function(t){if(!t.params||!t.params[0])return popup.log("--\u7a97\u53e3\u671f\u548c\u6b21\u6570-\u89c4\u5219\u6570\u636e\u5f02\u5e38"),!1;var n=Number(t.params[0]);1===n?p.push(t):n>1&&_.isObject(t.window)&&t.window.value>0&&(!_.isObject(t.is_in_window)||!_.isNumber(t.is_in_window.expire_time)||t.is_in_window.expire_time=n?p.push(t):popup.log("--\u7a97\u53e3\u671f\u548c\u6b21\u6570-\u89c4\u5219\u6570",t.is_in_window.count,"\u4e0d\u5339\u914d\u5f53\u524d\u6b21\u6570",n))}),p.length>0?(popup.log("--\u7a97\u53e3\u671f\u548c\u6b21\u6570-\u6709\u5339\u914d\u6210\u529f\u7684\u89c4\u5219",p),this.checkGlobalPopupLimit()):popup.log("--\u7a97\u53e3\u671f\u548c\u6b21\u6570-\u6ca1\u6709\u5339\u914d\u6210\u529f\u7684\u89c4\u5219",p)},popup.RuleCheck.prototype.checkGlobalPopupLimit=function(){var t=popup.store.getCurrentUserPlanList(),e=t.msg_limit_global,p=!0,n=this;_.isObject(e)&&!0===e.is_in_use&&_.isArray(e.limits)&&_.isArray(t.global_popup_count)&&!0===this.plan.global_msg_limit_enabled?(_.each(e.limits,function(e){if(_.isObject(e)&&_.isNumber(e.limit)){var o=popup.ruleTime.getLast(e,n.current_time),i=popup.ruleTime.getArrMatchCount(t.global_popup_count,o);popup.log("--\u5168\u5c40\u5f39\u7a97\u9650\u5236-\u5df2\u7ecf\u5f39\u7a97\u6b21\u6570-"+i+"-\u9650\u5236\u7684\u6b21\u6570"+e.limit+"-\u9650\u5236\u65f6\u95f4-"+o),p=i=2592e6&&delete popup.localData.plan_list[p]})},updateUserPlans:function(){var t=popup.serverData,e=popup.sa.store.getDistinctId();t.user_id?(popup.localData.user_list[e]=t.user_id,popup.localData.plan_list[t.user_id]||popup.localData.plan_list[e]&&(popup.localData.plan_list[t.user_id]=popup.localData.plan_list[e],delete popup.localData.plan_list[e])):popup.localData.user_list[e]||(popup.localData.user_list[e]=e)}};var IMAGE_MAP={close:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFoAAABaCAMAAAAPdrEwAAAAe1BMVEUAAAD////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////NgkbwAAAAKHRSTlMA5if6t/B0UjMSxpAtJB4MBfTr30oY6NjV0r2loZ6XkoaBenFp3UA/LNePaQAAAsxJREFUWMOsltlygzAMRRXMZsAsAZJmX9v6/7+wg1QXpjGxCDkvyWTIQZauDcCgzKLrPtnUSyGW9SbZX6OshDcQh36lH6j8MJ7pTZd6lGX6sr0IP7SDj7CA6chLoBkEFzm14nM1/P/2eGti1RZFq+LmdtwGw7afJ1Ue1dogcGCW4QptqCO2OPe1IbnL0Y7dE23wc2bJgSn44MFTvIMwLeMUXqZGfGKUkp+MPC2dwUjMGhWwUL7pnXRUsdbIIpow84VG1k9Xmf1e5U8Kq/R/68memAPqcggTCQUNc9SdL+iCL5jMd0B1j/RErh3LYrRyLa2po2x8KngJ9Uk5sWUwpZoVvIiiulNLhMwgHDhDED2MEH8X3zCDL4HV/R8lRTOEWYS0KWzt8GEm/mNLihpHKOeqJY6yLqDnbO42F1r9eXCzitMOfkuqfvkXTId6h1phSi5/ncbgneAtnDCAxTAzIn+POhfDFOObzAEsNLu0HXO06a4BCwd89wEk1h2ezdwl0rObvS5nNreHurg/lxKwsNPoHjXrHVhI+lMK3xjvMH4YelYzCSzc8V3zrx9CWtu5MG67eWEdhBSmI+GT7eIZt+Nny7YJ+y8ON9/cF1tWVL7LzTdTi6sSMtw9AE432wwl7u6MzqotMNwcM7Glc/TafRyB4+aa4dhdcoV993EDlptphlt3zZ72TgM8N88MDe3vDQWE5V6tWGaKyAbwqaiA5+aZQeETkk6QFtxuvhlaOkVwwxfgdq/IvHKbocBj6ac5OzYCIASBKGo10n+HBgakMswbaYDgTmX3fzgafhD4G+Hhg1cGXnT4PMFHVayCdVcBXGBu7cKwACOOC2YwTsIQ7KI7LBywJrlyByupK9Kw/lto4VFLAqLdmRwJiBDWwjDOI0QPPhPXRn3yTlyrILND4w7oOw3h5AlTPk5U/ddrZSk4RWW+C9hp2rgru6GiP/678n2UFPV1AAAAAElFTkSuQmCC"};popup.parseTree=function(t){this.img=void 0,this.content=void 0,this.title=void 0,this.button=[],this.image_button=void 0,this.buttonStyle={},this.view={},this.parseView(t.template),this.properties={maskCloseEnabled:t.properties.maskCloseEnabled,maskActionId:t.properties.maskActionId,maskColor:_.getRgba(t.properties.maskColor),maskAction:t.properties.maskAction},popup.popupTree.properties=this.properties},popup.parseTree.prototype={parseView:function(t){switch(t.type){case"column":case"row":this.getViewProp(t);break;case"image":this.getImg(t);break;case"label":this.getLabel(t);break;case"button":this.getButton(t);break;case"link":this.getLink(t);break;case"image_button":this.getImgButton(t)}this.img&&!_.isEmptyObject(this.img)&&(popup.popupTree.img=this.img),this.title&&!_.isEmptyObject(this.title)&&(popup.popupTree.title=this.title,popup.popupTree.diverseModule=!0),this.content&&!_.isEmptyObject(this.content)&&(popup.popupTree.content=this.content,popup.popupTree.diverseModule=!0),this.image_button&&!_.isEmptyObject(this.image_button)&&(popup.popupTree.image_button=this.image_button),this.buttonStyle&&!_.isEmptyObject(this.buttonStyle)&&(popup.popupTree.buttonStyle=this.buttonStyle),this.boxStyle&&!_.isEmptyObject(this.boxStyle)&&(popup.popupTree.boxStyle=this.boxStyle),this.container&&!_.isEmptyObject(this.container)&&(popup.popupTree.container=this.container),this.button&&!_.isEmptyObject(this.button)&&this.button.length>0&&(popup.popupTree.button=this.button,popup.popupTree.diverseModule=!0),this.view&&!_.isEmptyObject(this.view)&&(popup.popupTree.view=this.view),t.GRADE||(t.GRADE=0,this.view.container=Object.assign({},this.getViewProp(t))),t.subviews&&t.subviews.length>0&&_.each(t.subviews,function(e){e.GRADE=t.GRADE+1,this.parseView(e)},this)},getViewProp:function(t){switch(t.GRADE){case 0:return{style:"width: "+_.getRpx(t.layout.width)+";"};case 1:if(t.subviews.length>0){var e=Object.assign({},{backgroundImage:t.properties.backgroundImage?t.properties.backgroundImage:"",style:this.getStyle(t)}),p='background: url("'+e.backgroundImage+'");background-size: 100% 100%;'+e.style;this.view.content=Object.assign({},{style:p})}break;case 2:t.subviews&&t.subviews.length>0?this.view.button=Object.assign({},{type:t.type}):this.view.padding=Object.assign({},{style:"margin-top: "+_.getRpx(t.layout.margin.top)+";",type:t.type})}},isButtonBranch:function(t){var e=!0,p={image_button:1,link:1,button:1};return _.each(t,function(t,n){p[n]||(e=!1)}),e},getImg:function(t){this.img=_.extend({},this.getAttr(t.properties),this.getAction(t.action)),this.img.style=this.getStyle(t)},getImgButton:function(t){var e={};"close"===t.properties.msgType?t.properties.isHidden||(this.image_button=_.extend({},this.getAction(t.action),this.getAttr(t.properties)),t.layout.align&&(this.image_button.aligin=t.layout.align),this.image_button.style=this.getStyle(t),this.image_button.type=t.type):((e=_.extend({},this.getAction(t.action),this.getAttr(t.properties))).style=this.getStyle(t),e.type=t.type),_.isEmptyObject(e)||this.button.push(e)},getLabel:function(t){"title"===t.properties.msgType?(this.title=_.extend({},this.getAttr(t.properties)),this.title.style=this.getStyle(t)):"content"===t.properties.msgType&&(this.content=_.extend({},this.getAttr(t.properties)),this.content.style=this.getStyle(t))},getButton:function(t){var e={};(e=_.extend({},this.getAction(t.action),this.getAttr(t.properties))).style=this.getStyle(t),e.type=t.type,_.isEmptyObject(e)||this.button.push(e)},getLink:function(t){var e={};(e=_.extend({},this.getAction(t.action),this.getAttr(t.properties))).style=this.getStyle(t),e.type=t.type,_.isEmptyObject(e)||this.button.push(e)},getAttr:function(t){var e={};return t.text?e.innerText=t.text:t.image&&(t.localImageName?(e.src=IMAGE_MAP[t.localImageName],e.useLocalImage=!0):e.src=t.image),e},getAction:function(t){var e={};return t&&t.MINIPROGRAM&&(t=t.MINIPROGRAM[0],e.id=t.id,e.closeable=t.closeable,e.action_type=t.type,e.$sf_close_type=t.$sf_close_type,t.value&&(e.value=t.value),t.path&&(e.path=t.path),t.appid&&(e.appid=t.appid)),e},getStyle:function(t){var e,p={textAlign:"text-align",font:"font-size",backgroundColor:"background-color",borderWidth:function(t){return"border-width: "+t+";border-style: solid;"},borderColor:"border-color",cornerRadius:"border-radius",backgroundImage:function(t){return""},margin:this.boxModel("margin"),padding:this.boxModel("padding"),maxHeight:"max-height",maxWidth:"max-width"},n=["msgType","text","image","name","isHidden","align","localImageName"],o="";return e=_.extend({},t.layout,t.properties),_.each(e,function(t,e){t=_.getRpx(t);var i=p[e];if(n.indexOf(e)>=0)return!1;_.isString(i)?o+=i+":"+_.getRgba(t)+";":_.isFunction(i)?o+=i(t)+";":o+=e+":"+_.getRgba(t)+";"}),o},boxModel:function(t){return function(e){if("object"!=typeof e)return e;var p="";for(var n in e)p+=t+"-"+n+":"+_.getRpx(e[n]);return p}}};var QRCode={1011:1,1012:1,1013:1,1017:1,1047:1,1048:1,1049:1};popup.testSend={getPopupId:function(t){var e=0,p=t.query.scene;if(p){var n=decodeURIComponent(p).split("=");e="sf_test_id"===n[0]&&n[1]?n[1]:0}return e},start:function(t){if(!QRCode[t.scene])return!1;var e=this.getPopupId(t);if(!e)return!1;var p=popup.info.project,n=popup.info.platform,o=popup.sa.store.getDistinctId();_.wxrequest({url:popup.info.api_base_url+"/sfo/popup_windows/"+e+"?distinct_id="+encodeURIComponent(o)+"&app_id="+encodeURIComponent(popup.info.app_id)+"&project="+encodeURIComponent(p)+"&platform="+encodeURIComponent(n)+"&sdk_version="+encodeURIComponent(popup.lib_version)+"&time="+(new Date).getTime(),type:"GET",success:function(t){var e,p=t.data,n={content:p.content,type:p.popup_type,name:p.name||""},o=!0,i=_.getUuid()();try{e=JSON.parse(p.content)}catch(t){o=!1}var r={props:{$sf_succeed:!0},plan:{}};if(r.uuid=i,popup.popupTree={},"CUSTOMIZED"===p.popup_type)r.popupTree={},popup.CAMPAIGN_ERROR.onStart?(r.props={$sf_fail_reason:"onStart \u65b9\u6cd5\u672a\u5b9a\u4e49",$sf_succeed:!1},popup.track.popupDisplay(r),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(n,"1004","onStart \u65b9\u6cd5\u672a\u5b9a\u4e49")):p.content?(popup.campaign_listener.onStart(n),popup.track.popupDisplay(r)):(r.props={$sf_fail_reason:"\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e",$sf_succeed:!1},popup.track.popupDisplay(r),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(n,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e"));else{try{new popup.parseTree(e),r.popupTree=popup.popupTree,r.plan={popup_window_content:p}}catch(t){popup.log("--\u6d4b\u8bd5\u5f39\u7a97-\u89e3\u6790\u9519\u8bef",t),o=!1}o?(popup.track.popupDisplay(r),popup.CAMPAIGN_ERROR.onStart||popup.campaign_listener.onStart(n),popup.popupEmitter.notify(r)):(r.props={$sf_fail_reason:"\u5f39\u7a97\u5185\u5bb9\u5f02\u5e38",$sf_succeed:!1},popup.track.popupDisplay(r),popup.info.popup_listener.onLoadFailed(void 0,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e"),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(n,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e"))}}})}},popup.track={getPublicProps:function(){return{$sf_lib_version:popup.lib_version,$sf_plan_type:"\u8fd0\u8425\u8ba1\u5212",$sf_channel_service_name:"SENSORS_FOCUS",$sf_channel_category:"POPUP",$sf_platform_tag:popup.info.platform}},removeEmpty:function(t){_.each(t,function(e,p){""!==e&&void 0!==e||delete t[p]})},popupDisplay:function(t){var e=popup.track.getPublicProps(),p=popup.track.getPlanProps(t);_.extend(e,t.props,p),this.removeEmpty(e),popup.sa.track("$PlanPopupDisplay",e)},popupClick:function(t){var e=popup.track.getPublicProps(),p=popup.track.getPlanProps(t),n={type:t.props.$sf_msg_element_action,value:t.props.action_value||"",extra:t.props.action_value||""};try{if(popup.info.popup_listener.onClick(t.plan.plan_id,n),!popup.CAMPAIGN_ERROR.onClick){var o={name:t.plan.cname,plan_id:t.plan.plan_id,content:t.plan.popup_window_content?t.plan.popup_window_content.content:"",type:t.plan.popup_window_content?t.plan.popup_window_content.popup_type:"",action:n};popup.campaign_listener.onClick(o)}}catch(t){popup.log("popup_listener.onClick error",t)}delete t.props.action_value,_.extend(e,t.props,p),e.$sf_plan_id||delete e.$sf_plan_id,this.removeEmpty(e),popup.sa.track("$PlanPopupClick",e)},getPlanProps(t){var e={};if(!_.isObject(t))return e;var p=t.popupTree;if(e.$sf_msg_id=t.uuid,e.$sf_msg_title=p.title?p.title.innerText:"",e.$sf_msg_content=p.content?p.content.innerText:"",e.$sf_msg_image_url=p.img?p.img.src:"",e.$sf_plan_id=t.plan&&t.plan.plan_id||"",e.$sf_audience_id=t.plan&&t.plan.audience_id||"",t.plan.strategy_id?e.$sf_plan_strategy_id=t.plan.strategy_id:_.isBoolean(t.plan.is_control_group)&&(t.plan.is_control_group?e.$sf_plan_strategy_id=-1:e.$sf_plan_strategy_id=0),_.isObject(t.plan)){var n=t.plan.section_id;n&&(e.$sf_section_id=String(n),e.$sf_plan_type="\u65b0\u8d44\u6e90\u4f4d")}return e}};export default popup; \ No newline at end of file +var popup={plugin_name:"PopupWechat",plugin_version:"1.19.12",sa:{},info:{app_id:"",show_log:!0},campaign_listener:{},lib_version:"1.19.12",defaultPara:{platform:"MINIPROGRAM",preload_image:!0,defer_render:!1},serverData:{},localData:{},event_list:[],popuping:!1,convertPlans:[],eventRule:{},popupTree:{},log:function(){if(popup.info.show_log&&"object"==typeof console&&console.log)try{return console.log.apply(console,arguments)}catch(t){console.log(arguments[0])}},CAMPAIGN_ERROR:{}},getRandomBasic=function(){var t=(new Date).getTime();return function(e){return Math.ceil((t=(9301*t+49297)%233280)/233280*e)}}(),_={getRgba:function(t){return"object"!=typeof t?t:"rgba("+t.r+","+t.g+","+t.b+","+t.a+")"},getRpx:function(t){if(t){if(/^[0|1]?\.\d+$/.test(t))return 100*Number(t)+"%";var e=/^(-?\d+(\.\d+)?)px$/.exec(t);return e?2*Number(e[1])+"rpx":t}},extend:function(t){var e=Array.prototype.slice;return _.each(e.call(arguments,1),function(e){for(var p in e)void 0!==e[p]&&(t[p]=e[p])}),t},each:function(t,e,p){var n=Array.prototype.forEach,o={};if(null==t)return!1;if(n&&t.forEach===n)t.forEach(e,p);else if(t.length===+t.length){for(var i=0,r=t.length;i0&&(r[n[0]]||(r[n[0]]=1));return _.each(r,function(t,e){u.push(e)}),u},_.getConvertNumberValue=function(t){return _.isString(t)&&(t=Number(t)),Math.floor(1e3*t)/1e3},_.wxrequest=function(t){var e=wx.request(t);setTimeout(function(){_.isObject(e)&&_.isFunction(e.abort)&&e.abort()},3e4)},_.getProject=function(t){if(t&&t.split("?")[1]){var e=decodeURIComponent(t.split("?")[1]);return _.getURLSearchParams(e).project||"default"}return"default"},_.getCurrentPage=function(){var t=getCurrentPages(),e=t[t.length-1];return!!_.isObject(e)&&e},_.getPropertiesValue=function(t,e){var p=t[e];return"$event_duration"===e&&void 0===p&&(p=t.event_duration),p},popup._=_,popup.handleEvents=function(t,e){if("send"===t){if(popup.popuping)return popup.event_list.push(e),!1;e.event&&popup.eventRule[e.event]&&popup.eventTriggerProcess(popup.eventRule[e.event],e)}if("changeDistinctId"===t&&popup.updateAndListenPlan.changeId(),"popup_display"===t){popup.popuping=!0;try{popup.info.popup_listener.onLoadSuccess(e.plan.plan_id)}catch(t){popup.log("popup_listener.onLoad error",t)}}if("popup_load_fail"===t){var p=e.plan_id,n=e.fail_code,o=e.fail_reason;try{popup.info.popup_listener.onLoadFailed(p,n,o)}catch(t){popup.log("popup_listener.onLoad error",t)}}if("popup_click"===t&&popup.track.popupClick(e),"popup_end"===t){popup.popuping=!1;var i={name:e.plan.cname,plan_id:e.plan.plan_id,content:e.plan.popup_window_content?e.plan.popup_window_content.content:"",type:e.plan.popup_window_content?e.plan.popup_window_content.popup_type:""};popup.CAMPAIGN_ERROR.onEnd||popup.campaign_listener.onEnd(i);try{popup.info.popup_listener.onClose(e.plan.plan_id)}catch(t){popup.log("popup_listener.onLoad error",t)}popup.updateGlobalCount(),popup.updatePlanInterval(e.plan),_.each(popup.event_list,function(t){t.event&&popup.eventRule[t.event]&&popup.eventTriggerProcess(popup.eventRule[t.event],t)}),popup.event_list=[]}},popup.setPara=function(t){if(_.isObject(t)||(t={}),popup.info=_.extend(popup.info,popup.defaultPara,t),popup.info.app_id||popup.log("\u521d\u59cb\u5316\u53c2\u6570 appid \u6821\u9a8c\u5931\u8d25\uff0c\u65e0\u6cd5\u62c9\u53d6\u5f39\u7a97\u8ba1\u5212!"),_.isString(popup.info.api_base_url)&&"http"===popup.info.api_base_url.slice(0,4)||popup.log("popup \u5fc5\u987b\u586b\u5199\u6709\u6548 api_base_url"),popup.info.project||(popup.info.project=_.getProject(popup.sa.para.server_url)),_.isObject(popup.info.popup_listener)){var e=popup.info.popup_listener;_.isFunction(e.onClick)||(popup.info.popup_listener.onClick=function(){}),_.isFunction(e.onLoadSuccess)||(popup.info.popup_listener.onLoadSuccess=function(){}),_.isFunction(e.onLoadFailed)||(popup.info.popup_listener.onLoadFailed=function(){}),_.isFunction(e.onClose)||(popup.info.popup_listener.onClose=function(){})}else popup.info.popup_listener={onClick:function(){},onLoadSuccess:function(){},onLoadFailed:function(){},onClose:function(){}};_.isObject(t.campaign_listener)?(popup.campaign_listener=_.extend({},t.campaign_listener),popup.campaign_listener.shouldStart&&_.isFunction(popup.campaign_listener.shouldStart)||(popup.campaign_listener.shouldStart=function(){return!0},popup.CAMPAIGN_ERROR.shouldStart={error_code:"4001",reeor_txt:"NOT_DEFINED OR DEFINED_ERROR"}),popup.campaign_listener.onClick?_.isFunction(popup.campaign_listener.onClick)||(popup.CAMPAIGN_ERROR.onClick={error_code:"4002",reeor_txt:"DEFINED_TYPE_ERROR"}):popup.CAMPAIGN_ERROR.onClick={error_code:"4001",reeor_txt:"NOT_DEFINED"},popup.campaign_listener.onStart?_.isFunction(popup.campaign_listener.onStart)||(popup.CAMPAIGN_ERROR.onStart={error_code:"4002",reeor_txt:"DEFINED_TYPE_ERROR"}):popup.CAMPAIGN_ERROR.onStart={error_code:"4001",reeor_txt:"NOT_DEFINED"},popup.campaign_listener.onEnd?_.isFunction(popup.campaign_listener.onEnd)||(popup.CAMPAIGN_ERROR.onEnd={error_code:"4002",reeor_txt:"DEFINED_TYPE_ERROR"}):popup.CAMPAIGN_ERROR.onEnd={error_code:"4001",reeor_txt:"NOT_DEFINED"},popup.campaign_listener.onFailed?_.isFunction(popup.campaign_listener.onFailed)||(popup.CAMPAIGN_ERROR.onFailed={error_code:"4002",reeor_txt:"DEFINED_TYPE_ERROR"}):popup.CAMPAIGN_ERROR.onFailed={error_code:"4001",reeor_txt:"NOT_DEFINED"}):(popup.campaign_listener.shouldStart=function(){return!0},popup.CAMPAIGN_ERROR.shouldStart={error_code:"4001",reeor_txt:"NOT_DEFINED"},popup.CAMPAIGN_ERROR.onClick={error_code:"4001",reeor_txt:"NOT_DEFINED"},popup.CAMPAIGN_ERROR.onStart={error_code:"4001",reeor_txt:"NOT_DEFINED"},popup.CAMPAIGN_ERROR.onEnd={error_code:"4001",reeor_txt:"NOT_DEFINED"},popup.CAMPAIGN_ERROR.onFailed={error_code:"4001",reeor_txt:"NOT_DEFINED"},popup.CAMPAIGN_ERROR.campaign_listener={error_code:"4003",errot_txt:"CAMPAIGN_CUSTOMIZED_NULL_LISTENER OR DEFINED ERROR"})},popup.dataRender={that:null,queue:[],notify:function(t){_.isFunction(this.handle)?this.handle(this.that,t):this.queue.push(t)}},popup.popupEmitter={image_list:[],loaded:!1,notify:function(t){var e=_.getCurrentPage(),p=this;e&&_.isObject(e)&&_.isFunction(e.selectComponent)&&(popup.info.defer_render?setTimeout(function(){p.renderPopup(e,t)},0):p.renderPopup(e,t))},renderPopup:function(t,e){var p=t.selectComponent("#sensors_popup");if(_.isObject(p)&&_.isFunction(p.handle))p.handle(e);else{var n="";try{var o=_.getCurrentPage();n=o?o.route:""}catch(t){}popup.log("\u5f53\u524d\u9875\u9762 "+n+" \u672a\u96c6\u6210\u5f39\u7a97\u7ec4\u4ef6")}},loadImage:function(t){if(JSON.stringify(t)!==JSON.stringify(this.image_list)&&(this.loaded=!1,this.image_list=t),!this.loaded){var e=_.getCurrentPage();if(e&&_.isObject(e)&&_.isFunction(e.selectComponent)){var p=e.selectComponent("#sensors_popup");_.isObject(p)&&_.isFunction(p.loadImage)&&(p.loadImage(t),this.loaded=!0)}}},attached:function(){this.loaded||this.loadImage(this.image_list)}},popup.testPopup=function(){wx.onAppShow(function(t){popup.updateAndListenPlan.pullPlan(),popup.testSend.start(t)})},popup.updateGlobalCount=function(){var t=popup.sa.store.getDistinctId(),e=popup.localData.user_list[t],p=(new Date).getTime();if(!_.isArray(popup.localData.plan_list[e].global_popup_count))return popup.localData.plan_list[e].global_popup_count=[],popup.localData.plan_list[e].global_popup_count.unshift(p),!1;popup.localData.plan_list[e].global_popup_count.shift(),popup.localData.plan_list[e].global_popup_count.unshift(p)},popup.updatePlanInterval=function(t){var e=(new Date).getTime();_.isObject(t)&&_.isObject(t.popup_interval)&&t.popup_interval.value&&(t.is_in_popup_interval_window=popup.ruleTime.getExpire(t.popup_interval,e))},popup.init=function(t,e){popup.log("\u5f39\u7a97\u5f00\u59cb\u521d\u59cb\u5316\uff01"),this.sa=t,this.setPara(e),this.sub=new t.eventSub(this.handleEvents),popup.updateAndListenPlan.initial(),popup.testPopup(),t.popupEmitter=popup.popupEmitter},popup.changeCovertStatus=function(t){var e=JSON.parse(JSON.stringify(popup.convertPlans));_.each(e,function(p,n){var o=p.is_in_convert_window.step,i=p.is_in_convert_window.uuid;if(popup.convertPlans[n].is_in_convert_window.step=Math.min(2*o,6e5),!t||!_.isArray(t)||0===t.length)return!1;_.each(t,function(t){t.popup_display_uuid===i&&t.convert_time&&(delete popup.convertPlans[n].is_in_convert_window,popup.convertPlans.splice(n,1),e.splice(n,1),n--)})}),popup.updateAndListenPlan.updateData()},popup.asyncConvert=function(t){var e=popup.info.project,p=!1;if(!t&&0===popup.convertPlans.length)return!1;t&&(_.each(popup.convertPlans,function(e){e.plan_id===t.plan_id&&(p=!0)}),p||popup.convertPlans.push(t)),function t(){if(_.isEmptyObject(popup.localData)||!_.isArray(popup.convertPlans)||0===popup.convertPlans.length)return!1;var p=popup.convertPlans,n=p[0].is_in_convert_window&&p[0].is_in_convert_window.step||5e3,o=[],i=Date.now();_.each(p,function(t){var e=t.is_in_convert_window;if(!e)return!1;e.step||(e.step=5e3),n>e.step&&(n=e.step)}),_.each(p,function(t){if(!t.is_in_convert_window)return!1;var e=t.is_in_convert_window.expire_time;if(i>e||n>e-i)return delete t.is_in_convert_window,!1;o.push(t.is_in_convert_window.uuid)});var r=_.filter(p,function(t){return!!t.is_in_convert_window&&i11?(r.setFullYear(r.getFullYear()+parseInt(t/12)),r.setMonth(t%12)):r.setMonth(t),r.setDate(1),r.setHours(0),r.setMinutes(0),r.setSeconds(0),r.setMilliseconds(0),r.getTime()},second:function(t){var e={month:2592e6,week:6048e5,day:864e5,hour:36e5,minute:6e4,second:1e3},o=null;return r=new Date(p),t in e&&(o=e[t]*n),r.getTime()+o}};return!0!==t.natural?a.second(i):i in a?a[i]():void 0},getLast:function(t,e){var p=Number(t.value)||0,n=Number(t.value)-1||0,o=String(t.unit).toLowerCase(),i=null,r={day:function(){return(i=new Date(e)).setHours(0),i.setMinutes(0),i.setSeconds(0),i.setMilliseconds(0),i=i.getTime()-864e5*n},week:function(){var t=(i=new Date(e)).getDay();return 0===t&&(t=7),--t,i.setHours(0),i.setMinutes(0),i.setSeconds(0),i.setMilliseconds(0),i=i.getTime()-(24*t*60*60*1e3+7*n*24*60*60*1e3)},month:function(){var t=(i=new Date(e)).getMonth()+1-n;return t<=0?(i.setFullYear(i.getFullYear()+(parseInt(t/12)-1)),i.setMonth(12+t%12-1)):i.setMonth(t-1),i.setDate(1),i.setHours(0),i.setMinutes(0),i.setSeconds(0),i.setMilliseconds(0),i.getTime()},second:function(t){var n={month:2592e6,week:6048e5,day:864e5,hour:36e5,minute:6e4,second:1e3},o=null;return i=new Date(e),t in n&&(o=n[t]*p),i.getTime()-o}};return!0!==t.natural?r.second(o):o in r?r[o]():void 0},getArrMatchCount:function(t,e){var p=0;for(p=0;p=t[p])return p;return t.length},checkRule:function(t,e){var p=new Date,n=e,o=Number(t.value)||0,i=Number(t.value)-1||0,r=String(t.unit).toLowerCase(),a=null,u={day:function(){return(a=new Date(n)).setHours(23),a.setMinutes(59),a.setSeconds(59),a.setMilliseconds(999),a=a.getTime()+864e5*i,p>a},week:function(){var t=(a=new Date(n)).getDay();0===t&&(t=7);var e=7-t;return a.setHours(23),a.setMinutes(59),a.setSeconds(59),a.setMilliseconds(999),a=a.getTime()+24*e*60*60*1e3+7*i*24*60*60*1e3,p>a},month:function(){var t=(a=new Date(n)).getMonth()+i;return t>=11?(a.setFullYear(a.getFullYear()+t/11),a.setMonth(t%11)):a.setMonth(t),a.setDate(1),a.setHours(0),a.setMinutes(0),a.setSeconds(0),a.setMilliseconds(0),p>a},second:function(t){return a=new Date(n),t in inteval&&(interval_time={month:2592e6,week:6048e5,day:864e5,hour:36e5,minute:6e4,second:1e3}[t]*o),p>a+null}};return!0!==t.natural?u.second(r):r in u?u[r]():void 0}},popup.eventTriggerProcess=function(t,e){var p=!1;_.isArray(t)&&t.length>0&&_.isObject(t[0])&&(popup.log("--------------------\u89e6\u53d1\u4e8b\u4ef6\u5f00\u59cb--------------------"),_.each(t,function(t){_.isObject(t)&&void 0!==t.match_state&&delete t.match_state,new popup.RuleCheck(t,e)}),_.each(t,function(t){!0===t.match_state?!1===p?(p=!0,popup.log("\u68c0\u67e5\u5b8c\u6bd5-\u4f18\u5148\u5f39\u7a97-\u5f00\u59cb",t.plan.cname),new popup.PopupCheck(t,!0)):!0===p&&(popup.log("\u68c0\u67e5\u5b8c\u6bd5-\u975e\u4f18\u5148\u5f39\u7a97-\u4e0d\u6e32\u67d3",t.plan.cname),new popup.PopupCheck(t,!1)):popup.log("\u68c0\u67e5\u5b8c\u6bd5-\u8ba1\u5212-\u4e0d\u6ee1\u8db3",t.plan.cname)}),popup.log("--------------------\u89e6\u53d1\u4e8b\u4ef6\u7ed3\u675f--------------------"))},popup.PopupCheck=function(t,e){this.plan=t.plan,this.current_time=(new Date).getTime(),e?this.displayPopup():this.hidePopup()},popup.PopupCheck.prototype.displayPopup=function(){var t=_.getUuid()(),e={props:{$sf_succeed:!0}};popup.popupTree={},e.uuid=t,e.plan=this.plan;var p=this.plan.popup_window_content,n="",o=!0;if(p&&p.content)try{n=JSON.parse(p.content),new popup.parseTree(n)}catch(t){n=!1,o=!1}else popup.log("\u8ba1\u5212\u65e0\u7a97\u4f53\u5185\u5bb9\uff01"),o=!1;e.popupTree=popup.popupTree;var i={name:this.plan.cname,plan_id:this.plan.plan_id,content:this.plan.popup_window_content?this.plan.popup_window_content.content:"",type:this.plan.popup_window_content?this.plan.popup_window_content.popup_type:""};this.plan.hasOwnProperty("strategy_id")?this.plan.is_trigger?popup.campaign_listener.shouldStart(i)?p?"CUSTOMIZED"===p.popup_type?(e.popupTree={},popup.CAMPAIGN_ERROR.onStart?(e.props={$sf_fail_reason:"onStart \u672a\u5b9a\u4e49",$sf_succeed:!1},popup.track.popupDisplay(e),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,1004,"onStart \u672a\u5b9a\u4e49")):p.content?(popup.track.popupDisplay(e),popup.campaign_listener.onStart(i),popup.info.popup_listener.onLoadSuccess(this.plan.plan_id)):(e.props={$sf_fail_reason:"\u5f39\u7a97\u5185\u5bb9\u9519\u8bef",$sf_succeed:!1},popup.track.popupDisplay(e),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,1001,"\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e"))):o?(popup.track.popupDisplay(e),popup.CAMPAIGN_ERROR.onStart||popup.campaign_listener.onStart(i),this.renderPopup(e)):(e.props={$sf_fail_reason:"\u5f39\u7a97\u5185\u5bb9\u9519\u8bef",$sf_succeed:!1},popup.track.popupDisplay(e),popup.info.popup_listener.onLoadFailed(this.plan.plan_id,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e"),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e")):(e.props={$sf_fail_reason:"\u5f39\u7a97\u5185\u5bb9\u9519\u8bef",$sf_succeed:!1},popup.track.popupDisplay(e),popup.info.popup_listener.onLoadFailed(this.plan.plan_id,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e"),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e")):(e.props={$sf_fail_reason:"shouldStart \u63a5\u53e3\u8fd4\u56de false",$sf_succeed:!1},popup.track.popupDisplay(e),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,"1004","shouldStart \u63a5\u53e3\u8fd4\u56de false")):(e.props={$sf_fail_reason:"\u8ba1\u5212\u4e0b\u53d1 is_trigger \u4e3a false",$sf_succeed:!1},popup.track.popupDisplay(e),p&&"PRESET"===p.popup_type&&popup.info.popup_listener.onLoadFailed(this.plan.plan_id,"1005","\u8ba1\u5212\u4e0b\u53d1 is_trigger \u4e3a false"),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,"1005","\u8ba1\u5212\u4e0b\u53d1 is_trigger \u4e3a false")):this.plan.is_control_group?(e.props={$sf_fail_reason:"\u5bf9\u7167\u7ec4",$sf_succeed:!1},popup.track.popupDisplay(e),popup.info.popup_listener.onLoadFailed(this.plan.plan_id,"2000","\u5bf9\u7167\u7ec4"),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,"2000","\u5bf9\u7167\u7ec4")):popup.campaign_listener.shouldStart(i)?o?(popup.track.popupDisplay(e),popup.CAMPAIGN_ERROR.onStart||popup.campaign_listener.onStart(i),this.renderPopup(e)):(e.props={$sf_fail_reason:"\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e",$sf_succeed:!1},popup.track.popupDisplay(e),popup.info.popup_listener.onLoadFailed(this.plan.plan_id,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e"),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e")):(e.props={$sf_fail_reason:"shouldStart \u63a5\u53e3\u8fd4\u56de false",$sf_succeed:!1},popup.track.popupDisplay(e),popup.info.popup_listener.onLoadFailed(this.plan.plan_id,"1004","shouldStart \u63a5\u53e3\u8fd4\u56de false"),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,"1004","shouldStart \u63a5\u53e3\u8fd4\u56de false"));this.startConvertWindow(t),this.startPopupIntervalWindow(),this.startPopupLimitWindow(),this.setGlobalLimit(),this.deletePlanAllWindow(),popup.updateAndListenPlan.updateData()},popup.PopupCheck.prototype.hidePopup=function(){this.deletePlanAllWindow(),popup.updateAndListenPlan.updateData()},popup.PopupCheck.prototype.renderPopup=function(t){popup.log("\u6e32\u67d3\u5f39\u7a97"),popup.popupEmitter.notify(t)},popup.PopupCheck.prototype.startConvertWindow=function(t){popup.log("--\u5f39\u7a97\u5c55\u793a-\u8f6c\u5316\u7a97\u53e3\u8bbe\u7f6e"),_.isObject(this.plan.convert_window)&&this.plan.convert_window.value&&(this.plan.is_in_convert_window={expire_time:popup.ruleTime.getExpire(this.plan.convert_window,this.current_time),start_time:this.current_time,uuid:t},popup.asyncConvert(this.plan))},popup.PopupCheck.prototype.startPopupIntervalWindow=function(){_.isObject(this.plan.popup_interval)&&this.plan.popup_interval.value&&(this.plan.is_in_popup_interval_window=popup.ruleTime.getExpire(this.plan.popup_interval,this.current_time))},popup.PopupCheck.prototype.startPopupLimitWindow=function(){popup.log("--\u5f39\u7a97\u5c55\u793a-\u53c2\u4e0e\u9650\u5236\u7a97\u53e3\u8bbe\u7f6e\u91cd\u7f6e"),_.isObject(this.plan.re_enter)&&this.plan.re_enter.value&&(_.isObject(this.plan.is_in_popup_limit_window)?this.plan.is_in_popup_limit_window.count++:this.plan.is_in_popup_limit_window={expire_time:popup.ruleTime.getExpire(this.plan.re_enter,this.current_time),count:1})},popup.PopupCheck.prototype.setGlobalLimit=function(){popup.log("--\u5f39\u7a97\u5c55\u793a-\u5168\u5c40\u5f39\u7a97\u6b21\u6570\u8bbe\u7f6e");var t=popup.store.getCurrentUserPlanList();_.isArray(t.global_popup_count)||(t.global_popup_count=[]),t.global_popup_count.unshift(this.current_time);for(var e=t.global_popup_count,p=e[e.length-1];p+7776e63e3;)e.pop(),p=e[e.length-1]},popup.PopupCheck.prototype.deletePlanAllWindow=function(){var t=this.plan.pattern_popup.matcher_list;_.isArray(t)&&_.each(t,function(t){t.is_in_window&&(popup.log("--\u5f39\u7a97\u5c55\u793a-\u91cd\u7f6e\u5404\u4e2a\u89c4\u5219\u7684\u7a97\u53e3\u8ba1\u7b97-\u6210\u529f"),delete t.is_in_window)})},popup.RuleCheck=function(t,e){this.plan_match=t,this.plan=t.plan,this.rule_arr=t.rule,this.event_data=e,this.current_time=(new Date).getTime();var p="-------------\u68c0\u67e5-\u8ba1\u5212-("+this.plan.cname+")";_.each(this.rule_arr,function(t){p+="--\u5305\u542b\u89c4\u5219-("+t.event_name+"\uff09-\u89e6\u53d1"+t.params[0]+"\u6b21"}),popup.log(p),popup.log(this.plan),this.checkPlanIsExpire(),popup.updateAndListenPlan.updateData()},popup.RuleCheck.prototype.checkPlanIsExpire=function(){!this.plan.expire_at||_.isNumber(this.plan.expire_at)&&this.current_timethis.current_time?popup.log("--\u5b58\u5728\u8f6c\u5316\u7a97\u53e3 - \u4e0d\u6ee1\u8db3",this.plan.is_in_convert_window):(popup.log("--\u4e0d\u5b58\u5728\u8f6c\u5316\u7a97\u53e3\u6216\u8005\u7a97\u53e3\u8d85\u65f6\u5df2\u7ecf\u8fc7\u671f - \u6ee1\u8db3",this.plan.is_in_convert_window),this.checkGlobalPopupInterval())},popup.RuleCheck.prototype.checkGlobalPopupInterval=function(){var t=popup.store.getCurrentUserPlanList(),e=t.global_popup_count;if(_.isArray(e)&&e.length>=1){var p=popup.ruleTime.getLast(t.popup_interval_global,this.current_time);p>e[0]?(popup.log("--\u5168\u5c40\u5f39\u7a97\u95f4\u9694-\u6ee1\u8db3-"+p+">\u4e0a\u6b21\u5f39\u7a97\u65f6\u95f4"+e[0]),this.checkPopupInterval()):popup.log("\u68c0\u67e5-\u5168\u5c40\u5f39\u7a97\u95f4\u9694-\u4e0d\u6ee1\u8db3-"+p+"<\u4e0a\u6b21\u5f39\u7a97\u65f6\u95f4"+e[0])}else popup.log("--\u5168\u5c40\u5f39\u7a97\u95f4\u9694-\u6ca1\u6709\u5f39\u8fc7\u7a97-\u6ee1\u8db3"),this.checkPopupInterval()},popup.RuleCheck.prototype.checkPopupInterval=function(){_.isNumber(this.plan.is_in_popup_interval_window)?this.current_time>this.plan.is_in_popup_interval_window?(popup.log("--\u5f39\u7a97\u95f4\u9694-\u5f53\u524d\u65f6\u95f4\u5927\u4e8e\u56fa\u5b9a\u5f39\u7a97\u95f4\u9694-\u6ee1\u8db3"),this.plan.is_in_popup_interval_window=null,this.checkPermission()&&this.checkProperties()):popup.log("--\u5f39\u7a97\u95f4\u9694-\u5f53\u524d\u65f6\u95f4\u5c0f\u4e8e\u56fa\u5b9a\u5f39\u7a97\u95f4\u9694-\u4e0d\u6ee1\u8db3"):(popup.log("--\u5f39\u7a97\u95f4\u9694-\u7a97\u53e3\u4e0d\u5b58\u5728-\u65b0\u5f00"),this.plan.is_in_popup_interval_window=null,this.checkPermission()&&this.checkProperties())},popup.RuleCheck.prototype.isMatched=function(t){var e={equal:function(t,e){if(!_.isNumber(t)&&!_.isString(t))return!1;for(var p=0,n=e.length;p=0},notContain:function(t,e){return!!_.isString(t)&&-1===t.indexOf(e[0])},isTrue:function(t){return!0===t},isFalse:function(t){return!1===t},isSet:function(t){return void 0!==t},notSet:function(t){return void 0===t},isEmpty:function(t){if(!_.isString(t)&&!_.isArray(t))return!1;if(_.isString(t))return""===t;for(var e=0;eNumber(e[0])},between:function(t,e){return!!_.isNumber(t)&&(t>=Number(e[0])&&t<=Number(e[1]))},in:function(t,e){if(!_.isArray(t))return!1;for(var p=0;p=0)return!0;return!1},notInclude:function(t,e){if(!_.isArray(t))return!1;for(var p=0;p=p&&o<=n}catch(t){popup.log("absolute_between Error",t)}},absoluteBetween:function(t,e){try{var p=new Date(e[0]),n=new Date(e[1]),o=new Date(t);return o>=p&&o<=n}catch(t){popup.log("absolute_between Error",t)}}},p=this,n=t.relation,o="or"===String(n).toLowerCase(),i="and"===String(n).toLowerCase(),r=!!i,a=!0;return _.each(t.conditions,function(t){if(!a)return!1;if(!t.field)return!1;var n=t.field.lastIndexOf("."),u=t.params,s=t.function;if(!e[s])return r=!1,a=!1,!1;if(n<0)return!1;var l=t.field.slice(n+1),c=p.event_data.properties,d=_.getPropertiesValue(c,l),g=e[s](d,u);o&&g&&(r=!0,a=!1),i&&!g&&(r=!1,a=!1)}),r},popup.RuleCheck.prototype.checkPermission=function(){var t=this.plan.event_permission;if(!_.isObject(t)||_.isEmptyObject(t))return!0;var e=this,p=[],n=function(t){return _.filter(t,function(t){return!(t&&t.conditions&&(!t.conditions||0!==t.conditions.length))||e.isMatched(t)})};return function t(e,o){_.each(e,function(e){if(p=n([e]),_.isArray(p)&&p.length>0){var i=e[o]||[];i&&i.length>0&&t(i,o)}})}([t],"filters"),_.isArray(p)&&p.length>0?(popup.log("--\u89d2\u8272\u5c5e\u6027\u5339\u914d-\u6ee1\u8db3",p),!0):(popup.log("--\u89d2\u8272\u5c5e\u6027\u5339\u914d-\u4e0d\u6ee1\u8db3"),!1)},popup.RuleCheck.prototype.checkProperties=function(){var t=this,e=_.filter(this.rule_arr,function(e){var p=e.multi_filter?e.multi_filter:e.filter;return!(p&&(!p.conditions||0!==p.conditions.length))||t.isMatched(p)});_.isArray(e)&&e.length>0?(this.checkWindowAndMatch(e),popup.log("--\u5c5e\u6027\u5339\u914d-\u6ee1\u8db3",e)):popup.log("--\u5c5e\u6027\u5339\u914d-\u4e0d\u6ee1\u8db3")},popup.RuleCheck.prototype.checkWindowAndMatch=function(t){var e=this,p=[];_.each(t,function(t){if(!t.params||!t.params[0])return popup.log("--\u7a97\u53e3\u671f\u548c\u6b21\u6570-\u89c4\u5219\u6570\u636e\u5f02\u5e38"),!1;var n=Number(t.params[0]);1===n?p.push(t):n>1&&_.isObject(t.window)&&t.window.value>0&&(!_.isObject(t.is_in_window)||!_.isNumber(t.is_in_window.expire_time)||t.is_in_window.expire_time=n?p.push(t):popup.log("--\u7a97\u53e3\u671f\u548c\u6b21\u6570-\u89c4\u5219\u6570",t.is_in_window.count,"\u4e0d\u5339\u914d\u5f53\u524d\u6b21\u6570",n))}),p.length>0?(popup.log("--\u7a97\u53e3\u671f\u548c\u6b21\u6570-\u6709\u5339\u914d\u6210\u529f\u7684\u89c4\u5219",p),this.checkGlobalPopupLimit()):popup.log("--\u7a97\u53e3\u671f\u548c\u6b21\u6570-\u6ca1\u6709\u5339\u914d\u6210\u529f\u7684\u89c4\u5219",p)},popup.RuleCheck.prototype.checkGlobalPopupLimit=function(){var t=popup.store.getCurrentUserPlanList(),e=t.msg_limit_global,p=!0,n=this;_.isObject(e)&&!0===e.is_in_use&&_.isArray(e.limits)&&_.isArray(t.global_popup_count)&&!0===this.plan.global_msg_limit_enabled?(_.each(e.limits,function(e){if(_.isObject(e)&&_.isNumber(e.limit)){var o=popup.ruleTime.getLast(e,n.current_time),i=popup.ruleTime.getArrMatchCount(t.global_popup_count,o);popup.log("--\u5168\u5c40\u5f39\u7a97\u9650\u5236-\u5df2\u7ecf\u5f39\u7a97\u6b21\u6570-"+i+"-\u9650\u5236\u7684\u6b21\u6570"+e.limit+"-\u9650\u5236\u65f6\u95f4-"+o),p=i=2592e6&&delete popup.localData.plan_list[p]})},updateUserPlans:function(){var t=popup.serverData,e=popup.sa.store.getDistinctId();t.user_id?(popup.localData.user_list[e]=t.user_id,popup.localData.plan_list[t.user_id]||popup.localData.plan_list[e]&&(popup.localData.plan_list[t.user_id]=popup.localData.plan_list[e],delete popup.localData.plan_list[e])):popup.localData.user_list[e]||(popup.localData.user_list[e]=e)}};var IMAGE_MAP={close:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFoAAABaCAMAAAAPdrEwAAAAe1BMVEUAAAD////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////NgkbwAAAAKHRSTlMA5if6t/B0UjMSxpAtJB4MBfTr30oY6NjV0r2loZ6XkoaBenFp3UA/LNePaQAAAsxJREFUWMOsltlygzAMRRXMZsAsAZJmX9v6/7+wg1QXpjGxCDkvyWTIQZauDcCgzKLrPtnUSyGW9SbZX6OshDcQh36lH6j8MJ7pTZd6lGX6sr0IP7SDj7CA6chLoBkEFzm14nM1/P/2eGti1RZFq+LmdtwGw7afJ1Ue1dogcGCW4QptqCO2OPe1IbnL0Y7dE23wc2bJgSn44MFTvIMwLeMUXqZGfGKUkp+MPC2dwUjMGhWwUL7pnXRUsdbIIpow84VG1k9Xmf1e5U8Kq/R/68memAPqcggTCQUNc9SdL+iCL5jMd0B1j/RErh3LYrRyLa2po2x8KngJ9Uk5sWUwpZoVvIiiulNLhMwgHDhDED2MEH8X3zCDL4HV/R8lRTOEWYS0KWzt8GEm/mNLihpHKOeqJY6yLqDnbO42F1r9eXCzitMOfkuqfvkXTId6h1phSi5/ncbgneAtnDCAxTAzIn+POhfDFOObzAEsNLu0HXO06a4BCwd89wEk1h2ezdwl0rObvS5nNreHurg/lxKwsNPoHjXrHVhI+lMK3xjvMH4YelYzCSzc8V3zrx9CWtu5MG67eWEdhBSmI+GT7eIZt+Nny7YJ+y8ON9/cF1tWVL7LzTdTi6sSMtw9AE432wwl7u6MzqotMNwcM7Glc/TafRyB4+aa4dhdcoV993EDlptphlt3zZ72TgM8N88MDe3vDQWE5V6tWGaKyAbwqaiA5+aZQeETkk6QFtxuvhlaOkVwwxfgdq/IvHKbocBj6ac5OzYCIASBKGo10n+HBgakMswbaYDgTmX3fzgafhD4G+Hhg1cGXnT4PMFHVayCdVcBXGBu7cKwACOOC2YwTsIQ7KI7LBywJrlyByupK9Kw/lto4VFLAqLdmRwJiBDWwjDOI0QPPhPXRn3yTlyrILND4w7oOw3h5AlTPk5U/ddrZSk4RWW+C9hp2rgru6GiP/678n2UFPV1AAAAAElFTkSuQmCC"};popup.parseTree=function(t){this.img=void 0,this.content=void 0,this.title=void 0,this.button=[],this.image_button=void 0,this.buttonStyle={},this.view={},this.parseView(t.template),this.properties={maskCloseEnabled:t.properties.maskCloseEnabled,maskActionId:t.properties.maskActionId,maskColor:_.getRgba(t.properties.maskColor),maskAction:t.properties.maskAction},popup.popupTree.properties=this.properties},popup.parseTree.prototype={parseView:function(t){switch(t.type){case"column":case"row":this.getViewProp(t);break;case"image":this.getImg(t);break;case"label":this.getLabel(t);break;case"button":this.getButton(t);break;case"link":this.getLink(t);break;case"image_button":this.getImgButton(t)}this.img&&!_.isEmptyObject(this.img)&&(popup.popupTree.img=this.img),this.title&&!_.isEmptyObject(this.title)&&(popup.popupTree.title=this.title,popup.popupTree.diverseModule=!0),this.content&&!_.isEmptyObject(this.content)&&(popup.popupTree.content=this.content,popup.popupTree.diverseModule=!0),this.image_button&&!_.isEmptyObject(this.image_button)&&(popup.popupTree.image_button=this.image_button),this.buttonStyle&&!_.isEmptyObject(this.buttonStyle)&&(popup.popupTree.buttonStyle=this.buttonStyle),this.boxStyle&&!_.isEmptyObject(this.boxStyle)&&(popup.popupTree.boxStyle=this.boxStyle),this.container&&!_.isEmptyObject(this.container)&&(popup.popupTree.container=this.container),this.button&&!_.isEmptyObject(this.button)&&this.button.length>0&&(popup.popupTree.button=this.button,popup.popupTree.diverseModule=!0),this.view&&!_.isEmptyObject(this.view)&&(popup.popupTree.view=this.view),t.GRADE||(t.GRADE=0,this.view.container=Object.assign({},this.getViewProp(t))),t.subviews&&t.subviews.length>0&&_.each(t.subviews,function(e){e.GRADE=t.GRADE+1,this.parseView(e)},this)},getViewProp:function(t){switch(t.GRADE){case 0:return{style:"width: "+_.getRpx(t.layout.width)+";"};case 1:if(t.subviews.length>0){var e=Object.assign({},{backgroundImage:t.properties.backgroundImage?t.properties.backgroundImage:"",style:this.getStyle(t)}),p='background: url("'+e.backgroundImage+'");background-size: 100% 100%;'+e.style;this.view.content=Object.assign({},{style:p})}break;case 2:t.subviews&&t.subviews.length>0?this.view.button=Object.assign({},{type:t.type}):this.view.padding=Object.assign({},{style:"margin-top: "+_.getRpx(t.layout.margin.top)+";",type:t.type})}},isButtonBranch:function(t){var e=!0,p={image_button:1,link:1,button:1};return _.each(t,function(t,n){p[n]||(e=!1)}),e},getImg:function(t){this.img=_.extend({},this.getAttr(t.properties),this.getAction(t.action)),this.img.style=this.getStyle(t)},getImgButton:function(t){var e={};"close"===t.properties.msgType?t.properties.isHidden||(this.image_button=_.extend({},this.getAction(t.action),this.getAttr(t.properties)),t.layout.align&&(this.image_button.aligin=t.layout.align),this.image_button.style=this.getStyle(t),this.image_button.type=t.type):((e=_.extend({},this.getAction(t.action),this.getAttr(t.properties))).style=this.getStyle(t),e.type=t.type),_.isEmptyObject(e)||this.button.push(e)},getLabel:function(t){"title"===t.properties.msgType?(this.title=_.extend({},this.getAttr(t.properties)),this.title.style=this.getStyle(t)):"content"===t.properties.msgType&&(this.content=_.extend({},this.getAttr(t.properties)),this.content.style=this.getStyle(t))},getButton:function(t){var e={};(e=_.extend({},this.getAction(t.action),this.getAttr(t.properties))).style=this.getStyle(t),e.type=t.type,_.isEmptyObject(e)||this.button.push(e)},getLink:function(t){var e={};(e=_.extend({},this.getAction(t.action),this.getAttr(t.properties))).style=this.getStyle(t),e.type=t.type,_.isEmptyObject(e)||this.button.push(e)},getAttr:function(t){var e={};return t.text?e.innerText=t.text:t.image&&(t.localImageName?(e.src=IMAGE_MAP[t.localImageName],e.useLocalImage=!0):e.src=t.image),e},getAction:function(t){var e={};return t&&t.MINIPROGRAM&&(t=t.MINIPROGRAM[0],e.id=t.id,e.closeable=t.closeable,e.action_type=t.type,e.$sf_close_type=t.$sf_close_type,t.value&&(e.value=t.value),t.path&&(e.path=t.path),t.appid&&(e.appid=t.appid)),e},getStyle:function(t){var e,p={textAlign:"text-align",font:"font-size",backgroundColor:"background-color",borderWidth:function(t){return"border-width: "+t+";border-style: solid;"},borderColor:"border-color",cornerRadius:"border-radius",backgroundImage:function(t){return""},margin:this.boxModel("margin"),padding:this.boxModel("padding"),maxHeight:"max-height",maxWidth:"max-width"},n=["msgType","text","image","name","isHidden","align","localImageName"],o="";return e=_.extend({},t.layout,t.properties),_.each(e,function(t,e){t=_.getRpx(t);var i=p[e];if(n.indexOf(e)>=0)return!1;_.isString(i)?o+=i+":"+_.getRgba(t)+";":_.isFunction(i)?o+=i(t)+";":o+=e+":"+_.getRgba(t)+";"}),o},boxModel:function(t){return function(e){if("object"!=typeof e)return e;var p="";for(var n in e)p+=t+"-"+n+":"+_.getRpx(e[n]);return p}}};var QRCode={1011:1,1012:1,1013:1,1017:1,1047:1,1048:1,1049:1};popup.testSend={getPopupId:function(t){var e=0,p=t.query.scene;if(p){var n=decodeURIComponent(p).split("=");e="sf_test_id"===n[0]&&n[1]?n[1]:0}return e},start:function(t){if(!QRCode[t.scene])return!1;var e=this.getPopupId(t);if(!e)return!1;var p=popup.info.project,n=popup.info.platform,o=popup.sa.store.getDistinctId();_.wxrequest({url:popup.info.api_base_url+"/sfo/popup_windows/"+e+"?distinct_id="+encodeURIComponent(o)+"&app_id="+encodeURIComponent(popup.info.app_id)+"&project="+encodeURIComponent(p)+"&platform="+encodeURIComponent(n)+"&sdk_version="+encodeURIComponent(popup.lib_version)+"&time="+(new Date).getTime(),type:"GET",success:function(t){var e,p=t.data,n={content:p.content,type:p.popup_type,name:p.name||""},o=!0,i=_.getUuid()();try{e=JSON.parse(p.content)}catch(t){o=!1}var r={props:{$sf_succeed:!0},plan:{}};if(r.uuid=i,popup.popupTree={},"CUSTOMIZED"===p.popup_type)r.popupTree={},popup.CAMPAIGN_ERROR.onStart?(r.props={$sf_fail_reason:"onStart \u65b9\u6cd5\u672a\u5b9a\u4e49",$sf_succeed:!1},popup.track.popupDisplay(r),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(n,"1004","onStart \u65b9\u6cd5\u672a\u5b9a\u4e49")):p.content?(popup.campaign_listener.onStart(n),popup.track.popupDisplay(r)):(r.props={$sf_fail_reason:"\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e",$sf_succeed:!1},popup.track.popupDisplay(r),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(n,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e"));else{try{new popup.parseTree(e),r.popupTree=popup.popupTree,r.plan={popup_window_content:p}}catch(t){popup.log("--\u6d4b\u8bd5\u5f39\u7a97-\u89e3\u6790\u9519\u8bef",t),o=!1}o?(popup.track.popupDisplay(r),popup.CAMPAIGN_ERROR.onStart||popup.campaign_listener.onStart(n),popup.popupEmitter.notify(r)):(r.props={$sf_fail_reason:"\u5f39\u7a97\u5185\u5bb9\u5f02\u5e38",$sf_succeed:!1},popup.track.popupDisplay(r),popup.info.popup_listener.onLoadFailed(void 0,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e"),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(n,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e"))}}})}},popup.track={getPublicProps:function(){return{$sf_lib_version:popup.lib_version,$sf_plan_type:"\u8fd0\u8425\u8ba1\u5212",$sf_channel_service_name:"SENSORS_FOCUS",$sf_channel_category:"POPUP",$sf_platform_tag:popup.info.platform}},removeEmpty:function(t){_.each(t,function(e,p){""!==e&&void 0!==e||delete t[p]})},popupDisplay:function(t){var e=popup.track.getPublicProps(),p=popup.track.getPlanProps(t);_.extend(e,t.props,p),this.removeEmpty(e),popup.sa.track("$PlanPopupDisplay",e)},popupClick:function(t){var e=popup.track.getPublicProps(),p=popup.track.getPlanProps(t),n={type:t.props.$sf_msg_element_action,value:t.props.action_value||"",extra:t.props.action_value||""};try{if(popup.info.popup_listener.onClick(t.plan.plan_id,n),!popup.CAMPAIGN_ERROR.onClick){var o={name:t.plan.cname,plan_id:t.plan.plan_id,content:t.plan.popup_window_content?t.plan.popup_window_content.content:"",type:t.plan.popup_window_content?t.plan.popup_window_content.popup_type:"",action:n};popup.campaign_listener.onClick(o)}}catch(t){popup.log("popup_listener.onClick error",t)}delete t.props.action_value,_.extend(e,t.props,p),e.$sf_plan_id||delete e.$sf_plan_id,this.removeEmpty(e),popup.sa.track("$PlanPopupClick",e)},getPlanProps(t){var e={};if(!_.isObject(t))return e;var p=t.popupTree;if(e.$sf_msg_id=t.uuid,e.$sf_msg_title=p.title?p.title.innerText:"",e.$sf_msg_content=p.content?p.content.innerText:"",e.$sf_msg_image_url=p.img?p.img.src:"",e.$sf_plan_id=t.plan&&t.plan.plan_id||"",e.$sf_audience_id=t.plan&&t.plan.audience_id||"",t.plan.strategy_id?e.$sf_plan_strategy_id=t.plan.strategy_id:_.isBoolean(t.plan.is_control_group)&&(t.plan.is_control_group?e.$sf_plan_strategy_id=-1:e.$sf_plan_strategy_id=0),_.isObject(t.plan)){var n=t.plan.section_id;n&&(e.$sf_section_id=String(n),e.$sf_plan_type="\u65b0\u8d44\u6e90\u4f4d")}return e}};export default popup; \ No newline at end of file diff --git a/dist/wechat/plugin/sm-encryption/index.cmd.js b/dist/wechat/plugin/sm-encryption/index.cmd.js index c0fc3a7..7a901bd 100644 --- a/dist/wechat/plugin/sm-encryption/index.cmd.js +++ b/dist/wechat/plugin/sm-encryption/index.cmd.js @@ -1 +1 @@ -"use strict";function sm(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=2)}var getSmBuildArgs=function(){var t;function e(t,e,r){null!=t&&("number"==typeof t?this.fromNumber(t,e,r):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}function r(){return new e(null)}var n="undefined"!=typeof navigator;n&&"Microsoft Internet Explorer"==navigator.appName?(e.prototype.am=function(t,e,r,n,i,s){for(var o=32767&e,a=e>>15;--s>=0;){var h=32767&this[t],u=this[t++]>>15,l=a*h+u*o;i=((h=o*h+((32767&l)<<15)+r[n]+(1073741823&i))>>>30)+(l>>>15)+a*u+(i>>>30),r[n++]=1073741823&h}return i},t=30):n&&"Netscape"!=navigator.appName?(e.prototype.am=function(t,e,r,n,i,s){for(;--s>=0;){var o=e*this[t++]+r[n]+i;i=Math.floor(o/67108864),r[n++]=67108863&o}return i},t=26):(e.prototype.am=function(t,e,r,n,i,s){for(var o=16383&e,a=e>>14;--s>=0;){var h=16383&this[t],u=this[t++]>>14,l=a*h+u*o;i=((h=o*h+((16383&l)<<14)+r[n]+i)>>28)+(l>>14)+a*u,r[n++]=268435455&h}return i},t=28),e.prototype.DB=t,e.prototype.DM=(1<>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}function c(t){this.m=t}function d(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function v(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function b(){}function w(t){return t}function S(t){this.r2=r(),this.q3=r(),e.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}c.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},c.prototype.revert=function(t){return t},c.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},c.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},c.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},d.prototype.convert=function(t){var n=r();return t.abs().dlShiftTo(this.m.t,n),n.divRemTo(this.m,null,n),t.s<0&&n.compareTo(e.ZERO)>0&&this.m.subTo(n,n),n},d.prototype.revert=function(t){var e=r();return t.copyTo(e),this.reduce(e),e},d.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e>15)*this.mpl&this.um)<<15)&t.DM;for(t[r=e+this.m.t]+=this.m.am(0,n,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},d.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},d.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},e.prototype.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},e.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},e.prototype.fromString=function(t,r){if(!r&&t.length>=2&&"0"===t[0]){var n=!0;switch(t[1]){case"x":r=16;break;case"b":r=2;break;case"o":r=8;break;default:n=!1}n&&(t=t.substr(2))}var i;if(16==r)i=4;else if(8==r)i=3;else if(256==r)i=8;else if(2==r)i=1;else if(32==r)i=5;else{if(4!=r)return void this.fromRadix(t,r);i=2}this.t=0,this.s=0;for(var s=t.length,o=!1,a=0;--s>=0;){var h=8==i?255&t[s]:u(t,s);h<0?"-"==t.charAt(s)&&(o=!0):(o=!1,0==a?this[this.t++]=h:a+i>this.DB?(this[this.t-1]|=(h&(1<>this.DB-a):this[this.t-1]|=h<=this.DB&&(a-=this.DB))}8==i&&0!=(128&t[0])&&(this.s=-1,a>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==t;)--this.t},e.prototype.dlShiftTo=function(t,e){var r;for(r=this.t-1;r>=0;--r)e[r+t]=this[r];for(r=t-1;r>=0;--r)e[r]=0;e.t=this.t+t,e.s=this.s},e.prototype.drShiftTo=function(t,e){for(var r=t;r=0;--r)e[r+o+1]=this[r]>>i|a,a=(this[r]&s)<=0;--r)e[r]=0;e[o]=a,e.t=this.t+o+1,e.s=this.s,e.clamp()},e.prototype.rShiftTo=function(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var n=t%this.DB,i=this.DB-n,s=(1<>n;for(var o=r+1;o>n;n>0&&(e[this.t-r-1]|=(this.s&s)<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[r++]=this.DV+n:n>0&&(e[r++]=n),e.t=r,e.clamp()},e.prototype.multiplyTo=function(t,r){var n=this.abs(),i=t.abs(),s=n.t;for(r.t=s+i.t;--s>=0;)r[s]=0;for(s=0;s=0;)t[r]=0;for(r=0;r=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()},e.prototype.divRemTo=function(t,n,i){var s=t.abs();if(!(s.t<=0)){var o=this.abs();if(o.t0?(s.lShiftTo(l,a),o.lShiftTo(l,i)):(s.copyTo(a),o.copyTo(i));var c=a.t,d=a[c-1];if(0!=d){var p=d*(1<1?a[c-2]>>this.F2:0),_=this.FV/p,g=(1<=0&&(i[i.t++]=1,i.subTo(b,i)),e.ONE.dlShiftTo(c,b),b.subTo(a,a);a.t=0;){var w=i[--y]==d?this.DM:Math.floor(i[y]*_+(i[y-1]+m)*g);if((i[y]+=a.am(0,w,i,v,0,c))0&&i.rShiftTo(l,i),h<0&&e.ZERO.subTo(i,i)}}},e.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},e.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},e.prototype.exp=function(t,n){if(t>4294967295||t<1)return e.ONE;var i=r(),s=r(),o=n.convert(this),a=f(t)-1;for(o.copyTo(i);--a>=0;)if(n.sqrTo(i,s),(t&1<0)n.mulTo(s,o,i);else{var h=i;i=s,s=h}return n.revert(i)},e.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var r,n=(1<0)for(a>a)>0&&(i=!0,s=h(r));o>=0;)a>(a+=this.DB-e)):(r=this[o]>>(a-=e)&n,a<=0&&(a+=this.DB,--o)),r>0&&(i=!0),i&&(s+=h(r));return i?s:"0"},e.prototype.negate=function(){var t=r();return e.ZERO.subTo(this,t),t},e.prototype.abs=function(){return this.s<0?this.negate():this},e.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(0!=(e=r-t.t))return this.s<0?-e:e;for(;--r>=0;)if(0!=(e=this[r]-t[r]))return e;return 0},e.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+f(this[this.t-1]^this.s&this.DM)},e.prototype.mod=function(t){var n=r();return this.abs().divRemTo(t,null,n),this.s<0&&n.compareTo(e.ZERO)>0&&t.subTo(n,n),n},e.prototype.modPowInt=function(t,e){var r;return r=t<256||e.isEven()?new c(e):new d(e),this.exp(t,r)},e.ZERO=l(0),e.ONE=l(1),b.prototype.convert=w,b.prototype.revert=w,b.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r)},b.prototype.sqrTo=function(t,e){t.squareTo(e)},S.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=r();return t.copyTo(e),this.reduce(e),e},S.prototype.revert=function(t){return t},S.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},S.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},S.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var T,x,F,B=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],E=(1<<26)/B[B.length-1];function k(){var t;t=(new Date).getTime(),x[F++]^=255&t,x[F++]^=t>>8&255,x[F++]^=t>>16&255,x[F++]^=t>>24&255,F>=q&&(F-=q)}if(e.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},e.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),n=Math.pow(t,e),i=l(n),s=r(),o=r(),a="";for(this.divRemTo(i,s,o);s.signum()>0;)a=(n+o.intValue()).toString(t).substr(1)+a,s.divRemTo(i,s,o);return o.intValue().toString(t)+a},e.prototype.fromRadix=function(t,r){this.fromInt(0),null==r&&(r=10);for(var n=this.chunkSize(r),i=Math.pow(r,n),s=!1,o=0,a=0,h=0;h=n&&(this.dMultiply(i),this.dAddOffset(a,0),o=0,a=0))}o>0&&(this.dMultiply(Math.pow(r,o)),this.dAddOffset(a,0)),s&&e.ZERO.subTo(this,this)},e.prototype.fromNumber=function(t,r,n){if("number"==typeof r)if(t<2)this.fromInt(1);else for(this.fromNumber(t,n),this.testBit(t-1)||this.bitwiseTo(e.ONE.shiftLeft(t-1),_,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(r);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(e.ONE.shiftLeft(t-1),this);else{var i=new Array,s=7&t;i.length=1+(t>>3),r.nextBytes(i),s>0?i[0]&=(1<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e[r++]=n:n<-1&&(e[r++]=this.DV+n),e.t=r,e.clamp()},e.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},e.prototype.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},e.prototype.multiplyLowerTo=function(t,e,r){var n,i=Math.min(this.t+t.t,e);for(r.s=0,r.t=i;i>0;)r[--i]=0;for(n=r.t-this.t;i=0;)r[n]=0;for(n=Math.max(e-this.t,0);n0)if(0==e)r=this[0]%t;else for(var n=this.t-1;n>=0;--n)r=(e*r+this[n])%t;return r},e.prototype.millerRabin=function(t){var n=this.subtract(e.ONE),i=n.getLowestSetBit();if(i<=0)return!1;var s=n.shiftRight(i);(t=t+1>>1)>B.length&&(t=B.length);for(var o=r(),a=0;a>24},e.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},e.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},e.prototype.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var r,n=this.DB-t*this.DB%8,i=0;if(t-- >0)for(n>n)!=(this.s&this.DM)>>n&&(e[i++]=r|this.s<=0;)n<8?(r=(this[t]&(1<>(n+=this.DB-8)):(r=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),0!=(128&r)&&(r|=-256),0==i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(e[i++]=r);return e},e.prototype.equals=function(t){return 0==this.compareTo(t)},e.prototype.min=function(t){return this.compareTo(t)<0?this:t},e.prototype.max=function(t){return this.compareTo(t)>0?this:t},e.prototype.and=function(t){var e=r();return this.bitwiseTo(t,p,e),e},e.prototype.or=function(t){var e=r();return this.bitwiseTo(t,_,e),e},e.prototype.xor=function(t){var e=r();return this.bitwiseTo(t,g,e),e},e.prototype.andNot=function(t){var e=r();return this.bitwiseTo(t,m,e),e},e.prototype.not=function(){for(var t=r(),e=0;e=this.t?0!=this.s:0!=(this[e]&1<1){var _=r();for(i.sqrTo(a[1],_);h<=p;)a[h]=r(),i.mulTo(_,a[h-2],a[h]),h+=2}var g,m,y=t.t-1,v=!0,b=r();for(s=f(t[y])-1;y>=0;){for(s>=u?g=t[y]>>s-u&p:(g=(t[y]&(1<0&&(g|=t[y-1]>>this.DB+s-u)),h=n;0==(1&g);)g>>=1,--h;if((s-=h)<0&&(s+=this.DB,--y),v)a[g].copyTo(o),v=!1;else{for(;h>1;)i.sqrTo(o,b),i.sqrTo(b,o),h-=2;h>0?i.sqrTo(o,b):(m=o,o=b,b=m),i.mulTo(b,a[g],o)}for(;y>=0&&0==(t[y]&1<=0?(n.subTo(i,n),r&&s.subTo(a,s),o.subTo(h,o)):(i.subTo(n,i),r&&a.subTo(s,a),h.subTo(o,h))}return 0!=i.compareTo(e.ONE)?e.ZERO:h.compareTo(t)>=0?h.subtract(t):h.signum()<0?(h.addTo(t,h),h.signum()<0?h.add(t):h):h},e.prototype.pow=function(t){return this.exp(t,new b)},e.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var n=e;e=r,r=n}var i=e.getLowestSetBit(),s=r.getLowestSetBit();if(s<0)return e;for(i0&&(e.rShiftTo(s,e),r.rShiftTo(s,r));e.signum()>0;)(i=e.getLowestSetBit())>0&&e.rShiftTo(i,e),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return s>0&&r.lShiftTo(s,r),r},e.prototype.isProbablePrime=function(t){var e,r=this.abs();if(1==r.t&&r[0]<=B[B.length-1]){for(e=0;e>>8,x[F++]=255&D;F=0,k()}function I(){if(null==T){for(k(),(T=new O).init(x),F=0;F>>32-r}function o(t,e){for(var r=[],n=t.length-1;n>=0;n--)r[n]=255&(t[n]^e[n]);return r}function a(t){return t^s(t,9)^s(t,17)}function h(t){var e=8*t.length,r=e%512;r=r>=448?512-r%448-1:448-r-1;for(var o=new Array((r-7)/8),h=new Array(8),u=0,l=o.length;u=0;d--)if(e.length>8){var p=e.length-8;h[d]=parseInt(e.substr(p),2),e=e.substr(0,p)}else e.length>0&&(h[d]=parseInt(e,2),e="");for(var _,g=new Uint8Array([].concat(t,[128],o,h)),m=new DataView(g.buffer,0),y=g.length/64,v=new Uint32Array([1937774191,1226093241,388252375,3666478592,2842636476,372324522,3817729613,2969243214]),b=0;b=0&&Z<=15?2043430169:2055708042,q=(Z>=0&&Z<=15?B^E^k:B&E|B&k|E&k)+D+((O=s(s(B,12)+A+s(P,Z),7))^s(B,12))+i[Z],M=(Z>=0&&Z<=15?A^z^I:A&z|~A&I)+R+O+n[Z],D=k,k=s(E,9),E=B,B=q,R=I,I=s(z,19),z=A,A=a(M);v[0]^=B,v[1]^=E,v[2]^=k,v[3]^=D,v[4]^=A,v[5]^=z,v[6]^=I,v[7]^=R}for(var C=[],L=0,U=v.length;L>>24,(16711680&N)>>>16,(65280&N)>>>8,255&N)}return C}for(var u=64,l=new Uint8Array(u),f=new Uint8Array(u),c=0;cu&&(e=h(e));e.length2&&void 0!==arguments[2]?arguments[2]:"1234567812345678";r=a.utf8ToHex(r);var n=a.leftPad(l.curve.a.toBigInteger().toRadix(16),64),i=a.leftPad(l.curve.b.toBigInteger().toRadix(16),64),s=a.leftPad(l.getX().toBigInteger().toRadix(16),64),o=a.leftPad(l.getY().toBigInteger().toRadix(16),64),u=void 0,f=void 0;if(128===e.length)u=e.substr(0,64),f=e.substr(64,64);else{var c=l.curve.decodePointHex(e);u=a.leftPad(c.getX().toBigInteger().toRadix(16),64),f=a.leftPad(c.getY().toBigInteger().toRadix(16),64)}var d=a.hexToArray(r+n+i+s+o+u+f),p=4*r.length;d.unshift(255&p),d.unshift(p>>8&255);var _=h(d);return a.arrayToHex(h(_.concat(a.hexToArray(t))))}function _(){var t=a.generateKeyPairHex(),e=f.decodePointHex(t.publicKey);return t.k=new n(t.privateKey,16),t.x1=e.getX().toBigInteger(),t}t.exports={generateKeyPairHex:a.generateKeyPairHex,compressPublicKeyHex:a.compressPublicKeyHex,comparePublicKeyHex:a.comparePublicKeyHex,doEncrypt:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;t="string"==typeof t?a.hexToArray(a.utf8ToHex(t)):Array.prototype.slice.call(t),e=a.getGlobalCurve().decodePointHex(e);var i=a.generateKeyPairHex(),s=new n(i.privateKey,16),o=i.publicKey;o.length>128&&(o=o.substr(o.length-128));var u=e.multiply(s),l=a.hexToArray(a.leftPad(u.getX().toBigInteger().toRadix(16),64)),f=a.hexToArray(a.leftPad(u.getY().toBigInteger().toRadix(16),64)),c=a.arrayToHex(h([].concat(l,t,f))),p=1,_=0,g=[],m=[].concat(l,f),y=function(){g=h([].concat(m,[p>>24&255,p>>16&255,p>>8&255,255&p])),p++,_=0};y();for(var v=0,b=t.length;v2&&void 0!==arguments[2]?arguments[2]:1,i=(arguments.length>3&&void 0!==arguments[3]?arguments[3]:{}).output,s=void 0===i?"string":i;e=new n(e,16);var o=t.substr(128,64),u=t.substr(192);r===d&&(o=t.substr(t.length-64),u=t.substr(128,t.length-128-64));var l=a.hexToArray(u),f=a.getGlobalCurve().decodePointHex("04"+t.substr(0,128)).multiply(e),c=a.hexToArray(a.leftPad(f.getX().toBigInteger().toRadix(16),64)),p=a.hexToArray(a.leftPad(f.getY().toBigInteger().toRadix(16),64)),_=1,g=0,m=[],y=[].concat(c,p),v=function(){m=h([].concat(y,[_>>24&255,_>>16&255,_>>8&255,255&_])),_++,g=0};v();for(var b=0,w=l.length;b2&&void 0!==arguments[2]?arguments[2]:{},i=r.pointPool,o=r.der,h=r.hash,u=r.publicKey,f=r.userId,d="string"==typeof t?a.utf8ToHex(t):a.arrayToHex(t);h&&(d=p(d,u=u||function(t){var e=l.multiply(new n(t,16)),r=a.leftPad(e.getX().toBigInteger().toString(16),64),i=a.leftPad(e.getY().toBigInteger().toString(16),64);return"04"+r+i}(e),f));var g=new n(e,16),m=new n(d,16),y=null,v=null,b=null;do{do{var w=void 0;y=(w=i&&i.length?i.pop():_()).k,v=m.add(w.x1).mod(c)}while(v.equals(n.ZERO)||v.add(y).equals(c));b=g.add(n.ONE).modInverse(c).multiply(y.subtract(v.multiply(g))).mod(c)}while(b.equals(n.ZERO));return o?s(v,b):a.leftPad(v.toString(16),64)+a.leftPad(b.toString(16),64)},doVerifySignature:function(t,e,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},s=i.der,h=i.hash,u=i.userId,d="string"==typeof t?a.utf8ToHex(t):a.arrayToHex(t);h&&(d=p(d,r,u));var _=void 0,g=void 0;if(s){var m=o(e);_=m.r,g=m.s}else _=new n(e.substring(0,64),16),g=new n(e.substring(64),16);var y=f.decodePointHex(r),v=new n(d,16),b=_.add(g).mod(c);if(b.equals(n.ZERO))return!1;var w=l.multiply(g).add(y.multiply(b)),S=v.add(w.getX().toBigInteger()).mod(c);return _.equals(S)},getPoint:_,verifyPublicKey:a.verifyPublicKey,hexToArray:a.hexToArray}},function(t,e,r){function n(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function s(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var o=r(0).BigInteger;var a=function(){function t(){s(this,t),this.tlv=null,this.t="00",this.l="00",this.v=""}return t.prototype.getEncodedHex=function(){return this.tlv||(this.v=this.getValue(),this.l=this.getLength(),this.tlv=this.t+this.l+this.v),this.tlv},t.prototype.getLength=function(){var t=this.v.length/2,e=t.toString(16);return e.length%2==1&&(e="0"+e),t<128?e:(128+e.length/2).toString(16)+e},t.prototype.getValue=function(){return""},t}(),h=function(t){function e(r){s(this,e);var i=n(this,t.call(this));return i.t="02",r&&(i.v=function(t){var e=t.toString(16);if("-"!==e[0])e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e);else{var r=(e=e.substr(1)).length;r%2==1?r+=1:e.match(/^[0-7]/)||(r+=2);for(var n="",i=0;i=e?t:new Array(e-t.length+1).join("0")+t}t.exports={getGlobalCurve:function(){return u},generateEcparam:c,generateKeyPairHex:function(t,e,r){var n=(t?new i(t,e,r):new i(f.bitLength(),a)).mod(f.subtract(i.ONE)).add(i.ONE),s=d(n.toString(16),64),o=l.multiply(n);return{privateKey:s,publicKey:"04"+d(o.getX().toBigInteger().toString(16),64)+d(o.getY().toBigInteger().toString(16),64)}},compressPublicKeyHex:function(t){if(130!==t.length)throw new Error("Invalid public key to compress");var e=(t.length-2)/2,r=t.substr(2,e),n="03";return new i(t.substr(e+2,e),16).mod(new i("2")).equals(i.ZERO)&&(n="02"),n+r},utf8ToHex:function(t){for(var e=(t=unescape(encodeURIComponent(t))).length,r=[],n=0;n>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;for(var i=[],s=0;s>>2]>>>24-s%4*8&255;i.push((o>>>4).toString(16)),i.push((15&o).toString(16))}return i.join("")},leftPad:d,arrayToHex:function(t){return t.map(function(t){return 1===(t=t.toString(16)).length?"0"+t:t}).join("")},arrayToUtf8:function(t){for(var e=[],r=0,n=0;n<2*t.length;n+=2)e[n>>>3]|=parseInt(t[r],10)<<24-n%8*4,r++;try{for(var i=[],s=0;s>>2]>>>24-s%4*8&255;i.push(String.fromCharCode(o))}return decodeURIComponent(escape(i.join("")))}catch(t){throw new Error("Malformed UTF-8 data")}},hexToArray:function(t){var e=[],r=t.length;r%2!=0&&(t=d(t,r+1)),r=t.length;for(var n=0;n0;i--){n=n.twice();var s=e.testBit(i);s!==t.testBit(i)&&(n=n.add(s?this:r))}return n},t}(),u=function(){function t(e,r,i){n(this,t),this.q=e,this.a=this.fromBigInteger(r),this.b=this.fromBigInteger(i),this.infinity=new h(this,null,null)}return t.prototype.equals=function(t){return t===this||this.q.equals(t.q)&&this.a.equals(t.a)&&this.b.equals(t.b)},t.prototype.fromBigInteger=function(t){return new a(this.q,t)},t.prototype.decodePointHex=function(t){switch(parseInt(t.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:var e=this.fromBigInteger(new i(t.substr(2),16)),r=this.fromBigInteger(e.multiply(e.square()).add(e.multiply(this.a)).add(this.b).toBigInteger().modPow(this.q.divide(new i("4")).add(i.ONE),this.q));return r.toBigInteger().mod(s).equals(new i(t.substr(0,2),16).subtract(s))||(r=r.negate()),new h(this,e,r);case 4:case 6:case 7:var n=(t.length-2)/2,o=t.substr(2,n),a=t.substr(n+2,n);return new h(this,this.fromBigInteger(new i(o,16)),this.fromBigInteger(new i(a,16)));default:return null}},t}();t.exports={ECPointFp:h,ECCurveFp:u}},function(t,e,r){var n=r(1),i=n.sm3,s=n.hmac;function o(t){return t.map(function(t){return 1===(t=t.toString(16)).length?"0"+t:t}).join("")}function a(t){var e,r,n=[],i=t.length;i%2!=0&&(r=i+1,t=(e=t).length>=r?e:new Array(r-e.length+1).join("0")+e),i=t.length;for(var s=0;s>>6),e.push(128|63&i);else if(i<=55295||i>=57344&&i<=65535)e.push(224|i>>>12),e.push(128|i>>>6&63),e.push(128|63&i);else{if(!(i>=65536&&i<=1114111))throw e.push(i),new Error("input is not supported");r++,e.push(240|i>>>18&28),e.push(128|i>>>12&63),e.push(128|i>>>6&63),e.push(128|63&i)}}return e}(t):Array.prototype.slice.call(t),e){if("hmac"!==(e.mode||"hmac"))throw new Error("invalid mode");var r=e.key;if(!r)throw new Error("invalid key");return r="string"==typeof r?a(r):Array.prototype.slice.call(r),o(s(t,r))}return o(i(t))}},function(t,e,r){var n=0,i=32,s=16,o=[214,144,233,254,204,225,61,183,22,182,20,194,40,251,44,5,43,103,154,118,42,190,4,195,170,68,19,38,73,134,6,153,156,66,80,244,145,239,152,122,51,84,11,67,237,207,172,98,228,179,28,169,201,8,232,149,128,223,148,250,117,143,63,166,71,7,167,252,243,115,23,186,131,89,60,25,230,133,79,168,104,107,129,178,113,100,218,139,248,235,15,75,112,86,157,53,30,36,14,94,99,88,209,162,37,34,124,59,1,33,120,135,212,0,70,87,159,211,39,82,76,54,2,231,160,196,200,158,234,191,138,210,64,199,56,181,163,247,242,206,249,97,21,161,224,174,93,164,155,52,26,85,173,147,50,48,245,140,177,227,29,246,226,46,130,102,202,96,192,41,35,171,13,83,78,111,213,219,55,69,222,253,142,47,3,255,106,114,109,108,91,81,141,27,175,146,187,221,188,127,17,217,92,65,31,16,90,216,10,193,49,136,165,205,123,189,45,116,208,18,184,229,180,176,137,105,151,74,12,150,119,126,101,185,241,9,197,110,198,132,24,240,125,236,58,220,77,32,121,238,95,62,215,203,57,72],a=[462357,472066609,943670861,1415275113,1886879365,2358483617,2830087869,3301692121,3773296373,4228057617,404694573,876298825,1347903077,1819507329,2291111581,2762715833,3234320085,3705924337,4177462797,337322537,808926789,1280531041,1752135293,2223739545,2695343797,3166948049,3638552301,4110090761,269950501,741554753,1213159005,1684763257];function h(t){for(var e=[],r=0,n=t.length;r>>32-r}function l(t){return(255&o[t>>>24&255])<<24|(255&o[t>>>16&255])<<16|(255&o[t>>>8&255])<<8|255&o[255&t]}function f(t){return t^u(t,2)^u(t,10)^u(t,18)^u(t,24)}function c(t){return t^u(t,13)^u(t,23)}function d(t,e,r){for(var n=new Array(4),i=new Array(4),s=0;s<4;s++)i[0]=255&t[4*s],i[1]=255&t[4*s+1],i[2]=255&t[4*s+2],i[3]=255&t[4*s+3],n[s]=i[0]<<24|i[1]<<16|i[2]<<8|i[3];for(var o,a=0;a<32;a+=4)o=n[1]^n[2]^n[3]^r[a+0],n[0]^=f(l(o)),o=n[2]^n[3]^n[0]^r[a+1],n[1]^=f(l(o)),o=n[3]^n[0]^n[1]^r[a+2],n[2]^=f(l(o)),o=n[0]^n[1]^n[2]^r[a+3],n[3]^=f(l(o));for(var h=0;h<16;h+=4)e[h]=n[3-h/4]>>>24&255,e[h+1]=n[3-h/4]>>>16&255,e[h+2]=n[3-h/4]>>>8&255,e[h+3]=255&n[3-h/4]}function p(t,e,r){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},u=o.padding,f=void 0===u?"pkcs#7":u,p=o.mode,_=o.iv,g=void 0===_?[]:_,m=o.output,y=void 0===m?"string":m;if("cbc"===p&&("string"==typeof g&&(g=h(g)),16!==g.length))throw new Error("iv is invalid");if("string"==typeof e&&(e=h(e)),16!==e.length)throw new Error("key is invalid");if(t="string"==typeof t?r!==n?function(t){for(var e=[],r=0,n=t.length;r>>6),e.push(128|63&i);else if(i<=55295||i>=57344&&i<=65535)e.push(224|i>>>12),e.push(128|i>>>6&63),e.push(128|63&i);else{if(!(i>=65536&&i<=1114111))throw e.push(i),new Error("input is not supported");r++,e.push(240|i>>>18&28),e.push(128|i>>>12&63),e.push(128|i>>>6&63),e.push(128|63&i)}}return e}(t):h(t):[].concat(t),("pkcs#5"===f||"pkcs#7"===f)&&r!==n)for(var v=s-t.length%s,b=0;b=s;){var B=t.slice(F,F+16),E=new Array(16);if("cbc"===p)for(var k=0;k=240&&t[r]<=247?(e.push(String.fromCodePoint(((7&t[r])<<18)+((63&t[r+1])<<12)+((63&t[r+2])<<6)+(63&t[r+3]))),r+=3):t[r]>=224&&t[r]<=239?(e.push(String.fromCodePoint(((15&t[r])<<12)+((63&t[r+1])<<6)+(63&t[r+2]))),r+=2):t[r]>=192&&t[r]<=223?(e.push(String.fromCodePoint(((31&t[r])<<6)+(63&t[r+1]))),r++):e.push(String.fromCodePoint(t[r]));return e.join("")}(S):S}t.exports={encrypt:function(t,e,r){return p(t,e,1,r)},decrypt:function(t,e,r){return p(t,e,0,r)}}}]};function buildSMModule(){return sm(getSmBuildArgs())}function getPako(){function t(t){for(var e=t.length;--e>=0;)t[e]=0}var e=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),r=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),n=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),i=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),s=new Array(576);t(s);var o=new Array(60);t(o);var a=new Array(512);t(a);var h=new Array(256);t(h);var u=new Array(29);t(u);var l,f,c,d=new Array(30);function p(t,e,r,n,i){this.static_tree=t,this.extra_bits=e,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=t&&t.length}function _(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}t(d);var g=function(t){return t<256?a[t]:a[256+(t>>>7)]},m=function(t,e){t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},y=function(t,e,r){t.bi_valid>16-r?(t.bi_buf|=e<>16-t.bi_valid,t.bi_valid+=r-16):(t.bi_buf|=e<>>=1,r<<=1}while(--e>0);return r>>>1},w=function(t,e,r){var n,i,s=new Array(16),o=0;for(n=1;n<=15;n++)o=o+r[n-1]<<1,s[n]=o;for(i=0;i<=e;i++){var a=t[2*i+1];0!==a&&(t[2*i]=b(s[a]++,a))}},S=function(t){var e;for(e=0;e<286;e++)t.dyn_ltree[2*e]=0;for(e=0;e<30;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.sym_next=t.matches=0},T=function(t){t.bi_valid>8?m(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},x=function(t,e,r,n){var i=2*e,s=2*r;return t[i]>1;r>=1;r--)F(t,s,r);i=h;do{r=t.heap[1],t.heap[1]=t.heap[t.heap_len--],F(t,s,1),n=t.heap[1],t.heap[--t.heap_max]=r,t.heap[--t.heap_max]=n,s[2*i]=s[2*r]+s[2*n],t.depth[i]=(t.depth[r]>=t.depth[n]?t.depth[r]:t.depth[n])+1,s[2*r+1]=s[2*n+1]=i,t.heap[1]=i++,F(t,s,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],function(t,e){var r,n,i,s,o,a,h=e.dyn_tree,u=e.max_code,l=e.stat_desc.static_tree,f=e.stat_desc.has_stree,c=e.stat_desc.extra_bits,d=e.stat_desc.extra_base,p=e.stat_desc.max_length,_=0;for(s=0;s<=15;s++)t.bl_count[s]=0;for(h[2*t.heap[t.heap_max]+1]=0,r=t.heap_max+1;r<573;r++)(s=h[2*h[2*(n=t.heap[r])+1]+1]+1)>p&&(s=p,_++),h[2*n+1]=s,n>u||(t.bl_count[s]++,o=0,n>=d&&(o=c[n-d]),a=h[2*n],t.opt_len+=a*(s+o),f&&(t.static_len+=a*(l[2*n+1]+o)));if(0!==_){do{for(s=p-1;0===t.bl_count[s];)s--;t.bl_count[s]--,t.bl_count[s+1]+=2,t.bl_count[p]--,_-=2}while(_>0);for(s=p;0!==s;s--)for(n=t.bl_count[s];0!==n;)(i=t.heap[--r])>u||(h[2*i+1]!==s&&(t.opt_len+=(s-h[2*i+1])*h[2*i],h[2*i+1]=s),n--)}}(t,e),w(s,u,t.bl_count)},k=function(t,e,r){var n,i,s=-1,o=e[1],a=0,h=7,u=4;for(0===o&&(h=138,u=3),e[2*(r+1)+1]=65535,n=0;n<=r;n++)i=o,o=e[2*(n+1)+1],++a>=7;g<30;g++)for(d[g]=m<<7,t=0;t<1<0?(2===t.strm.data_type&&(t.strm.data_type=function(t){var e,r=4093624447;for(e=0;e<=31;e++,r>>>=1)if(1&r&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<256;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0}(t)),E(t,t.l_desc),E(t,t.d_desc),u=function(t){var e;for(k(t,t.dyn_ltree,t.l_desc.max_code),k(t,t.dyn_dtree,t.d_desc.max_code),E(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*i[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e}(t),a=t.opt_len+3+7>>>3,(h=t.static_len+3+7>>>3)<=a&&(a=h)):a=h=r+5,r+4<=a&&-1!==e?z(t,e,r,n):4===t.strategy||h===a?(y(t,2+(n?1:0),3),B(t,s,o)):(y(t,4+(n?1:0),3),function(t,e,r,n){var s;for(y(t,e-257,5),y(t,r-1,5),y(t,n-4,4),s=0;s>8,t.pending_buf[t.sym_buf+t.sym_next++]=r,0===e?t.dyn_ltree[2*r]++:(t.matches++,e--,t.dyn_ltree[2*(h[r]+256+1)]++,t.dyn_dtree[2*g(e)]++),t.sym_next===t.sym_end},_tr_align:function(t){y(t,2,3),v(t,256,s),function(t){16===t.bi_valid?(m(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}(t)}},R=function(t,e,r,n){for(var i=65535&t|0,s=t>>>16&65535|0,o=0;0!==r;){r-=o=r>2e3?2e3:r;do{s=s+(i=i+e[n++]|0)|0}while(--o);i%=65521,s%=65521}return i|s<<16|0},O=new Uint32Array(function(){for(var t,e=[],r=0;r<256;r++){t=r;for(var n=0;n<8;n++)t=1&t?3988292384^t>>>1:t>>>1;e[r]=t}return e}()),q=function(t,e,r,n){var i=O,s=n+r;t^=-1;for(var o=n;o>>8^i[255&(t^e[o])];return-1^t},M={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},P={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},Z=I._tr_init,C=I._tr_stored_block,L=I._tr_flush_block,U=I._tr_tally,N=I._tr_align,H=P.Z_NO_FLUSH,j=P.Z_PARTIAL_FLUSH,K=P.Z_FULL_FLUSH,V=P.Z_FINISH,Y=P.Z_BLOCK,X=P.Z_OK,G=P.Z_STREAM_END,J=P.Z_STREAM_ERROR,W=P.Z_DATA_ERROR,$=P.Z_BUF_ERROR,Q=P.Z_DEFAULT_COMPRESSION,tt=P.Z_FILTERED,et=P.Z_HUFFMAN_ONLY,rt=P.Z_RLE,nt=P.Z_FIXED,it=P.Z_DEFAULT_STRATEGY,st=P.Z_UNKNOWN,ot=P.Z_DEFLATED,at=286,ht=30,ut=19,lt=2*at+1,ft=15,ct=function(t,e){return t.msg=M[e],e},dt=function(t){return 2*t-(t>4?9:0)},pt=function(t){for(var e=t.length;--e>=0;)t[e]=0},_t=function(t){var e,r,n,i=t.w_size;n=e=t.hash_size;do{r=t.head[--n],t.head[n]=r>=i?r-i:0}while(--e);n=e=i;do{r=t.prev[--n],t.prev[n]=r>=i?r-i:0}while(--e)},gt=function(t,e,r){return(e<t.avail_out&&(r=t.avail_out),0!==r&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+r),t.next_out),t.next_out+=r,e.pending_out+=r,t.total_out+=r,t.avail_out-=r,e.pending-=r,0===e.pending&&(e.pending_out=0))},yt=function(t,e){L(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,mt(t.strm)},vt=function(t,e){t.pending_buf[t.pending++]=e},bt=function(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},wt=function(t,e,r,n){var i=t.avail_in;return i>n&&(i=n),0===i?0:(t.avail_in-=i,e.set(t.input.subarray(t.next_in,t.next_in+i),r),1===t.state.wrap?t.adler=R(t.adler,e,i,r):2===t.state.wrap&&(t.adler=q(t.adler,e,i,r)),t.next_in+=i,t.total_in+=i,i)},St=function(t,e){var r,n,i=t.max_chain_length,s=t.strstart,o=t.prev_length,a=t.nice_match,h=t.strstart>t.w_size-262?t.strstart-(t.w_size-262):0,u=t.window,l=t.w_mask,f=t.prev,c=t.strstart+258,d=u[s+o-1],p=u[s+o];t.prev_length>=t.good_match&&(i>>=2),a>t.lookahead&&(a=t.lookahead);do{if(u[(r=e)+o]===p&&u[r+o-1]===d&&u[r]===u[s]&&u[++r]===u[s+1]){s+=2,r++;do{}while(u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&so){if(t.match_start=e,o=n,n>=a)break;d=u[s+o-1],p=u[s+o]}}}while((e=f[e&l])>h&&0!=--i);return o<=t.lookahead?o:t.lookahead},Tt=function(t){var e,r,n,i=t.w_size;do{if(r=t.window_size-t.lookahead-t.strstart,t.strstart>=i+(i-262)&&(t.window.set(t.window.subarray(i,i+i-r),0),t.match_start-=i,t.strstart-=i,t.block_start-=i,t.insert>t.strstart&&(t.insert=t.strstart),_t(t),r+=i),0===t.strm.avail_in)break;if(e=wt(t.strm,t.window,t.strstart+t.lookahead,r),t.lookahead+=e,t.lookahead+t.insert>=3)for(n=t.strstart-t.insert,t.ins_h=t.window[n],t.ins_h=gt(t,t.ins_h,t.window[n+1]);t.insert&&(t.ins_h=gt(t,t.ins_h,t.window[n+3-1]),t.prev[n&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=n,n++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<262&&0!==t.strm.avail_in)},xt=function(t,e){var r,n,i,s=t.pending_buf_size-5>t.w_size?t.w_size:t.pending_buf_size-5,o=0,a=t.strm.avail_in;do{if(r=65535,i=t.bi_valid+42>>3,t.strm.avail_out(n=t.strstart-t.block_start)+t.strm.avail_in&&(r=n+t.strm.avail_in),r>i&&(r=i),r>8,t.pending_buf[t.pending-2]=~r,t.pending_buf[t.pending-1]=~r>>8,mt(t.strm),n&&(n>r&&(n=r),t.strm.output.set(t.window.subarray(t.block_start,t.block_start+n),t.strm.next_out),t.strm.next_out+=n,t.strm.avail_out-=n,t.strm.total_out+=n,t.block_start+=n,r-=n),r&&(wt(t.strm,t.strm.output,t.strm.next_out,r),t.strm.next_out+=r,t.strm.avail_out-=r,t.strm.total_out+=r)}while(0===o);return(a-=t.strm.avail_in)&&(a>=t.w_size?(t.matches=2,t.window.set(t.strm.input.subarray(t.strm.next_in-t.w_size,t.strm.next_in),0),t.strstart=t.w_size,t.insert=t.strstart):(t.window_size-t.strstart<=a&&(t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,t.insert>t.strstart&&(t.insert=t.strstart)),t.window.set(t.strm.input.subarray(t.strm.next_in-a,t.strm.next_in),t.strstart),t.strstart+=a,t.insert+=a>t.w_size-t.insert?t.w_size-t.insert:a),t.block_start=t.strstart),t.high_wateri&&t.block_start>=t.w_size&&(t.block_start-=t.w_size,t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,i+=t.w_size,t.insert>t.strstart&&(t.insert=t.strstart)),i>t.strm.avail_in&&(i=t.strm.avail_in),i&&(wt(t.strm,t.window,t.strstart,i),t.strstart+=i,t.insert+=i>t.w_size-t.insert?t.w_size-t.insert:i),t.high_water>3,s=(i=t.pending_buf_size-i>65535?65535:t.pending_buf_size-i)>t.w_size?t.w_size:i,((n=t.strstart-t.block_start)>=s||(n||e===V)&&e!==H&&0===t.strm.avail_in&&n<=i)&&(r=n>i?i:n,o=e===V&&0===t.strm.avail_in&&r===n?1:0,C(t,t.block_start,r,o),t.block_start+=r,mt(t.strm)),o?3:1)},Ft=function(t,e){for(var r,n;;){if(t.lookahead<262){if(Tt(t),t.lookahead<262&&e===H)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=gt(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==r&&t.strstart-r<=t.w_size-262&&(t.match_length=St(t,r)),t.match_length>=3)if(n=U(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=gt(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=gt(t,t.ins_h,t.window[t.strstart+1]);else n=U(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(n&&(yt(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===V?(yt(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(yt(t,!1),0===t.strm.avail_out)?1:2},Bt=function(t,e){for(var r,n,i;;){if(t.lookahead<262){if(Tt(t),t.lookahead<262&&e===H)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=gt(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==r&&t.prev_length4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){i=t.strstart+t.lookahead-3,n=U(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=i&&(t.ins_h=gt(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,n&&(yt(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if((n=U(t,0,t.window[t.strstart-1]))&&yt(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(n=U(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===V?(yt(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(yt(t,!1),0===t.strm.avail_out)?1:2};function Et(t,e,r,n,i){this.good_length=t,this.max_lazy=e,this.nice_length=r,this.max_chain=n,this.func=i}var kt=[new Et(0,0,0,0,xt),new Et(4,4,8,4,Ft),new Et(4,5,16,8,Ft),new Et(4,6,32,32,Ft),new Et(4,4,16,16,Bt),new Et(8,16,32,32,Bt),new Et(8,16,128,128,Bt),new Et(8,32,128,256,Bt),new Et(32,128,258,1024,Bt),new Et(32,258,258,4096,Bt)];function Dt(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=ot,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(2*lt),this.dyn_dtree=new Uint16Array(2*(2*ht+1)),this.bl_tree=new Uint16Array(2*(2*ut+1)),pt(this.dyn_ltree),pt(this.dyn_dtree),pt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(ft+1),this.heap=new Uint16Array(2*at+1),pt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*at+1),pt(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}var At=function(t){if(!t)return 1;var e=t.state;return!e||e.strm!==t||42!==e.status&&57!==e.status&&69!==e.status&&73!==e.status&&91!==e.status&&103!==e.status&&113!==e.status&&666!==e.status?1:0},zt=function(t){if(At(t))return ct(t,J);t.total_in=t.total_out=0,t.data_type=st;var e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=2===e.wrap?57:e.wrap?42:113,t.adler=2===e.wrap?0:1,e.last_flush=-2,Z(e),X},It=function(t){var e,r=zt(t);return r===X&&((e=t.state).window_size=2*e.w_size,pt(e.head),e.max_lazy_match=kt[e.level].max_lazy,e.good_match=kt[e.level].good_length,e.nice_match=kt[e.level].nice_length,e.max_chain_length=kt[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=2,e.match_available=0,e.ins_h=0),r},Rt=function(t,e,r,n,i,s){if(!t)return J;var o=1;if(e===Q&&(e=6),n<0?(o=0,n=-n):n>15&&(o=2,n-=16),i<1||i>9||r!==ot||n<8||n>15||e<0||e>9||s<0||s>nt||8===n&&1!==o)return ct(t,J);8===n&&(n=9);var a=new Dt;return t.state=a,a.strm=t,a.status=42,a.wrap=o,a.gzhead=null,a.w_bits=n,a.w_size=1<Y||e<0)return t?ct(t,J):J;var r=t.state;if(!t.output||0!==t.avail_in&&!t.input||666===r.status&&e!==V)return ct(t,0===t.avail_out?$:J);var n=r.last_flush;if(r.last_flush=e,0!==r.pending){if(mt(t),0===t.avail_out)return r.last_flush=-1,X}else if(0===t.avail_in&&dt(e)<=dt(n)&&e!==V)return ct(t,$);if(666===r.status&&0!==t.avail_in)return ct(t,$);if(42===r.status&&0===r.wrap&&(r.status=113),42===r.status){var i=ot+(r.w_bits-8<<4)<<8;if(i|=(r.strategy>=et||r.level<2?0:r.level<6?1:6===r.level?2:3)<<6,0!==r.strstart&&(i|=32),bt(r,i+=31-i%31),0!==r.strstart&&(bt(r,t.adler>>>16),bt(r,65535&t.adler)),t.adler=1,r.status=113,mt(t),0!==r.pending)return r.last_flush=-1,X}if(57===r.status)if(t.adler=0,vt(r,31),vt(r,139),vt(r,8),r.gzhead)vt(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),vt(r,255&r.gzhead.time),vt(r,r.gzhead.time>>8&255),vt(r,r.gzhead.time>>16&255),vt(r,r.gzhead.time>>24&255),vt(r,9===r.level?2:r.strategy>=et||r.level<2?4:0),vt(r,255&r.gzhead.os),r.gzhead.extra&&r.gzhead.extra.length&&(vt(r,255&r.gzhead.extra.length),vt(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(t.adler=q(t.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=69;else if(vt(r,0),vt(r,0),vt(r,0),vt(r,0),vt(r,0),vt(r,9===r.level?2:r.strategy>=et||r.level<2?4:0),vt(r,3),r.status=113,mt(t),0!==r.pending)return r.last_flush=-1,X;if(69===r.status){if(r.gzhead.extra){for(var s=r.pending,o=(65535&r.gzhead.extra.length)-r.gzindex;r.pending+o>r.pending_buf_size;){var a=r.pending_buf_size-r.pending;if(r.pending_buf.set(r.gzhead.extra.subarray(r.gzindex,r.gzindex+a),r.pending),r.pending=r.pending_buf_size,r.gzhead.hcrc&&r.pending>s&&(t.adler=q(t.adler,r.pending_buf,r.pending-s,s)),r.gzindex+=a,mt(t),0!==r.pending)return r.last_flush=-1,X;s=0,o-=a}var h=new Uint8Array(r.gzhead.extra);r.pending_buf.set(h.subarray(r.gzindex,r.gzindex+o),r.pending),r.pending+=o,r.gzhead.hcrc&&r.pending>s&&(t.adler=q(t.adler,r.pending_buf,r.pending-s,s)),r.gzindex=0}r.status=73}if(73===r.status){if(r.gzhead.name){var u,l=r.pending;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>l&&(t.adler=q(t.adler,r.pending_buf,r.pending-l,l)),mt(t),0!==r.pending)return r.last_flush=-1,X;l=0}u=r.gzindexl&&(t.adler=q(t.adler,r.pending_buf,r.pending-l,l)),r.gzindex=0}r.status=91}if(91===r.status){if(r.gzhead.comment){var f,c=r.pending;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>c&&(t.adler=q(t.adler,r.pending_buf,r.pending-c,c)),mt(t),0!==r.pending)return r.last_flush=-1,X;c=0}f=r.gzindexc&&(t.adler=q(t.adler,r.pending_buf,r.pending-c,c))}r.status=103}if(103===r.status){if(r.gzhead.hcrc){if(r.pending+2>r.pending_buf_size&&(mt(t),0!==r.pending))return r.last_flush=-1,X;vt(r,255&t.adler),vt(r,t.adler>>8&255),t.adler=0}if(r.status=113,mt(t),0!==r.pending)return r.last_flush=-1,X}if(0!==t.avail_in||0!==r.lookahead||e!==H&&666!==r.status){var d=0===r.level?xt(r,e):r.strategy===et?function(t,e){for(var r;;){if(0===t.lookahead&&(Tt(t),0===t.lookahead)){if(e===H)return 1;break}if(t.match_length=0,r=U(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,r&&(yt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===V?(yt(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(yt(t,!1),0===t.strm.avail_out)?1:2}(r,e):r.strategy===rt?function(t,e){for(var r,n,i,s,o=t.window;;){if(t.lookahead<=258){if(Tt(t),t.lookahead<=258&&e===H)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(n=o[i=t.strstart-1])===o[++i]&&n===o[++i]&&n===o[++i]){s=t.strstart+258;do{}while(n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&it.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(r=U(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(r=U(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),r&&(yt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===V?(yt(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(yt(t,!1),0===t.strm.avail_out)?1:2}(r,e):kt[r.level].func(r,e);if(3!==d&&4!==d||(r.status=666),1===d||3===d)return 0===t.avail_out&&(r.last_flush=-1),X;if(2===d&&(e===j?N(r):e!==Y&&(C(r,0,0,!1),e===K&&(pt(r.head),0===r.lookahead&&(r.strstart=0,r.block_start=0,r.insert=0))),mt(t),0===t.avail_out))return r.last_flush=-1,X}return e!==V?X:r.wrap<=0?G:(2===r.wrap?(vt(r,255&t.adler),vt(r,t.adler>>8&255),vt(r,t.adler>>16&255),vt(r,t.adler>>24&255),vt(r,255&t.total_in),vt(r,t.total_in>>8&255),vt(r,t.total_in>>16&255),vt(r,t.total_in>>24&255)):(bt(r,t.adler>>>16),bt(r,65535&t.adler)),mt(t),r.wrap>0&&(r.wrap=-r.wrap),0!==r.pending?X:G)},deflateEnd:function(t){if(At(t))return J;var e=t.state.status;return t.state=null,113===e?ct(t,W):X},deflateSetDictionary:function(t,e){var r=e.length;if(At(t))return J;var n=t.state,i=n.wrap;if(2===i||1===i&&42!==n.status||n.lookahead)return J;if(1===i&&(t.adler=R(t.adler,e,r,0)),n.wrap=0,r>=n.w_size){0===i&&(pt(n.head),n.strstart=0,n.block_start=0,n.insert=0);var s=new Uint8Array(n.w_size);s.set(e.subarray(r-n.w_size,r),0),e=s,r=n.w_size}var o=t.avail_in,a=t.next_in,h=t.input;for(t.avail_in=r,t.next_in=0,t.input=e,Tt(n);n.lookahead>=3;){var u=n.strstart,l=n.lookahead-2;do{n.ins_h=gt(n,n.ins_h,n.window[u+3-1]),n.prev[u&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=u,u++}while(--l);n.strstart=u,n.lookahead=2,Tt(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,t.next_in=a,t.input=h,t.avail_in=o,n.wrap=i,X},deflateInfo:"pako deflate (from Nodeca project)"};function qt(t){return(qt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var Mt=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},Pt={assign:function(t){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var r=e.shift();if(r){if("object"!==qt(r))throw new TypeError(r+"must be non-object");for(var n in r)Mt(r,n)&&(t[n]=r[n])}}return t},flattenChunks:function(t){for(var e=0,r=0,n=t.length;r=252?6:Lt>=248?5:Lt>=240?4:Lt>=224?3:Lt>=192?2:1;Ct[254]=Ct[254]=1;var Ut={string2buf:function(t){if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);var e,r,n,i,s,o=t.length,a=0;for(i=0;i>>6,e[s++]=128|63&r):r<65536?(e[s++]=224|r>>>12,e[s++]=128|r>>>6&63,e[s++]=128|63&r):(e[s++]=240|r>>>18,e[s++]=128|r>>>12&63,e[s++]=128|r>>>6&63,e[s++]=128|63&r);return e},buf2string:function(t,e){var r,n,i=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));var s=new Array(2*i);for(n=0,r=0;r4)s[n++]=65533,r+=a-1;else{for(o&=2===a?31:3===a?15:7;a>1&&r1?s[n++]=65533:o<65536?s[n++]=o:(o-=65536,s[n++]=55296|o>>10&1023,s[n++]=56320|1023&o)}}}return function(t,e){if(e<65534&&t.subarray&&Zt)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));for(var r="",n=0;nt.length&&(e=t.length);for(var r=e-1;r>=0&&128==(192&t[r]);)r--;return r<0?e:0===r?e:r+Ct[t[r]]>e?r:e}};var Nt=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0},Ht=Object.prototype.toString,jt=P.Z_NO_FLUSH,Kt=P.Z_SYNC_FLUSH,Vt=P.Z_FULL_FLUSH,Yt=P.Z_FINISH,Xt=P.Z_OK,Gt=P.Z_STREAM_END,Jt=P.Z_DEFAULT_COMPRESSION,Wt=P.Z_DEFAULT_STRATEGY,$t=P.Z_DEFLATED;function Qt(t){this.options=Pt.assign({level:Jt,method:$t,chunkSize:16384,windowBits:15,memLevel:8,strategy:Wt},t||{});var e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Nt,this.strm.avail_out=0;var r=Ot.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(r!==Xt)throw new Error(M[r]);if(e.header&&Ot.deflateSetHeader(this.strm,e.header),e.dictionary){var n;if(n="string"==typeof e.dictionary?Ut.string2buf(e.dictionary):"[object ArrayBuffer]"===Ht.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,(r=Ot.deflateSetDictionary(this.strm,n))!==Xt)throw new Error(M[r]);this._dict_set=!0}}function te(t,e){var r=new Qt(e);if(r.push(t,!0),r.err)throw r.msg||M[r.err];return r.result}return Qt.prototype.push=function(t,e){var r,n,i=this.strm,s=this.options.chunkSize;if(this.ended)return!1;for(n=e===~~e?e:!0===e?Yt:jt,"string"==typeof t?i.input=Ut.string2buf(t):"[object ArrayBuffer]"===Ht.call(t)?i.input=new Uint8Array(t):i.input=t,i.next_in=0,i.avail_in=i.input.length;;)if(0===i.avail_out&&(i.output=new Uint8Array(s),i.next_out=0,i.avail_out=s),(n===Kt||n===Vt)&&i.avail_out<=6)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else{if((r=Ot.deflate(i,n))===Gt)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),r=Ot.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===Xt;if(0!==i.avail_out){if(n>0&&i.next_out>0)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else if(0===i.avail_in)break}else this.onData(i.output)}return!0},Qt.prototype.onData=function(t){this.chunks.push(t)},Qt.prototype.onEnd=function(t){t===Xt&&(this.result=Pt.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg},{Deflate:Qt,deflate:te,deflateRaw:function(t,e){return(e=e||{}).raw=!0,te(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,te(t,e)},constants:P}}var sm2,sm4,hexToArray,sm4key,encryptedSm4Key,iv,oldSingleEncoder,oldBatchSender,_this,_sa,_,_config,pako,base={plugin_version:"1.19.11"};function createPlugin(t){if("object"==typeof t&&"string"==typeof t.plugin_name&&""!==t.plugin_name)return t.plugin_version=base.plugin_version,t.log=t.log||function(){"object"==typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)},t;"object"==typeof console&&"function"==typeof console.error&&console.error('plugin must contain proprerty "plugin_name"')}function getStorage(t){return new Promise(function(e){wx.getStorage({key:t,complete:function(t){e(t&&t.data)}})})}function saveStorage(t,e){return new Promise(function(r){wx.setStorage({key:t,data:e,success:function(){r(!0)},fail:function(){r(!1)}})})}var signalBatchSenderReady,encDataStoreName="sensors_mp_encrypted_data";function get128RandomByte(t){t=t||16;for(var e="";t-- >0;){var r=Math.ceil(255*_.getRandom()).toString(16);e+=2===r.length?r:"0"+r}return e}function matchType(t,e,r){return typeof t===r||(_this.log(e+" must be "+r),!1)}function isTruthy(t,e){return!!t||(_this.log(e+" cant not be null"),!1)}function isSupportSMEncryption(){try{var t=new Uint8Array(1);return t[0]=1,1===t[0]}catch(t){return!1}}function hexToBase64(t){return _.btoa(String.fromCharCode.apply(null,t.replace(/\r|\n/g,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")))}function encryptData(t){var e=t;try{_.isObject(t)&&(t=JSON.stringify(t)),t=Array.prototype.slice.call(pako.gzip(t));var r=sm4.encrypt(t,sm4key,{mode:"cbc",iv:iv});return hexToBase64(iv+r)}catch(t){_this.log("sm encryptData error: "+t.message)}return e}function encryptSingleTrackData(t){var e=encryptData(t);if(_.isString(e)){var r={pkv:_config.pkv,ekey:encryptedSm4Key,flush_time:Date.now(),payloads:[e]},n=JSON.stringify(r);return"data="+encodeURIComponent(n)+"&gzip=9"}return _this.log("SM encryption error, data will not be encrypted"),oldSingleEncoder.call(_sa.kit,t)}function convertToEncDataStruct(t){return{enc:"SM",config:{pkv:_config.pkv,ekey:encryptedSm4Key},payload:t}}function sendSingleDataImmediately(t){try{t._flush_time=Date.now();var e=_sa.kit.onceTrackData(t),r=_sa.para.server_url+"?"+e;-1!==_sa.para.server_url.indexOf("?")&&(r=_sa.para.server_url+"&"+e),_.wxrequest({url:r,method:"GET"})}catch(t){_this.log("onceSend error: "+t.message)}}function readEncStorageToMem(){return getStorage(encDataStoreName).then(t=>{if(_.isArray(t)&&t.length>0)for(var e=0;e0)for(var r=0;rsaveStorage(_sa.para.storage_prepare_data_key,[]))}function groupAndSend(t){for(var e={},r=0;r0){var a=JSON.stringify(s);a="data_list="+encodeURIComponent(a)+"&gzip=9";var h=t.length;_.wxrequest({url:_sa.para.server_url,method:"POST",dataType:"text",data:a,header:{"content-type":"text/plain"},success:function(){oldBatchSender.batchRemove.call(oldBatchSender,h)},fail:function(){oldBatchSender.sendFail.call(oldBatchSender)}})}else _this.log("group send error: no data available")}var SmBatchSend={readySignal:new Promise(function(t){signalBatchSenderReady=t}),init:function(){readEncStorageToMem().then(readLegacyStorage).then(encryptLegacyStorageData).then(persistStorage).finally(()=>{_sa.para.storage_prepare_data_key=encDataStoreName,oldBatchSender.batchInterval(),oldBatchSender.onAppHide(),oldBatchSender.sendHasInit=!0,oldBatchSender.syncStorage=!0,signalBatchSenderReady()}).catch(t=>{_this.log("sm batch-send init err"+t.message)})},send:function(t){SmBatchSend.readySignal.then(function(){if(oldBatchSender.dataHasChange=!0,_sa.store.mem.getLength()>=500&&(_this.log("storage data is too large"),_sa.store.mem.mdata.shift()),t){var e=encryptData(t);if(!_.isString(e))return _this.log("encrypt send data failed. send immediately"),void sendSingleDataImmediately(t);_sa.store.mem.add(convertToEncDataStruct(e))}oldBatchSender.sendAsOver()})},wxrequest:function(t){var e=t.data;e[0].config&&e[0].config.ekey?groupAndSend(e):_this.log("SM Encryption data error.")}};function doEncryptSM4Key(t,e){for(var r=0;r<10;){r++;var n=sm2.doEncrypt(hexToArray(t).slice(),e,1);if("0"!==n[0]||"4"!==n[1])return hexToBase64(n)}throw"generate SM4 ekey failed"}var SmEncryption={plugin_name:"SMEncryption",init:function(t,e){_=(_sa=t)._,_config=e,_this=this;try{if(!isSupportSMEncryption())return void this.log("mini base lib incompatible, data send will not be encrypted");if(!t||!t.kit||!t.kit.onceTrackData)return void this.log("SMEncryption init failed, SDK version incompatible.");var r=buildSMModule();pako=getPako(),sm2=r.sm2,sm4=r.sm4,hexToArray=sm2.hexToArray,isTruthy(e,"SMEncryption init config")&&matchType(e.pkv,"pkv","number")&&isTruthy(e.pub_key,"pub_key")&&matchType(e.pub_key,"pub_key","string")?(iv=get128RandomByte(),sm4key=get128RandomByte(),encryptedSm4Key=doEncryptSM4Key(sm4key,_config.pub_key),oldSingleEncoder=_sa.kit.onceTrackData,oldBatchSender=_sa.sendStrategy,_sa.kit.onceTrackData=encryptSingleTrackData,_sa.sendStrategy.init=SmBatchSend.init,_sa.sendStrategy.send=SmBatchSend.send,_sa.sendStrategy.wxrequest=SmBatchSend.wxrequest,_this.log("SMEncryption init succeed")):_this.log("SMEncryption init failed")}catch(t){_this.log("SMEncryption init exception: "+t)}}},index=createPlugin(SmEncryption);module.exports=index; \ No newline at end of file +"use strict";function sm(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=2)}var getSmBuildArgs=function(){var t;function e(t,e,r){null!=t&&("number"==typeof t?this.fromNumber(t,e,r):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}function r(){return new e(null)}var n="undefined"!=typeof navigator;n&&"Microsoft Internet Explorer"==navigator.appName?(e.prototype.am=function(t,e,r,n,i,s){for(var o=32767&e,a=e>>15;--s>=0;){var h=32767&this[t],u=this[t++]>>15,l=a*h+u*o;i=((h=o*h+((32767&l)<<15)+r[n]+(1073741823&i))>>>30)+(l>>>15)+a*u+(i>>>30),r[n++]=1073741823&h}return i},t=30):n&&"Netscape"!=navigator.appName?(e.prototype.am=function(t,e,r,n,i,s){for(;--s>=0;){var o=e*this[t++]+r[n]+i;i=Math.floor(o/67108864),r[n++]=67108863&o}return i},t=26):(e.prototype.am=function(t,e,r,n,i,s){for(var o=16383&e,a=e>>14;--s>=0;){var h=16383&this[t],u=this[t++]>>14,l=a*h+u*o;i=((h=o*h+((16383&l)<<14)+r[n]+i)>>28)+(l>>14)+a*u,r[n++]=268435455&h}return i},t=28),e.prototype.DB=t,e.prototype.DM=(1<>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}function c(t){this.m=t}function d(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function v(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function b(){}function w(t){return t}function S(t){this.r2=r(),this.q3=r(),e.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}c.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},c.prototype.revert=function(t){return t},c.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},c.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},c.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},d.prototype.convert=function(t){var n=r();return t.abs().dlShiftTo(this.m.t,n),n.divRemTo(this.m,null,n),t.s<0&&n.compareTo(e.ZERO)>0&&this.m.subTo(n,n),n},d.prototype.revert=function(t){var e=r();return t.copyTo(e),this.reduce(e),e},d.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e>15)*this.mpl&this.um)<<15)&t.DM;for(t[r=e+this.m.t]+=this.m.am(0,n,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},d.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},d.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},e.prototype.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},e.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},e.prototype.fromString=function(t,r){if(!r&&t.length>=2&&"0"===t[0]){var n=!0;switch(t[1]){case"x":r=16;break;case"b":r=2;break;case"o":r=8;break;default:n=!1}n&&(t=t.substr(2))}var i;if(16==r)i=4;else if(8==r)i=3;else if(256==r)i=8;else if(2==r)i=1;else if(32==r)i=5;else{if(4!=r)return void this.fromRadix(t,r);i=2}this.t=0,this.s=0;for(var s=t.length,o=!1,a=0;--s>=0;){var h=8==i?255&t[s]:u(t,s);h<0?"-"==t.charAt(s)&&(o=!0):(o=!1,0==a?this[this.t++]=h:a+i>this.DB?(this[this.t-1]|=(h&(1<>this.DB-a):this[this.t-1]|=h<=this.DB&&(a-=this.DB))}8==i&&0!=(128&t[0])&&(this.s=-1,a>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==t;)--this.t},e.prototype.dlShiftTo=function(t,e){var r;for(r=this.t-1;r>=0;--r)e[r+t]=this[r];for(r=t-1;r>=0;--r)e[r]=0;e.t=this.t+t,e.s=this.s},e.prototype.drShiftTo=function(t,e){for(var r=t;r=0;--r)e[r+o+1]=this[r]>>i|a,a=(this[r]&s)<=0;--r)e[r]=0;e[o]=a,e.t=this.t+o+1,e.s=this.s,e.clamp()},e.prototype.rShiftTo=function(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var n=t%this.DB,i=this.DB-n,s=(1<>n;for(var o=r+1;o>n;n>0&&(e[this.t-r-1]|=(this.s&s)<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[r++]=this.DV+n:n>0&&(e[r++]=n),e.t=r,e.clamp()},e.prototype.multiplyTo=function(t,r){var n=this.abs(),i=t.abs(),s=n.t;for(r.t=s+i.t;--s>=0;)r[s]=0;for(s=0;s=0;)t[r]=0;for(r=0;r=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()},e.prototype.divRemTo=function(t,n,i){var s=t.abs();if(!(s.t<=0)){var o=this.abs();if(o.t0?(s.lShiftTo(l,a),o.lShiftTo(l,i)):(s.copyTo(a),o.copyTo(i));var c=a.t,d=a[c-1];if(0!=d){var p=d*(1<1?a[c-2]>>this.F2:0),_=this.FV/p,g=(1<=0&&(i[i.t++]=1,i.subTo(b,i)),e.ONE.dlShiftTo(c,b),b.subTo(a,a);a.t=0;){var w=i[--y]==d?this.DM:Math.floor(i[y]*_+(i[y-1]+m)*g);if((i[y]+=a.am(0,w,i,v,0,c))0&&i.rShiftTo(l,i),h<0&&e.ZERO.subTo(i,i)}}},e.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},e.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},e.prototype.exp=function(t,n){if(t>4294967295||t<1)return e.ONE;var i=r(),s=r(),o=n.convert(this),a=f(t)-1;for(o.copyTo(i);--a>=0;)if(n.sqrTo(i,s),(t&1<0)n.mulTo(s,o,i);else{var h=i;i=s,s=h}return n.revert(i)},e.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var r,n=(1<0)for(a>a)>0&&(i=!0,s=h(r));o>=0;)a>(a+=this.DB-e)):(r=this[o]>>(a-=e)&n,a<=0&&(a+=this.DB,--o)),r>0&&(i=!0),i&&(s+=h(r));return i?s:"0"},e.prototype.negate=function(){var t=r();return e.ZERO.subTo(this,t),t},e.prototype.abs=function(){return this.s<0?this.negate():this},e.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(0!=(e=r-t.t))return this.s<0?-e:e;for(;--r>=0;)if(0!=(e=this[r]-t[r]))return e;return 0},e.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+f(this[this.t-1]^this.s&this.DM)},e.prototype.mod=function(t){var n=r();return this.abs().divRemTo(t,null,n),this.s<0&&n.compareTo(e.ZERO)>0&&t.subTo(n,n),n},e.prototype.modPowInt=function(t,e){var r;return r=t<256||e.isEven()?new c(e):new d(e),this.exp(t,r)},e.ZERO=l(0),e.ONE=l(1),b.prototype.convert=w,b.prototype.revert=w,b.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r)},b.prototype.sqrTo=function(t,e){t.squareTo(e)},S.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=r();return t.copyTo(e),this.reduce(e),e},S.prototype.revert=function(t){return t},S.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},S.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},S.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var T,x,F,B=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],E=(1<<26)/B[B.length-1];function k(){var t;t=(new Date).getTime(),x[F++]^=255&t,x[F++]^=t>>8&255,x[F++]^=t>>16&255,x[F++]^=t>>24&255,F>=q&&(F-=q)}if(e.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},e.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),n=Math.pow(t,e),i=l(n),s=r(),o=r(),a="";for(this.divRemTo(i,s,o);s.signum()>0;)a=(n+o.intValue()).toString(t).substr(1)+a,s.divRemTo(i,s,o);return o.intValue().toString(t)+a},e.prototype.fromRadix=function(t,r){this.fromInt(0),null==r&&(r=10);for(var n=this.chunkSize(r),i=Math.pow(r,n),s=!1,o=0,a=0,h=0;h=n&&(this.dMultiply(i),this.dAddOffset(a,0),o=0,a=0))}o>0&&(this.dMultiply(Math.pow(r,o)),this.dAddOffset(a,0)),s&&e.ZERO.subTo(this,this)},e.prototype.fromNumber=function(t,r,n){if("number"==typeof r)if(t<2)this.fromInt(1);else for(this.fromNumber(t,n),this.testBit(t-1)||this.bitwiseTo(e.ONE.shiftLeft(t-1),_,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(r);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(e.ONE.shiftLeft(t-1),this);else{var i=new Array,s=7&t;i.length=1+(t>>3),r.nextBytes(i),s>0?i[0]&=(1<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e[r++]=n:n<-1&&(e[r++]=this.DV+n),e.t=r,e.clamp()},e.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},e.prototype.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},e.prototype.multiplyLowerTo=function(t,e,r){var n,i=Math.min(this.t+t.t,e);for(r.s=0,r.t=i;i>0;)r[--i]=0;for(n=r.t-this.t;i=0;)r[n]=0;for(n=Math.max(e-this.t,0);n0)if(0==e)r=this[0]%t;else for(var n=this.t-1;n>=0;--n)r=(e*r+this[n])%t;return r},e.prototype.millerRabin=function(t){var n=this.subtract(e.ONE),i=n.getLowestSetBit();if(i<=0)return!1;var s=n.shiftRight(i);(t=t+1>>1)>B.length&&(t=B.length);for(var o=r(),a=0;a>24},e.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},e.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},e.prototype.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var r,n=this.DB-t*this.DB%8,i=0;if(t-- >0)for(n>n)!=(this.s&this.DM)>>n&&(e[i++]=r|this.s<=0;)n<8?(r=(this[t]&(1<>(n+=this.DB-8)):(r=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),0!=(128&r)&&(r|=-256),0==i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(e[i++]=r);return e},e.prototype.equals=function(t){return 0==this.compareTo(t)},e.prototype.min=function(t){return this.compareTo(t)<0?this:t},e.prototype.max=function(t){return this.compareTo(t)>0?this:t},e.prototype.and=function(t){var e=r();return this.bitwiseTo(t,p,e),e},e.prototype.or=function(t){var e=r();return this.bitwiseTo(t,_,e),e},e.prototype.xor=function(t){var e=r();return this.bitwiseTo(t,g,e),e},e.prototype.andNot=function(t){var e=r();return this.bitwiseTo(t,m,e),e},e.prototype.not=function(){for(var t=r(),e=0;e=this.t?0!=this.s:0!=(this[e]&1<1){var _=r();for(i.sqrTo(a[1],_);h<=p;)a[h]=r(),i.mulTo(_,a[h-2],a[h]),h+=2}var g,m,y=t.t-1,v=!0,b=r();for(s=f(t[y])-1;y>=0;){for(s>=u?g=t[y]>>s-u&p:(g=(t[y]&(1<0&&(g|=t[y-1]>>this.DB+s-u)),h=n;0==(1&g);)g>>=1,--h;if((s-=h)<0&&(s+=this.DB,--y),v)a[g].copyTo(o),v=!1;else{for(;h>1;)i.sqrTo(o,b),i.sqrTo(b,o),h-=2;h>0?i.sqrTo(o,b):(m=o,o=b,b=m),i.mulTo(b,a[g],o)}for(;y>=0&&0==(t[y]&1<=0?(n.subTo(i,n),r&&s.subTo(a,s),o.subTo(h,o)):(i.subTo(n,i),r&&a.subTo(s,a),h.subTo(o,h))}return 0!=i.compareTo(e.ONE)?e.ZERO:h.compareTo(t)>=0?h.subtract(t):h.signum()<0?(h.addTo(t,h),h.signum()<0?h.add(t):h):h},e.prototype.pow=function(t){return this.exp(t,new b)},e.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var n=e;e=r,r=n}var i=e.getLowestSetBit(),s=r.getLowestSetBit();if(s<0)return e;for(i0&&(e.rShiftTo(s,e),r.rShiftTo(s,r));e.signum()>0;)(i=e.getLowestSetBit())>0&&e.rShiftTo(i,e),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return s>0&&r.lShiftTo(s,r),r},e.prototype.isProbablePrime=function(t){var e,r=this.abs();if(1==r.t&&r[0]<=B[B.length-1]){for(e=0;e>>8,x[F++]=255&D;F=0,k()}function I(){if(null==T){for(k(),(T=new O).init(x),F=0;F>>32-r}function o(t,e){for(var r=[],n=t.length-1;n>=0;n--)r[n]=255&(t[n]^e[n]);return r}function a(t){return t^s(t,9)^s(t,17)}function h(t){var e=8*t.length,r=e%512;r=r>=448?512-r%448-1:448-r-1;for(var o=new Array((r-7)/8),h=new Array(8),u=0,l=o.length;u=0;d--)if(e.length>8){var p=e.length-8;h[d]=parseInt(e.substr(p),2),e=e.substr(0,p)}else e.length>0&&(h[d]=parseInt(e,2),e="");for(var _,g=new Uint8Array([].concat(t,[128],o,h)),m=new DataView(g.buffer,0),y=g.length/64,v=new Uint32Array([1937774191,1226093241,388252375,3666478592,2842636476,372324522,3817729613,2969243214]),b=0;b=0&&Z<=15?2043430169:2055708042,q=(Z>=0&&Z<=15?B^E^k:B&E|B&k|E&k)+D+((O=s(s(B,12)+A+s(P,Z),7))^s(B,12))+i[Z],M=(Z>=0&&Z<=15?A^z^I:A&z|~A&I)+R+O+n[Z],D=k,k=s(E,9),E=B,B=q,R=I,I=s(z,19),z=A,A=a(M);v[0]^=B,v[1]^=E,v[2]^=k,v[3]^=D,v[4]^=A,v[5]^=z,v[6]^=I,v[7]^=R}for(var C=[],L=0,U=v.length;L>>24,(16711680&N)>>>16,(65280&N)>>>8,255&N)}return C}for(var u=64,l=new Uint8Array(u),f=new Uint8Array(u),c=0;cu&&(e=h(e));e.length2&&void 0!==arguments[2]?arguments[2]:"1234567812345678";r=a.utf8ToHex(r);var n=a.leftPad(l.curve.a.toBigInteger().toRadix(16),64),i=a.leftPad(l.curve.b.toBigInteger().toRadix(16),64),s=a.leftPad(l.getX().toBigInteger().toRadix(16),64),o=a.leftPad(l.getY().toBigInteger().toRadix(16),64),u=void 0,f=void 0;if(128===e.length)u=e.substr(0,64),f=e.substr(64,64);else{var c=l.curve.decodePointHex(e);u=a.leftPad(c.getX().toBigInteger().toRadix(16),64),f=a.leftPad(c.getY().toBigInteger().toRadix(16),64)}var d=a.hexToArray(r+n+i+s+o+u+f),p=4*r.length;d.unshift(255&p),d.unshift(p>>8&255);var _=h(d);return a.arrayToHex(h(_.concat(a.hexToArray(t))))}function _(){var t=a.generateKeyPairHex(),e=f.decodePointHex(t.publicKey);return t.k=new n(t.privateKey,16),t.x1=e.getX().toBigInteger(),t}t.exports={generateKeyPairHex:a.generateKeyPairHex,compressPublicKeyHex:a.compressPublicKeyHex,comparePublicKeyHex:a.comparePublicKeyHex,doEncrypt:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;t="string"==typeof t?a.hexToArray(a.utf8ToHex(t)):Array.prototype.slice.call(t),e=a.getGlobalCurve().decodePointHex(e);var i=a.generateKeyPairHex(),s=new n(i.privateKey,16),o=i.publicKey;o.length>128&&(o=o.substr(o.length-128));var u=e.multiply(s),l=a.hexToArray(a.leftPad(u.getX().toBigInteger().toRadix(16),64)),f=a.hexToArray(a.leftPad(u.getY().toBigInteger().toRadix(16),64)),c=a.arrayToHex(h([].concat(l,t,f))),p=1,_=0,g=[],m=[].concat(l,f),y=function(){g=h([].concat(m,[p>>24&255,p>>16&255,p>>8&255,255&p])),p++,_=0};y();for(var v=0,b=t.length;v2&&void 0!==arguments[2]?arguments[2]:1,i=(arguments.length>3&&void 0!==arguments[3]?arguments[3]:{}).output,s=void 0===i?"string":i;e=new n(e,16);var o=t.substr(128,64),u=t.substr(192);r===d&&(o=t.substr(t.length-64),u=t.substr(128,t.length-128-64));var l=a.hexToArray(u),f=a.getGlobalCurve().decodePointHex("04"+t.substr(0,128)).multiply(e),c=a.hexToArray(a.leftPad(f.getX().toBigInteger().toRadix(16),64)),p=a.hexToArray(a.leftPad(f.getY().toBigInteger().toRadix(16),64)),_=1,g=0,m=[],y=[].concat(c,p),v=function(){m=h([].concat(y,[_>>24&255,_>>16&255,_>>8&255,255&_])),_++,g=0};v();for(var b=0,w=l.length;b2&&void 0!==arguments[2]?arguments[2]:{},i=r.pointPool,o=r.der,h=r.hash,u=r.publicKey,f=r.userId,d="string"==typeof t?a.utf8ToHex(t):a.arrayToHex(t);h&&(d=p(d,u=u||function(t){var e=l.multiply(new n(t,16)),r=a.leftPad(e.getX().toBigInteger().toString(16),64),i=a.leftPad(e.getY().toBigInteger().toString(16),64);return"04"+r+i}(e),f));var g=new n(e,16),m=new n(d,16),y=null,v=null,b=null;do{do{var w=void 0;y=(w=i&&i.length?i.pop():_()).k,v=m.add(w.x1).mod(c)}while(v.equals(n.ZERO)||v.add(y).equals(c));b=g.add(n.ONE).modInverse(c).multiply(y.subtract(v.multiply(g))).mod(c)}while(b.equals(n.ZERO));return o?s(v,b):a.leftPad(v.toString(16),64)+a.leftPad(b.toString(16),64)},doVerifySignature:function(t,e,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},s=i.der,h=i.hash,u=i.userId,d="string"==typeof t?a.utf8ToHex(t):a.arrayToHex(t);h&&(d=p(d,r,u));var _=void 0,g=void 0;if(s){var m=o(e);_=m.r,g=m.s}else _=new n(e.substring(0,64),16),g=new n(e.substring(64),16);var y=f.decodePointHex(r),v=new n(d,16),b=_.add(g).mod(c);if(b.equals(n.ZERO))return!1;var w=l.multiply(g).add(y.multiply(b)),S=v.add(w.getX().toBigInteger()).mod(c);return _.equals(S)},getPoint:_,verifyPublicKey:a.verifyPublicKey,hexToArray:a.hexToArray}},function(t,e,r){function n(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function s(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var o=r(0).BigInteger;var a=function(){function t(){s(this,t),this.tlv=null,this.t="00",this.l="00",this.v=""}return t.prototype.getEncodedHex=function(){return this.tlv||(this.v=this.getValue(),this.l=this.getLength(),this.tlv=this.t+this.l+this.v),this.tlv},t.prototype.getLength=function(){var t=this.v.length/2,e=t.toString(16);return e.length%2==1&&(e="0"+e),t<128?e:(128+e.length/2).toString(16)+e},t.prototype.getValue=function(){return""},t}(),h=function(t){function e(r){s(this,e);var i=n(this,t.call(this));return i.t="02",r&&(i.v=function(t){var e=t.toString(16);if("-"!==e[0])e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e);else{var r=(e=e.substr(1)).length;r%2==1?r+=1:e.match(/^[0-7]/)||(r+=2);for(var n="",i=0;i=e?t:new Array(e-t.length+1).join("0")+t}t.exports={getGlobalCurve:function(){return u},generateEcparam:c,generateKeyPairHex:function(t,e,r){var n=(t?new i(t,e,r):new i(f.bitLength(),a)).mod(f.subtract(i.ONE)).add(i.ONE),s=d(n.toString(16),64),o=l.multiply(n);return{privateKey:s,publicKey:"04"+d(o.getX().toBigInteger().toString(16),64)+d(o.getY().toBigInteger().toString(16),64)}},compressPublicKeyHex:function(t){if(130!==t.length)throw new Error("Invalid public key to compress");var e=(t.length-2)/2,r=t.substr(2,e),n="03";return new i(t.substr(e+2,e),16).mod(new i("2")).equals(i.ZERO)&&(n="02"),n+r},utf8ToHex:function(t){for(var e=(t=unescape(encodeURIComponent(t))).length,r=[],n=0;n>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;for(var i=[],s=0;s>>2]>>>24-s%4*8&255;i.push((o>>>4).toString(16)),i.push((15&o).toString(16))}return i.join("")},leftPad:d,arrayToHex:function(t){return t.map(function(t){return 1===(t=t.toString(16)).length?"0"+t:t}).join("")},arrayToUtf8:function(t){for(var e=[],r=0,n=0;n<2*t.length;n+=2)e[n>>>3]|=parseInt(t[r],10)<<24-n%8*4,r++;try{for(var i=[],s=0;s>>2]>>>24-s%4*8&255;i.push(String.fromCharCode(o))}return decodeURIComponent(escape(i.join("")))}catch(t){throw new Error("Malformed UTF-8 data")}},hexToArray:function(t){var e=[],r=t.length;r%2!=0&&(t=d(t,r+1)),r=t.length;for(var n=0;n0;i--){n=n.twice();var s=e.testBit(i);s!==t.testBit(i)&&(n=n.add(s?this:r))}return n},t}(),u=function(){function t(e,r,i){n(this,t),this.q=e,this.a=this.fromBigInteger(r),this.b=this.fromBigInteger(i),this.infinity=new h(this,null,null)}return t.prototype.equals=function(t){return t===this||this.q.equals(t.q)&&this.a.equals(t.a)&&this.b.equals(t.b)},t.prototype.fromBigInteger=function(t){return new a(this.q,t)},t.prototype.decodePointHex=function(t){switch(parseInt(t.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:var e=this.fromBigInteger(new i(t.substr(2),16)),r=this.fromBigInteger(e.multiply(e.square()).add(e.multiply(this.a)).add(this.b).toBigInteger().modPow(this.q.divide(new i("4")).add(i.ONE),this.q));return r.toBigInteger().mod(s).equals(new i(t.substr(0,2),16).subtract(s))||(r=r.negate()),new h(this,e,r);case 4:case 6:case 7:var n=(t.length-2)/2,o=t.substr(2,n),a=t.substr(n+2,n);return new h(this,this.fromBigInteger(new i(o,16)),this.fromBigInteger(new i(a,16)));default:return null}},t}();t.exports={ECPointFp:h,ECCurveFp:u}},function(t,e,r){var n=r(1),i=n.sm3,s=n.hmac;function o(t){return t.map(function(t){return 1===(t=t.toString(16)).length?"0"+t:t}).join("")}function a(t){var e,r,n=[],i=t.length;i%2!=0&&(r=i+1,t=(e=t).length>=r?e:new Array(r-e.length+1).join("0")+e),i=t.length;for(var s=0;s>>6),e.push(128|63&i);else if(i<=55295||i>=57344&&i<=65535)e.push(224|i>>>12),e.push(128|i>>>6&63),e.push(128|63&i);else{if(!(i>=65536&&i<=1114111))throw e.push(i),new Error("input is not supported");r++,e.push(240|i>>>18&28),e.push(128|i>>>12&63),e.push(128|i>>>6&63),e.push(128|63&i)}}return e}(t):Array.prototype.slice.call(t),e){if("hmac"!==(e.mode||"hmac"))throw new Error("invalid mode");var r=e.key;if(!r)throw new Error("invalid key");return r="string"==typeof r?a(r):Array.prototype.slice.call(r),o(s(t,r))}return o(i(t))}},function(t,e,r){var n=0,i=32,s=16,o=[214,144,233,254,204,225,61,183,22,182,20,194,40,251,44,5,43,103,154,118,42,190,4,195,170,68,19,38,73,134,6,153,156,66,80,244,145,239,152,122,51,84,11,67,237,207,172,98,228,179,28,169,201,8,232,149,128,223,148,250,117,143,63,166,71,7,167,252,243,115,23,186,131,89,60,25,230,133,79,168,104,107,129,178,113,100,218,139,248,235,15,75,112,86,157,53,30,36,14,94,99,88,209,162,37,34,124,59,1,33,120,135,212,0,70,87,159,211,39,82,76,54,2,231,160,196,200,158,234,191,138,210,64,199,56,181,163,247,242,206,249,97,21,161,224,174,93,164,155,52,26,85,173,147,50,48,245,140,177,227,29,246,226,46,130,102,202,96,192,41,35,171,13,83,78,111,213,219,55,69,222,253,142,47,3,255,106,114,109,108,91,81,141,27,175,146,187,221,188,127,17,217,92,65,31,16,90,216,10,193,49,136,165,205,123,189,45,116,208,18,184,229,180,176,137,105,151,74,12,150,119,126,101,185,241,9,197,110,198,132,24,240,125,236,58,220,77,32,121,238,95,62,215,203,57,72],a=[462357,472066609,943670861,1415275113,1886879365,2358483617,2830087869,3301692121,3773296373,4228057617,404694573,876298825,1347903077,1819507329,2291111581,2762715833,3234320085,3705924337,4177462797,337322537,808926789,1280531041,1752135293,2223739545,2695343797,3166948049,3638552301,4110090761,269950501,741554753,1213159005,1684763257];function h(t){for(var e=[],r=0,n=t.length;r>>32-r}function l(t){return(255&o[t>>>24&255])<<24|(255&o[t>>>16&255])<<16|(255&o[t>>>8&255])<<8|255&o[255&t]}function f(t){return t^u(t,2)^u(t,10)^u(t,18)^u(t,24)}function c(t){return t^u(t,13)^u(t,23)}function d(t,e,r){for(var n=new Array(4),i=new Array(4),s=0;s<4;s++)i[0]=255&t[4*s],i[1]=255&t[4*s+1],i[2]=255&t[4*s+2],i[3]=255&t[4*s+3],n[s]=i[0]<<24|i[1]<<16|i[2]<<8|i[3];for(var o,a=0;a<32;a+=4)o=n[1]^n[2]^n[3]^r[a+0],n[0]^=f(l(o)),o=n[2]^n[3]^n[0]^r[a+1],n[1]^=f(l(o)),o=n[3]^n[0]^n[1]^r[a+2],n[2]^=f(l(o)),o=n[0]^n[1]^n[2]^r[a+3],n[3]^=f(l(o));for(var h=0;h<16;h+=4)e[h]=n[3-h/4]>>>24&255,e[h+1]=n[3-h/4]>>>16&255,e[h+2]=n[3-h/4]>>>8&255,e[h+3]=255&n[3-h/4]}function p(t,e,r){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},u=o.padding,f=void 0===u?"pkcs#7":u,p=o.mode,_=o.iv,g=void 0===_?[]:_,m=o.output,y=void 0===m?"string":m;if("cbc"===p&&("string"==typeof g&&(g=h(g)),16!==g.length))throw new Error("iv is invalid");if("string"==typeof e&&(e=h(e)),16!==e.length)throw new Error("key is invalid");if(t="string"==typeof t?r!==n?function(t){for(var e=[],r=0,n=t.length;r>>6),e.push(128|63&i);else if(i<=55295||i>=57344&&i<=65535)e.push(224|i>>>12),e.push(128|i>>>6&63),e.push(128|63&i);else{if(!(i>=65536&&i<=1114111))throw e.push(i),new Error("input is not supported");r++,e.push(240|i>>>18&28),e.push(128|i>>>12&63),e.push(128|i>>>6&63),e.push(128|63&i)}}return e}(t):h(t):[].concat(t),("pkcs#5"===f||"pkcs#7"===f)&&r!==n)for(var v=s-t.length%s,b=0;b=s;){var B=t.slice(F,F+16),E=new Array(16);if("cbc"===p)for(var k=0;k=240&&t[r]<=247?(e.push(String.fromCodePoint(((7&t[r])<<18)+((63&t[r+1])<<12)+((63&t[r+2])<<6)+(63&t[r+3]))),r+=3):t[r]>=224&&t[r]<=239?(e.push(String.fromCodePoint(((15&t[r])<<12)+((63&t[r+1])<<6)+(63&t[r+2]))),r+=2):t[r]>=192&&t[r]<=223?(e.push(String.fromCodePoint(((31&t[r])<<6)+(63&t[r+1]))),r++):e.push(String.fromCodePoint(t[r]));return e.join("")}(S):S}t.exports={encrypt:function(t,e,r){return p(t,e,1,r)},decrypt:function(t,e,r){return p(t,e,0,r)}}}]};function buildSMModule(){return sm(getSmBuildArgs())}function getPako(){function t(t){for(var e=t.length;--e>=0;)t[e]=0}var e=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),r=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),n=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),i=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),s=new Array(576);t(s);var o=new Array(60);t(o);var a=new Array(512);t(a);var h=new Array(256);t(h);var u=new Array(29);t(u);var l,f,c,d=new Array(30);function p(t,e,r,n,i){this.static_tree=t,this.extra_bits=e,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=t&&t.length}function _(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}t(d);var g=function(t){return t<256?a[t]:a[256+(t>>>7)]},m=function(t,e){t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},y=function(t,e,r){t.bi_valid>16-r?(t.bi_buf|=e<>16-t.bi_valid,t.bi_valid+=r-16):(t.bi_buf|=e<>>=1,r<<=1}while(--e>0);return r>>>1},w=function(t,e,r){var n,i,s=new Array(16),o=0;for(n=1;n<=15;n++)o=o+r[n-1]<<1,s[n]=o;for(i=0;i<=e;i++){var a=t[2*i+1];0!==a&&(t[2*i]=b(s[a]++,a))}},S=function(t){var e;for(e=0;e<286;e++)t.dyn_ltree[2*e]=0;for(e=0;e<30;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.sym_next=t.matches=0},T=function(t){t.bi_valid>8?m(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},x=function(t,e,r,n){var i=2*e,s=2*r;return t[i]>1;r>=1;r--)F(t,s,r);i=h;do{r=t.heap[1],t.heap[1]=t.heap[t.heap_len--],F(t,s,1),n=t.heap[1],t.heap[--t.heap_max]=r,t.heap[--t.heap_max]=n,s[2*i]=s[2*r]+s[2*n],t.depth[i]=(t.depth[r]>=t.depth[n]?t.depth[r]:t.depth[n])+1,s[2*r+1]=s[2*n+1]=i,t.heap[1]=i++,F(t,s,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],function(t,e){var r,n,i,s,o,a,h=e.dyn_tree,u=e.max_code,l=e.stat_desc.static_tree,f=e.stat_desc.has_stree,c=e.stat_desc.extra_bits,d=e.stat_desc.extra_base,p=e.stat_desc.max_length,_=0;for(s=0;s<=15;s++)t.bl_count[s]=0;for(h[2*t.heap[t.heap_max]+1]=0,r=t.heap_max+1;r<573;r++)(s=h[2*h[2*(n=t.heap[r])+1]+1]+1)>p&&(s=p,_++),h[2*n+1]=s,n>u||(t.bl_count[s]++,o=0,n>=d&&(o=c[n-d]),a=h[2*n],t.opt_len+=a*(s+o),f&&(t.static_len+=a*(l[2*n+1]+o)));if(0!==_){do{for(s=p-1;0===t.bl_count[s];)s--;t.bl_count[s]--,t.bl_count[s+1]+=2,t.bl_count[p]--,_-=2}while(_>0);for(s=p;0!==s;s--)for(n=t.bl_count[s];0!==n;)(i=t.heap[--r])>u||(h[2*i+1]!==s&&(t.opt_len+=(s-h[2*i+1])*h[2*i],h[2*i+1]=s),n--)}}(t,e),w(s,u,t.bl_count)},k=function(t,e,r){var n,i,s=-1,o=e[1],a=0,h=7,u=4;for(0===o&&(h=138,u=3),e[2*(r+1)+1]=65535,n=0;n<=r;n++)i=o,o=e[2*(n+1)+1],++a>=7;g<30;g++)for(d[g]=m<<7,t=0;t<1<0?(2===t.strm.data_type&&(t.strm.data_type=function(t){var e,r=4093624447;for(e=0;e<=31;e++,r>>>=1)if(1&r&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<256;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0}(t)),E(t,t.l_desc),E(t,t.d_desc),u=function(t){var e;for(k(t,t.dyn_ltree,t.l_desc.max_code),k(t,t.dyn_dtree,t.d_desc.max_code),E(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*i[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e}(t),a=t.opt_len+3+7>>>3,(h=t.static_len+3+7>>>3)<=a&&(a=h)):a=h=r+5,r+4<=a&&-1!==e?z(t,e,r,n):4===t.strategy||h===a?(y(t,2+(n?1:0),3),B(t,s,o)):(y(t,4+(n?1:0),3),function(t,e,r,n){var s;for(y(t,e-257,5),y(t,r-1,5),y(t,n-4,4),s=0;s>8,t.pending_buf[t.sym_buf+t.sym_next++]=r,0===e?t.dyn_ltree[2*r]++:(t.matches++,e--,t.dyn_ltree[2*(h[r]+256+1)]++,t.dyn_dtree[2*g(e)]++),t.sym_next===t.sym_end},_tr_align:function(t){y(t,2,3),v(t,256,s),function(t){16===t.bi_valid?(m(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}(t)}},R=function(t,e,r,n){for(var i=65535&t|0,s=t>>>16&65535|0,o=0;0!==r;){r-=o=r>2e3?2e3:r;do{s=s+(i=i+e[n++]|0)|0}while(--o);i%=65521,s%=65521}return i|s<<16|0},O=new Uint32Array(function(){for(var t,e=[],r=0;r<256;r++){t=r;for(var n=0;n<8;n++)t=1&t?3988292384^t>>>1:t>>>1;e[r]=t}return e}()),q=function(t,e,r,n){var i=O,s=n+r;t^=-1;for(var o=n;o>>8^i[255&(t^e[o])];return-1^t},M={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},P={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},Z=I._tr_init,C=I._tr_stored_block,L=I._tr_flush_block,U=I._tr_tally,N=I._tr_align,H=P.Z_NO_FLUSH,j=P.Z_PARTIAL_FLUSH,K=P.Z_FULL_FLUSH,V=P.Z_FINISH,Y=P.Z_BLOCK,X=P.Z_OK,G=P.Z_STREAM_END,J=P.Z_STREAM_ERROR,W=P.Z_DATA_ERROR,$=P.Z_BUF_ERROR,Q=P.Z_DEFAULT_COMPRESSION,tt=P.Z_FILTERED,et=P.Z_HUFFMAN_ONLY,rt=P.Z_RLE,nt=P.Z_FIXED,it=P.Z_DEFAULT_STRATEGY,st=P.Z_UNKNOWN,ot=P.Z_DEFLATED,at=286,ht=30,ut=19,lt=2*at+1,ft=15,ct=function(t,e){return t.msg=M[e],e},dt=function(t){return 2*t-(t>4?9:0)},pt=function(t){for(var e=t.length;--e>=0;)t[e]=0},_t=function(t){var e,r,n,i=t.w_size;n=e=t.hash_size;do{r=t.head[--n],t.head[n]=r>=i?r-i:0}while(--e);n=e=i;do{r=t.prev[--n],t.prev[n]=r>=i?r-i:0}while(--e)},gt=function(t,e,r){return(e<t.avail_out&&(r=t.avail_out),0!==r&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+r),t.next_out),t.next_out+=r,e.pending_out+=r,t.total_out+=r,t.avail_out-=r,e.pending-=r,0===e.pending&&(e.pending_out=0))},yt=function(t,e){L(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,mt(t.strm)},vt=function(t,e){t.pending_buf[t.pending++]=e},bt=function(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},wt=function(t,e,r,n){var i=t.avail_in;return i>n&&(i=n),0===i?0:(t.avail_in-=i,e.set(t.input.subarray(t.next_in,t.next_in+i),r),1===t.state.wrap?t.adler=R(t.adler,e,i,r):2===t.state.wrap&&(t.adler=q(t.adler,e,i,r)),t.next_in+=i,t.total_in+=i,i)},St=function(t,e){var r,n,i=t.max_chain_length,s=t.strstart,o=t.prev_length,a=t.nice_match,h=t.strstart>t.w_size-262?t.strstart-(t.w_size-262):0,u=t.window,l=t.w_mask,f=t.prev,c=t.strstart+258,d=u[s+o-1],p=u[s+o];t.prev_length>=t.good_match&&(i>>=2),a>t.lookahead&&(a=t.lookahead);do{if(u[(r=e)+o]===p&&u[r+o-1]===d&&u[r]===u[s]&&u[++r]===u[s+1]){s+=2,r++;do{}while(u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&so){if(t.match_start=e,o=n,n>=a)break;d=u[s+o-1],p=u[s+o]}}}while((e=f[e&l])>h&&0!=--i);return o<=t.lookahead?o:t.lookahead},Tt=function(t){var e,r,n,i=t.w_size;do{if(r=t.window_size-t.lookahead-t.strstart,t.strstart>=i+(i-262)&&(t.window.set(t.window.subarray(i,i+i-r),0),t.match_start-=i,t.strstart-=i,t.block_start-=i,t.insert>t.strstart&&(t.insert=t.strstart),_t(t),r+=i),0===t.strm.avail_in)break;if(e=wt(t.strm,t.window,t.strstart+t.lookahead,r),t.lookahead+=e,t.lookahead+t.insert>=3)for(n=t.strstart-t.insert,t.ins_h=t.window[n],t.ins_h=gt(t,t.ins_h,t.window[n+1]);t.insert&&(t.ins_h=gt(t,t.ins_h,t.window[n+3-1]),t.prev[n&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=n,n++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<262&&0!==t.strm.avail_in)},xt=function(t,e){var r,n,i,s=t.pending_buf_size-5>t.w_size?t.w_size:t.pending_buf_size-5,o=0,a=t.strm.avail_in;do{if(r=65535,i=t.bi_valid+42>>3,t.strm.avail_out(n=t.strstart-t.block_start)+t.strm.avail_in&&(r=n+t.strm.avail_in),r>i&&(r=i),r>8,t.pending_buf[t.pending-2]=~r,t.pending_buf[t.pending-1]=~r>>8,mt(t.strm),n&&(n>r&&(n=r),t.strm.output.set(t.window.subarray(t.block_start,t.block_start+n),t.strm.next_out),t.strm.next_out+=n,t.strm.avail_out-=n,t.strm.total_out+=n,t.block_start+=n,r-=n),r&&(wt(t.strm,t.strm.output,t.strm.next_out,r),t.strm.next_out+=r,t.strm.avail_out-=r,t.strm.total_out+=r)}while(0===o);return(a-=t.strm.avail_in)&&(a>=t.w_size?(t.matches=2,t.window.set(t.strm.input.subarray(t.strm.next_in-t.w_size,t.strm.next_in),0),t.strstart=t.w_size,t.insert=t.strstart):(t.window_size-t.strstart<=a&&(t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,t.insert>t.strstart&&(t.insert=t.strstart)),t.window.set(t.strm.input.subarray(t.strm.next_in-a,t.strm.next_in),t.strstart),t.strstart+=a,t.insert+=a>t.w_size-t.insert?t.w_size-t.insert:a),t.block_start=t.strstart),t.high_wateri&&t.block_start>=t.w_size&&(t.block_start-=t.w_size,t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,i+=t.w_size,t.insert>t.strstart&&(t.insert=t.strstart)),i>t.strm.avail_in&&(i=t.strm.avail_in),i&&(wt(t.strm,t.window,t.strstart,i),t.strstart+=i,t.insert+=i>t.w_size-t.insert?t.w_size-t.insert:i),t.high_water>3,s=(i=t.pending_buf_size-i>65535?65535:t.pending_buf_size-i)>t.w_size?t.w_size:i,((n=t.strstart-t.block_start)>=s||(n||e===V)&&e!==H&&0===t.strm.avail_in&&n<=i)&&(r=n>i?i:n,o=e===V&&0===t.strm.avail_in&&r===n?1:0,C(t,t.block_start,r,o),t.block_start+=r,mt(t.strm)),o?3:1)},Ft=function(t,e){for(var r,n;;){if(t.lookahead<262){if(Tt(t),t.lookahead<262&&e===H)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=gt(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==r&&t.strstart-r<=t.w_size-262&&(t.match_length=St(t,r)),t.match_length>=3)if(n=U(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=gt(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=gt(t,t.ins_h,t.window[t.strstart+1]);else n=U(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(n&&(yt(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===V?(yt(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(yt(t,!1),0===t.strm.avail_out)?1:2},Bt=function(t,e){for(var r,n,i;;){if(t.lookahead<262){if(Tt(t),t.lookahead<262&&e===H)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=gt(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==r&&t.prev_length4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){i=t.strstart+t.lookahead-3,n=U(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=i&&(t.ins_h=gt(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,n&&(yt(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if((n=U(t,0,t.window[t.strstart-1]))&&yt(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(n=U(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===V?(yt(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(yt(t,!1),0===t.strm.avail_out)?1:2};function Et(t,e,r,n,i){this.good_length=t,this.max_lazy=e,this.nice_length=r,this.max_chain=n,this.func=i}var kt=[new Et(0,0,0,0,xt),new Et(4,4,8,4,Ft),new Et(4,5,16,8,Ft),new Et(4,6,32,32,Ft),new Et(4,4,16,16,Bt),new Et(8,16,32,32,Bt),new Et(8,16,128,128,Bt),new Et(8,32,128,256,Bt),new Et(32,128,258,1024,Bt),new Et(32,258,258,4096,Bt)];function Dt(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=ot,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(2*lt),this.dyn_dtree=new Uint16Array(2*(2*ht+1)),this.bl_tree=new Uint16Array(2*(2*ut+1)),pt(this.dyn_ltree),pt(this.dyn_dtree),pt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(ft+1),this.heap=new Uint16Array(2*at+1),pt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*at+1),pt(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}var At=function(t){if(!t)return 1;var e=t.state;return!e||e.strm!==t||42!==e.status&&57!==e.status&&69!==e.status&&73!==e.status&&91!==e.status&&103!==e.status&&113!==e.status&&666!==e.status?1:0},zt=function(t){if(At(t))return ct(t,J);t.total_in=t.total_out=0,t.data_type=st;var e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=2===e.wrap?57:e.wrap?42:113,t.adler=2===e.wrap?0:1,e.last_flush=-2,Z(e),X},It=function(t){var e,r=zt(t);return r===X&&((e=t.state).window_size=2*e.w_size,pt(e.head),e.max_lazy_match=kt[e.level].max_lazy,e.good_match=kt[e.level].good_length,e.nice_match=kt[e.level].nice_length,e.max_chain_length=kt[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=2,e.match_available=0,e.ins_h=0),r},Rt=function(t,e,r,n,i,s){if(!t)return J;var o=1;if(e===Q&&(e=6),n<0?(o=0,n=-n):n>15&&(o=2,n-=16),i<1||i>9||r!==ot||n<8||n>15||e<0||e>9||s<0||s>nt||8===n&&1!==o)return ct(t,J);8===n&&(n=9);var a=new Dt;return t.state=a,a.strm=t,a.status=42,a.wrap=o,a.gzhead=null,a.w_bits=n,a.w_size=1<Y||e<0)return t?ct(t,J):J;var r=t.state;if(!t.output||0!==t.avail_in&&!t.input||666===r.status&&e!==V)return ct(t,0===t.avail_out?$:J);var n=r.last_flush;if(r.last_flush=e,0!==r.pending){if(mt(t),0===t.avail_out)return r.last_flush=-1,X}else if(0===t.avail_in&&dt(e)<=dt(n)&&e!==V)return ct(t,$);if(666===r.status&&0!==t.avail_in)return ct(t,$);if(42===r.status&&0===r.wrap&&(r.status=113),42===r.status){var i=ot+(r.w_bits-8<<4)<<8;if(i|=(r.strategy>=et||r.level<2?0:r.level<6?1:6===r.level?2:3)<<6,0!==r.strstart&&(i|=32),bt(r,i+=31-i%31),0!==r.strstart&&(bt(r,t.adler>>>16),bt(r,65535&t.adler)),t.adler=1,r.status=113,mt(t),0!==r.pending)return r.last_flush=-1,X}if(57===r.status)if(t.adler=0,vt(r,31),vt(r,139),vt(r,8),r.gzhead)vt(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),vt(r,255&r.gzhead.time),vt(r,r.gzhead.time>>8&255),vt(r,r.gzhead.time>>16&255),vt(r,r.gzhead.time>>24&255),vt(r,9===r.level?2:r.strategy>=et||r.level<2?4:0),vt(r,255&r.gzhead.os),r.gzhead.extra&&r.gzhead.extra.length&&(vt(r,255&r.gzhead.extra.length),vt(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(t.adler=q(t.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=69;else if(vt(r,0),vt(r,0),vt(r,0),vt(r,0),vt(r,0),vt(r,9===r.level?2:r.strategy>=et||r.level<2?4:0),vt(r,3),r.status=113,mt(t),0!==r.pending)return r.last_flush=-1,X;if(69===r.status){if(r.gzhead.extra){for(var s=r.pending,o=(65535&r.gzhead.extra.length)-r.gzindex;r.pending+o>r.pending_buf_size;){var a=r.pending_buf_size-r.pending;if(r.pending_buf.set(r.gzhead.extra.subarray(r.gzindex,r.gzindex+a),r.pending),r.pending=r.pending_buf_size,r.gzhead.hcrc&&r.pending>s&&(t.adler=q(t.adler,r.pending_buf,r.pending-s,s)),r.gzindex+=a,mt(t),0!==r.pending)return r.last_flush=-1,X;s=0,o-=a}var h=new Uint8Array(r.gzhead.extra);r.pending_buf.set(h.subarray(r.gzindex,r.gzindex+o),r.pending),r.pending+=o,r.gzhead.hcrc&&r.pending>s&&(t.adler=q(t.adler,r.pending_buf,r.pending-s,s)),r.gzindex=0}r.status=73}if(73===r.status){if(r.gzhead.name){var u,l=r.pending;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>l&&(t.adler=q(t.adler,r.pending_buf,r.pending-l,l)),mt(t),0!==r.pending)return r.last_flush=-1,X;l=0}u=r.gzindexl&&(t.adler=q(t.adler,r.pending_buf,r.pending-l,l)),r.gzindex=0}r.status=91}if(91===r.status){if(r.gzhead.comment){var f,c=r.pending;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>c&&(t.adler=q(t.adler,r.pending_buf,r.pending-c,c)),mt(t),0!==r.pending)return r.last_flush=-1,X;c=0}f=r.gzindexc&&(t.adler=q(t.adler,r.pending_buf,r.pending-c,c))}r.status=103}if(103===r.status){if(r.gzhead.hcrc){if(r.pending+2>r.pending_buf_size&&(mt(t),0!==r.pending))return r.last_flush=-1,X;vt(r,255&t.adler),vt(r,t.adler>>8&255),t.adler=0}if(r.status=113,mt(t),0!==r.pending)return r.last_flush=-1,X}if(0!==t.avail_in||0!==r.lookahead||e!==H&&666!==r.status){var d=0===r.level?xt(r,e):r.strategy===et?function(t,e){for(var r;;){if(0===t.lookahead&&(Tt(t),0===t.lookahead)){if(e===H)return 1;break}if(t.match_length=0,r=U(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,r&&(yt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===V?(yt(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(yt(t,!1),0===t.strm.avail_out)?1:2}(r,e):r.strategy===rt?function(t,e){for(var r,n,i,s,o=t.window;;){if(t.lookahead<=258){if(Tt(t),t.lookahead<=258&&e===H)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(n=o[i=t.strstart-1])===o[++i]&&n===o[++i]&&n===o[++i]){s=t.strstart+258;do{}while(n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&it.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(r=U(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(r=U(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),r&&(yt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===V?(yt(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(yt(t,!1),0===t.strm.avail_out)?1:2}(r,e):kt[r.level].func(r,e);if(3!==d&&4!==d||(r.status=666),1===d||3===d)return 0===t.avail_out&&(r.last_flush=-1),X;if(2===d&&(e===j?N(r):e!==Y&&(C(r,0,0,!1),e===K&&(pt(r.head),0===r.lookahead&&(r.strstart=0,r.block_start=0,r.insert=0))),mt(t),0===t.avail_out))return r.last_flush=-1,X}return e!==V?X:r.wrap<=0?G:(2===r.wrap?(vt(r,255&t.adler),vt(r,t.adler>>8&255),vt(r,t.adler>>16&255),vt(r,t.adler>>24&255),vt(r,255&t.total_in),vt(r,t.total_in>>8&255),vt(r,t.total_in>>16&255),vt(r,t.total_in>>24&255)):(bt(r,t.adler>>>16),bt(r,65535&t.adler)),mt(t),r.wrap>0&&(r.wrap=-r.wrap),0!==r.pending?X:G)},deflateEnd:function(t){if(At(t))return J;var e=t.state.status;return t.state=null,113===e?ct(t,W):X},deflateSetDictionary:function(t,e){var r=e.length;if(At(t))return J;var n=t.state,i=n.wrap;if(2===i||1===i&&42!==n.status||n.lookahead)return J;if(1===i&&(t.adler=R(t.adler,e,r,0)),n.wrap=0,r>=n.w_size){0===i&&(pt(n.head),n.strstart=0,n.block_start=0,n.insert=0);var s=new Uint8Array(n.w_size);s.set(e.subarray(r-n.w_size,r),0),e=s,r=n.w_size}var o=t.avail_in,a=t.next_in,h=t.input;for(t.avail_in=r,t.next_in=0,t.input=e,Tt(n);n.lookahead>=3;){var u=n.strstart,l=n.lookahead-2;do{n.ins_h=gt(n,n.ins_h,n.window[u+3-1]),n.prev[u&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=u,u++}while(--l);n.strstart=u,n.lookahead=2,Tt(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,t.next_in=a,t.input=h,t.avail_in=o,n.wrap=i,X},deflateInfo:"pako deflate (from Nodeca project)"};function qt(t){return(qt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var Mt=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},Pt={assign:function(t){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var r=e.shift();if(r){if("object"!==qt(r))throw new TypeError(r+"must be non-object");for(var n in r)Mt(r,n)&&(t[n]=r[n])}}return t},flattenChunks:function(t){for(var e=0,r=0,n=t.length;r=252?6:Lt>=248?5:Lt>=240?4:Lt>=224?3:Lt>=192?2:1;Ct[254]=Ct[254]=1;var Ut={string2buf:function(t){if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);var e,r,n,i,s,o=t.length,a=0;for(i=0;i>>6,e[s++]=128|63&r):r<65536?(e[s++]=224|r>>>12,e[s++]=128|r>>>6&63,e[s++]=128|63&r):(e[s++]=240|r>>>18,e[s++]=128|r>>>12&63,e[s++]=128|r>>>6&63,e[s++]=128|63&r);return e},buf2string:function(t,e){var r,n,i=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));var s=new Array(2*i);for(n=0,r=0;r4)s[n++]=65533,r+=a-1;else{for(o&=2===a?31:3===a?15:7;a>1&&r1?s[n++]=65533:o<65536?s[n++]=o:(o-=65536,s[n++]=55296|o>>10&1023,s[n++]=56320|1023&o)}}}return function(t,e){if(e<65534&&t.subarray&&Zt)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));for(var r="",n=0;nt.length&&(e=t.length);for(var r=e-1;r>=0&&128==(192&t[r]);)r--;return r<0?e:0===r?e:r+Ct[t[r]]>e?r:e}};var Nt=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0},Ht=Object.prototype.toString,jt=P.Z_NO_FLUSH,Kt=P.Z_SYNC_FLUSH,Vt=P.Z_FULL_FLUSH,Yt=P.Z_FINISH,Xt=P.Z_OK,Gt=P.Z_STREAM_END,Jt=P.Z_DEFAULT_COMPRESSION,Wt=P.Z_DEFAULT_STRATEGY,$t=P.Z_DEFLATED;function Qt(t){this.options=Pt.assign({level:Jt,method:$t,chunkSize:16384,windowBits:15,memLevel:8,strategy:Wt},t||{});var e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Nt,this.strm.avail_out=0;var r=Ot.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(r!==Xt)throw new Error(M[r]);if(e.header&&Ot.deflateSetHeader(this.strm,e.header),e.dictionary){var n;if(n="string"==typeof e.dictionary?Ut.string2buf(e.dictionary):"[object ArrayBuffer]"===Ht.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,(r=Ot.deflateSetDictionary(this.strm,n))!==Xt)throw new Error(M[r]);this._dict_set=!0}}function te(t,e){var r=new Qt(e);if(r.push(t,!0),r.err)throw r.msg||M[r.err];return r.result}return Qt.prototype.push=function(t,e){var r,n,i=this.strm,s=this.options.chunkSize;if(this.ended)return!1;for(n=e===~~e?e:!0===e?Yt:jt,"string"==typeof t?i.input=Ut.string2buf(t):"[object ArrayBuffer]"===Ht.call(t)?i.input=new Uint8Array(t):i.input=t,i.next_in=0,i.avail_in=i.input.length;;)if(0===i.avail_out&&(i.output=new Uint8Array(s),i.next_out=0,i.avail_out=s),(n===Kt||n===Vt)&&i.avail_out<=6)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else{if((r=Ot.deflate(i,n))===Gt)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),r=Ot.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===Xt;if(0!==i.avail_out){if(n>0&&i.next_out>0)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else if(0===i.avail_in)break}else this.onData(i.output)}return!0},Qt.prototype.onData=function(t){this.chunks.push(t)},Qt.prototype.onEnd=function(t){t===Xt&&(this.result=Pt.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg},{Deflate:Qt,deflate:te,deflateRaw:function(t,e){return(e=e||{}).raw=!0,te(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,te(t,e)},constants:P}}var sm2,sm4,hexToArray,sm4key,encryptedSm4Key,iv,oldSingleEncoder,oldBatchSender,_this,_sa,_,_config,pako,base={plugin_version:"1.19.12"};function createPlugin(t){if("object"==typeof t&&"string"==typeof t.plugin_name&&""!==t.plugin_name)return t.plugin_version=base.plugin_version,t.log=t.log||function(){"object"==typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)},t;"object"==typeof console&&"function"==typeof console.error&&console.error('plugin must contain proprerty "plugin_name"')}function getStorage(t){return new Promise(function(e){wx.getStorage({key:t,complete:function(t){e(t&&t.data)}})})}function saveStorage(t,e){return new Promise(function(r){wx.setStorage({key:t,data:e,success:function(){r(!0)},fail:function(){r(!1)}})})}var signalBatchSenderReady,encDataStoreName="sensors_mp_encrypted_data";function get128RandomByte(t){t=t||16;for(var e="";t-- >0;){var r=Math.ceil(255*_.getRandom()).toString(16);e+=2===r.length?r:"0"+r}return e}function matchType(t,e,r){return typeof t===r||(_this.log(e+" must be "+r),!1)}function isTruthy(t,e){return!!t||(_this.log(e+" cant not be null"),!1)}function isSupportSMEncryption(){try{var t=new Uint8Array(1);return t[0]=1,1===t[0]}catch(t){return!1}}function hexToBase64(t){return _.btoa(String.fromCharCode.apply(null,t.replace(/\r|\n/g,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")))}function encryptData(t){var e=t;try{_.isObject(t)&&(t=JSON.stringify(t)),t=Array.prototype.slice.call(pako.gzip(t));var r=sm4.encrypt(t,sm4key,{mode:"cbc",iv:iv});return hexToBase64(iv+r)}catch(t){_this.log("sm encryptData error: "+t.message)}return e}function encryptSingleTrackData(t){var e=encryptData(t);if(_.isString(e)){var r={pkv:_config.pkv,ekey:encryptedSm4Key,flush_time:Date.now(),payloads:[e]},n=JSON.stringify(r);return"data="+encodeURIComponent(n)+"&gzip=9"}return _this.log("SM encryption error, data will not be encrypted"),oldSingleEncoder.call(_sa.kit,t)}function convertToEncDataStruct(t){return{enc:"SM",config:{pkv:_config.pkv,ekey:encryptedSm4Key},payload:t}}function sendSingleDataImmediately(t){try{t._flush_time=Date.now();var e=_sa.kit.onceTrackData(t),r=_sa.para.server_url+"?"+e;-1!==_sa.para.server_url.indexOf("?")&&(r=_sa.para.server_url+"&"+e),_.wxrequest({url:r,method:"GET"})}catch(t){_this.log("onceSend error: "+t.message)}}function readEncStorageToMem(){return getStorage(encDataStoreName).then(t=>{if(_.isArray(t)&&t.length>0)for(var e=0;e0)for(var r=0;rsaveStorage(_sa.para.storage_prepare_data_key,[]))}function groupAndSend(t){for(var e={},r=0;r0){var a=JSON.stringify(s);a="data_list="+encodeURIComponent(a)+"&gzip=9";var h=t.length;_.wxrequest({url:_sa.para.server_url,method:"POST",dataType:"text",data:a,header:{"content-type":"text/plain"},success:function(){oldBatchSender.batchRemove.call(oldBatchSender,h)},fail:function(){oldBatchSender.sendFail.call(oldBatchSender)}})}else _this.log("group send error: no data available")}var SmBatchSend={readySignal:new Promise(function(t){signalBatchSenderReady=t}),init:function(){readEncStorageToMem().then(readLegacyStorage).then(encryptLegacyStorageData).then(persistStorage).finally(()=>{_sa.para.storage_prepare_data_key=encDataStoreName,oldBatchSender.batchInterval(),oldBatchSender.onAppHide(),oldBatchSender.sendHasInit=!0,oldBatchSender.syncStorage=!0,signalBatchSenderReady()}).catch(t=>{_this.log("sm batch-send init err"+t.message)})},send:function(t){SmBatchSend.readySignal.then(function(){if(oldBatchSender.dataHasChange=!0,_sa.store.mem.getLength()>=500&&(_this.log("storage data is too large"),_sa.store.mem.mdata.shift()),t){var e=encryptData(t);if(!_.isString(e))return _this.log("encrypt send data failed. send immediately"),void sendSingleDataImmediately(t);_sa.store.mem.add(convertToEncDataStruct(e))}oldBatchSender.sendAsOver()})},wxrequest:function(t){var e=t.data;e[0].config&&e[0].config.ekey?groupAndSend(e):_this.log("SM Encryption data error.")}};function doEncryptSM4Key(t,e){for(var r=0;r<10;){r++;var n=sm2.doEncrypt(hexToArray(t).slice(),e,1);if("0"!==n[0]||"4"!==n[1])return hexToBase64(n)}throw"generate SM4 ekey failed"}var SmEncryption={plugin_name:"SMEncryption",init:function(t,e){_=(_sa=t)._,_config=e,_this=this;try{if(!isSupportSMEncryption())return void this.log("mini base lib incompatible, data send will not be encrypted");if(!t||!t.kit||!t.kit.onceTrackData)return void this.log("SMEncryption init failed, SDK version incompatible.");var r=buildSMModule();pako=getPako(),sm2=r.sm2,sm4=r.sm4,hexToArray=sm2.hexToArray,isTruthy(e,"SMEncryption init config")&&matchType(e.pkv,"pkv","number")&&isTruthy(e.pub_key,"pub_key")&&matchType(e.pub_key,"pub_key","string")?(iv=get128RandomByte(),sm4key=get128RandomByte(),encryptedSm4Key=doEncryptSM4Key(sm4key,_config.pub_key),oldSingleEncoder=_sa.kit.onceTrackData,oldBatchSender=_sa.sendStrategy,_sa.kit.onceTrackData=encryptSingleTrackData,_sa.sendStrategy.init=SmBatchSend.init,_sa.sendStrategy.send=SmBatchSend.send,_sa.sendStrategy.wxrequest=SmBatchSend.wxrequest,_this.log("SMEncryption init succeed")):_this.log("SMEncryption init failed")}catch(t){_this.log("SMEncryption init exception: "+t)}}},index=createPlugin(SmEncryption);module.exports=index; \ No newline at end of file diff --git a/dist/wechat/plugin/sm-encryption/index.esm.js b/dist/wechat/plugin/sm-encryption/index.esm.js index fb6230c..2a419d1 100644 --- a/dist/wechat/plugin/sm-encryption/index.esm.js +++ b/dist/wechat/plugin/sm-encryption/index.esm.js @@ -1 +1 @@ -function sm(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=2)}var getSmBuildArgs=function(){var t;function e(t,e,r){null!=t&&("number"==typeof t?this.fromNumber(t,e,r):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}function r(){return new e(null)}var n="undefined"!=typeof navigator;n&&"Microsoft Internet Explorer"==navigator.appName?(e.prototype.am=function(t,e,r,n,i,s){for(var o=32767&e,a=e>>15;--s>=0;){var h=32767&this[t],u=this[t++]>>15,l=a*h+u*o;i=((h=o*h+((32767&l)<<15)+r[n]+(1073741823&i))>>>30)+(l>>>15)+a*u+(i>>>30),r[n++]=1073741823&h}return i},t=30):n&&"Netscape"!=navigator.appName?(e.prototype.am=function(t,e,r,n,i,s){for(;--s>=0;){var o=e*this[t++]+r[n]+i;i=Math.floor(o/67108864),r[n++]=67108863&o}return i},t=26):(e.prototype.am=function(t,e,r,n,i,s){for(var o=16383&e,a=e>>14;--s>=0;){var h=16383&this[t],u=this[t++]>>14,l=a*h+u*o;i=((h=o*h+((16383&l)<<14)+r[n]+i)>>28)+(l>>14)+a*u,r[n++]=268435455&h}return i},t=28),e.prototype.DB=t,e.prototype.DM=(1<>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}function c(t){this.m=t}function d(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function v(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function b(){}function w(t){return t}function S(t){this.r2=r(),this.q3=r(),e.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}c.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},c.prototype.revert=function(t){return t},c.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},c.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},c.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},d.prototype.convert=function(t){var n=r();return t.abs().dlShiftTo(this.m.t,n),n.divRemTo(this.m,null,n),t.s<0&&n.compareTo(e.ZERO)>0&&this.m.subTo(n,n),n},d.prototype.revert=function(t){var e=r();return t.copyTo(e),this.reduce(e),e},d.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e>15)*this.mpl&this.um)<<15)&t.DM;for(t[r=e+this.m.t]+=this.m.am(0,n,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},d.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},d.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},e.prototype.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},e.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},e.prototype.fromString=function(t,r){if(!r&&t.length>=2&&"0"===t[0]){var n=!0;switch(t[1]){case"x":r=16;break;case"b":r=2;break;case"o":r=8;break;default:n=!1}n&&(t=t.substr(2))}var i;if(16==r)i=4;else if(8==r)i=3;else if(256==r)i=8;else if(2==r)i=1;else if(32==r)i=5;else{if(4!=r)return void this.fromRadix(t,r);i=2}this.t=0,this.s=0;for(var s=t.length,o=!1,a=0;--s>=0;){var h=8==i?255&t[s]:u(t,s);h<0?"-"==t.charAt(s)&&(o=!0):(o=!1,0==a?this[this.t++]=h:a+i>this.DB?(this[this.t-1]|=(h&(1<>this.DB-a):this[this.t-1]|=h<=this.DB&&(a-=this.DB))}8==i&&0!=(128&t[0])&&(this.s=-1,a>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==t;)--this.t},e.prototype.dlShiftTo=function(t,e){var r;for(r=this.t-1;r>=0;--r)e[r+t]=this[r];for(r=t-1;r>=0;--r)e[r]=0;e.t=this.t+t,e.s=this.s},e.prototype.drShiftTo=function(t,e){for(var r=t;r=0;--r)e[r+o+1]=this[r]>>i|a,a=(this[r]&s)<=0;--r)e[r]=0;e[o]=a,e.t=this.t+o+1,e.s=this.s,e.clamp()},e.prototype.rShiftTo=function(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var n=t%this.DB,i=this.DB-n,s=(1<>n;for(var o=r+1;o>n;n>0&&(e[this.t-r-1]|=(this.s&s)<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[r++]=this.DV+n:n>0&&(e[r++]=n),e.t=r,e.clamp()},e.prototype.multiplyTo=function(t,r){var n=this.abs(),i=t.abs(),s=n.t;for(r.t=s+i.t;--s>=0;)r[s]=0;for(s=0;s=0;)t[r]=0;for(r=0;r=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()},e.prototype.divRemTo=function(t,n,i){var s=t.abs();if(!(s.t<=0)){var o=this.abs();if(o.t0?(s.lShiftTo(l,a),o.lShiftTo(l,i)):(s.copyTo(a),o.copyTo(i));var c=a.t,d=a[c-1];if(0!=d){var p=d*(1<1?a[c-2]>>this.F2:0),_=this.FV/p,g=(1<=0&&(i[i.t++]=1,i.subTo(b,i)),e.ONE.dlShiftTo(c,b),b.subTo(a,a);a.t=0;){var w=i[--y]==d?this.DM:Math.floor(i[y]*_+(i[y-1]+m)*g);if((i[y]+=a.am(0,w,i,v,0,c))0&&i.rShiftTo(l,i),h<0&&e.ZERO.subTo(i,i)}}},e.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},e.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},e.prototype.exp=function(t,n){if(t>4294967295||t<1)return e.ONE;var i=r(),s=r(),o=n.convert(this),a=f(t)-1;for(o.copyTo(i);--a>=0;)if(n.sqrTo(i,s),(t&1<0)n.mulTo(s,o,i);else{var h=i;i=s,s=h}return n.revert(i)},e.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var r,n=(1<0)for(a>a)>0&&(i=!0,s=h(r));o>=0;)a>(a+=this.DB-e)):(r=this[o]>>(a-=e)&n,a<=0&&(a+=this.DB,--o)),r>0&&(i=!0),i&&(s+=h(r));return i?s:"0"},e.prototype.negate=function(){var t=r();return e.ZERO.subTo(this,t),t},e.prototype.abs=function(){return this.s<0?this.negate():this},e.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(0!=(e=r-t.t))return this.s<0?-e:e;for(;--r>=0;)if(0!=(e=this[r]-t[r]))return e;return 0},e.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+f(this[this.t-1]^this.s&this.DM)},e.prototype.mod=function(t){var n=r();return this.abs().divRemTo(t,null,n),this.s<0&&n.compareTo(e.ZERO)>0&&t.subTo(n,n),n},e.prototype.modPowInt=function(t,e){var r;return r=t<256||e.isEven()?new c(e):new d(e),this.exp(t,r)},e.ZERO=l(0),e.ONE=l(1),b.prototype.convert=w,b.prototype.revert=w,b.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r)},b.prototype.sqrTo=function(t,e){t.squareTo(e)},S.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=r();return t.copyTo(e),this.reduce(e),e},S.prototype.revert=function(t){return t},S.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},S.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},S.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var T,x,F,B=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],E=(1<<26)/B[B.length-1];function k(){var t;t=(new Date).getTime(),x[F++]^=255&t,x[F++]^=t>>8&255,x[F++]^=t>>16&255,x[F++]^=t>>24&255,F>=q&&(F-=q)}if(e.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},e.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),n=Math.pow(t,e),i=l(n),s=r(),o=r(),a="";for(this.divRemTo(i,s,o);s.signum()>0;)a=(n+o.intValue()).toString(t).substr(1)+a,s.divRemTo(i,s,o);return o.intValue().toString(t)+a},e.prototype.fromRadix=function(t,r){this.fromInt(0),null==r&&(r=10);for(var n=this.chunkSize(r),i=Math.pow(r,n),s=!1,o=0,a=0,h=0;h=n&&(this.dMultiply(i),this.dAddOffset(a,0),o=0,a=0))}o>0&&(this.dMultiply(Math.pow(r,o)),this.dAddOffset(a,0)),s&&e.ZERO.subTo(this,this)},e.prototype.fromNumber=function(t,r,n){if("number"==typeof r)if(t<2)this.fromInt(1);else for(this.fromNumber(t,n),this.testBit(t-1)||this.bitwiseTo(e.ONE.shiftLeft(t-1),_,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(r);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(e.ONE.shiftLeft(t-1),this);else{var i=new Array,s=7&t;i.length=1+(t>>3),r.nextBytes(i),s>0?i[0]&=(1<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e[r++]=n:n<-1&&(e[r++]=this.DV+n),e.t=r,e.clamp()},e.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},e.prototype.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},e.prototype.multiplyLowerTo=function(t,e,r){var n,i=Math.min(this.t+t.t,e);for(r.s=0,r.t=i;i>0;)r[--i]=0;for(n=r.t-this.t;i=0;)r[n]=0;for(n=Math.max(e-this.t,0);n0)if(0==e)r=this[0]%t;else for(var n=this.t-1;n>=0;--n)r=(e*r+this[n])%t;return r},e.prototype.millerRabin=function(t){var n=this.subtract(e.ONE),i=n.getLowestSetBit();if(i<=0)return!1;var s=n.shiftRight(i);(t=t+1>>1)>B.length&&(t=B.length);for(var o=r(),a=0;a>24},e.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},e.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},e.prototype.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var r,n=this.DB-t*this.DB%8,i=0;if(t-- >0)for(n>n)!=(this.s&this.DM)>>n&&(e[i++]=r|this.s<=0;)n<8?(r=(this[t]&(1<>(n+=this.DB-8)):(r=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),0!=(128&r)&&(r|=-256),0==i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(e[i++]=r);return e},e.prototype.equals=function(t){return 0==this.compareTo(t)},e.prototype.min=function(t){return this.compareTo(t)<0?this:t},e.prototype.max=function(t){return this.compareTo(t)>0?this:t},e.prototype.and=function(t){var e=r();return this.bitwiseTo(t,p,e),e},e.prototype.or=function(t){var e=r();return this.bitwiseTo(t,_,e),e},e.prototype.xor=function(t){var e=r();return this.bitwiseTo(t,g,e),e},e.prototype.andNot=function(t){var e=r();return this.bitwiseTo(t,m,e),e},e.prototype.not=function(){for(var t=r(),e=0;e=this.t?0!=this.s:0!=(this[e]&1<1){var _=r();for(i.sqrTo(a[1],_);h<=p;)a[h]=r(),i.mulTo(_,a[h-2],a[h]),h+=2}var g,m,y=t.t-1,v=!0,b=r();for(s=f(t[y])-1;y>=0;){for(s>=u?g=t[y]>>s-u&p:(g=(t[y]&(1<0&&(g|=t[y-1]>>this.DB+s-u)),h=n;0==(1&g);)g>>=1,--h;if((s-=h)<0&&(s+=this.DB,--y),v)a[g].copyTo(o),v=!1;else{for(;h>1;)i.sqrTo(o,b),i.sqrTo(b,o),h-=2;h>0?i.sqrTo(o,b):(m=o,o=b,b=m),i.mulTo(b,a[g],o)}for(;y>=0&&0==(t[y]&1<=0?(n.subTo(i,n),r&&s.subTo(a,s),o.subTo(h,o)):(i.subTo(n,i),r&&a.subTo(s,a),h.subTo(o,h))}return 0!=i.compareTo(e.ONE)?e.ZERO:h.compareTo(t)>=0?h.subtract(t):h.signum()<0?(h.addTo(t,h),h.signum()<0?h.add(t):h):h},e.prototype.pow=function(t){return this.exp(t,new b)},e.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var n=e;e=r,r=n}var i=e.getLowestSetBit(),s=r.getLowestSetBit();if(s<0)return e;for(i0&&(e.rShiftTo(s,e),r.rShiftTo(s,r));e.signum()>0;)(i=e.getLowestSetBit())>0&&e.rShiftTo(i,e),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return s>0&&r.lShiftTo(s,r),r},e.prototype.isProbablePrime=function(t){var e,r=this.abs();if(1==r.t&&r[0]<=B[B.length-1]){for(e=0;e>>8,x[F++]=255&D;F=0,k()}function I(){if(null==T){for(k(),(T=new O).init(x),F=0;F>>32-r}function o(t,e){for(var r=[],n=t.length-1;n>=0;n--)r[n]=255&(t[n]^e[n]);return r}function a(t){return t^s(t,9)^s(t,17)}function h(t){var e=8*t.length,r=e%512;r=r>=448?512-r%448-1:448-r-1;for(var o=new Array((r-7)/8),h=new Array(8),u=0,l=o.length;u=0;d--)if(e.length>8){var p=e.length-8;h[d]=parseInt(e.substr(p),2),e=e.substr(0,p)}else e.length>0&&(h[d]=parseInt(e,2),e="");for(var _,g=new Uint8Array([].concat(t,[128],o,h)),m=new DataView(g.buffer,0),y=g.length/64,v=new Uint32Array([1937774191,1226093241,388252375,3666478592,2842636476,372324522,3817729613,2969243214]),b=0;b=0&&Z<=15?2043430169:2055708042,q=(Z>=0&&Z<=15?B^E^k:B&E|B&k|E&k)+D+((O=s(s(B,12)+A+s(P,Z),7))^s(B,12))+i[Z],M=(Z>=0&&Z<=15?A^z^I:A&z|~A&I)+R+O+n[Z],D=k,k=s(E,9),E=B,B=q,R=I,I=s(z,19),z=A,A=a(M);v[0]^=B,v[1]^=E,v[2]^=k,v[3]^=D,v[4]^=A,v[5]^=z,v[6]^=I,v[7]^=R}for(var C=[],L=0,U=v.length;L>>24,(16711680&N)>>>16,(65280&N)>>>8,255&N)}return C}for(var u=64,l=new Uint8Array(u),f=new Uint8Array(u),c=0;cu&&(e=h(e));e.length2&&void 0!==arguments[2]?arguments[2]:"1234567812345678";r=a.utf8ToHex(r);var n=a.leftPad(l.curve.a.toBigInteger().toRadix(16),64),i=a.leftPad(l.curve.b.toBigInteger().toRadix(16),64),s=a.leftPad(l.getX().toBigInteger().toRadix(16),64),o=a.leftPad(l.getY().toBigInteger().toRadix(16),64),u=void 0,f=void 0;if(128===e.length)u=e.substr(0,64),f=e.substr(64,64);else{var c=l.curve.decodePointHex(e);u=a.leftPad(c.getX().toBigInteger().toRadix(16),64),f=a.leftPad(c.getY().toBigInteger().toRadix(16),64)}var d=a.hexToArray(r+n+i+s+o+u+f),p=4*r.length;d.unshift(255&p),d.unshift(p>>8&255);var _=h(d);return a.arrayToHex(h(_.concat(a.hexToArray(t))))}function _(){var t=a.generateKeyPairHex(),e=f.decodePointHex(t.publicKey);return t.k=new n(t.privateKey,16),t.x1=e.getX().toBigInteger(),t}t.exports={generateKeyPairHex:a.generateKeyPairHex,compressPublicKeyHex:a.compressPublicKeyHex,comparePublicKeyHex:a.comparePublicKeyHex,doEncrypt:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;t="string"==typeof t?a.hexToArray(a.utf8ToHex(t)):Array.prototype.slice.call(t),e=a.getGlobalCurve().decodePointHex(e);var i=a.generateKeyPairHex(),s=new n(i.privateKey,16),o=i.publicKey;o.length>128&&(o=o.substr(o.length-128));var u=e.multiply(s),l=a.hexToArray(a.leftPad(u.getX().toBigInteger().toRadix(16),64)),f=a.hexToArray(a.leftPad(u.getY().toBigInteger().toRadix(16),64)),c=a.arrayToHex(h([].concat(l,t,f))),p=1,_=0,g=[],m=[].concat(l,f),y=function(){g=h([].concat(m,[p>>24&255,p>>16&255,p>>8&255,255&p])),p++,_=0};y();for(var v=0,b=t.length;v2&&void 0!==arguments[2]?arguments[2]:1,i=(arguments.length>3&&void 0!==arguments[3]?arguments[3]:{}).output,s=void 0===i?"string":i;e=new n(e,16);var o=t.substr(128,64),u=t.substr(192);r===d&&(o=t.substr(t.length-64),u=t.substr(128,t.length-128-64));var l=a.hexToArray(u),f=a.getGlobalCurve().decodePointHex("04"+t.substr(0,128)).multiply(e),c=a.hexToArray(a.leftPad(f.getX().toBigInteger().toRadix(16),64)),p=a.hexToArray(a.leftPad(f.getY().toBigInteger().toRadix(16),64)),_=1,g=0,m=[],y=[].concat(c,p),v=function(){m=h([].concat(y,[_>>24&255,_>>16&255,_>>8&255,255&_])),_++,g=0};v();for(var b=0,w=l.length;b2&&void 0!==arguments[2]?arguments[2]:{},i=r.pointPool,o=r.der,h=r.hash,u=r.publicKey,f=r.userId,d="string"==typeof t?a.utf8ToHex(t):a.arrayToHex(t);h&&(d=p(d,u=u||function(t){var e=l.multiply(new n(t,16)),r=a.leftPad(e.getX().toBigInteger().toString(16),64),i=a.leftPad(e.getY().toBigInteger().toString(16),64);return"04"+r+i}(e),f));var g=new n(e,16),m=new n(d,16),y=null,v=null,b=null;do{do{var w=void 0;y=(w=i&&i.length?i.pop():_()).k,v=m.add(w.x1).mod(c)}while(v.equals(n.ZERO)||v.add(y).equals(c));b=g.add(n.ONE).modInverse(c).multiply(y.subtract(v.multiply(g))).mod(c)}while(b.equals(n.ZERO));return o?s(v,b):a.leftPad(v.toString(16),64)+a.leftPad(b.toString(16),64)},doVerifySignature:function(t,e,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},s=i.der,h=i.hash,u=i.userId,d="string"==typeof t?a.utf8ToHex(t):a.arrayToHex(t);h&&(d=p(d,r,u));var _=void 0,g=void 0;if(s){var m=o(e);_=m.r,g=m.s}else _=new n(e.substring(0,64),16),g=new n(e.substring(64),16);var y=f.decodePointHex(r),v=new n(d,16),b=_.add(g).mod(c);if(b.equals(n.ZERO))return!1;var w=l.multiply(g).add(y.multiply(b)),S=v.add(w.getX().toBigInteger()).mod(c);return _.equals(S)},getPoint:_,verifyPublicKey:a.verifyPublicKey,hexToArray:a.hexToArray}},function(t,e,r){function n(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function s(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var o=r(0).BigInteger;var a=function(){function t(){s(this,t),this.tlv=null,this.t="00",this.l="00",this.v=""}return t.prototype.getEncodedHex=function(){return this.tlv||(this.v=this.getValue(),this.l=this.getLength(),this.tlv=this.t+this.l+this.v),this.tlv},t.prototype.getLength=function(){var t=this.v.length/2,e=t.toString(16);return e.length%2==1&&(e="0"+e),t<128?e:(128+e.length/2).toString(16)+e},t.prototype.getValue=function(){return""},t}(),h=function(t){function e(r){s(this,e);var i=n(this,t.call(this));return i.t="02",r&&(i.v=function(t){var e=t.toString(16);if("-"!==e[0])e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e);else{var r=(e=e.substr(1)).length;r%2==1?r+=1:e.match(/^[0-7]/)||(r+=2);for(var n="",i=0;i=e?t:new Array(e-t.length+1).join("0")+t}t.exports={getGlobalCurve:function(){return u},generateEcparam:c,generateKeyPairHex:function(t,e,r){var n=(t?new i(t,e,r):new i(f.bitLength(),a)).mod(f.subtract(i.ONE)).add(i.ONE),s=d(n.toString(16),64),o=l.multiply(n);return{privateKey:s,publicKey:"04"+d(o.getX().toBigInteger().toString(16),64)+d(o.getY().toBigInteger().toString(16),64)}},compressPublicKeyHex:function(t){if(130!==t.length)throw new Error("Invalid public key to compress");var e=(t.length-2)/2,r=t.substr(2,e),n="03";return new i(t.substr(e+2,e),16).mod(new i("2")).equals(i.ZERO)&&(n="02"),n+r},utf8ToHex:function(t){for(var e=(t=unescape(encodeURIComponent(t))).length,r=[],n=0;n>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;for(var i=[],s=0;s>>2]>>>24-s%4*8&255;i.push((o>>>4).toString(16)),i.push((15&o).toString(16))}return i.join("")},leftPad:d,arrayToHex:function(t){return t.map(function(t){return 1===(t=t.toString(16)).length?"0"+t:t}).join("")},arrayToUtf8:function(t){for(var e=[],r=0,n=0;n<2*t.length;n+=2)e[n>>>3]|=parseInt(t[r],10)<<24-n%8*4,r++;try{for(var i=[],s=0;s>>2]>>>24-s%4*8&255;i.push(String.fromCharCode(o))}return decodeURIComponent(escape(i.join("")))}catch(t){throw new Error("Malformed UTF-8 data")}},hexToArray:function(t){var e=[],r=t.length;r%2!=0&&(t=d(t,r+1)),r=t.length;for(var n=0;n0;i--){n=n.twice();var s=e.testBit(i);s!==t.testBit(i)&&(n=n.add(s?this:r))}return n},t}(),u=function(){function t(e,r,i){n(this,t),this.q=e,this.a=this.fromBigInteger(r),this.b=this.fromBigInteger(i),this.infinity=new h(this,null,null)}return t.prototype.equals=function(t){return t===this||this.q.equals(t.q)&&this.a.equals(t.a)&&this.b.equals(t.b)},t.prototype.fromBigInteger=function(t){return new a(this.q,t)},t.prototype.decodePointHex=function(t){switch(parseInt(t.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:var e=this.fromBigInteger(new i(t.substr(2),16)),r=this.fromBigInteger(e.multiply(e.square()).add(e.multiply(this.a)).add(this.b).toBigInteger().modPow(this.q.divide(new i("4")).add(i.ONE),this.q));return r.toBigInteger().mod(s).equals(new i(t.substr(0,2),16).subtract(s))||(r=r.negate()),new h(this,e,r);case 4:case 6:case 7:var n=(t.length-2)/2,o=t.substr(2,n),a=t.substr(n+2,n);return new h(this,this.fromBigInteger(new i(o,16)),this.fromBigInteger(new i(a,16)));default:return null}},t}();t.exports={ECPointFp:h,ECCurveFp:u}},function(t,e,r){var n=r(1),i=n.sm3,s=n.hmac;function o(t){return t.map(function(t){return 1===(t=t.toString(16)).length?"0"+t:t}).join("")}function a(t){var e,r,n=[],i=t.length;i%2!=0&&(r=i+1,t=(e=t).length>=r?e:new Array(r-e.length+1).join("0")+e),i=t.length;for(var s=0;s>>6),e.push(128|63&i);else if(i<=55295||i>=57344&&i<=65535)e.push(224|i>>>12),e.push(128|i>>>6&63),e.push(128|63&i);else{if(!(i>=65536&&i<=1114111))throw e.push(i),new Error("input is not supported");r++,e.push(240|i>>>18&28),e.push(128|i>>>12&63),e.push(128|i>>>6&63),e.push(128|63&i)}}return e}(t):Array.prototype.slice.call(t),e){if("hmac"!==(e.mode||"hmac"))throw new Error("invalid mode");var r=e.key;if(!r)throw new Error("invalid key");return r="string"==typeof r?a(r):Array.prototype.slice.call(r),o(s(t,r))}return o(i(t))}},function(t,e,r){var n=0,i=32,s=16,o=[214,144,233,254,204,225,61,183,22,182,20,194,40,251,44,5,43,103,154,118,42,190,4,195,170,68,19,38,73,134,6,153,156,66,80,244,145,239,152,122,51,84,11,67,237,207,172,98,228,179,28,169,201,8,232,149,128,223,148,250,117,143,63,166,71,7,167,252,243,115,23,186,131,89,60,25,230,133,79,168,104,107,129,178,113,100,218,139,248,235,15,75,112,86,157,53,30,36,14,94,99,88,209,162,37,34,124,59,1,33,120,135,212,0,70,87,159,211,39,82,76,54,2,231,160,196,200,158,234,191,138,210,64,199,56,181,163,247,242,206,249,97,21,161,224,174,93,164,155,52,26,85,173,147,50,48,245,140,177,227,29,246,226,46,130,102,202,96,192,41,35,171,13,83,78,111,213,219,55,69,222,253,142,47,3,255,106,114,109,108,91,81,141,27,175,146,187,221,188,127,17,217,92,65,31,16,90,216,10,193,49,136,165,205,123,189,45,116,208,18,184,229,180,176,137,105,151,74,12,150,119,126,101,185,241,9,197,110,198,132,24,240,125,236,58,220,77,32,121,238,95,62,215,203,57,72],a=[462357,472066609,943670861,1415275113,1886879365,2358483617,2830087869,3301692121,3773296373,4228057617,404694573,876298825,1347903077,1819507329,2291111581,2762715833,3234320085,3705924337,4177462797,337322537,808926789,1280531041,1752135293,2223739545,2695343797,3166948049,3638552301,4110090761,269950501,741554753,1213159005,1684763257];function h(t){for(var e=[],r=0,n=t.length;r>>32-r}function l(t){return(255&o[t>>>24&255])<<24|(255&o[t>>>16&255])<<16|(255&o[t>>>8&255])<<8|255&o[255&t]}function f(t){return t^u(t,2)^u(t,10)^u(t,18)^u(t,24)}function c(t){return t^u(t,13)^u(t,23)}function d(t,e,r){for(var n=new Array(4),i=new Array(4),s=0;s<4;s++)i[0]=255&t[4*s],i[1]=255&t[4*s+1],i[2]=255&t[4*s+2],i[3]=255&t[4*s+3],n[s]=i[0]<<24|i[1]<<16|i[2]<<8|i[3];for(var o,a=0;a<32;a+=4)o=n[1]^n[2]^n[3]^r[a+0],n[0]^=f(l(o)),o=n[2]^n[3]^n[0]^r[a+1],n[1]^=f(l(o)),o=n[3]^n[0]^n[1]^r[a+2],n[2]^=f(l(o)),o=n[0]^n[1]^n[2]^r[a+3],n[3]^=f(l(o));for(var h=0;h<16;h+=4)e[h]=n[3-h/4]>>>24&255,e[h+1]=n[3-h/4]>>>16&255,e[h+2]=n[3-h/4]>>>8&255,e[h+3]=255&n[3-h/4]}function p(t,e,r){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},u=o.padding,f=void 0===u?"pkcs#7":u,p=o.mode,_=o.iv,g=void 0===_?[]:_,m=o.output,y=void 0===m?"string":m;if("cbc"===p&&("string"==typeof g&&(g=h(g)),16!==g.length))throw new Error("iv is invalid");if("string"==typeof e&&(e=h(e)),16!==e.length)throw new Error("key is invalid");if(t="string"==typeof t?r!==n?function(t){for(var e=[],r=0,n=t.length;r>>6),e.push(128|63&i);else if(i<=55295||i>=57344&&i<=65535)e.push(224|i>>>12),e.push(128|i>>>6&63),e.push(128|63&i);else{if(!(i>=65536&&i<=1114111))throw e.push(i),new Error("input is not supported");r++,e.push(240|i>>>18&28),e.push(128|i>>>12&63),e.push(128|i>>>6&63),e.push(128|63&i)}}return e}(t):h(t):[].concat(t),("pkcs#5"===f||"pkcs#7"===f)&&r!==n)for(var v=s-t.length%s,b=0;b=s;){var B=t.slice(F,F+16),E=new Array(16);if("cbc"===p)for(var k=0;k=240&&t[r]<=247?(e.push(String.fromCodePoint(((7&t[r])<<18)+((63&t[r+1])<<12)+((63&t[r+2])<<6)+(63&t[r+3]))),r+=3):t[r]>=224&&t[r]<=239?(e.push(String.fromCodePoint(((15&t[r])<<12)+((63&t[r+1])<<6)+(63&t[r+2]))),r+=2):t[r]>=192&&t[r]<=223?(e.push(String.fromCodePoint(((31&t[r])<<6)+(63&t[r+1]))),r++):e.push(String.fromCodePoint(t[r]));return e.join("")}(S):S}t.exports={encrypt:function(t,e,r){return p(t,e,1,r)},decrypt:function(t,e,r){return p(t,e,0,r)}}}]};function buildSMModule(){return sm(getSmBuildArgs())}function getPako(){function t(t){for(var e=t.length;--e>=0;)t[e]=0}var e=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),r=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),n=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),i=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),s=new Array(576);t(s);var o=new Array(60);t(o);var a=new Array(512);t(a);var h=new Array(256);t(h);var u=new Array(29);t(u);var l,f,c,d=new Array(30);function p(t,e,r,n,i){this.static_tree=t,this.extra_bits=e,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=t&&t.length}function _(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}t(d);var g=function(t){return t<256?a[t]:a[256+(t>>>7)]},m=function(t,e){t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},y=function(t,e,r){t.bi_valid>16-r?(t.bi_buf|=e<>16-t.bi_valid,t.bi_valid+=r-16):(t.bi_buf|=e<>>=1,r<<=1}while(--e>0);return r>>>1},w=function(t,e,r){var n,i,s=new Array(16),o=0;for(n=1;n<=15;n++)o=o+r[n-1]<<1,s[n]=o;for(i=0;i<=e;i++){var a=t[2*i+1];0!==a&&(t[2*i]=b(s[a]++,a))}},S=function(t){var e;for(e=0;e<286;e++)t.dyn_ltree[2*e]=0;for(e=0;e<30;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.sym_next=t.matches=0},T=function(t){t.bi_valid>8?m(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},x=function(t,e,r,n){var i=2*e,s=2*r;return t[i]>1;r>=1;r--)F(t,s,r);i=h;do{r=t.heap[1],t.heap[1]=t.heap[t.heap_len--],F(t,s,1),n=t.heap[1],t.heap[--t.heap_max]=r,t.heap[--t.heap_max]=n,s[2*i]=s[2*r]+s[2*n],t.depth[i]=(t.depth[r]>=t.depth[n]?t.depth[r]:t.depth[n])+1,s[2*r+1]=s[2*n+1]=i,t.heap[1]=i++,F(t,s,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],function(t,e){var r,n,i,s,o,a,h=e.dyn_tree,u=e.max_code,l=e.stat_desc.static_tree,f=e.stat_desc.has_stree,c=e.stat_desc.extra_bits,d=e.stat_desc.extra_base,p=e.stat_desc.max_length,_=0;for(s=0;s<=15;s++)t.bl_count[s]=0;for(h[2*t.heap[t.heap_max]+1]=0,r=t.heap_max+1;r<573;r++)(s=h[2*h[2*(n=t.heap[r])+1]+1]+1)>p&&(s=p,_++),h[2*n+1]=s,n>u||(t.bl_count[s]++,o=0,n>=d&&(o=c[n-d]),a=h[2*n],t.opt_len+=a*(s+o),f&&(t.static_len+=a*(l[2*n+1]+o)));if(0!==_){do{for(s=p-1;0===t.bl_count[s];)s--;t.bl_count[s]--,t.bl_count[s+1]+=2,t.bl_count[p]--,_-=2}while(_>0);for(s=p;0!==s;s--)for(n=t.bl_count[s];0!==n;)(i=t.heap[--r])>u||(h[2*i+1]!==s&&(t.opt_len+=(s-h[2*i+1])*h[2*i],h[2*i+1]=s),n--)}}(t,e),w(s,u,t.bl_count)},k=function(t,e,r){var n,i,s=-1,o=e[1],a=0,h=7,u=4;for(0===o&&(h=138,u=3),e[2*(r+1)+1]=65535,n=0;n<=r;n++)i=o,o=e[2*(n+1)+1],++a>=7;g<30;g++)for(d[g]=m<<7,t=0;t<1<0?(2===t.strm.data_type&&(t.strm.data_type=function(t){var e,r=4093624447;for(e=0;e<=31;e++,r>>>=1)if(1&r&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<256;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0}(t)),E(t,t.l_desc),E(t,t.d_desc),u=function(t){var e;for(k(t,t.dyn_ltree,t.l_desc.max_code),k(t,t.dyn_dtree,t.d_desc.max_code),E(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*i[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e}(t),a=t.opt_len+3+7>>>3,(h=t.static_len+3+7>>>3)<=a&&(a=h)):a=h=r+5,r+4<=a&&-1!==e?z(t,e,r,n):4===t.strategy||h===a?(y(t,2+(n?1:0),3),B(t,s,o)):(y(t,4+(n?1:0),3),function(t,e,r,n){var s;for(y(t,e-257,5),y(t,r-1,5),y(t,n-4,4),s=0;s>8,t.pending_buf[t.sym_buf+t.sym_next++]=r,0===e?t.dyn_ltree[2*r]++:(t.matches++,e--,t.dyn_ltree[2*(h[r]+256+1)]++,t.dyn_dtree[2*g(e)]++),t.sym_next===t.sym_end},_tr_align:function(t){y(t,2,3),v(t,256,s),function(t){16===t.bi_valid?(m(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}(t)}},R=function(t,e,r,n){for(var i=65535&t|0,s=t>>>16&65535|0,o=0;0!==r;){r-=o=r>2e3?2e3:r;do{s=s+(i=i+e[n++]|0)|0}while(--o);i%=65521,s%=65521}return i|s<<16|0},O=new Uint32Array(function(){for(var t,e=[],r=0;r<256;r++){t=r;for(var n=0;n<8;n++)t=1&t?3988292384^t>>>1:t>>>1;e[r]=t}return e}()),q=function(t,e,r,n){var i=O,s=n+r;t^=-1;for(var o=n;o>>8^i[255&(t^e[o])];return-1^t},M={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},P={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},Z=I._tr_init,C=I._tr_stored_block,L=I._tr_flush_block,U=I._tr_tally,N=I._tr_align,H=P.Z_NO_FLUSH,j=P.Z_PARTIAL_FLUSH,K=P.Z_FULL_FLUSH,V=P.Z_FINISH,Y=P.Z_BLOCK,X=P.Z_OK,G=P.Z_STREAM_END,J=P.Z_STREAM_ERROR,W=P.Z_DATA_ERROR,$=P.Z_BUF_ERROR,Q=P.Z_DEFAULT_COMPRESSION,tt=P.Z_FILTERED,et=P.Z_HUFFMAN_ONLY,rt=P.Z_RLE,nt=P.Z_FIXED,it=P.Z_DEFAULT_STRATEGY,st=P.Z_UNKNOWN,ot=P.Z_DEFLATED,at=286,ht=30,ut=19,lt=2*at+1,ft=15,ct=function(t,e){return t.msg=M[e],e},dt=function(t){return 2*t-(t>4?9:0)},pt=function(t){for(var e=t.length;--e>=0;)t[e]=0},_t=function(t){var e,r,n,i=t.w_size;n=e=t.hash_size;do{r=t.head[--n],t.head[n]=r>=i?r-i:0}while(--e);n=e=i;do{r=t.prev[--n],t.prev[n]=r>=i?r-i:0}while(--e)},gt=function(t,e,r){return(e<t.avail_out&&(r=t.avail_out),0!==r&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+r),t.next_out),t.next_out+=r,e.pending_out+=r,t.total_out+=r,t.avail_out-=r,e.pending-=r,0===e.pending&&(e.pending_out=0))},yt=function(t,e){L(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,mt(t.strm)},vt=function(t,e){t.pending_buf[t.pending++]=e},bt=function(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},wt=function(t,e,r,n){var i=t.avail_in;return i>n&&(i=n),0===i?0:(t.avail_in-=i,e.set(t.input.subarray(t.next_in,t.next_in+i),r),1===t.state.wrap?t.adler=R(t.adler,e,i,r):2===t.state.wrap&&(t.adler=q(t.adler,e,i,r)),t.next_in+=i,t.total_in+=i,i)},St=function(t,e){var r,n,i=t.max_chain_length,s=t.strstart,o=t.prev_length,a=t.nice_match,h=t.strstart>t.w_size-262?t.strstart-(t.w_size-262):0,u=t.window,l=t.w_mask,f=t.prev,c=t.strstart+258,d=u[s+o-1],p=u[s+o];t.prev_length>=t.good_match&&(i>>=2),a>t.lookahead&&(a=t.lookahead);do{if(u[(r=e)+o]===p&&u[r+o-1]===d&&u[r]===u[s]&&u[++r]===u[s+1]){s+=2,r++;do{}while(u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&so){if(t.match_start=e,o=n,n>=a)break;d=u[s+o-1],p=u[s+o]}}}while((e=f[e&l])>h&&0!=--i);return o<=t.lookahead?o:t.lookahead},Tt=function(t){var e,r,n,i=t.w_size;do{if(r=t.window_size-t.lookahead-t.strstart,t.strstart>=i+(i-262)&&(t.window.set(t.window.subarray(i,i+i-r),0),t.match_start-=i,t.strstart-=i,t.block_start-=i,t.insert>t.strstart&&(t.insert=t.strstart),_t(t),r+=i),0===t.strm.avail_in)break;if(e=wt(t.strm,t.window,t.strstart+t.lookahead,r),t.lookahead+=e,t.lookahead+t.insert>=3)for(n=t.strstart-t.insert,t.ins_h=t.window[n],t.ins_h=gt(t,t.ins_h,t.window[n+1]);t.insert&&(t.ins_h=gt(t,t.ins_h,t.window[n+3-1]),t.prev[n&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=n,n++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<262&&0!==t.strm.avail_in)},xt=function(t,e){var r,n,i,s=t.pending_buf_size-5>t.w_size?t.w_size:t.pending_buf_size-5,o=0,a=t.strm.avail_in;do{if(r=65535,i=t.bi_valid+42>>3,t.strm.avail_out(n=t.strstart-t.block_start)+t.strm.avail_in&&(r=n+t.strm.avail_in),r>i&&(r=i),r>8,t.pending_buf[t.pending-2]=~r,t.pending_buf[t.pending-1]=~r>>8,mt(t.strm),n&&(n>r&&(n=r),t.strm.output.set(t.window.subarray(t.block_start,t.block_start+n),t.strm.next_out),t.strm.next_out+=n,t.strm.avail_out-=n,t.strm.total_out+=n,t.block_start+=n,r-=n),r&&(wt(t.strm,t.strm.output,t.strm.next_out,r),t.strm.next_out+=r,t.strm.avail_out-=r,t.strm.total_out+=r)}while(0===o);return(a-=t.strm.avail_in)&&(a>=t.w_size?(t.matches=2,t.window.set(t.strm.input.subarray(t.strm.next_in-t.w_size,t.strm.next_in),0),t.strstart=t.w_size,t.insert=t.strstart):(t.window_size-t.strstart<=a&&(t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,t.insert>t.strstart&&(t.insert=t.strstart)),t.window.set(t.strm.input.subarray(t.strm.next_in-a,t.strm.next_in),t.strstart),t.strstart+=a,t.insert+=a>t.w_size-t.insert?t.w_size-t.insert:a),t.block_start=t.strstart),t.high_wateri&&t.block_start>=t.w_size&&(t.block_start-=t.w_size,t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,i+=t.w_size,t.insert>t.strstart&&(t.insert=t.strstart)),i>t.strm.avail_in&&(i=t.strm.avail_in),i&&(wt(t.strm,t.window,t.strstart,i),t.strstart+=i,t.insert+=i>t.w_size-t.insert?t.w_size-t.insert:i),t.high_water>3,s=(i=t.pending_buf_size-i>65535?65535:t.pending_buf_size-i)>t.w_size?t.w_size:i,((n=t.strstart-t.block_start)>=s||(n||e===V)&&e!==H&&0===t.strm.avail_in&&n<=i)&&(r=n>i?i:n,o=e===V&&0===t.strm.avail_in&&r===n?1:0,C(t,t.block_start,r,o),t.block_start+=r,mt(t.strm)),o?3:1)},Ft=function(t,e){for(var r,n;;){if(t.lookahead<262){if(Tt(t),t.lookahead<262&&e===H)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=gt(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==r&&t.strstart-r<=t.w_size-262&&(t.match_length=St(t,r)),t.match_length>=3)if(n=U(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=gt(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=gt(t,t.ins_h,t.window[t.strstart+1]);else n=U(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(n&&(yt(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===V?(yt(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(yt(t,!1),0===t.strm.avail_out)?1:2},Bt=function(t,e){for(var r,n,i;;){if(t.lookahead<262){if(Tt(t),t.lookahead<262&&e===H)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=gt(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==r&&t.prev_length4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){i=t.strstart+t.lookahead-3,n=U(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=i&&(t.ins_h=gt(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,n&&(yt(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if((n=U(t,0,t.window[t.strstart-1]))&&yt(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(n=U(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===V?(yt(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(yt(t,!1),0===t.strm.avail_out)?1:2};function Et(t,e,r,n,i){this.good_length=t,this.max_lazy=e,this.nice_length=r,this.max_chain=n,this.func=i}var kt=[new Et(0,0,0,0,xt),new Et(4,4,8,4,Ft),new Et(4,5,16,8,Ft),new Et(4,6,32,32,Ft),new Et(4,4,16,16,Bt),new Et(8,16,32,32,Bt),new Et(8,16,128,128,Bt),new Et(8,32,128,256,Bt),new Et(32,128,258,1024,Bt),new Et(32,258,258,4096,Bt)];function Dt(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=ot,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(2*lt),this.dyn_dtree=new Uint16Array(2*(2*ht+1)),this.bl_tree=new Uint16Array(2*(2*ut+1)),pt(this.dyn_ltree),pt(this.dyn_dtree),pt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(ft+1),this.heap=new Uint16Array(2*at+1),pt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*at+1),pt(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}var At=function(t){if(!t)return 1;var e=t.state;return!e||e.strm!==t||42!==e.status&&57!==e.status&&69!==e.status&&73!==e.status&&91!==e.status&&103!==e.status&&113!==e.status&&666!==e.status?1:0},zt=function(t){if(At(t))return ct(t,J);t.total_in=t.total_out=0,t.data_type=st;var e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=2===e.wrap?57:e.wrap?42:113,t.adler=2===e.wrap?0:1,e.last_flush=-2,Z(e),X},It=function(t){var e,r=zt(t);return r===X&&((e=t.state).window_size=2*e.w_size,pt(e.head),e.max_lazy_match=kt[e.level].max_lazy,e.good_match=kt[e.level].good_length,e.nice_match=kt[e.level].nice_length,e.max_chain_length=kt[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=2,e.match_available=0,e.ins_h=0),r},Rt=function(t,e,r,n,i,s){if(!t)return J;var o=1;if(e===Q&&(e=6),n<0?(o=0,n=-n):n>15&&(o=2,n-=16),i<1||i>9||r!==ot||n<8||n>15||e<0||e>9||s<0||s>nt||8===n&&1!==o)return ct(t,J);8===n&&(n=9);var a=new Dt;return t.state=a,a.strm=t,a.status=42,a.wrap=o,a.gzhead=null,a.w_bits=n,a.w_size=1<Y||e<0)return t?ct(t,J):J;var r=t.state;if(!t.output||0!==t.avail_in&&!t.input||666===r.status&&e!==V)return ct(t,0===t.avail_out?$:J);var n=r.last_flush;if(r.last_flush=e,0!==r.pending){if(mt(t),0===t.avail_out)return r.last_flush=-1,X}else if(0===t.avail_in&&dt(e)<=dt(n)&&e!==V)return ct(t,$);if(666===r.status&&0!==t.avail_in)return ct(t,$);if(42===r.status&&0===r.wrap&&(r.status=113),42===r.status){var i=ot+(r.w_bits-8<<4)<<8;if(i|=(r.strategy>=et||r.level<2?0:r.level<6?1:6===r.level?2:3)<<6,0!==r.strstart&&(i|=32),bt(r,i+=31-i%31),0!==r.strstart&&(bt(r,t.adler>>>16),bt(r,65535&t.adler)),t.adler=1,r.status=113,mt(t),0!==r.pending)return r.last_flush=-1,X}if(57===r.status)if(t.adler=0,vt(r,31),vt(r,139),vt(r,8),r.gzhead)vt(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),vt(r,255&r.gzhead.time),vt(r,r.gzhead.time>>8&255),vt(r,r.gzhead.time>>16&255),vt(r,r.gzhead.time>>24&255),vt(r,9===r.level?2:r.strategy>=et||r.level<2?4:0),vt(r,255&r.gzhead.os),r.gzhead.extra&&r.gzhead.extra.length&&(vt(r,255&r.gzhead.extra.length),vt(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(t.adler=q(t.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=69;else if(vt(r,0),vt(r,0),vt(r,0),vt(r,0),vt(r,0),vt(r,9===r.level?2:r.strategy>=et||r.level<2?4:0),vt(r,3),r.status=113,mt(t),0!==r.pending)return r.last_flush=-1,X;if(69===r.status){if(r.gzhead.extra){for(var s=r.pending,o=(65535&r.gzhead.extra.length)-r.gzindex;r.pending+o>r.pending_buf_size;){var a=r.pending_buf_size-r.pending;if(r.pending_buf.set(r.gzhead.extra.subarray(r.gzindex,r.gzindex+a),r.pending),r.pending=r.pending_buf_size,r.gzhead.hcrc&&r.pending>s&&(t.adler=q(t.adler,r.pending_buf,r.pending-s,s)),r.gzindex+=a,mt(t),0!==r.pending)return r.last_flush=-1,X;s=0,o-=a}var h=new Uint8Array(r.gzhead.extra);r.pending_buf.set(h.subarray(r.gzindex,r.gzindex+o),r.pending),r.pending+=o,r.gzhead.hcrc&&r.pending>s&&(t.adler=q(t.adler,r.pending_buf,r.pending-s,s)),r.gzindex=0}r.status=73}if(73===r.status){if(r.gzhead.name){var u,l=r.pending;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>l&&(t.adler=q(t.adler,r.pending_buf,r.pending-l,l)),mt(t),0!==r.pending)return r.last_flush=-1,X;l=0}u=r.gzindexl&&(t.adler=q(t.adler,r.pending_buf,r.pending-l,l)),r.gzindex=0}r.status=91}if(91===r.status){if(r.gzhead.comment){var f,c=r.pending;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>c&&(t.adler=q(t.adler,r.pending_buf,r.pending-c,c)),mt(t),0!==r.pending)return r.last_flush=-1,X;c=0}f=r.gzindexc&&(t.adler=q(t.adler,r.pending_buf,r.pending-c,c))}r.status=103}if(103===r.status){if(r.gzhead.hcrc){if(r.pending+2>r.pending_buf_size&&(mt(t),0!==r.pending))return r.last_flush=-1,X;vt(r,255&t.adler),vt(r,t.adler>>8&255),t.adler=0}if(r.status=113,mt(t),0!==r.pending)return r.last_flush=-1,X}if(0!==t.avail_in||0!==r.lookahead||e!==H&&666!==r.status){var d=0===r.level?xt(r,e):r.strategy===et?function(t,e){for(var r;;){if(0===t.lookahead&&(Tt(t),0===t.lookahead)){if(e===H)return 1;break}if(t.match_length=0,r=U(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,r&&(yt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===V?(yt(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(yt(t,!1),0===t.strm.avail_out)?1:2}(r,e):r.strategy===rt?function(t,e){for(var r,n,i,s,o=t.window;;){if(t.lookahead<=258){if(Tt(t),t.lookahead<=258&&e===H)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(n=o[i=t.strstart-1])===o[++i]&&n===o[++i]&&n===o[++i]){s=t.strstart+258;do{}while(n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&it.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(r=U(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(r=U(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),r&&(yt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===V?(yt(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(yt(t,!1),0===t.strm.avail_out)?1:2}(r,e):kt[r.level].func(r,e);if(3!==d&&4!==d||(r.status=666),1===d||3===d)return 0===t.avail_out&&(r.last_flush=-1),X;if(2===d&&(e===j?N(r):e!==Y&&(C(r,0,0,!1),e===K&&(pt(r.head),0===r.lookahead&&(r.strstart=0,r.block_start=0,r.insert=0))),mt(t),0===t.avail_out))return r.last_flush=-1,X}return e!==V?X:r.wrap<=0?G:(2===r.wrap?(vt(r,255&t.adler),vt(r,t.adler>>8&255),vt(r,t.adler>>16&255),vt(r,t.adler>>24&255),vt(r,255&t.total_in),vt(r,t.total_in>>8&255),vt(r,t.total_in>>16&255),vt(r,t.total_in>>24&255)):(bt(r,t.adler>>>16),bt(r,65535&t.adler)),mt(t),r.wrap>0&&(r.wrap=-r.wrap),0!==r.pending?X:G)},deflateEnd:function(t){if(At(t))return J;var e=t.state.status;return t.state=null,113===e?ct(t,W):X},deflateSetDictionary:function(t,e){var r=e.length;if(At(t))return J;var n=t.state,i=n.wrap;if(2===i||1===i&&42!==n.status||n.lookahead)return J;if(1===i&&(t.adler=R(t.adler,e,r,0)),n.wrap=0,r>=n.w_size){0===i&&(pt(n.head),n.strstart=0,n.block_start=0,n.insert=0);var s=new Uint8Array(n.w_size);s.set(e.subarray(r-n.w_size,r),0),e=s,r=n.w_size}var o=t.avail_in,a=t.next_in,h=t.input;for(t.avail_in=r,t.next_in=0,t.input=e,Tt(n);n.lookahead>=3;){var u=n.strstart,l=n.lookahead-2;do{n.ins_h=gt(n,n.ins_h,n.window[u+3-1]),n.prev[u&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=u,u++}while(--l);n.strstart=u,n.lookahead=2,Tt(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,t.next_in=a,t.input=h,t.avail_in=o,n.wrap=i,X},deflateInfo:"pako deflate (from Nodeca project)"};function qt(t){return(qt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var Mt=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},Pt={assign:function(t){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var r=e.shift();if(r){if("object"!==qt(r))throw new TypeError(r+"must be non-object");for(var n in r)Mt(r,n)&&(t[n]=r[n])}}return t},flattenChunks:function(t){for(var e=0,r=0,n=t.length;r=252?6:Lt>=248?5:Lt>=240?4:Lt>=224?3:Lt>=192?2:1;Ct[254]=Ct[254]=1;var Ut={string2buf:function(t){if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);var e,r,n,i,s,o=t.length,a=0;for(i=0;i>>6,e[s++]=128|63&r):r<65536?(e[s++]=224|r>>>12,e[s++]=128|r>>>6&63,e[s++]=128|63&r):(e[s++]=240|r>>>18,e[s++]=128|r>>>12&63,e[s++]=128|r>>>6&63,e[s++]=128|63&r);return e},buf2string:function(t,e){var r,n,i=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));var s=new Array(2*i);for(n=0,r=0;r4)s[n++]=65533,r+=a-1;else{for(o&=2===a?31:3===a?15:7;a>1&&r1?s[n++]=65533:o<65536?s[n++]=o:(o-=65536,s[n++]=55296|o>>10&1023,s[n++]=56320|1023&o)}}}return function(t,e){if(e<65534&&t.subarray&&Zt)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));for(var r="",n=0;nt.length&&(e=t.length);for(var r=e-1;r>=0&&128==(192&t[r]);)r--;return r<0?e:0===r?e:r+Ct[t[r]]>e?r:e}};var Nt=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0},Ht=Object.prototype.toString,jt=P.Z_NO_FLUSH,Kt=P.Z_SYNC_FLUSH,Vt=P.Z_FULL_FLUSH,Yt=P.Z_FINISH,Xt=P.Z_OK,Gt=P.Z_STREAM_END,Jt=P.Z_DEFAULT_COMPRESSION,Wt=P.Z_DEFAULT_STRATEGY,$t=P.Z_DEFLATED;function Qt(t){this.options=Pt.assign({level:Jt,method:$t,chunkSize:16384,windowBits:15,memLevel:8,strategy:Wt},t||{});var e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Nt,this.strm.avail_out=0;var r=Ot.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(r!==Xt)throw new Error(M[r]);if(e.header&&Ot.deflateSetHeader(this.strm,e.header),e.dictionary){var n;if(n="string"==typeof e.dictionary?Ut.string2buf(e.dictionary):"[object ArrayBuffer]"===Ht.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,(r=Ot.deflateSetDictionary(this.strm,n))!==Xt)throw new Error(M[r]);this._dict_set=!0}}function te(t,e){var r=new Qt(e);if(r.push(t,!0),r.err)throw r.msg||M[r.err];return r.result}return Qt.prototype.push=function(t,e){var r,n,i=this.strm,s=this.options.chunkSize;if(this.ended)return!1;for(n=e===~~e?e:!0===e?Yt:jt,"string"==typeof t?i.input=Ut.string2buf(t):"[object ArrayBuffer]"===Ht.call(t)?i.input=new Uint8Array(t):i.input=t,i.next_in=0,i.avail_in=i.input.length;;)if(0===i.avail_out&&(i.output=new Uint8Array(s),i.next_out=0,i.avail_out=s),(n===Kt||n===Vt)&&i.avail_out<=6)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else{if((r=Ot.deflate(i,n))===Gt)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),r=Ot.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===Xt;if(0!==i.avail_out){if(n>0&&i.next_out>0)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else if(0===i.avail_in)break}else this.onData(i.output)}return!0},Qt.prototype.onData=function(t){this.chunks.push(t)},Qt.prototype.onEnd=function(t){t===Xt&&(this.result=Pt.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg},{Deflate:Qt,deflate:te,deflateRaw:function(t,e){return(e=e||{}).raw=!0,te(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,te(t,e)},constants:P}}var sm2,sm4,hexToArray,sm4key,encryptedSm4Key,iv,oldSingleEncoder,oldBatchSender,_this,_sa,_,_config,pako,base={plugin_version:"1.19.11"};function createPlugin(t){if("object"==typeof t&&"string"==typeof t.plugin_name&&""!==t.plugin_name)return t.plugin_version=base.plugin_version,t.log=t.log||function(){"object"==typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)},t;"object"==typeof console&&"function"==typeof console.error&&console.error('plugin must contain proprerty "plugin_name"')}function getStorage(t){return new Promise(function(e){wx.getStorage({key:t,complete:function(t){e(t&&t.data)}})})}function saveStorage(t,e){return new Promise(function(r){wx.setStorage({key:t,data:e,success:function(){r(!0)},fail:function(){r(!1)}})})}var signalBatchSenderReady,encDataStoreName="sensors_mp_encrypted_data";function get128RandomByte(t){t=t||16;for(var e="";t-- >0;){var r=Math.ceil(255*_.getRandom()).toString(16);e+=2===r.length?r:"0"+r}return e}function matchType(t,e,r){return typeof t===r||(_this.log(e+" must be "+r),!1)}function isTruthy(t,e){return!!t||(_this.log(e+" cant not be null"),!1)}function isSupportSMEncryption(){try{var t=new Uint8Array(1);return t[0]=1,1===t[0]}catch(t){return!1}}function hexToBase64(t){return _.btoa(String.fromCharCode.apply(null,t.replace(/\r|\n/g,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")))}function encryptData(t){var e=t;try{_.isObject(t)&&(t=JSON.stringify(t)),t=Array.prototype.slice.call(pako.gzip(t));var r=sm4.encrypt(t,sm4key,{mode:"cbc",iv:iv});return hexToBase64(iv+r)}catch(t){_this.log("sm encryptData error: "+t.message)}return e}function encryptSingleTrackData(t){var e=encryptData(t);if(_.isString(e)){var r={pkv:_config.pkv,ekey:encryptedSm4Key,flush_time:Date.now(),payloads:[e]},n=JSON.stringify(r);return"data="+encodeURIComponent(n)+"&gzip=9"}return _this.log("SM encryption error, data will not be encrypted"),oldSingleEncoder.call(_sa.kit,t)}function convertToEncDataStruct(t){return{enc:"SM",config:{pkv:_config.pkv,ekey:encryptedSm4Key},payload:t}}function sendSingleDataImmediately(t){try{t._flush_time=Date.now();var e=_sa.kit.onceTrackData(t),r=_sa.para.server_url+"?"+e;-1!==_sa.para.server_url.indexOf("?")&&(r=_sa.para.server_url+"&"+e),_.wxrequest({url:r,method:"GET"})}catch(t){_this.log("onceSend error: "+t.message)}}function readEncStorageToMem(){return getStorage(encDataStoreName).then(t=>{if(_.isArray(t)&&t.length>0)for(var e=0;e0)for(var r=0;rsaveStorage(_sa.para.storage_prepare_data_key,[]))}function groupAndSend(t){for(var e={},r=0;r0){var a=JSON.stringify(s);a="data_list="+encodeURIComponent(a)+"&gzip=9";var h=t.length;_.wxrequest({url:_sa.para.server_url,method:"POST",dataType:"text",data:a,header:{"content-type":"text/plain"},success:function(){oldBatchSender.batchRemove.call(oldBatchSender,h)},fail:function(){oldBatchSender.sendFail.call(oldBatchSender)}})}else _this.log("group send error: no data available")}var SmBatchSend={readySignal:new Promise(function(t){signalBatchSenderReady=t}),init:function(){readEncStorageToMem().then(readLegacyStorage).then(encryptLegacyStorageData).then(persistStorage).finally(()=>{_sa.para.storage_prepare_data_key=encDataStoreName,oldBatchSender.batchInterval(),oldBatchSender.onAppHide(),oldBatchSender.sendHasInit=!0,oldBatchSender.syncStorage=!0,signalBatchSenderReady()}).catch(t=>{_this.log("sm batch-send init err"+t.message)})},send:function(t){SmBatchSend.readySignal.then(function(){if(oldBatchSender.dataHasChange=!0,_sa.store.mem.getLength()>=500&&(_this.log("storage data is too large"),_sa.store.mem.mdata.shift()),t){var e=encryptData(t);if(!_.isString(e))return _this.log("encrypt send data failed. send immediately"),void sendSingleDataImmediately(t);_sa.store.mem.add(convertToEncDataStruct(e))}oldBatchSender.sendAsOver()})},wxrequest:function(t){var e=t.data;e[0].config&&e[0].config.ekey?groupAndSend(e):_this.log("SM Encryption data error.")}};function doEncryptSM4Key(t,e){for(var r=0;r<10;){r++;var n=sm2.doEncrypt(hexToArray(t).slice(),e,1);if("0"!==n[0]||"4"!==n[1])return hexToBase64(n)}throw"generate SM4 ekey failed"}var SmEncryption={plugin_name:"SMEncryption",init:function(t,e){_=(_sa=t)._,_config=e,_this=this;try{if(!isSupportSMEncryption())return void this.log("mini base lib incompatible, data send will not be encrypted");if(!t||!t.kit||!t.kit.onceTrackData)return void this.log("SMEncryption init failed, SDK version incompatible.");var r=buildSMModule();pako=getPako(),sm2=r.sm2,sm4=r.sm4,hexToArray=sm2.hexToArray,isTruthy(e,"SMEncryption init config")&&matchType(e.pkv,"pkv","number")&&isTruthy(e.pub_key,"pub_key")&&matchType(e.pub_key,"pub_key","string")?(iv=get128RandomByte(),sm4key=get128RandomByte(),encryptedSm4Key=doEncryptSM4Key(sm4key,_config.pub_key),oldSingleEncoder=_sa.kit.onceTrackData,oldBatchSender=_sa.sendStrategy,_sa.kit.onceTrackData=encryptSingleTrackData,_sa.sendStrategy.init=SmBatchSend.init,_sa.sendStrategy.send=SmBatchSend.send,_sa.sendStrategy.wxrequest=SmBatchSend.wxrequest,_this.log("SMEncryption init succeed")):_this.log("SMEncryption init failed")}catch(t){_this.log("SMEncryption init exception: "+t)}}},index=createPlugin(SmEncryption);export default index; \ No newline at end of file +function sm(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=2)}var getSmBuildArgs=function(){var t;function e(t,e,r){null!=t&&("number"==typeof t?this.fromNumber(t,e,r):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}function r(){return new e(null)}var n="undefined"!=typeof navigator;n&&"Microsoft Internet Explorer"==navigator.appName?(e.prototype.am=function(t,e,r,n,i,s){for(var o=32767&e,a=e>>15;--s>=0;){var h=32767&this[t],u=this[t++]>>15,l=a*h+u*o;i=((h=o*h+((32767&l)<<15)+r[n]+(1073741823&i))>>>30)+(l>>>15)+a*u+(i>>>30),r[n++]=1073741823&h}return i},t=30):n&&"Netscape"!=navigator.appName?(e.prototype.am=function(t,e,r,n,i,s){for(;--s>=0;){var o=e*this[t++]+r[n]+i;i=Math.floor(o/67108864),r[n++]=67108863&o}return i},t=26):(e.prototype.am=function(t,e,r,n,i,s){for(var o=16383&e,a=e>>14;--s>=0;){var h=16383&this[t],u=this[t++]>>14,l=a*h+u*o;i=((h=o*h+((16383&l)<<14)+r[n]+i)>>28)+(l>>14)+a*u,r[n++]=268435455&h}return i},t=28),e.prototype.DB=t,e.prototype.DM=(1<>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}function c(t){this.m=t}function d(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function v(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function b(){}function w(t){return t}function S(t){this.r2=r(),this.q3=r(),e.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}c.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},c.prototype.revert=function(t){return t},c.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},c.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},c.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},d.prototype.convert=function(t){var n=r();return t.abs().dlShiftTo(this.m.t,n),n.divRemTo(this.m,null,n),t.s<0&&n.compareTo(e.ZERO)>0&&this.m.subTo(n,n),n},d.prototype.revert=function(t){var e=r();return t.copyTo(e),this.reduce(e),e},d.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e>15)*this.mpl&this.um)<<15)&t.DM;for(t[r=e+this.m.t]+=this.m.am(0,n,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},d.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},d.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},e.prototype.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},e.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},e.prototype.fromString=function(t,r){if(!r&&t.length>=2&&"0"===t[0]){var n=!0;switch(t[1]){case"x":r=16;break;case"b":r=2;break;case"o":r=8;break;default:n=!1}n&&(t=t.substr(2))}var i;if(16==r)i=4;else if(8==r)i=3;else if(256==r)i=8;else if(2==r)i=1;else if(32==r)i=5;else{if(4!=r)return void this.fromRadix(t,r);i=2}this.t=0,this.s=0;for(var s=t.length,o=!1,a=0;--s>=0;){var h=8==i?255&t[s]:u(t,s);h<0?"-"==t.charAt(s)&&(o=!0):(o=!1,0==a?this[this.t++]=h:a+i>this.DB?(this[this.t-1]|=(h&(1<>this.DB-a):this[this.t-1]|=h<=this.DB&&(a-=this.DB))}8==i&&0!=(128&t[0])&&(this.s=-1,a>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==t;)--this.t},e.prototype.dlShiftTo=function(t,e){var r;for(r=this.t-1;r>=0;--r)e[r+t]=this[r];for(r=t-1;r>=0;--r)e[r]=0;e.t=this.t+t,e.s=this.s},e.prototype.drShiftTo=function(t,e){for(var r=t;r=0;--r)e[r+o+1]=this[r]>>i|a,a=(this[r]&s)<=0;--r)e[r]=0;e[o]=a,e.t=this.t+o+1,e.s=this.s,e.clamp()},e.prototype.rShiftTo=function(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var n=t%this.DB,i=this.DB-n,s=(1<>n;for(var o=r+1;o>n;n>0&&(e[this.t-r-1]|=(this.s&s)<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[r++]=this.DV+n:n>0&&(e[r++]=n),e.t=r,e.clamp()},e.prototype.multiplyTo=function(t,r){var n=this.abs(),i=t.abs(),s=n.t;for(r.t=s+i.t;--s>=0;)r[s]=0;for(s=0;s=0;)t[r]=0;for(r=0;r=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()},e.prototype.divRemTo=function(t,n,i){var s=t.abs();if(!(s.t<=0)){var o=this.abs();if(o.t0?(s.lShiftTo(l,a),o.lShiftTo(l,i)):(s.copyTo(a),o.copyTo(i));var c=a.t,d=a[c-1];if(0!=d){var p=d*(1<1?a[c-2]>>this.F2:0),_=this.FV/p,g=(1<=0&&(i[i.t++]=1,i.subTo(b,i)),e.ONE.dlShiftTo(c,b),b.subTo(a,a);a.t=0;){var w=i[--y]==d?this.DM:Math.floor(i[y]*_+(i[y-1]+m)*g);if((i[y]+=a.am(0,w,i,v,0,c))0&&i.rShiftTo(l,i),h<0&&e.ZERO.subTo(i,i)}}},e.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},e.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},e.prototype.exp=function(t,n){if(t>4294967295||t<1)return e.ONE;var i=r(),s=r(),o=n.convert(this),a=f(t)-1;for(o.copyTo(i);--a>=0;)if(n.sqrTo(i,s),(t&1<0)n.mulTo(s,o,i);else{var h=i;i=s,s=h}return n.revert(i)},e.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var r,n=(1<0)for(a>a)>0&&(i=!0,s=h(r));o>=0;)a>(a+=this.DB-e)):(r=this[o]>>(a-=e)&n,a<=0&&(a+=this.DB,--o)),r>0&&(i=!0),i&&(s+=h(r));return i?s:"0"},e.prototype.negate=function(){var t=r();return e.ZERO.subTo(this,t),t},e.prototype.abs=function(){return this.s<0?this.negate():this},e.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(0!=(e=r-t.t))return this.s<0?-e:e;for(;--r>=0;)if(0!=(e=this[r]-t[r]))return e;return 0},e.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+f(this[this.t-1]^this.s&this.DM)},e.prototype.mod=function(t){var n=r();return this.abs().divRemTo(t,null,n),this.s<0&&n.compareTo(e.ZERO)>0&&t.subTo(n,n),n},e.prototype.modPowInt=function(t,e){var r;return r=t<256||e.isEven()?new c(e):new d(e),this.exp(t,r)},e.ZERO=l(0),e.ONE=l(1),b.prototype.convert=w,b.prototype.revert=w,b.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r)},b.prototype.sqrTo=function(t,e){t.squareTo(e)},S.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=r();return t.copyTo(e),this.reduce(e),e},S.prototype.revert=function(t){return t},S.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},S.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},S.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var T,x,F,B=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],E=(1<<26)/B[B.length-1];function k(){var t;t=(new Date).getTime(),x[F++]^=255&t,x[F++]^=t>>8&255,x[F++]^=t>>16&255,x[F++]^=t>>24&255,F>=q&&(F-=q)}if(e.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},e.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),n=Math.pow(t,e),i=l(n),s=r(),o=r(),a="";for(this.divRemTo(i,s,o);s.signum()>0;)a=(n+o.intValue()).toString(t).substr(1)+a,s.divRemTo(i,s,o);return o.intValue().toString(t)+a},e.prototype.fromRadix=function(t,r){this.fromInt(0),null==r&&(r=10);for(var n=this.chunkSize(r),i=Math.pow(r,n),s=!1,o=0,a=0,h=0;h=n&&(this.dMultiply(i),this.dAddOffset(a,0),o=0,a=0))}o>0&&(this.dMultiply(Math.pow(r,o)),this.dAddOffset(a,0)),s&&e.ZERO.subTo(this,this)},e.prototype.fromNumber=function(t,r,n){if("number"==typeof r)if(t<2)this.fromInt(1);else for(this.fromNumber(t,n),this.testBit(t-1)||this.bitwiseTo(e.ONE.shiftLeft(t-1),_,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(r);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(e.ONE.shiftLeft(t-1),this);else{var i=new Array,s=7&t;i.length=1+(t>>3),r.nextBytes(i),s>0?i[0]&=(1<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e[r++]=n:n<-1&&(e[r++]=this.DV+n),e.t=r,e.clamp()},e.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},e.prototype.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},e.prototype.multiplyLowerTo=function(t,e,r){var n,i=Math.min(this.t+t.t,e);for(r.s=0,r.t=i;i>0;)r[--i]=0;for(n=r.t-this.t;i=0;)r[n]=0;for(n=Math.max(e-this.t,0);n0)if(0==e)r=this[0]%t;else for(var n=this.t-1;n>=0;--n)r=(e*r+this[n])%t;return r},e.prototype.millerRabin=function(t){var n=this.subtract(e.ONE),i=n.getLowestSetBit();if(i<=0)return!1;var s=n.shiftRight(i);(t=t+1>>1)>B.length&&(t=B.length);for(var o=r(),a=0;a>24},e.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},e.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},e.prototype.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var r,n=this.DB-t*this.DB%8,i=0;if(t-- >0)for(n>n)!=(this.s&this.DM)>>n&&(e[i++]=r|this.s<=0;)n<8?(r=(this[t]&(1<>(n+=this.DB-8)):(r=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),0!=(128&r)&&(r|=-256),0==i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(e[i++]=r);return e},e.prototype.equals=function(t){return 0==this.compareTo(t)},e.prototype.min=function(t){return this.compareTo(t)<0?this:t},e.prototype.max=function(t){return this.compareTo(t)>0?this:t},e.prototype.and=function(t){var e=r();return this.bitwiseTo(t,p,e),e},e.prototype.or=function(t){var e=r();return this.bitwiseTo(t,_,e),e},e.prototype.xor=function(t){var e=r();return this.bitwiseTo(t,g,e),e},e.prototype.andNot=function(t){var e=r();return this.bitwiseTo(t,m,e),e},e.prototype.not=function(){for(var t=r(),e=0;e=this.t?0!=this.s:0!=(this[e]&1<1){var _=r();for(i.sqrTo(a[1],_);h<=p;)a[h]=r(),i.mulTo(_,a[h-2],a[h]),h+=2}var g,m,y=t.t-1,v=!0,b=r();for(s=f(t[y])-1;y>=0;){for(s>=u?g=t[y]>>s-u&p:(g=(t[y]&(1<0&&(g|=t[y-1]>>this.DB+s-u)),h=n;0==(1&g);)g>>=1,--h;if((s-=h)<0&&(s+=this.DB,--y),v)a[g].copyTo(o),v=!1;else{for(;h>1;)i.sqrTo(o,b),i.sqrTo(b,o),h-=2;h>0?i.sqrTo(o,b):(m=o,o=b,b=m),i.mulTo(b,a[g],o)}for(;y>=0&&0==(t[y]&1<=0?(n.subTo(i,n),r&&s.subTo(a,s),o.subTo(h,o)):(i.subTo(n,i),r&&a.subTo(s,a),h.subTo(o,h))}return 0!=i.compareTo(e.ONE)?e.ZERO:h.compareTo(t)>=0?h.subtract(t):h.signum()<0?(h.addTo(t,h),h.signum()<0?h.add(t):h):h},e.prototype.pow=function(t){return this.exp(t,new b)},e.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var n=e;e=r,r=n}var i=e.getLowestSetBit(),s=r.getLowestSetBit();if(s<0)return e;for(i0&&(e.rShiftTo(s,e),r.rShiftTo(s,r));e.signum()>0;)(i=e.getLowestSetBit())>0&&e.rShiftTo(i,e),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return s>0&&r.lShiftTo(s,r),r},e.prototype.isProbablePrime=function(t){var e,r=this.abs();if(1==r.t&&r[0]<=B[B.length-1]){for(e=0;e>>8,x[F++]=255&D;F=0,k()}function I(){if(null==T){for(k(),(T=new O).init(x),F=0;F>>32-r}function o(t,e){for(var r=[],n=t.length-1;n>=0;n--)r[n]=255&(t[n]^e[n]);return r}function a(t){return t^s(t,9)^s(t,17)}function h(t){var e=8*t.length,r=e%512;r=r>=448?512-r%448-1:448-r-1;for(var o=new Array((r-7)/8),h=new Array(8),u=0,l=o.length;u=0;d--)if(e.length>8){var p=e.length-8;h[d]=parseInt(e.substr(p),2),e=e.substr(0,p)}else e.length>0&&(h[d]=parseInt(e,2),e="");for(var _,g=new Uint8Array([].concat(t,[128],o,h)),m=new DataView(g.buffer,0),y=g.length/64,v=new Uint32Array([1937774191,1226093241,388252375,3666478592,2842636476,372324522,3817729613,2969243214]),b=0;b=0&&Z<=15?2043430169:2055708042,q=(Z>=0&&Z<=15?B^E^k:B&E|B&k|E&k)+D+((O=s(s(B,12)+A+s(P,Z),7))^s(B,12))+i[Z],M=(Z>=0&&Z<=15?A^z^I:A&z|~A&I)+R+O+n[Z],D=k,k=s(E,9),E=B,B=q,R=I,I=s(z,19),z=A,A=a(M);v[0]^=B,v[1]^=E,v[2]^=k,v[3]^=D,v[4]^=A,v[5]^=z,v[6]^=I,v[7]^=R}for(var C=[],L=0,U=v.length;L>>24,(16711680&N)>>>16,(65280&N)>>>8,255&N)}return C}for(var u=64,l=new Uint8Array(u),f=new Uint8Array(u),c=0;cu&&(e=h(e));e.length2&&void 0!==arguments[2]?arguments[2]:"1234567812345678";r=a.utf8ToHex(r);var n=a.leftPad(l.curve.a.toBigInteger().toRadix(16),64),i=a.leftPad(l.curve.b.toBigInteger().toRadix(16),64),s=a.leftPad(l.getX().toBigInteger().toRadix(16),64),o=a.leftPad(l.getY().toBigInteger().toRadix(16),64),u=void 0,f=void 0;if(128===e.length)u=e.substr(0,64),f=e.substr(64,64);else{var c=l.curve.decodePointHex(e);u=a.leftPad(c.getX().toBigInteger().toRadix(16),64),f=a.leftPad(c.getY().toBigInteger().toRadix(16),64)}var d=a.hexToArray(r+n+i+s+o+u+f),p=4*r.length;d.unshift(255&p),d.unshift(p>>8&255);var _=h(d);return a.arrayToHex(h(_.concat(a.hexToArray(t))))}function _(){var t=a.generateKeyPairHex(),e=f.decodePointHex(t.publicKey);return t.k=new n(t.privateKey,16),t.x1=e.getX().toBigInteger(),t}t.exports={generateKeyPairHex:a.generateKeyPairHex,compressPublicKeyHex:a.compressPublicKeyHex,comparePublicKeyHex:a.comparePublicKeyHex,doEncrypt:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;t="string"==typeof t?a.hexToArray(a.utf8ToHex(t)):Array.prototype.slice.call(t),e=a.getGlobalCurve().decodePointHex(e);var i=a.generateKeyPairHex(),s=new n(i.privateKey,16),o=i.publicKey;o.length>128&&(o=o.substr(o.length-128));var u=e.multiply(s),l=a.hexToArray(a.leftPad(u.getX().toBigInteger().toRadix(16),64)),f=a.hexToArray(a.leftPad(u.getY().toBigInteger().toRadix(16),64)),c=a.arrayToHex(h([].concat(l,t,f))),p=1,_=0,g=[],m=[].concat(l,f),y=function(){g=h([].concat(m,[p>>24&255,p>>16&255,p>>8&255,255&p])),p++,_=0};y();for(var v=0,b=t.length;v2&&void 0!==arguments[2]?arguments[2]:1,i=(arguments.length>3&&void 0!==arguments[3]?arguments[3]:{}).output,s=void 0===i?"string":i;e=new n(e,16);var o=t.substr(128,64),u=t.substr(192);r===d&&(o=t.substr(t.length-64),u=t.substr(128,t.length-128-64));var l=a.hexToArray(u),f=a.getGlobalCurve().decodePointHex("04"+t.substr(0,128)).multiply(e),c=a.hexToArray(a.leftPad(f.getX().toBigInteger().toRadix(16),64)),p=a.hexToArray(a.leftPad(f.getY().toBigInteger().toRadix(16),64)),_=1,g=0,m=[],y=[].concat(c,p),v=function(){m=h([].concat(y,[_>>24&255,_>>16&255,_>>8&255,255&_])),_++,g=0};v();for(var b=0,w=l.length;b2&&void 0!==arguments[2]?arguments[2]:{},i=r.pointPool,o=r.der,h=r.hash,u=r.publicKey,f=r.userId,d="string"==typeof t?a.utf8ToHex(t):a.arrayToHex(t);h&&(d=p(d,u=u||function(t){var e=l.multiply(new n(t,16)),r=a.leftPad(e.getX().toBigInteger().toString(16),64),i=a.leftPad(e.getY().toBigInteger().toString(16),64);return"04"+r+i}(e),f));var g=new n(e,16),m=new n(d,16),y=null,v=null,b=null;do{do{var w=void 0;y=(w=i&&i.length?i.pop():_()).k,v=m.add(w.x1).mod(c)}while(v.equals(n.ZERO)||v.add(y).equals(c));b=g.add(n.ONE).modInverse(c).multiply(y.subtract(v.multiply(g))).mod(c)}while(b.equals(n.ZERO));return o?s(v,b):a.leftPad(v.toString(16),64)+a.leftPad(b.toString(16),64)},doVerifySignature:function(t,e,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},s=i.der,h=i.hash,u=i.userId,d="string"==typeof t?a.utf8ToHex(t):a.arrayToHex(t);h&&(d=p(d,r,u));var _=void 0,g=void 0;if(s){var m=o(e);_=m.r,g=m.s}else _=new n(e.substring(0,64),16),g=new n(e.substring(64),16);var y=f.decodePointHex(r),v=new n(d,16),b=_.add(g).mod(c);if(b.equals(n.ZERO))return!1;var w=l.multiply(g).add(y.multiply(b)),S=v.add(w.getX().toBigInteger()).mod(c);return _.equals(S)},getPoint:_,verifyPublicKey:a.verifyPublicKey,hexToArray:a.hexToArray}},function(t,e,r){function n(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function s(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var o=r(0).BigInteger;var a=function(){function t(){s(this,t),this.tlv=null,this.t="00",this.l="00",this.v=""}return t.prototype.getEncodedHex=function(){return this.tlv||(this.v=this.getValue(),this.l=this.getLength(),this.tlv=this.t+this.l+this.v),this.tlv},t.prototype.getLength=function(){var t=this.v.length/2,e=t.toString(16);return e.length%2==1&&(e="0"+e),t<128?e:(128+e.length/2).toString(16)+e},t.prototype.getValue=function(){return""},t}(),h=function(t){function e(r){s(this,e);var i=n(this,t.call(this));return i.t="02",r&&(i.v=function(t){var e=t.toString(16);if("-"!==e[0])e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e);else{var r=(e=e.substr(1)).length;r%2==1?r+=1:e.match(/^[0-7]/)||(r+=2);for(var n="",i=0;i=e?t:new Array(e-t.length+1).join("0")+t}t.exports={getGlobalCurve:function(){return u},generateEcparam:c,generateKeyPairHex:function(t,e,r){var n=(t?new i(t,e,r):new i(f.bitLength(),a)).mod(f.subtract(i.ONE)).add(i.ONE),s=d(n.toString(16),64),o=l.multiply(n);return{privateKey:s,publicKey:"04"+d(o.getX().toBigInteger().toString(16),64)+d(o.getY().toBigInteger().toString(16),64)}},compressPublicKeyHex:function(t){if(130!==t.length)throw new Error("Invalid public key to compress");var e=(t.length-2)/2,r=t.substr(2,e),n="03";return new i(t.substr(e+2,e),16).mod(new i("2")).equals(i.ZERO)&&(n="02"),n+r},utf8ToHex:function(t){for(var e=(t=unescape(encodeURIComponent(t))).length,r=[],n=0;n>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;for(var i=[],s=0;s>>2]>>>24-s%4*8&255;i.push((o>>>4).toString(16)),i.push((15&o).toString(16))}return i.join("")},leftPad:d,arrayToHex:function(t){return t.map(function(t){return 1===(t=t.toString(16)).length?"0"+t:t}).join("")},arrayToUtf8:function(t){for(var e=[],r=0,n=0;n<2*t.length;n+=2)e[n>>>3]|=parseInt(t[r],10)<<24-n%8*4,r++;try{for(var i=[],s=0;s>>2]>>>24-s%4*8&255;i.push(String.fromCharCode(o))}return decodeURIComponent(escape(i.join("")))}catch(t){throw new Error("Malformed UTF-8 data")}},hexToArray:function(t){var e=[],r=t.length;r%2!=0&&(t=d(t,r+1)),r=t.length;for(var n=0;n0;i--){n=n.twice();var s=e.testBit(i);s!==t.testBit(i)&&(n=n.add(s?this:r))}return n},t}(),u=function(){function t(e,r,i){n(this,t),this.q=e,this.a=this.fromBigInteger(r),this.b=this.fromBigInteger(i),this.infinity=new h(this,null,null)}return t.prototype.equals=function(t){return t===this||this.q.equals(t.q)&&this.a.equals(t.a)&&this.b.equals(t.b)},t.prototype.fromBigInteger=function(t){return new a(this.q,t)},t.prototype.decodePointHex=function(t){switch(parseInt(t.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:var e=this.fromBigInteger(new i(t.substr(2),16)),r=this.fromBigInteger(e.multiply(e.square()).add(e.multiply(this.a)).add(this.b).toBigInteger().modPow(this.q.divide(new i("4")).add(i.ONE),this.q));return r.toBigInteger().mod(s).equals(new i(t.substr(0,2),16).subtract(s))||(r=r.negate()),new h(this,e,r);case 4:case 6:case 7:var n=(t.length-2)/2,o=t.substr(2,n),a=t.substr(n+2,n);return new h(this,this.fromBigInteger(new i(o,16)),this.fromBigInteger(new i(a,16)));default:return null}},t}();t.exports={ECPointFp:h,ECCurveFp:u}},function(t,e,r){var n=r(1),i=n.sm3,s=n.hmac;function o(t){return t.map(function(t){return 1===(t=t.toString(16)).length?"0"+t:t}).join("")}function a(t){var e,r,n=[],i=t.length;i%2!=0&&(r=i+1,t=(e=t).length>=r?e:new Array(r-e.length+1).join("0")+e),i=t.length;for(var s=0;s>>6),e.push(128|63&i);else if(i<=55295||i>=57344&&i<=65535)e.push(224|i>>>12),e.push(128|i>>>6&63),e.push(128|63&i);else{if(!(i>=65536&&i<=1114111))throw e.push(i),new Error("input is not supported");r++,e.push(240|i>>>18&28),e.push(128|i>>>12&63),e.push(128|i>>>6&63),e.push(128|63&i)}}return e}(t):Array.prototype.slice.call(t),e){if("hmac"!==(e.mode||"hmac"))throw new Error("invalid mode");var r=e.key;if(!r)throw new Error("invalid key");return r="string"==typeof r?a(r):Array.prototype.slice.call(r),o(s(t,r))}return o(i(t))}},function(t,e,r){var n=0,i=32,s=16,o=[214,144,233,254,204,225,61,183,22,182,20,194,40,251,44,5,43,103,154,118,42,190,4,195,170,68,19,38,73,134,6,153,156,66,80,244,145,239,152,122,51,84,11,67,237,207,172,98,228,179,28,169,201,8,232,149,128,223,148,250,117,143,63,166,71,7,167,252,243,115,23,186,131,89,60,25,230,133,79,168,104,107,129,178,113,100,218,139,248,235,15,75,112,86,157,53,30,36,14,94,99,88,209,162,37,34,124,59,1,33,120,135,212,0,70,87,159,211,39,82,76,54,2,231,160,196,200,158,234,191,138,210,64,199,56,181,163,247,242,206,249,97,21,161,224,174,93,164,155,52,26,85,173,147,50,48,245,140,177,227,29,246,226,46,130,102,202,96,192,41,35,171,13,83,78,111,213,219,55,69,222,253,142,47,3,255,106,114,109,108,91,81,141,27,175,146,187,221,188,127,17,217,92,65,31,16,90,216,10,193,49,136,165,205,123,189,45,116,208,18,184,229,180,176,137,105,151,74,12,150,119,126,101,185,241,9,197,110,198,132,24,240,125,236,58,220,77,32,121,238,95,62,215,203,57,72],a=[462357,472066609,943670861,1415275113,1886879365,2358483617,2830087869,3301692121,3773296373,4228057617,404694573,876298825,1347903077,1819507329,2291111581,2762715833,3234320085,3705924337,4177462797,337322537,808926789,1280531041,1752135293,2223739545,2695343797,3166948049,3638552301,4110090761,269950501,741554753,1213159005,1684763257];function h(t){for(var e=[],r=0,n=t.length;r>>32-r}function l(t){return(255&o[t>>>24&255])<<24|(255&o[t>>>16&255])<<16|(255&o[t>>>8&255])<<8|255&o[255&t]}function f(t){return t^u(t,2)^u(t,10)^u(t,18)^u(t,24)}function c(t){return t^u(t,13)^u(t,23)}function d(t,e,r){for(var n=new Array(4),i=new Array(4),s=0;s<4;s++)i[0]=255&t[4*s],i[1]=255&t[4*s+1],i[2]=255&t[4*s+2],i[3]=255&t[4*s+3],n[s]=i[0]<<24|i[1]<<16|i[2]<<8|i[3];for(var o,a=0;a<32;a+=4)o=n[1]^n[2]^n[3]^r[a+0],n[0]^=f(l(o)),o=n[2]^n[3]^n[0]^r[a+1],n[1]^=f(l(o)),o=n[3]^n[0]^n[1]^r[a+2],n[2]^=f(l(o)),o=n[0]^n[1]^n[2]^r[a+3],n[3]^=f(l(o));for(var h=0;h<16;h+=4)e[h]=n[3-h/4]>>>24&255,e[h+1]=n[3-h/4]>>>16&255,e[h+2]=n[3-h/4]>>>8&255,e[h+3]=255&n[3-h/4]}function p(t,e,r){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},u=o.padding,f=void 0===u?"pkcs#7":u,p=o.mode,_=o.iv,g=void 0===_?[]:_,m=o.output,y=void 0===m?"string":m;if("cbc"===p&&("string"==typeof g&&(g=h(g)),16!==g.length))throw new Error("iv is invalid");if("string"==typeof e&&(e=h(e)),16!==e.length)throw new Error("key is invalid");if(t="string"==typeof t?r!==n?function(t){for(var e=[],r=0,n=t.length;r>>6),e.push(128|63&i);else if(i<=55295||i>=57344&&i<=65535)e.push(224|i>>>12),e.push(128|i>>>6&63),e.push(128|63&i);else{if(!(i>=65536&&i<=1114111))throw e.push(i),new Error("input is not supported");r++,e.push(240|i>>>18&28),e.push(128|i>>>12&63),e.push(128|i>>>6&63),e.push(128|63&i)}}return e}(t):h(t):[].concat(t),("pkcs#5"===f||"pkcs#7"===f)&&r!==n)for(var v=s-t.length%s,b=0;b=s;){var B=t.slice(F,F+16),E=new Array(16);if("cbc"===p)for(var k=0;k=240&&t[r]<=247?(e.push(String.fromCodePoint(((7&t[r])<<18)+((63&t[r+1])<<12)+((63&t[r+2])<<6)+(63&t[r+3]))),r+=3):t[r]>=224&&t[r]<=239?(e.push(String.fromCodePoint(((15&t[r])<<12)+((63&t[r+1])<<6)+(63&t[r+2]))),r+=2):t[r]>=192&&t[r]<=223?(e.push(String.fromCodePoint(((31&t[r])<<6)+(63&t[r+1]))),r++):e.push(String.fromCodePoint(t[r]));return e.join("")}(S):S}t.exports={encrypt:function(t,e,r){return p(t,e,1,r)},decrypt:function(t,e,r){return p(t,e,0,r)}}}]};function buildSMModule(){return sm(getSmBuildArgs())}function getPako(){function t(t){for(var e=t.length;--e>=0;)t[e]=0}var e=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),r=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),n=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),i=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),s=new Array(576);t(s);var o=new Array(60);t(o);var a=new Array(512);t(a);var h=new Array(256);t(h);var u=new Array(29);t(u);var l,f,c,d=new Array(30);function p(t,e,r,n,i){this.static_tree=t,this.extra_bits=e,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=t&&t.length}function _(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}t(d);var g=function(t){return t<256?a[t]:a[256+(t>>>7)]},m=function(t,e){t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},y=function(t,e,r){t.bi_valid>16-r?(t.bi_buf|=e<>16-t.bi_valid,t.bi_valid+=r-16):(t.bi_buf|=e<>>=1,r<<=1}while(--e>0);return r>>>1},w=function(t,e,r){var n,i,s=new Array(16),o=0;for(n=1;n<=15;n++)o=o+r[n-1]<<1,s[n]=o;for(i=0;i<=e;i++){var a=t[2*i+1];0!==a&&(t[2*i]=b(s[a]++,a))}},S=function(t){var e;for(e=0;e<286;e++)t.dyn_ltree[2*e]=0;for(e=0;e<30;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.sym_next=t.matches=0},T=function(t){t.bi_valid>8?m(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},x=function(t,e,r,n){var i=2*e,s=2*r;return t[i]>1;r>=1;r--)F(t,s,r);i=h;do{r=t.heap[1],t.heap[1]=t.heap[t.heap_len--],F(t,s,1),n=t.heap[1],t.heap[--t.heap_max]=r,t.heap[--t.heap_max]=n,s[2*i]=s[2*r]+s[2*n],t.depth[i]=(t.depth[r]>=t.depth[n]?t.depth[r]:t.depth[n])+1,s[2*r+1]=s[2*n+1]=i,t.heap[1]=i++,F(t,s,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],function(t,e){var r,n,i,s,o,a,h=e.dyn_tree,u=e.max_code,l=e.stat_desc.static_tree,f=e.stat_desc.has_stree,c=e.stat_desc.extra_bits,d=e.stat_desc.extra_base,p=e.stat_desc.max_length,_=0;for(s=0;s<=15;s++)t.bl_count[s]=0;for(h[2*t.heap[t.heap_max]+1]=0,r=t.heap_max+1;r<573;r++)(s=h[2*h[2*(n=t.heap[r])+1]+1]+1)>p&&(s=p,_++),h[2*n+1]=s,n>u||(t.bl_count[s]++,o=0,n>=d&&(o=c[n-d]),a=h[2*n],t.opt_len+=a*(s+o),f&&(t.static_len+=a*(l[2*n+1]+o)));if(0!==_){do{for(s=p-1;0===t.bl_count[s];)s--;t.bl_count[s]--,t.bl_count[s+1]+=2,t.bl_count[p]--,_-=2}while(_>0);for(s=p;0!==s;s--)for(n=t.bl_count[s];0!==n;)(i=t.heap[--r])>u||(h[2*i+1]!==s&&(t.opt_len+=(s-h[2*i+1])*h[2*i],h[2*i+1]=s),n--)}}(t,e),w(s,u,t.bl_count)},k=function(t,e,r){var n,i,s=-1,o=e[1],a=0,h=7,u=4;for(0===o&&(h=138,u=3),e[2*(r+1)+1]=65535,n=0;n<=r;n++)i=o,o=e[2*(n+1)+1],++a>=7;g<30;g++)for(d[g]=m<<7,t=0;t<1<0?(2===t.strm.data_type&&(t.strm.data_type=function(t){var e,r=4093624447;for(e=0;e<=31;e++,r>>>=1)if(1&r&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<256;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0}(t)),E(t,t.l_desc),E(t,t.d_desc),u=function(t){var e;for(k(t,t.dyn_ltree,t.l_desc.max_code),k(t,t.dyn_dtree,t.d_desc.max_code),E(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*i[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e}(t),a=t.opt_len+3+7>>>3,(h=t.static_len+3+7>>>3)<=a&&(a=h)):a=h=r+5,r+4<=a&&-1!==e?z(t,e,r,n):4===t.strategy||h===a?(y(t,2+(n?1:0),3),B(t,s,o)):(y(t,4+(n?1:0),3),function(t,e,r,n){var s;for(y(t,e-257,5),y(t,r-1,5),y(t,n-4,4),s=0;s>8,t.pending_buf[t.sym_buf+t.sym_next++]=r,0===e?t.dyn_ltree[2*r]++:(t.matches++,e--,t.dyn_ltree[2*(h[r]+256+1)]++,t.dyn_dtree[2*g(e)]++),t.sym_next===t.sym_end},_tr_align:function(t){y(t,2,3),v(t,256,s),function(t){16===t.bi_valid?(m(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}(t)}},R=function(t,e,r,n){for(var i=65535&t|0,s=t>>>16&65535|0,o=0;0!==r;){r-=o=r>2e3?2e3:r;do{s=s+(i=i+e[n++]|0)|0}while(--o);i%=65521,s%=65521}return i|s<<16|0},O=new Uint32Array(function(){for(var t,e=[],r=0;r<256;r++){t=r;for(var n=0;n<8;n++)t=1&t?3988292384^t>>>1:t>>>1;e[r]=t}return e}()),q=function(t,e,r,n){var i=O,s=n+r;t^=-1;for(var o=n;o>>8^i[255&(t^e[o])];return-1^t},M={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},P={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},Z=I._tr_init,C=I._tr_stored_block,L=I._tr_flush_block,U=I._tr_tally,N=I._tr_align,H=P.Z_NO_FLUSH,j=P.Z_PARTIAL_FLUSH,K=P.Z_FULL_FLUSH,V=P.Z_FINISH,Y=P.Z_BLOCK,X=P.Z_OK,G=P.Z_STREAM_END,J=P.Z_STREAM_ERROR,W=P.Z_DATA_ERROR,$=P.Z_BUF_ERROR,Q=P.Z_DEFAULT_COMPRESSION,tt=P.Z_FILTERED,et=P.Z_HUFFMAN_ONLY,rt=P.Z_RLE,nt=P.Z_FIXED,it=P.Z_DEFAULT_STRATEGY,st=P.Z_UNKNOWN,ot=P.Z_DEFLATED,at=286,ht=30,ut=19,lt=2*at+1,ft=15,ct=function(t,e){return t.msg=M[e],e},dt=function(t){return 2*t-(t>4?9:0)},pt=function(t){for(var e=t.length;--e>=0;)t[e]=0},_t=function(t){var e,r,n,i=t.w_size;n=e=t.hash_size;do{r=t.head[--n],t.head[n]=r>=i?r-i:0}while(--e);n=e=i;do{r=t.prev[--n],t.prev[n]=r>=i?r-i:0}while(--e)},gt=function(t,e,r){return(e<t.avail_out&&(r=t.avail_out),0!==r&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+r),t.next_out),t.next_out+=r,e.pending_out+=r,t.total_out+=r,t.avail_out-=r,e.pending-=r,0===e.pending&&(e.pending_out=0))},yt=function(t,e){L(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,mt(t.strm)},vt=function(t,e){t.pending_buf[t.pending++]=e},bt=function(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},wt=function(t,e,r,n){var i=t.avail_in;return i>n&&(i=n),0===i?0:(t.avail_in-=i,e.set(t.input.subarray(t.next_in,t.next_in+i),r),1===t.state.wrap?t.adler=R(t.adler,e,i,r):2===t.state.wrap&&(t.adler=q(t.adler,e,i,r)),t.next_in+=i,t.total_in+=i,i)},St=function(t,e){var r,n,i=t.max_chain_length,s=t.strstart,o=t.prev_length,a=t.nice_match,h=t.strstart>t.w_size-262?t.strstart-(t.w_size-262):0,u=t.window,l=t.w_mask,f=t.prev,c=t.strstart+258,d=u[s+o-1],p=u[s+o];t.prev_length>=t.good_match&&(i>>=2),a>t.lookahead&&(a=t.lookahead);do{if(u[(r=e)+o]===p&&u[r+o-1]===d&&u[r]===u[s]&&u[++r]===u[s+1]){s+=2,r++;do{}while(u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&so){if(t.match_start=e,o=n,n>=a)break;d=u[s+o-1],p=u[s+o]}}}while((e=f[e&l])>h&&0!=--i);return o<=t.lookahead?o:t.lookahead},Tt=function(t){var e,r,n,i=t.w_size;do{if(r=t.window_size-t.lookahead-t.strstart,t.strstart>=i+(i-262)&&(t.window.set(t.window.subarray(i,i+i-r),0),t.match_start-=i,t.strstart-=i,t.block_start-=i,t.insert>t.strstart&&(t.insert=t.strstart),_t(t),r+=i),0===t.strm.avail_in)break;if(e=wt(t.strm,t.window,t.strstart+t.lookahead,r),t.lookahead+=e,t.lookahead+t.insert>=3)for(n=t.strstart-t.insert,t.ins_h=t.window[n],t.ins_h=gt(t,t.ins_h,t.window[n+1]);t.insert&&(t.ins_h=gt(t,t.ins_h,t.window[n+3-1]),t.prev[n&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=n,n++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<262&&0!==t.strm.avail_in)},xt=function(t,e){var r,n,i,s=t.pending_buf_size-5>t.w_size?t.w_size:t.pending_buf_size-5,o=0,a=t.strm.avail_in;do{if(r=65535,i=t.bi_valid+42>>3,t.strm.avail_out(n=t.strstart-t.block_start)+t.strm.avail_in&&(r=n+t.strm.avail_in),r>i&&(r=i),r>8,t.pending_buf[t.pending-2]=~r,t.pending_buf[t.pending-1]=~r>>8,mt(t.strm),n&&(n>r&&(n=r),t.strm.output.set(t.window.subarray(t.block_start,t.block_start+n),t.strm.next_out),t.strm.next_out+=n,t.strm.avail_out-=n,t.strm.total_out+=n,t.block_start+=n,r-=n),r&&(wt(t.strm,t.strm.output,t.strm.next_out,r),t.strm.next_out+=r,t.strm.avail_out-=r,t.strm.total_out+=r)}while(0===o);return(a-=t.strm.avail_in)&&(a>=t.w_size?(t.matches=2,t.window.set(t.strm.input.subarray(t.strm.next_in-t.w_size,t.strm.next_in),0),t.strstart=t.w_size,t.insert=t.strstart):(t.window_size-t.strstart<=a&&(t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,t.insert>t.strstart&&(t.insert=t.strstart)),t.window.set(t.strm.input.subarray(t.strm.next_in-a,t.strm.next_in),t.strstart),t.strstart+=a,t.insert+=a>t.w_size-t.insert?t.w_size-t.insert:a),t.block_start=t.strstart),t.high_wateri&&t.block_start>=t.w_size&&(t.block_start-=t.w_size,t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,i+=t.w_size,t.insert>t.strstart&&(t.insert=t.strstart)),i>t.strm.avail_in&&(i=t.strm.avail_in),i&&(wt(t.strm,t.window,t.strstart,i),t.strstart+=i,t.insert+=i>t.w_size-t.insert?t.w_size-t.insert:i),t.high_water>3,s=(i=t.pending_buf_size-i>65535?65535:t.pending_buf_size-i)>t.w_size?t.w_size:i,((n=t.strstart-t.block_start)>=s||(n||e===V)&&e!==H&&0===t.strm.avail_in&&n<=i)&&(r=n>i?i:n,o=e===V&&0===t.strm.avail_in&&r===n?1:0,C(t,t.block_start,r,o),t.block_start+=r,mt(t.strm)),o?3:1)},Ft=function(t,e){for(var r,n;;){if(t.lookahead<262){if(Tt(t),t.lookahead<262&&e===H)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=gt(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==r&&t.strstart-r<=t.w_size-262&&(t.match_length=St(t,r)),t.match_length>=3)if(n=U(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=gt(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=gt(t,t.ins_h,t.window[t.strstart+1]);else n=U(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(n&&(yt(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===V?(yt(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(yt(t,!1),0===t.strm.avail_out)?1:2},Bt=function(t,e){for(var r,n,i;;){if(t.lookahead<262){if(Tt(t),t.lookahead<262&&e===H)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=gt(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==r&&t.prev_length4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){i=t.strstart+t.lookahead-3,n=U(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=i&&(t.ins_h=gt(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,n&&(yt(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if((n=U(t,0,t.window[t.strstart-1]))&&yt(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(n=U(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===V?(yt(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(yt(t,!1),0===t.strm.avail_out)?1:2};function Et(t,e,r,n,i){this.good_length=t,this.max_lazy=e,this.nice_length=r,this.max_chain=n,this.func=i}var kt=[new Et(0,0,0,0,xt),new Et(4,4,8,4,Ft),new Et(4,5,16,8,Ft),new Et(4,6,32,32,Ft),new Et(4,4,16,16,Bt),new Et(8,16,32,32,Bt),new Et(8,16,128,128,Bt),new Et(8,32,128,256,Bt),new Et(32,128,258,1024,Bt),new Et(32,258,258,4096,Bt)];function Dt(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=ot,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(2*lt),this.dyn_dtree=new Uint16Array(2*(2*ht+1)),this.bl_tree=new Uint16Array(2*(2*ut+1)),pt(this.dyn_ltree),pt(this.dyn_dtree),pt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(ft+1),this.heap=new Uint16Array(2*at+1),pt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*at+1),pt(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}var At=function(t){if(!t)return 1;var e=t.state;return!e||e.strm!==t||42!==e.status&&57!==e.status&&69!==e.status&&73!==e.status&&91!==e.status&&103!==e.status&&113!==e.status&&666!==e.status?1:0},zt=function(t){if(At(t))return ct(t,J);t.total_in=t.total_out=0,t.data_type=st;var e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=2===e.wrap?57:e.wrap?42:113,t.adler=2===e.wrap?0:1,e.last_flush=-2,Z(e),X},It=function(t){var e,r=zt(t);return r===X&&((e=t.state).window_size=2*e.w_size,pt(e.head),e.max_lazy_match=kt[e.level].max_lazy,e.good_match=kt[e.level].good_length,e.nice_match=kt[e.level].nice_length,e.max_chain_length=kt[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=2,e.match_available=0,e.ins_h=0),r},Rt=function(t,e,r,n,i,s){if(!t)return J;var o=1;if(e===Q&&(e=6),n<0?(o=0,n=-n):n>15&&(o=2,n-=16),i<1||i>9||r!==ot||n<8||n>15||e<0||e>9||s<0||s>nt||8===n&&1!==o)return ct(t,J);8===n&&(n=9);var a=new Dt;return t.state=a,a.strm=t,a.status=42,a.wrap=o,a.gzhead=null,a.w_bits=n,a.w_size=1<Y||e<0)return t?ct(t,J):J;var r=t.state;if(!t.output||0!==t.avail_in&&!t.input||666===r.status&&e!==V)return ct(t,0===t.avail_out?$:J);var n=r.last_flush;if(r.last_flush=e,0!==r.pending){if(mt(t),0===t.avail_out)return r.last_flush=-1,X}else if(0===t.avail_in&&dt(e)<=dt(n)&&e!==V)return ct(t,$);if(666===r.status&&0!==t.avail_in)return ct(t,$);if(42===r.status&&0===r.wrap&&(r.status=113),42===r.status){var i=ot+(r.w_bits-8<<4)<<8;if(i|=(r.strategy>=et||r.level<2?0:r.level<6?1:6===r.level?2:3)<<6,0!==r.strstart&&(i|=32),bt(r,i+=31-i%31),0!==r.strstart&&(bt(r,t.adler>>>16),bt(r,65535&t.adler)),t.adler=1,r.status=113,mt(t),0!==r.pending)return r.last_flush=-1,X}if(57===r.status)if(t.adler=0,vt(r,31),vt(r,139),vt(r,8),r.gzhead)vt(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),vt(r,255&r.gzhead.time),vt(r,r.gzhead.time>>8&255),vt(r,r.gzhead.time>>16&255),vt(r,r.gzhead.time>>24&255),vt(r,9===r.level?2:r.strategy>=et||r.level<2?4:0),vt(r,255&r.gzhead.os),r.gzhead.extra&&r.gzhead.extra.length&&(vt(r,255&r.gzhead.extra.length),vt(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(t.adler=q(t.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=69;else if(vt(r,0),vt(r,0),vt(r,0),vt(r,0),vt(r,0),vt(r,9===r.level?2:r.strategy>=et||r.level<2?4:0),vt(r,3),r.status=113,mt(t),0!==r.pending)return r.last_flush=-1,X;if(69===r.status){if(r.gzhead.extra){for(var s=r.pending,o=(65535&r.gzhead.extra.length)-r.gzindex;r.pending+o>r.pending_buf_size;){var a=r.pending_buf_size-r.pending;if(r.pending_buf.set(r.gzhead.extra.subarray(r.gzindex,r.gzindex+a),r.pending),r.pending=r.pending_buf_size,r.gzhead.hcrc&&r.pending>s&&(t.adler=q(t.adler,r.pending_buf,r.pending-s,s)),r.gzindex+=a,mt(t),0!==r.pending)return r.last_flush=-1,X;s=0,o-=a}var h=new Uint8Array(r.gzhead.extra);r.pending_buf.set(h.subarray(r.gzindex,r.gzindex+o),r.pending),r.pending+=o,r.gzhead.hcrc&&r.pending>s&&(t.adler=q(t.adler,r.pending_buf,r.pending-s,s)),r.gzindex=0}r.status=73}if(73===r.status){if(r.gzhead.name){var u,l=r.pending;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>l&&(t.adler=q(t.adler,r.pending_buf,r.pending-l,l)),mt(t),0!==r.pending)return r.last_flush=-1,X;l=0}u=r.gzindexl&&(t.adler=q(t.adler,r.pending_buf,r.pending-l,l)),r.gzindex=0}r.status=91}if(91===r.status){if(r.gzhead.comment){var f,c=r.pending;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>c&&(t.adler=q(t.adler,r.pending_buf,r.pending-c,c)),mt(t),0!==r.pending)return r.last_flush=-1,X;c=0}f=r.gzindexc&&(t.adler=q(t.adler,r.pending_buf,r.pending-c,c))}r.status=103}if(103===r.status){if(r.gzhead.hcrc){if(r.pending+2>r.pending_buf_size&&(mt(t),0!==r.pending))return r.last_flush=-1,X;vt(r,255&t.adler),vt(r,t.adler>>8&255),t.adler=0}if(r.status=113,mt(t),0!==r.pending)return r.last_flush=-1,X}if(0!==t.avail_in||0!==r.lookahead||e!==H&&666!==r.status){var d=0===r.level?xt(r,e):r.strategy===et?function(t,e){for(var r;;){if(0===t.lookahead&&(Tt(t),0===t.lookahead)){if(e===H)return 1;break}if(t.match_length=0,r=U(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,r&&(yt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===V?(yt(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(yt(t,!1),0===t.strm.avail_out)?1:2}(r,e):r.strategy===rt?function(t,e){for(var r,n,i,s,o=t.window;;){if(t.lookahead<=258){if(Tt(t),t.lookahead<=258&&e===H)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(n=o[i=t.strstart-1])===o[++i]&&n===o[++i]&&n===o[++i]){s=t.strstart+258;do{}while(n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&it.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(r=U(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(r=U(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),r&&(yt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===V?(yt(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(yt(t,!1),0===t.strm.avail_out)?1:2}(r,e):kt[r.level].func(r,e);if(3!==d&&4!==d||(r.status=666),1===d||3===d)return 0===t.avail_out&&(r.last_flush=-1),X;if(2===d&&(e===j?N(r):e!==Y&&(C(r,0,0,!1),e===K&&(pt(r.head),0===r.lookahead&&(r.strstart=0,r.block_start=0,r.insert=0))),mt(t),0===t.avail_out))return r.last_flush=-1,X}return e!==V?X:r.wrap<=0?G:(2===r.wrap?(vt(r,255&t.adler),vt(r,t.adler>>8&255),vt(r,t.adler>>16&255),vt(r,t.adler>>24&255),vt(r,255&t.total_in),vt(r,t.total_in>>8&255),vt(r,t.total_in>>16&255),vt(r,t.total_in>>24&255)):(bt(r,t.adler>>>16),bt(r,65535&t.adler)),mt(t),r.wrap>0&&(r.wrap=-r.wrap),0!==r.pending?X:G)},deflateEnd:function(t){if(At(t))return J;var e=t.state.status;return t.state=null,113===e?ct(t,W):X},deflateSetDictionary:function(t,e){var r=e.length;if(At(t))return J;var n=t.state,i=n.wrap;if(2===i||1===i&&42!==n.status||n.lookahead)return J;if(1===i&&(t.adler=R(t.adler,e,r,0)),n.wrap=0,r>=n.w_size){0===i&&(pt(n.head),n.strstart=0,n.block_start=0,n.insert=0);var s=new Uint8Array(n.w_size);s.set(e.subarray(r-n.w_size,r),0),e=s,r=n.w_size}var o=t.avail_in,a=t.next_in,h=t.input;for(t.avail_in=r,t.next_in=0,t.input=e,Tt(n);n.lookahead>=3;){var u=n.strstart,l=n.lookahead-2;do{n.ins_h=gt(n,n.ins_h,n.window[u+3-1]),n.prev[u&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=u,u++}while(--l);n.strstart=u,n.lookahead=2,Tt(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,t.next_in=a,t.input=h,t.avail_in=o,n.wrap=i,X},deflateInfo:"pako deflate (from Nodeca project)"};function qt(t){return(qt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var Mt=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},Pt={assign:function(t){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var r=e.shift();if(r){if("object"!==qt(r))throw new TypeError(r+"must be non-object");for(var n in r)Mt(r,n)&&(t[n]=r[n])}}return t},flattenChunks:function(t){for(var e=0,r=0,n=t.length;r=252?6:Lt>=248?5:Lt>=240?4:Lt>=224?3:Lt>=192?2:1;Ct[254]=Ct[254]=1;var Ut={string2buf:function(t){if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);var e,r,n,i,s,o=t.length,a=0;for(i=0;i>>6,e[s++]=128|63&r):r<65536?(e[s++]=224|r>>>12,e[s++]=128|r>>>6&63,e[s++]=128|63&r):(e[s++]=240|r>>>18,e[s++]=128|r>>>12&63,e[s++]=128|r>>>6&63,e[s++]=128|63&r);return e},buf2string:function(t,e){var r,n,i=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));var s=new Array(2*i);for(n=0,r=0;r4)s[n++]=65533,r+=a-1;else{for(o&=2===a?31:3===a?15:7;a>1&&r1?s[n++]=65533:o<65536?s[n++]=o:(o-=65536,s[n++]=55296|o>>10&1023,s[n++]=56320|1023&o)}}}return function(t,e){if(e<65534&&t.subarray&&Zt)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));for(var r="",n=0;nt.length&&(e=t.length);for(var r=e-1;r>=0&&128==(192&t[r]);)r--;return r<0?e:0===r?e:r+Ct[t[r]]>e?r:e}};var Nt=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0},Ht=Object.prototype.toString,jt=P.Z_NO_FLUSH,Kt=P.Z_SYNC_FLUSH,Vt=P.Z_FULL_FLUSH,Yt=P.Z_FINISH,Xt=P.Z_OK,Gt=P.Z_STREAM_END,Jt=P.Z_DEFAULT_COMPRESSION,Wt=P.Z_DEFAULT_STRATEGY,$t=P.Z_DEFLATED;function Qt(t){this.options=Pt.assign({level:Jt,method:$t,chunkSize:16384,windowBits:15,memLevel:8,strategy:Wt},t||{});var e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Nt,this.strm.avail_out=0;var r=Ot.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(r!==Xt)throw new Error(M[r]);if(e.header&&Ot.deflateSetHeader(this.strm,e.header),e.dictionary){var n;if(n="string"==typeof e.dictionary?Ut.string2buf(e.dictionary):"[object ArrayBuffer]"===Ht.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,(r=Ot.deflateSetDictionary(this.strm,n))!==Xt)throw new Error(M[r]);this._dict_set=!0}}function te(t,e){var r=new Qt(e);if(r.push(t,!0),r.err)throw r.msg||M[r.err];return r.result}return Qt.prototype.push=function(t,e){var r,n,i=this.strm,s=this.options.chunkSize;if(this.ended)return!1;for(n=e===~~e?e:!0===e?Yt:jt,"string"==typeof t?i.input=Ut.string2buf(t):"[object ArrayBuffer]"===Ht.call(t)?i.input=new Uint8Array(t):i.input=t,i.next_in=0,i.avail_in=i.input.length;;)if(0===i.avail_out&&(i.output=new Uint8Array(s),i.next_out=0,i.avail_out=s),(n===Kt||n===Vt)&&i.avail_out<=6)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else{if((r=Ot.deflate(i,n))===Gt)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),r=Ot.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===Xt;if(0!==i.avail_out){if(n>0&&i.next_out>0)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else if(0===i.avail_in)break}else this.onData(i.output)}return!0},Qt.prototype.onData=function(t){this.chunks.push(t)},Qt.prototype.onEnd=function(t){t===Xt&&(this.result=Pt.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg},{Deflate:Qt,deflate:te,deflateRaw:function(t,e){return(e=e||{}).raw=!0,te(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,te(t,e)},constants:P}}var sm2,sm4,hexToArray,sm4key,encryptedSm4Key,iv,oldSingleEncoder,oldBatchSender,_this,_sa,_,_config,pako,base={plugin_version:"1.19.12"};function createPlugin(t){if("object"==typeof t&&"string"==typeof t.plugin_name&&""!==t.plugin_name)return t.plugin_version=base.plugin_version,t.log=t.log||function(){"object"==typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)},t;"object"==typeof console&&"function"==typeof console.error&&console.error('plugin must contain proprerty "plugin_name"')}function getStorage(t){return new Promise(function(e){wx.getStorage({key:t,complete:function(t){e(t&&t.data)}})})}function saveStorage(t,e){return new Promise(function(r){wx.setStorage({key:t,data:e,success:function(){r(!0)},fail:function(){r(!1)}})})}var signalBatchSenderReady,encDataStoreName="sensors_mp_encrypted_data";function get128RandomByte(t){t=t||16;for(var e="";t-- >0;){var r=Math.ceil(255*_.getRandom()).toString(16);e+=2===r.length?r:"0"+r}return e}function matchType(t,e,r){return typeof t===r||(_this.log(e+" must be "+r),!1)}function isTruthy(t,e){return!!t||(_this.log(e+" cant not be null"),!1)}function isSupportSMEncryption(){try{var t=new Uint8Array(1);return t[0]=1,1===t[0]}catch(t){return!1}}function hexToBase64(t){return _.btoa(String.fromCharCode.apply(null,t.replace(/\r|\n/g,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")))}function encryptData(t){var e=t;try{_.isObject(t)&&(t=JSON.stringify(t)),t=Array.prototype.slice.call(pako.gzip(t));var r=sm4.encrypt(t,sm4key,{mode:"cbc",iv:iv});return hexToBase64(iv+r)}catch(t){_this.log("sm encryptData error: "+t.message)}return e}function encryptSingleTrackData(t){var e=encryptData(t);if(_.isString(e)){var r={pkv:_config.pkv,ekey:encryptedSm4Key,flush_time:Date.now(),payloads:[e]},n=JSON.stringify(r);return"data="+encodeURIComponent(n)+"&gzip=9"}return _this.log("SM encryption error, data will not be encrypted"),oldSingleEncoder.call(_sa.kit,t)}function convertToEncDataStruct(t){return{enc:"SM",config:{pkv:_config.pkv,ekey:encryptedSm4Key},payload:t}}function sendSingleDataImmediately(t){try{t._flush_time=Date.now();var e=_sa.kit.onceTrackData(t),r=_sa.para.server_url+"?"+e;-1!==_sa.para.server_url.indexOf("?")&&(r=_sa.para.server_url+"&"+e),_.wxrequest({url:r,method:"GET"})}catch(t){_this.log("onceSend error: "+t.message)}}function readEncStorageToMem(){return getStorage(encDataStoreName).then(t=>{if(_.isArray(t)&&t.length>0)for(var e=0;e0)for(var r=0;rsaveStorage(_sa.para.storage_prepare_data_key,[]))}function groupAndSend(t){for(var e={},r=0;r0){var a=JSON.stringify(s);a="data_list="+encodeURIComponent(a)+"&gzip=9";var h=t.length;_.wxrequest({url:_sa.para.server_url,method:"POST",dataType:"text",data:a,header:{"content-type":"text/plain"},success:function(){oldBatchSender.batchRemove.call(oldBatchSender,h)},fail:function(){oldBatchSender.sendFail.call(oldBatchSender)}})}else _this.log("group send error: no data available")}var SmBatchSend={readySignal:new Promise(function(t){signalBatchSenderReady=t}),init:function(){readEncStorageToMem().then(readLegacyStorage).then(encryptLegacyStorageData).then(persistStorage).finally(()=>{_sa.para.storage_prepare_data_key=encDataStoreName,oldBatchSender.batchInterval(),oldBatchSender.onAppHide(),oldBatchSender.sendHasInit=!0,oldBatchSender.syncStorage=!0,signalBatchSenderReady()}).catch(t=>{_this.log("sm batch-send init err"+t.message)})},send:function(t){SmBatchSend.readySignal.then(function(){if(oldBatchSender.dataHasChange=!0,_sa.store.mem.getLength()>=500&&(_this.log("storage data is too large"),_sa.store.mem.mdata.shift()),t){var e=encryptData(t);if(!_.isString(e))return _this.log("encrypt send data failed. send immediately"),void sendSingleDataImmediately(t);_sa.store.mem.add(convertToEncDataStruct(e))}oldBatchSender.sendAsOver()})},wxrequest:function(t){var e=t.data;e[0].config&&e[0].config.ekey?groupAndSend(e):_this.log("SM Encryption data error.")}};function doEncryptSM4Key(t,e){for(var r=0;r<10;){r++;var n=sm2.doEncrypt(hexToArray(t).slice(),e,1);if("0"!==n[0]||"4"!==n[1])return hexToBase64(n)}throw"generate SM4 ekey failed"}var SmEncryption={plugin_name:"SMEncryption",init:function(t,e){_=(_sa=t)._,_config=e,_this=this;try{if(!isSupportSMEncryption())return void this.log("mini base lib incompatible, data send will not be encrypted");if(!t||!t.kit||!t.kit.onceTrackData)return void this.log("SMEncryption init failed, SDK version incompatible.");var r=buildSMModule();pako=getPako(),sm2=r.sm2,sm4=r.sm4,hexToArray=sm2.hexToArray,isTruthy(e,"SMEncryption init config")&&matchType(e.pkv,"pkv","number")&&isTruthy(e.pub_key,"pub_key")&&matchType(e.pub_key,"pub_key","string")?(iv=get128RandomByte(),sm4key=get128RandomByte(),encryptedSm4Key=doEncryptSM4Key(sm4key,_config.pub_key),oldSingleEncoder=_sa.kit.onceTrackData,oldBatchSender=_sa.sendStrategy,_sa.kit.onceTrackData=encryptSingleTrackData,_sa.sendStrategy.init=SmBatchSend.init,_sa.sendStrategy.send=SmBatchSend.send,_sa.sendStrategy.wxrequest=SmBatchSend.wxrequest,_this.log("SMEncryption init succeed")):_this.log("SMEncryption init failed")}catch(t){_this.log("SMEncryption init exception: "+t)}}},index=createPlugin(SmEncryption);export default index; \ No newline at end of file diff --git a/dist/wechat/sensorsdata.cjs.js b/dist/wechat/sensorsdata.cjs.js index dbc7326..67d4653 100644 --- a/dist/wechat/sensorsdata.cjs.js +++ b/dist/wechat/sensorsdata.cjs.js @@ -1 +1 @@ -"use strict";var sa={},saPara={name:"sensors",server_url:"",send_timeout:1e3,show_log:!1,login_id_key:"$identity_login_id",allow_amend_share_path:!0,max_string_length:500,datasend_timeout:3e3,source_channel:[],autoTrack:{appLaunch:!0,appShow:!0,appHide:!0,pageShow:!0,pageShare:!0,mpClick:!1,mpFavorite:!0,pageLeave:!1},autotrack_exclude_page:{pageShow:[],pageLeave:[]},is_persistent_save:{share:!1,utm:!1},preset_properties:{url_path:!0},preset_events:{moments_page:!1,defer_track:!1,share_info_use_string:!1},batch_send:!0,storage_store_key:"sensorsdata2015_wechat",storage_prepare_data_key:"sensors_mp_prepare_data"};function log(){if(saPara.show_log&&"object"==typeof console&&console.log)try{return console.log.apply(console,arguments)}catch(e){console.log(arguments[0])}}var nativeIsArray=Array.isArray,ObjProto=Object.prototype,ArrayProto=Array.prototype,nativeForEach=ArrayProto.forEach,nativeIndexOf=ArrayProto.indexOf,toString=ObjProto.toString,hasOwnProperty=ObjProto.hasOwnProperty,slice=ArrayProto.slice;function each(e,t,a){if(null==e)return!1;var r={};if(nativeForEach&&e.forEach===nativeForEach)e.forEach(t,a);else if(e.length===+e.length){for(var i=0,n=e.length;i0&&each(this.store_queue,function(e){sa[e.method].apply(sa,slice.call(e.params))}),this.store_queue=[])}};function _decodeURIComponent(e){var t="";try{t=decodeURIComponent(e)}catch(a){t=e}return t}var hasOwnProperty$2=Object.prototype.hasOwnProperty,decodeURIComponent$1=_decodeURIComponent;function initAppGlobalName(){var e=App;App=function(t){t[saPara.name]=sa,e.apply(this,arguments)}}function getPublicPresetProperties(){var e=getRefPage(),t=getCurrentPageInfo(),a={$referrer:e.route,$referrer_title:e.title,$title:t.title,$url:t.url};return!0===saPara.preset_properties.url_path&&(a.$url_path=t.path),a}function encodeDates(e){return each(e,function(t,a){isDate(t)?e[a]=formatDate(t):isObject(t)&&(e[a]=encodeDates(t))}),e}function formatDate(e){function t(e){return e<10?"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())}function searchObjDate(e){(isObject(e)||isArray(e))&&each(e,function(t,a){isObject(t)||isArray(t)?searchObjDate(e[a]):isDate(t)&&(e[a]=formatDate(t))})}function formatString(e){return e.length>saPara.max_string_length?(log("\u5b57\u7b26\u4e32\u957f\u5ea6\u8d85\u8fc7\u9650\u5236\uff0c\u5df2\u7ecf\u505a\u622a\u53d6--"+e),e.slice(0,saPara.max_string_length)):e}function searchObjString(e){isObject(e)&&each(e,function(t,a){isObject(t)?searchObjString(e[a]):isString(t)&&(e[a]=formatString(t))})}function parseSuperProperties(e){isObject(e)&&each(e,function(t,a){if(isFunction(t))try{e[a]=t(),isFunction(e[a])&&(log("\u60a8\u7684\u5c5e\u6027- "+a+" \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[a])}catch(t){delete e[a],log("\u60a8\u7684\u5c5e\u6027- "+a+" \u629b\u51fa\u4e86\u5f02\u5e38\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}})}function unique(e){for(var t,a=[],r={},i=0;i255)||(log("id \u957f\u5ea6\u8d85\u8fc7 255 \u4e2a\u5b57\u7b26\uff01"),!1)}};function strip_sa_properties(e){return isObject(e)?(each(e,function(t,a){if(isArray(t)){var r=[];each(t,function(e){if(isString(e))r.push(e);else if(isUndefined(e))r.push("null");else try{r.push(JSON.stringify(e))}catch(e){log("\u60a8\u7684\u6570\u636e - "+a+":"+t+" - \u7684\u6570\u7ec4\u91cc\u7684\u503c\u6709\u9519\u8bef,\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}}),e[a]=r}if(isObject(t))try{e[a]=JSON.stringify(t)}catch(r){delete e[a],log("\u60a8\u7684\u6570\u636e - "+a+":"+t+" - \u7684\u6570\u636e\u503c\u6709\u9519\u8bef,\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}else isString(t)||isNumber(t)||isDate(t)||isBoolean(t)||isArray(t)||(log("\u60a8\u7684\u6570\u636e - "+a+":"+t+" - \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[a])}),e):e}function strip_empty_properties(e){var t={};return each(e,function(e,a){null==e&&void 0===e||(t[a]=e)}),t}function utf8Encode(e){var t,a,r,i,n="";for(t=a=0,r=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,i=0;i127&&s<2048?String.fromCharCode(s>>6|192,63&s|128):String.fromCharCode(s>>12|224,s>>6&63|128,63&s|128),null!==o&&(a>t&&(n+=e.substring(t,a)),n+=o,t=a=i+1)}return a>t&&(n+=e.substring(t,e.length)),n}function base64Encode(e){var t,a,r,i,n,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,u=0,c="",p=[];if(!e)return e;e=utf8Encode(e);do{t=(n=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>18&63,a=n>>12&63,r=n>>6&63,i=63&n,p[u++]=s.charAt(t)+s.charAt(a)+s.charAt(r)+s.charAt(i)}while(o255||(r=e.charCodeAt(o++))>255||(i=e.charCodeAt(o++))>255)&&log("Failed to execute 'btoa' : The string to be encoded contains characters outside of the Latin1 range."),s+=n.charAt((t=a<<16|r<<8|i)>>18&63)+n.charAt(t>>12&63)+n.charAt(t>>6&63)+n.charAt(63&t);return u?s.slice(0,u-3)+"===".substring(u):s}function urlBase64Encode(e){return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}))}function getCurrentPage(){var e={};try{var t=getCurrentPages();e=t[t.length-1]}catch(e){log(e)}return e}function getCurrentPath(){var e="\u672a\u53d6\u5230";try{var t=getCurrentPage();e=t?t.route:e}catch(e){log(e)}return e}function getIsFirstDay(){return!!("object"==typeof store._state&&isNumber(store._state.first_visit_day_time)&&store._state.first_visit_day_time>(new Date).getTime())}function getCurrentUrl(e){var t=getCurrentPath(),a="";return isObject(e)&&e.sensors_mp_encode_url_query&&(a=e.sensors_mp_encode_url_query),t?a?t+"?"+a:t:"\u672a\u53d6\u5230"}function getPath(e){return e=isString(e)?e.replace(/^\//,""):"\u53d6\u503c\u5f02\u5e38"}function getCustomUtmFromQuery(e,t,a,r){if(!isObject(e))return{};var i={};if(e.sa_utm)for(var n in e)"sa_utm"!==n?include(saPara.source_channel,n)&&(i[a+n]=e[n]):i[r+n]=e[n];else for(var s in e)-1===(" "+SOURCE_CHANNEL_STANDARD+" ").indexOf(" "+s+" ")?include(saPara.source_channel,s)&&(i[a+s]=e[s]):i[t+s]=e[s];return i}function getObjFromQuery(e){var t=e.split("?"),a=[],r={};return t&&t[1]?(each(t[1].split("&"),function(e){(a=e.split("="))[0]&&a[1]&&(r[a[0]]=a[1])}),r):{}}function setStorageSync(e,t){var a=function(){wx.setStorageSync(e,t)};try{a()}catch(e){log("set Storage fail --",e);try{a()}catch(e){log("set Storage fail again --",e)}}}function getStorageSync(e){var t="";try{t=wx.getStorageSync(e)}catch(e){log("getStorage fail")}return t}function getMPScene(e){return isNumber(e)||isString(e)&&""!==e?e="wx-"+String(e):"\u672a\u53d6\u5230\u503c"}function objToParam(e,t){if(!isObject(e))return log("\u8bf7\u4f20\u5165\u6709\u6548\u5bf9\u8c61"),"";var a=[];for(var r in e)if(hasOwnProperty$2.call(e,r)){var i=e[r];void 0===i?a.push(r+"="):(i=t?encodeURIComponent(i):i,a.push(r+"="+i))}return a.join("&")}function delObjectKey(e){if(isObject(e))for(var t=0;t=2?(meta.page_route_map.shift(),meta.page_route_map.push(e)):meta.page_route_map.push(e)}}catch(e){log(e)}}function getRefPage(){var e={route:"\u76f4\u63a5\u6253\u5f00",path:"\u76f4\u63a5\u6253\u5f00",title:""};return meta.page_route_map.length>1&&(e.title=meta.page_route_map[0].title,e.route=meta.page_route_map[0].route,e.path=meta.page_route_map[0].path),e}function getCurrentPageInfo(){var e=getCurrentPage(),t={title:"",url:"",path:"\u672a\u53d6\u5230"};if(e&&e.route){var a=e.sensors_mp_url_query?"?"+e.sensors_mp_url_query:"";t.title=getPageTitle(e.route),t.url=e.route+a,t.path=e.route}return t}function setPageRefData(e,t,a){var r=getRefPage();isObject(e)&&(t?meta.page_route_map.length>0&&t?(a=a?"?"+a:"",e.$referrer=getPath(t)+a,e.$referrer_title=getPageTitle(t)):(e.$referrer="\u76f4\u63a5\u6253\u5f00",e.$referrer_title=""):(e.$referrer=r.route,e.$referrer_title=r.title))}function getPageTitle(e){if("\u672a\u53d6\u5230"===e||!e)return"";var t="";try{if(__wxConfig){var a=__wxConfig,r=__wxConfig.page||{},i=r[e]||r[e+".html"],n={},s={};if(a.global&&a.global.window&&a.global.window.navigationBarTitleText&&(n.titleVal=a.global.window.navigationBarTitleText),i&&i.window&&i.window.navigationBarTitleText&&(s.titleVal=i.window.navigationBarTitleText),!s.titleVal&&__wxAppCode__){var o=__wxAppCode__[e+".json"];o&&o.navigationBarTitleText&&(s.titleVal=o.navigationBarTitleText)}if(each(meta.global_title,function(a,r){if(r===e)return t=a}),0===t.length){var u=extend(n,s);t=u.titleVal||""}}}catch(e){log(e)}return t}function wxrequest(e){if(compareSDKVersion(meta.wx_sdk_version,"2.10.0")>=0)e.timeout=saPara.datasend_timeout,wx.request(e);else{var t=wx.request(e);setTimeout(function(){isObject(t)&&isFunction(t.abort)&&t.abort()},saPara.datasend_timeout)}}function validId(e){return"string"!=typeof e&&"number"!=typeof e||""===e?(log("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1):"number"!=typeof e||(e=String(e),/^\d+$/.test(e))?!!check.checkIdLength(e)&&e:(log("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1)}function compareSDKVersion(e,t){e=e.split("."),t=t.split(".");for(var a=Math.max(e.length,t.length);e.lengthn)return 1;if(i{wx.getNetworkType({success:function(t){meta.preset_properties.$network_type=setUpperCase(t.networkType),e()},fail:function(e){log("\u83b7\u53d6\u7f51\u7edc\u4fe1\u606f\u5931\u8d25",e),t()}})})}function getSystemInfo(){var e=meta.preset_properties;return new Promise(t=>{wx.getSystemInfo({success:function(a){var r,i;e.$brand=setUpperCase(a.brand),e.$manufacturer=a.brand,e.$model=a.model,e.$screen_width=Number(a.screenWidth),e.$screen_height=Number(a.screenHeight),e.$os=(r=a.platform,"ios"===(i=r.toLowerCase())?"iOS":"android"===i?"Android":r),e.$os_version=a.system.indexOf(" ")>-1?a.system.split(" ")[1]:a.system,meta.wx_sdk_version=a.SDKVersion,e.$mp_client_app_version=a.version,e.$mp_client_basic_library_version=meta.wx_sdk_version;var n=(new Date).getTimezoneOffset(),s=getAppInfoSync();isNumber(n)&&(e.$timezone_offset=n),s.appId&&(e.$app_id=s.appId),s.appVersion&&(e.$app_version=s.appVersion),t()}})})}var info={currentProps:meta.preset_properties},logger={info:function(){if(saPara.show_log&&"object"==typeof console&&console.log)try{if(3===arguments.length)return console.log(arguments[0],arguments[1],arguments[2]);if(2===arguments.length)return console.log(arguments[0],arguments[1]);if(1===arguments.length)return console.log(arguments[0])}catch(e){console.log(arguments[0])}}};function isValidListener(e){return"function"==typeof e||!(!e||"object"!=typeof e)&&isValidListener(e.listener)}class EventEmitterBase{constructor(){this._events={}}on(e,t){if(!e||!t)return!1;if(!isValidListener(t))throw new Error("listener must be a function");this._events[e]=this._events[e]||[];var a="object"==typeof t;return this._events[e].push(a?t:{listener:t,once:!1}),this}prepend(e,t){if(!e||!t)return!1;if(!isValidListener(t))throw new Error("listener must be a function");this._events[e]=this._events[e]||[];var a="object"==typeof t;return this._events[e].unshift(a?t:{listener:t,once:!1}),this}prependOnce(e,t){return this.prepend(e,{listener:t,once:!0})}once(e,t){return this.on(e,{listener:t,once:!0})}off(e,t){var a=this._events[e];if(!a)return!1;if("number"==typeof t)a.splice(t,1);else if("function"==typeof t)for(var r=0,i=a.length;r0&&this.cacheEvents.forEach(function(a){a.type===e&&t.call(null,a.data)})}emit(e,t){super.emit.apply(this,arguments),this.cacheEvents.push({type:e,data:t}),this.cacheEvents.length>this.maxLen&&this.cacheEvents.shift()}}var _=Object.freeze({__proto__:null,decodeURIComponent:decodeURIComponent$1,encodeDates:encodeDates,formatDate:formatDate,searchObjDate:searchObjDate,formatString:formatString,searchObjString:searchObjString,parseSuperProperties:parseSuperProperties,unique:unique,check:check,getUtmFromPage:getUtmFromPage,setQuery:setQuery,setLatestShare:setLatestShare,setLatestChannel:setLatestChannel,setUpperCase:setUpperCase,compareSDKVersion:compareSDKVersion,validId:validId,wxrequest:wxrequest,getPageTitle:getPageTitle,setPageRefData:setPageRefData,getCurrentPageInfo:getCurrentPageInfo,getRefPage:getRefPage,setRefPage:setRefPage,setPageSfSource:setPageSfSource,setSfSource:setSfSource,setUtm:setUtm,getMixedQuery:getMixedQuery,detectOptionQuery:detectOptionQuery,getShareInfo:getShareInfo,setShareInfo:setShareInfo,shareInfoData:shareInfoData,delObjectKey:delObjectKey,objToParam:objToParam,getMPScene:getMPScene,getStorageSync:getStorageSync,setStorageSync:setStorageSync,getObjFromQuery:getObjFromQuery,getCustomUtmFromQuery:getCustomUtmFromQuery,getPath:getPath,getCurrentUrl:getCurrentUrl,getIsFirstDay:getIsFirstDay,getCurrentPath:getCurrentPath,getCurrentPage:getCurrentPage,urlBase64Encode:urlBase64Encode,btoa:btoa,base64Encode:base64Encode,strip_empty_properties:strip_empty_properties,strip_sa_properties:strip_sa_properties,setNavigationBarTitle:setNavigationBarTitle,networkStatusChange:networkStatusChange,getNetworkType:getNetworkType,getSystemInfo:getSystemInfo,encodeTrackData:encodeTrackData,initAppGlobalName:initAppGlobalName,getPublicPresetProperties:getPublicPresetProperties,setPublicProperties:setPublicProperties,isPresetIdKeys:isPresetIdKeys,isNewLoginId:isNewLoginId,isSameAndAnonymousID:isSameAndAnonymousID,info:info,logger:logger,getAppId:getAppId,getAppInfoSync:getAppInfoSync,getOpenidNameByAppid:getOpenidNameByAppid,rot13defs:rot13defs,rot13obfs:rot13obfs,each:each,isObject:isObject,getRandom:getRandom,extend:extend,extend2Lev:extend2Lev,coverExtend:coverExtend,isArray:isArray,isFunction:isFunction,isArguments:isArguments,toArray:toArray,values:values,include:include,trim:trim,isEmptyObject:isEmptyObject,deepCopy:deepCopy,isUndefined:isUndefined,isString:isString,isDate:isDate,isBoolean:isBoolean,isNumber:isNumber,isJSONString:isJSONString,isInteger:isInteger,isSafeInteger:isSafeInteger,slice:slice,urlSafeBase64:urlSafeBase64,EventEmitterBase:EventEmitterBase,EventEmitterEx:EventEmitterEx,log:log});function onEventSend(){return{}}function processData(e){return e}function batchTrackData(e){var t=Date.now();return e.forEach(function(e){e._flush_time=t}),"data_list="+encodeTrackData(e)}var mergeStorageData={getData:function(e){wx.getStorage({key:saPara.storage_prepare_data_key,complete:function(t){var a=t.data&&isArray(t.data)?t.data:[];mergeStorageData.deleteAesData(a),e&&e()}})},deleteAesData:function(e){var t=[],a=e.length;if(a>0){for(var r=0;r=saPara.batch_send.max_length&&this.batchSend()},wxrequest:function(e){if(isArray(e.data)&&e.data.length>0){var t=kit.batchTrackData(e.data);sa._.wxrequest({url:saPara.server_url,method:"POST",dataType:"text",data:t,header:{"content-type":"text/plain"},success:function(){e.success(e.len)},fail:function(){e.fail()}})}else e.success(e.len)},batchSend:function(){if(this.dataHasSend){var e,t,a=store.mem.mdata;(t=(e=a.length>=100?a.slice(0,100):a).length)>0&&(this.dataHasSend=!1,this.wxrequest({data:e,len:t,success:this.batchRemove.bind(this),fail:this.sendFail.bind(this)}))}},sendFail:function(){this.dataHasSend=!0,this.failTime++},batchRemove:function(e){store.mem.clear(e),this.dataHasSend=!0,this.dataHasChange=!0,this.batchWrite(),this.failTime=0},is_first_batch_write:!0,batchWrite:function(){this.dataHasChange&&(this.dataHasChange=!1,this.syncStorage&&sa._.setStorageSync(saPara.storage_prepare_data_key,store.mem.mdata))},batchInterval:function(){var e=this;!function t(){setTimeout(function(){e.batchWrite(),t()},500)}(),function t(){setTimeout(function(){e.batchSend(),t()},saPara.batch_send.send_timeout*Math.pow(2,e.failTime))}()}};function onceSend(e){e._flush_time=Date.now();var t=kit.onceTrackData(e),a=saPara.server_url+"?"+t;-1!==saPara.server_url.indexOf("?")&&(a=saPara.server_url+"&"+t),wxrequest({url:a,method:"GET"})}function buildData(e,t){var a={distinct_id:sa.store.getDistinctId(),identities:sa.store._state.identities,lib:{$lib:LIB_NAME,$lib_method:"code",$lib_version:LIB_VERSION},properties:{}};return"track_id_unbind"===e.type&&"$UnbindID"===e.event&&(a.identities=deepCopy(e.unbind_value),delete e.unbind_value),isObject(t)||(t={}),extend(a,sa.store.getUnionId(),e),isObject(e.properties)&&!isEmptyObject(e.properties)&&extend(a.properties,e.properties),e.type&&"profile"===e.type.slice(0,7)||(a._track_id=Number(String(getRandom()).slice(2,5)+String(getRandom()).slice(2,4)+String(Date.now()).slice(-4)),a.properties=extend({},getPublicPresetProperties(),meta.preset_properties,sa.store.getProps(),t,a.properties),"track"===e.type&&(a.properties.$is_first_day=getIsFirstDay())),a.properties.$time&&isDate(a.properties.$time)?(a.time=1*a.properties.$time,delete a.properties.$time):a.time=1*new Date,sa.ee.sdk.emit("createData",a),sa.ee.sdk.emit("beforeBuildCheck",a),sa.ee.data.emit("beforeBuildCheck",a),parseSuperProperties(a.properties),searchObjDate(a),strip_sa_properties(a.properties),searchObjString(a),sa.ee.data.emit("finalAdjustData",a),a}function dataStage(e){if(!saPara.server_url)return!1;if(meta.current_scene&&1154===meta.current_scene&&!sa.para.preset_events.moments_page)return!1;var t=sa._.deepCopy(e),a=buildData(e,kit.onEventSend(t));a?(log(a),sa.events.emit("send",a),sa.para.batch_send?sendStrategy.send(a):onceSend(a)):log("error: \u6570\u636e\u5f02\u5e38 "+a)}sa.popupEmitter={attached:function(){return!1}};var usePlugin=function(e,t){if(!isObject(e)&&!isFunction(e))return log("plugin must be an object",e),!1;if(isFunction(e.init)||log("plugin maybe missing init method",e.plugin_name||e),isString(e.plugin_name)&&e.plugin_name?sa.modules[e.plugin_name]?e=sa.modules[e.plugin_name]:sa.modules[e.plugin_name]=e:log("plugin_name is not defined - ",e.plugin_name||e),isObject(e)&&!0===e.plugin_is_init)return e;if(isObject(e)&&e.plugin_name&&(isString(e.plugin_version)&&e.plugin_version===LIB_VERSION||log("warning!"+e.plugin_name+" plugin version do not match SDK version \uff01\uff01\uff01")),meta.init_status)"function"==typeof e.init&&(e.init(sa,t),e.plugin_is_init=!0,log(e.plugin_name+" plugin is initialized"));else{var a={target:e,para:t};meta.plugin.uninitialized_list.push(a)}return e},checkPluginInitStatus=function(){if(meta.plugin.uninitialized_list.length>0){for(var e in meta.plugin.uninitialized_list){var t=meta.plugin.uninitialized_list[e];t&&t.target&&"function"==typeof t.target.init&&!t.target.plugin_is_init&&(t.target.init(sa,t.para),isObject(t.target)&&(t.target.plugin_is_init=!0,isString(t.target.plugin_name)&&t.target.plugin_name&&log(t.target.plugin_name+" plugin is initialized")))}meta.plugin.uninitialized_list=[]}};function initAppShowHide(){wx.onAppShow(function(e){if(!meta.life_state.app_launched){var t=wx.getLaunchOptionsSync()||{};sa.autoTrackCustom.appLaunch(t)}sa.autoTrackCustom.appShow(e)}),wx.onAppHide(function(){sa.autoTrackCustom.appHide()})}function checkAppLaunch(){if(!meta.life_state.app_launched){var e=wx.getLaunchOptionsSync()||{};sa.autoTrackCustom.appLaunch(e)}}function mpProxy(e,t,a){var r=sa.autoTrackCustom[a];if(e[t]){var i=e[t];e[t]=function(){!sa.para.autoTrackIsFirst||isObject(sa.para.autoTrackIsFirst)&&!sa.para.autoTrackIsFirst[a]?(i.apply(this,arguments),r.apply(this,arguments)):(!0===sa.para.autoTrackIsFirst||isObject(sa.para.autoTrackIsFirst)&&sa.para.autoTrackIsFirst[a])&&(r.apply(this,arguments),i.apply(this,arguments)),sa.ee.page.emit(a)}}else e[t]=function(){r.apply(this,arguments),sa.ee.page.emit(a)}}function clickTrack(e){var t,a={},r={},i=e.currentTarget||{},n=e.target||{};if(isObject(sa.para.framework)&&isObject(sa.para.framework.taro)&&!sa.para.framework.taro.createApp&&n.id&&i.id&&n.id!==i.id)return!1;var s=i.dataset||{};if(t=e.type,a.$element_id=i.id,a.$element_type=s.type,a.$element_content=s.content,a.$element_name=s.name,isObject(e.event_prop)&&(r=e.event_prop),t&&isClick(t)){if(sa.para.preset_events&&sa.para.preset_events.collect_element&&!1===sa.para.preset_events.collect_element(arguments[0]))return!1;a.$url_path=sa._.getCurrentPath(),sa._.setPageRefData(a),a=sa._.extend(a,r),sa.track("$MPClick",a)}}function clickProxy(e,t){var a=e[t];e[t]=function(){var e=a.apply(this,arguments),t=arguments[0];return isObject(t)&&(sa.para.preset_events.defer_track?setTimeout(function(){clickTrack(t)},0):clickTrack(t)),e}}function isClick(e){return!!{tap:1,longpress:1,longtap:1}[e]}function tabProxy(e){var t=e.onTabItemTap;e.onTabItemTap=function(e){t&&t.apply(this,arguments);var a={};e&&(a.$element_content=e.text),a.$element_type="tabBar",a.$url_path=sa._.getCurrentPath(),sa._.setPageRefData(a),sa.track("$MPClick",a)}}function getMethods(e){var t=MP_FILTER_HOOK,a=[];for(var r in e)"function"!=typeof e[r]||t[r]||a.push(r);return a}function initPageProxy(){var e=Page;Page=function(t){try{t||(t={}),monitorClick(t),monitorHooks(t),e.apply(this,arguments)}catch(t){e.apply(this,arguments)}};var t=Component;Component=function(e){try{e||(e={}),e.methods||(e.methods={}),monitorClick(e.methods),monitorHooks(e.methods),t.apply(this,arguments)}catch(e){t.apply(this,arguments)}}}function monitorClick(e){var t=[];if(sa.para.autoTrack&&sa.para.autoTrack.mpClick){t=getMethods(e),tabProxy(e);for(var a=t.length,r=0;r100)log("Key ["+e+"] is invalid");else if(!check.checkKeyword(e))return log("Key ["+e+"] is invalid"),!1;if(isPresetIdKeys(e,["$mp_openid","$identity_mp_openid","$identity_mp_unionid","$mp_unionid","$mp_id","$identity_mp_id"]))return log("Key ["+e+"] is invalid"),!1;if(!(t=validId(t)))return!1;if(isSameAndAnonymousID(t))return!1;var a=store.getFirstId(),r=store.getDistinctId();isNewLoginId(e,t)&&(store._state.identities[e]=t,store.set("history_login_id",{name:e,value:t}),a||store.set("first_id",r),sa.trackSignup({id:t,event_name:"$SignUp",id_name:e}),store.identitiesSet({type:"login",id:t,id_name:e}))}function getAnonymousID(){if(!isEmptyObject(store._state))return store._state._first_id||store._state.first_id||store._state._distinct_id||store._state.distinct_id;log("\u8bf7\u5148\u521d\u59cb\u5316SDK")}function getIdentities(){return isEmptyObject(store._state)?(log("\u8bf7\u5148\u521d\u59cb\u5316SDK"),null):store._state.identities||null}function logout(e){var t=store.getFirstId();store.identitiesSet({type:"logout"}),store.set("history_login_id",{name:"",value:""}),t?(store.set("first_id",""),!0===e?store.set("distinct_id",store.getUUID()):store.set("distinct_id",t)):log("\u6ca1\u6709first_id\uff0clogout\u5931\u8d25")}function getPresetProperties(){if(meta.preset_properties&&meta.preset_properties.$lib){var e={};each(meta.preset_properties,function(t,a){0===a.indexOf("$")&&(e[a]=t)});var t={$url_path:getCurrentPath(),$is_first_day:getIsFirstDay(),$is_first_time:meta.is_first_launch},a=extend(e,t,meta.preset_properties,store.getProps());return delete a.$lib,a}return{}}function setOpenid(e,t){if(!(e=validId(e)))return!1;if(!checkPrivacyStatus())return!1;if(!meta.init_status)return store.store_queue.push({method:"setOpenid",params:arguments}),!1;log("\u8be5\u65b9\u6cd5\u5df2\u4e0d\u5efa\u8bae\u4f7f\u7528\uff0c\u5982\u679c\u662f id2 \u7528\u6237\uff0c\u8bf7\u4f7f\u7528 identify \u4ee3\u66ff\uff0c\u5982\u679c\u662f id3 \u7528\u6237\uff0c\u8bf7\u4f7f\u7528 bindOpenid \u4ee3\u66ff"),t&&log("%c \u5f53\u524d\u7248\u672c setOpenid \u63a5\u53e3 \u5df2\u4e0d\u652f\u6301\u4f20\u5165\u7b2c\u4e8c\u4e2a\u53c2\u6570","color:#F39C12;font-size: 14px;"),store.set("openid",e),sa.identify(e,!0);var a=getOpenidNameByAppid();store._state.identities[a]=e,store.save()}function unsetOpenid(e){log("\u8be5\u65b9\u6cd5\u5df2\u4e0d\u5efa\u8bae\u4f7f\u7528\uff0c\u5982\u679c\u662f id3 \u7528\u6237\uff0c\u8bf7\u4f7f\u7528 unbindOpenid \u4ee3\u66ff");var t=validId(e);if(!t)return!1;var a=store._state.openid;a===t&&store.set("openid","");var r=getOpenidNameByAppid();if(hasOwnProperty$3.call(store._state.identities,r)&&t===store._state.identities[r]){delete store._state.identities[r];var i=store.getFirstId(),n=store.getDistinctId(),s=store._state&&store._state.identities&&store._state.identities.$identity_mp_id;i&&i===a&&s&&store.change("first_id",s),n&&n===a&&s&&store.change("distinct_id",s),store.save()}}function bindOpenid(e){if(!(e=validId(e)))return!1;var t=getOpenidNameByAppid();this.bind(t,e)}function unbindOpenid(e){if(!validId(e))return!1;var t=getOpenidNameByAppid();this.unbind(t,e)}function setUnionid(e){var t=validId(e);t&&bind("$identity_mp_unionid",t)}function unsetUnionid(e){var t=validId(e);if(t){if(hasOwnProperty$3.call(store._state.identities,"$identity_mp_unionid")&&t===store._state.identities.$identity_mp_unionid){var a=getOpenidNameByAppid();hasOwnProperty$3.call(store._state.identities,a)&&(delete store._state.identities[a],delete store._state.openid,store.save())}unbind("$identity_mp_unionid",t)}}function initWithOpenid(e,t){(e=e||{}).appid&&(saPara.appid=e.appid),sa.openid.getOpenid(function(a){a&&sa.setOpenid(a,e.isCoverLogin),t&&isFunction(t)&&t(a),sa.init(e)})}function bind(e,t){if(isNumber(t)){if(isInteger(t)&&!1===isSafeInteger(t))return log("Value must be String"),!1;t=String(t)}if(!isString(e))return log("Key must be String"),!1;var a=store.getHistoryLoginId(),r=a?a.name:"";return!check.checkKeyword(e)||isPresetIdKeys(e,[IDENTITY_KEY.LOGIN,r,"$mp_id","$identity_mp_id"])?(log("Key ["+e+"] is invalid"),!1):t&&""!==t?isString(t)?!!check.checkIdLength(t)&&(store._state.identities[e]=t,store.save(),void dataStage({type:"track_id_bind",event:"$BindID"})):(log("Value must be String"),!1):(log("Value is empty or null"),!1)}function unbind(e,t){if(isNumber(t)){if(isInteger(t)&&!1===isSafeInteger(t))return log("Value must be String"),!1;t=String(t)}if(!isString(e))return log("Key must be String"),!1;if(!sa._.check.checkKeyword(e)||isPresetIdKeys(e,[IDENTITY_KEY.LOGIN]))return log("Key ["+e+"] is invalid"),!1;if(!t||""===t)return log("Value is empty or null"),!1;if(!isString(t))return log("Value must be String"),!1;if(!sa._.check.checkIdLength(t))return!1;hasOwnProperty$3.call(store._state.identities,e)&&t===store._state.identities[e]&&("$mp_id"!==e&&"$identity_mp_id"!==e&&delete store._state.identities[e],store.save());var a=store.getDistinctId(),r=store.getFirstId();a===e+"+"+t&&(store.set("first_id",""),store.set("distinct_id",r),store.set("history_login_id",{name:"",value:""}));var i={};i[e]=t,dataStage({type:"track_id_unbind",event:"$UnbindID",unbind_value:i})}function setWebViewUrl(e,t){if(log("setWebViewUrl \u65b9\u6cd5\u5df2\u4ece 2022-9-23 \u5f00\u59cb\u5e9f\u5f03\uff0c\u8bf7\u5c3d\u5feb\u53bb\u9664\u8be5 API \u7684\u8c03\u7528\uff0c\u5e76\u4f7f\u7528 use \u63d2\u4ef6 \u4ee3\u66ff"),!isString(e)||""===e)return log("error:\u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;if(!/^http(s)?:\/\//.test(e))return log("warning: \u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;var a=/([^?#]+)(\?[^#]*)?(#.*)?/.exec(e);if(!a)return!1;var r,i=a[1]||"",n=a[2]||"",s=a[3]||"",o="",u=store.getDistinctId()||"",c=store.getFirstId()||"";urlSafeBase64&&urlSafeBase64.encode?u=u?urlSafeBase64.trim(urlSafeBase64.encode(urlBase64Encode(u))):"":rot13obfs&&(u=u?rot13obfs(u):""),u=encodeURIComponent(u);var p=c?"f"+u:"d"+u;t?(r=s.indexOf("_sasdk"),o=s.indexOf("?")>-1?r>-1?i+n+"#"+s.substring(1,r)+"_sasdk="+p:i+n+"#"+s.substring(1)+"&_sasdk="+p:i+n+"#"+s.substring(1)+"?_sasdk="+p):(r=n.indexOf("_sasdk"),o=/^\?(\w)+/.test(n)?r>-1?i+n.replace(/(_sasdk=)([^&]*)/gi,"_sasdk="+p)+s:i+"?"+n.substring(1)+"&_sasdk="+p+s:i+"?"+n.substring(1)+"_sasdk="+p+s);return o}function quick(){var e=arguments[0],t=arguments[1],a=arguments[2],r=isObject(a)?a:{};if("getAnonymousID"===e){if(!isEmptyObject(store._state))return store._state._first_id||store._state.first_id||store._state._distinct_id||store._state.distinct_id;log("\u8bf7\u5148\u521d\u59cb\u5316SDK")}else"appLaunch"===e||"appShow"===e?t?sa.autoTrackCustom[e](t,r):log("App\u7684launch\u548cshow\uff0c\u5728sensors.quick\u7b2c\u4e8c\u4e2a\u53c2\u6570\u5fc5\u987b\u4f20\u5165App\u7684options\u53c2\u6570"):"appHide"===e&&(r=isObject(t)?t:{},sa.autoTrackCustom[e](r))}function appLaunch(e,t){var a={};e&&e.scene?(meta.current_scene=e.scene,a.$scene=getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,delObjectKey(e.query)),e&&e.path&&(a.$url_path=getPath(e.path),a.$title=getPageTitle(e.path)),setShareInfo(e,a);var r=setUtm(e,a);meta.is_first_launch?(a.$is_first_time=!0,isEmptyObject(r.pre1)||sa.setOnceProfile(r.pre1)):a.$is_first_time=!1,setLatestChannel(r.pre2),setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=setQuery(e.query),a.$url=e.path+(a.$url_query?"?"+a.$url_query:""),setPageRefData(t),isObject(t)&&(a=extend(a,t)),sa.track("$MPLaunch",a)}function appShow(e,t){var a={};meta.mp_show_time=(new Date).getTime(),e&&e.scene?(meta.current_scene=e.scene,a.$scene=getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,delObjectKey(e.query)),e&&e.path&&(a.$url_path=getPath(e.path),a.$title=getPageTitle(e.path)),setShareInfo(e,a),setLatestChannel(setUtm(e,a).pre2),setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=setQuery(e.query),e&&e.path&&(a.$url=e.path+(a.$url_query?"?"+a.$url_query:"")),setPageRefData(a,e.path,a.$url_query),isObject(t)&&(a=extend(a,t)),sa.track("$MPShow",a)}function appHide(e){var t=(new Date).getTime(),a={};a.$url_path=getCurrentPath(),meta.mp_show_time&&t-meta.mp_show_time>0&&(t-meta.mp_show_time)/36e5<24&&(a.event_duration=(t-meta.mp_show_time)/1e3),setPageRefData(a),isObject(e)&&(a=extend(a,e)),sa.track("$MPHide",a),sa.sendStrategy.onAppHide()}function pageShow(e){var t={},a=getCurrentPath(),r=getPageTitle(a),i=getCurrentPage();setRefPage(),r&&(t.$title=r),t.$url_path=a,t.$url_query=i.sensors_mp_url_query?i.sensors_mp_url_query:"",setPageSfSource(t=extend(t,getUtmFromPage())),setPageRefData(t),isObject(e)&&(t=extend(t,e)),sa.track("$MPViewScreen",t)}function setPara(e){sa.para=extend2Lev(saPara,e);var t=[];if(isArray(saPara.source_channel))for(var a=saPara.source_channel.length,r=0;r0&&(t-meta.mp_show_time)/36e5<24&&(a.event_duration=(t-meta.mp_show_time)/1e3),setPageRefData(a),e?(a=extend(a,e),sa.track("$MPHide",a)):saPara.autoTrack&&saPara.autoTrack.appHide&&sa.autoTrackCustom.trackCustom("appHide",a,"$MPHide")},pageLoad:function(e){meta.current_scene&&1010===meta.current_scene&&e&&(e.sampshare&&delete e.sampshare,delObjectKey(e)),e&&isObject(e)&&(this.sensors_mp_url_query=setQuery(e),this.sensors_mp_encode_url_query=setQuery(e,!0))},pageShow:function(){meta.page_show_time=Date.now();var e={},t=getCurrentPath(),a=getPageTitle(t);setRefPage(),e.$url_path=t,e.$url_query=this.sensors_mp_url_query?this.sensors_mp_url_query:"",setPageRefData(e=extend(e,getUtmFromPage())),setPageSfSource(e),a&&(e.$title=a),saPara.onshow?saPara.onshow(sa,t,this):-1===saPara.autotrack_exclude_page.pageShow.indexOf(t)&&sa.autoTrackCustom.trackCustom("pageShow",e,"$MPViewScreen")},pageShare:function(e){var t=e.onShareAppMessage;e.onShareAppMessage=function(){var e=this;meta.share_method="\u8f6c\u53d1\u6d88\u606f\u5361\u7247";var a,r=t.apply(this,arguments);if(saPara.autoTrack&&saPara.autoTrack.pageShare){var i={$url_path:getCurrentPath(),$share_depth:meta.query_share_depth,$share_method:meta.share_method};setPageRefData(i),sa.autoTrackCustom.trackCustom("pageShare",i,"$MPShare")}function n(t){return isObject(t)||(t={}),(isUndefined(t.path)||""===t.path)&&(t.path=getCurrentUrl(e)),isString(t.path)&&(-1===t.path.indexOf("?")?t.path=t.path+"?":"&"!==t.path.slice(-1)&&(t.path=t.path+"&")),t.path=t.path+getShareInfo(),t}if(sa.para.allow_amend_share_path&&isObject(r=n(r)))for(var s in r)if((a=r[s])&&isFunction(a.then)&&isFunction(a.catch))try{r[s]=r[s].then(function(e){return n(e)})}catch(e){log("onShareAppMessage: "+e)}return r}},pageShareTimeline:function(e){var t=e.onShareTimeline;e.onShareTimeline=function(){meta.share_method="\u670b\u53cb\u5708\u5206\u4eab";var e=t.apply(this,arguments);if(saPara.autoTrack&&saPara.autoTrack.pageShare){var a={$url_path:getCurrentPath(),$share_depth:meta.query_share_depth,$share_method:meta.share_method};setPageRefData(a),sa.autoTrackCustom.trackCustom("pageShare",a,"$MPShare")}return saPara.allow_amend_share_path&&("object"!=typeof e&&(e={}),"object"==typeof e&&void 0===e.query&&(e.query=""),"object"==typeof e&&"string"==typeof e.query&&""!==e.query&&"&"!==e.query.slice(-1)&&(e.query=e.query+"&"),e.query=e.query+getShareInfo()),e}},pageAddFavorites:function(){var e={};e.$url_path=getCurrentPath(),saPara.autoTrack&&saPara.autoTrack.mpFavorite&&sa.autoTrackCustom.trackCustom("mpFavorite",e,"$MPAddFavorites")},pageHide:function(){sa.para.autoTrack&&sa.para.autoTrack.pageLeave&&sendPageLeave()}};function sendPageLeave(){var e={},t="";try{t=(e=getCurrentPage())?e.route:""}catch(e){log(e)}if(meta.page_show_time>=0&&""!==t){var a={},r=getPageTitle(t),i=(Date.now()-meta.page_show_time)/1e3;(isNaN(i)||i<0)&&(i=0),a.$url_query=e.sensors_mp_url_query?e.sensors_mp_url_query:"",a.$url_path=t,a.$title=r,a.event_duration=i,-1===saPara.autotrack_exclude_page.pageLeave.indexOf(t)&&sa.track("$MPPageLeave",a),meta.page_show_time=-1}}var openid={getRequest:function(e){wx.login({success:function(t){t.code&&saPara.appid&&saPara.openid_url?wxrequest({url:saPara.openid_url+"&code="+t.code+"&appid="+saPara.appid,method:"GET",complete:function(t){isObject(t)&&isObject(t.data)&&t.data.openid?e(t.data.openid):e()}}):e()}})},getWXStorage:function(){var e=store.getStorage();if(e&&isObject(e))return e.openid},getOpenid:function(e){if(!saPara.appid)return e(),!1;var t=this.getWXStorage();t?e(t):this.getRequest(e)}},functions=Object.freeze({__proto__:null,setProfile:setProfile,setOnceProfile:setOnceProfile,appendProfile:appendProfile,incrementProfile:incrementProfile,track:track,identify:identify,trackSignup:trackSignup,login:login,loginWithKey:loginWithKey,getAnonymousID:getAnonymousID,getIdentities:getIdentities,logout:logout,getPresetProperties:getPresetProperties,setOpenid:setOpenid,unsetOpenid:unsetOpenid,bindOpenid:bindOpenid,unbindOpenid:unbindOpenid,setUnionid:setUnionid,unsetUnionid:unsetUnionid,bindUnionid:setUnionid,unbindUnionid:unsetUnionid,initWithOpenid:initWithOpenid,bind:bind,unbind:unbind,setWebViewUrl:setWebViewUrl,quick:quick,appLaunch:appLaunch,appShow:appShow,appHide:appHide,pageShow:pageShow,setPara:setPara,getServerUrl:getServerUrl,sendPageLeave:sendPageLeave,openid:openid,autoTrackCustom:autoTrackCustom,registerApp:registerApp,register:register,clearAllRegister:clearAllRegister,clearAppRegister:clearAppRegister,clearAllProps:clearAllProps});function buildAPI(e){for(var t in functions)e[t]=functions[t]}function setFirstVisitTime(){meta.is_first_launch&&setOnceProfile({$first_visit_time:new Date})}function checkIsComplete(){meta.initialState.isComplete=!0,meta.initialState.queue.length>0&&(each(meta.initialState.queue,function(e){"appLaunch"===e[0]?sa.autoTrackCustom.appLaunch.apply(sa.autoTrackCustom,slice.call(e[1])):sa[e[0]].apply(sa,slice.call(e[1]))}),meta.initialState.queue=[])}function init(e){if(!0===meta.init_status)return!1;function t(){checkIsComplete(),checkAppLaunch(),sa.ee.sdk.emit("ready")}meta.init_status=!0,sa.ee.sdk.emit("beforeInit"),e&&isObject(e)&&sa.setPara(e),sa.ee.sdk.emit("initPara"),sa.ee.sdk.emit("afterInitPara"),sa.store.init(),sa.checkPluginInitStatus(),setFirstVisitTime(),sa.para.batch_send&&sa.sendStrategy.init();var a=[getNetworkType(),getSystemInfo()].concat(meta.promise_list);Promise.all(a).then(()=>{t()}).catch(()=>{t()})}function registerPropertyPlugin(e){isFunction(e.properties)?!e.isMatchedWithFilter||isFunction(e.isMatchedWithFilter)?sa.ee.data.on("finalAdjustData",function(t){try{isFunction(e.isMatchedWithFilter)?e.isMatchedWithFilter(t)&&e.properties(t):e.properties(t)}catch(e){log("execute registerPropertyPlugin callback error:"+e)}}):log("registerPropertyPlugin arguments error, isMatchedWithFilter must be function"):log("registerPropertyPlugin arguments error, properties must be function")}sa._=_,sa.modules={},sa.meta=meta,sa.kit=kit,sa.mergeStorageData=mergeStorageData,sa.dataStage=dataStage,sa.sendStrategy=sendStrategy,sa.store=store,sa.usePlugin=usePlugin,sa.checkPluginInitStatus=checkPluginInitStatus,sa.eventSub=eventSub,sa.events=new eventEmitter,sa.ee=ee,sa.registerPropertyPlugin=registerPropertyPlugin,sa.enableDataCollect=enableDataCollect,sa.initialState=meta.initialState,sa.IDENTITY_KEY={EMAIL:IDENTITY_KEY.EMAIL,MOBILE:IDENTITY_KEY.MOBILE},buildAPI(sa),apiStaging(),setNavigationBarTitle(),networkStatusChange(),initAppGlobalName(),initAppShowHide(),initPageProxy(),sa.init=init;var base={plugin_version:"1.19.11"};function createPlugin(e){if("object"==typeof e&&"string"==typeof e.plugin_name&&""!==e.plugin_name)return e.plugin_version=base.plugin_version,e.log=e.log||function(){"object"==typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)},e;"object"==typeof console&&"function"==typeof console.error&&console.error('plugin must contain proprerty "plugin_name"')}var disableSDK={init(e){e.disableSDK=this.disableSDK.bind(this),e.enableSDK=this.enableSDK.bind(this),e.getDisabled=this.getDisabled.bind(this)},plugin_name:"DisableSDK",disabled:!1,disableSDK(){this.disabled=!0},enableSDK(){this.disabled=!1},getDisabled(){return this.disabled}},DisableSDK=createPlugin(disableSDK);sa.usePlugin(DisableSDK),module.exports=sa; \ No newline at end of file +"use strict";var sa={},saPara={name:"sensors",server_url:"",send_timeout:1e3,show_log:!1,login_id_key:"$identity_login_id",allow_amend_share_path:!0,max_string_length:500,datasend_timeout:3e3,source_channel:[],autoTrack:{appLaunch:!0,appShow:!0,appHide:!0,pageShow:!0,pageShare:!0,mpClick:!1,mpFavorite:!0,pageLeave:!1},autotrack_exclude_page:{pageShow:[],pageLeave:[]},is_persistent_save:{share:!1,utm:!1},preset_properties:{url_path:!0},preset_events:{moments_page:!1,defer_track:!1,share_info_use_string:!1},batch_send:!0,storage_store_key:"sensorsdata2015_wechat",storage_prepare_data_key:"sensors_mp_prepare_data"};function log(){if(saPara.show_log&&"object"==typeof console&&console.log)try{return console.log.apply(console,arguments)}catch(e){console.log(arguments[0])}}var nativeIsArray=Array.isArray,ObjProto=Object.prototype,ArrayProto=Array.prototype,nativeForEach=ArrayProto.forEach,nativeIndexOf=ArrayProto.indexOf,toString=ObjProto.toString,hasOwnProperty=ObjProto.hasOwnProperty,slice=ArrayProto.slice;function each(e,t,a){if(null==e)return!1;var r={};if(nativeForEach&&e.forEach===nativeForEach)e.forEach(t,a);else if(e.length===+e.length){for(var i=0,n=e.length;i0&&each(this.store_queue,function(e){sa[e.method].apply(sa,slice.call(e.params))}),this.store_queue=[])}};function _decodeURIComponent(e){var t="";try{t=decodeURIComponent(e)}catch(a){t=e}return t}var hasOwnProperty$2=Object.prototype.hasOwnProperty,decodeURIComponent$1=_decodeURIComponent;function initAppGlobalName(){var e=App;App=function(t){t[saPara.name]=sa,e.apply(this,arguments)}}function getPublicPresetProperties(){var e=getRefPage(),t=getCurrentPageInfo(),a={$referrer:e.route,$referrer_title:e.title,$title:t.title,$url:t.url};return!0===saPara.preset_properties.url_path&&(a.$url_path=t.path),a}function encodeDates(e){return each(e,function(t,a){isDate(t)?e[a]=formatDate(t):isObject(t)&&(e[a]=encodeDates(t))}),e}function formatDate(e){function t(e){return e<10?"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())}function searchObjDate(e){(isObject(e)||isArray(e))&&each(e,function(t,a){isObject(t)||isArray(t)?searchObjDate(e[a]):isDate(t)&&(e[a]=formatDate(t))})}function formatString(e){return e.length>saPara.max_string_length?(log("\u5b57\u7b26\u4e32\u957f\u5ea6\u8d85\u8fc7\u9650\u5236\uff0c\u5df2\u7ecf\u505a\u622a\u53d6--"+e),e.slice(0,saPara.max_string_length)):e}function searchObjString(e){isObject(e)&&each(e,function(t,a){isObject(t)?searchObjString(e[a]):isString(t)&&(e[a]=formatString(t))})}function parseSuperProperties(e){isObject(e)&&each(e,function(t,a){if(isFunction(t))try{e[a]=t(),isFunction(e[a])&&(log("\u60a8\u7684\u5c5e\u6027- "+a+" \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[a])}catch(t){delete e[a],log("\u60a8\u7684\u5c5e\u6027- "+a+" \u629b\u51fa\u4e86\u5f02\u5e38\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}})}function unique(e){for(var t,a=[],r={},i=0;i255)||(log("id \u957f\u5ea6\u8d85\u8fc7 255 \u4e2a\u5b57\u7b26\uff01"),!1)}};function strip_sa_properties(e){return isObject(e)?(each(e,function(t,a){if(isArray(t)){var r=[];each(t,function(e){if(isString(e))r.push(e);else if(isUndefined(e))r.push("null");else try{r.push(JSON.stringify(e))}catch(e){log("\u60a8\u7684\u6570\u636e - "+a+":"+t+" - \u7684\u6570\u7ec4\u91cc\u7684\u503c\u6709\u9519\u8bef,\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}}),e[a]=r}if(isObject(t))try{e[a]=JSON.stringify(t)}catch(r){delete e[a],log("\u60a8\u7684\u6570\u636e - "+a+":"+t+" - \u7684\u6570\u636e\u503c\u6709\u9519\u8bef,\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}else isString(t)||isNumber(t)||isDate(t)||isBoolean(t)||isArray(t)||(log("\u60a8\u7684\u6570\u636e - "+a+":"+t+" - \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[a])}),e):e}function strip_empty_properties(e){var t={};return each(e,function(e,a){null==e&&void 0===e||(t[a]=e)}),t}function utf8Encode(e){var t,a,r,i,n="";for(t=a=0,r=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,i=0;i127&&s<2048?String.fromCharCode(s>>6|192,63&s|128):String.fromCharCode(s>>12|224,s>>6&63|128,63&s|128),null!==o&&(a>t&&(n+=e.substring(t,a)),n+=o,t=a=i+1)}return a>t&&(n+=e.substring(t,e.length)),n}function base64Encode(e){var t,a,r,i,n,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,u=0,c="",p=[];if(!e)return e;e=utf8Encode(e);do{t=(n=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>18&63,a=n>>12&63,r=n>>6&63,i=63&n,p[u++]=s.charAt(t)+s.charAt(a)+s.charAt(r)+s.charAt(i)}while(o255||(r=e.charCodeAt(o++))>255||(i=e.charCodeAt(o++))>255)&&log("Failed to execute 'btoa' : The string to be encoded contains characters outside of the Latin1 range."),s+=n.charAt((t=a<<16|r<<8|i)>>18&63)+n.charAt(t>>12&63)+n.charAt(t>>6&63)+n.charAt(63&t);return u?s.slice(0,u-3)+"===".substring(u):s}function urlBase64Encode(e){return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}))}function getCurrentPage(){var e={};try{var t=getCurrentPages();e=t[t.length-1]}catch(e){log(e)}return e}function getCurrentPath(){var e="\u672a\u53d6\u5230";try{var t=getCurrentPage();e=t?t.route:e}catch(e){log(e)}return e}function getIsFirstDay(){return!!("object"==typeof store._state&&isNumber(store._state.first_visit_day_time)&&store._state.first_visit_day_time>(new Date).getTime())}function getCurrentUrl(e){var t=getCurrentPath(),a="";return isObject(e)&&e.sensors_mp_encode_url_query&&(a=e.sensors_mp_encode_url_query),t?a?t+"?"+a:t:"\u672a\u53d6\u5230"}function getPath(e){return e=isString(e)?e.replace(/^\//,""):"\u53d6\u503c\u5f02\u5e38"}function getCustomUtmFromQuery(e,t,a,r){if(!isObject(e))return{};var i={};if(e.sa_utm)for(var n in e)"sa_utm"!==n?include(saPara.source_channel,n)&&(i[a+n]=e[n]):i[r+n]=e[n];else for(var s in e)-1===(" "+SOURCE_CHANNEL_STANDARD+" ").indexOf(" "+s+" ")?include(saPara.source_channel,s)&&(i[a+s]=e[s]):i[t+s]=e[s];return i}function getObjFromQuery(e){var t=e.split("?"),a=[],r={};return t&&t[1]?(each(t[1].split("&"),function(e){(a=e.split("="))[0]&&a[1]&&(r[a[0]]=a[1])}),r):{}}function setStorageSync(e,t){var a=function(){wx.setStorageSync(e,t)};try{a()}catch(e){log("set Storage fail --",e);try{a()}catch(e){log("set Storage fail again --",e)}}}function getStorageSync(e){var t="";try{t=wx.getStorageSync(e)}catch(e){log("getStorage fail")}return t}function getMPScene(e){return isNumber(e)||isString(e)&&""!==e?e="wx-"+String(e):"\u672a\u53d6\u5230\u503c"}function objToParam(e,t){if(!isObject(e))return log("\u8bf7\u4f20\u5165\u6709\u6548\u5bf9\u8c61"),"";var a=[];for(var r in e)if(hasOwnProperty$2.call(e,r)){var i=e[r];void 0===i?a.push(r+"="):(i=t?encodeURIComponent(i):i,a.push(r+"="+i))}return a.join("&")}function delObjectKey(e){if(isObject(e))for(var t=0;t=2?(meta.page_route_map.shift(),meta.page_route_map.push(e)):meta.page_route_map.push(e)}}catch(e){log(e)}}function getRefPage(){var e={route:"\u76f4\u63a5\u6253\u5f00",path:"\u76f4\u63a5\u6253\u5f00",title:""};return meta.page_route_map.length>1&&(e.title=meta.page_route_map[0].title,e.route=meta.page_route_map[0].route,e.path=meta.page_route_map[0].path),e}function getCurrentPageInfo(){var e=getCurrentPage(),t={title:"",url:"",path:"\u672a\u53d6\u5230"};if(e&&e.route){var a=e.sensors_mp_url_query?"?"+e.sensors_mp_url_query:"";t.title=getPageTitle(e.route),t.url=e.route+a,t.path=e.route}return t}function setPageRefData(e,t,a){var r=getRefPage();isObject(e)&&(t?meta.page_route_map.length>0&&t?(a=a?"?"+a:"",e.$referrer=getPath(t)+a,e.$referrer_title=getPageTitle(t)):(e.$referrer="\u76f4\u63a5\u6253\u5f00",e.$referrer_title=""):(e.$referrer=r.route,e.$referrer_title=r.title))}function getPageTitle(e){if("\u672a\u53d6\u5230"===e||!e)return"";var t="";try{if(__wxConfig){var a=__wxConfig,r=__wxConfig.page||{},i=r[e]||r[e+".html"],n={},s={};if(a.global&&a.global.window&&a.global.window.navigationBarTitleText&&(n.titleVal=a.global.window.navigationBarTitleText),i&&i.window&&i.window.navigationBarTitleText&&(s.titleVal=i.window.navigationBarTitleText),!s.titleVal&&__wxAppCode__){var o=__wxAppCode__[e+".json"];o&&o.navigationBarTitleText&&(s.titleVal=o.navigationBarTitleText)}if(each(meta.global_title,function(a,r){if(r===e)return t=a}),0===t.length){var u=extend(n,s);t=u.titleVal||""}}}catch(e){log(e)}return t}function wxrequest(e){if(compareSDKVersion(meta.wx_sdk_version,"2.10.0")>=0)e.timeout=saPara.datasend_timeout,wx.request(e);else{var t=wx.request(e);setTimeout(function(){isObject(t)&&isFunction(t.abort)&&t.abort()},saPara.datasend_timeout)}}function validId(e){return"string"!=typeof e&&"number"!=typeof e||""===e?(log("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1):"number"!=typeof e||(e=String(e),/^\d+$/.test(e))?!!check.checkIdLength(e)&&e:(log("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1)}function compareSDKVersion(e,t){e=e.split("."),t=t.split(".");for(var a=Math.max(e.length,t.length);e.lengthn)return 1;if(i{wx.getNetworkType({success:function(t){meta.preset_properties.$network_type=setUpperCase(t.networkType),e()},fail:function(e){log("\u83b7\u53d6\u7f51\u7edc\u4fe1\u606f\u5931\u8d25",e),t()}})})}function getSystemInfo(){var e=meta.preset_properties;return new Promise(t=>{wx.getSystemInfo({success:function(a){var r,i;e.$brand=setUpperCase(a.brand),e.$manufacturer=a.brand,e.$model=a.model,e.$screen_width=Number(a.screenWidth),e.$screen_height=Number(a.screenHeight),e.$os=(r=a.platform,"ios"===(i=r.toLowerCase())?"iOS":"android"===i?"Android":r),e.$os_version=a.system.indexOf(" ")>-1?a.system.split(" ")[1]:a.system,meta.wx_sdk_version=a.SDKVersion,e.$mp_client_app_version=a.version,e.$mp_client_basic_library_version=meta.wx_sdk_version;var n=(new Date).getTimezoneOffset(),s=getAppInfoSync();isNumber(n)&&(e.$timezone_offset=n),s.appId&&(e.$app_id=s.appId),s.appVersion&&(e.$app_version=s.appVersion),t()}})})}var info={currentProps:meta.preset_properties},logger={info:function(){if(saPara.show_log&&"object"==typeof console&&console.log)try{if(3===arguments.length)return console.log(arguments[0],arguments[1],arguments[2]);if(2===arguments.length)return console.log(arguments[0],arguments[1]);if(1===arguments.length)return console.log(arguments[0])}catch(e){console.log(arguments[0])}}};function isValidListener(e){return"function"==typeof e||!(!e||"object"!=typeof e)&&isValidListener(e.listener)}class EventEmitterBase{constructor(){this._events={}}on(e,t){if(!e||!t)return!1;if(!isValidListener(t))throw new Error("listener must be a function");this._events[e]=this._events[e]||[];var a="object"==typeof t;return this._events[e].push(a?t:{listener:t,once:!1}),this}prepend(e,t){if(!e||!t)return!1;if(!isValidListener(t))throw new Error("listener must be a function");this._events[e]=this._events[e]||[];var a="object"==typeof t;return this._events[e].unshift(a?t:{listener:t,once:!1}),this}prependOnce(e,t){return this.prepend(e,{listener:t,once:!0})}once(e,t){return this.on(e,{listener:t,once:!0})}off(e,t){var a=this._events[e];if(!a)return!1;if("number"==typeof t)a.splice(t,1);else if("function"==typeof t)for(var r=0,i=a.length;r0&&this.cacheEvents.forEach(function(a){a.type===e&&t.call(null,a.data)})}emit(e,t){super.emit.apply(this,arguments),this.cacheEvents.push({type:e,data:t}),this.cacheEvents.length>this.maxLen&&this.cacheEvents.shift()}}var _=Object.freeze({__proto__:null,decodeURIComponent:decodeURIComponent$1,encodeDates:encodeDates,formatDate:formatDate,searchObjDate:searchObjDate,formatString:formatString,searchObjString:searchObjString,parseSuperProperties:parseSuperProperties,unique:unique,check:check,getUtmFromPage:getUtmFromPage,setQuery:setQuery,setLatestShare:setLatestShare,setLatestChannel:setLatestChannel,setUpperCase:setUpperCase,compareSDKVersion:compareSDKVersion,validId:validId,wxrequest:wxrequest,getPageTitle:getPageTitle,setPageRefData:setPageRefData,getCurrentPageInfo:getCurrentPageInfo,getRefPage:getRefPage,setRefPage:setRefPage,setPageSfSource:setPageSfSource,setSfSource:setSfSource,setUtm:setUtm,getMixedQuery:getMixedQuery,detectOptionQuery:detectOptionQuery,getShareInfo:getShareInfo,setShareInfo:setShareInfo,shareInfoData:shareInfoData,delObjectKey:delObjectKey,objToParam:objToParam,getMPScene:getMPScene,getStorageSync:getStorageSync,setStorageSync:setStorageSync,getObjFromQuery:getObjFromQuery,getCustomUtmFromQuery:getCustomUtmFromQuery,getPath:getPath,getCurrentUrl:getCurrentUrl,getIsFirstDay:getIsFirstDay,getCurrentPath:getCurrentPath,getCurrentPage:getCurrentPage,urlBase64Encode:urlBase64Encode,btoa:btoa,base64Encode:base64Encode,strip_empty_properties:strip_empty_properties,strip_sa_properties:strip_sa_properties,setNavigationBarTitle:setNavigationBarTitle,networkStatusChange:networkStatusChange,getNetworkType:getNetworkType,getSystemInfo:getSystemInfo,encodeTrackData:encodeTrackData,initAppGlobalName:initAppGlobalName,getPublicPresetProperties:getPublicPresetProperties,setPublicProperties:setPublicProperties,isPresetIdKeys:isPresetIdKeys,isNewLoginId:isNewLoginId,isSameAndAnonymousID:isSameAndAnonymousID,info:info,logger:logger,getAppId:getAppId,getAppInfoSync:getAppInfoSync,getOpenidNameByAppid:getOpenidNameByAppid,rot13defs:rot13defs,rot13obfs:rot13obfs,each:each,isObject:isObject,getRandom:getRandom,extend:extend,extend2Lev:extend2Lev,coverExtend:coverExtend,isArray:isArray,isFunction:isFunction,isArguments:isArguments,toArray:toArray,values:values,include:include,trim:trim,isEmptyObject:isEmptyObject,deepCopy:deepCopy,isUndefined:isUndefined,isString:isString,isDate:isDate,isBoolean:isBoolean,isNumber:isNumber,isJSONString:isJSONString,isInteger:isInteger,isSafeInteger:isSafeInteger,slice:slice,urlSafeBase64:urlSafeBase64,EventEmitterBase:EventEmitterBase,EventEmitterEx:EventEmitterEx,log:log});function onEventSend(){return{}}function processData(e){return e}function batchTrackData(e){var t=Date.now();return e.forEach(function(e){e._flush_time=t}),"data_list="+encodeTrackData(e)}var mergeStorageData={getData:function(e){wx.getStorage({key:saPara.storage_prepare_data_key,complete:function(t){var a=t.data&&isArray(t.data)?t.data:[];mergeStorageData.deleteAesData(a),e&&e()}})},deleteAesData:function(e){var t=[],a=e.length;if(a>0){for(var r=0;r=saPara.batch_send.max_length&&this.batchSend()},wxrequest:function(e){if(isArray(e.data)&&e.data.length>0){var t=kit.batchTrackData(e.data);sa._.wxrequest({url:saPara.server_url,method:"POST",dataType:"text",data:t,header:{"content-type":"text/plain"},success:function(){e.success(e.len)},fail:function(){e.fail()}})}else e.success(e.len)},batchSend:function(){if(this.dataHasSend){var e,t,a=store.mem.mdata;(t=(e=a.length>=100?a.slice(0,100):a).length)>0&&(this.dataHasSend=!1,this.wxrequest({data:e,len:t,success:this.batchRemove.bind(this),fail:this.sendFail.bind(this)}))}},sendFail:function(){this.dataHasSend=!0,this.failTime++},batchRemove:function(e){store.mem.clear(e),this.dataHasSend=!0,this.dataHasChange=!0,this.batchWrite(),this.failTime=0},is_first_batch_write:!0,batchWrite:function(){this.dataHasChange&&(this.dataHasChange=!1,this.syncStorage&&sa._.setStorageSync(saPara.storage_prepare_data_key,store.mem.mdata))},batchInterval:function(){var e=this;!function t(){setTimeout(function(){e.batchWrite(),t()},500)}(),function t(){setTimeout(function(){e.batchSend(),t()},saPara.batch_send.send_timeout*Math.pow(2,e.failTime))}()}};function onceSend(e){e._flush_time=Date.now();var t=kit.onceTrackData(e),a=saPara.server_url+"?"+t;-1!==saPara.server_url.indexOf("?")&&(a=saPara.server_url+"&"+t),wxrequest({url:a,method:"GET"})}function buildData(e,t){var a={distinct_id:sa.store.getDistinctId(),identities:sa.store._state.identities,lib:{$lib:LIB_NAME,$lib_method:"code",$lib_version:LIB_VERSION},properties:{}};return"track_id_unbind"===e.type&&"$UnbindID"===e.event&&(a.identities=deepCopy(e.unbind_value),delete e.unbind_value),isObject(t)||(t={}),extend(a,sa.store.getUnionId(),e),isObject(e.properties)&&!isEmptyObject(e.properties)&&extend(a.properties,e.properties),e.type&&"profile"===e.type.slice(0,7)||(a._track_id=Number(String(getRandom()).slice(2,5)+String(getRandom()).slice(2,4)+String(Date.now()).slice(-4)),a.properties=extend({},getPublicPresetProperties(),meta.preset_properties,sa.store.getProps(),t,a.properties),"track"===e.type&&(a.properties.$is_first_day=getIsFirstDay())),a.properties.$time&&isDate(a.properties.$time)?(a.time=1*a.properties.$time,delete a.properties.$time):a.time=1*new Date,sa.ee.sdk.emit("createData",a),sa.ee.sdk.emit("beforeBuildCheck",a),sa.ee.data.emit("beforeBuildCheck",a),parseSuperProperties(a.properties),searchObjDate(a),strip_sa_properties(a.properties),searchObjString(a),sa.ee.data.emit("finalAdjustData",a),a}function dataStage(e){if(!saPara.server_url)return!1;if(meta.current_scene&&1154===meta.current_scene&&!sa.para.preset_events.moments_page)return!1;var t=sa._.deepCopy(e),a=buildData(e,kit.onEventSend(t));a?(log(a),sa.events.emit("send",a),sa.para.batch_send?sendStrategy.send(a):onceSend(a)):log("error: \u6570\u636e\u5f02\u5e38 "+a)}sa.popupEmitter={attached:function(){return!1}};var usePlugin=function(e,t){if(!isObject(e)&&!isFunction(e))return log("plugin must be an object",e),!1;if(isFunction(e.init)||log("plugin maybe missing init method",e.plugin_name||e),isString(e.plugin_name)&&e.plugin_name?sa.modules[e.plugin_name]?e=sa.modules[e.plugin_name]:sa.modules[e.plugin_name]=e:log("plugin_name is not defined - ",e.plugin_name||e),isObject(e)&&!0===e.plugin_is_init)return e;if(isObject(e)&&e.plugin_name&&(isString(e.plugin_version)&&e.plugin_version===LIB_VERSION||log("warning!"+e.plugin_name+" plugin version do not match SDK version \uff01\uff01\uff01")),meta.init_status)"function"==typeof e.init&&(e.init(sa,t),e.plugin_is_init=!0,log(e.plugin_name+" plugin is initialized"));else{var a={target:e,para:t};meta.plugin.uninitialized_list.push(a)}return e},checkPluginInitStatus=function(){if(meta.plugin.uninitialized_list.length>0){for(var e in meta.plugin.uninitialized_list){var t=meta.plugin.uninitialized_list[e];t&&t.target&&"function"==typeof t.target.init&&!t.target.plugin_is_init&&(t.target.init(sa,t.para),isObject(t.target)&&(t.target.plugin_is_init=!0,isString(t.target.plugin_name)&&t.target.plugin_name&&log(t.target.plugin_name+" plugin is initialized")))}meta.plugin.uninitialized_list=[]}};function initAppShowHide(){wx.onAppShow(function(e){if(!meta.life_state.app_launched){var t=wx.getLaunchOptionsSync()||{};sa.autoTrackCustom.appLaunch(t)}sa.autoTrackCustom.appShow(e)}),wx.onAppHide(function(){sa.autoTrackCustom.appHide()})}function checkAppLaunch(){if(!meta.life_state.app_launched){var e=wx.getLaunchOptionsSync()||{};sa.autoTrackCustom.appLaunch(e)}}function mpProxy(e,t,a){var r=sa.autoTrackCustom[a];if(e[t]){var i=e[t];e[t]=function(){!sa.para.autoTrackIsFirst||isObject(sa.para.autoTrackIsFirst)&&!sa.para.autoTrackIsFirst[a]?(i.apply(this,arguments),r.apply(this,arguments)):(!0===sa.para.autoTrackIsFirst||isObject(sa.para.autoTrackIsFirst)&&sa.para.autoTrackIsFirst[a])&&(r.apply(this,arguments),i.apply(this,arguments)),sa.ee.page.emit(a)}}else e[t]=function(){r.apply(this,arguments),sa.ee.page.emit(a)}}function clickTrack(e){var t,a={},r={},i=e.currentTarget||{},n=e.target||{};if(isObject(sa.para.framework)&&isObject(sa.para.framework.taro)&&!sa.para.framework.taro.createApp&&n.id&&i.id&&n.id!==i.id)return!1;var s=i.dataset||{};if(t=e.type,a.$element_id=i.id,a.$element_type=s.type,a.$element_content=s.content,a.$element_name=s.name,isObject(e.event_prop)&&(r=e.event_prop),t&&isClick(t)){if(sa.para.preset_events&&sa.para.preset_events.collect_element&&!1===sa.para.preset_events.collect_element(arguments[0]))return!1;a.$url_path=sa._.getCurrentPath(),sa._.setPageRefData(a),a=sa._.extend(a,r),sa.track("$MPClick",a)}}function clickProxy(e,t){var a=e[t];e[t]=function(){var e=a.apply(this,arguments),t=arguments[0];return isObject(t)&&(sa.para.preset_events.defer_track?setTimeout(function(){clickTrack(t)},0):clickTrack(t)),e}}function isClick(e){return!!{tap:1,longpress:1,longtap:1}[e]}function tabProxy(e){var t=e.onTabItemTap;e.onTabItemTap=function(e){t&&t.apply(this,arguments);var a={};e&&(a.$element_content=e.text),a.$element_type="tabBar",a.$url_path=sa._.getCurrentPath(),sa._.setPageRefData(a),sa.track("$MPClick",a)}}function getMethods(e){var t=MP_FILTER_HOOK,a=[];for(var r in e)"function"!=typeof e[r]||t[r]||a.push(r);return a}function initPageProxy(){var e=Page;Page=function(t){try{t||(t={}),monitorClick(t),monitorHooks(t),e.apply(this,arguments)}catch(t){e.apply(this,arguments)}};var t=Component;Component=function(e){try{e||(e={}),e.methods||(e.methods={}),monitorClick(e.methods),monitorHooks(e.methods),t.apply(this,arguments)}catch(e){t.apply(this,arguments)}}}function monitorClick(e){var t=[];if(sa.para.autoTrack&&sa.para.autoTrack.mpClick){t=getMethods(e),tabProxy(e);for(var a=t.length,r=0;r100)log("Key ["+e+"] is invalid");else if(!check.checkKeyword(e))return log("Key ["+e+"] is invalid"),!1;if(isPresetIdKeys(e,["$mp_openid","$identity_mp_openid","$identity_mp_unionid","$mp_unionid","$mp_id","$identity_mp_id"]))return log("Key ["+e+"] is invalid"),!1;if(!(t=validId(t)))return!1;if(isSameAndAnonymousID(t))return!1;var a=store.getFirstId(),r=store.getDistinctId();isNewLoginId(e,t)&&(store._state.identities[e]=t,store.set("history_login_id",{name:e,value:t}),a||store.set("first_id",r),sa.trackSignup({id:t,event_name:"$SignUp",id_name:e}),store.identitiesSet({type:"login",id:t,id_name:e}))}function getAnonymousID(){if(!isEmptyObject(store._state))return store._state._first_id||store._state.first_id||store._state._distinct_id||store._state.distinct_id;log("\u8bf7\u5148\u521d\u59cb\u5316SDK")}function getIdentities(){return isEmptyObject(store._state)?(log("\u8bf7\u5148\u521d\u59cb\u5316SDK"),null):store._state.identities||null}function logout(e){var t=store.getFirstId();store.identitiesSet({type:"logout"}),store.set("history_login_id",{name:"",value:""}),t?(store.set("first_id",""),!0===e?store.set("distinct_id",store.getUUID()):store.set("distinct_id",t)):log("\u6ca1\u6709first_id\uff0clogout\u5931\u8d25")}function getPresetProperties(){if(meta.preset_properties&&meta.preset_properties.$lib){var e={};each(meta.preset_properties,function(t,a){0===a.indexOf("$")&&(e[a]=t)});var t={$url_path:getCurrentPath(),$is_first_day:getIsFirstDay(),$is_first_time:meta.is_first_launch},a=extend(e,t,meta.preset_properties,store.getProps());return delete a.$lib,a}return{}}function setOpenid(e,t){if(!(e=validId(e)))return!1;if(!checkPrivacyStatus())return!1;if(!meta.init_status)return store.store_queue.push({method:"setOpenid",params:arguments}),!1;log("\u8be5\u65b9\u6cd5\u5df2\u4e0d\u5efa\u8bae\u4f7f\u7528\uff0c\u5982\u679c\u662f id2 \u7528\u6237\uff0c\u8bf7\u4f7f\u7528 identify \u4ee3\u66ff\uff0c\u5982\u679c\u662f id3 \u7528\u6237\uff0c\u8bf7\u4f7f\u7528 bindOpenid \u4ee3\u66ff"),t&&log("%c \u5f53\u524d\u7248\u672c setOpenid \u63a5\u53e3 \u5df2\u4e0d\u652f\u6301\u4f20\u5165\u7b2c\u4e8c\u4e2a\u53c2\u6570","color:#F39C12;font-size: 14px;"),store.set("openid",e),sa.identify(e,!0);var a=getOpenidNameByAppid();store._state.identities[a]=e,store.save()}function unsetOpenid(e){log("\u8be5\u65b9\u6cd5\u5df2\u4e0d\u5efa\u8bae\u4f7f\u7528\uff0c\u5982\u679c\u662f id3 \u7528\u6237\uff0c\u8bf7\u4f7f\u7528 unbindOpenid \u4ee3\u66ff");var t=validId(e);if(!t)return!1;var a=store._state.openid;a===t&&store.set("openid","");var r=getOpenidNameByAppid();if(hasOwnProperty$3.call(store._state.identities,r)&&t===store._state.identities[r]){delete store._state.identities[r];var i=store.getFirstId(),n=store.getDistinctId(),s=store._state&&store._state.identities&&store._state.identities.$identity_mp_id;i&&i===a&&s&&store.change("first_id",s),n&&n===a&&s&&store.change("distinct_id",s),store.save()}}function bindOpenid(e){if(!(e=validId(e)))return!1;var t=getOpenidNameByAppid();this.bind(t,e)}function unbindOpenid(e){if(!validId(e))return!1;var t=getOpenidNameByAppid();this.unbind(t,e)}function setUnionid(e){var t=validId(e);t&&bind("$identity_mp_unionid",t)}function unsetUnionid(e){var t=validId(e);if(t){if(hasOwnProperty$3.call(store._state.identities,"$identity_mp_unionid")&&t===store._state.identities.$identity_mp_unionid){var a=getOpenidNameByAppid();hasOwnProperty$3.call(store._state.identities,a)&&(delete store._state.identities[a],delete store._state.openid,store.save())}unbind("$identity_mp_unionid",t)}}function initWithOpenid(e,t){(e=e||{}).appid&&(saPara.appid=e.appid),sa.openid.getOpenid(function(a){a&&sa.setOpenid(a,e.isCoverLogin),t&&isFunction(t)&&t(a),sa.init(e)})}function bind(e,t){if(isNumber(t)){if(isInteger(t)&&!1===isSafeInteger(t))return log("Value must be String"),!1;t=String(t)}if(!isString(e))return log("Key must be String"),!1;var a=store.getHistoryLoginId(),r=a?a.name:"";return!check.checkKeyword(e)||isPresetIdKeys(e,[IDENTITY_KEY.LOGIN,r,"$mp_id","$identity_mp_id"])?(log("Key ["+e+"] is invalid"),!1):t&&""!==t?isString(t)?!!check.checkIdLength(t)&&(store._state.identities[e]=t,store.save(),void dataStage({type:"track_id_bind",event:"$BindID"})):(log("Value must be String"),!1):(log("Value is empty or null"),!1)}function unbind(e,t){if(isNumber(t)){if(isInteger(t)&&!1===isSafeInteger(t))return log("Value must be String"),!1;t=String(t)}if(!isString(e))return log("Key must be String"),!1;if(!sa._.check.checkKeyword(e)||isPresetIdKeys(e,[IDENTITY_KEY.LOGIN]))return log("Key ["+e+"] is invalid"),!1;if(!t||""===t)return log("Value is empty or null"),!1;if(!isString(t))return log("Value must be String"),!1;if(!sa._.check.checkIdLength(t))return!1;hasOwnProperty$3.call(store._state.identities,e)&&t===store._state.identities[e]&&("$mp_id"!==e&&"$identity_mp_id"!==e&&delete store._state.identities[e],store.save());var a=store.getDistinctId(),r=store.getFirstId();a===e+"+"+t&&(store.set("first_id",""),store.set("distinct_id",r),store.set("history_login_id",{name:"",value:""}));var i={};i[e]=t,dataStage({type:"track_id_unbind",event:"$UnbindID",unbind_value:i})}function setWebViewUrl(e,t){if(log("setWebViewUrl \u65b9\u6cd5\u5df2\u4ece 2022-9-23 \u5f00\u59cb\u5e9f\u5f03\uff0c\u8bf7\u5c3d\u5feb\u53bb\u9664\u8be5 API \u7684\u8c03\u7528\uff0c\u5e76\u4f7f\u7528 use \u63d2\u4ef6 \u4ee3\u66ff"),!isString(e)||""===e)return log("error:\u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;if(!/^http(s)?:\/\//.test(e))return log("warning: \u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;var a=/([^?#]+)(\?[^#]*)?(#.*)?/.exec(e);if(!a)return!1;var r,i=a[1]||"",n=a[2]||"",s=a[3]||"",o="",u=store.getDistinctId()||"",c=store.getFirstId()||"";urlSafeBase64&&urlSafeBase64.encode?u=u?urlSafeBase64.trim(urlSafeBase64.encode(urlBase64Encode(u))):"":rot13obfs&&(u=u?rot13obfs(u):""),u=encodeURIComponent(u);var p=c?"f"+u:"d"+u;t?(r=s.indexOf("_sasdk"),o=s.indexOf("?")>-1?r>-1?i+n+"#"+s.substring(1,r)+"_sasdk="+p:i+n+"#"+s.substring(1)+"&_sasdk="+p:i+n+"#"+s.substring(1)+"?_sasdk="+p):(r=n.indexOf("_sasdk"),o=/^\?(\w)+/.test(n)?r>-1?i+n.replace(/(_sasdk=)([^&]*)/gi,"_sasdk="+p)+s:i+"?"+n.substring(1)+"&_sasdk="+p+s:i+"?"+n.substring(1)+"_sasdk="+p+s);return o}function quick(){var e=arguments[0],t=arguments[1],a=arguments[2],r=isObject(a)?a:{};if("getAnonymousID"===e){if(!isEmptyObject(store._state))return store._state._first_id||store._state.first_id||store._state._distinct_id||store._state.distinct_id;log("\u8bf7\u5148\u521d\u59cb\u5316SDK")}else"appLaunch"===e||"appShow"===e?t?sa.autoTrackCustom[e](t,r):log("App\u7684launch\u548cshow\uff0c\u5728sensors.quick\u7b2c\u4e8c\u4e2a\u53c2\u6570\u5fc5\u987b\u4f20\u5165App\u7684options\u53c2\u6570"):"appHide"===e&&(r=isObject(t)?t:{},sa.autoTrackCustom[e](r))}function appLaunch(e,t){var a={};e&&e.scene?(meta.current_scene=e.scene,a.$scene=getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,delObjectKey(e.query)),e&&e.path&&(a.$url_path=getPath(e.path),a.$title=getPageTitle(e.path)),setShareInfo(e,a);var r=setUtm(e,a);meta.is_first_launch?(a.$is_first_time=!0,isEmptyObject(r.pre1)||sa.setOnceProfile(r.pre1)):a.$is_first_time=!1,setLatestChannel(r.pre2),setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=setQuery(e.query),a.$url=e.path+(a.$url_query?"?"+a.$url_query:""),setPageRefData(t),isObject(t)&&(a=extend(a,t)),sa.track("$MPLaunch",a)}function appShow(e,t){var a={};meta.mp_show_time=(new Date).getTime(),e&&e.scene?(meta.current_scene=e.scene,a.$scene=getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,delObjectKey(e.query)),e&&e.path&&(a.$url_path=getPath(e.path),a.$title=getPageTitle(e.path)),setShareInfo(e,a),setLatestChannel(setUtm(e,a).pre2),setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=setQuery(e.query),e&&e.path&&(a.$url=e.path+(a.$url_query?"?"+a.$url_query:"")),setPageRefData(a,e.path,a.$url_query),isObject(t)&&(a=extend(a,t)),sa.track("$MPShow",a)}function appHide(e){var t=(new Date).getTime(),a={};a.$url_path=getCurrentPath(),meta.mp_show_time&&t-meta.mp_show_time>0&&(t-meta.mp_show_time)/36e5<24&&(a.event_duration=(t-meta.mp_show_time)/1e3),setPageRefData(a),isObject(e)&&(a=extend(a,e)),sa.track("$MPHide",a),sa.sendStrategy.onAppHide()}function pageShow(e){var t={},a=getCurrentPath(),r=getPageTitle(a),i=getCurrentPage();r&&(t.$title=r),t.$url_path=a,t.$url_query=i.sensors_mp_url_query?i.sensors_mp_url_query:"",setPageSfSource(t=extend(t,getUtmFromPage())),setPageRefData(t),isObject(e)&&(t=extend(t,e)),sa.track("$MPViewScreen",t)}function setPara(e){sa.para=extend2Lev(saPara,e);var t=[];if(isArray(saPara.source_channel))for(var a=saPara.source_channel.length,r=0;r0&&(t-meta.mp_show_time)/36e5<24&&(a.event_duration=(t-meta.mp_show_time)/1e3),setPageRefData(a),e?(a=extend(a,e),sa.track("$MPHide",a)):saPara.autoTrack&&saPara.autoTrack.appHide&&sa.autoTrackCustom.trackCustom("appHide",a,"$MPHide")},pageLoad:function(e){meta.current_scene&&1010===meta.current_scene&&e&&(e.sampshare&&delete e.sampshare,delObjectKey(e)),e&&isObject(e)&&(this.sensors_mp_url_query=setQuery(e),this.sensors_mp_encode_url_query=setQuery(e,!0))},pageShow:function(){meta.page_show_time=Date.now();var e={},t=getCurrentPath(),a=getPageTitle(t);setRefPage(),e.$url_path=t,e.$url_query=this.sensors_mp_url_query?this.sensors_mp_url_query:"",setPageRefData(e=extend(e,getUtmFromPage())),setPageSfSource(e),a&&(e.$title=a),saPara.onshow?saPara.onshow(sa,t,this):-1===saPara.autotrack_exclude_page.pageShow.indexOf(t)&&sa.autoTrackCustom.trackCustom("pageShow",e,"$MPViewScreen")},pageShare:function(e){var t=e.onShareAppMessage;e.onShareAppMessage=function(){var e=this;meta.share_method="\u8f6c\u53d1\u6d88\u606f\u5361\u7247";var a,r=t.apply(this,arguments);if(saPara.autoTrack&&saPara.autoTrack.pageShare){var i={$url_path:getCurrentPath(),$share_depth:meta.query_share_depth,$share_method:meta.share_method};setPageRefData(i),sa.autoTrackCustom.trackCustom("pageShare",i,"$MPShare")}function n(t){return isObject(t)||(t={}),(isUndefined(t.path)||""===t.path)&&(t.path=getCurrentUrl(e)),isString(t.path)&&(-1===t.path.indexOf("?")?t.path=t.path+"?":"&"!==t.path.slice(-1)&&(t.path=t.path+"&")),t.path=t.path+getShareInfo(),t}if(sa.para.allow_amend_share_path&&isObject(r=n(r)))for(var s in r)if((a=r[s])&&isFunction(a.then)&&isFunction(a.catch))try{r[s]=r[s].then(function(e){return n(e)})}catch(e){log("onShareAppMessage: "+e)}return r}},pageShareTimeline:function(e){var t=e.onShareTimeline;e.onShareTimeline=function(){meta.share_method="\u670b\u53cb\u5708\u5206\u4eab";var e=t.apply(this,arguments);if(saPara.autoTrack&&saPara.autoTrack.pageShare){var a={$url_path:getCurrentPath(),$share_depth:meta.query_share_depth,$share_method:meta.share_method};setPageRefData(a),sa.autoTrackCustom.trackCustom("pageShare",a,"$MPShare")}return saPara.allow_amend_share_path&&("object"!=typeof e&&(e={}),"object"==typeof e&&void 0===e.query&&(e.query=""),"object"==typeof e&&"string"==typeof e.query&&""!==e.query&&"&"!==e.query.slice(-1)&&(e.query=e.query+"&"),e.query=e.query+getShareInfo()),e}},pageAddFavorites:function(){var e={};e.$url_path=getCurrentPath(),saPara.autoTrack&&saPara.autoTrack.mpFavorite&&sa.autoTrackCustom.trackCustom("mpFavorite",e,"$MPAddFavorites")},pageHide:function(){sa.para.autoTrack&&sa.para.autoTrack.pageLeave&&sendPageLeave()}};function sendPageLeave(){var e={},t="";try{t=(e=getCurrentPage())?e.route:""}catch(e){log(e)}if(meta.page_show_time>=0&&""!==t){var a={},r=getPageTitle(t),i=(Date.now()-meta.page_show_time)/1e3;(isNaN(i)||i<0)&&(i=0),a.$url_query=e.sensors_mp_url_query?e.sensors_mp_url_query:"",a.$url_path=t,a.$title=r,a.event_duration=i,-1===saPara.autotrack_exclude_page.pageLeave.indexOf(t)&&sa.track("$MPPageLeave",a),meta.page_show_time=-1}}var openid={getRequest:function(e){wx.login({success:function(t){t.code&&saPara.appid&&saPara.openid_url?wxrequest({url:saPara.openid_url+"&code="+t.code+"&appid="+saPara.appid,method:"GET",complete:function(t){isObject(t)&&isObject(t.data)&&t.data.openid?e(t.data.openid):e()}}):e()}})},getWXStorage:function(){var e=store.getStorage();if(e&&isObject(e))return e.openid},getOpenid:function(e){if(!saPara.appid)return e(),!1;var t=this.getWXStorage();t?e(t):this.getRequest(e)}},functions=Object.freeze({__proto__:null,setProfile:setProfile,setOnceProfile:setOnceProfile,appendProfile:appendProfile,incrementProfile:incrementProfile,track:track,identify:identify,trackSignup:trackSignup,login:login,loginWithKey:loginWithKey,getAnonymousID:getAnonymousID,getIdentities:getIdentities,logout:logout,getPresetProperties:getPresetProperties,setOpenid:setOpenid,unsetOpenid:unsetOpenid,bindOpenid:bindOpenid,unbindOpenid:unbindOpenid,setUnionid:setUnionid,unsetUnionid:unsetUnionid,bindUnionid:setUnionid,unbindUnionid:unsetUnionid,initWithOpenid:initWithOpenid,bind:bind,unbind:unbind,setWebViewUrl:setWebViewUrl,quick:quick,appLaunch:appLaunch,appShow:appShow,appHide:appHide,pageShow:pageShow,setPara:setPara,getServerUrl:getServerUrl,sendPageLeave:sendPageLeave,openid:openid,autoTrackCustom:autoTrackCustom,registerApp:registerApp,register:register,clearAllRegister:clearAllRegister,clearAppRegister:clearAppRegister,clearAllProps:clearAllProps});function buildAPI(e){for(var t in functions)e[t]=functions[t]}function setFirstVisitTime(){meta.is_first_launch&&setOnceProfile({$first_visit_time:new Date})}function checkIsComplete(){meta.initialState.isComplete=!0,meta.initialState.queue.length>0&&(each(meta.initialState.queue,function(e){"appLaunch"===e[0]?sa.autoTrackCustom.appLaunch.apply(sa.autoTrackCustom,slice.call(e[1])):sa[e[0]].apply(sa,slice.call(e[1]))}),meta.initialState.queue=[])}function init(e){if(!0===meta.init_status)return!1;function t(){checkIsComplete(),checkAppLaunch(),sa.ee.sdk.emit("ready")}meta.init_status=!0,sa.ee.sdk.emit("beforeInit"),e&&isObject(e)&&sa.setPara(e),sa.ee.sdk.emit("initPara"),sa.ee.sdk.emit("afterInitPara"),sa.store.init(),sa.checkPluginInitStatus(),setFirstVisitTime(),sa.para.batch_send&&sa.sendStrategy.init();var a=[getNetworkType(),getSystemInfo()].concat(meta.promise_list);Promise.all(a).then(()=>{t()}).catch(()=>{t()})}function registerPropertyPlugin(e){isFunction(e.properties)?!e.isMatchedWithFilter||isFunction(e.isMatchedWithFilter)?sa.ee.data.on("finalAdjustData",function(t){try{isFunction(e.isMatchedWithFilter)?e.isMatchedWithFilter(t)&&e.properties(t):e.properties(t)}catch(e){log("execute registerPropertyPlugin callback error:"+e)}}):log("registerPropertyPlugin arguments error, isMatchedWithFilter must be function"):log("registerPropertyPlugin arguments error, properties must be function")}sa._=_,sa.modules={},sa.meta=meta,sa.kit=kit,sa.mergeStorageData=mergeStorageData,sa.dataStage=dataStage,sa.sendStrategy=sendStrategy,sa.store=store,sa.usePlugin=usePlugin,sa.checkPluginInitStatus=checkPluginInitStatus,sa.eventSub=eventSub,sa.events=new eventEmitter,sa.ee=ee,sa.registerPropertyPlugin=registerPropertyPlugin,sa.enableDataCollect=enableDataCollect,sa.initialState=meta.initialState,sa.IDENTITY_KEY={EMAIL:IDENTITY_KEY.EMAIL,MOBILE:IDENTITY_KEY.MOBILE},buildAPI(sa),apiStaging(),setNavigationBarTitle(),networkStatusChange(),initAppGlobalName(),initAppShowHide(),initPageProxy(),sa.init=init;var base={plugin_version:"1.19.12"};function createPlugin(e){if("object"==typeof e&&"string"==typeof e.plugin_name&&""!==e.plugin_name)return e.plugin_version=base.plugin_version,e.log=e.log||function(){"object"==typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)},e;"object"==typeof console&&"function"==typeof console.error&&console.error('plugin must contain proprerty "plugin_name"')}var disableSDK={init(e){e.disableSDK=this.disableSDK.bind(this),e.enableSDK=this.enableSDK.bind(this),e.getDisabled=this.getDisabled.bind(this)},plugin_name:"DisableSDK",disabled:!1,disableSDK(){this.disabled=!0},enableSDK(){this.disabled=!1},getDisabled(){return this.disabled}},DisableSDK=createPlugin(disableSDK);sa.usePlugin(DisableSDK),module.exports=sa; \ No newline at end of file diff --git a/dist/wechat/sensorsdata.esm.js b/dist/wechat/sensorsdata.esm.js index a76678d..0879085 100644 --- a/dist/wechat/sensorsdata.esm.js +++ b/dist/wechat/sensorsdata.esm.js @@ -1 +1 @@ -var sa={},saPara={name:"sensors",server_url:"",send_timeout:1e3,show_log:!1,login_id_key:"$identity_login_id",allow_amend_share_path:!0,max_string_length:500,datasend_timeout:3e3,source_channel:[],autoTrack:{appLaunch:!0,appShow:!0,appHide:!0,pageShow:!0,pageShare:!0,mpClick:!1,mpFavorite:!0,pageLeave:!1},autotrack_exclude_page:{pageShow:[],pageLeave:[]},is_persistent_save:{share:!1,utm:!1},preset_properties:{url_path:!0},preset_events:{moments_page:!1,defer_track:!1,share_info_use_string:!1},batch_send:!0,storage_store_key:"sensorsdata2015_wechat",storage_prepare_data_key:"sensors_mp_prepare_data"};function log(){if(saPara.show_log&&"object"==typeof console&&console.log)try{return console.log.apply(console,arguments)}catch(e){console.log(arguments[0])}}var nativeIsArray=Array.isArray,ObjProto=Object.prototype,ArrayProto=Array.prototype,nativeForEach=ArrayProto.forEach,nativeIndexOf=ArrayProto.indexOf,toString=ObjProto.toString,hasOwnProperty=ObjProto.hasOwnProperty,slice=ArrayProto.slice;function each(e,t,a){if(null==e)return!1;var r={};if(nativeForEach&&e.forEach===nativeForEach)e.forEach(t,a);else if(e.length===+e.length){for(var i=0,n=e.length;i0&&each(this.store_queue,function(e){sa[e.method].apply(sa,slice.call(e.params))}),this.store_queue=[])}};function _decodeURIComponent(e){var t="";try{t=decodeURIComponent(e)}catch(a){t=e}return t}var hasOwnProperty$2=Object.prototype.hasOwnProperty,decodeURIComponent$1=_decodeURIComponent;function initAppGlobalName(){var e=App;App=function(t){t[saPara.name]=sa,e.apply(this,arguments)}}function getPublicPresetProperties(){var e=getRefPage(),t=getCurrentPageInfo(),a={$referrer:e.route,$referrer_title:e.title,$title:t.title,$url:t.url};return!0===saPara.preset_properties.url_path&&(a.$url_path=t.path),a}function encodeDates(e){return each(e,function(t,a){isDate(t)?e[a]=formatDate(t):isObject(t)&&(e[a]=encodeDates(t))}),e}function formatDate(e){function t(e){return e<10?"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())}function searchObjDate(e){(isObject(e)||isArray(e))&&each(e,function(t,a){isObject(t)||isArray(t)?searchObjDate(e[a]):isDate(t)&&(e[a]=formatDate(t))})}function formatString(e){return e.length>saPara.max_string_length?(log("\u5b57\u7b26\u4e32\u957f\u5ea6\u8d85\u8fc7\u9650\u5236\uff0c\u5df2\u7ecf\u505a\u622a\u53d6--"+e),e.slice(0,saPara.max_string_length)):e}function searchObjString(e){isObject(e)&&each(e,function(t,a){isObject(t)?searchObjString(e[a]):isString(t)&&(e[a]=formatString(t))})}function parseSuperProperties(e){isObject(e)&&each(e,function(t,a){if(isFunction(t))try{e[a]=t(),isFunction(e[a])&&(log("\u60a8\u7684\u5c5e\u6027- "+a+" \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[a])}catch(t){delete e[a],log("\u60a8\u7684\u5c5e\u6027- "+a+" \u629b\u51fa\u4e86\u5f02\u5e38\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}})}function unique(e){for(var t,a=[],r={},i=0;i255)||(log("id \u957f\u5ea6\u8d85\u8fc7 255 \u4e2a\u5b57\u7b26\uff01"),!1)}};function strip_sa_properties(e){return isObject(e)?(each(e,function(t,a){if(isArray(t)){var r=[];each(t,function(e){if(isString(e))r.push(e);else if(isUndefined(e))r.push("null");else try{r.push(JSON.stringify(e))}catch(e){log("\u60a8\u7684\u6570\u636e - "+a+":"+t+" - \u7684\u6570\u7ec4\u91cc\u7684\u503c\u6709\u9519\u8bef,\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}}),e[a]=r}if(isObject(t))try{e[a]=JSON.stringify(t)}catch(r){delete e[a],log("\u60a8\u7684\u6570\u636e - "+a+":"+t+" - \u7684\u6570\u636e\u503c\u6709\u9519\u8bef,\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}else isString(t)||isNumber(t)||isDate(t)||isBoolean(t)||isArray(t)||(log("\u60a8\u7684\u6570\u636e - "+a+":"+t+" - \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[a])}),e):e}function strip_empty_properties(e){var t={};return each(e,function(e,a){null==e&&void 0===e||(t[a]=e)}),t}function utf8Encode(e){var t,a,r,i,n="";for(t=a=0,r=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,i=0;i127&&s<2048?String.fromCharCode(s>>6|192,63&s|128):String.fromCharCode(s>>12|224,s>>6&63|128,63&s|128),null!==o&&(a>t&&(n+=e.substring(t,a)),n+=o,t=a=i+1)}return a>t&&(n+=e.substring(t,e.length)),n}function base64Encode(e){var t,a,r,i,n,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,u=0,c="",p=[];if(!e)return e;e=utf8Encode(e);do{t=(n=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>18&63,a=n>>12&63,r=n>>6&63,i=63&n,p[u++]=s.charAt(t)+s.charAt(a)+s.charAt(r)+s.charAt(i)}while(o255||(r=e.charCodeAt(o++))>255||(i=e.charCodeAt(o++))>255)&&log("Failed to execute 'btoa' : The string to be encoded contains characters outside of the Latin1 range."),s+=n.charAt((t=a<<16|r<<8|i)>>18&63)+n.charAt(t>>12&63)+n.charAt(t>>6&63)+n.charAt(63&t);return u?s.slice(0,u-3)+"===".substring(u):s}function urlBase64Encode(e){return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}))}function getCurrentPage(){var e={};try{var t=getCurrentPages();e=t[t.length-1]}catch(e){log(e)}return e}function getCurrentPath(){var e="\u672a\u53d6\u5230";try{var t=getCurrentPage();e=t?t.route:e}catch(e){log(e)}return e}function getIsFirstDay(){return!!("object"==typeof store._state&&isNumber(store._state.first_visit_day_time)&&store._state.first_visit_day_time>(new Date).getTime())}function getCurrentUrl(e){var t=getCurrentPath(),a="";return isObject(e)&&e.sensors_mp_encode_url_query&&(a=e.sensors_mp_encode_url_query),t?a?t+"?"+a:t:"\u672a\u53d6\u5230"}function getPath(e){return e=isString(e)?e.replace(/^\//,""):"\u53d6\u503c\u5f02\u5e38"}function getCustomUtmFromQuery(e,t,a,r){if(!isObject(e))return{};var i={};if(e.sa_utm)for(var n in e)"sa_utm"!==n?include(saPara.source_channel,n)&&(i[a+n]=e[n]):i[r+n]=e[n];else for(var s in e)-1===(" "+SOURCE_CHANNEL_STANDARD+" ").indexOf(" "+s+" ")?include(saPara.source_channel,s)&&(i[a+s]=e[s]):i[t+s]=e[s];return i}function getObjFromQuery(e){var t=e.split("?"),a=[],r={};return t&&t[1]?(each(t[1].split("&"),function(e){(a=e.split("="))[0]&&a[1]&&(r[a[0]]=a[1])}),r):{}}function setStorageSync(e,t){var a=function(){wx.setStorageSync(e,t)};try{a()}catch(e){log("set Storage fail --",e);try{a()}catch(e){log("set Storage fail again --",e)}}}function getStorageSync(e){var t="";try{t=wx.getStorageSync(e)}catch(e){log("getStorage fail")}return t}function getMPScene(e){return isNumber(e)||isString(e)&&""!==e?e="wx-"+String(e):"\u672a\u53d6\u5230\u503c"}function objToParam(e,t){if(!isObject(e))return log("\u8bf7\u4f20\u5165\u6709\u6548\u5bf9\u8c61"),"";var a=[];for(var r in e)if(hasOwnProperty$2.call(e,r)){var i=e[r];void 0===i?a.push(r+"="):(i=t?encodeURIComponent(i):i,a.push(r+"="+i))}return a.join("&")}function delObjectKey(e){if(isObject(e))for(var t=0;t=2?(meta.page_route_map.shift(),meta.page_route_map.push(e)):meta.page_route_map.push(e)}}catch(e){log(e)}}function getRefPage(){var e={route:"\u76f4\u63a5\u6253\u5f00",path:"\u76f4\u63a5\u6253\u5f00",title:""};return meta.page_route_map.length>1&&(e.title=meta.page_route_map[0].title,e.route=meta.page_route_map[0].route,e.path=meta.page_route_map[0].path),e}function getCurrentPageInfo(){var e=getCurrentPage(),t={title:"",url:"",path:"\u672a\u53d6\u5230"};if(e&&e.route){var a=e.sensors_mp_url_query?"?"+e.sensors_mp_url_query:"";t.title=getPageTitle(e.route),t.url=e.route+a,t.path=e.route}return t}function setPageRefData(e,t,a){var r=getRefPage();isObject(e)&&(t?meta.page_route_map.length>0&&t?(a=a?"?"+a:"",e.$referrer=getPath(t)+a,e.$referrer_title=getPageTitle(t)):(e.$referrer="\u76f4\u63a5\u6253\u5f00",e.$referrer_title=""):(e.$referrer=r.route,e.$referrer_title=r.title))}function getPageTitle(e){if("\u672a\u53d6\u5230"===e||!e)return"";var t="";try{if(__wxConfig){var a=__wxConfig,r=__wxConfig.page||{},i=r[e]||r[e+".html"],n={},s={};if(a.global&&a.global.window&&a.global.window.navigationBarTitleText&&(n.titleVal=a.global.window.navigationBarTitleText),i&&i.window&&i.window.navigationBarTitleText&&(s.titleVal=i.window.navigationBarTitleText),!s.titleVal&&__wxAppCode__){var o=__wxAppCode__[e+".json"];o&&o.navigationBarTitleText&&(s.titleVal=o.navigationBarTitleText)}if(each(meta.global_title,function(a,r){if(r===e)return t=a}),0===t.length){var u=extend(n,s);t=u.titleVal||""}}}catch(e){log(e)}return t}function wxrequest(e){if(compareSDKVersion(meta.wx_sdk_version,"2.10.0")>=0)e.timeout=saPara.datasend_timeout,wx.request(e);else{var t=wx.request(e);setTimeout(function(){isObject(t)&&isFunction(t.abort)&&t.abort()},saPara.datasend_timeout)}}function validId(e){return"string"!=typeof e&&"number"!=typeof e||""===e?(log("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1):"number"!=typeof e||(e=String(e),/^\d+$/.test(e))?!!check.checkIdLength(e)&&e:(log("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1)}function compareSDKVersion(e,t){e=e.split("."),t=t.split(".");for(var a=Math.max(e.length,t.length);e.lengthn)return 1;if(i{wx.getNetworkType({success:function(t){meta.preset_properties.$network_type=setUpperCase(t.networkType),e()},fail:function(e){log("\u83b7\u53d6\u7f51\u7edc\u4fe1\u606f\u5931\u8d25",e),t()}})})}function getSystemInfo(){var e=meta.preset_properties;return new Promise(t=>{wx.getSystemInfo({success:function(a){var r,i;e.$brand=setUpperCase(a.brand),e.$manufacturer=a.brand,e.$model=a.model,e.$screen_width=Number(a.screenWidth),e.$screen_height=Number(a.screenHeight),e.$os=(r=a.platform,"ios"===(i=r.toLowerCase())?"iOS":"android"===i?"Android":r),e.$os_version=a.system.indexOf(" ")>-1?a.system.split(" ")[1]:a.system,meta.wx_sdk_version=a.SDKVersion,e.$mp_client_app_version=a.version,e.$mp_client_basic_library_version=meta.wx_sdk_version;var n=(new Date).getTimezoneOffset(),s=getAppInfoSync();isNumber(n)&&(e.$timezone_offset=n),s.appId&&(e.$app_id=s.appId),s.appVersion&&(e.$app_version=s.appVersion),t()}})})}var info={currentProps:meta.preset_properties},logger={info:function(){if(saPara.show_log&&"object"==typeof console&&console.log)try{if(3===arguments.length)return console.log(arguments[0],arguments[1],arguments[2]);if(2===arguments.length)return console.log(arguments[0],arguments[1]);if(1===arguments.length)return console.log(arguments[0])}catch(e){console.log(arguments[0])}}};function isValidListener(e){return"function"==typeof e||!(!e||"object"!=typeof e)&&isValidListener(e.listener)}class EventEmitterBase{constructor(){this._events={}}on(e,t){if(!e||!t)return!1;if(!isValidListener(t))throw new Error("listener must be a function");this._events[e]=this._events[e]||[];var a="object"==typeof t;return this._events[e].push(a?t:{listener:t,once:!1}),this}prepend(e,t){if(!e||!t)return!1;if(!isValidListener(t))throw new Error("listener must be a function");this._events[e]=this._events[e]||[];var a="object"==typeof t;return this._events[e].unshift(a?t:{listener:t,once:!1}),this}prependOnce(e,t){return this.prepend(e,{listener:t,once:!0})}once(e,t){return this.on(e,{listener:t,once:!0})}off(e,t){var a=this._events[e];if(!a)return!1;if("number"==typeof t)a.splice(t,1);else if("function"==typeof t)for(var r=0,i=a.length;r0&&this.cacheEvents.forEach(function(a){a.type===e&&t.call(null,a.data)})}emit(e,t){super.emit.apply(this,arguments),this.cacheEvents.push({type:e,data:t}),this.cacheEvents.length>this.maxLen&&this.cacheEvents.shift()}}var _=Object.freeze({__proto__:null,decodeURIComponent:decodeURIComponent$1,encodeDates:encodeDates,formatDate:formatDate,searchObjDate:searchObjDate,formatString:formatString,searchObjString:searchObjString,parseSuperProperties:parseSuperProperties,unique:unique,check:check,getUtmFromPage:getUtmFromPage,setQuery:setQuery,setLatestShare:setLatestShare,setLatestChannel:setLatestChannel,setUpperCase:setUpperCase,compareSDKVersion:compareSDKVersion,validId:validId,wxrequest:wxrequest,getPageTitle:getPageTitle,setPageRefData:setPageRefData,getCurrentPageInfo:getCurrentPageInfo,getRefPage:getRefPage,setRefPage:setRefPage,setPageSfSource:setPageSfSource,setSfSource:setSfSource,setUtm:setUtm,getMixedQuery:getMixedQuery,detectOptionQuery:detectOptionQuery,getShareInfo:getShareInfo,setShareInfo:setShareInfo,shareInfoData:shareInfoData,delObjectKey:delObjectKey,objToParam:objToParam,getMPScene:getMPScene,getStorageSync:getStorageSync,setStorageSync:setStorageSync,getObjFromQuery:getObjFromQuery,getCustomUtmFromQuery:getCustomUtmFromQuery,getPath:getPath,getCurrentUrl:getCurrentUrl,getIsFirstDay:getIsFirstDay,getCurrentPath:getCurrentPath,getCurrentPage:getCurrentPage,urlBase64Encode:urlBase64Encode,btoa:btoa,base64Encode:base64Encode,strip_empty_properties:strip_empty_properties,strip_sa_properties:strip_sa_properties,setNavigationBarTitle:setNavigationBarTitle,networkStatusChange:networkStatusChange,getNetworkType:getNetworkType,getSystemInfo:getSystemInfo,encodeTrackData:encodeTrackData,initAppGlobalName:initAppGlobalName,getPublicPresetProperties:getPublicPresetProperties,setPublicProperties:setPublicProperties,isPresetIdKeys:isPresetIdKeys,isNewLoginId:isNewLoginId,isSameAndAnonymousID:isSameAndAnonymousID,info:info,logger:logger,getAppId:getAppId,getAppInfoSync:getAppInfoSync,getOpenidNameByAppid:getOpenidNameByAppid,rot13defs:rot13defs,rot13obfs:rot13obfs,each:each,isObject:isObject,getRandom:getRandom,extend:extend,extend2Lev:extend2Lev,coverExtend:coverExtend,isArray:isArray,isFunction:isFunction,isArguments:isArguments,toArray:toArray,values:values,include:include,trim:trim,isEmptyObject:isEmptyObject,deepCopy:deepCopy,isUndefined:isUndefined,isString:isString,isDate:isDate,isBoolean:isBoolean,isNumber:isNumber,isJSONString:isJSONString,isInteger:isInteger,isSafeInteger:isSafeInteger,slice:slice,urlSafeBase64:urlSafeBase64,EventEmitterBase:EventEmitterBase,EventEmitterEx:EventEmitterEx,log:log});function onEventSend(){return{}}function processData(e){return e}function batchTrackData(e){var t=Date.now();return e.forEach(function(e){e._flush_time=t}),"data_list="+encodeTrackData(e)}var mergeStorageData={getData:function(e){wx.getStorage({key:saPara.storage_prepare_data_key,complete:function(t){var a=t.data&&isArray(t.data)?t.data:[];mergeStorageData.deleteAesData(a),e&&e()}})},deleteAesData:function(e){var t=[],a=e.length;if(a>0){for(var r=0;r=saPara.batch_send.max_length&&this.batchSend()},wxrequest:function(e){if(isArray(e.data)&&e.data.length>0){var t=kit.batchTrackData(e.data);sa._.wxrequest({url:saPara.server_url,method:"POST",dataType:"text",data:t,header:{"content-type":"text/plain"},success:function(){e.success(e.len)},fail:function(){e.fail()}})}else e.success(e.len)},batchSend:function(){if(this.dataHasSend){var e,t,a=store.mem.mdata;(t=(e=a.length>=100?a.slice(0,100):a).length)>0&&(this.dataHasSend=!1,this.wxrequest({data:e,len:t,success:this.batchRemove.bind(this),fail:this.sendFail.bind(this)}))}},sendFail:function(){this.dataHasSend=!0,this.failTime++},batchRemove:function(e){store.mem.clear(e),this.dataHasSend=!0,this.dataHasChange=!0,this.batchWrite(),this.failTime=0},is_first_batch_write:!0,batchWrite:function(){this.dataHasChange&&(this.dataHasChange=!1,this.syncStorage&&sa._.setStorageSync(saPara.storage_prepare_data_key,store.mem.mdata))},batchInterval:function(){var e=this;!function t(){setTimeout(function(){e.batchWrite(),t()},500)}(),function t(){setTimeout(function(){e.batchSend(),t()},saPara.batch_send.send_timeout*Math.pow(2,e.failTime))}()}};function onceSend(e){e._flush_time=Date.now();var t=kit.onceTrackData(e),a=saPara.server_url+"?"+t;-1!==saPara.server_url.indexOf("?")&&(a=saPara.server_url+"&"+t),wxrequest({url:a,method:"GET"})}function buildData(e,t){var a={distinct_id:sa.store.getDistinctId(),identities:sa.store._state.identities,lib:{$lib:LIB_NAME,$lib_method:"code",$lib_version:LIB_VERSION},properties:{}};return"track_id_unbind"===e.type&&"$UnbindID"===e.event&&(a.identities=deepCopy(e.unbind_value),delete e.unbind_value),isObject(t)||(t={}),extend(a,sa.store.getUnionId(),e),isObject(e.properties)&&!isEmptyObject(e.properties)&&extend(a.properties,e.properties),e.type&&"profile"===e.type.slice(0,7)||(a._track_id=Number(String(getRandom()).slice(2,5)+String(getRandom()).slice(2,4)+String(Date.now()).slice(-4)),a.properties=extend({},getPublicPresetProperties(),meta.preset_properties,sa.store.getProps(),t,a.properties),"track"===e.type&&(a.properties.$is_first_day=getIsFirstDay())),a.properties.$time&&isDate(a.properties.$time)?(a.time=1*a.properties.$time,delete a.properties.$time):a.time=1*new Date,sa.ee.sdk.emit("createData",a),sa.ee.sdk.emit("beforeBuildCheck",a),sa.ee.data.emit("beforeBuildCheck",a),parseSuperProperties(a.properties),searchObjDate(a),strip_sa_properties(a.properties),searchObjString(a),sa.ee.data.emit("finalAdjustData",a),a}function dataStage(e){if(!saPara.server_url)return!1;if(meta.current_scene&&1154===meta.current_scene&&!sa.para.preset_events.moments_page)return!1;var t=sa._.deepCopy(e),a=buildData(e,kit.onEventSend(t));a?(log(a),sa.events.emit("send",a),sa.para.batch_send?sendStrategy.send(a):onceSend(a)):log("error: \u6570\u636e\u5f02\u5e38 "+a)}sa.popupEmitter={attached:function(){return!1}};var usePlugin=function(e,t){if(!isObject(e)&&!isFunction(e))return log("plugin must be an object",e),!1;if(isFunction(e.init)||log("plugin maybe missing init method",e.plugin_name||e),isString(e.plugin_name)&&e.plugin_name?sa.modules[e.plugin_name]?e=sa.modules[e.plugin_name]:sa.modules[e.plugin_name]=e:log("plugin_name is not defined - ",e.plugin_name||e),isObject(e)&&!0===e.plugin_is_init)return e;if(isObject(e)&&e.plugin_name&&(isString(e.plugin_version)&&e.plugin_version===LIB_VERSION||log("warning!"+e.plugin_name+" plugin version do not match SDK version \uff01\uff01\uff01")),meta.init_status)"function"==typeof e.init&&(e.init(sa,t),e.plugin_is_init=!0,log(e.plugin_name+" plugin is initialized"));else{var a={target:e,para:t};meta.plugin.uninitialized_list.push(a)}return e},checkPluginInitStatus=function(){if(meta.plugin.uninitialized_list.length>0){for(var e in meta.plugin.uninitialized_list){var t=meta.plugin.uninitialized_list[e];t&&t.target&&"function"==typeof t.target.init&&!t.target.plugin_is_init&&(t.target.init(sa,t.para),isObject(t.target)&&(t.target.plugin_is_init=!0,isString(t.target.plugin_name)&&t.target.plugin_name&&log(t.target.plugin_name+" plugin is initialized")))}meta.plugin.uninitialized_list=[]}};function initAppShowHide(){wx.onAppShow(function(e){if(!meta.life_state.app_launched){var t=wx.getLaunchOptionsSync()||{};sa.autoTrackCustom.appLaunch(t)}sa.autoTrackCustom.appShow(e)}),wx.onAppHide(function(){sa.autoTrackCustom.appHide()})}function checkAppLaunch(){if(!meta.life_state.app_launched){var e=wx.getLaunchOptionsSync()||{};sa.autoTrackCustom.appLaunch(e)}}function mpProxy(e,t,a){var r=sa.autoTrackCustom[a];if(e[t]){var i=e[t];e[t]=function(){!sa.para.autoTrackIsFirst||isObject(sa.para.autoTrackIsFirst)&&!sa.para.autoTrackIsFirst[a]?(i.apply(this,arguments),r.apply(this,arguments)):(!0===sa.para.autoTrackIsFirst||isObject(sa.para.autoTrackIsFirst)&&sa.para.autoTrackIsFirst[a])&&(r.apply(this,arguments),i.apply(this,arguments)),sa.ee.page.emit(a)}}else e[t]=function(){r.apply(this,arguments),sa.ee.page.emit(a)}}function clickTrack(e){var t,a={},r={},i=e.currentTarget||{},n=e.target||{};if(isObject(sa.para.framework)&&isObject(sa.para.framework.taro)&&!sa.para.framework.taro.createApp&&n.id&&i.id&&n.id!==i.id)return!1;var s=i.dataset||{};if(t=e.type,a.$element_id=i.id,a.$element_type=s.type,a.$element_content=s.content,a.$element_name=s.name,isObject(e.event_prop)&&(r=e.event_prop),t&&isClick(t)){if(sa.para.preset_events&&sa.para.preset_events.collect_element&&!1===sa.para.preset_events.collect_element(arguments[0]))return!1;a.$url_path=sa._.getCurrentPath(),sa._.setPageRefData(a),a=sa._.extend(a,r),sa.track("$MPClick",a)}}function clickProxy(e,t){var a=e[t];e[t]=function(){var e=a.apply(this,arguments),t=arguments[0];return isObject(t)&&(sa.para.preset_events.defer_track?setTimeout(function(){clickTrack(t)},0):clickTrack(t)),e}}function isClick(e){return!!{tap:1,longpress:1,longtap:1}[e]}function tabProxy(e){var t=e.onTabItemTap;e.onTabItemTap=function(e){t&&t.apply(this,arguments);var a={};e&&(a.$element_content=e.text),a.$element_type="tabBar",a.$url_path=sa._.getCurrentPath(),sa._.setPageRefData(a),sa.track("$MPClick",a)}}function getMethods(e){var t=MP_FILTER_HOOK,a=[];for(var r in e)"function"!=typeof e[r]||t[r]||a.push(r);return a}function initPageProxy(){var e=Page;Page=function(t){try{t||(t={}),monitorClick(t),monitorHooks(t),e.apply(this,arguments)}catch(t){e.apply(this,arguments)}};var t=Component;Component=function(e){try{e||(e={}),e.methods||(e.methods={}),monitorClick(e.methods),monitorHooks(e.methods),t.apply(this,arguments)}catch(e){t.apply(this,arguments)}}}function monitorClick(e){var t=[];if(sa.para.autoTrack&&sa.para.autoTrack.mpClick){t=getMethods(e),tabProxy(e);for(var a=t.length,r=0;r100)log("Key ["+e+"] is invalid");else if(!check.checkKeyword(e))return log("Key ["+e+"] is invalid"),!1;if(isPresetIdKeys(e,["$mp_openid","$identity_mp_openid","$identity_mp_unionid","$mp_unionid","$mp_id","$identity_mp_id"]))return log("Key ["+e+"] is invalid"),!1;if(!(t=validId(t)))return!1;if(isSameAndAnonymousID(t))return!1;var a=store.getFirstId(),r=store.getDistinctId();isNewLoginId(e,t)&&(store._state.identities[e]=t,store.set("history_login_id",{name:e,value:t}),a||store.set("first_id",r),sa.trackSignup({id:t,event_name:"$SignUp",id_name:e}),store.identitiesSet({type:"login",id:t,id_name:e}))}function getAnonymousID(){if(!isEmptyObject(store._state))return store._state._first_id||store._state.first_id||store._state._distinct_id||store._state.distinct_id;log("\u8bf7\u5148\u521d\u59cb\u5316SDK")}function getIdentities(){return isEmptyObject(store._state)?(log("\u8bf7\u5148\u521d\u59cb\u5316SDK"),null):store._state.identities||null}function logout(e){var t=store.getFirstId();store.identitiesSet({type:"logout"}),store.set("history_login_id",{name:"",value:""}),t?(store.set("first_id",""),!0===e?store.set("distinct_id",store.getUUID()):store.set("distinct_id",t)):log("\u6ca1\u6709first_id\uff0clogout\u5931\u8d25")}function getPresetProperties(){if(meta.preset_properties&&meta.preset_properties.$lib){var e={};each(meta.preset_properties,function(t,a){0===a.indexOf("$")&&(e[a]=t)});var t={$url_path:getCurrentPath(),$is_first_day:getIsFirstDay(),$is_first_time:meta.is_first_launch},a=extend(e,t,meta.preset_properties,store.getProps());return delete a.$lib,a}return{}}function setOpenid(e,t){if(!(e=validId(e)))return!1;if(!checkPrivacyStatus())return!1;if(!meta.init_status)return store.store_queue.push({method:"setOpenid",params:arguments}),!1;log("\u8be5\u65b9\u6cd5\u5df2\u4e0d\u5efa\u8bae\u4f7f\u7528\uff0c\u5982\u679c\u662f id2 \u7528\u6237\uff0c\u8bf7\u4f7f\u7528 identify \u4ee3\u66ff\uff0c\u5982\u679c\u662f id3 \u7528\u6237\uff0c\u8bf7\u4f7f\u7528 bindOpenid \u4ee3\u66ff"),t&&log("%c \u5f53\u524d\u7248\u672c setOpenid \u63a5\u53e3 \u5df2\u4e0d\u652f\u6301\u4f20\u5165\u7b2c\u4e8c\u4e2a\u53c2\u6570","color:#F39C12;font-size: 14px;"),store.set("openid",e),sa.identify(e,!0);var a=getOpenidNameByAppid();store._state.identities[a]=e,store.save()}function unsetOpenid(e){log("\u8be5\u65b9\u6cd5\u5df2\u4e0d\u5efa\u8bae\u4f7f\u7528\uff0c\u5982\u679c\u662f id3 \u7528\u6237\uff0c\u8bf7\u4f7f\u7528 unbindOpenid \u4ee3\u66ff");var t=validId(e);if(!t)return!1;var a=store._state.openid;a===t&&store.set("openid","");var r=getOpenidNameByAppid();if(hasOwnProperty$3.call(store._state.identities,r)&&t===store._state.identities[r]){delete store._state.identities[r];var i=store.getFirstId(),n=store.getDistinctId(),s=store._state&&store._state.identities&&store._state.identities.$identity_mp_id;i&&i===a&&s&&store.change("first_id",s),n&&n===a&&s&&store.change("distinct_id",s),store.save()}}function bindOpenid(e){if(!(e=validId(e)))return!1;var t=getOpenidNameByAppid();this.bind(t,e)}function unbindOpenid(e){if(!validId(e))return!1;var t=getOpenidNameByAppid();this.unbind(t,e)}function setUnionid(e){var t=validId(e);t&&bind("$identity_mp_unionid",t)}function unsetUnionid(e){var t=validId(e);if(t){if(hasOwnProperty$3.call(store._state.identities,"$identity_mp_unionid")&&t===store._state.identities.$identity_mp_unionid){var a=getOpenidNameByAppid();hasOwnProperty$3.call(store._state.identities,a)&&(delete store._state.identities[a],delete store._state.openid,store.save())}unbind("$identity_mp_unionid",t)}}function initWithOpenid(e,t){(e=e||{}).appid&&(saPara.appid=e.appid),sa.openid.getOpenid(function(a){a&&sa.setOpenid(a,e.isCoverLogin),t&&isFunction(t)&&t(a),sa.init(e)})}function bind(e,t){if(isNumber(t)){if(isInteger(t)&&!1===isSafeInteger(t))return log("Value must be String"),!1;t=String(t)}if(!isString(e))return log("Key must be String"),!1;var a=store.getHistoryLoginId(),r=a?a.name:"";return!check.checkKeyword(e)||isPresetIdKeys(e,[IDENTITY_KEY.LOGIN,r,"$mp_id","$identity_mp_id"])?(log("Key ["+e+"] is invalid"),!1):t&&""!==t?isString(t)?!!check.checkIdLength(t)&&(store._state.identities[e]=t,store.save(),void dataStage({type:"track_id_bind",event:"$BindID"})):(log("Value must be String"),!1):(log("Value is empty or null"),!1)}function unbind(e,t){if(isNumber(t)){if(isInteger(t)&&!1===isSafeInteger(t))return log("Value must be String"),!1;t=String(t)}if(!isString(e))return log("Key must be String"),!1;if(!sa._.check.checkKeyword(e)||isPresetIdKeys(e,[IDENTITY_KEY.LOGIN]))return log("Key ["+e+"] is invalid"),!1;if(!t||""===t)return log("Value is empty or null"),!1;if(!isString(t))return log("Value must be String"),!1;if(!sa._.check.checkIdLength(t))return!1;hasOwnProperty$3.call(store._state.identities,e)&&t===store._state.identities[e]&&("$mp_id"!==e&&"$identity_mp_id"!==e&&delete store._state.identities[e],store.save());var a=store.getDistinctId(),r=store.getFirstId();a===e+"+"+t&&(store.set("first_id",""),store.set("distinct_id",r),store.set("history_login_id",{name:"",value:""}));var i={};i[e]=t,dataStage({type:"track_id_unbind",event:"$UnbindID",unbind_value:i})}function setWebViewUrl(e,t){if(log("setWebViewUrl \u65b9\u6cd5\u5df2\u4ece 2022-9-23 \u5f00\u59cb\u5e9f\u5f03\uff0c\u8bf7\u5c3d\u5feb\u53bb\u9664\u8be5 API \u7684\u8c03\u7528\uff0c\u5e76\u4f7f\u7528 use \u63d2\u4ef6 \u4ee3\u66ff"),!isString(e)||""===e)return log("error:\u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;if(!/^http(s)?:\/\//.test(e))return log("warning: \u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;var a=/([^?#]+)(\?[^#]*)?(#.*)?/.exec(e);if(!a)return!1;var r,i=a[1]||"",n=a[2]||"",s=a[3]||"",o="",u=store.getDistinctId()||"",c=store.getFirstId()||"";urlSafeBase64&&urlSafeBase64.encode?u=u?urlSafeBase64.trim(urlSafeBase64.encode(urlBase64Encode(u))):"":rot13obfs&&(u=u?rot13obfs(u):""),u=encodeURIComponent(u);var p=c?"f"+u:"d"+u;t?(r=s.indexOf("_sasdk"),o=s.indexOf("?")>-1?r>-1?i+n+"#"+s.substring(1,r)+"_sasdk="+p:i+n+"#"+s.substring(1)+"&_sasdk="+p:i+n+"#"+s.substring(1)+"?_sasdk="+p):(r=n.indexOf("_sasdk"),o=/^\?(\w)+/.test(n)?r>-1?i+n.replace(/(_sasdk=)([^&]*)/gi,"_sasdk="+p)+s:i+"?"+n.substring(1)+"&_sasdk="+p+s:i+"?"+n.substring(1)+"_sasdk="+p+s);return o}function quick(){var e=arguments[0],t=arguments[1],a=arguments[2],r=isObject(a)?a:{};if("getAnonymousID"===e){if(!isEmptyObject(store._state))return store._state._first_id||store._state.first_id||store._state._distinct_id||store._state.distinct_id;log("\u8bf7\u5148\u521d\u59cb\u5316SDK")}else"appLaunch"===e||"appShow"===e?t?sa.autoTrackCustom[e](t,r):log("App\u7684launch\u548cshow\uff0c\u5728sensors.quick\u7b2c\u4e8c\u4e2a\u53c2\u6570\u5fc5\u987b\u4f20\u5165App\u7684options\u53c2\u6570"):"appHide"===e&&(r=isObject(t)?t:{},sa.autoTrackCustom[e](r))}function appLaunch(e,t){var a={};e&&e.scene?(meta.current_scene=e.scene,a.$scene=getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,delObjectKey(e.query)),e&&e.path&&(a.$url_path=getPath(e.path),a.$title=getPageTitle(e.path)),setShareInfo(e,a);var r=setUtm(e,a);meta.is_first_launch?(a.$is_first_time=!0,isEmptyObject(r.pre1)||sa.setOnceProfile(r.pre1)):a.$is_first_time=!1,setLatestChannel(r.pre2),setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=setQuery(e.query),a.$url=e.path+(a.$url_query?"?"+a.$url_query:""),setPageRefData(t),isObject(t)&&(a=extend(a,t)),sa.track("$MPLaunch",a)}function appShow(e,t){var a={};meta.mp_show_time=(new Date).getTime(),e&&e.scene?(meta.current_scene=e.scene,a.$scene=getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,delObjectKey(e.query)),e&&e.path&&(a.$url_path=getPath(e.path),a.$title=getPageTitle(e.path)),setShareInfo(e,a),setLatestChannel(setUtm(e,a).pre2),setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=setQuery(e.query),e&&e.path&&(a.$url=e.path+(a.$url_query?"?"+a.$url_query:"")),setPageRefData(a,e.path,a.$url_query),isObject(t)&&(a=extend(a,t)),sa.track("$MPShow",a)}function appHide(e){var t=(new Date).getTime(),a={};a.$url_path=getCurrentPath(),meta.mp_show_time&&t-meta.mp_show_time>0&&(t-meta.mp_show_time)/36e5<24&&(a.event_duration=(t-meta.mp_show_time)/1e3),setPageRefData(a),isObject(e)&&(a=extend(a,e)),sa.track("$MPHide",a),sa.sendStrategy.onAppHide()}function pageShow(e){var t={},a=getCurrentPath(),r=getPageTitle(a),i=getCurrentPage();setRefPage(),r&&(t.$title=r),t.$url_path=a,t.$url_query=i.sensors_mp_url_query?i.sensors_mp_url_query:"",setPageSfSource(t=extend(t,getUtmFromPage())),setPageRefData(t),isObject(e)&&(t=extend(t,e)),sa.track("$MPViewScreen",t)}function setPara(e){sa.para=extend2Lev(saPara,e);var t=[];if(isArray(saPara.source_channel))for(var a=saPara.source_channel.length,r=0;r0&&(t-meta.mp_show_time)/36e5<24&&(a.event_duration=(t-meta.mp_show_time)/1e3),setPageRefData(a),e?(a=extend(a,e),sa.track("$MPHide",a)):saPara.autoTrack&&saPara.autoTrack.appHide&&sa.autoTrackCustom.trackCustom("appHide",a,"$MPHide")},pageLoad:function(e){meta.current_scene&&1010===meta.current_scene&&e&&(e.sampshare&&delete e.sampshare,delObjectKey(e)),e&&isObject(e)&&(this.sensors_mp_url_query=setQuery(e),this.sensors_mp_encode_url_query=setQuery(e,!0))},pageShow:function(){meta.page_show_time=Date.now();var e={},t=getCurrentPath(),a=getPageTitle(t);setRefPage(),e.$url_path=t,e.$url_query=this.sensors_mp_url_query?this.sensors_mp_url_query:"",setPageRefData(e=extend(e,getUtmFromPage())),setPageSfSource(e),a&&(e.$title=a),saPara.onshow?saPara.onshow(sa,t,this):-1===saPara.autotrack_exclude_page.pageShow.indexOf(t)&&sa.autoTrackCustom.trackCustom("pageShow",e,"$MPViewScreen")},pageShare:function(e){var t=e.onShareAppMessage;e.onShareAppMessage=function(){var e=this;meta.share_method="\u8f6c\u53d1\u6d88\u606f\u5361\u7247";var a,r=t.apply(this,arguments);if(saPara.autoTrack&&saPara.autoTrack.pageShare){var i={$url_path:getCurrentPath(),$share_depth:meta.query_share_depth,$share_method:meta.share_method};setPageRefData(i),sa.autoTrackCustom.trackCustom("pageShare",i,"$MPShare")}function n(t){return isObject(t)||(t={}),(isUndefined(t.path)||""===t.path)&&(t.path=getCurrentUrl(e)),isString(t.path)&&(-1===t.path.indexOf("?")?t.path=t.path+"?":"&"!==t.path.slice(-1)&&(t.path=t.path+"&")),t.path=t.path+getShareInfo(),t}if(sa.para.allow_amend_share_path&&isObject(r=n(r)))for(var s in r)if((a=r[s])&&isFunction(a.then)&&isFunction(a.catch))try{r[s]=r[s].then(function(e){return n(e)})}catch(e){log("onShareAppMessage: "+e)}return r}},pageShareTimeline:function(e){var t=e.onShareTimeline;e.onShareTimeline=function(){meta.share_method="\u670b\u53cb\u5708\u5206\u4eab";var e=t.apply(this,arguments);if(saPara.autoTrack&&saPara.autoTrack.pageShare){var a={$url_path:getCurrentPath(),$share_depth:meta.query_share_depth,$share_method:meta.share_method};setPageRefData(a),sa.autoTrackCustom.trackCustom("pageShare",a,"$MPShare")}return saPara.allow_amend_share_path&&("object"!=typeof e&&(e={}),"object"==typeof e&&void 0===e.query&&(e.query=""),"object"==typeof e&&"string"==typeof e.query&&""!==e.query&&"&"!==e.query.slice(-1)&&(e.query=e.query+"&"),e.query=e.query+getShareInfo()),e}},pageAddFavorites:function(){var e={};e.$url_path=getCurrentPath(),saPara.autoTrack&&saPara.autoTrack.mpFavorite&&sa.autoTrackCustom.trackCustom("mpFavorite",e,"$MPAddFavorites")},pageHide:function(){sa.para.autoTrack&&sa.para.autoTrack.pageLeave&&sendPageLeave()}};function sendPageLeave(){var e={},t="";try{t=(e=getCurrentPage())?e.route:""}catch(e){log(e)}if(meta.page_show_time>=0&&""!==t){var a={},r=getPageTitle(t),i=(Date.now()-meta.page_show_time)/1e3;(isNaN(i)||i<0)&&(i=0),a.$url_query=e.sensors_mp_url_query?e.sensors_mp_url_query:"",a.$url_path=t,a.$title=r,a.event_duration=i,-1===saPara.autotrack_exclude_page.pageLeave.indexOf(t)&&sa.track("$MPPageLeave",a),meta.page_show_time=-1}}var openid={getRequest:function(e){wx.login({success:function(t){t.code&&saPara.appid&&saPara.openid_url?wxrequest({url:saPara.openid_url+"&code="+t.code+"&appid="+saPara.appid,method:"GET",complete:function(t){isObject(t)&&isObject(t.data)&&t.data.openid?e(t.data.openid):e()}}):e()}})},getWXStorage:function(){var e=store.getStorage();if(e&&isObject(e))return e.openid},getOpenid:function(e){if(!saPara.appid)return e(),!1;var t=this.getWXStorage();t?e(t):this.getRequest(e)}},functions=Object.freeze({__proto__:null,setProfile:setProfile,setOnceProfile:setOnceProfile,appendProfile:appendProfile,incrementProfile:incrementProfile,track:track,identify:identify,trackSignup:trackSignup,login:login,loginWithKey:loginWithKey,getAnonymousID:getAnonymousID,getIdentities:getIdentities,logout:logout,getPresetProperties:getPresetProperties,setOpenid:setOpenid,unsetOpenid:unsetOpenid,bindOpenid:bindOpenid,unbindOpenid:unbindOpenid,setUnionid:setUnionid,unsetUnionid:unsetUnionid,bindUnionid:setUnionid,unbindUnionid:unsetUnionid,initWithOpenid:initWithOpenid,bind:bind,unbind:unbind,setWebViewUrl:setWebViewUrl,quick:quick,appLaunch:appLaunch,appShow:appShow,appHide:appHide,pageShow:pageShow,setPara:setPara,getServerUrl:getServerUrl,sendPageLeave:sendPageLeave,openid:openid,autoTrackCustom:autoTrackCustom,registerApp:registerApp,register:register,clearAllRegister:clearAllRegister,clearAppRegister:clearAppRegister,clearAllProps:clearAllProps});function buildAPI(e){for(var t in functions)e[t]=functions[t]}function setFirstVisitTime(){meta.is_first_launch&&setOnceProfile({$first_visit_time:new Date})}function checkIsComplete(){meta.initialState.isComplete=!0,meta.initialState.queue.length>0&&(each(meta.initialState.queue,function(e){"appLaunch"===e[0]?sa.autoTrackCustom.appLaunch.apply(sa.autoTrackCustom,slice.call(e[1])):sa[e[0]].apply(sa,slice.call(e[1]))}),meta.initialState.queue=[])}function init(e){if(!0===meta.init_status)return!1;function t(){checkIsComplete(),checkAppLaunch(),sa.ee.sdk.emit("ready")}meta.init_status=!0,sa.ee.sdk.emit("beforeInit"),e&&isObject(e)&&sa.setPara(e),sa.ee.sdk.emit("initPara"),sa.ee.sdk.emit("afterInitPara"),sa.store.init(),sa.checkPluginInitStatus(),setFirstVisitTime(),sa.para.batch_send&&sa.sendStrategy.init();var a=[getNetworkType(),getSystemInfo()].concat(meta.promise_list);Promise.all(a).then(()=>{t()}).catch(()=>{t()})}function registerPropertyPlugin(e){isFunction(e.properties)?!e.isMatchedWithFilter||isFunction(e.isMatchedWithFilter)?sa.ee.data.on("finalAdjustData",function(t){try{isFunction(e.isMatchedWithFilter)?e.isMatchedWithFilter(t)&&e.properties(t):e.properties(t)}catch(e){log("execute registerPropertyPlugin callback error:"+e)}}):log("registerPropertyPlugin arguments error, isMatchedWithFilter must be function"):log("registerPropertyPlugin arguments error, properties must be function")}sa._=_,sa.modules={},sa.meta=meta,sa.kit=kit,sa.mergeStorageData=mergeStorageData,sa.dataStage=dataStage,sa.sendStrategy=sendStrategy,sa.store=store,sa.usePlugin=usePlugin,sa.checkPluginInitStatus=checkPluginInitStatus,sa.eventSub=eventSub,sa.events=new eventEmitter,sa.ee=ee,sa.registerPropertyPlugin=registerPropertyPlugin,sa.enableDataCollect=enableDataCollect,sa.initialState=meta.initialState,sa.IDENTITY_KEY={EMAIL:IDENTITY_KEY.EMAIL,MOBILE:IDENTITY_KEY.MOBILE},buildAPI(sa),apiStaging(),setNavigationBarTitle(),networkStatusChange(),initAppGlobalName(),initAppShowHide(),initPageProxy(),sa.init=init;var base={plugin_version:"1.19.11"};function createPlugin(e){if("object"==typeof e&&"string"==typeof e.plugin_name&&""!==e.plugin_name)return e.plugin_version=base.plugin_version,e.log=e.log||function(){"object"==typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)},e;"object"==typeof console&&"function"==typeof console.error&&console.error('plugin must contain proprerty "plugin_name"')}var disableSDK={init(e){e.disableSDK=this.disableSDK.bind(this),e.enableSDK=this.enableSDK.bind(this),e.getDisabled=this.getDisabled.bind(this)},plugin_name:"DisableSDK",disabled:!1,disableSDK(){this.disabled=!0},enableSDK(){this.disabled=!1},getDisabled(){return this.disabled}},DisableSDK=createPlugin(disableSDK);sa.usePlugin(DisableSDK);export default sa; \ No newline at end of file +var sa={},saPara={name:"sensors",server_url:"",send_timeout:1e3,show_log:!1,login_id_key:"$identity_login_id",allow_amend_share_path:!0,max_string_length:500,datasend_timeout:3e3,source_channel:[],autoTrack:{appLaunch:!0,appShow:!0,appHide:!0,pageShow:!0,pageShare:!0,mpClick:!1,mpFavorite:!0,pageLeave:!1},autotrack_exclude_page:{pageShow:[],pageLeave:[]},is_persistent_save:{share:!1,utm:!1},preset_properties:{url_path:!0},preset_events:{moments_page:!1,defer_track:!1,share_info_use_string:!1},batch_send:!0,storage_store_key:"sensorsdata2015_wechat",storage_prepare_data_key:"sensors_mp_prepare_data"};function log(){if(saPara.show_log&&"object"==typeof console&&console.log)try{return console.log.apply(console,arguments)}catch(e){console.log(arguments[0])}}var nativeIsArray=Array.isArray,ObjProto=Object.prototype,ArrayProto=Array.prototype,nativeForEach=ArrayProto.forEach,nativeIndexOf=ArrayProto.indexOf,toString=ObjProto.toString,hasOwnProperty=ObjProto.hasOwnProperty,slice=ArrayProto.slice;function each(e,t,a){if(null==e)return!1;var r={};if(nativeForEach&&e.forEach===nativeForEach)e.forEach(t,a);else if(e.length===+e.length){for(var i=0,n=e.length;i0&&each(this.store_queue,function(e){sa[e.method].apply(sa,slice.call(e.params))}),this.store_queue=[])}};function _decodeURIComponent(e){var t="";try{t=decodeURIComponent(e)}catch(a){t=e}return t}var hasOwnProperty$2=Object.prototype.hasOwnProperty,decodeURIComponent$1=_decodeURIComponent;function initAppGlobalName(){var e=App;App=function(t){t[saPara.name]=sa,e.apply(this,arguments)}}function getPublicPresetProperties(){var e=getRefPage(),t=getCurrentPageInfo(),a={$referrer:e.route,$referrer_title:e.title,$title:t.title,$url:t.url};return!0===saPara.preset_properties.url_path&&(a.$url_path=t.path),a}function encodeDates(e){return each(e,function(t,a){isDate(t)?e[a]=formatDate(t):isObject(t)&&(e[a]=encodeDates(t))}),e}function formatDate(e){function t(e){return e<10?"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())}function searchObjDate(e){(isObject(e)||isArray(e))&&each(e,function(t,a){isObject(t)||isArray(t)?searchObjDate(e[a]):isDate(t)&&(e[a]=formatDate(t))})}function formatString(e){return e.length>saPara.max_string_length?(log("\u5b57\u7b26\u4e32\u957f\u5ea6\u8d85\u8fc7\u9650\u5236\uff0c\u5df2\u7ecf\u505a\u622a\u53d6--"+e),e.slice(0,saPara.max_string_length)):e}function searchObjString(e){isObject(e)&&each(e,function(t,a){isObject(t)?searchObjString(e[a]):isString(t)&&(e[a]=formatString(t))})}function parseSuperProperties(e){isObject(e)&&each(e,function(t,a){if(isFunction(t))try{e[a]=t(),isFunction(e[a])&&(log("\u60a8\u7684\u5c5e\u6027- "+a+" \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[a])}catch(t){delete e[a],log("\u60a8\u7684\u5c5e\u6027- "+a+" \u629b\u51fa\u4e86\u5f02\u5e38\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}})}function unique(e){for(var t,a=[],r={},i=0;i255)||(log("id \u957f\u5ea6\u8d85\u8fc7 255 \u4e2a\u5b57\u7b26\uff01"),!1)}};function strip_sa_properties(e){return isObject(e)?(each(e,function(t,a){if(isArray(t)){var r=[];each(t,function(e){if(isString(e))r.push(e);else if(isUndefined(e))r.push("null");else try{r.push(JSON.stringify(e))}catch(e){log("\u60a8\u7684\u6570\u636e - "+a+":"+t+" - \u7684\u6570\u7ec4\u91cc\u7684\u503c\u6709\u9519\u8bef,\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}}),e[a]=r}if(isObject(t))try{e[a]=JSON.stringify(t)}catch(r){delete e[a],log("\u60a8\u7684\u6570\u636e - "+a+":"+t+" - \u7684\u6570\u636e\u503c\u6709\u9519\u8bef,\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}else isString(t)||isNumber(t)||isDate(t)||isBoolean(t)||isArray(t)||(log("\u60a8\u7684\u6570\u636e - "+a+":"+t+" - \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[a])}),e):e}function strip_empty_properties(e){var t={};return each(e,function(e,a){null==e&&void 0===e||(t[a]=e)}),t}function utf8Encode(e){var t,a,r,i,n="";for(t=a=0,r=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,i=0;i127&&s<2048?String.fromCharCode(s>>6|192,63&s|128):String.fromCharCode(s>>12|224,s>>6&63|128,63&s|128),null!==o&&(a>t&&(n+=e.substring(t,a)),n+=o,t=a=i+1)}return a>t&&(n+=e.substring(t,e.length)),n}function base64Encode(e){var t,a,r,i,n,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,u=0,c="",p=[];if(!e)return e;e=utf8Encode(e);do{t=(n=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>18&63,a=n>>12&63,r=n>>6&63,i=63&n,p[u++]=s.charAt(t)+s.charAt(a)+s.charAt(r)+s.charAt(i)}while(o255||(r=e.charCodeAt(o++))>255||(i=e.charCodeAt(o++))>255)&&log("Failed to execute 'btoa' : The string to be encoded contains characters outside of the Latin1 range."),s+=n.charAt((t=a<<16|r<<8|i)>>18&63)+n.charAt(t>>12&63)+n.charAt(t>>6&63)+n.charAt(63&t);return u?s.slice(0,u-3)+"===".substring(u):s}function urlBase64Encode(e){return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}))}function getCurrentPage(){var e={};try{var t=getCurrentPages();e=t[t.length-1]}catch(e){log(e)}return e}function getCurrentPath(){var e="\u672a\u53d6\u5230";try{var t=getCurrentPage();e=t?t.route:e}catch(e){log(e)}return e}function getIsFirstDay(){return!!("object"==typeof store._state&&isNumber(store._state.first_visit_day_time)&&store._state.first_visit_day_time>(new Date).getTime())}function getCurrentUrl(e){var t=getCurrentPath(),a="";return isObject(e)&&e.sensors_mp_encode_url_query&&(a=e.sensors_mp_encode_url_query),t?a?t+"?"+a:t:"\u672a\u53d6\u5230"}function getPath(e){return e=isString(e)?e.replace(/^\//,""):"\u53d6\u503c\u5f02\u5e38"}function getCustomUtmFromQuery(e,t,a,r){if(!isObject(e))return{};var i={};if(e.sa_utm)for(var n in e)"sa_utm"!==n?include(saPara.source_channel,n)&&(i[a+n]=e[n]):i[r+n]=e[n];else for(var s in e)-1===(" "+SOURCE_CHANNEL_STANDARD+" ").indexOf(" "+s+" ")?include(saPara.source_channel,s)&&(i[a+s]=e[s]):i[t+s]=e[s];return i}function getObjFromQuery(e){var t=e.split("?"),a=[],r={};return t&&t[1]?(each(t[1].split("&"),function(e){(a=e.split("="))[0]&&a[1]&&(r[a[0]]=a[1])}),r):{}}function setStorageSync(e,t){var a=function(){wx.setStorageSync(e,t)};try{a()}catch(e){log("set Storage fail --",e);try{a()}catch(e){log("set Storage fail again --",e)}}}function getStorageSync(e){var t="";try{t=wx.getStorageSync(e)}catch(e){log("getStorage fail")}return t}function getMPScene(e){return isNumber(e)||isString(e)&&""!==e?e="wx-"+String(e):"\u672a\u53d6\u5230\u503c"}function objToParam(e,t){if(!isObject(e))return log("\u8bf7\u4f20\u5165\u6709\u6548\u5bf9\u8c61"),"";var a=[];for(var r in e)if(hasOwnProperty$2.call(e,r)){var i=e[r];void 0===i?a.push(r+"="):(i=t?encodeURIComponent(i):i,a.push(r+"="+i))}return a.join("&")}function delObjectKey(e){if(isObject(e))for(var t=0;t=2?(meta.page_route_map.shift(),meta.page_route_map.push(e)):meta.page_route_map.push(e)}}catch(e){log(e)}}function getRefPage(){var e={route:"\u76f4\u63a5\u6253\u5f00",path:"\u76f4\u63a5\u6253\u5f00",title:""};return meta.page_route_map.length>1&&(e.title=meta.page_route_map[0].title,e.route=meta.page_route_map[0].route,e.path=meta.page_route_map[0].path),e}function getCurrentPageInfo(){var e=getCurrentPage(),t={title:"",url:"",path:"\u672a\u53d6\u5230"};if(e&&e.route){var a=e.sensors_mp_url_query?"?"+e.sensors_mp_url_query:"";t.title=getPageTitle(e.route),t.url=e.route+a,t.path=e.route}return t}function setPageRefData(e,t,a){var r=getRefPage();isObject(e)&&(t?meta.page_route_map.length>0&&t?(a=a?"?"+a:"",e.$referrer=getPath(t)+a,e.$referrer_title=getPageTitle(t)):(e.$referrer="\u76f4\u63a5\u6253\u5f00",e.$referrer_title=""):(e.$referrer=r.route,e.$referrer_title=r.title))}function getPageTitle(e){if("\u672a\u53d6\u5230"===e||!e)return"";var t="";try{if(__wxConfig){var a=__wxConfig,r=__wxConfig.page||{},i=r[e]||r[e+".html"],n={},s={};if(a.global&&a.global.window&&a.global.window.navigationBarTitleText&&(n.titleVal=a.global.window.navigationBarTitleText),i&&i.window&&i.window.navigationBarTitleText&&(s.titleVal=i.window.navigationBarTitleText),!s.titleVal&&__wxAppCode__){var o=__wxAppCode__[e+".json"];o&&o.navigationBarTitleText&&(s.titleVal=o.navigationBarTitleText)}if(each(meta.global_title,function(a,r){if(r===e)return t=a}),0===t.length){var u=extend(n,s);t=u.titleVal||""}}}catch(e){log(e)}return t}function wxrequest(e){if(compareSDKVersion(meta.wx_sdk_version,"2.10.0")>=0)e.timeout=saPara.datasend_timeout,wx.request(e);else{var t=wx.request(e);setTimeout(function(){isObject(t)&&isFunction(t.abort)&&t.abort()},saPara.datasend_timeout)}}function validId(e){return"string"!=typeof e&&"number"!=typeof e||""===e?(log("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1):"number"!=typeof e||(e=String(e),/^\d+$/.test(e))?!!check.checkIdLength(e)&&e:(log("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1)}function compareSDKVersion(e,t){e=e.split("."),t=t.split(".");for(var a=Math.max(e.length,t.length);e.lengthn)return 1;if(i{wx.getNetworkType({success:function(t){meta.preset_properties.$network_type=setUpperCase(t.networkType),e()},fail:function(e){log("\u83b7\u53d6\u7f51\u7edc\u4fe1\u606f\u5931\u8d25",e),t()}})})}function getSystemInfo(){var e=meta.preset_properties;return new Promise(t=>{wx.getSystemInfo({success:function(a){var r,i;e.$brand=setUpperCase(a.brand),e.$manufacturer=a.brand,e.$model=a.model,e.$screen_width=Number(a.screenWidth),e.$screen_height=Number(a.screenHeight),e.$os=(r=a.platform,"ios"===(i=r.toLowerCase())?"iOS":"android"===i?"Android":r),e.$os_version=a.system.indexOf(" ")>-1?a.system.split(" ")[1]:a.system,meta.wx_sdk_version=a.SDKVersion,e.$mp_client_app_version=a.version,e.$mp_client_basic_library_version=meta.wx_sdk_version;var n=(new Date).getTimezoneOffset(),s=getAppInfoSync();isNumber(n)&&(e.$timezone_offset=n),s.appId&&(e.$app_id=s.appId),s.appVersion&&(e.$app_version=s.appVersion),t()}})})}var info={currentProps:meta.preset_properties},logger={info:function(){if(saPara.show_log&&"object"==typeof console&&console.log)try{if(3===arguments.length)return console.log(arguments[0],arguments[1],arguments[2]);if(2===arguments.length)return console.log(arguments[0],arguments[1]);if(1===arguments.length)return console.log(arguments[0])}catch(e){console.log(arguments[0])}}};function isValidListener(e){return"function"==typeof e||!(!e||"object"!=typeof e)&&isValidListener(e.listener)}class EventEmitterBase{constructor(){this._events={}}on(e,t){if(!e||!t)return!1;if(!isValidListener(t))throw new Error("listener must be a function");this._events[e]=this._events[e]||[];var a="object"==typeof t;return this._events[e].push(a?t:{listener:t,once:!1}),this}prepend(e,t){if(!e||!t)return!1;if(!isValidListener(t))throw new Error("listener must be a function");this._events[e]=this._events[e]||[];var a="object"==typeof t;return this._events[e].unshift(a?t:{listener:t,once:!1}),this}prependOnce(e,t){return this.prepend(e,{listener:t,once:!0})}once(e,t){return this.on(e,{listener:t,once:!0})}off(e,t){var a=this._events[e];if(!a)return!1;if("number"==typeof t)a.splice(t,1);else if("function"==typeof t)for(var r=0,i=a.length;r0&&this.cacheEvents.forEach(function(a){a.type===e&&t.call(null,a.data)})}emit(e,t){super.emit.apply(this,arguments),this.cacheEvents.push({type:e,data:t}),this.cacheEvents.length>this.maxLen&&this.cacheEvents.shift()}}var _=Object.freeze({__proto__:null,decodeURIComponent:decodeURIComponent$1,encodeDates:encodeDates,formatDate:formatDate,searchObjDate:searchObjDate,formatString:formatString,searchObjString:searchObjString,parseSuperProperties:parseSuperProperties,unique:unique,check:check,getUtmFromPage:getUtmFromPage,setQuery:setQuery,setLatestShare:setLatestShare,setLatestChannel:setLatestChannel,setUpperCase:setUpperCase,compareSDKVersion:compareSDKVersion,validId:validId,wxrequest:wxrequest,getPageTitle:getPageTitle,setPageRefData:setPageRefData,getCurrentPageInfo:getCurrentPageInfo,getRefPage:getRefPage,setRefPage:setRefPage,setPageSfSource:setPageSfSource,setSfSource:setSfSource,setUtm:setUtm,getMixedQuery:getMixedQuery,detectOptionQuery:detectOptionQuery,getShareInfo:getShareInfo,setShareInfo:setShareInfo,shareInfoData:shareInfoData,delObjectKey:delObjectKey,objToParam:objToParam,getMPScene:getMPScene,getStorageSync:getStorageSync,setStorageSync:setStorageSync,getObjFromQuery:getObjFromQuery,getCustomUtmFromQuery:getCustomUtmFromQuery,getPath:getPath,getCurrentUrl:getCurrentUrl,getIsFirstDay:getIsFirstDay,getCurrentPath:getCurrentPath,getCurrentPage:getCurrentPage,urlBase64Encode:urlBase64Encode,btoa:btoa,base64Encode:base64Encode,strip_empty_properties:strip_empty_properties,strip_sa_properties:strip_sa_properties,setNavigationBarTitle:setNavigationBarTitle,networkStatusChange:networkStatusChange,getNetworkType:getNetworkType,getSystemInfo:getSystemInfo,encodeTrackData:encodeTrackData,initAppGlobalName:initAppGlobalName,getPublicPresetProperties:getPublicPresetProperties,setPublicProperties:setPublicProperties,isPresetIdKeys:isPresetIdKeys,isNewLoginId:isNewLoginId,isSameAndAnonymousID:isSameAndAnonymousID,info:info,logger:logger,getAppId:getAppId,getAppInfoSync:getAppInfoSync,getOpenidNameByAppid:getOpenidNameByAppid,rot13defs:rot13defs,rot13obfs:rot13obfs,each:each,isObject:isObject,getRandom:getRandom,extend:extend,extend2Lev:extend2Lev,coverExtend:coverExtend,isArray:isArray,isFunction:isFunction,isArguments:isArguments,toArray:toArray,values:values,include:include,trim:trim,isEmptyObject:isEmptyObject,deepCopy:deepCopy,isUndefined:isUndefined,isString:isString,isDate:isDate,isBoolean:isBoolean,isNumber:isNumber,isJSONString:isJSONString,isInteger:isInteger,isSafeInteger:isSafeInteger,slice:slice,urlSafeBase64:urlSafeBase64,EventEmitterBase:EventEmitterBase,EventEmitterEx:EventEmitterEx,log:log});function onEventSend(){return{}}function processData(e){return e}function batchTrackData(e){var t=Date.now();return e.forEach(function(e){e._flush_time=t}),"data_list="+encodeTrackData(e)}var mergeStorageData={getData:function(e){wx.getStorage({key:saPara.storage_prepare_data_key,complete:function(t){var a=t.data&&isArray(t.data)?t.data:[];mergeStorageData.deleteAesData(a),e&&e()}})},deleteAesData:function(e){var t=[],a=e.length;if(a>0){for(var r=0;r=saPara.batch_send.max_length&&this.batchSend()},wxrequest:function(e){if(isArray(e.data)&&e.data.length>0){var t=kit.batchTrackData(e.data);sa._.wxrequest({url:saPara.server_url,method:"POST",dataType:"text",data:t,header:{"content-type":"text/plain"},success:function(){e.success(e.len)},fail:function(){e.fail()}})}else e.success(e.len)},batchSend:function(){if(this.dataHasSend){var e,t,a=store.mem.mdata;(t=(e=a.length>=100?a.slice(0,100):a).length)>0&&(this.dataHasSend=!1,this.wxrequest({data:e,len:t,success:this.batchRemove.bind(this),fail:this.sendFail.bind(this)}))}},sendFail:function(){this.dataHasSend=!0,this.failTime++},batchRemove:function(e){store.mem.clear(e),this.dataHasSend=!0,this.dataHasChange=!0,this.batchWrite(),this.failTime=0},is_first_batch_write:!0,batchWrite:function(){this.dataHasChange&&(this.dataHasChange=!1,this.syncStorage&&sa._.setStorageSync(saPara.storage_prepare_data_key,store.mem.mdata))},batchInterval:function(){var e=this;!function t(){setTimeout(function(){e.batchWrite(),t()},500)}(),function t(){setTimeout(function(){e.batchSend(),t()},saPara.batch_send.send_timeout*Math.pow(2,e.failTime))}()}};function onceSend(e){e._flush_time=Date.now();var t=kit.onceTrackData(e),a=saPara.server_url+"?"+t;-1!==saPara.server_url.indexOf("?")&&(a=saPara.server_url+"&"+t),wxrequest({url:a,method:"GET"})}function buildData(e,t){var a={distinct_id:sa.store.getDistinctId(),identities:sa.store._state.identities,lib:{$lib:LIB_NAME,$lib_method:"code",$lib_version:LIB_VERSION},properties:{}};return"track_id_unbind"===e.type&&"$UnbindID"===e.event&&(a.identities=deepCopy(e.unbind_value),delete e.unbind_value),isObject(t)||(t={}),extend(a,sa.store.getUnionId(),e),isObject(e.properties)&&!isEmptyObject(e.properties)&&extend(a.properties,e.properties),e.type&&"profile"===e.type.slice(0,7)||(a._track_id=Number(String(getRandom()).slice(2,5)+String(getRandom()).slice(2,4)+String(Date.now()).slice(-4)),a.properties=extend({},getPublicPresetProperties(),meta.preset_properties,sa.store.getProps(),t,a.properties),"track"===e.type&&(a.properties.$is_first_day=getIsFirstDay())),a.properties.$time&&isDate(a.properties.$time)?(a.time=1*a.properties.$time,delete a.properties.$time):a.time=1*new Date,sa.ee.sdk.emit("createData",a),sa.ee.sdk.emit("beforeBuildCheck",a),sa.ee.data.emit("beforeBuildCheck",a),parseSuperProperties(a.properties),searchObjDate(a),strip_sa_properties(a.properties),searchObjString(a),sa.ee.data.emit("finalAdjustData",a),a}function dataStage(e){if(!saPara.server_url)return!1;if(meta.current_scene&&1154===meta.current_scene&&!sa.para.preset_events.moments_page)return!1;var t=sa._.deepCopy(e),a=buildData(e,kit.onEventSend(t));a?(log(a),sa.events.emit("send",a),sa.para.batch_send?sendStrategy.send(a):onceSend(a)):log("error: \u6570\u636e\u5f02\u5e38 "+a)}sa.popupEmitter={attached:function(){return!1}};var usePlugin=function(e,t){if(!isObject(e)&&!isFunction(e))return log("plugin must be an object",e),!1;if(isFunction(e.init)||log("plugin maybe missing init method",e.plugin_name||e),isString(e.plugin_name)&&e.plugin_name?sa.modules[e.plugin_name]?e=sa.modules[e.plugin_name]:sa.modules[e.plugin_name]=e:log("plugin_name is not defined - ",e.plugin_name||e),isObject(e)&&!0===e.plugin_is_init)return e;if(isObject(e)&&e.plugin_name&&(isString(e.plugin_version)&&e.plugin_version===LIB_VERSION||log("warning!"+e.plugin_name+" plugin version do not match SDK version \uff01\uff01\uff01")),meta.init_status)"function"==typeof e.init&&(e.init(sa,t),e.plugin_is_init=!0,log(e.plugin_name+" plugin is initialized"));else{var a={target:e,para:t};meta.plugin.uninitialized_list.push(a)}return e},checkPluginInitStatus=function(){if(meta.plugin.uninitialized_list.length>0){for(var e in meta.plugin.uninitialized_list){var t=meta.plugin.uninitialized_list[e];t&&t.target&&"function"==typeof t.target.init&&!t.target.plugin_is_init&&(t.target.init(sa,t.para),isObject(t.target)&&(t.target.plugin_is_init=!0,isString(t.target.plugin_name)&&t.target.plugin_name&&log(t.target.plugin_name+" plugin is initialized")))}meta.plugin.uninitialized_list=[]}};function initAppShowHide(){wx.onAppShow(function(e){if(!meta.life_state.app_launched){var t=wx.getLaunchOptionsSync()||{};sa.autoTrackCustom.appLaunch(t)}sa.autoTrackCustom.appShow(e)}),wx.onAppHide(function(){sa.autoTrackCustom.appHide()})}function checkAppLaunch(){if(!meta.life_state.app_launched){var e=wx.getLaunchOptionsSync()||{};sa.autoTrackCustom.appLaunch(e)}}function mpProxy(e,t,a){var r=sa.autoTrackCustom[a];if(e[t]){var i=e[t];e[t]=function(){!sa.para.autoTrackIsFirst||isObject(sa.para.autoTrackIsFirst)&&!sa.para.autoTrackIsFirst[a]?(i.apply(this,arguments),r.apply(this,arguments)):(!0===sa.para.autoTrackIsFirst||isObject(sa.para.autoTrackIsFirst)&&sa.para.autoTrackIsFirst[a])&&(r.apply(this,arguments),i.apply(this,arguments)),sa.ee.page.emit(a)}}else e[t]=function(){r.apply(this,arguments),sa.ee.page.emit(a)}}function clickTrack(e){var t,a={},r={},i=e.currentTarget||{},n=e.target||{};if(isObject(sa.para.framework)&&isObject(sa.para.framework.taro)&&!sa.para.framework.taro.createApp&&n.id&&i.id&&n.id!==i.id)return!1;var s=i.dataset||{};if(t=e.type,a.$element_id=i.id,a.$element_type=s.type,a.$element_content=s.content,a.$element_name=s.name,isObject(e.event_prop)&&(r=e.event_prop),t&&isClick(t)){if(sa.para.preset_events&&sa.para.preset_events.collect_element&&!1===sa.para.preset_events.collect_element(arguments[0]))return!1;a.$url_path=sa._.getCurrentPath(),sa._.setPageRefData(a),a=sa._.extend(a,r),sa.track("$MPClick",a)}}function clickProxy(e,t){var a=e[t];e[t]=function(){var e=a.apply(this,arguments),t=arguments[0];return isObject(t)&&(sa.para.preset_events.defer_track?setTimeout(function(){clickTrack(t)},0):clickTrack(t)),e}}function isClick(e){return!!{tap:1,longpress:1,longtap:1}[e]}function tabProxy(e){var t=e.onTabItemTap;e.onTabItemTap=function(e){t&&t.apply(this,arguments);var a={};e&&(a.$element_content=e.text),a.$element_type="tabBar",a.$url_path=sa._.getCurrentPath(),sa._.setPageRefData(a),sa.track("$MPClick",a)}}function getMethods(e){var t=MP_FILTER_HOOK,a=[];for(var r in e)"function"!=typeof e[r]||t[r]||a.push(r);return a}function initPageProxy(){var e=Page;Page=function(t){try{t||(t={}),monitorClick(t),monitorHooks(t),e.apply(this,arguments)}catch(t){e.apply(this,arguments)}};var t=Component;Component=function(e){try{e||(e={}),e.methods||(e.methods={}),monitorClick(e.methods),monitorHooks(e.methods),t.apply(this,arguments)}catch(e){t.apply(this,arguments)}}}function monitorClick(e){var t=[];if(sa.para.autoTrack&&sa.para.autoTrack.mpClick){t=getMethods(e),tabProxy(e);for(var a=t.length,r=0;r100)log("Key ["+e+"] is invalid");else if(!check.checkKeyword(e))return log("Key ["+e+"] is invalid"),!1;if(isPresetIdKeys(e,["$mp_openid","$identity_mp_openid","$identity_mp_unionid","$mp_unionid","$mp_id","$identity_mp_id"]))return log("Key ["+e+"] is invalid"),!1;if(!(t=validId(t)))return!1;if(isSameAndAnonymousID(t))return!1;var a=store.getFirstId(),r=store.getDistinctId();isNewLoginId(e,t)&&(store._state.identities[e]=t,store.set("history_login_id",{name:e,value:t}),a||store.set("first_id",r),sa.trackSignup({id:t,event_name:"$SignUp",id_name:e}),store.identitiesSet({type:"login",id:t,id_name:e}))}function getAnonymousID(){if(!isEmptyObject(store._state))return store._state._first_id||store._state.first_id||store._state._distinct_id||store._state.distinct_id;log("\u8bf7\u5148\u521d\u59cb\u5316SDK")}function getIdentities(){return isEmptyObject(store._state)?(log("\u8bf7\u5148\u521d\u59cb\u5316SDK"),null):store._state.identities||null}function logout(e){var t=store.getFirstId();store.identitiesSet({type:"logout"}),store.set("history_login_id",{name:"",value:""}),t?(store.set("first_id",""),!0===e?store.set("distinct_id",store.getUUID()):store.set("distinct_id",t)):log("\u6ca1\u6709first_id\uff0clogout\u5931\u8d25")}function getPresetProperties(){if(meta.preset_properties&&meta.preset_properties.$lib){var e={};each(meta.preset_properties,function(t,a){0===a.indexOf("$")&&(e[a]=t)});var t={$url_path:getCurrentPath(),$is_first_day:getIsFirstDay(),$is_first_time:meta.is_first_launch},a=extend(e,t,meta.preset_properties,store.getProps());return delete a.$lib,a}return{}}function setOpenid(e,t){if(!(e=validId(e)))return!1;if(!checkPrivacyStatus())return!1;if(!meta.init_status)return store.store_queue.push({method:"setOpenid",params:arguments}),!1;log("\u8be5\u65b9\u6cd5\u5df2\u4e0d\u5efa\u8bae\u4f7f\u7528\uff0c\u5982\u679c\u662f id2 \u7528\u6237\uff0c\u8bf7\u4f7f\u7528 identify \u4ee3\u66ff\uff0c\u5982\u679c\u662f id3 \u7528\u6237\uff0c\u8bf7\u4f7f\u7528 bindOpenid \u4ee3\u66ff"),t&&log("%c \u5f53\u524d\u7248\u672c setOpenid \u63a5\u53e3 \u5df2\u4e0d\u652f\u6301\u4f20\u5165\u7b2c\u4e8c\u4e2a\u53c2\u6570","color:#F39C12;font-size: 14px;"),store.set("openid",e),sa.identify(e,!0);var a=getOpenidNameByAppid();store._state.identities[a]=e,store.save()}function unsetOpenid(e){log("\u8be5\u65b9\u6cd5\u5df2\u4e0d\u5efa\u8bae\u4f7f\u7528\uff0c\u5982\u679c\u662f id3 \u7528\u6237\uff0c\u8bf7\u4f7f\u7528 unbindOpenid \u4ee3\u66ff");var t=validId(e);if(!t)return!1;var a=store._state.openid;a===t&&store.set("openid","");var r=getOpenidNameByAppid();if(hasOwnProperty$3.call(store._state.identities,r)&&t===store._state.identities[r]){delete store._state.identities[r];var i=store.getFirstId(),n=store.getDistinctId(),s=store._state&&store._state.identities&&store._state.identities.$identity_mp_id;i&&i===a&&s&&store.change("first_id",s),n&&n===a&&s&&store.change("distinct_id",s),store.save()}}function bindOpenid(e){if(!(e=validId(e)))return!1;var t=getOpenidNameByAppid();this.bind(t,e)}function unbindOpenid(e){if(!validId(e))return!1;var t=getOpenidNameByAppid();this.unbind(t,e)}function setUnionid(e){var t=validId(e);t&&bind("$identity_mp_unionid",t)}function unsetUnionid(e){var t=validId(e);if(t){if(hasOwnProperty$3.call(store._state.identities,"$identity_mp_unionid")&&t===store._state.identities.$identity_mp_unionid){var a=getOpenidNameByAppid();hasOwnProperty$3.call(store._state.identities,a)&&(delete store._state.identities[a],delete store._state.openid,store.save())}unbind("$identity_mp_unionid",t)}}function initWithOpenid(e,t){(e=e||{}).appid&&(saPara.appid=e.appid),sa.openid.getOpenid(function(a){a&&sa.setOpenid(a,e.isCoverLogin),t&&isFunction(t)&&t(a),sa.init(e)})}function bind(e,t){if(isNumber(t)){if(isInteger(t)&&!1===isSafeInteger(t))return log("Value must be String"),!1;t=String(t)}if(!isString(e))return log("Key must be String"),!1;var a=store.getHistoryLoginId(),r=a?a.name:"";return!check.checkKeyword(e)||isPresetIdKeys(e,[IDENTITY_KEY.LOGIN,r,"$mp_id","$identity_mp_id"])?(log("Key ["+e+"] is invalid"),!1):t&&""!==t?isString(t)?!!check.checkIdLength(t)&&(store._state.identities[e]=t,store.save(),void dataStage({type:"track_id_bind",event:"$BindID"})):(log("Value must be String"),!1):(log("Value is empty or null"),!1)}function unbind(e,t){if(isNumber(t)){if(isInteger(t)&&!1===isSafeInteger(t))return log("Value must be String"),!1;t=String(t)}if(!isString(e))return log("Key must be String"),!1;if(!sa._.check.checkKeyword(e)||isPresetIdKeys(e,[IDENTITY_KEY.LOGIN]))return log("Key ["+e+"] is invalid"),!1;if(!t||""===t)return log("Value is empty or null"),!1;if(!isString(t))return log("Value must be String"),!1;if(!sa._.check.checkIdLength(t))return!1;hasOwnProperty$3.call(store._state.identities,e)&&t===store._state.identities[e]&&("$mp_id"!==e&&"$identity_mp_id"!==e&&delete store._state.identities[e],store.save());var a=store.getDistinctId(),r=store.getFirstId();a===e+"+"+t&&(store.set("first_id",""),store.set("distinct_id",r),store.set("history_login_id",{name:"",value:""}));var i={};i[e]=t,dataStage({type:"track_id_unbind",event:"$UnbindID",unbind_value:i})}function setWebViewUrl(e,t){if(log("setWebViewUrl \u65b9\u6cd5\u5df2\u4ece 2022-9-23 \u5f00\u59cb\u5e9f\u5f03\uff0c\u8bf7\u5c3d\u5feb\u53bb\u9664\u8be5 API \u7684\u8c03\u7528\uff0c\u5e76\u4f7f\u7528 use \u63d2\u4ef6 \u4ee3\u66ff"),!isString(e)||""===e)return log("error:\u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;if(!/^http(s)?:\/\//.test(e))return log("warning: \u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;var a=/([^?#]+)(\?[^#]*)?(#.*)?/.exec(e);if(!a)return!1;var r,i=a[1]||"",n=a[2]||"",s=a[3]||"",o="",u=store.getDistinctId()||"",c=store.getFirstId()||"";urlSafeBase64&&urlSafeBase64.encode?u=u?urlSafeBase64.trim(urlSafeBase64.encode(urlBase64Encode(u))):"":rot13obfs&&(u=u?rot13obfs(u):""),u=encodeURIComponent(u);var p=c?"f"+u:"d"+u;t?(r=s.indexOf("_sasdk"),o=s.indexOf("?")>-1?r>-1?i+n+"#"+s.substring(1,r)+"_sasdk="+p:i+n+"#"+s.substring(1)+"&_sasdk="+p:i+n+"#"+s.substring(1)+"?_sasdk="+p):(r=n.indexOf("_sasdk"),o=/^\?(\w)+/.test(n)?r>-1?i+n.replace(/(_sasdk=)([^&]*)/gi,"_sasdk="+p)+s:i+"?"+n.substring(1)+"&_sasdk="+p+s:i+"?"+n.substring(1)+"_sasdk="+p+s);return o}function quick(){var e=arguments[0],t=arguments[1],a=arguments[2],r=isObject(a)?a:{};if("getAnonymousID"===e){if(!isEmptyObject(store._state))return store._state._first_id||store._state.first_id||store._state._distinct_id||store._state.distinct_id;log("\u8bf7\u5148\u521d\u59cb\u5316SDK")}else"appLaunch"===e||"appShow"===e?t?sa.autoTrackCustom[e](t,r):log("App\u7684launch\u548cshow\uff0c\u5728sensors.quick\u7b2c\u4e8c\u4e2a\u53c2\u6570\u5fc5\u987b\u4f20\u5165App\u7684options\u53c2\u6570"):"appHide"===e&&(r=isObject(t)?t:{},sa.autoTrackCustom[e](r))}function appLaunch(e,t){var a={};e&&e.scene?(meta.current_scene=e.scene,a.$scene=getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,delObjectKey(e.query)),e&&e.path&&(a.$url_path=getPath(e.path),a.$title=getPageTitle(e.path)),setShareInfo(e,a);var r=setUtm(e,a);meta.is_first_launch?(a.$is_first_time=!0,isEmptyObject(r.pre1)||sa.setOnceProfile(r.pre1)):a.$is_first_time=!1,setLatestChannel(r.pre2),setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=setQuery(e.query),a.$url=e.path+(a.$url_query?"?"+a.$url_query:""),setPageRefData(t),isObject(t)&&(a=extend(a,t)),sa.track("$MPLaunch",a)}function appShow(e,t){var a={};meta.mp_show_time=(new Date).getTime(),e&&e.scene?(meta.current_scene=e.scene,a.$scene=getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,delObjectKey(e.query)),e&&e.path&&(a.$url_path=getPath(e.path),a.$title=getPageTitle(e.path)),setShareInfo(e,a),setLatestChannel(setUtm(e,a).pre2),setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=setQuery(e.query),e&&e.path&&(a.$url=e.path+(a.$url_query?"?"+a.$url_query:"")),setPageRefData(a,e.path,a.$url_query),isObject(t)&&(a=extend(a,t)),sa.track("$MPShow",a)}function appHide(e){var t=(new Date).getTime(),a={};a.$url_path=getCurrentPath(),meta.mp_show_time&&t-meta.mp_show_time>0&&(t-meta.mp_show_time)/36e5<24&&(a.event_duration=(t-meta.mp_show_time)/1e3),setPageRefData(a),isObject(e)&&(a=extend(a,e)),sa.track("$MPHide",a),sa.sendStrategy.onAppHide()}function pageShow(e){var t={},a=getCurrentPath(),r=getPageTitle(a),i=getCurrentPage();r&&(t.$title=r),t.$url_path=a,t.$url_query=i.sensors_mp_url_query?i.sensors_mp_url_query:"",setPageSfSource(t=extend(t,getUtmFromPage())),setPageRefData(t),isObject(e)&&(t=extend(t,e)),sa.track("$MPViewScreen",t)}function setPara(e){sa.para=extend2Lev(saPara,e);var t=[];if(isArray(saPara.source_channel))for(var a=saPara.source_channel.length,r=0;r0&&(t-meta.mp_show_time)/36e5<24&&(a.event_duration=(t-meta.mp_show_time)/1e3),setPageRefData(a),e?(a=extend(a,e),sa.track("$MPHide",a)):saPara.autoTrack&&saPara.autoTrack.appHide&&sa.autoTrackCustom.trackCustom("appHide",a,"$MPHide")},pageLoad:function(e){meta.current_scene&&1010===meta.current_scene&&e&&(e.sampshare&&delete e.sampshare,delObjectKey(e)),e&&isObject(e)&&(this.sensors_mp_url_query=setQuery(e),this.sensors_mp_encode_url_query=setQuery(e,!0))},pageShow:function(){meta.page_show_time=Date.now();var e={},t=getCurrentPath(),a=getPageTitle(t);setRefPage(),e.$url_path=t,e.$url_query=this.sensors_mp_url_query?this.sensors_mp_url_query:"",setPageRefData(e=extend(e,getUtmFromPage())),setPageSfSource(e),a&&(e.$title=a),saPara.onshow?saPara.onshow(sa,t,this):-1===saPara.autotrack_exclude_page.pageShow.indexOf(t)&&sa.autoTrackCustom.trackCustom("pageShow",e,"$MPViewScreen")},pageShare:function(e){var t=e.onShareAppMessage;e.onShareAppMessage=function(){var e=this;meta.share_method="\u8f6c\u53d1\u6d88\u606f\u5361\u7247";var a,r=t.apply(this,arguments);if(saPara.autoTrack&&saPara.autoTrack.pageShare){var i={$url_path:getCurrentPath(),$share_depth:meta.query_share_depth,$share_method:meta.share_method};setPageRefData(i),sa.autoTrackCustom.trackCustom("pageShare",i,"$MPShare")}function n(t){return isObject(t)||(t={}),(isUndefined(t.path)||""===t.path)&&(t.path=getCurrentUrl(e)),isString(t.path)&&(-1===t.path.indexOf("?")?t.path=t.path+"?":"&"!==t.path.slice(-1)&&(t.path=t.path+"&")),t.path=t.path+getShareInfo(),t}if(sa.para.allow_amend_share_path&&isObject(r=n(r)))for(var s in r)if((a=r[s])&&isFunction(a.then)&&isFunction(a.catch))try{r[s]=r[s].then(function(e){return n(e)})}catch(e){log("onShareAppMessage: "+e)}return r}},pageShareTimeline:function(e){var t=e.onShareTimeline;e.onShareTimeline=function(){meta.share_method="\u670b\u53cb\u5708\u5206\u4eab";var e=t.apply(this,arguments);if(saPara.autoTrack&&saPara.autoTrack.pageShare){var a={$url_path:getCurrentPath(),$share_depth:meta.query_share_depth,$share_method:meta.share_method};setPageRefData(a),sa.autoTrackCustom.trackCustom("pageShare",a,"$MPShare")}return saPara.allow_amend_share_path&&("object"!=typeof e&&(e={}),"object"==typeof e&&void 0===e.query&&(e.query=""),"object"==typeof e&&"string"==typeof e.query&&""!==e.query&&"&"!==e.query.slice(-1)&&(e.query=e.query+"&"),e.query=e.query+getShareInfo()),e}},pageAddFavorites:function(){var e={};e.$url_path=getCurrentPath(),saPara.autoTrack&&saPara.autoTrack.mpFavorite&&sa.autoTrackCustom.trackCustom("mpFavorite",e,"$MPAddFavorites")},pageHide:function(){sa.para.autoTrack&&sa.para.autoTrack.pageLeave&&sendPageLeave()}};function sendPageLeave(){var e={},t="";try{t=(e=getCurrentPage())?e.route:""}catch(e){log(e)}if(meta.page_show_time>=0&&""!==t){var a={},r=getPageTitle(t),i=(Date.now()-meta.page_show_time)/1e3;(isNaN(i)||i<0)&&(i=0),a.$url_query=e.sensors_mp_url_query?e.sensors_mp_url_query:"",a.$url_path=t,a.$title=r,a.event_duration=i,-1===saPara.autotrack_exclude_page.pageLeave.indexOf(t)&&sa.track("$MPPageLeave",a),meta.page_show_time=-1}}var openid={getRequest:function(e){wx.login({success:function(t){t.code&&saPara.appid&&saPara.openid_url?wxrequest({url:saPara.openid_url+"&code="+t.code+"&appid="+saPara.appid,method:"GET",complete:function(t){isObject(t)&&isObject(t.data)&&t.data.openid?e(t.data.openid):e()}}):e()}})},getWXStorage:function(){var e=store.getStorage();if(e&&isObject(e))return e.openid},getOpenid:function(e){if(!saPara.appid)return e(),!1;var t=this.getWXStorage();t?e(t):this.getRequest(e)}},functions=Object.freeze({__proto__:null,setProfile:setProfile,setOnceProfile:setOnceProfile,appendProfile:appendProfile,incrementProfile:incrementProfile,track:track,identify:identify,trackSignup:trackSignup,login:login,loginWithKey:loginWithKey,getAnonymousID:getAnonymousID,getIdentities:getIdentities,logout:logout,getPresetProperties:getPresetProperties,setOpenid:setOpenid,unsetOpenid:unsetOpenid,bindOpenid:bindOpenid,unbindOpenid:unbindOpenid,setUnionid:setUnionid,unsetUnionid:unsetUnionid,bindUnionid:setUnionid,unbindUnionid:unsetUnionid,initWithOpenid:initWithOpenid,bind:bind,unbind:unbind,setWebViewUrl:setWebViewUrl,quick:quick,appLaunch:appLaunch,appShow:appShow,appHide:appHide,pageShow:pageShow,setPara:setPara,getServerUrl:getServerUrl,sendPageLeave:sendPageLeave,openid:openid,autoTrackCustom:autoTrackCustom,registerApp:registerApp,register:register,clearAllRegister:clearAllRegister,clearAppRegister:clearAppRegister,clearAllProps:clearAllProps});function buildAPI(e){for(var t in functions)e[t]=functions[t]}function setFirstVisitTime(){meta.is_first_launch&&setOnceProfile({$first_visit_time:new Date})}function checkIsComplete(){meta.initialState.isComplete=!0,meta.initialState.queue.length>0&&(each(meta.initialState.queue,function(e){"appLaunch"===e[0]?sa.autoTrackCustom.appLaunch.apply(sa.autoTrackCustom,slice.call(e[1])):sa[e[0]].apply(sa,slice.call(e[1]))}),meta.initialState.queue=[])}function init(e){if(!0===meta.init_status)return!1;function t(){checkIsComplete(),checkAppLaunch(),sa.ee.sdk.emit("ready")}meta.init_status=!0,sa.ee.sdk.emit("beforeInit"),e&&isObject(e)&&sa.setPara(e),sa.ee.sdk.emit("initPara"),sa.ee.sdk.emit("afterInitPara"),sa.store.init(),sa.checkPluginInitStatus(),setFirstVisitTime(),sa.para.batch_send&&sa.sendStrategy.init();var a=[getNetworkType(),getSystemInfo()].concat(meta.promise_list);Promise.all(a).then(()=>{t()}).catch(()=>{t()})}function registerPropertyPlugin(e){isFunction(e.properties)?!e.isMatchedWithFilter||isFunction(e.isMatchedWithFilter)?sa.ee.data.on("finalAdjustData",function(t){try{isFunction(e.isMatchedWithFilter)?e.isMatchedWithFilter(t)&&e.properties(t):e.properties(t)}catch(e){log("execute registerPropertyPlugin callback error:"+e)}}):log("registerPropertyPlugin arguments error, isMatchedWithFilter must be function"):log("registerPropertyPlugin arguments error, properties must be function")}sa._=_,sa.modules={},sa.meta=meta,sa.kit=kit,sa.mergeStorageData=mergeStorageData,sa.dataStage=dataStage,sa.sendStrategy=sendStrategy,sa.store=store,sa.usePlugin=usePlugin,sa.checkPluginInitStatus=checkPluginInitStatus,sa.eventSub=eventSub,sa.events=new eventEmitter,sa.ee=ee,sa.registerPropertyPlugin=registerPropertyPlugin,sa.enableDataCollect=enableDataCollect,sa.initialState=meta.initialState,sa.IDENTITY_KEY={EMAIL:IDENTITY_KEY.EMAIL,MOBILE:IDENTITY_KEY.MOBILE},buildAPI(sa),apiStaging(),setNavigationBarTitle(),networkStatusChange(),initAppGlobalName(),initAppShowHide(),initPageProxy(),sa.init=init;var base={plugin_version:"1.19.12"};function createPlugin(e){if("object"==typeof e&&"string"==typeof e.plugin_name&&""!==e.plugin_name)return e.plugin_version=base.plugin_version,e.log=e.log||function(){"object"==typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)},e;"object"==typeof console&&"function"==typeof console.error&&console.error('plugin must contain proprerty "plugin_name"')}var disableSDK={init(e){e.disableSDK=this.disableSDK.bind(this),e.enableSDK=this.enableSDK.bind(this),e.getDisabled=this.getDisabled.bind(this)},plugin_name:"DisableSDK",disabled:!1,disableSDK(){this.disabled=!0},enableSDK(){this.disabled=!1},getDisabled(){return this.disabled}},DisableSDK=createPlugin(disableSDK);sa.usePlugin(DisableSDK);export default sa; \ No newline at end of file diff --git a/package.json b/package.json index e45301a..83635fe 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sa-sdk-miniprogram", - "version": "1.19.11", + "version": "1.19.12", "description": "sensorsdata miniprogram sdk", "main": "dist/wechat/sensorsdata.cjs.js", "scripts": { diff --git a/product/wechat/sensorsdata.es6.full.js b/product/wechat/sensorsdata.es6.full.js index 2abb28d..2ecf79a 100644 --- a/product/wechat/sensorsdata.es6.full.js +++ b/product/wechat/sensorsdata.es6.full.js @@ -539,7 +539,7 @@ var IDENTITY_KEY = { LOGIN: '$identity_login_id' }; -var LIB_VERSION = '1.19.11'; +var LIB_VERSION = '1.19.12'; var LIB_NAME = 'MiniProgram'; /* @@ -4106,7 +4106,6 @@ function pageShow(prop) { var router = getCurrentPath(); var title = getPageTitle(router); var currentPage = getCurrentPage(); - setRefPage(); if (title) { obj.$title = title; } @@ -4794,7 +4793,7 @@ initPageProxy(); sa.init = init; var base = { - plugin_version: '1.19.11' + plugin_version: '1.19.12' }; function createPlugin(obj) { diff --git a/product/wechat/sensorsdata.full.js b/product/wechat/sensorsdata.full.js index 6170613..bf0068d 100644 --- a/product/wechat/sensorsdata.full.js +++ b/product/wechat/sensorsdata.full.js @@ -541,7 +541,7 @@ var IDENTITY_KEY = { LOGIN: '$identity_login_id' }; -var LIB_VERSION = '1.19.11'; +var LIB_VERSION = '1.19.12'; var LIB_NAME = 'MiniProgram'; /* @@ -4108,7 +4108,6 @@ function pageShow(prop) { var router = getCurrentPath(); var title = getPageTitle(router); var currentPage = getCurrentPage(); - setRefPage(); if (title) { obj.$title = title; } @@ -4796,7 +4795,7 @@ initPageProxy(); sa.init = init; var base = { - plugin_version: '1.19.11' + plugin_version: '1.19.12' }; function createPlugin(obj) { diff --git a/sensorsdata.es6.min.js b/sensorsdata.es6.min.js index a76678d..0879085 100644 --- a/sensorsdata.es6.min.js +++ b/sensorsdata.es6.min.js @@ -1 +1 @@ -var sa={},saPara={name:"sensors",server_url:"",send_timeout:1e3,show_log:!1,login_id_key:"$identity_login_id",allow_amend_share_path:!0,max_string_length:500,datasend_timeout:3e3,source_channel:[],autoTrack:{appLaunch:!0,appShow:!0,appHide:!0,pageShow:!0,pageShare:!0,mpClick:!1,mpFavorite:!0,pageLeave:!1},autotrack_exclude_page:{pageShow:[],pageLeave:[]},is_persistent_save:{share:!1,utm:!1},preset_properties:{url_path:!0},preset_events:{moments_page:!1,defer_track:!1,share_info_use_string:!1},batch_send:!0,storage_store_key:"sensorsdata2015_wechat",storage_prepare_data_key:"sensors_mp_prepare_data"};function log(){if(saPara.show_log&&"object"==typeof console&&console.log)try{return console.log.apply(console,arguments)}catch(e){console.log(arguments[0])}}var nativeIsArray=Array.isArray,ObjProto=Object.prototype,ArrayProto=Array.prototype,nativeForEach=ArrayProto.forEach,nativeIndexOf=ArrayProto.indexOf,toString=ObjProto.toString,hasOwnProperty=ObjProto.hasOwnProperty,slice=ArrayProto.slice;function each(e,t,a){if(null==e)return!1;var r={};if(nativeForEach&&e.forEach===nativeForEach)e.forEach(t,a);else if(e.length===+e.length){for(var i=0,n=e.length;i0&&each(this.store_queue,function(e){sa[e.method].apply(sa,slice.call(e.params))}),this.store_queue=[])}};function _decodeURIComponent(e){var t="";try{t=decodeURIComponent(e)}catch(a){t=e}return t}var hasOwnProperty$2=Object.prototype.hasOwnProperty,decodeURIComponent$1=_decodeURIComponent;function initAppGlobalName(){var e=App;App=function(t){t[saPara.name]=sa,e.apply(this,arguments)}}function getPublicPresetProperties(){var e=getRefPage(),t=getCurrentPageInfo(),a={$referrer:e.route,$referrer_title:e.title,$title:t.title,$url:t.url};return!0===saPara.preset_properties.url_path&&(a.$url_path=t.path),a}function encodeDates(e){return each(e,function(t,a){isDate(t)?e[a]=formatDate(t):isObject(t)&&(e[a]=encodeDates(t))}),e}function formatDate(e){function t(e){return e<10?"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())}function searchObjDate(e){(isObject(e)||isArray(e))&&each(e,function(t,a){isObject(t)||isArray(t)?searchObjDate(e[a]):isDate(t)&&(e[a]=formatDate(t))})}function formatString(e){return e.length>saPara.max_string_length?(log("\u5b57\u7b26\u4e32\u957f\u5ea6\u8d85\u8fc7\u9650\u5236\uff0c\u5df2\u7ecf\u505a\u622a\u53d6--"+e),e.slice(0,saPara.max_string_length)):e}function searchObjString(e){isObject(e)&&each(e,function(t,a){isObject(t)?searchObjString(e[a]):isString(t)&&(e[a]=formatString(t))})}function parseSuperProperties(e){isObject(e)&&each(e,function(t,a){if(isFunction(t))try{e[a]=t(),isFunction(e[a])&&(log("\u60a8\u7684\u5c5e\u6027- "+a+" \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[a])}catch(t){delete e[a],log("\u60a8\u7684\u5c5e\u6027- "+a+" \u629b\u51fa\u4e86\u5f02\u5e38\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}})}function unique(e){for(var t,a=[],r={},i=0;i255)||(log("id \u957f\u5ea6\u8d85\u8fc7 255 \u4e2a\u5b57\u7b26\uff01"),!1)}};function strip_sa_properties(e){return isObject(e)?(each(e,function(t,a){if(isArray(t)){var r=[];each(t,function(e){if(isString(e))r.push(e);else if(isUndefined(e))r.push("null");else try{r.push(JSON.stringify(e))}catch(e){log("\u60a8\u7684\u6570\u636e - "+a+":"+t+" - \u7684\u6570\u7ec4\u91cc\u7684\u503c\u6709\u9519\u8bef,\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}}),e[a]=r}if(isObject(t))try{e[a]=JSON.stringify(t)}catch(r){delete e[a],log("\u60a8\u7684\u6570\u636e - "+a+":"+t+" - \u7684\u6570\u636e\u503c\u6709\u9519\u8bef,\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}else isString(t)||isNumber(t)||isDate(t)||isBoolean(t)||isArray(t)||(log("\u60a8\u7684\u6570\u636e - "+a+":"+t+" - \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[a])}),e):e}function strip_empty_properties(e){var t={};return each(e,function(e,a){null==e&&void 0===e||(t[a]=e)}),t}function utf8Encode(e){var t,a,r,i,n="";for(t=a=0,r=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,i=0;i127&&s<2048?String.fromCharCode(s>>6|192,63&s|128):String.fromCharCode(s>>12|224,s>>6&63|128,63&s|128),null!==o&&(a>t&&(n+=e.substring(t,a)),n+=o,t=a=i+1)}return a>t&&(n+=e.substring(t,e.length)),n}function base64Encode(e){var t,a,r,i,n,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,u=0,c="",p=[];if(!e)return e;e=utf8Encode(e);do{t=(n=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>18&63,a=n>>12&63,r=n>>6&63,i=63&n,p[u++]=s.charAt(t)+s.charAt(a)+s.charAt(r)+s.charAt(i)}while(o255||(r=e.charCodeAt(o++))>255||(i=e.charCodeAt(o++))>255)&&log("Failed to execute 'btoa' : The string to be encoded contains characters outside of the Latin1 range."),s+=n.charAt((t=a<<16|r<<8|i)>>18&63)+n.charAt(t>>12&63)+n.charAt(t>>6&63)+n.charAt(63&t);return u?s.slice(0,u-3)+"===".substring(u):s}function urlBase64Encode(e){return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}))}function getCurrentPage(){var e={};try{var t=getCurrentPages();e=t[t.length-1]}catch(e){log(e)}return e}function getCurrentPath(){var e="\u672a\u53d6\u5230";try{var t=getCurrentPage();e=t?t.route:e}catch(e){log(e)}return e}function getIsFirstDay(){return!!("object"==typeof store._state&&isNumber(store._state.first_visit_day_time)&&store._state.first_visit_day_time>(new Date).getTime())}function getCurrentUrl(e){var t=getCurrentPath(),a="";return isObject(e)&&e.sensors_mp_encode_url_query&&(a=e.sensors_mp_encode_url_query),t?a?t+"?"+a:t:"\u672a\u53d6\u5230"}function getPath(e){return e=isString(e)?e.replace(/^\//,""):"\u53d6\u503c\u5f02\u5e38"}function getCustomUtmFromQuery(e,t,a,r){if(!isObject(e))return{};var i={};if(e.sa_utm)for(var n in e)"sa_utm"!==n?include(saPara.source_channel,n)&&(i[a+n]=e[n]):i[r+n]=e[n];else for(var s in e)-1===(" "+SOURCE_CHANNEL_STANDARD+" ").indexOf(" "+s+" ")?include(saPara.source_channel,s)&&(i[a+s]=e[s]):i[t+s]=e[s];return i}function getObjFromQuery(e){var t=e.split("?"),a=[],r={};return t&&t[1]?(each(t[1].split("&"),function(e){(a=e.split("="))[0]&&a[1]&&(r[a[0]]=a[1])}),r):{}}function setStorageSync(e,t){var a=function(){wx.setStorageSync(e,t)};try{a()}catch(e){log("set Storage fail --",e);try{a()}catch(e){log("set Storage fail again --",e)}}}function getStorageSync(e){var t="";try{t=wx.getStorageSync(e)}catch(e){log("getStorage fail")}return t}function getMPScene(e){return isNumber(e)||isString(e)&&""!==e?e="wx-"+String(e):"\u672a\u53d6\u5230\u503c"}function objToParam(e,t){if(!isObject(e))return log("\u8bf7\u4f20\u5165\u6709\u6548\u5bf9\u8c61"),"";var a=[];for(var r in e)if(hasOwnProperty$2.call(e,r)){var i=e[r];void 0===i?a.push(r+"="):(i=t?encodeURIComponent(i):i,a.push(r+"="+i))}return a.join("&")}function delObjectKey(e){if(isObject(e))for(var t=0;t=2?(meta.page_route_map.shift(),meta.page_route_map.push(e)):meta.page_route_map.push(e)}}catch(e){log(e)}}function getRefPage(){var e={route:"\u76f4\u63a5\u6253\u5f00",path:"\u76f4\u63a5\u6253\u5f00",title:""};return meta.page_route_map.length>1&&(e.title=meta.page_route_map[0].title,e.route=meta.page_route_map[0].route,e.path=meta.page_route_map[0].path),e}function getCurrentPageInfo(){var e=getCurrentPage(),t={title:"",url:"",path:"\u672a\u53d6\u5230"};if(e&&e.route){var a=e.sensors_mp_url_query?"?"+e.sensors_mp_url_query:"";t.title=getPageTitle(e.route),t.url=e.route+a,t.path=e.route}return t}function setPageRefData(e,t,a){var r=getRefPage();isObject(e)&&(t?meta.page_route_map.length>0&&t?(a=a?"?"+a:"",e.$referrer=getPath(t)+a,e.$referrer_title=getPageTitle(t)):(e.$referrer="\u76f4\u63a5\u6253\u5f00",e.$referrer_title=""):(e.$referrer=r.route,e.$referrer_title=r.title))}function getPageTitle(e){if("\u672a\u53d6\u5230"===e||!e)return"";var t="";try{if(__wxConfig){var a=__wxConfig,r=__wxConfig.page||{},i=r[e]||r[e+".html"],n={},s={};if(a.global&&a.global.window&&a.global.window.navigationBarTitleText&&(n.titleVal=a.global.window.navigationBarTitleText),i&&i.window&&i.window.navigationBarTitleText&&(s.titleVal=i.window.navigationBarTitleText),!s.titleVal&&__wxAppCode__){var o=__wxAppCode__[e+".json"];o&&o.navigationBarTitleText&&(s.titleVal=o.navigationBarTitleText)}if(each(meta.global_title,function(a,r){if(r===e)return t=a}),0===t.length){var u=extend(n,s);t=u.titleVal||""}}}catch(e){log(e)}return t}function wxrequest(e){if(compareSDKVersion(meta.wx_sdk_version,"2.10.0")>=0)e.timeout=saPara.datasend_timeout,wx.request(e);else{var t=wx.request(e);setTimeout(function(){isObject(t)&&isFunction(t.abort)&&t.abort()},saPara.datasend_timeout)}}function validId(e){return"string"!=typeof e&&"number"!=typeof e||""===e?(log("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1):"number"!=typeof e||(e=String(e),/^\d+$/.test(e))?!!check.checkIdLength(e)&&e:(log("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1)}function compareSDKVersion(e,t){e=e.split("."),t=t.split(".");for(var a=Math.max(e.length,t.length);e.lengthn)return 1;if(i{wx.getNetworkType({success:function(t){meta.preset_properties.$network_type=setUpperCase(t.networkType),e()},fail:function(e){log("\u83b7\u53d6\u7f51\u7edc\u4fe1\u606f\u5931\u8d25",e),t()}})})}function getSystemInfo(){var e=meta.preset_properties;return new Promise(t=>{wx.getSystemInfo({success:function(a){var r,i;e.$brand=setUpperCase(a.brand),e.$manufacturer=a.brand,e.$model=a.model,e.$screen_width=Number(a.screenWidth),e.$screen_height=Number(a.screenHeight),e.$os=(r=a.platform,"ios"===(i=r.toLowerCase())?"iOS":"android"===i?"Android":r),e.$os_version=a.system.indexOf(" ")>-1?a.system.split(" ")[1]:a.system,meta.wx_sdk_version=a.SDKVersion,e.$mp_client_app_version=a.version,e.$mp_client_basic_library_version=meta.wx_sdk_version;var n=(new Date).getTimezoneOffset(),s=getAppInfoSync();isNumber(n)&&(e.$timezone_offset=n),s.appId&&(e.$app_id=s.appId),s.appVersion&&(e.$app_version=s.appVersion),t()}})})}var info={currentProps:meta.preset_properties},logger={info:function(){if(saPara.show_log&&"object"==typeof console&&console.log)try{if(3===arguments.length)return console.log(arguments[0],arguments[1],arguments[2]);if(2===arguments.length)return console.log(arguments[0],arguments[1]);if(1===arguments.length)return console.log(arguments[0])}catch(e){console.log(arguments[0])}}};function isValidListener(e){return"function"==typeof e||!(!e||"object"!=typeof e)&&isValidListener(e.listener)}class EventEmitterBase{constructor(){this._events={}}on(e,t){if(!e||!t)return!1;if(!isValidListener(t))throw new Error("listener must be a function");this._events[e]=this._events[e]||[];var a="object"==typeof t;return this._events[e].push(a?t:{listener:t,once:!1}),this}prepend(e,t){if(!e||!t)return!1;if(!isValidListener(t))throw new Error("listener must be a function");this._events[e]=this._events[e]||[];var a="object"==typeof t;return this._events[e].unshift(a?t:{listener:t,once:!1}),this}prependOnce(e,t){return this.prepend(e,{listener:t,once:!0})}once(e,t){return this.on(e,{listener:t,once:!0})}off(e,t){var a=this._events[e];if(!a)return!1;if("number"==typeof t)a.splice(t,1);else if("function"==typeof t)for(var r=0,i=a.length;r0&&this.cacheEvents.forEach(function(a){a.type===e&&t.call(null,a.data)})}emit(e,t){super.emit.apply(this,arguments),this.cacheEvents.push({type:e,data:t}),this.cacheEvents.length>this.maxLen&&this.cacheEvents.shift()}}var _=Object.freeze({__proto__:null,decodeURIComponent:decodeURIComponent$1,encodeDates:encodeDates,formatDate:formatDate,searchObjDate:searchObjDate,formatString:formatString,searchObjString:searchObjString,parseSuperProperties:parseSuperProperties,unique:unique,check:check,getUtmFromPage:getUtmFromPage,setQuery:setQuery,setLatestShare:setLatestShare,setLatestChannel:setLatestChannel,setUpperCase:setUpperCase,compareSDKVersion:compareSDKVersion,validId:validId,wxrequest:wxrequest,getPageTitle:getPageTitle,setPageRefData:setPageRefData,getCurrentPageInfo:getCurrentPageInfo,getRefPage:getRefPage,setRefPage:setRefPage,setPageSfSource:setPageSfSource,setSfSource:setSfSource,setUtm:setUtm,getMixedQuery:getMixedQuery,detectOptionQuery:detectOptionQuery,getShareInfo:getShareInfo,setShareInfo:setShareInfo,shareInfoData:shareInfoData,delObjectKey:delObjectKey,objToParam:objToParam,getMPScene:getMPScene,getStorageSync:getStorageSync,setStorageSync:setStorageSync,getObjFromQuery:getObjFromQuery,getCustomUtmFromQuery:getCustomUtmFromQuery,getPath:getPath,getCurrentUrl:getCurrentUrl,getIsFirstDay:getIsFirstDay,getCurrentPath:getCurrentPath,getCurrentPage:getCurrentPage,urlBase64Encode:urlBase64Encode,btoa:btoa,base64Encode:base64Encode,strip_empty_properties:strip_empty_properties,strip_sa_properties:strip_sa_properties,setNavigationBarTitle:setNavigationBarTitle,networkStatusChange:networkStatusChange,getNetworkType:getNetworkType,getSystemInfo:getSystemInfo,encodeTrackData:encodeTrackData,initAppGlobalName:initAppGlobalName,getPublicPresetProperties:getPublicPresetProperties,setPublicProperties:setPublicProperties,isPresetIdKeys:isPresetIdKeys,isNewLoginId:isNewLoginId,isSameAndAnonymousID:isSameAndAnonymousID,info:info,logger:logger,getAppId:getAppId,getAppInfoSync:getAppInfoSync,getOpenidNameByAppid:getOpenidNameByAppid,rot13defs:rot13defs,rot13obfs:rot13obfs,each:each,isObject:isObject,getRandom:getRandom,extend:extend,extend2Lev:extend2Lev,coverExtend:coverExtend,isArray:isArray,isFunction:isFunction,isArguments:isArguments,toArray:toArray,values:values,include:include,trim:trim,isEmptyObject:isEmptyObject,deepCopy:deepCopy,isUndefined:isUndefined,isString:isString,isDate:isDate,isBoolean:isBoolean,isNumber:isNumber,isJSONString:isJSONString,isInteger:isInteger,isSafeInteger:isSafeInteger,slice:slice,urlSafeBase64:urlSafeBase64,EventEmitterBase:EventEmitterBase,EventEmitterEx:EventEmitterEx,log:log});function onEventSend(){return{}}function processData(e){return e}function batchTrackData(e){var t=Date.now();return e.forEach(function(e){e._flush_time=t}),"data_list="+encodeTrackData(e)}var mergeStorageData={getData:function(e){wx.getStorage({key:saPara.storage_prepare_data_key,complete:function(t){var a=t.data&&isArray(t.data)?t.data:[];mergeStorageData.deleteAesData(a),e&&e()}})},deleteAesData:function(e){var t=[],a=e.length;if(a>0){for(var r=0;r=saPara.batch_send.max_length&&this.batchSend()},wxrequest:function(e){if(isArray(e.data)&&e.data.length>0){var t=kit.batchTrackData(e.data);sa._.wxrequest({url:saPara.server_url,method:"POST",dataType:"text",data:t,header:{"content-type":"text/plain"},success:function(){e.success(e.len)},fail:function(){e.fail()}})}else e.success(e.len)},batchSend:function(){if(this.dataHasSend){var e,t,a=store.mem.mdata;(t=(e=a.length>=100?a.slice(0,100):a).length)>0&&(this.dataHasSend=!1,this.wxrequest({data:e,len:t,success:this.batchRemove.bind(this),fail:this.sendFail.bind(this)}))}},sendFail:function(){this.dataHasSend=!0,this.failTime++},batchRemove:function(e){store.mem.clear(e),this.dataHasSend=!0,this.dataHasChange=!0,this.batchWrite(),this.failTime=0},is_first_batch_write:!0,batchWrite:function(){this.dataHasChange&&(this.dataHasChange=!1,this.syncStorage&&sa._.setStorageSync(saPara.storage_prepare_data_key,store.mem.mdata))},batchInterval:function(){var e=this;!function t(){setTimeout(function(){e.batchWrite(),t()},500)}(),function t(){setTimeout(function(){e.batchSend(),t()},saPara.batch_send.send_timeout*Math.pow(2,e.failTime))}()}};function onceSend(e){e._flush_time=Date.now();var t=kit.onceTrackData(e),a=saPara.server_url+"?"+t;-1!==saPara.server_url.indexOf("?")&&(a=saPara.server_url+"&"+t),wxrequest({url:a,method:"GET"})}function buildData(e,t){var a={distinct_id:sa.store.getDistinctId(),identities:sa.store._state.identities,lib:{$lib:LIB_NAME,$lib_method:"code",$lib_version:LIB_VERSION},properties:{}};return"track_id_unbind"===e.type&&"$UnbindID"===e.event&&(a.identities=deepCopy(e.unbind_value),delete e.unbind_value),isObject(t)||(t={}),extend(a,sa.store.getUnionId(),e),isObject(e.properties)&&!isEmptyObject(e.properties)&&extend(a.properties,e.properties),e.type&&"profile"===e.type.slice(0,7)||(a._track_id=Number(String(getRandom()).slice(2,5)+String(getRandom()).slice(2,4)+String(Date.now()).slice(-4)),a.properties=extend({},getPublicPresetProperties(),meta.preset_properties,sa.store.getProps(),t,a.properties),"track"===e.type&&(a.properties.$is_first_day=getIsFirstDay())),a.properties.$time&&isDate(a.properties.$time)?(a.time=1*a.properties.$time,delete a.properties.$time):a.time=1*new Date,sa.ee.sdk.emit("createData",a),sa.ee.sdk.emit("beforeBuildCheck",a),sa.ee.data.emit("beforeBuildCheck",a),parseSuperProperties(a.properties),searchObjDate(a),strip_sa_properties(a.properties),searchObjString(a),sa.ee.data.emit("finalAdjustData",a),a}function dataStage(e){if(!saPara.server_url)return!1;if(meta.current_scene&&1154===meta.current_scene&&!sa.para.preset_events.moments_page)return!1;var t=sa._.deepCopy(e),a=buildData(e,kit.onEventSend(t));a?(log(a),sa.events.emit("send",a),sa.para.batch_send?sendStrategy.send(a):onceSend(a)):log("error: \u6570\u636e\u5f02\u5e38 "+a)}sa.popupEmitter={attached:function(){return!1}};var usePlugin=function(e,t){if(!isObject(e)&&!isFunction(e))return log("plugin must be an object",e),!1;if(isFunction(e.init)||log("plugin maybe missing init method",e.plugin_name||e),isString(e.plugin_name)&&e.plugin_name?sa.modules[e.plugin_name]?e=sa.modules[e.plugin_name]:sa.modules[e.plugin_name]=e:log("plugin_name is not defined - ",e.plugin_name||e),isObject(e)&&!0===e.plugin_is_init)return e;if(isObject(e)&&e.plugin_name&&(isString(e.plugin_version)&&e.plugin_version===LIB_VERSION||log("warning!"+e.plugin_name+" plugin version do not match SDK version \uff01\uff01\uff01")),meta.init_status)"function"==typeof e.init&&(e.init(sa,t),e.plugin_is_init=!0,log(e.plugin_name+" plugin is initialized"));else{var a={target:e,para:t};meta.plugin.uninitialized_list.push(a)}return e},checkPluginInitStatus=function(){if(meta.plugin.uninitialized_list.length>0){for(var e in meta.plugin.uninitialized_list){var t=meta.plugin.uninitialized_list[e];t&&t.target&&"function"==typeof t.target.init&&!t.target.plugin_is_init&&(t.target.init(sa,t.para),isObject(t.target)&&(t.target.plugin_is_init=!0,isString(t.target.plugin_name)&&t.target.plugin_name&&log(t.target.plugin_name+" plugin is initialized")))}meta.plugin.uninitialized_list=[]}};function initAppShowHide(){wx.onAppShow(function(e){if(!meta.life_state.app_launched){var t=wx.getLaunchOptionsSync()||{};sa.autoTrackCustom.appLaunch(t)}sa.autoTrackCustom.appShow(e)}),wx.onAppHide(function(){sa.autoTrackCustom.appHide()})}function checkAppLaunch(){if(!meta.life_state.app_launched){var e=wx.getLaunchOptionsSync()||{};sa.autoTrackCustom.appLaunch(e)}}function mpProxy(e,t,a){var r=sa.autoTrackCustom[a];if(e[t]){var i=e[t];e[t]=function(){!sa.para.autoTrackIsFirst||isObject(sa.para.autoTrackIsFirst)&&!sa.para.autoTrackIsFirst[a]?(i.apply(this,arguments),r.apply(this,arguments)):(!0===sa.para.autoTrackIsFirst||isObject(sa.para.autoTrackIsFirst)&&sa.para.autoTrackIsFirst[a])&&(r.apply(this,arguments),i.apply(this,arguments)),sa.ee.page.emit(a)}}else e[t]=function(){r.apply(this,arguments),sa.ee.page.emit(a)}}function clickTrack(e){var t,a={},r={},i=e.currentTarget||{},n=e.target||{};if(isObject(sa.para.framework)&&isObject(sa.para.framework.taro)&&!sa.para.framework.taro.createApp&&n.id&&i.id&&n.id!==i.id)return!1;var s=i.dataset||{};if(t=e.type,a.$element_id=i.id,a.$element_type=s.type,a.$element_content=s.content,a.$element_name=s.name,isObject(e.event_prop)&&(r=e.event_prop),t&&isClick(t)){if(sa.para.preset_events&&sa.para.preset_events.collect_element&&!1===sa.para.preset_events.collect_element(arguments[0]))return!1;a.$url_path=sa._.getCurrentPath(),sa._.setPageRefData(a),a=sa._.extend(a,r),sa.track("$MPClick",a)}}function clickProxy(e,t){var a=e[t];e[t]=function(){var e=a.apply(this,arguments),t=arguments[0];return isObject(t)&&(sa.para.preset_events.defer_track?setTimeout(function(){clickTrack(t)},0):clickTrack(t)),e}}function isClick(e){return!!{tap:1,longpress:1,longtap:1}[e]}function tabProxy(e){var t=e.onTabItemTap;e.onTabItemTap=function(e){t&&t.apply(this,arguments);var a={};e&&(a.$element_content=e.text),a.$element_type="tabBar",a.$url_path=sa._.getCurrentPath(),sa._.setPageRefData(a),sa.track("$MPClick",a)}}function getMethods(e){var t=MP_FILTER_HOOK,a=[];for(var r in e)"function"!=typeof e[r]||t[r]||a.push(r);return a}function initPageProxy(){var e=Page;Page=function(t){try{t||(t={}),monitorClick(t),monitorHooks(t),e.apply(this,arguments)}catch(t){e.apply(this,arguments)}};var t=Component;Component=function(e){try{e||(e={}),e.methods||(e.methods={}),monitorClick(e.methods),monitorHooks(e.methods),t.apply(this,arguments)}catch(e){t.apply(this,arguments)}}}function monitorClick(e){var t=[];if(sa.para.autoTrack&&sa.para.autoTrack.mpClick){t=getMethods(e),tabProxy(e);for(var a=t.length,r=0;r100)log("Key ["+e+"] is invalid");else if(!check.checkKeyword(e))return log("Key ["+e+"] is invalid"),!1;if(isPresetIdKeys(e,["$mp_openid","$identity_mp_openid","$identity_mp_unionid","$mp_unionid","$mp_id","$identity_mp_id"]))return log("Key ["+e+"] is invalid"),!1;if(!(t=validId(t)))return!1;if(isSameAndAnonymousID(t))return!1;var a=store.getFirstId(),r=store.getDistinctId();isNewLoginId(e,t)&&(store._state.identities[e]=t,store.set("history_login_id",{name:e,value:t}),a||store.set("first_id",r),sa.trackSignup({id:t,event_name:"$SignUp",id_name:e}),store.identitiesSet({type:"login",id:t,id_name:e}))}function getAnonymousID(){if(!isEmptyObject(store._state))return store._state._first_id||store._state.first_id||store._state._distinct_id||store._state.distinct_id;log("\u8bf7\u5148\u521d\u59cb\u5316SDK")}function getIdentities(){return isEmptyObject(store._state)?(log("\u8bf7\u5148\u521d\u59cb\u5316SDK"),null):store._state.identities||null}function logout(e){var t=store.getFirstId();store.identitiesSet({type:"logout"}),store.set("history_login_id",{name:"",value:""}),t?(store.set("first_id",""),!0===e?store.set("distinct_id",store.getUUID()):store.set("distinct_id",t)):log("\u6ca1\u6709first_id\uff0clogout\u5931\u8d25")}function getPresetProperties(){if(meta.preset_properties&&meta.preset_properties.$lib){var e={};each(meta.preset_properties,function(t,a){0===a.indexOf("$")&&(e[a]=t)});var t={$url_path:getCurrentPath(),$is_first_day:getIsFirstDay(),$is_first_time:meta.is_first_launch},a=extend(e,t,meta.preset_properties,store.getProps());return delete a.$lib,a}return{}}function setOpenid(e,t){if(!(e=validId(e)))return!1;if(!checkPrivacyStatus())return!1;if(!meta.init_status)return store.store_queue.push({method:"setOpenid",params:arguments}),!1;log("\u8be5\u65b9\u6cd5\u5df2\u4e0d\u5efa\u8bae\u4f7f\u7528\uff0c\u5982\u679c\u662f id2 \u7528\u6237\uff0c\u8bf7\u4f7f\u7528 identify \u4ee3\u66ff\uff0c\u5982\u679c\u662f id3 \u7528\u6237\uff0c\u8bf7\u4f7f\u7528 bindOpenid \u4ee3\u66ff"),t&&log("%c \u5f53\u524d\u7248\u672c setOpenid \u63a5\u53e3 \u5df2\u4e0d\u652f\u6301\u4f20\u5165\u7b2c\u4e8c\u4e2a\u53c2\u6570","color:#F39C12;font-size: 14px;"),store.set("openid",e),sa.identify(e,!0);var a=getOpenidNameByAppid();store._state.identities[a]=e,store.save()}function unsetOpenid(e){log("\u8be5\u65b9\u6cd5\u5df2\u4e0d\u5efa\u8bae\u4f7f\u7528\uff0c\u5982\u679c\u662f id3 \u7528\u6237\uff0c\u8bf7\u4f7f\u7528 unbindOpenid \u4ee3\u66ff");var t=validId(e);if(!t)return!1;var a=store._state.openid;a===t&&store.set("openid","");var r=getOpenidNameByAppid();if(hasOwnProperty$3.call(store._state.identities,r)&&t===store._state.identities[r]){delete store._state.identities[r];var i=store.getFirstId(),n=store.getDistinctId(),s=store._state&&store._state.identities&&store._state.identities.$identity_mp_id;i&&i===a&&s&&store.change("first_id",s),n&&n===a&&s&&store.change("distinct_id",s),store.save()}}function bindOpenid(e){if(!(e=validId(e)))return!1;var t=getOpenidNameByAppid();this.bind(t,e)}function unbindOpenid(e){if(!validId(e))return!1;var t=getOpenidNameByAppid();this.unbind(t,e)}function setUnionid(e){var t=validId(e);t&&bind("$identity_mp_unionid",t)}function unsetUnionid(e){var t=validId(e);if(t){if(hasOwnProperty$3.call(store._state.identities,"$identity_mp_unionid")&&t===store._state.identities.$identity_mp_unionid){var a=getOpenidNameByAppid();hasOwnProperty$3.call(store._state.identities,a)&&(delete store._state.identities[a],delete store._state.openid,store.save())}unbind("$identity_mp_unionid",t)}}function initWithOpenid(e,t){(e=e||{}).appid&&(saPara.appid=e.appid),sa.openid.getOpenid(function(a){a&&sa.setOpenid(a,e.isCoverLogin),t&&isFunction(t)&&t(a),sa.init(e)})}function bind(e,t){if(isNumber(t)){if(isInteger(t)&&!1===isSafeInteger(t))return log("Value must be String"),!1;t=String(t)}if(!isString(e))return log("Key must be String"),!1;var a=store.getHistoryLoginId(),r=a?a.name:"";return!check.checkKeyword(e)||isPresetIdKeys(e,[IDENTITY_KEY.LOGIN,r,"$mp_id","$identity_mp_id"])?(log("Key ["+e+"] is invalid"),!1):t&&""!==t?isString(t)?!!check.checkIdLength(t)&&(store._state.identities[e]=t,store.save(),void dataStage({type:"track_id_bind",event:"$BindID"})):(log("Value must be String"),!1):(log("Value is empty or null"),!1)}function unbind(e,t){if(isNumber(t)){if(isInteger(t)&&!1===isSafeInteger(t))return log("Value must be String"),!1;t=String(t)}if(!isString(e))return log("Key must be String"),!1;if(!sa._.check.checkKeyword(e)||isPresetIdKeys(e,[IDENTITY_KEY.LOGIN]))return log("Key ["+e+"] is invalid"),!1;if(!t||""===t)return log("Value is empty or null"),!1;if(!isString(t))return log("Value must be String"),!1;if(!sa._.check.checkIdLength(t))return!1;hasOwnProperty$3.call(store._state.identities,e)&&t===store._state.identities[e]&&("$mp_id"!==e&&"$identity_mp_id"!==e&&delete store._state.identities[e],store.save());var a=store.getDistinctId(),r=store.getFirstId();a===e+"+"+t&&(store.set("first_id",""),store.set("distinct_id",r),store.set("history_login_id",{name:"",value:""}));var i={};i[e]=t,dataStage({type:"track_id_unbind",event:"$UnbindID",unbind_value:i})}function setWebViewUrl(e,t){if(log("setWebViewUrl \u65b9\u6cd5\u5df2\u4ece 2022-9-23 \u5f00\u59cb\u5e9f\u5f03\uff0c\u8bf7\u5c3d\u5feb\u53bb\u9664\u8be5 API \u7684\u8c03\u7528\uff0c\u5e76\u4f7f\u7528 use \u63d2\u4ef6 \u4ee3\u66ff"),!isString(e)||""===e)return log("error:\u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;if(!/^http(s)?:\/\//.test(e))return log("warning: \u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;var a=/([^?#]+)(\?[^#]*)?(#.*)?/.exec(e);if(!a)return!1;var r,i=a[1]||"",n=a[2]||"",s=a[3]||"",o="",u=store.getDistinctId()||"",c=store.getFirstId()||"";urlSafeBase64&&urlSafeBase64.encode?u=u?urlSafeBase64.trim(urlSafeBase64.encode(urlBase64Encode(u))):"":rot13obfs&&(u=u?rot13obfs(u):""),u=encodeURIComponent(u);var p=c?"f"+u:"d"+u;t?(r=s.indexOf("_sasdk"),o=s.indexOf("?")>-1?r>-1?i+n+"#"+s.substring(1,r)+"_sasdk="+p:i+n+"#"+s.substring(1)+"&_sasdk="+p:i+n+"#"+s.substring(1)+"?_sasdk="+p):(r=n.indexOf("_sasdk"),o=/^\?(\w)+/.test(n)?r>-1?i+n.replace(/(_sasdk=)([^&]*)/gi,"_sasdk="+p)+s:i+"?"+n.substring(1)+"&_sasdk="+p+s:i+"?"+n.substring(1)+"_sasdk="+p+s);return o}function quick(){var e=arguments[0],t=arguments[1],a=arguments[2],r=isObject(a)?a:{};if("getAnonymousID"===e){if(!isEmptyObject(store._state))return store._state._first_id||store._state.first_id||store._state._distinct_id||store._state.distinct_id;log("\u8bf7\u5148\u521d\u59cb\u5316SDK")}else"appLaunch"===e||"appShow"===e?t?sa.autoTrackCustom[e](t,r):log("App\u7684launch\u548cshow\uff0c\u5728sensors.quick\u7b2c\u4e8c\u4e2a\u53c2\u6570\u5fc5\u987b\u4f20\u5165App\u7684options\u53c2\u6570"):"appHide"===e&&(r=isObject(t)?t:{},sa.autoTrackCustom[e](r))}function appLaunch(e,t){var a={};e&&e.scene?(meta.current_scene=e.scene,a.$scene=getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,delObjectKey(e.query)),e&&e.path&&(a.$url_path=getPath(e.path),a.$title=getPageTitle(e.path)),setShareInfo(e,a);var r=setUtm(e,a);meta.is_first_launch?(a.$is_first_time=!0,isEmptyObject(r.pre1)||sa.setOnceProfile(r.pre1)):a.$is_first_time=!1,setLatestChannel(r.pre2),setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=setQuery(e.query),a.$url=e.path+(a.$url_query?"?"+a.$url_query:""),setPageRefData(t),isObject(t)&&(a=extend(a,t)),sa.track("$MPLaunch",a)}function appShow(e,t){var a={};meta.mp_show_time=(new Date).getTime(),e&&e.scene?(meta.current_scene=e.scene,a.$scene=getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,delObjectKey(e.query)),e&&e.path&&(a.$url_path=getPath(e.path),a.$title=getPageTitle(e.path)),setShareInfo(e,a),setLatestChannel(setUtm(e,a).pre2),setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=setQuery(e.query),e&&e.path&&(a.$url=e.path+(a.$url_query?"?"+a.$url_query:"")),setPageRefData(a,e.path,a.$url_query),isObject(t)&&(a=extend(a,t)),sa.track("$MPShow",a)}function appHide(e){var t=(new Date).getTime(),a={};a.$url_path=getCurrentPath(),meta.mp_show_time&&t-meta.mp_show_time>0&&(t-meta.mp_show_time)/36e5<24&&(a.event_duration=(t-meta.mp_show_time)/1e3),setPageRefData(a),isObject(e)&&(a=extend(a,e)),sa.track("$MPHide",a),sa.sendStrategy.onAppHide()}function pageShow(e){var t={},a=getCurrentPath(),r=getPageTitle(a),i=getCurrentPage();setRefPage(),r&&(t.$title=r),t.$url_path=a,t.$url_query=i.sensors_mp_url_query?i.sensors_mp_url_query:"",setPageSfSource(t=extend(t,getUtmFromPage())),setPageRefData(t),isObject(e)&&(t=extend(t,e)),sa.track("$MPViewScreen",t)}function setPara(e){sa.para=extend2Lev(saPara,e);var t=[];if(isArray(saPara.source_channel))for(var a=saPara.source_channel.length,r=0;r0&&(t-meta.mp_show_time)/36e5<24&&(a.event_duration=(t-meta.mp_show_time)/1e3),setPageRefData(a),e?(a=extend(a,e),sa.track("$MPHide",a)):saPara.autoTrack&&saPara.autoTrack.appHide&&sa.autoTrackCustom.trackCustom("appHide",a,"$MPHide")},pageLoad:function(e){meta.current_scene&&1010===meta.current_scene&&e&&(e.sampshare&&delete e.sampshare,delObjectKey(e)),e&&isObject(e)&&(this.sensors_mp_url_query=setQuery(e),this.sensors_mp_encode_url_query=setQuery(e,!0))},pageShow:function(){meta.page_show_time=Date.now();var e={},t=getCurrentPath(),a=getPageTitle(t);setRefPage(),e.$url_path=t,e.$url_query=this.sensors_mp_url_query?this.sensors_mp_url_query:"",setPageRefData(e=extend(e,getUtmFromPage())),setPageSfSource(e),a&&(e.$title=a),saPara.onshow?saPara.onshow(sa,t,this):-1===saPara.autotrack_exclude_page.pageShow.indexOf(t)&&sa.autoTrackCustom.trackCustom("pageShow",e,"$MPViewScreen")},pageShare:function(e){var t=e.onShareAppMessage;e.onShareAppMessage=function(){var e=this;meta.share_method="\u8f6c\u53d1\u6d88\u606f\u5361\u7247";var a,r=t.apply(this,arguments);if(saPara.autoTrack&&saPara.autoTrack.pageShare){var i={$url_path:getCurrentPath(),$share_depth:meta.query_share_depth,$share_method:meta.share_method};setPageRefData(i),sa.autoTrackCustom.trackCustom("pageShare",i,"$MPShare")}function n(t){return isObject(t)||(t={}),(isUndefined(t.path)||""===t.path)&&(t.path=getCurrentUrl(e)),isString(t.path)&&(-1===t.path.indexOf("?")?t.path=t.path+"?":"&"!==t.path.slice(-1)&&(t.path=t.path+"&")),t.path=t.path+getShareInfo(),t}if(sa.para.allow_amend_share_path&&isObject(r=n(r)))for(var s in r)if((a=r[s])&&isFunction(a.then)&&isFunction(a.catch))try{r[s]=r[s].then(function(e){return n(e)})}catch(e){log("onShareAppMessage: "+e)}return r}},pageShareTimeline:function(e){var t=e.onShareTimeline;e.onShareTimeline=function(){meta.share_method="\u670b\u53cb\u5708\u5206\u4eab";var e=t.apply(this,arguments);if(saPara.autoTrack&&saPara.autoTrack.pageShare){var a={$url_path:getCurrentPath(),$share_depth:meta.query_share_depth,$share_method:meta.share_method};setPageRefData(a),sa.autoTrackCustom.trackCustom("pageShare",a,"$MPShare")}return saPara.allow_amend_share_path&&("object"!=typeof e&&(e={}),"object"==typeof e&&void 0===e.query&&(e.query=""),"object"==typeof e&&"string"==typeof e.query&&""!==e.query&&"&"!==e.query.slice(-1)&&(e.query=e.query+"&"),e.query=e.query+getShareInfo()),e}},pageAddFavorites:function(){var e={};e.$url_path=getCurrentPath(),saPara.autoTrack&&saPara.autoTrack.mpFavorite&&sa.autoTrackCustom.trackCustom("mpFavorite",e,"$MPAddFavorites")},pageHide:function(){sa.para.autoTrack&&sa.para.autoTrack.pageLeave&&sendPageLeave()}};function sendPageLeave(){var e={},t="";try{t=(e=getCurrentPage())?e.route:""}catch(e){log(e)}if(meta.page_show_time>=0&&""!==t){var a={},r=getPageTitle(t),i=(Date.now()-meta.page_show_time)/1e3;(isNaN(i)||i<0)&&(i=0),a.$url_query=e.sensors_mp_url_query?e.sensors_mp_url_query:"",a.$url_path=t,a.$title=r,a.event_duration=i,-1===saPara.autotrack_exclude_page.pageLeave.indexOf(t)&&sa.track("$MPPageLeave",a),meta.page_show_time=-1}}var openid={getRequest:function(e){wx.login({success:function(t){t.code&&saPara.appid&&saPara.openid_url?wxrequest({url:saPara.openid_url+"&code="+t.code+"&appid="+saPara.appid,method:"GET",complete:function(t){isObject(t)&&isObject(t.data)&&t.data.openid?e(t.data.openid):e()}}):e()}})},getWXStorage:function(){var e=store.getStorage();if(e&&isObject(e))return e.openid},getOpenid:function(e){if(!saPara.appid)return e(),!1;var t=this.getWXStorage();t?e(t):this.getRequest(e)}},functions=Object.freeze({__proto__:null,setProfile:setProfile,setOnceProfile:setOnceProfile,appendProfile:appendProfile,incrementProfile:incrementProfile,track:track,identify:identify,trackSignup:trackSignup,login:login,loginWithKey:loginWithKey,getAnonymousID:getAnonymousID,getIdentities:getIdentities,logout:logout,getPresetProperties:getPresetProperties,setOpenid:setOpenid,unsetOpenid:unsetOpenid,bindOpenid:bindOpenid,unbindOpenid:unbindOpenid,setUnionid:setUnionid,unsetUnionid:unsetUnionid,bindUnionid:setUnionid,unbindUnionid:unsetUnionid,initWithOpenid:initWithOpenid,bind:bind,unbind:unbind,setWebViewUrl:setWebViewUrl,quick:quick,appLaunch:appLaunch,appShow:appShow,appHide:appHide,pageShow:pageShow,setPara:setPara,getServerUrl:getServerUrl,sendPageLeave:sendPageLeave,openid:openid,autoTrackCustom:autoTrackCustom,registerApp:registerApp,register:register,clearAllRegister:clearAllRegister,clearAppRegister:clearAppRegister,clearAllProps:clearAllProps});function buildAPI(e){for(var t in functions)e[t]=functions[t]}function setFirstVisitTime(){meta.is_first_launch&&setOnceProfile({$first_visit_time:new Date})}function checkIsComplete(){meta.initialState.isComplete=!0,meta.initialState.queue.length>0&&(each(meta.initialState.queue,function(e){"appLaunch"===e[0]?sa.autoTrackCustom.appLaunch.apply(sa.autoTrackCustom,slice.call(e[1])):sa[e[0]].apply(sa,slice.call(e[1]))}),meta.initialState.queue=[])}function init(e){if(!0===meta.init_status)return!1;function t(){checkIsComplete(),checkAppLaunch(),sa.ee.sdk.emit("ready")}meta.init_status=!0,sa.ee.sdk.emit("beforeInit"),e&&isObject(e)&&sa.setPara(e),sa.ee.sdk.emit("initPara"),sa.ee.sdk.emit("afterInitPara"),sa.store.init(),sa.checkPluginInitStatus(),setFirstVisitTime(),sa.para.batch_send&&sa.sendStrategy.init();var a=[getNetworkType(),getSystemInfo()].concat(meta.promise_list);Promise.all(a).then(()=>{t()}).catch(()=>{t()})}function registerPropertyPlugin(e){isFunction(e.properties)?!e.isMatchedWithFilter||isFunction(e.isMatchedWithFilter)?sa.ee.data.on("finalAdjustData",function(t){try{isFunction(e.isMatchedWithFilter)?e.isMatchedWithFilter(t)&&e.properties(t):e.properties(t)}catch(e){log("execute registerPropertyPlugin callback error:"+e)}}):log("registerPropertyPlugin arguments error, isMatchedWithFilter must be function"):log("registerPropertyPlugin arguments error, properties must be function")}sa._=_,sa.modules={},sa.meta=meta,sa.kit=kit,sa.mergeStorageData=mergeStorageData,sa.dataStage=dataStage,sa.sendStrategy=sendStrategy,sa.store=store,sa.usePlugin=usePlugin,sa.checkPluginInitStatus=checkPluginInitStatus,sa.eventSub=eventSub,sa.events=new eventEmitter,sa.ee=ee,sa.registerPropertyPlugin=registerPropertyPlugin,sa.enableDataCollect=enableDataCollect,sa.initialState=meta.initialState,sa.IDENTITY_KEY={EMAIL:IDENTITY_KEY.EMAIL,MOBILE:IDENTITY_KEY.MOBILE},buildAPI(sa),apiStaging(),setNavigationBarTitle(),networkStatusChange(),initAppGlobalName(),initAppShowHide(),initPageProxy(),sa.init=init;var base={plugin_version:"1.19.11"};function createPlugin(e){if("object"==typeof e&&"string"==typeof e.plugin_name&&""!==e.plugin_name)return e.plugin_version=base.plugin_version,e.log=e.log||function(){"object"==typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)},e;"object"==typeof console&&"function"==typeof console.error&&console.error('plugin must contain proprerty "plugin_name"')}var disableSDK={init(e){e.disableSDK=this.disableSDK.bind(this),e.enableSDK=this.enableSDK.bind(this),e.getDisabled=this.getDisabled.bind(this)},plugin_name:"DisableSDK",disabled:!1,disableSDK(){this.disabled=!0},enableSDK(){this.disabled=!1},getDisabled(){return this.disabled}},DisableSDK=createPlugin(disableSDK);sa.usePlugin(DisableSDK);export default sa; \ No newline at end of file +var sa={},saPara={name:"sensors",server_url:"",send_timeout:1e3,show_log:!1,login_id_key:"$identity_login_id",allow_amend_share_path:!0,max_string_length:500,datasend_timeout:3e3,source_channel:[],autoTrack:{appLaunch:!0,appShow:!0,appHide:!0,pageShow:!0,pageShare:!0,mpClick:!1,mpFavorite:!0,pageLeave:!1},autotrack_exclude_page:{pageShow:[],pageLeave:[]},is_persistent_save:{share:!1,utm:!1},preset_properties:{url_path:!0},preset_events:{moments_page:!1,defer_track:!1,share_info_use_string:!1},batch_send:!0,storage_store_key:"sensorsdata2015_wechat",storage_prepare_data_key:"sensors_mp_prepare_data"};function log(){if(saPara.show_log&&"object"==typeof console&&console.log)try{return console.log.apply(console,arguments)}catch(e){console.log(arguments[0])}}var nativeIsArray=Array.isArray,ObjProto=Object.prototype,ArrayProto=Array.prototype,nativeForEach=ArrayProto.forEach,nativeIndexOf=ArrayProto.indexOf,toString=ObjProto.toString,hasOwnProperty=ObjProto.hasOwnProperty,slice=ArrayProto.slice;function each(e,t,a){if(null==e)return!1;var r={};if(nativeForEach&&e.forEach===nativeForEach)e.forEach(t,a);else if(e.length===+e.length){for(var i=0,n=e.length;i0&&each(this.store_queue,function(e){sa[e.method].apply(sa,slice.call(e.params))}),this.store_queue=[])}};function _decodeURIComponent(e){var t="";try{t=decodeURIComponent(e)}catch(a){t=e}return t}var hasOwnProperty$2=Object.prototype.hasOwnProperty,decodeURIComponent$1=_decodeURIComponent;function initAppGlobalName(){var e=App;App=function(t){t[saPara.name]=sa,e.apply(this,arguments)}}function getPublicPresetProperties(){var e=getRefPage(),t=getCurrentPageInfo(),a={$referrer:e.route,$referrer_title:e.title,$title:t.title,$url:t.url};return!0===saPara.preset_properties.url_path&&(a.$url_path=t.path),a}function encodeDates(e){return each(e,function(t,a){isDate(t)?e[a]=formatDate(t):isObject(t)&&(e[a]=encodeDates(t))}),e}function formatDate(e){function t(e){return e<10?"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())}function searchObjDate(e){(isObject(e)||isArray(e))&&each(e,function(t,a){isObject(t)||isArray(t)?searchObjDate(e[a]):isDate(t)&&(e[a]=formatDate(t))})}function formatString(e){return e.length>saPara.max_string_length?(log("\u5b57\u7b26\u4e32\u957f\u5ea6\u8d85\u8fc7\u9650\u5236\uff0c\u5df2\u7ecf\u505a\u622a\u53d6--"+e),e.slice(0,saPara.max_string_length)):e}function searchObjString(e){isObject(e)&&each(e,function(t,a){isObject(t)?searchObjString(e[a]):isString(t)&&(e[a]=formatString(t))})}function parseSuperProperties(e){isObject(e)&&each(e,function(t,a){if(isFunction(t))try{e[a]=t(),isFunction(e[a])&&(log("\u60a8\u7684\u5c5e\u6027- "+a+" \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[a])}catch(t){delete e[a],log("\u60a8\u7684\u5c5e\u6027- "+a+" \u629b\u51fa\u4e86\u5f02\u5e38\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}})}function unique(e){for(var t,a=[],r={},i=0;i255)||(log("id \u957f\u5ea6\u8d85\u8fc7 255 \u4e2a\u5b57\u7b26\uff01"),!1)}};function strip_sa_properties(e){return isObject(e)?(each(e,function(t,a){if(isArray(t)){var r=[];each(t,function(e){if(isString(e))r.push(e);else if(isUndefined(e))r.push("null");else try{r.push(JSON.stringify(e))}catch(e){log("\u60a8\u7684\u6570\u636e - "+a+":"+t+" - \u7684\u6570\u7ec4\u91cc\u7684\u503c\u6709\u9519\u8bef,\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}}),e[a]=r}if(isObject(t))try{e[a]=JSON.stringify(t)}catch(r){delete e[a],log("\u60a8\u7684\u6570\u636e - "+a+":"+t+" - \u7684\u6570\u636e\u503c\u6709\u9519\u8bef,\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}else isString(t)||isNumber(t)||isDate(t)||isBoolean(t)||isArray(t)||(log("\u60a8\u7684\u6570\u636e - "+a+":"+t+" - \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[a])}),e):e}function strip_empty_properties(e){var t={};return each(e,function(e,a){null==e&&void 0===e||(t[a]=e)}),t}function utf8Encode(e){var t,a,r,i,n="";for(t=a=0,r=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,i=0;i127&&s<2048?String.fromCharCode(s>>6|192,63&s|128):String.fromCharCode(s>>12|224,s>>6&63|128,63&s|128),null!==o&&(a>t&&(n+=e.substring(t,a)),n+=o,t=a=i+1)}return a>t&&(n+=e.substring(t,e.length)),n}function base64Encode(e){var t,a,r,i,n,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,u=0,c="",p=[];if(!e)return e;e=utf8Encode(e);do{t=(n=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>18&63,a=n>>12&63,r=n>>6&63,i=63&n,p[u++]=s.charAt(t)+s.charAt(a)+s.charAt(r)+s.charAt(i)}while(o255||(r=e.charCodeAt(o++))>255||(i=e.charCodeAt(o++))>255)&&log("Failed to execute 'btoa' : The string to be encoded contains characters outside of the Latin1 range."),s+=n.charAt((t=a<<16|r<<8|i)>>18&63)+n.charAt(t>>12&63)+n.charAt(t>>6&63)+n.charAt(63&t);return u?s.slice(0,u-3)+"===".substring(u):s}function urlBase64Encode(e){return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}))}function getCurrentPage(){var e={};try{var t=getCurrentPages();e=t[t.length-1]}catch(e){log(e)}return e}function getCurrentPath(){var e="\u672a\u53d6\u5230";try{var t=getCurrentPage();e=t?t.route:e}catch(e){log(e)}return e}function getIsFirstDay(){return!!("object"==typeof store._state&&isNumber(store._state.first_visit_day_time)&&store._state.first_visit_day_time>(new Date).getTime())}function getCurrentUrl(e){var t=getCurrentPath(),a="";return isObject(e)&&e.sensors_mp_encode_url_query&&(a=e.sensors_mp_encode_url_query),t?a?t+"?"+a:t:"\u672a\u53d6\u5230"}function getPath(e){return e=isString(e)?e.replace(/^\//,""):"\u53d6\u503c\u5f02\u5e38"}function getCustomUtmFromQuery(e,t,a,r){if(!isObject(e))return{};var i={};if(e.sa_utm)for(var n in e)"sa_utm"!==n?include(saPara.source_channel,n)&&(i[a+n]=e[n]):i[r+n]=e[n];else for(var s in e)-1===(" "+SOURCE_CHANNEL_STANDARD+" ").indexOf(" "+s+" ")?include(saPara.source_channel,s)&&(i[a+s]=e[s]):i[t+s]=e[s];return i}function getObjFromQuery(e){var t=e.split("?"),a=[],r={};return t&&t[1]?(each(t[1].split("&"),function(e){(a=e.split("="))[0]&&a[1]&&(r[a[0]]=a[1])}),r):{}}function setStorageSync(e,t){var a=function(){wx.setStorageSync(e,t)};try{a()}catch(e){log("set Storage fail --",e);try{a()}catch(e){log("set Storage fail again --",e)}}}function getStorageSync(e){var t="";try{t=wx.getStorageSync(e)}catch(e){log("getStorage fail")}return t}function getMPScene(e){return isNumber(e)||isString(e)&&""!==e?e="wx-"+String(e):"\u672a\u53d6\u5230\u503c"}function objToParam(e,t){if(!isObject(e))return log("\u8bf7\u4f20\u5165\u6709\u6548\u5bf9\u8c61"),"";var a=[];for(var r in e)if(hasOwnProperty$2.call(e,r)){var i=e[r];void 0===i?a.push(r+"="):(i=t?encodeURIComponent(i):i,a.push(r+"="+i))}return a.join("&")}function delObjectKey(e){if(isObject(e))for(var t=0;t=2?(meta.page_route_map.shift(),meta.page_route_map.push(e)):meta.page_route_map.push(e)}}catch(e){log(e)}}function getRefPage(){var e={route:"\u76f4\u63a5\u6253\u5f00",path:"\u76f4\u63a5\u6253\u5f00",title:""};return meta.page_route_map.length>1&&(e.title=meta.page_route_map[0].title,e.route=meta.page_route_map[0].route,e.path=meta.page_route_map[0].path),e}function getCurrentPageInfo(){var e=getCurrentPage(),t={title:"",url:"",path:"\u672a\u53d6\u5230"};if(e&&e.route){var a=e.sensors_mp_url_query?"?"+e.sensors_mp_url_query:"";t.title=getPageTitle(e.route),t.url=e.route+a,t.path=e.route}return t}function setPageRefData(e,t,a){var r=getRefPage();isObject(e)&&(t?meta.page_route_map.length>0&&t?(a=a?"?"+a:"",e.$referrer=getPath(t)+a,e.$referrer_title=getPageTitle(t)):(e.$referrer="\u76f4\u63a5\u6253\u5f00",e.$referrer_title=""):(e.$referrer=r.route,e.$referrer_title=r.title))}function getPageTitle(e){if("\u672a\u53d6\u5230"===e||!e)return"";var t="";try{if(__wxConfig){var a=__wxConfig,r=__wxConfig.page||{},i=r[e]||r[e+".html"],n={},s={};if(a.global&&a.global.window&&a.global.window.navigationBarTitleText&&(n.titleVal=a.global.window.navigationBarTitleText),i&&i.window&&i.window.navigationBarTitleText&&(s.titleVal=i.window.navigationBarTitleText),!s.titleVal&&__wxAppCode__){var o=__wxAppCode__[e+".json"];o&&o.navigationBarTitleText&&(s.titleVal=o.navigationBarTitleText)}if(each(meta.global_title,function(a,r){if(r===e)return t=a}),0===t.length){var u=extend(n,s);t=u.titleVal||""}}}catch(e){log(e)}return t}function wxrequest(e){if(compareSDKVersion(meta.wx_sdk_version,"2.10.0")>=0)e.timeout=saPara.datasend_timeout,wx.request(e);else{var t=wx.request(e);setTimeout(function(){isObject(t)&&isFunction(t.abort)&&t.abort()},saPara.datasend_timeout)}}function validId(e){return"string"!=typeof e&&"number"!=typeof e||""===e?(log("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1):"number"!=typeof e||(e=String(e),/^\d+$/.test(e))?!!check.checkIdLength(e)&&e:(log("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1)}function compareSDKVersion(e,t){e=e.split("."),t=t.split(".");for(var a=Math.max(e.length,t.length);e.lengthn)return 1;if(i{wx.getNetworkType({success:function(t){meta.preset_properties.$network_type=setUpperCase(t.networkType),e()},fail:function(e){log("\u83b7\u53d6\u7f51\u7edc\u4fe1\u606f\u5931\u8d25",e),t()}})})}function getSystemInfo(){var e=meta.preset_properties;return new Promise(t=>{wx.getSystemInfo({success:function(a){var r,i;e.$brand=setUpperCase(a.brand),e.$manufacturer=a.brand,e.$model=a.model,e.$screen_width=Number(a.screenWidth),e.$screen_height=Number(a.screenHeight),e.$os=(r=a.platform,"ios"===(i=r.toLowerCase())?"iOS":"android"===i?"Android":r),e.$os_version=a.system.indexOf(" ")>-1?a.system.split(" ")[1]:a.system,meta.wx_sdk_version=a.SDKVersion,e.$mp_client_app_version=a.version,e.$mp_client_basic_library_version=meta.wx_sdk_version;var n=(new Date).getTimezoneOffset(),s=getAppInfoSync();isNumber(n)&&(e.$timezone_offset=n),s.appId&&(e.$app_id=s.appId),s.appVersion&&(e.$app_version=s.appVersion),t()}})})}var info={currentProps:meta.preset_properties},logger={info:function(){if(saPara.show_log&&"object"==typeof console&&console.log)try{if(3===arguments.length)return console.log(arguments[0],arguments[1],arguments[2]);if(2===arguments.length)return console.log(arguments[0],arguments[1]);if(1===arguments.length)return console.log(arguments[0])}catch(e){console.log(arguments[0])}}};function isValidListener(e){return"function"==typeof e||!(!e||"object"!=typeof e)&&isValidListener(e.listener)}class EventEmitterBase{constructor(){this._events={}}on(e,t){if(!e||!t)return!1;if(!isValidListener(t))throw new Error("listener must be a function");this._events[e]=this._events[e]||[];var a="object"==typeof t;return this._events[e].push(a?t:{listener:t,once:!1}),this}prepend(e,t){if(!e||!t)return!1;if(!isValidListener(t))throw new Error("listener must be a function");this._events[e]=this._events[e]||[];var a="object"==typeof t;return this._events[e].unshift(a?t:{listener:t,once:!1}),this}prependOnce(e,t){return this.prepend(e,{listener:t,once:!0})}once(e,t){return this.on(e,{listener:t,once:!0})}off(e,t){var a=this._events[e];if(!a)return!1;if("number"==typeof t)a.splice(t,1);else if("function"==typeof t)for(var r=0,i=a.length;r0&&this.cacheEvents.forEach(function(a){a.type===e&&t.call(null,a.data)})}emit(e,t){super.emit.apply(this,arguments),this.cacheEvents.push({type:e,data:t}),this.cacheEvents.length>this.maxLen&&this.cacheEvents.shift()}}var _=Object.freeze({__proto__:null,decodeURIComponent:decodeURIComponent$1,encodeDates:encodeDates,formatDate:formatDate,searchObjDate:searchObjDate,formatString:formatString,searchObjString:searchObjString,parseSuperProperties:parseSuperProperties,unique:unique,check:check,getUtmFromPage:getUtmFromPage,setQuery:setQuery,setLatestShare:setLatestShare,setLatestChannel:setLatestChannel,setUpperCase:setUpperCase,compareSDKVersion:compareSDKVersion,validId:validId,wxrequest:wxrequest,getPageTitle:getPageTitle,setPageRefData:setPageRefData,getCurrentPageInfo:getCurrentPageInfo,getRefPage:getRefPage,setRefPage:setRefPage,setPageSfSource:setPageSfSource,setSfSource:setSfSource,setUtm:setUtm,getMixedQuery:getMixedQuery,detectOptionQuery:detectOptionQuery,getShareInfo:getShareInfo,setShareInfo:setShareInfo,shareInfoData:shareInfoData,delObjectKey:delObjectKey,objToParam:objToParam,getMPScene:getMPScene,getStorageSync:getStorageSync,setStorageSync:setStorageSync,getObjFromQuery:getObjFromQuery,getCustomUtmFromQuery:getCustomUtmFromQuery,getPath:getPath,getCurrentUrl:getCurrentUrl,getIsFirstDay:getIsFirstDay,getCurrentPath:getCurrentPath,getCurrentPage:getCurrentPage,urlBase64Encode:urlBase64Encode,btoa:btoa,base64Encode:base64Encode,strip_empty_properties:strip_empty_properties,strip_sa_properties:strip_sa_properties,setNavigationBarTitle:setNavigationBarTitle,networkStatusChange:networkStatusChange,getNetworkType:getNetworkType,getSystemInfo:getSystemInfo,encodeTrackData:encodeTrackData,initAppGlobalName:initAppGlobalName,getPublicPresetProperties:getPublicPresetProperties,setPublicProperties:setPublicProperties,isPresetIdKeys:isPresetIdKeys,isNewLoginId:isNewLoginId,isSameAndAnonymousID:isSameAndAnonymousID,info:info,logger:logger,getAppId:getAppId,getAppInfoSync:getAppInfoSync,getOpenidNameByAppid:getOpenidNameByAppid,rot13defs:rot13defs,rot13obfs:rot13obfs,each:each,isObject:isObject,getRandom:getRandom,extend:extend,extend2Lev:extend2Lev,coverExtend:coverExtend,isArray:isArray,isFunction:isFunction,isArguments:isArguments,toArray:toArray,values:values,include:include,trim:trim,isEmptyObject:isEmptyObject,deepCopy:deepCopy,isUndefined:isUndefined,isString:isString,isDate:isDate,isBoolean:isBoolean,isNumber:isNumber,isJSONString:isJSONString,isInteger:isInteger,isSafeInteger:isSafeInteger,slice:slice,urlSafeBase64:urlSafeBase64,EventEmitterBase:EventEmitterBase,EventEmitterEx:EventEmitterEx,log:log});function onEventSend(){return{}}function processData(e){return e}function batchTrackData(e){var t=Date.now();return e.forEach(function(e){e._flush_time=t}),"data_list="+encodeTrackData(e)}var mergeStorageData={getData:function(e){wx.getStorage({key:saPara.storage_prepare_data_key,complete:function(t){var a=t.data&&isArray(t.data)?t.data:[];mergeStorageData.deleteAesData(a),e&&e()}})},deleteAesData:function(e){var t=[],a=e.length;if(a>0){for(var r=0;r=saPara.batch_send.max_length&&this.batchSend()},wxrequest:function(e){if(isArray(e.data)&&e.data.length>0){var t=kit.batchTrackData(e.data);sa._.wxrequest({url:saPara.server_url,method:"POST",dataType:"text",data:t,header:{"content-type":"text/plain"},success:function(){e.success(e.len)},fail:function(){e.fail()}})}else e.success(e.len)},batchSend:function(){if(this.dataHasSend){var e,t,a=store.mem.mdata;(t=(e=a.length>=100?a.slice(0,100):a).length)>0&&(this.dataHasSend=!1,this.wxrequest({data:e,len:t,success:this.batchRemove.bind(this),fail:this.sendFail.bind(this)}))}},sendFail:function(){this.dataHasSend=!0,this.failTime++},batchRemove:function(e){store.mem.clear(e),this.dataHasSend=!0,this.dataHasChange=!0,this.batchWrite(),this.failTime=0},is_first_batch_write:!0,batchWrite:function(){this.dataHasChange&&(this.dataHasChange=!1,this.syncStorage&&sa._.setStorageSync(saPara.storage_prepare_data_key,store.mem.mdata))},batchInterval:function(){var e=this;!function t(){setTimeout(function(){e.batchWrite(),t()},500)}(),function t(){setTimeout(function(){e.batchSend(),t()},saPara.batch_send.send_timeout*Math.pow(2,e.failTime))}()}};function onceSend(e){e._flush_time=Date.now();var t=kit.onceTrackData(e),a=saPara.server_url+"?"+t;-1!==saPara.server_url.indexOf("?")&&(a=saPara.server_url+"&"+t),wxrequest({url:a,method:"GET"})}function buildData(e,t){var a={distinct_id:sa.store.getDistinctId(),identities:sa.store._state.identities,lib:{$lib:LIB_NAME,$lib_method:"code",$lib_version:LIB_VERSION},properties:{}};return"track_id_unbind"===e.type&&"$UnbindID"===e.event&&(a.identities=deepCopy(e.unbind_value),delete e.unbind_value),isObject(t)||(t={}),extend(a,sa.store.getUnionId(),e),isObject(e.properties)&&!isEmptyObject(e.properties)&&extend(a.properties,e.properties),e.type&&"profile"===e.type.slice(0,7)||(a._track_id=Number(String(getRandom()).slice(2,5)+String(getRandom()).slice(2,4)+String(Date.now()).slice(-4)),a.properties=extend({},getPublicPresetProperties(),meta.preset_properties,sa.store.getProps(),t,a.properties),"track"===e.type&&(a.properties.$is_first_day=getIsFirstDay())),a.properties.$time&&isDate(a.properties.$time)?(a.time=1*a.properties.$time,delete a.properties.$time):a.time=1*new Date,sa.ee.sdk.emit("createData",a),sa.ee.sdk.emit("beforeBuildCheck",a),sa.ee.data.emit("beforeBuildCheck",a),parseSuperProperties(a.properties),searchObjDate(a),strip_sa_properties(a.properties),searchObjString(a),sa.ee.data.emit("finalAdjustData",a),a}function dataStage(e){if(!saPara.server_url)return!1;if(meta.current_scene&&1154===meta.current_scene&&!sa.para.preset_events.moments_page)return!1;var t=sa._.deepCopy(e),a=buildData(e,kit.onEventSend(t));a?(log(a),sa.events.emit("send",a),sa.para.batch_send?sendStrategy.send(a):onceSend(a)):log("error: \u6570\u636e\u5f02\u5e38 "+a)}sa.popupEmitter={attached:function(){return!1}};var usePlugin=function(e,t){if(!isObject(e)&&!isFunction(e))return log("plugin must be an object",e),!1;if(isFunction(e.init)||log("plugin maybe missing init method",e.plugin_name||e),isString(e.plugin_name)&&e.plugin_name?sa.modules[e.plugin_name]?e=sa.modules[e.plugin_name]:sa.modules[e.plugin_name]=e:log("plugin_name is not defined - ",e.plugin_name||e),isObject(e)&&!0===e.plugin_is_init)return e;if(isObject(e)&&e.plugin_name&&(isString(e.plugin_version)&&e.plugin_version===LIB_VERSION||log("warning!"+e.plugin_name+" plugin version do not match SDK version \uff01\uff01\uff01")),meta.init_status)"function"==typeof e.init&&(e.init(sa,t),e.plugin_is_init=!0,log(e.plugin_name+" plugin is initialized"));else{var a={target:e,para:t};meta.plugin.uninitialized_list.push(a)}return e},checkPluginInitStatus=function(){if(meta.plugin.uninitialized_list.length>0){for(var e in meta.plugin.uninitialized_list){var t=meta.plugin.uninitialized_list[e];t&&t.target&&"function"==typeof t.target.init&&!t.target.plugin_is_init&&(t.target.init(sa,t.para),isObject(t.target)&&(t.target.plugin_is_init=!0,isString(t.target.plugin_name)&&t.target.plugin_name&&log(t.target.plugin_name+" plugin is initialized")))}meta.plugin.uninitialized_list=[]}};function initAppShowHide(){wx.onAppShow(function(e){if(!meta.life_state.app_launched){var t=wx.getLaunchOptionsSync()||{};sa.autoTrackCustom.appLaunch(t)}sa.autoTrackCustom.appShow(e)}),wx.onAppHide(function(){sa.autoTrackCustom.appHide()})}function checkAppLaunch(){if(!meta.life_state.app_launched){var e=wx.getLaunchOptionsSync()||{};sa.autoTrackCustom.appLaunch(e)}}function mpProxy(e,t,a){var r=sa.autoTrackCustom[a];if(e[t]){var i=e[t];e[t]=function(){!sa.para.autoTrackIsFirst||isObject(sa.para.autoTrackIsFirst)&&!sa.para.autoTrackIsFirst[a]?(i.apply(this,arguments),r.apply(this,arguments)):(!0===sa.para.autoTrackIsFirst||isObject(sa.para.autoTrackIsFirst)&&sa.para.autoTrackIsFirst[a])&&(r.apply(this,arguments),i.apply(this,arguments)),sa.ee.page.emit(a)}}else e[t]=function(){r.apply(this,arguments),sa.ee.page.emit(a)}}function clickTrack(e){var t,a={},r={},i=e.currentTarget||{},n=e.target||{};if(isObject(sa.para.framework)&&isObject(sa.para.framework.taro)&&!sa.para.framework.taro.createApp&&n.id&&i.id&&n.id!==i.id)return!1;var s=i.dataset||{};if(t=e.type,a.$element_id=i.id,a.$element_type=s.type,a.$element_content=s.content,a.$element_name=s.name,isObject(e.event_prop)&&(r=e.event_prop),t&&isClick(t)){if(sa.para.preset_events&&sa.para.preset_events.collect_element&&!1===sa.para.preset_events.collect_element(arguments[0]))return!1;a.$url_path=sa._.getCurrentPath(),sa._.setPageRefData(a),a=sa._.extend(a,r),sa.track("$MPClick",a)}}function clickProxy(e,t){var a=e[t];e[t]=function(){var e=a.apply(this,arguments),t=arguments[0];return isObject(t)&&(sa.para.preset_events.defer_track?setTimeout(function(){clickTrack(t)},0):clickTrack(t)),e}}function isClick(e){return!!{tap:1,longpress:1,longtap:1}[e]}function tabProxy(e){var t=e.onTabItemTap;e.onTabItemTap=function(e){t&&t.apply(this,arguments);var a={};e&&(a.$element_content=e.text),a.$element_type="tabBar",a.$url_path=sa._.getCurrentPath(),sa._.setPageRefData(a),sa.track("$MPClick",a)}}function getMethods(e){var t=MP_FILTER_HOOK,a=[];for(var r in e)"function"!=typeof e[r]||t[r]||a.push(r);return a}function initPageProxy(){var e=Page;Page=function(t){try{t||(t={}),monitorClick(t),monitorHooks(t),e.apply(this,arguments)}catch(t){e.apply(this,arguments)}};var t=Component;Component=function(e){try{e||(e={}),e.methods||(e.methods={}),monitorClick(e.methods),monitorHooks(e.methods),t.apply(this,arguments)}catch(e){t.apply(this,arguments)}}}function monitorClick(e){var t=[];if(sa.para.autoTrack&&sa.para.autoTrack.mpClick){t=getMethods(e),tabProxy(e);for(var a=t.length,r=0;r100)log("Key ["+e+"] is invalid");else if(!check.checkKeyword(e))return log("Key ["+e+"] is invalid"),!1;if(isPresetIdKeys(e,["$mp_openid","$identity_mp_openid","$identity_mp_unionid","$mp_unionid","$mp_id","$identity_mp_id"]))return log("Key ["+e+"] is invalid"),!1;if(!(t=validId(t)))return!1;if(isSameAndAnonymousID(t))return!1;var a=store.getFirstId(),r=store.getDistinctId();isNewLoginId(e,t)&&(store._state.identities[e]=t,store.set("history_login_id",{name:e,value:t}),a||store.set("first_id",r),sa.trackSignup({id:t,event_name:"$SignUp",id_name:e}),store.identitiesSet({type:"login",id:t,id_name:e}))}function getAnonymousID(){if(!isEmptyObject(store._state))return store._state._first_id||store._state.first_id||store._state._distinct_id||store._state.distinct_id;log("\u8bf7\u5148\u521d\u59cb\u5316SDK")}function getIdentities(){return isEmptyObject(store._state)?(log("\u8bf7\u5148\u521d\u59cb\u5316SDK"),null):store._state.identities||null}function logout(e){var t=store.getFirstId();store.identitiesSet({type:"logout"}),store.set("history_login_id",{name:"",value:""}),t?(store.set("first_id",""),!0===e?store.set("distinct_id",store.getUUID()):store.set("distinct_id",t)):log("\u6ca1\u6709first_id\uff0clogout\u5931\u8d25")}function getPresetProperties(){if(meta.preset_properties&&meta.preset_properties.$lib){var e={};each(meta.preset_properties,function(t,a){0===a.indexOf("$")&&(e[a]=t)});var t={$url_path:getCurrentPath(),$is_first_day:getIsFirstDay(),$is_first_time:meta.is_first_launch},a=extend(e,t,meta.preset_properties,store.getProps());return delete a.$lib,a}return{}}function setOpenid(e,t){if(!(e=validId(e)))return!1;if(!checkPrivacyStatus())return!1;if(!meta.init_status)return store.store_queue.push({method:"setOpenid",params:arguments}),!1;log("\u8be5\u65b9\u6cd5\u5df2\u4e0d\u5efa\u8bae\u4f7f\u7528\uff0c\u5982\u679c\u662f id2 \u7528\u6237\uff0c\u8bf7\u4f7f\u7528 identify \u4ee3\u66ff\uff0c\u5982\u679c\u662f id3 \u7528\u6237\uff0c\u8bf7\u4f7f\u7528 bindOpenid \u4ee3\u66ff"),t&&log("%c \u5f53\u524d\u7248\u672c setOpenid \u63a5\u53e3 \u5df2\u4e0d\u652f\u6301\u4f20\u5165\u7b2c\u4e8c\u4e2a\u53c2\u6570","color:#F39C12;font-size: 14px;"),store.set("openid",e),sa.identify(e,!0);var a=getOpenidNameByAppid();store._state.identities[a]=e,store.save()}function unsetOpenid(e){log("\u8be5\u65b9\u6cd5\u5df2\u4e0d\u5efa\u8bae\u4f7f\u7528\uff0c\u5982\u679c\u662f id3 \u7528\u6237\uff0c\u8bf7\u4f7f\u7528 unbindOpenid \u4ee3\u66ff");var t=validId(e);if(!t)return!1;var a=store._state.openid;a===t&&store.set("openid","");var r=getOpenidNameByAppid();if(hasOwnProperty$3.call(store._state.identities,r)&&t===store._state.identities[r]){delete store._state.identities[r];var i=store.getFirstId(),n=store.getDistinctId(),s=store._state&&store._state.identities&&store._state.identities.$identity_mp_id;i&&i===a&&s&&store.change("first_id",s),n&&n===a&&s&&store.change("distinct_id",s),store.save()}}function bindOpenid(e){if(!(e=validId(e)))return!1;var t=getOpenidNameByAppid();this.bind(t,e)}function unbindOpenid(e){if(!validId(e))return!1;var t=getOpenidNameByAppid();this.unbind(t,e)}function setUnionid(e){var t=validId(e);t&&bind("$identity_mp_unionid",t)}function unsetUnionid(e){var t=validId(e);if(t){if(hasOwnProperty$3.call(store._state.identities,"$identity_mp_unionid")&&t===store._state.identities.$identity_mp_unionid){var a=getOpenidNameByAppid();hasOwnProperty$3.call(store._state.identities,a)&&(delete store._state.identities[a],delete store._state.openid,store.save())}unbind("$identity_mp_unionid",t)}}function initWithOpenid(e,t){(e=e||{}).appid&&(saPara.appid=e.appid),sa.openid.getOpenid(function(a){a&&sa.setOpenid(a,e.isCoverLogin),t&&isFunction(t)&&t(a),sa.init(e)})}function bind(e,t){if(isNumber(t)){if(isInteger(t)&&!1===isSafeInteger(t))return log("Value must be String"),!1;t=String(t)}if(!isString(e))return log("Key must be String"),!1;var a=store.getHistoryLoginId(),r=a?a.name:"";return!check.checkKeyword(e)||isPresetIdKeys(e,[IDENTITY_KEY.LOGIN,r,"$mp_id","$identity_mp_id"])?(log("Key ["+e+"] is invalid"),!1):t&&""!==t?isString(t)?!!check.checkIdLength(t)&&(store._state.identities[e]=t,store.save(),void dataStage({type:"track_id_bind",event:"$BindID"})):(log("Value must be String"),!1):(log("Value is empty or null"),!1)}function unbind(e,t){if(isNumber(t)){if(isInteger(t)&&!1===isSafeInteger(t))return log("Value must be String"),!1;t=String(t)}if(!isString(e))return log("Key must be String"),!1;if(!sa._.check.checkKeyword(e)||isPresetIdKeys(e,[IDENTITY_KEY.LOGIN]))return log("Key ["+e+"] is invalid"),!1;if(!t||""===t)return log("Value is empty or null"),!1;if(!isString(t))return log("Value must be String"),!1;if(!sa._.check.checkIdLength(t))return!1;hasOwnProperty$3.call(store._state.identities,e)&&t===store._state.identities[e]&&("$mp_id"!==e&&"$identity_mp_id"!==e&&delete store._state.identities[e],store.save());var a=store.getDistinctId(),r=store.getFirstId();a===e+"+"+t&&(store.set("first_id",""),store.set("distinct_id",r),store.set("history_login_id",{name:"",value:""}));var i={};i[e]=t,dataStage({type:"track_id_unbind",event:"$UnbindID",unbind_value:i})}function setWebViewUrl(e,t){if(log("setWebViewUrl \u65b9\u6cd5\u5df2\u4ece 2022-9-23 \u5f00\u59cb\u5e9f\u5f03\uff0c\u8bf7\u5c3d\u5feb\u53bb\u9664\u8be5 API \u7684\u8c03\u7528\uff0c\u5e76\u4f7f\u7528 use \u63d2\u4ef6 \u4ee3\u66ff"),!isString(e)||""===e)return log("error:\u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;if(!/^http(s)?:\/\//.test(e))return log("warning: \u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;var a=/([^?#]+)(\?[^#]*)?(#.*)?/.exec(e);if(!a)return!1;var r,i=a[1]||"",n=a[2]||"",s=a[3]||"",o="",u=store.getDistinctId()||"",c=store.getFirstId()||"";urlSafeBase64&&urlSafeBase64.encode?u=u?urlSafeBase64.trim(urlSafeBase64.encode(urlBase64Encode(u))):"":rot13obfs&&(u=u?rot13obfs(u):""),u=encodeURIComponent(u);var p=c?"f"+u:"d"+u;t?(r=s.indexOf("_sasdk"),o=s.indexOf("?")>-1?r>-1?i+n+"#"+s.substring(1,r)+"_sasdk="+p:i+n+"#"+s.substring(1)+"&_sasdk="+p:i+n+"#"+s.substring(1)+"?_sasdk="+p):(r=n.indexOf("_sasdk"),o=/^\?(\w)+/.test(n)?r>-1?i+n.replace(/(_sasdk=)([^&]*)/gi,"_sasdk="+p)+s:i+"?"+n.substring(1)+"&_sasdk="+p+s:i+"?"+n.substring(1)+"_sasdk="+p+s);return o}function quick(){var e=arguments[0],t=arguments[1],a=arguments[2],r=isObject(a)?a:{};if("getAnonymousID"===e){if(!isEmptyObject(store._state))return store._state._first_id||store._state.first_id||store._state._distinct_id||store._state.distinct_id;log("\u8bf7\u5148\u521d\u59cb\u5316SDK")}else"appLaunch"===e||"appShow"===e?t?sa.autoTrackCustom[e](t,r):log("App\u7684launch\u548cshow\uff0c\u5728sensors.quick\u7b2c\u4e8c\u4e2a\u53c2\u6570\u5fc5\u987b\u4f20\u5165App\u7684options\u53c2\u6570"):"appHide"===e&&(r=isObject(t)?t:{},sa.autoTrackCustom[e](r))}function appLaunch(e,t){var a={};e&&e.scene?(meta.current_scene=e.scene,a.$scene=getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,delObjectKey(e.query)),e&&e.path&&(a.$url_path=getPath(e.path),a.$title=getPageTitle(e.path)),setShareInfo(e,a);var r=setUtm(e,a);meta.is_first_launch?(a.$is_first_time=!0,isEmptyObject(r.pre1)||sa.setOnceProfile(r.pre1)):a.$is_first_time=!1,setLatestChannel(r.pre2),setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=setQuery(e.query),a.$url=e.path+(a.$url_query?"?"+a.$url_query:""),setPageRefData(t),isObject(t)&&(a=extend(a,t)),sa.track("$MPLaunch",a)}function appShow(e,t){var a={};meta.mp_show_time=(new Date).getTime(),e&&e.scene?(meta.current_scene=e.scene,a.$scene=getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,delObjectKey(e.query)),e&&e.path&&(a.$url_path=getPath(e.path),a.$title=getPageTitle(e.path)),setShareInfo(e,a),setLatestChannel(setUtm(e,a).pre2),setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=setQuery(e.query),e&&e.path&&(a.$url=e.path+(a.$url_query?"?"+a.$url_query:"")),setPageRefData(a,e.path,a.$url_query),isObject(t)&&(a=extend(a,t)),sa.track("$MPShow",a)}function appHide(e){var t=(new Date).getTime(),a={};a.$url_path=getCurrentPath(),meta.mp_show_time&&t-meta.mp_show_time>0&&(t-meta.mp_show_time)/36e5<24&&(a.event_duration=(t-meta.mp_show_time)/1e3),setPageRefData(a),isObject(e)&&(a=extend(a,e)),sa.track("$MPHide",a),sa.sendStrategy.onAppHide()}function pageShow(e){var t={},a=getCurrentPath(),r=getPageTitle(a),i=getCurrentPage();r&&(t.$title=r),t.$url_path=a,t.$url_query=i.sensors_mp_url_query?i.sensors_mp_url_query:"",setPageSfSource(t=extend(t,getUtmFromPage())),setPageRefData(t),isObject(e)&&(t=extend(t,e)),sa.track("$MPViewScreen",t)}function setPara(e){sa.para=extend2Lev(saPara,e);var t=[];if(isArray(saPara.source_channel))for(var a=saPara.source_channel.length,r=0;r0&&(t-meta.mp_show_time)/36e5<24&&(a.event_duration=(t-meta.mp_show_time)/1e3),setPageRefData(a),e?(a=extend(a,e),sa.track("$MPHide",a)):saPara.autoTrack&&saPara.autoTrack.appHide&&sa.autoTrackCustom.trackCustom("appHide",a,"$MPHide")},pageLoad:function(e){meta.current_scene&&1010===meta.current_scene&&e&&(e.sampshare&&delete e.sampshare,delObjectKey(e)),e&&isObject(e)&&(this.sensors_mp_url_query=setQuery(e),this.sensors_mp_encode_url_query=setQuery(e,!0))},pageShow:function(){meta.page_show_time=Date.now();var e={},t=getCurrentPath(),a=getPageTitle(t);setRefPage(),e.$url_path=t,e.$url_query=this.sensors_mp_url_query?this.sensors_mp_url_query:"",setPageRefData(e=extend(e,getUtmFromPage())),setPageSfSource(e),a&&(e.$title=a),saPara.onshow?saPara.onshow(sa,t,this):-1===saPara.autotrack_exclude_page.pageShow.indexOf(t)&&sa.autoTrackCustom.trackCustom("pageShow",e,"$MPViewScreen")},pageShare:function(e){var t=e.onShareAppMessage;e.onShareAppMessage=function(){var e=this;meta.share_method="\u8f6c\u53d1\u6d88\u606f\u5361\u7247";var a,r=t.apply(this,arguments);if(saPara.autoTrack&&saPara.autoTrack.pageShare){var i={$url_path:getCurrentPath(),$share_depth:meta.query_share_depth,$share_method:meta.share_method};setPageRefData(i),sa.autoTrackCustom.trackCustom("pageShare",i,"$MPShare")}function n(t){return isObject(t)||(t={}),(isUndefined(t.path)||""===t.path)&&(t.path=getCurrentUrl(e)),isString(t.path)&&(-1===t.path.indexOf("?")?t.path=t.path+"?":"&"!==t.path.slice(-1)&&(t.path=t.path+"&")),t.path=t.path+getShareInfo(),t}if(sa.para.allow_amend_share_path&&isObject(r=n(r)))for(var s in r)if((a=r[s])&&isFunction(a.then)&&isFunction(a.catch))try{r[s]=r[s].then(function(e){return n(e)})}catch(e){log("onShareAppMessage: "+e)}return r}},pageShareTimeline:function(e){var t=e.onShareTimeline;e.onShareTimeline=function(){meta.share_method="\u670b\u53cb\u5708\u5206\u4eab";var e=t.apply(this,arguments);if(saPara.autoTrack&&saPara.autoTrack.pageShare){var a={$url_path:getCurrentPath(),$share_depth:meta.query_share_depth,$share_method:meta.share_method};setPageRefData(a),sa.autoTrackCustom.trackCustom("pageShare",a,"$MPShare")}return saPara.allow_amend_share_path&&("object"!=typeof e&&(e={}),"object"==typeof e&&void 0===e.query&&(e.query=""),"object"==typeof e&&"string"==typeof e.query&&""!==e.query&&"&"!==e.query.slice(-1)&&(e.query=e.query+"&"),e.query=e.query+getShareInfo()),e}},pageAddFavorites:function(){var e={};e.$url_path=getCurrentPath(),saPara.autoTrack&&saPara.autoTrack.mpFavorite&&sa.autoTrackCustom.trackCustom("mpFavorite",e,"$MPAddFavorites")},pageHide:function(){sa.para.autoTrack&&sa.para.autoTrack.pageLeave&&sendPageLeave()}};function sendPageLeave(){var e={},t="";try{t=(e=getCurrentPage())?e.route:""}catch(e){log(e)}if(meta.page_show_time>=0&&""!==t){var a={},r=getPageTitle(t),i=(Date.now()-meta.page_show_time)/1e3;(isNaN(i)||i<0)&&(i=0),a.$url_query=e.sensors_mp_url_query?e.sensors_mp_url_query:"",a.$url_path=t,a.$title=r,a.event_duration=i,-1===saPara.autotrack_exclude_page.pageLeave.indexOf(t)&&sa.track("$MPPageLeave",a),meta.page_show_time=-1}}var openid={getRequest:function(e){wx.login({success:function(t){t.code&&saPara.appid&&saPara.openid_url?wxrequest({url:saPara.openid_url+"&code="+t.code+"&appid="+saPara.appid,method:"GET",complete:function(t){isObject(t)&&isObject(t.data)&&t.data.openid?e(t.data.openid):e()}}):e()}})},getWXStorage:function(){var e=store.getStorage();if(e&&isObject(e))return e.openid},getOpenid:function(e){if(!saPara.appid)return e(),!1;var t=this.getWXStorage();t?e(t):this.getRequest(e)}},functions=Object.freeze({__proto__:null,setProfile:setProfile,setOnceProfile:setOnceProfile,appendProfile:appendProfile,incrementProfile:incrementProfile,track:track,identify:identify,trackSignup:trackSignup,login:login,loginWithKey:loginWithKey,getAnonymousID:getAnonymousID,getIdentities:getIdentities,logout:logout,getPresetProperties:getPresetProperties,setOpenid:setOpenid,unsetOpenid:unsetOpenid,bindOpenid:bindOpenid,unbindOpenid:unbindOpenid,setUnionid:setUnionid,unsetUnionid:unsetUnionid,bindUnionid:setUnionid,unbindUnionid:unsetUnionid,initWithOpenid:initWithOpenid,bind:bind,unbind:unbind,setWebViewUrl:setWebViewUrl,quick:quick,appLaunch:appLaunch,appShow:appShow,appHide:appHide,pageShow:pageShow,setPara:setPara,getServerUrl:getServerUrl,sendPageLeave:sendPageLeave,openid:openid,autoTrackCustom:autoTrackCustom,registerApp:registerApp,register:register,clearAllRegister:clearAllRegister,clearAppRegister:clearAppRegister,clearAllProps:clearAllProps});function buildAPI(e){for(var t in functions)e[t]=functions[t]}function setFirstVisitTime(){meta.is_first_launch&&setOnceProfile({$first_visit_time:new Date})}function checkIsComplete(){meta.initialState.isComplete=!0,meta.initialState.queue.length>0&&(each(meta.initialState.queue,function(e){"appLaunch"===e[0]?sa.autoTrackCustom.appLaunch.apply(sa.autoTrackCustom,slice.call(e[1])):sa[e[0]].apply(sa,slice.call(e[1]))}),meta.initialState.queue=[])}function init(e){if(!0===meta.init_status)return!1;function t(){checkIsComplete(),checkAppLaunch(),sa.ee.sdk.emit("ready")}meta.init_status=!0,sa.ee.sdk.emit("beforeInit"),e&&isObject(e)&&sa.setPara(e),sa.ee.sdk.emit("initPara"),sa.ee.sdk.emit("afterInitPara"),sa.store.init(),sa.checkPluginInitStatus(),setFirstVisitTime(),sa.para.batch_send&&sa.sendStrategy.init();var a=[getNetworkType(),getSystemInfo()].concat(meta.promise_list);Promise.all(a).then(()=>{t()}).catch(()=>{t()})}function registerPropertyPlugin(e){isFunction(e.properties)?!e.isMatchedWithFilter||isFunction(e.isMatchedWithFilter)?sa.ee.data.on("finalAdjustData",function(t){try{isFunction(e.isMatchedWithFilter)?e.isMatchedWithFilter(t)&&e.properties(t):e.properties(t)}catch(e){log("execute registerPropertyPlugin callback error:"+e)}}):log("registerPropertyPlugin arguments error, isMatchedWithFilter must be function"):log("registerPropertyPlugin arguments error, properties must be function")}sa._=_,sa.modules={},sa.meta=meta,sa.kit=kit,sa.mergeStorageData=mergeStorageData,sa.dataStage=dataStage,sa.sendStrategy=sendStrategy,sa.store=store,sa.usePlugin=usePlugin,sa.checkPluginInitStatus=checkPluginInitStatus,sa.eventSub=eventSub,sa.events=new eventEmitter,sa.ee=ee,sa.registerPropertyPlugin=registerPropertyPlugin,sa.enableDataCollect=enableDataCollect,sa.initialState=meta.initialState,sa.IDENTITY_KEY={EMAIL:IDENTITY_KEY.EMAIL,MOBILE:IDENTITY_KEY.MOBILE},buildAPI(sa),apiStaging(),setNavigationBarTitle(),networkStatusChange(),initAppGlobalName(),initAppShowHide(),initPageProxy(),sa.init=init;var base={plugin_version:"1.19.12"};function createPlugin(e){if("object"==typeof e&&"string"==typeof e.plugin_name&&""!==e.plugin_name)return e.plugin_version=base.plugin_version,e.log=e.log||function(){"object"==typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)},e;"object"==typeof console&&"function"==typeof console.error&&console.error('plugin must contain proprerty "plugin_name"')}var disableSDK={init(e){e.disableSDK=this.disableSDK.bind(this),e.enableSDK=this.enableSDK.bind(this),e.getDisabled=this.getDisabled.bind(this)},plugin_name:"DisableSDK",disabled:!1,disableSDK(){this.disabled=!0},enableSDK(){this.disabled=!1},getDisabled(){return this.disabled}},DisableSDK=createPlugin(disableSDK);sa.usePlugin(DisableSDK);export default sa; \ No newline at end of file diff --git a/sensorsdata.min.js b/sensorsdata.min.js index dbc7326..67d4653 100644 --- a/sensorsdata.min.js +++ b/sensorsdata.min.js @@ -1 +1 @@ -"use strict";var sa={},saPara={name:"sensors",server_url:"",send_timeout:1e3,show_log:!1,login_id_key:"$identity_login_id",allow_amend_share_path:!0,max_string_length:500,datasend_timeout:3e3,source_channel:[],autoTrack:{appLaunch:!0,appShow:!0,appHide:!0,pageShow:!0,pageShare:!0,mpClick:!1,mpFavorite:!0,pageLeave:!1},autotrack_exclude_page:{pageShow:[],pageLeave:[]},is_persistent_save:{share:!1,utm:!1},preset_properties:{url_path:!0},preset_events:{moments_page:!1,defer_track:!1,share_info_use_string:!1},batch_send:!0,storage_store_key:"sensorsdata2015_wechat",storage_prepare_data_key:"sensors_mp_prepare_data"};function log(){if(saPara.show_log&&"object"==typeof console&&console.log)try{return console.log.apply(console,arguments)}catch(e){console.log(arguments[0])}}var nativeIsArray=Array.isArray,ObjProto=Object.prototype,ArrayProto=Array.prototype,nativeForEach=ArrayProto.forEach,nativeIndexOf=ArrayProto.indexOf,toString=ObjProto.toString,hasOwnProperty=ObjProto.hasOwnProperty,slice=ArrayProto.slice;function each(e,t,a){if(null==e)return!1;var r={};if(nativeForEach&&e.forEach===nativeForEach)e.forEach(t,a);else if(e.length===+e.length){for(var i=0,n=e.length;i0&&each(this.store_queue,function(e){sa[e.method].apply(sa,slice.call(e.params))}),this.store_queue=[])}};function _decodeURIComponent(e){var t="";try{t=decodeURIComponent(e)}catch(a){t=e}return t}var hasOwnProperty$2=Object.prototype.hasOwnProperty,decodeURIComponent$1=_decodeURIComponent;function initAppGlobalName(){var e=App;App=function(t){t[saPara.name]=sa,e.apply(this,arguments)}}function getPublicPresetProperties(){var e=getRefPage(),t=getCurrentPageInfo(),a={$referrer:e.route,$referrer_title:e.title,$title:t.title,$url:t.url};return!0===saPara.preset_properties.url_path&&(a.$url_path=t.path),a}function encodeDates(e){return each(e,function(t,a){isDate(t)?e[a]=formatDate(t):isObject(t)&&(e[a]=encodeDates(t))}),e}function formatDate(e){function t(e){return e<10?"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())}function searchObjDate(e){(isObject(e)||isArray(e))&&each(e,function(t,a){isObject(t)||isArray(t)?searchObjDate(e[a]):isDate(t)&&(e[a]=formatDate(t))})}function formatString(e){return e.length>saPara.max_string_length?(log("\u5b57\u7b26\u4e32\u957f\u5ea6\u8d85\u8fc7\u9650\u5236\uff0c\u5df2\u7ecf\u505a\u622a\u53d6--"+e),e.slice(0,saPara.max_string_length)):e}function searchObjString(e){isObject(e)&&each(e,function(t,a){isObject(t)?searchObjString(e[a]):isString(t)&&(e[a]=formatString(t))})}function parseSuperProperties(e){isObject(e)&&each(e,function(t,a){if(isFunction(t))try{e[a]=t(),isFunction(e[a])&&(log("\u60a8\u7684\u5c5e\u6027- "+a+" \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[a])}catch(t){delete e[a],log("\u60a8\u7684\u5c5e\u6027- "+a+" \u629b\u51fa\u4e86\u5f02\u5e38\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}})}function unique(e){for(var t,a=[],r={},i=0;i255)||(log("id \u957f\u5ea6\u8d85\u8fc7 255 \u4e2a\u5b57\u7b26\uff01"),!1)}};function strip_sa_properties(e){return isObject(e)?(each(e,function(t,a){if(isArray(t)){var r=[];each(t,function(e){if(isString(e))r.push(e);else if(isUndefined(e))r.push("null");else try{r.push(JSON.stringify(e))}catch(e){log("\u60a8\u7684\u6570\u636e - "+a+":"+t+" - \u7684\u6570\u7ec4\u91cc\u7684\u503c\u6709\u9519\u8bef,\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}}),e[a]=r}if(isObject(t))try{e[a]=JSON.stringify(t)}catch(r){delete e[a],log("\u60a8\u7684\u6570\u636e - "+a+":"+t+" - \u7684\u6570\u636e\u503c\u6709\u9519\u8bef,\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}else isString(t)||isNumber(t)||isDate(t)||isBoolean(t)||isArray(t)||(log("\u60a8\u7684\u6570\u636e - "+a+":"+t+" - \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[a])}),e):e}function strip_empty_properties(e){var t={};return each(e,function(e,a){null==e&&void 0===e||(t[a]=e)}),t}function utf8Encode(e){var t,a,r,i,n="";for(t=a=0,r=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,i=0;i127&&s<2048?String.fromCharCode(s>>6|192,63&s|128):String.fromCharCode(s>>12|224,s>>6&63|128,63&s|128),null!==o&&(a>t&&(n+=e.substring(t,a)),n+=o,t=a=i+1)}return a>t&&(n+=e.substring(t,e.length)),n}function base64Encode(e){var t,a,r,i,n,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,u=0,c="",p=[];if(!e)return e;e=utf8Encode(e);do{t=(n=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>18&63,a=n>>12&63,r=n>>6&63,i=63&n,p[u++]=s.charAt(t)+s.charAt(a)+s.charAt(r)+s.charAt(i)}while(o255||(r=e.charCodeAt(o++))>255||(i=e.charCodeAt(o++))>255)&&log("Failed to execute 'btoa' : The string to be encoded contains characters outside of the Latin1 range."),s+=n.charAt((t=a<<16|r<<8|i)>>18&63)+n.charAt(t>>12&63)+n.charAt(t>>6&63)+n.charAt(63&t);return u?s.slice(0,u-3)+"===".substring(u):s}function urlBase64Encode(e){return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}))}function getCurrentPage(){var e={};try{var t=getCurrentPages();e=t[t.length-1]}catch(e){log(e)}return e}function getCurrentPath(){var e="\u672a\u53d6\u5230";try{var t=getCurrentPage();e=t?t.route:e}catch(e){log(e)}return e}function getIsFirstDay(){return!!("object"==typeof store._state&&isNumber(store._state.first_visit_day_time)&&store._state.first_visit_day_time>(new Date).getTime())}function getCurrentUrl(e){var t=getCurrentPath(),a="";return isObject(e)&&e.sensors_mp_encode_url_query&&(a=e.sensors_mp_encode_url_query),t?a?t+"?"+a:t:"\u672a\u53d6\u5230"}function getPath(e){return e=isString(e)?e.replace(/^\//,""):"\u53d6\u503c\u5f02\u5e38"}function getCustomUtmFromQuery(e,t,a,r){if(!isObject(e))return{};var i={};if(e.sa_utm)for(var n in e)"sa_utm"!==n?include(saPara.source_channel,n)&&(i[a+n]=e[n]):i[r+n]=e[n];else for(var s in e)-1===(" "+SOURCE_CHANNEL_STANDARD+" ").indexOf(" "+s+" ")?include(saPara.source_channel,s)&&(i[a+s]=e[s]):i[t+s]=e[s];return i}function getObjFromQuery(e){var t=e.split("?"),a=[],r={};return t&&t[1]?(each(t[1].split("&"),function(e){(a=e.split("="))[0]&&a[1]&&(r[a[0]]=a[1])}),r):{}}function setStorageSync(e,t){var a=function(){wx.setStorageSync(e,t)};try{a()}catch(e){log("set Storage fail --",e);try{a()}catch(e){log("set Storage fail again --",e)}}}function getStorageSync(e){var t="";try{t=wx.getStorageSync(e)}catch(e){log("getStorage fail")}return t}function getMPScene(e){return isNumber(e)||isString(e)&&""!==e?e="wx-"+String(e):"\u672a\u53d6\u5230\u503c"}function objToParam(e,t){if(!isObject(e))return log("\u8bf7\u4f20\u5165\u6709\u6548\u5bf9\u8c61"),"";var a=[];for(var r in e)if(hasOwnProperty$2.call(e,r)){var i=e[r];void 0===i?a.push(r+"="):(i=t?encodeURIComponent(i):i,a.push(r+"="+i))}return a.join("&")}function delObjectKey(e){if(isObject(e))for(var t=0;t=2?(meta.page_route_map.shift(),meta.page_route_map.push(e)):meta.page_route_map.push(e)}}catch(e){log(e)}}function getRefPage(){var e={route:"\u76f4\u63a5\u6253\u5f00",path:"\u76f4\u63a5\u6253\u5f00",title:""};return meta.page_route_map.length>1&&(e.title=meta.page_route_map[0].title,e.route=meta.page_route_map[0].route,e.path=meta.page_route_map[0].path),e}function getCurrentPageInfo(){var e=getCurrentPage(),t={title:"",url:"",path:"\u672a\u53d6\u5230"};if(e&&e.route){var a=e.sensors_mp_url_query?"?"+e.sensors_mp_url_query:"";t.title=getPageTitle(e.route),t.url=e.route+a,t.path=e.route}return t}function setPageRefData(e,t,a){var r=getRefPage();isObject(e)&&(t?meta.page_route_map.length>0&&t?(a=a?"?"+a:"",e.$referrer=getPath(t)+a,e.$referrer_title=getPageTitle(t)):(e.$referrer="\u76f4\u63a5\u6253\u5f00",e.$referrer_title=""):(e.$referrer=r.route,e.$referrer_title=r.title))}function getPageTitle(e){if("\u672a\u53d6\u5230"===e||!e)return"";var t="";try{if(__wxConfig){var a=__wxConfig,r=__wxConfig.page||{},i=r[e]||r[e+".html"],n={},s={};if(a.global&&a.global.window&&a.global.window.navigationBarTitleText&&(n.titleVal=a.global.window.navigationBarTitleText),i&&i.window&&i.window.navigationBarTitleText&&(s.titleVal=i.window.navigationBarTitleText),!s.titleVal&&__wxAppCode__){var o=__wxAppCode__[e+".json"];o&&o.navigationBarTitleText&&(s.titleVal=o.navigationBarTitleText)}if(each(meta.global_title,function(a,r){if(r===e)return t=a}),0===t.length){var u=extend(n,s);t=u.titleVal||""}}}catch(e){log(e)}return t}function wxrequest(e){if(compareSDKVersion(meta.wx_sdk_version,"2.10.0")>=0)e.timeout=saPara.datasend_timeout,wx.request(e);else{var t=wx.request(e);setTimeout(function(){isObject(t)&&isFunction(t.abort)&&t.abort()},saPara.datasend_timeout)}}function validId(e){return"string"!=typeof e&&"number"!=typeof e||""===e?(log("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1):"number"!=typeof e||(e=String(e),/^\d+$/.test(e))?!!check.checkIdLength(e)&&e:(log("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1)}function compareSDKVersion(e,t){e=e.split("."),t=t.split(".");for(var a=Math.max(e.length,t.length);e.lengthn)return 1;if(i{wx.getNetworkType({success:function(t){meta.preset_properties.$network_type=setUpperCase(t.networkType),e()},fail:function(e){log("\u83b7\u53d6\u7f51\u7edc\u4fe1\u606f\u5931\u8d25",e),t()}})})}function getSystemInfo(){var e=meta.preset_properties;return new Promise(t=>{wx.getSystemInfo({success:function(a){var r,i;e.$brand=setUpperCase(a.brand),e.$manufacturer=a.brand,e.$model=a.model,e.$screen_width=Number(a.screenWidth),e.$screen_height=Number(a.screenHeight),e.$os=(r=a.platform,"ios"===(i=r.toLowerCase())?"iOS":"android"===i?"Android":r),e.$os_version=a.system.indexOf(" ")>-1?a.system.split(" ")[1]:a.system,meta.wx_sdk_version=a.SDKVersion,e.$mp_client_app_version=a.version,e.$mp_client_basic_library_version=meta.wx_sdk_version;var n=(new Date).getTimezoneOffset(),s=getAppInfoSync();isNumber(n)&&(e.$timezone_offset=n),s.appId&&(e.$app_id=s.appId),s.appVersion&&(e.$app_version=s.appVersion),t()}})})}var info={currentProps:meta.preset_properties},logger={info:function(){if(saPara.show_log&&"object"==typeof console&&console.log)try{if(3===arguments.length)return console.log(arguments[0],arguments[1],arguments[2]);if(2===arguments.length)return console.log(arguments[0],arguments[1]);if(1===arguments.length)return console.log(arguments[0])}catch(e){console.log(arguments[0])}}};function isValidListener(e){return"function"==typeof e||!(!e||"object"!=typeof e)&&isValidListener(e.listener)}class EventEmitterBase{constructor(){this._events={}}on(e,t){if(!e||!t)return!1;if(!isValidListener(t))throw new Error("listener must be a function");this._events[e]=this._events[e]||[];var a="object"==typeof t;return this._events[e].push(a?t:{listener:t,once:!1}),this}prepend(e,t){if(!e||!t)return!1;if(!isValidListener(t))throw new Error("listener must be a function");this._events[e]=this._events[e]||[];var a="object"==typeof t;return this._events[e].unshift(a?t:{listener:t,once:!1}),this}prependOnce(e,t){return this.prepend(e,{listener:t,once:!0})}once(e,t){return this.on(e,{listener:t,once:!0})}off(e,t){var a=this._events[e];if(!a)return!1;if("number"==typeof t)a.splice(t,1);else if("function"==typeof t)for(var r=0,i=a.length;r0&&this.cacheEvents.forEach(function(a){a.type===e&&t.call(null,a.data)})}emit(e,t){super.emit.apply(this,arguments),this.cacheEvents.push({type:e,data:t}),this.cacheEvents.length>this.maxLen&&this.cacheEvents.shift()}}var _=Object.freeze({__proto__:null,decodeURIComponent:decodeURIComponent$1,encodeDates:encodeDates,formatDate:formatDate,searchObjDate:searchObjDate,formatString:formatString,searchObjString:searchObjString,parseSuperProperties:parseSuperProperties,unique:unique,check:check,getUtmFromPage:getUtmFromPage,setQuery:setQuery,setLatestShare:setLatestShare,setLatestChannel:setLatestChannel,setUpperCase:setUpperCase,compareSDKVersion:compareSDKVersion,validId:validId,wxrequest:wxrequest,getPageTitle:getPageTitle,setPageRefData:setPageRefData,getCurrentPageInfo:getCurrentPageInfo,getRefPage:getRefPage,setRefPage:setRefPage,setPageSfSource:setPageSfSource,setSfSource:setSfSource,setUtm:setUtm,getMixedQuery:getMixedQuery,detectOptionQuery:detectOptionQuery,getShareInfo:getShareInfo,setShareInfo:setShareInfo,shareInfoData:shareInfoData,delObjectKey:delObjectKey,objToParam:objToParam,getMPScene:getMPScene,getStorageSync:getStorageSync,setStorageSync:setStorageSync,getObjFromQuery:getObjFromQuery,getCustomUtmFromQuery:getCustomUtmFromQuery,getPath:getPath,getCurrentUrl:getCurrentUrl,getIsFirstDay:getIsFirstDay,getCurrentPath:getCurrentPath,getCurrentPage:getCurrentPage,urlBase64Encode:urlBase64Encode,btoa:btoa,base64Encode:base64Encode,strip_empty_properties:strip_empty_properties,strip_sa_properties:strip_sa_properties,setNavigationBarTitle:setNavigationBarTitle,networkStatusChange:networkStatusChange,getNetworkType:getNetworkType,getSystemInfo:getSystemInfo,encodeTrackData:encodeTrackData,initAppGlobalName:initAppGlobalName,getPublicPresetProperties:getPublicPresetProperties,setPublicProperties:setPublicProperties,isPresetIdKeys:isPresetIdKeys,isNewLoginId:isNewLoginId,isSameAndAnonymousID:isSameAndAnonymousID,info:info,logger:logger,getAppId:getAppId,getAppInfoSync:getAppInfoSync,getOpenidNameByAppid:getOpenidNameByAppid,rot13defs:rot13defs,rot13obfs:rot13obfs,each:each,isObject:isObject,getRandom:getRandom,extend:extend,extend2Lev:extend2Lev,coverExtend:coverExtend,isArray:isArray,isFunction:isFunction,isArguments:isArguments,toArray:toArray,values:values,include:include,trim:trim,isEmptyObject:isEmptyObject,deepCopy:deepCopy,isUndefined:isUndefined,isString:isString,isDate:isDate,isBoolean:isBoolean,isNumber:isNumber,isJSONString:isJSONString,isInteger:isInteger,isSafeInteger:isSafeInteger,slice:slice,urlSafeBase64:urlSafeBase64,EventEmitterBase:EventEmitterBase,EventEmitterEx:EventEmitterEx,log:log});function onEventSend(){return{}}function processData(e){return e}function batchTrackData(e){var t=Date.now();return e.forEach(function(e){e._flush_time=t}),"data_list="+encodeTrackData(e)}var mergeStorageData={getData:function(e){wx.getStorage({key:saPara.storage_prepare_data_key,complete:function(t){var a=t.data&&isArray(t.data)?t.data:[];mergeStorageData.deleteAesData(a),e&&e()}})},deleteAesData:function(e){var t=[],a=e.length;if(a>0){for(var r=0;r=saPara.batch_send.max_length&&this.batchSend()},wxrequest:function(e){if(isArray(e.data)&&e.data.length>0){var t=kit.batchTrackData(e.data);sa._.wxrequest({url:saPara.server_url,method:"POST",dataType:"text",data:t,header:{"content-type":"text/plain"},success:function(){e.success(e.len)},fail:function(){e.fail()}})}else e.success(e.len)},batchSend:function(){if(this.dataHasSend){var e,t,a=store.mem.mdata;(t=(e=a.length>=100?a.slice(0,100):a).length)>0&&(this.dataHasSend=!1,this.wxrequest({data:e,len:t,success:this.batchRemove.bind(this),fail:this.sendFail.bind(this)}))}},sendFail:function(){this.dataHasSend=!0,this.failTime++},batchRemove:function(e){store.mem.clear(e),this.dataHasSend=!0,this.dataHasChange=!0,this.batchWrite(),this.failTime=0},is_first_batch_write:!0,batchWrite:function(){this.dataHasChange&&(this.dataHasChange=!1,this.syncStorage&&sa._.setStorageSync(saPara.storage_prepare_data_key,store.mem.mdata))},batchInterval:function(){var e=this;!function t(){setTimeout(function(){e.batchWrite(),t()},500)}(),function t(){setTimeout(function(){e.batchSend(),t()},saPara.batch_send.send_timeout*Math.pow(2,e.failTime))}()}};function onceSend(e){e._flush_time=Date.now();var t=kit.onceTrackData(e),a=saPara.server_url+"?"+t;-1!==saPara.server_url.indexOf("?")&&(a=saPara.server_url+"&"+t),wxrequest({url:a,method:"GET"})}function buildData(e,t){var a={distinct_id:sa.store.getDistinctId(),identities:sa.store._state.identities,lib:{$lib:LIB_NAME,$lib_method:"code",$lib_version:LIB_VERSION},properties:{}};return"track_id_unbind"===e.type&&"$UnbindID"===e.event&&(a.identities=deepCopy(e.unbind_value),delete e.unbind_value),isObject(t)||(t={}),extend(a,sa.store.getUnionId(),e),isObject(e.properties)&&!isEmptyObject(e.properties)&&extend(a.properties,e.properties),e.type&&"profile"===e.type.slice(0,7)||(a._track_id=Number(String(getRandom()).slice(2,5)+String(getRandom()).slice(2,4)+String(Date.now()).slice(-4)),a.properties=extend({},getPublicPresetProperties(),meta.preset_properties,sa.store.getProps(),t,a.properties),"track"===e.type&&(a.properties.$is_first_day=getIsFirstDay())),a.properties.$time&&isDate(a.properties.$time)?(a.time=1*a.properties.$time,delete a.properties.$time):a.time=1*new Date,sa.ee.sdk.emit("createData",a),sa.ee.sdk.emit("beforeBuildCheck",a),sa.ee.data.emit("beforeBuildCheck",a),parseSuperProperties(a.properties),searchObjDate(a),strip_sa_properties(a.properties),searchObjString(a),sa.ee.data.emit("finalAdjustData",a),a}function dataStage(e){if(!saPara.server_url)return!1;if(meta.current_scene&&1154===meta.current_scene&&!sa.para.preset_events.moments_page)return!1;var t=sa._.deepCopy(e),a=buildData(e,kit.onEventSend(t));a?(log(a),sa.events.emit("send",a),sa.para.batch_send?sendStrategy.send(a):onceSend(a)):log("error: \u6570\u636e\u5f02\u5e38 "+a)}sa.popupEmitter={attached:function(){return!1}};var usePlugin=function(e,t){if(!isObject(e)&&!isFunction(e))return log("plugin must be an object",e),!1;if(isFunction(e.init)||log("plugin maybe missing init method",e.plugin_name||e),isString(e.plugin_name)&&e.plugin_name?sa.modules[e.plugin_name]?e=sa.modules[e.plugin_name]:sa.modules[e.plugin_name]=e:log("plugin_name is not defined - ",e.plugin_name||e),isObject(e)&&!0===e.plugin_is_init)return e;if(isObject(e)&&e.plugin_name&&(isString(e.plugin_version)&&e.plugin_version===LIB_VERSION||log("warning!"+e.plugin_name+" plugin version do not match SDK version \uff01\uff01\uff01")),meta.init_status)"function"==typeof e.init&&(e.init(sa,t),e.plugin_is_init=!0,log(e.plugin_name+" plugin is initialized"));else{var a={target:e,para:t};meta.plugin.uninitialized_list.push(a)}return e},checkPluginInitStatus=function(){if(meta.plugin.uninitialized_list.length>0){for(var e in meta.plugin.uninitialized_list){var t=meta.plugin.uninitialized_list[e];t&&t.target&&"function"==typeof t.target.init&&!t.target.plugin_is_init&&(t.target.init(sa,t.para),isObject(t.target)&&(t.target.plugin_is_init=!0,isString(t.target.plugin_name)&&t.target.plugin_name&&log(t.target.plugin_name+" plugin is initialized")))}meta.plugin.uninitialized_list=[]}};function initAppShowHide(){wx.onAppShow(function(e){if(!meta.life_state.app_launched){var t=wx.getLaunchOptionsSync()||{};sa.autoTrackCustom.appLaunch(t)}sa.autoTrackCustom.appShow(e)}),wx.onAppHide(function(){sa.autoTrackCustom.appHide()})}function checkAppLaunch(){if(!meta.life_state.app_launched){var e=wx.getLaunchOptionsSync()||{};sa.autoTrackCustom.appLaunch(e)}}function mpProxy(e,t,a){var r=sa.autoTrackCustom[a];if(e[t]){var i=e[t];e[t]=function(){!sa.para.autoTrackIsFirst||isObject(sa.para.autoTrackIsFirst)&&!sa.para.autoTrackIsFirst[a]?(i.apply(this,arguments),r.apply(this,arguments)):(!0===sa.para.autoTrackIsFirst||isObject(sa.para.autoTrackIsFirst)&&sa.para.autoTrackIsFirst[a])&&(r.apply(this,arguments),i.apply(this,arguments)),sa.ee.page.emit(a)}}else e[t]=function(){r.apply(this,arguments),sa.ee.page.emit(a)}}function clickTrack(e){var t,a={},r={},i=e.currentTarget||{},n=e.target||{};if(isObject(sa.para.framework)&&isObject(sa.para.framework.taro)&&!sa.para.framework.taro.createApp&&n.id&&i.id&&n.id!==i.id)return!1;var s=i.dataset||{};if(t=e.type,a.$element_id=i.id,a.$element_type=s.type,a.$element_content=s.content,a.$element_name=s.name,isObject(e.event_prop)&&(r=e.event_prop),t&&isClick(t)){if(sa.para.preset_events&&sa.para.preset_events.collect_element&&!1===sa.para.preset_events.collect_element(arguments[0]))return!1;a.$url_path=sa._.getCurrentPath(),sa._.setPageRefData(a),a=sa._.extend(a,r),sa.track("$MPClick",a)}}function clickProxy(e,t){var a=e[t];e[t]=function(){var e=a.apply(this,arguments),t=arguments[0];return isObject(t)&&(sa.para.preset_events.defer_track?setTimeout(function(){clickTrack(t)},0):clickTrack(t)),e}}function isClick(e){return!!{tap:1,longpress:1,longtap:1}[e]}function tabProxy(e){var t=e.onTabItemTap;e.onTabItemTap=function(e){t&&t.apply(this,arguments);var a={};e&&(a.$element_content=e.text),a.$element_type="tabBar",a.$url_path=sa._.getCurrentPath(),sa._.setPageRefData(a),sa.track("$MPClick",a)}}function getMethods(e){var t=MP_FILTER_HOOK,a=[];for(var r in e)"function"!=typeof e[r]||t[r]||a.push(r);return a}function initPageProxy(){var e=Page;Page=function(t){try{t||(t={}),monitorClick(t),monitorHooks(t),e.apply(this,arguments)}catch(t){e.apply(this,arguments)}};var t=Component;Component=function(e){try{e||(e={}),e.methods||(e.methods={}),monitorClick(e.methods),monitorHooks(e.methods),t.apply(this,arguments)}catch(e){t.apply(this,arguments)}}}function monitorClick(e){var t=[];if(sa.para.autoTrack&&sa.para.autoTrack.mpClick){t=getMethods(e),tabProxy(e);for(var a=t.length,r=0;r100)log("Key ["+e+"] is invalid");else if(!check.checkKeyword(e))return log("Key ["+e+"] is invalid"),!1;if(isPresetIdKeys(e,["$mp_openid","$identity_mp_openid","$identity_mp_unionid","$mp_unionid","$mp_id","$identity_mp_id"]))return log("Key ["+e+"] is invalid"),!1;if(!(t=validId(t)))return!1;if(isSameAndAnonymousID(t))return!1;var a=store.getFirstId(),r=store.getDistinctId();isNewLoginId(e,t)&&(store._state.identities[e]=t,store.set("history_login_id",{name:e,value:t}),a||store.set("first_id",r),sa.trackSignup({id:t,event_name:"$SignUp",id_name:e}),store.identitiesSet({type:"login",id:t,id_name:e}))}function getAnonymousID(){if(!isEmptyObject(store._state))return store._state._first_id||store._state.first_id||store._state._distinct_id||store._state.distinct_id;log("\u8bf7\u5148\u521d\u59cb\u5316SDK")}function getIdentities(){return isEmptyObject(store._state)?(log("\u8bf7\u5148\u521d\u59cb\u5316SDK"),null):store._state.identities||null}function logout(e){var t=store.getFirstId();store.identitiesSet({type:"logout"}),store.set("history_login_id",{name:"",value:""}),t?(store.set("first_id",""),!0===e?store.set("distinct_id",store.getUUID()):store.set("distinct_id",t)):log("\u6ca1\u6709first_id\uff0clogout\u5931\u8d25")}function getPresetProperties(){if(meta.preset_properties&&meta.preset_properties.$lib){var e={};each(meta.preset_properties,function(t,a){0===a.indexOf("$")&&(e[a]=t)});var t={$url_path:getCurrentPath(),$is_first_day:getIsFirstDay(),$is_first_time:meta.is_first_launch},a=extend(e,t,meta.preset_properties,store.getProps());return delete a.$lib,a}return{}}function setOpenid(e,t){if(!(e=validId(e)))return!1;if(!checkPrivacyStatus())return!1;if(!meta.init_status)return store.store_queue.push({method:"setOpenid",params:arguments}),!1;log("\u8be5\u65b9\u6cd5\u5df2\u4e0d\u5efa\u8bae\u4f7f\u7528\uff0c\u5982\u679c\u662f id2 \u7528\u6237\uff0c\u8bf7\u4f7f\u7528 identify \u4ee3\u66ff\uff0c\u5982\u679c\u662f id3 \u7528\u6237\uff0c\u8bf7\u4f7f\u7528 bindOpenid \u4ee3\u66ff"),t&&log("%c \u5f53\u524d\u7248\u672c setOpenid \u63a5\u53e3 \u5df2\u4e0d\u652f\u6301\u4f20\u5165\u7b2c\u4e8c\u4e2a\u53c2\u6570","color:#F39C12;font-size: 14px;"),store.set("openid",e),sa.identify(e,!0);var a=getOpenidNameByAppid();store._state.identities[a]=e,store.save()}function unsetOpenid(e){log("\u8be5\u65b9\u6cd5\u5df2\u4e0d\u5efa\u8bae\u4f7f\u7528\uff0c\u5982\u679c\u662f id3 \u7528\u6237\uff0c\u8bf7\u4f7f\u7528 unbindOpenid \u4ee3\u66ff");var t=validId(e);if(!t)return!1;var a=store._state.openid;a===t&&store.set("openid","");var r=getOpenidNameByAppid();if(hasOwnProperty$3.call(store._state.identities,r)&&t===store._state.identities[r]){delete store._state.identities[r];var i=store.getFirstId(),n=store.getDistinctId(),s=store._state&&store._state.identities&&store._state.identities.$identity_mp_id;i&&i===a&&s&&store.change("first_id",s),n&&n===a&&s&&store.change("distinct_id",s),store.save()}}function bindOpenid(e){if(!(e=validId(e)))return!1;var t=getOpenidNameByAppid();this.bind(t,e)}function unbindOpenid(e){if(!validId(e))return!1;var t=getOpenidNameByAppid();this.unbind(t,e)}function setUnionid(e){var t=validId(e);t&&bind("$identity_mp_unionid",t)}function unsetUnionid(e){var t=validId(e);if(t){if(hasOwnProperty$3.call(store._state.identities,"$identity_mp_unionid")&&t===store._state.identities.$identity_mp_unionid){var a=getOpenidNameByAppid();hasOwnProperty$3.call(store._state.identities,a)&&(delete store._state.identities[a],delete store._state.openid,store.save())}unbind("$identity_mp_unionid",t)}}function initWithOpenid(e,t){(e=e||{}).appid&&(saPara.appid=e.appid),sa.openid.getOpenid(function(a){a&&sa.setOpenid(a,e.isCoverLogin),t&&isFunction(t)&&t(a),sa.init(e)})}function bind(e,t){if(isNumber(t)){if(isInteger(t)&&!1===isSafeInteger(t))return log("Value must be String"),!1;t=String(t)}if(!isString(e))return log("Key must be String"),!1;var a=store.getHistoryLoginId(),r=a?a.name:"";return!check.checkKeyword(e)||isPresetIdKeys(e,[IDENTITY_KEY.LOGIN,r,"$mp_id","$identity_mp_id"])?(log("Key ["+e+"] is invalid"),!1):t&&""!==t?isString(t)?!!check.checkIdLength(t)&&(store._state.identities[e]=t,store.save(),void dataStage({type:"track_id_bind",event:"$BindID"})):(log("Value must be String"),!1):(log("Value is empty or null"),!1)}function unbind(e,t){if(isNumber(t)){if(isInteger(t)&&!1===isSafeInteger(t))return log("Value must be String"),!1;t=String(t)}if(!isString(e))return log("Key must be String"),!1;if(!sa._.check.checkKeyword(e)||isPresetIdKeys(e,[IDENTITY_KEY.LOGIN]))return log("Key ["+e+"] is invalid"),!1;if(!t||""===t)return log("Value is empty or null"),!1;if(!isString(t))return log("Value must be String"),!1;if(!sa._.check.checkIdLength(t))return!1;hasOwnProperty$3.call(store._state.identities,e)&&t===store._state.identities[e]&&("$mp_id"!==e&&"$identity_mp_id"!==e&&delete store._state.identities[e],store.save());var a=store.getDistinctId(),r=store.getFirstId();a===e+"+"+t&&(store.set("first_id",""),store.set("distinct_id",r),store.set("history_login_id",{name:"",value:""}));var i={};i[e]=t,dataStage({type:"track_id_unbind",event:"$UnbindID",unbind_value:i})}function setWebViewUrl(e,t){if(log("setWebViewUrl \u65b9\u6cd5\u5df2\u4ece 2022-9-23 \u5f00\u59cb\u5e9f\u5f03\uff0c\u8bf7\u5c3d\u5feb\u53bb\u9664\u8be5 API \u7684\u8c03\u7528\uff0c\u5e76\u4f7f\u7528 use \u63d2\u4ef6 \u4ee3\u66ff"),!isString(e)||""===e)return log("error:\u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;if(!/^http(s)?:\/\//.test(e))return log("warning: \u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;var a=/([^?#]+)(\?[^#]*)?(#.*)?/.exec(e);if(!a)return!1;var r,i=a[1]||"",n=a[2]||"",s=a[3]||"",o="",u=store.getDistinctId()||"",c=store.getFirstId()||"";urlSafeBase64&&urlSafeBase64.encode?u=u?urlSafeBase64.trim(urlSafeBase64.encode(urlBase64Encode(u))):"":rot13obfs&&(u=u?rot13obfs(u):""),u=encodeURIComponent(u);var p=c?"f"+u:"d"+u;t?(r=s.indexOf("_sasdk"),o=s.indexOf("?")>-1?r>-1?i+n+"#"+s.substring(1,r)+"_sasdk="+p:i+n+"#"+s.substring(1)+"&_sasdk="+p:i+n+"#"+s.substring(1)+"?_sasdk="+p):(r=n.indexOf("_sasdk"),o=/^\?(\w)+/.test(n)?r>-1?i+n.replace(/(_sasdk=)([^&]*)/gi,"_sasdk="+p)+s:i+"?"+n.substring(1)+"&_sasdk="+p+s:i+"?"+n.substring(1)+"_sasdk="+p+s);return o}function quick(){var e=arguments[0],t=arguments[1],a=arguments[2],r=isObject(a)?a:{};if("getAnonymousID"===e){if(!isEmptyObject(store._state))return store._state._first_id||store._state.first_id||store._state._distinct_id||store._state.distinct_id;log("\u8bf7\u5148\u521d\u59cb\u5316SDK")}else"appLaunch"===e||"appShow"===e?t?sa.autoTrackCustom[e](t,r):log("App\u7684launch\u548cshow\uff0c\u5728sensors.quick\u7b2c\u4e8c\u4e2a\u53c2\u6570\u5fc5\u987b\u4f20\u5165App\u7684options\u53c2\u6570"):"appHide"===e&&(r=isObject(t)?t:{},sa.autoTrackCustom[e](r))}function appLaunch(e,t){var a={};e&&e.scene?(meta.current_scene=e.scene,a.$scene=getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,delObjectKey(e.query)),e&&e.path&&(a.$url_path=getPath(e.path),a.$title=getPageTitle(e.path)),setShareInfo(e,a);var r=setUtm(e,a);meta.is_first_launch?(a.$is_first_time=!0,isEmptyObject(r.pre1)||sa.setOnceProfile(r.pre1)):a.$is_first_time=!1,setLatestChannel(r.pre2),setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=setQuery(e.query),a.$url=e.path+(a.$url_query?"?"+a.$url_query:""),setPageRefData(t),isObject(t)&&(a=extend(a,t)),sa.track("$MPLaunch",a)}function appShow(e,t){var a={};meta.mp_show_time=(new Date).getTime(),e&&e.scene?(meta.current_scene=e.scene,a.$scene=getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,delObjectKey(e.query)),e&&e.path&&(a.$url_path=getPath(e.path),a.$title=getPageTitle(e.path)),setShareInfo(e,a),setLatestChannel(setUtm(e,a).pre2),setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=setQuery(e.query),e&&e.path&&(a.$url=e.path+(a.$url_query?"?"+a.$url_query:"")),setPageRefData(a,e.path,a.$url_query),isObject(t)&&(a=extend(a,t)),sa.track("$MPShow",a)}function appHide(e){var t=(new Date).getTime(),a={};a.$url_path=getCurrentPath(),meta.mp_show_time&&t-meta.mp_show_time>0&&(t-meta.mp_show_time)/36e5<24&&(a.event_duration=(t-meta.mp_show_time)/1e3),setPageRefData(a),isObject(e)&&(a=extend(a,e)),sa.track("$MPHide",a),sa.sendStrategy.onAppHide()}function pageShow(e){var t={},a=getCurrentPath(),r=getPageTitle(a),i=getCurrentPage();setRefPage(),r&&(t.$title=r),t.$url_path=a,t.$url_query=i.sensors_mp_url_query?i.sensors_mp_url_query:"",setPageSfSource(t=extend(t,getUtmFromPage())),setPageRefData(t),isObject(e)&&(t=extend(t,e)),sa.track("$MPViewScreen",t)}function setPara(e){sa.para=extend2Lev(saPara,e);var t=[];if(isArray(saPara.source_channel))for(var a=saPara.source_channel.length,r=0;r0&&(t-meta.mp_show_time)/36e5<24&&(a.event_duration=(t-meta.mp_show_time)/1e3),setPageRefData(a),e?(a=extend(a,e),sa.track("$MPHide",a)):saPara.autoTrack&&saPara.autoTrack.appHide&&sa.autoTrackCustom.trackCustom("appHide",a,"$MPHide")},pageLoad:function(e){meta.current_scene&&1010===meta.current_scene&&e&&(e.sampshare&&delete e.sampshare,delObjectKey(e)),e&&isObject(e)&&(this.sensors_mp_url_query=setQuery(e),this.sensors_mp_encode_url_query=setQuery(e,!0))},pageShow:function(){meta.page_show_time=Date.now();var e={},t=getCurrentPath(),a=getPageTitle(t);setRefPage(),e.$url_path=t,e.$url_query=this.sensors_mp_url_query?this.sensors_mp_url_query:"",setPageRefData(e=extend(e,getUtmFromPage())),setPageSfSource(e),a&&(e.$title=a),saPara.onshow?saPara.onshow(sa,t,this):-1===saPara.autotrack_exclude_page.pageShow.indexOf(t)&&sa.autoTrackCustom.trackCustom("pageShow",e,"$MPViewScreen")},pageShare:function(e){var t=e.onShareAppMessage;e.onShareAppMessage=function(){var e=this;meta.share_method="\u8f6c\u53d1\u6d88\u606f\u5361\u7247";var a,r=t.apply(this,arguments);if(saPara.autoTrack&&saPara.autoTrack.pageShare){var i={$url_path:getCurrentPath(),$share_depth:meta.query_share_depth,$share_method:meta.share_method};setPageRefData(i),sa.autoTrackCustom.trackCustom("pageShare",i,"$MPShare")}function n(t){return isObject(t)||(t={}),(isUndefined(t.path)||""===t.path)&&(t.path=getCurrentUrl(e)),isString(t.path)&&(-1===t.path.indexOf("?")?t.path=t.path+"?":"&"!==t.path.slice(-1)&&(t.path=t.path+"&")),t.path=t.path+getShareInfo(),t}if(sa.para.allow_amend_share_path&&isObject(r=n(r)))for(var s in r)if((a=r[s])&&isFunction(a.then)&&isFunction(a.catch))try{r[s]=r[s].then(function(e){return n(e)})}catch(e){log("onShareAppMessage: "+e)}return r}},pageShareTimeline:function(e){var t=e.onShareTimeline;e.onShareTimeline=function(){meta.share_method="\u670b\u53cb\u5708\u5206\u4eab";var e=t.apply(this,arguments);if(saPara.autoTrack&&saPara.autoTrack.pageShare){var a={$url_path:getCurrentPath(),$share_depth:meta.query_share_depth,$share_method:meta.share_method};setPageRefData(a),sa.autoTrackCustom.trackCustom("pageShare",a,"$MPShare")}return saPara.allow_amend_share_path&&("object"!=typeof e&&(e={}),"object"==typeof e&&void 0===e.query&&(e.query=""),"object"==typeof e&&"string"==typeof e.query&&""!==e.query&&"&"!==e.query.slice(-1)&&(e.query=e.query+"&"),e.query=e.query+getShareInfo()),e}},pageAddFavorites:function(){var e={};e.$url_path=getCurrentPath(),saPara.autoTrack&&saPara.autoTrack.mpFavorite&&sa.autoTrackCustom.trackCustom("mpFavorite",e,"$MPAddFavorites")},pageHide:function(){sa.para.autoTrack&&sa.para.autoTrack.pageLeave&&sendPageLeave()}};function sendPageLeave(){var e={},t="";try{t=(e=getCurrentPage())?e.route:""}catch(e){log(e)}if(meta.page_show_time>=0&&""!==t){var a={},r=getPageTitle(t),i=(Date.now()-meta.page_show_time)/1e3;(isNaN(i)||i<0)&&(i=0),a.$url_query=e.sensors_mp_url_query?e.sensors_mp_url_query:"",a.$url_path=t,a.$title=r,a.event_duration=i,-1===saPara.autotrack_exclude_page.pageLeave.indexOf(t)&&sa.track("$MPPageLeave",a),meta.page_show_time=-1}}var openid={getRequest:function(e){wx.login({success:function(t){t.code&&saPara.appid&&saPara.openid_url?wxrequest({url:saPara.openid_url+"&code="+t.code+"&appid="+saPara.appid,method:"GET",complete:function(t){isObject(t)&&isObject(t.data)&&t.data.openid?e(t.data.openid):e()}}):e()}})},getWXStorage:function(){var e=store.getStorage();if(e&&isObject(e))return e.openid},getOpenid:function(e){if(!saPara.appid)return e(),!1;var t=this.getWXStorage();t?e(t):this.getRequest(e)}},functions=Object.freeze({__proto__:null,setProfile:setProfile,setOnceProfile:setOnceProfile,appendProfile:appendProfile,incrementProfile:incrementProfile,track:track,identify:identify,trackSignup:trackSignup,login:login,loginWithKey:loginWithKey,getAnonymousID:getAnonymousID,getIdentities:getIdentities,logout:logout,getPresetProperties:getPresetProperties,setOpenid:setOpenid,unsetOpenid:unsetOpenid,bindOpenid:bindOpenid,unbindOpenid:unbindOpenid,setUnionid:setUnionid,unsetUnionid:unsetUnionid,bindUnionid:setUnionid,unbindUnionid:unsetUnionid,initWithOpenid:initWithOpenid,bind:bind,unbind:unbind,setWebViewUrl:setWebViewUrl,quick:quick,appLaunch:appLaunch,appShow:appShow,appHide:appHide,pageShow:pageShow,setPara:setPara,getServerUrl:getServerUrl,sendPageLeave:sendPageLeave,openid:openid,autoTrackCustom:autoTrackCustom,registerApp:registerApp,register:register,clearAllRegister:clearAllRegister,clearAppRegister:clearAppRegister,clearAllProps:clearAllProps});function buildAPI(e){for(var t in functions)e[t]=functions[t]}function setFirstVisitTime(){meta.is_first_launch&&setOnceProfile({$first_visit_time:new Date})}function checkIsComplete(){meta.initialState.isComplete=!0,meta.initialState.queue.length>0&&(each(meta.initialState.queue,function(e){"appLaunch"===e[0]?sa.autoTrackCustom.appLaunch.apply(sa.autoTrackCustom,slice.call(e[1])):sa[e[0]].apply(sa,slice.call(e[1]))}),meta.initialState.queue=[])}function init(e){if(!0===meta.init_status)return!1;function t(){checkIsComplete(),checkAppLaunch(),sa.ee.sdk.emit("ready")}meta.init_status=!0,sa.ee.sdk.emit("beforeInit"),e&&isObject(e)&&sa.setPara(e),sa.ee.sdk.emit("initPara"),sa.ee.sdk.emit("afterInitPara"),sa.store.init(),sa.checkPluginInitStatus(),setFirstVisitTime(),sa.para.batch_send&&sa.sendStrategy.init();var a=[getNetworkType(),getSystemInfo()].concat(meta.promise_list);Promise.all(a).then(()=>{t()}).catch(()=>{t()})}function registerPropertyPlugin(e){isFunction(e.properties)?!e.isMatchedWithFilter||isFunction(e.isMatchedWithFilter)?sa.ee.data.on("finalAdjustData",function(t){try{isFunction(e.isMatchedWithFilter)?e.isMatchedWithFilter(t)&&e.properties(t):e.properties(t)}catch(e){log("execute registerPropertyPlugin callback error:"+e)}}):log("registerPropertyPlugin arguments error, isMatchedWithFilter must be function"):log("registerPropertyPlugin arguments error, properties must be function")}sa._=_,sa.modules={},sa.meta=meta,sa.kit=kit,sa.mergeStorageData=mergeStorageData,sa.dataStage=dataStage,sa.sendStrategy=sendStrategy,sa.store=store,sa.usePlugin=usePlugin,sa.checkPluginInitStatus=checkPluginInitStatus,sa.eventSub=eventSub,sa.events=new eventEmitter,sa.ee=ee,sa.registerPropertyPlugin=registerPropertyPlugin,sa.enableDataCollect=enableDataCollect,sa.initialState=meta.initialState,sa.IDENTITY_KEY={EMAIL:IDENTITY_KEY.EMAIL,MOBILE:IDENTITY_KEY.MOBILE},buildAPI(sa),apiStaging(),setNavigationBarTitle(),networkStatusChange(),initAppGlobalName(),initAppShowHide(),initPageProxy(),sa.init=init;var base={plugin_version:"1.19.11"};function createPlugin(e){if("object"==typeof e&&"string"==typeof e.plugin_name&&""!==e.plugin_name)return e.plugin_version=base.plugin_version,e.log=e.log||function(){"object"==typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)},e;"object"==typeof console&&"function"==typeof console.error&&console.error('plugin must contain proprerty "plugin_name"')}var disableSDK={init(e){e.disableSDK=this.disableSDK.bind(this),e.enableSDK=this.enableSDK.bind(this),e.getDisabled=this.getDisabled.bind(this)},plugin_name:"DisableSDK",disabled:!1,disableSDK(){this.disabled=!0},enableSDK(){this.disabled=!1},getDisabled(){return this.disabled}},DisableSDK=createPlugin(disableSDK);sa.usePlugin(DisableSDK),module.exports=sa; \ No newline at end of file +"use strict";var sa={},saPara={name:"sensors",server_url:"",send_timeout:1e3,show_log:!1,login_id_key:"$identity_login_id",allow_amend_share_path:!0,max_string_length:500,datasend_timeout:3e3,source_channel:[],autoTrack:{appLaunch:!0,appShow:!0,appHide:!0,pageShow:!0,pageShare:!0,mpClick:!1,mpFavorite:!0,pageLeave:!1},autotrack_exclude_page:{pageShow:[],pageLeave:[]},is_persistent_save:{share:!1,utm:!1},preset_properties:{url_path:!0},preset_events:{moments_page:!1,defer_track:!1,share_info_use_string:!1},batch_send:!0,storage_store_key:"sensorsdata2015_wechat",storage_prepare_data_key:"sensors_mp_prepare_data"};function log(){if(saPara.show_log&&"object"==typeof console&&console.log)try{return console.log.apply(console,arguments)}catch(e){console.log(arguments[0])}}var nativeIsArray=Array.isArray,ObjProto=Object.prototype,ArrayProto=Array.prototype,nativeForEach=ArrayProto.forEach,nativeIndexOf=ArrayProto.indexOf,toString=ObjProto.toString,hasOwnProperty=ObjProto.hasOwnProperty,slice=ArrayProto.slice;function each(e,t,a){if(null==e)return!1;var r={};if(nativeForEach&&e.forEach===nativeForEach)e.forEach(t,a);else if(e.length===+e.length){for(var i=0,n=e.length;i0&&each(this.store_queue,function(e){sa[e.method].apply(sa,slice.call(e.params))}),this.store_queue=[])}};function _decodeURIComponent(e){var t="";try{t=decodeURIComponent(e)}catch(a){t=e}return t}var hasOwnProperty$2=Object.prototype.hasOwnProperty,decodeURIComponent$1=_decodeURIComponent;function initAppGlobalName(){var e=App;App=function(t){t[saPara.name]=sa,e.apply(this,arguments)}}function getPublicPresetProperties(){var e=getRefPage(),t=getCurrentPageInfo(),a={$referrer:e.route,$referrer_title:e.title,$title:t.title,$url:t.url};return!0===saPara.preset_properties.url_path&&(a.$url_path=t.path),a}function encodeDates(e){return each(e,function(t,a){isDate(t)?e[a]=formatDate(t):isObject(t)&&(e[a]=encodeDates(t))}),e}function formatDate(e){function t(e){return e<10?"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())}function searchObjDate(e){(isObject(e)||isArray(e))&&each(e,function(t,a){isObject(t)||isArray(t)?searchObjDate(e[a]):isDate(t)&&(e[a]=formatDate(t))})}function formatString(e){return e.length>saPara.max_string_length?(log("\u5b57\u7b26\u4e32\u957f\u5ea6\u8d85\u8fc7\u9650\u5236\uff0c\u5df2\u7ecf\u505a\u622a\u53d6--"+e),e.slice(0,saPara.max_string_length)):e}function searchObjString(e){isObject(e)&&each(e,function(t,a){isObject(t)?searchObjString(e[a]):isString(t)&&(e[a]=formatString(t))})}function parseSuperProperties(e){isObject(e)&&each(e,function(t,a){if(isFunction(t))try{e[a]=t(),isFunction(e[a])&&(log("\u60a8\u7684\u5c5e\u6027- "+a+" \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[a])}catch(t){delete e[a],log("\u60a8\u7684\u5c5e\u6027- "+a+" \u629b\u51fa\u4e86\u5f02\u5e38\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}})}function unique(e){for(var t,a=[],r={},i=0;i255)||(log("id \u957f\u5ea6\u8d85\u8fc7 255 \u4e2a\u5b57\u7b26\uff01"),!1)}};function strip_sa_properties(e){return isObject(e)?(each(e,function(t,a){if(isArray(t)){var r=[];each(t,function(e){if(isString(e))r.push(e);else if(isUndefined(e))r.push("null");else try{r.push(JSON.stringify(e))}catch(e){log("\u60a8\u7684\u6570\u636e - "+a+":"+t+" - \u7684\u6570\u7ec4\u91cc\u7684\u503c\u6709\u9519\u8bef,\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}}),e[a]=r}if(isObject(t))try{e[a]=JSON.stringify(t)}catch(r){delete e[a],log("\u60a8\u7684\u6570\u636e - "+a+":"+t+" - \u7684\u6570\u636e\u503c\u6709\u9519\u8bef,\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}else isString(t)||isNumber(t)||isDate(t)||isBoolean(t)||isArray(t)||(log("\u60a8\u7684\u6570\u636e - "+a+":"+t+" - \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[a])}),e):e}function strip_empty_properties(e){var t={};return each(e,function(e,a){null==e&&void 0===e||(t[a]=e)}),t}function utf8Encode(e){var t,a,r,i,n="";for(t=a=0,r=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,i=0;i127&&s<2048?String.fromCharCode(s>>6|192,63&s|128):String.fromCharCode(s>>12|224,s>>6&63|128,63&s|128),null!==o&&(a>t&&(n+=e.substring(t,a)),n+=o,t=a=i+1)}return a>t&&(n+=e.substring(t,e.length)),n}function base64Encode(e){var t,a,r,i,n,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,u=0,c="",p=[];if(!e)return e;e=utf8Encode(e);do{t=(n=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>18&63,a=n>>12&63,r=n>>6&63,i=63&n,p[u++]=s.charAt(t)+s.charAt(a)+s.charAt(r)+s.charAt(i)}while(o255||(r=e.charCodeAt(o++))>255||(i=e.charCodeAt(o++))>255)&&log("Failed to execute 'btoa' : The string to be encoded contains characters outside of the Latin1 range."),s+=n.charAt((t=a<<16|r<<8|i)>>18&63)+n.charAt(t>>12&63)+n.charAt(t>>6&63)+n.charAt(63&t);return u?s.slice(0,u-3)+"===".substring(u):s}function urlBase64Encode(e){return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}))}function getCurrentPage(){var e={};try{var t=getCurrentPages();e=t[t.length-1]}catch(e){log(e)}return e}function getCurrentPath(){var e="\u672a\u53d6\u5230";try{var t=getCurrentPage();e=t?t.route:e}catch(e){log(e)}return e}function getIsFirstDay(){return!!("object"==typeof store._state&&isNumber(store._state.first_visit_day_time)&&store._state.first_visit_day_time>(new Date).getTime())}function getCurrentUrl(e){var t=getCurrentPath(),a="";return isObject(e)&&e.sensors_mp_encode_url_query&&(a=e.sensors_mp_encode_url_query),t?a?t+"?"+a:t:"\u672a\u53d6\u5230"}function getPath(e){return e=isString(e)?e.replace(/^\//,""):"\u53d6\u503c\u5f02\u5e38"}function getCustomUtmFromQuery(e,t,a,r){if(!isObject(e))return{};var i={};if(e.sa_utm)for(var n in e)"sa_utm"!==n?include(saPara.source_channel,n)&&(i[a+n]=e[n]):i[r+n]=e[n];else for(var s in e)-1===(" "+SOURCE_CHANNEL_STANDARD+" ").indexOf(" "+s+" ")?include(saPara.source_channel,s)&&(i[a+s]=e[s]):i[t+s]=e[s];return i}function getObjFromQuery(e){var t=e.split("?"),a=[],r={};return t&&t[1]?(each(t[1].split("&"),function(e){(a=e.split("="))[0]&&a[1]&&(r[a[0]]=a[1])}),r):{}}function setStorageSync(e,t){var a=function(){wx.setStorageSync(e,t)};try{a()}catch(e){log("set Storage fail --",e);try{a()}catch(e){log("set Storage fail again --",e)}}}function getStorageSync(e){var t="";try{t=wx.getStorageSync(e)}catch(e){log("getStorage fail")}return t}function getMPScene(e){return isNumber(e)||isString(e)&&""!==e?e="wx-"+String(e):"\u672a\u53d6\u5230\u503c"}function objToParam(e,t){if(!isObject(e))return log("\u8bf7\u4f20\u5165\u6709\u6548\u5bf9\u8c61"),"";var a=[];for(var r in e)if(hasOwnProperty$2.call(e,r)){var i=e[r];void 0===i?a.push(r+"="):(i=t?encodeURIComponent(i):i,a.push(r+"="+i))}return a.join("&")}function delObjectKey(e){if(isObject(e))for(var t=0;t=2?(meta.page_route_map.shift(),meta.page_route_map.push(e)):meta.page_route_map.push(e)}}catch(e){log(e)}}function getRefPage(){var e={route:"\u76f4\u63a5\u6253\u5f00",path:"\u76f4\u63a5\u6253\u5f00",title:""};return meta.page_route_map.length>1&&(e.title=meta.page_route_map[0].title,e.route=meta.page_route_map[0].route,e.path=meta.page_route_map[0].path),e}function getCurrentPageInfo(){var e=getCurrentPage(),t={title:"",url:"",path:"\u672a\u53d6\u5230"};if(e&&e.route){var a=e.sensors_mp_url_query?"?"+e.sensors_mp_url_query:"";t.title=getPageTitle(e.route),t.url=e.route+a,t.path=e.route}return t}function setPageRefData(e,t,a){var r=getRefPage();isObject(e)&&(t?meta.page_route_map.length>0&&t?(a=a?"?"+a:"",e.$referrer=getPath(t)+a,e.$referrer_title=getPageTitle(t)):(e.$referrer="\u76f4\u63a5\u6253\u5f00",e.$referrer_title=""):(e.$referrer=r.route,e.$referrer_title=r.title))}function getPageTitle(e){if("\u672a\u53d6\u5230"===e||!e)return"";var t="";try{if(__wxConfig){var a=__wxConfig,r=__wxConfig.page||{},i=r[e]||r[e+".html"],n={},s={};if(a.global&&a.global.window&&a.global.window.navigationBarTitleText&&(n.titleVal=a.global.window.navigationBarTitleText),i&&i.window&&i.window.navigationBarTitleText&&(s.titleVal=i.window.navigationBarTitleText),!s.titleVal&&__wxAppCode__){var o=__wxAppCode__[e+".json"];o&&o.navigationBarTitleText&&(s.titleVal=o.navigationBarTitleText)}if(each(meta.global_title,function(a,r){if(r===e)return t=a}),0===t.length){var u=extend(n,s);t=u.titleVal||""}}}catch(e){log(e)}return t}function wxrequest(e){if(compareSDKVersion(meta.wx_sdk_version,"2.10.0")>=0)e.timeout=saPara.datasend_timeout,wx.request(e);else{var t=wx.request(e);setTimeout(function(){isObject(t)&&isFunction(t.abort)&&t.abort()},saPara.datasend_timeout)}}function validId(e){return"string"!=typeof e&&"number"!=typeof e||""===e?(log("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1):"number"!=typeof e||(e=String(e),/^\d+$/.test(e))?!!check.checkIdLength(e)&&e:(log("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1)}function compareSDKVersion(e,t){e=e.split("."),t=t.split(".");for(var a=Math.max(e.length,t.length);e.lengthn)return 1;if(i{wx.getNetworkType({success:function(t){meta.preset_properties.$network_type=setUpperCase(t.networkType),e()},fail:function(e){log("\u83b7\u53d6\u7f51\u7edc\u4fe1\u606f\u5931\u8d25",e),t()}})})}function getSystemInfo(){var e=meta.preset_properties;return new Promise(t=>{wx.getSystemInfo({success:function(a){var r,i;e.$brand=setUpperCase(a.brand),e.$manufacturer=a.brand,e.$model=a.model,e.$screen_width=Number(a.screenWidth),e.$screen_height=Number(a.screenHeight),e.$os=(r=a.platform,"ios"===(i=r.toLowerCase())?"iOS":"android"===i?"Android":r),e.$os_version=a.system.indexOf(" ")>-1?a.system.split(" ")[1]:a.system,meta.wx_sdk_version=a.SDKVersion,e.$mp_client_app_version=a.version,e.$mp_client_basic_library_version=meta.wx_sdk_version;var n=(new Date).getTimezoneOffset(),s=getAppInfoSync();isNumber(n)&&(e.$timezone_offset=n),s.appId&&(e.$app_id=s.appId),s.appVersion&&(e.$app_version=s.appVersion),t()}})})}var info={currentProps:meta.preset_properties},logger={info:function(){if(saPara.show_log&&"object"==typeof console&&console.log)try{if(3===arguments.length)return console.log(arguments[0],arguments[1],arguments[2]);if(2===arguments.length)return console.log(arguments[0],arguments[1]);if(1===arguments.length)return console.log(arguments[0])}catch(e){console.log(arguments[0])}}};function isValidListener(e){return"function"==typeof e||!(!e||"object"!=typeof e)&&isValidListener(e.listener)}class EventEmitterBase{constructor(){this._events={}}on(e,t){if(!e||!t)return!1;if(!isValidListener(t))throw new Error("listener must be a function");this._events[e]=this._events[e]||[];var a="object"==typeof t;return this._events[e].push(a?t:{listener:t,once:!1}),this}prepend(e,t){if(!e||!t)return!1;if(!isValidListener(t))throw new Error("listener must be a function");this._events[e]=this._events[e]||[];var a="object"==typeof t;return this._events[e].unshift(a?t:{listener:t,once:!1}),this}prependOnce(e,t){return this.prepend(e,{listener:t,once:!0})}once(e,t){return this.on(e,{listener:t,once:!0})}off(e,t){var a=this._events[e];if(!a)return!1;if("number"==typeof t)a.splice(t,1);else if("function"==typeof t)for(var r=0,i=a.length;r0&&this.cacheEvents.forEach(function(a){a.type===e&&t.call(null,a.data)})}emit(e,t){super.emit.apply(this,arguments),this.cacheEvents.push({type:e,data:t}),this.cacheEvents.length>this.maxLen&&this.cacheEvents.shift()}}var _=Object.freeze({__proto__:null,decodeURIComponent:decodeURIComponent$1,encodeDates:encodeDates,formatDate:formatDate,searchObjDate:searchObjDate,formatString:formatString,searchObjString:searchObjString,parseSuperProperties:parseSuperProperties,unique:unique,check:check,getUtmFromPage:getUtmFromPage,setQuery:setQuery,setLatestShare:setLatestShare,setLatestChannel:setLatestChannel,setUpperCase:setUpperCase,compareSDKVersion:compareSDKVersion,validId:validId,wxrequest:wxrequest,getPageTitle:getPageTitle,setPageRefData:setPageRefData,getCurrentPageInfo:getCurrentPageInfo,getRefPage:getRefPage,setRefPage:setRefPage,setPageSfSource:setPageSfSource,setSfSource:setSfSource,setUtm:setUtm,getMixedQuery:getMixedQuery,detectOptionQuery:detectOptionQuery,getShareInfo:getShareInfo,setShareInfo:setShareInfo,shareInfoData:shareInfoData,delObjectKey:delObjectKey,objToParam:objToParam,getMPScene:getMPScene,getStorageSync:getStorageSync,setStorageSync:setStorageSync,getObjFromQuery:getObjFromQuery,getCustomUtmFromQuery:getCustomUtmFromQuery,getPath:getPath,getCurrentUrl:getCurrentUrl,getIsFirstDay:getIsFirstDay,getCurrentPath:getCurrentPath,getCurrentPage:getCurrentPage,urlBase64Encode:urlBase64Encode,btoa:btoa,base64Encode:base64Encode,strip_empty_properties:strip_empty_properties,strip_sa_properties:strip_sa_properties,setNavigationBarTitle:setNavigationBarTitle,networkStatusChange:networkStatusChange,getNetworkType:getNetworkType,getSystemInfo:getSystemInfo,encodeTrackData:encodeTrackData,initAppGlobalName:initAppGlobalName,getPublicPresetProperties:getPublicPresetProperties,setPublicProperties:setPublicProperties,isPresetIdKeys:isPresetIdKeys,isNewLoginId:isNewLoginId,isSameAndAnonymousID:isSameAndAnonymousID,info:info,logger:logger,getAppId:getAppId,getAppInfoSync:getAppInfoSync,getOpenidNameByAppid:getOpenidNameByAppid,rot13defs:rot13defs,rot13obfs:rot13obfs,each:each,isObject:isObject,getRandom:getRandom,extend:extend,extend2Lev:extend2Lev,coverExtend:coverExtend,isArray:isArray,isFunction:isFunction,isArguments:isArguments,toArray:toArray,values:values,include:include,trim:trim,isEmptyObject:isEmptyObject,deepCopy:deepCopy,isUndefined:isUndefined,isString:isString,isDate:isDate,isBoolean:isBoolean,isNumber:isNumber,isJSONString:isJSONString,isInteger:isInteger,isSafeInteger:isSafeInteger,slice:slice,urlSafeBase64:urlSafeBase64,EventEmitterBase:EventEmitterBase,EventEmitterEx:EventEmitterEx,log:log});function onEventSend(){return{}}function processData(e){return e}function batchTrackData(e){var t=Date.now();return e.forEach(function(e){e._flush_time=t}),"data_list="+encodeTrackData(e)}var mergeStorageData={getData:function(e){wx.getStorage({key:saPara.storage_prepare_data_key,complete:function(t){var a=t.data&&isArray(t.data)?t.data:[];mergeStorageData.deleteAesData(a),e&&e()}})},deleteAesData:function(e){var t=[],a=e.length;if(a>0){for(var r=0;r=saPara.batch_send.max_length&&this.batchSend()},wxrequest:function(e){if(isArray(e.data)&&e.data.length>0){var t=kit.batchTrackData(e.data);sa._.wxrequest({url:saPara.server_url,method:"POST",dataType:"text",data:t,header:{"content-type":"text/plain"},success:function(){e.success(e.len)},fail:function(){e.fail()}})}else e.success(e.len)},batchSend:function(){if(this.dataHasSend){var e,t,a=store.mem.mdata;(t=(e=a.length>=100?a.slice(0,100):a).length)>0&&(this.dataHasSend=!1,this.wxrequest({data:e,len:t,success:this.batchRemove.bind(this),fail:this.sendFail.bind(this)}))}},sendFail:function(){this.dataHasSend=!0,this.failTime++},batchRemove:function(e){store.mem.clear(e),this.dataHasSend=!0,this.dataHasChange=!0,this.batchWrite(),this.failTime=0},is_first_batch_write:!0,batchWrite:function(){this.dataHasChange&&(this.dataHasChange=!1,this.syncStorage&&sa._.setStorageSync(saPara.storage_prepare_data_key,store.mem.mdata))},batchInterval:function(){var e=this;!function t(){setTimeout(function(){e.batchWrite(),t()},500)}(),function t(){setTimeout(function(){e.batchSend(),t()},saPara.batch_send.send_timeout*Math.pow(2,e.failTime))}()}};function onceSend(e){e._flush_time=Date.now();var t=kit.onceTrackData(e),a=saPara.server_url+"?"+t;-1!==saPara.server_url.indexOf("?")&&(a=saPara.server_url+"&"+t),wxrequest({url:a,method:"GET"})}function buildData(e,t){var a={distinct_id:sa.store.getDistinctId(),identities:sa.store._state.identities,lib:{$lib:LIB_NAME,$lib_method:"code",$lib_version:LIB_VERSION},properties:{}};return"track_id_unbind"===e.type&&"$UnbindID"===e.event&&(a.identities=deepCopy(e.unbind_value),delete e.unbind_value),isObject(t)||(t={}),extend(a,sa.store.getUnionId(),e),isObject(e.properties)&&!isEmptyObject(e.properties)&&extend(a.properties,e.properties),e.type&&"profile"===e.type.slice(0,7)||(a._track_id=Number(String(getRandom()).slice(2,5)+String(getRandom()).slice(2,4)+String(Date.now()).slice(-4)),a.properties=extend({},getPublicPresetProperties(),meta.preset_properties,sa.store.getProps(),t,a.properties),"track"===e.type&&(a.properties.$is_first_day=getIsFirstDay())),a.properties.$time&&isDate(a.properties.$time)?(a.time=1*a.properties.$time,delete a.properties.$time):a.time=1*new Date,sa.ee.sdk.emit("createData",a),sa.ee.sdk.emit("beforeBuildCheck",a),sa.ee.data.emit("beforeBuildCheck",a),parseSuperProperties(a.properties),searchObjDate(a),strip_sa_properties(a.properties),searchObjString(a),sa.ee.data.emit("finalAdjustData",a),a}function dataStage(e){if(!saPara.server_url)return!1;if(meta.current_scene&&1154===meta.current_scene&&!sa.para.preset_events.moments_page)return!1;var t=sa._.deepCopy(e),a=buildData(e,kit.onEventSend(t));a?(log(a),sa.events.emit("send",a),sa.para.batch_send?sendStrategy.send(a):onceSend(a)):log("error: \u6570\u636e\u5f02\u5e38 "+a)}sa.popupEmitter={attached:function(){return!1}};var usePlugin=function(e,t){if(!isObject(e)&&!isFunction(e))return log("plugin must be an object",e),!1;if(isFunction(e.init)||log("plugin maybe missing init method",e.plugin_name||e),isString(e.plugin_name)&&e.plugin_name?sa.modules[e.plugin_name]?e=sa.modules[e.plugin_name]:sa.modules[e.plugin_name]=e:log("plugin_name is not defined - ",e.plugin_name||e),isObject(e)&&!0===e.plugin_is_init)return e;if(isObject(e)&&e.plugin_name&&(isString(e.plugin_version)&&e.plugin_version===LIB_VERSION||log("warning!"+e.plugin_name+" plugin version do not match SDK version \uff01\uff01\uff01")),meta.init_status)"function"==typeof e.init&&(e.init(sa,t),e.plugin_is_init=!0,log(e.plugin_name+" plugin is initialized"));else{var a={target:e,para:t};meta.plugin.uninitialized_list.push(a)}return e},checkPluginInitStatus=function(){if(meta.plugin.uninitialized_list.length>0){for(var e in meta.plugin.uninitialized_list){var t=meta.plugin.uninitialized_list[e];t&&t.target&&"function"==typeof t.target.init&&!t.target.plugin_is_init&&(t.target.init(sa,t.para),isObject(t.target)&&(t.target.plugin_is_init=!0,isString(t.target.plugin_name)&&t.target.plugin_name&&log(t.target.plugin_name+" plugin is initialized")))}meta.plugin.uninitialized_list=[]}};function initAppShowHide(){wx.onAppShow(function(e){if(!meta.life_state.app_launched){var t=wx.getLaunchOptionsSync()||{};sa.autoTrackCustom.appLaunch(t)}sa.autoTrackCustom.appShow(e)}),wx.onAppHide(function(){sa.autoTrackCustom.appHide()})}function checkAppLaunch(){if(!meta.life_state.app_launched){var e=wx.getLaunchOptionsSync()||{};sa.autoTrackCustom.appLaunch(e)}}function mpProxy(e,t,a){var r=sa.autoTrackCustom[a];if(e[t]){var i=e[t];e[t]=function(){!sa.para.autoTrackIsFirst||isObject(sa.para.autoTrackIsFirst)&&!sa.para.autoTrackIsFirst[a]?(i.apply(this,arguments),r.apply(this,arguments)):(!0===sa.para.autoTrackIsFirst||isObject(sa.para.autoTrackIsFirst)&&sa.para.autoTrackIsFirst[a])&&(r.apply(this,arguments),i.apply(this,arguments)),sa.ee.page.emit(a)}}else e[t]=function(){r.apply(this,arguments),sa.ee.page.emit(a)}}function clickTrack(e){var t,a={},r={},i=e.currentTarget||{},n=e.target||{};if(isObject(sa.para.framework)&&isObject(sa.para.framework.taro)&&!sa.para.framework.taro.createApp&&n.id&&i.id&&n.id!==i.id)return!1;var s=i.dataset||{};if(t=e.type,a.$element_id=i.id,a.$element_type=s.type,a.$element_content=s.content,a.$element_name=s.name,isObject(e.event_prop)&&(r=e.event_prop),t&&isClick(t)){if(sa.para.preset_events&&sa.para.preset_events.collect_element&&!1===sa.para.preset_events.collect_element(arguments[0]))return!1;a.$url_path=sa._.getCurrentPath(),sa._.setPageRefData(a),a=sa._.extend(a,r),sa.track("$MPClick",a)}}function clickProxy(e,t){var a=e[t];e[t]=function(){var e=a.apply(this,arguments),t=arguments[0];return isObject(t)&&(sa.para.preset_events.defer_track?setTimeout(function(){clickTrack(t)},0):clickTrack(t)),e}}function isClick(e){return!!{tap:1,longpress:1,longtap:1}[e]}function tabProxy(e){var t=e.onTabItemTap;e.onTabItemTap=function(e){t&&t.apply(this,arguments);var a={};e&&(a.$element_content=e.text),a.$element_type="tabBar",a.$url_path=sa._.getCurrentPath(),sa._.setPageRefData(a),sa.track("$MPClick",a)}}function getMethods(e){var t=MP_FILTER_HOOK,a=[];for(var r in e)"function"!=typeof e[r]||t[r]||a.push(r);return a}function initPageProxy(){var e=Page;Page=function(t){try{t||(t={}),monitorClick(t),monitorHooks(t),e.apply(this,arguments)}catch(t){e.apply(this,arguments)}};var t=Component;Component=function(e){try{e||(e={}),e.methods||(e.methods={}),monitorClick(e.methods),monitorHooks(e.methods),t.apply(this,arguments)}catch(e){t.apply(this,arguments)}}}function monitorClick(e){var t=[];if(sa.para.autoTrack&&sa.para.autoTrack.mpClick){t=getMethods(e),tabProxy(e);for(var a=t.length,r=0;r100)log("Key ["+e+"] is invalid");else if(!check.checkKeyword(e))return log("Key ["+e+"] is invalid"),!1;if(isPresetIdKeys(e,["$mp_openid","$identity_mp_openid","$identity_mp_unionid","$mp_unionid","$mp_id","$identity_mp_id"]))return log("Key ["+e+"] is invalid"),!1;if(!(t=validId(t)))return!1;if(isSameAndAnonymousID(t))return!1;var a=store.getFirstId(),r=store.getDistinctId();isNewLoginId(e,t)&&(store._state.identities[e]=t,store.set("history_login_id",{name:e,value:t}),a||store.set("first_id",r),sa.trackSignup({id:t,event_name:"$SignUp",id_name:e}),store.identitiesSet({type:"login",id:t,id_name:e}))}function getAnonymousID(){if(!isEmptyObject(store._state))return store._state._first_id||store._state.first_id||store._state._distinct_id||store._state.distinct_id;log("\u8bf7\u5148\u521d\u59cb\u5316SDK")}function getIdentities(){return isEmptyObject(store._state)?(log("\u8bf7\u5148\u521d\u59cb\u5316SDK"),null):store._state.identities||null}function logout(e){var t=store.getFirstId();store.identitiesSet({type:"logout"}),store.set("history_login_id",{name:"",value:""}),t?(store.set("first_id",""),!0===e?store.set("distinct_id",store.getUUID()):store.set("distinct_id",t)):log("\u6ca1\u6709first_id\uff0clogout\u5931\u8d25")}function getPresetProperties(){if(meta.preset_properties&&meta.preset_properties.$lib){var e={};each(meta.preset_properties,function(t,a){0===a.indexOf("$")&&(e[a]=t)});var t={$url_path:getCurrentPath(),$is_first_day:getIsFirstDay(),$is_first_time:meta.is_first_launch},a=extend(e,t,meta.preset_properties,store.getProps());return delete a.$lib,a}return{}}function setOpenid(e,t){if(!(e=validId(e)))return!1;if(!checkPrivacyStatus())return!1;if(!meta.init_status)return store.store_queue.push({method:"setOpenid",params:arguments}),!1;log("\u8be5\u65b9\u6cd5\u5df2\u4e0d\u5efa\u8bae\u4f7f\u7528\uff0c\u5982\u679c\u662f id2 \u7528\u6237\uff0c\u8bf7\u4f7f\u7528 identify \u4ee3\u66ff\uff0c\u5982\u679c\u662f id3 \u7528\u6237\uff0c\u8bf7\u4f7f\u7528 bindOpenid \u4ee3\u66ff"),t&&log("%c \u5f53\u524d\u7248\u672c setOpenid \u63a5\u53e3 \u5df2\u4e0d\u652f\u6301\u4f20\u5165\u7b2c\u4e8c\u4e2a\u53c2\u6570","color:#F39C12;font-size: 14px;"),store.set("openid",e),sa.identify(e,!0);var a=getOpenidNameByAppid();store._state.identities[a]=e,store.save()}function unsetOpenid(e){log("\u8be5\u65b9\u6cd5\u5df2\u4e0d\u5efa\u8bae\u4f7f\u7528\uff0c\u5982\u679c\u662f id3 \u7528\u6237\uff0c\u8bf7\u4f7f\u7528 unbindOpenid \u4ee3\u66ff");var t=validId(e);if(!t)return!1;var a=store._state.openid;a===t&&store.set("openid","");var r=getOpenidNameByAppid();if(hasOwnProperty$3.call(store._state.identities,r)&&t===store._state.identities[r]){delete store._state.identities[r];var i=store.getFirstId(),n=store.getDistinctId(),s=store._state&&store._state.identities&&store._state.identities.$identity_mp_id;i&&i===a&&s&&store.change("first_id",s),n&&n===a&&s&&store.change("distinct_id",s),store.save()}}function bindOpenid(e){if(!(e=validId(e)))return!1;var t=getOpenidNameByAppid();this.bind(t,e)}function unbindOpenid(e){if(!validId(e))return!1;var t=getOpenidNameByAppid();this.unbind(t,e)}function setUnionid(e){var t=validId(e);t&&bind("$identity_mp_unionid",t)}function unsetUnionid(e){var t=validId(e);if(t){if(hasOwnProperty$3.call(store._state.identities,"$identity_mp_unionid")&&t===store._state.identities.$identity_mp_unionid){var a=getOpenidNameByAppid();hasOwnProperty$3.call(store._state.identities,a)&&(delete store._state.identities[a],delete store._state.openid,store.save())}unbind("$identity_mp_unionid",t)}}function initWithOpenid(e,t){(e=e||{}).appid&&(saPara.appid=e.appid),sa.openid.getOpenid(function(a){a&&sa.setOpenid(a,e.isCoverLogin),t&&isFunction(t)&&t(a),sa.init(e)})}function bind(e,t){if(isNumber(t)){if(isInteger(t)&&!1===isSafeInteger(t))return log("Value must be String"),!1;t=String(t)}if(!isString(e))return log("Key must be String"),!1;var a=store.getHistoryLoginId(),r=a?a.name:"";return!check.checkKeyword(e)||isPresetIdKeys(e,[IDENTITY_KEY.LOGIN,r,"$mp_id","$identity_mp_id"])?(log("Key ["+e+"] is invalid"),!1):t&&""!==t?isString(t)?!!check.checkIdLength(t)&&(store._state.identities[e]=t,store.save(),void dataStage({type:"track_id_bind",event:"$BindID"})):(log("Value must be String"),!1):(log("Value is empty or null"),!1)}function unbind(e,t){if(isNumber(t)){if(isInteger(t)&&!1===isSafeInteger(t))return log("Value must be String"),!1;t=String(t)}if(!isString(e))return log("Key must be String"),!1;if(!sa._.check.checkKeyword(e)||isPresetIdKeys(e,[IDENTITY_KEY.LOGIN]))return log("Key ["+e+"] is invalid"),!1;if(!t||""===t)return log("Value is empty or null"),!1;if(!isString(t))return log("Value must be String"),!1;if(!sa._.check.checkIdLength(t))return!1;hasOwnProperty$3.call(store._state.identities,e)&&t===store._state.identities[e]&&("$mp_id"!==e&&"$identity_mp_id"!==e&&delete store._state.identities[e],store.save());var a=store.getDistinctId(),r=store.getFirstId();a===e+"+"+t&&(store.set("first_id",""),store.set("distinct_id",r),store.set("history_login_id",{name:"",value:""}));var i={};i[e]=t,dataStage({type:"track_id_unbind",event:"$UnbindID",unbind_value:i})}function setWebViewUrl(e,t){if(log("setWebViewUrl \u65b9\u6cd5\u5df2\u4ece 2022-9-23 \u5f00\u59cb\u5e9f\u5f03\uff0c\u8bf7\u5c3d\u5feb\u53bb\u9664\u8be5 API \u7684\u8c03\u7528\uff0c\u5e76\u4f7f\u7528 use \u63d2\u4ef6 \u4ee3\u66ff"),!isString(e)||""===e)return log("error:\u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;if(!/^http(s)?:\/\//.test(e))return log("warning: \u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;var a=/([^?#]+)(\?[^#]*)?(#.*)?/.exec(e);if(!a)return!1;var r,i=a[1]||"",n=a[2]||"",s=a[3]||"",o="",u=store.getDistinctId()||"",c=store.getFirstId()||"";urlSafeBase64&&urlSafeBase64.encode?u=u?urlSafeBase64.trim(urlSafeBase64.encode(urlBase64Encode(u))):"":rot13obfs&&(u=u?rot13obfs(u):""),u=encodeURIComponent(u);var p=c?"f"+u:"d"+u;t?(r=s.indexOf("_sasdk"),o=s.indexOf("?")>-1?r>-1?i+n+"#"+s.substring(1,r)+"_sasdk="+p:i+n+"#"+s.substring(1)+"&_sasdk="+p:i+n+"#"+s.substring(1)+"?_sasdk="+p):(r=n.indexOf("_sasdk"),o=/^\?(\w)+/.test(n)?r>-1?i+n.replace(/(_sasdk=)([^&]*)/gi,"_sasdk="+p)+s:i+"?"+n.substring(1)+"&_sasdk="+p+s:i+"?"+n.substring(1)+"_sasdk="+p+s);return o}function quick(){var e=arguments[0],t=arguments[1],a=arguments[2],r=isObject(a)?a:{};if("getAnonymousID"===e){if(!isEmptyObject(store._state))return store._state._first_id||store._state.first_id||store._state._distinct_id||store._state.distinct_id;log("\u8bf7\u5148\u521d\u59cb\u5316SDK")}else"appLaunch"===e||"appShow"===e?t?sa.autoTrackCustom[e](t,r):log("App\u7684launch\u548cshow\uff0c\u5728sensors.quick\u7b2c\u4e8c\u4e2a\u53c2\u6570\u5fc5\u987b\u4f20\u5165App\u7684options\u53c2\u6570"):"appHide"===e&&(r=isObject(t)?t:{},sa.autoTrackCustom[e](r))}function appLaunch(e,t){var a={};e&&e.scene?(meta.current_scene=e.scene,a.$scene=getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,delObjectKey(e.query)),e&&e.path&&(a.$url_path=getPath(e.path),a.$title=getPageTitle(e.path)),setShareInfo(e,a);var r=setUtm(e,a);meta.is_first_launch?(a.$is_first_time=!0,isEmptyObject(r.pre1)||sa.setOnceProfile(r.pre1)):a.$is_first_time=!1,setLatestChannel(r.pre2),setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=setQuery(e.query),a.$url=e.path+(a.$url_query?"?"+a.$url_query:""),setPageRefData(t),isObject(t)&&(a=extend(a,t)),sa.track("$MPLaunch",a)}function appShow(e,t){var a={};meta.mp_show_time=(new Date).getTime(),e&&e.scene?(meta.current_scene=e.scene,a.$scene=getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,delObjectKey(e.query)),e&&e.path&&(a.$url_path=getPath(e.path),a.$title=getPageTitle(e.path)),setShareInfo(e,a),setLatestChannel(setUtm(e,a).pre2),setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=setQuery(e.query),e&&e.path&&(a.$url=e.path+(a.$url_query?"?"+a.$url_query:"")),setPageRefData(a,e.path,a.$url_query),isObject(t)&&(a=extend(a,t)),sa.track("$MPShow",a)}function appHide(e){var t=(new Date).getTime(),a={};a.$url_path=getCurrentPath(),meta.mp_show_time&&t-meta.mp_show_time>0&&(t-meta.mp_show_time)/36e5<24&&(a.event_duration=(t-meta.mp_show_time)/1e3),setPageRefData(a),isObject(e)&&(a=extend(a,e)),sa.track("$MPHide",a),sa.sendStrategy.onAppHide()}function pageShow(e){var t={},a=getCurrentPath(),r=getPageTitle(a),i=getCurrentPage();r&&(t.$title=r),t.$url_path=a,t.$url_query=i.sensors_mp_url_query?i.sensors_mp_url_query:"",setPageSfSource(t=extend(t,getUtmFromPage())),setPageRefData(t),isObject(e)&&(t=extend(t,e)),sa.track("$MPViewScreen",t)}function setPara(e){sa.para=extend2Lev(saPara,e);var t=[];if(isArray(saPara.source_channel))for(var a=saPara.source_channel.length,r=0;r0&&(t-meta.mp_show_time)/36e5<24&&(a.event_duration=(t-meta.mp_show_time)/1e3),setPageRefData(a),e?(a=extend(a,e),sa.track("$MPHide",a)):saPara.autoTrack&&saPara.autoTrack.appHide&&sa.autoTrackCustom.trackCustom("appHide",a,"$MPHide")},pageLoad:function(e){meta.current_scene&&1010===meta.current_scene&&e&&(e.sampshare&&delete e.sampshare,delObjectKey(e)),e&&isObject(e)&&(this.sensors_mp_url_query=setQuery(e),this.sensors_mp_encode_url_query=setQuery(e,!0))},pageShow:function(){meta.page_show_time=Date.now();var e={},t=getCurrentPath(),a=getPageTitle(t);setRefPage(),e.$url_path=t,e.$url_query=this.sensors_mp_url_query?this.sensors_mp_url_query:"",setPageRefData(e=extend(e,getUtmFromPage())),setPageSfSource(e),a&&(e.$title=a),saPara.onshow?saPara.onshow(sa,t,this):-1===saPara.autotrack_exclude_page.pageShow.indexOf(t)&&sa.autoTrackCustom.trackCustom("pageShow",e,"$MPViewScreen")},pageShare:function(e){var t=e.onShareAppMessage;e.onShareAppMessage=function(){var e=this;meta.share_method="\u8f6c\u53d1\u6d88\u606f\u5361\u7247";var a,r=t.apply(this,arguments);if(saPara.autoTrack&&saPara.autoTrack.pageShare){var i={$url_path:getCurrentPath(),$share_depth:meta.query_share_depth,$share_method:meta.share_method};setPageRefData(i),sa.autoTrackCustom.trackCustom("pageShare",i,"$MPShare")}function n(t){return isObject(t)||(t={}),(isUndefined(t.path)||""===t.path)&&(t.path=getCurrentUrl(e)),isString(t.path)&&(-1===t.path.indexOf("?")?t.path=t.path+"?":"&"!==t.path.slice(-1)&&(t.path=t.path+"&")),t.path=t.path+getShareInfo(),t}if(sa.para.allow_amend_share_path&&isObject(r=n(r)))for(var s in r)if((a=r[s])&&isFunction(a.then)&&isFunction(a.catch))try{r[s]=r[s].then(function(e){return n(e)})}catch(e){log("onShareAppMessage: "+e)}return r}},pageShareTimeline:function(e){var t=e.onShareTimeline;e.onShareTimeline=function(){meta.share_method="\u670b\u53cb\u5708\u5206\u4eab";var e=t.apply(this,arguments);if(saPara.autoTrack&&saPara.autoTrack.pageShare){var a={$url_path:getCurrentPath(),$share_depth:meta.query_share_depth,$share_method:meta.share_method};setPageRefData(a),sa.autoTrackCustom.trackCustom("pageShare",a,"$MPShare")}return saPara.allow_amend_share_path&&("object"!=typeof e&&(e={}),"object"==typeof e&&void 0===e.query&&(e.query=""),"object"==typeof e&&"string"==typeof e.query&&""!==e.query&&"&"!==e.query.slice(-1)&&(e.query=e.query+"&"),e.query=e.query+getShareInfo()),e}},pageAddFavorites:function(){var e={};e.$url_path=getCurrentPath(),saPara.autoTrack&&saPara.autoTrack.mpFavorite&&sa.autoTrackCustom.trackCustom("mpFavorite",e,"$MPAddFavorites")},pageHide:function(){sa.para.autoTrack&&sa.para.autoTrack.pageLeave&&sendPageLeave()}};function sendPageLeave(){var e={},t="";try{t=(e=getCurrentPage())?e.route:""}catch(e){log(e)}if(meta.page_show_time>=0&&""!==t){var a={},r=getPageTitle(t),i=(Date.now()-meta.page_show_time)/1e3;(isNaN(i)||i<0)&&(i=0),a.$url_query=e.sensors_mp_url_query?e.sensors_mp_url_query:"",a.$url_path=t,a.$title=r,a.event_duration=i,-1===saPara.autotrack_exclude_page.pageLeave.indexOf(t)&&sa.track("$MPPageLeave",a),meta.page_show_time=-1}}var openid={getRequest:function(e){wx.login({success:function(t){t.code&&saPara.appid&&saPara.openid_url?wxrequest({url:saPara.openid_url+"&code="+t.code+"&appid="+saPara.appid,method:"GET",complete:function(t){isObject(t)&&isObject(t.data)&&t.data.openid?e(t.data.openid):e()}}):e()}})},getWXStorage:function(){var e=store.getStorage();if(e&&isObject(e))return e.openid},getOpenid:function(e){if(!saPara.appid)return e(),!1;var t=this.getWXStorage();t?e(t):this.getRequest(e)}},functions=Object.freeze({__proto__:null,setProfile:setProfile,setOnceProfile:setOnceProfile,appendProfile:appendProfile,incrementProfile:incrementProfile,track:track,identify:identify,trackSignup:trackSignup,login:login,loginWithKey:loginWithKey,getAnonymousID:getAnonymousID,getIdentities:getIdentities,logout:logout,getPresetProperties:getPresetProperties,setOpenid:setOpenid,unsetOpenid:unsetOpenid,bindOpenid:bindOpenid,unbindOpenid:unbindOpenid,setUnionid:setUnionid,unsetUnionid:unsetUnionid,bindUnionid:setUnionid,unbindUnionid:unsetUnionid,initWithOpenid:initWithOpenid,bind:bind,unbind:unbind,setWebViewUrl:setWebViewUrl,quick:quick,appLaunch:appLaunch,appShow:appShow,appHide:appHide,pageShow:pageShow,setPara:setPara,getServerUrl:getServerUrl,sendPageLeave:sendPageLeave,openid:openid,autoTrackCustom:autoTrackCustom,registerApp:registerApp,register:register,clearAllRegister:clearAllRegister,clearAppRegister:clearAppRegister,clearAllProps:clearAllProps});function buildAPI(e){for(var t in functions)e[t]=functions[t]}function setFirstVisitTime(){meta.is_first_launch&&setOnceProfile({$first_visit_time:new Date})}function checkIsComplete(){meta.initialState.isComplete=!0,meta.initialState.queue.length>0&&(each(meta.initialState.queue,function(e){"appLaunch"===e[0]?sa.autoTrackCustom.appLaunch.apply(sa.autoTrackCustom,slice.call(e[1])):sa[e[0]].apply(sa,slice.call(e[1]))}),meta.initialState.queue=[])}function init(e){if(!0===meta.init_status)return!1;function t(){checkIsComplete(),checkAppLaunch(),sa.ee.sdk.emit("ready")}meta.init_status=!0,sa.ee.sdk.emit("beforeInit"),e&&isObject(e)&&sa.setPara(e),sa.ee.sdk.emit("initPara"),sa.ee.sdk.emit("afterInitPara"),sa.store.init(),sa.checkPluginInitStatus(),setFirstVisitTime(),sa.para.batch_send&&sa.sendStrategy.init();var a=[getNetworkType(),getSystemInfo()].concat(meta.promise_list);Promise.all(a).then(()=>{t()}).catch(()=>{t()})}function registerPropertyPlugin(e){isFunction(e.properties)?!e.isMatchedWithFilter||isFunction(e.isMatchedWithFilter)?sa.ee.data.on("finalAdjustData",function(t){try{isFunction(e.isMatchedWithFilter)?e.isMatchedWithFilter(t)&&e.properties(t):e.properties(t)}catch(e){log("execute registerPropertyPlugin callback error:"+e)}}):log("registerPropertyPlugin arguments error, isMatchedWithFilter must be function"):log("registerPropertyPlugin arguments error, properties must be function")}sa._=_,sa.modules={},sa.meta=meta,sa.kit=kit,sa.mergeStorageData=mergeStorageData,sa.dataStage=dataStage,sa.sendStrategy=sendStrategy,sa.store=store,sa.usePlugin=usePlugin,sa.checkPluginInitStatus=checkPluginInitStatus,sa.eventSub=eventSub,sa.events=new eventEmitter,sa.ee=ee,sa.registerPropertyPlugin=registerPropertyPlugin,sa.enableDataCollect=enableDataCollect,sa.initialState=meta.initialState,sa.IDENTITY_KEY={EMAIL:IDENTITY_KEY.EMAIL,MOBILE:IDENTITY_KEY.MOBILE},buildAPI(sa),apiStaging(),setNavigationBarTitle(),networkStatusChange(),initAppGlobalName(),initAppShowHide(),initPageProxy(),sa.init=init;var base={plugin_version:"1.19.12"};function createPlugin(e){if("object"==typeof e&&"string"==typeof e.plugin_name&&""!==e.plugin_name)return e.plugin_version=base.plugin_version,e.log=e.log||function(){"object"==typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)},e;"object"==typeof console&&"function"==typeof console.error&&console.error('plugin must contain proprerty "plugin_name"')}var disableSDK={init(e){e.disableSDK=this.disableSDK.bind(this),e.enableSDK=this.enableSDK.bind(this),e.getDisabled=this.getDisabled.bind(this)},plugin_name:"DisableSDK",disabled:!1,disableSDK(){this.disabled=!0},enableSDK(){this.disabled=!1},getDisabled(){return this.disabled}},DisableSDK=createPlugin(disableSDK);sa.usePlugin(DisableSDK),module.exports=sa; \ No newline at end of file