@olenbetong/appframe-core 2.10.2 → 2.11.1
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 +131 -146
- package/dist/esm/af.common.legacy.js +137 -152
- package/dist/esm/af.common.legacy.min.js +1 -1
- package/dist/esm/af.common.legacy.min.js.map +4 -4
- package/dist/esm/af.common.min.js +2 -2
- package/dist/esm/af.common.min.js.map +4 -4
- package/dist/iife/af.common.js +131 -146
- package/dist/iife/af.common.legacy.js +137 -152
- package/dist/iife/af.common.legacy.min.js +1 -1
- package/dist/iife/af.common.legacy.min.js.map +4 -4
- package/dist/iife/af.common.min.js +2 -2
- package/dist/iife/af.common.min.js.map +4 -4
- package/es/SessionHandler.js +1 -3
- package/es/UserSession.js +33 -29
- package/es/date.d.ts +16 -0
- package/es/date.js +15 -3
- package/es/date.test.d.ts +1 -0
- package/es/date.test.js +23 -0
- package/es/downloadRequest.js +6 -11
- package/es/errorHandler.d.ts +1 -0
- package/es/errorHandler.js +5 -21
- package/es/expose.d.ts +1 -1
- package/es/expose.test.d.ts +10 -0
- package/es/expose.test.js +36 -0
- package/es/getUserImage.test.d.ts +1 -0
- package/es/getUserImage.test.js +30 -0
- package/es/index.d.ts +1 -1
- package/es/index.js +2 -2
- package/es/invariant.test.d.ts +1 -0
- package/es/invariant.test.js +19 -0
- package/es/localStorage.js +1 -3
- package/es/parseFunc.js +1 -1
- package/es/parseFunc.test.d.ts +1 -0
- package/es/parseFunc.test.js +14 -0
- package/package.json +5 -3
- package/src/date.test.ts +27 -0
- package/src/date.ts +22 -3
- package/src/downloadRequest.ts +6 -12
- package/src/errorHandler.ts +6 -21
- package/src/expose.test.ts +59 -0
- package/src/expose.ts +1 -1
- package/src/getUserImage.test.ts +50 -0
- package/src/index.ts +1 -1
- package/src/invariant.test.ts +23 -0
- package/src/parseFunc.test.ts +17 -0
- package/src/parseFunc.ts +1 -1
|
@@ -136,29 +136,131 @@ var UserSession = class extends SessionHandler {
|
|
|
136
136
|
}
|
|
137
137
|
};
|
|
138
138
|
|
|
139
|
+
// src/log.ts
|
|
140
|
+
async function logActivity(activity, parameters = {}, timeElapsed = 0) {
|
|
141
|
+
var _a2;
|
|
142
|
+
try {
|
|
143
|
+
let response = await fetch("/api/logging/log-activity", {
|
|
144
|
+
method: "POST",
|
|
145
|
+
body: JSON.stringify({
|
|
146
|
+
article: af.article.id,
|
|
147
|
+
timeElapsed,
|
|
148
|
+
action: activity,
|
|
149
|
+
parameters: __spreadProps(__spreadValues({}, parameters), {
|
|
150
|
+
_session: getSessionData()
|
|
151
|
+
})
|
|
152
|
+
}),
|
|
153
|
+
headers: { "Content-Type": "application/json", Accept: "application/json" }
|
|
154
|
+
});
|
|
155
|
+
if (!response.ok) {
|
|
156
|
+
if ((_a2 = response.headers.get("Content-Type")) == null ? void 0 : _a2.includes("application/json")) {
|
|
157
|
+
let data = await response.json();
|
|
158
|
+
console.error(data.error);
|
|
159
|
+
} else {
|
|
160
|
+
console.error("".concat(response.status, " ").concat(response.statusText));
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
} catch (error) {
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
function startActivity(activity, startParameters = {}) {
|
|
167
|
+
let start = performance.now();
|
|
168
|
+
return (endParameters = {}) => logActivity(activity, __spreadValues(__spreadValues({}, startParameters), endParameters), performance.now() - start);
|
|
169
|
+
}
|
|
170
|
+
async function time(callback) {
|
|
171
|
+
let start = performance.now();
|
|
172
|
+
let returnValue = await callback();
|
|
173
|
+
return [returnValue, performance.now() - start];
|
|
174
|
+
}
|
|
175
|
+
async function logError(error) {
|
|
176
|
+
var _a2;
|
|
177
|
+
try {
|
|
178
|
+
if (!error)
|
|
179
|
+
return;
|
|
180
|
+
let data = typeof error === "string" ? { error } : typeof error === "object" ? "message" in error ? {
|
|
181
|
+
error: error.message,
|
|
182
|
+
stack: (_a2 = error.stack) != null ? _a2 : null
|
|
183
|
+
} : { error: error.toString() } : { error: "Unspecified error" };
|
|
184
|
+
console.error(error);
|
|
185
|
+
let result = await fetch("/data/Logger/LogError", {
|
|
186
|
+
method: "POST",
|
|
187
|
+
body: JSON.stringify(data),
|
|
188
|
+
headers: {
|
|
189
|
+
"Content-Type": "application/json; charset=utf-8"
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
if (result.ok) {
|
|
193
|
+
return await result.json();
|
|
194
|
+
}
|
|
195
|
+
console.error(Error("Failed to log error"));
|
|
196
|
+
} catch (e) {
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
function getSessionId() {
|
|
200
|
+
var _a2;
|
|
201
|
+
return (_a2 = crypto.randomUUID) == null ? void 0 : _a2.call(crypto);
|
|
202
|
+
}
|
|
203
|
+
var sessionStart = Date.now();
|
|
204
|
+
var sessionId = getSessionId();
|
|
205
|
+
var deviceId = "";
|
|
206
|
+
var browserSessionId = "";
|
|
207
|
+
if ("document" in window) {
|
|
208
|
+
let startSession = () => {
|
|
209
|
+
var _a2;
|
|
210
|
+
return logActivity("AfSessionInit", {
|
|
211
|
+
"appframe-core": af.common.version,
|
|
212
|
+
"appframe-data": (_a2 = af.data) == null ? void 0 : _a2.version,
|
|
213
|
+
"app-version": af.article.version
|
|
214
|
+
});
|
|
215
|
+
};
|
|
216
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
217
|
+
deviceId = localStorage.getItem("_afDeviceId");
|
|
218
|
+
browserSessionId = sessionStorage.getItem("_afSessionId");
|
|
219
|
+
if (!deviceId) {
|
|
220
|
+
deviceId = getSessionId();
|
|
221
|
+
localStorage.setItem("_afDeviceId", deviceId);
|
|
222
|
+
}
|
|
223
|
+
if (!browserSessionId) {
|
|
224
|
+
browserSessionId = sessionId;
|
|
225
|
+
sessionStorage.setItem("_afSessionId", browserSessionId);
|
|
226
|
+
}
|
|
227
|
+
startSession();
|
|
228
|
+
});
|
|
229
|
+
document.addEventListener("visibilitychange", function logData() {
|
|
230
|
+
if (document.visibilityState === "hidden") {
|
|
231
|
+
navigator.sendBeacon(
|
|
232
|
+
"/api/logging/log-activity",
|
|
233
|
+
JSON.stringify({
|
|
234
|
+
article: af.article.id,
|
|
235
|
+
action: "AfSessionEnd",
|
|
236
|
+
parameters: {
|
|
237
|
+
_session: getSessionData()
|
|
238
|
+
}
|
|
239
|
+
})
|
|
240
|
+
);
|
|
241
|
+
} else {
|
|
242
|
+
startSession();
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
function getSessionData() {
|
|
247
|
+
return {
|
|
248
|
+
browserSessionId,
|
|
249
|
+
sessionStart,
|
|
250
|
+
sessionLength: Date.now() - sessionStart,
|
|
251
|
+
sessionId,
|
|
252
|
+
deviceId
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
|
|
139
256
|
// src/errorHandler.ts
|
|
140
257
|
var _a;
|
|
141
258
|
if (true) {
|
|
142
259
|
(_a = window.window) == null ? void 0 : _a.addEventListener("error", (event) => {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
file: event.filename,
|
|
148
|
-
line: (_d = event.lineno) != null ? _d : 0,
|
|
149
|
-
column: (_e = event.colno) != null ? _e : 0,
|
|
150
|
-
stack: (_g = (_f = event.error) == null ? void 0 : _f.stack) != null ? _g : null
|
|
151
|
-
};
|
|
152
|
-
fetch("/data/Logger/LogError", {
|
|
153
|
-
body: JSON.stringify(data),
|
|
154
|
-
headers: {
|
|
155
|
-
Accept: "application/json",
|
|
156
|
-
"Content-Type": "application/json; charset=utf-8",
|
|
157
|
-
"X-Requested-With": "XMLHttpRequest"
|
|
158
|
-
},
|
|
159
|
-
method: "POST"
|
|
160
|
-
});
|
|
161
|
-
} catch (ex) {
|
|
260
|
+
if (typeof event === "object" && "error" in event) {
|
|
261
|
+
logError(event.error);
|
|
262
|
+
} else if (typeof event === "object" && "message" in event) {
|
|
263
|
+
logError(event);
|
|
162
264
|
}
|
|
163
265
|
});
|
|
164
266
|
}
|
|
@@ -207,13 +309,16 @@ var localStorage_default = new LocalStorage();
|
|
|
207
309
|
function toLocalISODate(date) {
|
|
208
310
|
return date ? toLocalISODateTime(date).substring(0, 10) : null;
|
|
209
311
|
}
|
|
210
|
-
function pad(num) {
|
|
211
|
-
return String(num).padStart(
|
|
312
|
+
function pad(num, digits = 2) {
|
|
313
|
+
return String(num).padStart(digits, "0");
|
|
212
314
|
}
|
|
213
315
|
function toLocalISODateTime(date) {
|
|
214
316
|
return date ? "".concat(date.getFullYear(), "-").concat(pad(date.getMonth() + 1), "-").concat(pad(date.getDate()), "T").concat(pad(date.getHours()), ":").concat(pad(
|
|
215
317
|
date.getMinutes()
|
|
216
|
-
), ":").concat(pad(date.getSeconds()), ".").concat(pad(date.getMilliseconds())) : null;
|
|
318
|
+
), ":").concat(pad(date.getSeconds()), ".").concat(pad(date.getMilliseconds(), 3)) : null;
|
|
319
|
+
}
|
|
320
|
+
function toLocalDateTime(date) {
|
|
321
|
+
return date ? date.toISOString().substring(0, 16) : "";
|
|
217
322
|
}
|
|
218
323
|
|
|
219
324
|
// src/downloadBlob.ts
|
|
@@ -250,13 +355,8 @@ function invariant(condition, message) {
|
|
|
250
355
|
// src/downloadRequest.ts
|
|
251
356
|
async function downloadRequest(request, { fileName, signal, onProgress }) {
|
|
252
357
|
var _a2;
|
|
253
|
-
function reportProgress(progress) {
|
|
254
|
-
if (typeof onProgress === "function") {
|
|
255
|
-
onProgress(__spreadValues({}, progress));
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
358
|
let bytesReceived = 0;
|
|
259
|
-
|
|
359
|
+
onProgress == null ? void 0 : onProgress({ status: "requested" });
|
|
260
360
|
try {
|
|
261
361
|
let response = await fetch(request);
|
|
262
362
|
if (!response.ok || !response.body) {
|
|
@@ -277,7 +377,7 @@ async function downloadRequest(request, { fileName, signal, onProgress }) {
|
|
|
277
377
|
return;
|
|
278
378
|
}
|
|
279
379
|
bytesReceived += read.value.length;
|
|
280
|
-
|
|
380
|
+
onProgress == null ? void 0 : onProgress({ bytesReceived, status: "downloading" });
|
|
281
381
|
controller.enqueue(read.value);
|
|
282
382
|
return pump();
|
|
283
383
|
});
|
|
@@ -289,14 +389,14 @@ async function downloadRequest(request, { fileName, signal, onProgress }) {
|
|
|
289
389
|
} catch (error) {
|
|
290
390
|
}
|
|
291
391
|
const blob = await response.blob();
|
|
292
|
-
|
|
392
|
+
onProgress == null ? void 0 : onProgress({ bytesReceived, status: "downloaded" });
|
|
293
393
|
await downloadBlob(blob, fileName);
|
|
294
|
-
|
|
394
|
+
onProgress == null ? void 0 : onProgress({ bytesReceived, status: "completed" });
|
|
295
395
|
} catch (err) {
|
|
296
396
|
if (signal == null ? void 0 : signal.aborted) {
|
|
297
|
-
|
|
397
|
+
onProgress == null ? void 0 : onProgress({ status: "cancelled" });
|
|
298
398
|
} else {
|
|
299
|
-
|
|
399
|
+
onProgress == null ? void 0 : onProgress({ error: err.message, status: "error" });
|
|
300
400
|
}
|
|
301
401
|
}
|
|
302
402
|
}
|
|
@@ -309,9 +409,10 @@ function has(obj, key) {
|
|
|
309
409
|
// src/parseFunc.ts
|
|
310
410
|
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)*)\}$/;
|
|
311
411
|
function parseFunc(func) {
|
|
412
|
+
var _a2;
|
|
312
413
|
var match = func.toString().match(funcRegex);
|
|
313
414
|
invariant(match, "Unable to parse function!");
|
|
314
|
-
return { name: match[1], args: match[2].split(","), body: match[3] };
|
|
415
|
+
return { name: (_a2 = func.name) != null ? _a2 : match[1], args: match[2].split(",").map((a) => a.trim()), body: match[3] };
|
|
315
416
|
}
|
|
316
417
|
|
|
317
418
|
// src/Namespace.ts
|
|
@@ -450,123 +551,6 @@ function localize(stringParts, ...args) {
|
|
|
450
551
|
return localized;
|
|
451
552
|
}
|
|
452
553
|
|
|
453
|
-
// src/log.ts
|
|
454
|
-
async function logActivity(activity, parameters = {}, timeElapsed = 0) {
|
|
455
|
-
var _a2;
|
|
456
|
-
try {
|
|
457
|
-
let response = await fetch("/api/logging/log-activity", {
|
|
458
|
-
method: "POST",
|
|
459
|
-
body: JSON.stringify({
|
|
460
|
-
article: af.article.id,
|
|
461
|
-
timeElapsed,
|
|
462
|
-
action: activity,
|
|
463
|
-
parameters: __spreadProps(__spreadValues({}, parameters), {
|
|
464
|
-
_session: getSessionData()
|
|
465
|
-
})
|
|
466
|
-
}),
|
|
467
|
-
headers: { "Content-Type": "application/json", Accept: "application/json" }
|
|
468
|
-
});
|
|
469
|
-
if (!response.ok) {
|
|
470
|
-
if ((_a2 = response.headers.get("Content-Type")) == null ? void 0 : _a2.includes("application/json")) {
|
|
471
|
-
let data = await response.json();
|
|
472
|
-
console.error(data.error);
|
|
473
|
-
} else {
|
|
474
|
-
console.error("".concat(response.status, " ").concat(response.statusText));
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
} catch (error) {
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
function startActivity(activity, startParameters = {}) {
|
|
481
|
-
let start = performance.now();
|
|
482
|
-
return (endParameters = {}) => logActivity(activity, __spreadValues(__spreadValues({}, startParameters), endParameters), performance.now() - start);
|
|
483
|
-
}
|
|
484
|
-
async function time(callback) {
|
|
485
|
-
let start = performance.now();
|
|
486
|
-
let returnValue = await callback();
|
|
487
|
-
return [returnValue, performance.now() - start];
|
|
488
|
-
}
|
|
489
|
-
async function logError(error) {
|
|
490
|
-
var _a2;
|
|
491
|
-
try {
|
|
492
|
-
if (!error)
|
|
493
|
-
return;
|
|
494
|
-
let data = typeof error === "string" ? { error } : typeof error === "object" ? "message" in error ? {
|
|
495
|
-
error: error.message,
|
|
496
|
-
stack: (_a2 = error.stack) != null ? _a2 : null
|
|
497
|
-
} : { error: error.toString() } : { error: "Unspecified error" };
|
|
498
|
-
console.error(error);
|
|
499
|
-
let result = await fetch("/data/Logger/LogError", {
|
|
500
|
-
method: "POST",
|
|
501
|
-
body: JSON.stringify(data),
|
|
502
|
-
headers: {
|
|
503
|
-
"Content-Type": "application/json; charset=utf-8"
|
|
504
|
-
}
|
|
505
|
-
});
|
|
506
|
-
if (result.ok) {
|
|
507
|
-
return await result.json();
|
|
508
|
-
}
|
|
509
|
-
console.error(Error("Failed to log error"));
|
|
510
|
-
} catch (e) {
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
function getSessionId() {
|
|
514
|
-
var _a2;
|
|
515
|
-
return (_a2 = crypto.randomUUID) == null ? void 0 : _a2.call(crypto);
|
|
516
|
-
}
|
|
517
|
-
var sessionStart = Date.now();
|
|
518
|
-
var sessionId = getSessionId();
|
|
519
|
-
var deviceId = "";
|
|
520
|
-
var browserSessionId = "";
|
|
521
|
-
if ("document" in window) {
|
|
522
|
-
let startSession = () => {
|
|
523
|
-
var _a2;
|
|
524
|
-
return logActivity("AfSessionInit", {
|
|
525
|
-
"appframe-core": af.common.version,
|
|
526
|
-
"appframe-data": (_a2 = af.data) == null ? void 0 : _a2.version,
|
|
527
|
-
"app-version": af.article.version
|
|
528
|
-
});
|
|
529
|
-
};
|
|
530
|
-
document.addEventListener("DOMContentLoaded", () => {
|
|
531
|
-
deviceId = localStorage.getItem("_afDeviceId");
|
|
532
|
-
browserSessionId = sessionStorage.getItem("_afSessionId");
|
|
533
|
-
if (!deviceId) {
|
|
534
|
-
deviceId = getSessionId();
|
|
535
|
-
localStorage.setItem("_afDeviceId", deviceId);
|
|
536
|
-
}
|
|
537
|
-
if (!browserSessionId) {
|
|
538
|
-
browserSessionId = sessionId;
|
|
539
|
-
sessionStorage.setItem("_afSessionId", browserSessionId);
|
|
540
|
-
}
|
|
541
|
-
startSession();
|
|
542
|
-
});
|
|
543
|
-
document.addEventListener("visibilitychange", function logData() {
|
|
544
|
-
if (document.visibilityState === "hidden") {
|
|
545
|
-
navigator.sendBeacon(
|
|
546
|
-
"/api/logging/log-activity",
|
|
547
|
-
JSON.stringify({
|
|
548
|
-
article: af.article.id,
|
|
549
|
-
action: "AfSessionEnd",
|
|
550
|
-
parameters: {
|
|
551
|
-
_session: getSessionData()
|
|
552
|
-
}
|
|
553
|
-
})
|
|
554
|
-
);
|
|
555
|
-
} else {
|
|
556
|
-
startSession();
|
|
557
|
-
}
|
|
558
|
-
});
|
|
559
|
-
}
|
|
560
|
-
function getSessionData() {
|
|
561
|
-
return {
|
|
562
|
-
browserSessionId,
|
|
563
|
-
sessionStart,
|
|
564
|
-
sessionLength: Date.now() - sessionStart,
|
|
565
|
-
sessionId,
|
|
566
|
-
deviceId
|
|
567
|
-
};
|
|
568
|
-
}
|
|
569
|
-
|
|
570
554
|
// src/settings.ts
|
|
571
555
|
function getKey(article) {
|
|
572
556
|
const articleKey = article || af.article.id;
|
|
@@ -699,7 +683,7 @@ async function alert(prompt, options = {}) {
|
|
|
699
683
|
}
|
|
700
684
|
|
|
701
685
|
// src/index.ts
|
|
702
|
-
var version = "2.
|
|
686
|
+
var version = "2.11.1";
|
|
703
687
|
export {
|
|
704
688
|
ConfirmButtons,
|
|
705
689
|
SessionHandler,
|
|
@@ -724,6 +708,7 @@ export {
|
|
|
724
708
|
saveSettings,
|
|
725
709
|
startActivity,
|
|
726
710
|
time,
|
|
711
|
+
toLocalDateTime,
|
|
727
712
|
toLocalISODate,
|
|
728
713
|
toLocalISODateTime,
|
|
729
714
|
version,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var G=Object.defineProperty,Q=Object.defineProperties;var ee=Object.getOwnPropertyDescriptors;var C=Object.getOwnPropertySymbols;var te=Object.prototype.hasOwnProperty,ne=Object.prototype.propertyIsEnumerable;var I=(e,t,n)=>t in e?G(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,f=(e,t)=>{for(var n in t||(t={}))te.call(t,n)&&I(e,n,t[n]);if(C)for(var n of C(t))ne.call(t,n)&&I(e,n,t[n]);return e},P=(e,t)=>Q(e,ee(t));var s=(e,t,n)=>(I(e,typeof t!="symbol"?t+"":t,n),n);function L(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 m=class{constructor(){s(this,"eventHandler",L())}authenticated(){this.eventHandler.emit("onAuthenticated")}async expired(t,n){try{let o=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 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="'.concat(i,'" style="border:0;width:min(500px,100vw);height:min(700px, 100vh);"></iframe>'),document.body.append(r),r.showModal(),await o,r.remove()}}catch(o){window.location.href="/login?ReturnUrl=".concat(encodeURIComponent(window.location.pathname)).concat(encodeURIComponent(window.location.search))}}attachEvent(t,n){return this.eventHandler.on(t,n)}detachEvent(t,n){return this.eventHandler.off(t,n)}};var E=class extends m{constructor(n){super();s(this,"amDesignator","a.m.");s(this,"dayNames",["sunday","monday","tuesday","wednesday","thursday","friday","saturday"]);s(this,"dayNamesShort",["sun","mon","tue","wed","thu","fri","sat"]);s(this,"decimalSeparator",".");s(this,"domain","OB");s(this,"email");s(this,"formats");s(this,"groupSeparator",null);s(this,"integratedSecurity",!1);s(this,"isDeveloper",!1);s(this,"login","");s(this,"loginType");s(this,"monthNames",["january","february","march","april","may","june","july","august","september","october","november","december",""]);s(this,"monthNamesShort",["jan","feb","mar","apr","may","jun","jul","augt","sep","oct","nov","dec",""]);s(this,"name");s(this,"pmDesignator","p.m.");s(this,"shortDateFormat","dd.MM.yyyy");s(this,"culture","en-GB");s(this,"uiculture","en-GB");this.formats={},Object.assign(this,n)}};var U;(U=window.window)==null||U.addEventListener("error",e=>{var t,n,o,r,i,a,l;try{let p={error:(o=(n=(t=e.error)==null?void 0:t.message)!=null?n:e.message)!=null?o:null,file:e.filename,line:(r=e.lineno)!=null?r:0,column:(i=e.colno)!=null?i:0,stack:(l=(a=e.error)==null?void 0:a.stack)!=null?l:null};fetch("/data/Logger/LogError",{body:JSON.stringify(p),headers:{Accept:"application/json","Content-Type":"application/json; charset=utf-8","X-Requested-With":"XMLHttpRequest"},method:"POST"})}catch(p){}});function _(e){var t;return[((t=af==null?void 0:af.article)==null?void 0:t.id)||"","common",e].join(".")}var T=class{constructor(){s(this,"isPersisted",()=>!0)}getLocalStorageKey(t,n){return n?["common",t].join("."):_(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=_("");for(let n in localStorage)n.slice(0,t.length)===t&&localStorage.removeItem(n)}},oe=new T;function re(e){return e?H(e).substring(0,10):null}function y(e){return String(e).padStart(2,"0")}function H(e){return e?"".concat(e.getFullYear(),"-").concat(y(e.getMonth()+1),"-").concat(y(e.getDate()),"T").concat(y(e.getHours()),":").concat(y(e.getMinutes()),":").concat(y(e.getSeconds()),".").concat(y(e.getMilliseconds())):null}function z(e,t){return new Promise(function(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(function(){URL.revokeObjectURL(r),n()},250)}catch(r){o(r)}})}function u(e,t){if(e)return;let n=typeof t=="function"?t():t;throw new Error(n!=null?n:"Invariant failed")}async function ie(e,{fileName:t,signal:n,onProgress:o}){var a;function r(l){typeof o=="function"&&o(f({},l))}let i=0;r({status:"requested"});try{let l=await fetch(e);if(!l.ok||!l.body){if((a=l.headers.get("content-type"))!=null&&a.includes("application/json")){let g=await l.json();u(!g.error,g.error)}throw new Error("".concat(l.status," ").concat(l.statusText))}try{let g=l.body.getReader(),D=new ReadableStream({start:function(h){function c(){return g.read().then(function(S){if(S.done){h.close();return}return i+=S.value.length,r({bytesReceived:i,status:"downloading"}),h.enqueue(S.value),c()})}return c()}});l=new Response(D)}catch(g){}let p=await l.blob();r({bytesReceived:i,status:"downloaded"}),await z(p,t),r({bytesReceived:i,status:"completed"})}catch(l){n!=null&&n.aborted?r({status:"cancelled"}):r({error:l.message,status:"error"})}}function b(e,t){return Object.prototype.hasOwnProperty.call(e,t)}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 O(e){var t=e.toString().match(ae);return u(t,"Unable to parse function!"),{name:t[1],args:t[2].split(","),body:t[3]}}function M(){}M.prototype=Object.create(null);var q=M;function j(e,t){if(typeof e=="object"){if(typeof t=="string"){let n=t.split(".");return j(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 q;return n}}}function k(e,t,n={}){if(Array.isArray(t))for(let o of t){let{name:r}=O(o);u(r,"Unable to detect name of function! Name it, or only supply one function and include name in first parameter."),k(e,o)}else{let o,r;if(typeof t=="function"&&(o=O(t).name),typeof e=="string"){let i=e.split(".");o||(o=i[i.length-1],i=i.slice(0,i.length-1)),r=j(window,i)}else o&&(typeof e=="object"||typeof e=="function")?r=e:u(!1,"Invalid typeof parameter 'name', or unable to parse pValue!");b(r,o)&&(n==null?void 0:n.overwrite)!==!0?console.warn([e,o].join(".")+" is already defined!"):r[o]=t}}var se={xs:64,sm:128,md:256,lg:512,xl:void 0};function B(e,t,n,o="xs"){if(e&&typeof e=="object")return B(e.primKey,e.login,e.hash,e.size);if(!e||!n)return"";let r=se[o];return"/api/data/blob/EmployeesLookup/".concat(e,"/Image/").concat(encodeURIComponent(t!=null?t:"")).concat(t?".":"").concat(encodeURIComponent(n),".jpg").concat(r?"?width=".concat(r):"")}async function le(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 d(e,t){var n,o;if(typeof e=="string"&&e.trim().length===0)return e;if(!(e===void 0||e===""||e===null))if(((o=(n=window.af)==null?void 0:n.article)==null?void 0:o.i18n)!==void 0){if(!b(af.article.i18n,e)){af.article.i18n[e]=e;let r=le(e).then(i=>(af.article.i18n[e]=i,i));if(t)return r}return af.article.i18n[e]}else return e}function ce(e,...t){u(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:"".concat(r,"$").concat(i)).join(""),o=d(n);return t.forEach((r,i)=>{o=o.replace("$"+i,r)}),o}async function N(e,t={},n=0){var o;try{let r=await fetch("/api/logging/log-activity",{method:"POST",body:JSON.stringify({article:af.article.id,timeElapsed:n,action:e,parameters:P(f({},t),{_session:R()})}),headers:{"Content-Type":"application/json",Accept:"application/json"}});if(!r.ok)if((o=r.headers.get("Content-Type"))!=null&&o.includes("application/json")){let i=await r.json();console.error(i.error)}else console.error("".concat(r.status," ").concat(r.statusText))}catch(r){}}function ue(e,t={}){let n=performance.now();return(o={})=>N(e,f(f({},t),o),performance.now()-n)}async function de(e){let t=performance.now();return[await e(),performance.now()-t]}async function ge(e){var t;try{if(!e)return;let n=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 o=await fetch("/data/Logger/LogError",{method:"POST",body:JSON.stringify(n),headers:{"Content-Type":"application/json; charset=utf-8"}});if(o.ok)return await o.json();console.error(Error("Failed to log error"))}catch(n){}}function J(){var e;return(e=crypto.randomUUID)==null?void 0:e.call(crypto)}var F=Date.now(),K=J(),w="",v="";if("document"in window){let e=()=>{var t;return N("AfSessionInit",{"appframe-core":af.common.version,"appframe-data":(t=af.data)==null?void 0:t.version,"app-version":af.article.version})};document.addEventListener("DOMContentLoaded",()=>{w=localStorage.getItem("_afDeviceId"),v=sessionStorage.getItem("_afSessionId"),w||(w=J(),localStorage.setItem("_afDeviceId",w)),v||(v=K,sessionStorage.setItem("_afSessionId",v)),e()}),document.addEventListener("visibilitychange",function(){document.visibilityState==="hidden"?navigator.sendBeacon("/api/logging/log-activity",JSON.stringify({article:af.article.id,action:"AfSessionEnd",parameters:{_session:R()}})):e()})}function R(){return{browserSessionId:v,sessionStart:F,sessionLength:Date.now()-F,sessionId:K,deviceId:w}}function V(e){let t=e||af.article.id;return"".concat(t,".").concat(af.userSession.login)}function fe(e,t){if(!(af!=null&&af.userSession))return null;let n=V(t),o=JSON.parse(localStorage.getItem(n)||"{}");return e?o[e]||null:o}function pe(e,t,n){if(!(af!=null&&af.userSession))return;let o=V(n),r=JSON.parse(localStorage.getItem(o)||"{}");typeof t<"u"?r[e]=t:r=e,localStorage.setItem(o,JSON.stringify(r))}var me='\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=me,document.body.append(e)}function Z(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 A=new Map;async function $({buttons:e,content:t,className:n,id:o,title:r}){var D,h;if(o&&A.has(o))return await A.get(o);let i=document.querySelector("#AlertDialogTemplate");if(!i)throw Error("No alert dialog template found");let a=(D=i.content.firstElementChild)==null?void 0:D.cloneNode(!0),l=a==null?void 0:a.querySelector("article"),p=a==null?void 0:a.querySelector("footer menu");if(!a||!l||!p)throw Error("Invalid alert dialog template");if(n&&n.split(/\s+/).forEach(c=>a==null?void 0:a.classList.add(c)),r){let c=document.createElement("header");c.append(r),(h=l.parentNode)==null||h.insertBefore(c,l)}l.appendChild(typeof t=="string"?document.createTextNode(t):t);for(let{label:c,value:S,primary:Y}of e){let W=document.createElement("li"),x=document.createElement("button");x.value=S,Y&&x.classList.add("primary"),x.textContent=c,W.appendChild(x),p.appendChild(x)}document.body.appendChild(a),a.showModal();let g=Z(a).then(c=>(o&&A.has(o)&&A.delete(o),a&&document.body.removeChild(a),c));return o&&A.set(o,g),await g}var X=(n=>(n[n.YesNo=0]="YesNo",n[n.OkCancel=1]="OkCancel",n))(X||{});async function ye(e,t={}){let{buttons:n=0,title:o}=t,r=n===1?[{label:d("OK"),value:"yes",primary:!0},{label:d("Cancel"),value:"no"}]:[{label:d("Yes"),value:"yes",primary:!0},{label:d("No"),value:"no"}];return await $({content:e,buttons:r,className:"alert-dialog-confirm",title:o})==="yes"}async function he(e,t={}){await $(f({content:e,className:"alert-dialog-alert",buttons:[{label:d("OK"),value:"ok",primary:!0}]},t))}var ct="2.10.2";export{X as ConfirmButtons,m as SessionHandler,E as UserSession,he as alert,ye as confirm,z as downloadBlob,ie as downloadRequest,k as expose,d as getLocalizedString,R as getSessionData,fe as getSettings,B as getUserImage,b as has,u as invariant,oe as localStorage,ce as localize,N as logActivity,ge as logError,L as mitt,$ as openAlertDialog,pe as saveSettings,ue as startActivity,de as time,re as toLocalISODate,H as toLocalISODateTime,ct as version,Z as waitForDialog};
|
|
1
|
+
var P=Object.defineProperty,ee=Object.defineProperties;var te=Object.getOwnPropertyDescriptors;var C=Object.getOwnPropertySymbols;var ne=Object.prototype.hasOwnProperty,oe=Object.prototype.propertyIsEnumerable;var I=(e,t,o)=>t in e?P(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,m=(e,t)=>{for(var o in t||(t={}))ne.call(t,o)&&I(e,o,t[o]);if(C)for(var o of C(t))oe.call(t,o)&&I(e,o,t[o]);return e},U=(e,t)=>ee(e,te(t));var l=(e,t,o)=>(I(e,typeof t!="symbol"?t+"":t,o),o);function L(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",L())}authenticated(){this.eventHandler.emit("onAuthenticated")}async expired(t,o){try{let n=new Promise(a=>{let i=()=>{this.eventHandler.off("onAuthenticated",i),t==null||t(),a()};this.eventHandler.on("onAuthenticated",i)}),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 a="/login?ReturnUrl=%2fapi/sessionexpired/remove";o!=="RequireTwoFactor"?await fetch("/logout",{method:"POST"}):a="/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(a,'" 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 E=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)}};async function T(e,t={},o=0){var n;try{let r=await fetch("/api/logging/log-activity",{method:"POST",body:JSON.stringify({article:af.article.id,timeElapsed:o,action:e,parameters:U(m({},t),{_session:z()})}),headers:{"Content-Type":"application/json",Accept:"application/json"}});if(!r.ok)if((n=r.headers.get("Content-Type"))!=null&&n.includes("application/json")){let a=await r.json();console.error(a.error)}else console.error("".concat(r.status," ").concat(r.statusText))}catch(r){}}function re(e,t={}){let o=performance.now();return(n={})=>T(e,m(m({},t),n),performance.now()-o)}async function ie(e){let t=performance.now();return[await e(),performance.now()-t]}async function A(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 H(){var e;return(e=crypto.randomUUID)==null?void 0:e.call(crypto)}var _=Date.now(),M=H(),b="",x="";if("document"in window){let e=()=>{var t;return T("AfSessionInit",{"appframe-core":af.common.version,"appframe-data":(t=af.data)==null?void 0:t.version,"app-version":af.article.version})};document.addEventListener("DOMContentLoaded",()=>{b=localStorage.getItem("_afDeviceId"),x=sessionStorage.getItem("_afSessionId"),b||(b=H(),localStorage.setItem("_afDeviceId",b)),x||(x=M,sessionStorage.setItem("_afSessionId",x)),e()}),document.addEventListener("visibilitychange",function(){document.visibilityState==="hidden"?navigator.sendBeacon("/api/logging/log-activity",JSON.stringify({article:af.article.id,action:"AfSessionEnd",parameters:{_session:z()}})):e()})}function z(){return{browserSessionId:x,sessionStart:_,sessionLength:Date.now()-_,sessionId:M,deviceId:b}}var q;(q=window.window)==null||q.addEventListener("error",e=>{typeof e=="object"&&"error"in e?A(e.error):typeof e=="object"&&"message"in e&&A(e)});function k(e){var t;return[((t=af==null?void 0:af.article)==null?void 0:t.id)||"","common",e].join(".")}var O=class{constructor(){l(this,"isPersisted",()=>!0)}getLocalStorageKey(t,o){return o?["common",t].join("."):k(t)}get(t,o,n){let r=this.getLocalStorageKey(t,n),a=localStorage.getItem(r);return a!==null?JSON.parse(a):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=k("");for(let o in localStorage)o.slice(0,t.length)===t&&localStorage.removeItem(o)}},ae=new O;function le(e){return e?B(e).substring(0,10):null}function g(e,t=2){return String(e).padStart(t,"0")}function B(e){return e?"".concat(e.getFullYear(),"-").concat(g(e.getMonth()+1),"-").concat(g(e.getDate()),"T").concat(g(e.getHours()),":").concat(g(e.getMinutes()),":").concat(g(e.getSeconds()),".").concat(g(e.getMilliseconds(),3)):null}function se(e){return e?e.toISOString().substring(0,16):""}function j(e,t){return new Promise(function(o,n){try{let r=URL.createObjectURL(e),a=document.body,i=document.createElement("a");i.setAttribute("download",t),i.href=r,a.append(i),i.click(),a.removeChild(i),setTimeout(function(){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 ce(e,{fileName:t,signal:o,onProgress:n}){var a;let r=0;n==null||n({status:"requested"});try{let i=await fetch(e);if(!i.ok||!i.body){if((a=i.headers.get("content-type"))!=null&&a.includes("application/json")){let d=await i.json();c(!d.error,d.error)}throw new Error("".concat(i.status," ").concat(i.statusText))}try{let d=i.body.getReader(),D=new ReadableStream({start:function(y){function h(){return d.read().then(function(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()}});i=new Response(D)}catch(d){}let f=await i.blob();n==null||n({bytesReceived:r,status:"downloaded"}),await j(f,t),n==null||n({bytesReceived:r,status:"completed"})}catch(i){o!=null&&o.aborted?n==null||n({status:"cancelled"}):n==null||n({error:i.message,status:"error"})}}function v(e,t){return Object.prototype.hasOwnProperty.call(e,t)}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)*)\}$/;function N(e){var o;var t=e.toString().match(ue);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 F(){}F.prototype=Object.create(null);var J=F;function R(e,t){if(typeof e=="object"){if(typeof t=="string"){let o=t.split(".");return R(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 J;return o}}}function K(e,t,o={}){if(Array.isArray(t))for(let n of t){let{name:r}=N(n);c(r,"Unable to detect name of function! Name it, or only supply one function and include name in first parameter."),K(e,n)}else{let n,r;if(typeof t=="function"&&(n=N(t).name),typeof e=="string"){let a=e.split(".");n||(n=a[a.length-1],a=a.slice(0,a.length-1)),r=R(window,a)}else n&&(typeof e=="object"||typeof e=="function")?r=e:c(!1,"Invalid typeof parameter 'name', or unable to parse pValue!");v(r,n)&&(o==null?void 0:o.overwrite)!==!0?console.warn([e,n].join(".")+" is already defined!"):r[n]=t}}var de={xs:64,sm:128,md:256,lg:512,xl:void 0};function V(e,t,o,n="xs"){if(e&&typeof e=="object")return V(e.primKey,e.login,e.hash,e.size);if(!e||!o)return"";let r=de[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):"")}async function fe(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(!v(af.article.i18n,e)){af.article.i18n[e]=e;let r=fe(e).then(a=>(af.article.i18n[e]=a,a));if(t)return r}return af.article.i18n[e]}else return e}function me(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,a)=>a===e.length-1?r:"".concat(r,"$").concat(a)).join(""),n=u(o);return t.forEach((r,a)=>{n=n.replace("$"+a,r)}),n}function Z(e){let t=e||af.article.id;return"".concat(t,".").concat(af.userSession.login)}function pe(e,t){if(!(af!=null&&af.userSession))return null;let o=Z(t),n=JSON.parse(localStorage.getItem(o)||"{}");return e?n[e]||null:n}function ge(e,t,o){if(!(af!=null&&af.userSession))return;let n=Z(o),r=JSON.parse(localStorage.getItem(n)||"{}");typeof t<"u"?r[e]=t:r=e,localStorage.setItem(n,JSON.stringify(r))}var ye='\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=ye,document.body.append(e)}function Y(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 w=new Map;async function $({buttons:e,content:t,className:o,id:n,title:r}){var y,h;if(n&&w.has(n))return await w.get(n);let a=document.querySelector("#AlertDialogTemplate");if(!a)throw Error("No alert dialog template found");let i=(y=a.content.firstElementChild)==null?void 0:y.cloneNode(!0),f=i==null?void 0:i.querySelector("article"),d=i==null?void 0:i.querySelector("footer menu");if(!i||!f||!d)throw Error("Invalid alert dialog template");if(o&&o.split(/\s+/).forEach(s=>i==null?void 0:i.classList.add(s)),r){let s=document.createElement("header");s.append(r),(h=f.parentNode)==null||h.insertBefore(s,f)}f.appendChild(typeof t=="string"?document.createTextNode(t):t);for(let{label:s,value:G,primary:W}of e){let Q=document.createElement("li"),S=document.createElement("button");S.value=G,W&&S.classList.add("primary"),S.textContent=s,Q.appendChild(S),d.appendChild(S)}document.body.appendChild(i),i.showModal();let D=Y(i).then(s=>(n&&w.has(n)&&w.delete(n),i&&document.body.removeChild(i),s));return n&&w.set(n,D),await D}var X=(o=>(o[o.YesNo=0]="YesNo",o[o.OkCancel=1]="OkCancel",o))(X||{});async function he(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 $({content:e,buttons:r,className:"alert-dialog-confirm",title:n})==="yes"}async function Se(e,t={}){await $(m({content:e,className:"alert-dialog-alert",buttons:[{label:u("OK"),value:"ok",primary:!0}]},t))}var ut="2.11.1";export{X as ConfirmButtons,p as SessionHandler,E as UserSession,Se as alert,he as confirm,j as downloadBlob,ce as downloadRequest,K as expose,u as getLocalizedString,z as getSessionData,pe as getSettings,V as getUserImage,v as has,c as invariant,ae as localStorage,me as localize,T as logActivity,A as logError,L as mitt,$ as openAlertDialog,ge as saveSettings,re as startActivity,ie as time,se as toLocalDateTime,le as toLocalISODate,B as toLocalISODateTime,ut as version,Y as waitForDialog};
|
|
2
2
|
//# sourceMappingURL=af.common.legacy.min.js.map
|