import { a as t } from "./alasql-f60045ee.js";
var e = function() {
  if ("undefined" != typeof self)
    return self;
  if ("undefined" != typeof window)
    return window;
  if ("undefined" != typeof global)
    return global;
  throw new Error("unable to locate global object");
}();
const r = e.fetch, n = e.fetch.bind(e), s = e.Headers, o = e.Request, a = e.Response, i = Object.freeze(Object.defineProperty({ __proto__: null, Headers: s, Request: o, Response: a, default: n, fetch: r }, Symbol.toStringTag, { value: "Module" })), c = t(i);
class u extends Error {
  constructor(t2) {
    super(t2), this.__isStorageError = true, this.name = "StorageError";
  }
}
function l(t2) {
  return "object" == typeof t2 && null !== t2 && "__isStorageError" in t2;
}
class d extends u {
  constructor(t2, e2) {
    super(t2), this.name = "StorageApiError", this.status = e2;
  }
  toJSON() {
    return { name: this.name, message: this.message, status: this.status };
  }
}
class h extends u {
  constructor(t2, e2) {
    super(t2), this.name = "StorageUnknownError", this.originalError = e2;
  }
}
var f = globalThis && globalThis.__awaiter || function(t2, e2, r2, n2) {
  return new (r2 || (r2 = Promise))(function(s2, o2) {
    function a2(t3) {
      try {
        c2(n2.next(t3));
      } catch (t4) {
        o2(t4);
      }
    }
    function i2(t3) {
      try {
        c2(n2.throw(t3));
      } catch (t4) {
        o2(t4);
      }
    }
    function c2(t3) {
      var e3;
      t3.done ? s2(t3.value) : (e3 = t3.value, e3 instanceof r2 ? e3 : new r2(function(t4) {
        t4(e3);
      })).then(a2, i2);
    }
    c2((n2 = n2.apply(t2, e2 || [])).next());
  });
};
const p = (t2) => {
  let e2;
  return e2 = t2 || ("undefined" == typeof fetch ? (...t3) => Promise.resolve().then(() => i).then(({ default: e3 }) => e3(...t3)) : fetch), (...t3) => e2(...t3);
}, w = (t2) => {
  if (Array.isArray(t2))
    return t2.map((t3) => w(t3));
  if ("function" == typeof t2 || t2 !== Object(t2))
    return t2;
  const e2 = {};
  return Object.entries(t2).forEach(([t3, r2]) => {
    const n2 = t3.replace(/([-_][a-z])/gi, (t4) => t4.toUpperCase().replace(/[-_]/g, ""));
    e2[n2] = w(r2);
  }), e2;
};
var y = globalThis && globalThis.__awaiter || function(t2, e2, r2, n2) {
  return new (r2 || (r2 = Promise))(function(s2, o2) {
    function a2(t3) {
      try {
        c2(n2.next(t3));
      } catch (t4) {
        o2(t4);
      }
    }
    function i2(t3) {
      try {
        c2(n2.throw(t3));
      } catch (t4) {
        o2(t4);
      }
    }
    function c2(t3) {
      var e3;
      t3.done ? s2(t3.value) : (e3 = t3.value, e3 instanceof r2 ? e3 : new r2(function(t4) {
        t4(e3);
      })).then(a2, i2);
    }
    c2((n2 = n2.apply(t2, e2 || [])).next());
  });
};
const g = (t2) => t2.msg || t2.message || t2.error_description || t2.error || JSON.stringify(t2), v = (t2, e2, r2) => y(void 0, void 0, void 0, function* () {
  const n2 = yield f(void 0, void 0, void 0, function* () {
    return "undefined" == typeof Response ? (yield Promise.resolve().then(() => i)).Response : Response;
  });
  t2 instanceof n2 && !(null == r2 ? void 0 : r2.noResolveJson) ? t2.json().then((r3) => {
    e2(new d(g(r3), t2.status || 500));
  }).catch((t3) => {
    e2(new h(g(t3), t3));
  }) : e2(new h(g(t2), t2));
}), m = (t2, e2, r2, n2) => {
  const s2 = { method: t2, headers: (null == e2 ? void 0 : e2.headers) || {} };
  return "GET" === t2 ? s2 : (s2.headers = Object.assign({ "Content-Type": "application/json" }, null == e2 ? void 0 : e2.headers), n2 && (s2.body = JSON.stringify(n2)), Object.assign(Object.assign({}, s2), r2));
};
function _(t2, e2, r2, n2, s2, o2) {
  return y(this, void 0, void 0, function* () {
    return new Promise((a2, i2) => {
      t2(r2, m(e2, n2, s2, o2)).then((t3) => {
        if (!t3.ok)
          throw t3;
        return (null == n2 ? void 0 : n2.noResolveJson) ? t3 : t3.json();
      }).then((t3) => a2(t3)).catch((t3) => v(t3, i2, n2));
    });
  });
}
function b(t2, e2, r2, n2) {
  return y(this, void 0, void 0, function* () {
    return _(t2, "GET", e2, r2, n2);
  });
}
function x(t2, e2, r2, n2, s2) {
  return y(this, void 0, void 0, function* () {
    return _(t2, "POST", e2, n2, s2, r2);
  });
}
function j(t2, e2, r2, n2, s2) {
  return y(this, void 0, void 0, function* () {
    return _(t2, "PUT", e2, n2, s2, r2);
  });
}
function O(t2, e2, r2, n2) {
  return y(this, void 0, void 0, function* () {
    return _(t2, "HEAD", e2, Object.assign(Object.assign({}, r2), { noResolveJson: true }), n2);
  });
}
function E(t2, e2, r2, n2, s2) {
  return y(this, void 0, void 0, function* () {
    return _(t2, "DELETE", e2, n2, s2, r2);
  });
}
var A = globalThis && globalThis.__awaiter || function(t2, e2, r2, n2) {
  return new (r2 || (r2 = Promise))(function(s2, o2) {
    function a2(t3) {
      try {
        c2(n2.next(t3));
      } catch (t4) {
        o2(t4);
      }
    }
    function i2(t3) {
      try {
        c2(n2.throw(t3));
      } catch (t4) {
        o2(t4);
      }
    }
    function c2(t3) {
      var e3;
      t3.done ? s2(t3.value) : (e3 = t3.value, e3 instanceof r2 ? e3 : new r2(function(t4) {
        t4(e3);
      })).then(a2, i2);
    }
    c2((n2 = n2.apply(t2, e2 || [])).next());
  });
};
const k = (t2) => {
  let e2;
  return e2 = t2 || ("undefined" == typeof fetch ? n : fetch), (...t3) => e2(...t3);
}, S = (t2, e2, r2) => {
  const n2 = k(r2), o2 = "undefined" == typeof Headers ? s : Headers;
  return (r3, s2) => A(void 0, void 0, void 0, function* () {
    var a2;
    const i2 = null !== (a2 = yield e2()) && void 0 !== a2 ? a2 : t2;
    let c2 = new o2(null == s2 ? void 0 : s2.headers);
    return c2.has("apikey") || c2.set("apikey", t2), c2.has("Authorization") || c2.set("Authorization", `Bearer ${i2}`), n2(r3, Object.assign(Object.assign({}, s2), { headers: c2 }));
  });
}, T = "2.65.0", R = "http://localhost:9999", P = "supabase.auth.token", J = { "X-Client-Info": `gotrue-js/${T}` }, C = 10, $ = "X-Supabase-Api-Version", I = { "2024-01-01": { timestamp: Date.parse("2024-01-01T00:00:00.0Z"), name: "2024-01-01" } };
function N() {
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(t2) {
    const e2 = 16 * Math.random() | 0;
    return ("x" == t2 ? e2 : 3 & e2 | 8).toString(16);
  });
}
const U = () => "undefined" != typeof document, M = { tested: false, writable: false }, z = () => {
  if (!U())
    return false;
  try {
    if ("object" != typeof globalThis.localStorage)
      return false;
  } catch (t3) {
    return false;
  }
  if (M.tested)
    return M.writable;
  const t2 = `lswt-${Math.random()}${Math.random()}`;
  try {
    globalThis.localStorage.setItem(t2, t2), globalThis.localStorage.removeItem(t2), M.tested = true, M.writable = true;
  } catch (t3) {
    M.tested = true, M.writable = false;
  }
  return M.writable;
};
function D(t2) {
  const e2 = {}, r2 = new URL(t2);
  if (r2.hash && "#" === r2.hash[0])
    try {
      new URLSearchParams(r2.hash.substring(1)).forEach((t3, r3) => {
        e2[r3] = t3;
      });
    } catch (t3) {
    }
  return r2.searchParams.forEach((t3, r3) => {
    e2[r3] = t3;
  }), e2;
}
const H = (t2) => {
  let e2;
  return e2 = t2 || ("undefined" == typeof fetch ? (...t3) => Promise.resolve().then(() => i).then(({ default: e3 }) => e3(...t3)) : fetch), (...t3) => e2(...t3);
}, W = (t2) => "object" == typeof t2 && null !== t2 && "status" in t2 && "ok" in t2 && "json" in t2 && "function" == typeof t2.json, G = async (t2, e2, r2) => {
  await t2.setItem(e2, JSON.stringify(r2));
}, q = async (t2, e2) => {
  const r2 = await t2.getItem(e2);
  if (!r2)
    return null;
  try {
    return JSON.parse(r2);
  } catch (t3) {
    return r2;
  }
}, L = async (t2, e2) => {
  await t2.removeItem(e2);
};
class F {
  constructor() {
    this.promise = new F.promiseConstructor((t2, e2) => {
      this.resolve = t2, this.reject = e2;
    });
  }
}
function V(t2) {
  const e2 = t2.split(".");
  if (3 !== e2.length)
    throw new Error("JWT is not valid: not a JWT structure");
  if (!/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}=?$|[a-z0-9_-]{2}(==)?$)$/i.test(e2[1]))
    throw new Error("JWT is not valid: payload is not in base64url format");
  const r2 = e2[1];
  return JSON.parse(function(t3) {
    const e3 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
    let r3, n2, s2, o2, a2, i2, c2, u2 = "", l2 = 0;
    for (t3 = t3.replace("-", "+").replace("_", "/"); l2 < t3.length; )
      o2 = e3.indexOf(t3.charAt(l2++)), a2 = e3.indexOf(t3.charAt(l2++)), i2 = e3.indexOf(t3.charAt(l2++)), c2 = e3.indexOf(t3.charAt(l2++)), r3 = o2 << 2 | a2 >> 4, n2 = (15 & a2) << 4 | i2 >> 2, s2 = (3 & i2) << 6 | c2, u2 += String.fromCharCode(r3), 64 != i2 && 0 != n2 && (u2 += String.fromCharCode(n2)), 64 != c2 && 0 != s2 && (u2 += String.fromCharCode(s2));
    return u2;
  }(r2));
}
async function B(t2) {
  return await new Promise((e2) => {
    setTimeout(() => e2(null), t2);
  });
}
function X(t2, e2) {
  return new Promise((r2, n2) => {
    (async () => {
      for (let s2 = 0; s2 < 1 / 0; s2++)
        try {
          const n3 = await t2(s2);
          if (!e2(s2, null, n3))
            return void r2(n3);
        } catch (t3) {
          if (!e2(s2, t3))
            return void n2(t3);
        }
    })();
  });
}
function Z(t2) {
  return ("0" + t2.toString(16)).substr(-2);
}
async function K(t2) {
  if (!("undefined" != typeof crypto && void 0 !== crypto.subtle && "undefined" != typeof TextEncoder))
    return t2;
  const e2 = await async function(t3) {
    const e3 = new TextEncoder().encode(t3), r2 = await crypto.subtle.digest("SHA-256", e3), n2 = new Uint8Array(r2);
    return Array.from(n2).map((t4) => String.fromCharCode(t4)).join("");
  }(t2);
  return btoa(e2).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
}
async function Y(t2, e2, r2 = false) {
  const n2 = function() {
    const t3 = new Uint32Array(56);
    if ("undefined" == typeof crypto) {
      const t4 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~", e3 = t4.length;
      let r3 = "";
      for (let n3 = 0; n3 < 56; n3++)
        r3 += t4.charAt(Math.floor(Math.random() * e3));
      return r3;
    }
    return crypto.getRandomValues(t3), Array.from(t3, Z).join("");
  }();
  let s2 = n2;
  r2 && (s2 += "/PASSWORD_RECOVERY"), await G(t2, `${e2}-code-verifier`, s2);
  const o2 = await K(n2);
  return [o2, n2 === o2 ? "plain" : "s256"];
}
F.promiseConstructor = Promise;
const Q = /^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;
class tt extends Error {
  constructor(t2, e2, r2) {
    super(t2), this.__isAuthError = true, this.name = "AuthError", this.status = e2, this.code = r2;
  }
}
function et(t2) {
  return "object" == typeof t2 && null !== t2 && "__isAuthError" in t2;
}
class rt extends tt {
  constructor(t2, e2, r2) {
    super(t2, e2, r2), this.name = "AuthApiError", this.status = e2, this.code = r2;
  }
}
function nt(t2) {
  return et(t2) && "AuthApiError" === t2.name;
}
class st extends tt {
  constructor(t2, e2) {
    super(t2), this.name = "AuthUnknownError", this.originalError = e2;
  }
}
class ot extends tt {
  constructor(t2, e2, r2, n2) {
    super(t2, r2, n2), this.name = e2, this.status = r2;
  }
}
class at extends ot {
  constructor() {
    super("Auth session missing!", "AuthSessionMissingError", 400, void 0);
  }
}
function it(t2) {
  return et(t2) && "AuthSessionMissingError" === t2.name;
}
class ct extends ot {
  constructor() {
    super("Auth session or user missing", "AuthInvalidTokenResponseError", 500, void 0);
  }
}
class ut extends ot {
  constructor(t2) {
    super(t2, "AuthInvalidCredentialsError", 400, void 0);
  }
}
class lt extends ot {
  constructor(t2, e2 = null) {
    super(t2, "AuthImplicitGrantRedirectError", 500, void 0), this.details = null, this.details = e2;
  }
  toJSON() {
    return { name: this.name, message: this.message, status: this.status, details: this.details };
  }
}
class dt extends ot {
  constructor(t2, e2 = null) {
    super(t2, "AuthPKCEGrantCodeExchangeError", 500, void 0), this.details = null, this.details = e2;
  }
  toJSON() {
    return { name: this.name, message: this.message, status: this.status, details: this.details };
  }
}
class ht extends ot {
  constructor(t2, e2) {
    super(t2, "AuthRetryableFetchError", e2, void 0);
  }
}
function ft(t2) {
  return et(t2) && "AuthRetryableFetchError" === t2.name;
}
class pt extends ot {
  constructor(t2, e2, r2) {
    super(t2, "AuthWeakPasswordError", e2, "weak_password"), this.reasons = r2;
  }
}
function wt(t2) {
  return et(t2) && "AuthWeakPasswordError" === t2.name;
}
var yt = globalThis && globalThis.__rest || function(t2, e2) {
  var r2 = {};
  for (var n2 in t2)
    Object.prototype.hasOwnProperty.call(t2, n2) && e2.indexOf(n2) < 0 && (r2[n2] = t2[n2]);
  if (null != t2 && "function" == typeof Object.getOwnPropertySymbols) {
    var s2 = 0;
    for (n2 = Object.getOwnPropertySymbols(t2); s2 < n2.length; s2++)
      e2.indexOf(n2[s2]) < 0 && Object.prototype.propertyIsEnumerable.call(t2, n2[s2]) && (r2[n2[s2]] = t2[n2[s2]]);
  }
  return r2;
};
const gt = (t2) => t2.msg || t2.message || t2.error_description || t2.error || JSON.stringify(t2), vt = [502, 503, 504];
async function mt(t2) {
  var e2;
  if (!W(t2))
    throw new ht(gt(t2), 0);
  if (vt.includes(t2.status))
    throw new ht(gt(t2), t2.status);
  let r2, n2;
  try {
    r2 = await t2.json();
  } catch (t3) {
    throw new st(gt(t3), t3);
  }
  const s2 = function(t3) {
    const e3 = t3.headers.get($);
    if (!e3)
      return null;
    if (!e3.match(Q))
      return null;
    try {
      return /* @__PURE__ */ new Date(`${e3}T00:00:00.0Z`);
    } catch (t4) {
      return null;
    }
  }(t2);
  if (s2 && s2.getTime() >= I["2024-01-01"].timestamp && "object" == typeof r2 && r2 && "string" == typeof r2.code ? n2 = r2.code : "object" == typeof r2 && r2 && "string" == typeof r2.error_code && (n2 = r2.error_code), n2) {
    if ("weak_password" === n2)
      throw new pt(gt(r2), t2.status, (null === (e2 = r2.weak_password) || void 0 === e2 ? void 0 : e2.reasons) || []);
    if ("session_not_found" === n2)
      throw new at();
  } else if ("object" == typeof r2 && r2 && "object" == typeof r2.weak_password && r2.weak_password && Array.isArray(r2.weak_password.reasons) && r2.weak_password.reasons.length && r2.weak_password.reasons.reduce((t3, e3) => t3 && "string" == typeof e3, true))
    throw new pt(gt(r2), t2.status, r2.weak_password.reasons);
  throw new rt(gt(r2), t2.status || 500, n2);
}
const _t = (t2, e2, r2, n2) => {
  const s2 = { method: t2, headers: (null == e2 ? void 0 : e2.headers) || {} };
  return "GET" === t2 ? s2 : (s2.headers = Object.assign({ "Content-Type": "application/json;charset=UTF-8" }, null == e2 ? void 0 : e2.headers), s2.body = JSON.stringify(n2), Object.assign(Object.assign({}, s2), r2));
};
async function bt(t2, e2, r2, n2) {
  var s2;
  const o2 = Object.assign({}, null == n2 ? void 0 : n2.headers);
  o2[$] || (o2[$] = I["2024-01-01"].name), (null == n2 ? void 0 : n2.jwt) && (o2.Authorization = `Bearer ${n2.jwt}`);
  const a2 = null !== (s2 = null == n2 ? void 0 : n2.query) && void 0 !== s2 ? s2 : {};
  (null == n2 ? void 0 : n2.redirectTo) && (a2.redirect_to = n2.redirectTo);
  const i2 = Object.keys(a2).length ? "?" + new URLSearchParams(a2).toString() : "", c2 = await async function(t3, e3, r3, n3, s3, o3) {
    const a3 = _t(e3, n3, s3, o3);
    let i3;
    try {
      i3 = await t3(r3, Object.assign({}, a3));
    } catch (t4) {
      throw new ht(gt(t4), 0);
    }
    i3.ok || await mt(i3);
    if (null == n3 ? void 0 : n3.noResolveJson)
      return i3;
    try {
      return await i3.json();
    } catch (t4) {
      await mt(t4);
    }
  }(t2, e2, r2 + i2, { headers: o2, noResolveJson: null == n2 ? void 0 : n2.noResolveJson }, {}, null == n2 ? void 0 : n2.body);
  return (null == n2 ? void 0 : n2.xform) ? null == n2 ? void 0 : n2.xform(c2) : { data: Object.assign({}, c2), error: null };
}
function xt(t2) {
  var e2;
  let r2 = null;
  var n2;
  (function(t3) {
    return t3.access_token && t3.refresh_token && t3.expires_in;
  })(t2) && (r2 = Object.assign({}, t2), t2.expires_at || (r2.expires_at = (n2 = t2.expires_in, Math.round(Date.now() / 1e3) + n2)));
  return { data: { session: r2, user: null !== (e2 = t2.user) && void 0 !== e2 ? e2 : t2 }, error: null };
}
function jt(t2) {
  const e2 = xt(t2);
  return !e2.error && t2.weak_password && "object" == typeof t2.weak_password && Array.isArray(t2.weak_password.reasons) && t2.weak_password.reasons.length && t2.weak_password.message && "string" == typeof t2.weak_password.message && t2.weak_password.reasons.reduce((t3, e3) => t3 && "string" == typeof e3, true) && (e2.data.weak_password = t2.weak_password), e2;
}
function Ot(t2) {
  var e2;
  return { data: { user: null !== (e2 = t2.user) && void 0 !== e2 ? e2 : t2 }, error: null };
}
function Et(t2) {
  return { data: t2, error: null };
}
function At(t2) {
  const { action_link: e2, email_otp: r2, hashed_token: n2, redirect_to: s2, verification_type: o2 } = t2, a2 = yt(t2, ["action_link", "email_otp", "hashed_token", "redirect_to", "verification_type"]);
  return { data: { properties: { action_link: e2, email_otp: r2, hashed_token: n2, redirect_to: s2, verification_type: o2 }, user: Object.assign({}, a2) }, error: null };
}
function kt(t2) {
  return t2;
}
export {
  i as $,
  st as A,
  it as B,
  V as C,
  lt as D,
  dt as E,
  D as F,
  nt as G,
  N as H,
  X as I,
  C as J,
  ft as K,
  F as L,
  G as M,
  R as N,
  P as O,
  J as P,
  jt as Q,
  B as R,
  u as S,
  S as T,
  rt as U,
  tt as V,
  ht as W,
  pt as X,
  ot as Y,
  wt as Z,
  bt as _,
  p as a,
  w as b,
  h as c,
  E as d,
  j as e,
  H as f,
  b as g,
  O as h,
  l as i,
  et as j,
  kt as k,
  Ot as l,
  At as m,
  U as n,
  Y as o,
  x as p,
  ut as q,
  c as r,
  z as s,
  ct as t,
  q as u,
  T as v,
  L as w,
  xt as x,
  Et as y,
  at as z
};
