@olenbetong/appframe-core 2.11.1 → 2.11.3
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 +16 -21
- package/dist/esm/af.common.legacy.js +38 -41
- 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 +16 -21
- package/dist/iife/af.common.legacy.js +38 -41
- 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/expose.js +1 -2
- package/es/getLocalizedString.js +1 -2
- package/es/index.d.ts +0 -1
- package/es/index.js +1 -2
- package/es/invariant.d.ts +8 -0
- package/es/invariant.js +8 -0
- package/es/log.js +6 -5
- package/es/settings.js +2 -2
- package/package.json +2 -2
- package/src/expose.ts +1 -2
- package/src/getLocalizedString.ts +1 -3
- package/src/index.ts +0 -1
- package/src/invariant.ts +8 -0
- package/src/log.ts +7 -5
- package/src/settings.ts +3 -2
- package/es/has.d.ts +0 -1
- package/es/has.js +0 -3
- package/src/has.ts +0 -3
package/dist/esm/af.common.js
CHANGED
|
@@ -111,12 +111,13 @@ var UserSession = class extends SessionHandler {
|
|
|
111
111
|
};
|
|
112
112
|
|
|
113
113
|
// src/log.ts
|
|
114
|
+
var article = window.af?.article?.id ?? window.window?.location.pathname.substring(1).split("/")[0];
|
|
114
115
|
async function logActivity(activity, parameters = {}, timeElapsed = 0) {
|
|
115
116
|
try {
|
|
116
117
|
let response = await fetch("/api/logging/log-activity", {
|
|
117
118
|
method: "POST",
|
|
118
119
|
body: JSON.stringify({
|
|
119
|
-
article
|
|
120
|
+
article,
|
|
120
121
|
timeElapsed,
|
|
121
122
|
action: activity,
|
|
122
123
|
parameters: {
|
|
@@ -178,9 +179,9 @@ var deviceId = "";
|
|
|
178
179
|
var browserSessionId = "";
|
|
179
180
|
if ("document" in window) {
|
|
180
181
|
let startSession = () => logActivity("AfSessionInit", {
|
|
181
|
-
"appframe-core": af
|
|
182
|
-
"appframe-data": af
|
|
183
|
-
"app-version": af
|
|
182
|
+
"appframe-core": window.af?.common.version,
|
|
183
|
+
"appframe-data": window.af?.data?.version,
|
|
184
|
+
"app-version": window.af?.article.version
|
|
184
185
|
});
|
|
185
186
|
document.addEventListener("DOMContentLoaded", () => {
|
|
186
187
|
deviceId = localStorage.getItem("_afDeviceId");
|
|
@@ -200,7 +201,7 @@ if ("document" in window) {
|
|
|
200
201
|
navigator.sendBeacon(
|
|
201
202
|
"/api/logging/log-activity",
|
|
202
203
|
JSON.stringify({
|
|
203
|
-
article
|
|
204
|
+
article,
|
|
204
205
|
action: "AfSessionEnd",
|
|
205
206
|
parameters: {
|
|
206
207
|
_session: getSessionData()
|
|
@@ -365,11 +366,6 @@ async function downloadRequest(request, { fileName, signal, onProgress }) {
|
|
|
365
366
|
}
|
|
366
367
|
}
|
|
367
368
|
|
|
368
|
-
// src/has.ts
|
|
369
|
-
function has(obj, key) {
|
|
370
|
-
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
371
|
-
}
|
|
372
|
-
|
|
373
369
|
// src/parseFunc.ts
|
|
374
370
|
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)*)\}$/;
|
|
375
371
|
function parseFunc(func) {
|
|
@@ -429,7 +425,7 @@ function expose(name, value, options = {}) {
|
|
|
429
425
|
} else {
|
|
430
426
|
invariant(false, "Invalid typeof parameter 'name', or unable to parse pValue!");
|
|
431
427
|
}
|
|
432
|
-
if (
|
|
428
|
+
if (Object.hasOwn(namespace, keyName) && options?.overwrite !== true) {
|
|
433
429
|
console.warn([name, keyName].join(".") + " is already defined!");
|
|
434
430
|
} else {
|
|
435
431
|
namespace[keyName] = value;
|
|
@@ -483,7 +479,7 @@ function getLocalizedString(string, wait) {
|
|
|
483
479
|
return;
|
|
484
480
|
}
|
|
485
481
|
if (window.af?.article?.i18n !== void 0) {
|
|
486
|
-
if (!
|
|
482
|
+
if (!Object.hasOwn(af.article.i18n, string)) {
|
|
487
483
|
af.article.i18n[string] = string;
|
|
488
484
|
let promise = fetchLocalizedString(string).then((text) => {
|
|
489
485
|
af.article.i18n[string] = text;
|
|
@@ -514,24 +510,24 @@ function localize(stringParts, ...args) {
|
|
|
514
510
|
}
|
|
515
511
|
|
|
516
512
|
// src/settings.ts
|
|
517
|
-
function getKey(
|
|
518
|
-
const articleKey =
|
|
519
|
-
return `${articleKey}.${af
|
|
513
|
+
function getKey(article2) {
|
|
514
|
+
const articleKey = article2 ?? window.af?.article?.id ?? window.window?.location.pathname.substring(1).split("/")[0];
|
|
515
|
+
return `${articleKey}.${window.af?.userSession.login ?? "anonymous"}`;
|
|
520
516
|
}
|
|
521
|
-
function getSettings(setting,
|
|
517
|
+
function getSettings(setting, article2) {
|
|
522
518
|
if (!af?.userSession)
|
|
523
519
|
return null;
|
|
524
|
-
const key = getKey(
|
|
520
|
+
const key = getKey(article2);
|
|
525
521
|
const settings = JSON.parse(localStorage.getItem(key) || "{}");
|
|
526
522
|
if (setting) {
|
|
527
523
|
return settings[setting] || null;
|
|
528
524
|
}
|
|
529
525
|
return settings;
|
|
530
526
|
}
|
|
531
|
-
function saveSettings(setting, value,
|
|
527
|
+
function saveSettings(setting, value, article2) {
|
|
532
528
|
if (!af?.userSession)
|
|
533
529
|
return;
|
|
534
|
-
const key = getKey(
|
|
530
|
+
const key = getKey(article2);
|
|
535
531
|
let userSettings = JSON.parse(localStorage.getItem(key) || "{}");
|
|
536
532
|
if (typeof value !== "undefined") {
|
|
537
533
|
userSettings[setting] = value;
|
|
@@ -654,7 +650,7 @@ async function alert(prompt, options = {}) {
|
|
|
654
650
|
}
|
|
655
651
|
|
|
656
652
|
// src/index.ts
|
|
657
|
-
var version = "2.11.
|
|
653
|
+
var version = "2.11.3";
|
|
658
654
|
export {
|
|
659
655
|
ConfirmButtons,
|
|
660
656
|
SessionHandler,
|
|
@@ -668,7 +664,6 @@ export {
|
|
|
668
664
|
getSessionData,
|
|
669
665
|
getSettings,
|
|
670
666
|
getUserImage,
|
|
671
|
-
has,
|
|
672
667
|
invariant,
|
|
673
668
|
localStorage_default as localStorage,
|
|
674
669
|
localize,
|
|
@@ -137,13 +137,15 @@ var UserSession = class extends SessionHandler {
|
|
|
137
137
|
};
|
|
138
138
|
|
|
139
139
|
// src/log.ts
|
|
140
|
+
var _a, _b, _c, _d;
|
|
141
|
+
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];
|
|
140
142
|
async function logActivity(activity, parameters = {}, timeElapsed = 0) {
|
|
141
|
-
var
|
|
143
|
+
var _a3;
|
|
142
144
|
try {
|
|
143
145
|
let response = await fetch("/api/logging/log-activity", {
|
|
144
146
|
method: "POST",
|
|
145
147
|
body: JSON.stringify({
|
|
146
|
-
article
|
|
148
|
+
article,
|
|
147
149
|
timeElapsed,
|
|
148
150
|
action: activity,
|
|
149
151
|
parameters: __spreadProps(__spreadValues({}, parameters), {
|
|
@@ -153,7 +155,7 @@ async function logActivity(activity, parameters = {}, timeElapsed = 0) {
|
|
|
153
155
|
headers: { "Content-Type": "application/json", Accept: "application/json" }
|
|
154
156
|
});
|
|
155
157
|
if (!response.ok) {
|
|
156
|
-
if ((
|
|
158
|
+
if ((_a3 = response.headers.get("Content-Type")) == null ? void 0 : _a3.includes("application/json")) {
|
|
157
159
|
let data = await response.json();
|
|
158
160
|
console.error(data.error);
|
|
159
161
|
} else {
|
|
@@ -173,13 +175,13 @@ async function time(callback) {
|
|
|
173
175
|
return [returnValue, performance.now() - start];
|
|
174
176
|
}
|
|
175
177
|
async function logError(error) {
|
|
176
|
-
var
|
|
178
|
+
var _a3;
|
|
177
179
|
try {
|
|
178
180
|
if (!error)
|
|
179
181
|
return;
|
|
180
182
|
let data = typeof error === "string" ? { error } : typeof error === "object" ? "message" in error ? {
|
|
181
183
|
error: error.message,
|
|
182
|
-
stack: (
|
|
184
|
+
stack: (_a3 = error.stack) != null ? _a3 : null
|
|
183
185
|
} : { error: error.toString() } : { error: "Unspecified error" };
|
|
184
186
|
console.error(error);
|
|
185
187
|
let result = await fetch("/data/Logger/LogError", {
|
|
@@ -197,8 +199,8 @@ async function logError(error) {
|
|
|
197
199
|
}
|
|
198
200
|
}
|
|
199
201
|
function getSessionId() {
|
|
200
|
-
var
|
|
201
|
-
return (
|
|
202
|
+
var _a3;
|
|
203
|
+
return (_a3 = crypto.randomUUID) == null ? void 0 : _a3.call(crypto);
|
|
202
204
|
}
|
|
203
205
|
var sessionStart = Date.now();
|
|
204
206
|
var sessionId = getSessionId();
|
|
@@ -206,11 +208,11 @@ var deviceId = "";
|
|
|
206
208
|
var browserSessionId = "";
|
|
207
209
|
if ("document" in window) {
|
|
208
210
|
let startSession = () => {
|
|
209
|
-
var
|
|
211
|
+
var _a3, _b2, _c2, _d2;
|
|
210
212
|
return logActivity("AfSessionInit", {
|
|
211
|
-
"appframe-core": af.common.version,
|
|
212
|
-
"appframe-data": (
|
|
213
|
-
"app-version": af.article.version
|
|
213
|
+
"appframe-core": (_a3 = window.af) == null ? void 0 : _a3.common.version,
|
|
214
|
+
"appframe-data": (_c2 = (_b2 = window.af) == null ? void 0 : _b2.data) == null ? void 0 : _c2.version,
|
|
215
|
+
"app-version": (_d2 = window.af) == null ? void 0 : _d2.article.version
|
|
214
216
|
});
|
|
215
217
|
};
|
|
216
218
|
document.addEventListener("DOMContentLoaded", () => {
|
|
@@ -231,7 +233,7 @@ if ("document" in window) {
|
|
|
231
233
|
navigator.sendBeacon(
|
|
232
234
|
"/api/logging/log-activity",
|
|
233
235
|
JSON.stringify({
|
|
234
|
-
article
|
|
236
|
+
article,
|
|
235
237
|
action: "AfSessionEnd",
|
|
236
238
|
parameters: {
|
|
237
239
|
_session: getSessionData()
|
|
@@ -254,9 +256,9 @@ function getSessionData() {
|
|
|
254
256
|
}
|
|
255
257
|
|
|
256
258
|
// src/errorHandler.ts
|
|
257
|
-
var
|
|
259
|
+
var _a2;
|
|
258
260
|
if (true) {
|
|
259
|
-
(
|
|
261
|
+
(_a2 = window.window) == null ? void 0 : _a2.addEventListener("error", (event) => {
|
|
260
262
|
if (typeof event === "object" && "error" in event) {
|
|
261
263
|
logError(event.error);
|
|
262
264
|
} else if (typeof event === "object" && "message" in event) {
|
|
@@ -267,8 +269,8 @@ if (true) {
|
|
|
267
269
|
|
|
268
270
|
// src/localStorage.ts
|
|
269
271
|
function getLocalKey(key) {
|
|
270
|
-
var
|
|
271
|
-
return [((
|
|
272
|
+
var _a3;
|
|
273
|
+
return [((_a3 = af == null ? void 0 : af.article) == null ? void 0 : _a3.id) || "", "common", key].join(".");
|
|
272
274
|
}
|
|
273
275
|
var LocalStorage = class {
|
|
274
276
|
constructor() {
|
|
@@ -354,13 +356,13 @@ function invariant(condition, message) {
|
|
|
354
356
|
|
|
355
357
|
// src/downloadRequest.ts
|
|
356
358
|
async function downloadRequest(request, { fileName, signal, onProgress }) {
|
|
357
|
-
var
|
|
359
|
+
var _a3;
|
|
358
360
|
let bytesReceived = 0;
|
|
359
361
|
onProgress == null ? void 0 : onProgress({ status: "requested" });
|
|
360
362
|
try {
|
|
361
363
|
let response = await fetch(request);
|
|
362
364
|
if (!response.ok || !response.body) {
|
|
363
|
-
if ((
|
|
365
|
+
if ((_a3 = response.headers.get("content-type")) == null ? void 0 : _a3.includes("application/json")) {
|
|
364
366
|
let data = await response.json();
|
|
365
367
|
invariant(!data.error, data.error);
|
|
366
368
|
}
|
|
@@ -401,18 +403,13 @@ async function downloadRequest(request, { fileName, signal, onProgress }) {
|
|
|
401
403
|
}
|
|
402
404
|
}
|
|
403
405
|
|
|
404
|
-
// src/has.ts
|
|
405
|
-
function has(obj, key) {
|
|
406
|
-
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
407
|
-
}
|
|
408
|
-
|
|
409
406
|
// src/parseFunc.ts
|
|
410
407
|
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)*)\}$/;
|
|
411
408
|
function parseFunc(func) {
|
|
412
|
-
var
|
|
409
|
+
var _a3;
|
|
413
410
|
var match = func.toString().match(funcRegex);
|
|
414
411
|
invariant(match, "Unable to parse function!");
|
|
415
|
-
return { name: (
|
|
412
|
+
return { name: (_a3 = func.name) != null ? _a3 : match[1], args: match[2].split(",").map((a) => a.trim()), body: match[3] };
|
|
416
413
|
}
|
|
417
414
|
|
|
418
415
|
// src/Namespace.ts
|
|
@@ -466,7 +463,7 @@ function expose(name, value, options = {}) {
|
|
|
466
463
|
} else {
|
|
467
464
|
invariant(false, "Invalid typeof parameter 'name', or unable to parse pValue!");
|
|
468
465
|
}
|
|
469
|
-
if (
|
|
466
|
+
if (Object.hasOwn(namespace, keyName) && (options == null ? void 0 : options.overwrite) !== true) {
|
|
470
467
|
console.warn([name, keyName].join(".") + " is already defined!");
|
|
471
468
|
} else {
|
|
472
469
|
namespace[keyName] = value;
|
|
@@ -513,15 +510,15 @@ async function fetchLocalizedString(text) {
|
|
|
513
510
|
return text;
|
|
514
511
|
}
|
|
515
512
|
function getLocalizedString(string, wait) {
|
|
516
|
-
var
|
|
513
|
+
var _a3, _b2;
|
|
517
514
|
if (typeof string === "string" && string.trim().length === 0) {
|
|
518
515
|
return string;
|
|
519
516
|
}
|
|
520
517
|
if (string === void 0 || string === "" || string === null) {
|
|
521
518
|
return;
|
|
522
519
|
}
|
|
523
|
-
if (((
|
|
524
|
-
if (!
|
|
520
|
+
if (((_b2 = (_a3 = window.af) == null ? void 0 : _a3.article) == null ? void 0 : _b2.i18n) !== void 0) {
|
|
521
|
+
if (!Object.hasOwn(af.article.i18n, string)) {
|
|
525
522
|
af.article.i18n[string] = string;
|
|
526
523
|
let promise = fetchLocalizedString(string).then((text) => {
|
|
527
524
|
af.article.i18n[string] = text;
|
|
@@ -552,24 +549,25 @@ function localize(stringParts, ...args) {
|
|
|
552
549
|
}
|
|
553
550
|
|
|
554
551
|
// src/settings.ts
|
|
555
|
-
function getKey(
|
|
556
|
-
|
|
557
|
-
|
|
552
|
+
function getKey(article2) {
|
|
553
|
+
var _a3, _b2, _c2, _d2, _e, _f;
|
|
554
|
+
const articleKey = (_d2 = article2 != null ? article2 : (_b2 = (_a3 = window.af) == null ? void 0 : _a3.article) == null ? void 0 : _b2.id) != null ? _d2 : (_c2 = window.window) == null ? void 0 : _c2.location.pathname.substring(1).split("/")[0];
|
|
555
|
+
return "".concat(articleKey, ".").concat((_f = (_e = window.af) == null ? void 0 : _e.userSession.login) != null ? _f : "anonymous");
|
|
558
556
|
}
|
|
559
|
-
function getSettings(setting,
|
|
557
|
+
function getSettings(setting, article2) {
|
|
560
558
|
if (!(af == null ? void 0 : af.userSession))
|
|
561
559
|
return null;
|
|
562
|
-
const key = getKey(
|
|
560
|
+
const key = getKey(article2);
|
|
563
561
|
const settings = JSON.parse(localStorage.getItem(key) || "{}");
|
|
564
562
|
if (setting) {
|
|
565
563
|
return settings[setting] || null;
|
|
566
564
|
}
|
|
567
565
|
return settings;
|
|
568
566
|
}
|
|
569
|
-
function saveSettings(setting, value,
|
|
567
|
+
function saveSettings(setting, value, article2) {
|
|
570
568
|
if (!(af == null ? void 0 : af.userSession))
|
|
571
569
|
return;
|
|
572
|
-
const key = getKey(
|
|
570
|
+
const key = getKey(article2);
|
|
573
571
|
let userSettings = JSON.parse(localStorage.getItem(key) || "{}");
|
|
574
572
|
if (typeof value !== "undefined") {
|
|
575
573
|
userSettings[setting] = value;
|
|
@@ -610,14 +608,14 @@ function waitForDialog(dialog, cancelValue = "No") {
|
|
|
610
608
|
}
|
|
611
609
|
var alertDialogPromiseMap = /* @__PURE__ */ new Map();
|
|
612
610
|
async function openAlertDialog({ buttons, content, className, id, title }) {
|
|
613
|
-
var
|
|
611
|
+
var _a3, _b2;
|
|
614
612
|
if (id && alertDialogPromiseMap.has(id)) {
|
|
615
613
|
return await alertDialogPromiseMap.get(id);
|
|
616
614
|
}
|
|
617
615
|
let $template = document.querySelector("#AlertDialogTemplate");
|
|
618
616
|
if (!$template)
|
|
619
617
|
throw Error("No alert dialog template found");
|
|
620
|
-
let $dialog = (
|
|
618
|
+
let $dialog = (_a3 = $template.content.firstElementChild) == null ? void 0 : _a3.cloneNode(true);
|
|
621
619
|
let $content = $dialog == null ? void 0 : $dialog.querySelector("article");
|
|
622
620
|
let $menu = $dialog == null ? void 0 : $dialog.querySelector("footer menu");
|
|
623
621
|
if (!$dialog || !$content || !$menu)
|
|
@@ -628,7 +626,7 @@ async function openAlertDialog({ buttons, content, className, id, title }) {
|
|
|
628
626
|
if (title) {
|
|
629
627
|
let $header = document.createElement("header");
|
|
630
628
|
$header.append(title);
|
|
631
|
-
(
|
|
629
|
+
(_b2 = $content.parentNode) == null ? void 0 : _b2.insertBefore($header, $content);
|
|
632
630
|
}
|
|
633
631
|
$content.appendChild(typeof content === "string" ? document.createTextNode(content) : content);
|
|
634
632
|
for (let { label, value, primary } of buttons) {
|
|
@@ -683,7 +681,7 @@ async function alert(prompt, options = {}) {
|
|
|
683
681
|
}
|
|
684
682
|
|
|
685
683
|
// src/index.ts
|
|
686
|
-
var version = "2.11.
|
|
684
|
+
var version = "2.11.3";
|
|
687
685
|
export {
|
|
688
686
|
ConfirmButtons,
|
|
689
687
|
SessionHandler,
|
|
@@ -697,7 +695,6 @@ export {
|
|
|
697
695
|
getSessionData,
|
|
698
696
|
getSettings,
|
|
699
697
|
getUserImage,
|
|
700
|
-
has,
|
|
701
698
|
invariant,
|
|
702
699
|
localStorage_default as localStorage,
|
|
703
700
|
localize,
|
|
@@ -1,2 +1,2 @@
|
|
|
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};
|
|
1
|
+
var oe=Object.defineProperty,re=Object.defineProperties;var ie=Object.getOwnPropertyDescriptors;var $=Object.getOwnPropertySymbols;var ae=Object.prototype.hasOwnProperty,le=Object.prototype.propertyIsEnumerable;var A=(e,t,o)=>t in e?oe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,g=(e,t)=>{for(var o in t||(t={}))ae.call(t,o)&&A(e,o,t[o]);if($)for(var o of $(t))le.call(t,o)&&A(e,o,t[o]);return e},C=(e,t)=>re(e,ie(t));var l=(e,t,o)=>(A(e,typeof t!="symbol"?t+"":t,o),o);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 m=class{constructor(){l(this,"eventHandler",I())}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 L=class extends m{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 _,H,M,q,k=(q=(H=(_=window.af)==null?void 0:_.article)==null?void 0:H.id)!=null?q:(M=window.window)==null?void 0:M.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:k,timeElapsed:o,action:e,parameters:C(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 a=await r.json();console.error(a.error)}else console.error("".concat(r.status," ").concat(r.statusText))}catch(r){}}function se(e,t={}){let o=performance.now();return(n={})=>T(e,g(g({},t),n),performance.now()-o)}async function ce(e){let t=performance.now();return[await e(),performance.now()-t]}async function D(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 B(){var e;return(e=crypto.randomUUID)==null?void 0:e.call(crypto)}var U=Date.now(),F=B(),S="",x="";if("document"in window){let e=()=>{var t,o,n,r;return T("AfSessionInit",{"appframe-core":(t=window.af)==null?void 0:t.common.version,"appframe-data":(n=(o=window.af)==null?void 0:o.data)==null?void 0:n.version,"app-version":(r=window.af)==null?void 0:r.article.version})};document.addEventListener("DOMContentLoaded",()=>{S=localStorage.getItem("_afDeviceId"),x=sessionStorage.getItem("_afSessionId"),S||(S=B(),localStorage.setItem("_afDeviceId",S)),x||(x=F,sessionStorage.setItem("_afSessionId",x)),e()}),document.addEventListener("visibilitychange",function(){document.visibilityState==="hidden"?navigator.sendBeacon("/api/logging/log-activity",JSON.stringify({article:k,action:"AfSessionEnd",parameters:{_session:E()}})):e()})}function E(){return{browserSessionId:x,sessionStart:U,sessionLength:Date.now()-U,sessionId:F,deviceId:S}}var J;(J=window.window)==null||J.addEventListener("error",e=>{typeof e=="object"&&"error"in e?D(e.error):typeof e=="object"&&"message"in e&&D(e)});function K(e){var t;return[((t=af==null?void 0:af.article)==null?void 0:t.id)||"","common",e].join(".")}var z=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)}},ue=new z;function de(e){return e?V(e).substring(0,10):null}function p(e,t=2){return String(e).padStart(t,"0")}function V(e){return e?"".concat(e.getFullYear(),"-").concat(p(e.getMonth()+1),"-").concat(p(e.getDate()),"T").concat(p(e.getHours()),":").concat(p(e.getMinutes()),":").concat(p(e.getSeconds()),".").concat(p(e.getMilliseconds(),3)):null}function fe(e){return e?e.toISOString().substring(0,16):""}function O(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 ge(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 f=await i.json();c(!f.error,f.error)}throw new Error("".concat(i.status," ").concat(i.statusText))}try{let f=i.body.getReader(),v=new ReadableStream({start:function(y){function h(){return f.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(v)}catch(f){}let u=await i.blob();n==null||n({bytesReceived:r,status:"downloaded"}),await O(u,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"})}}var me=/^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 j(e){var o;var t=e.toString().match(me);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 Z(){}Z.prototype=Object.create(null);var Y=Z;function N(e,t){if(typeof e=="object"){if(typeof t=="string"){let o=t.split(".");return N(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 Y;return o}}}function X(e,t,o={}){if(Array.isArray(t))for(let n of t){let{name:r}=j(n);c(r,"Unable to detect name of function! Name it, or only supply one function and include name in first parameter."),X(e,n)}else{let n,r;if(typeof t=="function"&&(n=j(t).name),typeof e=="string"){let a=e.split(".");n||(n=a[a.length-1],a=a.slice(0,a.length-1)),r=N(window,a)}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([e,n].join(".")+" is already defined!"):r[n]=t}}var pe={xs:64,sm:128,md:256,lg:512,xl:void 0};function G(e,t,o,n="xs"){if(e&&typeof e=="object")return G(e.primKey,e.login,e.hash,e.size);if(!e||!o)return"";let r=pe[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 ye(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 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=ye(e).then(a=>(af.article.i18n[e]=a,a));if(t)return r}return af.article.i18n[e]}else return e}function he(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=d(o);return t.forEach((r,a)=>{n=n.replace("$"+a,r)}),n}function W(e){var o,n,r,a,i,u;let t=(a=e!=null?e:(n=(o=window.af)==null?void 0:o.article)==null?void 0:n.id)!=null?a:(r=window.window)==null?void 0:r.location.pathname.substring(1).split("/")[0];return"".concat(t,".").concat((u=(i=window.af)==null?void 0:i.userSession.login)!=null?u:"anonymous")}function be(e,t){if(!(af!=null&&af.userSession))return null;let o=W(t),n=JSON.parse(localStorage.getItem(o)||"{}");return e?n[e]||null:n}function Se(e,t,o){if(!(af!=null&&af.userSession))return;let n=W(o),r=JSON.parse(localStorage.getItem(n)||"{}");typeof t<"u"?r[e]=t:r=e,localStorage.setItem(n,JSON.stringify(r))}var xe='\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=xe,document.body.append(e)}function Q(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 R({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),u=i==null?void 0:i.querySelector("article"),f=i==null?void 0:i.querySelector("footer menu");if(!i||!u||!f)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=u.parentNode)==null||h.insertBefore(s,u)}u.appendChild(typeof t=="string"?document.createTextNode(t):t);for(let{label:s,value:ee,primary:te}of e){let ne=document.createElement("li"),b=document.createElement("button");b.value=ee,te&&b.classList.add("primary"),b.textContent=s,ne.appendChild(b),f.appendChild(b)}document.body.appendChild(i),i.showModal();let v=Q(i).then(s=>(n&&w.has(n)&&w.delete(n),i&&document.body.removeChild(i),s));return n&&w.set(n,v),await v}var P=(o=>(o[o.YesNo=0]="YesNo",o[o.OkCancel=1]="OkCancel",o))(P||{});async function we(e,t={}){let{buttons:o=0,title:n}=t,r=o===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 R({content:e,buttons:r,className:"alert-dialog-confirm",title:n})==="yes"}async function ve(e,t={}){await R(g({content:e,className:"alert-dialog-alert",buttons:[{label:d("OK"),value:"ok",primary:!0}]},t))}var dt="2.11.3";export{P as ConfirmButtons,m as SessionHandler,L as UserSession,ve as alert,we as confirm,O as downloadBlob,ge as downloadRequest,X as expose,d as getLocalizedString,E as getSessionData,be as getSettings,G as getUserImage,c as invariant,ue as localStorage,he as localize,T as logActivity,D as logError,I as mitt,R as openAlertDialog,Se as saveSettings,se as startActivity,ce as time,fe as toLocalDateTime,de as toLocalISODate,V as toLocalISODateTime,dt as version,Q as waitForDialog};
|
|
2
2
|
//# sourceMappingURL=af.common.legacy.min.js.map
|