You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
91 KiB
1 lines
91 KiB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).gravityengine=t()}(this,function(){"use strict";function i(t,e){var n,i=Object.keys(t);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(t),e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),i.push.apply(i,n)),i}function n(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?i(Object(n),!0).forEach(function(e){o(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function w(){w=function(){return o};var o={},e=Object.prototype,c=e.hasOwnProperty,u=Object.defineProperty||function(e,t,n){e[t]=n.value},t="function"==typeof Symbol?Symbol:{},i=t.iterator||"@@iterator",n=t.asyncIterator||"@@asyncIterator",r=t.toStringTag||"@@toStringTag";function a(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{a({},"")}catch(e){a=function(e,t,n){return e[t]=n}}function s(e,t,n,i){var r,a,o,s,t=t&&t.prototype instanceof f?t:f,t=Object.create(t.prototype),i=new k(i||[]);return u(t,"_invoke",{value:(r=e,a=n,o=i,s="suspendedStart",function(e,t){if("executing"===s)throw new Error("Generator is already running");if("completed"===s){if("throw"===e)throw t;return I()}for(o.method=e,o.arg=t;;){var n=o.delegate;if(n){n=function e(t,n){var i=n.method,r=t.iterator[i];if(void 0===r)return n.delegate=null,"throw"===i&&t.iterator.return&&(n.method="return",n.arg=void 0,e(t,n),"throw"===n.method)||"return"!==i&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+i+"' method")),p;i=l(r,t.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,p;r=i.arg;return r?r.done?(n[t.resultName]=r.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=void 0),n.delegate=null,p):r:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,p)}(n,o);if(n){if(n===p)continue;return n}}if("next"===o.method)o.sent=o._sent=o.arg;else if("throw"===o.method){if("suspendedStart"===s)throw s="completed",o.arg;o.dispatchException(o.arg)}else"return"===o.method&&o.abrupt("return",o.arg);s="executing";n=l(r,a,o);if("normal"===n.type){if(s=o.done?"completed":"suspendedYield",n.arg===p)continue;return{value:n.arg,done:o.done}}"throw"===n.type&&(s="completed",o.method="throw",o.arg=n.arg)}})}),t}function l(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}o.wrap=s;var p={};function f(){}function h(){}function d(){}var t={},g=(a(t,i,function(){return this}),Object.getPrototypeOf),g=g&&g(g(S([]))),v=(g&&g!==e&&c.call(g,i)&&(t=g),d.prototype=f.prototype=Object.create(t));function m(e){["next","throw","return"].forEach(function(t){a(e,t,function(e){return this._invoke(t,e)})})}function y(o,s){var t;u(this,"_invoke",{value:function(n,i){function e(){return new s(function(e,t){!function t(e,n,i,r){var a,e=l(o[e],o,n);if("throw"!==e.type)return(n=(a=e.arg).value)&&"object"==typeof n&&c.call(n,"__await")?s.resolve(n.__await).then(function(e){t("next",e,i,r)},function(e){t("throw",e,i,r)}):s.resolve(n).then(function(e){a.value=e,i(a)},function(e){return t("throw",e,i,r)});r(e.arg)}(n,i,e,t)})}return t=t?t.then(e,e):e()}})}function _(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function b(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(_,this),this.reset(!0)}function S(t){if(t){var n,e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length))return n=-1,(e=function e(){for(;++n<t.length;)if(c.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e}).next=e}return{next:I}}function I(){return{value:void 0,done:!0}}return u(v,"constructor",{value:h.prototype=d,configurable:!0}),u(d,"constructor",{value:h,configurable:!0}),h.displayName=a(d,r,"GeneratorFunction"),o.isGeneratorFunction=function(e){e="function"==typeof e&&e.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},o.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,a(e,r,"GeneratorFunction")),e.prototype=Object.create(v),e},o.awrap=function(e){return{__await:e}},m(y.prototype),a(y.prototype,n,function(){return this}),o.AsyncIterator=y,o.async=function(e,t,n,i,r){void 0===r&&(r=Promise);var a=new y(s(e,t,n,i),r);return o.isGeneratorFunction(t)?a:a.next().then(function(e){return e.done?e.value:a.next()})},m(v),a(v,r,"Generator"),a(v,i,function(){return this}),a(v,"toString",function(){return"[object Generator]"}),o.keys=function(e){var t,n=Object(e),i=[];for(t in n)i.push(t);return i.reverse(),function e(){for(;i.length;){var t=i.pop();if(t in n)return e.value=t,e.done=!1,e}return e.done=!0,e}},o.values=S,k.prototype={constructor:k,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(b),!e)for(var t in this)"t"===t.charAt(0)&&c.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(n){if(this.done)throw n;var i=this;function e(e,t){return a.type="throw",a.arg=n,i.next=e,t&&(i.method="next",i.arg=void 0),!!t}for(var t=this.tryEntries.length-1;0<=t;--t){var r=this.tryEntries[t],a=r.completion;if("root"===r.tryLoc)return e("end");if(r.tryLoc<=this.prev){var o=c.call(r,"catchLoc"),s=c.call(r,"finallyLoc");if(o&&s){if(this.prev<r.catchLoc)return e(r.catchLoc,!0);if(this.prev<r.finallyLoc)return e(r.finallyLoc)}else if(o){if(this.prev<r.catchLoc)return e(r.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<r.finallyLoc)return e(r.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;0<=n;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&c.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var r=i;break}}var a=(r=r&&("break"===e||"continue"===e)&&r.tryLoc<=t&&t<=r.finallyLoc?null:r)?r.completion:{};return a.type=e,a.arg=t,r?(this.method="next",this.next=r.finallyLoc,p):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),p},finish:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),b(n),p}},catch:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var n,i,r=this.tryEntries[t];if(r.tryLoc===e)return"throw"===(n=r.completion).type&&(i=n.arg,b(r)),i}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:S(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),p}},o}function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function c(e,t,n,i,r,a,o){try{var s=e[a](o),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(i,r)}function u(s){return function(){var e=this,o=arguments;return new Promise(function(t,n){var i=s.apply(e,o);function r(e){c(i,t,n,r,a,"next",e)}function a(e){c(i,t,n,r,a,"throw",e)}r(void 0)})}}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,f(i.key),i)}}function l(e,t,n){return t&&a(e.prototype,t),n&&a(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function o(e,t,n){return(t=f(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function x(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i,r,a,o,s=[],c=!0,u=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(i=a.call(n)).done)&&(s.push(i.value),s.length!==t);c=!0);}catch(e){u=!0,r=e}finally{try{if(!c&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw r}}return s}}(e,t)||h(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(e,t){var n;if(e)return"string"==typeof e?p(e,t):"Map"===(n="Object"===(n=Object.prototype.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:n)||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?p(e,t):void 0}function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function f(e){e=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0===n)return("string"===t?String:Number)(e);if("object"!=typeof(n=n.call(e,t||"default")))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}(e,"string");return"symbol"==typeof e?e:String(e)}var d="4.8.19",g="MG",q="cocoscreator",b="https://backend.gravity-engine.com/event_center/api/v1",t=function(){function e(){s(this,e),this.config={persistenceName:"GravityEngine",persistenceNameOld:"GravityEngine_web"}}return l(e,[{key:"getConfig",value:function(){return this.config}},{key:"getStorage",value:function(e,t,n){e=localStorage.getItem(e);if(!t)return S.isJSONString(e)?JSON.parse(e):{};S.isJSONString(e)?n(JSON.parse(e)):n({})}},{key:"setStorage",value:function(e,t){localStorage.setItem(e,t)}},{key:"_setSystemProxy",value:function(e){this._sysCallback=e}},{key:"getSystemInfo",value:function(e){var t=this._getOs(),t={mp_platform:"web",system:t,platform:t,screenWidth:window.screen.width,screenHeight:window.screen.height,systemLanguage:navigator.language};this._sysCallback&&(t=S.extend(t,this._sysCallback(e))),e.success(t),e.complete()}},{key:"_getOs",value:function(){var e=navigator.userAgent;return/Windows/i.test(e)?/Phone/.test(e)||/WPDesktop/.test(e)?"Windows Phone":"Windows":/(iPhone|iPad|iPod)/.test(e)?"iOS":/Android/.test(e)?"Android":/(BlackBerry|PlayBook|BB10)/i.test(e)?"BlackBerry":/Mac/i.test(e)?"MacOS":/Linux/.test(e)?"Linux":/CrOS/.test(e)?"ChromeOS":""}},{key:"getNetworkType",value:function(e){e.complete()}},{key:"onNetworkStatusChange",value:function(){}},{key:"request",value:function(e){var t={},n=new XMLHttpRequest;if(n.open(e.method,e.url),e.header)for(var i in e.header)n.setRequestHeader(i,e.header[i]);return n.onreadystatechange=function(){4===n.readyState&&200===n.status?(t.statusCode=200,S.isJSONString(n.responseText)&&(t.data=JSON.parse(n.responseText)),e.success(t)):200!==n.status&&(t.errMsg="network error",e.fail(t))},n.ontimeout=function(){t.errMsg="timeout",e.fail(t)},n.send(e.data),n}},{key:"initAutoTrackInstance",value:function(e,t){this.instance=e,this.autoTrack=t.autoTrack;var n=this;"onpagehide"in window?window.onpagehide=function(){n.onPageHide(!0)}:window.onbeforeunload=function(){n.onPageHide(!0)},n.onPageShow(),n.autoTrack.appHide&&n.instance.timeEvent("ta_page_hide"),"onvisibilitychange"in document&&(document.onvisibilitychange=function(){document.hidden?n.onPageHide(!1):(n.onPageShow(),n.autoTrack.appHide&&n.instance.timeEvent("ta_page_hide"))})}},{key:"setGlobal",value:function(e,t){window[t]=e}},{key:"getAppOptions",value:function(){}},{key:"showToast",value:function(){}},{key:"onPageShow",value:function(){var e;this.autoTrack.appShow&&(S.extend(e={},this.autoTrack.properties),S.isFunction(this.autoTrack.callback)&&S.extend(e,this.autoTrack.callback("appShow")),this.instance._internalTrack("$WebPageView",e))}},{key:"onPageHide",value:function(e){var t;this.autoTrack.appHide&&(S.extend(t={},this.autoTrack.properties),S.isFunction(this.autoTrack.callback)&&S.extend(t,this.autoTrack.callback("appHide")),this.instance._internalTrack("$WebPageHide",t,new Date,null,e))}}],[{key:"createInstance",value:function(){return new e}}]),e}(),$=function(){function n(e,t){s(this,n),this.taInstance=e,this.config=t||{},this.referrer="Directly open",this.config.isPlugin?(e.App=function(){App.apply(this,arguments)},inension(e.Page)):(t=App,App=this._initAppExtention(t),e=Page,Page=this._initPageExtension(e))}return l(n,[{key:"_initPageExtension",value:function(a){var o=this;return function(e){var t=e.onLoad,n=e.onShow,i=e.onShareAppMessage,r={};return e.onLoad=function(e){r=e||{},"function"==typeof t&&t.call(this,e)},e.onShow=function(e){o.onPageShow(r),"function"==typeof n&&n.call(this,e)},"function"==typeof i&&(e.onShareAppMessage=function(e){e=i.call(this,e);return o.onPageShare(e)}),a(e)}}},{key:"_initAppExtention",value:function(r){var a=this;return function(e){var t=e.onLaunch,n=e.onShow,i=e.onHide;return e.onLaunch=function(e){a.onAppLaunch(e,this),"function"==typeof t&&t.call(this,e)},e.onShow=function(e){a.onAppShow(e),"function"==typeof n&&n.call(this,e)},e.onHide=function(){a.onAppHide(),"function"==typeof i&&i.call(this)},r(e)}}},{key:"onAppLaunch",value:function(e,t){this._setAutoTrackProperties(e),S.isUndefined(t)||(t[this.taInstance.name]=this.taInstance),this.config.appLaunch&&(t={},e&&e.path&&(t.$url_query=S.setQuery(e.query),t.$scene=String(e.scene||e.from)),this.taInstance._internalTrack("$MPLaunch",t))}},{key:"onAppShow",value:function(e){var t;this.config.appHide&&this.taInstance.timeEvent("$MPHide"),this._setAutoTrackProperties(e),this.config.appShow&&(t={},e&&e.path&&(t.$url_path=this._getPath(e.path),t.$url_query=S.setQuery(e.query),t.$scene=String(e.scene||e.from)),S.extend(t,this.config.properties),S.isFunction(this.config.callback)&&S.extend(t,this.config.callback("appShow")),this.taInstance._internalTrack("$MPShow",t))}},{key:"onAppHide",value:function(){var e;this.config.appHide&&(S.extend(e={},this.config.properties),S.isFunction(this.config.callback)&&S.extend(e,this.config.callback("appHide")),this.taInstance._internalTrack("$MPHide",e))}},{key:"_getCurrentPath",value:function(){var e="Not to get";try{var t=getCurrentPages(),e=t[t.length-1].route}catch(e){M.info(e)}return e}},{key:"_setAutoTrackProperties",value:function(e){this.taInstance._setAutoTrackProperties({})}},{key:"_getPath",value:function(e){return"string"==typeof e?e.replace(/^\//,""):"Abnormal values"}},{key:"onPageShare",value:function(e){if(this.config.pageShare){var t=1;try{t=getCurrentPages().length}catch(e){t=1}this.taInstance._internalTrack("$MPShare",{$share_method:"转发消息卡片",$share_depth:t,$url_path:this._getCurrentPath()})}return S.isObject(e)?e:{}}},{key:"onPageShow",value:function(e){var t;this.config.pageShow&&(t=this._getCurrentPath(),S.setQuery(e),this.referrer=t)}}]),n}(),L=function(){function r(t,e,n){var i=this,t=(s(this,r),this.taInstance=t,this.config=e||{},{});try{t=n.getLaunchOptionsSync()}catch(e){t={}}this._onShow(t),this.startTracked=!0,n.onShow(function(e){i._onShow(e)}),n.onHide(function(){var e;i.startTracked=!1,i.config.appHide&&(S.extend(e={},i.config.properties),S.isFunction(i.config.callback)&&S.extend(e,i.config.callback("appHide")),i.taInstance._internalTrack("$MPHide",e))})}return l(r,[{key:"_onShow",value:function(e){var t;S.isObject(e)||(e={}),this.startTracked||(this.config.appHide&&this.taInstance.timeEvent("$MPHide"),this.config.appShow&&(S.extend(t={},this.config.properties),S.isFunction(this.config.callback)&&S.extend(t,this.config.callback("appShow")),this.taInstance._internalTrack("$MPShow",n(n({},t),{},{$scene:String((null==(t=e)?void 0:t.scene)||(null==(t=e)?void 0:t.from)),$url_query:S.setQuery((null==(e=k.getAppOptions())?void 0:e.query)||{})}))))}}]),r}();var v=function(){function i(e,t,n){s(this,i),this.api=e,this.config=t,this._config=n}return l(i,[{key:"getConfig",value:function(){return this.config}},{key:"getStorage",value:function(e,t,n){if(!t)return"dd_mp"===this._config.platform?(t=this.api.getStorageSync({key:e}),S.isJSONString(t.data)?JSON.parse(t.data):{}):(t=this.api.getStorageSync(e),S.isJSONString(t)?JSON.parse(t):{});this.api.getStorage({key:e,success:function(e){e=S.isJSONString(e.data)?JSON.parse(e.data):{};n(e)},fail:function(){M.warn("getStorage faild"),n({})}})}},{key:"setStorage",value:function(e,t){this.api.setStorage({key:e,data:t})}},{key:"_getPlatform",value:function(){return""}},{key:"getSystemInfo",value:function(t){var n=this._config.mpPlatform;this.api.getSystemInfo({success:function(e){S.isFunction(n)?e.mp_platform=n(e):e.mp_platform=n,t.success(e),"wechat"===n&&t.complete()},complete:function(){t.complete()}})}},{key:"getNetworkType",value:function(t){S.isFunction(this.api.getNetworkType)?this.api.getNetworkType({success:function(e){t.success(e)},complete:function(){t.complete()}}):(t.success({}),t.complete())}},{key:"onNetworkStatusChange",value:function(e){S.isFunction(this.api.onNetworkStatusChange)?this.api.onNetworkStatusChange(e):e({})}},{key:"request",value:function(t){var e;if("ali_mp"===this._config.platform||"dd_mp"===this._config.platform)return(e=S.extend({},t)).headers=t.header,e.success=function(e){e.statusCode=e.status,t.success(e)},e.fail=function(e){e.errMsg=e.errorMessage,t.fail(e)},"dd_mp"===this._config.platform?this.api.httpRequest(e):this.api.request(e);try{if("taobao_mg"!==this._config.platform)return this.api.request(t);var n=t,i={},r=new XMLHttpRequest;if(r.open(n.method,n.url),n.header)for(var a in n.header)r.setRequestHeader(a,n.header[a]);return r.onreadystatechange=function(){4===r.readyState&&200===r.status?(i.statusCode=200,S.isJSONString(r.responseText)&&(i.data=JSON.parse(r.responseText)),n.success(i)):200!==r.status&&(i.errMsg="network error",n.fail(i))},r.ontimeout=function(){i.errMsg="timeout",n.fail(i)},r.send(JSON.parse(n.data)),r}catch(e){}}},{key:"initAutoTrackInstance",value:function(e,t){return S.isObject(t.autoTrack)&&(t.autoTrack.isPlugin=t.is_plugin),new(this._config.mp?$:L)(e,t.autoTrack,this.api)}},{key:"setGlobal",value:function(e,t){if(this._config.mp)M.warn("GravityAnalytics: we do not set global name for GE instance when you do not enable auto track.");else if("ali_mg"!==this._config.platform)try{GameGlobal[t]=e}catch(e){}}},{key:"getAppOptions",value:function(e){var t={};try{t=this.api.getLaunchOptionsSync()}catch(e){t={}}if(S.isFunction(e))try{this._config.mp?this.api.onAppShow(e):this.api.onShow(e)}catch(e){M.warn("Cannot register onShow callback.")}return t}},{key:"showToast",value:function(e){var t;S.isFunction(this.api.showToast)&&(t={title:e},"dd_mp"!==this._config.platform&&"ali_mp"!==this._config.platform||(t.content=e),this.api.showToast(t))}}],[{key:"createInstance",value:function(){return this._createInstance("R_CURRENT_PLATFORM")}},{key:"_createInstance",value:function(e){switch(e){case"wechat_mp":return new i(wx,{persistenceName:"GravityEngine",persistenceNameOld:"GravityEngine_wechat"},{mpPlatform:"wechat",mp:!0,platform:e});case"wechat_mg":return new i(wx,{persistenceName:"GravityEngine",persistenceNameOld:"GravityEngine_wechat_game"},{mpPlatform:"wechat",platform:e});case"qq_mp":return new i(qq,{persistenceName:"GravityEngine",persistenceNameOld:"GravityEngine_qq"},{mpPlatform:"qq",mp:!0,platform:e});case"qq_mg":return new i(qq,{persistenceName:"GravityEngine",persistenceNameOld:"GravityEngine_qq_game"},{mpPlatform:"qq",platform:e});case"baidu_mp":return new i(swan,{persistenceName:"GravityEngine",persistenceNameOld:"GravityEngine_swan"},{mpPlatform:function(e){return e.host},mp:!0,platform:e});case"baidu_mg":return new i(swan,{persistenceName:"GravityEngine",persistenceNameOld:"GravityEngine_swan_game"},{mpPlatform:function(e){return e.host},platform:e});case"taobao_mg":return new i(my,{persistenceName:"GravityEngine",persistenceNameOld:"GravityEngine_taobao_game"},{mpPlatform:"taobao",platform:e});case"tt_mg":return new i(tt,{persistenceName:"GravityEngine",persistenceNameOld:"GravityEngine_tt_game"},{mpPlatform:function(e){return e.appName},platform:e});case"tt_mp":return new i(tt,{persistenceName:"GravityEngine",persistenceNameOld:"GravityEngine_tt"},{mpPlatform:function(e){return e.appName},mp:!0,platform:e});case"ali_mp":return new i(my,{persistenceName:"GravityEngine",persistenceNameOld:"GravityEngine_ali"},{mpPlatform:function(e){return e.app},mp:!0,platform:e});case"ali_mg":return new i(my,{persistenceName:"GravityEngine",persistenceNameOld:"GravityEngine_ali_game"},{mpPlatform:function(e){return e.app},platform:e});case"dd_mp":return new i(dd,{persistenceName:"GravityEngine",persistenceNameOld:"GravityEngine_dd"},{mpPlatform:"dingding",mp:!0,platform:e});case"bl_mg":return new i(bl,{persistenceName:"GravityEngine",persistenceNameOld:"GravityEngine_bl_game"},{mpPlatform:"bilibili",platform:e});case"kuaishou_mp":return new i(ks,{persistenceName:"GravityEngine",persistenceNameOld:"GravityEngine_kuaishou_program"},{mpPlatform:"kuaishou",mp:!0,platform:e});case"kuaishou_mg":return new i(ks,{persistenceName:"GravityEngine",persistenceNameOld:"GravityEngine_kuaishou_game"},{mpPlatform:"kuaishou_game",platform:e});case"qh360_mg":return new i(qh,{persistenceName:"GravityEngine",persistenceNameOld:"GravityEngine_qh360"},{mpPlatform:"qh360",platform:e});case"tb_mp":return new i(my,{persistenceName:"GravityEngine",persistenceNameOld:"GravityEngine_tb"},{mpPlatform:"tb",mp:!0,platform:e});case"jd_mp":return new i(jd,{persistenceName:"GravityEngine",persistenceNameOld:"GravityEngine_jd"},{mpPlatform:"jd",mp:!0,platform:e});case"qh360_mp":return new i(qh,{persistenceName:"GravityEngine",persistenceNameOld:"GravityEngine_qh360"},{mpPlatform:"qh360",mp:!0,platform:e});case"WEB":return new t.createInstance}}}]),i}(),F=l(function e(t,n){var i=this;s(this,e),this.taInstance=t,this.config=n||{},this.config.appShow&&this.taInstance._internalTrack("$MPShow"),this.config.appHide&&this.taInstance.timeEvent("$MPHide"),qg.onShow(function(){var e;i.config.appHide&&i.taInstance.timeEvent("$MPHide"),i.config.appShow&&(S.extend(e={},i.config.properties),S.isFunction(i.config.callback)&&S.extend(e,i.config.callback("appShow")),i.taInstance._internalTrack("$MPShow"))}),qg.onHide(function(){var e;i.config.appHide&&(S.extend(e={},i.config.properties),S.isFunction(i.config.callback)&&S.extend(e,i.config.callback("appHide")),i.taInstance._internalTrack("$MPHide"))})}),J=function(){function e(){s(this,e),this.config={persistenceName:"gravityengine",persistenceNameOld:"gravityengine_qg_vivo_game",asyncPersistence:!0}}return l(e,[{key:"getConfig",value:function(){return this.config||{}}},{key:"getStorage",value:function(e,t,n){if(!t)return t=qg.getStorageSync({key:e}),S.isJSONString(t)?JSON.parse(t):{};qg.getStorage({key:e,success:function(e){e=S.isJSONString(e)?JSON.parse(e):{};n(e)},fail:function(){n({})}})}},{key:"setStorage",value:function(e,t){qg.setStorage({key:e,value:t})}},{key:"getSystemInfo",value:function(i){qg.getSystemInfo({success:function(e){var t=e,n=[e.osType,e.osVersionName].join(" ");t.brand=e.manufacturer,t.system=n,t.mp_platform="vivo_qg",i.success(t)},complete:function(){i.complete()}})}},{key:"getQuickDevice",value:function(n){var i={os_name:"android",android_id:"",imei:"",oaid:"",mac:"",android_version:"",api_version:0,rom:{gravityengine_qg_huawei_game:"EMUI",gravityengine_qg:"MIUI",gravityengine_qg_oppo_game:"ColorOS",gravityengine_qg_vivo_game:"FuntouchOS",gravityengine_qg_mz_game:"Flyme"}[n.platform],rom_version:"",phone_brand:"",phone_model:""};qg.getSystemInfo({success:function(e){var t;i.android_version=e.system,i.api_version=e.platformVersionCode,i.rom_version=e.COREVersion,i.phone_brand=e.brand,i.phone_model=e.model,qg.getOAID&&(e=null!=(t=null==(t=(e=qg).getOAID)?void 0:t.call(e).oaid)?t:"",i.android_id=e,i.imei=e,i.oaid=e),n.success(i)}})}},{key:"getNetworkType",value:function(n){qg.getNetworkType({success:function(e){var t=e;t.networkType=e.type,n.success(t)},complete:function(){n.complete()}})}},{key:"onNetworkStatusChange",value:function(n){qg.subscribeNetworkStatus({callback:function(e){var t=e;t.networkType=e.type,n(t)}})}},{key:"request",value:function(t){return qg.request({url:t.url,data:t.data,method:t.method,header:t.header,success:function(e){t.success(e)},fail:function(e){t.fail(e)}})}},{key:"initAutoTrackInstance",value:function(e,t){return new F(e,t.autoTrack)}},{key:"setGlobal",value:function(e,t){globalThis[t]=e}},{key:"getAppOptions",value:function(){try{if(!qg.getLaunchOptionsSync)return{};var e=qg.getLaunchOptionsSync(),t=e.referrerInfo.extraData,n=e.query.internal,i=n&&n.channel?n.channel:"";if(t)return{query:t,scene:""};if("deeplink"!==i)return{};var r,a=n.custom_params,o=JSON.parse(a).cus_origin_uri,s=new URLSearchParams(o.split("?")[1]),c={},u=function(e,t){var n,i,r,a,o="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(o)return i=!(n=!0),{s:function(){o=o.call(e)},n:function(){var e=o.next();return n=e.done,e},e:function(e){i=!0,r=e},f:function(){try{n||null==o.return||o.return()}finally{if(i)throw r}}};if(Array.isArray(e)||(o=h(e))||t&&e&&"number"==typeof e.length)return o&&(e=o),a=0,{s:t=function(){},n:function(){return a>=e.length?{done:!0}:{done:!1,value:e[a++]}},e:function(e){throw e},f:t};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(s);try{for(u.s();!(r=u.n()).done;){var l=x(r.value,2),p=l[0],f=l[1];c[p]=f}}catch(e){u.e(e)}finally{u.f()}return{query:c,scene:""}}catch(e){return{}}}},{key:"showToast",value:function(e){qg.showToast({message:e,duration:0})}}],[{key:"createInstance",value:function(){return new e}}]),e}(),U=l(function e(t,n,i){var r=this;s(this,e),this.taInstance=t,this.config=n||{},this.config.appShow&&(S.extend(t={},this.config.properties),S.isFunction(this.config.callback)&&S.extend(t,this.config.callback("appShow")),this.taInstance._internalTrack("$MPShow",t)),this.config.appHide&&this.taInstance.timeEvent("$MPHide"),i.onShow(function(){var e;r.config.appHide&&r.taInstance.timeEvent("$MPHide"),r.config.appShow&&(S.extend(e={},r.config.properties),S.isFunction(r.config.callback)&&S.extend(e,r.config.callback("appShow")),r.taInstance._internalTrack("$MPShow",e))}),i.onHide(function(){var e;r.config.appHide&&(S.extend(e={},r.config.properties),S.isFunction(r.config.callback)&&S.extend(e,r.config.callback("appHide")),r.taInstance._internalTrack("$MPHide",e))})}),m=function(){function i(e,t,n){s(this,i),this.api=e,this.config=t,this._config=n}return l(i,[{key:"getConfig",value:function(){return this.config||{}}},{key:"getStorage",value:function(e,t,n){e=localStorage.getItem(e);if(!t)return S.isJSONString(e)?JSON.parse(e):{};S.isJSONString(e)?n(JSON.parse(e)):n({})}},{key:"setStorage",value:function(e,t){localStorage.setItem(e,t)}},{key:"getSystemInfo",value:function(t){var n=this._config.mpPlatform;this.api.getSystemInfo({success:function(e){e.mp_platform=n,t.success(e)},complete:function(){t.complete()}})}},{key:"getQuickDevice",value:function(n){var i={os_name:"android",android_id:"",imei:"",oaid:"",mac:"",android_version:"",api_version:0,rom:{gravityengine_qg_huawei_game:"EMUI",gravityengine_qg:"MIUI",gravityengine_qg_oppo_game:"ColorOS",gravityengine_qg_vivo_game:"FuntouchOS",gravityengine_qg_mz_game:"Flyme"}[n.platform],rom_version:"",phone_brand:"",phone_model:""},r=this;this.api.getSystemInfo({success:function(e){function t(){n.success(i)}i.android_version=e.system,i.api_version=e.platformVersionCode,i.rom_version=e.COREVersion,i.phone_brand=e.brand,i.phone_model=e.model,r.api.getDeviceId?r.api.getDeviceId({success:function(e){i.android_id=e.deviceId,i.imei=e.deviceId,i.oaid=e.deviceId,t()}}):r.api.getOAID?r.api.getOAID({success:function(e){i.android_id=e.oaid,i.imei=e.oaid,i.oaid=e.oaid,t()}}):t()}})}},{key:"getNetworkType",value:function(t){this.api.getNetworkType({success:function(e){t.success(e)},complete:function(){t.complete()}})}},{key:"onNetworkStatusChange",value:function(t){this.api.onNetworkStatusChange({callback:function(e){t(e)}})}},{key:"request",value:function(e){var t={},n=new XMLHttpRequest;if(n.open(e.method,e.url),e.header)for(var i in e.header)n.setRequestHeader(i,e.header[i]);return n.onreadystatechange=function(){4===n.readyState&&200===n.status?(t.statusCode=200,S.isJSONString(n.responseText)&&(t.data=JSON.parse(n.responseText)),e.success(t)):200!==n.status&&(t.errMsg="network error",e.fail(t))},n.ontimeout=function(){t.errMsg="timeout",e.fail(t)},n.send(e.data),n}},{key:"initAutoTrackInstance",value:function(e,t){return new U(e,t.autoTrack,this.api)}},{key:"setGlobal",value:function(e,t){globalThis[t]=e}},{key:"getAppOptions",value:function(){return"oppo_qg"===this._config.mpPlatform?this.api.getEnterOptionsSync():this.api.getLaunchOptionsSync()}},{key:"showToast",value:function(e){this.api.showToast({title:e,icon:"none",duration:2e3})}}],[{key:"createInstance",value:function(){return this._createInstance("R_CURRENT_PLATFORM")}},{key:"_createInstance",value:function(e){switch(e){case"oppo":return new i(qg,{persistenceName:"gravityengine",persistenceNameOld:"gravityengine_qg_oppo_game"},{mpPlatform:"oppo_qg"});case"huawei":return new i(hbs,{persistenceName:"gravityengine",persistenceNameOld:"gravityengine_qg_huawei_game"},{mpPlatform:"huawei_qg"});case"mz":return new i(qg,{persistenceName:"gravityengine",persistenceNameOld:"gravityengine_qg_mz_game"},{mpPlatform:"mz"});case"xiaomi":return new i(qg,{persistenceName:"gravityengine",persistenceNameOld:"gravityengine_qg"},{mpPlatform:"xiaomi"})}}}]),i}(),H=function(){function e(){s(this,e)}return l(e,null,[{key:"createInstance",value:function(){var n,e=Object.freeze({WECHAT_GAME:104,QQ_PLAY:105,BAIDU_GAME:107,VIVO_GAME:108,OPPO_GAME:109,HUAWEI_GAME:110,XIAOMI_GAME:111,BYTEDANCE_GAME:117,QTT_GAME:116,LINKSURE:119,ALIPAY_GAME:113,TAOBAO_MINIGAME:121,TAOBAO_MINI_GAME:"TAOBAO_MINI_GAME",WECHAT_MINI_GAME:"WECHAT_GAME",BAIDU_MINI_GAME:"BAIDU_MINI_GAME",XIAOMI_QUICK_GAME:"XIAOMI_QUICK_GAME",OPPO_MINI_GAME:"OPPO_MINI_GAME",VIVO_MINI_GAME:"VIVO_MINI_GAME",HUAWEI_QUICK_GAME:"HUAWEI_QUICK_GAME",BYTEDANCE_MINI_GAME:"BYTEDANCE_MINI_GAME",QTT_MINI_GAME:"QTT_MINI_GAME",LINKSURE_MINI_GAME:"LINKSURE_MINI_GAME",ALIPAY_MINI_GAME:"ALIPAY_MINI_GAME"});return cc.sys.platform===e.WECHAT_GAME||cc.sys.platform===e.WECHAT_MINI_GAME?v._createInstance("wechat_mg"):cc.sys.platform===e.BAIDU_GAME||cc.sys.platform===e.BAIDU_MIN_GAME?v._createInstance("baidu_mg"):cc.sys.platform===e.TAOBAO_MINI_GAME||cc.sys.platform===e.TAOBAO_MINIGAME?v._createInstance("taobao_mg"):cc.sys.platform===e.VIVO_GAME||cc.sys.platform===e.VIVO_MINI_GAME?J.createInstance():cc.sys.platform===e.QQ_PLAY?v._createInstance("qq_mg"):cc.sys.platform===e.OPPO_GAME||cc.sys.platform===e.OPPO_MINI_GAME?m._createInstance("oppo"):cc.sys.platform===e.HUAWEI_GAME||cc.sys.platform===e.HUAWEI_QUICK_GAME?m._createInstance("huawei"):cc.sys.platform===e.XIAOMI_GAME||cc.sys.platform===e.XIAOMI_QUICK_GAME?m._createInstance("xiaomi"):cc.sys.platform===e.ALIPAY_GAME||cc.sys.platform===e.ALIPAY_MINI_GAME?v._createInstance("ali_mg"):cc.sys.platform===e.BYTEDANCE_GAME||cc.sys.platform===e.BYTEDANCE_MINI_GAME?v._createInstance("tt_mg"):((n=t.createInstance())._sysCallback=function(){return{system:cc.sys.os.replace(" ","")+" "+cc.sys.osVersion}},n.getNetworkType=function(e){var t={};switch(cc.sys.getNetworkType()){case cc.sys.NetworkType.LAN:t.networkType="WIFI";break;case cc.sys.NetworkType.WWAN:t.networkType="WWAN";break;default:t.networkType="NONE"}e.success(t),e.complete()},n.getSystemInfo=function(e){var t={mp_platform:cc.sys.platform.toString(),system:n._getOs(),screenWidth:window.screen.width,screenHeight:window.screen.height};n._sysCallback&&(t=S.extend(t,n._sysCallback(e))),e.success(t),e.complete()},n)}}]),e}(),k=function(){function e(){s(this,e)}return l(e,null,[{key:"_getCurrentPlatform",value:function(){return this.currentPlatform||(this.currentPlatform=H.createInstance())}},{key:"getConfig",value:function(){return this._getCurrentPlatform().getConfig()}},{key:"getStorage",value:function(e,t,n){return this._getCurrentPlatform().getStorage(e,t,n)}},{key:"setStorage",value:function(e,t){return this._getCurrentPlatform().setStorage(e,t)}},{key:"getSystemInfo",value:function(e){return this._getCurrentPlatform().getSystemInfo(e)}},{key:"getNetworkType",value:function(e){return this._getCurrentPlatform().getNetworkType(e)}},{key:"getQuickDevice",value:function(e){return this._getCurrentPlatform().getQuickDevice(e)}},{key:"onNetworkStatusChange",value:function(e){this._getCurrentPlatform().onNetworkStatusChange(e)}},{key:"request",value:function(e){return this._getCurrentPlatform().request(e)}},{key:"initAutoTrackInstance",value:function(e,t){return this._getCurrentPlatform().initAutoTrackInstance(e,t)}},{key:"setGlobal",value:function(e,t){e&&t&&this._getCurrentPlatform().setGlobal(e,t)}},{key:"getAppOptions",value:function(e){return this._getCurrentPlatform().getAppOptions(e)}},{key:"showDebugToast",value:function(e){this._getCurrentPlatform().showToast(e)}}]),e}(),S={},e=Array.prototype,y=Object.prototype,_=e.slice,I=y.toString,P=Object.prototype.hasOwnProperty,N=e.forEach,y=Array.isArray,A={};function O(){return new RegExp(/(.*?)\.?([^.]*?)\.(com|net|org|biz|ws|in|me|co\.uk|co|org\.uk|ltd\.uk|plc\.uk|me\.uk|edu|mil|br\.com|cn\.com|eu\.com|hu\.com|no\.com|qc\.com|sa\.com|se\.com|se\.net|us\.com|uy\.com|ac|co\.ac|gv\.ac|or\.ac|ac\.ac|af|am|as|at|ac\.at|co\.at|gv\.at|or\.at|asn\.au|com\.au|edu\.au|org\.au|net\.au|id\.au|be|ac\.be|adm\.br|adv\.br|am\.br|arq\.br|art\.br|bio\.br|cng\.br|cnt\.br|com\.br|ecn\.br|eng\.br|esp\.br|etc\.br|eti\.br|fm\.br|fot\.br|fst\.br|g12\.br|gov\.br|ind\.br|inf\.br|jor\.br|lel\.br|med\.br|mil\.br|net\.br|nom\.br|ntr\.br|odo\.br|org\.br|ppg\.br|pro\.br|psc\.br|psi\.br|rec\.br|slg\.br|tmp\.br|tur\.br|tv\.br|vet\.br|zlg\.br|br|ab\.ca|bc\.ca|mb\.ca|nb\.ca|nf\.ca|ns\.ca|nt\.ca|on\.ca|pe\.ca|qc\.ca|sk\.ca|yk\.ca|ca|cc|ac\.cn|net\.cn|com\.cn|edu\.cn|gov\.cn|org\.cn|bj\.cn|sh\.cn|tj\.cn|cq\.cn|he\.cn|nm\.cn|ln\.cn|jl\.cn|hl\.cn|js\.cn|zj\.cn|ah\.cn|gd\.cn|gx\.cn|hi\.cn|sc\.cn|gz\.cn|yn\.cn|xz\.cn|sn\.cn|gs\.cn|qh\.cn|nx\.cn|xj\.cn|tw\.cn|hk\.cn|mo\.cn|cn|cx|cz|de|dk|fo|com\.ec|tm\.fr|com\.fr|asso\.fr|presse\.fr|fr|gf|gs|co\.il|net\.il|ac\.il|k12\.il|gov\.il|muni\.il|ac\.in|co\.in|org\.in|ernet\.in|gov\.in|net\.in|res\.in|is|it|ac\.jp|co\.jp|go\.jp|or\.jp|ne\.jp|ac\.kr|co\.kr|go\.kr|ne\.kr|nm\.kr|or\.kr|li|lt|lu|asso\.mc|tm\.mc|com\.mm|org\.mm|net\.mm|edu\.mm|gov\.mm|ms|nl|no|nu|pl|ro|org\.ro|store\.ro|tm\.ro|firm\.ro|www\.ro|arts\.ro|rec\.ro|info\.ro|nom\.ro|nt\.ro|se|si|com\.sg|org\.sg|net\.sg|gov\.sg|sk|st|tf|ac\.th|co\.th|go\.th|mi\.th|net\.th|or\.th|tm|to|com\.tr|edu\.tr|gov\.tr|k12\.tr|net\.tr|org\.tr|com\.tw|org\.tw|net\.tw|ac\.uk|uk\.com|uk\.net|gb\.com|gb\.net|vg|sh|kz|ch|info|ua|gov|name|pro|ie|hk|com\.hk|org\.hk|net\.hk|edu\.hk|us|tk|cd|by|ad|lv|eu\.lv|bz|es|jp|cl|ag|mobi|eu|co\.nz|org\.nz|net\.nz|maori\.nz|iwi\.nz|io|la|md|sc|sg|vc|tw|travel|my|se|tv|pt|com\.pt|edu\.pt|asia|fi|com\.ve|net\.ve|fi|org\.ve|web\.ve|info\.ve|co\.ve|tel|im|gr|ru|net\.ru|org\.ru|hr|com\.hr|ly|xyz)$/)}function E(e,t){var n=e.charAt(0),t=t.split(n);return n===e?t:t[(e=parseInt(e.substring(1),10))<0?t.length+e:e-1]}function C(e,t){for(var n,i=e.charAt(0),r=t.split("&"),a=[],o={},s=e.substring(1),c=0,u=r.length;c<u;c++)if(""!==(a=(a=r[c].match(/(.*?)=(.*)/))||[r[c],r[c],""])[1].replace(/\s/g,"")){if(a[2]=(n=a[2]||"",S.decodeURIComponent(n.replace(/\+/g," "))),s===a[1])return a[2];(n=a[1].match(/(.*)\[([0-9]+)\]/))?(o[n[1]]=o[n[1]]||[],o[n[1]][n[2]]=a[2]):o[a[1]]=a[2]}return i===e?o:o[s]}S.isNumber=function(e){return"number"==typeof e?0==e-e:"string"==typeof e&&""!==e.trim()&&(Number.isFinite?Number.isFinite(+e):isFinite(+e))},S.each=function(e,t,n){if(null==e)return!1;if(N&&e.forEach===N)e.forEach(t,n);else if(e.length===+e.length){for(var i=0,r=e.length;i<r;i++)if(i in e&&t.call(n,e[i],i,e)===A)return!1}else for(var a in e)if(P.call(e,a)&&t.call(n,e[a],a,e)===A)return!1},S.sleep=function(t){return new Promise(function(e){return setTimeout(e,t)})},S.extend=function(n){return S.each(_.call(arguments,1),function(e){for(var t in e)void 0!==e[t]&&(n[t]=e[t])}),n},S.extend2Layers=function(n){return S.each(_.call(arguments,1),function(e){for(var t in e)void 0!==e[t]&&(S.isObject(e[t])&&S.isObject(n[t])?S.extend(n[t],e[t]):n[t]=e[t])}),n},S.isArray=y||function(e){return"[object Array]"===I.call(e)},S.isFunction=function(e){try{return"function"==typeof e}catch(e){return!1}},S.isPromise=function(e){return"[object Promise]"===I.call(e)&&null!=e},S.isObject=function(e){return"[object Object]"===I.call(e)&&null!=e},S.isEmptyObject=function(e){if(S.isObject(e)){for(var t in e)if(P.call(e,t))return!1;return!0}return!1},S.isUndefined=function(e){return void 0===e},S.isString=function(e){return"[object String]"===I.call(e)},S.isDate=function(e){return"[object Date]"===I.call(e)},S.isBoolean=function(e){return"[object Boolean]"===I.call(e)},S.isNumber=function(e){return"[object Number]"===I.call(e)&&/[\d\.]+/.test(String(e))},S.isJSONString=function(e){try{JSON.parse(e)}catch(e){return!1}return!0},S.decodeURIComponent=function(t){var n="";try{n=decodeURIComponent(t)}catch(e){n=t}return n},S.encodeURIComponent=function(t){var n="";try{n=encodeURIComponent(t)}catch(e){n=t}return n},S.utf8Encode=function(e){for(var t,n="",i=t=0,r=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,a=0;a<r;a++){var o=e.charCodeAt(a),s=null;o<128?t++:s=127<o&&o<2048?String.fromCharCode(o>>6|192,63&o|128):String.fromCharCode(o>>12|224,o>>6&63|128,63&o|128),null!==s&&(i<t&&(n+=e.substring(i,t)),n+=s,i=t=a+1)}return i<t&&(n+=e.substring(i,e.length)),n},S.base64Encode=function(e){var t,n,i,r,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,s=0,c="",u=[];if(!e)return e;for(e=S.utf8Encode(e);t=(r=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>12&63,n=r>>6&63,i=63&r,u[s++]=a.charAt(r>>18&63)+a.charAt(t)+a.charAt(n)+a.charAt(i),o<e.length;);switch(c=u.join(""),e.length%3){case 1:c=c.slice(0,-2)+"==";break;case 2:c=c.slice(0,-1)+"="}return c},S.encodeDates=function(i){return S.each(i,function(e,t){if(S.isDate(e))i[t]=S.formatDate(e);else if(S.isObject(e))i[t]=S.encodeDates(e);else if(S.isArray(e))for(var n=0;n<e.length;n++)S.isDate(e[n])&&(i[t][n]=S.formatDate(e[n]))}),i},S.formatDate=function(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())+"."+((e=e.getMilliseconds())<100&&9<e?"0"+e:e<10?"00"+e:e)},S.searchObjDate=function(n){try{(S.isObject(n)||S.isArray(n))&&S.each(n,function(e,t){S.isObject(e)||S.isArray(e)?S.searchObjDate(n[t]):S.isDate(e)&&(n[t]=S.formatDate(e))})}catch(e){M.warn(e)}},S.UUID=function(){var e=(new Date).getTime();return String(Math.random()).replace(".","").slice(1,11)+"-"+e},S.UUIDv4=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})},S.setMpPlatform=function(e){S.mpPlatform=e},S.getMpPlatform=function(){return S.mpPlatform},S.createExtraHeaders=function(){return{"GE-Integration-Type":g,"GE-Integration-Version":d,"GE-Integration-Count":"1","GE-Integration-Extra":S.getMpPlatform()}},S.checkAppId=function(e){if("number"==typeof e)e=String(e);else if("string"!=typeof e)return"";return e=e.replace(/\s*/g,"")},S.checkUrl=function(e){return e=e.replace(/\s*/g,""),e=S.url("basic",e)},S.url=function(e,t){var n,i={};if("tld?"===e)return O();if(t=t||window.location.toString(),!e)return t;if(e=e.toString(),t.match(/^mailto:([^/].+)/))n=t.match(/^mailto:([^/].+)/),i.protocol="mailto",i.email=n[1];else{if((t=t.match(/(.*?)\/#!(.*)/)?(n=t.match(/(.*?)\/#!(.*)/))[1]+n[2]:t).match(/(.*?)#(.*)/)&&(n=t.match(/(.*?)#(.*)/),i.hash=n[2],t=n[1]),i.hash&&e.match(/^#/))return C(e,i.hash);if(t.match(/(.*?)\?(.*)/)&&(n=t.match(/(.*?)\?(.*)/),i.query=n[2],t=n[1]),i.query&&e.match(/^\?/))return C(e,i.query);if(t.match(/(.*?):?\/\/(.*)/)&&(n=t.match(/(.*?):?\/\/(.*)/),i.protocol=n[1].toLowerCase(),t=n[2]),t.match(/(.*?)(\/.*)/)&&(n=t.match(/(.*?)(\/.*)/),i.path=n[2],t=n[1]),i.path=(i.path||"").replace(/^([^/])/,"/$1").replace(/\/$/,""),(e=e.match(/^[-0-9]+$/)?e.replace(/^([^/])/,"/$1"):e).match(/^\//))return E(e,i.path.substring(1));if((n=(n=E("/-1",i.path.substring(1)))&&n.match(/(.*?)\.(.*)/))&&(i.file=n[0],i.filename=n[1],i.fileext=n[2]),t.match(/(.*):([0-9]+)$/)&&(n=t.match(/(.*):([0-9]+)$/),i.port=n[2],t=n[1]),t.match(/(.*?)@(.*)/)&&(n=t.match(/(.*?)@(.*)/),i.auth=n[1],t=n[2]),i.auth&&(n=i.auth.match(/(.*):(.*)/),i.user=n?n[1]:i.auth,i.pass=n?n[2]:void 0),i.hostname=t.toLowerCase(),"."===e.charAt(0))return E(e,i.hostname);O()&&(n=i.hostname.match(O()))&&(i.tld=n[3],i.domain=n[2]?n[2]+"."+n[3]:void 0,i.sub=n[1]||void 0);t=i.port?":"+i.port:"";i.protocol=i.protocol||window.location.protocol.replace(":",""),i.port=i.port||("https"===i.protocol?"443":"80"),i.protocol=i.protocol||("443"===i.port?"https":"http"),i.basic=i.protocol+"://"+i.hostname+t}return e in i?i[e]:"{}"===e?i:""},S.createString=function(e){for(var t=e,n=Math.random().toString(36).substr(2);n.length<t;)n+=Math.random().toString(36).substr(2);return n=n.substr(0,e)},S.createAesKey=function(){return S.createString(16)},S.setQuery=function(e){try{if(!S.isObject(e))return"";var t,n=k.getConfig().persistenceNameOld.includes("GravityEngine_ali"),i=[];for(t in e)(n||e.hasOwnProperty(t))&&i.push(encodeURIComponent(t)+"="+encodeURIComponent(e[t]));return i.join("&")}catch(e){return""}},S.generateEncryptyData=function(e,t){if(void 0!==t){var n=t.publicKey,t=t.version;if(void 0!==n&&void 0!==t&&"undefined"!=typeof CryptoJS&&"undefined"!=typeof JSEncrypt){var i=S.createAesKey();try{var r=CryptoJS.enc.Utf8.parse(i),a=CryptoJS.enc.Utf8.parse(JSON.stringify(e)),o=S.isUndefined(CryptoJS.pad.Pkcs7)?CryptoJS.pad.PKCS7:CryptoJS.pad.Pkcs7,s=CryptoJS.AES.encrypt(a,r,{mode:CryptoJS.mode.ECB,padding:o}).toString(),c=new JSEncrypt,u=(c.setPublicKey(n),c.encrypt(i));return!1===u?(M.warn("私钥加密失败,返回原数据"),e):{pkv:t,ekey:u,payload:s}}catch(e){M.warn("数据加密失败,返回原数据: "+e)}}}return e};var M="object"===r(M)?M:{},j=(M.info=function(){if("object"===("undefined"==typeof console?"undefined":r(console))&&console.log&&M.enabled)try{return console.log.apply(console,arguments)}catch(e){console.log(arguments[0])}},M.warn=function(){if("object"===("undefined"==typeof console?"undefined":r(console))&&console.log&&M.enabled)try{return console.warn.apply(console,arguments)}catch(e){console.warn(arguments[0])}},/^\$?[a-zA-Z][a-zA-Z0-9_]{0,49}$/),T=function(){function e(){s(this,e)}return l(e,null,[{key:"stripProperties",value:function(e){return S.isObject(e)&&S.each(e,function(e,t){S.isString(e)||S.isNumber(e)||S.isDate(e)||S.isBoolean(e)||S.isArray(e)||S.isObject(e)||M.warn("Your data -",t,e,"- format does not meet requirements and may not be stored correctly. Attribute values only support String, Number, Date, Boolean, Array, Object")}),e}},{key:"_checkPropertiesKey",value:function(e){var n=!0;return S.each(e,function(e,t){j.test(t)||(M.warn("Invalid KEY: "+t),n=!1)}),n}},{key:"event",value:function(e){return!(!S.isString(e)||!j.test(e))||(M.warn("Check the parameter format. The eventName must start with an English letter and contain no more than 50 characters including letters, digits, and underscores: "+e),!1)}},{key:"propertyName",value:function(e){return!(!S.isString(e)||!j.test(e))||(M.warn("Check the parameter format. PropertyName must start with a letter and contain letters, digits, and underscores (_). The value is a string of no more than 50 characters: "+e),!1)}},{key:"properties",value:function(e){return this.stripProperties(e),!(e&&(S.isObject(e)?!this._checkPropertiesKey(e)&&(M.warn("Check the parameter format. The properties key must start with a letter, contain digits, letters, and underscores (_), and contain a maximum of 50 characters"),1):(M.warn("properties can be none, but it must be an object"),1)))}},{key:"propertiesMust",value:function(e){return this.stripProperties(e),void 0===e||!S.isObject(e)||S.isEmptyObject(e)?(M.warn("properties must be an object with a value"),!1):!!this._checkPropertiesKey(e)||(M.warn("Check the parameter format. The properties key must start with a letter, contain digits, letters, and underscores (_), and contain a maximum of 50 characters"),!1)}},{key:"userId",value:function(e){return!(!S.isString(e)||!/^.{1,64}$/.test(e))||(M.warn("The user ID must be a string of less than 64 characters and cannot be null"),!1)}},{key:"userAddProperties",value:function(e){if(!this.propertiesMust(e))return!1;for(var t in e)if(!S.isNumber(e[t]))return M.warn("The attributes of userAdd need to be Number"),!1;return!0}},{key:"userAppendProperties",value:function(e){if(!this.propertiesMust(e))return!1;for(var t in e)if(!S.isArray(e[t]))return M.warn("The attribute of userAppend must be Array"),!1;return!0}}]),e}(),R=function(){function o(e,t,n,i,r,a){s(this,o),this.data=e,this.serverUrl=t,this.callback=a,this.debugMode=r,this.tryCount=S.isNumber(n)?n:1,this.permissionTryCount=6,this.timeout=S.isNumber(i)?i:3e3,this.taClassName="HttpTask"}return l(o,[{key:"run",value:function(){var n=this,e=S.createExtraHeaders(),t=(e["content-type"]="application/json","debug"===this.debugMode&&(e["Turbo-Debug-Mode"]=1),k.request({url:this.serverUrl,method:"POST",data:this.data,header:e,success:function(e){var t;0===(null==e||null==(t=e.data)?void 0:t.code)?n.onSuccess(e):n.onFailed(e)},fail:function(e){n.onFailed(e)}}));setTimeout(function(){if((S.isObject(t)||S.isPromise(t))&&S.isFunction(t.abort))try{t.abort()}catch(e){}},this.timeout)}},{key:"onSuccess",value:function(e){var t,n;200===e.statusCode?(n="Data Verified",null!=e&&null!=(t=e.data)&&null!=(t=t.extra)&&null!=(t=t.errors)&&t.length&&(n=e.data.extra.errors),this.callback({code:null==e||null==(t=e.data)?void 0:t.code,msg:n})):this.callback({code:(null==e?void 0:e.statusCode)||-3,msg:e.statusCode})}},{key:"onFailed",value:function(e){var t,n=this;0<--this.tryCount?setTimeout(function(){n.run()},1e3):this.callback({code:-3,msg:"".concat(null==e||null==(t=e.data)?void 0:t.msg,":").concat(null==e||null==(t=e.data)||null==(e=t.extra)?void 0:e.error)})}}]),o}(),V=new(function(){function e(){s(this,e),this.items=[],this.isRunning=!1,this.showDebug=!1}return l(e,[{key:"enqueue",value:function(e,t,n){var i=!(3<arguments.length&&void 0!==arguments[3])||arguments[3],r="debug"===n.debugMode,a=this,e=new R(JSON.stringify(e),t,n.maxRetries,n.sendTimeout,n.debugMode,function(e){a.isRunning=!1,S.isFunction(n.callback)&&n.callback(e),a._runNext(r),r&&M.info("code ".concat(e.code," and msg is,"),e.msg)});!0===i?(this.items.push(e),this._runNext(r)):e.run()}},{key:"_dequeue",value:function(){return this.items.shift()}},{key:"_runNext",value:function(e){if(0<this.items.length&&!this.isRunning)if(this.isRunning=!0,e)this._dequeue().run();else{for(var t=this.items.splice(0,this.items.length),e=t[0],n=JSON.parse(e.data),i=1;i<t.length;i++){var r=t[i],r=JSON.parse(r.data);n.event_list=n.event_list.concat(r.event_list)}var a=(new Date).getTime();n.$flush_time=a,new R(JSON.stringify(n),e.serverUrl,e.tryCount,e.timeout,null==e?void 0:e.debugMode,e.callback).run()}}}]),e}()),z={name:"GravityEngine",is_plugin:!1,maxRetries:3,sendTimeout:5e3,enablePersistence:!0,asyncPersistence:!1,strict:!1,debugMode:"none"},D={properties:{$lib_version:d,$lib:q,$scene:"",$today_first_scene:""},getSystemInfo:function(e){var n=this;k.onNetworkStatusChange(function(e){n.properties.$network_type=e.networkType}),k.getNetworkType({success:function(e){n.properties.$network_type=e.networkType},complete:function(){k.getSystemInfo({success:function(e){M.info(JSON.stringify(e,null,4));var t={$manufacturer:e.brand,$brand:e.brand,$model:e.model,$screen_width:Number(e.screenWidth),$screen_height:Number(e.screenHeight),$system_language:e.language,$os:e.platform,$os_version:e.system};S.extend(n.properties,t),S.setMpPlatform(e.mp_platform)},complete:function(){e()}})}})}},W=function(){function e(t,n){var i=this;s(this,e),this.enabled=t.enablePersistence,this.enabled?(t.isChildInstance?(this.name=t.persistenceName+"_"+t.name,this.nameOld=t.persistenceNameOld+"_"+t.name):(this.name=t.persistenceName,this.nameOld=t.persistenceNameOld),t.asyncPersistence?(this._state={},k.getStorage(this.name,!0,function(e){S.isEmptyObject(e)?k.getStorage(i.nameOld,!0,function(e){i._state=S.extend2Layers({},e,i._state),i._init(t,n),i._save()}):(i._state=S.extend2Layers({},e,i._state),i._init(t,n),i._save())})):(this._state=k.getStorage(this.name)||{},S.isEmptyObject(this._state)&&(this._state=k.getStorage(this.nameOld)||{}),this._init(t,n))):(this._state={},this._init(t,n))}return l(e,[{key:"_init",value:function(e,t){this.getDistinctId()||this.setDistinctId(S.UUID()),e.isChildInstance||this.getDeviceId()||this._setDeviceId(S.UUID()),this.initComplete=!0,"function"==typeof t&&t();var e=k.getStorage(this.name),t=null==e?void 0:e.current_first_scene_date,n=null==e?void 0:e.current_first_scene,i=(new Date).toLocaleDateString();n&&t&&t===i?D.properties.$today_first_scene=String(null==e?void 0:e.current_first_scene):(e=String((null==(n=k.getAppOptions())?void 0:n.scene)||(null==(t=k.getAppOptions())?void 0:t.from)),D.properties.$today_first_scene=e,this._state.current_first_scene=e,this._state.current_first_scene_date=i),this._save()}},{key:"_save",value:function(){this.enabled&&this.initComplete&&k.setStorage(this.name,JSON.stringify(this._state))}},{key:"_set",value:function(e,t){var n,i=this;"string"==typeof e?(n={})[e]=t:"object"===r(e)&&(n=e),S.each(n,function(e,t){i._state[t]=e}),this._save()}},{key:"_get",value:function(e){return this._state[e]}},{key:"setEventTimer",value:function(e,t){var n=this._state.event_timers||{};n[e]=t,this._set("event_timers",n)}},{key:"removeEventTimer",value:function(e){var t=(this._state.event_timers||{})[e];return S.isUndefined(t)||(delete this._state.event_timers[e],this._save()),t}},{key:"getDeviceId",value:function(){return this._state.device_id}},{key:"_setDeviceId",value:function(e){this.getDeviceId()?M.warn("cannot modify the device id."):this._set("device_id",e)}},{key:"getDistinctId",value:function(){return this._state.distinct_id}},{key:"setDistinctId",value:function(e){this._set("distinct_id",e)}},{key:"getAccountId",value:function(){return this._state.account_id}},{key:"setAccountId",value:function(e){this._set("account_id",e)}},{key:"getSuperProperties",value:function(){return this._state.props||{}}},{key:"setSuperProperties",value:function(e,t){t=t?e:S.extend(this.getSuperProperties(),e);this._set("props",t)}}]),e}();function G(){return k.getConfig().persistenceNameOld}var Q=function(){function n(e){s(this,n),e.appId=S.checkAppId((null==e?void 0:e.clientId)||""),e.accessToken=e.accessToken,e.accessToken||console.warn("GravityAnalytics: accessToken must be required"),e.serverUrl="".concat(b,"/event/collect/?access_token=").concat(e.accessToken);var t=S.extend({},z,k.getConfig());S.isObject(e)?this.config=S.extend(t,e):this.config=t,this._init(this.config)}var e,t;return l(n,[{key:"_init",value:function(e){var t=this,n=(this.name=e.name,this.appId=e.clientId,this.accessToken=e.accessToken,e.serverUrl||e.server_url),n=(this.serverUrl=n,this.serverDebugUrl=n,this.configUrl=n+"/config",this.autoTrackProperties={},this._queue=[],this.config.syncBatchSize=100,this.config.syncInterval=60,e.isChildInstance?this._state={}:(M.enabled="debug"===e.debugMode,this.instances=[],this._state={getSystemInfo:!1,initComplete:!1},D.getSystemInfo(function(){t._updateState({getSystemInfo:!0})}),k.setGlobal(this,this.name)),D.properties.$scene=String((null==(n=k.getAppOptions())?void 0:n.scene)||(null==(n=k.getAppOptions())?void 0:n.from)),this.store=new W(e,function(){t.config.asyncPersistence&&S.isFunction(t.config.persistenceComplete)&&t.config.persistenceComplete(t),t._updateState()}),this.enabled=!S.isBoolean(this.store._get("ge_enabled"))||this.store._get("ge_enabled"),this.isOptOut=!!S.isBoolean(this.store._get("ge_isOptOut"))&&this.store._get("ge_isOptOut"),G()),i="GravityEngine_quick_mp"===n;(i||"GravityEngine_wechat_game"===n||"GravityEngine_taobao_game"===n||"GravityEngine_tt_game"===n||"GravityEngine_ali_game"===n||n.includes("gravityengine_qg"))&&null!=e&&null!=(n=e.autoTrack)&&n.appLaunch&&this.track(i?"$AppStart":"$MPLaunch",{$url_query:S.setQuery(this.getQuery())}),!e.isChildInstance&&e.autoTrack&&(this.autoTrack=k.initAutoTrackInstance(this,e))}},{key:"updateConfig",value:function(e,t){}},{key:"initInstance",value:function(e,t){if(!this.config.isChildInstance)return S.isString(e)&&e!==this.name&&S.isUndefined(this[e])?(t=new n(S.extend({},this.config,{enablePersistence:!1,isChildInstance:!0,name:e},t)),this[e]=t,this.instances.push(e),this[e]._state=this._state,t):void M.warn("initInstance() failed due to the name is invalid: "+e);M.warn("initInstance() cannot be called on child instance")}},{key:"lightInstance",value:function(e){return this[e]}},{key:"_setAutoTrackProperties",value:function(e){S.extend(this.autoTrackProperties,e)}},{key:"setupAndStart",value:function(e){if(null!=e&&e.clientId&&(this.config.appId=e.clientId,this.appId=e.clientId),this._state.initComplete)return!1;this._updateState({initComplete:!0})}},{key:"_isReady",value:function(){return this._state.getSystemInfo&&this._state.initComplete&&this.store.initComplete&&this.config.appId&&this.config.accessToken}},{key:"_updateState",value:function(e){var t=this;S.isObject(e)&&S.extend(this._state,e),this._onStateChange(),S.each(this.instances,function(e){t[e]._onStateChange()})}},{key:"_onStateChange",value:function(){var t=this;this._isReady()&&this._queue&&0<this._queue.length&&(S.each(this._queue,function(e){t[e[0]].apply(t,_.call(e[1]))}),this._queue=[])}},{key:"_hasDisabled",value:function(){var e=!this.enabled||this.isOptOut;return e&&M.info("GravityEngine is Pause or Stop!"),e}},{key:"_sendRequest",value:function(e,t,n){if(!this._hasDisabled())if(!S.isUndefined(this.config.disableEventList)&&this.config.disableEventList.includes(e.eventName))M.info("disabled Event : "+e.eventName);else{t=S.isDate(t)?t:new Date;var t={event_list:[{type:e.type,time:new Date(t).getTime()}]},i=(t.event_list[0].event=e.eventName,"track"===e.type?(t.event_list[0].properties=this.getSendProperties(),i=this.store.removeEventTimer(e.eventName),S.isUndefined(i)||(i=(new Date).getTime()-i,86400<(i=parseFloat((i/1e3).toFixed(3)))?i=86400:i<0&&(i=0),t.event_list[0].properties.$event_duration=i)):t.event_list[0].properties={},S.isObject(e.properties)&&!S.isEmptyObject(e.properties)&&S.extend(t.event_list[0].properties,e.properties),S.searchObjDate(t.event_list[0]),t.client_id=this.appId,M.info(JSON.stringify(t,null,4)),this.serverUrl);if(S.isBoolean(this.config.enableEncrypt)&&1==this.config.enableEncrypt&&(t.event_list[0]=S.generateEncryptyData(t.event_list[0],void 0)),n){var r,n=new FormData;"debug"===this.config.debugMode?(n.append("source","client"),n.append("appid",this.appId),n.append("deviceId",this.getDeviceId()),n.append("data",JSON.stringify(t.event_list[0]))):(r=S.base64Encode(JSON.stringify(t)),n.append("data",r));try{navigator.sendBeacon(i,n)}catch(e){}S.isFunction(e.onComplete)&&e.onComplete({statusCode:200})}else V.enqueue(t,i,{maxRetries:this.config.maxRetries,sendTimeout:this.config.sendTimeout,callback:e.onComplete,debugMode:this.config.debugMode})}}},{key:"_isObjectParams",value:function(e){return S.isObject(e)&&S.isFunction(e.onComplete)}},{key:"track",value:function(e,t,n,i){var r;this._hasDisabled()||(this._isObjectParams(e)&&(e=(r=e).eventName,t=r.properties,n=r.time,i=r.onComplete),T.event(e)&&T.properties(t)||!this.config.strict?this._internalTrack(e,t,n,i):S.isFunction(i)&&i({code:-1,msg:"invalid parameters"}))}},{key:"_internalTrack",value:function(e,t,n,i,r){this._hasDisabled()||(n=S.isDate(n)?n:new Date,this._isReady()?this._sendRequest({type:"track",eventName:e,properties:t,onComplete:i},n,r):this._queue.push(["_internalTrack",[e,t,n,i]]))}},{key:"userSet",value:function(e,t,n){var i;this._hasDisabled()||(this._isObjectParams(e)&&(e=(i=e).properties,t=i.time,n=i.onComplete),T.propertiesMust(e)||!this.config.strict?(t=S.isDate(t)?t:new Date,this._isReady()?this._sendRequest({type:"profile",eventName:"profile_set",properties:e,onComplete:n},t):this._queue.push(["userSet",[e,t,n]])):(M.warn("calling userSet failed due to invalid arguments"),S.isFunction(n)&&n({code:-1,msg:"invalid parameters"})))}},{key:"userSetOnce",value:function(e,t,n){var i;this._hasDisabled()||(this._isObjectParams(e)&&(e=(i=e).properties,t=i.time,n=i.onComplete),T.propertiesMust(e)||!this.config.strict?(t=S.isDate(t)?t:new Date,this._isReady()?this._sendRequest({type:"profile",eventName:"profile_set_once",properties:e,onComplete:n},t):this._queue.push(["userSetOnce",[e,t,n]])):(M.warn("calling userSetOnce failed due to invalid arguments"),S.isFunction(n)&&n({code:-1,msg:"invalid parameters"})))}},{key:"userAdd",value:function(e,t,n){var i;this._hasDisabled()||(this._isObjectParams(e)&&(e=(i=e).properties,t=i.time,n=i.onComplete),T.propertiesMust(e)||!this.config.strict?(t=S.isDate(t)?t:new Date,this._isReady()?this._sendRequest({type:"profile",eventName:"profile_increment",properties:e,onComplete:n},t):this._queue.push(["userAdd",[e,t,n]])):(M.warn("calling userAdd failed due to invalid arguments"),S.isFunction(n)&&n({code:-1,msg:"invalid parameters"})))}},{key:"userNumberMax",value:function(e,t,n){if(!this._hasDisabled()){var i,r,a;for(r in this._isObjectParams(e)&&(e=(i=e).properties,t=i.time,n=i.onComplete),e)if("number"!=typeof e[r])return a="The key ".concat(r," must be type of number"),console.warn(a),void(S.isFunction(n)&&n({code:-1,msg:a}));T.propertiesMust(e)||!this.config.strict?(t=S.isDate(t)?t:new Date,this._isReady()?this._sendRequest({type:"profile",eventName:"profile_number_max",properties:e,onComplete:n},t):this._queue.push(["userNumberMax",[e,t,n]])):(M.warn("calling userNumberMax failed due to invalid arguments"),S.isFunction(n)&&n({code:-1,msg:"invalid parameters"}))}}},{key:"userNumberMin",value:function(e,t,n){if(!this._hasDisabled()){var i,r,a;for(r in this._isObjectParams(e)&&(e=(i=e).properties,t=i.time,n=i.onComplete),e)if("number"!=typeof e[r])return a="The key ".concat(r," must be type of number"),console.warn(a),void(S.isFunction(n)&&n({code:-1,msg:a}));T.propertiesMust(e)||!this.config.strict?(t=S.isDate(t)?t:new Date,this._isReady()?this._sendRequest({type:"profile",eventName:"profile_number_min",properties:e,onComplete:n},t):this._queue.push(["userNumberMin",[e,t,n]])):(M.warn("calling userNumberMin failed due to invalid arguments"),S.isFunction(n)&&n({code:-1,msg:"invalid parameters"}))}}},{key:"userDel",value:function(e,t){var n,i={};this._hasDisabled()||(this._isObjectParams(i)&&(i=(n=i).properties,e=n.time,t=n.onComplete),T.propertiesMust(i)||!this.config.strict?(e=S.isDate(e)?e:new Date,this._isReady()?this._sendRequest({type:"profile",eventName:"profile_delete",properties:i,onComplete:t},e):this._queue.push(["userDel",[i,e,t]])):(M.warn("calling userDel failed due to invalid arguments"),S.isFunction(t)&&t({code:-1,msg:"invalid parameters"})))}},{key:"userAppend",value:function(e,t,n){var i;this._hasDisabled()||(this._isObjectParams(e)&&(e=(i=e).properties,t=i.time,n=i.onComplete),T.propertiesMust(e)||!this.config.strict?(t=S.isDate(t)?t:new Date,this._isReady()?this._sendRequest({type:"profile",eventName:"profile_append",properties:e,onComplete:n},t):this._queue.push(["userAppend",[e,t,n]])):(M.warn("calling userAppend failed due to invalid arguments"),S.isFunction(n)&&n({code:-1,msg:"invalid parameters"})))}},{key:"userUniqAppend",value:function(e,t,n){var i;this._hasDisabled()||(this._isObjectParams(e)&&(e=(i=e).properties,t=i.time,n=i.onComplete),T.userAppendProperties(e)||!this.config.strict?(t=S.isDate(t)?t:new Date,this._isReady()?this._sendRequest({type:"profile",eventName:"profile_uniq_append",properties:e,onComplete:n},t):this._queue.push(["userUniqAppend",[e,t,n]])):(M.warn("calling userAppend failed due to invalid arguments"),S.isFunction(n)&&n({code:-1,msg:"invalid parameters"})))}},{key:"userUnset",value:function(e,t,n){var i,e=o({},e,null);this._hasDisabled()||(this._isObjectParams(e)&&(e=(i=e).properties,t=i.time,n=i.onComplete),T.propertiesMust(e)||!this.config.strict?(t=S.isDate(t)?t:new Date,this._isReady()?this._sendRequest({type:"profile",eventName:"profile_unset",properties:e,onComplete:n},t):this._queue.push(["userUnset",[e,t,n]])):(M.warn("calling userUnset failed due to invalid arguments"),S.isFunction(n)&&n({code:-1,msg:"invalid parameters"})))}},{key:"getQuickAppInfo",value:function(){return new Promise(function(i,e){var t;k.getQuickDevice({success:(t=u(w().mark(function e(t){var n;return w().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n={os_name:"android",android_id:t.user,imei:t.device,oaid:t.oaid,mac:t.mac,android_version:t.system,api_version:t.osVersionCode,rom:t.vendorOsName,rom_version:t.vendorOsVersion,phone_brand:t.manufacturer,phone_model:t.model},e.abrupt("return",i(n));case 2:case"end":return e.stop()}},e)})),function(e){return t.apply(this,arguments)})})})}},{key:"getQuickGameInfo",value:function(){return new Promise(function(t){var e=G();k.getQuickDevice({platform:e,success:function(e){return t(e)}})})}},{key:"uploadQuickAppDeviceInfo",value:function(){var o=this;return new Promise(function(r,a){var t;k.getQuickDevice({success:(t=u(w().mark(function e(t){var n,i;return w().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n={os_name:"android",android_id:t.user,imei:t.device,oaid:t.oaid,mac:t.mac,android_version:t.system,api_version:t.osVersionCode,rom:t.vendorOsName,rom_version:t.vendorOsVersion,phone_brand:t.manufacturer,phone_model:t.model},i="".concat(b,"/user/device_info/?access_token=").concat(o.accessToken,"&client_id=").concat(o.appId),e.next=4,o.sendNetWork(i,{data:n});case 4:return i=e.sent,e.abrupt("return",(0===i.code?r:a)(i));case 6:case"end":return e.stop()}},e)})),function(e){return t.apply(this,arguments)})})})}},{key:"uploadQuickGameDeviceInfo",value:function(){var o=this;return new Promise(function(r,a){var t,e=G();k.getQuickDevice({platform:e,success:(t=u(w().mark(function e(t){var n,i;return w().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=t,i="".concat(b,"/user/device_info/?access_token=").concat(o.accessToken,"&client_id=").concat(o.appId),e.next=4,o.sendNetWork(i,{data:n});case 4:return i=e.sent,e.abrupt("return",(0===i.code?r:a)(i));case 6:case"end":return e.stop()}},e)})),function(e){return t.apply(this,arguments)})})})}},{key:"logoutEvent",value:function(){this.track("$MPLogout",{})}},{key:"loginEvent",value:function(){this.track("$MPLogin",{})}},{key:"registerEvent",value:function(){"GravityEngine_quick_mp"===G()?this.track("$AppRegister",{}):this.track("$MPRegister",{})}},{key:"payEvent",value:function(e,t,n,i,r){if("number"!=typeof e)throw new Error("pay_amount must be a number");if("string"!=typeof t)throw new Error("pay_type must be a string");if("string"!=typeof n)throw new Error("order_id must be a string");if("string"!=typeof i)throw new Error("pay_reason must be a string");if("string"!=typeof r)throw new Error("pay_method must be a string");this.track("$PayEvent",{$pay_amount:e,$pay_type:t,$order_id:n,$pay_reason:i,$pay_method:r})}},{key:"bindTAThirdPlatform",value:function(e,t){if(!e&&!t)throw new Error("taAccountId or taDistinctId must be required");if(e&&"string"!=typeof e)throw new Error("taAccountId must be a string");if(t&&"string"!=typeof t)throw new Error("taDistinctId must be a string");this.track("$BindThirdPlatform",{$third_platform_type:"ta",$ta_account_id:e,$ta_distinct_id:t})}},{key:"adShowEvent",value:function(e,t,n){var i=G(),r="GravityEngine_ali_game"===i?"alipay":"wechat";if("GravityEngine_wechat"===i||"GravityEngine_wechat_game"===i||"GravityEngine_ali_game"===i){if("string"!=typeof e)throw new Error("ad_type must be a string");if("string"!=typeof t)throw new Error("ad_unit_id must be a string");i={$ad_type:e,$ad_unit_id:t,$adn_type:r};"[object Object]"===Object.prototype.toString.call(n)&&Object.assign(i,n),this.track("$AdShow",i)}}},{key:"getQuery",value:function(){try{var e;return null!=k&&k.getAppOptions&&null!=(e=k.getAppOptions())&&e.query?k.getAppOptions().query||{}:{}}catch(e){return{}}}},{key:"sendNetWork",value:function(e,i){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"POST";return new Promise(function(t,n){k.request({url:e,method:r,data:"string"==typeof i?i:JSON.stringify(i),header:{"content-type":"application/json"},success:function(e){200===e.statusCode||200===e.status?t(e.data):n(e)},fail:function(e){n(e)}})})}},{key:"_errorPromise",value:function(e){return Promise.reject(new Error(e))}},{key:"initializeWithHistoryUserInfo",value:(t=u(w().mark(function e(){var t,n,i=arguments;return w().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=0<i.length&&void 0!==i[0]?i[0]:{},n=1<i.length?i[1]:void 0,e.abrupt("return",this.initialize(t,n));case 3:case"end":return e.stop()}},e,this)})),function(){return t.apply(this,arguments)})},{key:"initialize",value:(e=u(w().mark(function e(){var m,y,_=this,t=arguments;return w().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return m=0<t.length&&void 0!==t[0]?t[0]:{},y=1<t.length?t[1]:void 0,e.abrupt("return",new Promise(function(){var n=u(w().mark(function e(g,v){return w().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:try{k.getStorage("is_ge_registered",!0,function(){var t=u(w().mark(function e(t){var n,i,r,a,o,s,c,u,l,p,f,h,d;return w().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(i="",_._state.initComplete?null!=m&&m.name?null!=m&&m.version||0===(null==m?void 0:m.version)?S.isNumber(null==m?void 0:m.version)&&"number"==typeof(null==m?void 0:m.version)?void 0!==y&&("[object Object]"!==Object.prototype.toString.call(y)?i="history_info must be type: Object":null!=y&&y.company?"string"!=typeof y.company?i="history_info.company must be type: String":null!=y&&y.create_time||0===y.create_time?S.isNumber(y.create_time)&&"number"==typeof y.create_time||(i="history_info.create_time must be type: Number"):i="history_info.create_time must be required":i="history_info.company must be required"):i="version must be type: Number":i="version must be required":i="name must be required":i="initialize must be called after setupAndStart",i)return e.abrupt("return",v(i));e.next=4;break;case 4:if(n=_.getQuery(),i=G(),a=i.includes("GravityEngine_ali"),r=(null==m?void 0:m.channel)||"base_channel",o=(null==m?void 0:m.enable_sync_attribution)||!1,a={client_id:_.appId,name:m.name,channel:a&&null!=n&&n.channel?n.channel:r,version:m.version,wx_openid:(null==m?void 0:m.openid)||(null==m?void 0:m.wx_openid)||"",wx_unionid:(null==m?void 0:m.wx_unionid)||"",promoted_object_id:(null==m?void 0:m.promoted_object_id)||"",need_return_attribution:o,ad_data:n},y&&(a.history_info=y),"GravityEngine_quick_mp"===(o=G()))return e.next=15,_.getQuickAppInfo();e.next=16;break;case 15:a.device_info=e.sent;case 16:if(o.includes("gravityengine_qg"))return e.next=19,_.getQuickGameInfo();e.next=20;break;case 19:a.device_info=e.sent;case 20:return c="".concat(b,"/user/initialize/?access_token=").concat(_.accessToken,"&client_id=").concat(_.appId),e.next=23,_.sendNetWork(c,a);case 23:if(0!==(s=e.sent).code)return e.abrupt("return",v(s));e.next=26;break;case 26:return c=D.properties,p=new Date,f=p.getFullYear(),h=("0"+(p.getMonth()+1)).slice(-2),d=("0"+p.getDate()).slice(-2),u=("0"+p.getHours()).slice(-2),l=("0"+p.getMinutes()).slice(-2),p=("0"+p.getSeconds()).slice(-2),f="".concat(f,"-").concat(h,"-").concat(d," ").concat(u,":").concat(l,":").concat(p),"Y"!==t&&(_.userSetOnce({$channel:r,$manufacturer:c.$manufacturer,$model:c.$model,$brand:c.$brand,$os:c.$os,$first_visit_time:f,$first_scene:String(null==(h=k.getAppOptions())?void 0:h.scene),$gravity_referee_openid:(null==n?void 0:n.gravity_referee_openid)||void 0}),d=S.setQuery(_.getQuery()),_.track("GravityEngine_quick_mp"===o?"$AppStart":"$MPLaunch",{$url_query:d}),_.track("$MPShow",{$url_query:d})),k.setStorage("is_ge_registered",JSON.stringify("Y")),e.abrupt("return",g(s));case 38:case"end":return e.stop()}},e)}));return function(e){return t.apply(this,arguments)}}())}catch(e){v(e)}case 1:case"end":return e.stop()}},e)}));return function(e,t){return n.apply(this,arguments)}}()));case 3:case"end":return e.stop()}},e)})),function(){return e.apply(this,arguments)})},{key:"authorizeOpenID",value:function(e){this.identify(e)}},{key:"identify",value:function(e){if(!this._hasDisabled()){if("number"==typeof e)e=String(e);else if("string"!=typeof e)return!1;this.store.setDistinctId(e)}}},{key:"getDistinctId",value:function(){return this.store.getDistinctId()}},{key:"login",value:function(e){if(!this._hasDisabled()){if("number"==typeof e)e=String(e);else if("string"!=typeof e)return!1;this.store.setAccountId(e)}}},{key:"getAccountId",value:function(){return this.store.getAccountId()}},{key:"logout",value:function(){this._hasDisabled()||this.store.setAccountId(null)}},{key:"setSuperProperties",value:function(e){this._hasDisabled()||(T.propertiesMust(e)||!this.config.strict?this.store.setSuperProperties(e):M.warn("setSuperProperties parameter must be a valid property value"))}},{key:"clearSuperProperties",value:function(){this._hasDisabled()||this.store.setSuperProperties({},!0)}},{key:"unsetSuperProperty",value:function(e){var t;this._hasDisabled()||S.isString(e)&&(delete(t=this.getSuperProperties())[e],this.store.setSuperProperties(t,!0))}},{key:"getSuperProperties",value:function(){return this.store.getSuperProperties()}},{key:"getSendProperties",value:function(){try{var e,t=S.extend({},D.properties,this.autoTrackProperties,this.store.getSuperProperties(),this.dynamicProperties?this.dynamicProperties():{});for(e in t)"string"==typeof t[e]&&(t[e]=t[e].substring(0,8192));return t}catch(e){return{}}}},{key:"getPresetProperties",value:function(){var e=D.properties,t={},n=e.$system_language,n=(t.system_language=S.isUndefined(n)?"":n,e.$os),n=(t.os=S.isUndefined(n)?"":n,e.$screen_width),n=(t.screenWidth=S.isUndefined(n)?0:n,e.$screen_height),n=(t.screenHeight=S.isUndefined(n)?0:n,e.$network_type),n=(t.networkType=S.isUndefined(n)?"":n,e.$model),n=(t.deviceModel=S.isUndefined(n)?"":n,e.$os_version),n=(t.osVersion=S.isUndefined(n)?"":n,t.deviceId=this.getDeviceId(),0-(new Date).getTimezoneOffset()/60),n=(t.zoneOffset=n,e.$manufacturer),n=(t.manufacturer=S.isUndefined(n)?"":n,e.$manufacturer);return t.brand=S.isUndefined(n)?"":n,t.toEventPresetProperties=function(){var e;return{$app_id:this.appId,$model:t.deviceModel,$screen_width:t.screenWidth,$screen_height:t.screenHeight,$system_language:t.system_language,$os:t.os,$os_version:t.osVersion,$network_type:t.networkType,$manufacturer:t.manufacturer,$brand:t.manufacturer,$scene:String((null==(e=k.getAppOptions())?void 0:e.scene)||(null==(e=k.getAppOptions())?void 0:e.from))}},t}},{key:"setDynamicSuperProperties",value:function(e){this._hasDisabled()||("function"==typeof e?T.properties(e())||!this.config.strict?this.dynamicProperties=e:M.warn("A dynamic public property must return a valid property value"):M.warn("setDynamicSuperProperties parameter must be a function type"))}},{key:"timeEvent",value:function(e,t){this._hasDisabled()||(t=S.isDate(t)?t:new Date,this._isReady()?T.event(e)||!this.config.strict?this.store.setEventTimer(e,t.getTime()):M.warn("calling timeEvent failed due to invalid eventName: "+e):this._queue.push(["timeEvent",[e,t]]))}},{key:"getDeviceId",value:function(){return D.properties.$device_id}},{key:"enableTracking",value:function(e){this.enabled=e,this.store._set("ta_enabled",e)}},{key:"optOutTracking",value:function(){this.store.setSuperProperties({},!0),this.store.setDistinctId(S.UUID()),this.store.setAccountId(null),this._queue.splice(0,this._queue.length),this.isOptOut=!0,this.store._set("ge_isOptOut",!0)}},{key:"optOutTrackingAndDeleteUser",value:function(){var e=new Date;this._sendRequest({type:"user_del"},e),this.optOutTracking()}},{key:"optInTracking",value:function(){this.isOptOut=!1,this.store._set("ge_isOptOut",!1)}},{key:"setTrackStatus",value:function(e){switch(e){case"PAUSE":this.eventSaveOnly=!1,this.optInTracking(),this.enableTracking(!1);break;case"STOP":this.eventSaveOnly=!1,this.optOutTracking(!0);break;default:this.eventSaveOnly=!1,this.optInTracking(),this.enableTracking(!0)}}},{key:"getCommonOpenId",value:function(a,o){var s=this;return new Promise(function(){var n=u(w().mark(function e(t,n){var i,r;return w().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,a){e.next=3;break}return e.abrupt("return",n("code is required"));case 3:return r="https://backend.gravity-engine.com/event_center/api/v1/base/".concat(o,"/code2Session/?access_token=").concat(s.accessToken),e.next=6,s.sendNetWork(r,{code:a});case 6:return r=e.sent,e.abrupt("return",0===r.code&&null!=r&&null!=(i=r.data)&&i.resp?t(r.data.resp):n(r));case 10:return e.prev=10,e.t0=e.catch(0),e.abrupt("return",n(e.t0));case 13:case"end":return e.stop()}},e,null,[[0,10]])}));return function(e,t){return n.apply(this,arguments)}}())}},{key:"getWechatOpenId",value:function(e){return this.getCommonOpenId(e,"wx")}},{key:"getKuaishouOpenId",value:function(e){return this.getCommonOpenId(e,"ks")}},{key:"getDouyinOpenId",value:function(e){return this.getCommonOpenId(e,"dy")}}]),n}(),B={name:"GravityEngine",enableLog:!0,enableNative:!1},e=function(){function n(e){s(this,n),e.appId=S.checkAppId(e.clientId),e.accessToken=e.accessToken,e.appId?e.accessToken||console.warn("GravityAnalytics: accessToken must be required"):console.warn("GravityAnalytics: clientId must be required"),e.serverUrl="".concat(b,"/event/collect/?access_token=").concat(e.accessToken);var t=S.extend({},B,k.getConfig());S.isObject(e)?this.config=S.extend(t,e):this.config=t,this._init(this.config)}var e;return l(n,[{key:"_isNativePlatform",value:function(){return!(!this._isIOS()&&!this._isAndroid()||!this.config.enableNative)}},{key:"_isIOS",value:function(){return!(!cc.sys.isNative||"iOS"!==cc.sys.os)}},{key:"_isAndroid",value:function(){return!(!cc.sys.isNative||"Android"!==cc.sys.os)}},{key:"_init",value:function(t){this.name=t.name,this.appId=t.clientId,this.accessToken=t.accessToken;var e=t.serverUrl||t.server_url;if(this.serverUrl=e,this._isNativePlatform())this.initInstanceForNative();else try{this.geJs=new GravityAnalyticsAPIForJS(t)}catch(e){this.geJs=new Q(t)}}},{key:"setupAndStart",value:function(){var e,t;this._isNativePlatform()?(e=window,t=this,e.__autoTrackCallback=function(e){return S.isFunction(t.config.autoTrack.callback)?(e=t.config.autoTrack.callback(e),JSON.stringify(e)):"{}"},this.setupAndStartForNative()):this.geJs.setupAndStart()}},{key:"track",value:function(e,t,n,i){this._isNativePlatform()?this.trackForNative(e,t,n):this.geJs.track(e,t,n,i)}},{key:"initializeWithHistoryUserInfo",value:(e=u(w().mark(function e(){var t,n,i=arguments;return w().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=0<i.length&&void 0!==i[0]?i[0]:{},n=1<i.length?i[1]:void 0,this._isNativePlatform())return e.abrupt("return",new Promise(function(e,t){t("方法暂时不支持原生")}));e.next=4;break;case 4:return e.abrupt("return",this.geJs.initializeWithHistoryUserInfo(t,n));case 5:case"end":return e.stop()}},e,this)})),function(){return e.apply(this,arguments)})},{key:"initialize",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},t=1<arguments.length?arguments[1]:void 0;if(!this._isNativePlatform())return this.geJs.initialize(e,t);this.initializeForNative(e)}},{key:"registerEvent",value:function(){if(!this._isNativePlatform())return this.geJs.registerEvent();this.trackForNative("$AppRegister",{})}},{key:"loginEvent",value:function(){if(!this._isNativePlatform())return this.geJs.loginEvent()}},{key:"logoutEvent",value:function(){if(!this._isNativePlatform())return this.geJs.logoutEvent()}},{key:"payEvent",value:function(e,t,n,i,r){if(!this._isNativePlatform())return this.geJs.payEvent(e,t,n,i,r);if("number"!=typeof e)throw new Error("pay_amount must be a number");if("string"!=typeof t)throw new Error("pay_type must be a string");if("string"!=typeof n)throw new Error("order_id must be a string");if("string"!=typeof i)throw new Error("pay_reason must be a string");if("string"!=typeof r)throw new Error("pay_method must be a string");this.trackForNative("$PayEvent",{$pay_amount:e,$pay_type:t,$order_id:n,$pay_reason:i,$pay_method:r})}},{key:"bindTAThirdPlatform",value:function(e,t){if(!this._isNativePlatform())return this.geJs.bindTAThirdPlatform(e,t);if(!e&&!t)throw new Error("taAccountId or taDistinctId must be required");if(e&&"string"!=typeof e)throw new Error("taAccountId must be a string");if(t&&"string"!=typeof t)throw new Error("taDistinctId must be a string");this.trackForNative("$BindThirdPlatform",{$third_platform_type:"ta",$ta_account_id:e,$ta_distinct_id:t})}},{key:"adShowEvent",value:function(e,t,n){if(!this._isNativePlatform())return this.geJs.adShowEvent(e,t,n);if("string"!=typeof e)throw new Error("ad_type must be a string");if("string"!=typeof t)throw new Error("ad_unit_id must be a string");e={$ad_type:e,$ad_unit_id:t};"[object Object]"===Object.prototype.toString.call(n)&&Object.assign(e,n),this.trackForNative("$AdShow",e)}},{key:"userSet",value:function(e,t,n){this._isNativePlatform()?this.userSetForNative(e,t):this.geJs.userSet(e,t,n)}},{key:"userSetOnce",value:function(e,t,n){this._isNativePlatform()?this.userSetOnceForNative(e,t):this.geJs.userSetOnce(e,t,n)}},{key:"userUnset",value:function(e,t,n){this._isNativePlatform()?this.userUnsetForNative(e,t):this.geJs.userUnset(e,t,n)}},{key:"userDel",value:function(e,t){this._isNativePlatform()?this.userDelForNative(e):this.geJs.userDel(e,t)}},{key:"userAdd",value:function(e,t,n){this._isNativePlatform()?this.userAddForNative(e,t):this.geJs.userAdd(e,t,n)}},{key:"userNumberMax",value:function(e,t,n){this._isNativePlatform()?this.userNumberMaxForNative(e,t):this.geJs.userNumberMax(e,t,n)}},{key:"userNumberMin",value:function(e,t,n){this._isNativePlatform()?this.userNumberMinForNative(e,t):this.geJs.userNumberMin(e,t,n)}},{key:"userAppend",value:function(e,t,n){this._isNativePlatform()?this.userAppendForNative(e,t):this.geJs.userAppend(e,t,n)}},{key:"userUniqAppend",value:function(e,t,n){this._isNativePlatform()?this.userUniqAppendForNative(e,t):this.geJs.userUniqAppend(e,t,n)}},{key:"authorizeOpenID",value:function(e){this.identify(e)}},{key:"identify",value:function(e){this._isNativePlatform()?this.identifyForNative(e):this.geJs.identify(e)}},{key:"getDistinctId",value:function(){if(this._isNativePlatform())throw new Error("not support this method");return this.geJs.getDistinctId()}},{key:"login",value:function(e){this._isNativePlatform()||this.geJs.login(e)}},{key:"getAccountId",value:function(){if(this._isNativePlatform())throw new Error("not support this method");return this.geJs.getAccountId()}},{key:"logout",value:function(){if(this._isNativePlatform())throw new Error("not support this method");this.geJs.logout()}},{key:"setSuperProperties",value:function(e){this._isNativePlatform()?this.setSuperPropertiesForNative(e):this.geJs.setSuperProperties(e)}},{key:"clearSuperProperties",value:function(){this._isNativePlatform()?this.clearSuperPropertiesForNative():this.geJs.clearSuperProperties()}},{key:"unsetSuperProperty",value:function(e){this._isNativePlatform()?this.unsetSuperPropertyForNative(e):this.geJs.unsetSuperProperty(e)}},{key:"getSuperProperties",value:function(){return this._isNativePlatform()?this.getSuperPropertiesForNative():this.geJs.getSuperProperties()}},{key:"getPresetProperties",value:function(){var e,t,n,i;return this._isNativePlatform()?(e=this.getPresetPropertiesForNative(),t={},i=e.$system_language,t.system_language=S.isUndefined(i)?"":i,i=e.$os,t.os=S.isUndefined(i)?"":i,i=e.$screen_width,t.screenWidth=S.isUndefined(i)?0:i,i=e.$screen_height,t.screenHeight=S.isUndefined(i)?0:i,i=e.$network_type,t.networkType=S.isUndefined(i)?"":i,i=e.$device_model,t.deviceModel=S.isUndefined(i)?"":i,i=e.$os_version,t.osVersion=S.isUndefined(i)?"":i,t.deviceId=this.getDeviceId(),n=0-(new Date).getTimezoneOffset()/60,t.zoneOffset=n,i=e.$manufacturer,t.manufacturer=S.isUndefined(i)?"":i,i=e.$manufacturer,t.brand=S.isUndefined(i)?"":i,t.toEventPresetProperties=function(){return{$device_model:t.deviceModel,$device_id:t.deviceId,$screen_width:t.screenWidth,$screen_height:t.screenHeight,$system_language:t.system_language,$os:t.os,$os_version:t.osVersion,$network_type:t.networkType,$zone_offset:n,$manufacturer:t.manufacturer,$brand:t.manufacturer}},t):this.geJs.getPresetProperties()}},{key:"setDynamicSuperProperties",value:function(t){this._isNativePlatform()?"function"==typeof t?(this.dynamicProperties=t,window.__dynamicPropertiesForNative=function(e){console.log("__dynamicPropertiesForNative: native msg: ",e);e=t(),e=S.encodeDates(e);return JSON.stringify(e)},this.setDynamicSuperPropertiesForNative("__dynamicPropertiesForNative")):logger.warn("setDynamicSuperProperties parameter must be a function type"):this.geJs.setDynamicSuperProperties(t)}},{key:"timeEvent",value:function(e,t){return this._isNativePlatform()?this.timeEventForNative(e):this.geJs.timeEvent(e,t)}},{key:"getDeviceId",value:function(){return this._isNativePlatform()?this.getDeviceIdForNative():this.geJs.getDeviceId()}},{key:"setTrackStatus",value:function(e){this._isNativePlatform()?this.setTrackStatusForNative(e):this.geJs.setTrackStatus(e)}},{key:"trackForNative",value:function(e,t,n){n=S.isDate(n)?n.getTime():"",S.isUndefined(t)&&(t={}),t=S.extend(t,this.dynamicProperties?this.dynamicProperties():{}),n={eventName:e,properties:t=S.encodeDates(t),time:n};this._isAndroid()?jsb.reflection.callStaticMethod("cn/gravity/engine/GravityEngineCocosCreatorAPI","track","(Ljava/lang/String;)V",JSON.stringify(n)):this._isIOS()&&jsb.reflection.callStaticMethod("GravityEngineCocosCreatorAPI","track:properties:time:appId:",e,JSON.stringify(t),formatTime,appId)}},{key:"timeEventForNative",value:function(e){var t={eventName:e};this._isAndroid()?jsb.reflection.callStaticMethod("cn/gravity/engine/GravityEngineCocosCreatorAPI","timeEvent","(Ljava/lang/String;Ljava/lang/String;)V",JSON.stringify(t)):this._isIOS()&&jsb.reflection.callStaticMethod("GravityEngineCocosCreatorAPI","timeEvent:appId:",e,appId)}},{key:"loginForNative",value:function(e,t){this._isAndroid()?jsb.reflection.callStaticMethod("cn/gravity/engine/GravityEngineCocosCreatorAPI","login","(Ljava/lang/String;Ljava/lang/String;)V",e,t):this._isIOS()&&jsb.reflection.callStaticMethod("GravityEngineCocosCreatorAPI","login:appId:",e,t)}},{key:"logoutForNative",value:function(e){this._isAndroid()?jsb.reflection.callStaticMethod("cn/gravity/engine/GravityEngineCocosCreatorAPI","logout","(Ljava/lang/String;)V",e):this._isIOS()&&jsb.reflection.callStaticMethod("GravityEngineCocosCreatorAPI","logout:",e)}},{key:"setSuperPropertiesForNative",value:function(e){var t={properties:e=S.encodeDates(e)};this._isAndroid()?jsb.reflection.callStaticMethod("cn/gravity/engine/GravityEngineCocosCreatorAPI","setSuperProperties","(Ljava/lang/String;)V",JSON.stringify(t)):this._isIOS()&&jsb.reflection.callStaticMethod("GravityEngineCocosCreatorAPI","setSuperProperties:appId:",JSON.stringify(e),appId)}},{key:"getSuperPropertiesForNative",value:function(){var e="{}";return this._isAndroid()?e=jsb.reflection.callStaticMethod("cn/gravity/engine/GravityEngineCocosCreatorAPI","getSuperProperties","(Ljava/lang/String;)V",""):this._isIOS()&&(e=jsb.reflection.callStaticMethod("GravityEngineCocosCreatorAPI","getSuperProperties:",appId)),JSON.parse(e)}},{key:"unsetSuperPropertyForNative",value:function(e){var t={property:e};this._isAndroid()?jsb.reflection.callStaticMethod("cn/gravity/engine/GravityEngineCocosCreatorAPI","unsetSuperProperty","(Ljava/lang/String;Ljava/lang/String;)V",JSON.stringify(t)):this._isIOS()&&jsb.reflection.callStaticMethod("GravityEngineCocosCreatorAPI","unsetSuperProperty:appId:",e,appId)}},{key:"clearSuperPropertiesForNative",value:function(){this._isAndroid()?jsb.reflection.callStaticMethod("cn/gravity/engine/GravityEngineCocosCreatorAPI","clearSuperProperties","(Ljava/lang/String;)V","appId"):this._isIOS()&&jsb.reflection.callStaticMethod("GravityEngineCocosCreatorAPI","clearSuperProperties:",appId)}},{key:"userSetForNative",value:function(e,t){t=S.isDate(t)?t.getTime():"",t={properties:e=S.encodeDates(e),time:t};this._isAndroid()?jsb.reflection.callStaticMethod("cn/gravity/engine/GravityEngineCocosCreatorAPI","userSet","(Ljava/lang/String;)V",JSON.stringify(t)):this._isIOS()&&jsb.reflection.callStaticMethod("GravityEngineCocosCreatorAPI","userSet:appId:",JSON.stringify(e),appId)}},{key:"userSetOnceForNative",value:function(e,t){t=S.isDate(t)?t.getTime():"",t={properties:e=S.encodeDates(e),time:t};this._isAndroid()?jsb.reflection.callStaticMethod("cn/gravity/engine/GravityEngineCocosCreatorAPI","userSetOnce","(Ljava/lang/String;)V",JSON.stringify(t)):this._isIOS()&&jsb.reflection.callStaticMethod("GravityEngineCocosCreatorAPI","userSetOnce:appId:",JSON.stringify(e),appId)}},{key:"userAppendForNative",value:function(e,t){t=S.isDate(t)?t.getTime():"",t={properties:e=S.encodeDates(e),time:t};this._isAndroid()?jsb.reflection.callStaticMethod("cn/gravity/engine/GravityEngineCocosCreatorAPI","userAppend","(Ljava/lang/String;)V",JSON.stringify(t)):this._isIOS()&&jsb.reflection.callStaticMethod("GravityEngineCocosCreatorAPI","userAppend:appId:",JSON.stringify(e),appId)}},{key:"userUniqAppendForNative",value:function(e,t){t=S.isDate(t)?t.getTime():"",t={properties:e=S.encodeDates(e),time:t};this._isAndroid()?jsb.reflection.callStaticMethod("cn/gravity/engine/GravityEngineCocosCreatorAPI","userUniqAppend","(Ljava/lang/String;)V",JSON.stringify(t)):this._isIOS()&&jsb.reflection.callStaticMethod("GravityEngineCocosCreatorAPI","userUniqAppend:appId:",JSON.stringify(e),appId)}},{key:"userAddForNative",value:function(e,t){t=S.isDate(t)?t.getTime():"",t={properties:e=S.encodeDates(e),time:t};this._isAndroid()?jsb.reflection.callStaticMethod("cn/gravity/engine/GravityEngineCocosCreatorAPI","userAdd","(Ljava/lang/String;Ljava/lang/String;)V",JSON.stringify(t)):this._isIOS()&&jsb.reflection.callStaticMethod("GravityEngineCocosCreatorAPI","userAdd:appId:",JSON.stringify(e),appId)}},{key:"userNumberMaxForNative",value:function(e,t){t=S.isDate(t)?t.getTime():"",t={properties:e=S.encodeDates(e),time:t};this._isAndroid()?jsb.reflection.callStaticMethod("cn/gravity/engine/GravityEngineCocosCreatorAPI","userNumberMax","(Ljava/lang/String;Ljava/lang/String;)V",JSON.stringify(t)):this._isIOS()&&jsb.reflection.callStaticMethod("GravityEngineCocosCreatorAPI","userNumberMax:appId:",JSON.stringify(e),appId)}},{key:"userNumberMinForNative",value:function(e,t){t=S.isDate(t)?t.getTime():"",t={properties:e=S.encodeDates(e),time:t};this._isAndroid()?jsb.reflection.callStaticMethod("cn/gravity/engine/GravityEngineCocosCreatorAPI","userNumberMin","(Ljava/lang/String;Ljava/lang/String;)V",JSON.stringify(t)):this._isIOS()&&jsb.reflection.callStaticMethod("GravityEngineCocosCreatorAPI","userNumberMin:appId:",JSON.stringify(e),appId)}},{key:"userUnsetForNative",value:function(e,t){t=S.isDate(t)?t.getTime():"",e={properties:e=S.encodeDates(e),time:t};this._isAndroid()?jsb.reflection.callStaticMethod("cn/gravity/engine/GravityEngineCocosCreatorAPI","userUnset","(Ljava/lang/String;Ljava/lang/String;)V",JSON.stringify(e)):this._isIOS()&&jsb.reflection.callStaticMethod("GravityEngineCocosCreatorAPI","userUnset:appId:",property,appId)}},{key:"userDelForNative",value:function(e){e={time:S.isDate(e)?e.getTime():""};this._isAndroid()?jsb.reflection.callStaticMethod("cn/gravity/engine/GravityEngineCocosCreatorAPI","userDel","(Ljava/lang/String;)V",JSON.stringify(e)):this._isIOS()&&jsb.reflection.callStaticMethod("GravityEngineCocosCreatorAPI","userDel:",appId)}},{key:"authorizeOpenIDForNative",value:function(e,t){this._isAndroid()?jsb.reflection.callStaticMethod("cn/gravity/engine/GravityEngineCocosCreatorAPI","authorizeOpenID","(Ljava/lang/String;Ljava/lang/String;)V",e,t):this._isIOS()&&jsb.reflection.callStaticMethod("GravityEngineCocosCreatorAPI","authorizeOpenID:appId:",e,t)}},{key:"identifyForNative",value:function(e){var t={distinctId:e};this._isAndroid()?jsb.reflection.callStaticMethod("cn/gravity/engine/GravityEngineCocosCreatorAPI","identify","(Ljava/lang/String;)V",JSON.stringify(t)):this._isIOS()&&jsb.reflection.callStaticMethod("GravityEngineCocosCreatorAPI","identify:appId:",e,appId)}},{key:"initInstanceForNative",value:function(){this._isAndroid()?jsb.reflection.callStaticMethod("cn/gravity/engine/GravityEngineCocosCreatorAPI","setCustomerLibInfo","(Ljava/lang/String;Ljava/lang/String;)V",g,d):this._isIOS()&&jsb.reflection.callStaticMethod("GravityEngineCocosCreatorAPI","setCustomerLibInfoWithLibName:libVersion:",g,d)}},{key:"setupAndStartForNative",value:function(){var e=0,t=("debug"===this.config.debugMode&&(e=1),{}),e=(S.isObject(this.config.secretKey)&&(t.publicKey=this.config.secretKey.publicKey,t.version=this.config.secretKey.version,t.symmetricEncryption="AES",t.asymmetricEncryption="RSA"),{accessToken:this.config.accessToken,mode:e,enableEncrypt:this.config.enableEncrypt,secretKey:t,timeZone:this.config.timeZone});this._isAndroid()?jsb.reflection.callStaticMethod("cn/gravity/engine/GravityEngineCocosCreatorAPI","setupAndStart","(Ljava/lang/String;)V",JSON.stringify(e)):this._isIOS()&&jsb.reflection.callStaticMethod("GravityEngineCocosCreatorAPI","startGravityAnalytics:",JSON.stringify(e))}},{key:"initializeForNative",value:function(e){var t=this.config.accessToken,n=(null==e?void 0:e.channel)||"",e=(null==e?void 0:e.enable_sync_attribution)||!1;this._isAndroid()?jsb.reflection.callStaticMethod("cn/gravity/engine/GravityEngineCocosCreatorAPI","initialize","(Ljava/lang/String;Ljava/lang/String;Z)V",t,n,e):this._isIOS()&&jsb.reflection.callStaticMethod("GravityEngineCocosCreatorAPI","setCustomerLibInfoWithLibName:libVersion:",g,d)}},{key:"setDynamicSuperPropertiesForNative",value:function(e,t){this._isAndroid()?jsb.reflection.callStaticMethod("cn/gravity/engine/GravityEngineCocosCreatorAPI","setDynamicSuperProperties","(Ljava/lang/String;Ljava/lang/String;)V",e,t):this._isIOS()&&jsb.reflection.callStaticMethod("GravityEngineCocosCreatorAPI","setDynamicSuperProperties:appId:",e,t)}},{key:"getDeviceIdForNative",value:function(){return this._isAndroid()?jsb.reflection.callStaticMethod("cn/gravity/engine/GravityEngineCocosCreatorAPI","getDeviceId","(Ljava/lang/String;)Ljava/lang/String;",""):this._isIOS()?jsb.reflection.callStaticMethod("GravityEngineCocosCreatorAPI","getDeviceId:",appId):void 0}},{key:"getDistinctIdForNative",value:function(e){return this._isAndroid()?jsb.reflection.callStaticMethod("cn/gravity/engine/GravityEngineCocosCreatorAPI","getDistinctId","(Ljava/lang/String;)Ljava/lang/String;",e):this._isIOS()?jsb.reflection.callStaticMethod("GravityEngineCocosCreatorAPI","getDistinctId:",e):void 0}},{key:"getAccountIdForNative",value:function(e){return this._isAndroid()?jsb.reflection.callStaticMethod("cn/gravity/engine/GravityEngineCocosCreatorAPI","getAccountId","(Ljava/lang/String;)Ljava/lang/String;",e):this._isIOS()?jsb.reflection.callStaticMethod("GravityEngineCocosCreatorAPI","getAccountId:",e):void 0}},{key:"getPresetPropertiesForNative",value:function(){var e="{}";return this._isAndroid()?e=jsb.reflection.callStaticMethod("cn/gravity/engine/GravityEngineCocosCreatorAPI","getPresetProperties","(Ljava/lang/String;)Ljava/lang/String;",""):this._isIOS()&&(e=jsb.reflection.callStaticMethod("GravityEngineCocosCreatorAPI","getPresetProperties:",appId)),JSON.parse(e)}},{key:"setTrackStatusForNative",value:function(e){var t={status:e};this._isAndroid()?jsb.reflection.callStaticMethod("cn/gravity/engine/GravityEngineCocosCreatorAPI","setTrackStatus","(Ljava/lang/String;Ljava/lang/String;)V",JSON.stringify(t)):this._isIOS()&&jsb.reflection.callStaticMethod("GravityEngineCocosCreatorAPI","setTrackStatus:appId:",e,appId)}}]),n}();return window.GravityAnalyticsAPI=e,window.GravityAnalyticsAPIForJS=Q,e});
|