var e = "object" == typeof window && window.window === window ? window : "object" == typeof self && self.self === self ? self : "object" == typeof global && global.global === global ? global : globalThis;
function t(e2, t2, n2) {
  var o2 = new XMLHttpRequest();
  o2.open("GET", e2), o2.responseType = "blob", o2.onload = function() {
    i(o2.response, t2, n2);
  }, o2.onerror = function() {
  }, o2.send();
}
function n(e2) {
  var t2 = new XMLHttpRequest();
  t2.open("HEAD", e2, false);
  try {
    t2.send();
  } catch (e3) {
  }
  return t2.status >= 200 && t2.status <= 299;
}
function o(e2) {
  try {
    e2.dispatchEvent(new MouseEvent("click"));
  } catch (n2) {
    var t2 = document.createEvent("MouseEvents");
    t2.initMouseEvent("click", true, true, window, 0, 0, 0, 80, 20, false, false, false, false, 0, null), e2.dispatchEvent(t2);
  }
}
var a = e.navigator && /Macintosh/.test(navigator.userAgent) && /AppleWebKit/.test(navigator.userAgent) && !/Safari/.test(navigator.userAgent), i = e.saveAs || ("object" != typeof window || window !== e ? function() {
} : "download" in HTMLAnchorElement.prototype && !a ? function(a2, i2, r) {
  var s = e.URL || e.webkitURL, l = document.createElement("a");
  i2 = i2 || a2.name || "download", l.download = i2, l.rel = "noopener", "string" == typeof a2 ? (l.href = a2, l.origin !== location.origin ? n(l.href) ? t(a2, i2, r) : o(l, l.target = "_blank") : o(l)) : (l.href = s.createObjectURL(a2), setTimeout(function() {
    s.revokeObjectURL(l.href);
  }, 4e4), setTimeout(function() {
    o(l);
  }, 0));
} : "msSaveOrOpenBlob" in navigator ? function(e2, a2, i2) {
  if (a2 = a2 || e2.name || "download", "string" == typeof e2)
    if (n(e2))
      t(e2, a2, i2);
    else {
      var r = document.createElement("a");
      r.href = e2, r.target = "_blank", setTimeout(function() {
        o(r);
      });
    }
  else
    navigator.msSaveOrOpenBlob(function(e3, t2) {
      return void 0 === t2 ? t2 = { autoBom: false } : "object" != typeof t2 && (t2 = { autoBom: !t2 }), t2.autoBom && /^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e3.type) ? new Blob([String.fromCharCode(65279), e3], { type: e3.type }) : e3;
    }(e2, i2), a2);
} : function(n2, o2, i2, r) {
  if ((r = r || open("", "_blank")) && (r.document.title = r.document.body.innerText = "downloading..."), "string" == typeof n2)
    return t(n2, o2, i2);
  var s = "application/octet-stream" === n2.type, l = /constructor/i.test(e.HTMLElement) || e.safari, c = /CriOS\/[\d]+/.test(navigator.userAgent);
  if ((c || s && l || a) && "undefined" != typeof FileReader) {
    var u = new FileReader();
    u.onloadend = function() {
      var e2 = u.result;
      e2 = c ? e2 : e2.replace(/^data:[^;]*;/, "data:attachment/file;"), r ? r.location.href = e2 : location = e2, r = null;
    }, u.readAsDataURL(n2);
  } else {
    var f = e.URL || e.webkitURL, d = f.createObjectURL(n2);
    r ? r.location = d : location.href = d, r = null, setTimeout(function() {
      f.revokeObjectURL(d);
    }, 4e4);
  }
});
e.saveAs = i.saveAs = i;
export {
  i as s
};
