@olenbetong/appframe-core 2.13.0 → 2.14.0

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.
@@ -22,7 +22,7 @@ function mitt_default(n) {
22
22
  }
23
23
 
24
24
  //#endregion
25
- //#region \0@oxc-project+runtime@0.143.0/helpers/esm/typeof.js
25
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
26
26
  function _typeof(o) {
27
27
  "@babel/helpers - typeof";
28
28
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -33,7 +33,7 @@ function _typeof(o) {
33
33
  }
34
34
 
35
35
  //#endregion
36
- //#region \0@oxc-project+runtime@0.143.0/helpers/esm/toPrimitive.js
36
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
37
37
  function toPrimitive(t, r) {
38
38
  if ("object" != _typeof(t) || !t) return t;
39
39
  var e = t[Symbol.toPrimitive];
@@ -46,14 +46,14 @@ function toPrimitive(t, r) {
46
46
  }
47
47
 
48
48
  //#endregion
49
- //#region \0@oxc-project+runtime@0.143.0/helpers/esm/toPropertyKey.js
49
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
50
50
  function toPropertyKey(t) {
51
51
  var i = toPrimitive(t, "string");
52
52
  return "symbol" == _typeof(i) ? i : i + "";
53
53
  }
54
54
 
55
55
  //#endregion
56
- //#region \0@oxc-project+runtime@0.143.0/helpers/esm/defineProperty.js
56
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
57
57
  function _defineProperty(e, r, t) {
58
58
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
59
59
  value: t,
@@ -554,9 +554,9 @@ function expose(name, value, options = {}) {
554
554
 
555
555
  //#endregion
556
556
  //#region src/getLocalizedString.ts
557
- async function fetchLocalizedString(text) {
557
+ async function fetchLocalizedString(text, project) {
558
558
  try {
559
- let response = await fetch(`/api/user/localize/new/${af.article.id}`, {
559
+ let response = await fetch(`/api/user/localize/new/${encodeURIComponent(project)}`, {
560
560
  body: JSON.stringify({ text }),
561
561
  headers: {
562
562
  Accept: "application/json; */*",
@@ -569,20 +569,77 @@ async function fetchLocalizedString(text) {
569
569
  } catch {}
570
570
  return text;
571
571
  }
572
- function getLocalizedString(string, wait) {
572
+ /**
573
+ * The dictionary a string is resolved in: the project's when the page carries one,
574
+ * otherwise the article's; nothing when the page has no `af` at all.
575
+ */
576
+ function sourceFor(project) {
577
+ let af = window.af;
578
+ if (!af) return void 0;
579
+ if (project) {
580
+ let dictionary = af.i18n?.[project];
581
+ if (dictionary) return {
582
+ dictionary,
583
+ harvestAs: project
584
+ };
585
+ }
586
+ let article = af.article;
587
+ if (!article?.i18n) return void 0;
588
+ return {
589
+ dictionary: article.i18n,
590
+ harvestAs: article.id
591
+ };
592
+ }
593
+ function getLocalizedString(string, waitOrOptions) {
573
594
  if (typeof string === "string" && string.trim().length === 0) return string;
574
595
  if (string === void 0 || string === "" || string === null) return;
575
- if (window.af?.article?.i18n !== void 0) {
576
- if (!Object.hasOwn(af.article.i18n, string)) {
577
- af.article.i18n[string] = string;
578
- let promise = fetchLocalizedString(string).then((text) => {
579
- af.article.i18n[string] = text;
580
- return text;
581
- });
582
- if (wait) return promise;
583
- }
584
- return af.article.i18n[string];
585
- } else return string;
596
+ let { project, wait } = typeof waitOrOptions === "object" ? waitOrOptions : { wait: waitOrOptions };
597
+ let source = sourceFor(project);
598
+ if (source === void 0) return string;
599
+ let { dictionary, harvestAs } = source;
600
+ if (!Object.hasOwn(dictionary, string)) {
601
+ dictionary[string] = string;
602
+ let promise = fetchLocalizedString(string, harvestAs).then((text) => {
603
+ dictionary[string] = text;
604
+ return text;
605
+ });
606
+ if (wait) return promise;
607
+ }
608
+ return dictionary[string];
609
+ }
610
+ /**
611
+ * `getLocalizedString` and `localize` bound to a globalization project, for code that is
612
+ * not part of the article it runs on: the site chrome, the shared component packages.
613
+ *
614
+ * On a page whose template renders the project (`af.i18n[project]` exists) the strings are
615
+ * looked up and harvested there; on any other page they resolve through the article's
616
+ * dictionary as a plain `getLocalizedString` would.
617
+ *
618
+ * @example
619
+ * ```ts
620
+ * const { getLocalizedString: t } = createLocalizer("synergi-chrome");
621
+ * t("Applications");
622
+ * ```
623
+ */
624
+ function createLocalizer(project) {
625
+ function bound(string, wait) {
626
+ return getLocalizedString(string, {
627
+ project,
628
+ wait
629
+ });
630
+ }
631
+ function localize(stringParts, ...args) {
632
+ let localized = bound(stringParts.map((s, i) => i === stringParts.length - 1 ? s : `${s}$${i}`).join(""));
633
+ args.forEach((arg, index) => {
634
+ localized = localized.replace(`$${index}`, String(arg));
635
+ });
636
+ return localized;
637
+ }
638
+ return {
639
+ project,
640
+ getLocalizedString: bound,
641
+ localize
642
+ };
586
643
  }
587
644
 
588
645
  //#endregion
@@ -2048,7 +2105,7 @@ function saveSettings(setting, value, article) {
2048
2105
 
2049
2106
  //#endregion
2050
2107
  //#region src/index.ts
2051
- const version = "2.12.0";
2108
+ const version = "2.14.0";
2052
2109
 
2053
2110
  //#endregion
2054
- export { ConfirmButtons, NO_FILTER_ID, RELATIVE_DATE_VALUES, SessionHandler, UserSession, addGroupAtPath, alert, canDeleteSavedFilter, canEditSavedFilter, canRenameSavedFilter, canSetCrossDomain, canShareSavedFilter, changeOperator, coerceParameterValue, coerceToStandardLayout, confirm, convertFilter, countExpressions, createEmptyFilter, createEmptyGroup, createExpression, decodeXml, describeFilter, downloadBlob, downloadReport, downloadRequest, encodeXml, expose, fetchParameterDefault, findSavedFilter, getDefaultOperator, getDefaultParameterValues, getDynamicValueLabel, getDynamicValuesForField, getLocalizedString, getNodeAtPath, getOperatorArity, getOperatorLabel, getOperatorsForField, getReportExtension, getReportFileName, getReportFormats, getReportMediaType, getReportRequest, getSessionData, getSettings, getUserImage, getValueType, insertNodeAtPath, invariant, isCompleteExpression, isEmptyFilter, isExpression, isGroup, isProcedureDefault, isStandardLayout, localStorage_default as localStorage, localize, logActivity, logError, mitt_default as mitt, normalizeOperator, openAlertDialog, openReport, parseParameterItems, parseParameters, parseRecordSource, partitionSavedFilters, printReport, pruneFilter, readElement, readElements, removeNodeAtPath, renderReport, resolveParameterDefaults, restoreParameterValues, saveSettings, serializeParameters, setGroupMode, startActivity, time, toFieldMetadata, toFieldMetadataList, toFilterFieldType, toFilterTree, toLocalDateTime, toLocalISODate, toLocalISODateTime, toReport, toReportParameter, toReportParameters, toSavedFilter, toSavedFilters, updateNodeAtPath, version, waitForDialog };
2111
+ export { ConfirmButtons, NO_FILTER_ID, RELATIVE_DATE_VALUES, SessionHandler, UserSession, addGroupAtPath, alert, canDeleteSavedFilter, canEditSavedFilter, canRenameSavedFilter, canSetCrossDomain, canShareSavedFilter, changeOperator, coerceParameterValue, coerceToStandardLayout, confirm, convertFilter, countExpressions, createEmptyFilter, createEmptyGroup, createExpression, createLocalizer, decodeXml, describeFilter, downloadBlob, downloadReport, downloadRequest, encodeXml, expose, fetchParameterDefault, findSavedFilter, getDefaultOperator, getDefaultParameterValues, getDynamicValueLabel, getDynamicValuesForField, getLocalizedString, getNodeAtPath, getOperatorArity, getOperatorLabel, getOperatorsForField, getReportExtension, getReportFileName, getReportFormats, getReportMediaType, getReportRequest, getSessionData, getSettings, getUserImage, getValueType, insertNodeAtPath, invariant, isCompleteExpression, isEmptyFilter, isExpression, isGroup, isProcedureDefault, isStandardLayout, localStorage_default as localStorage, localize, logActivity, logError, mitt_default as mitt, normalizeOperator, openAlertDialog, openReport, parseParameterItems, parseParameters, parseRecordSource, partitionSavedFilters, printReport, pruneFilter, readElement, readElements, removeNodeAtPath, renderReport, resolveParameterDefaults, restoreParameterValues, saveSettings, serializeParameters, setGroupMode, startActivity, time, toFieldMetadata, toFieldMetadataList, toFilterFieldType, toFilterTree, toLocalDateTime, toLocalISODate, toLocalISODateTime, toReport, toReportParameter, toReportParameters, toSavedFilter, toSavedFilters, updateNodeAtPath, version, waitForDialog };
@@ -508,9 +508,9 @@ function expose(name, value, options = {}) {
508
508
 
509
509
  //#endregion
510
510
  //#region src/getLocalizedString.ts
511
- async function fetchLocalizedString(text) {
511
+ async function fetchLocalizedString(text, project) {
512
512
  try {
513
- let response = await fetch(`/api/user/localize/new/${af.article.id}`, {
513
+ let response = await fetch(`/api/user/localize/new/${encodeURIComponent(project)}`, {
514
514
  body: JSON.stringify({ text }),
515
515
  headers: {
516
516
  Accept: "application/json; */*",
@@ -523,20 +523,77 @@ async function fetchLocalizedString(text) {
523
523
  } catch {}
524
524
  return text;
525
525
  }
526
- function getLocalizedString(string, wait) {
526
+ /**
527
+ * The dictionary a string is resolved in: the project's when the page carries one,
528
+ * otherwise the article's; nothing when the page has no `af` at all.
529
+ */
530
+ function sourceFor(project) {
531
+ let af = window.af;
532
+ if (!af) return void 0;
533
+ if (project) {
534
+ let dictionary = af.i18n?.[project];
535
+ if (dictionary) return {
536
+ dictionary,
537
+ harvestAs: project
538
+ };
539
+ }
540
+ let article = af.article;
541
+ if (!article?.i18n) return void 0;
542
+ return {
543
+ dictionary: article.i18n,
544
+ harvestAs: article.id
545
+ };
546
+ }
547
+ function getLocalizedString(string, waitOrOptions) {
527
548
  if (typeof string === "string" && string.trim().length === 0) return string;
528
549
  if (string === void 0 || string === "" || string === null) return;
529
- if (window.af?.article?.i18n !== void 0) {
530
- if (!Object.hasOwn(af.article.i18n, string)) {
531
- af.article.i18n[string] = string;
532
- let promise = fetchLocalizedString(string).then((text) => {
533
- af.article.i18n[string] = text;
534
- return text;
535
- });
536
- if (wait) return promise;
537
- }
538
- return af.article.i18n[string];
539
- } else return string;
550
+ let { project, wait } = typeof waitOrOptions === "object" ? waitOrOptions : { wait: waitOrOptions };
551
+ let source = sourceFor(project);
552
+ if (source === void 0) return string;
553
+ let { dictionary, harvestAs } = source;
554
+ if (!Object.hasOwn(dictionary, string)) {
555
+ dictionary[string] = string;
556
+ let promise = fetchLocalizedString(string, harvestAs).then((text) => {
557
+ dictionary[string] = text;
558
+ return text;
559
+ });
560
+ if (wait) return promise;
561
+ }
562
+ return dictionary[string];
563
+ }
564
+ /**
565
+ * `getLocalizedString` and `localize` bound to a globalization project, for code that is
566
+ * not part of the article it runs on: the site chrome, the shared component packages.
567
+ *
568
+ * On a page whose template renders the project (`af.i18n[project]` exists) the strings are
569
+ * looked up and harvested there; on any other page they resolve through the article's
570
+ * dictionary as a plain `getLocalizedString` would.
571
+ *
572
+ * @example
573
+ * ```ts
574
+ * const { getLocalizedString: t } = createLocalizer("synergi-chrome");
575
+ * t("Applications");
576
+ * ```
577
+ */
578
+ function createLocalizer(project) {
579
+ function bound(string, wait) {
580
+ return getLocalizedString(string, {
581
+ project,
582
+ wait
583
+ });
584
+ }
585
+ function localize(stringParts, ...args) {
586
+ let localized = bound(stringParts.map((s, i) => i === stringParts.length - 1 ? s : `${s}$${i}`).join(""));
587
+ args.forEach((arg, index) => {
588
+ localized = localized.replace(`$${index}`, String(arg));
589
+ });
590
+ return localized;
591
+ }
592
+ return {
593
+ project,
594
+ getLocalizedString: bound,
595
+ localize
596
+ };
540
597
  }
541
598
 
542
599
  //#endregion
@@ -2002,7 +2059,7 @@ function saveSettings(setting, value, article) {
2002
2059
 
2003
2060
  //#endregion
2004
2061
  //#region src/index.ts
2005
- const version = "2.12.0";
2062
+ const version = "2.14.0";
2006
2063
 
2007
2064
  //#endregion
2008
- export { ConfirmButtons, NO_FILTER_ID, RELATIVE_DATE_VALUES, SessionHandler, UserSession, addGroupAtPath, alert, canDeleteSavedFilter, canEditSavedFilter, canRenameSavedFilter, canSetCrossDomain, canShareSavedFilter, changeOperator, coerceParameterValue, coerceToStandardLayout, confirm, convertFilter, countExpressions, createEmptyFilter, createEmptyGroup, createExpression, decodeXml, describeFilter, downloadBlob, downloadReport, downloadRequest, encodeXml, expose, fetchParameterDefault, findSavedFilter, getDefaultOperator, getDefaultParameterValues, getDynamicValueLabel, getDynamicValuesForField, getLocalizedString, getNodeAtPath, getOperatorArity, getOperatorLabel, getOperatorsForField, getReportExtension, getReportFileName, getReportFormats, getReportMediaType, getReportRequest, getSessionData, getSettings, getUserImage, getValueType, insertNodeAtPath, invariant, isCompleteExpression, isEmptyFilter, isExpression, isGroup, isProcedureDefault, isStandardLayout, localStorage_default as localStorage, localize, logActivity, logError, mitt_default as mitt, normalizeOperator, openAlertDialog, openReport, parseParameterItems, parseParameters, parseRecordSource, partitionSavedFilters, printReport, pruneFilter, readElement, readElements, removeNodeAtPath, renderReport, resolveParameterDefaults, restoreParameterValues, saveSettings, serializeParameters, setGroupMode, startActivity, time, toFieldMetadata, toFieldMetadataList, toFilterFieldType, toFilterTree, toLocalDateTime, toLocalISODate, toLocalISODateTime, toReport, toReportParameter, toReportParameters, toSavedFilter, toSavedFilters, updateNodeAtPath, version, waitForDialog };
2065
+ export { ConfirmButtons, NO_FILTER_ID, RELATIVE_DATE_VALUES, SessionHandler, UserSession, addGroupAtPath, alert, canDeleteSavedFilter, canEditSavedFilter, canRenameSavedFilter, canSetCrossDomain, canShareSavedFilter, changeOperator, coerceParameterValue, coerceToStandardLayout, confirm, convertFilter, countExpressions, createEmptyFilter, createEmptyGroup, createExpression, createLocalizer, decodeXml, describeFilter, downloadBlob, downloadReport, downloadRequest, encodeXml, expose, fetchParameterDefault, findSavedFilter, getDefaultOperator, getDefaultParameterValues, getDynamicValueLabel, getDynamicValuesForField, getLocalizedString, getNodeAtPath, getOperatorArity, getOperatorLabel, getOperatorsForField, getReportExtension, getReportFileName, getReportFormats, getReportMediaType, getReportRequest, getSessionData, getSettings, getUserImage, getValueType, insertNodeAtPath, invariant, isCompleteExpression, isEmptyFilter, isExpression, isGroup, isProcedureDefault, isStandardLayout, localStorage_default as localStorage, localize, logActivity, logError, mitt_default as mitt, normalizeOperator, openAlertDialog, openReport, parseParameterItems, parseParameters, parseRecordSource, partitionSavedFilters, printReport, pruneFilter, readElement, readElements, removeNodeAtPath, renderReport, resolveParameterDefaults, restoreParameterValues, saveSettings, serializeParameters, setGroupMode, startActivity, time, toFieldMetadata, toFieldMetadataList, toFilterFieldType, toFilterTree, toLocalDateTime, toLocalISODate, toLocalISODateTime, toReport, toReportParameter, toReportParameters, toSavedFilter, toSavedFilters, updateNodeAtPath, version, waitForDialog };
@@ -1,5 +1,5 @@
1
- function e(e){return{all:e||=new Map,on:function(t,n){var r=e.get(t);r?r.push(n):e.set(t,[n])},off:function(t,n){var r=e.get(t);r&&(n?r.splice(r.indexOf(n)>>>0,1):e.set(t,[]))},emit:function(t,n){var r=e.get(t);r&&r.slice().map(function(e){e(n)}),(r=e.get(`*`))&&r.slice().map(function(e){e(t,n)})}}}var t=class{eventHandler=e();authenticated(){this.eventHandler.emit(`onAuthenticated`)}async expired(e,t){try{let n=new Promise(t=>{let n=()=>{this.eventHandler.off(`onAuthenticated`,n),e?.(),t()};this.eventHandler.on(`onAuthenticated`,n)}),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 e=`/login?ReturnUrl=%2fapi/sessionexpired/remove`;t===`RequireTwoFactor`?e=`/login?RequireTwoFactor=1&ReturnUrl=%2fapi/sessionexpired/remove`:await fetch(`/logout`,{method:`POST`}),r.innerHTML=`<iframe sandbox="allow-same-origin allow-scripts allow-modals allow-top-navigation-by-user-activation allow-forms" src="${e}" style="border:0;width:min(500px,100vw);height:min(700px, 100vh);"></iframe>`,document.body.append(r),r.showModal(),await n,r.remove()}}catch{window.location.href=`/login?ReturnUrl=${encodeURIComponent(window.location.pathname)}${encodeURIComponent(window.location.search)}`}}attachEvent(e,t){return this.eventHandler.on(e,t)}detachEvent(e,t){return this.eventHandler.off(e,t)}},n=class extends t{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(e){super(),this.formats={},Object.assign(this,e)}};const r=window.af?.article?.id??window.window?.location.pathname.substring(1).split(`/`)[0];async function i(e,t={},n=0){try{let i=await fetch(`/api/logging/log-activity`,{method:`POST`,body:JSON.stringify({article:r,timeElapsed:n,action:e,parameters:{...t,_session:p()}}),headers:{"Content-Type":`application/json`,Accept:`application/json`}});if(!i.ok){if(i.headers.get(`Content-Type`)?.includes(`application/json`)){let e=await i.json();console.error(e.error)}else console.error(`${i.status} ${i.statusText}`)}}catch{}}function a(e,t={}){let n=performance.now();return(r={})=>i(e,{...t,...r},performance.now()-n)}async function o(e){let t=performance.now();return[await e(),performance.now()-t]}async function s(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 c(){return crypto.randomUUID?.()}let l=Date.now(),u=c(),d=``,f=``;if(`document`in window){let e=()=>i(`AfSessionInit`,{"appframe-core":window.af?.common?.version,"appframe-data":window.af?.data?.version,"app-version":window.af?.article?.version});document.addEventListener(`DOMContentLoaded`,()=>{d=localStorage.getItem(`_afDeviceId`),f=sessionStorage.getItem(`_afSessionId`),d||(d=c(),localStorage.setItem(`_afDeviceId`,d)),f||(f=u,sessionStorage.setItem(`_afSessionId`,f)),e()}),document.addEventListener(`visibilitychange`,function(){document.visibilityState===`hidden`?navigator.sendBeacon(`/api/logging/log-activity`,JSON.stringify({article:r,action:`AfSessionEnd`,parameters:{_session:p()}})):e()})}function p(){return{browserSessionId:f,sessionStart:l,sessionLength:Date.now()-l,sessionId:u,deviceId:d}}window.window?.addEventListener(`error`,e=>{typeof e==`object`&&`error`in e?s(e.error):typeof e==`object`&&`message`in e&&s(e)});function m(e){return[af?.article?.id||``,`common`,e].join(`.`)}var ee=new class{isPersisted=()=>!0;getLocalStorageKey(e,t){return t?[`common`,e].join(`.`):m(e)}get(e,t,n){let r=this.getLocalStorageKey(e,n),i=localStorage.getItem(r);return i===null?t:JSON.parse(i)}set(e,t,n){localStorage.setItem(this.getLocalStorageKey(e,n),JSON.stringify(t))}remove(e,t){let n=this.getLocalStorageKey(e,t);return localStorage.getItem(n)!==null&&(localStorage.removeItem(n),!0)}clear(){let e=m(``);for(let t in localStorage)t.slice(0,e.length)===e&&localStorage.removeItem(t)}};function te(e){return e?ne(e).substring(0,10):null}function h(e,t=2){return String(e).padStart(t,`0`)}function ne(e){return e?`${e.getFullYear()}-${h(e.getMonth()+1)}-${h(e.getDate())}T${h(e.getHours())}:${h(e.getMinutes())}:${h(e.getSeconds())}.${h(e.getMilliseconds(),3)}`:null}function re(e){return e?e.toISOString().substring(0,16):``}function ie(e,t){return new Promise((n,r)=>{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(e){r(e)}})}function g(e,t){if(e)return;let n=typeof t==`function`?t():t;throw Error(n??`Invariant failed`)}async function ae(e,{fileName:t,signal:n,onProgress:r}){let i=0;r?.({status:`requested`});try{let n=await fetch(e);if(!n.ok||!n.body){if(n.headers.get(`content-type`)?.includes(`application/json`)){let e=await n.json();g(!e.error,e.error)}throw Error(`${n.status} ${n.statusText}`)}try{let e=n.body.getReader(),t=new ReadableStream({start:t=>{function n(){return e.read().then(e=>{if(e.done){t.close();return}return i+=e.value.length,r?.({bytesReceived:i,status:`downloading`}),t.enqueue(e.value),n()})}return n()}});n=new Response(t)}catch{}let a=await n.blob();r?.({bytesReceived:i,status:`downloaded`}),await ie(a,t),r?.({bytesReceived:i,status:`completed`})}catch(e){n?.aborted?r?.({status:`cancelled`}):r?.({error:e.message,status:`error`})}}const oe=/^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)*)\}$/,se=/^(?:\(([^)]*)\)|([a-zA-Z$_][a-zA-Z0-9$_]*))\s*=>\s*\{([\s\S]*)\}$/,ce=/^(?:\(([^)]*)\)|([a-zA-Z$_][a-zA-Z0-9$_]*))\s*=>\s*([\s\S]+)$/,_=e=>e.split(`,`).map(e=>e.trim()).filter(Boolean);function le(e){let t=e.toString(),n=t.match(se);if(n){let t=_(n[1]??n[2]??``);return{name:e.name,args:t,body:n[3]}}let r=t.match(ce);if(r){let t=_(r[1]??r[2]??``);return{name:e.name,args:t,body:r[3]}}let i=t.match(oe);return g(i,`Unable to parse function!`),{name:e.name??i[1],args:_(i[2]),body:i[3]}}function ue(){}ue.prototype=Object.create(null);function de(e,t){if(typeof e==`object`){if(typeof t==`string`)return de(e,t.split(`.`));if(Array.isArray(t)){let n=e;for(let e=0;e<t.length;e++)n=n[t[e]]=n[t[e]]||new ue;return n}}}function fe(e,t,n={}){if(Array.isArray(t))for(let n of t){let{name:t}=le(n);g(t,`Unable to detect name of function! Name it, or only supply one function and include name in first parameter.`),fe(e,n)}else{let r,i;if(typeof t==`function`&&(r=le(t).name),typeof e==`string`){let t=e.split(`.`);r||(r=t[t.length-1],t=t.slice(0,t.length-1)),i=de(window,t)}else r&&(typeof e==`object`||typeof e==`function`)?i=e:g(!1,`Invalid typeof parameter 'name', or unable to parse pValue!`);Object.hasOwn(i,r)&&n?.overwrite!==!0?console.warn(`${[e,r].join(`.`)} is already defined!`):i[r]=t}}async function pe(e){try{let t=await fetch(`/api/user/localize/new/${af.article.id}`,{body:JSON.stringify({text:e}),headers:{Accept:`application/json; */*`,"Content-Type":`application/json`,"X-Requested-With":`XMLHttpRequest`},method:`POST`});if(t.ok)return await t.json()}catch{}return e}function v(e,t){if(typeof e==`string`&&e.trim().length===0)return e;if(e!==void 0&&e!==``&&e!==null){if(window.af?.article?.i18n!==void 0){if(!Object.hasOwn(af.article.i18n,e)){af.article.i18n[e]=e;let n=pe(e).then(t=>(af.article.i18n[e]=t,t));if(t)return n}return af.article.i18n[e]}return e}}const me=[`isnull`,`isnotnull`,`istrue`,`isfalse`,`isblank`,`isnotblank`],he=[`between`,`notbetween`,`datebetween`,`datenotbetween`],ge=[`inlist`,`notinlist`];function y(e){return me.includes(e)?`none`:he.includes(e)?`pair`:ge.includes(e)?`list`:`single`}const _e={equals:`Equal to`,notequals:`Not equal to`,greaterthan:`Greater than`,greaterthanorequal:`Greater than or equal to`,lessthan:`Less than`,lessthanorequal:`Less than or equal to`,beginswith:`Begins with`,notbeginswith:`Does not begin with`,endswith:`Ends with`,notendswith:`Does not end with`,contains:`Contains`,notcontains:`Does not contain`,like:`Like`,notlike:`Not like`,isnull:`Is null`,isnotnull:`Is not null`,isblank:`Is empty`,isnotblank:`Is not empty`,istrue:`Is true`,isfalse:`Is false`,inlist:`In list`,notinlist:`Not in list`,between:`Between`,notbetween:`Not between`,dateequals:`Equal to`,notdatequals:`Not equal to`,dategreaterthan:`After`,dategreaterthanorequal:`On or after`,datelessthan:`Before`,datelessthanorequal:`Up to`,datebetween:`Between`,datenotbetween:`Not between`},ve={greaterthan:`After`,greaterthanorequal:`On or after`,lessthan:`Before`,lessthanorequal:`Up to`};function ye(e,t){return v((t===`date`||t===`datetime`?ve[e]:void 0)??_e[e]??e)}const b=[`equals`,`notequals`],x=[`inlist`,`notinlist`],S=[`between`,`notbetween`],C=[`greaterthan`,`greaterthanorequal`,`lessthan`,`lessthanorequal`],be=[`contains`,`notcontains`,`beginswith`,`notbeginswith`,`endswith`,`notendswith`,`isblank`,`isnotblank`],xe={date:[...b,...x,...S,...C],datetime:[...b,...x,...S,...C],number:[...b,...x,...S,...C],boolean:[`istrue`,`isfalse`],string:[...b,...be,...x,...S,...C],uniqueidentifier:[...b,...be,...x,...S,...C]},Se={date:`equals`,datetime:`equals`,number:`equals`,boolean:`istrue`,string:`contains`,uniqueidentifier:`beginswith`};function Ce(e){let t=[...xe[e.type]??xe.string];return e.nullable&&e.type!==`boolean`&&t.push(`isnull`,`isnotnull`),t}function we(e){return Se[e.type]??`equals`}function w(e,t){if(y(t)===`none`)return`null`;switch(e.type){case`number`:return`number`;case`boolean`:return`boolean`;case`date`:case`datetime`:return`datetime`;case`uniqueidentifier`:return`uniqueidentifier`;default:return`string`}}const Te=[`Yesterday`,`Today`,`Tomorrow`,`ThisWeek`,`ThisMonth`,`ThisYear`,`LastWeek`,`LastMonth`,`LastYear`,`NextWeek`,`NextMonth`,`NextYear`],Ee={CurrentUser:`Current user`,Yesterday:`Yesterday`,Today:`Today`,Tomorrow:`Tomorrow`,ThisWeek:`This week`,ThisMonth:`This month`,ThisYear:`This year`,LastWeek:`Last week`,LastMonth:`Last month`,LastYear:`Last year`,NextWeek:`Next week`,NextMonth:`Next month`,NextYear:`Next year`,UserYesterday:`Yesterday`,UserToday:`Today`,UserTomorrow:`Tomorrow`,UserThisWeek:`This week`,UserThisMonth:`This month`,UserThisYear:`This year`,UserLastWeek:`Last week`,UserLastMonth:`Last month`,UserLastYear:`Last year`,UserNextWeek:`Next week`,UserNextMonth:`Next month`,UserNextYear:`Next year`};function De(e){return v(Ee[e]??e)}function Oe(e){return e.type===`date`||e.type===`datetime`?[...Te]:e.type===`string`?[`CurrentUser`]:[]}const ke={not:`notequals`,tweens:`notbetween`,notdate:`notdatequals`,notdateequals:`notdatequals`};function T(e){let t=e.toLowerCase().replace(/[\s,]/g,``);return ke[t]??t}function E(){return D(`and`)}function D(e=`and`){return{type:`group`,mode:e,items:[]}}function O(e){return e.type===`group`}function k(e){return e.type===`expression`}function Ae(e){return e?k(e)?{type:`group`,mode:`and`,items:[e]}:e:E()}function je(e){return A(e)===0}function A(e){return e?k(e)?1:e.items.reduce((e,t)=>e+A(t),0):0}function Me(e){if(!e)return null;if(k(e))return j(e)?{type:`group`,mode:`and`,items:[e]}:null;let t=e.items.map(e=>O(e)?Me(e):j(e)?e:null).filter(e=>e!==null);return t.length===0?null:{...e,items:t}}function j(e){if(O(e))return e.items.some(j);if(!e.column||!e.operator)return!1;let t=y(T(e.operator));return t===`none`?!0:e.value===null||e.value===void 0||e.value===``?!1:t===`pair`?Array.isArray(e.value)&&e.value.length===2&&e.value.every(e=>e!==``&&e!=null):t!==`list`||Array.isArray(e.value)&&e.value.length>0}function Ne(e,t){let n=t??we(e);return{type:`expression`,column:e.name,operator:n,value:Pe(n),valueType:w(e,n)}}function Pe(e){switch(y(e)){case`none`:return null;case`pair`:return[``,``];case`list`:return[];default:return``}}function Fe(e,t,n){let r=y(T(e.operator)),i=y(t),a=e.value;i!==r&&(a=Pe(t));let o=e.valueType===`special`&&i===r?`special`:w(n,t);return{...e,operator:t,value:a,valueType:o}}function Ie(e,t){let n=e;for(let e of t){if(!n||!O(n))return null;n=n.items[e]}return n??null}function M(e,t,n){if(t.length===0)return n(e)??e;if(!O(e))return e;let[r,...i]=t,a=e.items[r];if(!a)return e;let o=[...e.items];if(i.length===0){let e=n(a);e===null?o.splice(r,1):o[r]=e}else o[r]=M(a,i,n);return{...e,items:o}}function Le(e,t,n){return M(e,t,e=>O(e)?{...e,items:[...e.items,n]}:e)}function Re(e,t){return t.length===0?E():M(e,t,()=>null)}function ze(e,t,n){return M(e,t,e=>O(e)?{...e,mode:n}:e)}function Be(e,t=[]){let n=Ie(e,t);return Le(e,t,D(n&&O(n)&&n.mode===`and`?`or`:`and`))}async function Ve(e,t){let n=await fetch(`/api/filter/convert`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e),signal:t});if(!n.ok)throw Error(`Failed to convert filter: ${n.status} ${n.statusText}`);let r=await n.json();return{...r,filterObject:r.filterObject?Ae(r.filterObject):null}}function He(e,t={}){return e?Ue(e,new Map((t.fields??[]).map(e=>[e.name.toLowerCase(),e])),0):``}function Ue(e,t,n){if(k(e))return We(e,t);let r=e.items.map(e=>Ue(e,t,n+1)).filter(e=>e!==``);if(r.length===0)return``;if(r.length===1)return r[0];let i=e.mode===`or`?` OR `:` AND `,a=r.join(i);return n===0?a:`(${a})`}function We(e,t){if(!e.column||!e.operator)return``;let n=t.get(e.column.toLowerCase()),r=n?.caption??e.column,i=T(e.operator),a=ye(i,n?.type),o=y(i);return o===`none`?`[${r}] ${a}`:`[${r}] ${a} ${Ge(e,o)}`}function Ge(e,t){let{value:n,valueType:r}=e;if(r===`special`&&typeof n==`string`)return De(n);if(Array.isArray(n)){let e=n.map(e=>Ke(e,r));return t===`pair`?e.join(` - `):`(${e.join(`, `)})`}return Ke(n,r)}function Ke(e,t){return e==null?``:e instanceof Date?e.toISOString().slice(0,10):typeof e==`number`||typeof e==`boolean`||t===`number`||t===`boolean`?String(e):`'${String(e)}'`}const qe=[`string`,`number`,`boolean`,`date`,`datetime`,`uniqueidentifier`];function N(e){let t=e?.trim().toLowerCase();return qe.find(e=>e===t)??`string`}function P(e){return e===!0||e===1}function F(e){return{name:e.FieldName??``,type:N(e.DataType),nullable:P(e.Nullable),excludeFromFilter:P(e.ExcludeFromFilter),valueListRecordSource:e.ValueListRecordSource||void 0}}function Je(e){return e.map(F).filter(e=>e.name!==``&&!e.excludeFromFilter).sort((e,t)=>e.name.localeCompare(t.name))}function Ye(e){return!e||k(e)||e.mode!==`or`?!1:e.items.every(e=>O(e)&&e.mode===`and`&&e.items.every(k))}function Xe(e){if(!e)return{type:`group`,mode:`or`,items:[{type:`group`,mode:`and`,items:[]}]};if(k(e))return{type:`group`,mode:`or`,items:[{type:`group`,mode:`and`,items:[e]}]};if(e.mode===`or`){let t=e.items.map(e=>{let t=[];return I(e,t),{type:`group`,mode:`and`,items:t}});return{type:`group`,mode:`or`,items:t.length>0?t:[{type:`group`,mode:`and`,items:[]}]}}let t=[];return I(e,t),{type:`group`,mode:`or`,items:[{type:`group`,mode:`and`,items:t}]}}function I(e,t){if(k(e)){t.push(e);return}for(let n of e.items)I(n,t)}const Ze=-1;function Qe(e){return{filterId:e.FilterID??-1,primKey:e.PrimKey??``,name:e.FilterName??``,criteria:e.FilterCriteria??``,dbObjectId:e.DBObjectID??``,accessLevel:$e(e.AccessLevel),createdByUser:L(e.CreatedByUser),createdBy:e.CreatedBy??``,domain:e.Domain??null,crossDomain:L(e.CrossDomain),isPersonallyShared:L(e.IsPersonallyShared),hideCriteria:L(e.HideFilterCriteria),headerText:e.OptionalHeaderText||null,comment:e.OptionalComment||null,parameters:e.Parameters||null,reportTitle:e.ReportTitle||null,created:et(e.Created),updated:et(e.Updated)}}function $e(e){return e===`Manager`||e===`Editor`?e:`Reader`}function L(e){return typeof e==`string`?e.toLowerCase()===`true`:!!e}function et(e){if(!e)return null;if(e instanceof Date)return e;let t=new Date(e);return Number.isNaN(t.getTime())?null:t}function tt(e){return e.filter(e=>(e.FilterID??-1)!==-1).map(Qe).sort((e,t)=>e.name.localeCompare(t.name))}function nt(e){let t=[],n=[];for(let r of e)r.createdByUser?t.push(r):n.push(r);return{mine:t,shared:n}}function rt(e,t){if(t!=null)return e.find(e=>e.filterId===t)}function it(e){return e.accessLevel===`Editor`||e.accessLevel===`Manager`}function at(e){return e.accessLevel===`Manager`}function R(e){return e.createdByUser}const ot=R,st=R,ct={xs:64,sm:128,md:256,lg:512,xl:void 0};function lt(e,t,n,r=`xs`){if(e&&typeof e==`object`)return lt(e.primKey,e.login,e.hash,e.size);if(!e||!n)return``;let i=ct[r];return`/api/data/blob/EmployeesLookup/${e}/Image/${encodeURIComponent(t??``)}${t?`.`:``}${encodeURIComponent(n)}.jpg${i?`?width=${i}`:``}`}function ut(e,...t){g(Array.isArray(e)&&e.length===t.length+1,`Method 'localize' must be used as a tag function`);let n=v(e.map((t,n)=>n===e.length-1?t:`${t}$${n}`).join(``));return t.forEach((e,t)=>{n=n.replace(`$${t}`,e)}),n}const dt={amp:`&`,lt:`<`,gt:`>`,quot:`"`,apos:`'`};function z(e){return e.replace(/&(#x?[0-9a-f]+|[a-z]+);/gi,(e,t)=>t.startsWith(`#x`)||t.startsWith(`#X`)?String.fromCodePoint(Number.parseInt(t.slice(2),16)):t.startsWith(`#`)?String.fromCodePoint(Number.parseInt(t.slice(1),10)):dt[t.toLowerCase()]??e)}function B(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&apos;`)}function V(e,t){let n=RegExp(`<${t}(?:\\s[^>]*)?>([\\s\\S]*?)</${t}>`).exec(e);if(!n)return null;let r=z(n[1]).trim();return r===``?null:r}function ft(e,t){return[...e.matchAll(RegExp(`<${t}(?:\\s[^>]*)?>([\\s\\S]*?)</${t}>`,`g`))].map(e=>z(e[1]).trim())}const pt={Byte:`number`,Decimal:`number`,Double:`number`,Int16:`number`,Int32:`number`,Int64:`number`,Single:`number`,Boolean:`boolean`,DateTime:`date`};function mt(e){let t=/<SelectColumns>([\s\S]*?)<\/SelectColumns>/.exec(e)?.[1]??``,n=[];for(let e of t.matchAll(/<afSelectColumn>([\s\S]*?)<\/afSelectColumn>/g)){let t=V(e[1],`Name`);t&&n.push({name:t,type:pt[V(e[1],`DataType`)??``]??`string`})}return n}function H(e){if(!e||!e.includes(`<afRecordSource`))return null;let t=V(e,`ViewName`);if(!t)return null;let n=V(e,`MaxRecords`);return{viewName:t,columns:mt(e),whereClause:V(e,`WhereClause`),filterString:V(e,`FilterString`),maxRecords:n===null||n===`0`?null:Number(n)}}const ht=[`String`,`Integer`,`Double`,`Date`,`Boolean`],gt=/^[a-z]stp_/i;function U(e){return typeof e==`string`&&gt.test(e.trim())}function W(e){return e?e.split(/\r\n|\r|\n/).map(e=>e.trim()).filter(e=>e!==``):[]}function _t(e){return ht.find(t=>t.toLowerCase()===e?.trim().toLowerCase())??`String`}function vt(e,t,n){if(t)return`lookup`;if(n)return`select`;switch(e){case`Integer`:case`Double`:return`number`;case`Date`:return`date`;case`Boolean`:return`boolean`;default:return`text`}}function yt(e){let t=e.Name??``,n=_t(e.DataType),r=W(e.Items),i=H(e.RecordSource),a=e.ValueMember??null;i&&!a&&(a=i.columns[0]?.name??null);let o=i?.columns.find(e=>e.name!==a)?.name??null,s=!!(i&&a);return{name:t,label:e.Label?.trim()||t,description:e.Description?.trim()||null,type:n,editor:vt(n,s,r.length>0),defaultValue:e.DefaultValue??null,items:r,recordSource:s?i:null,valueMember:s?a:null,displayMember:s?o:null,sortOrder:e.SortOrder??0,lookupWidth:e.LookupWidth??null,lookupHeight:e.LookupHeight??null}}function bt(e){return e.filter(e=>e.Name).map(yt).sort((e,t)=>e.sortOrder-t.sortOrder||e.label.localeCompare(t.label))}function G(e,t){if(t==null||t===``)return e.type!==`Boolean`&&null;switch(e.type){case`Boolean`:return typeof t==`boolean`?t:/^(true|1|ja|yes)$/i.test(String(t));case`Integer`:{let e=Number.parseInt(String(t),10);return Number.isNaN(e)?null:e}case`Double`:{let e=Number(String(t).replace(`,`,`.`));return Number.isNaN(e)?null:e}default:return String(t)}}function xt(e){let t={};for(let n of e)t[n.name]=U(n.defaultValue)?G(n,null):G(n,n.defaultValue);return t}function St(e,t){return t==null?``:typeof t==`boolean`?t?`True`:`False`:String(t)}function Ct(e,t){return`<Parameters Version="1">\n${e.map(e=>{let n=St(e,t[e.name]??null);return` <Parameter Name="${B(e.name)}" Type="${e.type}">${B(n)}</Parameter>`}).join(`
2
- `)}\n</Parameters>`}function wt(e){if(!e)return{};let t={};for(let n of e.matchAll(/<Parameter\s+([^>]*?)\/?>(?:([\s\S]*?)<\/Parameter>)?/g)){let e=/Name\s*=\s*"([^"]*)"/.exec(n[1])?.[1];e&&(t[e]=V(n[0],`Parameter`)??``)}return t}function Tt(e,t){let n=wt(t),r=xt(e);for(let t of e)t.name in n&&(r[t.name]=G(t,n[t.name]));return r}async function Et(e,t,n){if(!t.defaultValue||!U(t.defaultValue))return null;let r=await fetch(`/api/reporting/filters/${encodeURIComponent(e)}/GetParameterDefaultValue`,{body:JSON.stringify({parameterName:t.name}),credentials:`same-origin`,headers:{"Content-Type":`application/json`,"X-Requested-With":`XMLHttpRequest`},method:`POST`,signal:n});if(!r.ok)throw Error(`${r.status} ${r.statusText}`);return Ot(await r.json())}async function Dt(e,t,n,r){let i=t.filter(e=>U(e.defaultValue??``));if(i.length===0)return n;let a=await Promise.all(i.map(async t=>{try{return[t.name,await Et(e,t,r)]}catch{return[t.name,null]}})),o={...n};for(let[e,t]of a)t!==null&&(o[e]=t);return o}function Ot(e){let t=(Array.isArray(e)?e:Object.values(e).find(e=>Array.isArray(e)))?.[0];return t==null?null:Array.isArray(t)?t[0]??null:typeof t==`object`?Object.values(t)[0]??null:t}const kt={CSV:`csv`,HTML:`html`,IMAGE:`xbm`,MHT:`mht`,PDF:`pdf`,RTF:`rtf`,TEXT:`txt`,XLS:`xls`,XLSX:`xlsx`},At={CSV:`text/csv`,HTML:`text/html`,IMAGE:`image/x-xbitmap`,MHT:`message/rfc822`,PDF:`application/pdf`,RTF:`text/enriched`,TEXT:`text/plain`,XLS:`application/vnd.ms-excel`,XLSX:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`};function jt(e){return kt[e]}function K(e){return At[e]}const Mt=/[\\/:*?"<>|.#&+%\u0000-\u001f]/g;function q(e){let t=(e.fileName??e.reportId).trim().replace(Mt,`-`).replace(/-{2,}/g,`-`).replace(/^-|-$/g,``).trim();return`${t===``?e.reportId:t}.${jt(e.format)}`}function Nt(e){let t=window.location?.href;return t?new URL(e,t).toString():e}function J(e){let{domain:t,filter:n,headerText:r,hideFilterString:i,parameters:a,reportId:o,signal:s,timezone:c}=e,l=q(e),u=`/api/report/${encodeURIComponent(o)}/${encodeURIComponent(l)}`,d=new URLSearchParams,f=It(a),p=f.length>0||!!r||i===!0;if(t&&d.set(`Domain`,t),d.set(`timezone`,String(c??-new Date().getTimezoneOffset()/60)),!p)return n&&d.set(`Filter`,n),new Request(Nt(`${u}?${d}`),{credentials:`same-origin`,signal:s});let m={filter:n??``,parameters:f};return r&&(m.optionalheader=r),i===!0&&(m.showfiltercriteria=`true`),new Request(Nt(`${u}?${d}`),{body:JSON.stringify(m),credentials:`same-origin`,headers:{"Content-Type":`application/json`,"X-Requested-With":`XMLHttpRequest`},method:`POST`,signal:s})}async function Y(e){let t=await fetch(J(e));if((t.headers.get(`content-type`)??``).includes(`application/json`)){let e=await t.json();throw Error(e.error??`Failed to render report`)}if(!t.ok)throw Error(`${t.status} ${t.statusText}`);return t.blob()}function Pt(e){return ae(J(e),{fileName:q(e),onProgress:e.onProgress,signal:e.signal})}async function X(e){let t=await Y(e),n=URL.createObjectURL(t.type?t:new Blob([t],{type:K(e.format)}));if(!window.open(n,`_blank`,`noopener`))throw URL.revokeObjectURL(n),Error(`The report could not be opened. Allow pop-ups for this site and try again.`);window.setTimeout(()=>URL.revokeObjectURL(n),6e4)}async function Ft(e){let t=window.document;if(!t?.body)return X(e);let n=await Y(e),r=URL.createObjectURL(n.type?n:new Blob([n],{type:K(e.format)})),i=t.createElement(`iframe`);i.setAttribute(`aria-hidden`,`true`),i.style.cssText=`position:fixed;inset-block-start:0;inset-inline-start:0;inline-size:1px;block-size:1px;border:0;visibility:hidden`;let a=()=>{i.remove(),URL.revokeObjectURL(r)};try{await new Promise((e,n)=>{i.addEventListener(`load`,()=>e(),{once:!0}),i.addEventListener(`error`,()=>n(Error(`The report could not be loaded for printing`)),{once:!0}),i.src=r,t.body.append(i)}),i.contentWindow?.focus(),i.contentWindow?.print()}catch{return a(),X(e)}window.setTimeout(a,6e4)}function It(e){return e?Object.entries(e).filter(([,e])=>e!=null&&e!==``).map(([e,t])=>({name:e,value:typeof t==`boolean`?String(t):t})):[]}function Z(e){return e===!0||e===1}function Lt(e){let t=[];return Z(e.FormatPDF)&&t.push(`PDF`),Z(e.FormatCSV)&&t.push(`XLSX`,`XLS`,`CSV`),Z(e.FormatHTML)&&t.push(`HTML`),Z(e.FormatRTF)&&t.push(`RTF`),Z(e.FormatMHT)&&t.push(`MHT`),Z(e.FormatTEXT)&&t.push(`TEXT`),Z(e.FormatIMAGE)&&t.push(`IMAGE`),t}function Rt(e){let t=H(e.RecordSource);return{reportId:e.ReportID??``,shortId:e.ShortID??null,title:e.Title?.trim()||null,description:e.Description?.trim()||null,viewName:t?.viewName??null,initialFilter:t?.filterString??null,hasTitle:Z(e.HasTitle),hasHeader:Z(e.HasHeader),formats:Lt(e),timeout:e.Timeout??null}}function zt(){if(document.querySelector(`#AlertDialogTemplate`))return;let e=document.createElement(`template`);e.id=`AlertDialogTemplate`,e.innerHTML=`
1
+ function e(e){return{all:e||=new Map,on:function(t,n){var r=e.get(t);r?r.push(n):e.set(t,[n])},off:function(t,n){var r=e.get(t);r&&(n?r.splice(r.indexOf(n)>>>0,1):e.set(t,[]))},emit:function(t,n){var r=e.get(t);r&&r.slice().map(function(e){e(n)}),(r=e.get(`*`))&&r.slice().map(function(e){e(t,n)})}}}var t=class{eventHandler=e();authenticated(){this.eventHandler.emit(`onAuthenticated`)}async expired(e,t){try{let n=new Promise(t=>{let n=()=>{this.eventHandler.off(`onAuthenticated`,n),e?.(),t()};this.eventHandler.on(`onAuthenticated`,n)}),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 e=`/login?ReturnUrl=%2fapi/sessionexpired/remove`;t===`RequireTwoFactor`?e=`/login?RequireTwoFactor=1&ReturnUrl=%2fapi/sessionexpired/remove`:await fetch(`/logout`,{method:`POST`}),r.innerHTML=`<iframe sandbox="allow-same-origin allow-scripts allow-modals allow-top-navigation-by-user-activation allow-forms" src="${e}" style="border:0;width:min(500px,100vw);height:min(700px, 100vh);"></iframe>`,document.body.append(r),r.showModal(),await n,r.remove()}}catch{window.location.href=`/login?ReturnUrl=${encodeURIComponent(window.location.pathname)}${encodeURIComponent(window.location.search)}`}}attachEvent(e,t){return this.eventHandler.on(e,t)}detachEvent(e,t){return this.eventHandler.off(e,t)}},n=class extends t{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(e){super(),this.formats={},Object.assign(this,e)}};const r=window.af?.article?.id??window.window?.location.pathname.substring(1).split(`/`)[0];async function i(e,t={},n=0){try{let i=await fetch(`/api/logging/log-activity`,{method:`POST`,body:JSON.stringify({article:r,timeElapsed:n,action:e,parameters:{...t,_session:p()}}),headers:{"Content-Type":`application/json`,Accept:`application/json`}});if(!i.ok){if(i.headers.get(`Content-Type`)?.includes(`application/json`)){let e=await i.json();console.error(e.error)}else console.error(`${i.status} ${i.statusText}`)}}catch{}}function a(e,t={}){let n=performance.now();return(r={})=>i(e,{...t,...r},performance.now()-n)}async function o(e){let t=performance.now();return[await e(),performance.now()-t]}async function s(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 c(){return crypto.randomUUID?.()}let l=Date.now(),u=c(),d=``,f=``;if(`document`in window){let e=()=>i(`AfSessionInit`,{"appframe-core":window.af?.common?.version,"appframe-data":window.af?.data?.version,"app-version":window.af?.article?.version});document.addEventListener(`DOMContentLoaded`,()=>{d=localStorage.getItem(`_afDeviceId`),f=sessionStorage.getItem(`_afSessionId`),d||(d=c(),localStorage.setItem(`_afDeviceId`,d)),f||(f=u,sessionStorage.setItem(`_afSessionId`,f)),e()}),document.addEventListener(`visibilitychange`,function(){document.visibilityState===`hidden`?navigator.sendBeacon(`/api/logging/log-activity`,JSON.stringify({article:r,action:`AfSessionEnd`,parameters:{_session:p()}})):e()})}function p(){return{browserSessionId:f,sessionStart:l,sessionLength:Date.now()-l,sessionId:u,deviceId:d}}window.window?.addEventListener(`error`,e=>{typeof e==`object`&&`error`in e?s(e.error):typeof e==`object`&&`message`in e&&s(e)});function m(e){return[af?.article?.id||``,`common`,e].join(`.`)}var ee=new class{isPersisted=()=>!0;getLocalStorageKey(e,t){return t?[`common`,e].join(`.`):m(e)}get(e,t,n){let r=this.getLocalStorageKey(e,n),i=localStorage.getItem(r);return i===null?t:JSON.parse(i)}set(e,t,n){localStorage.setItem(this.getLocalStorageKey(e,n),JSON.stringify(t))}remove(e,t){let n=this.getLocalStorageKey(e,t);return localStorage.getItem(n)!==null&&(localStorage.removeItem(n),!0)}clear(){let e=m(``);for(let t in localStorage)t.slice(0,e.length)===e&&localStorage.removeItem(t)}};function te(e){return e?ne(e).substring(0,10):null}function h(e,t=2){return String(e).padStart(t,`0`)}function ne(e){return e?`${e.getFullYear()}-${h(e.getMonth()+1)}-${h(e.getDate())}T${h(e.getHours())}:${h(e.getMinutes())}:${h(e.getSeconds())}.${h(e.getMilliseconds(),3)}`:null}function re(e){return e?e.toISOString().substring(0,16):``}function ie(e,t){return new Promise((n,r)=>{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(e){r(e)}})}function g(e,t){if(e)return;let n=typeof t==`function`?t():t;throw Error(n??`Invariant failed`)}async function ae(e,{fileName:t,signal:n,onProgress:r}){let i=0;r?.({status:`requested`});try{let n=await fetch(e);if(!n.ok||!n.body){if(n.headers.get(`content-type`)?.includes(`application/json`)){let e=await n.json();g(!e.error,e.error)}throw Error(`${n.status} ${n.statusText}`)}try{let e=n.body.getReader(),t=new ReadableStream({start:t=>{function n(){return e.read().then(e=>{if(e.done){t.close();return}return i+=e.value.length,r?.({bytesReceived:i,status:`downloading`}),t.enqueue(e.value),n()})}return n()}});n=new Response(t)}catch{}let a=await n.blob();r?.({bytesReceived:i,status:`downloaded`}),await ie(a,t),r?.({bytesReceived:i,status:`completed`})}catch(e){n?.aborted?r?.({status:`cancelled`}):r?.({error:e.message,status:`error`})}}const oe=/^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)*)\}$/,se=/^(?:\(([^)]*)\)|([a-zA-Z$_][a-zA-Z0-9$_]*))\s*=>\s*\{([\s\S]*)\}$/,ce=/^(?:\(([^)]*)\)|([a-zA-Z$_][a-zA-Z0-9$_]*))\s*=>\s*([\s\S]+)$/,_=e=>e.split(`,`).map(e=>e.trim()).filter(Boolean);function v(e){let t=e.toString(),n=t.match(se);if(n){let t=_(n[1]??n[2]??``);return{name:e.name,args:t,body:n[3]}}let r=t.match(ce);if(r){let t=_(r[1]??r[2]??``);return{name:e.name,args:t,body:r[3]}}let i=t.match(oe);return g(i,`Unable to parse function!`),{name:e.name??i[1],args:_(i[2]),body:i[3]}}function y(){}y.prototype=Object.create(null);function le(e,t){if(typeof e==`object`){if(typeof t==`string`)return le(e,t.split(`.`));if(Array.isArray(t)){let n=e;for(let e=0;e<t.length;e++)n=n[t[e]]=n[t[e]]||new y;return n}}}function ue(e,t,n={}){if(Array.isArray(t))for(let n of t){let{name:t}=v(n);g(t,`Unable to detect name of function! Name it, or only supply one function and include name in first parameter.`),ue(e,n)}else{let r,i;if(typeof t==`function`&&(r=v(t).name),typeof e==`string`){let t=e.split(`.`);r||(r=t[t.length-1],t=t.slice(0,t.length-1)),i=le(window,t)}else r&&(typeof e==`object`||typeof e==`function`)?i=e:g(!1,`Invalid typeof parameter 'name', or unable to parse pValue!`);Object.hasOwn(i,r)&&n?.overwrite!==!0?console.warn(`${[e,r].join(`.`)} is already defined!`):i[r]=t}}async function de(e,t){try{let n=await fetch(`/api/user/localize/new/${encodeURIComponent(t)}`,{body:JSON.stringify({text:e}),headers:{Accept:`application/json; */*`,"Content-Type":`application/json`,"X-Requested-With":`XMLHttpRequest`},method:`POST`});if(n.ok)return await n.json()}catch{}return e}function fe(e){let t=window.af;if(!t)return;if(e){let n=t.i18n?.[e];if(n)return{dictionary:n,harvestAs:e}}let n=t.article;if(n?.i18n)return{dictionary:n.i18n,harvestAs:n.id}}function b(e,t){if(typeof e==`string`&&e.trim().length===0)return e;if(e===void 0||e===``||e===null)return;let{project:n,wait:r}=typeof t==`object`?t:{wait:t},i=fe(n);if(i===void 0)return e;let{dictionary:a,harvestAs:o}=i;if(!Object.hasOwn(a,e)){a[e]=e;let t=de(e,o).then(t=>(a[e]=t,t));if(r)return t}return a[e]}function pe(e){function t(t,n){return b(t,{project:e,wait:n})}function n(e,...n){let r=t(e.map((t,n)=>n===e.length-1?t:`${t}$${n}`).join(``));return n.forEach((e,t)=>{r=r.replace(`$${t}`,String(e))}),r}return{project:e,getLocalizedString:t,localize:n}}const me=[`isnull`,`isnotnull`,`istrue`,`isfalse`,`isblank`,`isnotblank`],he=[`between`,`notbetween`,`datebetween`,`datenotbetween`],ge=[`inlist`,`notinlist`];function x(e){return me.includes(e)?`none`:he.includes(e)?`pair`:ge.includes(e)?`list`:`single`}const _e={equals:`Equal to`,notequals:`Not equal to`,greaterthan:`Greater than`,greaterthanorequal:`Greater than or equal to`,lessthan:`Less than`,lessthanorequal:`Less than or equal to`,beginswith:`Begins with`,notbeginswith:`Does not begin with`,endswith:`Ends with`,notendswith:`Does not end with`,contains:`Contains`,notcontains:`Does not contain`,like:`Like`,notlike:`Not like`,isnull:`Is null`,isnotnull:`Is not null`,isblank:`Is empty`,isnotblank:`Is not empty`,istrue:`Is true`,isfalse:`Is false`,inlist:`In list`,notinlist:`Not in list`,between:`Between`,notbetween:`Not between`,dateequals:`Equal to`,notdatequals:`Not equal to`,dategreaterthan:`After`,dategreaterthanorequal:`On or after`,datelessthan:`Before`,datelessthanorequal:`Up to`,datebetween:`Between`,datenotbetween:`Not between`},ve={greaterthan:`After`,greaterthanorequal:`On or after`,lessthan:`Before`,lessthanorequal:`Up to`};function ye(e,t){return b((t===`date`||t===`datetime`?ve[e]:void 0)??_e[e]??e)}const S=[`equals`,`notequals`],C=[`inlist`,`notinlist`],w=[`between`,`notbetween`],T=[`greaterthan`,`greaterthanorequal`,`lessthan`,`lessthanorequal`],be=[`contains`,`notcontains`,`beginswith`,`notbeginswith`,`endswith`,`notendswith`,`isblank`,`isnotblank`],xe={date:[...S,...C,...w,...T],datetime:[...S,...C,...w,...T],number:[...S,...C,...w,...T],boolean:[`istrue`,`isfalse`],string:[...S,...be,...C,...w,...T],uniqueidentifier:[...S,...be,...C,...w,...T]},Se={date:`equals`,datetime:`equals`,number:`equals`,boolean:`istrue`,string:`contains`,uniqueidentifier:`beginswith`};function Ce(e){let t=[...xe[e.type]??xe.string];return e.nullable&&e.type!==`boolean`&&t.push(`isnull`,`isnotnull`),t}function we(e){return Se[e.type]??`equals`}function E(e,t){if(x(t)===`none`)return`null`;switch(e.type){case`number`:return`number`;case`boolean`:return`boolean`;case`date`:case`datetime`:return`datetime`;case`uniqueidentifier`:return`uniqueidentifier`;default:return`string`}}const Te=[`Yesterday`,`Today`,`Tomorrow`,`ThisWeek`,`ThisMonth`,`ThisYear`,`LastWeek`,`LastMonth`,`LastYear`,`NextWeek`,`NextMonth`,`NextYear`],Ee={CurrentUser:`Current user`,Yesterday:`Yesterday`,Today:`Today`,Tomorrow:`Tomorrow`,ThisWeek:`This week`,ThisMonth:`This month`,ThisYear:`This year`,LastWeek:`Last week`,LastMonth:`Last month`,LastYear:`Last year`,NextWeek:`Next week`,NextMonth:`Next month`,NextYear:`Next year`,UserYesterday:`Yesterday`,UserToday:`Today`,UserTomorrow:`Tomorrow`,UserThisWeek:`This week`,UserThisMonth:`This month`,UserThisYear:`This year`,UserLastWeek:`Last week`,UserLastMonth:`Last month`,UserLastYear:`Last year`,UserNextWeek:`Next week`,UserNextMonth:`Next month`,UserNextYear:`Next year`};function D(e){return b(Ee[e]??e)}function De(e){return e.type===`date`||e.type===`datetime`?[...Te]:e.type===`string`?[`CurrentUser`]:[]}const Oe={not:`notequals`,tweens:`notbetween`,notdate:`notdatequals`,notdateequals:`notdatequals`};function O(e){let t=e.toLowerCase().replace(/[\s,]/g,``);return Oe[t]??t}function k(){return A(`and`)}function A(e=`and`){return{type:`group`,mode:e,items:[]}}function j(e){return e.type===`group`}function M(e){return e.type===`expression`}function ke(e){return e?M(e)?{type:`group`,mode:`and`,items:[e]}:e:k()}function Ae(e){return N(e)===0}function N(e){return e?M(e)?1:e.items.reduce((e,t)=>e+N(t),0):0}function je(e){if(!e)return null;if(M(e))return P(e)?{type:`group`,mode:`and`,items:[e]}:null;let t=e.items.map(e=>j(e)?je(e):P(e)?e:null).filter(e=>e!==null);return t.length===0?null:{...e,items:t}}function P(e){if(j(e))return e.items.some(P);if(!e.column||!e.operator)return!1;let t=x(O(e.operator));return t===`none`?!0:e.value===null||e.value===void 0||e.value===``?!1:t===`pair`?Array.isArray(e.value)&&e.value.length===2&&e.value.every(e=>e!==``&&e!=null):t!==`list`||Array.isArray(e.value)&&e.value.length>0}function Me(e,t){let n=t??we(e);return{type:`expression`,column:e.name,operator:n,value:Ne(n),valueType:E(e,n)}}function Ne(e){switch(x(e)){case`none`:return null;case`pair`:return[``,``];case`list`:return[];default:return``}}function Pe(e,t,n){let r=x(O(e.operator)),i=x(t),a=e.value;i!==r&&(a=Ne(t));let o=e.valueType===`special`&&i===r?`special`:E(n,t);return{...e,operator:t,value:a,valueType:o}}function Fe(e,t){let n=e;for(let e of t){if(!n||!j(n))return null;n=n.items[e]}return n??null}function F(e,t,n){if(t.length===0)return n(e)??e;if(!j(e))return e;let[r,...i]=t,a=e.items[r];if(!a)return e;let o=[...e.items];if(i.length===0){let e=n(a);e===null?o.splice(r,1):o[r]=e}else o[r]=F(a,i,n);return{...e,items:o}}function Ie(e,t,n){return F(e,t,e=>j(e)?{...e,items:[...e.items,n]}:e)}function Le(e,t){return t.length===0?k():F(e,t,()=>null)}function Re(e,t,n){return F(e,t,e=>j(e)?{...e,mode:n}:e)}function ze(e,t=[]){let n=Fe(e,t);return Ie(e,t,A(n&&j(n)&&n.mode===`and`?`or`:`and`))}async function Be(e,t){let n=await fetch(`/api/filter/convert`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e),signal:t});if(!n.ok)throw Error(`Failed to convert filter: ${n.status} ${n.statusText}`);let r=await n.json();return{...r,filterObject:r.filterObject?ke(r.filterObject):null}}function Ve(e,t={}){return e?He(e,new Map((t.fields??[]).map(e=>[e.name.toLowerCase(),e])),0):``}function He(e,t,n){if(M(e))return Ue(e,t);let r=e.items.map(e=>He(e,t,n+1)).filter(e=>e!==``);if(r.length===0)return``;if(r.length===1)return r[0];let i=e.mode===`or`?` OR `:` AND `,a=r.join(i);return n===0?a:`(${a})`}function Ue(e,t){if(!e.column||!e.operator)return``;let n=t.get(e.column.toLowerCase()),r=n?.caption??e.column,i=O(e.operator),a=ye(i,n?.type),o=x(i);return o===`none`?`[${r}] ${a}`:`[${r}] ${a} ${We(e,o)}`}function We(e,t){let{value:n,valueType:r}=e;if(r===`special`&&typeof n==`string`)return D(n);if(Array.isArray(n)){let e=n.map(e=>Ge(e,r));return t===`pair`?e.join(` - `):`(${e.join(`, `)})`}return Ge(n,r)}function Ge(e,t){return e==null?``:e instanceof Date?e.toISOString().slice(0,10):typeof e==`number`||typeof e==`boolean`||t===`number`||t===`boolean`?String(e):`'${String(e)}'`}const Ke=[`string`,`number`,`boolean`,`date`,`datetime`,`uniqueidentifier`];function qe(e){let t=e?.trim().toLowerCase();return Ke.find(e=>e===t)??`string`}function Je(e){return e===!0||e===1}function Ye(e){return{name:e.FieldName??``,type:qe(e.DataType),nullable:Je(e.Nullable),excludeFromFilter:Je(e.ExcludeFromFilter),valueListRecordSource:e.ValueListRecordSource||void 0}}function Xe(e){return e.map(Ye).filter(e=>e.name!==``&&!e.excludeFromFilter).sort((e,t)=>e.name.localeCompare(t.name))}function Ze(e){return!e||M(e)||e.mode!==`or`?!1:e.items.every(e=>j(e)&&e.mode===`and`&&e.items.every(M))}function Qe(e){if(!e)return{type:`group`,mode:`or`,items:[{type:`group`,mode:`and`,items:[]}]};if(M(e))return{type:`group`,mode:`or`,items:[{type:`group`,mode:`and`,items:[e]}]};if(e.mode===`or`){let t=e.items.map(e=>{let t=[];return I(e,t),{type:`group`,mode:`and`,items:t}});return{type:`group`,mode:`or`,items:t.length>0?t:[{type:`group`,mode:`and`,items:[]}]}}let t=[];return I(e,t),{type:`group`,mode:`or`,items:[{type:`group`,mode:`and`,items:t}]}}function I(e,t){if(M(e)){t.push(e);return}for(let n of e.items)I(n,t)}const $e=-1;function et(e){return{filterId:e.FilterID??-1,primKey:e.PrimKey??``,name:e.FilterName??``,criteria:e.FilterCriteria??``,dbObjectId:e.DBObjectID??``,accessLevel:tt(e.AccessLevel),createdByUser:L(e.CreatedByUser),createdBy:e.CreatedBy??``,domain:e.Domain??null,crossDomain:L(e.CrossDomain),isPersonallyShared:L(e.IsPersonallyShared),hideCriteria:L(e.HideFilterCriteria),headerText:e.OptionalHeaderText||null,comment:e.OptionalComment||null,parameters:e.Parameters||null,reportTitle:e.ReportTitle||null,created:nt(e.Created),updated:nt(e.Updated)}}function tt(e){return e===`Manager`||e===`Editor`?e:`Reader`}function L(e){return typeof e==`string`?e.toLowerCase()===`true`:!!e}function nt(e){if(!e)return null;if(e instanceof Date)return e;let t=new Date(e);return Number.isNaN(t.getTime())?null:t}function rt(e){return e.filter(e=>(e.FilterID??-1)!==-1).map(et).sort((e,t)=>e.name.localeCompare(t.name))}function it(e){let t=[],n=[];for(let r of e)r.createdByUser?t.push(r):n.push(r);return{mine:t,shared:n}}function at(e,t){if(t!=null)return e.find(e=>e.filterId===t)}function ot(e){return e.accessLevel===`Editor`||e.accessLevel===`Manager`}function st(e){return e.accessLevel===`Manager`}function R(e){return e.createdByUser}const ct=R,lt=R,ut={xs:64,sm:128,md:256,lg:512,xl:void 0};function dt(e,t,n,r=`xs`){if(e&&typeof e==`object`)return dt(e.primKey,e.login,e.hash,e.size);if(!e||!n)return``;let i=ut[r];return`/api/data/blob/EmployeesLookup/${e}/Image/${encodeURIComponent(t??``)}${t?`.`:``}${encodeURIComponent(n)}.jpg${i?`?width=${i}`:``}`}function ft(e,...t){g(Array.isArray(e)&&e.length===t.length+1,`Method 'localize' must be used as a tag function`);let n=b(e.map((t,n)=>n===e.length-1?t:`${t}$${n}`).join(``));return t.forEach((e,t)=>{n=n.replace(`$${t}`,e)}),n}const pt={amp:`&`,lt:`<`,gt:`>`,quot:`"`,apos:`'`};function z(e){return e.replace(/&(#x?[0-9a-f]+|[a-z]+);/gi,(e,t)=>t.startsWith(`#x`)||t.startsWith(`#X`)?String.fromCodePoint(Number.parseInt(t.slice(2),16)):t.startsWith(`#`)?String.fromCodePoint(Number.parseInt(t.slice(1),10)):pt[t.toLowerCase()]??e)}function B(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&apos;`)}function V(e,t){let n=RegExp(`<${t}(?:\\s[^>]*)?>([\\s\\S]*?)</${t}>`).exec(e);if(!n)return null;let r=z(n[1]).trim();return r===``?null:r}function mt(e,t){return[...e.matchAll(RegExp(`<${t}(?:\\s[^>]*)?>([\\s\\S]*?)</${t}>`,`g`))].map(e=>z(e[1]).trim())}const ht={Byte:`number`,Decimal:`number`,Double:`number`,Int16:`number`,Int32:`number`,Int64:`number`,Single:`number`,Boolean:`boolean`,DateTime:`date`};function gt(e){let t=/<SelectColumns>([\s\S]*?)<\/SelectColumns>/.exec(e)?.[1]??``,n=[];for(let e of t.matchAll(/<afSelectColumn>([\s\S]*?)<\/afSelectColumn>/g)){let t=V(e[1],`Name`);t&&n.push({name:t,type:ht[V(e[1],`DataType`)??``]??`string`})}return n}function H(e){if(!e||!e.includes(`<afRecordSource`))return null;let t=V(e,`ViewName`);if(!t)return null;let n=V(e,`MaxRecords`);return{viewName:t,columns:gt(e),whereClause:V(e,`WhereClause`),filterString:V(e,`FilterString`),maxRecords:n===null||n===`0`?null:Number(n)}}const _t=[`String`,`Integer`,`Double`,`Date`,`Boolean`],vt=/^[a-z]stp_/i;function U(e){return typeof e==`string`&&vt.test(e.trim())}function yt(e){return e?e.split(/\r\n|\r|\n/).map(e=>e.trim()).filter(e=>e!==``):[]}function bt(e){return _t.find(t=>t.toLowerCase()===e?.trim().toLowerCase())??`String`}function xt(e,t,n){if(t)return`lookup`;if(n)return`select`;switch(e){case`Integer`:case`Double`:return`number`;case`Date`:return`date`;case`Boolean`:return`boolean`;default:return`text`}}function St(e){let t=e.Name??``,n=bt(e.DataType),r=yt(e.Items),i=H(e.RecordSource),a=e.ValueMember??null;i&&!a&&(a=i.columns[0]?.name??null);let o=i?.columns.find(e=>e.name!==a)?.name??null,s=!!(i&&a);return{name:t,label:e.Label?.trim()||t,description:e.Description?.trim()||null,type:n,editor:xt(n,s,r.length>0),defaultValue:e.DefaultValue??null,items:r,recordSource:s?i:null,valueMember:s?a:null,displayMember:s?o:null,sortOrder:e.SortOrder??0,lookupWidth:e.LookupWidth??null,lookupHeight:e.LookupHeight??null}}function Ct(e){return e.filter(e=>e.Name).map(St).sort((e,t)=>e.sortOrder-t.sortOrder||e.label.localeCompare(t.label))}function W(e,t){if(t==null||t===``)return e.type!==`Boolean`&&null;switch(e.type){case`Boolean`:return typeof t==`boolean`?t:/^(true|1|ja|yes)$/i.test(String(t));case`Integer`:{let e=Number.parseInt(String(t),10);return Number.isNaN(e)?null:e}case`Double`:{let e=Number(String(t).replace(`,`,`.`));return Number.isNaN(e)?null:e}default:return String(t)}}function wt(e){let t={};for(let n of e)t[n.name]=U(n.defaultValue)?W(n,null):W(n,n.defaultValue);return t}function Tt(e,t){return t==null?``:typeof t==`boolean`?t?`True`:`False`:String(t)}function Et(e,t){return`<Parameters Version="1">\n${e.map(e=>{let n=Tt(e,t[e.name]??null);return` <Parameter Name="${B(e.name)}" Type="${e.type}">${B(n)}</Parameter>`}).join(`
2
+ `)}\n</Parameters>`}function Dt(e){if(!e)return{};let t={};for(let n of e.matchAll(/<Parameter\s+([^>]*?)\/?>(?:([\s\S]*?)<\/Parameter>)?/g)){let e=/Name\s*=\s*"([^"]*)"/.exec(n[1])?.[1];e&&(t[e]=V(n[0],`Parameter`)??``)}return t}function Ot(e,t){let n=Dt(t),r=wt(e);for(let t of e)t.name in n&&(r[t.name]=W(t,n[t.name]));return r}async function kt(e,t,n){if(!t.defaultValue||!U(t.defaultValue))return null;let r=await fetch(`/api/reporting/filters/${encodeURIComponent(e)}/GetParameterDefaultValue`,{body:JSON.stringify({parameterName:t.name}),credentials:`same-origin`,headers:{"Content-Type":`application/json`,"X-Requested-With":`XMLHttpRequest`},method:`POST`,signal:n});if(!r.ok)throw Error(`${r.status} ${r.statusText}`);return jt(await r.json())}async function At(e,t,n,r){let i=t.filter(e=>U(e.defaultValue??``));if(i.length===0)return n;let a=await Promise.all(i.map(async t=>{try{return[t.name,await kt(e,t,r)]}catch{return[t.name,null]}})),o={...n};for(let[e,t]of a)t!==null&&(o[e]=t);return o}function jt(e){let t=(Array.isArray(e)?e:Object.values(e).find(e=>Array.isArray(e)))?.[0];return t==null?null:Array.isArray(t)?t[0]??null:typeof t==`object`?Object.values(t)[0]??null:t}const Mt={CSV:`csv`,HTML:`html`,IMAGE:`xbm`,MHT:`mht`,PDF:`pdf`,RTF:`rtf`,TEXT:`txt`,XLS:`xls`,XLSX:`xlsx`},Nt={CSV:`text/csv`,HTML:`text/html`,IMAGE:`image/x-xbitmap`,MHT:`message/rfc822`,PDF:`application/pdf`,RTF:`text/enriched`,TEXT:`text/plain`,XLS:`application/vnd.ms-excel`,XLSX:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`};function Pt(e){return Mt[e]}function G(e){return Nt[e]}const Ft=/[\\/:*?"<>|.#&+%\u0000-\u001f]/g;function K(e){let t=(e.fileName??e.reportId).trim().replace(Ft,`-`).replace(/-{2,}/g,`-`).replace(/^-|-$/g,``).trim();return`${t===``?e.reportId:t}.${Pt(e.format)}`}function It(e){let t=window.location?.href;return t?new URL(e,t).toString():e}function q(e){let{domain:t,filter:n,headerText:r,hideFilterString:i,parameters:a,reportId:o,signal:s,timezone:c}=e,l=K(e),u=`/api/report/${encodeURIComponent(o)}/${encodeURIComponent(l)}`,d=new URLSearchParams,f=zt(a),p=f.length>0||!!r||i===!0;if(t&&d.set(`Domain`,t),d.set(`timezone`,String(c??-new Date().getTimezoneOffset()/60)),!p)return n&&d.set(`Filter`,n),new Request(It(`${u}?${d}`),{credentials:`same-origin`,signal:s});let m={filter:n??``,parameters:f};return r&&(m.optionalheader=r),i===!0&&(m.showfiltercriteria=`true`),new Request(It(`${u}?${d}`),{body:JSON.stringify(m),credentials:`same-origin`,headers:{"Content-Type":`application/json`,"X-Requested-With":`XMLHttpRequest`},method:`POST`,signal:s})}async function J(e){let t=await fetch(q(e));if((t.headers.get(`content-type`)??``).includes(`application/json`)){let e=await t.json();throw Error(e.error??`Failed to render report`)}if(!t.ok)throw Error(`${t.status} ${t.statusText}`);return t.blob()}function Lt(e){return ae(q(e),{fileName:K(e),onProgress:e.onProgress,signal:e.signal})}async function Y(e){let t=await J(e),n=URL.createObjectURL(t.type?t:new Blob([t],{type:G(e.format)}));if(!window.open(n,`_blank`,`noopener`))throw URL.revokeObjectURL(n),Error(`The report could not be opened. Allow pop-ups for this site and try again.`);window.setTimeout(()=>URL.revokeObjectURL(n),6e4)}async function Rt(e){let t=window.document;if(!t?.body)return Y(e);let n=await J(e),r=URL.createObjectURL(n.type?n:new Blob([n],{type:G(e.format)})),i=t.createElement(`iframe`);i.setAttribute(`aria-hidden`,`true`),i.style.cssText=`position:fixed;inset-block-start:0;inset-inline-start:0;inline-size:1px;block-size:1px;border:0;visibility:hidden`;let a=()=>{i.remove(),URL.revokeObjectURL(r)};try{await new Promise((e,n)=>{i.addEventListener(`load`,()=>e(),{once:!0}),i.addEventListener(`error`,()=>n(Error(`The report could not be loaded for printing`)),{once:!0}),i.src=r,t.body.append(i)}),i.contentWindow?.focus(),i.contentWindow?.print()}catch{return a(),Y(e)}window.setTimeout(a,6e4)}function zt(e){return e?Object.entries(e).filter(([,e])=>e!=null&&e!==``).map(([e,t])=>({name:e,value:typeof t==`boolean`?String(t):t})):[]}function X(e){return e===!0||e===1}function Bt(e){let t=[];return X(e.FormatPDF)&&t.push(`PDF`),X(e.FormatCSV)&&t.push(`XLSX`,`XLS`,`CSV`),X(e.FormatHTML)&&t.push(`HTML`),X(e.FormatRTF)&&t.push(`RTF`),X(e.FormatMHT)&&t.push(`MHT`),X(e.FormatTEXT)&&t.push(`TEXT`),X(e.FormatIMAGE)&&t.push(`IMAGE`),t}function Vt(e){let t=H(e.RecordSource);return{reportId:e.ReportID??``,shortId:e.ShortID??null,title:e.Title?.trim()||null,description:e.Description?.trim()||null,viewName:t?.viewName??null,initialFilter:t?.filterString??null,hasTitle:X(e.HasTitle),hasHeader:X(e.HasHeader),formats:Bt(e),timeout:e.Timeout??null}}function Z(){if(document.querySelector(`#AlertDialogTemplate`))return;let e=document.createElement(`template`);e.id=`AlertDialogTemplate`,e.innerHTML=`
3
3
  <dialog class="alert-dialog">
4
4
  <form method="dialog">
5
5
  <article></article>
@@ -8,5 +8,5 @@ function e(e){return{all:e||=new Map,on:function(t,n){var r=e.get(t);r?r.push(n)
8
8
  </footer>
9
9
  </form>
10
10
  </dialog>
11
- `,document.body.append(e)}window.document&&(document.body?zt():document.addEventListener(`DOMContentLoaded`,zt,{once:!0}));function Bt(e,t=`No`){return new Promise(n=>{let r=new AbortController;e.addEventListener(`close`,()=>{n(e.returnValue),r.abort()},{signal:r.signal}),e.addEventListener(`cancel`,()=>{n(t),r.abort()},{signal:r.signal})})}const Q=new Map;async function $({buttons:e,content:t,className:n,id:r,title:i}){if(r&&Q.has(r))return await Q.get(r);let a=document.querySelector(`#AlertDialogTemplate`);if(!a)throw Error(`No alert dialog template found`);let o=a.content.firstElementChild?.cloneNode(!0),s=o?.querySelector(`article`),c=o?.querySelector(`footer menu`);if(!o||!s||!c)throw Error(`Invalid alert dialog template`);if(n)for(let e of n.split(/\s+/))o?.classList.add(e);if(i){let e=document.createElement(`header`);e.append(i),s.parentNode?.insertBefore(e,s)}s.appendChild(typeof t==`string`?document.createTextNode(t):t);for(let{label:t,value:n,primary:r}of e){let e=document.createElement(`li`),i=document.createElement(`button`);i.value=n,r&&i.classList.add(`primary`),i.textContent=t,e.appendChild(i),c.appendChild(i)}document.body.appendChild(o),o.showModal();let l=Bt(o).then(e=>(r&&Q.has(r)&&Q.delete(r),o&&document.body.removeChild(o),e));return r&&Q.set(r,l),await l}let Vt=function(e){return e[e.YesNo=0]=`YesNo`,e[e.OkCancel=1]=`OkCancel`,e}({});async function Ht(e,t={}){let{buttons:n=0,title:r}=t;return await $({content:e,buttons:n===1?[{label:v(`OK`),value:`yes`,primary:!0},{label:v(`Cancel`),value:`no`}]:[{label:v(`Yes`),value:`yes`,primary:!0},{label:v(`No`),value:`no`}],className:`alert-dialog-confirm`,title:r})===`yes`}async function Ut(e,t={}){await $({content:e,className:`alert-dialog-alert`,buttons:[{label:v(`OK`),value:`ok`,primary:!0}],...t})}function Wt(e){return`${e??window.af?.article?.id??window.window?.location.pathname.substring(1).split(`/`)[0]}.${window.af?.userSession.login??`anonymous`}`}function Gt(e,t){if(!window.af?.userSession)return null;let n=Wt(t),r=JSON.parse(localStorage.getItem(n)||`{}`);return e?r[e]||null:r}function Kt(e,t,n){if(!window.af?.userSession)return;let r=Wt(n),i=JSON.parse(localStorage.getItem(r)||`{}`);t===void 0?i=e:i[e]=t,localStorage.setItem(r,JSON.stringify(i))}const qt=`2.12.0`;export{Vt as ConfirmButtons,Ze as NO_FILTER_ID,Te as RELATIVE_DATE_VALUES,t as SessionHandler,n as UserSession,Be as addGroupAtPath,Ut as alert,ot as canDeleteSavedFilter,it as canEditSavedFilter,R as canRenameSavedFilter,st as canSetCrossDomain,at as canShareSavedFilter,Fe as changeOperator,G as coerceParameterValue,Xe as coerceToStandardLayout,Ht as confirm,Ve as convertFilter,A as countExpressions,E as createEmptyFilter,D as createEmptyGroup,Ne as createExpression,z as decodeXml,He as describeFilter,ie as downloadBlob,Pt as downloadReport,ae as downloadRequest,B as encodeXml,fe as expose,Et as fetchParameterDefault,rt as findSavedFilter,we as getDefaultOperator,xt as getDefaultParameterValues,De as getDynamicValueLabel,Oe as getDynamicValuesForField,v as getLocalizedString,Ie as getNodeAtPath,y as getOperatorArity,ye as getOperatorLabel,Ce as getOperatorsForField,jt as getReportExtension,q as getReportFileName,Lt as getReportFormats,K as getReportMediaType,J as getReportRequest,p as getSessionData,Gt as getSettings,lt as getUserImage,w as getValueType,Le as insertNodeAtPath,g as invariant,j as isCompleteExpression,je as isEmptyFilter,k as isExpression,O as isGroup,U as isProcedureDefault,Ye as isStandardLayout,ee as localStorage,ut as localize,i as logActivity,s as logError,e as mitt,T as normalizeOperator,$ as openAlertDialog,X as openReport,W as parseParameterItems,wt as parseParameters,H as parseRecordSource,nt as partitionSavedFilters,Ft as printReport,Me as pruneFilter,V as readElement,ft as readElements,Re as removeNodeAtPath,Y as renderReport,Dt as resolveParameterDefaults,Tt as restoreParameterValues,Kt as saveSettings,Ct as serializeParameters,ze as setGroupMode,a as startActivity,o as time,F as toFieldMetadata,Je as toFieldMetadataList,N as toFilterFieldType,Ae as toFilterTree,re as toLocalDateTime,te as toLocalISODate,ne as toLocalISODateTime,Rt as toReport,yt as toReportParameter,bt as toReportParameters,Qe as toSavedFilter,tt as toSavedFilters,M as updateNodeAtPath,qt as version,Bt as waitForDialog};
11
+ `,document.body.append(e)}window.document&&(document.body?Z():document.addEventListener(`DOMContentLoaded`,Z,{once:!0}));function Ht(e,t=`No`){return new Promise(n=>{let r=new AbortController;e.addEventListener(`close`,()=>{n(e.returnValue),r.abort()},{signal:r.signal}),e.addEventListener(`cancel`,()=>{n(t),r.abort()},{signal:r.signal})})}const Q=new Map;async function $({buttons:e,content:t,className:n,id:r,title:i}){if(r&&Q.has(r))return await Q.get(r);let a=document.querySelector(`#AlertDialogTemplate`);if(!a)throw Error(`No alert dialog template found`);let o=a.content.firstElementChild?.cloneNode(!0),s=o?.querySelector(`article`),c=o?.querySelector(`footer menu`);if(!o||!s||!c)throw Error(`Invalid alert dialog template`);if(n)for(let e of n.split(/\s+/))o?.classList.add(e);if(i){let e=document.createElement(`header`);e.append(i),s.parentNode?.insertBefore(e,s)}s.appendChild(typeof t==`string`?document.createTextNode(t):t);for(let{label:t,value:n,primary:r}of e){let e=document.createElement(`li`),i=document.createElement(`button`);i.value=n,r&&i.classList.add(`primary`),i.textContent=t,e.appendChild(i),c.appendChild(i)}document.body.appendChild(o),o.showModal();let l=Ht(o).then(e=>(r&&Q.has(r)&&Q.delete(r),o&&document.body.removeChild(o),e));return r&&Q.set(r,l),await l}let Ut=function(e){return e[e.YesNo=0]=`YesNo`,e[e.OkCancel=1]=`OkCancel`,e}({});async function Wt(e,t={}){let{buttons:n=0,title:r}=t;return await $({content:e,buttons:n===1?[{label:b(`OK`),value:`yes`,primary:!0},{label:b(`Cancel`),value:`no`}]:[{label:b(`Yes`),value:`yes`,primary:!0},{label:b(`No`),value:`no`}],className:`alert-dialog-confirm`,title:r})===`yes`}async function Gt(e,t={}){await $({content:e,className:`alert-dialog-alert`,buttons:[{label:b(`OK`),value:`ok`,primary:!0}],...t})}function Kt(e){return`${e??window.af?.article?.id??window.window?.location.pathname.substring(1).split(`/`)[0]}.${window.af?.userSession.login??`anonymous`}`}function qt(e,t){if(!window.af?.userSession)return null;let n=Kt(t),r=JSON.parse(localStorage.getItem(n)||`{}`);return e?r[e]||null:r}function Jt(e,t,n){if(!window.af?.userSession)return;let r=Kt(n),i=JSON.parse(localStorage.getItem(r)||`{}`);t===void 0?i=e:i[e]=t,localStorage.setItem(r,JSON.stringify(i))}const Yt=`2.14.0`;export{Ut as ConfirmButtons,$e as NO_FILTER_ID,Te as RELATIVE_DATE_VALUES,t as SessionHandler,n as UserSession,ze as addGroupAtPath,Gt as alert,ct as canDeleteSavedFilter,ot as canEditSavedFilter,R as canRenameSavedFilter,lt as canSetCrossDomain,st as canShareSavedFilter,Pe as changeOperator,W as coerceParameterValue,Qe as coerceToStandardLayout,Wt as confirm,Be as convertFilter,N as countExpressions,k as createEmptyFilter,A as createEmptyGroup,Me as createExpression,pe as createLocalizer,z as decodeXml,Ve as describeFilter,ie as downloadBlob,Lt as downloadReport,ae as downloadRequest,B as encodeXml,ue as expose,kt as fetchParameterDefault,at as findSavedFilter,we as getDefaultOperator,wt as getDefaultParameterValues,D as getDynamicValueLabel,De as getDynamicValuesForField,b as getLocalizedString,Fe as getNodeAtPath,x as getOperatorArity,ye as getOperatorLabel,Ce as getOperatorsForField,Pt as getReportExtension,K as getReportFileName,Bt as getReportFormats,G as getReportMediaType,q as getReportRequest,p as getSessionData,qt as getSettings,dt as getUserImage,E as getValueType,Ie as insertNodeAtPath,g as invariant,P as isCompleteExpression,Ae as isEmptyFilter,M as isExpression,j as isGroup,U as isProcedureDefault,Ze as isStandardLayout,ee as localStorage,ft as localize,i as logActivity,s as logError,e as mitt,O as normalizeOperator,$ as openAlertDialog,Y as openReport,yt as parseParameterItems,Dt as parseParameters,H as parseRecordSource,it as partitionSavedFilters,Rt as printReport,je as pruneFilter,V as readElement,mt as readElements,Le as removeNodeAtPath,J as renderReport,At as resolveParameterDefaults,Ot as restoreParameterValues,Jt as saveSettings,Et as serializeParameters,Re as setGroupMode,a as startActivity,o as time,Ye as toFieldMetadata,Xe as toFieldMetadataList,qe as toFilterFieldType,ke as toFilterTree,re as toLocalDateTime,te as toLocalISODate,ne as toLocalISODateTime,Vt as toReport,St as toReportParameter,Ct as toReportParameters,et as toSavedFilter,rt as toSavedFilters,F as updateNodeAtPath,Yt as version,Ht as waitForDialog};
12
12
  //# sourceMappingURL=af.common.legacy.min.js.map