import { n as normalizeComponent, A as FullModal, h as Icon, B as MaterialDetailPreviewNavigator, C as Info, T as ToolTip, E as Button, d as api, m as mixins, o as editor, _ as __vue2_script$1, H as EnterpriseMaterialDetailModal, p as commonjsGlobal, v as getUserDeviceId } from "./index.js";
/*!
 * Determine if an object is a Buffer
 *
 * @author   Feross Aboukhadijeh <https://feross.org>
 * @license  MIT
 */
var isBuffer$1 = function isBuffer(obj) {
  return obj != null && obj.constructor != null && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
};
var render$1 = function() {
  var _vm = this;
  var _h = _vm.$createElement;
  var _c = _vm._self._c || _h;
  return _c("FullModal", {
    attrs: {
      "visible": _vm.visible
    },
    on: {
      "change": _vm.handleVisibleChange
    }
  }, [_c("MaterialDetailPreviewNavigator", {
    class: _vm.bem("preview"),
    attrs: {
      "material": _vm.materialDetail,
      "materials": _vm.materials,
      "index": _vm.index,
      "backdropBlur": ""
    },
    on: {
      "change": _vm.handleIndexChange
    }
  }, [_c("div", {
    class: _vm.bem("menubar"),
    attrs: {
      "slot": "head"
    },
    slot: "head"
  }, [_vm.material ? _c("div", {
    class: [_vm.bem("icon"), _vm.bem("favo")]
  }, [_vm._t("favo", null, {
    "material": _vm.material,
    "materials": _vm.materials
  })], 2) : _vm._e(), _c("ATooltip", {
    attrs: {
      "placement": "bottom"
    }
  }, [_c("template", {
    slot: "title"
  }, [_vm._v("\u8D44\u6E90\u4FE1\u606F")]), _c("Icon", {
    class: _vm.bem("icon"),
    attrs: {
      "type": "iconinfo_outline"
    },
    on: {
      "click": _vm.toggleInfoVisible
    }
  })], 2), _vm.canEdit ? _c("AButton", {
    directives: [{
      name: "paid",
      rawName: "v-paid",
      value: {
        type: "MATERIAL"
      },
      expression: "{ type: 'MATERIAL' }"
    }],
    class: _vm.bem("btn"),
    on: {
      "click": _vm.openEditor
    }
  }, [_c("Icon", {
    attrs: {
      "type": "iconcolor_lens_fill"
    }
  }), _vm._v(" \u5F00\u59CB\u521B\u4F5C ")], 1) : _vm._e()], 1)]), _c("Info", {
    attrs: {
      "material": _vm.materialDetail
    },
    model: {
      value: _vm.infoVisible,
      callback: function($$v) {
        _vm.infoVisible = $$v;
      },
      expression: "infoVisible"
    }
  })], 1);
};
var staticRenderFns$1 = [];
const { cdmApi } = api;
const { openEditor } = editor;
const { bem } = mixins;
const __vue2_script = {
  name: "gaoding-material-detail",
  components: {
    FullModal,
    Icon,
    MaterialDetailPreviewNavigator,
    Info,
    ATooltip: ToolTip,
    AButton: Button
  },
  mixins: [bem],
  model: {
    prop: "visible",
    event: "change"
  },
  props: {
    visible: {
      type: Boolean,
      default: false
    },
    materials: {
      type: Array,
      required: true
    },
    index: {
      type: Number,
      required: true
    },
    canEdit: {
      type: Boolean,
      default: true
    },
    checkExpireTime: {
      type: Boolean,
      default: false
    },
    hasExpires: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      materialDetail: null,
      infoVisible: true
    };
  },
  computed: {
    material() {
      const index2 = this.index;
      if (index2 > -1 && index2 < this.materials.length) {
        return this.materials[this.index];
      }
      return null;
    }
  },
  watch: {
    visible: {
      handler(val) {
        if (!val) {
          this.materialDetail = null;
          this.infoVisible = true;
        }
      },
      immediate: true
    },
    index: {
      handler() {
        if (this.material) {
          this.fetchData();
        }
      },
      immediate: true
    }
  },
  methods: {
    async fetchData() {
      var _a;
      const id = this.material.id;
      const { data } = await cdmApi.getMaterialDetail({ id });
      const { design_category_id, channel_category_id } = data;
      const requests = [design_category_id, channel_category_id].map((id2) => id2 ? this.fetchCategoryDetail(id2) : Promise.resolve());
      const [design_category, channel_category] = await Promise.all(requests);
      data.design_category = design_category;
      data.channel_category = channel_category;
      data.favo = (_a = this.material.favo) != null ? _a : false;
      this.materialDetail = data;
    },
    async fetchCategoryDetail(id) {
      const { data } = await cdmApi.getCategoryDetail({ id });
      return data;
    },
    handleVisibleChange(val) {
      this.$emit("change", val);
    },
    toggleInfoVisible() {
      this.infoVisible = !this.infoVisible;
    },
    handleIndexChange(index2) {
      this.$emit("update:index", index2);
    },
    openEditor() {
      const execute = () => {
        this.$emit("recordOpenEditor", this.material, this.index);
        openEditor(this.materialDetail);
      };
      if (this.checkExpireTime) {
        this.hasExpires ? this.$emit("openContactModal") : execute();
      } else {
        execute();
      }
    }
  }
};
const __cssModules$1 = {};
var __component__$1 = /* @__PURE__ */ normalizeComponent(__vue2_script, render$1, staticRenderFns$1, false, __vue2_injectStyles$1, null, null, null);
function __vue2_injectStyles$1(context) {
  for (let o in __cssModules$1) {
    this[o] = __cssModules$1[o];
  }
}
var GaodingMaterialDetailModal = /* @__PURE__ */ function() {
  return __component__$1.exports;
}();
var render = function() {
  var _vm = this;
  var _h = _vm.$createElement;
  var _c = _vm._self._c || _h;
  return _c("FullModal", {
    attrs: {
      "visible": _vm.visible
    },
    on: {
      "change": _vm.handleVisibleChange
    }
  }, [_c("div", {
    ref: "container",
    class: _vm.bem("container")
  }, [_c("MaterialDetailPreviewNavigator", {
    class: _vm.bem("preview"),
    attrs: {
      "material": _vm.materialDetail,
      "materials": _vm.materials,
      "index": _vm.index,
      "backdropBlur": ""
    },
    on: {
      "change": _vm.handleIndexChange
    }
  }, [_c("div", {
    class: _vm.bem("menubar"),
    attrs: {
      "slot": "head"
    },
    slot: "head"
  }, [_c("ATooltip", {
    attrs: {
      "placement": "bottom"
    }
  }, [_c("template", {
    slot: "title"
  }, [_vm._v("\u8D44\u6E90\u4FE1\u606F")]), _c("Icon", {
    class: _vm.bem("icon"),
    attrs: {
      "type": "iconinfo_outline"
    },
    on: {
      "click": _vm.toggleInfoVisible
    }
  })], 2), _vm.downloadable ? _c("ATooltip", {
    attrs: {
      "placement": "bottom"
    }
  }, [_c("template", {
    slot: "title"
  }, [_vm._v("\u4E0B\u8F7D\u8D44\u6E90")]), _c("Icon", {
    class: _vm.bem("icon"),
    attrs: {
      "type": "icondownload_outline"
    },
    on: {
      "click": _vm.download
    }
  })], 2) : _vm._e(), _c("EllipsisDropdown", {
    class: _vm.bem("dropdown"),
    attrs: {
      "ellipsisClass": _vm.bem("icon"),
      "actions": _vm.actions,
      "theme": "pure",
      "type": "vertical"
    }
  }), _vm.creative ? _c("AButton", {
    class: _vm.bem("btn"),
    on: {
      "click": _vm.openEditor
    }
  }, [_c("Icon", {
    attrs: {
      "type": _vm.editorBtn.icon
    }
  }), _vm._v(" " + _vm._s(_vm.editorBtn.text) + " ")], 1) : _vm._e()], 1)]), _c("Info", {
    attrs: {
      "material": _vm.materialDetail,
      "repositoryId": _vm.repositoryId,
      "titleEditable": _vm.titleEditable,
      "showHistory": _vm.showHistory
    },
    on: {
      "titleChange": _vm.handleTitleChange
    },
    model: {
      value: _vm.infoVisible,
      callback: function($$v) {
        _vm.infoVisible = $$v;
      },
      expression: "infoVisible"
    }
  }, [_vm.isShowColorFilter ? _c("Property", [_c("MaterialColors", {
    attrs: {
      "material": _vm.materialDetail
    },
    on: {
      "lookup": _vm.handleLookupColor
    }
  })], 1) : _vm._e(), _c("Property", {
    attrs: {
      "name": "\u5206\u7C7B"
    }
  }, [_c("Categories", {
    attrs: {
      "categoryIds": _vm.categoryIds,
      "repositoryId": _vm.repositoryId,
      "categories": _vm.categories,
      "editable": _vm.isPersonalRepository || _vm.repUpdateCategoryPermission,
      "creatable": _vm.isPersonalRepository || _vm.categoriesCreatePermission,
      "modifiers": [{
        name: "offset",
        options: {
          offset: [-32, 7]
        }
      }]
    },
    on: {
      "update:categories": _vm.handleUpdateCategories,
      "change": _vm.handleCategoriesChange
    }
  })], 1), _c("Property", {
    attrs: {
      "name": "\u6807\u7B7E"
    }
  }, [_c("Tags", {
    attrs: {
      "initialTagIds": _vm.initialTagIds,
      "initialTags": _vm.initialTags,
      "repositoryId": _vm.repositoryId,
      "editable": _vm.isPersonalRepository || _vm.repUpdateTagPermission,
      "creatable": _vm.isPersonalRepository || _vm.tagCreatePermission,
      "modifiers": [{
        name: "offset",
        options: {
          offset: [-32, 7]
        }
      }],
      "noTagGroup": _vm.noTagGroup
    },
    on: {
      "changeTag": _vm.handleChangeTag
    }
  })], 1)], 1)], 1)]);
};
var staticRenderFns = [];
const __cssModules = {};
var __component__ = /* @__PURE__ */ normalizeComponent(__vue2_script$1, render, staticRenderFns, false, __vue2_injectStyles, null, null, null);
function __vue2_injectStyles(context) {
  for (let o in __cssModules) {
    this[o] = __cssModules[o];
  }
}
var CDSMaterialDetailModal = /* @__PURE__ */ function() {
  return __component__.exports;
}();
var MaterialDetailModal = {
  name: "material-detail-modal",
  EnterpriseMaterialDetailModal,
  GaodingMaterialDetailModal,
  CDSMaterialDetailModal
};
var axios$2 = { exports: {} };
var bind$2 = function bind(fn, thisArg) {
  return function wrap() {
    var args = new Array(arguments.length);
    for (var i = 0; i < args.length; i++) {
      args[i] = arguments[i];
    }
    return fn.apply(thisArg, args);
  };
};
var bind$1 = bind$2;
var isBuffer2 = isBuffer$1;
var toString = Object.prototype.toString;
function isArray(val) {
  return toString.call(val) === "[object Array]";
}
function isArrayBuffer(val) {
  return toString.call(val) === "[object ArrayBuffer]";
}
function isFormData(val) {
  return typeof FormData !== "undefined" && val instanceof FormData;
}
function isArrayBufferView(val) {
  var result;
  if (typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView) {
    result = ArrayBuffer.isView(val);
  } else {
    result = val && val.buffer && val.buffer instanceof ArrayBuffer;
  }
  return result;
}
function isString(val) {
  return typeof val === "string";
}
function isNumber(val) {
  return typeof val === "number";
}
function isUndefined(val) {
  return typeof val === "undefined";
}
function isObject(val) {
  return val !== null && typeof val === "object";
}
function isDate(val) {
  return toString.call(val) === "[object Date]";
}
function isFile(val) {
  return toString.call(val) === "[object File]";
}
function isBlob(val) {
  return toString.call(val) === "[object Blob]";
}
function isFunction(val) {
  return toString.call(val) === "[object Function]";
}
function isStream(val) {
  return isObject(val) && isFunction(val.pipe);
}
function isURLSearchParams(val) {
  return typeof URLSearchParams !== "undefined" && val instanceof URLSearchParams;
}
function trim(str) {
  return str.replace(/^\s*/, "").replace(/\s*$/, "");
}
function isStandardBrowserEnv() {
  if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
    return false;
  }
  return typeof window !== "undefined" && typeof document !== "undefined";
}
function forEach(obj, fn) {
  if (obj === null || typeof obj === "undefined") {
    return;
  }
  if (typeof obj !== "object") {
    obj = [obj];
  }
  if (isArray(obj)) {
    for (var i = 0, l = obj.length; i < l; i++) {
      fn.call(null, obj[i], i, obj);
    }
  } else {
    for (var key in obj) {
      if (Object.prototype.hasOwnProperty.call(obj, key)) {
        fn.call(null, obj[key], key, obj);
      }
    }
  }
}
function merge() {
  var result = {};
  function assignValue(val, key) {
    if (typeof result[key] === "object" && typeof val === "object") {
      result[key] = merge(result[key], val);
    } else {
      result[key] = val;
    }
  }
  for (var i = 0, l = arguments.length; i < l; i++) {
    forEach(arguments[i], assignValue);
  }
  return result;
}
function extend(a, b, thisArg) {
  forEach(b, function assignValue(val, key) {
    if (thisArg && typeof val === "function") {
      a[key] = bind$1(val, thisArg);
    } else {
      a[key] = val;
    }
  });
  return a;
}
var utils$c = {
  isArray,
  isArrayBuffer,
  isBuffer: isBuffer2,
  isFormData,
  isArrayBufferView,
  isString,
  isNumber,
  isObject,
  isUndefined,
  isDate,
  isFile,
  isBlob,
  isFunction,
  isStream,
  isURLSearchParams,
  isStandardBrowserEnv,
  forEach,
  merge,
  extend,
  trim
};
var utils$b = utils$c;
var normalizeHeaderName$1 = function normalizeHeaderName(headers, normalizedName) {
  utils$b.forEach(headers, function processHeader(value, name) {
    if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
      headers[normalizedName] = value;
      delete headers[name];
    }
  });
};
var enhanceError$1 = function enhanceError(error, config, code, request2, response) {
  error.config = config;
  if (code) {
    error.code = code;
  }
  error.request = request2;
  error.response = response;
  return error;
};
var enhanceError2 = enhanceError$1;
var createError$2 = function createError(message, config, code, request2, response) {
  var error = new Error(message);
  return enhanceError2(error, config, code, request2, response);
};
var createError$1 = createError$2;
var settle$1 = function settle(resolve, reject, response) {
  var validateStatus2 = response.config.validateStatus;
  if (!response.status || !validateStatus2 || validateStatus2(response.status)) {
    resolve(response);
  } else {
    reject(createError$1("Request failed with status code " + response.status, response.config, null, response.request, response));
  }
};
var utils$a = utils$c;
function encode(val) {
  return encodeURIComponent(val).replace(/%40/gi, "@").replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+").replace(/%5B/gi, "[").replace(/%5D/gi, "]");
}
var buildURL$1 = function buildURL(url, params, paramsSerializer) {
  if (!params) {
    return url;
  }
  var serializedParams;
  if (paramsSerializer) {
    serializedParams = paramsSerializer(params);
  } else if (utils$a.isURLSearchParams(params)) {
    serializedParams = params.toString();
  } else {
    var parts = [];
    utils$a.forEach(params, function serialize(val, key) {
      if (val === null || typeof val === "undefined") {
        return;
      }
      if (utils$a.isArray(val)) {
        key = key + "[]";
      } else {
        val = [val];
      }
      utils$a.forEach(val, function parseValue(v) {
        if (utils$a.isDate(v)) {
          v = v.toISOString();
        } else if (utils$a.isObject(v)) {
          v = JSON.stringify(v);
        }
        parts.push(encode(key) + "=" + encode(v));
      });
    });
    serializedParams = parts.join("&");
  }
  if (serializedParams) {
    url += (url.indexOf("?") === -1 ? "?" : "&") + serializedParams;
  }
  return url;
};
var utils$9 = utils$c;
var ignoreDuplicateOf = [
  "age",
  "authorization",
  "content-length",
  "content-type",
  "etag",
  "expires",
  "from",
  "host",
  "if-modified-since",
  "if-unmodified-since",
  "last-modified",
  "location",
  "max-forwards",
  "proxy-authorization",
  "referer",
  "retry-after",
  "user-agent"
];
var parseHeaders$1 = function parseHeaders(headers) {
  var parsed = {};
  var key;
  var val;
  var i;
  if (!headers) {
    return parsed;
  }
  utils$9.forEach(headers.split("\n"), function parser(line) {
    i = line.indexOf(":");
    key = utils$9.trim(line.substr(0, i)).toLowerCase();
    val = utils$9.trim(line.substr(i + 1));
    if (key) {
      if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
        return;
      }
      if (key === "set-cookie") {
        parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
      } else {
        parsed[key] = parsed[key] ? parsed[key] + ", " + val : val;
      }
    }
  });
  return parsed;
};
var utils$8 = utils$c;
var isURLSameOrigin$1 = utils$8.isStandardBrowserEnv() ? function standardBrowserEnv() {
  var msie = /(msie|trident)/i.test(navigator.userAgent);
  var urlParsingNode = document.createElement("a");
  var originURL;
  function resolveURL(url) {
    var href = url;
    if (msie) {
      urlParsingNode.setAttribute("href", href);
      href = urlParsingNode.href;
    }
    urlParsingNode.setAttribute("href", href);
    return {
      href: urlParsingNode.href,
      protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, "") : "",
      host: urlParsingNode.host,
      search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, "") : "",
      hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, "") : "",
      hostname: urlParsingNode.hostname,
      port: urlParsingNode.port,
      pathname: urlParsingNode.pathname.charAt(0) === "/" ? urlParsingNode.pathname : "/" + urlParsingNode.pathname
    };
  }
  originURL = resolveURL(window.location.href);
  return function isURLSameOrigin2(requestURL) {
    var parsed = utils$8.isString(requestURL) ? resolveURL(requestURL) : requestURL;
    return parsed.protocol === originURL.protocol && parsed.host === originURL.host;
  };
}() : function nonStandardBrowserEnv() {
  return function isURLSameOrigin2() {
    return true;
  };
}();
var utils$7 = utils$c;
var cookies = utils$7.isStandardBrowserEnv() ? function standardBrowserEnv2() {
  return {
    write: function write(name, value, expires, path, domain, secure) {
      var cookie = [];
      cookie.push(name + "=" + encodeURIComponent(value));
      if (utils$7.isNumber(expires)) {
        cookie.push("expires=" + new Date(expires).toGMTString());
      }
      if (utils$7.isString(path)) {
        cookie.push("path=" + path);
      }
      if (utils$7.isString(domain)) {
        cookie.push("domain=" + domain);
      }
      if (secure === true) {
        cookie.push("secure");
      }
      document.cookie = cookie.join("; ");
    },
    read: function read(name) {
      var match = document.cookie.match(new RegExp("(^|;\\s*)(" + name + ")=([^;]*)"));
      return match ? decodeURIComponent(match[3]) : null;
    },
    remove: function remove(name) {
      this.write(name, "", Date.now() - 864e5);
    }
  };
}() : function nonStandardBrowserEnv2() {
  return {
    write: function write() {
    },
    read: function read() {
      return null;
    },
    remove: function remove() {
    }
  };
}();
var utils$6 = utils$c;
var settle2 = settle$1;
var buildURL2 = buildURL$1;
var parseHeaders2 = parseHeaders$1;
var isURLSameOrigin = isURLSameOrigin$1;
var createError2 = createError$2;
var xhr = function xhrAdapter(config) {
  return new Promise(function dispatchXhrRequest(resolve, reject) {
    var requestData = config.data;
    var requestHeaders = config.headers;
    if (utils$6.isFormData(requestData)) {
      delete requestHeaders["Content-Type"];
    }
    var request2 = new XMLHttpRequest();
    if (config.auth) {
      var username = config.auth.username || "";
      var password = config.auth.password || "";
      requestHeaders.Authorization = "Basic " + btoa(username + ":" + password);
    }
    request2.open(config.method.toUpperCase(), buildURL2(config.url, config.params, config.paramsSerializer), true);
    request2.timeout = config.timeout;
    request2.onreadystatechange = function handleLoad() {
      if (!request2 || request2.readyState !== 4) {
        return;
      }
      if (request2.status === 0 && !(request2.responseURL && request2.responseURL.indexOf("file:") === 0)) {
        return;
      }
      var responseHeaders = "getAllResponseHeaders" in request2 ? parseHeaders2(request2.getAllResponseHeaders()) : null;
      var responseData = !config.responseType || config.responseType === "text" ? request2.responseText : request2.response;
      var response = {
        data: responseData,
        status: request2.status,
        statusText: request2.statusText,
        headers: responseHeaders,
        config,
        request: request2
      };
      settle2(resolve, reject, response);
      request2 = null;
    };
    request2.onerror = function handleError() {
      reject(createError2("Network Error", config, null, request2));
      request2 = null;
    };
    request2.ontimeout = function handleTimeout() {
      reject(createError2("timeout of " + config.timeout + "ms exceeded", config, "ECONNABORTED", request2));
      request2 = null;
    };
    if (utils$6.isStandardBrowserEnv()) {
      var cookies$1 = cookies;
      var xsrfValue = (config.withCredentials || isURLSameOrigin(config.url)) && config.xsrfCookieName ? cookies$1.read(config.xsrfCookieName) : void 0;
      if (xsrfValue) {
        requestHeaders[config.xsrfHeaderName] = xsrfValue;
      }
    }
    if ("setRequestHeader" in request2) {
      utils$6.forEach(requestHeaders, function setRequestHeader(val, key) {
        if (typeof requestData === "undefined" && key.toLowerCase() === "content-type") {
          delete requestHeaders[key];
        } else {
          request2.setRequestHeader(key, val);
        }
      });
    }
    if (config.withCredentials) {
      request2.withCredentials = true;
    }
    if (config.responseType) {
      try {
        request2.responseType = config.responseType;
      } catch (e) {
        if (config.responseType !== "json") {
          throw e;
        }
      }
    }
    if (typeof config.onDownloadProgress === "function") {
      request2.addEventListener("progress", config.onDownloadProgress);
    }
    if (typeof config.onUploadProgress === "function" && request2.upload) {
      request2.upload.addEventListener("progress", config.onUploadProgress);
    }
    if (config.cancelToken) {
      config.cancelToken.promise.then(function onCanceled(cancel) {
        if (!request2) {
          return;
        }
        request2.abort();
        reject(cancel);
        request2 = null;
      });
    }
    if (requestData === void 0) {
      requestData = null;
    }
    request2.send(requestData);
  });
};
var utils$5 = utils$c;
var normalizeHeaderName2 = normalizeHeaderName$1;
var DEFAULT_CONTENT_TYPE = {
  "Content-Type": "application/x-www-form-urlencoded"
};
function setContentTypeIfUnset(headers, value) {
  if (!utils$5.isUndefined(headers) && utils$5.isUndefined(headers["Content-Type"])) {
    headers["Content-Type"] = value;
  }
}
function getDefaultAdapter() {
  var adapter;
  if (typeof XMLHttpRequest !== "undefined") {
    adapter = xhr;
  } else if (typeof process !== "undefined") {
    adapter = xhr;
  }
  return adapter;
}
var defaults$3 = {
  adapter: getDefaultAdapter(),
  transformRequest: [function transformRequest(data, headers) {
    normalizeHeaderName2(headers, "Content-Type");
    if (utils$5.isFormData(data) || utils$5.isArrayBuffer(data) || utils$5.isBuffer(data) || utils$5.isStream(data) || utils$5.isFile(data) || utils$5.isBlob(data)) {
      return data;
    }
    if (utils$5.isArrayBufferView(data)) {
      return data.buffer;
    }
    if (utils$5.isURLSearchParams(data)) {
      setContentTypeIfUnset(headers, "application/x-www-form-urlencoded;charset=utf-8");
      return data.toString();
    }
    if (utils$5.isObject(data)) {
      setContentTypeIfUnset(headers, "application/json;charset=utf-8");
      return JSON.stringify(data);
    }
    return data;
  }],
  transformResponse: [function transformResponse(data) {
    if (typeof data === "string") {
      try {
        data = JSON.parse(data);
      } catch (e) {
      }
    }
    return data;
  }],
  timeout: 0,
  xsrfCookieName: "XSRF-TOKEN",
  xsrfHeaderName: "X-XSRF-TOKEN",
  maxContentLength: -1,
  validateStatus: function validateStatus(status) {
    return status >= 200 && status < 300;
  }
};
defaults$3.headers = {
  common: {
    "Accept": "application/json, text/plain, */*"
  }
};
utils$5.forEach(["delete", "get", "head"], function forEachMethodNoData(method) {
  defaults$3.headers[method] = {};
});
utils$5.forEach(["post", "put", "patch"], function forEachMethodWithData(method) {
  defaults$3.headers[method] = utils$5.merge(DEFAULT_CONTENT_TYPE);
});
var defaults_1 = defaults$3;
var utils$4 = utils$c;
function InterceptorManager$1() {
  this.handlers = [];
}
InterceptorManager$1.prototype.use = function use(fulfilled, rejected) {
  this.handlers.push({
    fulfilled,
    rejected
  });
  return this.handlers.length - 1;
};
InterceptorManager$1.prototype.eject = function eject(id) {
  if (this.handlers[id]) {
    this.handlers[id] = null;
  }
};
InterceptorManager$1.prototype.forEach = function forEach2(fn) {
  utils$4.forEach(this.handlers, function forEachHandler(h) {
    if (h !== null) {
      fn(h);
    }
  });
};
var InterceptorManager_1 = InterceptorManager$1;
var utils$3 = utils$c;
var transformData$1 = function transformData(data, headers, fns) {
  utils$3.forEach(fns, function transform(fn) {
    data = fn(data, headers);
  });
  return data;
};
var isCancel$1 = function isCancel(value) {
  return !!(value && value.__CANCEL__);
};
var isAbsoluteURL$1 = function isAbsoluteURL(url) {
  return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
};
var combineURLs$1 = function combineURLs(baseURL, relativeURL) {
  return relativeURL ? baseURL.replace(/\/+$/, "") + "/" + relativeURL.replace(/^\/+/, "") : baseURL;
};
var utils$2 = utils$c;
var transformData2 = transformData$1;
var isCancel2 = isCancel$1;
var defaults$2 = defaults_1;
var isAbsoluteURL2 = isAbsoluteURL$1;
var combineURLs2 = combineURLs$1;
function throwIfCancellationRequested(config) {
  if (config.cancelToken) {
    config.cancelToken.throwIfRequested();
  }
}
var dispatchRequest$1 = function dispatchRequest(config) {
  throwIfCancellationRequested(config);
  if (config.baseURL && !isAbsoluteURL2(config.url)) {
    config.url = combineURLs2(config.baseURL, config.url);
  }
  config.headers = config.headers || {};
  config.data = transformData2(config.data, config.headers, config.transformRequest);
  config.headers = utils$2.merge(config.headers.common || {}, config.headers[config.method] || {}, config.headers || {});
  utils$2.forEach(["delete", "get", "head", "post", "put", "patch", "common"], function cleanHeaderConfig(method) {
    delete config.headers[method];
  });
  var adapter = config.adapter || defaults$2.adapter;
  return adapter(config).then(function onAdapterResolution(response) {
    throwIfCancellationRequested(config);
    response.data = transformData2(response.data, response.headers, config.transformResponse);
    return response;
  }, function onAdapterRejection(reason) {
    if (!isCancel2(reason)) {
      throwIfCancellationRequested(config);
      if (reason && reason.response) {
        reason.response.data = transformData2(reason.response.data, reason.response.headers, config.transformResponse);
      }
    }
    return Promise.reject(reason);
  });
};
var defaults$1 = defaults_1;
var utils$1 = utils$c;
var InterceptorManager = InterceptorManager_1;
var dispatchRequest2 = dispatchRequest$1;
function Axios$1(instanceConfig) {
  this.defaults = instanceConfig;
  this.interceptors = {
    request: new InterceptorManager(),
    response: new InterceptorManager()
  };
}
Axios$1.prototype.request = function request(config) {
  if (typeof config === "string") {
    config = utils$1.merge({
      url: arguments[0]
    }, arguments[1]);
  }
  config = utils$1.merge(defaults$1, { method: "get" }, this.defaults, config);
  config.method = config.method.toLowerCase();
  var chain = [dispatchRequest2, void 0];
  var promise = Promise.resolve(config);
  this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
    chain.unshift(interceptor.fulfilled, interceptor.rejected);
  });
  this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
    chain.push(interceptor.fulfilled, interceptor.rejected);
  });
  while (chain.length) {
    promise = promise.then(chain.shift(), chain.shift());
  }
  return promise;
};
utils$1.forEach(["delete", "get", "head", "options"], function forEachMethodNoData2(method) {
  Axios$1.prototype[method] = function(url, config) {
    return this.request(utils$1.merge(config || {}, {
      method,
      url
    }));
  };
});
utils$1.forEach(["post", "put", "patch"], function forEachMethodWithData2(method) {
  Axios$1.prototype[method] = function(url, data, config) {
    return this.request(utils$1.merge(config || {}, {
      method,
      url,
      data
    }));
  };
});
var Axios_1 = Axios$1;
function Cancel$1(message) {
  this.message = message;
}
Cancel$1.prototype.toString = function toString2() {
  return "Cancel" + (this.message ? ": " + this.message : "");
};
Cancel$1.prototype.__CANCEL__ = true;
var Cancel_1 = Cancel$1;
var Cancel = Cancel_1;
function CancelToken(executor) {
  if (typeof executor !== "function") {
    throw new TypeError("executor must be a function.");
  }
  var resolvePromise;
  this.promise = new Promise(function promiseExecutor(resolve) {
    resolvePromise = resolve;
  });
  var token = this;
  executor(function cancel(message) {
    if (token.reason) {
      return;
    }
    token.reason = new Cancel(message);
    resolvePromise(token.reason);
  });
}
CancelToken.prototype.throwIfRequested = function throwIfRequested() {
  if (this.reason) {
    throw this.reason;
  }
};
CancelToken.source = function source() {
  var cancel;
  var token = new CancelToken(function executor(c) {
    cancel = c;
  });
  return {
    token,
    cancel
  };
};
var CancelToken_1 = CancelToken;
var spread = function spread2(callback) {
  return function wrap(arr) {
    return callback.apply(null, arr);
  };
};
var utils = utils$c;
var bind2 = bind$2;
var Axios = Axios_1;
var defaults = defaults_1;
function createInstance(defaultConfig) {
  var context = new Axios(defaultConfig);
  var instance = bind2(Axios.prototype.request, context);
  utils.extend(instance, Axios.prototype, context);
  utils.extend(instance, context);
  return instance;
}
var axios$1 = createInstance(defaults);
axios$1.Axios = Axios;
axios$1.create = function create(instanceConfig) {
  return createInstance(utils.merge(defaults, instanceConfig));
};
axios$1.Cancel = Cancel_1;
axios$1.CancelToken = CancelToken_1;
axios$1.isCancel = isCancel$1;
axios$1.all = function all(promises) {
  return Promise.all(promises);
};
axios$1.spread = spread;
axios$2.exports = axios$1;
axios$2.exports.default = axios$1;
var axios = axios$2.exports;
var md5$1 = { exports: {} };
var core = { exports: {} };
(function(module, exports) {
  (function(root, factory) {
    {
      module.exports = factory();
    }
  })(commonjsGlobal, function() {
    var CryptoJS = CryptoJS || function(Math2, undefined$1) {
      var create2 = Object.create || function() {
        function F() {
        }
        return function(obj) {
          var subtype;
          F.prototype = obj;
          subtype = new F();
          F.prototype = null;
          return subtype;
        };
      }();
      var C = {};
      var C_lib = C.lib = {};
      var Base = C_lib.Base = function() {
        return {
          extend: function(overrides) {
            var subtype = create2(this);
            if (overrides) {
              subtype.mixIn(overrides);
            }
            if (!subtype.hasOwnProperty("init") || this.init === subtype.init) {
              subtype.init = function() {
                subtype.$super.init.apply(this, arguments);
              };
            }
            subtype.init.prototype = subtype;
            subtype.$super = this;
            return subtype;
          },
          create: function() {
            var instance = this.extend();
            instance.init.apply(instance, arguments);
            return instance;
          },
          init: function() {
          },
          mixIn: function(properties) {
            for (var propertyName in properties) {
              if (properties.hasOwnProperty(propertyName)) {
                this[propertyName] = properties[propertyName];
              }
            }
            if (properties.hasOwnProperty("toString")) {
              this.toString = properties.toString;
            }
          },
          clone: function() {
            return this.init.prototype.extend(this);
          }
        };
      }();
      var WordArray = C_lib.WordArray = Base.extend({
        init: function(words, sigBytes) {
          words = this.words = words || [];
          if (sigBytes != undefined$1) {
            this.sigBytes = sigBytes;
          } else {
            this.sigBytes = words.length * 4;
          }
        },
        toString: function(encoder) {
          return (encoder || Hex).stringify(this);
        },
        concat: function(wordArray) {
          var thisWords = this.words;
          var thatWords = wordArray.words;
          var thisSigBytes = this.sigBytes;
          var thatSigBytes = wordArray.sigBytes;
          this.clamp();
          if (thisSigBytes % 4) {
            for (var i = 0; i < thatSigBytes; i++) {
              var thatByte = thatWords[i >>> 2] >>> 24 - i % 4 * 8 & 255;
              thisWords[thisSigBytes + i >>> 2] |= thatByte << 24 - (thisSigBytes + i) % 4 * 8;
            }
          } else {
            for (var i = 0; i < thatSigBytes; i += 4) {
              thisWords[thisSigBytes + i >>> 2] = thatWords[i >>> 2];
            }
          }
          this.sigBytes += thatSigBytes;
          return this;
        },
        clamp: function() {
          var words = this.words;
          var sigBytes = this.sigBytes;
          words[sigBytes >>> 2] &= 4294967295 << 32 - sigBytes % 4 * 8;
          words.length = Math2.ceil(sigBytes / 4);
        },
        clone: function() {
          var clone = Base.clone.call(this);
          clone.words = this.words.slice(0);
          return clone;
        },
        random: function(nBytes) {
          var words = [];
          var r = function(m_w) {
            var m_w = m_w;
            var m_z = 987654321;
            var mask = 4294967295;
            return function() {
              m_z = 36969 * (m_z & 65535) + (m_z >> 16) & mask;
              m_w = 18e3 * (m_w & 65535) + (m_w >> 16) & mask;
              var result = (m_z << 16) + m_w & mask;
              result /= 4294967296;
              result += 0.5;
              return result * (Math2.random() > 0.5 ? 1 : -1);
            };
          };
          for (var i = 0, rcache; i < nBytes; i += 4) {
            var _r = r((rcache || Math2.random()) * 4294967296);
            rcache = _r() * 987654071;
            words.push(_r() * 4294967296 | 0);
          }
          return new WordArray.init(words, nBytes);
        }
      });
      var C_enc = C.enc = {};
      var Hex = C_enc.Hex = {
        stringify: function(wordArray) {
          var words = wordArray.words;
          var sigBytes = wordArray.sigBytes;
          var hexChars = [];
          for (var i = 0; i < sigBytes; i++) {
            var bite = words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
            hexChars.push((bite >>> 4).toString(16));
            hexChars.push((bite & 15).toString(16));
          }
          return hexChars.join("");
        },
        parse: function(hexStr) {
          var hexStrLength = hexStr.length;
          var words = [];
          for (var i = 0; i < hexStrLength; i += 2) {
            words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << 24 - i % 8 * 4;
          }
          return new WordArray.init(words, hexStrLength / 2);
        }
      };
      var Latin1 = C_enc.Latin1 = {
        stringify: function(wordArray) {
          var words = wordArray.words;
          var sigBytes = wordArray.sigBytes;
          var latin1Chars = [];
          for (var i = 0; i < sigBytes; i++) {
            var bite = words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
            latin1Chars.push(String.fromCharCode(bite));
          }
          return latin1Chars.join("");
        },
        parse: function(latin1Str) {
          var latin1StrLength = latin1Str.length;
          var words = [];
          for (var i = 0; i < latin1StrLength; i++) {
            words[i >>> 2] |= (latin1Str.charCodeAt(i) & 255) << 24 - i % 4 * 8;
          }
          return new WordArray.init(words, latin1StrLength);
        }
      };
      var Utf8 = C_enc.Utf8 = {
        stringify: function(wordArray) {
          try {
            return decodeURIComponent(escape(Latin1.stringify(wordArray)));
          } catch (e) {
            throw new Error("Malformed UTF-8 data");
          }
        },
        parse: function(utf8Str) {
          return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
        }
      };
      var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
        reset: function() {
          this._data = new WordArray.init();
          this._nDataBytes = 0;
        },
        _append: function(data) {
          if (typeof data == "string") {
            data = Utf8.parse(data);
          }
          this._data.concat(data);
          this._nDataBytes += data.sigBytes;
        },
        _process: function(doFlush) {
          var data = this._data;
          var dataWords = data.words;
          var dataSigBytes = data.sigBytes;
          var blockSize = this.blockSize;
          var blockSizeBytes = blockSize * 4;
          var nBlocksReady = dataSigBytes / blockSizeBytes;
          if (doFlush) {
            nBlocksReady = Math2.ceil(nBlocksReady);
          } else {
            nBlocksReady = Math2.max((nBlocksReady | 0) - this._minBufferSize, 0);
          }
          var nWordsReady = nBlocksReady * blockSize;
          var nBytesReady = Math2.min(nWordsReady * 4, dataSigBytes);
          if (nWordsReady) {
            for (var offset = 0; offset < nWordsReady; offset += blockSize) {
              this._doProcessBlock(dataWords, offset);
            }
            var processedWords = dataWords.splice(0, nWordsReady);
            data.sigBytes -= nBytesReady;
          }
          return new WordArray.init(processedWords, nBytesReady);
        },
        clone: function() {
          var clone = Base.clone.call(this);
          clone._data = this._data.clone();
          return clone;
        },
        _minBufferSize: 0
      });
      C_lib.Hasher = BufferedBlockAlgorithm.extend({
        cfg: Base.extend(),
        init: function(cfg) {
          this.cfg = this.cfg.extend(cfg);
          this.reset();
        },
        reset: function() {
          BufferedBlockAlgorithm.reset.call(this);
          this._doReset();
        },
        update: function(messageUpdate) {
          this._append(messageUpdate);
          this._process();
          return this;
        },
        finalize: function(messageUpdate) {
          if (messageUpdate) {
            this._append(messageUpdate);
          }
          var hash = this._doFinalize();
          return hash;
        },
        blockSize: 512 / 32,
        _createHelper: function(hasher) {
          return function(message, cfg) {
            return new hasher.init(cfg).finalize(message);
          };
        },
        _createHmacHelper: function(hasher) {
          return function(message, key) {
            return new C_algo.HMAC.init(hasher, key).finalize(message);
          };
        }
      });
      var C_algo = C.algo = {};
      return C;
    }(Math);
    return CryptoJS;
  });
})(core);
(function(module, exports) {
  (function(root, factory) {
    {
      module.exports = factory(core.exports);
    }
  })(commonjsGlobal, function(CryptoJS) {
    (function(Math2) {
      var C = CryptoJS;
      var C_lib = C.lib;
      var WordArray = C_lib.WordArray;
      var Hasher = C_lib.Hasher;
      var C_algo = C.algo;
      var T = [];
      (function() {
        for (var i = 0; i < 64; i++) {
          T[i] = Math2.abs(Math2.sin(i + 1)) * 4294967296 | 0;
        }
      })();
      var MD5 = C_algo.MD5 = Hasher.extend({
        _doReset: function() {
          this._hash = new WordArray.init([
            1732584193,
            4023233417,
            2562383102,
            271733878
          ]);
        },
        _doProcessBlock: function(M, offset) {
          for (var i = 0; i < 16; i++) {
            var offset_i = offset + i;
            var M_offset_i = M[offset_i];
            M[offset_i] = (M_offset_i << 8 | M_offset_i >>> 24) & 16711935 | (M_offset_i << 24 | M_offset_i >>> 8) & 4278255360;
          }
          var H = this._hash.words;
          var M_offset_0 = M[offset + 0];
          var M_offset_1 = M[offset + 1];
          var M_offset_2 = M[offset + 2];
          var M_offset_3 = M[offset + 3];
          var M_offset_4 = M[offset + 4];
          var M_offset_5 = M[offset + 5];
          var M_offset_6 = M[offset + 6];
          var M_offset_7 = M[offset + 7];
          var M_offset_8 = M[offset + 8];
          var M_offset_9 = M[offset + 9];
          var M_offset_10 = M[offset + 10];
          var M_offset_11 = M[offset + 11];
          var M_offset_12 = M[offset + 12];
          var M_offset_13 = M[offset + 13];
          var M_offset_14 = M[offset + 14];
          var M_offset_15 = M[offset + 15];
          var a = H[0];
          var b = H[1];
          var c = H[2];
          var d = H[3];
          a = FF(a, b, c, d, M_offset_0, 7, T[0]);
          d = FF(d, a, b, c, M_offset_1, 12, T[1]);
          c = FF(c, d, a, b, M_offset_2, 17, T[2]);
          b = FF(b, c, d, a, M_offset_3, 22, T[3]);
          a = FF(a, b, c, d, M_offset_4, 7, T[4]);
          d = FF(d, a, b, c, M_offset_5, 12, T[5]);
          c = FF(c, d, a, b, M_offset_6, 17, T[6]);
          b = FF(b, c, d, a, M_offset_7, 22, T[7]);
          a = FF(a, b, c, d, M_offset_8, 7, T[8]);
          d = FF(d, a, b, c, M_offset_9, 12, T[9]);
          c = FF(c, d, a, b, M_offset_10, 17, T[10]);
          b = FF(b, c, d, a, M_offset_11, 22, T[11]);
          a = FF(a, b, c, d, M_offset_12, 7, T[12]);
          d = FF(d, a, b, c, M_offset_13, 12, T[13]);
          c = FF(c, d, a, b, M_offset_14, 17, T[14]);
          b = FF(b, c, d, a, M_offset_15, 22, T[15]);
          a = GG(a, b, c, d, M_offset_1, 5, T[16]);
          d = GG(d, a, b, c, M_offset_6, 9, T[17]);
          c = GG(c, d, a, b, M_offset_11, 14, T[18]);
          b = GG(b, c, d, a, M_offset_0, 20, T[19]);
          a = GG(a, b, c, d, M_offset_5, 5, T[20]);
          d = GG(d, a, b, c, M_offset_10, 9, T[21]);
          c = GG(c, d, a, b, M_offset_15, 14, T[22]);
          b = GG(b, c, d, a, M_offset_4, 20, T[23]);
          a = GG(a, b, c, d, M_offset_9, 5, T[24]);
          d = GG(d, a, b, c, M_offset_14, 9, T[25]);
          c = GG(c, d, a, b, M_offset_3, 14, T[26]);
          b = GG(b, c, d, a, M_offset_8, 20, T[27]);
          a = GG(a, b, c, d, M_offset_13, 5, T[28]);
          d = GG(d, a, b, c, M_offset_2, 9, T[29]);
          c = GG(c, d, a, b, M_offset_7, 14, T[30]);
          b = GG(b, c, d, a, M_offset_12, 20, T[31]);
          a = HH(a, b, c, d, M_offset_5, 4, T[32]);
          d = HH(d, a, b, c, M_offset_8, 11, T[33]);
          c = HH(c, d, a, b, M_offset_11, 16, T[34]);
          b = HH(b, c, d, a, M_offset_14, 23, T[35]);
          a = HH(a, b, c, d, M_offset_1, 4, T[36]);
          d = HH(d, a, b, c, M_offset_4, 11, T[37]);
          c = HH(c, d, a, b, M_offset_7, 16, T[38]);
          b = HH(b, c, d, a, M_offset_10, 23, T[39]);
          a = HH(a, b, c, d, M_offset_13, 4, T[40]);
          d = HH(d, a, b, c, M_offset_0, 11, T[41]);
          c = HH(c, d, a, b, M_offset_3, 16, T[42]);
          b = HH(b, c, d, a, M_offset_6, 23, T[43]);
          a = HH(a, b, c, d, M_offset_9, 4, T[44]);
          d = HH(d, a, b, c, M_offset_12, 11, T[45]);
          c = HH(c, d, a, b, M_offset_15, 16, T[46]);
          b = HH(b, c, d, a, M_offset_2, 23, T[47]);
          a = II(a, b, c, d, M_offset_0, 6, T[48]);
          d = II(d, a, b, c, M_offset_7, 10, T[49]);
          c = II(c, d, a, b, M_offset_14, 15, T[50]);
          b = II(b, c, d, a, M_offset_5, 21, T[51]);
          a = II(a, b, c, d, M_offset_12, 6, T[52]);
          d = II(d, a, b, c, M_offset_3, 10, T[53]);
          c = II(c, d, a, b, M_offset_10, 15, T[54]);
          b = II(b, c, d, a, M_offset_1, 21, T[55]);
          a = II(a, b, c, d, M_offset_8, 6, T[56]);
          d = II(d, a, b, c, M_offset_15, 10, T[57]);
          c = II(c, d, a, b, M_offset_6, 15, T[58]);
          b = II(b, c, d, a, M_offset_13, 21, T[59]);
          a = II(a, b, c, d, M_offset_4, 6, T[60]);
          d = II(d, a, b, c, M_offset_11, 10, T[61]);
          c = II(c, d, a, b, M_offset_2, 15, T[62]);
          b = II(b, c, d, a, M_offset_9, 21, T[63]);
          H[0] = H[0] + a | 0;
          H[1] = H[1] + b | 0;
          H[2] = H[2] + c | 0;
          H[3] = H[3] + d | 0;
        },
        _doFinalize: function() {
          var data = this._data;
          var dataWords = data.words;
          var nBitsTotal = this._nDataBytes * 8;
          var nBitsLeft = data.sigBytes * 8;
          dataWords[nBitsLeft >>> 5] |= 128 << 24 - nBitsLeft % 32;
          var nBitsTotalH = Math2.floor(nBitsTotal / 4294967296);
          var nBitsTotalL = nBitsTotal;
          dataWords[(nBitsLeft + 64 >>> 9 << 4) + 15] = (nBitsTotalH << 8 | nBitsTotalH >>> 24) & 16711935 | (nBitsTotalH << 24 | nBitsTotalH >>> 8) & 4278255360;
          dataWords[(nBitsLeft + 64 >>> 9 << 4) + 14] = (nBitsTotalL << 8 | nBitsTotalL >>> 24) & 16711935 | (nBitsTotalL << 24 | nBitsTotalL >>> 8) & 4278255360;
          data.sigBytes = (dataWords.length + 1) * 4;
          this._process();
          var hash = this._hash;
          var H = hash.words;
          for (var i = 0; i < 4; i++) {
            var H_i = H[i];
            H[i] = (H_i << 8 | H_i >>> 24) & 16711935 | (H_i << 24 | H_i >>> 8) & 4278255360;
          }
          return hash;
        },
        clone: function() {
          var clone = Hasher.clone.call(this);
          clone._hash = this._hash.clone();
          return clone;
        }
      });
      function FF(a, b, c, d, x, s, t) {
        var n = a + (b & c | ~b & d) + x + t;
        return (n << s | n >>> 32 - s) + b;
      }
      function GG(a, b, c, d, x, s, t) {
        var n = a + (b & d | c & ~d) + x + t;
        return (n << s | n >>> 32 - s) + b;
      }
      function HH(a, b, c, d, x, s, t) {
        var n = a + (b ^ c ^ d) + x + t;
        return (n << s | n >>> 32 - s) + b;
      }
      function II(a, b, c, d, x, s, t) {
        var n = a + (c ^ (b | ~d)) + x + t;
        return (n << s | n >>> 32 - s) + b;
      }
      C.MD5 = Hasher._createHelper(MD5);
      C.HmacMD5 = Hasher._createHmacHelper(MD5);
    })(Math);
    return CryptoJS.MD5;
  });
})(md5$1);
var md5 = md5$1.exports;
function _classCallCheck(instance, Constructor) {
  if (!(instance instanceof Constructor)) {
    throw new TypeError("Cannot call a class as a function");
  }
}
function _defineProperties(target, props) {
  for (var i = 0; i < props.length; i++) {
    var descriptor = props[i];
    descriptor.enumerable = descriptor.enumerable || false;
    descriptor.configurable = true;
    if ("value" in descriptor)
      descriptor.writable = true;
    Object.defineProperty(target, descriptor.key, descriptor);
  }
}
function _createClass(Constructor, protoProps, staticProps) {
  if (protoProps)
    _defineProperties(Constructor.prototype, protoProps);
  if (staticProps)
    _defineProperties(Constructor, staticProps);
  return Constructor;
}
var AB_WIND_TRACK = {
  event: "abtest_track",
  event_id: 125,
  ab_tags: []
};
var WIND_TRACK = function WIND_TRACK2(option, abTags) {
  var user_id = option.user_id, device_id = option.device_id, is_login = option.is_login, app_name = option.app_name;
  var timestamp = new Date().getTime();
  var versions = "8.12.0";
  var env = "prod";
  var project = app_name;
  if (app_name.endsWith("_dev")) {
    env = "dev";
    project = app_name.replace("_dev", "");
  }
  if (process) {
    versions = process.versions && process.versions.node || "8.12.0";
  }
  return {
    data: {
      attributes: {
        ab_tags: abTags
      },
      device_id: String(device_id),
      user_id: String(user_id),
      is_login: Number(is_login),
      event: AB_WIND_TRACK.event,
      event_id: AB_WIND_TRACK.event_id,
      timestamp,
      env
    },
    project,
    sdk_version: "1.0.0",
    report_time: timestamp,
    path: "/wind",
    runtime: {
      plat: "node",
      version: "v".concat(versions)
    }
  };
};
var gzip = function gzip2(input, options) {
  var zlib = require("zlib");
  var promise = new Promise(function(resolve, reject) {
    zlib.gzip(input, options, function(error, result) {
      if (!error)
        resolve(result);
      else
        reject(Error(error));
    });
  });
  return promise;
};
var abtestTrack = function abtestTrack2(option, abTags) {
  return gzip(JSON.stringify(WIND_TRACK(option, abTags))).then(function(buffer) {
    var base64 = buffer.toString("base64");
    return axios.get("https://wind.hlgdata.com/wind?gzip=1&data=".concat(encodeURIComponent(base64)));
  }).catch(function(err) {
    console.log(err);
  });
};
var ABTEST_KEY_SIGN = "ABTEST_KEY_SIGN";
var rules = {
  app_key: [{
    require: true,
    message: "parameter app_key is not present"
  }, {
    empty: false,
    message: "parameter app_key cannot be empty"
  }],
  app_name: [{
    require: true,
    message: "parameter app_name is not present"
  }, {
    empty: false,
    message: "parameter app_name cannot be empty"
  }],
  user_id: [{
    require: true,
    message: "parameter user_id is not present"
  }, {
    empty: true,
    message: "parameter user_id cannot be empty"
  }],
  device_id: [{
    require: true,
    message: "parameter device_id is not present"
  }, {
    empty: false,
    message: "parameter device_id cannot be empty"
  }],
  is_login: [{
    require: false,
    message: "parameter is_login is not present"
  }, {
    empty: false,
    message: "parameter is_login cannot be empty"
  }]
};
var isBrowser = function isBrowser2() {
  return typeof window !== "undefined";
};
var GdABTestSdk = /* @__PURE__ */ function() {
  function GdABTestSdk2() {
    _classCallCheck(this, GdABTestSdk2);
    this.option = null;
    this.hooks = {};
  }
  _createClass(GdABTestSdk2, [{
    key: "init",
    value: function init(option) {
      var flag = this._optionValidator(option);
      if (flag) {
        this.option = option;
      }
    }
  }, {
    key: "getSyncAbTags",
    value: function getSyncAbTags(eventId) {
      return this.takeAbtags(eventId);
    }
  }, {
    key: "getAsyncAbTags",
    value: function getAsyncAbTags(eventId) {
      var _this = this;
      return new Promise(function(resolve) {
        var abtags = _this.takeAbtags(eventId);
        if (!abtags) {
          _this.on("fetch", function() {
            var abtags2 = _this.takeAbtags(eventId);
            resolve(abtags2);
          });
          setTimeout(function() {
            var abtags2 = _this.takeAbtags(eventId);
            resolve(abtags2);
          }, 2e3);
          return;
        }
        resolve(abtags);
      });
    }
  }, {
    key: "getAbTags",
    value: function getAbTags(eventId) {
      var _this2 = this;
      return new Promise(function(resolve) {
        var abtags = _this2.takeAbtags(eventId);
        if (!abtags) {
          _this2.on("fetch", function() {
            var abtags2 = _this2.takeAbtags(eventId);
            resolve(abtags2);
          });
          setTimeout(function() {
            var abtags2 = _this2.takeAbtags(eventId);
            resolve(abtags2);
          }, 2e3);
          return;
        }
        resolve(abtags);
      });
    }
  }, {
    key: "takeAbtags",
    value: function takeAbtags(eventId) {
      var matchedExps = this._getMatchedExps(false);
      if (!matchedExps) {
        return null;
      }
      var exps = matchedExps.filter(function(exp) {
        return exp.eventIds.includes(eventId);
      });
      var abtags = exps.map(function(exp) {
        return "".concat(exp.experimentId, "_").concat(exp.versionId);
      });
      if (abtags.length === 0) {
        return null;
      }
      return abtags;
    }
  }, {
    key: "getValue",
    value: function getValue(variableName, defaultVaule) {
      if (typeof variableName === "string") {
        return this._getSingleValue(variableName, defaultVaule);
      }
      if (Array.isArray(variableName)) {
        if (!Array.isArray(defaultVaule)) {
          return "defaultVaule should be an array";
        }
        return this._getMultipleValue(variableName, defaultVaule);
      }
    }
  }, {
    key: "getTag",
    value: function getTag(variableName) {
      return this._getSingleTag(variableName);
    }
  }, {
    key: "setUserId",
    value: function setUserId(userId) {
      var _this3 = this;
      return new Promise(function(resolve, reject) {
        if (!_this3.option) {
          reject(new Error("Please initialize sdk first"));
        } else {
          resolve();
        }
      }).then(function() {
        if (userId !== _this3.option.user_id) {
          _this3.option.user_id = userId;
          _this3._clearMatchedExps();
          return _this3.getExps();
        }
      }).catch(function(err) {
        console.error(err);
      });
    }
  }, {
    key: "setDeviceId",
    value: function setDeviceId(deviceId) {
      var _this4 = this;
      return new Promise(function(resolve, reject) {
        if (!_this4.option) {
          reject(new Error("Please initialize sdk first"));
        } else {
          resolve();
        }
      }).then(function() {
        if (deviceId !== _this4.option.device_id) {
          _this4.option.device_id = deviceId;
          _this4._clearMatchedExps();
          return _this4.getExps();
        }
      }).catch(function(err) {
        console.error(err);
      });
    }
  }, {
    key: "on",
    value: function on(name, callback) {
      if (!this.hooks[name]) {
        this.hooks[name] = [];
      }
      this.hooks[name].push(callback);
    }
  }, {
    key: "runFetchHook",
    value: function runFetchHook(data) {
      if (!this.hooks.fetch) {
        return;
      }
      this.hooks.fetch.forEach(function(callback) {
        callback(data || []);
      });
    }
  }, {
    key: "runWindTrackHook",
    value: function runWindTrackHook(exps) {
      var ab_tags = exps.filter(function(data) {
        return data;
      }).map(function(data) {
        return "".concat(data.experimentId, "_").concat(data.versionId);
      });
      if (!this.hooks.windTrack) {
        if (!isBrowser()) {
          abtestTrack(this.option, ab_tags);
        }
        return;
      }
      this.hooks.windTrack.forEach(function(callback) {
        AB_WIND_TRACK.ab_tags = ab_tags || [];
        callback(AB_WIND_TRACK || {});
      });
    }
  }, {
    key: "getExps",
    value: function getExps() {
      var _this5 = this;
      return new Promise(function(resolve) {
        var exps = _this5._getMatchedExps();
        resolve(exps);
      }).then(function(exps) {
        if (exps) {
          return exps;
        } else {
          return _this5._requestExps();
        }
      }).then(function(res) {
        return res;
      });
    }
  }, {
    key: "getCache",
    value: function getCache() {
      return this._getMatchedExps();
    }
  }, {
    key: "_getMatchedExps",
    value: function _getMatchedExps() {
      var timeOutFlag = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
      var _ref = this.option || {}, app_key = _ref.app_key, device_id = _ref.device_id;
      if (global.localStorage && global.localStorage.getItem(app_key)) {
        var storage = JSON.parse(global.localStorage.getItem(app_key));
        var exp = storage.data[0];
        if (exp && exp.deviceId !== device_id) {
          return null;
        }
        if (timeOutFlag && new Date().getTime() - storage.timestamp < 60 * 30 * 1e3) {
          return storage.data;
        }
        if (!timeOutFlag) {
          return storage.data;
        }
      }
      return null;
    }
  }, {
    key: "_setMatchedExps",
    value: function _setMatchedExps(data) {
      var _ref2 = this.option || {}, app_key = _ref2.app_key;
      if (global.localStorage) {
        global.localStorage.setItem(app_key, JSON.stringify({
          timestamp: new Date().getTime(),
          data
        }));
      }
    }
  }, {
    key: "_clearMatchedExps",
    value: function _clearMatchedExps() {
      var _ref3 = this.option || {}, app_key = _ref3.app_key;
      if (global.localStorage) {
        global.localStorage.removeItem(app_key);
      }
    }
  }, {
    key: "_getSingleValue",
    value: function _getSingleValue(variableName) {
      var _this6 = this;
      var defaultVaule = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
      return this.getExps().then(function(data) {
        var exp = data.filter(function(item) {
          return item.variableName === variableName;
        });
        if (exp[0] && exp[0].variableValue) {
          _this6.runWindTrackHook(exp);
          return exp[0].variableValue;
        }
        return defaultVaule;
      }).catch(function() {
        return defaultVaule;
      });
    }
  }, {
    key: "_getSingleTag",
    value: function _getSingleTag(variableName) {
      return this.getExps().then(function(data) {
        var exp = data.find(function(item) {
          return item.variableName === variableName;
        });
        if (exp) {
          return "".concat(exp.experimentId, "_").concat(exp.versionId);
        }
        return null;
      }).catch(function() {
        return null;
      });
    }
  }, {
    key: "_getMultipleValue",
    value: function _getMultipleValue(variableNames) {
      var _this7 = this;
      var defaultVaule = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
      return this.getExps().then(function(data) {
        var exps = variableNames.map(function(val) {
          return data.find(function(item) {
            return val === item.variableName;
          });
        });
        _this7.runWindTrackHook(exps);
        var vals = exps.map(function(exp, index2) {
          if (exp) {
            return exp.variableValue;
          }
          return defaultVaule[index2] || "";
        });
        return vals;
      }).catch(function() {
        return defaultVaule;
      });
    }
  }, {
    key: "_requestExps",
    value: function _requestExps() {
      var _this8 = this;
      if (!this.option) {
        console.error("please initialize sdk first");
        return;
      }
      var _this$option = this.option, app_key = _this$option.app_key, app_name = _this$option.app_name, user_id = _this$option.user_id, device_id = _this$option.device_id, is_login = _this$option.is_login;
      var sign = md5(app_key + device_id + ABTEST_KEY_SIGN).toString().toUpperCase();
      return axios.get("https://abtest-proxy.hlgdata.com/v2/strategy/".concat(app_name), {
        params: {
          user_id,
          device_id,
          is_login
        },
        headers: {
          "ABTEST-SIGN": sign
        }
      }).then(function(res) {
        _this8._setMatchedExps(res.data);
        _this8.runFetchHook(res.data);
        return res.data;
      }).catch(function(err) {
        console.log(err);
      });
    }
  }, {
    key: "_optionValidator",
    value: function _optionValidator(option) {
      for (var key in rules) {
        if (rules[key][0].require && option[key] === void 0) {
          console.error(rules[key][0].message);
          return false;
        }
        if (!rules[key][1].empty && !option[key]) {
          console.error(rules[key][1].message);
          return false;
        }
      }
      return true;
    }
  }]);
  return GdABTestSdk2;
}();
var index = new GdABTestSdk();
const isDev = ["dev", "fat"].includes({}.ENV_NAME);
const APP_KEY = isDev ? "ABTEST_5efd644b-019b-426c-8ade-805e77d7aa52" : "ABTEST_f6519045-8bfd-4f0d-b690-8ab5b019bf8c";
const APP_NAME = isDev ? "gd_web_dev" : "gd_web";
index.init({
  app_key: APP_KEY,
  app_name: APP_NAME,
  device_id: getUserDeviceId(),
  user_id: "",
  is_login: "0"
});
export { MaterialDetailModal as M };
