@qaecy/cue-sdk 0.0.24 → 0.0.26

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.
@@ -587,7 +587,7 @@ function Je(i, t = !1) {
587
587
  function to(i, t = "") {
588
588
  return D(`${t}${i}`);
589
589
  }
590
- class x {
590
+ class k {
591
591
  _value;
592
592
  _listeners = /* @__PURE__ */ new Set();
593
593
  constructor(t) {
@@ -646,13 +646,13 @@ const Y = {
646
646
  apiKey: "AIzaSyAiW42QBx9HS4Khu88pCW7MV66IhBAQul0",
647
647
  appId: "1:151132927589:web:d2ffdb377dfadfd23ab88c",
648
648
  measurementId: "G-YT4PK6HGZD"
649
- }, kt = "qaecy-mvp-406413", eo = "734737865998", se = "europe-west6", Et = "projects", xt = "spaces_chats_eu_west6", It = "spaces_raw_eu_west6", Ct = "spaces_processed_eu_west6", Tt = "spaces_logs_eu_west6", St = "cue_public_eu_west6", Rt = "db_persistence_eu_west6", oo = "/data-views/admin/consumption", ro = "/data-views/admin/profile/organizations", At = "/data-views/admin/profile/api-keys", Pt = "/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", ae = "/triplestore/query", po = "/triplestore/update", lo = "/triplestore/shacl", ie = "/qlever-server/qlever/query", co = "/qlever-server/qlever/update", ho = "/qlever-server/qlever/shacl", Ot = "/commands/file-system-structure/batch", Dt = "microsoft.com", Lt = "superadmin", dt = "https://cue.qaecy.com/r/";
649
+ }, kt = "qaecy-mvp-406413", eo = "734737865998", se = "europe-west6", Et = "projects", xt = "spaces_chats_eu_west6", It = "spaces_raw_eu_west6", Ct = "spaces_processed_eu_west6", Tt = "spaces_logs_eu_west6", St = "cue_public_eu_west6", Rt = "db_persistence_eu_west6", oo = "/data-views/admin/consumption", ro = "/data-views/admin/profile/organizations", At = "/data-views/admin/profile/api-keys", Pt = "/commands/admin/profile/api-keys", so = "/commands/admin/profile/terms", ao = (i) => `/data-views/admin/organizations/${i}/members`, io = "/commands/admin/project", no = (i) => `/commands/admin/project/${i}`, po = "/assistant/search", ae = "/triplestore/query", lo = "/triplestore/update", co = "/triplestore/shacl", ie = "/qlever-server/qlever/query", ho = "/qlever-server/qlever/update", go = "/qlever-server/qlever/shacl", Ot = "/commands/file-system-structure/batch", Dt = "microsoft.com", Lt = "superadmin", dt = "https://cue.qaecy.com/r/";
650
650
  class qt {
651
651
  _auth;
652
652
  _endpoints;
653
- _userSignal = new x(null);
654
- _tokenSignal = new x(null);
655
- _isSuperAdminSignal = new x(!1);
653
+ _userSignal = new k(null);
654
+ _tokenSignal = new k(null);
655
+ _isSuperAdminSignal = new k(!1);
656
656
  _userIdsSignal;
657
657
  _stopTokenListener;
658
658
  /** Reactive auth state — emits the signed-in `User`, or `null` when signed out. */
@@ -837,8 +837,8 @@ class jt {
837
837
  return e;
838
838
  }
839
839
  }
840
- const go = "/data-views/tables", uo = "/commands/tables";
841
- class mo {
840
+ const uo = "/data-views/tables", mo = "/commands/tables";
841
+ class wo {
842
842
  constructor(t, e) {
843
843
  this._auth = t, this._gatewayUrl = e;
844
844
  }
@@ -846,7 +846,7 @@ class mo {
846
846
  _gatewayUrl;
847
847
  async listTables(t) {
848
848
  const e = await this._auth.authenticatedFetch(
849
- `${this._gatewayUrl}${go}`,
849
+ `${this._gatewayUrl}${uo}`,
850
850
  {
851
851
  headers: {
852
852
  "Content-Type": "application/json",
@@ -861,7 +861,7 @@ class mo {
861
861
  }
862
862
  async saveTables(t, e) {
863
863
  const o = await this._auth.authenticatedFetch(
864
- `${this._gatewayUrl}${uo}`,
864
+ `${this._gatewayUrl}${mo}`,
865
865
  {
866
866
  method: "PUT",
867
867
  headers: {
@@ -878,7 +878,7 @@ class mo {
878
878
  }
879
879
  class Ut {
880
880
  constructor(t, e, o, r) {
881
- this._auth = t, this._gatewayUrl = e, this.projects = o, this.sync = r, this.tables = new mo(t, e);
881
+ this._auth = t, this._gatewayUrl = e, this.projects = o, this.sync = r, this.tables = new wo(t, e);
882
882
  }
883
883
  _auth;
884
884
  _gatewayUrl;
@@ -910,7 +910,7 @@ class Ut {
910
910
  */
911
911
  async search(t) {
912
912
  const e = await this._auth.authenticatedFetch(
913
- `${this._gatewayUrl}${no}`,
913
+ `${this._gatewayUrl}${po}`,
914
914
  {
915
915
  method: "POST",
916
916
  headers: { "Content-Type": "application/json", "cue-project-id": t.projectId },
@@ -970,7 +970,7 @@ class Ut {
970
970
  const r = o?.format ?? "json-ld", s = r === "turtle" ? "text/turtle" : "application/ld+json";
971
971
  if (o?.graphType === "fuseki") {
972
972
  const c = await this._auth.authenticatedFetch(
973
- `${this._gatewayUrl}${lo}`,
973
+ `${this._gatewayUrl}${co}`,
974
974
  {
975
975
  method: "POST",
976
976
  headers: {
@@ -988,7 +988,7 @@ class Ut {
988
988
  }
989
989
  return r === "turtle" ? c.text() : c.json();
990
990
  }
991
- const a = `${this._gatewayUrl}${ho}${o?.verbose ? "?verbose=true" : ""}`, n = new URLSearchParams({ shape: t }), p = await this._auth.authenticatedFetch(a, {
991
+ const a = `${this._gatewayUrl}${go}${o?.verbose ? "?verbose=true" : ""}`, n = new URLSearchParams({ shape: t }), p = await this._auth.authenticatedFetch(a, {
992
992
  method: "POST",
993
993
  headers: {
994
994
  "Content-Type": "application/x-www-form-urlencoded",
@@ -1039,7 +1039,7 @@ const nt = [
1039
1039
  "railway",
1040
1040
  "natural",
1041
1041
  "manmade"
1042
- ], wo = {
1042
+ ], fo = {
1043
1043
  address: {
1044
1044
  category: "address",
1045
1045
  label: "Address",
@@ -1102,9 +1102,9 @@ const nt = [
1102
1102
  }
1103
1103
  };
1104
1104
  function S(i) {
1105
- return wo[i];
1105
+ return fo[i];
1106
1106
  }
1107
- const fo = {
1107
+ const yo = {
1108
1108
  "land-use-plan": "#f59e0b",
1109
1109
  // amber – primary zoning
1110
1110
  "local-plan": "#ec4899",
@@ -1135,7 +1135,7 @@ const fo = {
1135
1135
  function N(i, t) {
1136
1136
  return i[0] < t[2] && i[2] > t[0] && i[1] < t[3] && i[3] > t[1];
1137
1137
  }
1138
- const yo = "https://nominatim.openstreetmap.org", bo = "cue-gis/0.0.1", vo = {
1138
+ const bo = "https://nominatim.openstreetmap.org", vo = "cue-gis/0.0.1", _o = {
1139
1139
  address: "street",
1140
1140
  poi: "shop",
1141
1141
  railway: "station",
@@ -1150,7 +1150,7 @@ const yo = "https://nominatim.openstreetmap.org", bo = "cue-gis/0.0.1", vo = {
1150
1150
  function B(i) {
1151
1151
  return `${L}:${i}`;
1152
1152
  }
1153
- function _o(i) {
1153
+ function ko(i) {
1154
1154
  const t = S(i);
1155
1155
  return {
1156
1156
  id: B(i),
@@ -1165,13 +1165,13 @@ function _o(i) {
1165
1165
  descriptionKey: `gis.layer.${L}.${i}.description`
1166
1166
  };
1167
1167
  }
1168
- class ko {
1168
+ class Eo {
1169
1169
  baseUrl;
1170
1170
  userAgent;
1171
1171
  email;
1172
1172
  limit;
1173
1173
  constructor(t = {}) {
1174
- this.baseUrl = t.baseUrl ?? yo, this.userAgent = t.userAgent ?? bo, this.email = t.email, this.limit = Math.min(t.limit ?? 40, 40);
1174
+ this.baseUrl = t.baseUrl ?? bo, this.userAgent = t.userAgent ?? vo, this.email = t.email, this.limit = Math.min(t.limit ?? 40, 40);
1175
1175
  }
1176
1176
  async listFeatureCategoryDescriptors(t) {
1177
1177
  return (await Promise.allSettled(
@@ -1184,7 +1184,7 @@ class ko {
1184
1184
  ).map((o) => S(o.value.category));
1185
1185
  }
1186
1186
  async listAvailableLayers(t) {
1187
- return (await this.listFeatureCategoryDescriptors(t)).map((o) => _o(o.category));
1187
+ return (await this.listFeatureCategoryDescriptors(t)).map((o) => ko(o.category));
1188
1188
  }
1189
1189
  async getFeaturesForLayer(t, e) {
1190
1190
  const o = nt.find((r) => B(r) === e);
@@ -1201,7 +1201,7 @@ class ko {
1201
1201
  * so bounded viewbox searches return meaningful results.
1202
1202
  */
1203
1203
  async search(t, e) {
1204
- const [o, r, s, a] = t, n = e ? vo[e] : "place", p = new URLSearchParams({
1204
+ const [o, r, s, a] = t, n = e ? _o[e] : "place", p = new URLSearchParams({
1205
1205
  q: n,
1206
1206
  format: "jsonv2",
1207
1207
  viewbox: `${o},${a},${s},${r}`,
@@ -1353,7 +1353,7 @@ const Mt = {
1353
1353
  1281: "infrastructure",
1354
1354
  1282: "infrastructure",
1355
1355
  9999: "other"
1356
- }, Eo = {
1356
+ }, xo = {
1357
1357
  // Residential
1358
1358
  1110: "residential",
1359
1359
  // Einfamilienhaus
@@ -1415,7 +1415,7 @@ const Mt = {
1415
1415
  // Empfangsgebäude Bahn/Bus
1416
1416
  1282: "infrastructure"
1417
1417
  // Parkhaus, Garage
1418
- }, xo = [
1418
+ }, Io = [
1419
1419
  // "Gebäude" is the Swiss AV BoFlaeche land-cover label for a building footprint.
1420
1420
  // It does not encode the actual use type, so map it to 'other' as a safe fallback.
1421
1421
  [/^geb[äa]ude$/i, "other"],
@@ -1429,22 +1429,22 @@ const Mt = {
1429
1429
  [/gemischt|mixed|blandet/i, "mixed"]
1430
1430
  ];
1431
1431
  function O(i) {
1432
- for (const [t, e] of xo)
1432
+ for (const [t, e] of Io)
1433
1433
  if (t.test(i)) return e;
1434
1434
  }
1435
- function Io(i, t) {
1435
+ function Co(i, t) {
1436
1436
  if (i == null) return;
1437
1437
  const e = String(i).trim();
1438
- return t === "swiss-gwr" ? Eo[e] ?? O(e) : t === "danish-matrikel" ? Mt[e] ?? O(e) : t === "zurich-wfs" || t === "swiss-av-wfs" ? zt[e] ?? O(e) : zt[e] ?? Mt[e] ?? O(e);
1438
+ return t === "swiss-gwr" ? xo[e] ?? O(e) : t === "danish-matrikel" ? Mt[e] ?? O(e) : t === "zurich-wfs" || t === "swiss-av-wfs" ? zt[e] ?? O(e) : zt[e] ?? Mt[e] ?? O(e);
1439
1439
  }
1440
- function Co(i, t) {
1440
+ function To(i, t) {
1441
1441
  if (i != null)
1442
1442
  return O(String(i).trim());
1443
1443
  }
1444
1444
  function pe(i) {
1445
1445
  return i.trim().toLowerCase().replace(/[\s_\-]/g, "");
1446
1446
  }
1447
- const To = {
1447
+ const So = {
1448
1448
  // Swiss ÖREB rechtsstatus
1449
1449
  inkraft: "in-force",
1450
1450
  laufendeanderung: "amendment-pending",
@@ -1465,7 +1465,7 @@ const To = {
1465
1465
  };
1466
1466
  function le(i) {
1467
1467
  if (i)
1468
- return To[pe(i)];
1468
+ return So[pe(i)];
1469
1469
  }
1470
1470
  const Nt = {
1471
1471
  // Swiss Nutzungsplanung (typ_gde_bezeichnung and common variants)
@@ -1521,7 +1521,7 @@ const Nt = {
1521
1521
  // Danish plandata.dk
1522
1522
  lokalplan: "local-plan",
1523
1523
  kommuneplanramme: "municipal-plan-framework"
1524
- }, So = [
1524
+ }, Ro = [
1525
1525
  [/quartiererhalt/i, "neighbourhood-conservation-plan"],
1526
1526
  [/lärmempfindlich|laermempfindlich/i, "noise-sensitivity-plan"],
1527
1527
  [/gewässerschutz|grundwasserschutz/i, "water-protection-plan"],
@@ -1565,20 +1565,20 @@ function ce(i) {
1565
1565
  if (!i) return;
1566
1566
  const t = pe(i);
1567
1567
  if (t in Nt) return Nt[t];
1568
- for (const [e, o] of So)
1568
+ for (const [e, o] of Ro)
1569
1569
  if (e.test(i)) return o;
1570
1570
  console.warn(
1571
1571
  `[cue-gis] Unknown zone plan type — add "${i}" to classifyZonePlanType: no ZonePlanType mapping found.`
1572
1572
  );
1573
1573
  }
1574
- const Ro = "https://maps.zh.ch/wfs/OGDZHWFS", Ao = "zurich-wfs", Po = [8.35, 47.15, 8.95, 47.7], Oo = [5.9, 45.7, 10.55, 47.85];
1574
+ const Ao = "https://maps.zh.ch/wfs/OGDZHWFS", Po = "zurich-wfs", Oo = [8.35, 47.15, 8.95, 47.7], Do = [5.9, 45.7, 10.55, 47.85];
1575
1575
  function Z(i) {
1576
1576
  return typeof i == "string" ? i : i.typeName;
1577
1577
  }
1578
1578
  function J(i) {
1579
1579
  return typeof i == "string" ? void 0 : i.cqlFilter;
1580
1580
  }
1581
- function Do(i) {
1581
+ function Lo(i) {
1582
1582
  if (!i) return [0, 0];
1583
1583
  const t = i.coordinates;
1584
1584
  switch (i.type) {
@@ -1596,20 +1596,20 @@ function Do(i) {
1596
1596
  return [0, 0];
1597
1597
  }
1598
1598
  }
1599
- function Lo(i, t) {
1599
+ function qo(i, t) {
1600
1600
  if (!i) return t;
1601
1601
  for (const e of ["plannavn", "bezeichnung", "name", "strassenname", "objektname", "title", "label"])
1602
1602
  if (typeof i[e] == "string" && i[e]) return i[e];
1603
1603
  return t;
1604
1604
  }
1605
- function qo(i, t, e) {
1605
+ function jo(i, t, e) {
1606
1606
  return e ? `${i}:${t}[${e}]` : `${i}:${t}`;
1607
1607
  }
1608
- const jo = /* @__PURE__ */ new Set(["building", "cadastre", "greenspace", "paved", "zone"]);
1608
+ const Uo = /* @__PURE__ */ new Set(["building", "cadastre", "greenspace", "paved", "zone"]);
1609
1609
  function tt(i, t, e, o) {
1610
- const r = e.replace(/^ms:/, ""), s = S(t), a = jo.has(t) ? "priority" : "raw";
1610
+ const r = e.replace(/^ms:/, ""), s = S(t), a = Uo.has(t) ? "priority" : "raw";
1611
1611
  return {
1612
- id: qo(i, e, o),
1612
+ id: jo(i, e, o),
1613
1613
  sourceId: i,
1614
1614
  sourceLayerId: e,
1615
1615
  category: t,
@@ -1621,32 +1621,32 @@ function tt(i, t, e, o) {
1621
1621
  descriptionKey: `gis.layer.${i}.${r}.description`
1622
1622
  };
1623
1623
  }
1624
- function Uo(i, t) {
1624
+ function Mo(i, t) {
1625
1625
  if (!i) return { featureType: "building" };
1626
1626
  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;
1627
1627
  return {
1628
1628
  featureType: "building",
1629
1629
  areaM2: typeof e == "number" ? e : void 0,
1630
1630
  buildingUse: r ? String(r) : void 0,
1631
- buildingUseGeneric: Io(r, t),
1631
+ buildingUseGeneric: Co(r, t),
1632
1632
  floors: typeof o == "number" ? o : void 0,
1633
1633
  yearBuilt: typeof s == "number" ? s : void 0,
1634
1634
  registryId: a
1635
1635
  };
1636
1636
  }
1637
- function Mo(i, t) {
1637
+ function zo(i, t) {
1638
1638
  if (!i) return { featureType: "plot" };
1639
1639
  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;
1640
1640
  return {
1641
1641
  featureType: "plot",
1642
1642
  areaM2: typeof a == "number" ? a : void 0,
1643
1643
  plotUse: n ? String(n) : void 0,
1644
- plotUseGeneric: Co(n),
1644
+ plotUseGeneric: To(n),
1645
1645
  plotId: s,
1646
1646
  registryId: e
1647
1647
  };
1648
1648
  }
1649
- function zo(i) {
1649
+ function No(i) {
1650
1650
  if (!i) return { featureType: "greenspace" };
1651
1651
  const t = i.flaeche ?? void 0, e = i.art ?? void 0;
1652
1652
  return {
@@ -1655,7 +1655,7 @@ function zo(i) {
1655
1655
  surfaceType: e ? String(e) : void 0
1656
1656
  };
1657
1657
  }
1658
- function No(i) {
1658
+ function $o(i) {
1659
1659
  if (!i) return { featureType: "paved" };
1660
1660
  const t = i.flaeche ?? void 0, e = i.art ?? void 0;
1661
1661
  return {
@@ -1664,7 +1664,7 @@ function No(i) {
1664
1664
  surfaceType: e ? String(e) : void 0
1665
1665
  };
1666
1666
  }
1667
- function $o(i) {
1667
+ function Fo(i) {
1668
1668
  if (!i) return { featureType: "zone" };
1669
1669
  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 = le(r), a = i.typ_gde_bezeichnung ?? void 0, n = ce(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;
1670
1670
  return {
@@ -1682,7 +1682,7 @@ function $o(i) {
1682
1682
  areaM2: typeof w == "number" ? w : void 0
1683
1683
  };
1684
1684
  }
1685
- function Fo(i) {
1685
+ function Bo(i) {
1686
1686
  const t = i.match(/^(\w+)\s*=\s*'([^']+)'$/);
1687
1687
  if (t) {
1688
1688
  const [, o, r] = t;
@@ -1703,7 +1703,7 @@ class et {
1703
1703
  sourceId;
1704
1704
  outputFormat;
1705
1705
  constructor(t) {
1706
- this.categoryMap = t.categoryMap, this.baseUrl = t.baseUrl ?? Ro, this.sourceId = t.sourceId ?? Ao, this.outputFormat = t.outputFormat ?? "application/json; subtype=geojson";
1706
+ this.categoryMap = t.categoryMap, this.baseUrl = t.baseUrl ?? Ao, this.sourceId = t.sourceId ?? Po, this.outputFormat = t.outputFormat ?? "application/json; subtype=geojson";
1707
1707
  }
1708
1708
  async listFeatureCategoryDescriptors(t) {
1709
1709
  const e = await this.listAvailableLayers(t);
@@ -1727,7 +1727,7 @@ class et {
1727
1727
  return o ? this._fetchAndConvert(t, o.descriptor, o.cqlFilter) : [];
1728
1728
  }
1729
1729
  async _fetchAndConvert(t, e, o) {
1730
- const r = await this._fetchFeatures(t, e.sourceLayerId, void 0, o), s = o ? Fo(o) : void 0;
1730
+ const r = await this._fetchFeatures(t, e.sourceLayerId, void 0, o), s = o ? Bo(o) : void 0;
1731
1731
  return (s ? r.features.filter((n) => s(n.properties)) : r.features).map((n, p) => this.toGisFeature(n, e, p));
1732
1732
  }
1733
1733
  /**
@@ -1776,7 +1776,7 @@ class et {
1776
1776
  return g.json();
1777
1777
  }
1778
1778
  toGisFeature(t, e, o) {
1779
- 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;
1779
+ const [r, s] = Lo(t.geometry), a = qo(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;
1780
1780
  return {
1781
1781
  id: t.id ?? `${e.sourceLayerId}/${o}`,
1782
1782
  preferredColor: e.preferredColor,
@@ -1797,7 +1797,7 @@ class et {
1797
1797
  };
1798
1798
  }
1799
1799
  _extractNormalisedProperties(t, e) {
1800
- 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);
1800
+ return e.category === "building" ? Mo(t.properties, this.sourceId) : e.category === "greenspace" ? No(t.properties) : e.category === "paved" ? $o(t.properties) : e.category === "zone" ? Fo(t.properties) : zo(t.properties, this.sourceId);
1801
1801
  }
1802
1802
  }
1803
1803
  const he = [8, 54.5, 15.2, 57.8], de = {
@@ -1809,7 +1809,7 @@ const he = [8, 54.5, 15.2, 57.8], de = {
1809
1809
  { source: "danish-matrikel", typename: "mat_v001:samletfastejendom_current" }
1810
1810
  ]
1811
1811
  };
1812
- function Bo(i) {
1812
+ function Go(i) {
1813
1813
  if (!i) return [0, 0];
1814
1814
  const t = i.coordinates;
1815
1815
  switch (i.type) {
@@ -1827,7 +1827,7 @@ function Bo(i) {
1827
1827
  return [0, 0];
1828
1828
  }
1829
1829
  }
1830
- function Go(i, t) {
1830
+ function Ho(i, t) {
1831
1831
  if (!i) return t;
1832
1832
  for (const e of [
1833
1833
  "mat:matrikelnummer",
@@ -1843,14 +1843,14 @@ function Go(i, t) {
1843
1843
  if (typeof i[e] == "string" && i[e]) return i[e];
1844
1844
  return t;
1845
1845
  }
1846
- function Ho(i, t, e) {
1846
+ function Wo(i, t, e) {
1847
1847
  return `${i}:${t}:${e}`;
1848
1848
  }
1849
- const Wo = /* @__PURE__ */ new Set(["building", "cadastre", "zone"]);
1849
+ const Vo = /* @__PURE__ */ new Set(["building", "cadastre", "zone"]);
1850
1850
  function ot(i, t, e) {
1851
- const o = e.typename.replace(/^[^:]+:/, ""), r = S(t), s = Wo.has(t) ? "priority" : "raw";
1851
+ const o = e.typename.replace(/^[^:]+:/, ""), r = S(t), s = Vo.has(t) ? "priority" : "raw";
1852
1852
  return {
1853
- id: Ho(i, e.source, e.typename),
1853
+ id: Wo(i, e.source, e.typename),
1854
1854
  sourceId: i,
1855
1855
  sourceLayerId: e.typename,
1856
1856
  category: t,
@@ -1862,7 +1862,7 @@ function ot(i, t, e) {
1862
1862
  descriptionKey: `gis.layer.${i}.${e.source}.${o}.description`
1863
1863
  };
1864
1864
  }
1865
- function Vo(i, t) {
1865
+ function Ko(i, t) {
1866
1866
  if (t === "building") {
1867
1867
  const a = i?.byg041BebyggetAreal ?? i?.byg038SamletBygningsareal, n = i?.byg021BygningensAnvendelse, p = i?.id_lokalId, c = i?.byg026Opførelsesår;
1868
1868
  return {
@@ -1898,7 +1898,7 @@ function Vo(i, t) {
1898
1898
  registryId: s ?? void 0
1899
1899
  };
1900
1900
  }
1901
- class Ko {
1901
+ class Qo {
1902
1902
  categoryMap;
1903
1903
  dataViewsBaseUrl;
1904
1904
  getHeaders;
@@ -1967,7 +1967,7 @@ class Ko {
1967
1967
  return d.json();
1968
1968
  }
1969
1969
  _toGisFeature(t, e, o) {
1970
- 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;
1970
+ const [r, s] = Go(t.geometry), a = t.id ?? `${e.sourceLayerId}/${o}`, n = Ho(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" ? Ko(t.properties, e.category) : void 0;
1971
1971
  return {
1972
1972
  id: a,
1973
1973
  sourceId: this.sourceId,
@@ -1988,7 +1988,7 @@ class Ko {
1988
1988
  };
1989
1989
  }
1990
1990
  }
1991
- const Qo = {
1991
+ const Xo = {
1992
1992
  address: [
1993
1993
  "ms:ogd-0406_arv_basis_avzh_hausnummer_pos_p",
1994
1994
  "ms:ogd-0571_afv_gv_strat_strassennetz_l"
@@ -2039,16 +2039,16 @@ const Qo = {
2039
2039
  }, ge = [
2040
2040
  {
2041
2041
  name: "Canton of Zürich",
2042
- coverageBBox: Po,
2042
+ coverageBBox: Oo,
2043
2043
  supportedCategories: ["address", "poi", "railway", "natural", "manmade", "building", "cadastre", "greenspace", "paved", "zone"],
2044
2044
  priority: 10,
2045
2045
  adapter: new et({
2046
- categoryMap: Qo
2046
+ categoryMap: Xo
2047
2047
  })
2048
2048
  },
2049
2049
  {
2050
2050
  name: "Switzerland (national AV cadastre)",
2051
- coverageBBox: Oo,
2051
+ coverageBBox: Do,
2052
2052
  supportedCategories: ["cadastre"],
2053
2053
  priority: 5,
2054
2054
  // Lower priority than canton-specific adapters. For ZH, the canton adapter (priority 10) wins.
@@ -2099,7 +2099,7 @@ function $t(i) {
2099
2099
  (t, e) => nt.indexOf(t.category) - nt.indexOf(e.category)
2100
2100
  );
2101
2101
  }
2102
- class Xo {
2102
+ class Yo {
2103
2103
  nominatim;
2104
2104
  regions;
2105
2105
  /**
@@ -2114,9 +2114,9 @@ class Xo {
2114
2114
  zonePlanTypeColors: r,
2115
2115
  ...s
2116
2116
  } = t;
2117
- this.nominatim = new ko(s);
2117
+ this.nominatim = new Eo(s);
2118
2118
  const a = o ? ge : [];
2119
- this.regions = e ?? a, this.zonePlanTypeColors = { ...fo, ...r };
2119
+ this.regions = e ?? a, this.zonePlanTypeColors = { ...yo, ...r };
2120
2120
  }
2121
2121
  /**
2122
2122
  * Return the available feature categories together with UI metadata such as
@@ -2247,7 +2247,7 @@ class Xo {
2247
2247
  ), a = [], n = [];
2248
2248
  for (const d of s)
2249
2249
  d.status === "fulfilled" && (d.value.isNominatim ? n.push(...d.value.features) : a.push(...d.value.features));
2250
- const p = Jo(a, n), c = /* @__PURE__ */ new Map(), h = [];
2250
+ const p = tr(a, n), c = /* @__PURE__ */ new Map(), h = [];
2251
2251
  for (const d of p) {
2252
2252
  const g = Ft(d), w = W(d), u = c.get(g);
2253
2253
  (u === void 0 || w > u) && (c.set(g, w), h.push(d));
@@ -2271,18 +2271,18 @@ function Ft(i) {
2271
2271
  const t = Math.round(i.lat * 1e3) / 1e3, e = Math.round(i.lon * 1e3) / 1e3;
2272
2272
  return `${(i.name ?? i.id ?? "").toLowerCase().trim()}|${t}|${e}`;
2273
2273
  }
2274
- const Yo = 1e-3;
2275
- function Zo(i, t) {
2274
+ const Zo = 1e-3;
2275
+ function Jo(i, t) {
2276
2276
  const e = i.lat - t.lat, o = i.lon - t.lon;
2277
2277
  return Math.sqrt(e * e + o * o);
2278
2278
  }
2279
- function Jo(i, t) {
2279
+ function tr(i, t) {
2280
2280
  if (t.length === 0) return i;
2281
2281
  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 = [];
2282
2282
  for (const a of t) {
2283
- let n = -1, p = Yo;
2283
+ let n = -1, p = Zo;
2284
2284
  for (let c = 0; c < r.length; c++) {
2285
- const h = Zo(a, r[c].feature);
2285
+ const h = Jo(a, r[c].feature);
2286
2286
  h < p && (p = h, n = c);
2287
2287
  }
2288
2288
  n >= 0 ? (r[n].feature.originalData = {
@@ -2296,8 +2296,8 @@ function Jo(i, t) {
2296
2296
  ...s
2297
2297
  ];
2298
2298
  }
2299
- const tr = "/data-views", er = 1500;
2300
- class or {
2299
+ const er = "/data-views", or = 1500;
2300
+ class rr {
2301
2301
  // undefined = not yet built
2302
2302
  /** @internal — construct via `cue.gis`, not directly. */
2303
2303
  constructor(t, e) {
@@ -2380,7 +2380,7 @@ class or {
2380
2380
  }
2381
2381
  // ── Private ───────────────────────────────────────────────────────────────
2382
2382
  _scheduleDebouncedQuery() {
2383
- this._debounceTimer !== null && clearTimeout(this._debounceTimer), this._debounceTimer = setTimeout(() => this._queryLayers(), er);
2383
+ this._debounceTimer !== null && clearTimeout(this._debounceTimer), this._debounceTimer = setTimeout(() => this._queryLayers(), or);
2384
2384
  }
2385
2385
  _getGateway() {
2386
2386
  if (this._gatewayCache !== null && this._gatewayProjectId === this._projectId)
@@ -2391,14 +2391,14 @@ class or {
2391
2391
  coverageBBox: he,
2392
2392
  supportedCategories: Object.keys(de),
2393
2393
  priority: 10,
2394
- adapter: new Ko({
2395
- dataViewsBaseUrl: `${this._gatewayUrl}${tr}`,
2394
+ adapter: new Qo({
2395
+ dataViewsBaseUrl: `${this._gatewayUrl}${er}`,
2396
2396
  getHeaders: async () => ({
2397
2397
  ...await this._getAuthHeaders(),
2398
2398
  "x-project-id": t
2399
2399
  })
2400
2400
  })
2401
- }), this._gatewayCache = new Xo({ regions: e }), this._gatewayProjectId = t, this._gatewayCache;
2401
+ }), this._gatewayCache = new Yo({ regions: e }), this._gatewayProjectId = t, this._gatewayCache;
2402
2402
  }
2403
2403
  async _queryLayers() {
2404
2404
  const t = this._bbox;
@@ -2514,6 +2514,19 @@ class Bt {
2514
2514
  async removeUserFromProject(t, e) {
2515
2515
  await F(this._functions, "removeUserFromProject")({ uid: t, spaceId: e });
2516
2516
  }
2517
+ /**
2518
+ * Delete a project by ID. Requires superadmin privileges on the server.
2519
+ */
2520
+ async deleteProject(t) {
2521
+ const e = await this._auth.authenticatedFetch(
2522
+ `${this._gatewayUrl}${no(t)}`,
2523
+ { method: "DELETE" }
2524
+ );
2525
+ if (!e.ok) {
2526
+ const o = await e.text().catch(() => "");
2527
+ throw new Error(`Failed to delete project: ${e.status} ${e.statusText}${o ? ` — ${o}` : ""}`);
2528
+ }
2529
+ }
2517
2530
  }
2518
2531
  class Gt {
2519
2532
  constructor(t, e, o, r) {
@@ -2653,6 +2666,7 @@ const Ht = ["superadmin", "admin", "syncer", "member"], Wt = {
2653
2666
  createProvider: "superadmin",
2654
2667
  changeContentCategories: "syncer",
2655
2668
  deleteDocuments: "superadmin",
2669
+ deleteProject: "admin",
2656
2670
  deleteUserFromProject: "admin",
2657
2671
  downloadDocuments: "member",
2658
2672
  editContentCategories: "syncer",
@@ -2663,12 +2677,14 @@ const Ht = ["superadmin", "admin", "syncer", "member"], Wt = {
2663
2677
  uploadDocuments: "syncer",
2664
2678
  viewEntities: "member"
2665
2679
  };
2666
- function rr() {
2680
+ function sr() {
2667
2681
  return {
2668
2682
  changeContentCategories: !1,
2669
2683
  createEntities: !1,
2684
+ createProject: !1,
2670
2685
  createProvider: !1,
2671
2686
  deleteDocuments: !1,
2687
+ deleteProject: !1,
2672
2688
  deleteUserFromProject: !1,
2673
2689
  downloadDocuments: !1,
2674
2690
  editContentCategories: !1,
@@ -2682,19 +2698,29 @@ function rr() {
2682
2698
  }
2683
2699
  class Vt {
2684
2700
  constructor(t) {
2685
- this._isSuperAdmin = t, this._projectRoles = new x([]), this.privileges = ct(
2686
- [this._projectRoles, t],
2701
+ this._isSuperAdmin = t, this._projectRoles = new k([]), this._orgRole = new k(null), this.privileges = ct(
2702
+ [this._projectRoles, this._orgRole, t],
2687
2703
  () => this._compute()
2688
2704
  );
2689
2705
  }
2690
2706
  _isSuperAdmin;
2691
2707
  _projectRoles;
2708
+ _orgRole;
2692
2709
  /**
2693
2710
  * Reactive signal — current user's privileges for the selected project.
2694
2711
  * Recomputes automatically when `setProjectRoles()` is called or when
2695
2712
  * the `isSuperAdmin` signal changes.
2696
2713
  */
2697
2714
  privileges;
2715
+ /**
2716
+ * Set the user's role within the organisation that owns the selected project.
2717
+ * Pass `null` to clear the organisation role (e.g. when deselecting a project).
2718
+ *
2719
+ * Only organisation admins (and superadmins) may create projects.
2720
+ */
2721
+ setOrgRole(t) {
2722
+ this._orgRole.get() !== t && this._orgRole.set(t);
2723
+ }
2698
2724
  /**
2699
2725
  * Set the user's roles for the currently selected project.
2700
2726
  *
@@ -2713,10 +2739,10 @@ class Vt {
2713
2739
  return e === -1 ? [] : Array.from(Ht.slice(e));
2714
2740
  }
2715
2741
  _compute() {
2716
- const t = this._projectRoles.get(), e = rr();
2717
- for (const o of Object.keys(Wt))
2718
- e[o] = t.includes(Wt[o]);
2719
- return e;
2742
+ const t = this._projectRoles.get(), e = this._isSuperAdmin.get(), o = sr();
2743
+ for (const r of Object.keys(Wt))
2744
+ o[r] = t.includes(Wt[r]);
2745
+ return o.createProject = e || this._orgRole.get() === "admin", o;
2720
2746
  }
2721
2747
  }
2722
2748
  class Kt {
@@ -2764,7 +2790,7 @@ class Kt {
2764
2790
  d.set(w, g), g += w.length;
2765
2791
  return JSON.parse(new TextDecoder().decode(d));
2766
2792
  } catch (o) {
2767
- if (sr(o)) return;
2793
+ if (ar(o)) return;
2768
2794
  throw o;
2769
2795
  }
2770
2796
  }
@@ -2786,7 +2812,7 @@ class Kt {
2786
2812
  );
2787
2813
  }
2788
2814
  }
2789
- function sr(i) {
2815
+ function ar(i) {
2790
2816
  return typeof i == "object" && i !== null && "code" in i && i.code === "storage/object-not-found";
2791
2817
  }
2792
2818
  const b = {
@@ -6068,9 +6094,9 @@ class gt {
6068
6094
  ), this._nsMap = t, t;
6069
6095
  }
6070
6096
  }
6071
- class ar {
6097
+ class ir {
6072
6098
  constructor(t, e, o, r, s) {
6073
- 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(
6099
+ this._api = t, this._projectId = e, this._queryCache = r, this._graphType = s, this._currentLang = o, this._api.setLanguage(o), this._contentCategories = new k([]), this._entityCategories = new k([]), this._relationships = new k([]), this.availableContentCategories = this._contentCategories.asReadonly(), this.availableEntityCategories = this._entityCategories.asReadonly(), this.availableEntityRelationships = this._relationships.asReadonly(), this.ready = this._load(o).catch(
6074
6100
  (a) => console.error("[CueProjectSchema] Initial load failed:", a)
6075
6101
  );
6076
6102
  }
@@ -6197,7 +6223,7 @@ GROUP BY ?iri ?parent`;
6197
6223
  });
6198
6224
  }
6199
6225
  }
6200
- const ir = "https://qlever.dev/api/osm-planet";
6226
+ const nr = "https://qlever.dev/api/osm-planet";
6201
6227
  class ue {
6202
6228
  constructor(t, e, o = dt, r, s) {
6203
6229
  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(
@@ -6211,15 +6237,15 @@ class ue {
6211
6237
  /** Full RDF base URL for this project, e.g. `https://cue.qaecy.com/r/{pid}/` */
6212
6238
  baseURL;
6213
6239
  // ── Internal writable slices ───────────────────────────────────────────────
6214
- _entityDetails = new x({});
6215
- _entityDocuments = new x(
6240
+ _entityDetails = new k({});
6241
+ _entityDocuments = new k(
6216
6242
  {}
6217
6243
  );
6218
- _entityRelationships = new x({});
6219
- _entityOSMMap = new x({});
6220
- _osmWKTMap = new x({});
6244
+ _entityRelationships = new k({});
6245
+ _entityOSMMap = new k({});
6246
+ _osmWKTMap = new k({});
6221
6247
  _fetchingOSMIds = /* @__PURE__ */ new Set();
6222
- _entityGraph = new x(void 0);
6248
+ _entityGraph = new k(void 0);
6223
6249
  // ── Derived signals ────────────────────────────────────────────────────────
6224
6250
  _entityInfoMapComputed = ct(
6225
6251
  [
@@ -6495,18 +6521,18 @@ ORDER BY DESC(?weight)`, o = await this._api.sparql(
6495
6521
  (f) => s[f] !== void 0 && !w.has(f) && !!w.add(f)
6496
6522
  ).map((f) => ({ osmIRI: f, wkt: s[f] }));
6497
6523
  const u = /* @__PURE__ */ new Map();
6498
- for (const { osm: f, viaRels: k, entityUUID: m } of h.indirect) {
6499
- const E = s[f];
6500
- if (E)
6501
- for (const I of k) {
6524
+ for (const { osm: f, viaRels: E, entityUUID: m } of h.indirect) {
6525
+ const x = s[f];
6526
+ if (x)
6527
+ for (const I of E) {
6502
6528
  const v = `${I}:${m}`, y = u.get(v) ?? { geometries: [], entityUUID: m };
6503
- y.geometries.some((C) => C.osmIRI === f) || (y.geometries.push({ osmIRI: f, wkt: E }), u.set(v, y));
6529
+ y.geometries.some((C) => C.osmIRI === f) || (y.geometries.push({ osmIRI: f, wkt: x }), u.set(v, y));
6504
6530
  }
6505
6531
  }
6506
6532
  u.size > 0 && (g = Array.from(u.entries()).map(
6507
- ([f, { geometries: k, entityUUID: m }]) => ({
6533
+ ([f, { geometries: E, entityUUID: m }]) => ({
6508
6534
  rel: f.split(":")[0],
6509
- geometries: k,
6535
+ geometries: E,
6510
6536
  entityUUID: m
6511
6537
  })
6512
6538
  ));
@@ -6637,7 +6663,7 @@ GROUP BY ?e1Cat ?e2Cat`;
6637
6663
  const o = e.map((n) => `<${n}>`).join(" "), r = `PREFIX geo: <${A.geo}>
6638
6664
  SELECT * WHERE {
6639
6665
  VALUES ?s { ${o} }
6640
- SERVICE <${ir}> {
6666
+ SERVICE <${nr}> {
6641
6667
  ?s geo:hasGeometry/geo:asWKT ?wkt
6642
6668
  }
6643
6669
  }`, s = await this._api.sparql(
@@ -6662,8 +6688,8 @@ class pt {
6662
6688
  baseURL;
6663
6689
  /** Tracks the language for which `_documentInfoMap` is currently populated. */
6664
6690
  _currentLang;
6665
- _documentInfoMap = new x({});
6666
- _projectDocumentsData = new x({
6691
+ _documentInfoMap = new k({});
6692
+ _projectDocumentsData = new k({
6667
6693
  duplicateCount: 0,
6668
6694
  documentsBySuffix: {},
6669
6695
  documentsByContentCategory: {}
@@ -6987,9 +7013,9 @@ WHERE {
6987
7013
  return o?.count ? parseInt(o.count.value, 10) : 0;
6988
7014
  }
6989
7015
  }
6990
- class nr {
7016
+ class pr {
6991
7017
  constructor(t, e, { language: o, queryCache: r, rdfBase: s = dt, graphType: a }) {
6992
- this._api = t, this._projectId = e, this.schema = new ar(t, e, o, r, a), this.entities = new ue(t, e, s, r, a), this.documents = new pt(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));
7018
+ this._api = t, this._projectId = e, this.schema = new ir(t, e, o, r, a), this.entities = new ue(t, e, s, r, a), this.documents = new pt(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));
6993
7019
  }
6994
7020
  _api;
6995
7021
  _projectId;
@@ -7020,7 +7046,7 @@ class nr {
7020
7046
  /** Project document overview (counts by suffix and category). Fetched on init. */
7021
7047
  projectDocumentsData;
7022
7048
  // ── Search state ───────────────────────────────────────────────────────────
7023
- _searchResults = new x(void 0);
7049
+ _searchResults = new k(void 0);
7024
7050
  /** The result of the most recent `search()` call. `undefined` before first search. */
7025
7051
  searchResults;
7026
7052
  _destroyed = !1;
@@ -7120,14 +7146,14 @@ function Qt(i, t) {
7120
7146
  s.has(m.contentUUID) ? (s.get(m.contentUUID) || []).some((v) => v.locationUUID === m.locationUUID) || p.push(m) : n.push(m);
7121
7147
  const c = [], h = [];
7122
7148
  for (const m of t) {
7123
- const E = o.get(m.contentUUID);
7124
- E ? E.some((v) => v.locationUUID === m.locationUUID) || h.push(m) : c.push(m);
7149
+ const x = o.get(m.contentUUID);
7150
+ x ? x.some((v) => v.locationUUID === m.locationUUID) || h.push(m) : c.push(m);
7125
7151
  }
7126
7152
  const d = i.length - n.length - p.length, g = i.length, w = g > 0 ? d / g : 1;
7127
7153
  let u = 0, f = 0;
7128
7154
  for (const m of i)
7129
7155
  f += m.size || 0, (s.get(m.contentUUID) || []).some((v) => v.locationUUID === m.locationUUID) && (u += m.size || 0);
7130
- const k = f > 0 ? u / f : 1;
7156
+ const E = f > 0 ? u / f : 1;
7131
7157
  e({
7132
7158
  localNotOnRemote: n,
7133
7159
  localNotOnRemotePathOnly: p,
@@ -7137,13 +7163,13 @@ function Qt(i, t) {
7137
7163
  totalCount: g,
7138
7164
  syncSize: u,
7139
7165
  totalSize: f,
7140
- synctPctSize: k,
7166
+ synctPctSize: E,
7141
7167
  synctPctCount: w
7142
7168
  });
7143
7169
  });
7144
7170
  }
7145
7171
  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 || {});
7146
- const pr = {
7172
+ const lr = {
7147
7173
  ".aac": {
7148
7174
  type: l.AUDIO,
7149
7175
  open: !0,
@@ -8004,21 +8030,21 @@ const pr = {
8004
8030
  }
8005
8031
  };
8006
8032
  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 + "";
8007
- const { namedNode: lr, literal: Cr } = j;
8008
- lr("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
8009
- const { namedNode: Tr } = j, { namedNode: cr, literal: Sr } = j;
8033
+ const { namedNode: cr, literal: Tr } = j;
8010
8034
  cr("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
8011
- function hr(i) {
8035
+ const { namedNode: Sr } = j, { namedNode: hr, literal: Rr } = j;
8036
+ hr("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
8037
+ function dr(i) {
8012
8038
  const t = i.split(".");
8013
8039
  return t.length > 1 ? "." + t.pop()?.toLowerCase() : "";
8014
8040
  }
8015
- const { namedNode: dr, literal: Rr } = j;
8016
- dr("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
8017
8041
  const { namedNode: gr, literal: Ar } = j;
8018
8042
  gr("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
8043
+ const { namedNode: ur, literal: Pr } = j;
8044
+ ur("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
8019
8045
  function Xt(i, t, e, o, r, s, a, n = !1, p = !1) {
8020
- const c = hr(i), h = D(o), d = `${t}/${h}${c}`;
8021
- a === void 0 && (a = pr[c]?.mime ?? "application/octet-stream");
8046
+ const c = dr(i), h = D(o), d = `${t}/${h}${c}`;
8047
+ a === void 0 && (a = lr[c]?.mime ?? "application/octet-stream");
8022
8048
  const g = to(i, r);
8023
8049
  return {
8024
8050
  name: i,
@@ -8054,10 +8080,10 @@ async function Yt(i) {
8054
8080
  return t(i);
8055
8081
  }
8056
8082
  let q = null, G = null, H = null;
8057
- function Pr(i) {
8083
+ function Or(i) {
8058
8084
  H = i, G = null, q = null;
8059
8085
  }
8060
- async function ur() {
8086
+ async function mr() {
8061
8087
  if (typeof window < "u") {
8062
8088
  if (!H)
8063
8089
  throw new Error(
@@ -8079,7 +8105,7 @@ async function ur() {
8079
8105
  await a.default({ module_or_path: r }), q = a.scan;
8080
8106
  }
8081
8107
  }
8082
- const mr = "qlever", $ = 1e3, ut = "cue:pending:";
8108
+ const wr = "qlever", $ = 1e3, ut = "cue:pending:";
8083
8109
  async function mt(i) {
8084
8110
  const { tmpdir: t } = await import(
8085
8111
  /* webpackIgnore: true */
@@ -8110,7 +8136,7 @@ async function Jt(i) {
8110
8136
  }
8111
8137
  await (await U()).writeFile(await mt(i.spaceId), t, "utf-8");
8112
8138
  }
8113
- async function wr(i) {
8139
+ async function fr(i) {
8114
8140
  if (typeof window < "u") {
8115
8141
  window.localStorage.removeItem(`${ut}${i}`);
8116
8142
  return;
@@ -8120,7 +8146,7 @@ async function wr(i) {
8120
8146
  } catch {
8121
8147
  }
8122
8148
  }
8123
- class fr {
8149
+ class yr {
8124
8150
  constructor(t, e, o, r) {
8125
8151
  this._auth = t, this._projects = e, this._blob = o, this._gatewayUrl = r;
8126
8152
  }
@@ -8199,22 +8225,22 @@ class fr {
8199
8225
  this._api?.getConsumption(o) ?? Promise.reject(new Error("CueSyncApi is not bound to a CueApi instance")),
8200
8226
  this._fetchUnitCreditMap(s),
8201
8227
  this._fetchTierNames()
8202
- ]), f = (await Qt(t, h)).localNotOnRemote ?? [], k = f.length > 0 ? await this.scanCost(f) : [];
8203
- let m = 0, E = 0;
8204
- for (const v of k) {
8228
+ ]), f = (await Qt(t, h)).localNotOnRemote ?? [], E = f.length > 0 ? await this.scanCost(f) : [];
8229
+ let m = 0, x = 0;
8230
+ for (const v of E) {
8205
8231
  m += v.units;
8206
8232
  const y = g[c], C = y?.[v.ext] ?? 1;
8207
8233
  s && y && !(v.ext in y) && console.info(` Unknown format: .${v.ext} (using default rate of 1 credit/unit)`);
8208
8234
  const P = v.units * C;
8209
- E += P, v.credits = Math.round(P);
8235
+ x += P, v.credits = Math.round(P);
8210
8236
  }
8211
8237
  const I = w[c] ?? c;
8212
8238
  return {
8213
- costRecords: k,
8239
+ costRecords: E,
8214
8240
  tier: c,
8215
8241
  tierName: I,
8216
8242
  unitsToConsume: m,
8217
- creditsToConsume: Math.round(E),
8243
+ creditsToConsume: Math.round(x),
8218
8244
  creditsAvailable: d.creditsAvailable,
8219
8245
  unitsAvailable: d.unitsAvailable,
8220
8246
  filesToUpload: f.length,
@@ -8235,7 +8261,7 @@ class fr {
8235
8261
  a && (console.info(`Total local files: ${t.length}`), console.info(`Total remote files: ${d.length}`), console.info(
8236
8262
  `Total files to sync: ${(u.localNotOnRemote?.length ?? 0) + u.localNotOnRemotePathOnly.length}`
8237
8263
  ));
8238
- let f = u.syncCount, k = u.syncSize, m = 0, E = !1;
8264
+ let f = u.syncCount, E = u.syncSize, m = 0, x = !1;
8239
8265
  const I = u.localNotOnRemote ?? [];
8240
8266
  if (I.length > 0) {
8241
8267
  const C = (await this.scanCost(I)).reduce((P, we) => P + we.units, 0);
@@ -8266,7 +8292,7 @@ class fr {
8266
8292
  size: y.size,
8267
8293
  providerId: r,
8268
8294
  fileContentExists: !1
8269
- }), E = !0, f += 1, k += y.size || 0, this._logProgress(f, u.totalCount, k, u.totalSize, n);
8295
+ }), x = !0, f += 1, E += y.size || 0, this._logProgress(f, u.totalCount, E, u.totalSize, n);
8270
8296
  } catch (C) {
8271
8297
  m += 1, console.error(`[CueSyncApi] Failed to upload file: ${y.fullPath}`), a && console.error("[CueSyncApi] Upload error details:", C);
8272
8298
  }
@@ -8278,23 +8304,23 @@ class fr {
8278
8304
  size: y.size,
8279
8305
  providerId: r,
8280
8306
  fileContentExists: !0
8281
- }), E = !0, f += 1, k += y.size || 0, this._logProgress(f, u.totalCount, k, u.totalSize, n);
8307
+ }), x = !0, f += 1, E += y.size || 0, this._logProgress(f, u.totalCount, E, u.totalSize, n);
8282
8308
  await this._drainPending(a), this._stopFlushTimer();
8283
8309
  const v = await (this._api?.getConsumption(o) ?? Promise.resolve({ creditsAvailable: 0 }));
8284
8310
  return {
8285
8311
  syncCount: f,
8286
- syncSize: k,
8312
+ syncSize: E,
8287
8313
  failedUploads: m,
8288
8314
  totalCount: u.totalCount,
8289
8315
  totalSize: u.totalSize,
8290
- rdfWritten: E,
8316
+ rdfWritten: x,
8291
8317
  creditsAvailable: v.creditsAvailable
8292
8318
  };
8293
8319
  }
8294
8320
  async _getOrCreateGraph(t, e) {
8295
8321
  const o = this._graphMap.get(t);
8296
8322
  if (o) return o;
8297
- const s = (await this._projects.getProject(t))?.projectSettings?.graph?.type ?? mr, a = s === "qlever" ? `${this._gatewayUrl}${ie}` : `${this._gatewayUrl}${ae}`, n = s === "qlever" ? `${this._gatewayUrl}${co}` : `${this._gatewayUrl}${po}`, p = new Ze({
8323
+ const s = (await this._projects.getProject(t))?.projectSettings?.graph?.type ?? wr, a = s === "qlever" ? `${this._gatewayUrl}${ie}` : `${this._gatewayUrl}${ae}`, n = s === "qlever" ? `${this._gatewayUrl}${ho}` : `${this._gatewayUrl}${lo}`, p = new Ze({
8298
8324
  graphType: s,
8299
8325
  queryEndpoint: a,
8300
8326
  updateEndpoint: n,
@@ -8396,7 +8422,7 @@ WHERE {
8396
8422
  }
8397
8423
  async _flushBatch(t, e, o) {
8398
8424
  const r = [...t];
8399
- this._pendingSpaceId === e && (this._pendingItems = []), await wr(e);
8425
+ this._pendingSpaceId === e && (this._pendingItems = []), await fr(e);
8400
8426
  try {
8401
8427
  for (let s = 0; s < r.length; s += $)
8402
8428
  await this._postFssBatch(r.slice(s, s + $), e);
@@ -8437,7 +8463,7 @@ WHERE {
8437
8463
  * shown to the user before or after calling {@link sync}.
8438
8464
  */
8439
8465
  async scanCost(t) {
8440
- if (G || (G = ur()), await G, !q) throw new Error("WASM scan function not initialised");
8466
+ if (G || (G = mr()), await G, !q) throw new Error("WASM scan function not initialised");
8441
8467
  const e = 200, o = /* @__PURE__ */ new Map();
8442
8468
  for (let r = 0; r < t.length; r += e) {
8443
8469
  const s = t.slice(r, r + e), a = await Promise.all(
@@ -8595,7 +8621,7 @@ class me {
8595
8621
  * ```
8596
8622
  */
8597
8623
  get gis() {
8598
- return this._gis || (this._gis = new or(
8624
+ return this._gis || (this._gis = new rr(
8599
8625
  () => this.api.getAuthHeaders(),
8600
8626
  this._endpoints.gatewayUrl
8601
8627
  )), this._gis;
@@ -8654,9 +8680,9 @@ class me {
8654
8680
  storageLogs: h,
8655
8681
  storageChatSessions: d,
8656
8682
  storagePersistence: g
8657
- }), u = new fr(s, a, w, r.gatewayUrl), f = new Ut(s, r.gatewayUrl, a, u);
8683
+ }), u = new yr(s, a, w, r.gatewayUrl), f = new Ut(s, r.gatewayUrl, a, u);
8658
8684
  u._bindApi(f);
8659
- const k = new Gt(s, t, !1, r.gatewayUrl), m = Object.create(me.prototype), E = new Vt(s.isSuperAdmin), I = new Kt(g), v = new jt(w);
8685
+ const E = new Gt(s, t, !1, r.gatewayUrl), m = Object.create(me.prototype), x = new Vt(s.isSuperAdmin), I = new Kt(g), v = new jt(w);
8660
8686
  return Object.assign(m, {
8661
8687
  _app: t,
8662
8688
  _endpoints: r,
@@ -8666,8 +8692,8 @@ class me {
8666
8692
  auth: s,
8667
8693
  api: f,
8668
8694
  projects: a,
8669
- profile: k,
8670
- privileges: E,
8695
+ profile: E,
8696
+ privileges: x,
8671
8697
  cache: I,
8672
8698
  storage: v
8673
8699
  }), m;
@@ -8699,7 +8725,7 @@ class me {
8699
8725
  get: (r) => this.cache.getQueryCache(t, r).then((s) => s?.results),
8700
8726
  set: (r, s) => this.cache.setQueryCache(t, r, { query: r, results: s })
8701
8727
  };
8702
- return new nr(this.api, t, { ...e, queryCache: o });
8728
+ return new pr(this.api, t, { ...e, queryCache: o });
8703
8729
  }
8704
8730
  /**
8705
8731
  * Creates a `CueProjectEntities` instance for the given project, with the
@@ -8784,19 +8810,19 @@ export {
8784
8810
  Ut as a,
8785
8811
  qt as b,
8786
8812
  Kt as c,
8787
- or as d,
8813
+ rr as d,
8788
8814
  Vt as e,
8789
8815
  Gt as f,
8790
8816
  pt as g,
8791
8817
  ue as h,
8792
- ar as i,
8793
- nr as j,
8818
+ ir as i,
8819
+ pr as j,
8794
8820
  Bt as k,
8795
- x as l,
8821
+ k as l,
8796
8822
  jt as m,
8797
- fr as n,
8798
- mo as o,
8799
- Pr as p,
8823
+ yr as n,
8824
+ wo as o,
8825
+ Or as p,
8800
8826
  ct as q,
8801
8827
  Tt as r,
8802
8828
  ht as s,
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { C as s, a as u, b as C, c as i, d as t, e as c, f as o, g as r, h as l, i as n, j as P, k as j, l as m, m as S, n as g, o as h, R as p, p as R, q as f, s as E } from "./cue-ztX7FTFH.js";
1
+ import { C as s, a as u, b as C, c as i, d as t, e as c, f as o, g as r, h as l, i as n, j as P, k as j, l as m, m as S, n as g, o as h, R as p, p as R, q as f, s as E } from "./cue-BjbRXItA.js";
2
2
  export {
3
3
  s as Cue,
4
4
  u as CueApi,
@@ -2,11 +2,15 @@ import { ReadonlySignal } from './signal';
2
2
  /** Roles ordered from highest to lowest privilege. */
3
3
  declare const ROLE_HIERARCHY: readonly ["superadmin", "admin", "syncer", "member"];
4
4
  export type UserProjectRole = (typeof ROLE_HIERARCHY)[number];
5
+ /** Role a user can have within an organization. */
6
+ export type UserOrgRole = 'admin' | 'member';
5
7
  export interface Privileges {
6
8
  changeContentCategories: boolean;
7
9
  createEntities: boolean;
10
+ createProject: boolean;
8
11
  createProvider: boolean;
9
12
  deleteDocuments: boolean;
13
+ deleteProject: boolean;
10
14
  deleteUserFromProject: boolean;
11
15
  downloadDocuments: boolean;
12
16
  editContentCategories: boolean;
@@ -17,21 +21,29 @@ export interface Privileges {
17
21
  uploadDocuments: boolean;
18
22
  viewEntities: boolean;
19
23
  }
20
- /** Minimum role required for each privilege. */
21
- export declare const REQUIRED_ROLES: Record<keyof Privileges, UserProjectRole>;
24
+ /**
25
+ * Minimum project role required for each privilege.
26
+ * Note: `createProject` is intentionally absent — it is gated by the
27
+ * user's organisation role, not their project role.
28
+ */
29
+ export declare const REQUIRED_ROLES: Record<Exclude<keyof Privileges, 'createProject'>, UserProjectRole>;
22
30
  /**
23
31
  * Manages role-based access control for the current user + selected project.
24
32
  *
25
33
  * - Call `setProjectRoles()` whenever the selected project changes.
34
+ * - Call `setOrgRole()` whenever the selected project's organisation changes.
26
35
  * - Read `privileges` (a `ReadonlySignal<Privileges>`) for reactive access.
27
36
  *
28
37
  * @example
29
38
  * cue.privileges.setProjectRoles(['admin']);
39
+ * cue.privileges.setOrgRole('admin');
30
40
  * const canUpload = cue.privileges.privileges.get().uploadDocuments; // true
41
+ * const canCreate = cue.privileges.privileges.get().createProject; // true
31
42
  */
32
43
  export declare class CuePrivileges {
33
44
  private readonly _isSuperAdmin;
34
45
  private readonly _projectRoles;
46
+ private readonly _orgRole;
35
47
  /**
36
48
  * Reactive signal — current user's privileges for the selected project.
37
49
  * Recomputes automatically when `setProjectRoles()` is called or when
@@ -39,6 +51,13 @@ export declare class CuePrivileges {
39
51
  */
40
52
  readonly privileges: ReadonlySignal<Privileges>;
41
53
  constructor(_isSuperAdmin: ReadonlySignal<boolean>);
54
+ /**
55
+ * Set the user's role within the organisation that owns the selected project.
56
+ * Pass `null` to clear the organisation role (e.g. when deselecting a project).
57
+ *
58
+ * Only organisation admins (and superadmins) may create projects.
59
+ */
60
+ setOrgRole(role: UserOrgRole | null): void;
42
61
  /**
43
62
  * Set the user's roles for the currently selected project.
44
63
  *
package/lib/project.d.ts CHANGED
@@ -37,5 +37,9 @@ export declare class CueProjects {
37
37
  changeUserRoleOnProject(uid: string, projectId: string, role: ProjectRole): Promise<void>;
38
38
  /** Remove a member from a project. */
39
39
  removeUserFromProject(uid: string, projectId: string): Promise<void>;
40
+ /**
41
+ * Delete a project by ID. Requires superadmin privileges on the server.
42
+ */
43
+ deleteProject(projectId: string): Promise<void>;
40
44
  }
41
45
  export {};
package/node.js CHANGED
@@ -1,5 +1,5 @@
1
- import { C as h, B as l, r as _, t as S, u as E, n as m, v as P, a as d } from "./cue-ztX7FTFH.js";
2
- import { b as j, c as y, d as I, e as K, f as L, g as v, h as x, i as H, j as N, k as O, l as D, m as G, o as W, R as k, p as q, q as Q, s as V } from "./cue-ztX7FTFH.js";
1
+ import { C as h, B as l, r as _, t as S, u as E, n as m, v as P, a as d } from "./cue-BjbRXItA.js";
2
+ import { b as j, c as y, d as I, e as K, f as L, g as v, h as x, i as H, j as N, k as O, l as D, m as G, o as W, R as k, p as q, q as Q, s as V } from "./cue-BjbRXItA.js";
3
3
  import { getStorage as e, connectStorageEmulator as b } from "firebase/storage";
4
4
  import "firebase/firestore";
5
5
  class A extends h {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qaecy/cue-sdk",
3
- "version": "0.0.24",
3
+ "version": "0.0.26",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",
package/variables.d.ts CHANGED
@@ -27,6 +27,7 @@ export declare const ENDPOINT_COMMANDS_PROFILE_API_KEYS = "/commands/admin/profi
27
27
  export declare const ENDPOINT_COMMANDS_PROFILE_TERMS = "/commands/admin/profile/terms";
28
28
  export declare const ENDPOINT_ORG_MEMBERS: (orgId: string) => string;
29
29
  export declare const ENDPOINT_CREATE_PROJECT = "/commands/admin/project";
30
+ export declare const ENDPOINT_DELETE_PROJECT: (projectId: string) => string;
30
31
  export declare const ENDPOINT_SEARCH = "/assistant/search";
31
32
  export declare const ENDPOINT_FUSEKI_QUERY = "/triplestore/query";
32
33
  export declare const ENDPOINT_FUSEKI_UPDATE = "/triplestore/update";