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