@qaecy/cue-sdk 0.0.8 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,11 @@
1
- import { getApps as $t, initializeApp as qt } from "firebase/app";
2
- import { ref as w, getDownloadURL as B, getMetadata as $, getBlob as xt, updateMetadata as Lt, uploadBytesResumable as et, uploadBytes as G, StringFormat as jt, uploadString as Nt, listAll as q, getStorage as x, connectStorageEmulator as kt } from "firebase/storage";
3
- import { Writer as Bt, DataFactory as O } from "n3";
4
- import { getFirestore as Ft, connectFirestoreEmulator as Ht, collection as st, getDocs as zt, query as Gt, where as Wt, limit as Kt, doc as it, getDoc as Qt, setDoc as Vt, serverTimestamp as Xt, increment as Yt } from "firebase/firestore";
5
- import { getAuth as Jt, connectAuthEmulator as Zt, onIdTokenChanged as te, getIdTokenResult as nt, signInWithEmailAndPassword as ee, GoogleAuthProvider as W, OAuthProvider as K, signInWithPopup as se, signInWithRedirect as ie, getRedirectResult as ne, signInWithCustomToken as ae, signOut as oe, onAuthStateChanged as re, fetchSignInMethodsForEmail as ce, linkWithPopup as le, unlink as ue, reauthenticateWithCredential as at, EmailAuthProvider as F, updatePassword as pe, linkWithCredential as he, verifyBeforeUpdateEmail as de, sendEmailVerification as fe } from "firebase/auth";
6
- import { v5 as me } from "uuid";
1
+ import { getApps as Lt, initializeApp as Nt } from "firebase/app";
2
+ import { ref as w, getDownloadURL as k, getMetadata as M, getBlob as Pt, updateMetadata as qt, uploadBytesResumable as et, uploadBytes as z, StringFormat as jt, uploadString as kt, listAll as $, getStorage as x, connectStorageEmulator as Bt } from "firebase/storage";
3
+ import { Writer as Ft, DataFactory as U } from "n3";
4
+ import { getFirestore as Ht, connectFirestoreEmulator as zt, collection as st, getDocs as Gt, query as Wt, where as Kt, limit as Qt, doc as it, getDoc as Vt, setDoc as Xt, serverTimestamp as Yt, increment as Jt } from "firebase/firestore";
5
+ import { getAuth as Zt, connectAuthEmulator as te, onIdTokenChanged as ee, getIdTokenResult as G, signInWithEmailAndPassword as se, GoogleAuthProvider as W, OAuthProvider as K, signInWithPopup as ie, signInWithRedirect as ne, getRedirectResult as ae, signInWithCustomToken as oe, signOut as re, onAuthStateChanged as ce, fetchSignInMethodsForEmail as le, linkWithPopup as ue, unlink as pe, reauthenticateWithCredential as nt, EmailAuthProvider as B, updatePassword as he, linkWithCredential as de, verifyBeforeUpdateEmail as fe, sendEmailVerification as me } from "firebase/auth";
6
+ import { v5 as ye } from "uuid";
7
7
  import "spark-md5";
8
- import { getFunctions as Pt, connectFunctionsEmulator as vt, httpsCallable as b } from "firebase/functions";
8
+ import { getFunctions as bt, connectFunctionsEmulator as vt, httpsCallable as N } from "firebase/functions";
9
9
  class V {
10
10
  queryEndpoint;
11
11
  updateEndpoint;
@@ -81,7 +81,7 @@ class V {
81
81
  };
82
82
  }
83
83
  }
84
- class H extends Error {
84
+ class F extends Error {
85
85
  constructor(t) {
86
86
  super(`QLever is locked (rebuild in progress): ${t}`), this.name = "QLeverLockedError";
87
87
  }
@@ -119,7 +119,7 @@ class P {
119
119
  try {
120
120
  return await t();
121
121
  } catch (a) {
122
- if (i = a, a instanceof H && n < e) {
122
+ if (i = a, a instanceof F && n < e) {
123
123
  const c = 0.5 + Math.random(), r = s * Math.pow(2, n) * c;
124
124
  await new Promise((u) => setTimeout(u, r));
125
125
  continue;
@@ -184,7 +184,7 @@ class P {
184
184
  });
185
185
  if (!e.ok) {
186
186
  const s = await e.text();
187
- throw e.status === 423 ? new H(s) : new Error(`SPARQL update failed (HTTP ${e.status}): ${s}`);
187
+ throw e.status === 423 ? new F(s) : new Error(`SPARQL update failed (HTTP ${e.status}): ${s}`);
188
188
  }
189
189
  return await e.json();
190
190
  });
@@ -204,7 +204,7 @@ class P {
204
204
  await this._postToDataEndpoint(t, `${this.dataEndpoint}/delete`);
205
205
  }
206
206
  async _postToDataEndpoint(t, e) {
207
- const s = await this._quadsToNQuads(t), i = await ye(Buffer.from(s, "utf-8"));
207
+ const s = await this._quadsToNQuads(t), i = await ge(Buffer.from(s, "utf-8"));
208
208
  await P._retryOnLocked(async () => {
209
209
  const n = await fetch(e, {
210
210
  method: "POST",
@@ -217,18 +217,18 @@ class P {
217
217
  });
218
218
  if (!n.ok) {
219
219
  const a = await n.text();
220
- throw n.status === 423 ? new H(a) : new Error(`QLever data POST failed (HTTP ${n.status}): ${a}`);
220
+ throw n.status === 423 ? new F(a) : new Error(`QLever data POST failed (HTTP ${n.status}): ${a}`);
221
221
  }
222
222
  });
223
223
  }
224
224
  _quadsToNQuads(t) {
225
225
  return new Promise((e, s) => {
226
- const i = new Bt({ format: "application/n-quads" });
226
+ const i = new Ft({ format: "application/n-quads" });
227
227
  i.addQuads(t), i.end((n, a) => n ? s(n) : e(a));
228
228
  });
229
229
  }
230
230
  }
231
- async function ye(l) {
231
+ async function ge(l) {
232
232
  const t = new CompressionStream("gzip"), e = t.writable.getWriter();
233
233
  e.write(new Uint8Array(l)), e.close();
234
234
  const s = [], i = t.readable.getReader();
@@ -243,7 +243,7 @@ async function ye(l) {
243
243
  a.set(r, c), c += r.byteLength;
244
244
  return a.buffer;
245
245
  }
246
- class ge {
246
+ class _e {
247
247
  constructor(t) {
248
248
  switch (this.options = t, this.options.graphType) {
249
249
  case "qlever":
@@ -298,7 +298,7 @@ class ge {
298
298
  return this.options.graphType === "qlever" ? this._db.deleteData(t) : Promise.reject(new Error("deleteData not supported for Fuseki — use update() with SPARQL DELETE DATA"));
299
299
  }
300
300
  }
301
- class _e {
301
+ class Ee {
302
302
  constructor(t) {
303
303
  this.options = t;
304
304
  }
@@ -327,7 +327,7 @@ class _e {
327
327
  async getDownloadURL(t, e) {
328
328
  const s = w(this._bucket(t), e);
329
329
  try {
330
- return await B(s);
330
+ return await k(s);
331
331
  } catch (i) {
332
332
  if (i?.code === "storage/object-not-found") return;
333
333
  throw i;
@@ -342,8 +342,8 @@ class _e {
342
342
  if (this._knownMissing.has(s)) return;
343
343
  const i = w(this._bucket(t), e);
344
344
  try {
345
- const n = await $(i);
346
- return `${await B(i)}&t=${encodeURIComponent(n.updated)}`;
345
+ const n = await M(i);
346
+ return `${await k(i)}&t=${encodeURIComponent(n.updated)}`;
347
347
  } catch (n) {
348
348
  if (n?.code === "storage/object-not-found" || n?.status === 404) {
349
349
  this._knownMissing.add(s), console.debug(`[CueBlobStorage] ${e} not found (404 OK — optional cache file)`);
@@ -356,7 +356,7 @@ class _e {
356
356
  async getFile(t, e) {
357
357
  const s = w(this._bucket(t), e);
358
358
  try {
359
- return await xt(s);
359
+ return await Pt(s);
360
360
  } catch (i) {
361
361
  if (i?.code === "storage/object-not-found") return;
362
362
  throw i;
@@ -382,8 +382,8 @@ class _e {
382
382
  ]);
383
383
  try {
384
384
  const [a, c] = await Promise.all([
385
- n(B(e)),
386
- n($(e))
385
+ n(k(e)),
386
+ n(M(e))
387
387
  ]), r = `${a}&t=${encodeURIComponent(c.updated)}`, u = await fetch(r, { signal: s.signal });
388
388
  if (!u.ok) throw new Error(`HTTP ${u.status}`);
389
389
  return u.text();
@@ -399,7 +399,7 @@ class _e {
399
399
  async getMetadata(t, e) {
400
400
  const s = w(this._bucket(t), e);
401
401
  try {
402
- const i = await $(s);
402
+ const i = await M(s);
403
403
  return {
404
404
  updated: i.updated,
405
405
  contentType: i.contentType,
@@ -414,7 +414,7 @@ class _e {
414
414
  /** Update custom metadata on an existing file. */
415
415
  async setMetadata(t, e, s) {
416
416
  const i = w(this._bucket(t), e);
417
- await Lt(i, { customMetadata: s });
417
+ await qt(i, { customMetadata: s });
418
418
  }
419
419
  // ─── Uploads ──────────────────────────────────────────────────────────────
420
420
  /**
@@ -443,18 +443,18 @@ class _e {
443
443
  */
444
444
  async uploadBytes(t, e, s, i) {
445
445
  const n = w(this._bucket(t), e);
446
- await G(n, s, i ? { customMetadata: i } : void 0);
446
+ await z(n, s, i ? { customMetadata: i } : void 0);
447
447
  }
448
448
  /** Upload a string or base64-encoded value. */
449
449
  async uploadString(t, e, s, i = jt.RAW, n) {
450
450
  const a = w(this._bucket(t), e);
451
- await Nt(a, s, i, n ? { customMetadata: n } : void 0);
451
+ await kt(a, s, i, n ? { customMetadata: n } : void 0);
452
452
  }
453
453
  // ─── Listing ──────────────────────────────────────────────────────────────
454
454
  /** List all item names directly under `prefix` in the given bucket. */
455
455
  async listFiles(t, e) {
456
456
  const s = w(this._bucket(t), e);
457
- return (await q(s)).items.map((n) => n.name);
457
+ return (await $(s)).items.map((n) => n.name);
458
458
  }
459
459
  /**
460
460
  * Recursively list all file full-paths under `prefix` in the given bucket.
@@ -462,7 +462,7 @@ class _e {
462
462
  */
463
463
  async listFilesRecursive(t, e) {
464
464
  const s = this._bucket(t), i = async (n) => {
465
- const a = await q(w(s, n));
465
+ const a = await $(w(s, n));
466
466
  let c = a.items.map((r) => r.fullPath);
467
467
  for (const r of a.prefixes)
468
468
  c = c.concat(await i(r.fullPath));
@@ -478,7 +478,7 @@ class _e {
478
478
  const { deleteObject: s } = await import("firebase/storage"), i = this._bucket(t);
479
479
  let n = 0;
480
480
  const a = async (c) => {
481
- const r = await q(w(i, c));
481
+ const r = await $(w(i, c));
482
482
  for (const u of r.items)
483
483
  await s(u), n++;
484
484
  for (const u of r.prefixes)
@@ -532,15 +532,15 @@ class _e {
532
532
  */
533
533
  async uploadProcessed(t, e, s) {
534
534
  const i = w(this.options.storageProcessed, t);
535
- return await $(i).catch(() => null) ? !1 : (await G(i, e, { customMetadata: s }), !0);
535
+ return await M(i).catch(() => null) ? !1 : (await z(i, e, { customMetadata: s }), !0);
536
536
  }
537
537
  /** List all blob names directly under `prefix` in the raw bucket. */
538
538
  async listRaw(t) {
539
539
  const e = w(this.options.storageRaw, t);
540
- return (await q(e)).items.map((i) => i.name);
540
+ return (await $(e)).items.map((i) => i.name);
541
541
  }
542
542
  }
543
- const ot = {
543
+ const at = {
544
544
  ä: "ae",
545
545
  ä: "ae",
546
546
  Ä: "AE",
@@ -574,18 +574,18 @@ const ot = {
574
574
  þ: "th",
575
575
  Þ: "Th"
576
576
  };
577
- function D(l, t = !1) {
577
+ function v(l, t = !1) {
578
578
  const e = "daca0510-72b5-48ba-9091-b918ca18136b";
579
- return l = Ee(l, t), me(l, e);
579
+ return l = we(l, t), ye(l, e);
580
580
  }
581
- function Ee(l, t = !1) {
581
+ function we(l, t = !1) {
582
582
  let e = l;
583
- for (const s in ot)
584
- e = e.replace(new RegExp(s, "g"), ot[s]);
583
+ for (const s in at)
584
+ e = e.replace(new RegExp(s, "g"), at[s]);
585
585
  return t && e !== l && console.info(`${l} -> ${e}`), e;
586
586
  }
587
- function we(l, t = "") {
588
- return D(`${t}${l}`);
587
+ function Ie(l, t = "") {
588
+ return v(`${t}${l}`);
589
589
  }
590
590
  class I {
591
591
  _value;
@@ -631,23 +631,23 @@ function X(l, t) {
631
631
  };
632
632
  }
633
633
  async function Y(l, t, e, s) {
634
- const i = D(l);
634
+ const i = v(l);
635
635
  let n;
636
636
  if (s) {
637
637
  const c = await s.get(i);
638
- c !== void 0 && (e(c, !0), n = D(JSON.stringify(c)));
638
+ c !== void 0 && (e(c, !0), n = v(JSON.stringify(c)));
639
639
  }
640
640
  const a = await t();
641
- return e(a, !1), s && D(JSON.stringify(a)) !== n && s.set(i, a).catch(
641
+ return e(a, !1), s && v(JSON.stringify(a)) !== n && s.set(i, a).catch(
642
642
  (r) => console.error("[staleWhileRevalidate] Cache write failed:", r)
643
643
  ), a;
644
644
  }
645
- const z = {
645
+ const H = {
646
646
  apiKey: "AIzaSyAiW42QBx9HS4Khu88pCW7MV66IhBAQul0",
647
647
  appId: "1:151132927589:web:d2ffdb377dfadfd23ab88c",
648
648
  measurementId: "G-YT4PK6HGZD"
649
- }, rt = "qaecy-mvp-406413", Ie = "734737865998", bt = "europe-west6", ct = "projects", Ce = "spaces_chats_eu_west6", Te = "spaces_raw_eu_west6", Ae = "spaces_processed_eu_west6", Re = "spaces_logs_eu_west6", Se = "cue_public_eu_west6", lt = "db_persistence_eu_west6", xe = "/data-views/admin/consumption", Pe = "/data-views/admin/profile/organizations", L = "/data-views/admin/profile/api-keys", ve = (l) => `/data-views/admin/organizations/${l}/members`, be = "/commands/admin/project", De = "/assistant/search", Dt = "/triplestore/query", Ue = "/triplestore/update", Ut = "/qlever-server/qlever/query", Oe = "/qlever-server/qlever/update", ut = "/commands/file-system-structure/batch", pt = "microsoft.com", ht = "superadmin", J = "https://cue.qaecy.com/r/";
650
- class dt {
649
+ }, ot = "qaecy-mvp-406413", Ce = "734737865998", Dt = "europe-west6", rt = "projects", Te = "spaces_chats_eu_west6", Ae = "spaces_raw_eu_west6", Se = "spaces_processed_eu_west6", Re = "spaces_logs_eu_west6", xe = "cue_public_eu_west6", ct = "db_persistence_eu_west6", Pe = "/data-views/admin/consumption", be = "/data-views/admin/profile/organizations", lt = "/data-views/admin/profile/api-keys", ut = "/commands/admin/profile/api-keys", ve = "/commands/admin/profile/terms", De = (l) => `/data-views/admin/organizations/${l}/members`, Ue = "/commands/admin/project", Oe = "/assistant/search", Ut = "/triplestore/query", Me = "/triplestore/update", Ot = "/qlever-server/qlever/query", $e = "/qlever-server/qlever/update", pt = "/commands/file-system-structure/batch", ht = "microsoft.com", dt = "superadmin", J = "https://cue.qaecy.com/r/";
650
+ class ft {
651
651
  _auth;
652
652
  _endpoints;
653
653
  _userSignal = new I(null);
@@ -664,19 +664,19 @@ class dt {
664
664
  /** All unique UIDs for the current user (Firebase UID + linked provider UIDs). */
665
665
  userIds;
666
666
  constructor(t, e = !1, s) {
667
- this._auth = Jt(t), this._endpoints = s, e && Zt(this._auth, s.authEmulatorUrl, {
667
+ this._auth = Zt(t), this._endpoints = s, e && te(this._auth, s.authEmulatorUrl, {
668
668
  disableWarnings: !0
669
669
  }), this.user = this._userSignal.asReadonly(), this.token = this._tokenSignal.asReadonly(), this.isSuperAdmin = this._isSuperAdminSignal.asReadonly(), this._userIdsSignal = X([this._userSignal], () => {
670
670
  const i = this._userSignal.get();
671
671
  if (!i) return [];
672
672
  const n = /* @__PURE__ */ new Set([i.uid]);
673
673
  return i.providerData.forEach((a) => n.add(a.uid)), Array.from(n);
674
- }), this.userIds = this._userIdsSignal, this._stopTokenListener = te(this._auth, async (i) => {
674
+ }), this.userIds = this._userIdsSignal, this._stopTokenListener = ee(this._auth, async (i) => {
675
675
  if (this._userSignal.set(i), i) {
676
676
  const n = await i.getIdToken();
677
677
  this._tokenSignal.set(n);
678
- const a = await nt(i);
679
- this._isSuperAdminSignal.set(a.claims.role === ht);
678
+ const a = await G(i);
679
+ this._isSuperAdminSignal.set(a.claims.role === dt);
680
680
  } else
681
681
  this._tokenSignal.set(null), this._isSuperAdminSignal.set(!1);
682
682
  });
@@ -689,14 +689,14 @@ class dt {
689
689
  if (t === "password") {
690
690
  if (!e)
691
691
  throw new Error("credentials are required for password sign-in");
692
- return (await ee(
692
+ return (await se(
693
693
  this._auth,
694
694
  e.email,
695
695
  e.password
696
696
  )).user;
697
697
  }
698
- const s = t === "google" ? new W() : new K(pt);
699
- return (await se(this._auth, s)).user;
698
+ const s = t === "google" ? new W() : new K(ht);
699
+ return (await ie(this._auth, s)).user;
700
700
  }
701
701
  /**
702
702
  * Initiate a redirect-based sign-in (mobile / iframe contexts where popups
@@ -704,8 +704,8 @@ class dt {
704
704
  * retrieve the result.
705
705
  */
706
706
  async signInWithRedirect(t) {
707
- const e = t === "google" ? new W() : new K(pt);
708
- await ie(this._auth, e);
707
+ const e = t === "google" ? new W() : new K(ht);
708
+ await ne(this._auth, e);
709
709
  }
710
710
  /**
711
711
  * Retrieve the result of a redirect sign-in. Returns the signed-in `User`
@@ -713,7 +713,7 @@ class dt {
713
713
  * Call this once on app startup before showing a sign-in UI.
714
714
  */
715
715
  async checkRedirectResult() {
716
- return (await ne(this._auth))?.user ?? null;
716
+ return (await ae(this._auth))?.user ?? null;
717
717
  }
718
718
  /**
719
719
  * One-shot async check — returns `true` if the current user has the
@@ -722,7 +722,7 @@ class dt {
722
722
  */
723
723
  async checkSuperAdmin() {
724
724
  const t = this._auth.currentUser;
725
- return t ? (await nt(t)).claims.role === ht : !1;
725
+ return t ? (await G(t)).claims.role === dt : !1;
726
726
  }
727
727
  /** Sign in with a Cue API key. `projectId` is optional — omit it when no project context is available (e.g. admin flows). */
728
728
  async signInWithApiKey(t, e) {
@@ -735,11 +735,33 @@ class dt {
735
735
  if (!i.ok)
736
736
  throw new Error(`Failed to fetch custom token: ${i.statusText}`);
737
737
  const { token: n } = await i.json();
738
- return (await ae(this._auth, n)).user;
738
+ return (await oe(this._auth, n)).user;
739
739
  }
740
740
  /** Sign out the current user */
741
741
  async signOut() {
742
- await oe(this._auth);
742
+ await re(this._auth);
743
+ }
744
+ /**
745
+ * Register a new user by name and email.
746
+ * The backend validates that the email domain belongs to an existing organisation,
747
+ * creates the Firebase Auth account, assigns org membership, and dispatches a
748
+ * "set your password" email to the address provided.
749
+ * Returns the new user's UID and the organisation name on success.
750
+ */
751
+ async signUp(t, e) {
752
+ const s = await fetch(
753
+ `${this._endpoints.gatewayUrl}/commands/admin/user/signup`,
754
+ {
755
+ method: "POST",
756
+ headers: { "Content-Type": "application/json" },
757
+ body: JSON.stringify({ name: t, email: e })
758
+ }
759
+ );
760
+ if (!s.ok) {
761
+ const i = await s.json().catch(() => ({}));
762
+ throw new Error(i?.message ?? `Sign-up failed (${s.status})`);
763
+ }
764
+ return s.json();
743
765
  }
744
766
  /** Currently signed-in user, or null if not authenticated */
745
767
  get currentUser() {
@@ -747,7 +769,7 @@ class dt {
747
769
  }
748
770
  /** Subscribe to authentication state changes. Returns an unsubscribe function. */
749
771
  onAuthStateChanged(t) {
750
- return re(this._auth, t);
772
+ return ce(this._auth, t);
751
773
  }
752
774
  /** Get the Firebase ID token for the current user, or null if not authenticated */
753
775
  async getToken(t = !1) {
@@ -779,7 +801,7 @@ class dt {
779
801
  return this._auth;
780
802
  }
781
803
  }
782
- class ft {
804
+ class mt {
783
805
  constructor(t, e, s, i) {
784
806
  this._auth = t, this._gatewayUrl = e, this.projects = s, this.sync = i;
785
807
  }
@@ -806,7 +828,7 @@ class ft {
806
828
  */
807
829
  async search(t) {
808
830
  const e = await this._auth.authenticatedFetch(
809
- `${this._gatewayUrl}${De}`,
831
+ `${this._gatewayUrl}${Oe}`,
810
832
  {
811
833
  method: "POST",
812
834
  headers: { "Content-Type": "application/json", "cue-project-id": t.projectId },
@@ -829,7 +851,7 @@ class ft {
829
851
  */
830
852
  async sparql(t, e, s) {
831
853
  console.log(s);
832
- const i = s === "qlever" ? Ut : Dt;
854
+ const i = s === "qlever" ? Ot : Ut;
833
855
  console.log(`Executing SPARQL query against ${i} for project ${e} with graph type ${s ?? "fuseki"}`);
834
856
  const n = new URLSearchParams();
835
857
  n.append("query", t);
@@ -854,7 +876,7 @@ class ft {
854
876
  }
855
877
  async getConsumption(t) {
856
878
  const e = await this._auth.authenticatedFetch(
857
- `${this._gatewayUrl}${xe}`,
879
+ `${this._gatewayUrl}${Pe}`,
858
880
  {
859
881
  headers: {
860
882
  "Content-Type": "application/json",
@@ -870,11 +892,11 @@ class ft {
870
892
  return e.json();
871
893
  }
872
894
  }
873
- class mt {
895
+ class yt {
874
896
  constructor(t, e, s = !1, i) {
875
- if (this._auth = t, this._db = Ft(e), this._functions = Pt(e, bt), this._gatewayUrl = i?.gatewayUrl ?? "", s) {
897
+ if (this._auth = t, this._db = Ht(e), this._functions = bt(e, Dt), this._gatewayUrl = i?.gatewayUrl ?? "", s) {
876
898
  const n = i?.firestoreEmulatorHost ?? "localhost", a = i?.firestoreEmulatorPort ?? 8080;
877
- Ht(this._db, n, a), vt(this._functions, "localhost", 5001);
899
+ zt(this._db, n, a), vt(this._functions, "localhost", 5001);
878
900
  }
879
901
  }
880
902
  _auth;
@@ -891,7 +913,7 @@ class mt {
891
913
  * Throws if a project with the given ID already exists.
892
914
  */
893
915
  async createProject(t) {
894
- const e = await this._auth.authenticatedFetch(`${this._gatewayUrl}${be}`, {
916
+ const e = await this._auth.authenticatedFetch(`${this._gatewayUrl}${Ue}`, {
895
917
  method: "POST",
896
918
  headers: { "Content-Type": "application/json" },
897
919
  body: JSON.stringify(t)
@@ -907,12 +929,12 @@ class mt {
907
929
  * Access is gated by Firestore rules which check membership.
908
930
  */
909
931
  async listProjects() {
910
- const t = this._requireUser(), e = st(this._db, ct);
911
- return (await zt(Gt(e, Wt("members", "array-contains", t), Kt(100)))).docs.map((i) => i.data());
932
+ const t = this._requireUser(), e = st(this._db, rt);
933
+ return (await Gt(Wt(e, Kt("members", "array-contains", t), Qt(100)))).docs.map((i) => i.data());
912
934
  }
913
935
  /** Fetch a single project by ID. Returns null if not found. */
914
936
  async getProject(t) {
915
- const e = it(st(this._db, ct), t), s = await Qt(e);
937
+ const e = it(st(this._db, rt), t), s = await Vt(e);
916
938
  return s.exists() ? s.data() : null;
917
939
  }
918
940
  /**
@@ -922,9 +944,9 @@ class mt {
922
944
  async incrementUnitsConsumed(t, e, s) {
923
945
  if (e <= 0) return;
924
946
  const i = it(this._db, "clientSync", t);
925
- await Vt(i, {
926
- unitsConsumed: Yt(e),
927
- lastUpdated: Xt(),
947
+ await Xt(i, {
948
+ unitsConsumed: Jt(e),
949
+ lastUpdated: Yt(),
928
950
  lastUserId: s
929
951
  }, { merge: !0 });
930
952
  }
@@ -932,20 +954,20 @@ class mt {
932
954
  * Invite a user to a project by email. Returns the invited user's uid and display name.
933
955
  */
934
956
  async inviteUserToProject(t, e, s) {
935
- return (await b(this._functions, "inviteUserToProject")({ email: t, spaceId: e, role: s })).data;
957
+ return (await N(this._functions, "inviteUserToProject")({ email: t, spaceId: e, role: s })).data;
936
958
  }
937
959
  /** Change an existing member's role on a project. */
938
960
  async changeUserRoleOnProject(t, e, s) {
939
- await b(this._functions, "changeUserRoleOnProject")({ uid: t, spaceId: e, role: s });
961
+ await N(this._functions, "changeUserRoleOnProject")({ uid: t, spaceId: e, role: s });
940
962
  }
941
963
  /** Remove a member from a project. */
942
964
  async removeUserFromProject(t, e) {
943
- await b(this._functions, "removeUserFromProject")({ uid: t, spaceId: e });
965
+ await N(this._functions, "removeUserFromProject")({ uid: t, spaceId: e });
944
966
  }
945
967
  }
946
- class yt {
968
+ class gt {
947
969
  constructor(t, e, s, i) {
948
- this._auth = t, this._gatewayUrl = i, this._functions = Pt(e, bt), s && vt(this._functions, "localhost", 5001);
970
+ this._auth = t, this._gatewayUrl = i, this._functions = bt(e, Dt), s && vt(this._functions, "localhost", 5001);
949
971
  }
950
972
  _auth;
951
973
  _gatewayUrl;
@@ -962,13 +984,13 @@ class yt {
962
984
  }
963
985
  /** Whether the current user has an active API key. */
964
986
  async hasAPIKey() {
965
- return await this._fetch(L) !== null;
987
+ return await this._fetch(lt) !== null;
966
988
  }
967
989
  /** Returns the sign-in methods registered for the current user's email. */
968
990
  async getSignInMethods() {
969
991
  const t = this._auth.currentUser;
970
992
  if (!t?.email) throw new Error("User has no e-mail");
971
- return ce(this._auth.firebaseAuth, t.email);
993
+ return le(this._auth.firebaseAuth, t.email);
972
994
  }
973
995
  /** Builds a human-readable label from a Firebase UserInfo provider entry. */
974
996
  buildProviderLabel(t) {
@@ -981,42 +1003,42 @@ class yt {
981
1003
  }
982
1004
  /** Links a Google or Microsoft provider to the current account via popup. Returns the new provider label. */
983
1005
  async linkProvider(t) {
984
- const e = this._requireUser(), s = t === "google.com" ? new W() : new K(t), n = (await le(e, s)).user.providerData.find(
1006
+ const e = this._requireUser(), s = t === "google.com" ? new W() : new K(t), n = (await ue(e, s)).user.providerData.find(
985
1007
  (a) => a.providerId === t
986
1008
  );
987
1009
  return n ? this.buildProviderLabel(n) : "-";
988
1010
  }
989
1011
  /** Unlinks a provider from the current account. */
990
1012
  async unlinkProvider(t) {
991
- await ue(this._requireUser(), t);
1013
+ await pe(this._requireUser(), t);
992
1014
  }
993
1015
  /** Changes the password. Reauthenticates first. */
994
1016
  async updatePassword(t, e) {
995
1017
  const s = this._requireUser();
996
1018
  if (!s.email) throw new Error("User has no e-mail");
997
- await at(
1019
+ await nt(
998
1020
  s,
999
- F.credential(s.email, t)
1000
- ), await pe(s, e);
1021
+ B.credential(s.email, t)
1022
+ ), await he(s, e);
1001
1023
  }
1002
1024
  /** Adds (sets) a password for an account that currently only uses SSO. */
1003
1025
  async addPassword(t) {
1004
1026
  const e = this._requireUser();
1005
1027
  if (!e.email) throw new Error("User has no e-mail");
1006
- await he(e, F.credential(e.email, t));
1028
+ await de(e, B.credential(e.email, t));
1007
1029
  }
1008
1030
  /** Requests an e-mail change. Sends a verification e-mail to the new address. */
1009
1031
  async updateEmail(t, e) {
1010
1032
  const s = this._requireUser();
1011
1033
  if (!s.email) throw new Error("User e-mail not available");
1012
- await at(
1034
+ await nt(
1013
1035
  s,
1014
- F.credential(s.email, e)
1015
- ), await de(s, t), await fe(s);
1036
+ B.credential(s.email, e)
1037
+ ), await fe(s, t), await me(s);
1016
1038
  }
1017
1039
  /** Creates a new API key for the current user. */
1018
1040
  async createAPIKey(t) {
1019
- return this._fetch(L, {
1041
+ return this._fetch(ut, {
1020
1042
  method: "POST",
1021
1043
  headers: { "Content-Type": "application/json" },
1022
1044
  body: JSON.stringify({ expiration: t })
@@ -1025,7 +1047,7 @@ class yt {
1025
1047
  /** Revokes the current user's API key. */
1026
1048
  async revokeAPIKey() {
1027
1049
  const t = await this._auth.authenticatedFetch(
1028
- this._url(L),
1050
+ this._url(ut),
1029
1051
  { method: "DELETE" }
1030
1052
  );
1031
1053
  if (!t.ok)
@@ -1033,17 +1055,17 @@ class yt {
1033
1055
  }
1034
1056
  /** Fetches the current user's existing API key. */
1035
1057
  async requestAPIKey() {
1036
- const t = await this._fetch(L);
1058
+ const t = await this._fetch(lt);
1037
1059
  if (!t) throw new Error("No API key found");
1038
1060
  return t;
1039
1061
  }
1040
1062
  /** Returns organizations the current user is a member of. */
1041
1063
  async listOrganizations() {
1042
- return this._fetch(Pe);
1064
+ return this._fetch(be);
1043
1065
  }
1044
1066
  /** Returns all members of the given organisation. Caller must be an org admin or superadmin. */
1045
1067
  async getOrgMembers(t) {
1046
- return this._fetch(ve(t));
1068
+ return this._fetch(De(t));
1047
1069
  }
1048
1070
  _requireUser() {
1049
1071
  const t = this._auth.currentUser;
@@ -1055,14 +1077,28 @@ class yt {
1055
1077
  * Uses the `getUserInfo` Firebase callable function.
1056
1078
  */
1057
1079
  async getUserInfo(t) {
1058
- return (await b(this._functions, "getUserInfo")({ uids: t })).data;
1080
+ return (await N(this._functions, "getUserInfo")({ uids: t })).data;
1081
+ }
1082
+ /** Record that the current user has accepted the terms of service. Sets a `terms` custom claim on the token. */
1083
+ async acceptTerms(t) {
1084
+ await this._fetch(ve, {
1085
+ method: "POST",
1086
+ headers: { "Content-Type": "application/json" },
1087
+ body: JSON.stringify({ version: t })
1088
+ });
1059
1089
  }
1060
- /** Record that the current user has accepted the terms of service. */
1061
- async acceptTerms() {
1062
- await b(this._functions, "acceptTerms")({});
1090
+ /**
1091
+ * Returns the terms version the current user has accepted (e.g. `"v1"`),
1092
+ * or `null` if they have not accepted any version yet.
1093
+ * Reads from the cached ID token — call after `acceptTerms()` with a
1094
+ * force-refreshed token to see the updated value.
1095
+ */
1096
+ async latestTermsAccepted() {
1097
+ const t = this._auth.currentUser;
1098
+ return t ? (await G(t)).claims.terms ?? null : null;
1063
1099
  }
1064
1100
  }
1065
- const gt = ["superadmin", "admin", "syncer", "member"], _t = {
1101
+ const _t = ["superadmin", "admin", "syncer", "member"], Et = {
1066
1102
  createEntities: "admin",
1067
1103
  createProvider: "superadmin",
1068
1104
  changeContentCategories: "syncer",
@@ -1077,7 +1113,7 @@ const gt = ["superadmin", "admin", "syncer", "member"], _t = {
1077
1113
  uploadDocuments: "syncer",
1078
1114
  viewEntities: "member"
1079
1115
  };
1080
- function Me() {
1116
+ function Le() {
1081
1117
  return {
1082
1118
  changeContentCategories: !1,
1083
1119
  createEntities: !1,
@@ -1094,7 +1130,7 @@ function Me() {
1094
1130
  viewEntities: !1
1095
1131
  };
1096
1132
  }
1097
- class Et {
1133
+ class wt {
1098
1134
  constructor(t) {
1099
1135
  this._isSuperAdmin = t, this._projectRoles = new I([]), this.privileges = X(
1100
1136
  [this._projectRoles, t],
@@ -1123,17 +1159,17 @@ class Et {
1123
1159
  _expand(t) {
1124
1160
  if (this._isSuperAdmin.get())
1125
1161
  return ["superadmin", "admin", "syncer", "member"];
1126
- const e = gt.findIndex((s) => t.includes(s));
1127
- return e === -1 ? [] : Array.from(gt.slice(e));
1162
+ const e = _t.findIndex((s) => t.includes(s));
1163
+ return e === -1 ? [] : Array.from(_t.slice(e));
1128
1164
  }
1129
1165
  _compute() {
1130
- const t = this._projectRoles.get(), e = Me();
1131
- for (const s of Object.keys(_t))
1132
- e[s] = t.includes(_t[s]);
1166
+ const t = this._projectRoles.get(), e = Le();
1167
+ for (const s of Object.keys(Et))
1168
+ e[s] = t.includes(Et[s]);
1133
1169
  return e;
1134
1170
  }
1135
1171
  }
1136
- class wt {
1172
+ class It {
1137
1173
  constructor(t) {
1138
1174
  this._storage = t;
1139
1175
  }
@@ -1166,7 +1202,7 @@ class wt {
1166
1202
  // ── Internal helpers ───────────────────────────────────────────────────────
1167
1203
  async _get(t, e) {
1168
1204
  try {
1169
- const i = await (await xt(w(this._storage, `${t}/${e}.json.gz`))).arrayBuffer(), n = new DecompressionStream("gzip"), a = n.writable.getWriter(), c = n.readable.getReader();
1205
+ const i = await (await Pt(w(this._storage, `${t}/${e}.json.gz`))).arrayBuffer(), n = new DecompressionStream("gzip"), a = n.writable.getWriter(), c = n.readable.getReader();
1170
1206
  a.write(new Uint8Array(i)), a.close();
1171
1207
  const r = [];
1172
1208
  let u = await c.read();
@@ -1178,7 +1214,7 @@ class wt {
1178
1214
  m.set(g, h), h += g.length;
1179
1215
  return JSON.parse(new TextDecoder().decode(m));
1180
1216
  } catch (s) {
1181
- if ($e(s)) return;
1217
+ if (Ne(s)) return;
1182
1218
  throw s;
1183
1219
  }
1184
1220
  }
@@ -1193,17 +1229,17 @@ class wt {
1193
1229
  let h = 0;
1194
1230
  for (const g of r)
1195
1231
  m.set(g, h), h += g.length;
1196
- await G(
1232
+ await z(
1197
1233
  w(this._storage, `${t}/${e}.json.gz`),
1198
1234
  m,
1199
1235
  { contentType: "application/gzip" }
1200
1236
  );
1201
1237
  }
1202
1238
  }
1203
- function $e(l) {
1239
+ function Ne(l) {
1204
1240
  return typeof l == "object" && l !== null && "code" in l && l.code === "storage/object-not-found";
1205
1241
  }
1206
- const R = {
1242
+ const S = {
1207
1243
  qcy: "https://dev.qaecy.com/ont#"
1208
1244
  }, Q = {
1209
1245
  rdfs: "http://www.w3.org/2000/01/rdf-schema#",
@@ -1284,7 +1320,7 @@ class qe {
1284
1320
  return this._runCategoriesQuery(this._buildCategoriesQuery(t, e));
1285
1321
  }
1286
1322
  _buildCategoriesQuery(t, e) {
1287
- return `PREFIX qcy: <${R.qcy}>
1323
+ return `PREFIX qcy: <${S.qcy}>
1288
1324
  PREFIX skos: <${Q.skos}>
1289
1325
  SELECT ?iri ?parent (SAMPLE(?l) AS ?label)
1290
1326
  WHERE {
@@ -1310,7 +1346,7 @@ GROUP BY ?iri ?parent`;
1310
1346
  return this._runRelationshipsQuery(this._buildRelationshipsQuery(t));
1311
1347
  }
1312
1348
  _buildRelationshipsQuery(t) {
1313
- return `PREFIX qcy: <${R.qcy}>
1349
+ return `PREFIX qcy: <${S.qcy}>
1314
1350
  PREFIX rdfs: <${Q.rdfs}>
1315
1351
  SELECT ?iri ?parent (SAMPLE(?l) AS ?label)
1316
1352
  WHERE {
@@ -1334,8 +1370,8 @@ GROUP BY ?iri ?parent`;
1334
1370
  });
1335
1371
  }
1336
1372
  }
1337
- const Le = "https://qlever.dev/api/osm-planet";
1338
- class je {
1373
+ const je = "https://qlever.dev/api/osm-planet";
1374
+ class ke {
1339
1375
  constructor(t, e, s = J, i, n) {
1340
1376
  this._api = t, this._projectId = e, this._queryCache = i, this._graphType = n, this.baseURL = `${s}${e}/`, this.entityInfoMap = this._entityInfoMapComputed, this.entityGraph = this._entityGraph.asReadonly(), this._entityOSMMap.subscribe(() => this._checkPendingOSMFetches()), this._fetchEntityGraph().catch(
1341
1377
  (a) => console.error("[CueProjectEntities] Entity graph fetch failed:", a)
@@ -1397,7 +1433,7 @@ class je {
1397
1433
  requestEntityData(t, e = !1) {
1398
1434
  const s = t.filter((a) => this._entityDetails.get()[a] === void 0);
1399
1435
  if (s.length === 0) return;
1400
- const i = s.map((a) => `r:${a}`).join(" "), n = `PREFIX qcy: <${R.qcy}>
1436
+ const i = s.map((a) => `r:${a}`).join(" "), n = `PREFIX qcy: <${S.qcy}>
1401
1437
  PREFIX r: <${this.baseURL}>
1402
1438
  SELECT ?id (SAMPLE(?val) AS ?value) (GROUP_CONCAT(DISTINCT STR(?cat); SEPARATOR=";") AS ?categories) ?mentionCount
1403
1439
  WHERE {
@@ -1437,7 +1473,7 @@ GROUP BY ?id ?mentionCount`;
1437
1473
  const s = { ...this._entityOSMMap.get() };
1438
1474
  for (const r of e) s[r] = { direct: [], indirect: [] };
1439
1475
  this._entityOSMMap.set(s);
1440
- const i = e.map((r) => `r:${r}`).join(" "), n = `PREFIX qcy: <${R.qcy}>
1476
+ const i = e.map((r) => `r:${r}`).join(" "), n = `PREFIX qcy: <${S.qcy}>
1441
1477
  PREFIX r: <${this.baseURL}>
1442
1478
  SELECT ?id ?osm ?direct ?rels ?entityUUID
1443
1479
  WHERE {
@@ -1501,7 +1537,7 @@ WHERE {
1501
1537
  async fetchEntityDocuments(t) {
1502
1538
  const e = t.replace(/^.*\/([^/]*)$/, "$1");
1503
1539
  this._entityDocuments.set({ ...this._entityDocuments.get(), [e]: [] }), this._entityDetails.get()[e] === void 0 && this.requestEntityData([e]);
1504
- const s = `PREFIX qcy: <${R.qcy}>
1540
+ const s = `PREFIX qcy: <${S.qcy}>
1505
1541
  SELECT DISTINCT ?id
1506
1542
  WHERE {
1507
1543
  BIND(<${t}> AS ?iri)
@@ -1534,7 +1570,7 @@ WHERE {
1534
1570
  if (T)
1535
1571
  for (const A of C) {
1536
1572
  const E = `${A}:${d}`, _ = f.get(E) ?? { geometries: [], entityUUID: d };
1537
- _.geometries.some((S) => S.osmIRI === y) || (_.geometries.push({ osmIRI: y, wkt: T }), f.set(E, _));
1573
+ _.geometries.some((R) => R.osmIRI === y) || (_.geometries.push({ osmIRI: y, wkt: T }), f.set(E, _));
1538
1574
  }
1539
1575
  }
1540
1576
  f.size > 0 && (h = Array.from(f.entries()).map(
@@ -1558,7 +1594,7 @@ WHERE {
1558
1594
  return c;
1559
1595
  }
1560
1596
  async _fetchOutgoingRelationships(t) {
1561
- const e = `PREFIX qcy: <${R.qcy}>
1597
+ const e = `PREFIX qcy: <${S.qcy}>
1562
1598
  SELECT ?rel ?related (SAMPLE(?val) AS ?nodeValue) (GROUP_CONCAT(STR(?cat); SEPARATOR=";") AS ?categories)
1563
1599
  WHERE {
1564
1600
  BIND(<${t}> AS ?s)
@@ -1586,7 +1622,7 @@ GROUP BY ?rel ?related`, s = await this._api.sparql(e, this._projectId, this._gr
1586
1622
  }), this._entityDetails.set(n), i;
1587
1623
  }
1588
1624
  async _fetchIncomingRelationships(t) {
1589
- const e = `PREFIX qcy: <${R.qcy}>
1625
+ const e = `PREFIX qcy: <${S.qcy}>
1590
1626
  SELECT ?rel ?relating (SAMPLE(?val) AS ?nodeValue) (GROUP_CONCAT(STR(?cat); SEPARATOR=";") AS ?categories)
1591
1627
  WHERE {
1592
1628
  BIND(<${t}> AS ?s)
@@ -1614,7 +1650,7 @@ GROUP BY ?rel ?relating`, s = await this._api.sparql(e, this._projectId, this._g
1614
1650
  }), this._entityDetails.set(n), i;
1615
1651
  }
1616
1652
  async _fetchEntityGraph() {
1617
- const t = `PREFIX qcy: <${R.qcy}>
1653
+ const t = `PREFIX qcy: <${S.qcy}>
1618
1654
  SELECT ?e1Cat ?e2Cat (COUNT(?e1) AS ?e1Count) (COUNT(?e2) AS ?e2Count)
1619
1655
  WHERE {
1620
1656
  ?e1 a qcy:CanonicalEntity ;
@@ -1659,7 +1695,7 @@ GROUP BY ?e1Cat ?e2Cat`;
1659
1695
  const s = e.map((c) => `<${c}>`).join(" "), i = `PREFIX geo: <${Q.geo}>
1660
1696
  SELECT * WHERE {
1661
1697
  VALUES ?s { ${s} }
1662
- SERVICE <${Le}> {
1698
+ SERVICE <${je}> {
1663
1699
  ?s geo:hasGeometry/geo:asWKT ?wkt
1664
1700
  }
1665
1701
  }`, n = await this._api.sparql(i, this._projectId, this._graphType), a = { ...this._osmWKTMap.get() };
@@ -1668,7 +1704,7 @@ SELECT * WHERE {
1668
1704
  }), this._osmWKTMap.set(a);
1669
1705
  }
1670
1706
  }
1671
- class Ne {
1707
+ class Be {
1672
1708
  constructor(t, e, s, i = J, n, a) {
1673
1709
  this._api = t, this._projectId = e, this._queryCache = n, this._graphType = a, this.baseURL = `${i}${e}/`, this._language = s, this.documentInfoMap = this._documentInfoMap.asReadonly(), this.projectDocumentsData = this._projectDocumentsData.asReadonly();
1674
1710
  }
@@ -1744,7 +1780,7 @@ class Ne {
1744
1780
  requestDocumentData(t) {
1745
1781
  const e = t.filter((a) => this._documentInfoMap.get()[a] === void 0);
1746
1782
  if (e.length === 0) return;
1747
- const s = e.map((a) => `r:${a}`).join(" "), i = this._language, n = `PREFIX qcy: <${R.qcy}>
1783
+ const s = e.map((a) => `r:${a}`).join(" "), i = this._language, n = `PREFIX qcy: <${S.qcy}>
1748
1784
  PREFIX r: <${this.baseURL}>
1749
1785
  SELECT ?id ?contentIRI ?suffix ?size ?subject ?summary
1750
1786
  (SAMPLE(?fp) AS ?path)
@@ -1798,7 +1834,7 @@ GROUP BY ?id ?contentIRI ?suffix ?size ?subject ?summary`;
1798
1834
  return this._runDocumentsBySuffixQuery(this._buildDocumentsBySuffixQuery());
1799
1835
  }
1800
1836
  _buildDocumentsBySuffixQuery() {
1801
- return `PREFIX qcy: <${R.qcy}>
1837
+ return `PREFIX qcy: <${S.qcy}>
1802
1838
  SELECT ?ext (SUM(?size) AS ?totalSize) (COUNT(*) AS ?docCount)
1803
1839
  WHERE {
1804
1840
  {
@@ -1827,7 +1863,7 @@ ORDER BY DESC(?docCount)`;
1827
1863
  return this._runDocumentsByContentCategoryQuery(this._buildDocumentsByContentCategoryQuery());
1828
1864
  }
1829
1865
  _buildDocumentsByContentCategoryQuery() {
1830
- return `PREFIX qcy: <${R.qcy}>
1866
+ return `PREFIX qcy: <${S.qcy}>
1831
1867
  SELECT ?cat (SUM(?size) AS ?totalSize) (COUNT(*) AS ?docCount)
1832
1868
  WHERE {
1833
1869
  {
@@ -1856,7 +1892,7 @@ ORDER BY DESC(?docCount)`;
1856
1892
  return this._runDuplicateCountQuery(this._buildDuplicateCountQuery());
1857
1893
  }
1858
1894
  _buildDuplicateCountQuery() {
1859
- return `PREFIX qcy: <${R.qcy}>
1895
+ return `PREFIX qcy: <${S.qcy}>
1860
1896
  SELECT (COUNT(*) AS ?count)
1861
1897
  WHERE {
1862
1898
  SELECT ?fc
@@ -1874,9 +1910,9 @@ WHERE {
1874
1910
  return s?.count ? parseInt(s.count.value, 10) : 0;
1875
1911
  }
1876
1912
  }
1877
- class ke {
1913
+ class Fe {
1878
1914
  constructor(t, e, { language: s, queryCache: i, rdfBase: n = J, graphType: a }) {
1879
- this._api = t, this._projectId = e, this.schema = new qe(t, e, s, i, a), this.entities = new je(t, e, n, i, a), this.documents = new Ne(t, e, s, n, i, a), this.availableContentCategories = this.schema.availableContentCategories, this.availableEntityCategories = this.schema.availableEntityCategories, this.availableEntityRelationships = this.schema.availableEntityRelationships, this.entityInfoMap = this.entities.entityInfoMap, this.entityGraph = this.entities.entityGraph, this.documentInfoMap = this.documents.documentInfoMap, this.projectDocumentsData = this.documents.projectDocumentsData, this.searchResults = this._searchResults.asReadonly(), this.documents.fetchOverview().catch((c) => console.error("[CueProjectView] fetchOverview failed:", c));
1915
+ this._api = t, this._projectId = e, this.schema = new qe(t, e, s, i, a), this.entities = new ke(t, e, n, i, a), this.documents = new Be(t, e, s, n, i, a), this.availableContentCategories = this.schema.availableContentCategories, this.availableEntityCategories = this.schema.availableEntityCategories, this.availableEntityRelationships = this.schema.availableEntityRelationships, this.entityInfoMap = this.entities.entityInfoMap, this.entityGraph = this.entities.entityGraph, this.documentInfoMap = this.documents.documentInfoMap, this.projectDocumentsData = this.documents.projectDocumentsData, this.searchResults = this._searchResults.asReadonly(), this.documents.fetchOverview().catch((c) => console.error("[CueProjectView] fetchOverview failed:", c));
1880
1916
  }
1881
1917
  _api;
1882
1918
  _projectId;
@@ -1989,7 +2025,7 @@ class ke {
1989
2025
  this._destroyed = !0, this._searchResults.set(void 0);
1990
2026
  }
1991
2027
  }
1992
- function It(l, t) {
2028
+ function Ct(l, t) {
1993
2029
  return new Promise((e) => {
1994
2030
  const s = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
1995
2031
  for (const d of l)
@@ -2025,7 +2061,7 @@ function It(l, t) {
2025
2061
  });
2026
2062
  }
2027
2063
  var o = /* @__PURE__ */ ((l) => (l.AUTOMATION = "automation", l.ARCHIVE = "archive", l.AUDIO = "audio", l.BACKUP = "backup", l.BINARY = "binary", l.BIM = "bim", l.CAD = "cad", l.DATA = "data", l.EMAIL = "email", l.FONT = "font", l.GEOSPATIAL = "geospatial", l.IMAGE = "image", l.INSTALLER = "installer", l.MARKUP = "markup", l.MULTIMEDIA = "multimedia", l.PLANNING = "planning", l.PRESENTATION = "presentation", l.SCRIPT = "script", l.SPREADSHEET = "spreadsheet", l.TEXT = "text", l.THREE_D = "3d", l.UNKNOWN = "unknown", l.VIDEO = "video", l))(o || {});
2028
- const Be = {
2064
+ const He = {
2029
2065
  ".aac": {
2030
2066
  type: o.AUDIO,
2031
2067
  open: !0,
@@ -2886,22 +2922,22 @@ const Be = {
2886
2922
  }
2887
2923
  };
2888
2924
  o.AUDIO + "", o.VIDEO + "", o.IMAGE + "", o.TEXT + "", o.MARKUP + "", o.SCRIPT + "", o.DATA + "", o.ARCHIVE + "", o.INSTALLER + "", o.BINARY + "", o.BACKUP + "", o.AUTOMATION + "", o.PRESENTATION + "", o.SPREADSHEET + "", o.FONT + "", o.GEOSPATIAL + "", o.THREE_D + "", o.CAD + "", o.BIM + "", o.PLANNING + "", o.EMAIL + "", o.MULTIMEDIA + "", o.UNKNOWN + "";
2889
- const { namedNode: Fe, literal: as } = O;
2890
- Fe("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
2891
- const { namedNode: os } = O, { namedNode: He, literal: rs } = O;
2892
- He("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
2893
- function ze(l) {
2925
+ const { namedNode: ze, literal: rs } = U;
2926
+ ze("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
2927
+ const { namedNode: cs } = U, { namedNode: Ge, literal: ls } = U;
2928
+ Ge("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
2929
+ function We(l) {
2894
2930
  const t = l.split(".");
2895
2931
  return t.length > 1 ? "." + t.pop()?.toLowerCase() : "";
2896
2932
  }
2897
- const { namedNode: Ge, literal: cs } = O;
2898
- Ge("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
2899
- const { namedNode: We, literal: ls } = O;
2900
- We("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
2901
- function Ct(l, t, e, s, i, n, a, c = !1, r = !1) {
2902
- const u = ze(l), p = D(s), m = `${t}/${p}${u}`;
2903
- a === void 0 && (a = Be[u]?.mime ?? "application/octet-stream");
2904
- const h = we(l, i);
2933
+ const { namedNode: Ke, literal: us } = U;
2934
+ Ke("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
2935
+ const { namedNode: Qe, literal: ps } = U;
2936
+ Qe("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
2937
+ function Tt(l, t, e, s, i, n, a, c = !1, r = !1) {
2938
+ const u = We(l), p = v(s), m = `${t}/${p}${u}`;
2939
+ a === void 0 && (a = He[u]?.mime ?? "application/octet-stream");
2940
+ const h = Ie(l, i);
2905
2941
  return {
2906
2942
  name: l,
2907
2943
  blob_name: m,
@@ -2921,49 +2957,49 @@ function Ct(l, t, e, s, i, n, a, c = !1, r = !1) {
2921
2957
  })
2922
2958
  };
2923
2959
  }
2924
- async function M() {
2960
+ async function O() {
2925
2961
  return import("fs/promises");
2926
2962
  }
2927
- async function Tt(l) {
2963
+ async function At(l) {
2928
2964
  if (typeof window < "u")
2929
2965
  throw new Error(
2930
2966
  `Cannot read file from path "${l}" in a browser environment. Provide file.data (Uint8Array) instead.`
2931
2967
  );
2932
- const { readFile: t } = await M();
2968
+ const { readFile: t } = await O();
2933
2969
  return t(l);
2934
2970
  }
2935
- let U = null, N = null, k = null;
2936
- function us(l) {
2937
- k = l, N = null, U = null;
2971
+ let D = null, q = null, j = null;
2972
+ function hs(l) {
2973
+ j = l, q = null, D = null;
2938
2974
  }
2939
- async function Ke() {
2975
+ async function Ve() {
2940
2976
  if (typeof window < "u") {
2941
- if (!k)
2977
+ if (!j)
2942
2978
  throw new Error(
2943
2979
  "WASM scanner is not configured for browser use. Call configureScanWasm(baseUrl) during app initialisation."
2944
2980
  );
2945
- const l = await fetch(`${k}/dir_scanner_wasm_bg.wasm`);
2981
+ const l = await fetch(`${j}/dir_scanner_wasm_bg.wasm`);
2946
2982
  if (!l.ok)
2947
2983
  throw new Error(`Failed to fetch WASM binary: ${l.status} ${l.statusText}`);
2948
- const t = new Uint8Array(await l.arrayBuffer()), s = await import(`${k}/dir_scanner_wasm.mjs`);
2949
- await s.default({ module_or_path: t }), U = s.scan;
2984
+ const t = new Uint8Array(await l.arrayBuffer()), s = await import(`${j}/dir_scanner_wasm.mjs`);
2985
+ await s.default({ module_or_path: t }), D = s.scan;
2950
2986
  } else {
2951
- const { readFile: l } = await M(), { join: t } = await import("path"), { pathToFileURL: e } = await import("url"), s = t(__dirname, "assets", "wasm"), i = await l(t(s, "dir_scanner_wasm_bg.wasm")), a = await import(e(t(s, "dir_scanner_wasm.mjs")).href);
2952
- await a.default({ module_or_path: i }), U = a.scan;
2987
+ const { readFile: l } = await O(), { join: t } = await import("path"), { pathToFileURL: e } = await import("url"), s = t(__dirname, "assets", "wasm"), i = await l(t(s, "dir_scanner_wasm_bg.wasm")), a = await import(e(t(s, "dir_scanner_wasm.mjs")).href);
2988
+ await a.default({ module_or_path: i }), D = a.scan;
2953
2989
  }
2954
2990
  }
2955
- const Qe = "fuseki", j = 1e3, Z = "cue:pending:";
2991
+ const Xe = "fuseki", L = 1e3, Z = "cue:pending:";
2956
2992
  async function tt(l) {
2957
2993
  const { tmpdir: t } = await import("os"), { join: e } = await import("path");
2958
2994
  return e(t(), `cue-sync-pending-${l}.json`);
2959
2995
  }
2960
- async function At(l) {
2996
+ async function St(l) {
2961
2997
  if (typeof window < "u") {
2962
2998
  const t = window.localStorage.getItem(`${Z}${l}`);
2963
2999
  return t ? JSON.parse(t) : null;
2964
3000
  }
2965
3001
  try {
2966
- const t = await (await M()).readFile(await tt(l), "utf-8");
3002
+ const t = await (await O()).readFile(await tt(l), "utf-8");
2967
3003
  return JSON.parse(t);
2968
3004
  } catch {
2969
3005
  return null;
@@ -2975,19 +3011,19 @@ async function Rt(l) {
2975
3011
  window.localStorage.setItem(`${Z}${l.spaceId}`, t);
2976
3012
  return;
2977
3013
  }
2978
- await (await M()).writeFile(await tt(l.spaceId), t, "utf-8");
3014
+ await (await O()).writeFile(await tt(l.spaceId), t, "utf-8");
2979
3015
  }
2980
- async function Ve(l) {
3016
+ async function Ye(l) {
2981
3017
  if (typeof window < "u") {
2982
3018
  window.localStorage.removeItem(`${Z}${l}`);
2983
3019
  return;
2984
3020
  }
2985
3021
  try {
2986
- await (await M()).unlink(await tt(l));
3022
+ await (await O()).unlink(await tt(l));
2987
3023
  } catch {
2988
3024
  }
2989
3025
  }
2990
- class Xe {
3026
+ class Je {
2991
3027
  constructor(t, e, s, i) {
2992
3028
  this._auth = t, this._projects = e, this._blob = s, this._gatewayUrl = i;
2993
3029
  }
@@ -3032,8 +3068,8 @@ class Xe {
3032
3068
  providerId: e.providerId,
3033
3069
  fileContentExists: !1
3034
3070
  }));
3035
- for (let i = 0; i < s.length; i += j)
3036
- await this._postFssBatch(s.slice(i, i + j), e.spaceId);
3071
+ for (let i = 0; i < s.length; i += L)
3072
+ await this._postFssBatch(s.slice(i, i + L), e.spaceId);
3037
3073
  e.verbose && console.info(`Pushed metadata for ${s.length} file(s) ✅`);
3038
3074
  }
3039
3075
  /**
@@ -3043,7 +3079,7 @@ class Xe {
3043
3079
  */
3044
3080
  async flushPendingMetadata(t, e, s) {
3045
3081
  this._legacy = s ?? !1;
3046
- const i = await At(t);
3082
+ const i = await St(t);
3047
3083
  if (!(!i || i.items.length === 0)) {
3048
3084
  console.info(`Trying to upload metadata (${i.items.length} item(s))...`), e && console.info(`Flushing ${i.items.length} pending file location(s) from previous sync ⏳`);
3049
3085
  try {
@@ -3066,14 +3102,14 @@ class Xe {
3066
3102
  this._api?.getConsumption(s) ?? Promise.reject(new Error("CueSyncApi is not bound to a CueApi instance")),
3067
3103
  this._fetchUnitCreditMap(n),
3068
3104
  this._fetchTierNames()
3069
- ]), y = (await It(t, p)).localNotOnRemote ?? [], C = y.length > 0 ? await this.scanCost(y) : [];
3105
+ ]), y = (await Ct(t, p)).localNotOnRemote ?? [], C = y.length > 0 ? await this.scanCost(y) : [];
3070
3106
  let d = 0, T = 0;
3071
3107
  for (const E of C) {
3072
3108
  d += E.units;
3073
- const _ = h[u], S = _?.[E.ext] ?? 1;
3109
+ const _ = h[u], R = _?.[E.ext] ?? 1;
3074
3110
  n && _ && !(E.ext in _) && console.info(` Unknown format: .${E.ext} (using default rate of 1 credit/unit)`);
3075
- const v = E.units * S;
3076
- T += v, E.credits = Math.round(v);
3111
+ const b = E.units * R;
3112
+ T += b, E.credits = Math.round(b);
3077
3113
  }
3078
3114
  const A = g[u] ?? u;
3079
3115
  return {
@@ -3098,35 +3134,35 @@ class Xe {
3098
3134
  const [m, h] = await Promise.all([
3099
3135
  this._listRemoteFiles(p, s, i, a),
3100
3136
  this._api?.getConsumption(s) ?? Promise.reject(new Error("CueSyncApi is not bound to a CueApi instance"))
3101
- ]), { unitsAvailable: g } = h, f = await It(t, m);
3137
+ ]), { unitsAvailable: g } = h, f = await Ct(t, m);
3102
3138
  a && (console.info(`Total local files: ${t.length}`), console.info(`Total remote files: ${m.length}`), console.info(
3103
3139
  `Total files to sync: ${(f.localNotOnRemote?.length ?? 0) + f.localNotOnRemotePathOnly.length}`
3104
3140
  ));
3105
3141
  let y = f.syncCount, C = f.syncSize, d = 0, T = !1;
3106
3142
  const A = f.localNotOnRemote ?? [];
3107
3143
  if (A.length > 0) {
3108
- const S = (await this.scanCost(A)).reduce((v, Mt) => v + Mt.units, 0);
3109
- if (S > g)
3144
+ const R = (await this.scanCost(A)).reduce((b, $t) => b + $t.units, 0);
3145
+ if (R > g)
3110
3146
  throw new Error(
3111
- `Insufficient units: ${S} units required but only ${g} available.`
3147
+ `Insufficient units: ${R} units required but only ${g} available.`
3112
3148
  );
3113
3149
  }
3114
3150
  await this._initPendingBatch(s, a), a && A.length && console.info("Syncing missing files ⏳");
3115
3151
  for (const _ of A)
3116
3152
  try {
3117
- const S = Ct(
3153
+ const R = Tt(
3118
3154
  _.relativePath,
3119
3155
  s,
3120
3156
  n,
3121
3157
  _.md5,
3122
3158
  i
3123
3159
  );
3124
- if (!S.blob_name) throw new Error(`blob_name missing for ${_.relativePath}`);
3125
- const v = _.data ?? new Uint8Array(await Tt(_.fullPath));
3160
+ if (!R.blob_name) throw new Error(`blob_name missing for ${_.relativePath}`);
3161
+ const b = _.data ?? new Uint8Array(await At(_.fullPath));
3126
3162
  await this._blob.uploadRaw(
3127
- S.blob_name,
3128
- v,
3129
- S
3163
+ R.blob_name,
3164
+ b,
3165
+ R
3130
3166
  ), await this._queueFileLocation({
3131
3167
  relativePath: _.relativePath,
3132
3168
  md5: _.md5,
@@ -3134,8 +3170,8 @@ class Xe {
3134
3170
  providerId: i,
3135
3171
  fileContentExists: !1
3136
3172
  }), T = !0, y += 1, C += _.size || 0, this._logProgress(y, f.totalCount, C, f.totalSize, c);
3137
- } catch (S) {
3138
- d += 1, console.error(`[CueSyncApi] Failed to upload file: ${_.fullPath}`), a && console.error("[CueSyncApi] Upload error details:", S);
3173
+ } catch (R) {
3174
+ d += 1, console.error(`[CueSyncApi] Failed to upload file: ${_.fullPath}`), a && console.error("[CueSyncApi] Upload error details:", R);
3139
3175
  }
3140
3176
  a && f.localNotOnRemotePathOnly.length && console.info(`Syncing missing file locations (on provider "${i}") ⏳`);
3141
3177
  for (const _ of f.localNotOnRemotePathOnly)
@@ -3161,7 +3197,7 @@ class Xe {
3161
3197
  async _getOrCreateGraph(t, e) {
3162
3198
  const s = this._graphMap.get(t);
3163
3199
  if (s) return s;
3164
- const n = (await this._projects.getProject(t))?.projectSettings?.graph?.type ?? Qe, a = n === "qlever" ? `${this._gatewayUrl}${Ut}` : `${this._gatewayUrl}${Dt}`, c = n === "qlever" ? `${this._gatewayUrl}${Oe}` : `${this._gatewayUrl}${Ue}`, r = new ge({
3200
+ const n = (await this._projects.getProject(t))?.projectSettings?.graph?.type ?? Xe, a = n === "qlever" ? `${this._gatewayUrl}${Ot}` : `${this._gatewayUrl}${Ut}`, c = n === "qlever" ? `${this._gatewayUrl}${$e}` : `${this._gatewayUrl}${Me}`, r = new _e({
3165
3201
  graphType: n,
3166
3202
  queryEndpoint: a,
3167
3203
  updateEndpoint: c,
@@ -3201,7 +3237,7 @@ class Xe {
3201
3237
  return r;
3202
3238
  }
3203
3239
  async _getGraphFiles(t, e) {
3204
- const s = `PREFIX qcy: <${R.qcy}>
3240
+ const s = `PREFIX qcy: <${S.qcy}>
3205
3241
  SELECT ?fc ?loc ?created ?fp ?size
3206
3242
  WHERE {
3207
3243
  ?fc a qcy:FileContent ;
@@ -3210,7 +3246,14 @@ WHERE {
3210
3246
  ?loc qcy:remoteProviderId "${e}" ;
3211
3247
  qcy:dateCreated ?created ;
3212
3248
  qcy:filePath ?fp .
3213
- }`, i = await t.query(s, "application/sparql-results+json"), n = {};
3249
+ }`;
3250
+ let i;
3251
+ try {
3252
+ i = await t.query(s, "application/sparql-results+json");
3253
+ } catch (a) {
3254
+ throw (a instanceof Error ? a.message : String(a)).includes("HTTP 500") ? new Error("GRAPH_UNAVAILABLE: The knowledge graph for this project has no database configured. Contact your administrator or check the project setup.") : a;
3255
+ }
3256
+ const n = {};
3214
3257
  if (typeof i == "string") return n;
3215
3258
  for (const a of i.results.bindings) {
3216
3259
  const c = a.loc.value.split("/").at(-1) ?? "", r = a.fc.value.split("/").at(-1) ?? "", u = a.created.value, p = a.size.value;
@@ -3220,7 +3263,7 @@ WHERE {
3220
3263
  }
3221
3264
  async _initPendingBatch(t, e) {
3222
3265
  this._flushTimer !== null && (clearInterval(this._flushTimer), this._flushTimer = null), this._pendingSpaceId = t, this._pendingItems = [];
3223
- const s = await At(t);
3266
+ const s = await St(t);
3224
3267
  if (s && s.items.length > 0) {
3225
3268
  console.info(`Trying to upload metadata from interrupted sync (${s.items.length} item(s))...`), e && console.info(`Flushing ${s.items.length} pending file location(s) from previous sync ⏳`);
3226
3269
  try {
@@ -3256,10 +3299,10 @@ WHERE {
3256
3299
  }
3257
3300
  async _flushBatch(t, e, s) {
3258
3301
  const i = [...t];
3259
- this._pendingSpaceId === e && (this._pendingItems = []), await Ve(e);
3302
+ this._pendingSpaceId === e && (this._pendingItems = []), await Ye(e);
3260
3303
  try {
3261
- for (let n = 0; n < i.length; n += j)
3262
- await this._postFssBatch(i.slice(n, n + j), e);
3304
+ for (let n = 0; n < i.length; n += L)
3305
+ await this._postFssBatch(i.slice(n, n + L), e);
3263
3306
  s && console.info(`Wrote ${i.length} file location(s) to commands API ✅`);
3264
3307
  } catch (n) {
3265
3308
  const a = [...i, ...this._pendingItems];
@@ -3267,7 +3310,7 @@ WHERE {
3267
3310
  }
3268
3311
  }
3269
3312
  async _postFssBatch(t, e) {
3270
- const s = this._legacy ? `${this._gatewayUrl}${ut}?blob=true` : `${this._gatewayUrl}${ut}`;
3313
+ const s = this._legacy ? `${this._gatewayUrl}${pt}?blob=true` : `${this._gatewayUrl}${pt}`;
3271
3314
  let i;
3272
3315
  try {
3273
3316
  i = await this._auth.authenticatedFetch(s, {
@@ -3297,16 +3340,16 @@ WHERE {
3297
3340
  * shown to the user before or after calling {@link sync}.
3298
3341
  */
3299
3342
  async scanCost(t) {
3300
- if (N || (N = Ke()), await N, !U) throw new Error("WASM scan function not initialised");
3343
+ if (q || (q = Ve()), await q, !D) throw new Error("WASM scan function not initialised");
3301
3344
  const e = 200, s = /* @__PURE__ */ new Map();
3302
3345
  for (let i = 0; i < t.length; i += e) {
3303
3346
  const n = t.slice(i, i + e), a = await Promise.all(
3304
3347
  n.map(async (r) => ({
3305
3348
  originalPath: r.relativePath,
3306
3349
  // Use pre-loaded data if available (browser), otherwise read from disk (Node.js).
3307
- data: r.data ?? new Uint8Array(await Tt(r.fullPath))
3350
+ data: r.data ?? new Uint8Array(await At(r.fullPath))
3308
3351
  }))
3309
- ), c = U(a);
3352
+ ), c = D(a);
3310
3353
  for (const r of c) {
3311
3354
  const u = s.get(r.ext);
3312
3355
  u ? (u.count += r.count, u.units += r.units, u.sizeMb += r.sizeMb) : s.set(r.ext, { ...r });
@@ -3364,7 +3407,7 @@ WHERE {
3364
3407
  const { spaceId: s, providerId: i, userId: n, signal: a, onProgress: c } = e;
3365
3408
  if (!t.data)
3366
3409
  throw new Error("syncBrowserFile requires file.data (Uint8Array). Read the file with File.arrayBuffer() first.");
3367
- const r = Ct(t.relativePath, s, n, t.md5, i);
3410
+ const r = Tt(t.relativePath, s, n, t.md5, i);
3368
3411
  if (!r.blob_name) throw new Error(`blob_name missing for ${t.relativePath}`);
3369
3412
  await this._blob.uploadRaw(
3370
3413
  r.blob_name,
@@ -3377,6 +3420,9 @@ WHERE {
3377
3420
  { relativePath: t.relativePath, md5: t.md5, size: t.size, providerId: i, fileContentExists: !1 }
3378
3421
  );
3379
3422
  }
3423
+ async getTierNames() {
3424
+ return this._fetchTierNames();
3425
+ }
3380
3426
  async _fetchTierNames() {
3381
3427
  try {
3382
3428
  const t = await this._blob.downloadPublic("tier-names.json");
@@ -3405,7 +3451,7 @@ WHERE {
3405
3451
  n({ percent: a, syncCount: t, totalCount: e, syncSize: s, totalSize: i });
3406
3452
  }
3407
3453
  }
3408
- const St = {
3454
+ const xt = {
3409
3455
  production: {
3410
3456
  gatewayUrl: "https://accessors-api-gateway-ueyeemwf2a-oa.a.run.app",
3411
3457
  tokenUrl: "https://accessors-api-gateway-ueyeemwf2a-oa.a.run.app/token",
@@ -3425,7 +3471,7 @@ const St = {
3425
3471
  firestoreEmulatorPort: 8080
3426
3472
  }
3427
3473
  };
3428
- class Ot {
3474
+ class Mt {
3429
3475
  auth;
3430
3476
  api;
3431
3477
  projects;
@@ -3439,22 +3485,22 @@ class Ot {
3439
3485
  !t.apiKey && !t.appId && !t.measurementId && console.warn(
3440
3486
  "Using default SDK app settings. Contact QAECY for your own configuration for any production code."
3441
3487
  );
3442
- const s = t.apiKey ?? z.apiKey, i = t.appId ?? z.appId, n = t.measurementId ?? z.measurementId, a = t.environment ?? "production";
3443
- this._endpoints = { ...St[a], ...t.endpoints }, this._isEmulator = a === "emulator", this._app = $t().find((r) => r.name === "[DEFAULT]") ?? qt({
3488
+ const s = t.apiKey ?? H.apiKey, i = t.appId ?? H.appId, n = t.measurementId ?? H.measurementId, a = t.environment ?? "production";
3489
+ this._endpoints = { ...xt[a], ...t.endpoints }, this._isEmulator = a === "emulator", this._app = Lt().find((r) => r.name === "[DEFAULT]") ?? Nt({
3444
3490
  apiKey: s,
3445
3491
  appId: i,
3446
3492
  measurementId: n,
3447
- authDomain: `${rt}.firebaseapp.com`,
3448
- projectId: rt,
3449
- messagingSenderId: Ie
3450
- }), this.auth = new dt(this._app, this._isEmulator, this._endpoints), this.projects = new mt(this.auth, this._app, this._isEmulator, this._endpoints), this.api = this._buildApi(this.projects), this.profile = new yt(
3493
+ authDomain: `${ot}.firebaseapp.com`,
3494
+ projectId: ot,
3495
+ messagingSenderId: Ce
3496
+ }), this.auth = new ft(this._app, this._isEmulator, this._endpoints), this.projects = new yt(this.auth, this._app, this._isEmulator, this._endpoints), this.api = this._buildApi(this.projects), this.profile = new gt(
3451
3497
  this.auth,
3452
3498
  this._app,
3453
3499
  this._isEmulator,
3454
3500
  this._endpoints.gatewayUrl
3455
- ), this.privileges = new Et(this.auth.isSuperAdmin);
3456
- const c = x(this._app, lt);
3457
- this._isEmulator && kt(c, this._endpoints.storageEmulatorHost, this._endpoints.storageEmulatorPort), this.cache = new wt(c);
3501
+ ), this.privileges = new wt(this.auth.isSuperAdmin);
3502
+ const c = x(this._app, ct);
3503
+ this._isEmulator && Bt(c, this._endpoints.storageEmulatorHost, this._endpoints.storageEmulatorPort), this.cache = new It(c);
3458
3504
  }
3459
3505
  /**
3460
3506
  * Create a `Cue` instance from an already-initialized Firebase app.
@@ -3473,16 +3519,16 @@ class Ot {
3473
3519
  * });
3474
3520
  */
3475
3521
  static fromApp(t, e = {}) {
3476
- const s = e.environment ?? "production", i = { ...St[s], ...e.endpoints }, n = new dt(t, !1, i), a = new mt(n, t, !1, i), c = x(t, Te), r = x(t, Ae), u = x(t, Se), p = x(t, Re), m = x(t, Ce), h = x(t, lt), g = new _e({
3522
+ const s = e.environment ?? "production", i = { ...xt[s], ...e.endpoints }, n = new ft(t, !1, i), a = new yt(n, t, !1, i), c = x(t, Ae), r = x(t, Se), u = x(t, xe), p = x(t, Re), m = x(t, Te), h = x(t, ct), g = new Ee({
3477
3523
  storageRaw: c,
3478
3524
  storageProcessed: r,
3479
3525
  storagePublic: u,
3480
3526
  storageLogs: p,
3481
3527
  storageChatSessions: m,
3482
3528
  storagePersistence: h
3483
- }), f = new Xe(n, a, g, i.gatewayUrl), y = new ft(n, i.gatewayUrl, a, f);
3529
+ }), f = new Je(n, a, g, i.gatewayUrl), y = new mt(n, i.gatewayUrl, a, f);
3484
3530
  f._bindApi(y);
3485
- const C = new yt(n, t, !1, i.gatewayUrl), d = Object.create(Ot.prototype), T = new Et(n.isSuperAdmin), A = new wt(h);
3531
+ const C = new gt(n, t, !1, i.gatewayUrl), d = Object.create(Mt.prototype), T = new wt(n.isSuperAdmin), A = new It(h);
3486
3532
  return Object.assign(d, {
3487
3533
  _app: t,
3488
3534
  _endpoints: i,
@@ -3497,7 +3543,7 @@ class Ot {
3497
3543
  }
3498
3544
  /** Override in subclasses to provide a custom CueApi (e.g. with sync). */
3499
3545
  _buildApi(t) {
3500
- return new ft(this.auth, this._endpoints.gatewayUrl, t);
3546
+ return new mt(this.auth, this._endpoints.gatewayUrl, t);
3501
3547
  }
3502
3548
  /** Convenience: get the current user's Firebase ID token */
3503
3549
  getToken(t = !1) {
@@ -3522,32 +3568,32 @@ class Ot {
3522
3568
  get: (i) => this.cache.getQueryCache(t, i).then((n) => n?.results),
3523
3569
  set: (i, n) => this.cache.setQueryCache(t, i, { query: i, results: n })
3524
3570
  };
3525
- return new ke(this.api, t, { ...e, queryCache: s });
3571
+ return new Fe(this.api, t, { ...e, queryCache: s });
3526
3572
  }
3527
3573
  }
3528
3574
  export {
3529
- Ce as B,
3530
- Ot as C,
3531
- _t as R,
3532
- ft as a,
3533
- dt as b,
3534
- wt as c,
3535
- Et as d,
3536
- yt as e,
3537
- Ne as f,
3538
- je as g,
3575
+ Te as B,
3576
+ Mt as C,
3577
+ Et as R,
3578
+ mt as a,
3579
+ ft as b,
3580
+ It as c,
3581
+ wt as d,
3582
+ gt as e,
3583
+ Be as f,
3584
+ ke as g,
3539
3585
  qe as h,
3540
- ke as i,
3541
- mt as j,
3586
+ Fe as i,
3587
+ yt as j,
3542
3588
  I as k,
3543
- Xe as l,
3544
- us as m,
3545
- X as n,
3546
- Re as o,
3547
- Te as p,
3548
- lt as q,
3549
- Ae as r,
3589
+ X as l,
3590
+ Re as m,
3591
+ Ae as n,
3592
+ ct as o,
3593
+ Se as p,
3594
+ xe as q,
3595
+ Je as r,
3550
3596
  Y as s,
3551
- Se as t,
3552
- _e as u
3597
+ Ee as t,
3598
+ hs as u
3553
3599
  };