/* eslint-disable */
Date.now = Date.now || function () {
  return new Date().getTime();
};
let SEQUENCE = Date.now();
const noop = function () { };
const getCwarn = function () {
  const t = typeof console === 'object' ? console.warn : noop;
  try {
    const e = {
      warn: t,
    };
    e.warn.call(e);
  } catch (n) {
    return noop;
  }
  return t;
};
var util = {
  noop,
  warn: getCwarn(),
  createObject(t) {
    if (Object.create) {
      return Object.create(t);
    }
    const e = function () { };
    return e.prototype = t, new e();
  },
  each(t, e) {
    let n = 0;
    const r = t.length;
    if (this.T(t, 'Array')) {
      for (; n < r && !1 !== e.call(t[n], t[n], n); n++) { }
    } else {
      for (n in t) {
        if (!1 === e.call(t[n], t[n], n)) {
          break;
        }
      }
    }
    return t;
  },
  safetyCall(t, e, n) {
    if (typeof t !== 'function') {
      return n;
    }
    try {
      return t.apply(this, e);
    } catch (r) {
      return n;
    }
  },
  ignoreByRule(t, e) {
    if (!t || !e) return !1;
    if ((this.isString(e) || e.source || this.T(e) === 'Function') && (e = [e]), !this.isArray(e)) {
      return util.warn('[cloudMonitor] invalid rules of ignore config, (list of) String/RegExp/Funcitons are available'),
      !1;
    }
    for (var n, r = [], o = 0, i = e.length; o < i; o++) if (n = e[o], this.isString(n)) r.push(n.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, '\\$1')); else if (n && n.source) r.push(n.source); else if (n && this.T(n) === 'Function' && !0 === this.safetyCall(n, [t], !1)) return !0;
    const a = new RegExp(r.join('|'), 'i');
    return !!(r.length && a.test && a.test(t));
  },
  T(t, e) {
    const n = Object.prototype.toString.call(t).substring(8).replace(']', '');
    return e ? n === e : n;
  },
  J(t) {
    if (!t || typeof t !== 'string') {
      return t;
    }
    let e = null;
    try {
      e = JSON.parse(t);
    } catch (n) { }
    return e;
  },
  pick(t) {
    return t === 1 || Math.ceil(Math.random() * t) === 1;
  },
  verifyConfig(t) {
    if ('sample' in t) {
      const e = t.sample;
      let n = e;
      e && /^\d+(\.\d+)?%$/.test(e) && (n = parseInt(100 / parseFloat(e))), n > 0 && n < 1 && (n = parseInt(1 / n)), n >= 1 && n <= 100 ? t.sample = n : delete t.sample;
    }
    return t;
  },
  delay(t, e) {
    return e === -1 ? (t(), null) : setTimeout(t, e || 0);
  },
  ext(t) {
    for (let e = 1, n = arguments.length; e < n; e++) {
      const r = arguments[e];
      for (const o in r) {
        Object.prototype.hasOwnProperty.call(r, o) && (t[o] = r[o]);
      }
    }
    return t;
  },
  sub(t, e) {
    const n = {};
    return this.each(t, (t, r) => {
      e.indexOf(r) !== -1 && (n[r] = t);
    }), n;
  },
  uu() {
    for (var t, e, n = 20, r = new Array(n), o = Date.now().toString(36).split(''); n-- > 0;) {
      e = (t = 36 * Math.random() | 0).toString(36), r[n] = t % 3 ? e : e.toUpperCase();
    }
    for (let i = 0; i < 8; i++) {
      r.splice(3 * i + 2, 0, o[i]);
    }
    return r.join('');
  },
  seq() {
    return (SEQUENCE++).toString(36);
  },
  decode(t) {
    try {
      t = decodeURIComponent(t);
    } catch (e) { }
    return t;
  },
  encode(t, e) {
    try {
      t = e ? encodeURIComponent(t).replace(/\(/g, '%28').replace(/\)/g, '%29') : encodeURIComponent(t);
    } catch (n) { }
    return t;
  },
  serialize(t) {
    t = t || {};
    const e = [];
    for (const n in t) {
      Object.prototype.hasOwnProperty.call(t, n) && t[n] !== undefined && e.push(`${n}=${this.encode(t[n], n === 'msg')}`);
    }
    return e.join('&');
  },
  checkAPI(t, e) {
    if (!t || typeof t !== 'string') {
      return !1;
    }
    let n = /openmonitor(\.(dev|sit|test))?\.alipay[\w-]*/.test(t);
    return !n && e && (n = /(\.png)|(\.gif)|(alicdn\.com)/.test(t)), !n;
  },
  checkAutoError(t) {
    return !(!t || !t.message) && !/failed[\w\s]+fetch/i.test(t.message);
  },
  cutUrlSearch(t) {
    return t && typeof t === 'string' ? t.replace(/^(.*?https?:)?\/\//, '').replace(/\?.*$/, '').replace(/&.*$/, '').replace(/\/\d{1,}$/, '/*')
      .replace(/\/\d{1,}\//, '/*/') : '';
  },
  patchPath(t) {
    if (!t || typeof t !== 'string') return '';
    t = t.replace(/^\//, '');
    return t.includes('pages/') ? t.replace(/\.\.\//g, '') : t.replace(/^\.\./, 'pages');
  },
  getRandIP() {
    for (var t = [], e = 0; e < 4; e++) {
      const n = Math.floor(256 * Math.random());
      t[e] = (n > 15 ? '' : '0') + n.toString(16);
    }
    return t.join('');
  },
  getSortNum(t) {
    return t ? (t += 1) >= 1000 && t <= 9999 ? t : t < 1000 ? t + 1000 : t % 10000 + 1000 : 1000;
  },
  getRandNum(t) {
    return t && typeof t === 'string' ? t.length < 5 ? this.getNum(5) : t.substring(t.length - 5) : this.getNum(5);
  },
  getNum(t) {
    for (var e = [], n = 0; n < t; n++) {
      const r = Math.floor(16 * Math.random());
      e[n] = r.toString(16);
    }
    return e.join('');
  },
  isFunction(t) {
    return typeof t === 'function';
  },
  isPlainObject(t) {
    return Object.prototype.toString.call(t) === '[object Object]';
  },
  isString(t) {
    return Object.prototype.toString.call(t) === '[object String]';
  },
  isArray(t) {
    return Object.prototype.toString.call(t) === '[object Array]';
  },
  joinRegExp(t) {
    for (var e, n = [], r = 0, o = t.length; r < o; r++) {
      e = t[r], this.isString(e) ? n.push(e.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, '\\$1')) : e && e.source && n.push(e.source);
    }
    return new RegExp(n.join('|'), 'i');
  },
  getPropertyValue(j, arr) {
    if (!arr) return '';
    for (const k in j) {
      if (arr.indexOf(k) > -1 && (typeof j[k] !== 'object')) {
        return `${j[k]}`;
      }
    }
    return '';
  },
  hashCode(s) {
    let hash = 0; let i; let
      chr;
    for (i = 0; i < s.length; i++) {
      chr = s.charCodeAt(i);
      hash = ((hash << 5) - hash) + chr;
      hash |= 0; // Convert to 32bit integer
    }
    return hash;
  },
  toHex(s) {
    return !s ? null : (`000${this.hashCode(s).toString(16)}`).slice(-4);
  },
  replaceAll(str, find, replace) {
    return str.replace(new RegExp(find, 'g'), replace);
  },
};
const util_1 = util;
const pushToQueue = function (e, t) {
  let i;
  {
    if (t.t !== 'error' || !(i = e.requestQueue[0]) || i.t !== 'error' || t.msg !== i.msg) {
      if (t.t === 'behavior') {
        const n = e.requestQueue && e.requestQueue.length;
        if (n > 0 && e.requestQueue[n - 1].t === 'behavior') {
          const r = t.behavior || [];
          e.requestQueue[n - 1].behavior.concat(r);
        } else e.requestQueue.push(t);
      } else e.requestQueue.unshift(t);
      return e.onReady(() => {
        e.requestTimmer = util.delay(() => {
          e.clear();
        }, e.requestQueue[0] && e.requestQueue[0].t === 'error' ? 3e3 : -1);
      }), !0;
    }
    i.times++;
  }
};
var Base = function (t) {
  return this.ver = '1.0.9', this.syn = 0, this.err = 0, this._conf = util.ext({}, Base.dftCon), this.sampleCache = {}, this.requestQueue = [], this.hash = util.seq(), this.resetSession(), this.setConfig(t), this.rip = util.getRandIP(), this._common = {}, this;
};
Base.dftCon = {
  sample: 1,
  tag: '',
  imgUrls: ['https://openmonitor.alipay-eco.com/cloudmonitor/put.htm?'],
  release: undefined,
  environment: 'production',
  charset: 'utf-8',
}, Base.prototype = {
  constructor: Base,
  getPage() {
    const e = this._conf.page;
    return util.safetyCall(e, [], `${e}`);
  },
  setPage() { },
  setConfig(e) {
    e && typeof e === 'object' && (util.verifyConfig(e), e = this.setImgUrl(e), this._conf = util.ext({}, this._conf, e));
  },
  setImgUrl(e) {
    return e.imgUrl && (this._conf.imgUrls = [e.imgUrl]), e;
  },
  sendRequest() { },
  postData() { },
  commonInfo() {
    return {};
  },
  setCommonInfo(e) {
    e && typeof e === 'object' && (this._common = util.ext({}, this._common, e));
  },
  resetSession() {
    this.session = util.uu(), this.sBegin = Date.now();
  },
  getConfig(e) {
    return e ? this._conf[e] : util.ext({}, this._conf);
  },
  sampling(e) {
    return e === 1 || (typeof this.sampleCache[e] === 'boolean' ? this.sampleCache[e] : (this.sampleCache[e] = util.pick(e),
    this.sampleCache[e]));
  },
  clear() {
    let e; const
      t = this;
    if (t.syn > 2) {
      return clearTimeout(t.requestTimmer), t.requestTimmer = setTimeout(() => {
        t.clear();
      }, 50), t;
    }
    for (clearTimeout(t.requestTimmer), t.requestTimmer = null; t.syn < 2 && (e = t.requestQueue.pop()); t.syn++) {
      e.t === 'res' ? t.postData(e, 'res') : e.t === 'error' ? t.postData(e, 'err') : e.t === 'behavior' ? t.postData(e, 'behavior') : t.sendRequest(e);
    }
    !!t.requestQueue.length && (t.requestTimmer = setTimeout(() => {
      t.clear();
    }, 50));
    return this;
  },
  getToken(e) {
    const t = this._conf.token;
    return !t ? '-' : t[e] || '-';
  },
  _lg(e, t, i) {
    const n = this._conf; const r = t.page || util.patchPath(this.getPage()); const s = n.ignore || {}; const o = s.ignoreErrors; const u = s.ignoreUrls; const
      a = s.ignoreApis;
    return util.ignoreByRule(r, u) || util.ignoreByRule(util.decode(r), u) ? this : e === 'error' && (util.ignoreByRule(t.msg, o) || util.ignoreByRule(util.decode(t.msg), o)) ? this : e === 'api' && (util.ignoreByRule(t.api, a) || util.ignoreByRule(util.decode(t.api), a)) ? this : t && !n.disabled && (n.pid || n.token) ? i && !this.sampling(i) ? this : (t = util.ext({
      t: e,
      page: r,
      environment: n.environment,
      _input_charset: n.charset,
      timestamp: Date.now(),
    }, t, this.commonInfo(), this._common, {
      token: this.getToken(e),
      pid: n.pid || '-',
      _v: this.ver,
      sampling: i || 1,
    }), pushToQueue(this, t)) : this;
  },
  custom(e, t) {
    if (!e || typeof e !== 'object') {
      return this;
    }
    let i = !1;
    const r = {
      timestamp: Date.now(),
    };
    return util.each(e, (e, t) => !(i = t && t.length <= 20) && util.warn(`[CloudMonitor] invalid key: ${t}`), r[`x-${t}`] = e, i), i ? this._lg('custom', r, t || 1) : this;
  },
  logInfo() {
    if (arguments.length === 0) return;
    let msg = '';
    for (let e = 0, n = arguments.length; e < n; e++) {
      msg += (` ${JSON.stringify(arguments[e])}`);
    }
    const r = {
      timestamp: Date.now(),
      level: 'info',
      msg: msg.substring(1),
    };
    return this._lg('log', r, 1), this;
  },
  report(k, e) {
    if (!k || !e || typeof e !== 'object') {
      return this;
    }
    let i = !1;
    const r = {
      timestamp: Date.now(),
    };
    return util.each(e, (e, t) => !(i = t && t.length <= 20) && util.warn(`[CloudMonitor] invalid key: ${t}`), r[`x-${t}`] = e, i), i ? this._lg(k, r, 1) : this;
  },
};
const base = Base;
const validApiKeys = ['api', 'success', 'time', 'code', 'msg', 'begin', 'response', 'c1', 'c2', 'c3'];
const parseStatData = function (t, e) {
  const r = t.split('::');
  return r.length > 1 ? util_1.ext({
    group: r[0],
    key: r[1],
  }, e) : util_1.ext({
    group: 'default_group',
    key: r[0],
  }, e);
};
const Reporter = function (t) {
  base.call(this, t);
  let e;
  try {
    e = typeof performance === 'object' ? performance.timing.fetchStart : Date.now();
  } catch (r) {
    e = Date.now();
  }
  return this._startTime = e, this;
};
Reporter.prototype = util_1.createObject(base.prototype), util_1.ext(base.dftCon, {
  startTime: null,
}), util_1.ext(Reporter.prototype, {
  constructor: Reporter,
  _super: base,
  sum(t, e, r) {
    try {
      return this._lg('sum', parseStatData(t, {
        val: e || 1,
        begin: Date.now(),
      }), r);
    } catch (n) {
      util_1.warn(`[retcode] can not get parseStatData: ${n}`);
    }
  },
  avg(t, e, r) {
    try {
      return this._lg('avg', parseStatData(t, {
        val: e || 0,
        begin: Date.now(),
      }), r);
    } catch (n) {
      util_1.warn(`[retcode] can not get parseStatData: ${n}`);
    }
  },
  percent(t, e, r, n) {
    try {
      return this._lg('percent', parseStatData(t, {
        subkey: e,
        val: r || 0,
        begin: Date.now(),
      }), n);
    } catch (i) {
      util_1.warn(`[retcode] can not get parseStatData: ${i}`);
    }
  },
  msg(t, e) {
    if (t && !(t.length > 180)) {
      return this.custom({
        msg: t,
      }, e);
    }
  },
  error(t, e) {
    if (!t) {
      return util_1.warn(`[cloudMonitor] invalid param e: ${t}`), this;
    }
    arguments.length === 1 ? (typeof t === 'string' && (t = {
      message: t,
    }, e = {}), typeof t === 'object' && (e = t = t.error || t)) : (typeof t === 'string' && (t = {
      message: t,
    }), typeof e !== 'object' && (e = {}));
    const r = t.name || 'CustomError';
    var n = util_1.encode(t.message);
    const i = util_1.encode(util_1.replaceAll(t.stack || '', 'http.*\\d*:\\d*', 'unknow'));
    e = e || {};
    const s = {
      begin: Date.now(),
      cate: r,
      msg: n.substring(0, 256),
      stack: i && i.substring(0, 256),
      file: e.filename || '',
      line: e.lineno || '',
      col: e.colno || '',
      err: {
        msg_raw: n,
        stack_raw: i,
      },
    }; var
      n = (this.getConfig('ignore') || {}).ignoreErrors;
    return util.ignoreByRule(s.msg, n) || util.ignoreByRule(util.decode(s.msg), n) ? this : (this.beforeSend && this.beforeSend('error', s)), this._lg('error', s, 1);
  },
  behavior(t) {
    if (t) {
      const e = typeof t === 'object' && t.behavior ? t : {
        behavior: t,
      };
      return this.beforeSend && this.beforeSend('behavior', t), this._lg('behavior', e, 1);
    }
  },
  api(e, t, r, i, a, s) {
    if (!e) {
      return util.warn('[cloudMonitor] api is null'), this;
    }
    e = typeof e === 'string' ? {
      api: e,
      success: t,
      time: r,
      code: i,
      msg: a,
      begin: s,
    } : util.sub(e, validApiKeys);
    if (e.code = e.code || '', e.msg = e.msg || '', e.success = e.success ? 1 : 0, e.time = +e.time, e.begin = e.begin || '', !e.api || isNaN(e.time)) {
      return util.warn('[cloudMonitor] invalid time or api'), this;
    }
    const c = (this.getConfig('ignore') || {}).ignoreApis;
    if (util.ignoreByRule(e.api, c) || util.ignoreByRule(util.decode(e.api), c)) return this;
    this.beforeSend && this.beforeSend('api', e);
    return this._lg('api', e, e.success && !e.response && this.getConfig('sample'));
  },
  resource(t, e) {
    if (!t || !util_1.isPlainObject(t)) {
      return util_1.warn(`[cloudMonitor] invalid param data: ${t}`), this;
    }
    const r = Object.keys(t);
    const n = ['begin', 'dom', 'load', 'res', 'dl'];
    let i = !1;
    for (const o in n) {
      if (r.indexOf(n[o]) < 0) {
        i = !0;
        break;
      }
    }
    if (i) {
      return util_1.warn(`[cloudMonitor] lack param data: ${t}`), this;
    }
    const a = {
      begin: t.begin || Date.now(),
      dom: t.dom || '',
      load: t.load || '',
      res: util_1.isArray(t.res) ? JSON.stringify(t.res) : JSON.stringify([]),
      dl: t.dl || '',
    };
    return this._lg('res', a, e);
  },
}), Reporter._super = base, Reporter._root = base, base.Reporter = Reporter;
const reporter = Reporter;
const MiniProgramLogger = function (t) {
  const o = this;
  return Reporter.call(o, t), o._health = {
    errcount: 0,
    apisucc: 0,
    apifail: 0,
  }, o.DEFAUT_PAGE_PATH = '[app]', o.isSendPerf = !1, o.beforeSend = function (e, t) {
    e === 'error' ? o._health.errcount++ : e === 'api' && o._health[t.success ? 'apisucc' : 'apifail']++;
  }, typeof o.autoSetCommonInfo === 'function' && o.autoSetCommonInfo(), this;
};
MiniProgramLogger.prototype = util.createObject(Reporter.prototype), util.ext(Reporter._root.dftCon, {
  sendRequest() { }, getCurrentPage() { }, getPrePage() { },
}), util.ext(MiniProgramLogger.prototype, {
  constructor: MiniProgramLogger,
  _super: Reporter,
  onReady(e) {
    const t = this;
    t._common.uid ? e() : setTimeout(() => {
      t.onReady(e);
    }, 100);
  },
  sendRequest(e, o) {
    const a = this;
    if (a.getConfig('debug') || a.err > 0) {
      typeof console !== 'undefined' && console && typeof console.log === 'function' && console.log('[cloudMonitor] [DEBUG MODE] log data', e);
    } else {
      const r = a._conf.sendRequest;
      util.each(a.getConfig('imgUrls'), (t, i) => {
        typeof e === 'object' && (e = util.serialize(e));
        let n = t + e;
        o && (n += '&post_res=');
        if (typeof r === 'function') {
          try {
            !i ? r(n, o, a) : r(n, o);
          } catch (i) {
            util.warn('[cloudMonitor] error in sendRequest', i);
          }
        }
      });
    }
  },
  postData(e, o) {
    const t = {};
    t[o] = e[o], delete e[o], this.sendRequest(e, t);
  },
  getPage(delta) {
    const e = this._conf.getCurrentPage;
    if (typeof e === 'function') {
      try {
        const o = e();
        if (o && typeof o === 'string') {
          return o;
        }
      } catch (t) {
        util.warn('[cloudMonitor] error in getPage', t);
      }
    }
    return typeof e === 'string' && e ? e : this.DEFAUT_PAGE_PATH;
  },
  addHook() {
    return this;
  },
  removeHook() {
    return this;
  },
  hookApp(e) {
    const o = this;
    const t = {
      onError(t) {
        const n = arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments);
        const r = e.onError;
        try {
          o.error(t);
        } catch (t) {
          util.warn('[cloudMonitor] error in hookApp:onError', t);
        }
        if (typeof r === 'function') {
          return r.apply(this, n);
        }
      },
    };
    return util.ext({}, e, t);
  },
  autoSetCommonInfo() {
    this.setCommonInfo({
      app: 'mini_common',
      uid: this._conf.uid,
    });
  },
  _lgPV(t) {
    if (!t) return;
    if (typeof t === 'string') {
      t = { page: t };
    }
    t.page = util.cutUrlSearch(t.page);
    t.url && (t.url = util.cutUrlSearch(t.url));
    !t.spmPre && (t.spmPre = util.toHex(this.getPage()) || ''), !t.spmId && (t.spmId = util.toHex(t.page) || ''), !t.scene && (t.scene = ''), this._lg('pv', t);
  },
  sendHealthOnPageShowOrHide() {
    try {
      this.sessionPage = this.getPage(), this.sendHealth(), this.speedCache && (this._lg('speed', this.speedCache), this.speedCache = null,
      clearTimeout(this.speedTimmer)), this.clear();
    } catch (o) {
      util.warn('[cloudMonitor] error in sendHealthOnPageShowOrHide', o);
    }
  },
  sendHealth() {
    if (this.sessionPage) {
      const e = util.ext({}, this._health);
      e.healthy = e.errcount > 0 ? 0 : 1, e.begin = Date.now();
      const o = e.begin - this.sBegin;
      e.page = this.sessionPage, e.stay = o, this._lg('health', e, 1), this._health = {
        errcount: 0,
        apisucc: 0,
        apifail: 0,
      }, this.sessionPage = null;
    }
  },
  parseResponse(e) {
    if (!e || typeof e !== 'object') return {};
    const r = '';
    let c = util.getPropertyValue(e, this._conf.code) || e.stat || e.status || e.code || e.success;
    let u = util.getPropertyValue(e, this._conf.msg) || e.msg || e.message || e.subMsg || e.errorMsg || e.ret || e.errorResponse || '';
    typeof u === 'object' && (c = c || u.code, u = u.msg || u.message || u.info || u.ret || JSON.stringify(u));
    return {
      code: c,
      msg: u,
      response: util.pick(10000) ? JSON.stringify(e).substr(0, 256) : '',
    };
  },
});
MiniProgramLogger._super = reporter, MiniProgramLogger._root = reporter._root, reporter.MiniProgramLogger = MiniProgramLogger;
const miniProgramLogger = MiniProgramLogger;
const STORAGE_MINIPROGRAM_ALIPAY_UID_KEY = 'STORAGE_MINIPROGRAM_ALIPAY_UID';
const AlipayLogger = function (t) {
  return MiniProgramLogger.call(this, t), this;
};
AlipayLogger.prototype = util.createObject(MiniProgramLogger.prototype), util.ext(MiniProgramLogger._root.dftCon, {
  sendRequest(t, e, a) {
    if (typeof my !== 'undefined' && my && typeof my.request === 'function') {
      try {
        let o; let
          r = 'GET';
        e && (r = 'POST', o = JSON.stringify(e)), my.request({
          url: t,
          method: r,
          data: o,
          dataType: 'json',
          fail(t) {
            util.warn('[cloudMonitor] sendRequest fail', t);
            a && a.err++;
          },
          complete(_t) {
            a && a.syn--;
          },
        });
      } catch (n) {
        util.warn('[cloudMonitor] error in conf sendRequest', n);
      }
    }
  },
  getCurrentPage() {
    if (typeof getCurrentPages === 'function') {
      try {
        const t = getCurrentPages() || [];
        const e = t[t.length - 1];
        return e && e.route || null;
      } catch (o) {
        util.warn('[cloudMonitor] error in conf getCurrentPage', o);
      }
    }
  },
  getPrePage(delta) {
    if (typeof getCurrentPages === 'function') {
      try {
        const t = getCurrentPages() || [];
        const e = delta === undefined ? t[t.length - 2] : delta >= t.length ? t[0] : t[t.length - 1 - delta];
        return e && e.route || null;
      } catch (o) {
        util.warn('[cloudMonitor] error in conf getCurrentPage', o);
      }
    }
  },
}), util.ext(AlipayLogger.prototype, {
  constructor: AlipayLogger,
  _super: MiniProgramLogger,
  autoSetCommonInfo() {
    this.setCommonInfo({
      app: 'mini_alipay',
    }), this.autoSetNetworkType(), this.autoSetUid(), this.autoSystemInfo(), this.autoSetAppId(), this.autoSetSDKVersion(), this.autoSetRunScene();
  },
  autoSetUid() {
    const t = this;
    if (t._conf && t._conf.uid) {
      t.setCommonInfo({
        uid: t._conf.uid,
      });
    } else if (typeof my !== 'undefined' && my && typeof my.getStorage === 'function') {
      try {
        my.getStorage({
          key: STORAGE_MINIPROGRAM_ALIPAY_UID_KEY,
          success(e) {
            if (e && e.data && typeof e.data === 'string') {
              t.setCommonInfo({
                uid: e.data,
              });
            } else if (typeof my.setStorage === 'function') {
              const o = util.uu();
              my.setStorage({
                key: STORAGE_MINIPROGRAM_ALIPAY_UID_KEY,
                data: o,
                success() {
                  t.setCommonInfo({
                    uid: o,
                  });
                },
                fail(t) {
                  util.warn('[cloudMonitor] error in setStorage', t);
                },
              });
            }
          },
          fail(t) {
            util.warn('[cloudMonitor] error in getStorage', t);
          },
        });
      } catch (e) {
        util.warn('[cloudMonitor] error in autoSetUid', e);
      }
    }
  },
  autoSystemInfo() {
    const t = this;
    if (typeof my !== 'undefined' && my && typeof my.getSystemInfo === 'function') {
      try {
        my.getSystemInfo({
          success(e) {
            e && typeof e.model === 'string' && typeof e.version === 'string' && typeof e.platform === 'string' && typeof e.language === 'string' && t.setCommonInfo({
              mobile: e.model,
              version: e.version,
              platform: e.platform,
              system: e.system,
              resolution: `${e.windowWidth}*${e.windowHeight}`,
              language: e.language,
            });
          },
          fail(t) {
            util.warn('[cloudMonitor] autoSystemInfo getSystemInfo fail', t);
          },
        });
      } catch (e) {
        util.warn('[cloudMonitor] error in getSystemInfo', e);
      }
    }
  },
  autoSetNetworkType() {
    const t = this;
    if (typeof my !== 'undefined' && my && typeof my.getNetworkType === 'function') {
      try {
        my.getNetworkType({
          success(e) {
            e && typeof e.networkType === 'string' && t.setCommonInfo({
              net: e.networkType,
            });
          },
          fail(t) {
            util.warn('[cloudMonitor] autoSetNetworkType getNetworkType fail', t);
          },
        });
      } catch (e) {
        util.warn('[cloudMonitor] error in autoSetNetworkType', e);
      }
    }
  },
  autoSetAppId() {
    const t = this;
    if (typeof my !== 'undefined' && my && typeof my.getAppIdSync === 'function') {
      try {
        const appIdRes = my.getAppIdSync();
        t.setCommonInfo({ appId: appIdRes.appId });
      } catch (e) {
        util.warn('[cloudMonitor] error in autoSetNetworkType', e);
      }
    }
  },
  autoSetSDKVersion() {
    const t = this;
    if (typeof my !== 'undefined' && my && typeof my.SDKVersion === 'string') {
      t.setCommonInfo({
        sdk_version: my.SDKVersion,
      });
    }
  },
  autoSetRunScene() {
    const t = this;
    if (typeof my !== 'undefined' && my && typeof my.getRunScene === 'function') {
      try {
        my.getRunScene({
          success(e) {
            t._conf.environment = e.envVersion;
          },
        });
      } catch (e) {
        util.warn('[cloudMonitor] error in autoSetRunScene', e);
      }
    }
  },
  addHook() {
    const e = this;
    const t = util;
    const ca = e._conf.autoReportApi;
    const cp = e._conf.autoReportPage;

    !e.isHookInstantiated && (function () {
      if (ca) {
        if (typeof my !== 'undefined' && my && typeof my.request === 'function') {
          const s = my.request;
          var a = Object.getOwnPropertyDescriptor(my, 'request');
          a && a.writable && (my.request = function (i) {
            const a = new Date().getTime();
            let n = i;
            if (i && i.url) {
              const o = t.cutUrlSearch(i.url);
              if (!t.checkAPI(o, !0)) {
                return s.call(my, n);
              }
              let u = n && n.headers;
              const f = e._conf.extendApi;
              u && typeof u === 'object' || (u = {});
              const p = {
                success(t) {
                  typeof i.success === 'function' && i.success(t);
                  const s = new Date().getTime();
                  let u = {};
                  if (t.data && (!i.dataType || i.dataType === 'json')) {
                    u = e.parseResponse(t.data);
                    f && (u = util.ext(u, util.safetyCall(f, [i.data, t.data], {})));
                  }
                  e.api(util.ext({
                    api: o,
                    success: !0,
                    time: s - a,
                    code: '',
                    msg: '',
                    response: '',
                  }, u));
                },
                fail(t) {
                  typeof i.fail === 'function' && i.fail(t);
                  const s = new Date().getTime();
                  let n = '';
                  t && t.status && (n = t.status);
                  n == '' && t.error && (n = t.error);
                  let u = '';
                  const r = f ? util.safetyCall(f, [i.data], {}) : {};
                  t && t.body && (u = (u = JSON.stringify(t.body)).substring(0, 256)), e.api(util.ext({
                    api: o,
                    success: !1,
                    time: s - a,
                    code: n,
                    msg: u,
                  }, r));
                },
              };
              n = t.ext({}, n, p);
            }
            return s.call(my, n);
          });
        }
      }
      if (cp && typeof my !== 'undefined' && my) {
        if (typeof my.call === 'function') {
          const c = my.call;
          var a = Object.getOwnPropertyDescriptor(my, 'call');
          a && a.writable && (my.call = function (i, j, k) {
            if (i && i == 'startApp' && j && j.param && j.param.url) {
              let o = j.param.url;
              o = t.cutUrlSearch(o);
              e._lgPV({
                page: o,
                c3: 'c',
              });
            }
            return e.sendHealthOnPageShowOrHide(), c.call(my, i, j, k);
          });
        }
        if (typeof my.navigateTo === 'function') {
          const n = my.navigateTo;
          var a = Object.getOwnPropertyDescriptor(my, 'navigateTo');
          a && a.writable && (my.navigateTo = function (i) {
            if (i && i.url) {
              const o = t.cutUrlSearch(t.patchPath(i.url));
              e._lgPV({
                page: o,
                c3: 'nt',
              });
            }
            return e.sendHealthOnPageShowOrHide(), n.call(my, i);
          });
        }
        if (typeof my.navigateBack === 'function') {
          const w = my.navigateBack;
          var a = Object.getOwnPropertyDescriptor(my, 'navigateBack');
          a && a.writable && (my.navigateBack = function (i) {
            e._lgPV({
              page: e._conf.getPrePage(i || 1),
              c3: 'nb',
            });
            return e.sendHealthOnPageShowOrHide(), w.call(my, i);
          });
        }
        if (typeof my.redirectTo === 'function') {
          const x = my.redirectTo;
          var a = Object.getOwnPropertyDescriptor(my, 'redirectTo');
          a && a.writable && (my.redirectTo = function (i) {
            if (i && i.url) {
              const o = t.cutUrlSearch(t.patchPath(i.url));
              e._lgPV({
                page: o,
                c3: 'rt',
              });
            }
            return e.sendHealthOnPageShowOrHide(), x.call(my, i);
          });
        }
        if (typeof my.switchTab === 'function') {
          const y = my.switchTab;
          var a = Object.getOwnPropertyDescriptor(my, 'switchTab');
          a && a.writable && (my.switchTab = function (i) {
            if (i && i.url) {
              const o = t.cutUrlSearch(t.patchPath(i.url));
              e._lgPV({
                page: o,
                spmPre: 'T',
                c3: 'st',
              });
            }
            return e.sendHealthOnPageShowOrHide(), y.call(my, i);
          });
        }
        if (typeof my.reLaunch === 'function') {
          const z = my.reLaunch;
          var a = Object.getOwnPropertyDescriptor(my, 'reLaunch');
          a && a.writable && (my.reLaunch = function (i) {
            if (i && i.url) {
              const o = t.cutUrlSearch(t.patchPath(i.url));
              e._lgPV({
                page: o,
                spmPre: 'T',
                c3: 'rl',
              });
            }
            return z.call(my, i);
          });
        }
        if (typeof my.navigateToMiniProgram === 'function') {
          const m = my.navigateToMiniProgram;
          var a = Object.getOwnPropertyDescriptor(my, 'navigateToMiniProgram');
          a && a.writable && (my.navigateToMiniProgram = function (i) {
            if (i) {
              let o = i.path || i.appId || '-';
              o = t.cutUrlSearch(o);
              e._lgPV({
                page: o,
                c3: 'ntmp',
              });
            }
            return m.call(my, i);
          });
        }
      }
    }.call(e), e.isHookInstantiated = !0);
    return e;
  },
  init(t) {
    if (!t || !t.pid) {
      util.warn('[cloudMonitor] not set pid');
    }
    let p; const
      e = this;
    if (t.options) {
      p = t.options.path, t.scene = t.options.scene, delete t.options;
    }
    if (!t.ignore) {
      t.ignore = {
        ignoreUrls: [/\.(png|jpg|gif|jpeg)$/, /[\"{}]+/, /\.tfs.alipayobjects.com\.*/],
      };
    }
    this.setConfig(t), this.addHook();
    if (p) {
      e.entrance = util.toHex(p);
      e.onReady(() => {
        e._lg('pv', { spmPre: 'E', spmId: e.entrance || '', scene: e._conf.scene || '', c3: 'init' });
      });
    }
    return this;
  },
});
AlipayLogger._super = miniProgramLogger, AlipayLogger._root = miniProgramLogger._root, miniProgramLogger.AlipayLogger = AlipayLogger;
export default new AlipayLogger();

