@qaecy/cue-sdk 0.0.16 → 0.0.17

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,12 +1,12 @@
1
- import { getApps as ne, initializeApp as pe } from "firebase/app";
2
- import { ref as _, getDownloadURL as V, getMetadata as U, getBlob as Wt, updateMetadata as le, uploadBytesResumable as ut, uploadBytes as ot, StringFormat as ce, uploadString as he, listAll as z, getStorage as S, connectStorageEmulator as de } from "firebase/storage";
3
- import { Writer as ge, DataFactory as j } from "n3";
4
- import { getFirestore as ue, connectFirestoreEmulator as me, collection as mt, getDocs as we, query as fe, where as ye, limit as be, doc as wt, getDoc as ve, setDoc as _e, serverTimestamp as ke, increment as Ee } from "firebase/firestore";
5
- import { getAuth as xe, connectAuthEmulator as Ce, onIdTokenChanged as Ie, getIdTokenResult as rt, signInWithEmailAndPassword as Te, GoogleAuthProvider as st, OAuthProvider as at, signInWithPopup as Se, signInWithRedirect as Ae, getRedirectResult as Re, signInWithCustomToken as Oe, signOut as Pe, onAuthStateChanged as De, fetchSignInMethodsForEmail as Le, linkWithPopup as qe, unlink as je, reauthenticateWithCredential as ft, EmailAuthProvider as K, updatePassword as Me, linkWithCredential as Ue, verifyBeforeUpdateEmail as ze, sendEmailVerification as Ne } from "firebase/auth";
6
- import { v5 as $e } from "uuid";
1
+ import { getApps as ge, initializeApp as ue } from "firebase/app";
2
+ import { ref as _, getDownloadURL as F, getMetadata as M, getBlob as Xt, updateMetadata as me, uploadBytesResumable as mt, uploadBytes as rt, StringFormat as we, uploadString as fe, listAll as z, getStorage as T, connectStorageEmulator as K } from "firebase/storage";
3
+ import { Writer as ye, DataFactory as j } from "n3";
4
+ import { getFirestore as be, connectFirestoreEmulator as ve, collection as wt, getDocs as _e, query as ke, where as Ee, limit as xe, doc as ft, getDoc as Ce, setDoc as Ie, serverTimestamp as Te, increment as Se } from "firebase/firestore";
5
+ import { getAuth as Ae, connectAuthEmulator as Re, onIdTokenChanged as Pe, getIdTokenResult as st, signInWithEmailAndPassword as Oe, GoogleAuthProvider as at, OAuthProvider as it, signInWithPopup as De, signInWithRedirect as Le, getRedirectResult as qe, signInWithCustomToken as je, signOut as Ue, onAuthStateChanged as Me, fetchSignInMethodsForEmail as ze, linkWithPopup as Ne, unlink as $e, reauthenticateWithCredential as yt, EmailAuthProvider as Q, updatePassword as Fe, linkWithCredential as Be, verifyBeforeUpdateEmail as Ge, sendEmailVerification as He } from "firebase/auth";
6
+ import { v5 as We } from "uuid";
7
7
  import "spark-md5";
8
- import { getFunctions as Vt, connectFunctionsEmulator as Kt, httpsCallable as F } from "firebase/functions";
9
- class nt {
8
+ import { getFunctions as Yt, connectFunctionsEmulator as Zt, httpsCallable as B } from "firebase/functions";
9
+ class pt {
10
10
  queryEndpoint;
11
11
  updateEndpoint;
12
12
  baseHeaders;
@@ -18,7 +18,7 @@ class nt {
18
18
  constructor(t) {
19
19
  this.queryEndpoint = t.queryEndpoint, this.updateEndpoint = t.updateEndpoint, this.baseHeaders = Object.fromEntries(
20
20
  Object.entries(t.originalHeaders || {}).filter(
21
- ([e]) => nt.RELEVANT_HEADER_KEYS.includes(e)
21
+ ([e]) => pt.RELEVANT_HEADER_KEYS.includes(e)
22
22
  )
23
23
  ), t.authHeader !== void 0 && (this.baseHeaders.Authorization = t.authHeader);
24
24
  }
@@ -81,7 +81,7 @@ class nt {
81
81
  };
82
82
  }
83
83
  }
84
- class Q extends Error {
84
+ class X 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 A {
119
119
  try {
120
120
  return await t();
121
121
  } catch (a) {
122
- if (r = a, a instanceof Q && s < e) {
122
+ if (r = a, a instanceof X && s < e) {
123
123
  const n = 0.5 + Math.random(), p = o * Math.pow(2, s) * n;
124
124
  await new Promise((c) => setTimeout(c, p));
125
125
  continue;
@@ -184,7 +184,7 @@ class A {
184
184
  });
185
185
  if (!e.ok) {
186
186
  const o = await e.text();
187
- throw e.status === 423 ? new Q(o) : new Error(`SPARQL update failed (HTTP ${e.status}): ${o}`);
187
+ throw e.status === 423 ? new X(o) : new Error(`SPARQL update failed (HTTP ${e.status}): ${o}`);
188
188
  }
189
189
  return await e.json();
190
190
  });
@@ -204,7 +204,7 @@ class A {
204
204
  await this._postToDataEndpoint(t, `${this.dataEndpoint}/delete`);
205
205
  }
206
206
  async _postToDataEndpoint(t, e) {
207
- const o = await this._quadsToNQuads(t), r = await Fe(Buffer.from(o, "utf-8"));
207
+ const o = await this._quadsToNQuads(t), r = await Ve(Buffer.from(o, "utf-8"));
208
208
  await A._retryOnLocked(async () => {
209
209
  const s = await fetch(e, {
210
210
  method: "POST",
@@ -217,18 +217,18 @@ class A {
217
217
  });
218
218
  if (!s.ok) {
219
219
  const a = await s.text();
220
- throw s.status === 423 ? new Q(a) : new Error(`QLever data POST failed (HTTP ${s.status}): ${a}`);
220
+ throw s.status === 423 ? new X(a) : new Error(`QLever data POST failed (HTTP ${s.status}): ${a}`);
221
221
  }
222
222
  });
223
223
  }
224
224
  _quadsToNQuads(t) {
225
225
  return new Promise((e, o) => {
226
- const r = new ge({ format: "application/n-quads" });
226
+ const r = new ye({ format: "application/n-quads" });
227
227
  r.addQuads(t), r.end((s, a) => s ? o(s) : e(a));
228
228
  });
229
229
  }
230
230
  }
231
- async function Fe(i) {
231
+ async function Ve(i) {
232
232
  const t = new CompressionStream("gzip"), e = t.writable.getWriter();
233
233
  e.write(new Uint8Array(i)), e.close();
234
234
  const o = [], r = t.readable.getReader();
@@ -243,14 +243,14 @@ async function Fe(i) {
243
243
  a.set(p, n), n += p.byteLength;
244
244
  return a.buffer;
245
245
  }
246
- class Be {
246
+ class Ke {
247
247
  constructor(t) {
248
248
  switch (this.options = t, this.options.graphType) {
249
249
  case "qlever":
250
250
  this._db = new A(this.options);
251
251
  break;
252
252
  case "fuseki":
253
- this._db = new nt(this.options);
253
+ this._db = new pt(this.options);
254
254
  break;
255
255
  default:
256
256
  throw new Error(`Unsupported graph type: ${this.options.graphType}`);
@@ -298,7 +298,7 @@ class Be {
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 Ge {
301
+ class Qe {
302
302
  constructor(t) {
303
303
  this.options = t;
304
304
  }
@@ -327,7 +327,7 @@ class Ge {
327
327
  async getDownloadURL(t, e) {
328
328
  const o = _(this._bucket(t), e);
329
329
  try {
330
- return await V(o);
330
+ return await F(o);
331
331
  } catch (r) {
332
332
  if (r?.code === "storage/object-not-found") return;
333
333
  throw r;
@@ -342,8 +342,8 @@ class Ge {
342
342
  if (this._knownMissing.has(o)) return;
343
343
  const r = _(this._bucket(t), e);
344
344
  try {
345
- const s = await U(r);
346
- return `${await V(r)}&t=${encodeURIComponent(s.updated)}`;
345
+ const s = await M(r);
346
+ return `${await F(r)}&t=${encodeURIComponent(s.updated)}`;
347
347
  } catch (s) {
348
348
  if (s?.code === "storage/object-not-found" || s?.status === 404) {
349
349
  this._knownMissing.add(o), console.debug(`[CueBlobStorage] ${e} not found (404 OK — optional cache file)`);
@@ -356,7 +356,7 @@ class Ge {
356
356
  async getFile(t, e) {
357
357
  const o = _(this._bucket(t), e);
358
358
  try {
359
- return await Wt(o);
359
+ return await Xt(o);
360
360
  } catch (r) {
361
361
  if (r?.code === "storage/object-not-found") return;
362
362
  throw r;
@@ -382,8 +382,8 @@ class Ge {
382
382
  ]);
383
383
  try {
384
384
  const [a, n] = await Promise.all([
385
- s(V(e)),
386
- s(U(e))
385
+ s(F(e)),
386
+ s(M(e))
387
387
  ]), p = `${a}&t=${encodeURIComponent(n.updated)}`, c = await fetch(p, { signal: o.signal });
388
388
  if (!c.ok) throw new Error(`HTTP ${c.status}`);
389
389
  return c.text();
@@ -399,7 +399,7 @@ class Ge {
399
399
  async getMetadata(t, e) {
400
400
  const o = _(this._bucket(t), e);
401
401
  try {
402
- const r = await U(o);
402
+ const r = await M(o);
403
403
  return {
404
404
  updated: r.updated,
405
405
  contentType: r.contentType,
@@ -414,7 +414,7 @@ class Ge {
414
414
  /** Update custom metadata on an existing file. */
415
415
  async setMetadata(t, e, o) {
416
416
  const r = _(this._bucket(t), e);
417
- await le(r, { customMetadata: o });
417
+ await me(r, { customMetadata: o });
418
418
  }
419
419
  // ─── Uploads ──────────────────────────────────────────────────────────────
420
420
  /**
@@ -423,7 +423,7 @@ class Ge {
423
423
  * upload progress needs to be surfaced in the UI.
424
424
  */
425
425
  uploadResumable(t, e, o, r) {
426
- const s = _(this._bucket(t), e), a = ut(s, o, r ? { customMetadata: r } : void 0);
426
+ const s = _(this._bucket(t), e), a = mt(s, o, r ? { customMetadata: r } : void 0);
427
427
  return {
428
428
  complete: () => new Promise((n, p) => a.then(() => n(), p)),
429
429
  pause: () => a.pause(),
@@ -443,12 +443,12 @@ class Ge {
443
443
  */
444
444
  async uploadBytes(t, e, o, r) {
445
445
  const s = _(this._bucket(t), e);
446
- await ot(s, o, r ? { customMetadata: r } : void 0);
446
+ await rt(s, o, r ? { customMetadata: r } : void 0);
447
447
  }
448
448
  /** Upload a string or base64-encoded value. */
449
- async uploadString(t, e, o, r = ce.RAW, s) {
449
+ async uploadString(t, e, o, r = we.RAW, s) {
450
450
  const a = _(this._bucket(t), e);
451
- await he(a, o, r, s ? { customMetadata: s } : void 0);
451
+ await fe(a, o, r, s ? { customMetadata: s } : void 0);
452
452
  }
453
453
  // ─── Listing ──────────────────────────────────────────────────────────────
454
454
  /** List all item names directly under `prefix` in the given bucket. */
@@ -499,7 +499,7 @@ class Ge {
499
499
  d(new DOMException("Upload cancelled", "AbortError"));
500
500
  return;
501
501
  }
502
- const g = ut(n, e, { customMetadata: o }), w = () => {
502
+ const g = mt(n, e, { customMetadata: o }), w = () => {
503
503
  g.cancel(), d(new DOMException("Upload cancelled", "AbortError"));
504
504
  };
505
505
  s?.addEventListener("abort", w, { once: !0 }), g.on(
@@ -532,7 +532,7 @@ class Ge {
532
532
  */
533
533
  async uploadProcessed(t, e, o) {
534
534
  const r = _(this.options.storageProcessed, t);
535
- return await U(r).catch(() => null) ? !1 : (await ot(r, e, { customMetadata: o }), !0);
535
+ return await M(r).catch(() => null) ? !1 : (await rt(r, e, { customMetadata: o }), !0);
536
536
  }
537
537
  /** List all blob names directly under `prefix` in the raw bucket. */
538
538
  async listRaw(t) {
@@ -540,7 +540,7 @@ class Ge {
540
540
  return (await z(e)).items.map((r) => r.name);
541
541
  }
542
542
  }
543
- const yt = {
543
+ const bt = {
544
544
  ä: "ae",
545
545
  ä: "ae",
546
546
  Ä: "AE",
@@ -576,15 +576,15 @@ const yt = {
576
576
  };
577
577
  function D(i, t = !1) {
578
578
  const e = "daca0510-72b5-48ba-9091-b918ca18136b";
579
- return i = He(i, t), $e(i, e);
579
+ return i = Xe(i, t), We(i, e);
580
580
  }
581
- function He(i, t = !1) {
581
+ function Xe(i, t = !1) {
582
582
  let e = i;
583
- for (const o in yt)
584
- e = e.replace(new RegExp(o, "g"), yt[o]);
583
+ for (const o in bt)
584
+ e = e.replace(new RegExp(o, "g"), bt[o]);
585
585
  return t && e !== i && console.info(`${i} -> ${e}`), e;
586
586
  }
587
- function We(i, t = "") {
587
+ function Ye(i, t = "") {
588
588
  return D(`${t}${i}`);
589
589
  }
590
590
  class x {
@@ -608,7 +608,7 @@ class x {
608
608
  return this;
609
609
  }
610
610
  }
611
- function pt(i, t) {
611
+ function lt(i, t) {
612
612
  const e = /* @__PURE__ */ new Set();
613
613
  let o = t(), r = !1;
614
614
  const s = [], a = () => {
@@ -630,7 +630,7 @@ function pt(i, t) {
630
630
  }
631
631
  };
632
632
  }
633
- async function lt(i, t, e, o) {
633
+ async function ct(i, t, e, o) {
634
634
  const r = D(i);
635
635
  let s;
636
636
  if (o) {
@@ -642,12 +642,12 @@ async function lt(i, t, e, o) {
642
642
  (p) => console.error("[staleWhileRevalidate] Cache write failed:", p)
643
643
  ), a;
644
644
  }
645
- const X = {
645
+ const Y = {
646
646
  apiKey: "AIzaSyAiW42QBx9HS4Khu88pCW7MV66IhBAQul0",
647
647
  appId: "1:151132927589:web:d2ffdb377dfadfd23ab88c",
648
648
  measurementId: "G-YT4PK6HGZD"
649
- }, bt = "qaecy-mvp-406413", Ve = "734737865998", Qt = "europe-west6", vt = "projects", Ke = "spaces_chats_eu_west6", Qe = "spaces_raw_eu_west6", Xe = "spaces_processed_eu_west6", Ye = "spaces_logs_eu_west6", Ze = "cue_public_eu_west6", _t = "db_persistence_eu_west6", Je = "/data-views/admin/consumption", to = "/data-views/admin/profile/organizations", kt = "/data-views/admin/profile/api-keys", Et = "/commands/admin/profile/api-keys", eo = "/commands/admin/profile/terms", oo = (i) => `/data-views/admin/organizations/${i}/members`, ro = "/commands/admin/project", so = "/assistant/search", Xt = "/triplestore/query", ao = "/triplestore/update", io = "/triplestore/shacl", Yt = "/qlever-server/qlever/query", no = "/qlever-server/qlever/update", po = "/qlever-server/qlever/shacl", xt = "/commands/file-system-structure/batch", Ct = "microsoft.com", It = "superadmin", ct = "https://cue.qaecy.com/r/";
650
- class Tt {
649
+ }, vt = "qaecy-mvp-406413", Ze = "734737865998", Jt = "europe-west6", _t = "projects", Je = "spaces_chats_eu_west6", kt = "spaces_raw_eu_west6", Et = "spaces_processed_eu_west6", to = "spaces_logs_eu_west6", eo = "cue_public_eu_west6", xt = "db_persistence_eu_west6", oo = "/data-views/admin/consumption", ro = "/data-views/admin/profile/organizations", Ct = "/data-views/admin/profile/api-keys", It = "/commands/admin/profile/api-keys", so = "/commands/admin/profile/terms", ao = (i) => `/data-views/admin/organizations/${i}/members`, io = "/commands/admin/project", no = "/assistant/search", te = "/triplestore/query", po = "/triplestore/update", lo = "/triplestore/shacl", ee = "/qlever-server/qlever/query", co = "/qlever-server/qlever/update", ho = "/qlever-server/qlever/shacl", Tt = "/commands/file-system-structure/batch", St = "microsoft.com", At = "superadmin", ht = "https://cue.qaecy.com/r/";
650
+ class Rt {
651
651
  _auth;
652
652
  _endpoints;
653
653
  _userSignal = new x(null);
@@ -664,19 +664,19 @@ class Tt {
664
664
  /** All unique UIDs for the current user (Firebase UID + linked provider UIDs). */
665
665
  userIds;
666
666
  constructor(t, e = !1, o) {
667
- this._auth = xe(t), this._endpoints = o, e && Ce(this._auth, o.authEmulatorUrl, {
667
+ this._auth = Ae(t), this._endpoints = o, e && Re(this._auth, o.authEmulatorUrl, {
668
668
  disableWarnings: !0
669
- }), this.user = this._userSignal.asReadonly(), this.token = this._tokenSignal.asReadonly(), this.isSuperAdmin = this._isSuperAdminSignal.asReadonly(), this._userIdsSignal = pt([this._userSignal], () => {
669
+ }), this.user = this._userSignal.asReadonly(), this.token = this._tokenSignal.asReadonly(), this.isSuperAdmin = this._isSuperAdminSignal.asReadonly(), this._userIdsSignal = lt([this._userSignal], () => {
670
670
  const r = this._userSignal.get();
671
671
  if (!r) return [];
672
672
  const s = /* @__PURE__ */ new Set([r.uid]);
673
673
  return r.providerData.forEach((a) => s.add(a.uid)), Array.from(s);
674
- }), this.userIds = this._userIdsSignal, this._stopTokenListener = Ie(this._auth, async (r) => {
674
+ }), this.userIds = this._userIdsSignal, this._stopTokenListener = Pe(this._auth, async (r) => {
675
675
  if (this._userSignal.set(r), r) {
676
676
  const s = await r.getIdToken();
677
677
  this._tokenSignal.set(s);
678
- const a = await rt(r);
679
- this._isSuperAdminSignal.set(a.claims.role === It);
678
+ const a = await st(r);
679
+ this._isSuperAdminSignal.set(a.claims.role === At);
680
680
  } else
681
681
  this._tokenSignal.set(null), this._isSuperAdminSignal.set(!1);
682
682
  });
@@ -689,14 +689,14 @@ class Tt {
689
689
  if (t === "password") {
690
690
  if (!e)
691
691
  throw new Error("credentials are required for password sign-in");
692
- return (await Te(
692
+ return (await Oe(
693
693
  this._auth,
694
694
  e.email,
695
695
  e.password
696
696
  )).user;
697
697
  }
698
- const o = t === "google" ? new st() : new at(Ct);
699
- return (await Se(this._auth, o)).user;
698
+ const o = t === "google" ? new at() : new it(St);
699
+ return (await De(this._auth, o)).user;
700
700
  }
701
701
  /**
702
702
  * Initiate a redirect-based sign-in (mobile / iframe contexts where popups
@@ -704,8 +704,8 @@ class Tt {
704
704
  * retrieve the result.
705
705
  */
706
706
  async signInWithRedirect(t) {
707
- const e = t === "google" ? new st() : new at(Ct);
708
- await Ae(this._auth, e);
707
+ const e = t === "google" ? new at() : new it(St);
708
+ await Le(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 Tt {
713
713
  * Call this once on app startup before showing a sign-in UI.
714
714
  */
715
715
  async checkRedirectResult() {
716
- return (await Re(this._auth))?.user ?? null;
716
+ return (await qe(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 Tt {
722
722
  */
723
723
  async checkSuperAdmin() {
724
724
  const t = this._auth.currentUser;
725
- return t ? (await rt(t)).claims.role === It : !1;
725
+ return t ? (await st(t)).claims.role === At : !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,11 @@ class Tt {
735
735
  if (!r.ok)
736
736
  throw new Error(`Failed to fetch custom token: ${r.statusText}`);
737
737
  const { token: s } = await r.json();
738
- return (await Oe(this._auth, s)).user;
738
+ return (await je(this._auth, s)).user;
739
739
  }
740
740
  /** Sign out the current user */
741
741
  async signOut() {
742
- await Pe(this._auth);
742
+ await Ue(this._auth);
743
743
  }
744
744
  /**
745
745
  * Register a new user by name and email.
@@ -769,7 +769,7 @@ class Tt {
769
769
  }
770
770
  /** Subscribe to authentication state changes. Returns an unsubscribe function. */
771
771
  onAuthStateChanged(t) {
772
- return De(this._auth, t);
772
+ return Me(this._auth, t);
773
773
  }
774
774
  /** Get the Firebase ID token for the current user, or null if not authenticated */
775
775
  async getToken(t = !1) {
@@ -801,8 +801,29 @@ class Tt {
801
801
  return this._auth;
802
802
  }
803
803
  }
804
- const lo = "/data-views/tables", co = "/commands/tables";
805
- class ho {
804
+ class Pt {
805
+ constructor(t, e) {
806
+ this._storageRaw = t, this._storageProcessed = e;
807
+ }
808
+ _storageRaw;
809
+ _storageProcessed;
810
+ /**
811
+ * Returns a Firebase authenticated download URL for a document stored in Cue.
812
+ *
813
+ * The storage path is `{projectId}/{uuid}{suffix}`, e.g. `my-project/abc-123.pdf`.
814
+ *
815
+ * @param projectId - The Cue project (space) ID.
816
+ * @param uuid - The document UUID.
817
+ * @param suffix - File suffix including the leading dot, e.g. `'.pdf'`, `'.ifc'`.
818
+ * @param bucket - `'raw'` (default, original uploads) or `'processed'` (derived artefacts).
819
+ */
820
+ async getDownloadUrl(t, e, o, r = "raw") {
821
+ const s = r === "processed" ? this._storageProcessed : this._storageRaw, a = _(s, `${t}/${e}${o}`);
822
+ return F(a);
823
+ }
824
+ }
825
+ const go = "/data-views/tables", uo = "/commands/tables";
826
+ class mo {
806
827
  constructor(t, e) {
807
828
  this._auth = t, this._gatewayUrl = e;
808
829
  }
@@ -810,7 +831,7 @@ class ho {
810
831
  _gatewayUrl;
811
832
  async listTables(t) {
812
833
  const e = await this._auth.authenticatedFetch(
813
- `${this._gatewayUrl}${lo}`,
834
+ `${this._gatewayUrl}${go}`,
814
835
  {
815
836
  headers: {
816
837
  "Content-Type": "application/json",
@@ -825,7 +846,7 @@ class ho {
825
846
  }
826
847
  async saveTables(t, e) {
827
848
  const o = await this._auth.authenticatedFetch(
828
- `${this._gatewayUrl}${co}`,
849
+ `${this._gatewayUrl}${uo}`,
829
850
  {
830
851
  method: "PUT",
831
852
  headers: {
@@ -840,9 +861,9 @@ class ho {
840
861
  throw new Error(`Failed to save tables: ${o.status} ${o.statusText}`);
841
862
  }
842
863
  }
843
- class St {
864
+ class Ot {
844
865
  constructor(t, e, o, r) {
845
- this._auth = t, this._gatewayUrl = e, this.projects = o, this.sync = r, this.tables = new ho(t, e);
866
+ this._auth = t, this._gatewayUrl = e, this.projects = o, this.sync = r, this.tables = new mo(t, e);
846
867
  }
847
868
  _auth;
848
869
  _gatewayUrl;
@@ -874,7 +895,7 @@ class St {
874
895
  */
875
896
  async search(t) {
876
897
  const e = await this._auth.authenticatedFetch(
877
- `${this._gatewayUrl}${so}`,
898
+ `${this._gatewayUrl}${no}`,
878
899
  {
879
900
  method: "POST",
880
901
  headers: { "Content-Type": "application/json", "cue-project-id": t.projectId },
@@ -897,7 +918,7 @@ class St {
897
918
  */
898
919
  async sparql(t, e, o) {
899
920
  o || (o = (await this.projects.getProject(e))?.projectSettings?.graph?.type ?? "qlever");
900
- const r = o === "fuseki" ? Xt : Yt;
921
+ const r = o === "fuseki" ? te : ee;
901
922
  console.log(`Executing SPARQL query against ${r} for project ${e} with graph type ${o}`);
902
923
  const s = new URLSearchParams();
903
924
  s.append("query", t);
@@ -934,7 +955,7 @@ class St {
934
955
  const r = o?.format ?? "json-ld", s = r === "turtle" ? "text/turtle" : "application/ld+json";
935
956
  if (o?.graphType === "fuseki") {
936
957
  const c = await this._auth.authenticatedFetch(
937
- `${this._gatewayUrl}${io}`,
958
+ `${this._gatewayUrl}${lo}`,
938
959
  {
939
960
  method: "POST",
940
961
  headers: {
@@ -952,7 +973,7 @@ class St {
952
973
  }
953
974
  return r === "turtle" ? c.text() : c.json();
954
975
  }
955
- const a = `${this._gatewayUrl}${po}${o?.verbose ? "?verbose=true" : ""}`, n = new URLSearchParams({ shape: t }), p = await this._auth.authenticatedFetch(a, {
976
+ const a = `${this._gatewayUrl}${ho}${o?.verbose ? "?verbose=true" : ""}`, n = new URLSearchParams({ shape: t }), p = await this._auth.authenticatedFetch(a, {
956
977
  method: "POST",
957
978
  headers: {
958
979
  "Content-Type": "application/x-www-form-urlencoded",
@@ -970,7 +991,7 @@ class St {
970
991
  }
971
992
  async getConsumption(t) {
972
993
  const e = await this._auth.authenticatedFetch(
973
- `${this._gatewayUrl}${Je}`,
994
+ `${this._gatewayUrl}${oo}`,
974
995
  {
975
996
  headers: {
976
997
  "Content-Type": "application/json",
@@ -986,7 +1007,7 @@ class St {
986
1007
  return e.json();
987
1008
  }
988
1009
  }
989
- const it = [
1010
+ const nt = [
990
1011
  "building",
991
1012
  "cadastre",
992
1013
  "zone",
@@ -997,13 +1018,13 @@ const it = [
997
1018
  "railway",
998
1019
  "natural",
999
1020
  "manmade"
1000
- ], Zt = [
1021
+ ], oe = [
1001
1022
  "address",
1002
1023
  "poi",
1003
1024
  "railway",
1004
1025
  "natural",
1005
1026
  "manmade"
1006
- ], go = {
1027
+ ], wo = {
1007
1028
  address: {
1008
1029
  category: "address",
1009
1030
  label: "Address",
@@ -1065,10 +1086,10 @@ const it = [
1065
1086
  preferredColor: "#db2777"
1066
1087
  }
1067
1088
  };
1068
- function T(i) {
1069
- return go[i];
1089
+ function S(i) {
1090
+ return wo[i];
1070
1091
  }
1071
- const uo = {
1092
+ const fo = {
1072
1093
  "land-use-plan": "#f59e0b",
1073
1094
  // amber – primary zoning
1074
1095
  "local-plan": "#ec4899",
@@ -1099,7 +1120,7 @@ const uo = {
1099
1120
  function N(i, t) {
1100
1121
  return i[0] < t[2] && i[2] > t[0] && i[1] < t[3] && i[3] > t[1];
1101
1122
  }
1102
- const mo = "https://nominatim.openstreetmap.org", wo = "cue-gis/0.0.1", fo = {
1123
+ const yo = "https://nominatim.openstreetmap.org", bo = "cue-gis/0.0.1", vo = {
1103
1124
  address: "street",
1104
1125
  poi: "shop",
1105
1126
  railway: "station",
@@ -1111,13 +1132,13 @@ const mo = "https://nominatim.openstreetmap.org", wo = "cue-gis/0.0.1", fo = {
1111
1132
  paved: "road",
1112
1133
  zone: "boundary"
1113
1134
  }, L = "nominatim";
1114
- function B(i) {
1135
+ function G(i) {
1115
1136
  return `${L}:${i}`;
1116
1137
  }
1117
- function yo(i) {
1118
- const t = T(i);
1138
+ function _o(i) {
1139
+ const t = S(i);
1119
1140
  return {
1120
- id: B(i),
1141
+ id: G(i),
1121
1142
  sourceId: L,
1122
1143
  sourceLayerId: i,
1123
1144
  category: i,
@@ -1129,43 +1150,43 @@ function yo(i) {
1129
1150
  descriptionKey: `gis.layer.${L}.${i}.description`
1130
1151
  };
1131
1152
  }
1132
- class bo {
1153
+ class ko {
1133
1154
  baseUrl;
1134
1155
  userAgent;
1135
1156
  email;
1136
1157
  limit;
1137
1158
  constructor(t = {}) {
1138
- this.baseUrl = t.baseUrl ?? mo, this.userAgent = t.userAgent ?? wo, this.email = t.email, this.limit = Math.min(t.limit ?? 40, 40);
1159
+ this.baseUrl = t.baseUrl ?? yo, this.userAgent = t.userAgent ?? bo, this.email = t.email, this.limit = Math.min(t.limit ?? 40, 40);
1139
1160
  }
1140
1161
  async listFeatureCategoryDescriptors(t) {
1141
1162
  return (await Promise.allSettled(
1142
- Zt.map(async (o) => {
1163
+ oe.map(async (o) => {
1143
1164
  const r = await this.search(t, o);
1144
1165
  return { category: o, hasResults: r.length > 0 };
1145
1166
  })
1146
1167
  )).filter(
1147
1168
  (o) => o.status === "fulfilled" && o.value.hasResults
1148
- ).map((o) => T(o.value.category));
1169
+ ).map((o) => S(o.value.category));
1149
1170
  }
1150
1171
  async listAvailableLayers(t) {
1151
- return (await this.listFeatureCategoryDescriptors(t)).map((o) => yo(o.category));
1172
+ return (await this.listFeatureCategoryDescriptors(t)).map((o) => _o(o.category));
1152
1173
  }
1153
1174
  async getFeaturesForLayer(t, e) {
1154
- const o = it.find((r) => B(r) === e);
1175
+ const o = nt.find((r) => G(r) === e);
1155
1176
  return o ? this.search(t, o) : [];
1156
1177
  }
1157
1178
  async listFeatureCategories(t) {
1158
1179
  return (await this.listFeatureCategoryDescriptors(t)).map((o) => o.category);
1159
1180
  }
1160
1181
  async getFeaturesOfCategory(t, e) {
1161
- return this.getFeaturesForLayer(t, B(e));
1182
+ return this.getFeaturesForLayer(t, G(e));
1162
1183
  }
1163
1184
  /**
1164
1185
  * Low-level search against the Nominatim API. Uses a per-layer probe query
1165
1186
  * so bounded viewbox searches return meaningful results.
1166
1187
  */
1167
1188
  async search(t, e) {
1168
- const [o, r, s, a] = t, n = e ? fo[e] : "place", p = new URLSearchParams({
1189
+ const [o, r, s, a] = t, n = e ? vo[e] : "place", p = new URLSearchParams({
1169
1190
  q: n,
1170
1191
  format: "jsonv2",
1171
1192
  viewbox: `${o},${a},${s},${r}`,
@@ -1189,12 +1210,12 @@ class bo {
1189
1210
  return (await h.json()).map((g) => this.toGisFeature(g, e));
1190
1211
  }
1191
1212
  toGisFeature(t, e) {
1192
- const [o, r, s, a] = t.boundingbox, n = e ?? t.category, p = T(n);
1213
+ const [o, r, s, a] = t.boundingbox, n = e ?? t.category, p = S(n);
1193
1214
  return {
1194
1215
  id: `${t.osm_type}/${t.osm_id}`,
1195
1216
  sourceId: L,
1196
1217
  sourceFeatureId: `${t.osm_type}/${t.osm_id}`,
1197
- layerId: B(n),
1218
+ layerId: G(n),
1198
1219
  name: t.name ?? t.display_name.split(",")[0].trim(),
1199
1220
  category: n,
1200
1221
  preferredColor: p.preferredColor,
@@ -1208,7 +1229,7 @@ class bo {
1208
1229
  };
1209
1230
  }
1210
1231
  }
1211
- const At = {
1232
+ const Dt = {
1212
1233
  // 100s – Residential
1213
1234
  110: "residential",
1214
1235
  120: "residential",
@@ -1287,7 +1308,7 @@ const At = {
1287
1308
  960: "agricultural",
1288
1309
  970: "agricultural",
1289
1310
  990: "other"
1290
- }, Rt = {
1311
+ }, Lt = {
1291
1312
  1010: "residential",
1292
1313
  1020: "mixed",
1293
1314
  1030: "residential",
@@ -1317,7 +1338,7 @@ const At = {
1317
1338
  1281: "infrastructure",
1318
1339
  1282: "infrastructure",
1319
1340
  9999: "other"
1320
- }, vo = {
1341
+ }, Eo = {
1321
1342
  // Residential
1322
1343
  1110: "residential",
1323
1344
  // Einfamilienhaus
@@ -1379,7 +1400,7 @@ const At = {
1379
1400
  // Empfangsgebäude Bahn/Bus
1380
1401
  1282: "infrastructure"
1381
1402
  // Parkhaus, Garage
1382
- }, _o = [
1403
+ }, xo = [
1383
1404
  // "Gebäude" is the Swiss AV BoFlaeche land-cover label for a building footprint.
1384
1405
  // It does not encode the actual use type, so map it to 'other' as a safe fallback.
1385
1406
  [/^geb[äa]ude$/i, "other"],
@@ -1392,23 +1413,23 @@ const At = {
1392
1413
  [/infrastruktur|verkehr|transport|energy|energie|forsyning|teknik|teknisk/i, "infrastructure"],
1393
1414
  [/gemischt|mixed|blandet/i, "mixed"]
1394
1415
  ];
1395
- function P(i) {
1396
- for (const [t, e] of _o)
1416
+ function O(i) {
1417
+ for (const [t, e] of xo)
1397
1418
  if (t.test(i)) return e;
1398
1419
  }
1399
- function ko(i, t) {
1420
+ function Co(i, t) {
1400
1421
  if (i == null) return;
1401
1422
  const e = String(i).trim();
1402
- return t === "swiss-gwr" ? vo[e] ?? P(e) : t === "danish-matrikel" ? At[e] ?? P(e) : t === "zurich-wfs" || t === "swiss-av-wfs" ? Rt[e] ?? P(e) : Rt[e] ?? At[e] ?? P(e);
1423
+ return t === "swiss-gwr" ? Eo[e] ?? O(e) : t === "danish-matrikel" ? Dt[e] ?? O(e) : t === "zurich-wfs" || t === "swiss-av-wfs" ? Lt[e] ?? O(e) : Lt[e] ?? Dt[e] ?? O(e);
1403
1424
  }
1404
- function Eo(i, t) {
1425
+ function Io(i, t) {
1405
1426
  if (i != null)
1406
- return P(String(i).trim());
1427
+ return O(String(i).trim());
1407
1428
  }
1408
- function Jt(i) {
1429
+ function re(i) {
1409
1430
  return i.trim().toLowerCase().replace(/[\s_\-]/g, "");
1410
1431
  }
1411
- const xo = {
1432
+ const To = {
1412
1433
  // Swiss ÖREB rechtsstatus
1413
1434
  inkraft: "in-force",
1414
1435
  laufendeanderung: "amendment-pending",
@@ -1427,11 +1448,11 @@ const xo = {
1427
1448
  forslag: "proposed",
1428
1449
  aflyst: "repealed"
1429
1450
  };
1430
- function te(i) {
1451
+ function se(i) {
1431
1452
  if (i)
1432
- return xo[Jt(i)];
1453
+ return To[re(i)];
1433
1454
  }
1434
- const Ot = {
1455
+ const qt = {
1435
1456
  // Swiss Nutzungsplanung (typ_gde_bezeichnung and common variants)
1436
1457
  grundnutzungszonenplan: "land-use-plan",
1437
1458
  nutzungszonenplan: "land-use-plan",
@@ -1485,7 +1506,7 @@ const Ot = {
1485
1506
  // Danish plandata.dk
1486
1507
  lokalplan: "local-plan",
1487
1508
  kommuneplanramme: "municipal-plan-framework"
1488
- }, Co = [
1509
+ }, So = [
1489
1510
  [/quartiererhalt/i, "neighbourhood-conservation-plan"],
1490
1511
  [/lärmempfindlich|laermempfindlich/i, "noise-sensitivity-plan"],
1491
1512
  [/gewässerschutz|grundwasserschutz/i, "water-protection-plan"],
@@ -1525,24 +1546,24 @@ const Ot = {
1525
1546
  // Catch-all: any remaining Xzone / Xareal designation from the Grundnutzungszonenplan
1526
1547
  [/zone$|areal$/i, "land-use-plan"]
1527
1548
  ];
1528
- function ee(i) {
1549
+ function ae(i) {
1529
1550
  if (!i) return;
1530
- const t = Jt(i);
1531
- if (t in Ot) return Ot[t];
1532
- for (const [e, o] of Co)
1551
+ const t = re(i);
1552
+ if (t in qt) return qt[t];
1553
+ for (const [e, o] of So)
1533
1554
  if (e.test(i)) return o;
1534
1555
  console.warn(
1535
1556
  `[cue-gis] Unknown zone plan type — add "${i}" to classifyZonePlanType: no ZonePlanType mapping found.`
1536
1557
  );
1537
1558
  }
1538
- const Io = "https://maps.zh.ch/wfs/OGDZHWFS", To = "zurich-wfs", So = [8.35, 47.15, 8.95, 47.7], Ao = [5.9, 45.7, 10.55, 47.85];
1539
- function Y(i) {
1559
+ const Ao = "https://maps.zh.ch/wfs/OGDZHWFS", Ro = "zurich-wfs", Po = [8.35, 47.15, 8.95, 47.7], Oo = [5.9, 45.7, 10.55, 47.85];
1560
+ function Z(i) {
1540
1561
  return typeof i == "string" ? i : i.typeName;
1541
1562
  }
1542
- function Z(i) {
1563
+ function J(i) {
1543
1564
  return typeof i == "string" ? void 0 : i.cqlFilter;
1544
1565
  }
1545
- function Ro(i) {
1566
+ function Do(i) {
1546
1567
  if (!i) return [0, 0];
1547
1568
  const t = i.coordinates;
1548
1569
  switch (i.type) {
@@ -1560,20 +1581,20 @@ function Ro(i) {
1560
1581
  return [0, 0];
1561
1582
  }
1562
1583
  }
1563
- function Oo(i, t) {
1584
+ function Lo(i, t) {
1564
1585
  if (!i) return t;
1565
1586
  for (const e of ["plannavn", "bezeichnung", "name", "strassenname", "objektname", "title", "label"])
1566
1587
  if (typeof i[e] == "string" && i[e]) return i[e];
1567
1588
  return t;
1568
1589
  }
1569
- function Po(i, t, e) {
1590
+ function qo(i, t, e) {
1570
1591
  return e ? `${i}:${t}[${e}]` : `${i}:${t}`;
1571
1592
  }
1572
- const Do = /* @__PURE__ */ new Set(["building", "cadastre", "greenspace", "paved", "zone"]);
1573
- function J(i, t, e, o) {
1574
- const r = e.replace(/^ms:/, ""), s = T(t), a = Do.has(t) ? "priority" : "raw";
1593
+ const jo = /* @__PURE__ */ new Set(["building", "cadastre", "greenspace", "paved", "zone"]);
1594
+ function tt(i, t, e, o) {
1595
+ const r = e.replace(/^ms:/, ""), s = S(t), a = jo.has(t) ? "priority" : "raw";
1575
1596
  return {
1576
- id: Po(i, e, o),
1597
+ id: qo(i, e, o),
1577
1598
  sourceId: i,
1578
1599
  sourceLayerId: e,
1579
1600
  category: t,
@@ -1585,32 +1606,32 @@ function J(i, t, e, o) {
1585
1606
  descriptionKey: `gis.layer.${i}.${r}.description`
1586
1607
  };
1587
1608
  }
1588
- function Lo(i, t) {
1609
+ function Uo(i, t) {
1589
1610
  if (!i) return { featureType: "building" };
1590
1611
  const e = i.grundflaeche ?? i.gbf ?? i.gebaeudegrundrissflaeche ?? i.flaeche ?? void 0, o = i.vollgeschosse ?? i.geschossanzahl ?? i.anzahl_geschosse ?? void 0, r = i.gebaeudefunktion ?? i.gfkode ?? i.art ?? i.objektart ?? void 0, s = i.baujahr ?? i.bauperiode ?? void 0, a = String(i.egid ?? i.gwr_egid ?? i.egris_egid ?? "").trim() || void 0;
1591
1612
  return {
1592
1613
  featureType: "building",
1593
1614
  areaM2: typeof e == "number" ? e : void 0,
1594
1615
  buildingUse: r ? String(r) : void 0,
1595
- buildingUseGeneric: ko(r, t),
1616
+ buildingUseGeneric: Co(r, t),
1596
1617
  floors: typeof o == "number" ? o : void 0,
1597
1618
  yearBuilt: typeof s == "number" ? s : void 0,
1598
1619
  registryId: a
1599
1620
  };
1600
1621
  }
1601
- function qo(i, t) {
1622
+ function Mo(i, t) {
1602
1623
  if (!i) return { featureType: "plot" };
1603
1624
  const e = i.egris_egrid ?? i.egrid ?? void 0, o = i.nummer ?? void 0, r = i.nbident ?? void 0, s = o && r ? `${o}, ${r}` : o ?? void 0, a = i.flaechenmass ?? i.flaeche ?? void 0, n = i.art ?? i.nutzungsart ?? void 0;
1604
1625
  return {
1605
1626
  featureType: "plot",
1606
1627
  areaM2: typeof a == "number" ? a : void 0,
1607
1628
  plotUse: n ? String(n) : void 0,
1608
- plotUseGeneric: Eo(n),
1629
+ plotUseGeneric: Io(n),
1609
1630
  plotId: s,
1610
1631
  registryId: e
1611
1632
  };
1612
1633
  }
1613
- function jo(i) {
1634
+ function zo(i) {
1614
1635
  if (!i) return { featureType: "greenspace" };
1615
1636
  const t = i.flaeche ?? void 0, e = i.art ?? void 0;
1616
1637
  return {
@@ -1619,7 +1640,7 @@ function jo(i) {
1619
1640
  surfaceType: e ? String(e) : void 0
1620
1641
  };
1621
1642
  }
1622
- function Mo(i) {
1643
+ function No(i) {
1623
1644
  if (!i) return { featureType: "paved" };
1624
1645
  const t = i.flaeche ?? void 0, e = i.art ?? void 0;
1625
1646
  return {
@@ -1628,9 +1649,9 @@ function Mo(i) {
1628
1649
  surfaceType: e ? String(e) : void 0
1629
1650
  };
1630
1651
  }
1631
- function Uo(i) {
1652
+ function $o(i) {
1632
1653
  if (!i) return { featureType: "zone" };
1633
- const t = i.plannavn ?? i.bezeichnung ?? i.typ_bezeichnung ?? i.art ?? void 0, e = i.planid ?? i.plannummer ?? void 0, o = i.artcode ?? i.typ_code ?? i.abkuerzung ?? e ?? void 0, r = i.rechtsstatus ?? i.status ?? void 0, s = te(r), a = i.typ_gde_bezeichnung ?? void 0, n = ee(a), p = i.dagsordenpunkt_url ?? i.dokument_url ?? i.link ?? void 0, c = i.auflagedatum ?? void 0, h = i.festsetzungsdatum ?? void 0, d = i.genehmigungsdatum ?? void 0, g = i.inkraftsetzungsdatum ?? void 0, w = i.flaeche ?? i.flaeche_m2 ?? void 0;
1654
+ const t = i.plannavn ?? i.bezeichnung ?? i.typ_bezeichnung ?? i.art ?? void 0, e = i.planid ?? i.plannummer ?? void 0, o = i.artcode ?? i.typ_code ?? i.abkuerzung ?? e ?? void 0, r = i.rechtsstatus ?? i.status ?? void 0, s = se(r), a = i.typ_gde_bezeichnung ?? void 0, n = ae(a), p = i.dagsordenpunkt_url ?? i.dokument_url ?? i.link ?? void 0, c = i.auflagedatum ?? void 0, h = i.festsetzungsdatum ?? void 0, d = i.genehmigungsdatum ?? void 0, g = i.inkraftsetzungsdatum ?? void 0, w = i.flaeche ?? i.flaeche_m2 ?? void 0;
1634
1655
  return {
1635
1656
  featureType: "zone",
1636
1657
  zoneType: t ? String(t) : void 0,
@@ -1646,7 +1667,7 @@ function Uo(i) {
1646
1667
  areaM2: typeof w == "number" ? w : void 0
1647
1668
  };
1648
1669
  }
1649
- function zo(i) {
1670
+ function Fo(i) {
1650
1671
  const t = i.match(/^(\w+)\s*=\s*'([^']+)'$/);
1651
1672
  if (t) {
1652
1673
  const [, o, r] = t;
@@ -1661,37 +1682,37 @@ function zo(i) {
1661
1682
  }
1662
1683
  return () => !0;
1663
1684
  }
1664
- class tt {
1685
+ class et {
1665
1686
  categoryMap;
1666
1687
  baseUrl;
1667
1688
  sourceId;
1668
1689
  outputFormat;
1669
1690
  constructor(t) {
1670
- this.categoryMap = t.categoryMap, this.baseUrl = t.baseUrl ?? Io, this.sourceId = t.sourceId ?? To, this.outputFormat = t.outputFormat ?? "application/json; subtype=geojson";
1691
+ this.categoryMap = t.categoryMap, this.baseUrl = t.baseUrl ?? Ao, this.sourceId = t.sourceId ?? Ro, this.outputFormat = t.outputFormat ?? "application/json; subtype=geojson";
1671
1692
  }
1672
1693
  async listFeatureCategoryDescriptors(t) {
1673
1694
  const e = await this.listAvailableLayers(t);
1674
- return [...new Map(e.map((o) => [o.category, T(o.category)])).values()];
1695
+ return [...new Map(e.map((o) => [o.category, S(o.category)])).values()];
1675
1696
  }
1676
1697
  async listAvailableLayers(t) {
1677
1698
  const e = Object.entries(this.categoryMap);
1678
1699
  return (await Promise.allSettled(
1679
1700
  e.flatMap(
1680
1701
  ([r, s]) => s.map(async (a) => {
1681
- const n = Y(a), p = Z(a), c = await this._fetchFeatures(t, n, 1, p);
1702
+ const n = Z(a), p = J(a), c = await this._fetchFeatures(t, n, 1, p);
1682
1703
  return { category: r, typeName: n, cqlFilter: p, hasResults: c.features.length > 0 };
1683
1704
  })
1684
1705
  )
1685
1706
  )).filter(
1686
1707
  (r) => r.status === "fulfilled" && r.value.hasResults
1687
- ).map((r) => J(this.sourceId, r.value.category, r.value.typeName, r.value.cqlFilter));
1708
+ ).map((r) => tt(this.sourceId, r.value.category, r.value.typeName, r.value.cqlFilter));
1688
1709
  }
1689
1710
  async getFeaturesForLayer(t, e) {
1690
1711
  const o = this._findLayerById(e);
1691
1712
  return o ? this._fetchAndConvert(t, o.descriptor, o.cqlFilter) : [];
1692
1713
  }
1693
1714
  async _fetchAndConvert(t, e, o) {
1694
- const r = await this._fetchFeatures(t, e.sourceLayerId, void 0, o), s = o ? zo(o) : void 0;
1715
+ const r = await this._fetchFeatures(t, e.sourceLayerId, void 0, o), s = o ? Fo(o) : void 0;
1695
1716
  return (s ? r.features.filter((n) => s(n.properties)) : r.features).map((n, p) => this.toGisFeature(n, e, p));
1696
1717
  }
1697
1718
  /**
@@ -1706,7 +1727,7 @@ class tt {
1706
1727
  const o = this.categoryMap[e] ?? [];
1707
1728
  return (await Promise.all(
1708
1729
  o.map((s) => {
1709
- const a = Y(s), n = Z(s), p = J(this.sourceId, e, a);
1730
+ const a = Z(s), n = J(s), p = tt(this.sourceId, e, a);
1710
1731
  return this._fetchAndConvert(t, p, n);
1711
1732
  })
1712
1733
  )).flat();
@@ -1716,7 +1737,7 @@ class tt {
1716
1737
  const e = Object.entries(this.categoryMap);
1717
1738
  for (const [o, r] of e)
1718
1739
  for (const s of r) {
1719
- const a = Y(s), n = Z(s), p = J(this.sourceId, o, a, n);
1740
+ const a = Z(s), n = J(s), p = tt(this.sourceId, o, a, n);
1720
1741
  if (p.id === t)
1721
1742
  return { descriptor: p, cqlFilter: n };
1722
1743
  }
@@ -1740,7 +1761,7 @@ class tt {
1740
1761
  return g.json();
1741
1762
  }
1742
1763
  toGisFeature(t, e, o) {
1743
- const [r, s] = Ro(t.geometry), a = Oo(t.properties, `${e.sourceLayerId}[${o}]`), n = t.bbox ? [t.bbox[0], t.bbox[1], t.bbox[2], t.bbox[3]] : void 0, p = e.tier, c = p === "priority" ? this._extractNormalisedProperties(t, e) : void 0;
1764
+ const [r, s] = Do(t.geometry), a = Lo(t.properties, `${e.sourceLayerId}[${o}]`), n = t.bbox ? [t.bbox[0], t.bbox[1], t.bbox[2], t.bbox[3]] : void 0, p = e.tier, c = p === "priority" ? this._extractNormalisedProperties(t, e) : void 0;
1744
1765
  return {
1745
1766
  id: t.id ?? `${e.sourceLayerId}/${o}`,
1746
1767
  preferredColor: e.preferredColor,
@@ -1761,10 +1782,10 @@ class tt {
1761
1782
  };
1762
1783
  }
1763
1784
  _extractNormalisedProperties(t, e) {
1764
- return e.category === "building" ? Lo(t.properties, this.sourceId) : e.category === "greenspace" ? jo(t.properties) : e.category === "paved" ? Mo(t.properties) : e.category === "zone" ? Uo(t.properties) : qo(t.properties, this.sourceId);
1785
+ return e.category === "building" ? Uo(t.properties, this.sourceId) : e.category === "greenspace" ? zo(t.properties) : e.category === "paved" ? No(t.properties) : e.category === "zone" ? $o(t.properties) : Mo(t.properties, this.sourceId);
1765
1786
  }
1766
1787
  }
1767
- const oe = [8, 54.5, 15.2, 57.8], re = {
1788
+ const ie = [8, 54.5, 15.2, 57.8], ne = {
1768
1789
  building: [
1769
1790
  { source: "danish-matrikel", typename: "bbr_v001:bygning_current" }
1770
1791
  ],
@@ -1773,7 +1794,7 @@ const oe = [8, 54.5, 15.2, 57.8], re = {
1773
1794
  { source: "danish-matrikel", typename: "mat_v001:samletfastejendom_current" }
1774
1795
  ]
1775
1796
  };
1776
- function No(i) {
1797
+ function Bo(i) {
1777
1798
  if (!i) return [0, 0];
1778
1799
  const t = i.coordinates;
1779
1800
  switch (i.type) {
@@ -1791,7 +1812,7 @@ function No(i) {
1791
1812
  return [0, 0];
1792
1813
  }
1793
1814
  }
1794
- function $o(i, t) {
1815
+ function Go(i, t) {
1795
1816
  if (!i) return t;
1796
1817
  for (const e of [
1797
1818
  "mat:matrikelnummer",
@@ -1807,14 +1828,14 @@ function $o(i, t) {
1807
1828
  if (typeof i[e] == "string" && i[e]) return i[e];
1808
1829
  return t;
1809
1830
  }
1810
- function Fo(i, t, e) {
1831
+ function Ho(i, t, e) {
1811
1832
  return `${i}:${t}:${e}`;
1812
1833
  }
1813
- const Bo = /* @__PURE__ */ new Set(["building", "cadastre", "zone"]);
1814
- function et(i, t, e) {
1815
- const o = e.typename.replace(/^[^:]+:/, ""), r = T(t), s = Bo.has(t) ? "priority" : "raw";
1834
+ const Wo = /* @__PURE__ */ new Set(["building", "cadastre", "zone"]);
1835
+ function ot(i, t, e) {
1836
+ const o = e.typename.replace(/^[^:]+:/, ""), r = S(t), s = Wo.has(t) ? "priority" : "raw";
1816
1837
  return {
1817
- id: Fo(i, e.source, e.typename),
1838
+ id: Ho(i, e.source, e.typename),
1818
1839
  sourceId: i,
1819
1840
  sourceLayerId: e.typename,
1820
1841
  category: t,
@@ -1826,7 +1847,7 @@ function et(i, t, e) {
1826
1847
  descriptionKey: `gis.layer.${i}.${e.source}.${o}.description`
1827
1848
  };
1828
1849
  }
1829
- function Go(i, t) {
1850
+ function Vo(i, t) {
1830
1851
  if (t === "building") {
1831
1852
  const a = i?.byg041BebyggetAreal ?? i?.byg038SamletBygningsareal, n = i?.byg021BygningensAnvendelse, p = i?.id_lokalId, c = i?.byg026Opførelsesår;
1832
1853
  return {
@@ -1843,8 +1864,8 @@ function Go(i, t) {
1843
1864
  featureType: "zone",
1844
1865
  zoneType: a ?? void 0,
1845
1866
  zoneCode: p ?? void 0,
1846
- legalStatus: te(c),
1847
- planType: ee(i?.typ_gde_bezeichnung),
1867
+ legalStatus: se(c),
1868
+ planType: ae(i?.typ_gde_bezeichnung),
1848
1869
  planId: n ?? void 0,
1849
1870
  planDocumentLink: h ?? void 0,
1850
1871
  publicationDate: i?.auflagedatum ?? void 0,
@@ -1862,19 +1883,19 @@ function Go(i, t) {
1862
1883
  registryId: s ?? void 0
1863
1884
  };
1864
1885
  }
1865
- class Ho {
1886
+ class Ko {
1866
1887
  categoryMap;
1867
1888
  dataViewsBaseUrl;
1868
1889
  getHeaders;
1869
1890
  sourceId;
1870
1891
  constructor(t) {
1871
- this.dataViewsBaseUrl = t.dataViewsBaseUrl.replace(/\/$/, ""), this.getHeaders = t.getHeaders, this.categoryMap = t.categoryMap ?? re, this.sourceId = t.sourceId ?? "cue-sdk-gis";
1892
+ this.dataViewsBaseUrl = t.dataViewsBaseUrl.replace(/\/$/, ""), this.getHeaders = t.getHeaders, this.categoryMap = t.categoryMap ?? ne, this.sourceId = t.sourceId ?? "cue-sdk-gis";
1872
1893
  }
1873
1894
  async listFeatureCategoryDescriptors(t) {
1874
1895
  const e = await this.listAvailableLayers(t);
1875
1896
  return [
1876
1897
  ...new Map(
1877
- e.map((o) => [o.category, T(o.category)])
1898
+ e.map((o) => [o.category, S(o.category)])
1878
1899
  ).values()
1879
1900
  ];
1880
1901
  }
@@ -1889,7 +1910,7 @@ class Ho {
1889
1910
  )
1890
1911
  )).filter(
1891
1912
  (r) => r.status === "fulfilled" && r.value.hasResults
1892
- ).map((r) => et(this.sourceId, r.value.category, r.value.entry));
1913
+ ).map((r) => ot(this.sourceId, r.value.category, r.value.entry));
1893
1914
  }
1894
1915
  async getFeaturesForLayer(t, e) {
1895
1916
  const o = this._findLayerById(e);
@@ -1903,7 +1924,7 @@ class Ho {
1903
1924
  const o = this.categoryMap[e] ?? [];
1904
1925
  return (await Promise.all(
1905
1926
  o.map((s) => {
1906
- const a = et(this.sourceId, e, s);
1927
+ const a = ot(this.sourceId, e, s);
1907
1928
  return this.getFeaturesForLayer(t, a.id);
1908
1929
  })
1909
1930
  )).flat();
@@ -1912,7 +1933,7 @@ class Ho {
1912
1933
  _findLayerById(t) {
1913
1934
  for (const [e, o] of Object.entries(this.categoryMap))
1914
1935
  for (const r of o) {
1915
- const s = et(this.sourceId, e, r);
1936
+ const s = ot(this.sourceId, e, r);
1916
1937
  if (s.id === t) return { entry: r, descriptor: s };
1917
1938
  }
1918
1939
  }
@@ -1931,7 +1952,7 @@ class Ho {
1931
1952
  return d.json();
1932
1953
  }
1933
1954
  _toGisFeature(t, e, o) {
1934
- const [r, s] = No(t.geometry), a = t.id ?? `${e.sourceLayerId}/${o}`, n = $o(t.properties, a), p = t.bbox ? [t.bbox[0], t.bbox[1], t.bbox[2], t.bbox[3]] : void 0, c = e.tier, h = c === "priority" ? Go(t.properties, e.category) : void 0;
1955
+ const [r, s] = Bo(t.geometry), a = t.id ?? `${e.sourceLayerId}/${o}`, n = Go(t.properties, a), p = t.bbox ? [t.bbox[0], t.bbox[1], t.bbox[2], t.bbox[3]] : void 0, c = e.tier, h = c === "priority" ? Vo(t.properties, e.category) : void 0;
1935
1956
  return {
1936
1957
  id: a,
1937
1958
  sourceId: this.sourceId,
@@ -1952,7 +1973,7 @@ class Ho {
1952
1973
  };
1953
1974
  }
1954
1975
  }
1955
- const Wo = {
1976
+ const Qo = {
1956
1977
  address: [
1957
1978
  "ms:ogd-0406_arv_basis_avzh_hausnummer_pos_p",
1958
1979
  "ms:ogd-0571_afv_gv_strat_strassennetz_l"
@@ -2000,23 +2021,23 @@ const Wo = {
2000
2021
  // ÖREB Überlagernde Festlegungen (Flächen) – overlaying planning constraints
2001
2022
  "ms:ogd-0155_arv_basis_np_ul_flaeche_f"
2002
2023
  ]
2003
- }, se = [
2024
+ }, pe = [
2004
2025
  {
2005
2026
  name: "Canton of Zürich",
2006
- coverageBBox: So,
2027
+ coverageBBox: Po,
2007
2028
  supportedCategories: ["address", "poi", "railway", "natural", "manmade", "building", "cadastre", "greenspace", "paved", "zone"],
2008
2029
  priority: 10,
2009
- adapter: new tt({
2010
- categoryMap: Wo
2030
+ adapter: new et({
2031
+ categoryMap: Qo
2011
2032
  })
2012
2033
  },
2013
2034
  {
2014
2035
  name: "Switzerland (national AV cadastre)",
2015
- coverageBBox: Ao,
2036
+ coverageBBox: Oo,
2016
2037
  supportedCategories: ["cadastre"],
2017
2038
  priority: 5,
2018
2039
  // Lower priority than canton-specific adapters. For ZH, the canton adapter (priority 10) wins.
2019
- adapter: new tt({
2040
+ adapter: new et({
2020
2041
  sourceId: "swiss-av-wfs",
2021
2042
  baseUrl: "https://wfs.geodienste.ch/av_0/deu",
2022
2043
  categoryMap: {
@@ -2040,10 +2061,10 @@ const Wo = {
2040
2061
  * - `pdk:kommuneplanramme_vedtaget` – adopted municipal plan frameworks
2041
2062
  */
2042
2063
  name: "Denmark (Plandata.dk – planning zones)",
2043
- coverageBBox: oe,
2064
+ coverageBBox: ie,
2044
2065
  supportedCategories: ["zone"],
2045
2066
  priority: 10,
2046
- adapter: new tt({
2067
+ adapter: new et({
2047
2068
  sourceId: "danish-plandata",
2048
2069
  baseUrl: "https://wfs.plandata.dk/geoserver/pdk/wfs",
2049
2070
  outputFormat: "application/json",
@@ -2058,12 +2079,12 @@ const Wo = {
2058
2079
  })
2059
2080
  }
2060
2081
  ];
2061
- function Pt(i) {
2082
+ function jt(i) {
2062
2083
  return [...i].sort(
2063
- (t, e) => it.indexOf(t.category) - it.indexOf(e.category)
2084
+ (t, e) => nt.indexOf(t.category) - nt.indexOf(e.category)
2064
2085
  );
2065
2086
  }
2066
- class Vo {
2087
+ class Xo {
2067
2088
  nominatim;
2068
2089
  regions;
2069
2090
  /**
@@ -2078,9 +2099,9 @@ class Vo {
2078
2099
  zonePlanTypeColors: r,
2079
2100
  ...s
2080
2101
  } = t;
2081
- this.nominatim = new bo(s);
2082
- const a = o ? se : [];
2083
- this.regions = e ?? a, this.zonePlanTypeColors = { ...uo, ...r };
2102
+ this.nominatim = new ko(s);
2103
+ const a = o ? pe : [];
2104
+ this.regions = e ?? a, this.zonePlanTypeColors = { ...fo, ...r };
2084
2105
  }
2085
2106
  /**
2086
2107
  * Return the available feature categories together with UI metadata such as
@@ -2098,13 +2119,13 @@ class Vo {
2098
2119
  const r = /* @__PURE__ */ new Set(), s = [];
2099
2120
  for (const a of e)
2100
2121
  for (const n of a.supportedCategories ?? [])
2101
- r.has(n) || (r.add(n), s.push(T(n)));
2102
- for (const a of Zt)
2103
- r.has(a) || s.push(T(a));
2104
- return Pt(s);
2122
+ r.has(n) || (r.add(n), s.push(S(n)));
2123
+ for (const a of oe)
2124
+ r.has(a) || s.push(S(a));
2125
+ return jt(s);
2105
2126
  }
2106
2127
  const o = await this._adapterFor(t).listFeatureCategoryDescriptors(t);
2107
- return Pt(o);
2128
+ return jt(o);
2108
2129
  }
2109
2130
  /**
2110
2131
  * Return the feature categories that have at least one result within the
@@ -2177,7 +2198,7 @@ class Vo {
2177
2198
  const { features: n, idx: p } = await Promise.race(a.values());
2178
2199
  a.delete(p);
2179
2200
  for (const c of n) {
2180
- const h = Dt(c), d = W(c), g = s.get(h);
2201
+ const h = Ut(c), d = V(c), g = s.get(h);
2181
2202
  (g === void 0 || d > g) && (s.set(h, d), yield c);
2182
2203
  }
2183
2204
  }
@@ -2211,9 +2232,9 @@ class Vo {
2211
2232
  ), a = [], n = [];
2212
2233
  for (const d of s)
2213
2234
  d.status === "fulfilled" && (d.value.isNominatim ? n.push(...d.value.features) : a.push(...d.value.features));
2214
- const p = Xo(a, n), c = /* @__PURE__ */ new Map(), h = [];
2235
+ const p = Jo(a, n), c = /* @__PURE__ */ new Map(), h = [];
2215
2236
  for (const d of p) {
2216
- const g = Dt(d), w = W(d), u = c.get(g);
2237
+ const g = Ut(d), w = V(d), u = c.get(g);
2217
2238
  (u === void 0 || w > u) && (c.set(g, w), h.push(d));
2218
2239
  }
2219
2240
  return h;
@@ -2227,26 +2248,26 @@ class Vo {
2227
2248
  return this.regions.filter((o) => N(o.coverageBBox, t)).sort((o, r) => (r.priority ?? 0) - (o.priority ?? 0))[0]?.adapter ?? this.nominatim;
2228
2249
  }
2229
2250
  }
2230
- function W(i) {
2251
+ function V(i) {
2231
2252
  const t = i.geometry?.type;
2232
2253
  return t === "Polygon" || t === "MultiPolygon" ? 3 : t === "LineString" || t === "MultiLineString" ? 2 : 1;
2233
2254
  }
2234
- function Dt(i) {
2255
+ function Ut(i) {
2235
2256
  const t = Math.round(i.lat * 1e3) / 1e3, e = Math.round(i.lon * 1e3) / 1e3;
2236
2257
  return `${(i.name ?? i.id ?? "").toLowerCase().trim()}|${t}|${e}`;
2237
2258
  }
2238
- const Ko = 1e-3;
2239
- function Qo(i, t) {
2259
+ const Yo = 1e-3;
2260
+ function Zo(i, t) {
2240
2261
  const e = i.lat - t.lat, o = i.lon - t.lon;
2241
2262
  return Math.sqrt(e * e + o * o);
2242
2263
  }
2243
- function Xo(i, t) {
2264
+ function Jo(i, t) {
2244
2265
  if (t.length === 0) return i;
2245
- const e = i.filter((a) => W(a) === 3), o = i.filter((a) => W(a) !== 3), r = e.map((a) => ({ feature: { ...a, originalData: { ...a.originalData } }, matched: !1 })), s = [];
2266
+ const e = i.filter((a) => V(a) === 3), o = i.filter((a) => V(a) !== 3), r = e.map((a) => ({ feature: { ...a, originalData: { ...a.originalData } }, matched: !1 })), s = [];
2246
2267
  for (const a of t) {
2247
- let n = -1, p = Ko;
2268
+ let n = -1, p = Yo;
2248
2269
  for (let c = 0; c < r.length; c++) {
2249
- const h = Qo(a, r[c].feature);
2270
+ const h = Zo(a, r[c].feature);
2250
2271
  h < p && (p = h, n = c);
2251
2272
  }
2252
2273
  n >= 0 ? (r[n].feature.originalData = {
@@ -2260,8 +2281,8 @@ function Xo(i, t) {
2260
2281
  ...s
2261
2282
  ];
2262
2283
  }
2263
- const Yo = "/data-views", Zo = 1500;
2264
- class Jo {
2284
+ const tr = "/data-views", er = 1500;
2285
+ class or {
2265
2286
  // undefined = not yet built
2266
2287
  /** @internal — construct via `cue.gis`, not directly. */
2267
2288
  constructor(t, e) {
@@ -2344,25 +2365,25 @@ class Jo {
2344
2365
  }
2345
2366
  // ── Private ───────────────────────────────────────────────────────────────
2346
2367
  _scheduleDebouncedQuery() {
2347
- this._debounceTimer !== null && clearTimeout(this._debounceTimer), this._debounceTimer = setTimeout(() => this._queryLayers(), Zo);
2368
+ this._debounceTimer !== null && clearTimeout(this._debounceTimer), this._debounceTimer = setTimeout(() => this._queryLayers(), er);
2348
2369
  }
2349
2370
  _getGateway() {
2350
2371
  if (this._gatewayCache !== null && this._gatewayProjectId === this._projectId)
2351
2372
  return this._gatewayCache;
2352
- const t = this._projectId, e = [...se];
2373
+ const t = this._projectId, e = [...pe];
2353
2374
  return t && e.unshift({
2354
2375
  name: "Cue SDK (authenticated)",
2355
- coverageBBox: oe,
2356
- supportedCategories: Object.keys(re),
2376
+ coverageBBox: ie,
2377
+ supportedCategories: Object.keys(ne),
2357
2378
  priority: 10,
2358
- adapter: new Ho({
2359
- dataViewsBaseUrl: `${this._gatewayUrl}${Yo}`,
2379
+ adapter: new Ko({
2380
+ dataViewsBaseUrl: `${this._gatewayUrl}${tr}`,
2360
2381
  getHeaders: async () => ({
2361
2382
  ...await this._getAuthHeaders(),
2362
2383
  "x-project-id": t
2363
2384
  })
2364
2385
  })
2365
- }), this._gatewayCache = new Vo({ regions: e }), this._gatewayProjectId = t, this._gatewayCache;
2386
+ }), this._gatewayCache = new Xo({ regions: e }), this._gatewayProjectId = t, this._gatewayCache;
2366
2387
  }
2367
2388
  async _queryLayers() {
2368
2389
  const t = this._bbox;
@@ -2406,11 +2427,11 @@ class Jo {
2406
2427
  this._loadListeners.forEach((e) => e(t));
2407
2428
  }
2408
2429
  }
2409
- class Lt {
2430
+ class Mt {
2410
2431
  constructor(t, e, o = !1, r) {
2411
- if (this._auth = t, this._db = ue(e), this._functions = Vt(e, Qt), this._gatewayUrl = r?.gatewayUrl ?? "", o) {
2432
+ if (this._auth = t, this._db = be(e), this._functions = Yt(e, Jt), this._gatewayUrl = r?.gatewayUrl ?? "", o) {
2412
2433
  const s = r?.firestoreEmulatorHost ?? "localhost", a = r?.firestoreEmulatorPort ?? 8080;
2413
- me(this._db, s, a), Kt(this._functions, "localhost", 5001);
2434
+ ve(this._db, s, a), Zt(this._functions, "localhost", 5001);
2414
2435
  }
2415
2436
  }
2416
2437
  _auth;
@@ -2427,7 +2448,7 @@ class Lt {
2427
2448
  * Throws if a project with the given ID already exists.
2428
2449
  */
2429
2450
  async createProject(t) {
2430
- const e = await this._auth.authenticatedFetch(`${this._gatewayUrl}${ro}`, {
2451
+ const e = await this._auth.authenticatedFetch(`${this._gatewayUrl}${io}`, {
2431
2452
  method: "POST",
2432
2453
  headers: { "Content-Type": "application/json" },
2433
2454
  body: JSON.stringify(t)
@@ -2443,12 +2464,12 @@ class Lt {
2443
2464
  * Access is gated by Firestore rules which check membership.
2444
2465
  */
2445
2466
  async listProjects() {
2446
- const t = this._requireUser(), e = mt(this._db, vt);
2447
- return (await we(fe(e, ye("members", "array-contains", t), be(100)))).docs.map((r) => r.data());
2467
+ const t = this._requireUser(), e = wt(this._db, _t);
2468
+ return (await _e(ke(e, Ee("members", "array-contains", t), xe(100)))).docs.map((r) => r.data());
2448
2469
  }
2449
2470
  /** Fetch a single project by ID. Returns null if not found. */
2450
2471
  async getProject(t) {
2451
- const e = wt(mt(this._db, vt), t), o = await ve(e);
2472
+ const e = ft(wt(this._db, _t), t), o = await Ce(e);
2452
2473
  return o.exists() ? o.data() : null;
2453
2474
  }
2454
2475
  /**
@@ -2457,10 +2478,10 @@ class Lt {
2457
2478
  */
2458
2479
  async incrementUnitsConsumed(t, e, o) {
2459
2480
  if (e <= 0) return;
2460
- const r = wt(this._db, "clientSync", t);
2461
- await _e(r, {
2462
- unitsConsumed: Ee(e),
2463
- lastUpdated: ke(),
2481
+ const r = ft(this._db, "clientSync", t);
2482
+ await Ie(r, {
2483
+ unitsConsumed: Se(e),
2484
+ lastUpdated: Te(),
2464
2485
  lastUserId: o
2465
2486
  }, { merge: !0 });
2466
2487
  }
@@ -2468,20 +2489,20 @@ class Lt {
2468
2489
  * Invite a user to a project by email. Returns the invited user's uid and display name.
2469
2490
  */
2470
2491
  async inviteUserToProject(t, e, o) {
2471
- return (await F(this._functions, "inviteUserToProject")({ email: t, spaceId: e, role: o })).data;
2492
+ return (await B(this._functions, "inviteUserToProject")({ email: t, spaceId: e, role: o })).data;
2472
2493
  }
2473
2494
  /** Change an existing member's role on a project. */
2474
2495
  async changeUserRoleOnProject(t, e, o) {
2475
- await F(this._functions, "changeUserRoleOnProject")({ uid: t, spaceId: e, role: o });
2496
+ await B(this._functions, "changeUserRoleOnProject")({ uid: t, spaceId: e, role: o });
2476
2497
  }
2477
2498
  /** Remove a member from a project. */
2478
2499
  async removeUserFromProject(t, e) {
2479
- await F(this._functions, "removeUserFromProject")({ uid: t, spaceId: e });
2500
+ await B(this._functions, "removeUserFromProject")({ uid: t, spaceId: e });
2480
2501
  }
2481
2502
  }
2482
- class qt {
2503
+ class zt {
2483
2504
  constructor(t, e, o, r) {
2484
- this._auth = t, this._gatewayUrl = r, this._functions = Vt(e, Qt), o && Kt(this._functions, "localhost", 5001);
2505
+ this._auth = t, this._gatewayUrl = r, this._functions = Yt(e, Jt), o && Zt(this._functions, "localhost", 5001);
2485
2506
  }
2486
2507
  _auth;
2487
2508
  _gatewayUrl;
@@ -2498,13 +2519,13 @@ class qt {
2498
2519
  }
2499
2520
  /** Whether the current user has an active API key. */
2500
2521
  async hasAPIKey() {
2501
- return await this._fetch(kt) !== null;
2522
+ return await this._fetch(Ct) !== null;
2502
2523
  }
2503
2524
  /** Returns the sign-in methods registered for the current user's email. */
2504
2525
  async getSignInMethods() {
2505
2526
  const t = this._auth.currentUser;
2506
2527
  if (!t?.email) throw new Error("User has no e-mail");
2507
- return Le(this._auth.firebaseAuth, t.email);
2528
+ return ze(this._auth.firebaseAuth, t.email);
2508
2529
  }
2509
2530
  /** Builds a human-readable label from a Firebase UserInfo provider entry. */
2510
2531
  buildProviderLabel(t) {
@@ -2517,42 +2538,42 @@ class qt {
2517
2538
  }
2518
2539
  /** Links a Google or Microsoft provider to the current account via popup. Returns the new provider label. */
2519
2540
  async linkProvider(t) {
2520
- const e = this._requireUser(), o = t === "google.com" ? new st() : new at(t), s = (await qe(e, o)).user.providerData.find(
2541
+ const e = this._requireUser(), o = t === "google.com" ? new at() : new it(t), s = (await Ne(e, o)).user.providerData.find(
2521
2542
  (a) => a.providerId === t
2522
2543
  );
2523
2544
  return s ? this.buildProviderLabel(s) : "-";
2524
2545
  }
2525
2546
  /** Unlinks a provider from the current account. */
2526
2547
  async unlinkProvider(t) {
2527
- await je(this._requireUser(), t);
2548
+ await $e(this._requireUser(), t);
2528
2549
  }
2529
2550
  /** Changes the password. Reauthenticates first. */
2530
2551
  async updatePassword(t, e) {
2531
2552
  const o = this._requireUser();
2532
2553
  if (!o.email) throw new Error("User has no e-mail");
2533
- await ft(
2554
+ await yt(
2534
2555
  o,
2535
- K.credential(o.email, t)
2536
- ), await Me(o, e);
2556
+ Q.credential(o.email, t)
2557
+ ), await Fe(o, e);
2537
2558
  }
2538
2559
  /** Adds (sets) a password for an account that currently only uses SSO. */
2539
2560
  async addPassword(t) {
2540
2561
  const e = this._requireUser();
2541
2562
  if (!e.email) throw new Error("User has no e-mail");
2542
- await Ue(e, K.credential(e.email, t));
2563
+ await Be(e, Q.credential(e.email, t));
2543
2564
  }
2544
2565
  /** Requests an e-mail change. Sends a verification e-mail to the new address. */
2545
2566
  async updateEmail(t, e) {
2546
2567
  const o = this._requireUser();
2547
2568
  if (!o.email) throw new Error("User e-mail not available");
2548
- await ft(
2569
+ await yt(
2549
2570
  o,
2550
- K.credential(o.email, e)
2551
- ), await ze(o, t), await Ne(o);
2571
+ Q.credential(o.email, e)
2572
+ ), await Ge(o, t), await He(o);
2552
2573
  }
2553
2574
  /** Creates a new API key for the current user. */
2554
2575
  async createAPIKey(t) {
2555
- return this._fetch(Et, {
2576
+ return this._fetch(It, {
2556
2577
  method: "POST",
2557
2578
  headers: { "Content-Type": "application/json" },
2558
2579
  body: JSON.stringify({ expiration: t })
@@ -2561,7 +2582,7 @@ class qt {
2561
2582
  /** Revokes the current user's API key. */
2562
2583
  async revokeAPIKey() {
2563
2584
  const t = await this._auth.authenticatedFetch(
2564
- this._url(Et),
2585
+ this._url(It),
2565
2586
  { method: "DELETE" }
2566
2587
  );
2567
2588
  if (!t.ok)
@@ -2569,17 +2590,17 @@ class qt {
2569
2590
  }
2570
2591
  /** Fetches the current user's existing API key. */
2571
2592
  async requestAPIKey() {
2572
- const t = await this._fetch(kt);
2593
+ const t = await this._fetch(Ct);
2573
2594
  if (!t) throw new Error("No API key found");
2574
2595
  return t;
2575
2596
  }
2576
2597
  /** Returns organizations the current user is a member of. */
2577
2598
  async listOrganizations() {
2578
- return this._fetch(to);
2599
+ return this._fetch(ro);
2579
2600
  }
2580
2601
  /** Returns all members of the given organisation. Caller must be an org admin or superadmin. */
2581
2602
  async getOrgMembers(t) {
2582
- return this._fetch(oo(t));
2603
+ return this._fetch(ao(t));
2583
2604
  }
2584
2605
  _requireUser() {
2585
2606
  const t = this._auth.currentUser;
@@ -2591,11 +2612,11 @@ class qt {
2591
2612
  * Uses the `getUserInfo` Firebase callable function.
2592
2613
  */
2593
2614
  async getUserInfo(t) {
2594
- return (await F(this._functions, "getUserInfo")({ uids: t })).data;
2615
+ return (await B(this._functions, "getUserInfo")({ uids: t })).data;
2595
2616
  }
2596
2617
  /** Record that the current user has accepted the terms of service. Sets a `terms` custom claim on the token. */
2597
2618
  async acceptTerms(t) {
2598
- await this._fetch(eo, {
2619
+ await this._fetch(so, {
2599
2620
  method: "POST",
2600
2621
  headers: { "Content-Type": "application/json" },
2601
2622
  body: JSON.stringify({ version: t })
@@ -2609,10 +2630,10 @@ class qt {
2609
2630
  */
2610
2631
  async latestTermsAccepted() {
2611
2632
  const t = this._auth.currentUser;
2612
- return t ? (await rt(t)).claims.terms ?? null : null;
2633
+ return t ? (await st(t)).claims.terms ?? null : null;
2613
2634
  }
2614
2635
  }
2615
- const jt = ["superadmin", "admin", "syncer", "member"], Mt = {
2636
+ const Nt = ["superadmin", "admin", "syncer", "member"], $t = {
2616
2637
  createEntities: "admin",
2617
2638
  createProvider: "superadmin",
2618
2639
  changeContentCategories: "syncer",
@@ -2627,7 +2648,7 @@ const jt = ["superadmin", "admin", "syncer", "member"], Mt = {
2627
2648
  uploadDocuments: "syncer",
2628
2649
  viewEntities: "member"
2629
2650
  };
2630
- function tr() {
2651
+ function rr() {
2631
2652
  return {
2632
2653
  changeContentCategories: !1,
2633
2654
  createEntities: !1,
@@ -2644,9 +2665,9 @@ function tr() {
2644
2665
  viewEntities: !1
2645
2666
  };
2646
2667
  }
2647
- class Ut {
2668
+ class Ft {
2648
2669
  constructor(t) {
2649
- this._isSuperAdmin = t, this._projectRoles = new x([]), this.privileges = pt(
2670
+ this._isSuperAdmin = t, this._projectRoles = new x([]), this.privileges = lt(
2650
2671
  [this._projectRoles, t],
2651
2672
  () => this._compute()
2652
2673
  );
@@ -2673,17 +2694,17 @@ class Ut {
2673
2694
  _expand(t) {
2674
2695
  if (this._isSuperAdmin.get())
2675
2696
  return ["superadmin", "admin", "syncer", "member"];
2676
- const e = jt.findIndex((o) => t.includes(o));
2677
- return e === -1 ? [] : Array.from(jt.slice(e));
2697
+ const e = Nt.findIndex((o) => t.includes(o));
2698
+ return e === -1 ? [] : Array.from(Nt.slice(e));
2678
2699
  }
2679
2700
  _compute() {
2680
- const t = this._projectRoles.get(), e = tr();
2681
- for (const o of Object.keys(Mt))
2682
- e[o] = t.includes(Mt[o]);
2701
+ const t = this._projectRoles.get(), e = rr();
2702
+ for (const o of Object.keys($t))
2703
+ e[o] = t.includes($t[o]);
2683
2704
  return e;
2684
2705
  }
2685
2706
  }
2686
- class zt {
2707
+ class Bt {
2687
2708
  constructor(t) {
2688
2709
  this._storage = t;
2689
2710
  }
@@ -2716,7 +2737,7 @@ class zt {
2716
2737
  // ── Internal helpers ───────────────────────────────────────────────────────
2717
2738
  async _get(t, e) {
2718
2739
  try {
2719
- const r = await (await Wt(_(this._storage, `${t}/${e}.json.gz`))).arrayBuffer(), s = new DecompressionStream("gzip"), a = s.writable.getWriter(), n = s.readable.getReader();
2740
+ const r = await (await Xt(_(this._storage, `${t}/${e}.json.gz`))).arrayBuffer(), s = new DecompressionStream("gzip"), a = s.writable.getWriter(), n = s.readable.getReader();
2720
2741
  a.write(new Uint8Array(r)), a.close();
2721
2742
  const p = [];
2722
2743
  let c = await n.read();
@@ -2728,7 +2749,7 @@ class zt {
2728
2749
  d.set(w, g), g += w.length;
2729
2750
  return JSON.parse(new TextDecoder().decode(d));
2730
2751
  } catch (o) {
2731
- if (er(o)) return;
2752
+ if (sr(o)) return;
2732
2753
  throw o;
2733
2754
  }
2734
2755
  }
@@ -2743,14 +2764,14 @@ class zt {
2743
2764
  let g = 0;
2744
2765
  for (const w of p)
2745
2766
  d.set(w, g), g += w.length;
2746
- await ot(
2767
+ await rt(
2747
2768
  _(this._storage, `${t}/${e}.json.gz`),
2748
2769
  d,
2749
2770
  { contentType: "application/gzip" }
2750
2771
  );
2751
2772
  }
2752
2773
  }
2753
- function er(i) {
2774
+ function sr(i) {
2754
2775
  return typeof i == "object" && i !== null && "code" in i && i.code === "storage/object-not-found";
2755
2776
  }
2756
2777
  const b = {
@@ -6001,12 +6022,12 @@ const b = {
6001
6022
  fbsp: "http://purl.obolibrary.org/obo/FBSP_",
6002
6023
  rex: "http://purl.obolibrary.org/obo/REX_"
6003
6024
  };
6004
- class ht {
6025
+ class dt {
6005
6026
  static _instance;
6006
6027
  // Opposite map is built once
6007
6028
  _nsMap;
6008
6029
  static getInstance() {
6009
- return this._instance ? this._instance : (this._instance = new ht(), this._instance);
6030
+ return this._instance ? this._instance : (this._instance = new dt(), this._instance);
6010
6031
  }
6011
6032
  compactIRI(t) {
6012
6033
  let e = this._nsMap;
@@ -6032,7 +6053,7 @@ class ht {
6032
6053
  ), this._nsMap = t, t;
6033
6054
  }
6034
6055
  }
6035
- class or {
6056
+ class ar {
6036
6057
  constructor(t, e, o, r, s) {
6037
6058
  this._api = t, this._projectId = e, this._queryCache = r, this._graphType = s, this._currentLang = o, this._api.setLanguage(o), this._contentCategories = new x([]), this._entityCategories = new x([]), this._relationships = new x([]), this.availableContentCategories = this._contentCategories.asReadonly(), this.availableEntityCategories = this._entityCategories.asReadonly(), this.availableEntityRelationships = this._relationships.asReadonly(), this.ready = this._load(o).catch(
6038
6059
  (a) => console.error("[CueProjectSchema] Initial load failed:", a)
@@ -6088,7 +6109,7 @@ class or {
6088
6109
  return;
6089
6110
  }
6090
6111
  const o = this._buildCategoriesQuery(t, "ContentCategory"), r = this._buildCategoriesQuery(t, "EntityCategory"), s = this._buildRelationshipsQuery(t);
6091
- await lt(
6112
+ await ct(
6092
6113
  o + r + s,
6093
6114
  async () => {
6094
6115
  const [a, n, p] = await Promise.all([
@@ -6161,9 +6182,9 @@ GROUP BY ?iri ?parent`;
6161
6182
  });
6162
6183
  }
6163
6184
  }
6164
- const rr = "https://qlever.dev/api/osm-planet";
6165
- class sr {
6166
- constructor(t, e, o = ct, r, s) {
6185
+ const ir = "https://qlever.dev/api/osm-planet";
6186
+ class le {
6187
+ constructor(t, e, o = ht, r, s) {
6167
6188
  this._api = t, this._projectId = e, this._queryCache = r, this._graphType = s, this.baseURL = `${o}${e}/`, this.entityInfoMap = this._entityInfoMapComputed, this.entityGraph = this._entityGraph.asReadonly(), this._entityOSMMap.subscribe(() => this._checkPendingOSMFetches()), this._fetchEntityGraph().catch(
6168
6189
  (a) => console.error("[CueProjectEntities] Entity graph fetch failed:", a)
6169
6190
  );
@@ -6185,7 +6206,7 @@ class sr {
6185
6206
  _fetchingOSMIds = /* @__PURE__ */ new Set();
6186
6207
  _entityGraph = new x(void 0);
6187
6208
  // ── Derived signals ────────────────────────────────────────────────────────
6188
- _entityInfoMapComputed = pt(
6209
+ _entityInfoMapComputed = lt(
6189
6210
  [
6190
6211
  this._entityDetails,
6191
6212
  this._entityDocuments,
@@ -6426,7 +6447,7 @@ ORDER BY DESC(?weight)`, o = await this._api.sparql(
6426
6447
  };
6427
6448
  }
6428
6449
  if (t === "md") {
6429
- const s = ht.getInstance(), a = r.map((h) => ({
6450
+ const s = dt.getInstance(), a = r.map((h) => ({
6430
6451
  src: s.compactIRI(h.sourceCat.value),
6431
6452
  pred: s.compactIRI(h.predicate.value),
6432
6453
  tgt: s.compactIRI(h.targetCat.value),
@@ -6561,7 +6582,7 @@ WHERE {
6561
6582
  ?e2 qcy:hasEntityCategory ?e2Cat
6562
6583
  }
6563
6584
  GROUP BY ?e1Cat ?e2Cat`;
6564
- await lt(
6585
+ await ct(
6565
6586
  t,
6566
6587
  async () => {
6567
6588
  const e = await this._api.sparql(
@@ -6601,7 +6622,7 @@ GROUP BY ?e1Cat ?e2Cat`;
6601
6622
  const o = e.map((n) => `<${n}>`).join(" "), r = `PREFIX geo: <${R.geo}>
6602
6623
  SELECT * WHERE {
6603
6624
  VALUES ?s { ${o} }
6604
- SERVICE <${rr}> {
6625
+ SERVICE <${ir}> {
6605
6626
  ?s geo:hasGeometry/geo:asWKT ?wkt
6606
6627
  }
6607
6628
  }`, s = await this._api.sparql(
@@ -6614,8 +6635,8 @@ SELECT * WHERE {
6614
6635
  }), this._osmWKTMap.set(a);
6615
6636
  }
6616
6637
  }
6617
- class ar {
6618
- constructor(t, e, o, r = ct, s, a) {
6638
+ class ce {
6639
+ constructor(t, e, o, r = ht, s, a) {
6619
6640
  this._api = t, this._projectId = e, this._queryCache = s, this._graphType = a, this.baseURL = `${r}${e}/`, this._currentLang = o ?? this._api.language, this.documentInfoMap = this._documentInfoMap.asReadonly(), this.projectDocumentsData = this._projectDocumentsData.asReadonly();
6620
6641
  }
6621
6642
  _api;
@@ -6669,7 +6690,7 @@ class ar {
6669
6690
  documentsByContentCategory: {}
6670
6691
  });
6671
6692
  const t = this._buildDocumentsBySuffixQuery(), e = this._buildDocumentsByContentCategoryQuery(), o = this._buildDuplicateCountQuery();
6672
- await lt(
6693
+ await ct(
6673
6694
  t + e + o,
6674
6695
  async () => {
6675
6696
  const [r, s, a] = await Promise.all([
@@ -6689,16 +6710,89 @@ class ar {
6689
6710
  * once the SPARQL response arrives.
6690
6711
  */
6691
6712
  requestDocumentData(t) {
6692
- const e = t.filter((a) => this._documentInfoMap.get()[a] === void 0);
6693
- if (e.length === 0) return;
6694
- const o = e.map((a) => `r:${a}`).join(" "), r = this._api.language, s = `PREFIX qcy: <${b.qcy}>
6713
+ const e = t.filter((o) => this._documentInfoMap.get()[o] === void 0);
6714
+ e.length !== 0 && this._fetchDocumentInfoBatch(e).catch(
6715
+ (o) => console.error("[CueProjectDocuments] requestDocumentData failed:", o)
6716
+ );
6717
+ }
6718
+ /**
6719
+ * Promise-based alternative to {@link requestDocumentData} for non-reactive contexts.
6720
+ *
6721
+ * Resolves with the `DocumentInfo` entries for every requested UUID once the
6722
+ * SPARQL response arrives. UUIDs already present in the cache are returned
6723
+ * immediately without a network request. The result is also written into
6724
+ * `documentInfoMap` so reactive consumers stay in sync.
6725
+ *
6726
+ * UUIDs not found in the triplestore are omitted from the returned map.
6727
+ *
6728
+ * @example
6729
+ * ```ts
6730
+ * const docs = await cueProjectDocs.fetchDocumentData(['uuid1', 'uuid2']);
6731
+ * console.log(docs['uuid1'].subject);
6732
+ * ```
6733
+ */
6734
+ async fetchDocumentData(t) {
6735
+ const e = this._documentInfoMap.get(), o = t.filter((s) => e[s] === void 0);
6736
+ o.length > 0 && await this._fetchDocumentInfoBatch(o);
6737
+ const r = this._documentInfoMap.get();
6738
+ return Object.fromEntries(
6739
+ t.filter((s) => r[s] !== void 0).map((s) => [s, r[s]])
6740
+ );
6741
+ }
6742
+ /**
6743
+ * Returns the alternative representations of the given document UUID.
6744
+ *
6745
+ * Alternative representations are derived artefacts stored under
6746
+ * `qcy:alternativeRepresentation` in the triplestore — for example a
6747
+ * `.fragments` BIM tile derived from an `.ifc` source file.
6748
+ *
6749
+ * The returned `DocumentInfo` entries are also merged into
6750
+ * `documentInfoMap` so reactive consumers stay in sync.
6751
+ *
6752
+ * @example
6753
+ * ```ts
6754
+ * const alts = await docs.fetchAlternativeRepresentations('abc-123');
6755
+ * // alts[0].suffix => '.fragments'
6756
+ * ```
6757
+ */
6758
+ async fetchAlternativeRepresentations(t) {
6759
+ const e = `PREFIX qcy: <${b.qcy}>
6760
+ PREFIX r: <${this.baseURL}>
6761
+ SELECT ?altId
6762
+ WHERE {
6763
+ r:${t} qcy:alternativeRepresentation ?alt .
6764
+ BIND(REPLACE(STR(?alt), "^.*/([^/]*)$", "$1") AS ?altId)
6765
+ }`, r = (await this._api.sparql(e, this._projectId, this._graphType)).results.bindings.map((a) => a.altId?.value).filter((a) => !!a);
6766
+ if (r.length === 0) return [];
6767
+ const s = await this.fetchDocumentData(r);
6768
+ return r.map((a) => s[a]).filter((a) => a !== void 0);
6769
+ }
6770
+ /**
6771
+ * Returns a single arbitrary file path from the project's triplestore.
6772
+ * Useful for pre-filling path-based query inputs with a realistic example.
6773
+ */
6774
+ async randomFilePath() {
6775
+ const t = `PREFIX qcy: <${b.qcy}>
6776
+ SELECT ?path
6777
+ WHERE {
6778
+ ?fl a qcy:FileLocation ;
6779
+ qcy:filePath ?path .
6780
+ }
6781
+ LIMIT 1`;
6782
+ return (await this._api.sparql(t, this._projectId, this._graphType)).results.bindings[0]?.path?.value ?? null;
6783
+ }
6784
+ // ── Private helpers ────────────────────────────────────────────────────────
6785
+ /** Executes the document-info SPARQL query for the given UUIDs, merges results
6786
+ * into `documentInfoMap`, and returns the newly fetched entries. */
6787
+ async _fetchDocumentInfoBatch(t) {
6788
+ const e = t.map((p) => `r:${p}`).join(" "), o = this._api.language, r = `PREFIX qcy: <${b.qcy}>
6695
6789
  PREFIX r: <${this.baseURL}>
6696
6790
  SELECT ?id ?contentIRI ?suffix ?size ?subject ?summary
6697
6791
  (SAMPLE(?fp) AS ?path)
6698
6792
  (GROUP_CONCAT(DISTINCT ?tag; SEPARATOR=";") AS ?tags)
6699
6793
  (GROUP_CONCAT(DISTINCT STR(?cat); SEPARATOR=";") AS ?categories)
6700
6794
  WHERE {
6701
- VALUES ?contentIRI { ${o} }
6795
+ VALUES ?contentIRI { ${e} }
6702
6796
  ?contentIRI qcy:sizeBytes ?size ;
6703
6797
  qcy:hasFileLocation ?loc .
6704
6798
  ?loc qcy:filePath ?fp ;
@@ -6707,54 +6801,34 @@ WHERE {
6707
6801
  OPTIONAL { ?contentIRI qcy:tag ?tag }
6708
6802
  OPTIONAL { ?loc qcy:remoteProviderId ?pid }
6709
6803
 
6710
- OPTIONAL { ?contentIRI qcy:subject ?lang_subj FILTER(LANG(?lang_subj) = "${r}") }
6804
+ OPTIONAL { ?contentIRI qcy:subject ?lang_subj FILTER(LANG(?lang_subj) = "${o}") }
6711
6805
  OPTIONAL { ?contentIRI qcy:subject ?no_lang_subj }
6712
6806
  BIND(COALESCE(?lang_subj, ?no_lang_subj) AS ?subject)
6713
6807
 
6714
- OPTIONAL { ?contentIRI qcy:textSummary ?lang_summary FILTER(LANG(?lang_summary) = "${r}") }
6808
+ OPTIONAL { ?contentIRI qcy:textSummary ?lang_summary FILTER(LANG(?lang_summary) = "${o}") }
6715
6809
  OPTIONAL { ?contentIRI qcy:textSummary ?no_lang_summary }
6716
6810
  BIND(COALESCE(?lang_summary, ?no_lang_summary) AS ?summary)
6717
6811
 
6718
6812
  BIND(REPLACE(STR(?contentIRI), "^.*/([^/]*)$", "$1") AS ?id)
6719
6813
  }
6720
- GROUP BY ?id ?contentIRI ?suffix ?size ?subject ?summary`;
6721
- this._api.sparql(s, this._projectId).then((a) => {
6722
- const n = a, p = { ...this._documentInfoMap.get() };
6723
- n.results.bindings.forEach((c) => {
6724
- if (!c.id || !c.contentIRI) return;
6725
- const h = c.id.value;
6726
- p[h] = {
6727
- id: h,
6728
- contentIRI: c.contentIRI.value,
6729
- path: c.path?.value ?? "",
6730
- suffix: c.suffix?.value ?? "",
6731
- size: c.size ? parseInt(c.size.value, 10) : 0,
6732
- tags: c.tags?.value?.split(";").filter(Boolean) ?? [],
6733
- categories: c.categories?.value?.split(";").filter(Boolean) ?? [],
6734
- subject: c.subject?.value,
6735
- summary: c.summary?.value,
6736
- providerId: c.pid?.value
6737
- };
6738
- }), this._documentInfoMap.set(p);
6739
- }).catch(
6740
- (a) => console.error("[CueProjectDocuments] requestDocumentData failed:", a)
6741
- );
6742
- }
6743
- /**
6744
- * Returns a single arbitrary file path from the project's triplestore.
6745
- * Useful for pre-filling path-based query inputs with a realistic example.
6746
- */
6747
- async randomFilePath() {
6748
- const t = `PREFIX qcy: <${b.qcy}>
6749
- SELECT ?path
6750
- WHERE {
6751
- ?fl a qcy:FileLocation ;
6752
- qcy:filePath ?path .
6753
- }
6754
- LIMIT 1`;
6755
- return (await this._api.sparql(t, this._projectId, this._graphType)).results.bindings[0]?.path?.value ?? null;
6814
+ GROUP BY ?id ?contentIRI ?suffix ?size ?subject ?summary`, s = await this._api.sparql(r, this._projectId), a = { ...this._documentInfoMap.get() }, n = {};
6815
+ return s.results.bindings.forEach((p) => {
6816
+ if (!p.id || !p.contentIRI) return;
6817
+ const c = p.id.value, h = {
6818
+ id: c,
6819
+ contentIRI: p.contentIRI.value,
6820
+ path: p.path?.value ?? "",
6821
+ suffix: p.suffix?.value ?? "",
6822
+ size: p.size ? parseInt(p.size.value, 10) : 0,
6823
+ tags: p.tags?.value?.split(";").filter(Boolean) ?? [],
6824
+ categories: p.categories?.value?.split(";").filter(Boolean) ?? [],
6825
+ subject: p.subject?.value,
6826
+ summary: p.summary?.value,
6827
+ providerId: p.pid?.value
6828
+ };
6829
+ a[c] = h, n[c] = h;
6830
+ }), this._documentInfoMap.set(a), n;
6756
6831
  }
6757
- // ── Private helpers ────────────────────────────────────────────────────────
6758
6832
  async _fetchDocumentsBySuffix() {
6759
6833
  return this._runDocumentsBySuffixQuery(this._buildDocumentsBySuffixQuery());
6760
6834
  }
@@ -6835,9 +6909,9 @@ WHERE {
6835
6909
  return o?.count ? parseInt(o.count.value, 10) : 0;
6836
6910
  }
6837
6911
  }
6838
- class ir {
6839
- constructor(t, e, { language: o, queryCache: r, rdfBase: s = ct, graphType: a }) {
6840
- this._api = t, this._projectId = e, this.schema = new or(t, e, o, r, a), this.entities = new sr(t, e, s, r, a), this.documents = new ar(t, e, o, s, r, a), this.availableContentCategories = this.schema.availableContentCategories, this.availableEntityCategories = this.schema.availableEntityCategories, this.availableEntityRelationships = this.schema.availableEntityRelationships, this.schemaReady = this.schema.ready, 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((n) => console.error("[CueProjectView] fetchOverview failed:", n));
6912
+ class nr {
6913
+ constructor(t, e, { language: o, queryCache: r, rdfBase: s = ht, graphType: a }) {
6914
+ this._api = t, this._projectId = e, this.schema = new ar(t, e, o, r, a), this.entities = new le(t, e, s, r, a), this.documents = new ce(t, e, o, s, r, a), this.availableContentCategories = this.schema.availableContentCategories, this.availableEntityCategories = this.schema.availableEntityCategories, this.availableEntityRelationships = this.schema.availableEntityRelationships, this.schemaReady = this.schema.ready, 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((n) => console.error("[CueProjectView] fetchOverview failed:", n));
6841
6915
  }
6842
6916
  _api;
6843
6917
  _projectId;
@@ -6955,7 +7029,7 @@ class ir {
6955
7029
  this._destroyed = !0, this._searchResults.set(void 0);
6956
7030
  }
6957
7031
  }
6958
- function Nt(i, t) {
7032
+ function Gt(i, t) {
6959
7033
  return new Promise((e) => {
6960
7034
  const o = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
6961
7035
  for (const m of i)
@@ -6991,7 +7065,7 @@ function Nt(i, t) {
6991
7065
  });
6992
7066
  }
6993
7067
  var l = /* @__PURE__ */ ((i) => (i.AUTOMATION = "automation", i.ARCHIVE = "archive", i.AUDIO = "audio", i.BACKUP = "backup", i.BINARY = "binary", i.BIM = "bim", i.CAD = "cad", i.DATA = "data", i.EMAIL = "email", i.FONT = "font", i.GEOSPATIAL = "geospatial", i.IMAGE = "image", i.INSTALLER = "installer", i.MARKUP = "markup", i.MULTIMEDIA = "multimedia", i.PLANNING = "planning", i.PRESENTATION = "presentation", i.SCRIPT = "script", i.SPREADSHEET = "spreadsheet", i.TEXT = "text", i.THREE_D = "3d", i.UNKNOWN = "unknown", i.VIDEO = "video", i))(l || {});
6994
- const nr = {
7068
+ const pr = {
6995
7069
  ".aac": {
6996
7070
  type: l.AUDIO,
6997
7071
  open: !0,
@@ -7852,22 +7926,22 @@ const nr = {
7852
7926
  }
7853
7927
  };
7854
7928
  l.AUDIO + "", l.VIDEO + "", l.IMAGE + "", l.TEXT + "", l.MARKUP + "", l.SCRIPT + "", l.DATA + "", l.ARCHIVE + "", l.INSTALLER + "", l.BINARY + "", l.BACKUP + "", l.AUTOMATION + "", l.PRESENTATION + "", l.SPREADSHEET + "", l.FONT + "", l.GEOSPATIAL + "", l.THREE_D + "", l.CAD + "", l.BIM + "", l.PLANNING + "", l.EMAIL + "", l.MULTIMEDIA + "", l.UNKNOWN + "";
7855
- const { namedNode: pr, literal: Cr } = j;
7856
- pr("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
7857
- const { namedNode: Ir } = j, { namedNode: lr, literal: Tr } = j;
7929
+ const { namedNode: lr, literal: Ir } = j;
7858
7930
  lr("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
7859
- function cr(i) {
7931
+ const { namedNode: Tr } = j, { namedNode: cr, literal: Sr } = j;
7932
+ cr("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
7933
+ function hr(i) {
7860
7934
  const t = i.split(".");
7861
7935
  return t.length > 1 ? "." + t.pop()?.toLowerCase() : "";
7862
7936
  }
7863
- const { namedNode: hr, literal: Sr } = j;
7864
- hr("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
7865
7937
  const { namedNode: dr, literal: Ar } = j;
7866
7938
  dr("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
7867
- function $t(i, t, e, o, r, s, a, n = !1, p = !1) {
7868
- const c = cr(i), h = D(o), d = `${t}/${h}${c}`;
7869
- a === void 0 && (a = nr[c]?.mime ?? "application/octet-stream");
7870
- const g = We(i, r);
7939
+ const { namedNode: gr, literal: Rr } = j;
7940
+ gr("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
7941
+ function Ht(i, t, e, o, r, s, a, n = !1, p = !1) {
7942
+ const c = hr(i), h = D(o), d = `${t}/${h}${c}`;
7943
+ a === void 0 && (a = pr[c]?.mime ?? "application/octet-stream");
7944
+ const g = Ye(i, r);
7871
7945
  return {
7872
7946
  name: i,
7873
7947
  blob_name: d,
@@ -7887,37 +7961,37 @@ function $t(i, t, e, o, r, s, a, n = !1, p = !1) {
7887
7961
  })
7888
7962
  };
7889
7963
  }
7890
- async function M() {
7964
+ async function U() {
7891
7965
  return import(
7892
7966
  /* webpackIgnore: true */
7893
7967
  "fs/promises"
7894
7968
  );
7895
7969
  }
7896
- async function Ft(i) {
7970
+ async function Wt(i) {
7897
7971
  if (typeof window < "u")
7898
7972
  throw new Error(
7899
7973
  `Cannot read file from path "${i}" in a browser environment. Provide file.data (Uint8Array) instead.`
7900
7974
  );
7901
- const { readFile: t } = await M();
7975
+ const { readFile: t } = await U();
7902
7976
  return t(i);
7903
7977
  }
7904
- let q = null, G = null, H = null;
7905
- function Rr(i) {
7906
- H = i, G = null, q = null;
7978
+ let q = null, H = null, W = null;
7979
+ function Pr(i) {
7980
+ W = i, H = null, q = null;
7907
7981
  }
7908
- async function gr() {
7982
+ async function ur() {
7909
7983
  if (typeof window < "u") {
7910
- if (!H)
7984
+ if (!W)
7911
7985
  throw new Error(
7912
7986
  "WASM scanner is not configured for browser use. Call configureScanWasm(baseUrl) during app initialisation."
7913
7987
  );
7914
- const i = await fetch(`${H}/dir_scanner_wasm_bg.wasm`);
7988
+ const i = await fetch(`${W}/dir_scanner_wasm_bg.wasm`);
7915
7989
  if (!i.ok)
7916
7990
  throw new Error(`Failed to fetch WASM binary: ${i.status} ${i.statusText}`);
7917
- const t = new Uint8Array(await i.arrayBuffer()), o = await import(`${H}/dir_scanner_wasm.mjs`);
7991
+ const t = new Uint8Array(await i.arrayBuffer()), o = await import(`${W}/dir_scanner_wasm.mjs`);
7918
7992
  await o.default({ module_or_path: t }), q = o.scan;
7919
7993
  } else {
7920
- const { readFile: i } = await M(), { join: t } = await import(
7994
+ const { readFile: i } = await U(), { join: t } = await import(
7921
7995
  /* webpackIgnore: true */
7922
7996
  "path"
7923
7997
  ), { pathToFileURL: e } = await import(
@@ -7927,8 +8001,8 @@ async function gr() {
7927
8001
  await a.default({ module_or_path: r }), q = a.scan;
7928
8002
  }
7929
8003
  }
7930
- const ur = "qlever", $ = 1e3, dt = "cue:pending:";
7931
- async function gt(i) {
8004
+ const mr = "qlever", $ = 1e3, gt = "cue:pending:";
8005
+ async function ut(i) {
7932
8006
  const { tmpdir: t } = await import(
7933
8007
  /* webpackIgnore: true */
7934
8008
  "os"
@@ -7938,37 +8012,37 @@ async function gt(i) {
7938
8012
  );
7939
8013
  return e(t(), `cue-sync-pending-${i}.json`);
7940
8014
  }
7941
- async function Bt(i) {
8015
+ async function Vt(i) {
7942
8016
  if (typeof window < "u") {
7943
- const t = window.localStorage.getItem(`${dt}${i}`);
8017
+ const t = window.localStorage.getItem(`${gt}${i}`);
7944
8018
  return t ? JSON.parse(t) : null;
7945
8019
  }
7946
8020
  try {
7947
- const t = await (await M()).readFile(await gt(i), "utf-8");
8021
+ const t = await (await U()).readFile(await ut(i), "utf-8");
7948
8022
  return JSON.parse(t);
7949
8023
  } catch {
7950
8024
  return null;
7951
8025
  }
7952
8026
  }
7953
- async function Gt(i) {
8027
+ async function Kt(i) {
7954
8028
  const t = JSON.stringify(i);
7955
8029
  if (typeof window < "u") {
7956
- window.localStorage.setItem(`${dt}${i.spaceId}`, t);
8030
+ window.localStorage.setItem(`${gt}${i.spaceId}`, t);
7957
8031
  return;
7958
8032
  }
7959
- await (await M()).writeFile(await gt(i.spaceId), t, "utf-8");
8033
+ await (await U()).writeFile(await ut(i.spaceId), t, "utf-8");
7960
8034
  }
7961
- async function mr(i) {
8035
+ async function wr(i) {
7962
8036
  if (typeof window < "u") {
7963
- window.localStorage.removeItem(`${dt}${i}`);
8037
+ window.localStorage.removeItem(`${gt}${i}`);
7964
8038
  return;
7965
8039
  }
7966
8040
  try {
7967
- await (await M()).unlink(await gt(i));
8041
+ await (await U()).unlink(await ut(i));
7968
8042
  } catch {
7969
8043
  }
7970
8044
  }
7971
- class wr {
8045
+ class fr {
7972
8046
  constructor(t, e, o, r) {
7973
8047
  this._auth = t, this._projects = e, this._blob = o, this._gatewayUrl = r;
7974
8048
  }
@@ -8024,7 +8098,7 @@ class wr {
8024
8098
  */
8025
8099
  async flushPendingMetadata(t, e, o) {
8026
8100
  this._legacy = o ?? !1;
8027
- const r = await Bt(t);
8101
+ const r = await Vt(t);
8028
8102
  if (!(!r || r.items.length === 0)) {
8029
8103
  console.info(`Trying to upload metadata (${r.items.length} item(s))...`), e && console.info(`Flushing ${r.items.length} pending file location(s) from previous sync ⏳`);
8030
8104
  try {
@@ -8047,14 +8121,14 @@ class wr {
8047
8121
  this._api?.getConsumption(o) ?? Promise.reject(new Error("CueSyncApi is not bound to a CueApi instance")),
8048
8122
  this._fetchUnitCreditMap(s),
8049
8123
  this._fetchTierNames()
8050
- ]), f = (await Nt(t, h)).localNotOnRemote ?? [], k = f.length > 0 ? await this.scanCost(f) : [];
8124
+ ]), f = (await Gt(t, h)).localNotOnRemote ?? [], k = f.length > 0 ? await this.scanCost(f) : [];
8051
8125
  let m = 0, E = 0;
8052
8126
  for (const v of k) {
8053
8127
  m += v.units;
8054
8128
  const y = g[c], I = y?.[v.ext] ?? 1;
8055
8129
  s && y && !(v.ext in y) && console.info(` Unknown format: .${v.ext} (using default rate of 1 credit/unit)`);
8056
- const O = v.units * I;
8057
- E += O, v.credits = Math.round(O);
8130
+ const P = v.units * I;
8131
+ E += P, v.credits = Math.round(P);
8058
8132
  }
8059
8133
  const C = w[c] ?? c;
8060
8134
  return {
@@ -8079,14 +8153,14 @@ class wr {
8079
8153
  const [d, g] = await Promise.all([
8080
8154
  this._listRemoteFiles(h, o, r, a),
8081
8155
  this._api?.getConsumption(o) ?? Promise.reject(new Error("CueSyncApi is not bound to a CueApi instance"))
8082
- ]), { unitsAvailable: w } = g, u = await Nt(t, d);
8156
+ ]), { unitsAvailable: w } = g, u = await Gt(t, d);
8083
8157
  a && (console.info(`Total local files: ${t.length}`), console.info(`Total remote files: ${d.length}`), console.info(
8084
8158
  `Total files to sync: ${(u.localNotOnRemote?.length ?? 0) + u.localNotOnRemotePathOnly.length}`
8085
8159
  ));
8086
8160
  let f = u.syncCount, k = u.syncSize, m = 0, E = !1;
8087
8161
  const C = u.localNotOnRemote ?? [];
8088
8162
  if (C.length > 0) {
8089
- const I = (await this.scanCost(C)).reduce((O, ie) => O + ie.units, 0);
8163
+ const I = (await this.scanCost(C)).reduce((P, de) => P + de.units, 0);
8090
8164
  if (I > w)
8091
8165
  throw new Error(
8092
8166
  `Insufficient units: ${I} units required but only ${w} available.`
@@ -8095,7 +8169,7 @@ class wr {
8095
8169
  await this._initPendingBatch(o, a), a && C.length && console.info("Syncing missing files ⏳");
8096
8170
  for (const y of C)
8097
8171
  try {
8098
- const I = $t(
8172
+ const I = Ht(
8099
8173
  y.relativePath,
8100
8174
  o,
8101
8175
  s,
@@ -8103,10 +8177,10 @@ class wr {
8103
8177
  r
8104
8178
  );
8105
8179
  if (!I.blob_name) throw new Error(`blob_name missing for ${y.relativePath}`);
8106
- const O = y.data ?? new Uint8Array(await Ft(y.fullPath));
8180
+ const P = y.data ?? new Uint8Array(await Wt(y.fullPath));
8107
8181
  await this._blob.uploadRaw(
8108
8182
  I.blob_name,
8109
- O,
8183
+ P,
8110
8184
  I
8111
8185
  ), await this._queueFileLocation({
8112
8186
  relativePath: y.relativePath,
@@ -8142,7 +8216,7 @@ class wr {
8142
8216
  async _getOrCreateGraph(t, e) {
8143
8217
  const o = this._graphMap.get(t);
8144
8218
  if (o) return o;
8145
- const s = (await this._projects.getProject(t))?.projectSettings?.graph?.type ?? ur, a = s === "qlever" ? `${this._gatewayUrl}${Yt}` : `${this._gatewayUrl}${Xt}`, n = s === "qlever" ? `${this._gatewayUrl}${no}` : `${this._gatewayUrl}${ao}`, p = new Be({
8219
+ const s = (await this._projects.getProject(t))?.projectSettings?.graph?.type ?? mr, a = s === "qlever" ? `${this._gatewayUrl}${ee}` : `${this._gatewayUrl}${te}`, n = s === "qlever" ? `${this._gatewayUrl}${co}` : `${this._gatewayUrl}${po}`, p = new Ke({
8146
8220
  graphType: s,
8147
8221
  queryEndpoint: a,
8148
8222
  updateEndpoint: n,
@@ -8208,7 +8282,7 @@ WHERE {
8208
8282
  }
8209
8283
  async _initPendingBatch(t, e) {
8210
8284
  this._flushTimer !== null && (clearInterval(this._flushTimer), this._flushTimer = null), this._pendingSpaceId = t, this._pendingItems = [];
8211
- const o = await Bt(t);
8285
+ const o = await Vt(t);
8212
8286
  if (o && o.items.length > 0) {
8213
8287
  console.info(`Trying to upload metadata from interrupted sync (${o.items.length} item(s))...`), e && console.info(`Flushing ${o.items.length} pending file location(s) from previous sync ⏳`);
8214
8288
  try {
@@ -8229,7 +8303,7 @@ WHERE {
8229
8303
  typeof r == "object" && typeof r.unref == "function" && r.unref(), this._flushTimer = r;
8230
8304
  }
8231
8305
  async _queueFileLocation(t) {
8232
- this._pendingItems.push(t), this._pendingSpaceId && await Gt({ spaceId: this._pendingSpaceId, items: this._pendingItems });
8306
+ this._pendingItems.push(t), this._pendingSpaceId && await Kt({ spaceId: this._pendingSpaceId, items: this._pendingItems });
8233
8307
  }
8234
8308
  /**
8235
8309
  * Flush all queued file-location items to the commands API in a single batch.
@@ -8244,18 +8318,18 @@ WHERE {
8244
8318
  }
8245
8319
  async _flushBatch(t, e, o) {
8246
8320
  const r = [...t];
8247
- this._pendingSpaceId === e && (this._pendingItems = []), await mr(e);
8321
+ this._pendingSpaceId === e && (this._pendingItems = []), await wr(e);
8248
8322
  try {
8249
8323
  for (let s = 0; s < r.length; s += $)
8250
8324
  await this._postFssBatch(r.slice(s, s + $), e);
8251
8325
  o && console.info(`Wrote ${r.length} file location(s) to commands API ✅`);
8252
8326
  } catch (s) {
8253
8327
  const a = [...r, ...this._pendingItems];
8254
- throw this._pendingItems = a, await Gt({ spaceId: e, items: a }), s;
8328
+ throw this._pendingItems = a, await Kt({ spaceId: e, items: a }), s;
8255
8329
  }
8256
8330
  }
8257
8331
  async _postFssBatch(t, e) {
8258
- const o = this._legacy ? `${this._gatewayUrl}${xt}?blob=true` : `${this._gatewayUrl}${xt}`;
8332
+ const o = this._legacy ? `${this._gatewayUrl}${Tt}?blob=true` : `${this._gatewayUrl}${Tt}`;
8259
8333
  let r;
8260
8334
  try {
8261
8335
  r = await this._auth.authenticatedFetch(o, {
@@ -8285,14 +8359,14 @@ WHERE {
8285
8359
  * shown to the user before or after calling {@link sync}.
8286
8360
  */
8287
8361
  async scanCost(t) {
8288
- if (G || (G = gr()), await G, !q) throw new Error("WASM scan function not initialised");
8362
+ if (H || (H = ur()), await H, !q) throw new Error("WASM scan function not initialised");
8289
8363
  const e = 200, o = /* @__PURE__ */ new Map();
8290
8364
  for (let r = 0; r < t.length; r += e) {
8291
8365
  const s = t.slice(r, r + e), a = await Promise.all(
8292
8366
  s.map(async (p) => ({
8293
8367
  originalPath: p.relativePath,
8294
8368
  // Use pre-loaded data if available (browser), otherwise read from disk (Node.js).
8295
- data: p.data ?? new Uint8Array(await Ft(p.fullPath))
8369
+ data: p.data ?? new Uint8Array(await Wt(p.fullPath))
8296
8370
  }))
8297
8371
  ), n = q(a);
8298
8372
  for (const p of n) {
@@ -8352,7 +8426,7 @@ WHERE {
8352
8426
  const { spaceId: o, providerId: r, userId: s, signal: a, onProgress: n } = e;
8353
8427
  if (!t.data)
8354
8428
  throw new Error("syncBrowserFile requires file.data (Uint8Array). Read the file with File.arrayBuffer() first.");
8355
- const p = $t(t.relativePath, o, s, t.md5, r);
8429
+ const p = Ht(t.relativePath, o, s, t.md5, r);
8356
8430
  if (!p.blob_name) throw new Error(`blob_name missing for ${t.relativePath}`);
8357
8431
  await this._blob.uploadRaw(
8358
8432
  p.blob_name,
@@ -8396,7 +8470,7 @@ WHERE {
8396
8470
  s({ percent: a, syncCount: t, totalCount: e, syncSize: o, totalSize: r });
8397
8471
  }
8398
8472
  }
8399
- const Ht = {
8473
+ const Qt = {
8400
8474
  production: {
8401
8475
  gatewayUrl: "https://accessors-api-gateway-ueyeemwf2a-oa.a.run.app",
8402
8476
  tokenUrl: "https://accessors-api-gateway-ueyeemwf2a-oa.a.run.app/token",
@@ -8416,16 +8490,19 @@ const Ht = {
8416
8490
  firestoreEmulatorPort: 8080
8417
8491
  }
8418
8492
  };
8419
- class ae {
8493
+ class he {
8420
8494
  auth;
8421
8495
  api;
8422
8496
  projects;
8423
8497
  profile;
8424
8498
  privileges;
8425
8499
  cache;
8500
+ storage;
8426
8501
  _app;
8427
8502
  _endpoints;
8428
8503
  _isEmulator;
8504
+ _storageRaw;
8505
+ _storageProcessed;
8429
8506
  _gis = null;
8430
8507
  /**
8431
8508
  * Reactive GIS service. Lazily constructed on first access.
@@ -8439,7 +8516,7 @@ class ae {
8439
8516
  * ```
8440
8517
  */
8441
8518
  get gis() {
8442
- return this._gis || (this._gis = new Jo(
8519
+ return this._gis || (this._gis = new or(
8443
8520
  () => this.api.getAuthHeaders(),
8444
8521
  this._endpoints.gatewayUrl
8445
8522
  )), this._gis;
@@ -8448,22 +8525,22 @@ class ae {
8448
8525
  !t.apiKey && !t.appId && !t.measurementId && console.warn(
8449
8526
  "Using default SDK app settings. Contact QAECY for your own configuration for any production code."
8450
8527
  );
8451
- const o = t.apiKey ?? X.apiKey, r = t.appId ?? X.appId, s = t.measurementId ?? X.measurementId, a = t.environment ?? "production";
8452
- this._endpoints = { ...Ht[a], ...t.endpoints }, this._isEmulator = a === "emulator", this._app = ne().find((p) => p.name === "[DEFAULT]") ?? pe({
8528
+ const o = t.apiKey ?? Y.apiKey, r = t.appId ?? Y.appId, s = t.measurementId ?? Y.measurementId, a = t.environment ?? "production";
8529
+ this._endpoints = { ...Qt[a], ...t.endpoints }, this._isEmulator = a === "emulator", this._app = ge().find((p) => p.name === "[DEFAULT]") ?? ue({
8453
8530
  apiKey: o,
8454
8531
  appId: r,
8455
8532
  measurementId: s,
8456
- authDomain: `${bt}.firebaseapp.com`,
8457
- projectId: bt,
8458
- messagingSenderId: Ve
8459
- }), this.auth = new Tt(this._app, this._isEmulator, this._endpoints), this.projects = new Lt(this.auth, this._app, this._isEmulator, this._endpoints), this.api = this._buildApi(this.projects), this.profile = new qt(
8533
+ authDomain: `${vt}.firebaseapp.com`,
8534
+ projectId: vt,
8535
+ messagingSenderId: Ze
8536
+ }), this.auth = new Rt(this._app, this._isEmulator, this._endpoints), this.projects = new Mt(this.auth, this._app, this._isEmulator, this._endpoints), this._storageRaw = T(this._app, kt), this._storageProcessed = T(this._app, Et), this._isEmulator && (K(this._storageRaw, this._endpoints.storageEmulatorHost, this._endpoints.storageEmulatorPort), K(this._storageProcessed, this._endpoints.storageEmulatorHost, this._endpoints.storageEmulatorPort)), this.api = this._buildApi(this.projects), this.storage = new Pt(this._storageRaw, this._storageProcessed), this.profile = new zt(
8460
8537
  this.auth,
8461
8538
  this._app,
8462
8539
  this._isEmulator,
8463
8540
  this._endpoints.gatewayUrl
8464
- ), this.privileges = new Ut(this.auth.isSuperAdmin);
8465
- const n = S(this._app, _t);
8466
- this._isEmulator && de(n, this._endpoints.storageEmulatorHost, this._endpoints.storageEmulatorPort), this.cache = new zt(n);
8541
+ ), this.privileges = new Ft(this.auth.isSuperAdmin);
8542
+ const n = T(this._app, xt);
8543
+ this._isEmulator && K(n, this._endpoints.storageEmulatorHost, this._endpoints.storageEmulatorPort), this.cache = new Bt(n);
8467
8544
  }
8468
8545
  /**
8469
8546
  * Create a `Cue` instance from an already-initialized Firebase app.
@@ -8482,31 +8559,34 @@ class ae {
8482
8559
  * });
8483
8560
  */
8484
8561
  static fromApp(t, e = {}) {
8485
- const o = e.environment ?? "production", r = { ...Ht[o], ...e.endpoints }, s = new Tt(t, !1, r), a = new Lt(s, t, !1, r), n = S(t, Qe), p = S(t, Xe), c = S(t, Ze), h = S(t, Ye), d = S(t, Ke), g = S(t, _t), w = new Ge({
8562
+ const o = e.environment ?? "production", r = { ...Qt[o], ...e.endpoints }, s = new Rt(t, !1, r), a = new Mt(s, t, !1, r), n = T(t, kt), p = T(t, Et), c = T(t, eo), h = T(t, to), d = T(t, Je), g = T(t, xt), w = new Qe({
8486
8563
  storageRaw: n,
8487
8564
  storageProcessed: p,
8488
8565
  storagePublic: c,
8489
8566
  storageLogs: h,
8490
8567
  storageChatSessions: d,
8491
8568
  storagePersistence: g
8492
- }), u = new wr(s, a, w, r.gatewayUrl), f = new St(s, r.gatewayUrl, a, u);
8569
+ }), u = new fr(s, a, w, r.gatewayUrl), f = new Ot(s, r.gatewayUrl, a, u);
8493
8570
  u._bindApi(f);
8494
- const k = new qt(s, t, !1, r.gatewayUrl), m = Object.create(ae.prototype), E = new Ut(s.isSuperAdmin), C = new zt(g);
8571
+ const k = new zt(s, t, !1, r.gatewayUrl), m = Object.create(he.prototype), E = new Ft(s.isSuperAdmin), C = new Bt(g), v = new Pt(n, p);
8495
8572
  return Object.assign(m, {
8496
8573
  _app: t,
8497
8574
  _endpoints: r,
8498
8575
  _isEmulator: o === "emulator",
8576
+ _storageRaw: n,
8577
+ _storageProcessed: p,
8499
8578
  auth: s,
8500
8579
  api: f,
8501
8580
  projects: a,
8502
8581
  profile: k,
8503
8582
  privileges: E,
8504
- cache: C
8583
+ cache: C,
8584
+ storage: v
8505
8585
  }), m;
8506
8586
  }
8507
8587
  /** Override in subclasses to provide a custom CueApi (e.g. with sync). */
8508
8588
  _buildApi(t) {
8509
- return new St(this.auth, this._endpoints.gatewayUrl, t);
8589
+ return new Ot(this.auth, this._endpoints.gatewayUrl, t);
8510
8590
  }
8511
8591
  /** Convenience: get the current user's Firebase ID token */
8512
8592
  getToken(t = !1) {
@@ -8531,34 +8611,91 @@ class ae {
8531
8611
  get: (r) => this.cache.getQueryCache(t, r).then((s) => s?.results),
8532
8612
  set: (r, s) => this.cache.setQueryCache(t, r, { query: r, results: s })
8533
8613
  };
8534
- return new ir(this.api, t, { ...e, queryCache: o });
8614
+ return new nr(this.api, t, { ...e, queryCache: o });
8615
+ }
8616
+ /**
8617
+ * Creates a `CueProjectEntities` instance for the given project, with the
8618
+ * SDK query cache wired automatically.
8619
+ *
8620
+ * Prefer this over `new CueProjectEntities(cue.api, projectId)` — it avoids
8621
+ * the manual cache setup and keeps the instance bound to the correct API.
8622
+ *
8623
+ * @example
8624
+ * ```ts
8625
+ * const entities = cue.createProjectEntities('my-project');
8626
+ * entities.requestEntityData(['uuid1']);
8627
+ * const info = entities.entityInfoMap.get()['uuid1'];
8628
+ *
8629
+ * // Promise-based (no signal polling needed):
8630
+ * const graph = await entities.buildSummaryGraph('graph');
8631
+ * ```
8632
+ */
8633
+ createProjectEntities(t, e) {
8634
+ const o = e?.queryCache ?? {
8635
+ get: (r) => this.cache.getQueryCache(t, r).then((s) => s?.results),
8636
+ set: (r, s) => this.cache.setQueryCache(t, r, { query: r, results: s })
8637
+ };
8638
+ return new le(
8639
+ this.api,
8640
+ t,
8641
+ e?.rdfBase,
8642
+ o,
8643
+ e?.graphType
8644
+ );
8645
+ }
8646
+ /**
8647
+ * Creates a `CueProjectDocuments` instance for the given project, with the
8648
+ * SDK query cache wired automatically.
8649
+ *
8650
+ * Prefer this over `new CueProjectDocuments(cue.api, projectId)` — it avoids
8651
+ * the manual cache setup and keeps the instance bound to the correct API.
8652
+ *
8653
+ * @example
8654
+ * ```ts
8655
+ * const docs = cue.createProjectDocuments('my-project');
8656
+ * await docs.fetchOverview();
8657
+ * const data = await docs.fetchDocumentData(['uuid1', 'uuid2']);
8658
+ * ```
8659
+ */
8660
+ createProjectDocuments(t, e) {
8661
+ const o = e?.queryCache ?? {
8662
+ get: (r) => this.cache.getQueryCache(t, r).then((s) => s?.results),
8663
+ set: (r, s) => this.cache.setQueryCache(t, r, { query: r, results: s })
8664
+ };
8665
+ return new ce(
8666
+ this.api,
8667
+ t,
8668
+ e?.language,
8669
+ e?.rdfBase,
8670
+ o,
8671
+ e?.graphType
8672
+ );
8535
8673
  }
8536
8674
  }
8537
8675
  export {
8538
- Ke as B,
8539
- ae as C,
8540
- Mt as R,
8541
- St as a,
8542
- Tt as b,
8543
- zt as c,
8544
- Jo as d,
8545
- Ut as e,
8546
- qt as f,
8547
- ar as g,
8548
- sr as h,
8549
- or as i,
8550
- ir as j,
8551
- Lt as k,
8676
+ Je as B,
8677
+ he as C,
8678
+ $t as R,
8679
+ Ot as a,
8680
+ Rt as b,
8681
+ Bt as c,
8682
+ or as d,
8683
+ Ft as e,
8684
+ zt as f,
8685
+ ce as g,
8686
+ le as h,
8687
+ ar as i,
8688
+ nr as j,
8689
+ Mt as k,
8552
8690
  x as l,
8553
- wr as m,
8554
- ho as n,
8555
- Rr as o,
8556
- pt as p,
8557
- Ye as q,
8558
- Qe as r,
8559
- lt as s,
8560
- _t as t,
8561
- Xe as u,
8562
- Ze as v,
8563
- Ge as w
8691
+ Pt as m,
8692
+ fr as n,
8693
+ mo as o,
8694
+ Pr as p,
8695
+ lt as q,
8696
+ to as r,
8697
+ ct as s,
8698
+ xt as t,
8699
+ eo as u,
8700
+ Qe as v
8564
8701
  };