/*! js-cookie v3.0.5 | MIT */
function p(e) {
  for (var n = 1; n < arguments.length; n++) {
    var t = arguments[n];
    for (var i in t)
      e[i] = t[i];
  }
  return e;
}
var u = {
  read: function(e) {
    return e[0] === '"' && (e = e.slice(1, -1)), e.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
  },
  write: function(e) {
    return encodeURIComponent(e).replace(
      /%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,
      decodeURIComponent
    );
  }
};
function g(e, n) {
  function t(o, f, r) {
    if (!(typeof document > "u")) {
      r = p({}, n, r), typeof r.expires == "number" && (r.expires = new Date(Date.now() + r.expires * 864e5)), r.expires && (r.expires = r.expires.toUTCString()), o = encodeURIComponent(o).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
      var c = "";
      for (var s in r)
        r[s] && (c += "; " + s, r[s] !== !0 && (c += "=" + r[s].split(";")[0]));
      return document.cookie = o + "=" + e.write(f, o) + c;
    }
  }
  function i(o) {
    if (!(typeof document > "u" || arguments.length && !o)) {
      for (var f = document.cookie ? document.cookie.split("; ") : [], r = {}, c = 0; c < f.length; c++) {
        var s = f[c].split("="), d = s.slice(1).join("=");
        try {
          var a = decodeURIComponent(s[0]);
          if (r[a] = e.read(d, a), o === a)
            break;
        } catch {
        }
      }
      return o ? r[o] : r;
    }
  }
  return Object.create(
    {
      set: t,
      get: i,
      remove: function(o, f) {
        t(
          o,
          "",
          p({}, f, {
            expires: -1
          })
        );
      },
      withAttributes: function(o) {
        return g(this.converter, p({}, this.attributes, o));
      },
      withConverter: function(o) {
        return g(p({}, this.converter, o), this.attributes);
      }
    },
    {
      attributes: { value: Object.freeze(n) },
      converter: { value: Object.freeze(e) }
    }
  );
}
var l = g(u, { path: "/" });
const m = () => {
  const e = new URL(location.href).searchParams, n = e.get("token") || e.get("accessToken") || e.get("accesstoken") || "";
  n && (console.log("从url上取token:", n), JSON.stringify({ access_token: n }), l.set("accessToken", n));
}, v = () => {
  const e = JSON.parse(sessionStorage.getItem("projectInfo") || "{}"), n = new URL(location.href).searchParams, t = n.get("project") || n.get("projectId") || "";
  if (!t) return;
  const i = n.get("projectParent") || n.get("projectParentId") || (e == null ? void 0 : e.parentId) || "", o = n.get("projectName") || (e == null ? void 0 : e.name) || "";
  console.log("从url上取project:", t), sessionStorage.setItem("project", t), sessionStorage.setItem("projectInfo", JSON.stringify({ ...e, id: t, name: o, parentId: i }));
};
export {
  v as getProjectInfoFromQuery,
  m as getTokenFromQuery
};
