"use strict";var e,t,n="[UMENG] -- ",a=(t=!1,function(){null===e&&(e=new i);return e});function i(){this.setDebug=function(e){t=e};this.d=function(){if(t)try{"string"==typeof arguments[0]&&(arguments[0]=n+arguments[0]);console.debug.apply(console,arguments)}catch(e){}};this.i=function(){try{if(t)try{"string"==typeof arguments[0]&&(arguments[0]=n+arguments[0]);console.info.apply(console,arguments)}catch(e){}}catch(e){}};this.e=function(){if(t)try{"string"==typeof arguments[0]&&(arguments[0]=n+arguments[0]);console.error.apply(console,arguments)}catch(e){}};this.w=function(){if(t)try{"string"==typeof arguments[0]&&(arguments[0]=n+arguments[0]);console.warn.apply(console,arguments)}catch(e){}};this.v=function(){if(t)try{"string"==typeof arguments[0]&&(arguments[0]=n+arguments[0]);console.log.apply(console,arguments)}catch(e){}};this.t=function(){if(t)try{console.table.apply(console,arguments)}catch(e){}};this.tip=function(){try{"string"==typeof arguments[0]&&(arguments[0]=n+arguments[0]);console.log.apply(console,arguments)}catch(e){}};this.tip_w=function(e){try{console.log("%c "+n+e,"background:red; padding: 4px; padding-right: 8px; border-radius: 4px; color: #fff;")}catch(e){}};this.err=function(){try{"string"==typeof arguments[0]&&(arguments[0]=n+arguments[0]);console.error.apply(console,arguments)}catch(e){}}}var r,s=(r=e=null,function(){return r=r||new o});function o(){var n={};this.useOpenid=function(){return!!n.useOpenid};this.useSwanid=function(){return!!n.useSwanid};this.autoGetOpenid=function(){return!!n.autoGetOpenid};this.appKey=function(){return n.appKey};this.uploadUserInfo=function(){return n.uploadUserInfo};this.enableVerify=function(){return n.enableVerify};this.set=function(e){n=e};this.get=function(){return n};this.setItem=function(e,t){n[e]=t};this.getItem=function(e){return n[e]}}function u(){this.listeners={};this.maxListener=50}u.prototype.addListener=u.prototype.on=function(e,t){var n=this.listeners;n[e]&&n[e].length>=this.maxListener?console.error("监听器的最大数量是%d,您已超出限制",this.maxListener):n[e]instanceof Array?-1===n[e].indexOf(t)&&n[e].push(t):n[e]=[].concat(t)};u.prototype.emit=function(e){var t=Array.prototype.slice.call(arguments);t.shift();var n=this.listeners;n[e]instanceof Array&&n[e].forEach(function(e){e.apply(null,t)})};u.prototype.listeners=function(e){return this.listeners[e]};u.prototype.setMaxListeners=function(e){this.maxListener=e};u.prototype.removeListener=function(e,t){var n=this.listeners,t=(n[e]||[]).indexOf(t);0<=t&&n[e].splice(t,1)};u.prototype.removeAllListener=function(e){this.listeners[e]=[]};u.prototype.once=function(n,i){var r=this;this.on(n,function e(){var t=Array.prototype.slice.call(arguments);i.apply(null,t);r.removeListener(n,e)})};var c=new u;c.messageType={CONFIG_LOADED:0,UMA_LIB_INITED:1};var f=new(function(){function e(){}e.prototype.setStorage=function(e,t,n){wx.setStorage({key:e,data:t,success:function(){"function"==typeof n&&n(!0)},fail:function(){"function"==typeof n&&n(!1)}})};e.prototype.getStorage=function(t,n){wx.getStorage({key:t,success:function(e){"function"==typeof n&&n(e.data)},fail:function(e){a().w(t+": "+e.errMsg);"function"==typeof n&&n()}})};e.prototype.removeStorage=function(e,t){wx.removeStorage({key:e,success:function(){"function"==typeof t&&t(!0)},fail:function(){"function"==typeof t&&t(!1)}})};e.prototype.getSystemInfo=function(i){wx.getSystemInfo({success:function(e){var t={model:e.model,brand:e.brand,pixelRatio:e.pixelRatio,screenWidth:e.screenWidth,screenHeight:e.screenHeight,fontSizeSetting:e.fontSizeSetting,platform:e.platform,platformVersion:e.version,platformSDKVersion:e.SDKVersion,language:e.language,deviceName:e.model,OSVersion:e.system,resolution:""},n=e.system.split(" ");Array.isArray(n)&&(t.OS=n[0]);n=Math.round(e.screenWidth*e.pixelRatio),e=Math.round(e.screenHeight*e.pixelRatio);t.resolution=ee.length)&&e.substr(0,t.length)===t},endsWith:function(e,t){return!(!t||0===e.length||t.length>e.length)&&e.substring(e.length-t.length)===t},assign:function(e){if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),n=1;nd.SESSION_INTERVAL){t=!0;!function(e){try{var t=(ee||{}).options||{},n=v.assign({},function(e){var t,n={};for(t in e)0===t.indexOf("_um_")&&(n[t]=e[t]);a().v("query: ",e);a().v("_um_params: ",n);return n}(e.query));n.path=e.path||t.path;n.scene=e.scene?f.getPlatform()+"_"+e.scene:t.scene;t=e.referrerInfo;t&&(n.referrerAppId=t.appId);a().v("session options: ",n);t=n[d.UM_SSRC];t&&T().setShareSource(t);t=Date.now();ee={id:v.getRandomStr(10)+t,start_time:t,options:n}}catch(e){a().e("生成新session失败: ",e)}}(e);a().v("开始新的session(%s): ",ee.id,ee)}else a().v("延续上一次session(%s): %s ",ee.id,n.toLocaleTimeString(),ee);return t},pause:function(){!function(){if(ee){var e=new Date;ee.end_time=e.getTime();"number"!=typeof ee.duration&&(ee.duration=0);ee.duration=ee.end_time-$;D().set(d.CURRENT_SESSION,ee);a().v("退出会话(%s): %s ",ee.id,e.toLocaleTimeString(),ee)}}()},getCurrentSessionId:function(){return(ee||{}).id},getCurrentSession:function(){return ee},cloneCurrentSession:function(){return v.clone(ee)}}}function ie(e){var t=null;switch(e){case B.HALF_SESSION:t=function(){var e=null,t=te().cloneCurrentSession();t&&(e={header:{st:"1"},analytics:{sessions:[t]}});return e}();break;case B.CLOSE_SESSION:t=function(){var e=null,t={},n=te().cloneCurrentSession();if(n){var i=m().get(),r=T().get();Array.isArray(i)&&i.length&&(n.pages=v.clone(i));Array.isArray(r)&&r.length&&(n.shares=v.clone(r));m().clear();T().clear();t.sessions=[n]}n=F().getEkvs();if(n){t.ekvs=v.clone(n);F().clear()}(t.sessions||t.ekvs)&&(e={analytics:t});return e}();break;case B.EKV:t=function(){var e=null,t=F().getEkvs();if(t){e={analytics:{ekvs:v.clone(t)}};F().clear()}return e}()}return t}var re={sessions:"sn",ekvs:"e",active_user:"active_user"},oe={sdk_type:"sdt",access:"ac",access_subtype:"acs",device_model:"dm",language:"lang",device_type:"dt",device_manufacturer:"dmf",device_name:"dn",platform_version:"pv",id_type:"it",font_size_setting:"fss",os_version:"ov",device_manuid:"did",platform_sdk_version:"psv",device_brand:"db",appkey:"ak",_id:"id",id_tracking:"itr",imprint:"imp",sdk_version:"sv",resolution:"rl",testToken:"ttn"},se={uuid:"ud",unionid:"und",openid:"od",anonymousid:"nd",alipay_id:"ad",device_id:"dd",userid:"puid"};function ae(e){return{h:function(e,t){var n=ue(e,t);e&&e.id_tracking&&(n[t.id_tracking||"id_tracking"]=ue(e.id_tracking,se));return n}(e.header,oe),a:function(e,t){var n={};if(e)for(var i in e)e[i]&&(n[t[i]]=e[i]);return n}(e.analytics,re)}}function ue(e,t){var n,i={};for(n in e)t[n]?i[t[n]]=e[n]:i[n]=e[n];return i}var ce=k=N="";function fe(e){if(e.length<2)return(t=e.charCodeAt(0))<128?e:t<2048?_e(192|t>>>6)+_e(128|63&t):_e(224|t>>>12&15)+_e(128|t>>>6&63)+_e(128|63&t);var t=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return _e(240|t>>>18&7)+_e(128|t>>>12&63)+_e(128|t>>>6&63)+_e(128|63&t)}function pe(e){var t=[0,2,1][e.length%3],e=e.charCodeAt(0)<<16|(1>>18),ve.charAt(e>>>12&63),2<=t?"=":ve.charAt(e>>>6&63),1<=t?"=":ve.charAt(63&e)].join("")}function le(e){return e.replace(me,fe).replace(/[\s\S]{1,3}/g,pe)}function de(e){switch(e.length){case 4:var t=((7&e.charCodeAt(0))<<18|(63&e.charCodeAt(1))<<12|(63&e.charCodeAt(2))<<6|63&e.charCodeAt(3))-65536;return _e(55296+(t>>>10))+_e(56320+(1023&t));case 3:return _e((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return _e((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}}function he(e){var t=e.length,n=t%4,e=(0>>16),_e(e>>>8&255),_e(255&e)]).length-=[0,0,2,1][n];return e.join("")}function ge(e){return e.replace(/[\s\S]{1,4}/g,he).replace(Se,de)}var ve="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ye=function(e){for(var t={},n=0,i=e.length;n=t&&this.dequeue();n.push(e)};this.dequeue=function(){return n.shift()};this.front=function(){return n[0]};this.isEmpty=function(){return 0===n.length};this.clear=function(){n.length=0};this.size=function(){return n.length};this.items=function(){return n};this.print=function(){console.log(n.toString())}}var Ne,Te,we,Re,ke=(Ne=null,Te=!1,we=[],Re=new Ae(50),function(){return Ne=Ne||new Le});function Ue(t){var e=Re.front();if(e)Oe(e,function(){Re.dequeue();Ue(t)},function(){var e=Re.dequeue();e&&!e.noCache&&we.push(e);Ue(t)});else{!function(){we.forEach(function(e){Re.enqueue(e)});we.length=0}();t()}}function be(e){if(_().getId())if(Te)a().i("队列正在发送中");else{Te=!0;Ue(function(){Te=!1;"function"==typeof e&&e()})}else{a().i("获取id标识失败,暂缓发送");"function"==typeof e&&e()}}function Le(){this.send=function(e,t,n){e?this.add(e,t,function(){be(n)}):be(n)};this.add=function(e,t,n){!function e(t,n,i){if(z.instance().isLoaded()){n=n||{};var r=ie(t);if(r){var o=z.instance().getRealtimeFields();r.header=v.assign({},r.header,o);r.noCache=n.noCache;Re.enqueue(r)}"function"==typeof i&&i()}else setTimeout(function(){e(t,n,i)},100)}(e,t,n)};this.load=function(){var e=D().get(d.REQUESTS);e&&e.length&&e.forEach(function(e){Re.enqueue(e)});D().remove(d.REQUESTS)};this.save=function(){D().set(d.REQUESTS,v.clone(Re.items()));Re.clear()}}var De,Pe=(De=null,function(){return De=De||new Ce});function Ce(){this.update=function(){f.getUserInfo(function(t){if(t){var e=D().get(d.USER_INFO);e&&v.deepEqual(t,e)||function(t,n){var e=s().appKey(),i=f.getSdkType(),r=_().getId(),o=_().getIdType();if(e&&i&&r&&o){o={ak:s().appKey(),sdt:f.getSdkType(),uin:t.nickName,uia:t.avatar,uig:t.gender,uit:t.country,uip:t.province,uic:t.city,uil:t.language,id:_().getId(),it:_().getIdType()},o=JSON.stringify(o);o=Ie.encode(o);f.request({url:d.USERINFO_URL,method:"POST",header:{"content-type":"application/x-www-form-urlencoded"},data:"ui="+o,success:function(e){a().v("用户信息上传成功: ",t);n&&n(e&&e.data&&200===e.data.code)},fail:function(){a().e("用户信息上传失败: ",t);n&&n(!1)}})}}(t,function(e){e&&D().set(d.USER_INFO,t)})}})}}function Me(e,t){this.id=e;this.ts=Date.now();var n=typeof t;if("string"==n&&t)this[e]=t;else if("object"==n)for(var i in t)!{}.hasOwnProperty.call(t,i)||(this[i]=t[i])}function xe(){var r=!1,n=!1,o=0;this.init=function(e){a().v("sdk version: "+d.IMPL_VERSION);r?a().v("Lib重复实例化"):D().load(function(){a().v("cache初始化成功: ",D().getAll());!function(){_().setUseOpenid&&_().setUseOpenid(s().useOpenid());_().init(function(){z.instance().init();a().v("Header初始化成功")})}();r=!0;"function"==typeof e&&e();a().tip("SDK集成成功")})};this.resume=function(e){if(r&&!n){a().v("showOptions: ",e);var t;n=!0;s().enableVerify()&&e&&e.query&&(t=e.query._ttn,ce=t||ce);this._resume(e)}};this._resume=function(e){ke().load();var t=te().resume(e),e=te().getCurrentSessionId();F().setSessionId(e);t&&ke().add(B.HALF_SESSION,{},function(){_().setUseOpenid&&_().setUseOpenid(s().useOpenid());if(s().useOpenid()&&s().autoGetOpenid()&&!_().getId()){a().v("get id async");!function t(n,i){if(_().getId()||n<=0)return;_().getOpenIdAsync(s().appKey(),function(e){if(e){a().v("获取id成功");ke().send()}else{a().v("获取openid失败,启动重试,剩余可用次数",n-1);setTimeout(function(){t(n-1,i)},i)}})}(10,3e3)}else{a().v("session auto send");ke().send()}})};this.pause=function(e){if(r){n=!1;o=0;te().pause();s().uploadUserInfo()&&Pe().update();ke().send(B.CLOSE_SESSION,{},function(){ke().save();D().save();a().v("cache save success");"function"==typeof e&&e()})}};this.setOpenid=function(e){a().v("setOpenId: %s",e);_().setOpenid(e);ke().send()};this.setUnionid=function(e){a().v("setUnionid: %s",e);_().setUnionid(e)};this.setUserid=function(e,t){a().v("setUserid: %s",e,t);_().setUserid(e,t)};this.setAnonymousid=function(e){a().v("setAnonymousId: %s",e);_().setAnonymousid(e);ke().send()};this.setAppVersion=function(e){e&&"string"!=typeof e?a().w("setAppVersion方法只接受字符串类型参数"):z.instance().setAppVersion(e)};this.setAlipayUserid=function(e){if(e&&"string"!=typeof e)a().w("setAlipayUserid方法只接受字符串类型参数");else{a().v("setAlipayUserid: %s",e);_().setAlipayUserid(e)}};this.setSuperProperty=function(e){if(e&&"string"!=typeof e)a().w("超级属性只支持字符串类型");else{var t=this;if(z.instance().getSuperProperty()!==e){z.instance().setSuperProperty(e);t.pause(function(){t.resume()})}}};this.trackEvent=function(e,t){if(r){a().v("event: ",e,t);if(function(e,t){if(e&&"string"==typeof e){var n=["id","ts","du"],i={};n.forEach(function(e){i[e]=1});if(i[e])a().e("eventId不能与以下保留字冲突: "+n.join(","));else if(e.length>d.MAX_EVENTID_LENGTH)a().e("The maximum length of event id shall not exceed "+d.MAX_EVENTID_LENGTH);else{if(!t||"object"==typeof t&&!Array.isArray(t)||"string"==typeof t){if("object"==typeof t){var r,o=0;for(r in t)if({}.hasOwnProperty.call(t,r)){if(r.length>d.MAX_PROPERTY_KEY_LENGTH){a().e("The maximum length of property key shall not exceed "+d.MAX_PROPERTY_KEY_LENGTH);return}if(o>=d.MAX_PROPERTY_KEYS_COUNT){a().e("The maximum count of properties shall not exceed "+d.MAX_PROPERTY_KEYS_COUNT);return}if(i[r]){a().e("属性中的key不能与以下保留字冲突: "+n.join(","));return}o+=1}}return 1}a().e("please check trackEvent properties. properties should be string or object(not include Array)")}}else a().e('please check trackEvent id. id should be "string" and not null')}(e,t)){var n=new Me(e,t);F().addEvent(n);var i=!!ce,e=i?0:d.EVENT_SEND_DEFAULT_INTERVAL,t=Date.now();if(n=t,e=e,"number"!=typeof o||"number"!=typeof e||(o<=0||e=Ge.length||e){e&&function(){var e="https://umini.shujupie.com";d.LOG_URL=d.LOG_URL.replace(e,Ge[Fe]);d.GET_OPENID_URL=d.GET_OPENID_URL.replace(e,Ge[Fe]);d.USERINFO_URL=d.USERINFO_URL.replace(e,Ge[Fe])}();e&&a().v("命中可用服务",Ge[Fe]);e||a().tip_w("未命中可用服务")}else f.request({url:Ge[t]+"/uminiprogram_logs/ckdh",success:function(e){200===(e.code||e.status||e.statusCode)&&e.data&&200===e.data.code?Ke((Fe=t)+1,!0):Ke(t+1,!1)},fail:function(){Ke(t+1,!1)}})}({init:function(e){setTimeout(function(){Ke(0,!1)},e)}}).init(3e3);var qe=new je,He={_inited:!1,_log:a(),use:function(e,t){e&&v.isFunction(e.install)?e.install(He,t):v.isFunction(e)&&e(He,t);return He},messager:c,init:function(e){if(this._inited)a().v("已经实例过,请避免重复初始化");else if(e)if(e.appKey){"boolean"!=typeof e.useOpenid&&(e.useOpenid=!0);s().set(e);a().setDebug(e.debug);this._inited=!0;var t=this;c.emit(c.messageType.CONFIG_LOADED,e);try{var n=new xe;a().v("成功创建Lib对象");n.init(function(){a().v("Lib对象初始化成功");qe.installApi(t,n);a().v("安装Lib接口成功");c.emit(c.messageType.UMA_LIB_INITED,e)})}catch(e){a().w("创建Lib对象异常: "+e)}}else a().err("请确保传入正确的appkey");else a().err("请正确设置相关信息!")}};try{qe.installApi(He,null)}catch(e){a().w("uma赋值异常: ",e)}var Ye={FETCH_URL:"https://ucc.umeng.com/v1/mini/fetch",ABLOG_URL:"https://pslog.umeng.com/mini_ablog",SDK_VERSION:"2.5.2",MOBILE_NETWORK_NONE:"none",MOBILE_NETWORK_2G:"2g",MOBILE_NETWORK_3G:"3g",MOBILE_NETWORK_4G:"4g",MOBILE_NETWORK_5G:"5g",MOBILE_NETWORK_WIFI:"wifi",IMPRINT:"imprint"},We={},Je=Array.isArray;We.isArray=Je||function(e){return"[object Array]"===toString.call(e)};We.isObject=function(e){return e===Object(e)&&!We.isArray(e)};We.isEmptyObject=function(e){if(We.isObject(e)){for(var t in e)if(hasOwnProperty.call(e,t))return!1;return!0}return!1};We.isUndefined=function(e){return void 0===e};We.isString=function(e){return"[object String]"===toString.call(e)};We.isDate=function(e){return"[object Date]"===toString.call(e)};We.isNumber=function(e){return"[object Number]"===toString.call(e)};We.each=function(e,t,n){if(null!=e){var i={},r=Array.prototype.forEach;if(r&&e.forEach===r)e.forEach(t,n);else if(e.length===+e.length){for(var o=0,s=e.length;o