@olenbetong/appframe-core 2.11.8 → 2.11.9

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.
@@ -646,7 +646,7 @@ function saveSettings(setting, value, article2) {
646
646
  }
647
647
 
648
648
  // src/index.ts
649
- var version = "2.11.8";
649
+ var version = "2.11.9";
650
650
  export {
651
651
  ConfirmButtons,
652
652
  SessionHandler,
@@ -1,24 +1,3 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
21
-
22
1
  // ../../node_modules/.pnpm/mitt@3.0.1/node_modules/mitt/dist/mitt.mjs
23
2
  function mitt_default(n) {
24
3
  return { all: n = n || /* @__PURE__ */ new Map(), on: function(t, e) {
@@ -39,9 +18,7 @@ function mitt_default(n) {
39
18
 
40
19
  // src/SessionHandler.ts
41
20
  var SessionHandler = class {
42
- constructor() {
43
- __publicField(this, "eventHandler", mitt_default());
44
- }
21
+ eventHandler = mitt_default();
45
22
  authenticated() {
46
23
  this.eventHandler.emit("onAuthenticated");
47
24
  }
@@ -50,7 +27,7 @@ var SessionHandler = class {
50
27
  let authPromise = new Promise((resolve) => {
51
28
  let eventHandler = () => {
52
29
  this.eventHandler.off("onAuthenticated", eventHandler);
53
- callback == null ? void 0 : callback();
30
+ callback?.();
54
31
  resolve();
55
32
  };
56
33
  this.eventHandler.on("onAuthenticated", eventHandler);
@@ -69,7 +46,7 @@ var SessionHandler = class {
69
46
  } else {
70
47
  link = "/login?RequireTwoFactor=1&ReturnUrl=%2fapi/sessionexpired/remove";
71
48
  }
72
- dialog.innerHTML = '<iframe sandbox="allow-same-origin allow-scripts allow-modals allow-top-navigation-by-user-activation allow-forms" src="'.concat(link, '" style="border:0;width:min(500px,100vw);height:min(700px, 100vh);"></iframe>');
49
+ 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>`;
73
50
  document.body.append(dialog);
74
51
  dialog.showModal();
75
52
  await authPromise;
@@ -78,9 +55,9 @@ var SessionHandler = class {
78
55
  await authPromise;
79
56
  }
80
57
  } catch (_) {
81
- window.location.href = "/login?ReturnUrl=".concat(encodeURIComponent(window.location.pathname)).concat(encodeURIComponent(
58
+ window.location.href = `/login?ReturnUrl=${encodeURIComponent(window.location.pathname)}${encodeURIComponent(
82
59
  window.location.search
83
- ));
60
+ )}`;
84
61
  }
85
62
  }
86
63
  attachEvent(eventName, handler) {
@@ -93,51 +70,49 @@ var SessionHandler = class {
93
70
 
94
71
  // src/UserSession.ts
95
72
  var UserSession = class extends SessionHandler {
73
+ amDesignator = "a.m.";
74
+ dayNames = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"];
75
+ dayNamesShort = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"];
76
+ decimalSeparator = ".";
77
+ domain = "OB";
78
+ email;
79
+ formats;
80
+ groupSeparator = null;
81
+ integratedSecurity = false;
82
+ isDeveloper = false;
83
+ login = "";
84
+ loginType;
85
+ monthNames = [
86
+ "january",
87
+ "february",
88
+ "march",
89
+ "april",
90
+ "may",
91
+ "june",
92
+ "july",
93
+ "august",
94
+ "september",
95
+ "october",
96
+ "november",
97
+ "december",
98
+ ""
99
+ ];
100
+ monthNamesShort = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "augt", "sep", "oct", "nov", "dec", ""];
101
+ name;
102
+ pmDesignator = "p.m.";
103
+ shortDateFormat = "dd.MM.yyyy";
104
+ culture = "en-GB";
105
+ uiculture = "en-GB";
96
106
  constructor(userData) {
97
107
  super();
98
- __publicField(this, "amDesignator", "a.m.");
99
- __publicField(this, "dayNames", ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"]);
100
- __publicField(this, "dayNamesShort", ["sun", "mon", "tue", "wed", "thu", "fri", "sat"]);
101
- __publicField(this, "decimalSeparator", ".");
102
- __publicField(this, "domain", "OB");
103
- __publicField(this, "email");
104
- __publicField(this, "formats");
105
- __publicField(this, "groupSeparator", null);
106
- __publicField(this, "integratedSecurity", false);
107
- __publicField(this, "isDeveloper", false);
108
- __publicField(this, "login", "");
109
- __publicField(this, "loginType");
110
- __publicField(this, "monthNames", [
111
- "january",
112
- "february",
113
- "march",
114
- "april",
115
- "may",
116
- "june",
117
- "july",
118
- "august",
119
- "september",
120
- "october",
121
- "november",
122
- "december",
123
- ""
124
- ]);
125
- __publicField(this, "monthNamesShort", ["jan", "feb", "mar", "apr", "may", "jun", "jul", "augt", "sep", "oct", "nov", "dec", ""]);
126
- __publicField(this, "name");
127
- __publicField(this, "pmDesignator", "p.m.");
128
- __publicField(this, "shortDateFormat", "dd.MM.yyyy");
129
- __publicField(this, "culture", "en-GB");
130
- __publicField(this, "uiculture", "en-GB");
131
108
  this.formats = {};
132
109
  Object.assign(this, userData);
133
110
  }
134
111
  };
135
112
 
136
113
  // src/log.ts
137
- var _a, _b, _c, _d;
138
- 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];
114
+ var article = window.af?.article?.id ?? window.window?.location.pathname.substring(1).split("/")[0];
139
115
  async function logActivity(activity, parameters = {}, timeElapsed = 0) {
140
- var _a3;
141
116
  try {
142
117
  let response = await fetch("/api/logging/log-activity", {
143
118
  method: "POST",
@@ -145,26 +120,27 @@ async function logActivity(activity, parameters = {}, timeElapsed = 0) {
145
120
  article,
146
121
  timeElapsed,
147
122
  action: activity,
148
- parameters: __spreadProps(__spreadValues({}, parameters), {
123
+ parameters: {
124
+ ...parameters,
149
125
  _session: getSessionData()
150
- })
126
+ }
151
127
  }),
152
128
  headers: { "Content-Type": "application/json", Accept: "application/json" }
153
129
  });
154
130
  if (!response.ok) {
155
- if ((_a3 = response.headers.get("Content-Type")) == null ? void 0 : _a3.includes("application/json")) {
131
+ if (response.headers.get("Content-Type")?.includes("application/json")) {
156
132
  let data = await response.json();
157
133
  console.error(data.error);
158
134
  } else {
159
- console.error("".concat(response.status, " ").concat(response.statusText));
135
+ console.error(`${response.status} ${response.statusText}`);
160
136
  }
161
137
  }
162
- } catch (e) {
138
+ } catch {
163
139
  }
164
140
  }
165
141
  function startActivity(activity, startParameters = {}) {
166
142
  let start = performance.now();
167
- return (endParameters = {}) => logActivity(activity, __spreadValues(__spreadValues({}, startParameters), endParameters), performance.now() - start);
143
+ return (endParameters = {}) => logActivity(activity, { ...startParameters, ...endParameters }, performance.now() - start);
168
144
  }
169
145
  async function time(callback) {
170
146
  let start = performance.now();
@@ -172,12 +148,11 @@ async function time(callback) {
172
148
  return [returnValue, performance.now() - start];
173
149
  }
174
150
  async function logError(error) {
175
- var _a3;
176
151
  try {
177
152
  if (!error) return;
178
153
  let data = typeof error === "string" ? { error } : typeof error === "object" ? "message" in error ? {
179
154
  error: error.message,
180
- stack: (_a3 = error.stack) != null ? _a3 : null
155
+ stack: error.stack ?? null
181
156
  } : { error: error.toString() } : { error: "Unspecified error" };
182
157
  console.error(error);
183
158
  let result = await fetch("/data/Logger/LogError", {
@@ -191,26 +166,22 @@ async function logError(error) {
191
166
  return await result.json();
192
167
  }
193
168
  console.error(Error("Failed to log error"));
194
- } catch (e) {
169
+ } catch {
195
170
  }
196
171
  }
197
172
  function getSessionId() {
198
- var _a3;
199
- return (_a3 = crypto.randomUUID) == null ? void 0 : _a3.call(crypto);
173
+ return crypto.randomUUID?.();
200
174
  }
201
175
  var sessionStart = Date.now();
202
176
  var sessionId = getSessionId();
203
177
  var deviceId = "";
204
178
  var browserSessionId = "";
205
179
  if ("document" in window) {
206
- let startSession = () => {
207
- var _a3, _b2, _c2, _d2, _e, _f;
208
- return logActivity("AfSessionInit", {
209
- "appframe-core": (_b2 = (_a3 = window.af) == null ? void 0 : _a3.common) == null ? void 0 : _b2.version,
210
- "appframe-data": (_d2 = (_c2 = window.af) == null ? void 0 : _c2.data) == null ? void 0 : _d2.version,
211
- "app-version": (_f = (_e = window.af) == null ? void 0 : _e.article) == null ? void 0 : _f.version
212
- });
213
- };
180
+ let startSession = () => logActivity("AfSessionInit", {
181
+ "appframe-core": window.af?.common?.version,
182
+ "appframe-data": window.af?.data?.version,
183
+ "app-version": window.af?.article?.version
184
+ });
214
185
  document.addEventListener("DOMContentLoaded", () => {
215
186
  deviceId = localStorage.getItem("_afDeviceId");
216
187
  browserSessionId = sessionStorage.getItem("_afSessionId");
@@ -252,9 +223,8 @@ function getSessionData() {
252
223
  }
253
224
 
254
225
  // src/errorHandler.ts
255
- var _a2;
256
226
  if (true) {
257
- (_a2 = window.window) == null ? void 0 : _a2.addEventListener("error", (event) => {
227
+ window.window?.addEventListener("error", (event) => {
258
228
  if (typeof event === "object" && "error" in event) {
259
229
  logError(event.error);
260
230
  } else if (typeof event === "object" && "message" in event) {
@@ -265,13 +235,10 @@ if (true) {
265
235
 
266
236
  // src/localStorage.ts
267
237
  function getLocalKey(key) {
268
- var _a3;
269
- return [((_a3 = af == null ? void 0 : af.article) == null ? void 0 : _a3.id) || "", "common", key].join(".");
238
+ return [af?.article?.id || "", "common", key].join(".");
270
239
  }
271
240
  var LocalStorage = class {
272
- constructor() {
273
- __publicField(this, "isPersisted", () => true);
274
- }
241
+ isPersisted = () => true;
275
242
  getLocalStorageKey(key, global) {
276
243
  return global ? ["common", key].join(".") : getLocalKey(key);
277
244
  }
@@ -311,9 +278,9 @@ function pad(num, digits = 2) {
311
278
  return String(num).padStart(digits, "0");
312
279
  }
313
280
  function toLocalISODateTime(date) {
314
- return date ? "".concat(date.getFullYear(), "-").concat(pad(date.getMonth() + 1), "-").concat(pad(date.getDate()), "T").concat(pad(date.getHours()), ":").concat(pad(
281
+ return date ? `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}T${pad(date.getHours())}:${pad(
315
282
  date.getMinutes()
316
- ), ":").concat(pad(date.getSeconds()), ".").concat(pad(date.getMilliseconds(), 3)) : null;
283
+ )}:${pad(date.getSeconds())}.${pad(date.getMilliseconds(), 3)}` : null;
317
284
  }
318
285
  function toLocalDateTime(date) {
319
286
  return date ? date.toISOString().substring(0, 16) : "";
@@ -347,22 +314,21 @@ function invariant(condition, message) {
347
314
  return;
348
315
  }
349
316
  const provided = typeof message === "function" ? message() : message;
350
- throw new Error(provided != null ? provided : "Invariant failed");
317
+ throw new Error(provided ?? "Invariant failed");
351
318
  }
352
319
 
353
320
  // src/downloadRequest.ts
354
321
  async function downloadRequest(request, { fileName, signal, onProgress }) {
355
- var _a3;
356
322
  let bytesReceived = 0;
357
- onProgress == null ? void 0 : onProgress({ status: "requested" });
323
+ onProgress?.({ status: "requested" });
358
324
  try {
359
325
  let response = await fetch(request);
360
326
  if (!response.ok || !response.body) {
361
- if ((_a3 = response.headers.get("content-type")) == null ? void 0 : _a3.includes("application/json")) {
327
+ if (response.headers.get("content-type")?.includes("application/json")) {
362
328
  let data = await response.json();
363
329
  invariant(!data.error, data.error);
364
330
  }
365
- throw new Error("".concat(response.status, " ").concat(response.statusText));
331
+ throw new Error(`${response.status} ${response.statusText}`);
366
332
  }
367
333
  try {
368
334
  const reader = response.body.getReader();
@@ -375,7 +341,7 @@ async function downloadRequest(request, { fileName, signal, onProgress }) {
375
341
  return;
376
342
  }
377
343
  bytesReceived += read.value.length;
378
- onProgress == null ? void 0 : onProgress({ bytesReceived, status: "downloading" });
344
+ onProgress?.({ bytesReceived, status: "downloading" });
379
345
  controller.enqueue(read.value);
380
346
  return pump();
381
347
  });
@@ -384,17 +350,17 @@ async function downloadRequest(request, { fileName, signal, onProgress }) {
384
350
  }
385
351
  });
386
352
  response = new Response(stream);
387
- } catch (e) {
353
+ } catch {
388
354
  }
389
355
  const blob = await response.blob();
390
- onProgress == null ? void 0 : onProgress({ bytesReceived, status: "downloaded" });
356
+ onProgress?.({ bytesReceived, status: "downloaded" });
391
357
  await downloadBlob(blob, fileName);
392
- onProgress == null ? void 0 : onProgress({ bytesReceived, status: "completed" });
358
+ onProgress?.({ bytesReceived, status: "completed" });
393
359
  } catch (err) {
394
- if (signal == null ? void 0 : signal.aborted) {
395
- onProgress == null ? void 0 : onProgress({ status: "cancelled" });
360
+ if (signal?.aborted) {
361
+ onProgress?.({ status: "cancelled" });
396
362
  } else {
397
- onProgress == null ? void 0 : onProgress({ error: err.message, status: "error" });
363
+ onProgress?.({ error: err.message, status: "error" });
398
364
  }
399
365
  }
400
366
  }
@@ -402,10 +368,9 @@ async function downloadRequest(request, { fileName, signal, onProgress }) {
402
368
  // src/parseFunc.ts
403
369
  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)*)\}$/;
404
370
  function parseFunc(func) {
405
- var _a3;
406
371
  const match = func.toString().match(funcRegex);
407
372
  invariant(match, "Unable to parse function!");
408
- return { name: (_a3 = func.name) != null ? _a3 : match[1], args: match[2].split(",").map((a) => a.trim()), body: match[3] };
373
+ return { name: func.name ?? match[1], args: match[2].split(",").map((a) => a.trim()), body: match[3] };
409
374
  }
410
375
 
411
376
  // src/Namespace.ts
@@ -459,8 +424,8 @@ function expose(name, value, options = {}) {
459
424
  } else {
460
425
  invariant(false, "Invalid typeof parameter 'name', or unable to parse pValue!");
461
426
  }
462
- if (Object.hasOwn(namespace, keyName) && (options == null ? void 0 : options.overwrite) !== true) {
463
- console.warn("".concat([name, keyName].join("."), " is already defined!"));
427
+ if (Object.hasOwn(namespace, keyName) && options?.overwrite !== true) {
428
+ console.warn(`${[name, keyName].join(".")} is already defined!`);
464
429
  } else {
465
430
  namespace[keyName] = value;
466
431
  }
@@ -470,7 +435,7 @@ function expose(name, value, options = {}) {
470
435
  // src/getLocalizedString.ts
471
436
  async function fetchLocalizedString(text) {
472
437
  try {
473
- let response = await fetch("/api/user/localize/new/".concat(af.article.id), {
438
+ let response = await fetch(`/api/user/localize/new/${af.article.id}`, {
474
439
  body: JSON.stringify({ text }),
475
440
  headers: {
476
441
  Accept: "application/json; */*",
@@ -482,19 +447,18 @@ async function fetchLocalizedString(text) {
482
447
  if (response.ok) {
483
448
  return await response.json();
484
449
  }
485
- } catch (e) {
450
+ } catch {
486
451
  }
487
452
  return text;
488
453
  }
489
454
  function getLocalizedString(string, wait) {
490
- var _a3, _b2;
491
455
  if (typeof string === "string" && string.trim().length === 0) {
492
456
  return string;
493
457
  }
494
458
  if (string === void 0 || string === "" || string === null) {
495
459
  return;
496
460
  }
497
- if (((_b2 = (_a3 = window.af) == null ? void 0 : _a3.article) == null ? void 0 : _b2.i18n) !== void 0) {
461
+ if (window.af?.article?.i18n !== void 0) {
498
462
  if (!Object.hasOwn(af.article.i18n, string)) {
499
463
  af.article.i18n[string] = string;
500
464
  let promise = fetchLocalizedString(string).then((text) => {
@@ -527,7 +491,7 @@ function getUserImage(primKeyOrOptions, login, hash, size = "xs") {
527
491
  return "";
528
492
  }
529
493
  let sizePx = sizeMap[size];
530
- return "/api/data/blob/EmployeesLookup/".concat(primKeyOrOptions, "/Image/").concat(encodeURIComponent(login != null ? login : "")).concat(login ? "." : "").concat(encodeURIComponent(hash), ".jpg").concat(sizePx ? "?width=".concat(sizePx) : "");
494
+ return `/api/data/blob/EmployeesLookup/${primKeyOrOptions}/Image/${encodeURIComponent(login ?? "")}${login ? "." : ""}${encodeURIComponent(hash)}.jpg${sizePx ? `?width=${sizePx}` : ""}`;
531
495
  }
532
496
 
533
497
  // src/localize.ts
@@ -536,16 +500,25 @@ function localize(stringParts, ...args) {
536
500
  Array.isArray(stringParts) && stringParts.length === args.length + 1,
537
501
  "Method 'localize' must be used as a tag function"
538
502
  );
539
- let stringToLocalize = stringParts.map((s, i) => i === stringParts.length - 1 ? s : "".concat(s, "$").concat(i)).join("");
503
+ let stringToLocalize = stringParts.map((s, i) => i === stringParts.length - 1 ? s : `${s}$${i}`).join("");
540
504
  let localized = getLocalizedString(stringToLocalize);
541
505
  args.forEach((arg, index) => {
542
- localized = localized.replace("$".concat(index), arg);
506
+ localized = localized.replace(`$${index}`, arg);
543
507
  });
544
508
  return localized;
545
509
  }
546
510
 
547
511
  // src/alert.ts
548
- var template = '\n <dialog class="alert-dialog">\n <form method="dialog">\n <article></article>\n <footer>\n <menu></menu>\n </footer>\n </form>\n </dialog>\n';
512
+ var template = `
513
+ <dialog class="alert-dialog">
514
+ <form method="dialog">
515
+ <article></article>
516
+ <footer>
517
+ <menu></menu>
518
+ </footer>
519
+ </form>
520
+ </dialog>
521
+ `;
549
522
  if (window.document && !document.querySelector("#AlertDialogTemplate")) {
550
523
  let $template = document.createElement("template");
551
524
  $template.id = "AlertDialogTemplate";
@@ -575,25 +548,24 @@ function waitForDialog(dialog, cancelValue = "No") {
575
548
  }
576
549
  var alertDialogPromiseMap = /* @__PURE__ */ new Map();
577
550
  async function openAlertDialog({ buttons, content, className, id, title }) {
578
- var _a3, _b2;
579
551
  if (id && alertDialogPromiseMap.has(id)) {
580
552
  return await alertDialogPromiseMap.get(id);
581
553
  }
582
554
  let $template = document.querySelector("#AlertDialogTemplate");
583
555
  if (!$template) throw Error("No alert dialog template found");
584
- let $dialog = (_a3 = $template.content.firstElementChild) == null ? void 0 : _a3.cloneNode(true);
585
- let $content = $dialog == null ? void 0 : $dialog.querySelector("article");
586
- let $menu = $dialog == null ? void 0 : $dialog.querySelector("footer menu");
556
+ let $dialog = $template.content.firstElementChild?.cloneNode(true);
557
+ let $content = $dialog?.querySelector("article");
558
+ let $menu = $dialog?.querySelector("footer menu");
587
559
  if (!$dialog || !$content || !$menu) throw Error("Invalid alert dialog template");
588
560
  if (className) {
589
561
  for (const className_ of className.split(/\s+/)) {
590
- $dialog == null ? void 0 : $dialog.classList.add(className_);
562
+ $dialog?.classList.add(className_);
591
563
  }
592
564
  }
593
565
  if (title) {
594
566
  let $header = document.createElement("header");
595
567
  $header.append(title);
596
- (_b2 = $content.parentNode) == null ? void 0 : _b2.insertBefore($header, $content);
568
+ $content.parentNode?.insertBefore($header, $content);
597
569
  }
598
570
  $content.appendChild(typeof content === "string" ? document.createTextNode(content) : content);
599
571
  for (let { label, value, primary } of buttons) {
@@ -639,22 +611,21 @@ async function confirm(prompt, options = {}) {
639
611
  return result === "yes";
640
612
  }
641
613
  async function alert(prompt, options = {}) {
642
- await openAlertDialog(__spreadValues({
614
+ await openAlertDialog({
643
615
  content: prompt,
644
616
  className: "alert-dialog-alert",
645
- buttons: [{ label: getLocalizedString("OK"), value: "ok", primary: true }]
646
- }, options));
617
+ buttons: [{ label: getLocalizedString("OK"), value: "ok", primary: true }],
618
+ ...options
619
+ });
647
620
  }
648
621
 
649
622
  // src/settings.ts
650
623
  function getKey(article2) {
651
- var _a3, _b2, _c2, _d2, _e, _f;
652
- 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];
653
- return "".concat(articleKey, ".").concat((_f = (_e = window.af) == null ? void 0 : _e.userSession.login) != null ? _f : "anonymous");
624
+ const articleKey = article2 ?? window.af?.article?.id ?? window.window?.location.pathname.substring(1).split("/")[0];
625
+ return `${articleKey}.${window.af?.userSession.login ?? "anonymous"}`;
654
626
  }
655
627
  function getSettings(setting, article2) {
656
- var _a3;
657
- if (!((_a3 = window.af) == null ? void 0 : _a3.userSession)) return null;
628
+ if (!window.af?.userSession) return null;
658
629
  const key = getKey(article2);
659
630
  const settings = JSON.parse(localStorage.getItem(key) || "{}");
660
631
  if (setting) {
@@ -663,8 +634,7 @@ function getSettings(setting, article2) {
663
634
  return settings;
664
635
  }
665
636
  function saveSettings(setting, value, article2) {
666
- var _a3;
667
- if (!((_a3 = window.af) == null ? void 0 : _a3.userSession)) return;
637
+ if (!window.af?.userSession) return;
668
638
  const key = getKey(article2);
669
639
  let userSettings = JSON.parse(localStorage.getItem(key) || "{}");
670
640
  if (typeof value !== "undefined") {
@@ -676,7 +646,7 @@ function saveSettings(setting, value, article2) {
676
646
  }
677
647
 
678
648
  // src/index.ts
679
- var version = "2.11.8";
649
+ var version = "2.11.9";
680
650
  export {
681
651
  ConfirmButtons,
682
652
  SessionHandler,
@@ -1,2 +1,11 @@
1
- var oe=Object.defineProperty,re=Object.defineProperties;var ie=Object.getOwnPropertyDescriptors;var R=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,p=(e,t)=>{for(var o in t||(t={}))ae.call(t,o)&&A(e,o,t[o]);if(R)for(var o of R(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);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 g=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 g{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 U,H,M,q,k=(q=(H=(U=window.af)==null?void 0:U.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(p({},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 se(e,t={}){let o=performance.now();return(n={})=>T(e,p(p({},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 _=Date.now(),F=B(),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=B(),localStorage.setItem("_afDeviceId",b)),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:_,sessionLength:Date.now()-_,sessionId:F,deviceId:b}}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 j=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),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=K("");for(let o in localStorage)o.slice(0,t.length)===t&&localStorage.removeItem(o)}},ue=new j;function de(e){return e?V(e).substring(0,10):null}function m(e,t=2){return String(e).padStart(t,"0")}function V(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 fe(e){return e?e.toISOString().substring(0,16):""}function z(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 pe(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(),v=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(v)}catch(f){}let u=await a.blob();n==null||n({bytesReceived:r,status:"downloaded"}),await z(u,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 ge=/^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 o;let t=e.toString().match(ge);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}=O(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=O(t).name),typeof e=="string"){let i=e.split(".");n||(n=i[i.length-1],i=i.slice(0,i.length-1)),r=N(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 me(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=me(e).then(i=>(af.article.i18n[e]=i,i));if(t)return r}return af.article.i18n[e]}else return e}var ye={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=ye[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 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,i)=>i===e.length-1?r:"".concat(r,"$").concat(i)).join(""),n=d(o);return t.forEach((r,i)=>{n=n.replace("$".concat(i),r)}),n}var Se='\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=Se,document.body.append(e)}function W(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 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),u=a==null?void 0:a.querySelector("article"),f=a==null?void 0:a.querySelector("footer menu");if(!a||!u||!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=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"),S=document.createElement("button");S.value=ee,te&&S.classList.add("primary"),S.textContent=s,ne.appendChild(S),f.appendChild(S)}document.body.appendChild(a),a.showModal();let v=W(a).then(s=>(n&&w.has(n)&&w.delete(n),a&&document.body.removeChild(a),s));return n&&w.set(n,v),await v}var Q=(o=>(o[o.YesNo=0]="YesNo",o[o.OkCancel=1]="OkCancel",o))(Q||{});async function be(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 $({content:e,buttons:r,className:"alert-dialog-confirm",title:n})==="yes"}async function xe(e,t={}){await $(p({content:e,className:"alert-dialog-alert",buttons:[{label:d("OK"),value:"ok",primary:!0}]},t))}function P(e){var o,n,r,i,a,u;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((u=(a=window.af)==null?void 0:a.userSession.login)!=null?u:"anonymous")}function we(e,t){var r;if(!((r=window.af)!=null&&r.userSession))return null;let o=P(t),n=JSON.parse(localStorage.getItem(o)||"{}");return e?n[e]||null:n}function ve(e,t,o){var i;if(!((i=window.af)!=null&&i.userSession))return;let n=P(o),r=JSON.parse(localStorage.getItem(n)||"{}");typeof t<"u"?r[e]=t:r=e,localStorage.setItem(n,JSON.stringify(r))}var ct="2.11.8";export{Q as ConfirmButtons,g as SessionHandler,L as UserSession,xe as alert,be as confirm,z as downloadBlob,pe as downloadRequest,X as expose,d as getLocalizedString,E as getSessionData,we as getSettings,G as getUserImage,c as invariant,ue as localStorage,he as localize,T as logActivity,D as logError,I as mitt,$ as openAlertDialog,ve as saveSettings,se as startActivity,ce as time,fe as toLocalDateTime,de as toLocalISODate,V as toLocalISODateTime,ct as version,W as waitForDialog};
1
+ 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 $=window.af?.article?.id??window.window?.location.pathname.substring(1).split("/")[0];async function D(e,t={},n=0){try{let o=await fetch("/api/logging/log-activity",{method:"POST",body:JSON.stringify({article:$,timeElapsed:n,action:e,parameters:{...t,_session:A()}}),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 J(e,t={}){let n=performance.now();return(o={})=>D(e,{...t,...o},performance.now()-n)}async function K(e){let t=performance.now();return[await e(),performance.now()-t]}async function x(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 O(){return crypto.randomUUID?.()}var z=Date.now(),N=O(),y="",h="";if("document"in window){let e=()=>D("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=O(),localStorage.setItem("_afDeviceId",y)),h||(h=N,sessionStorage.setItem("_afSessionId",h)),e()}),document.addEventListener("visibilitychange",function(){document.visibilityState==="hidden"?navigator.sendBeacon("/api/logging/log-activity",JSON.stringify({article:$,action:"AfSessionEnd",parameters:{_session:A()}})):e()})}function A(){return{browserSessionId:h,sessionStart:z,sessionLength:Date.now()-z,sessionId:N,deviceId:y}}window.window?.addEventListener("error",e=>{typeof e=="object"&&"error"in e?x(e.error):typeof e=="object"&&"message"in e&&x(e)});function R(e){return[af?.article?.id||"","common",e].join(".")}var I=class{isPersisted=()=>!0;getLocalStorageKey(t,n){return n?["common",t].join("."):R(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=R("");for(let n in localStorage)n.slice(0,t.length)===t&&localStorage.removeItem(n)}},V=new I;function Z(e){return e?C(e).substring(0,10):null}function d(e,t=2){return String(e).padStart(t,"0")}function C(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 Y(e){return e?e.toISOString().substring(0,16):""}function L(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 s(e,t){if(e)return;let n=typeof t=="function"?t():t;throw new Error(n??"Invariant failed")}async function X(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 c=await i.json();s(!c.error,c.error)}throw new Error(`${i.status} ${i.statusText}`)}try{let c=i.body.getReader(),S=new ReadableStream({start:p=>{function l(){return c.read().then(f=>{if(f.done){p.close();return}return r+=f.value.length,o?.({bytesReceived:r,status:"downloading"}),p.enqueue(f.value),l()})}return l()}});i=new Response(S)}catch{}let a=await i.blob();o?.({bytesReceived:r,status:"downloaded"}),await L(a,t),o?.({bytesReceived:r,status:"completed"})}catch(i){n?.aborted?o?.({status:"cancelled"}):o?.({error:i.message,status:"error"})}}var G=/^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 T(e){let t=e.toString().match(G);return s(t,"Unable to parse function!"),{name:e.name??t[1],args:t[2].split(",").map(n=>n.trim()),body:t[3]}}function _(){}_.prototype=Object.create(null);var U=_;function E(e,t){if(typeof e=="object"){if(typeof t=="string"){let n=t.split(".");return E(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 U;return n}}}function H(e,t,n={}){if(Array.isArray(t))for(let o of t){let{name:r}=T(o);s(r,"Unable to detect name of function! Name it, or only supply one function and include name in first parameter."),H(e,o)}else{let o,r;if(typeof t=="function"&&(o=T(t).name),typeof e=="string"){let i=e.split(".");o||(o=i[i.length-1],i=i.slice(0,i.length-1)),r=E(window,i)}else o&&(typeof e=="object"||typeof e=="function")?r=e:s(!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 W(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 u(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=W(e).then(o=>(af.article.i18n[e]=o,o));if(t)return n}return af.article.i18n[e]}else return e}var Q={xs:64,sm:128,md:256,lg:512,xl:void 0};function M(e,t,n,o="xs"){if(e&&typeof e=="object")return M(e.primKey,e.login,e.hash,e.size);if(!e||!n)return"";let r=Q[o];return`/api/data/blob/EmployeesLookup/${e}/Image/${encodeURIComponent(t??"")}${t?".":""}${encodeURIComponent(n)}.jpg${r?`?width=${r}`:""}`}function ee(e,...t){s(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=u(n);return t.forEach((r,i)=>{o=o.replace(`$${i}`,r)}),o}var te=`
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=te,document.body.append(e)}function k(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 b=new Map;async function j({buttons:e,content:t,className:n,id:o,title:r}){if(o&&b.has(o))return await b.get(o);let i=document.querySelector("#AlertDialogTemplate");if(!i)throw Error("No alert dialog template found");let a=i.content.firstElementChild?.cloneNode(!0),c=a?.querySelector("article"),S=a?.querySelector("footer menu");if(!a||!c||!S)throw Error("Invalid alert dialog template");if(n)for(let l of n.split(/\s+/))a?.classList.add(l);if(r){let l=document.createElement("header");l.append(r),c.parentNode?.insertBefore(l,c)}c.appendChild(typeof t=="string"?document.createTextNode(t):t);for(let{label:l,value:f,primary:B}of e){let F=document.createElement("li"),m=document.createElement("button");m.value=f,B&&m.classList.add("primary"),m.textContent=l,F.appendChild(m),S.appendChild(m)}document.body.appendChild(a),a.showModal();let p=k(a).then(l=>(o&&b.has(o)&&b.delete(o),a&&document.body.removeChild(a),l));return o&&b.set(o,p),await p}var P=(n=>(n[n.YesNo=0]="YesNo",n[n.OkCancel=1]="OkCancel",n))(P||{});async function oe(e,t={}){let{buttons:n=0,title:o}=t,r=n===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 j({content:e,buttons:r,className:"alert-dialog-confirm",title:o})==="yes"}async function ne(e,t={}){await j({content:e,className:"alert-dialog-alert",buttons:[{label:u("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 re(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 ie(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 ke="2.11.9";export{P as ConfirmButtons,g as SessionHandler,v as UserSession,ne as alert,oe as confirm,L as downloadBlob,X as downloadRequest,H as expose,u as getLocalizedString,A as getSessionData,re as getSettings,M as getUserImage,s as invariant,V as localStorage,ee as localize,D as logActivity,x as logError,w as mitt,j as openAlertDialog,ie as saveSettings,J as startActivity,K as time,Y as toLocalDateTime,Z as toLocalISODate,C as toLocalISODateTime,ke as version,k as waitForDialog};
2
11
  //# sourceMappingURL=af.common.legacy.min.js.map