@edifice.io/client 2.6.7-develop-b2school.20261002174012 → 2.6.7-develop-integration.20261003123008

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.
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  var P = Object.defineProperty;
2
2
  var I = (n, e, t) => e in n ? P(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
- var u = (n, e, t) => I(n, typeof e != "symbol" ? e + "" : e, t);
3
+ var a = (n, e, t) => I(n, typeof e != "symbol" ? e + "" : e, t);
4
4
  import axios from "axios";
5
5
  import { MimeTypeUtils } from "@edifice.io/utilities";
6
6
  import { UAParser } from "ua-parser-js";
@@ -98,10 +98,10 @@ const ERROR_CODE = {
98
98
  INFOTIP: "infotip",
99
99
  RGPD_COOKIES: "rgpdCookies"
100
100
  // TODO compléter
101
- }, C = class C {
101
+ }, R = class R {
102
102
  constructor(e) {
103
- u(this, "name");
104
- u(this, "listeners", /* @__PURE__ */ new Set());
103
+ a(this, "name");
104
+ a(this, "listeners", /* @__PURE__ */ new Set());
105
105
  this.name = e;
106
106
  }
107
107
  /**
@@ -110,8 +110,8 @@ const ERROR_CODE = {
110
110
  * @returns the channel instance
111
111
  */
112
112
  static getChannel(e) {
113
- let t = C.channels.get(e);
114
- return t || (t = new C(e), C.channels.set(e, t)), t;
113
+ let t = R.channels.get(e);
114
+ return t || (t = new R(e), R.channels.set(e, t)), t;
115
115
  }
116
116
  /**
117
117
  * Add a listener and return a revocation function to remove it.
@@ -136,14 +136,14 @@ const ERROR_CODE = {
136
136
  * Close this channel: remove listeners and unregister from global map.
137
137
  */
138
138
  close() {
139
- this.listeners.clear(), C.channels.delete(this.name);
139
+ this.listeners.clear(), R.channels.delete(this.name);
140
140
  }
141
141
  };
142
- u(C, "channels", /* @__PURE__ */ new Map());
143
- let SimpleChannel = C;
142
+ a(R, "channels", /* @__PURE__ */ new Map());
143
+ let SimpleChannel = R;
144
144
  class Subscription {
145
145
  constructor(e, t) {
146
- u(this, "revoke");
146
+ a(this, "revoke");
147
147
  this._channel = e, this.revoke = this.setReceiver((s) => t == null ? void 0 : t(s));
148
148
  }
149
149
  setReceiver(e) {
@@ -160,7 +160,7 @@ class Subject {
160
160
  /* We maintain channels for sending messages.
161
161
  * Receiving channels are instantiated per subscription.
162
162
  */
163
- u(this, "publishChannels", /* @__PURE__ */ new Map());
163
+ a(this, "publishChannels", /* @__PURE__ */ new Map());
164
164
  }
165
165
  getChannelName(e) {
166
166
  return "Subject:" + e;
@@ -195,9 +195,9 @@ const ASYNC_DATA_NAME = {
195
195
  class Promisified {
196
196
  constructor() {
197
197
  //-------------------------------------
198
- u(this, "_resolution");
199
- u(this, "_rejection");
200
- u(this, "_promise", new Promise((e, t) => {
198
+ a(this, "_resolution");
199
+ a(this, "_rejection");
200
+ a(this, "_promise", new Promise((e, t) => {
201
201
  this._resolution = e, this._rejection = t;
202
202
  }));
203
203
  }
@@ -214,8 +214,8 @@ class Promisified {
214
214
  class NotifyFramework {
215
215
  constructor() {
216
216
  //-------------------------------------
217
- u(this, "promises", {});
218
- u(this, "subject", new Subject());
217
+ a(this, "promises", {});
218
+ a(this, "subject", new Subject());
219
219
  }
220
220
  asyncData(e) {
221
221
  return typeof this.promises[e] > "u" && (this.promises[e] = new Promisified()), this.promises[e];
@@ -246,8 +246,8 @@ const notify = new NotifyFramework(), loadedScripts$1 = {};
246
246
  class Http {
247
247
  constructor(e) {
248
248
  // Axios automatically manages the XSRF-TOKEN cookie and the X-XSRF-TOKEN HTTP header.
249
- u(this, "axios");
250
- u(this, "_latestResponse");
249
+ a(this, "axios");
250
+ a(this, "_latestResponse");
251
251
  this.axios = axios.create(e);
252
252
  }
253
253
  setCdn(e) {
@@ -327,8 +327,8 @@ class Http {
327
327
  const r = s ?? "exports", i = this.toAxiosConfig(t);
328
328
  return i.headers && (i.headers.Accept = "application/javascript"), this.axios.get(this.toCdnUrl(e), i).then((o) => this.mapAxiosResponse(o, t)).then((o) => {
329
329
  try {
330
- const a = `"use strict";var ${r.split(".")[0]}={};${o};return ${r};`;
331
- return Function(a)();
330
+ const u = `"use strict";var ${r.split(".")[0]}={};${o};return ${r};`;
331
+ return Function(u)();
332
332
  } catch {
333
333
  return o;
334
334
  }
@@ -344,7 +344,7 @@ class Http {
344
344
  }
345
345
  class TransportFramework {
346
346
  constructor() {
347
- u(this, "_http", new Http());
347
+ a(this, "_http", new Http());
348
348
  }
349
349
  get http() {
350
350
  return this._http;
@@ -363,11 +363,11 @@ class ConfigurationFrameworkFactory {
363
363
  const http$2 = transport.http;
364
364
  class Session {
365
365
  constructor() {
366
- u(this, "_me", null);
367
- u(this, "_currentLanguage", "");
368
- u(this, "_notLoggedIn", !0);
369
- u(this, "_description");
370
- u(this, "_profile");
366
+ a(this, "_me", null);
367
+ a(this, "_currentLanguage", "");
368
+ a(this, "_notLoggedIn", !0);
369
+ a(this, "_description");
370
+ a(this, "_profile");
371
371
  }
372
372
  get currentLanguage() {
373
373
  return this._currentLanguage;
@@ -412,7 +412,7 @@ class Session {
412
412
  hasRight(e, t) {
413
413
  if (t === "owner")
414
414
  return e.owner && e.owner.userId === this._me.userId;
415
- const s = t.right || t, i = e.shared.filter((a) => (this._me.groupsIds || []).indexOf(a.groupId) !== -1 || a.userId === this._me.userId).find((a) => a[s] || a.manager) !== void 0, o = t.workflow ? this.hasWorkflow(t.workflow) : !0;
415
+ const s = t.right || t, i = e.shared.filter((u) => (this._me.groupsIds || []).indexOf(u.groupId) !== -1 || u.userId === this._me.userId).find((u) => u[s] || u.manager) !== void 0, o = t.workflow ? this.hasWorkflow(t.workflow) : !0;
416
416
  return i && o;
417
417
  }
418
418
  ////////////////////////////////////////////////////////// Storage management
@@ -485,7 +485,7 @@ class Session {
485
485
  }
486
486
  class SessionFramework {
487
487
  constructor() {
488
- u(this, "session", new Session());
488
+ a(this, "session", new Session());
489
489
  }
490
490
  initialize() {
491
491
  return this.session.initialize();
@@ -509,22 +509,22 @@ class SessionFramework {
509
509
  const session = new SessionFramework();
510
510
  class Theme {
511
511
  constructor() {
512
- u(this, "_conf");
513
- u(this, "_loaded");
512
+ a(this, "_conf");
513
+ a(this, "_loaded");
514
514
  // legacy (readonly)
515
- u(this, "skinName", "");
516
- u(this, "themeName", "");
517
- u(this, "skin", "raw");
518
- u(this, "themeUrl", "/assets/themes/raw/default/");
519
- u(this, "templateOverrides", {});
520
- u(this, "portalTemplate", "/assets/themes/raw/portal.html");
521
- u(this, "basePath", "");
522
- u(this, "logoutCallback", "");
523
- u(this, "skins", []);
524
- u(this, "is1D", !1);
525
- u(this, "is2D", !1);
526
- u(this, "_onSkinReady", notify.onSkinReady());
527
- u(this, "_onOverrideReady", notify.onOverridesReady());
515
+ a(this, "skinName", "");
516
+ a(this, "themeName", "");
517
+ a(this, "skin", "raw");
518
+ a(this, "themeUrl", "/assets/themes/raw/default/");
519
+ a(this, "templateOverrides", {});
520
+ a(this, "portalTemplate", "/assets/themes/raw/portal.html");
521
+ a(this, "basePath", "");
522
+ a(this, "logoutCallback", "");
523
+ a(this, "skins", []);
524
+ a(this, "is1D", !1);
525
+ a(this, "is2D", !1);
526
+ a(this, "_onSkinReady", notify.onSkinReady());
527
+ a(this, "_onOverrideReady", notify.onOverridesReady());
528
528
  }
529
529
  initialize(e) {
530
530
  return notify.onSessionReady().promise.then(() => this.load(e));
@@ -858,9 +858,9 @@ class Idiom {
858
858
  const i = new Promisified();
859
859
  promises$1[t] = i.promise;
860
860
  const o = {};
861
- e && (o["Accept-Language"] = e), transport.http.get(t, { headers: o }).then((a) => {
862
- Object.assign(bundle$1, a), typeof s == "function" && s(), i.resolve();
863
- }).catch((a) => {
861
+ e && (o["Accept-Language"] = e), transport.http.get(t, { headers: o }).then((u) => {
862
+ Object.assign(bundle$1, u), typeof s == "function" && s(), i.resolve();
863
+ }).catch((u) => {
864
864
  typeof s == "function" && s(), i.reject();
865
865
  });
866
866
  }
@@ -896,7 +896,7 @@ class Idiom {
896
896
  class UserPreferences {
897
897
  constructor() {
898
898
  //-------------------------------------
899
- u(this, "data", {});
899
+ a(this, "data", {});
900
900
  }
901
901
  get(e) {
902
902
  return this.data[e];
@@ -923,10 +923,10 @@ class UserPreferences {
923
923
  class User {
924
924
  constructor() {
925
925
  //-------------------------------------
926
- u(this, "_me", null);
927
- u(this, "_keepOpenOnLogout", !1);
928
- u(this, "_preferences", new UserPreferences());
929
- u(this, "_bookmarkedApps", []);
926
+ a(this, "_me", null);
927
+ a(this, "_keepOpenOnLogout", !1);
928
+ a(this, "_preferences", new UserPreferences());
929
+ a(this, "_bookmarkedApps", []);
930
930
  }
931
931
  get keepOpenOnLogout() {
932
932
  return this._keepOpenOnLogout;
@@ -970,7 +970,7 @@ class User {
970
970
  });
971
971
  let r = !0;
972
972
  const i = [];
973
- s.bookmarks.forEach((o, a) => {
973
+ s.bookmarks.forEach((o, u) => {
974
974
  const c = this._me.apps.find((l) => l.name === o);
975
975
  if (c) {
976
976
  const l = Object.assign({}, c);
@@ -978,8 +978,8 @@ class User {
978
978
  } else
979
979
  i.push(o), r = !1;
980
980
  }), i.forEach((o) => {
981
- const a = s.bookmarks.indexOf(o);
982
- a !== -1 && s.bookmarks.splice(a, 1);
981
+ const u = s.bookmarks.indexOf(o);
982
+ u !== -1 && s.bookmarks.splice(u, 1);
983
983
  }), r || transport.http.putJson("/userbook/preference/apps", s);
984
984
  });
985
985
  }
@@ -1000,9 +1000,9 @@ const http$1 = transport == null ? void 0 : transport.http;
1000
1000
  class AppConf {
1001
1001
  constructor() {
1002
1002
  //-------------------------------------
1003
- u(this, "_publicConf", {});
1004
- u(this, "_currentApp");
1005
- u(this, "_appConf", {});
1003
+ a(this, "_publicConf", {});
1004
+ a(this, "_currentApp");
1005
+ a(this, "_appConf", {});
1006
1006
  }
1007
1007
  /**
1008
1008
  * Get the currently initialized App.
@@ -1040,8 +1040,8 @@ class AppConf {
1040
1040
  class Analytics {
1041
1041
  constructor() {
1042
1042
  //-------------------------------------
1043
- u(this, "_status", "void");
1044
- u(this, "_params");
1043
+ a(this, "_status", "void");
1044
+ a(this, "_params");
1045
1045
  }
1046
1046
  get status() {
1047
1047
  return this._status;
@@ -1082,9 +1082,9 @@ class Analytics {
1082
1082
  const t = await notify.onSessionReady().promise, s = session.session.description;
1083
1083
  let r;
1084
1084
  for (const l of t.structures) {
1085
- const h = e.structureMap[l];
1086
- if (h && h.collectiviteId && h.UAI) {
1087
- r = h;
1085
+ const p = e.structureMap[l];
1086
+ if (p && p.collectiviteId && p.UAI) {
1087
+ r = p;
1088
1088
  break;
1089
1089
  }
1090
1090
  }
@@ -1095,11 +1095,11 @@ class Analytics {
1095
1095
  if (!i) return;
1096
1096
  const o = i.xiti;
1097
1097
  if (!o || !o.LIBELLE_SERVICE || !r.UAI) return;
1098
- function a(l) {
1099
- let h = "";
1100
- for (let E = 0; E < l.length; E++)
1101
- h += l.charCodeAt(E);
1102
- return h;
1098
+ function u(l) {
1099
+ let p = "";
1100
+ for (let d = 0; d < l.length; d++)
1101
+ p += l.charCodeAt(d);
1102
+ return p;
1103
1103
  }
1104
1104
  const c = {
1105
1105
  Student: "ELEVE",
@@ -1118,7 +1118,7 @@ class Analytics {
1118
1118
  PROJET: r.projetId ? r.projetId : e.ID_PROJET,
1119
1119
  EXPLOITANT: e.ID_EXPLOITANT,
1120
1120
  PLATFORME: r.plateformeId ? r.plateformeId : e.ID_PLATEFORME,
1121
- ID_PERSO: a(t.userId),
1121
+ ID_PERSO: u(t.userId),
1122
1122
  PROFILE: s.profiles && s.profiles.length > 0 ? c[s.profiles[0]] ?? "" : ""
1123
1123
  };
1124
1124
  }
@@ -1146,12 +1146,12 @@ function detectDevice() {
1146
1146
  if (typeof window > "u")
1147
1147
  return { osName: "", osVersion: "", deviceType: "", deviceName: "" };
1148
1148
  const n = UAParser(), e = isPad(), t = n.device.vendor || "", s = n.device.model || "", r = t && s ? `${t} ${s}` : s || t || "Unknown";
1149
- let i = n.os.name || "Unknown", o = n.device.type || (e ? "tablet" : "desktop"), a = r;
1150
- return e && i.toLowerCase() == "macos" && (i = "iPadOS", o = "tablet", a = "iPad"), {
1149
+ let i = n.os.name || "Unknown", o = n.device.type || (e ? "tablet" : "desktop"), u = r;
1150
+ return e && i.toLowerCase() == "macos" && (i = "iPadOS", o = "tablet", u = "iPad"), {
1151
1151
  osName: i,
1152
1152
  osVersion: n.os.version || "Unknown",
1153
1153
  deviceType: o,
1154
- deviceName: a
1154
+ deviceName: u
1155
1155
  };
1156
1156
  }
1157
1157
  function readDeviceCookies() {
@@ -1177,7 +1177,7 @@ function setDeviceCookies() {
1177
1177
  class ConfigurationFramework {
1178
1178
  constructor() {
1179
1179
  //-------------------------------------
1180
- u(this, "Platform", {
1180
+ a(this, "Platform", {
1181
1181
  deploymentTag: "",
1182
1182
  cdnDomain: "",
1183
1183
  apps: new AppConf(),
@@ -1186,16 +1186,16 @@ class ConfigurationFramework {
1186
1186
  idiom: new Idiom(),
1187
1187
  listLanguages: () => transport.http.get("/languages")
1188
1188
  });
1189
- u(this, "School", {
1189
+ a(this, "School", {
1190
1190
  //apps; -> pinnedApps;
1191
1191
  });
1192
- u(this, "User", new User());
1192
+ a(this, "User", new User());
1193
1193
  setDeviceCookies();
1194
1194
  }
1195
1195
  async initialize(e, t) {
1196
1196
  if (!e) {
1197
- const r = (l) => (l < 10 ? "0" : "") + l.toFixed(0), i = /* @__PURE__ */ new Date(), o = i.getFullYear(), a = i.getMonth() + 1, c = i.getDate();
1198
- e = `${o}${r(a)}${r(c)}`;
1197
+ const r = (l) => (l < 10 ? "0" : "") + l.toFixed(0), i = /* @__PURE__ */ new Date(), o = i.getFullYear(), u = i.getMonth() + 1, c = i.getDate();
1198
+ e = `${o}${r(u)}${r(c)}`;
1199
1199
  }
1200
1200
  const s = e;
1201
1201
  this.Platform.deploymentTag = e, typeof t == "string" && t.length > 0 && (this.Platform.cdnDomain = t), transport.http.setCdn(this.Platform.cdnDomain), await Promise.all([
@@ -1237,8 +1237,8 @@ var _;
1237
1237
  const me = (_ = session == null ? void 0 : session.session) == null ? void 0 : _.user;
1238
1238
  class Notification {
1239
1239
  constructor(e) {
1240
- u(this, "_id");
1241
- u(this, "model");
1240
+ a(this, "_id");
1241
+ a(this, "model");
1242
1242
  e.reported = e.reporters && e.reporters.length > 0, this._id = e._id, this.model = e;
1243
1243
  }
1244
1244
  isUnread() {
@@ -1258,14 +1258,14 @@ class Notification {
1258
1258
  class TimelineApp {
1259
1259
  constructor() {
1260
1260
  //-------------------------------------
1261
- u(this, "_notifications", []);
1262
- u(this, "_notificationTypes", []);
1261
+ a(this, "_notifications", []);
1262
+ a(this, "_notificationTypes", []);
1263
1263
  // ex: ["BLOG"]
1264
- u(this, "_flashMessages", []);
1265
- u(this, "_pageNumber", 0);
1266
- u(this, "_lastPage", !1);
1267
- u(this, "_loading", !1);
1268
- u(this, "showMine", !1);
1264
+ a(this, "_flashMessages", []);
1265
+ a(this, "_pageNumber", 0);
1266
+ a(this, "_lastPage", !1);
1267
+ a(this, "_loading", !1);
1268
+ a(this, "showMine", !1);
1269
1269
  }
1270
1270
  get notifications() {
1271
1271
  return this._notifications;
@@ -1324,7 +1324,7 @@ class TimelineApp {
1324
1324
  if (r.number && r.results) {
1325
1325
  const i = r.results.filter(
1326
1326
  (o) => this._notifications.findIndex(
1327
- (a) => a._id === o._id
1327
+ (u) => u._id === o._id
1328
1328
  ) === -1
1329
1329
  ).map((o) => new Notification(o));
1330
1330
  this._notifications = this._notifications.concat(i), this._pageNumber++;
@@ -1355,7 +1355,97 @@ const ReactionTypes = [
1355
1355
  "REACTION_2",
1356
1356
  "REACTION_3",
1357
1357
  "REACTION_4"
1358
- ];
1358
+ ], GOOGLE_DRIVE_FOLDER_MIME_TYPE = "application/vnd.google-apps.folder";
1359
+ function toGoogleDriveDocument(n) {
1360
+ return {
1361
+ id: n.id,
1362
+ name: n.name,
1363
+ ownerDisplayName: n.ownerDisplayName,
1364
+ contentType: n.mimeType,
1365
+ size: n.size,
1366
+ isFolder: n.mimeType === GOOGLE_DRIVE_FOLDER_MIME_TYPE,
1367
+ lastModified: n.modifiedTime,
1368
+ shared: n.shared
1369
+ };
1370
+ }
1371
+ class GoogleDriveCopyError extends Error {
1372
+ constructor(e, t, s) {
1373
+ super(e), this.copied = t, this.failures = s, this.name = "GoogleDriveCopyError";
1374
+ }
1375
+ }
1376
+ class GoogleDriveService {
1377
+ constructor(e) {
1378
+ this.context = e;
1379
+ }
1380
+ get http() {
1381
+ return this.context.http();
1382
+ }
1383
+ /**
1384
+ * List a user's Google Drive documents and folders inside a given folder.
1385
+ *
1386
+ * Google Drive addresses its entries by opaque id, not by path: `parentId` is
1387
+ * the id of the folder to list. The query param is nonetheless named `path`,
1388
+ * as the backend kept the name it uses for Nextcloud.
1389
+ *
1390
+ * @param userId - the id of the user whose files are listed.
1391
+ * @param parentId - id of the folder to list; the Drive root when omitted.
1392
+ */
1393
+ async listDocuments(e, t) {
1394
+ return (await this.http.get(
1395
+ `/googledrive/files/user/${e}`,
1396
+ { queryParams: t ? { path: t } : void 0 }
1397
+ )).data.map(toGoogleDriveDocument);
1398
+ }
1399
+ /**
1400
+ * Copy Google Drive documents into the entcore workspace.
1401
+ *
1402
+ * @param userId - the id of the user whose files are copied.
1403
+ * @param ids - Drive ids of the documents to copy.
1404
+ * @param parentId - the workspace folder to copy into; user's root when omitted.
1405
+ * @param params.application - the application the documents are added from.
1406
+ * @param params.visibility - "protected" files the documents under the
1407
+ * documents added from applications, the way an upload does.
1408
+ * @throws GoogleDriveCopyError when the backend reports at least one failure.
1409
+ */
1410
+ async copyDocumentToWorkspace(e, t, s, r) {
1411
+ const i = t.map((d) => `id=${encodeURIComponent(d)}`).join("&"), u = (await this.http.put(
1412
+ `/googledrive/files/user/${e}/copy/workspace?${i}`,
1413
+ void 0,
1414
+ {
1415
+ queryParams: {
1416
+ ...s ? { parentId: s } : {},
1417
+ ...r != null && r.application ? { application: r.application } : {},
1418
+ ...(r == null ? void 0 : r.visibility) === "protected" ? { protected: !0 } : {}
1419
+ }
1420
+ }
1421
+ )).data ?? [], c = u.map((d) => d.workspace).filter((d) => !!(d != null && d._id)), l = new Set(u.map((d) => d.id)), p = [
1422
+ ...u.filter((d) => {
1423
+ var h;
1424
+ return d.status === "error" || !((h = d.workspace) != null && h._id);
1425
+ }).map(({ id: d, message: h }) => ({ id: d, message: h })),
1426
+ ...t.filter((d) => !l.has(d)).map((d) => ({ id: d, message: void 0 }))
1427
+ ];
1428
+ if (p.length > 0)
1429
+ throw new GoogleDriveCopyError(
1430
+ `Failed to copy ${p.length} of ${t.length} Google Drive document(s) to the workspace`,
1431
+ c,
1432
+ p
1433
+ );
1434
+ return c;
1435
+ }
1436
+ /**
1437
+ * Build the URL to download/preview a Google Drive document.
1438
+ * There is no dedicated thumbnail endpoint on the backend, so this is also
1439
+ * used as an image preview source for image documents.
1440
+ * @param userId - the id of the user who owns the file.
1441
+ * @param doc - the document to build the URL for.
1442
+ */
1443
+ getFileUrl(e, t) {
1444
+ return `/googledrive/files/user/${e}/file/${encodeURIComponent(
1445
+ t.id
1446
+ )}/download?isFolder=${t.isFolder}`;
1447
+ }
1448
+ }
1359
1449
  class NotifyFrameworkFactory {
1360
1450
  static instance() {
1361
1451
  return notify;
@@ -1414,7 +1504,7 @@ const m = class m {
1414
1504
  //
1415
1505
  // PROTECTED HELPERS
1416
1506
  //
1417
- u(this, "checkHttpResponse", (e) => {
1507
+ a(this, "checkHttpResponse", (e) => {
1418
1508
  if (this.http.latestResponse.status >= 300)
1419
1509
  throw this.http.latestResponse.statusText;
1420
1510
  return e;
@@ -1632,22 +1722,22 @@ const m = class m {
1632
1722
  //
1633
1723
  // STATIC REGISTRY
1634
1724
  //
1635
- u(m, "registry", new ServiceRegistry()), // Expose some useful functions
1636
- u(m, "register", m.registry.register.bind(m.registry)), u(m, "findService", m.registry.findService.bind(m.registry)), u(m, "findMainService", m.registry.findMainService.bind(m.registry)), u(m, "isRegistered", m.registry.isRegistered.bind(m.registry));
1725
+ a(m, "registry", new ServiceRegistry()), // Expose some useful functions
1726
+ a(m, "register", m.registry.register.bind(m.registry)), a(m, "findService", m.registry.findService.bind(m.registry)), a(m, "findMainService", m.registry.findMainService.bind(m.registry)), a(m, "isRegistered", m.registry.isRegistered.bind(m.registry));
1637
1727
  let ResourceService = m;
1638
1728
  const APP$3 = "collaborativeeditor", RESOURCE$3 = "collaborativeeditor";
1639
1729
  class CollaborativeEditorResourceService extends ResourceService {
1640
1730
  async create(e) {
1641
- const { name: t, description: s, thumbnail: r, folder: i } = e, o = r ? await this.getThumbnailPath(r) : "", a = await this.http.post("/collaborativeeditor", {
1731
+ const { name: t, description: s, thumbnail: r, folder: i } = e, o = r ? await this.getThumbnailPath(r) : "", u = await this.http.post("/collaborativeeditor", {
1642
1732
  name: t,
1643
1733
  description: s,
1644
1734
  thumbnail: o,
1645
1735
  folder: i
1646
1736
  });
1647
- return this.checkHttpResponse(a), a;
1737
+ return this.checkHttpResponse(u), u;
1648
1738
  }
1649
1739
  async update(e) {
1650
- const { name: t, description: s, thumbnail: r, entId: i } = e, o = await this.getThumbnailPath(r), a = await this.http.put(
1740
+ const { name: t, description: s, thumbnail: r, entId: i } = e, o = await this.getThumbnailPath(r), u = await this.http.put(
1651
1741
  `/collaborativeeditor/${i}`,
1652
1742
  {
1653
1743
  name: t,
@@ -1655,7 +1745,7 @@ class CollaborativeEditorResourceService extends ResourceService {
1655
1745
  thumbnail: o
1656
1746
  }
1657
1747
  );
1658
- return this.checkHttpResponse(a), { thumbnail: o, entId: i };
1748
+ return this.checkHttpResponse(u), { thumbnail: o, entId: i };
1659
1749
  }
1660
1750
  getResourceType() {
1661
1751
  return RESOURCE$3;
@@ -1910,9 +2000,9 @@ class AnalyticsService {
1910
2000
  let r;
1911
2001
  if (!(t != null && t.structures)) return;
1912
2002
  for (const l of t.structures) {
1913
- const h = n.structureMap[l];
1914
- if (h && h.collectiviteId && h.UAI) {
1915
- r = h;
2003
+ const p = n.structureMap[l];
2004
+ if (p && p.collectiviteId && p.UAI) {
2005
+ r = p;
1916
2006
  break;
1917
2007
  }
1918
2008
  }
@@ -1921,11 +2011,11 @@ class AnalyticsService {
1921
2011
  if (!i) return;
1922
2012
  const o = i.xiti;
1923
2013
  if (!o || !o.LIBELLE_SERVICE || !r.UAI) return;
1924
- function a(l) {
1925
- let h = "";
1926
- for (let E = 0; E < l.length; E++)
1927
- h += l.charCodeAt(E);
1928
- return h;
2014
+ function u(l) {
2015
+ let p = "";
2016
+ for (let d = 0; d < l.length; d++)
2017
+ p += l.charCodeAt(d);
2018
+ return p;
1929
2019
  }
1930
2020
  const c = {
1931
2021
  Student: "ELEVE",
@@ -1944,7 +2034,7 @@ class AnalyticsService {
1944
2034
  PROJET: r.projetId ? r.projetId : n.ID_PROJET,
1945
2035
  EXPLOITANT: n.ID_EXPLOITANT,
1946
2036
  PLATFORME: r.plateformeId ? r.plateformeId : n.ID_PLATEFORME,
1947
- ID_PERSO: a(t.userId),
2037
+ ID_PERSO: u(t.userId),
1948
2038
  PROFILE: s && s.length > 0 ? c[s[0]] ?? "" : ""
1949
2039
  };
1950
2040
  }
@@ -2179,25 +2269,25 @@ class ConfService {
2179
2269
  conf: t,
2180
2270
  publicTheme: s
2181
2271
  }) {
2182
- var E;
2183
- const r = await this.http.get("/theme"), i = (E = t == null ? void 0 : t.overriding) == null ? void 0 : E.find(
2184
- (p) => (
2272
+ var d;
2273
+ const r = await this.http.get("/theme"), i = (d = t == null ? void 0 : t.overriding) == null ? void 0 : d.find(
2274
+ (h) => (
2185
2275
  // Fix #WB2-2660:
2186
2276
  // If Public access => get the neo theme
2187
2277
  // Else get the theme from the user preference
2188
- s ? p.parent === "theme-open-ent" && p.bootstrapVersion === "ode-bootstrap-neo" : p.child === (r == null ? void 0 : r.themeName)
2278
+ s ? h.parent === "theme-open-ent" && h.bootstrapVersion === "ode-bootstrap-neo" : h.child === (r == null ? void 0 : r.themeName)
2189
2279
  )
2190
- ), o = s ? "default" : (r == null ? void 0 : r.skinName) || (i == null ? void 0 : i.skins[0]), a = (r == null ? void 0 : r.skin) || `/assets/themes/${i == null ? void 0 : i.child}/skins/${o}/`, c = i == null ? void 0 : i.skins, l = i == null ? void 0 : i.bootstrapVersion.split("-").slice(-1)[0], h = (i == null ? void 0 : i.parent) === "panda";
2280
+ ), o = s ? "default" : (r == null ? void 0 : r.skinName) || (i == null ? void 0 : i.skins[0]), u = (r == null ? void 0 : r.skin) || `/assets/themes/${i == null ? void 0 : i.child}/skins/${o}/`, c = i == null ? void 0 : i.skins, l = i == null ? void 0 : i.bootstrapVersion.split("-").slice(-1)[0], p = (i == null ? void 0 : i.parent) === "panda";
2191
2281
  return {
2192
- basePath: `${this.cdnDomain}${a}../../`,
2282
+ basePath: `${this.cdnDomain}${u}../../`,
2193
2283
  bootstrapVersion: l,
2194
- is1d: h,
2284
+ is1d: p,
2195
2285
  logoutCallback: (r == null ? void 0 : r.logoutCallback) || "",
2196
2286
  skin: i == null ? void 0 : i.child,
2197
2287
  skinName: o,
2198
2288
  skins: c,
2199
2289
  themeName: i == null ? void 0 : i.child,
2200
- themeUrl: a,
2290
+ themeUrl: u,
2201
2291
  npmTheme: (i == null ? void 0 : i.npmTheme) ?? void 0,
2202
2292
  uiOverrides: i == null ? void 0 : i.uiOverrides
2203
2293
  };
@@ -2214,7 +2304,7 @@ class ConfService {
2214
2304
  const SEND_ALL = "*";
2215
2305
  class WebBroker {
2216
2306
  constructor(e) {
2217
- u(this, "subscription");
2307
+ a(this, "subscription");
2218
2308
  this.odeServices = e;
2219
2309
  }
2220
2310
  get http() {
@@ -2246,10 +2336,10 @@ class WebBroker {
2246
2336
  }
2247
2337
  class DataService {
2248
2338
  constructor(e) {
2249
- u(this, "_webBroker");
2250
- u(this, "app");
2251
- u(this, "user");
2252
- u(this, "profile");
2339
+ a(this, "_webBroker");
2340
+ a(this, "app");
2341
+ a(this, "user");
2342
+ a(this, "profile");
2253
2343
  this.odeServices = e;
2254
2344
  }
2255
2345
  get conf() {
@@ -2283,7 +2373,7 @@ class DataService {
2283
2373
  addUserInfos(e) {
2284
2374
  return this.user && (e.userId = this.user.userId, e.structure = this.user.structureNames[0]), this.profile && (e.profil = this.profile[0]), e;
2285
2375
  }
2286
- trackVideoSave(e, t, s, r, i, o, a) {
2376
+ trackVideoSave(e, t, s, r, i, o, u) {
2287
2377
  const c = this.addUserInfos({
2288
2378
  "event-type": "VIDEO_SAVE",
2289
2379
  module: this.app || "video",
@@ -2294,7 +2384,7 @@ class DataService {
2294
2384
  source: r ? "CAPTURED" : "UPLOADED",
2295
2385
  url: i
2296
2386
  });
2297
- a && (c.device_type = a), this.trackWebEvent(c);
2387
+ u && (c.device_type = u), this.trackWebEvent(c);
2298
2388
  }
2299
2389
  trackVideoRead(e, t, s, r, i) {
2300
2390
  const o = this.addUserInfos({
@@ -2362,14 +2452,14 @@ class DirectoryService {
2362
2452
  id: s,
2363
2453
  displayName: r,
2364
2454
  notVisibleCount: o,
2365
- groups: t.map(({ name: a, id: c, nbUsers: l }) => ({
2455
+ groups: t.map(({ name: u, id: c, nbUsers: l }) => ({
2366
2456
  nbUsers: l,
2367
- displayName: a,
2457
+ displayName: u,
2368
2458
  id: c
2369
2459
  })),
2370
- users: i.map(({ displayName: a, id: c, profile: l }) => ({
2460
+ users: i.map(({ displayName: u, id: c, profile: l }) => ({
2371
2461
  profile: l,
2372
- displayName: a,
2462
+ displayName: u,
2373
2463
  // these info are missing from api
2374
2464
  firstName: "",
2375
2465
  lastName: "",
@@ -2384,9 +2474,9 @@ class DirectoryService {
2384
2474
  users: r
2385
2475
  }) {
2386
2476
  this.cache.clearCache("/directory/sharebookmark/all");
2387
- const i = r.map((p) => typeof p == "string" ? p : p.id), o = s.map((p) => typeof p == "string" ? p : p.id), a = t.map(async (p) => {
2388
- if (typeof p == "string") {
2389
- const { displayName: y, groups: d, id: g, notVisibleCount: A, users: f } = await this.getBookMarkById(p), w = f.map((D) => D.id), F = d.map((D) => D.id);
2477
+ const i = r.map((h) => typeof h == "string" ? h : h.id), o = s.map((h) => typeof h == "string" ? h : h.id), u = t.map(async (h) => {
2478
+ if (typeof h == "string") {
2479
+ const { displayName: y, groups: E, id: g, notVisibleCount: A, users: f } = await this.getBookMarkById(h), w = f.map((D) => D.id), F = E.map((D) => D.id);
2390
2480
  return {
2391
2481
  displayName: y,
2392
2482
  id: g,
@@ -2394,19 +2484,19 @@ class DirectoryService {
2394
2484
  members: [...F, ...w]
2395
2485
  };
2396
2486
  } else
2397
- return Promise.resolve(p);
2398
- }), l = (await Promise.all(a)).map((p) => p.members).reduce((p, y) => [...p, ...y], []), h = {
2487
+ return Promise.resolve(h);
2488
+ }), l = (await Promise.all(u)).map((h) => h.members).reduce((h, y) => [...h, ...y], []), p = {
2399
2489
  name: e,
2400
2490
  members: [...i, ...o, ...l]
2401
- }, { id: E } = await this.http.postJson(
2491
+ }, { id: d } = await this.http.postJson(
2402
2492
  "/directory/sharebookmark",
2403
- h
2493
+ p
2404
2494
  );
2405
2495
  return {
2406
- id: E,
2496
+ id: d,
2407
2497
  displayName: e,
2408
2498
  notVisibleCount: 0,
2409
- members: h.members
2499
+ members: p.members
2410
2500
  };
2411
2501
  }
2412
2502
  }
@@ -2445,10 +2535,10 @@ class EmbedderService {
2445
2535
  urlIsFromPattern(e, t) {
2446
2536
  const s = new RegExp("[^{}]+(?=(?:[^{}]*{[^}]*})*[^}]*$)", "g"), r = new RegExp("{[^}]*}", "g");
2447
2537
  let i = !0;
2448
- const o = t.match(s) || [], a = [];
2449
- return (t.match(r) || []).forEach((l, h) => {
2450
- l.includes("ignore") || a.push(o[h]);
2451
- }), a.forEach((l) => {
2538
+ const o = t.match(s) || [], u = [];
2539
+ return (t.match(r) || []).forEach((l, p) => {
2540
+ l.includes("ignore") || u.push(o[p]);
2541
+ }), u.forEach((l) => {
2452
2542
  if (!e.includes(l)) {
2453
2543
  i = !1;
2454
2544
  return;
@@ -2479,17 +2569,17 @@ class EmbedderService {
2479
2569
  if (this.urlIsFromPattern(t, s)) {
2480
2570
  const r = new RegExp("{[a-zA-Z0-9_.]+}", "g"), i = s.match(r) || [];
2481
2571
  let o = e.embed;
2482
- for (const a of i) {
2483
- let c = s.split(a)[0];
2572
+ for (const u of i) {
2573
+ let c = s.split(u)[0];
2484
2574
  const l = c.split("}");
2485
2575
  l.length > 1 && (c = l[l.length - 1]);
2486
- let h = t.split(c)[1];
2487
- if (!h)
2576
+ let p = t.split(c)[1];
2577
+ if (!p)
2488
2578
  continue;
2489
- const E = s.split(a)[1].split("{")[0];
2490
- E && (h = h.split(E)[0]);
2491
- const p = new RegExp("\\" + a.replace(/}/, "\\}"), "g");
2492
- o = o.replace(p, h);
2579
+ const d = s.split(u)[1].split("{")[0];
2580
+ d && (p = p.split(d)[0]);
2581
+ const h = new RegExp("\\" + u.replace(/}/, "\\}"), "g");
2582
+ o = o.replace(h, p);
2493
2583
  }
2494
2584
  return o;
2495
2585
  }
@@ -2743,9 +2833,9 @@ class IdiomService {
2743
2833
  const i = new Promisified();
2744
2834
  promises[t] = i.promise;
2745
2835
  const o = {};
2746
- e && (o["Accept-Language"] = e), this.http.get(t, { headers: o }).then((a) => {
2747
- Object.assign(bundle, a), typeof s == "function" && s(), i.resolve();
2748
- }).catch((a) => {
2836
+ e && (o["Accept-Language"] = e), this.http.get(t, { headers: o }).then((u) => {
2837
+ Object.assign(bundle, u), typeof s == "function" && s(), i.resolve();
2838
+ }).catch((u) => {
2749
2839
  typeof s == "function" && s(), i.reject();
2750
2840
  });
2751
2841
  }
@@ -2778,6 +2868,89 @@ class IdiomService {
2778
2868
  return e;
2779
2869
  }
2780
2870
  }
2871
+ function toRelativePath(n, e) {
2872
+ const t = `/remote.php/dav/files/${e}`, s = n.startsWith(t) ? n.slice(t.length) : n;
2873
+ return decodeURIComponent(s || "/");
2874
+ }
2875
+ function toNextcloudDocument(n, e) {
2876
+ return {
2877
+ path: toRelativePath(n.path, e),
2878
+ name: decodeURIComponent(n.displayname),
2879
+ ownerDisplayName: n.ownerDisplayName,
2880
+ contentType: n.contentType,
2881
+ size: n.size,
2882
+ favorite: n.favorite,
2883
+ etag: n.etag,
2884
+ fileId: n.fileId,
2885
+ isFolder: n.isFolder,
2886
+ lastModified: n.lastModified
2887
+ };
2888
+ }
2889
+ class NextcloudService {
2890
+ constructor(e) {
2891
+ this.context = e;
2892
+ }
2893
+ get http() {
2894
+ return this.context.http();
2895
+ }
2896
+ /**
2897
+ * List a user's Nextcloud documents and folders at a given path.
2898
+ * @param userId - the id of the user whose files are listed.
2899
+ * @param path - path to list, relative to the user's Nextcloud root; root when omitted.
2900
+ */
2901
+ async listDocuments(e, t) {
2902
+ return (await this.http.get(
2903
+ `/nextcloud/files/user/${e}`,
2904
+ { queryParams: t ? { path: t } : void 0 }
2905
+ )).data.map((r) => toNextcloudDocument(r, e));
2906
+ }
2907
+ /**
2908
+ * Copy Nextcloud documents into the entcore workspace.
2909
+ * @param userId - the id of the user whose files are copied.
2910
+ * @param paths - paths of the documents to copy, relative to the user's Nextcloud root.
2911
+ * @param parentId - the workspace folder to copy into; user's root when omitted.
2912
+ * @param params.application - the application the documents are added from.
2913
+ * @param params.visibility - "protected" files the documents under the
2914
+ * documents added from applications, the way an upload does.
2915
+ */
2916
+ async copyDocumentToWorkspace(e, t, s, r) {
2917
+ const i = t.map((u) => `path=${encodeURIComponent(u)}`).join("&");
2918
+ return (await this.http.put(
2919
+ `/nextcloud/files/user/${e}/copy/workspace?${i}`,
2920
+ void 0,
2921
+ {
2922
+ queryParams: {
2923
+ ...s ? { parentId: s } : {},
2924
+ ...r != null && r.application ? { application: r.application } : {},
2925
+ ...(r == null ? void 0 : r.visibility) === "protected" ? { protected: !0 } : {}
2926
+ }
2927
+ }
2928
+ )).data.filter((u) => !!(u != null && u._id));
2929
+ }
2930
+ /**
2931
+ * Check whether a user has an active Nextcloud OAuth2 connection.
2932
+ * @param userId - the id of the user to check.
2933
+ */
2934
+ async getOauth2Status(e) {
2935
+ return this.http.get(
2936
+ `/nextcloud/user/${e}/oauth2/status`
2937
+ );
2938
+ }
2939
+ /**
2940
+ * Build the URL to download/preview a Nextcloud document.
2941
+ * There is no dedicated thumbnail endpoint on the backend, so this is also
2942
+ * used as an image preview source for image documents.
2943
+ * @param userId - the id of the user who owns the file.
2944
+ * @param doc - the document to build the URL for.
2945
+ */
2946
+ getFileUrl(e, t) {
2947
+ return `/nextcloud/files/user/${e}/file/${encodeURIComponent(
2948
+ t.name
2949
+ )}/download?path=${encodeURIComponent(
2950
+ t.path
2951
+ )}&contentType=${encodeURIComponent(t.contentType ?? "")}&isFolder=${t.isFolder}`;
2952
+ }
2953
+ }
2781
2954
  class AbstractBehaviourService {
2782
2955
  //
2783
2956
  // IMPLEMENTATION
@@ -2786,7 +2959,7 @@ class AbstractBehaviourService {
2786
2959
  //-----------------
2787
2960
  //--- Utilities ---
2788
2961
  //-----------------
2789
- u(this, "_cache");
2962
+ a(this, "_cache");
2790
2963
  this.context = e, this._cache = new CacheService(this.context);
2791
2964
  }
2792
2965
  getApplication() {
@@ -2820,8 +2993,8 @@ class AbstractBehaviourService {
2820
2993
  class ActualitesBehaviour extends AbstractBehaviourService {
2821
2994
  constructor() {
2822
2995
  super(...arguments);
2823
- u(this, "APP", "actualites");
2824
- u(this, "RESOURCE", "actualites");
2996
+ a(this, "APP", "actualites");
2997
+ a(this, "RESOURCE", "actualites");
2825
2998
  }
2826
2999
  async loadResources() {
2827
3000
  const [t, s] = await Promise.all([
@@ -2832,10 +3005,10 @@ class ActualitesBehaviour extends AbstractBehaviourService {
2832
3005
  /* @__PURE__ */ new Map()
2833
3006
  );
2834
3007
  return t.map((i) => {
2835
- var a;
3008
+ var u;
2836
3009
  let o;
2837
3010
  return i.threadIcon ? o = i.threadIcon + "?thumbnail=48x48" : o = "/img/icons/glyphicons_036_file.png", this.dataToResource({
2838
- title: i.title + " [" + ((a = r.get(i.threadId)) == null ? void 0 : a.title) + "]",
3011
+ title: i.title + " [" + ((u = r.get(i.threadId)) == null ? void 0 : u.title) + "]",
2839
3012
  ownerName: i.owner.displayName,
2840
3013
  owner: i.owner.id,
2841
3014
  icon: o,
@@ -2856,8 +3029,8 @@ const hexToDataUrl = (n, e = 1, t = 1) => {
2856
3029
  class AppointmentsBehaviour extends AbstractBehaviourService {
2857
3030
  constructor() {
2858
3031
  super(...arguments);
2859
- u(this, "APP", "appointments");
2860
- u(this, "RESOURCE", "appointments");
3032
+ a(this, "APP", "appointments");
3033
+ a(this, "RESOURCE", "appointments");
2861
3034
  }
2862
3035
  async loadResources() {
2863
3036
  return (await this.httpGet("/appointments/grids/linker")).map((s) => this.dataToResource({
@@ -2875,8 +3048,8 @@ class AppointmentsBehaviour extends AbstractBehaviourService {
2875
3048
  class BlogBehaviour extends AbstractBehaviourService {
2876
3049
  constructor() {
2877
3050
  super(...arguments);
2878
- u(this, "APP", "blog");
2879
- u(this, "RESOURCE", "blog");
3051
+ a(this, "APP", "blog");
3052
+ a(this, "RESOURCE", "blog");
2880
3053
  }
2881
3054
  loadResources() {
2882
3055
  return new Promise(async (t, s) => {
@@ -2884,7 +3057,7 @@ class BlogBehaviour extends AbstractBehaviourService {
2884
3057
  const r = await this.httpGet("/blog/linker"), i = [];
2885
3058
  r.forEach((o) => {
2886
3059
  o.thumbnail ? o.thumbnail = o.thumbnail + "?thumbnail=48x48" : o.thumbnail = "/img/illustrations/blog.svg";
2887
- const a = o.fetchPosts.map((c) => this.dataToResource({
3060
+ const u = o.fetchPosts.map((c) => this.dataToResource({
2888
3061
  owner: o.author.userId,
2889
3062
  ownerName: o.author.username,
2890
3063
  title: c.title + " [" + o.title + "]",
@@ -2894,7 +3067,7 @@ class BlogBehaviour extends AbstractBehaviourService {
2894
3067
  shared: !!(o.shared && o.shared.length >= 0),
2895
3068
  modified: o.modified
2896
3069
  }));
2897
- i.push(...a);
3070
+ i.push(...u);
2898
3071
  }), t(i);
2899
3072
  } catch (r) {
2900
3073
  s(r);
@@ -2905,8 +3078,8 @@ class BlogBehaviour extends AbstractBehaviourService {
2905
3078
  class CollaborativewallBehaviour extends AbstractBehaviourService {
2906
3079
  constructor() {
2907
3080
  super(...arguments);
2908
- u(this, "APP", "collaborativewall");
2909
- u(this, "RESOURCE", "collaborativewall");
3081
+ a(this, "APP", "collaborativewall");
3082
+ a(this, "RESOURCE", "collaborativewall");
2910
3083
  }
2911
3084
  async loadResources() {
2912
3085
  return (await this.httpGet(
@@ -2928,8 +3101,8 @@ class CollaborativewallBehaviour extends AbstractBehaviourService {
2928
3101
  class CommunityBehaviour extends AbstractBehaviourService {
2929
3102
  constructor() {
2930
3103
  super(...arguments);
2931
- u(this, "APP", "community");
2932
- u(this, "RESOURCE", "community");
3104
+ a(this, "APP", "community");
3105
+ a(this, "RESOURCE", "community");
2933
3106
  }
2934
3107
  async loadResources() {
2935
3108
  return (await this.httpGet(
@@ -2953,8 +3126,8 @@ class CommunityBehaviour extends AbstractBehaviourService {
2953
3126
  class ExercizerBehaviour extends AbstractBehaviourService {
2954
3127
  constructor() {
2955
3128
  super(...arguments);
2956
- u(this, "APP", "exercizer");
2957
- u(this, "RESOURCE", "exercizer");
3129
+ a(this, "APP", "exercizer");
3130
+ a(this, "RESOURCE", "exercizer");
2958
3131
  }
2959
3132
  async loadResources() {
2960
3133
  return (await this.httpGet(
@@ -2962,8 +3135,8 @@ class ExercizerBehaviour extends AbstractBehaviourService {
2962
3135
  )).map((s) => {
2963
3136
  const r = s.picture ? s.picture + "?thumbnail=48x48" : "/img/illustrations/exercizer.svg";
2964
3137
  let i, o = !1;
2965
- const a = JSON.parse(s.scheduled_at);
2966
- return a.groupList.length > 0 ? (o = !0, i = a.groupList[0].name) : a.userList.length > 0 ? (o = !0, i = a.userList[0].name) : i = "", a.groupList.length + a.userList.length > 1 && (i += "..."), this.dataToResource({
3138
+ const u = JSON.parse(s.scheduled_at);
3139
+ return u.groupList.length > 0 ? (o = !0, i = u.groupList[0].name) : u.userList.length > 0 ? (o = !0, i = u.userList[0].name) : i = "", u.groupList.length + u.userList.length > 1 && (i += "..."), this.dataToResource({
2967
3140
  title: s.title,
2968
3141
  owner: s.owner,
2969
3142
  ownerName: i,
@@ -2979,8 +3152,8 @@ class ExercizerBehaviour extends AbstractBehaviourService {
2979
3152
  class FormulaireBehaviour extends AbstractBehaviourService {
2980
3153
  constructor() {
2981
3154
  super(...arguments);
2982
- u(this, "APP", "formulaire");
2983
- u(this, "RESOURCE", "formulaire");
3155
+ a(this, "APP", "formulaire");
3156
+ a(this, "RESOURCE", "formulaire");
2984
3157
  }
2985
3158
  async loadResources() {
2986
3159
  return (await this.httpGet(
@@ -3000,8 +3173,8 @@ class FormulaireBehaviour extends AbstractBehaviourService {
3000
3173
  class ForumBehaviour extends AbstractBehaviourService {
3001
3174
  constructor() {
3002
3175
  super(...arguments);
3003
- u(this, "APP", "forum");
3004
- u(this, "RESOURCE", "forum");
3176
+ a(this, "APP", "forum");
3177
+ a(this, "RESOURCE", "forum");
3005
3178
  }
3006
3179
  async loadResources() {
3007
3180
  return (await this.httpGet("/forum/categories")).map(
@@ -3021,8 +3194,8 @@ class ForumBehaviour extends AbstractBehaviourService {
3021
3194
  class HomeworksBehaviour extends AbstractBehaviourService {
3022
3195
  constructor() {
3023
3196
  super(...arguments);
3024
- u(this, "APP", "homeworks");
3025
- u(this, "RESOURCE", "homeworks");
3197
+ a(this, "APP", "homeworks");
3198
+ a(this, "RESOURCE", "homeworks");
3026
3199
  }
3027
3200
  async loadResources() {
3028
3201
  return (await this.httpGet("/homeworks/list")).filter((t) => t.owner && t.trashed === 0).map((t) => this.dataToResource({
@@ -3040,8 +3213,8 @@ class HomeworksBehaviour extends AbstractBehaviourService {
3040
3213
  class MagnetoBehaviour extends AbstractBehaviourService {
3041
3214
  constructor() {
3042
3215
  super(...arguments);
3043
- u(this, "APP", "magneto");
3044
- u(this, "RESOURCE", "magneto");
3216
+ a(this, "APP", "magneto");
3217
+ a(this, "RESOURCE", "magneto");
3045
3218
  }
3046
3219
  async loadResources() {
3047
3220
  const { all: t } = await this.httpGet(
@@ -3062,8 +3235,8 @@ class MagnetoBehaviour extends AbstractBehaviourService {
3062
3235
  class MindmapBehaviour extends AbstractBehaviourService {
3063
3236
  constructor() {
3064
3237
  super(...arguments);
3065
- u(this, "APP", "mindmap");
3066
- u(this, "RESOURCE", "mindmap");
3238
+ a(this, "APP", "mindmap");
3239
+ a(this, "RESOURCE", "mindmap");
3067
3240
  }
3068
3241
  async loadResources() {
3069
3242
  return (await this.httpGet("/mindmap/list/all")).map(
@@ -3083,8 +3256,8 @@ class MindmapBehaviour extends AbstractBehaviourService {
3083
3256
  class PagesBehaviour extends AbstractBehaviourService {
3084
3257
  constructor() {
3085
3258
  super(...arguments);
3086
- u(this, "APP", "pages");
3087
- u(this, "RESOURCE", "pages");
3259
+ a(this, "APP", "pages");
3260
+ a(this, "RESOURCE", "pages");
3088
3261
  }
3089
3262
  async loadResources() {
3090
3263
  const t = await this.httpGet("/pages/list/all"), s = [];
@@ -3102,15 +3275,15 @@ class PagesBehaviour extends AbstractBehaviourService {
3102
3275
  shared: typeof r.shared < "u",
3103
3276
  modified: r.modified
3104
3277
  })
3105
- ), (o = r.pages) == null || o.forEach((a) => {
3278
+ ), (o = r.pages) == null || o.forEach((u) => {
3106
3279
  s.push(
3107
3280
  this.dataToResource({
3108
- title: a.title,
3281
+ title: u.title,
3109
3282
  owner: r.owner.userId,
3110
3283
  ownerName: r.owner.displayName,
3111
3284
  icon: i,
3112
- path: "/pages#/website/" + r._id + "/" + a.titleLink,
3113
- _id: r._id + "/" + a.titleLink,
3285
+ path: "/pages#/website/" + r._id + "/" + u.titleLink,
3286
+ _id: r._id + "/" + u.titleLink,
3114
3287
  shared: typeof r.shared < "u",
3115
3288
  modified: r.modified
3116
3289
  })
@@ -3122,8 +3295,8 @@ class PagesBehaviour extends AbstractBehaviourService {
3122
3295
  class PollBehaviour extends AbstractBehaviourService {
3123
3296
  constructor() {
3124
3297
  super(...arguments);
3125
- u(this, "APP", "poll");
3126
- u(this, "RESOURCE", "poll");
3298
+ a(this, "APP", "poll");
3299
+ a(this, "RESOURCE", "poll");
3127
3300
  }
3128
3301
  async loadResources() {
3129
3302
  return (await this.httpGet("/poll/list/all")).map((s) => {
@@ -3144,8 +3317,8 @@ class PollBehaviour extends AbstractBehaviourService {
3144
3317
  class ScrapbookBehaviour extends AbstractBehaviourService {
3145
3318
  constructor() {
3146
3319
  super(...arguments);
3147
- u(this, "APP", "scrapbook");
3148
- u(this, "RESOURCE", "scrapbook");
3320
+ a(this, "APP", "scrapbook");
3321
+ a(this, "RESOURCE", "scrapbook");
3149
3322
  }
3150
3323
  async loadResources() {
3151
3324
  return (await this.httpGet(
@@ -3168,8 +3341,8 @@ class ScrapbookBehaviour extends AbstractBehaviourService {
3168
3341
  class TimelinegeneratorBehaviour extends AbstractBehaviourService {
3169
3342
  constructor() {
3170
3343
  super(...arguments);
3171
- u(this, "APP", "timelinegenerator");
3172
- u(this, "RESOURCE", "timelinegenerator");
3344
+ a(this, "APP", "timelinegenerator");
3345
+ a(this, "RESOURCE", "timelinegenerator");
3173
3346
  }
3174
3347
  loadResources() {
3175
3348
  return new Promise(async (t, s) => {
@@ -3177,12 +3350,12 @@ class TimelinegeneratorBehaviour extends AbstractBehaviourService {
3177
3350
  const i = (await this.httpGet(
3178
3351
  "/timelinegenerator/timelines"
3179
3352
  )).map((o) => {
3180
- const a = o.icon || "/img/illustrations/timeline-default.png";
3353
+ const u = o.icon || "/img/illustrations/timeline-default.png";
3181
3354
  return this.dataToResource({
3182
3355
  title: o.headline,
3183
3356
  ownerName: o.owner.displayName,
3184
3357
  owner: o.owner.userId,
3185
- icon: a,
3358
+ icon: u,
3186
3359
  path: "/timelinegenerator#/view/" + o._id,
3187
3360
  _id: o._id,
3188
3361
  shared: typeof o.shared < "u",
@@ -3199,8 +3372,8 @@ class TimelinegeneratorBehaviour extends AbstractBehaviourService {
3199
3372
  class WikiBehaviour extends AbstractBehaviourService {
3200
3373
  constructor() {
3201
3374
  super(...arguments);
3202
- u(this, "APP", "wiki");
3203
- u(this, "RESOURCE", "wiki");
3375
+ a(this, "APP", "wiki");
3376
+ a(this, "RESOURCE", "wiki");
3204
3377
  }
3205
3378
  async loadResources() {
3206
3379
  return (await this.httpGet(
@@ -3223,8 +3396,8 @@ class WikiBehaviour extends AbstractBehaviourService {
3223
3396
  class WorkspaceBehaviour extends AbstractBehaviourService {
3224
3397
  constructor() {
3225
3398
  super(...arguments);
3226
- u(this, "APP", "workspace");
3227
- u(this, "RESOURCE", "workspace");
3399
+ a(this, "APP", "workspace");
3400
+ a(this, "RESOURCE", "workspace");
3228
3401
  }
3229
3402
  loadResources({ search: t, asset_id: s }) {
3230
3403
  return new Promise(async (r, i) => {
@@ -3232,12 +3405,12 @@ class WorkspaceBehaviour extends AbstractBehaviourService {
3232
3405
  let o = "/workspace/documents?filter=all&hierarchical=true";
3233
3406
  s && s.length ? o += `&search=${t}` : t && t.length && (o += `&search=${t}`);
3234
3407
  const c = (await this.httpGet(o)).filter((l) => !l.deleted).map((l) => {
3235
- const h = l.metadata["content-type"] && l.metadata["content-type"].indexOf("image") !== -1 ? `/workspace/document/${l._id}?thumbnail=120x120` : "/img/icons/unknown-large.png";
3408
+ const p = l.metadata["content-type"] && l.metadata["content-type"].indexOf("image") !== -1 ? `/workspace/document/${l._id}?thumbnail=120x120` : "/img/icons/unknown-large.png";
3236
3409
  return this.dataToResource({
3237
3410
  title: l.name,
3238
3411
  ownerName: l.ownerName,
3239
3412
  owner: l.owner,
3240
- icon: h,
3413
+ icon: p,
3241
3414
  path: `/workspace/document/${l._id}`,
3242
3415
  _id: l._id,
3243
3416
  shared: !!(l.shared && l.shared.length >= 0),
@@ -3262,7 +3435,7 @@ const b = class b {
3262
3435
  e.session().getUser()
3263
3436
  ]);
3264
3437
  i != null && i.apps && (r != null && r.length) && (this.resourceProducingApps = r.filter(
3265
- (o) => i.apps.some((a) => a.address.includes(o))
3438
+ (o) => i.apps.some((u) => u.address.includes(o))
3266
3439
  ));
3267
3440
  } catch (r) {
3268
3441
  console.warn("Failed to load resource-producing apps:", r);
@@ -3345,8 +3518,8 @@ const b = class b {
3345
3518
  //
3346
3519
  // STATIC REGISTRY
3347
3520
  //
3348
- u(b, "registry", new ServiceRegistry()), // Expose some useful functions
3349
- u(b, "findBehaviour", b.registry.findService.bind(b.registry)), u(b, "hasBehaviour", b.registry.isRegistered.bind(b.registry)), u(b, "resourceProducingApps", []);
3521
+ a(b, "registry", new ServiceRegistry()), // Expose some useful functions
3522
+ a(b, "findBehaviour", b.registry.findService.bind(b.registry)), a(b, "hasBehaviour", b.registry.isRegistered.bind(b.registry)), a(b, "resourceProducingApps", []);
3350
3523
  let SnipletsService = b;
3351
3524
  class RightService {
3352
3525
  constructor(e) {
@@ -3545,14 +3718,14 @@ class SessionService {
3545
3718
  r,
3546
3719
  i,
3547
3720
  o,
3548
- a
3721
+ u
3549
3722
  ] = await Promise.all([
3550
3723
  this.getCurrentLanguage(e),
3551
3724
  this.latestQuotaAndUsage(e),
3552
3725
  this.loadDescription(e),
3553
3726
  this.getUserProfile(),
3554
3727
  this.getBookmarks(e)
3555
- ]), { type: c, ...l } = t || {}, h = {
3728
+ ]), { type: c, ...l } = t || {}, p = {
3556
3729
  ...l,
3557
3730
  profiles: c || ["Guest"],
3558
3731
  // "type" field from /userbook/api/person becomes "profiles"
@@ -3563,9 +3736,9 @@ class SessionService {
3563
3736
  user: e,
3564
3737
  quotaAndUsage: r,
3565
3738
  currentLanguage: s,
3566
- userDescription: h,
3739
+ userDescription: p,
3567
3740
  userProfile: o,
3568
- bookmarkedApps: a
3741
+ bookmarkedApps: u
3569
3742
  };
3570
3743
  }
3571
3744
  login(e, t, s, r) {
@@ -3659,7 +3832,7 @@ class SessionService {
3659
3832
  applications: []
3660
3833
  });
3661
3834
  const i = [];
3662
- return r.bookmarks.forEach((o, a) => {
3835
+ return r.bookmarks.forEach((o, u) => {
3663
3836
  const c = ((e == null ? void 0 : e.apps) || []).find(
3664
3837
  (l) => l.name === o
3665
3838
  );
@@ -3675,11 +3848,11 @@ class SessionService {
3675
3848
  }
3676
3849
  async getPerson(e = {}) {
3677
3850
  var c;
3678
- const { options: t = {}, params: s = {} } = e, r = new URLSearchParams(s).toString(), i = `/userbook/api/person${r ? `?${r}` : ""}`, { response: o, value: a } = await this.cache.httpGet(
3851
+ const { options: t = {}, params: s = {} } = e, r = new URLSearchParams(s).toString(), i = `/userbook/api/person${r ? `?${r}` : ""}`, { response: o, value: u } = await this.cache.httpGet(
3679
3852
  i,
3680
3853
  t
3681
3854
  );
3682
- return o.status < 200 || o.status >= 300 || typeof a == "string" ? null : ((c = a == null ? void 0 : a.result) == null ? void 0 : c[0]) || null;
3855
+ return o.status < 200 || o.status >= 300 || typeof u == "string" ? null : ((c = u == null ? void 0 : u.result) == null ? void 0 : c[0]) || null;
3683
3856
  }
3684
3857
  async isAdml() {
3685
3858
  const e = await this.getUser();
@@ -3737,38 +3910,38 @@ class ShareService {
3737
3910
  t,
3738
3911
  s,
3739
3912
  r
3740
- ), a = await this.cache.httpGetJson(o), c = a.users.visibles.filter(({ username: p, firstName: y, lastName: d, login: g }) => {
3913
+ ), u = await this.cache.httpGetJson(o), c = u.users.visibles.filter(({ username: h, firstName: y, lastName: E, login: g }) => {
3741
3914
  const A = StringUtils.removeAccents(
3742
- d || ""
3915
+ E || ""
3743
3916
  ).toLowerCase(), f = StringUtils.removeAccents(
3744
3917
  y || ""
3745
3918
  ).toLowerCase(), w = StringUtils.removeAccents(
3746
- p || ""
3919
+ h || ""
3747
3920
  ).toLowerCase(), F = StringUtils.removeAccents(g || "").toLowerCase();
3748
3921
  return w.includes(i) || f.includes(i) || A.includes(i) || F.includes(i);
3749
- }).map((p) => ({
3750
- avatarUrl: this.directory.getAvatarUrl(p.id, "user"),
3751
- directoryUrl: this.directory.getDirectoryUrl(p.id, "user"),
3752
- displayName: p.username,
3753
- id: p.id,
3754
- profile: p.profile,
3922
+ }).map((h) => ({
3923
+ avatarUrl: this.directory.getAvatarUrl(h.id, "user"),
3924
+ directoryUrl: this.directory.getDirectoryUrl(h.id, "user"),
3925
+ displayName: h.username,
3926
+ id: h.id,
3927
+ profile: h.profile,
3755
3928
  type: "user"
3756
- })), l = a.groups.visibles.filter(({ name: p }) => StringUtils.removeAccents(p || "").toLowerCase().includes(i)).map((p) => ({
3757
- avatarUrl: this.directory.getAvatarUrl(p.id, "group"),
3758
- directoryUrl: this.directory.getDirectoryUrl(p.id, "group"),
3759
- displayName: p.name,
3760
- id: p.id,
3929
+ })), l = u.groups.visibles.filter(({ name: h }) => StringUtils.removeAccents(h || "").toLowerCase().includes(i)).map((h) => ({
3930
+ avatarUrl: this.directory.getAvatarUrl(h.id, "group"),
3931
+ directoryUrl: this.directory.getDirectoryUrl(h.id, "group"),
3932
+ displayName: h.name,
3933
+ id: h.id,
3761
3934
  type: "group",
3762
- structureName: p.structureName
3935
+ structureName: h.structureName
3763
3936
  }));
3764
- return [...(await this.directory.getBookMarks()).filter(({ displayName: p }) => StringUtils.removeAccents(
3765
- p || ""
3766
- ).toLowerCase().includes(i)).map((p) => ({
3937
+ return [...(await this.directory.getBookMarks()).filter(({ displayName: h }) => StringUtils.removeAccents(
3938
+ h || ""
3939
+ ).toLowerCase().includes(i)).map((h) => ({
3767
3940
  avatarUrl: "",
3768
3941
  directoryUrl: "",
3769
3942
  profile: "",
3770
- displayName: p.displayName,
3771
- id: p.id,
3943
+ displayName: h.displayName,
3944
+ id: h.id,
3772
3945
  type: "sharebookmark"
3773
3946
  })), ...c, ...l];
3774
3947
  }
@@ -3784,10 +3957,10 @@ class ShareService {
3784
3957
  return s;
3785
3958
  }
3786
3959
  getActionsAvailableFor({ id: e, type: t }, s, r) {
3787
- const o = (t === "user" ? s.users.checked[e] : s.groups.checked[e]) || [], a = Object.keys(r), c = [];
3788
- for (const l of a)
3960
+ const o = (t === "user" ? s.users.checked[e] : s.groups.checked[e]) || [], u = Object.keys(r), c = [];
3961
+ for (const l of u)
3789
3962
  r[l].filter(
3790
- (p) => o.includes(p)
3963
+ (h) => o.includes(h)
3791
3964
  ).length > 0 && c.push(l);
3792
3965
  return c;
3793
3966
  }
@@ -3799,26 +3972,26 @@ class ShareService {
3799
3972
  s == null ? void 0 : s.getResourceRights
3800
3973
  ), o = await this.cache.httpGetJson(
3801
3974
  i
3802
- ), a = await this.getShareMapping(
3975
+ ), u = await this.getShareMapping(
3803
3976
  e,
3804
3977
  s == null ? void 0 : s.getShareMapping
3805
3978
  ), c = await this.cache.httpGetJson(
3806
3979
  "/infra/public/json/sharing-rights.json"
3807
- ), l = Object.keys(o.users.checked).map((d) => o.users.visibles.find(
3808
- (A) => A.id === d
3809
- )).filter((d) => d !== void 0).map((d) => {
3980
+ ), l = Object.keys(o.users.checked).map((E) => o.users.visibles.find(
3981
+ (A) => A.id === E
3982
+ )).filter((E) => E !== void 0).map((E) => {
3810
3983
  const g = this.getActionsAvailableFor(
3811
- { id: d.id, type: "user" },
3984
+ { id: E.id, type: "user" },
3812
3985
  o,
3813
- a
3986
+ u
3814
3987
  );
3815
3988
  return {
3816
- id: d.id,
3989
+ id: E.id,
3817
3990
  type: "user",
3818
- displayName: d.username,
3819
- profile: d.profile,
3820
- avatarUrl: this.directory.getAvatarUrl(d.id, "user"),
3821
- directoryUrl: this.directory.getDirectoryUrl(d.id, "user"),
3991
+ displayName: E.username,
3992
+ profile: E.profile,
3993
+ avatarUrl: this.directory.getAvatarUrl(E.id, "user"),
3994
+ directoryUrl: this.directory.getDirectoryUrl(E.id, "user"),
3822
3995
  actions: g.map((f) => {
3823
3996
  const w = c[f];
3824
3997
  return {
@@ -3828,21 +4001,21 @@ class ShareService {
3828
4001
  };
3829
4002
  })
3830
4003
  };
3831
- }).sort((d, g) => (d.displayName || "").localeCompare(g.displayName)), h = Object.keys(o.groups.checked).map((d) => o.groups.visibles.find(
3832
- (A) => A.id === d
3833
- )).filter((d) => d !== void 0).map((d) => {
4004
+ }).sort((E, g) => (E.displayName || "").localeCompare(g.displayName)), p = Object.keys(o.groups.checked).map((E) => o.groups.visibles.find(
4005
+ (A) => A.id === E
4006
+ )).filter((E) => E !== void 0).map((E) => {
3834
4007
  const g = this.getActionsAvailableFor(
3835
- { id: d.id, type: "group" },
4008
+ { id: E.id, type: "group" },
3836
4009
  o,
3837
- a
4010
+ u
3838
4011
  );
3839
4012
  return {
3840
- id: d.id,
4013
+ id: E.id,
3841
4014
  type: "group",
3842
- displayName: d.name,
4015
+ displayName: E.name,
3843
4016
  profile: void 0,
3844
- avatarUrl: this.directory.getAvatarUrl(d.id, "group"),
3845
- directoryUrl: this.directory.getDirectoryUrl(d.id, "group"),
4017
+ avatarUrl: this.directory.getAvatarUrl(E.id, "group"),
4018
+ directoryUrl: this.directory.getDirectoryUrl(E.id, "group"),
3846
4019
  actions: g.map((f) => {
3847
4020
  const w = c[f];
3848
4021
  return {
@@ -3852,26 +4025,26 @@ class ShareService {
3852
4025
  };
3853
4026
  })
3854
4027
  };
3855
- }).sort((d, g) => (d.displayName || "").localeCompare(g.displayName)), E = [...l, ...h], p = o.groups.visibles.map(
3856
- ({ groupDisplayName: d, id: g, name: A, labels: f }) => ({
4028
+ }).sort((E, g) => (E.displayName || "").localeCompare(g.displayName)), d = [...l, ...p], h = o.groups.visibles.map(
4029
+ ({ groupDisplayName: E, id: g, name: A, labels: f }) => ({
3857
4030
  labels: f,
3858
- displayName: d || A,
4031
+ displayName: E || A,
3859
4032
  id: g
3860
4033
  })
3861
4034
  ), y = o.users.visibles.map(
3862
- ({ id: d, profile: g, username: A, firstName: f, lastName: w, login: F }) => ({
4035
+ ({ id: E, profile: g, username: A, firstName: f, lastName: w, login: F }) => ({
3863
4036
  displayName: A,
3864
4037
  firstName: f,
3865
4038
  lastName: w,
3866
4039
  login: F,
3867
4040
  profile: g,
3868
- id: d
4041
+ id: E
3869
4042
  })
3870
4043
  );
3871
4044
  return {
3872
- rights: E,
4045
+ rights: d,
3873
4046
  visibleBookmarks: r,
3874
- visibleGroups: p,
4047
+ visibleGroups: h,
3875
4048
  visibleUsers: y
3876
4049
  };
3877
4050
  }
@@ -3882,7 +4055,7 @@ class ShareService {
3882
4055
  bookmarks: {}
3883
4056
  }, i = await this.getShareMapping(e, s);
3884
4057
  for (const o of t) {
3885
- const a = o.actions.map((l) => i[l.id]).reduce((l, h) => Array.isArray(h) ? [...l, ...h] : l, []), c = [...new Set(a)];
4058
+ const u = o.actions.map((l) => i[l.id]).reduce((l, p) => Array.isArray(p) ? [...l, ...p] : l, []), c = [...new Set(u)];
3886
4059
  c.length > 0 && (o.type === "user" ? r.users[o.id] = c : o.type === "group" ? r.groups[o.id] = c : r.bookmarks[o.id] = c);
3887
4060
  }
3888
4061
  return r;
@@ -3892,40 +4065,40 @@ class ShareService {
3892
4065
  e,
3893
4066
  s,
3894
4067
  r == null ? void 0 : r.getShareMapping
3895
- ), o = (r == null ? void 0 : r.saveResourceRights) || `/${e}/share/resource/${t}`, a = this.getSearchUrl(
4068
+ ), o = (r == null ? void 0 : r.saveResourceRights) || `/${e}/share/resource/${t}`, u = this.getSearchUrl(
3896
4069
  e,
3897
4070
  t,
3898
4071
  "",
3899
4072
  r == null ? void 0 : r.getResourceRights
3900
4073
  );
3901
- return this.cache.clearCache(a), await this.http.putJson(o, i);
4074
+ return this.cache.clearCache(u), await this.http.putJson(o, i);
3902
4075
  }
3903
4076
  async getActionsForApp(e, t) {
3904
4077
  const s = await this.cache.httpGetJson(
3905
4078
  "/infra/public/json/sharing-rights.json"
3906
4079
  ), r = await this.getShareMapping(e, t);
3907
4080
  return Object.keys(s).map((o) => {
3908
- const a = s[o];
4081
+ const u = s[o];
3909
4082
  return {
3910
4083
  displayName: o,
3911
4084
  id: o,
3912
- priority: a.priority,
3913
- requires: a.requires
4085
+ priority: u.priority,
4086
+ requires: u.requires
3914
4087
  };
3915
4088
  }).filter((o) => {
3916
- var a;
3917
- return ((a = r[o.id]) == null ? void 0 : a.length) > 0;
3918
- }).sort((o, a) => o.priority - a.priority);
4089
+ var u;
4090
+ return ((u = r[o.id]) == null ? void 0 : u.length) > 0;
4091
+ }).sort((o, u) => o.priority - u.priority);
3919
4092
  }
3920
4093
  }
3921
4094
  const loadedScripts = {};
3922
4095
  class HttpService {
3923
4096
  constructor(e, t) {
3924
4097
  // Axios automatically manages the XSRF-TOKEN cookie and the X-XSRF-TOKEN HTTP header.
3925
- u(this, "axios");
3926
- u(this, "baseUrl");
3927
- u(this, "headers", {});
3928
- u(this, "_latestResponse");
4098
+ a(this, "axios");
4099
+ a(this, "baseUrl");
4100
+ a(this, "headers", {});
4101
+ a(this, "_latestResponse");
3929
4102
  this.context = e, this.axios = axios.create(t);
3930
4103
  }
3931
4104
  fixBaseUrl(e) {
@@ -4140,8 +4313,8 @@ class HttpService {
4140
4313
  const r = s ?? "exports", i = this.toAxiosConfig(t);
4141
4314
  return i.headers && (i.headers.Accept = "application/javascript"), this.axios.get(this.toCdnUrl(e), i).then((o) => this.mapAxiosResponse(o, t)).then((o) => {
4142
4315
  try {
4143
- const a = `"use strict";var ${r.split(".")[0]}={};${o};return ${r};`;
4144
- return Function(a)();
4316
+ const u = `"use strict";var ${r.split(".")[0]}={};${o};return ${r};`;
4317
+ return Function(u)();
4145
4318
  } catch {
4146
4319
  return o;
4147
4320
  }
@@ -4155,7 +4328,7 @@ class HttpService {
4155
4328
  });
4156
4329
  }
4157
4330
  }
4158
- const R = class R {
4331
+ const C = class C {
4159
4332
  // in minutes. Applies to recorded videos.
4160
4333
  constructor(e) {
4161
4334
  this.context = e;
@@ -4176,8 +4349,8 @@ const R = class R {
4176
4349
  APP$4.VIDEO
4177
4350
  );
4178
4351
  return {
4179
- maxWeight: (e == null ? void 0 : e["max-videosize-mbytes"]) ?? R.MAX_WEIGHT,
4180
- maxDuration: (e == null ? void 0 : e["max-videoduration-minutes"]) ?? R.MAX_DURATION,
4352
+ maxWeight: (e == null ? void 0 : e["max-videosize-mbytes"]) ?? C.MAX_WEIGHT,
4353
+ maxDuration: (e == null ? void 0 : e["max-videoduration-minutes"]) ?? C.MAX_DURATION,
4181
4354
  acceptVideoUploadExtensions: ((t = e == null ? void 0 : e["accept-videoupload-extensions"]) == null ? void 0 : t.map(
4182
4355
  (s) => s.toUpperCase()
4183
4356
  )) ?? []
@@ -4200,43 +4373,43 @@ const R = class R {
4200
4373
  throw new Error("Invalid video filename");
4201
4374
  const i = `${e.browser.name} ${e.browser.version}`, o = new FormData();
4202
4375
  o.append("device", e.device || ""), o.append("browser", i), o.append("url", e.url), o.append("app", t), o.append("file", e.file, e.filename), o.append("weight", "" + e.file.size), o.append("captation", "" + s);
4203
- let a = `/video/encode?captation=${s}`;
4204
- r && (a += `&duration=${r}`);
4376
+ let u = `/video/encode?captation=${s}`;
4377
+ r && (u += `&duration=${r}`);
4205
4378
  const c = await this.http.post(
4206
- a,
4379
+ u,
4207
4380
  o,
4208
4381
  { headers: { "Content-Type": "multipart/form-data" } }
4209
4382
  );
4210
4383
  if (c.state == "running") {
4211
- let l = 0, h = 1;
4384
+ let l = 0, p = 1;
4212
4385
  do {
4213
- const E = h + l;
4386
+ const d = p + l;
4214
4387
  await new Promise(
4215
- (y) => setTimeout(y, E * 1e3)
4216
- ), l = h, h = Math.min(8, E);
4217
- const p = await this.http.get(
4388
+ (y) => setTimeout(y, d * 1e3)
4389
+ ), l = p, p = Math.min(8, d);
4390
+ const h = await this.http.get(
4218
4391
  `/video/status/${c.processid}`
4219
4392
  );
4220
- if (p.state == "succeed")
4221
- return p.videoworkspaceid && p.videosize && this.context.data().trackVideoSave(
4222
- p.videoworkspaceid,
4393
+ if (h.state == "succeed")
4394
+ return h.videoworkspaceid && h.videosize && this.context.data().trackVideoSave(
4395
+ h.videoworkspaceid,
4223
4396
  Math.round(r),
4224
- p.videosize,
4397
+ h.videosize,
4225
4398
  s,
4226
4399
  e.url,
4227
4400
  i,
4228
4401
  e.device
4229
- ), p;
4230
- if (p.state == "error")
4402
+ ), h;
4403
+ if (h.state == "error")
4231
4404
  break;
4232
4405
  } while (!0);
4233
4406
  }
4234
4407
  throw new Error("Video cannot be uploaded.");
4235
4408
  }
4236
4409
  };
4237
- u(R, "MAX_WEIGHT", 50), // in Mbytes. Applies to uploaded videos.
4238
- u(R, "MAX_DURATION", 3);
4239
- let VideoService = R;
4410
+ a(C, "MAX_WEIGHT", 50), // in Mbytes. Applies to uploaded videos.
4411
+ a(C, "MAX_DURATION", 3);
4412
+ let VideoService = C;
4240
4413
  class WidgetService {
4241
4414
  constructor(e) {
4242
4415
  this.context = e;
@@ -4317,7 +4490,7 @@ const defaultMappers = {
4317
4490
  }
4318
4491
  };
4319
4492
  // FIXME add edumedia support
4320
- u(v, "roleMappers", [
4493
+ a(v, "roleMappers", [
4321
4494
  (e) => Object.keys(defaultMappers).find((s) => defaultMappers[s](e))
4322
4495
  ]);
4323
4496
  let DocumentHelper = v;
@@ -4335,29 +4508,29 @@ class WorkspaceService {
4335
4508
  size: e.size,
4336
4509
  extension: i,
4337
4510
  role: DocumentHelper.role(r, !1, i)
4338
- }, a = t.replace("." + o.extension, ""), c = o.extension ? a + "." + o.extension : a;
4339
- return { basename: a, fullname: c, metadata: o };
4511
+ }, u = t.replace("." + o.extension, ""), c = o.extension ? u + "." + o.extension : u;
4512
+ return { basename: u, fullname: c, metadata: o };
4340
4513
  }
4341
4514
  async saveFile(e, t) {
4342
4515
  const { fullname: s, metadata: r } = this.extractMetadata(e), i = new FormData();
4343
4516
  i.append("file", e, s);
4344
4517
  const o = [];
4345
4518
  ((t == null ? void 0 : t.visibility) === "public" || (t == null ? void 0 : t.visibility) === "protected") && o.push(`${t.visibility}=true`), t != null && t.application && o.push(`application=${t.application}`), r.role === "img" && o.push("quality=1"), t != null && t.parentId && o.push(`parentId=${t.parentId}`);
4346
- const a = await this.http.postFile(
4519
+ const u = await this.http.postFile(
4347
4520
  `/workspace/document?${o.join("&")}`,
4348
4521
  i
4349
4522
  );
4350
4523
  if (this.http.isResponseError())
4351
4524
  throw this.http.latestResponse.statusText;
4352
- return a;
4525
+ return u;
4353
4526
  }
4354
4527
  async updateFile(e, t, s) {
4355
4528
  const { fullname: r, metadata: i } = this.extractMetadata(t), o = new FormData();
4356
4529
  o.append("file", t, r);
4357
- const a = [];
4358
- i.role === "img" && a.push("quality=1"), s != null && s.alt && a.push(`alt=${s.alt}`), s != null && s.legend && a.push(`legend=${s.legend}`), s != null && s.name && a.push(`name=${s.name}`);
4530
+ const u = [];
4531
+ i.role === "img" && u.push("quality=1"), s != null && s.alt && u.push(`alt=${s.alt}`), s != null && s.legend && u.push(`legend=${s.legend}`), s != null && s.name && u.push(`name=${s.name}`);
4359
4532
  const c = await this.http.putFile(
4360
- `/workspace/document/${e}?${a.join("&")}`,
4533
+ `/workspace/document/${e}?${u.join("&")}`,
4361
4534
  o
4362
4535
  );
4363
4536
  if (this.http.isResponseError())
@@ -4408,11 +4581,11 @@ class WorkspaceService {
4408
4581
  );
4409
4582
  if (this.http.isResponseError())
4410
4583
  throw this.http.latestResponse.statusText;
4411
- return r.forEach((o, a) => {
4584
+ return r.forEach((o, u) => {
4412
4585
  const c = e.findIndex(
4413
4586
  (l) => l._id === o._id
4414
4587
  );
4415
- 0 <= c && c < e.length && (e[c] = i[a]);
4588
+ 0 <= c && c < e.length && (e[c] = i[u]);
4416
4589
  }), e.filter((o) => !!o);
4417
4590
  }
4418
4591
  return e;
@@ -4427,12 +4600,12 @@ class WorkspaceService {
4427
4600
  if (typeof e == "string")
4428
4601
  return e.includes("data:image") || e.includes("thumbnail") ? e : `${e}${e.includes("?") ? "&" : "?"}thumbnail=${r}`;
4429
4602
  {
4430
- const a = `/workspace/${e.public ? "pub/" : ""}document/${e._id}?thumbnail=`, c = e.thumbnails;
4603
+ const u = `/workspace/${e.public ? "pub/" : ""}document/${e._id}?thumbnail=`, c = e.thumbnails;
4431
4604
  if ((o = (i = e.metadata) == null ? void 0 : i["content-type"]) != null && o.includes("video")) {
4432
4605
  const l = c && Object.keys(c).length > 0 ? Object.keys(c)[0] : null;
4433
- return l ? a + l : null;
4606
+ return l ? u + l : null;
4434
4607
  } else
4435
- return a + r;
4608
+ return u + r;
4436
4609
  }
4437
4610
  }
4438
4611
  /**
@@ -4486,22 +4659,24 @@ class WorkspaceService {
4486
4659
  }
4487
4660
  class OdeServices {
4488
4661
  constructor() {
4489
- u(this, "_analytics");
4490
- u(this, "_cache");
4491
- u(this, "_conf");
4492
- u(this, "_data");
4493
- u(this, "_directory");
4494
- u(this, "_http");
4495
- u(this, "_idiom");
4496
- u(this, "_notify");
4497
- u(this, "_rights");
4498
- u(this, "_session");
4499
- u(this, "_share");
4500
- u(this, "_video");
4501
- u(this, "_widget");
4502
- u(this, "_workspace");
4503
- u(this, "_embedder");
4504
- this._analytics = new AnalyticsService(this), this._cache = new CacheService(this), this._conf = new ConfService(this), this._data = new DataService(this), this._directory = new DirectoryService(this), this._http = new HttpService(this), this._idiom = new IdiomService(this), this._notify = NotifyFrameworkFactory.instance(), this._rights = new RightService(this), this._session = new SessionService(this), this._share = new ShareService(this), this._video = new VideoService(this), this._widget = new WidgetService(this), this._workspace = new WorkspaceService(this), this._embedder = new EmbedderService(this);
4662
+ a(this, "_analytics");
4663
+ a(this, "_cache");
4664
+ a(this, "_conf");
4665
+ a(this, "_data");
4666
+ a(this, "_directory");
4667
+ a(this, "_googledrive");
4668
+ a(this, "_http");
4669
+ a(this, "_idiom");
4670
+ a(this, "_nextcloud");
4671
+ a(this, "_notify");
4672
+ a(this, "_rights");
4673
+ a(this, "_session");
4674
+ a(this, "_share");
4675
+ a(this, "_video");
4676
+ a(this, "_widget");
4677
+ a(this, "_workspace");
4678
+ a(this, "_embedder");
4679
+ this._analytics = new AnalyticsService(this), this._cache = new CacheService(this), this._conf = new ConfService(this), this._data = new DataService(this), this._directory = new DirectoryService(this), this._googledrive = new GoogleDriveService(this), this._http = new HttpService(this), this._idiom = new IdiomService(this), this._nextcloud = new NextcloudService(this), this._notify = NotifyFrameworkFactory.instance(), this._rights = new RightService(this), this._session = new SessionService(this), this._share = new ShareService(this), this._video = new VideoService(this), this._widget = new WidgetService(this), this._workspace = new WorkspaceService(this), this._embedder = new EmbedderService(this);
4505
4680
  }
4506
4681
  initialize() {
4507
4682
  return this._data.initialize(), this;
@@ -4524,12 +4699,18 @@ class OdeServices {
4524
4699
  directory() {
4525
4700
  return this._directory;
4526
4701
  }
4702
+ googledrive() {
4703
+ return this._googledrive;
4704
+ }
4527
4705
  http() {
4528
4706
  return this._http;
4529
4707
  }
4530
4708
  idiom() {
4531
4709
  return this._idiom;
4532
4710
  }
4711
+ nextcloud() {
4712
+ return this._nextcloud;
4713
+ }
4533
4714
  notify() {
4534
4715
  return this._notify;
4535
4716
  }
@@ -4705,10 +4886,10 @@ const isActionAvailable = (n, e) => {
4705
4886
  class WidgetFramework {
4706
4887
  constructor() {
4707
4888
  //-------------------------------------
4708
- u(this, "_initialized");
4709
- u(this, "_widgets", []);
4889
+ a(this, "_initialized");
4890
+ a(this, "_widgets", []);
4710
4891
  ////////////////////////////////////// USER PREFERENCES
4711
- u(this, "_userPrefs", {});
4892
+ a(this, "_userPrefs", {});
4712
4893
  }
4713
4894
  initialize(e, t) {
4714
4895
  return this._initialized || (this._initialized = new Promisified(), notify.onSessionReady().promise.then((s) => {
@@ -4751,20 +4932,20 @@ class WidgetFramework {
4751
4932
  this._userPrefs = e ?? this._userPrefs;
4752
4933
  const t = configure.Platform.theme, s = [];
4753
4934
  t.listSkins().then((r) => {
4754
- var a;
4755
- const i = ((a = r.find((c) => c.child === t.skin)) == null ? void 0 : a.parent) === "panda" ? secondLevelWidgets : firstLevelWidgets;
4935
+ var u;
4936
+ const i = ((u = r.find((c) => c.child === t.skin)) == null ? void 0 : u.parent) === "panda" ? secondLevelWidgets : firstLevelWidgets;
4756
4937
  this._widgets = this._widgets.filter((c, l) => {
4757
- const h = c.platformConf.name;
4758
- return i.indexOf(h) !== -1 ? !1 : (this._userPrefs[h] || (this._userPrefs[h] = {
4759
- index: defaultWidgetOrder[h] ?? 999,
4938
+ const p = c.platformConf.name;
4939
+ return i.indexOf(p) !== -1 ? !1 : (this._userPrefs[p] || (this._userPrefs[p] = {
4940
+ index: defaultWidgetOrder[p] ?? 999,
4760
4941
  show: !0,
4761
4942
  position: c.platformConf.position
4762
- }), c.platformConf.mandatory && (this._userPrefs[h].show = !0, this._userPrefs[h].index = defaultWidgetOrder[h] ?? 999), c.platformConf.i18n && s.push(c.platformConf.i18n), c.applyUserPref(this._userPrefs[h]), !0);
4943
+ }), c.platformConf.mandatory && (this._userPrefs[p].show = !0, this._userPrefs[p].index = defaultWidgetOrder[p] ?? 999), c.platformConf.i18n && s.push(c.platformConf.i18n), c.applyUserPref(this._userPrefs[p]), !0);
4763
4944
  });
4764
4945
  const o = new Idiom();
4765
4946
  this._widgets = this._widgets.sort((c, l) => {
4766
- const h = o.translate(`timeline.settings.${c.platformConf.name}`).toLowerCase(), E = o.translate(`timeline.settings.${l.platformConf.name}`).toLowerCase();
4767
- return h < E ? -1 : h > E ? 1 : 0;
4947
+ const p = o.translate(`timeline.settings.${c.platformConf.name}`).toLowerCase(), d = o.translate(`timeline.settings.${l.platformConf.name}`).toLowerCase();
4948
+ return p < d ? -1 : p > d ? 1 : 0;
4768
4949
  });
4769
4950
  });
4770
4951
  }
@@ -4772,8 +4953,8 @@ class WidgetFramework {
4772
4953
  class Widget {
4773
4954
  //-------------------------------------
4774
4955
  constructor(e) {
4775
- u(this, "_schoolConf", {});
4776
- u(this, "_userPref");
4956
+ a(this, "_schoolConf", {});
4957
+ a(this, "_userPref");
4777
4958
  this._platformConf = e, this._userPref = null;
4778
4959
  }
4779
4960
  get platformConf() {
@@ -4824,6 +5005,8 @@ export {
4824
5005
  ERROR_CODE,
4825
5006
  EVENT_NAME,
4826
5007
  FOLDER,
5008
+ GOOGLE_DRIVE_FOLDER_MIME_TYPE,
5009
+ GoogleDriveCopyError,
4827
5010
  ITimelineFactory,
4828
5011
  LAYER_NAME,
4829
5012
  NotifyFrameworkFactory,