@olenbetong/appframe-core 2.11.8 → 2.11.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/af.common.js +17 -3
- package/dist/esm/af.common.legacy.js +118 -134
- package/dist/esm/af.common.legacy.min.js +10 -1
- package/dist/esm/af.common.legacy.min.js.map +3 -3
- package/dist/esm/af.common.min.js +2 -2
- package/dist/esm/af.common.min.js.map +3 -3
- package/dist/iife/af.common.js +19 -4
- package/dist/iife/af.common.legacy.js +120 -132
- package/dist/iife/af.common.legacy.min.js +10 -1
- package/dist/iife/af.common.legacy.min.js.map +3 -3
- package/dist/iife/af.common.min.js +2 -2
- package/dist/iife/af.common.min.js.map +3 -3
- package/es/index.js +1 -1
- package/es/parseFunc.js +19 -2
- package/es/parseFunc.test.js +45 -0
- package/package.json +5 -3
- package/src/parseFunc.test.ts +58 -0
- package/src/parseFunc.ts +29 -2
|
@@ -1,25 +1,9 @@
|
|
|
1
|
-
var
|
|
1
|
+
var af;
|
|
2
|
+
(af ||= {}).common = (() => {
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defProps = Object.defineProperties;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
-
var __spreadValues = (a, b) => {
|
|
12
|
-
for (var prop in b || (b = {}))
|
|
13
|
-
if (__hasOwnProp.call(b, prop))
|
|
14
|
-
__defNormalProp(a, prop, b[prop]);
|
|
15
|
-
if (__getOwnPropSymbols)
|
|
16
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
-
if (__propIsEnum.call(b, prop))
|
|
18
|
-
__defNormalProp(a, prop, b[prop]);
|
|
19
|
-
}
|
|
20
|
-
return a;
|
|
21
|
-
};
|
|
22
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
7
|
var __export = (target, all) => {
|
|
24
8
|
for (var name in all)
|
|
25
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -33,7 +17,6 @@ var af_common = (() => {
|
|
|
33
17
|
return to;
|
|
34
18
|
};
|
|
35
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
36
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
37
20
|
|
|
38
21
|
// src/index.ts
|
|
39
22
|
var index_exports = {};
|
|
@@ -87,9 +70,7 @@ var af_common = (() => {
|
|
|
87
70
|
|
|
88
71
|
// src/SessionHandler.ts
|
|
89
72
|
var SessionHandler = class {
|
|
90
|
-
|
|
91
|
-
__publicField(this, "eventHandler", mitt_default());
|
|
92
|
-
}
|
|
73
|
+
eventHandler = mitt_default();
|
|
93
74
|
authenticated() {
|
|
94
75
|
this.eventHandler.emit("onAuthenticated");
|
|
95
76
|
}
|
|
@@ -98,7 +79,7 @@ var af_common = (() => {
|
|
|
98
79
|
let authPromise = new Promise((resolve) => {
|
|
99
80
|
let eventHandler = () => {
|
|
100
81
|
this.eventHandler.off("onAuthenticated", eventHandler);
|
|
101
|
-
callback
|
|
82
|
+
callback?.();
|
|
102
83
|
resolve();
|
|
103
84
|
};
|
|
104
85
|
this.eventHandler.on("onAuthenticated", eventHandler);
|
|
@@ -117,7 +98,7 @@ var af_common = (() => {
|
|
|
117
98
|
} else {
|
|
118
99
|
link = "/login?RequireTwoFactor=1&ReturnUrl=%2fapi/sessionexpired/remove";
|
|
119
100
|
}
|
|
120
|
-
dialog.innerHTML =
|
|
101
|
+
dialog.innerHTML = `<iframe sandbox="allow-same-origin allow-scripts allow-modals allow-top-navigation-by-user-activation allow-forms" src="${link}" style="border:0;width:min(500px,100vw);height:min(700px, 100vh);"></iframe>`;
|
|
121
102
|
document.body.append(dialog);
|
|
122
103
|
dialog.showModal();
|
|
123
104
|
await authPromise;
|
|
@@ -126,9 +107,9 @@ var af_common = (() => {
|
|
|
126
107
|
await authPromise;
|
|
127
108
|
}
|
|
128
109
|
} catch (_) {
|
|
129
|
-
window.location.href =
|
|
110
|
+
window.location.href = `/login?ReturnUrl=${encodeURIComponent(window.location.pathname)}${encodeURIComponent(
|
|
130
111
|
window.location.search
|
|
131
|
-
)
|
|
112
|
+
)}`;
|
|
132
113
|
}
|
|
133
114
|
}
|
|
134
115
|
attachEvent(eventName, handler) {
|
|
@@ -141,51 +122,49 @@ var af_common = (() => {
|
|
|
141
122
|
|
|
142
123
|
// src/UserSession.ts
|
|
143
124
|
var UserSession = class extends SessionHandler {
|
|
125
|
+
amDesignator = "a.m.";
|
|
126
|
+
dayNames = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"];
|
|
127
|
+
dayNamesShort = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"];
|
|
128
|
+
decimalSeparator = ".";
|
|
129
|
+
domain = "OB";
|
|
130
|
+
email;
|
|
131
|
+
formats;
|
|
132
|
+
groupSeparator = null;
|
|
133
|
+
integratedSecurity = false;
|
|
134
|
+
isDeveloper = false;
|
|
135
|
+
login = "";
|
|
136
|
+
loginType;
|
|
137
|
+
monthNames = [
|
|
138
|
+
"january",
|
|
139
|
+
"february",
|
|
140
|
+
"march",
|
|
141
|
+
"april",
|
|
142
|
+
"may",
|
|
143
|
+
"june",
|
|
144
|
+
"july",
|
|
145
|
+
"august",
|
|
146
|
+
"september",
|
|
147
|
+
"october",
|
|
148
|
+
"november",
|
|
149
|
+
"december",
|
|
150
|
+
""
|
|
151
|
+
];
|
|
152
|
+
monthNamesShort = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "augt", "sep", "oct", "nov", "dec", ""];
|
|
153
|
+
name;
|
|
154
|
+
pmDesignator = "p.m.";
|
|
155
|
+
shortDateFormat = "dd.MM.yyyy";
|
|
156
|
+
culture = "en-GB";
|
|
157
|
+
uiculture = "en-GB";
|
|
144
158
|
constructor(userData) {
|
|
145
159
|
super();
|
|
146
|
-
__publicField(this, "amDesignator", "a.m.");
|
|
147
|
-
__publicField(this, "dayNames", ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"]);
|
|
148
|
-
__publicField(this, "dayNamesShort", ["sun", "mon", "tue", "wed", "thu", "fri", "sat"]);
|
|
149
|
-
__publicField(this, "decimalSeparator", ".");
|
|
150
|
-
__publicField(this, "domain", "OB");
|
|
151
|
-
__publicField(this, "email");
|
|
152
|
-
__publicField(this, "formats");
|
|
153
|
-
__publicField(this, "groupSeparator", null);
|
|
154
|
-
__publicField(this, "integratedSecurity", false);
|
|
155
|
-
__publicField(this, "isDeveloper", false);
|
|
156
|
-
__publicField(this, "login", "");
|
|
157
|
-
__publicField(this, "loginType");
|
|
158
|
-
__publicField(this, "monthNames", [
|
|
159
|
-
"january",
|
|
160
|
-
"february",
|
|
161
|
-
"march",
|
|
162
|
-
"april",
|
|
163
|
-
"may",
|
|
164
|
-
"june",
|
|
165
|
-
"july",
|
|
166
|
-
"august",
|
|
167
|
-
"september",
|
|
168
|
-
"october",
|
|
169
|
-
"november",
|
|
170
|
-
"december",
|
|
171
|
-
""
|
|
172
|
-
]);
|
|
173
|
-
__publicField(this, "monthNamesShort", ["jan", "feb", "mar", "apr", "may", "jun", "jul", "augt", "sep", "oct", "nov", "dec", ""]);
|
|
174
|
-
__publicField(this, "name");
|
|
175
|
-
__publicField(this, "pmDesignator", "p.m.");
|
|
176
|
-
__publicField(this, "shortDateFormat", "dd.MM.yyyy");
|
|
177
|
-
__publicField(this, "culture", "en-GB");
|
|
178
|
-
__publicField(this, "uiculture", "en-GB");
|
|
179
160
|
this.formats = {};
|
|
180
161
|
Object.assign(this, userData);
|
|
181
162
|
}
|
|
182
163
|
};
|
|
183
164
|
|
|
184
165
|
// src/log.ts
|
|
185
|
-
var
|
|
186
|
-
var article = (_d = (_b = (_a = window.af) == null ? void 0 : _a.article) == null ? void 0 : _b.id) != null ? _d : (_c = window.window) == null ? void 0 : _c.location.pathname.substring(1).split("/")[0];
|
|
166
|
+
var article = window.af?.article?.id ?? window.window?.location.pathname.substring(1).split("/")[0];
|
|
187
167
|
async function logActivity(activity, parameters = {}, timeElapsed = 0) {
|
|
188
|
-
var _a3;
|
|
189
168
|
try {
|
|
190
169
|
let response = await fetch("/api/logging/log-activity", {
|
|
191
170
|
method: "POST",
|
|
@@ -193,26 +172,27 @@ var af_common = (() => {
|
|
|
193
172
|
article,
|
|
194
173
|
timeElapsed,
|
|
195
174
|
action: activity,
|
|
196
|
-
parameters:
|
|
175
|
+
parameters: {
|
|
176
|
+
...parameters,
|
|
197
177
|
_session: getSessionData()
|
|
198
|
-
}
|
|
178
|
+
}
|
|
199
179
|
}),
|
|
200
180
|
headers: { "Content-Type": "application/json", Accept: "application/json" }
|
|
201
181
|
});
|
|
202
182
|
if (!response.ok) {
|
|
203
|
-
if (
|
|
183
|
+
if (response.headers.get("Content-Type")?.includes("application/json")) {
|
|
204
184
|
let data = await response.json();
|
|
205
185
|
console.error(data.error);
|
|
206
186
|
} else {
|
|
207
|
-
console.error(
|
|
187
|
+
console.error(`${response.status} ${response.statusText}`);
|
|
208
188
|
}
|
|
209
189
|
}
|
|
210
|
-
} catch
|
|
190
|
+
} catch {
|
|
211
191
|
}
|
|
212
192
|
}
|
|
213
193
|
function startActivity(activity, startParameters = {}) {
|
|
214
194
|
let start = performance.now();
|
|
215
|
-
return (endParameters = {}) => logActivity(activity,
|
|
195
|
+
return (endParameters = {}) => logActivity(activity, { ...startParameters, ...endParameters }, performance.now() - start);
|
|
216
196
|
}
|
|
217
197
|
async function time(callback) {
|
|
218
198
|
let start = performance.now();
|
|
@@ -220,12 +200,11 @@ var af_common = (() => {
|
|
|
220
200
|
return [returnValue, performance.now() - start];
|
|
221
201
|
}
|
|
222
202
|
async function logError(error) {
|
|
223
|
-
var _a3;
|
|
224
203
|
try {
|
|
225
204
|
if (!error) return;
|
|
226
205
|
let data = typeof error === "string" ? { error } : typeof error === "object" ? "message" in error ? {
|
|
227
206
|
error: error.message,
|
|
228
|
-
stack:
|
|
207
|
+
stack: error.stack ?? null
|
|
229
208
|
} : { error: error.toString() } : { error: "Unspecified error" };
|
|
230
209
|
console.error(error);
|
|
231
210
|
let result = await fetch("/data/Logger/LogError", {
|
|
@@ -239,26 +218,22 @@ var af_common = (() => {
|
|
|
239
218
|
return await result.json();
|
|
240
219
|
}
|
|
241
220
|
console.error(Error("Failed to log error"));
|
|
242
|
-
} catch
|
|
221
|
+
} catch {
|
|
243
222
|
}
|
|
244
223
|
}
|
|
245
224
|
function getSessionId() {
|
|
246
|
-
|
|
247
|
-
return (_a3 = crypto.randomUUID) == null ? void 0 : _a3.call(crypto);
|
|
225
|
+
return crypto.randomUUID?.();
|
|
248
226
|
}
|
|
249
227
|
var sessionStart = Date.now();
|
|
250
228
|
var sessionId = getSessionId();
|
|
251
229
|
var deviceId = "";
|
|
252
230
|
var browserSessionId = "";
|
|
253
231
|
if ("document" in window) {
|
|
254
|
-
let startSession = () => {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
"app-version": (_f = (_e = window.af) == null ? void 0 : _e.article) == null ? void 0 : _f.version
|
|
260
|
-
});
|
|
261
|
-
};
|
|
232
|
+
let startSession = () => logActivity("AfSessionInit", {
|
|
233
|
+
"appframe-core": window.af?.common?.version,
|
|
234
|
+
"appframe-data": window.af?.data?.version,
|
|
235
|
+
"app-version": window.af?.article?.version
|
|
236
|
+
});
|
|
262
237
|
document.addEventListener("DOMContentLoaded", () => {
|
|
263
238
|
deviceId = localStorage.getItem("_afDeviceId");
|
|
264
239
|
browserSessionId = sessionStorage.getItem("_afSessionId");
|
|
@@ -300,9 +275,8 @@ var af_common = (() => {
|
|
|
300
275
|
}
|
|
301
276
|
|
|
302
277
|
// src/errorHandler.ts
|
|
303
|
-
var _a2;
|
|
304
278
|
if (true) {
|
|
305
|
-
|
|
279
|
+
window.window?.addEventListener("error", (event) => {
|
|
306
280
|
if (typeof event === "object" && "error" in event) {
|
|
307
281
|
logError(event.error);
|
|
308
282
|
} else if (typeof event === "object" && "message" in event) {
|
|
@@ -313,13 +287,10 @@ var af_common = (() => {
|
|
|
313
287
|
|
|
314
288
|
// src/localStorage.ts
|
|
315
289
|
function getLocalKey(key) {
|
|
316
|
-
|
|
317
|
-
return [((_a3 = af == null ? void 0 : af.article) == null ? void 0 : _a3.id) || "", "common", key].join(".");
|
|
290
|
+
return [af?.article?.id || "", "common", key].join(".");
|
|
318
291
|
}
|
|
319
292
|
var LocalStorage = class {
|
|
320
|
-
|
|
321
|
-
__publicField(this, "isPersisted", () => true);
|
|
322
|
-
}
|
|
293
|
+
isPersisted = () => true;
|
|
323
294
|
getLocalStorageKey(key, global) {
|
|
324
295
|
return global ? ["common", key].join(".") : getLocalKey(key);
|
|
325
296
|
}
|
|
@@ -359,9 +330,9 @@ var af_common = (() => {
|
|
|
359
330
|
return String(num).padStart(digits, "0");
|
|
360
331
|
}
|
|
361
332
|
function toLocalISODateTime(date) {
|
|
362
|
-
return date ?
|
|
333
|
+
return date ? `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}T${pad(date.getHours())}:${pad(
|
|
363
334
|
date.getMinutes()
|
|
364
|
-
)
|
|
335
|
+
)}:${pad(date.getSeconds())}.${pad(date.getMilliseconds(), 3)}` : null;
|
|
365
336
|
}
|
|
366
337
|
function toLocalDateTime(date) {
|
|
367
338
|
return date ? date.toISOString().substring(0, 16) : "";
|
|
@@ -395,22 +366,21 @@ var af_common = (() => {
|
|
|
395
366
|
return;
|
|
396
367
|
}
|
|
397
368
|
const provided = typeof message === "function" ? message() : message;
|
|
398
|
-
throw new Error(provided
|
|
369
|
+
throw new Error(provided ?? "Invariant failed");
|
|
399
370
|
}
|
|
400
371
|
|
|
401
372
|
// src/downloadRequest.ts
|
|
402
373
|
async function downloadRequest(request, { fileName, signal, onProgress }) {
|
|
403
|
-
var _a3;
|
|
404
374
|
let bytesReceived = 0;
|
|
405
|
-
onProgress
|
|
375
|
+
onProgress?.({ status: "requested" });
|
|
406
376
|
try {
|
|
407
377
|
let response = await fetch(request);
|
|
408
378
|
if (!response.ok || !response.body) {
|
|
409
|
-
if (
|
|
379
|
+
if (response.headers.get("content-type")?.includes("application/json")) {
|
|
410
380
|
let data = await response.json();
|
|
411
381
|
invariant(!data.error, data.error);
|
|
412
382
|
}
|
|
413
|
-
throw new Error(
|
|
383
|
+
throw new Error(`${response.status} ${response.statusText}`);
|
|
414
384
|
}
|
|
415
385
|
try {
|
|
416
386
|
const reader = response.body.getReader();
|
|
@@ -423,7 +393,7 @@ var af_common = (() => {
|
|
|
423
393
|
return;
|
|
424
394
|
}
|
|
425
395
|
bytesReceived += read.value.length;
|
|
426
|
-
onProgress
|
|
396
|
+
onProgress?.({ bytesReceived, status: "downloading" });
|
|
427
397
|
controller.enqueue(read.value);
|
|
428
398
|
return pump();
|
|
429
399
|
});
|
|
@@ -432,28 +402,41 @@ var af_common = (() => {
|
|
|
432
402
|
}
|
|
433
403
|
});
|
|
434
404
|
response = new Response(stream);
|
|
435
|
-
} catch
|
|
405
|
+
} catch {
|
|
436
406
|
}
|
|
437
407
|
const blob = await response.blob();
|
|
438
|
-
onProgress
|
|
408
|
+
onProgress?.({ bytesReceived, status: "downloaded" });
|
|
439
409
|
await downloadBlob(blob, fileName);
|
|
440
|
-
onProgress
|
|
410
|
+
onProgress?.({ bytesReceived, status: "completed" });
|
|
441
411
|
} catch (err) {
|
|
442
|
-
if (signal
|
|
443
|
-
onProgress
|
|
412
|
+
if (signal?.aborted) {
|
|
413
|
+
onProgress?.({ status: "cancelled" });
|
|
444
414
|
} else {
|
|
445
|
-
onProgress
|
|
415
|
+
onProgress?.({ error: err.message, status: "error" });
|
|
446
416
|
}
|
|
447
417
|
}
|
|
448
418
|
}
|
|
449
419
|
|
|
450
420
|
// src/parseFunc.ts
|
|
451
421
|
var funcRegex = /^function(?:\s+([a-zA-Z$_][a-zA-Z0-9$_]*))?\s*\(((?:(?:\s*[a-zA-Z$_][a-zA-Z0-9$_]*)(?:\s*,\s*[a-zA-Z$_][a-zA-Z0-9$_]*)*)?)\s*\)\s*\{((?:.|\n|\r)*)\}$/;
|
|
422
|
+
var arrowBlockRegex = /^(?:\(([^)]*)\)|([a-zA-Z$_][a-zA-Z0-9$_]*))\s*=>\s*\{([\s\S]*)\}$/;
|
|
423
|
+
var arrowExpressionRegex = /^(?:\(([^)]*)\)|([a-zA-Z$_][a-zA-Z0-9$_]*))\s*=>\s*([\s\S]+)$/;
|
|
424
|
+
var parseArguments = (args) => args.split(",").map((a) => a.trim()).filter(Boolean);
|
|
452
425
|
function parseFunc(func) {
|
|
453
|
-
|
|
454
|
-
const
|
|
426
|
+
const funcString = func.toString();
|
|
427
|
+
const arrowBlockMatch = funcString.match(arrowBlockRegex);
|
|
428
|
+
if (arrowBlockMatch) {
|
|
429
|
+
const args = parseArguments(arrowBlockMatch[1] ?? arrowBlockMatch[2] ?? "");
|
|
430
|
+
return { name: func.name, args, body: arrowBlockMatch[3] };
|
|
431
|
+
}
|
|
432
|
+
const arrowExpressionMatch = funcString.match(arrowExpressionRegex);
|
|
433
|
+
if (arrowExpressionMatch) {
|
|
434
|
+
const args = parseArguments(arrowExpressionMatch[1] ?? arrowExpressionMatch[2] ?? "");
|
|
435
|
+
return { name: func.name, args, body: arrowExpressionMatch[3] };
|
|
436
|
+
}
|
|
437
|
+
const match = funcString.match(funcRegex);
|
|
455
438
|
invariant(match, "Unable to parse function!");
|
|
456
|
-
return { name:
|
|
439
|
+
return { name: func.name ?? match[1], args: parseArguments(match[2]), body: match[3] };
|
|
457
440
|
}
|
|
458
441
|
|
|
459
442
|
// src/Namespace.ts
|
|
@@ -507,8 +490,8 @@ var af_common = (() => {
|
|
|
507
490
|
} else {
|
|
508
491
|
invariant(false, "Invalid typeof parameter 'name', or unable to parse pValue!");
|
|
509
492
|
}
|
|
510
|
-
if (Object.hasOwn(namespace, keyName) &&
|
|
511
|
-
console.warn(
|
|
493
|
+
if (Object.hasOwn(namespace, keyName) && options?.overwrite !== true) {
|
|
494
|
+
console.warn(`${[name, keyName].join(".")} is already defined!`);
|
|
512
495
|
} else {
|
|
513
496
|
namespace[keyName] = value;
|
|
514
497
|
}
|
|
@@ -518,7 +501,7 @@ var af_common = (() => {
|
|
|
518
501
|
// src/getLocalizedString.ts
|
|
519
502
|
async function fetchLocalizedString(text) {
|
|
520
503
|
try {
|
|
521
|
-
let response = await fetch(
|
|
504
|
+
let response = await fetch(`/api/user/localize/new/${af.article.id}`, {
|
|
522
505
|
body: JSON.stringify({ text }),
|
|
523
506
|
headers: {
|
|
524
507
|
Accept: "application/json; */*",
|
|
@@ -530,19 +513,18 @@ var af_common = (() => {
|
|
|
530
513
|
if (response.ok) {
|
|
531
514
|
return await response.json();
|
|
532
515
|
}
|
|
533
|
-
} catch
|
|
516
|
+
} catch {
|
|
534
517
|
}
|
|
535
518
|
return text;
|
|
536
519
|
}
|
|
537
520
|
function getLocalizedString(string, wait) {
|
|
538
|
-
var _a3, _b2;
|
|
539
521
|
if (typeof string === "string" && string.trim().length === 0) {
|
|
540
522
|
return string;
|
|
541
523
|
}
|
|
542
524
|
if (string === void 0 || string === "" || string === null) {
|
|
543
525
|
return;
|
|
544
526
|
}
|
|
545
|
-
if (
|
|
527
|
+
if (window.af?.article?.i18n !== void 0) {
|
|
546
528
|
if (!Object.hasOwn(af.article.i18n, string)) {
|
|
547
529
|
af.article.i18n[string] = string;
|
|
548
530
|
let promise = fetchLocalizedString(string).then((text) => {
|
|
@@ -575,7 +557,7 @@ var af_common = (() => {
|
|
|
575
557
|
return "";
|
|
576
558
|
}
|
|
577
559
|
let sizePx = sizeMap[size];
|
|
578
|
-
return
|
|
560
|
+
return `/api/data/blob/EmployeesLookup/${primKeyOrOptions}/Image/${encodeURIComponent(login ?? "")}${login ? "." : ""}${encodeURIComponent(hash)}.jpg${sizePx ? `?width=${sizePx}` : ""}`;
|
|
579
561
|
}
|
|
580
562
|
|
|
581
563
|
// src/localize.ts
|
|
@@ -584,16 +566,25 @@ var af_common = (() => {
|
|
|
584
566
|
Array.isArray(stringParts) && stringParts.length === args.length + 1,
|
|
585
567
|
"Method 'localize' must be used as a tag function"
|
|
586
568
|
);
|
|
587
|
-
let stringToLocalize = stringParts.map((s, i) => i === stringParts.length - 1 ? s :
|
|
569
|
+
let stringToLocalize = stringParts.map((s, i) => i === stringParts.length - 1 ? s : `${s}$${i}`).join("");
|
|
588
570
|
let localized = getLocalizedString(stringToLocalize);
|
|
589
571
|
args.forEach((arg, index) => {
|
|
590
|
-
localized = localized.replace(
|
|
572
|
+
localized = localized.replace(`$${index}`, arg);
|
|
591
573
|
});
|
|
592
574
|
return localized;
|
|
593
575
|
}
|
|
594
576
|
|
|
595
577
|
// src/alert.ts
|
|
596
|
-
var template =
|
|
578
|
+
var template = `
|
|
579
|
+
<dialog class="alert-dialog">
|
|
580
|
+
<form method="dialog">
|
|
581
|
+
<article></article>
|
|
582
|
+
<footer>
|
|
583
|
+
<menu></menu>
|
|
584
|
+
</footer>
|
|
585
|
+
</form>
|
|
586
|
+
</dialog>
|
|
587
|
+
`;
|
|
597
588
|
if (window.document && !document.querySelector("#AlertDialogTemplate")) {
|
|
598
589
|
let $template = document.createElement("template");
|
|
599
590
|
$template.id = "AlertDialogTemplate";
|
|
@@ -623,25 +614,24 @@ var af_common = (() => {
|
|
|
623
614
|
}
|
|
624
615
|
var alertDialogPromiseMap = /* @__PURE__ */ new Map();
|
|
625
616
|
async function openAlertDialog({ buttons, content, className, id, title }) {
|
|
626
|
-
var _a3, _b2;
|
|
627
617
|
if (id && alertDialogPromiseMap.has(id)) {
|
|
628
618
|
return await alertDialogPromiseMap.get(id);
|
|
629
619
|
}
|
|
630
620
|
let $template = document.querySelector("#AlertDialogTemplate");
|
|
631
621
|
if (!$template) throw Error("No alert dialog template found");
|
|
632
|
-
let $dialog =
|
|
633
|
-
let $content = $dialog
|
|
634
|
-
let $menu = $dialog
|
|
622
|
+
let $dialog = $template.content.firstElementChild?.cloneNode(true);
|
|
623
|
+
let $content = $dialog?.querySelector("article");
|
|
624
|
+
let $menu = $dialog?.querySelector("footer menu");
|
|
635
625
|
if (!$dialog || !$content || !$menu) throw Error("Invalid alert dialog template");
|
|
636
626
|
if (className) {
|
|
637
627
|
for (const className_ of className.split(/\s+/)) {
|
|
638
|
-
$dialog
|
|
628
|
+
$dialog?.classList.add(className_);
|
|
639
629
|
}
|
|
640
630
|
}
|
|
641
631
|
if (title) {
|
|
642
632
|
let $header = document.createElement("header");
|
|
643
633
|
$header.append(title);
|
|
644
|
-
|
|
634
|
+
$content.parentNode?.insertBefore($header, $content);
|
|
645
635
|
}
|
|
646
636
|
$content.appendChild(typeof content === "string" ? document.createTextNode(content) : content);
|
|
647
637
|
for (let { label, value, primary } of buttons) {
|
|
@@ -687,22 +677,21 @@ var af_common = (() => {
|
|
|
687
677
|
return result === "yes";
|
|
688
678
|
}
|
|
689
679
|
async function alert(prompt, options = {}) {
|
|
690
|
-
await openAlertDialog(
|
|
680
|
+
await openAlertDialog({
|
|
691
681
|
content: prompt,
|
|
692
682
|
className: "alert-dialog-alert",
|
|
693
|
-
buttons: [{ label: getLocalizedString("OK"), value: "ok", primary: true }]
|
|
694
|
-
|
|
683
|
+
buttons: [{ label: getLocalizedString("OK"), value: "ok", primary: true }],
|
|
684
|
+
...options
|
|
685
|
+
});
|
|
695
686
|
}
|
|
696
687
|
|
|
697
688
|
// src/settings.ts
|
|
698
689
|
function getKey(article2) {
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
return "".concat(articleKey, ".").concat((_f = (_e = window.af) == null ? void 0 : _e.userSession.login) != null ? _f : "anonymous");
|
|
690
|
+
const articleKey = article2 ?? window.af?.article?.id ?? window.window?.location.pathname.substring(1).split("/")[0];
|
|
691
|
+
return `${articleKey}.${window.af?.userSession.login ?? "anonymous"}`;
|
|
702
692
|
}
|
|
703
693
|
function getSettings(setting, article2) {
|
|
704
|
-
|
|
705
|
-
if (!((_a3 = window.af) == null ? void 0 : _a3.userSession)) return null;
|
|
694
|
+
if (!window.af?.userSession) return null;
|
|
706
695
|
const key = getKey(article2);
|
|
707
696
|
const settings = JSON.parse(localStorage.getItem(key) || "{}");
|
|
708
697
|
if (setting) {
|
|
@@ -711,8 +700,7 @@ var af_common = (() => {
|
|
|
711
700
|
return settings;
|
|
712
701
|
}
|
|
713
702
|
function saveSettings(setting, value, article2) {
|
|
714
|
-
|
|
715
|
-
if (!((_a3 = window.af) == null ? void 0 : _a3.userSession)) return;
|
|
703
|
+
if (!window.af?.userSession) return;
|
|
716
704
|
const key = getKey(article2);
|
|
717
705
|
let userSettings = JSON.parse(localStorage.getItem(key) || "{}");
|
|
718
706
|
if (typeof value !== "undefined") {
|
|
@@ -724,6 +712,6 @@ var af_common = (() => {
|
|
|
724
712
|
}
|
|
725
713
|
|
|
726
714
|
// src/index.ts
|
|
727
|
-
var version = "2.11.
|
|
715
|
+
var version = "2.11.10";
|
|
728
716
|
return __toCommonJS(index_exports);
|
|
729
717
|
})();
|
|
@@ -1,2 +1,11 @@
|
|
|
1
|
-
var af_common=(()=>{var A=Object.defineProperty,ye=Object.defineProperties,he=Object.getOwnPropertyDescriptor,Se=Object.getOwnPropertyDescriptors,be=Object.getOwnPropertyNames,q=Object.getOwnPropertySymbols;var k=Object.prototype.hasOwnProperty,xe=Object.prototype.propertyIsEnumerable;var O=(e,t,o)=>t in e?A(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,g=(e,t)=>{for(var o in t||(t={}))k.call(t,o)&&O(e,o,t[o]);if(q)for(var o of q(t))xe.call(t,o)&&O(e,o,t[o]);return e},B=(e,t)=>ye(e,Se(t));var we=(e,t)=>{for(var o in t)A(e,o,{get:t[o],enumerable:!0})},ve=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of be(t))!k.call(e,r)&&r!==o&&A(e,r,{get:()=>t[r],enumerable:!(n=he(t,r))||n.enumerable});return e};var De=e=>ve(A({},"__esModule",{value:!0}),e);var l=(e,t,o)=>O(e,typeof t!="symbol"?t+"":t,o);var je={};we(je,{ConfirmButtons:()=>M,SessionHandler:()=>p,UserSession:()=>L,alert:()=>ce,confirm:()=>se,downloadBlob:()=>j,downloadRequest:()=>re,expose:()=>_,getLocalizedString:()=>u,getSessionData:()=>E,getSettings:()=>de,getUserImage:()=>U,invariant:()=>c,localStorage:()=>te,localize:()=>le,logActivity:()=>T,logError:()=>w,mitt:()=>I,openAlertDialog:()=>z,saveSettings:()=>fe,startActivity:()=>X,time:()=>G,toLocalDateTime:()=>oe,toLocalISODate:()=>ne,toLocalISODateTime:()=>$,version:()=>Ee,waitForDialog:()=>H});function I(e){return{all:e=e||new Map,on:function(t,o){var n=e.get(t);n?n.push(o):e.set(t,[o])},off:function(t,o){var n=e.get(t);n&&(o?n.splice(n.indexOf(o)>>>0,1):e.set(t,[]))},emit:function(t,o){var n=e.get(t);n&&n.slice().map(function(r){r(o)}),(n=e.get("*"))&&n.slice().map(function(r){r(t,o)})}}}var p=class{constructor(){l(this,"eventHandler",I())}authenticated(){this.eventHandler.emit("onAuthenticated")}async expired(t,o){try{let n=new Promise(i=>{let a=()=>{this.eventHandler.off("onAuthenticated",a),t==null||t(),i()};this.eventHandler.on("onAuthenticated",a)}),r=document.querySelector("dialog.session-expired-dialog");if(r)await n;else{r=document.createElement("dialog"),r.className="session-expired-dialog",r.style.display="flex",r.style.padding="0",r.style.left="50%",r.style.transform="translateX(-50%)";let i="/login?ReturnUrl=%2fapi/sessionexpired/remove";o!=="RequireTwoFactor"?await fetch("/logout",{method:"POST"}):i="/login?RequireTwoFactor=1&ReturnUrl=%2fapi/sessionexpired/remove",r.innerHTML='<iframe sandbox="allow-same-origin allow-scripts allow-modals allow-top-navigation-by-user-activation allow-forms" src="'.concat(i,'" style="border:0;width:min(500px,100vw);height:min(700px, 100vh);"></iframe>'),document.body.append(r),r.showModal(),await n,r.remove()}}catch(n){window.location.href="/login?ReturnUrl=".concat(encodeURIComponent(window.location.pathname)).concat(encodeURIComponent(window.location.search))}}attachEvent(t,o){return this.eventHandler.on(t,o)}detachEvent(t,o){return this.eventHandler.off(t,o)}};var L=class extends p{constructor(o){super();l(this,"amDesignator","a.m.");l(this,"dayNames",["sunday","monday","tuesday","wednesday","thursday","friday","saturday"]);l(this,"dayNamesShort",["sun","mon","tue","wed","thu","fri","sat"]);l(this,"decimalSeparator",".");l(this,"domain","OB");l(this,"email");l(this,"formats");l(this,"groupSeparator",null);l(this,"integratedSecurity",!1);l(this,"isDeveloper",!1);l(this,"login","");l(this,"loginType");l(this,"monthNames",["january","february","march","april","may","june","july","august","september","october","november","december",""]);l(this,"monthNamesShort",["jan","feb","mar","apr","may","jun","jul","augt","sep","oct","nov","dec",""]);l(this,"name");l(this,"pmDesignator","p.m.");l(this,"shortDateFormat","dd.MM.yyyy");l(this,"culture","en-GB");l(this,"uiculture","en-GB");this.formats={},Object.assign(this,o)}};var J,K,V,Z,Y=(Z=(K=(J=window.af)==null?void 0:J.article)==null?void 0:K.id)!=null?Z:(V=window.window)==null?void 0:V.location.pathname.substring(1).split("/")[0];async function T(e,t={},o=0){var n;try{let r=await fetch("/api/logging/log-activity",{method:"POST",body:JSON.stringify({article:Y,timeElapsed:o,action:e,parameters:B(g({},t),{_session:E()})}),headers:{"Content-Type":"application/json",Accept:"application/json"}});if(!r.ok)if((n=r.headers.get("Content-Type"))!=null&&n.includes("application/json")){let i=await r.json();console.error(i.error)}else console.error("".concat(r.status," ").concat(r.statusText))}catch(r){}}function X(e,t={}){let o=performance.now();return(n={})=>T(e,g(g({},t),n),performance.now()-o)}async function G(e){let t=performance.now();return[await e(),performance.now()-t]}async function w(e){var t;try{if(!e)return;let o=typeof e=="string"?{error:e}:typeof e=="object"?"message"in e?{error:e.message,stack:(t=e.stack)!=null?t:null}:{error:e.toString()}:{error:"Unspecified error"};console.error(e);let n=await fetch("/data/Logger/LogError",{method:"POST",body:JSON.stringify(o),headers:{"Content-Type":"application/json; charset=utf-8"}});if(n.ok)return await n.json();console.error(Error("Failed to log error"))}catch(o){}}function W(){var e;return(e=crypto.randomUUID)==null?void 0:e.call(crypto)}var F=Date.now(),Q=W(),b="",x="";if("document"in window){let e=()=>{var t,o,n,r,i,a;return T("AfSessionInit",{"appframe-core":(o=(t=window.af)==null?void 0:t.common)==null?void 0:o.version,"appframe-data":(r=(n=window.af)==null?void 0:n.data)==null?void 0:r.version,"app-version":(a=(i=window.af)==null?void 0:i.article)==null?void 0:a.version})};document.addEventListener("DOMContentLoaded",()=>{b=localStorage.getItem("_afDeviceId"),x=sessionStorage.getItem("_afSessionId"),b||(b=W(),localStorage.setItem("_afDeviceId",b)),x||(x=Q,sessionStorage.setItem("_afSessionId",x)),e()}),document.addEventListener("visibilitychange",function(){document.visibilityState==="hidden"?navigator.sendBeacon("/api/logging/log-activity",JSON.stringify({article:Y,action:"AfSessionEnd",parameters:{_session:E()}})):e()})}function E(){return{browserSessionId:x,sessionStart:F,sessionLength:Date.now()-F,sessionId:Q,deviceId:b}}var P;(P=window.window)==null||P.addEventListener("error",e=>{typeof e=="object"&&"error"in e?w(e.error):typeof e=="object"&&"message"in e&&w(e)});function ee(e){var t;return[((t=af==null?void 0:af.article)==null?void 0:t.id)||"","common",e].join(".")}var N=class{constructor(){l(this,"isPersisted",()=>!0)}getLocalStorageKey(t,o){return o?["common",t].join("."):ee(t)}get(t,o,n){let r=this.getLocalStorageKey(t,n),i=localStorage.getItem(r);return i!==null?JSON.parse(i):o}set(t,o,n){localStorage.setItem(this.getLocalStorageKey(t,n),JSON.stringify(o))}remove(t,o){let n=this.getLocalStorageKey(t,o);return localStorage.getItem(n)!==null?(localStorage.removeItem(n),!0):!1}clear(){let t=ee("");for(let o in localStorage)o.slice(0,t.length)===t&&localStorage.removeItem(o)}},te=new N;function ne(e){return e?$(e).substring(0,10):null}function m(e,t=2){return String(e).padStart(t,"0")}function $(e){return e?"".concat(e.getFullYear(),"-").concat(m(e.getMonth()+1),"-").concat(m(e.getDate()),"T").concat(m(e.getHours()),":").concat(m(e.getMinutes()),":").concat(m(e.getSeconds()),".").concat(m(e.getMilliseconds(),3)):null}function oe(e){return e?e.toISOString().substring(0,16):""}function j(e,t){return new Promise((o,n)=>{try{let r=URL.createObjectURL(e),i=document.body,a=document.createElement("a");a.setAttribute("download",t),a.href=r,i.append(a),a.click(),i.removeChild(a),setTimeout(()=>{URL.revokeObjectURL(r),o()},250)}catch(r){n(r)}})}function c(e,t){if(e)return;let o=typeof t=="function"?t():t;throw new Error(o!=null?o:"Invariant failed")}async function re(e,{fileName:t,signal:o,onProgress:n}){var i;let r=0;n==null||n({status:"requested"});try{let a=await fetch(e);if(!a.ok||!a.body){if((i=a.headers.get("content-type"))!=null&&i.includes("application/json")){let f=await a.json();c(!f.error,f.error)}throw new Error("".concat(a.status," ").concat(a.statusText))}try{let f=a.body.getReader(),D=new ReadableStream({start:y=>{function h(){return f.read().then(s=>{if(s.done){y.close();return}return r+=s.value.length,n==null||n({bytesReceived:r,status:"downloading"}),y.enqueue(s.value),h()})}return h()}});a=new Response(D)}catch(f){}let d=await a.blob();n==null||n({bytesReceived:r,status:"downloaded"}),await j(d,t),n==null||n({bytesReceived:r,status:"completed"})}catch(a){o!=null&&o.aborted?n==null||n({status:"cancelled"}):n==null||n({error:a.message,status:"error"})}}var Ae=/^function(?:\s+([a-zA-Z$_][a-zA-Z0-9$_]*))?\s*\(((?:(?:\s*[a-zA-Z$_][a-zA-Z0-9$_]*)(?:\s*,\s*[a-zA-Z$_][a-zA-Z0-9$_]*)*)?)\s*\)\s*\{((?:.|\n|\r)*)\}$/;function R(e){var o;let t=e.toString().match(Ae);return c(t,"Unable to parse function!"),{name:(o=e.name)!=null?o:t[1],args:t[2].split(",").map(n=>n.trim()),body:t[3]}}function ie(){}ie.prototype=Object.create(null);var ae=ie;function C(e,t){if(typeof e=="object"){if(typeof t=="string"){let o=t.split(".");return C(e,o)}else if(Array.isArray(t)){let o=e;for(let n=0;n<t.length;n++)o=o[t[n]]=o[t[n]]||new ae;return o}}}function _(e,t,o={}){if(Array.isArray(t))for(let n of t){let{name:r}=R(n);c(r,"Unable to detect name of function! Name it, or only supply one function and include name in first parameter."),_(e,n)}else{let n,r;if(typeof t=="function"&&(n=R(t).name),typeof e=="string"){let i=e.split(".");n||(n=i[i.length-1],i=i.slice(0,i.length-1)),r=C(window,i)}else n&&(typeof e=="object"||typeof e=="function")?r=e:c(!1,"Invalid typeof parameter 'name', or unable to parse pValue!");Object.hasOwn(r,n)&&(o==null?void 0:o.overwrite)!==!0?console.warn("".concat([e,n].join(".")," is already defined!")):r[n]=t}}async function Ie(e){try{let t=await fetch("/api/user/localize/new/".concat(af.article.id),{body:JSON.stringify({text:e}),headers:{Accept:"application/json; */*","Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},method:"POST"});if(t.ok)return await t.json()}catch(t){}return e}function u(e,t){var o,n;if(typeof e=="string"&&e.trim().length===0)return e;if(!(e===void 0||e===""||e===null))if(((n=(o=window.af)==null?void 0:o.article)==null?void 0:n.i18n)!==void 0){if(!Object.hasOwn(af.article.i18n,e)){af.article.i18n[e]=e;let r=Ie(e).then(i=>(af.article.i18n[e]=i,i));if(t)return r}return af.article.i18n[e]}else return e}var Le={xs:64,sm:128,md:256,lg:512,xl:void 0};function U(e,t,o,n="xs"){if(e&&typeof e=="object")return U(e.primKey,e.login,e.hash,e.size);if(!e||!o)return"";let r=Le[n];return"/api/data/blob/EmployeesLookup/".concat(e,"/Image/").concat(encodeURIComponent(t!=null?t:"")).concat(t?".":"").concat(encodeURIComponent(o),".jpg").concat(r?"?width=".concat(r):"")}function le(e,...t){c(Array.isArray(e)&&e.length===t.length+1,"Method 'localize' must be used as a tag function");let o=e.map((r,i)=>i===e.length-1?r:"".concat(r,"$").concat(i)).join(""),n=u(o);return t.forEach((r,i)=>{n=n.replace("$".concat(i),r)}),n}var Te='\n <dialog class="alert-dialog">\n <form method="dialog">\n <article></article>\n <footer>\n <menu></menu>\n </footer>\n </form>\n </dialog>\n';if(window.document&&!document.querySelector("#AlertDialogTemplate")){let e=document.createElement("template");e.id="AlertDialogTemplate",e.innerHTML=Te,document.body.append(e)}function H(e,t="No"){return new Promise(o=>{let n=new AbortController;e.addEventListener("close",()=>{o(e.returnValue),n.abort()},{signal:n.signal}),e.addEventListener("cancel",()=>{o(t),n.abort()},{signal:n.signal})})}var v=new Map;async function z({buttons:e,content:t,className:o,id:n,title:r}){var y,h;if(n&&v.has(n))return await v.get(n);let i=document.querySelector("#AlertDialogTemplate");if(!i)throw Error("No alert dialog template found");let a=(y=i.content.firstElementChild)==null?void 0:y.cloneNode(!0),d=a==null?void 0:a.querySelector("article"),f=a==null?void 0:a.querySelector("footer menu");if(!a||!d||!f)throw Error("Invalid alert dialog template");if(o)for(let s of o.split(/\s+/))a==null||a.classList.add(s);if(r){let s=document.createElement("header");s.append(r),(h=d.parentNode)==null||h.insertBefore(s,d)}d.appendChild(typeof t=="string"?document.createTextNode(t):t);for(let{label:s,value:pe,primary:ge}of e){let me=document.createElement("li"),S=document.createElement("button");S.value=pe,ge&&S.classList.add("primary"),S.textContent=s,me.appendChild(S),f.appendChild(S)}document.body.appendChild(a),a.showModal();let D=H(a).then(s=>(n&&v.has(n)&&v.delete(n),a&&document.body.removeChild(a),s));return n&&v.set(n,D),await D}var M=(o=>(o[o.YesNo=0]="YesNo",o[o.OkCancel=1]="OkCancel",o))(M||{});async function se(e,t={}){let{buttons:o=0,title:n}=t,r=o===1?[{label:u("OK"),value:"yes",primary:!0},{label:u("Cancel"),value:"no"}]:[{label:u("Yes"),value:"yes",primary:!0},{label:u("No"),value:"no"}];return await z({content:e,buttons:r,className:"alert-dialog-confirm",title:n})==="yes"}async function ce(e,t={}){await z(g({content:e,className:"alert-dialog-alert",buttons:[{label:u("OK"),value:"ok",primary:!0}]},t))}function ue(e){var o,n,r,i,a,d;let t=(i=e!=null?e:(n=(o=window.af)==null?void 0:o.article)==null?void 0:n.id)!=null?i:(r=window.window)==null?void 0:r.location.pathname.substring(1).split("/")[0];return"".concat(t,".").concat((d=(a=window.af)==null?void 0:a.userSession.login)!=null?d:"anonymous")}function de(e,t){var r;if(!((r=window.af)!=null&&r.userSession))return null;let o=ue(t),n=JSON.parse(localStorage.getItem(o)||"{}");return e?n[e]||null:n}function fe(e,t,o){var i;if(!((i=window.af)!=null&&i.userSession))return;let n=ue(o),r=JSON.parse(localStorage.getItem(n)||"{}");typeof t<"u"?r[e]=t:r=e,localStorage.setItem(n,JSON.stringify(r))}var Ee="2.11.8";return De(je);})();
|
|
1
|
+
var af;(af||={}).common=(()=>{var T=Object.defineProperty;var re=Object.getOwnPropertyDescriptor;var ie=Object.getOwnPropertyNames;var ae=Object.prototype.hasOwnProperty;var se=(e,t)=>{for(var n in t)T(e,n,{get:t[n],enumerable:!0})},le=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ie(t))!ae.call(e,r)&&r!==n&&T(e,r,{get:()=>t[r],enumerable:!(o=re(t,r))||o.enumerable});return e};var ce=e=>le(T({},"__esModule",{value:!0}),e);var he={};se(he,{ConfirmButtons:()=>C,SessionHandler:()=>g,UserSession:()=>v,alert:()=>W,confirm:()=>G,downloadBlob:()=>I,downloadRequest:()=>K,expose:()=>N,getLocalizedString:()=>c,getSessionData:()=>D,getSettings:()=>ee,getUserImage:()=>R,invariant:()=>l,localStorage:()=>F,localize:()=>X,logActivity:()=>A,logError:()=>b,mitt:()=>w,openAlertDialog:()=>L,saveSettings:()=>te,startActivity:()=>H,time:()=>k,toLocalDateTime:()=>J,toLocalISODate:()=>Z,toLocalISODateTime:()=>$,version:()=>ye,waitForDialog:()=>_});function w(e){return{all:e=e||new Map,on:function(t,n){var o=e.get(t);o?o.push(n):e.set(t,[n])},off:function(t,n){var o=e.get(t);o&&(n?o.splice(o.indexOf(n)>>>0,1):e.set(t,[]))},emit:function(t,n){var o=e.get(t);o&&o.slice().map(function(r){r(n)}),(o=e.get("*"))&&o.slice().map(function(r){r(t,n)})}}}var g=class{eventHandler=w();authenticated(){this.eventHandler.emit("onAuthenticated")}async expired(t,n){try{let o=new Promise(i=>{let a=()=>{this.eventHandler.off("onAuthenticated",a),t?.(),i()};this.eventHandler.on("onAuthenticated",a)}),r=document.querySelector("dialog.session-expired-dialog");if(r)await o;else{r=document.createElement("dialog"),r.className="session-expired-dialog",r.style.display="flex",r.style.padding="0",r.style.left="50%",r.style.transform="translateX(-50%)";let i="/login?ReturnUrl=%2fapi/sessionexpired/remove";n!=="RequireTwoFactor"?await fetch("/logout",{method:"POST"}):i="/login?RequireTwoFactor=1&ReturnUrl=%2fapi/sessionexpired/remove",r.innerHTML=`<iframe sandbox="allow-same-origin allow-scripts allow-modals allow-top-navigation-by-user-activation allow-forms" src="${i}" style="border:0;width:min(500px,100vw);height:min(700px, 100vh);"></iframe>`,document.body.append(r),r.showModal(),await o,r.remove()}}catch{window.location.href=`/login?ReturnUrl=${encodeURIComponent(window.location.pathname)}${encodeURIComponent(window.location.search)}`}}attachEvent(t,n){return this.eventHandler.on(t,n)}detachEvent(t,n){return this.eventHandler.off(t,n)}};var v=class extends g{amDesignator="a.m.";dayNames=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];dayNamesShort=["sun","mon","tue","wed","thu","fri","sat"];decimalSeparator=".";domain="OB";email;formats;groupSeparator=null;integratedSecurity=!1;isDeveloper=!1;login="";loginType;monthNames=["january","february","march","april","may","june","july","august","september","october","november","december",""];monthNamesShort=["jan","feb","mar","apr","may","jun","jul","augt","sep","oct","nov","dec",""];name;pmDesignator="p.m.";shortDateFormat="dd.MM.yyyy";culture="en-GB";uiculture="en-GB";constructor(t){super(),this.formats={},Object.assign(this,t)}};var M=window.af?.article?.id??window.window?.location.pathname.substring(1).split("/")[0];async function A(e,t={},n=0){try{let o=await fetch("/api/logging/log-activity",{method:"POST",body:JSON.stringify({article:M,timeElapsed:n,action:e,parameters:{...t,_session:D()}}),headers:{"Content-Type":"application/json",Accept:"application/json"}});if(!o.ok)if(o.headers.get("Content-Type")?.includes("application/json")){let r=await o.json();console.error(r.error)}else console.error(`${o.status} ${o.statusText}`)}catch{}}function H(e,t={}){let n=performance.now();return(o={})=>A(e,{...t,...o},performance.now()-n)}async function k(e){let t=performance.now();return[await e(),performance.now()-t]}async function b(e){try{if(!e)return;let t=typeof e=="string"?{error:e}:typeof e=="object"?"message"in e?{error:e.message,stack:e.stack??null}:{error:e.toString()}:{error:"Unspecified error"};console.error(e);let n=await fetch("/data/Logger/LogError",{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json; charset=utf-8"}});if(n.ok)return await n.json();console.error(Error("Failed to log error"))}catch{}}function P(){return crypto.randomUUID?.()}var U=Date.now(),q=P(),y="",h="";if("document"in window){let e=()=>A("AfSessionInit",{"appframe-core":window.af?.common?.version,"appframe-data":window.af?.data?.version,"app-version":window.af?.article?.version});document.addEventListener("DOMContentLoaded",()=>{y=localStorage.getItem("_afDeviceId"),h=sessionStorage.getItem("_afSessionId"),y||(y=P(),localStorage.setItem("_afDeviceId",y)),h||(h=q,sessionStorage.setItem("_afSessionId",h)),e()}),document.addEventListener("visibilitychange",function(){document.visibilityState==="hidden"?navigator.sendBeacon("/api/logging/log-activity",JSON.stringify({article:M,action:"AfSessionEnd",parameters:{_session:D()}})):e()})}function D(){return{browserSessionId:h,sessionStart:U,sessionLength:Date.now()-U,sessionId:q,deviceId:y}}window.window?.addEventListener("error",e=>{typeof e=="object"&&"error"in e?b(e.error):typeof e=="object"&&"message"in e&&b(e)});function B(e){return[af?.article?.id||"","common",e].join(".")}var E=class{isPersisted=()=>!0;getLocalStorageKey(t,n){return n?["common",t].join("."):B(t)}get(t,n,o){let r=this.getLocalStorageKey(t,o),i=localStorage.getItem(r);return i!==null?JSON.parse(i):n}set(t,n,o){localStorage.setItem(this.getLocalStorageKey(t,o),JSON.stringify(n))}remove(t,n){let o=this.getLocalStorageKey(t,n);return localStorage.getItem(o)!==null?(localStorage.removeItem(o),!0):!1}clear(){let t=B("");for(let n in localStorage)n.slice(0,t.length)===t&&localStorage.removeItem(n)}},F=new E;function Z(e){return e?$(e).substring(0,10):null}function d(e,t=2){return String(e).padStart(t,"0")}function $(e){return e?`${e.getFullYear()}-${d(e.getMonth()+1)}-${d(e.getDate())}T${d(e.getHours())}:${d(e.getMinutes())}:${d(e.getSeconds())}.${d(e.getMilliseconds(),3)}`:null}function J(e){return e?e.toISOString().substring(0,16):""}function I(e,t){return new Promise((n,o)=>{try{let r=URL.createObjectURL(e),i=document.body,a=document.createElement("a");a.setAttribute("download",t),a.href=r,i.append(a),a.click(),i.removeChild(a),setTimeout(()=>{URL.revokeObjectURL(r),n()},250)}catch(r){o(r)}})}function l(e,t){if(e)return;let n=typeof t=="function"?t():t;throw new Error(n??"Invariant failed")}async function K(e,{fileName:t,signal:n,onProgress:o}){let r=0;o?.({status:"requested"});try{let i=await fetch(e);if(!i.ok||!i.body){if(i.headers.get("content-type")?.includes("application/json")){let u=await i.json();l(!u.error,u.error)}throw new Error(`${i.status} ${i.statusText}`)}try{let u=i.body.getReader(),x=new ReadableStream({start:p=>{function s(){return u.read().then(f=>{if(f.done){p.close();return}return r+=f.value.length,o?.({bytesReceived:r,status:"downloading"}),p.enqueue(f.value),s()})}return s()}});i=new Response(x)}catch{}let a=await i.blob();o?.({bytesReceived:r,status:"downloaded"}),await I(a,t),o?.({bytesReceived:r,status:"completed"})}catch(i){n?.aborted?o?.({status:"cancelled"}):o?.({error:i.message,status:"error"})}}var ue=/^function(?:\s+([a-zA-Z$_][a-zA-Z0-9$_]*))?\s*\(((?:(?:\s*[a-zA-Z$_][a-zA-Z0-9$_]*)(?:\s*,\s*[a-zA-Z$_][a-zA-Z0-9$_]*)*)?)\s*\)\s*\{((?:.|\n|\r)*)\}$/,ge=/^(?:\(([^)]*)\)|([a-zA-Z$_][a-zA-Z0-9$_]*))\s*=>\s*\{([\s\S]*)\}$/,de=/^(?:\(([^)]*)\)|([a-zA-Z$_][a-zA-Z0-9$_]*))\s*=>\s*([\s\S]+)$/,z=e=>e.split(",").map(t=>t.trim()).filter(Boolean);function j(e){let t=e.toString(),n=t.match(ge);if(n){let i=z(n[1]??n[2]??"");return{name:e.name,args:i,body:n[3]}}let o=t.match(de);if(o){let i=z(o[1]??o[2]??"");return{name:e.name,args:i,body:o[3]}}let r=t.match(ue);return l(r,"Unable to parse function!"),{name:e.name??r[1],args:z(r[2]),body:r[3]}}function V(){}V.prototype=Object.create(null);var Y=V;function O(e,t){if(typeof e=="object"){if(typeof t=="string"){let n=t.split(".");return O(e,n)}else if(Array.isArray(t)){let n=e;for(let o=0;o<t.length;o++)n=n[t[o]]=n[t[o]]||new Y;return n}}}function N(e,t,n={}){if(Array.isArray(t))for(let o of t){let{name:r}=j(o);l(r,"Unable to detect name of function! Name it, or only supply one function and include name in first parameter."),N(e,o)}else{let o,r;if(typeof t=="function"&&(o=j(t).name),typeof e=="string"){let i=e.split(".");o||(o=i[i.length-1],i=i.slice(0,i.length-1)),r=O(window,i)}else o&&(typeof e=="object"||typeof e=="function")?r=e:l(!1,"Invalid typeof parameter 'name', or unable to parse pValue!");Object.hasOwn(r,o)&&n?.overwrite!==!0?console.warn(`${[e,o].join(".")} is already defined!`):r[o]=t}}async function pe(e){try{let t=await fetch(`/api/user/localize/new/${af.article.id}`,{body:JSON.stringify({text:e}),headers:{Accept:"application/json; */*","Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},method:"POST"});if(t.ok)return await t.json()}catch{}return e}function c(e,t){if(typeof e=="string"&&e.trim().length===0)return e;if(!(e===void 0||e===""||e===null))if(window.af?.article?.i18n!==void 0){if(!Object.hasOwn(af.article.i18n,e)){af.article.i18n[e]=e;let n=pe(e).then(o=>(af.article.i18n[e]=o,o));if(t)return n}return af.article.i18n[e]}else return e}var fe={xs:64,sm:128,md:256,lg:512,xl:void 0};function R(e,t,n,o="xs"){if(e&&typeof e=="object")return R(e.primKey,e.login,e.hash,e.size);if(!e||!n)return"";let r=fe[o];return`/api/data/blob/EmployeesLookup/${e}/Image/${encodeURIComponent(t??"")}${t?".":""}${encodeURIComponent(n)}.jpg${r?`?width=${r}`:""}`}function X(e,...t){l(Array.isArray(e)&&e.length===t.length+1,"Method 'localize' must be used as a tag function");let n=e.map((r,i)=>i===e.length-1?r:`${r}$${i}`).join(""),o=c(n);return t.forEach((r,i)=>{o=o.replace(`$${i}`,r)}),o}var me=`
|
|
2
|
+
<dialog class="alert-dialog">
|
|
3
|
+
<form method="dialog">
|
|
4
|
+
<article></article>
|
|
5
|
+
<footer>
|
|
6
|
+
<menu></menu>
|
|
7
|
+
</footer>
|
|
8
|
+
</form>
|
|
9
|
+
</dialog>
|
|
10
|
+
`;if(window.document&&!document.querySelector("#AlertDialogTemplate")){let e=document.createElement("template");e.id="AlertDialogTemplate",e.innerHTML=me,document.body.append(e)}function _(e,t="No"){return new Promise(n=>{let o=new AbortController;e.addEventListener("close",()=>{n(e.returnValue),o.abort()},{signal:o.signal}),e.addEventListener("cancel",()=>{n(t),o.abort()},{signal:o.signal})})}var S=new Map;async function L({buttons:e,content:t,className:n,id:o,title:r}){if(o&&S.has(o))return await S.get(o);let i=document.querySelector("#AlertDialogTemplate");if(!i)throw Error("No alert dialog template found");let a=i.content.firstElementChild?.cloneNode(!0),u=a?.querySelector("article"),x=a?.querySelector("footer menu");if(!a||!u||!x)throw Error("Invalid alert dialog template");if(n)for(let s of n.split(/\s+/))a?.classList.add(s);if(r){let s=document.createElement("header");s.append(r),u.parentNode?.insertBefore(s,u)}u.appendChild(typeof t=="string"?document.createTextNode(t):t);for(let{label:s,value:f,primary:oe}of e){let ne=document.createElement("li"),m=document.createElement("button");m.value=f,oe&&m.classList.add("primary"),m.textContent=s,ne.appendChild(m),x.appendChild(m)}document.body.appendChild(a),a.showModal();let p=_(a).then(s=>(o&&S.has(o)&&S.delete(o),a&&document.body.removeChild(a),s));return o&&S.set(o,p),await p}var C=(n=>(n[n.YesNo=0]="YesNo",n[n.OkCancel=1]="OkCancel",n))(C||{});async function G(e,t={}){let{buttons:n=0,title:o}=t,r=n===1?[{label:c("OK"),value:"yes",primary:!0},{label:c("Cancel"),value:"no"}]:[{label:c("Yes"),value:"yes",primary:!0},{label:c("No"),value:"no"}];return await L({content:e,buttons:r,className:"alert-dialog-confirm",title:o})==="yes"}async function W(e,t={}){await L({content:e,className:"alert-dialog-alert",buttons:[{label:c("OK"),value:"ok",primary:!0}],...t})}function Q(e){return`${e??window.af?.article?.id??window.window?.location.pathname.substring(1).split("/")[0]}.${window.af?.userSession.login??"anonymous"}`}function ee(e,t){if(!window.af?.userSession)return null;let n=Q(t),o=JSON.parse(localStorage.getItem(n)||"{}");return e?o[e]||null:o}function te(e,t,n){if(!window.af?.userSession)return;let o=Q(n),r=JSON.parse(localStorage.getItem(o)||"{}");typeof t<"u"?r[e]=t:r=e,localStorage.setItem(o,JSON.stringify(r))}var ye="2.11.10";return ce(he);})();
|
|
2
11
|
//# sourceMappingURL=af.common.legacy.min.js.map
|