zavadil-ts-common 1.2.78 → 2.0.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.
Files changed (29) hide show
  1. package/dist/index.d.ts +27 -23
  2. package/dist/index.esm.js +1 -1
  3. package/dist/index.esm.js.map +1 -1
  4. package/dist/index.js +1 -1
  5. package/dist/index.js.map +1 -1
  6. package/dist/oauth/OAuthRestClient.d.ts +9 -6
  7. package/dist/oauth/OAuthTokenManager.d.ts +11 -11
  8. package/dist/oauth/RestClientWithOAuth.d.ts +4 -4
  9. package/dist/oauth/tokenprovider/OAuthRefreshTokenProvider.d.ts +5 -0
  10. package/dist/oauth/tokenprovider/RefreshTokenProviderDefault.d.ts +14 -0
  11. package/dist/oauth/tokenprovider/RefreshTokenProviderLogin.d.ts +12 -0
  12. package/dist/oauth/tokenprovider/RefreshTokenProviderStorage.d.ts +10 -0
  13. package/dist/oauth/tokenprovider/RefreshTokenProviderUrl.d.ts +12 -0
  14. package/dist/util/NumberUtil.d.ts +2 -2
  15. package/dist/util/ObjectUtil.d.ts +1 -1
  16. package/package.json +1 -1
  17. package/src/oauth/OAuthRestClient.ts +20 -9
  18. package/src/oauth/OAuthTokenManager.ts +29 -29
  19. package/src/oauth/RestClientWithOAuth.ts +11 -11
  20. package/src/oauth/tokenprovider/OAuthRefreshTokenProvider.ts +6 -0
  21. package/src/oauth/tokenprovider/RefreshTokenProviderDefault.ts +52 -0
  22. package/src/oauth/tokenprovider/{IdTokenProviderLogin.ts → RefreshTokenProviderLogin.ts} +3 -3
  23. package/src/oauth/tokenprovider/{IdTokenProviderStorage.ts → RefreshTokenProviderStorage.ts} +9 -9
  24. package/src/oauth/tokenprovider/{IdTokenProviderUrl.ts → RefreshTokenProviderUrl.ts} +7 -7
  25. package/src/util/NumberUtil.ts +5 -1
  26. package/src/util/OAuthUtil.ts +2 -1
  27. package/src/util/ObjectUtil.ts +1 -1
  28. package/src/oauth/tokenprovider/IdTokenProviderDefault.ts +0 -52
  29. package/src/oauth/tokenprovider/OAuthIdTokenProvider.ts +0 -6
package/dist/index.d.ts CHANGED
@@ -218,13 +218,13 @@ type TokenRequestPayloadBase = {
218
218
  targetAudience: string;
219
219
  };
220
220
  type RequestAccessTokenPayload = TokenRequestPayloadBase & {
221
- idToken: string;
221
+ refreshToken: string;
222
222
  privilege: string;
223
223
  };
224
- type RequestIdTokenFromPrevTokenPayload = {
225
- idToken: string;
224
+ type RenewRefreshTokenPayload = {
225
+ refreshToken: string;
226
226
  };
227
- type RequestIdTokenFromLoginPayload = TokenRequestPayloadBase & {
227
+ type RequestRefreshTokenFromLoginPayload = TokenRequestPayloadBase & {
228
228
  login: string;
229
229
  password: string;
230
230
  };
@@ -235,6 +235,7 @@ type TokenResponsePayloadBase = {
235
235
  };
236
236
  type IdTokenPayload = TokenResponsePayloadBase & {};
237
237
  type AccessTokenPayload = TokenResponsePayloadBase & {};
238
+ type RefreshTokenPayload = TokenResponsePayloadBase & {};
238
239
  type JwKeyPayload = {
239
240
  kty: string;
240
241
  kid: string;
@@ -251,40 +252,42 @@ type JwksPayload = {
251
252
  declare class OAuthRestClient extends RestClient {
252
253
  constructor(oauthUrl: string);
253
254
  jwks(): Promise<JwksPayload>;
255
+ verifyRefreshToken(refreshToken: string): Promise<RefreshTokenPayload>;
256
+ verifyAccessToken(accessToken: string): Promise<AccessTokenPayload>;
254
257
  verifyIdToken(idToken: string): Promise<IdTokenPayload>;
255
- requestIdTokenFromLogin(request: RequestIdTokenFromLoginPayload): Promise<IdTokenPayload>;
256
- refreshIdToken(request: RequestIdTokenFromPrevTokenPayload): Promise<IdTokenPayload>;
258
+ requestRefreshTokenFromLogin(request: RequestRefreshTokenFromLoginPayload): Promise<RefreshTokenPayload>;
259
+ renewRefreshToken(request: RenewRefreshTokenPayload): Promise<RefreshTokenPayload>;
257
260
  requestAccessToken(request: RequestAccessTokenPayload): Promise<AccessTokenPayload>;
258
261
  }
259
262
 
260
- interface OAuthIdTokenProvider {
261
- getIdToken(): Promise<IdTokenPayload>;
263
+ interface OAuthRefreshTokenProvider {
264
+ getRefreshToken(): Promise<RefreshTokenPayload>;
262
265
  reset(): Promise<any>;
263
266
  }
264
267
 
265
268
  /**
266
269
  * Manages refresh of id and access tokens.
267
270
  */
268
- declare class OAuthTokenManager implements OAuthIdTokenProvider {
271
+ declare class OAuthTokenManager implements OAuthRefreshTokenProvider {
269
272
  oAuthServer: OAuthRestClient;
270
273
  audience: string;
271
- idToken?: IdTokenPayload;
272
- freshIdTokenProvider: OAuthIdTokenProvider;
274
+ refreshToken?: RefreshTokenPayload;
275
+ initialRefreshTokenProvider: OAuthRefreshTokenProvider;
273
276
  accessTokens: Map<string, AccessTokenPayload>;
274
- constructor(oAuthServerBaseUrl: string, targetAudience: string, freshIdTokenProvider: OAuthIdTokenProvider);
275
- hasValidIdToken(): boolean;
277
+ constructor(oAuthServerBaseUrl: string, targetAudience: string, initialRefreshTokenProvider: OAuthRefreshTokenProvider);
278
+ hasValidRefreshToken(): boolean;
276
279
  hasValidAccessToken(privilege: string): boolean;
277
280
  reset(): Promise<any>;
278
281
  /**
279
282
  * Get stored id token or ask the provider, this will trigger redirect to login screen in case of the default provider
280
283
  */
281
- getIdTokenInternal(): Promise<IdTokenPayload>;
284
+ getRefreshTokenInternal(): Promise<RefreshTokenPayload>;
282
285
  /**
283
286
  * Get id token, refresh it if needed
284
287
  */
285
- getIdToken(): Promise<IdTokenPayload>;
286
- getIdTokenRaw(): Promise<string>;
287
- setIdToken(token?: IdTokenPayload): void;
288
+ getRefreshToken(): Promise<IdTokenPayload>;
289
+ getRefreshTokenRaw(): Promise<string>;
290
+ setRefreshToken(token?: IdTokenPayload): void;
288
291
  verifyIdToken(token: string): Promise<IdTokenPayload>;
289
292
  login(login: string, password: string): Promise<any>;
290
293
  private getAccessTokenInternal;
@@ -305,14 +308,14 @@ type ServerOAuthInfoPayload = {
305
308
  oauthServerUrl: string;
306
309
  version: string;
307
310
  };
308
- declare class RestClientWithOAuth extends RestClient implements OAuthIdTokenProvider {
311
+ declare class RestClientWithOAuth extends RestClient implements OAuthRefreshTokenProvider {
309
312
  private insecureClient;
310
313
  private freshIdTokenProvider;
311
314
  private tokenManager;
312
315
  private serverInfo;
313
316
  private defaultPrivilege;
314
- constructor(url: string, freshIdTokenProvider?: OAuthIdTokenProvider, defaultPrivilege?: string);
315
- getIdToken(): Promise<IdTokenPayload>;
317
+ constructor(url: string, freshIdTokenProvider?: OAuthRefreshTokenProvider, defaultPrivilege?: string);
318
+ getRefreshToken(): Promise<IdTokenPayload>;
316
319
  /**
317
320
  * Attempt to get ID token from token manager
318
321
  */
@@ -335,7 +338,7 @@ declare class RestClientWithOAuth extends RestClient implements OAuthIdTokenProv
335
338
 
336
339
  declare class ObjectUtil {
337
340
  static isEmpty(obj: any): obj is null | undefined;
338
- static notEmpty(obj: any): boolean;
341
+ static notEmpty(obj: any): obj is object;
339
342
  static clone<T>(obj: T): T;
340
343
  static getNestedValue(obj: any, path: string): string;
341
344
  }
@@ -402,7 +405,8 @@ declare class DateUtil {
402
405
  static formatDuration(ms?: number | null): string;
403
406
  }
404
407
 
405
- declare class NumberUtil extends ObjectUtil {
408
+ declare class NumberUtil {
409
+ static isEmpty(n: any): n is null | undefined;
406
410
  static notEmpty(n?: number | null): n is number;
407
411
  static parseNumber(str: string | null | undefined): number | null;
408
412
  static round(n: number, d?: number): number;
@@ -501,4 +505,4 @@ declare class BasicLocalization extends Localization {
501
505
  constructor(language?: string);
502
506
  }
503
507
 
504
- export { type AccessTokenPayload, ArrayUtil, AsyncUtil, BasicLocalization, ByteUtil, CacheAsync, type CacheStats, CancellablePromise, CzechBasicDictionary, DateUtil, type Dictionary, type DictionaryMemoryData, type DictionaryMemoryValue, DictionaryWithFallback, EnglishBasicDictionary, type EntityBase, EntityCachedClient, EntityClient, EntityClientWithStub, type EntityWithName, EventManager, type Func, type FuncHandlers, type FuncHandlersCache, HashCacheAsync, type HashCacheStats, HashUtil, type IdTokenPayload, type JavaHeapStats, JsonUtil, type JwKeyPayload, type JwksPayload, Lazy, LazyAsync, Localization, LookupClient, type LookupTableEntity, MemoryDictionary, NumberUtil, OAuthRestClient, OAuthSubject, OAuthTokenManager, ObjectUtil, type Page, type PagingRequest, PagingUtil, type QueueStats, type RequestAccessTokenPayload, type RequestIdTokenFromLoginPayload, type RequestIdTokenFromPrevTokenPayload, type RequestOptions, RestClient, RestClientWithOAuth, type ServerOAuthInfoPayload, type SortingField, type SortingRequest, StringUtil, type TokenRequestPayloadBase, type TokenResponsePayloadBase, type TranslateParams, UrlUtil, type UserAlert, UserAlertType, UserAlerts, Vector2 };
508
+ export { type AccessTokenPayload, ArrayUtil, AsyncUtil, BasicLocalization, ByteUtil, CacheAsync, type CacheStats, CancellablePromise, CzechBasicDictionary, DateUtil, type Dictionary, type DictionaryMemoryData, type DictionaryMemoryValue, DictionaryWithFallback, EnglishBasicDictionary, type EntityBase, EntityCachedClient, EntityClient, EntityClientWithStub, type EntityWithName, EventManager, type Func, type FuncHandlers, type FuncHandlersCache, HashCacheAsync, type HashCacheStats, HashUtil, type IdTokenPayload, type JavaHeapStats, JsonUtil, type JwKeyPayload, type JwksPayload, Lazy, LazyAsync, Localization, LookupClient, type LookupTableEntity, MemoryDictionary, NumberUtil, OAuthRestClient, OAuthSubject, OAuthTokenManager, ObjectUtil, type Page, type PagingRequest, PagingUtil, type QueueStats, type RefreshTokenPayload, type RenewRefreshTokenPayload, type RequestAccessTokenPayload, type RequestOptions, type RequestRefreshTokenFromLoginPayload, RestClient, RestClientWithOAuth, type ServerOAuthInfoPayload, type SortingField, type SortingRequest, StringUtil, type TokenRequestPayloadBase, type TokenResponsePayloadBase, type TranslateParams, UrlUtil, type UserAlert, UserAlertType, UserAlerts, Vector2 };
package/dist/index.esm.js CHANGED
@@ -1,2 +1,2 @@
1
- var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};function e(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return n=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},n.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;var r,o=function(){function t(t){this.supplier=t}return t.prototype.get=function(){var t=this;return void 0!==this.cache?Promise.resolve(this.cache):(void 0===this.promise&&(this.promise=this.supplier().then((function(e){return t.cache=e,t.promise=void 0,Promise.resolve(e)})).catch((function(e){return t.promise=void 0,Promise.reject(e)}))),this.promise)},t.prototype.reset=function(){this.cache=void 0},t.prototype.hasCache=function(){return void 0!==this.cache},t.prototype.getCache=function(){return this.cache},t}(),i=function(t){function n(e,n){var r=t.call(this,e)||this;return r.maxAgeMs=n,r}return e(n,t),n.prototype.get=function(){return this.expires&&this.expires>new Date&&this.reset(),t.prototype.get.call(this)},n.prototype.set=function(t,e){this.cache=t,this.expires=e,this.maxAgeMs&&void 0===this.expires&&(this.expires=new Date((new Date).getTime()+this.maxAgeMs))},n}(o),s=function(){function t(t,e){this.cache=new Map,this.maxSize=100,this.supplier=t,e&&(this.maxSize=e)}return t.prototype.obtainCache=function(t){var e=this,n=this.cache.get(t);return n||(n=new i((function(){return e.supplier(t)})),this.cache.set(t,n)),n},t.prototype.get=function(t){return this.obtainCache(t).get()},t.prototype.set=function(t,e,n){this.obtainCache(t).set(e,n)},t.prototype.reset=function(t){t?this.cache.delete(t):this.cache.clear()},t.prototype.getSize=function(){return this.cache.size},t.prototype.getMaxSize=function(){return this.maxSize},t.prototype.getStats=function(){return{cachedItems:this.getSize(),capacity:this.getMaxSize()}},t.prototype.hasCache=function(t){return this.cache.has(t)},t}(),u=function(){function t(t){this.supplier=t}return t.prototype.get=function(){return void 0===this.cache&&(this.cache=this.supplier()),this.cache},t.prototype.reset=function(){this.cache=void 0},t.prototype.hasCache=function(){return void 0!==this.cache},t}(),a=function(){function t(){}return t.isEmpty=function(t){return null==t},t.notEmpty=function(e){return!t.isEmpty(e)},t.clone=function(t){if(null===t)throw new Error("Null cannot be cloned!");if("object"!=typeof t)throw new Error("Not an object, cannot be cloned!");return n({},t)},t.getNestedValue=function(t,e){if(!t||""===t)return"";for(var n=t,r=0,o=e.split(".");r<o.length;r++){var i=o[r];if(!n||"object"!=typeof n||!(i in n))return"";n=n[i]}return n},t}(),c=function(){function t(){}return t.isString=function(t){return"string"==typeof t},t.toString=function(e){var n,r;return t.isString(e)?e:null!==(r=null===(n=null==e?void 0:e.toString)||void 0===n?void 0:n.call(e))&&void 0!==r?r:""},t.isEmpty=function(t){return!!a.isEmpty(t)||0===t.length},t.notEmpty=function(e){return!t.isEmpty(e)},t.isBlank=function(e){return t.isEmpty(t.safeTrim(e))},t.notBlank=function(e){return!t.isBlank(e)},t.substr=function(t,e,n){return this.isEmpty(t)?"":t.substring(e,n)},t.replace=function(t,e,n){return this.isEmpty(t)||this.isEmpty(e)?"":t.replace(e,String(n))},t.containsLineBreaks=function(e){return!t.isBlank(e)&&e.includes("\n")},t.trimLeadingSlashes=function(e){return this.isEmpty(e)?"":t.toString(e).replace(/^\//g,"")},t.trimTrailingSlashes=function(e){return this.isEmpty(e)?"":t.toString(e).replace(/\/$/g,"")},t.trimSlashes=function(e){return this.isEmpty(e)?"":t.toString(e).replace(/^\/|\/$/g,"")},t.safeTruncate=function(e,n,r){return void 0===r&&(r=""),t.isEmpty(e)||!e?"":(e=t.toString(e)).length<=n?String(e):e.substring(0,n-r.length)+r},t.ellipsis=function(e,n,r){return void 0===r&&(r="..."),t.safeTruncate(e,n,r)},t.safeTrim=function(e){return t.isEmpty(e)?"":t.toString(e).trim()},t.safeLowercase=function(e){return t.isEmpty(e)||!e?"":t.toString(e).toLowerCase()},t.safeUppercase=function(e){return t.isEmpty(e)||!e?"":t.toString(e).toUpperCase()},t.capitalizeFirstLetter=function(e){return t.isBlank(e)?"":t.safeUppercase(e.charAt(0))+t.safeLowercase(t.substr(e,1))},t.toBigInt=function(t){return this.isEmpty(t)?null:BigInt(t)},t.getNonEmpty=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return e.find((function(e){return t.notEmpty(e)}))||""},t.getNonBlank=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return e.find((function(e){return t.notBlank(e)}))||""},t.emptyToNull=function(e){return t.isEmpty(e)?null:String(e)},t.blankToNull=function(e){return t.isBlank(e)?null:String(e)},t}(),h=function(){function t(){}return t.isEmpty=function(t){return a.isEmpty(t)||0===t.length},t.notEmpty=function(e){return!t.isEmpty(e)},t.remove=function(e,n){return t.isEmpty(e)?[]:null==e?void 0:e.filter((function(t){return t!==n}))},t}(),p=function(){function t(){}return t.sleep=function(t){return new Promise((function(e){return setTimeout(e,t)}))},t}(),f=function(){function t(){}return t.formatByteSize=function(t){var e=Number(t);if(null===e||Number.isNaN(e))return"";if(0===e)return"0";var n=Math.floor(Math.log(e)/Math.log(1024));return 1*+(e/Math.pow(1024,n)).toFixed(2)+" "+["B","kB","MB","GB","TB"][n]},t}(),l={page:0,size:10},g=function(){function t(){}return t.sortingFieldToString=function(t){if(!t)return"";var e=[];return e.push(t.name),e.push(t.desc?"desc":""),e.push(t.nullsLast?"nl":""),e.join("-")},t.sortingFieldFromString=function(t){var e=t.split("-");return{name:e[0],desc:e.length>1&&"desc"===c.safeLowercase(e[1]),nullsLast:e.length>2&&"nl"===c.safeLowercase(e[2])}},t.sortingRequestToString=function(e){return e.map((function(e){return t.sortingFieldToString(e)})).join("+")},t.sortingRequestFromString=function(e){return e?e.split("+").map((function(e){return t.sortingFieldFromString(e)})):[]},t.pagingRequestToQueryParams=function(e){if(e){var n={page:e.page,size:e.size};return e.search&&(n.search=e.search),e.sorting&&(n.sorting=t.sortingRequestToString(e.sorting)),n}},t.pagingRequestToString=function(e){if(!e)return"";var n=[];return n.push(String(e.page)),n.push(String(e.size)),n.push(c.safeTrim(e.search)),n.push(e.sorting?t.sortingRequestToString(e.sorting):""),n.join(":")},t.pagingRequestFromString=function(e){if(!e||c.isEmpty(e))return n({},l);var r=e.split(":");return r.length<4?n({},l):{page:Number(r[0]),size:Number(r[1]),search:String(r[2]),sorting:c.isEmpty(r[3])?void 0:t.sortingRequestFromString(r[3])}},t}(),d=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return e(n,t),n.notEmpty=function(t){return!a.isEmpty(t)},n.parseNumber=function(t){if(!t)return null;var e=Number(t);return Number.isNaN(e)?null:e},n.round=function(t,e){e||(e=0);var n=Math.pow(10,e);return Math.round(t*n)/n},n.portionToPercent=function(t,e){if(null==t)return"";var r=n.round(100*t,e);return"".concat(r,"%")},n}(a),y=function(){function t(){}return t.formatNumber=function(t,e){return void 0===e&&(e=2),String(t).padStart(e,"0")},t.parseDate=function(t){if(t)return"string"==typeof t?new Date(t):t},t.formatDateForHumans=function(e,n){if(void 0===n&&(n=!1),!(e=t.parseDate(e)))return"";var r=e.getFullYear(),o=t.formatNumber(e.getMonth()+1),i=t.formatNumber(e.getDate());if(!n)return"".concat(r,"-").concat(o,"-").concat(i);var s=t.formatNumber(e.getHours()),u=t.formatNumber(e.getMinutes()),a=t.formatNumber(e.getSeconds());return"".concat(r,"/").concat(o,"/").concat(i," ").concat(s,":").concat(u,":").concat(a)},t.formatDateTimeForHumans=function(e){return t.formatDateForHumans(e,!0)},t.formatDateForInput=function(e,n){if(void 0===n&&(n=!1),!(e=t.parseDate(e)))return"";var r=e.getFullYear(),o=t.formatNumber(e.getMonth()+1),i=t.formatNumber(e.getDate());if(!n)return"".concat(r,"-").concat(o,"-").concat(i);var s=t.formatNumber(e.getHours()),u=t.formatNumber(e.getMinutes()),a=t.formatNumber(e.getSeconds());return"".concat(r,"-").concat(o,"-").concat(i,"T").concat(s,":").concat(u,":").concat(a)},t.formatDateTimeForInput=function(e){return t.formatDateForInput(e,!0)},t.getDurationMs=function(e,n){if(e=t.parseDate(e),n=t.parseDate(n),a.isEmpty(e)||a.isEmpty(n))return null;try{return n.getTime()-e.getTime()}catch(t){return null}},t.getSinceDurationMs=function(e){return t.getDurationMs(e,new Date)},t.formatDuration=function(t){if(!t)return"";var e=Math.floor(t/1e3);t-=1e3*e;var n=Math.floor(e/60);e-=60*n;var r=Math.floor(n/60);n-=60*r;var o=Math.floor(r/24);r-=24*o;var i=[];return o>0&&i.push("".concat(o,"d")),r>0&&i.push("".concat(r,"h")),n>0&&i.push("".concat(n,"m")),e>0&&0===o&&0===r&&i.push("".concat(e,"s")),t>0&&0===o&&0===r&&0===n&&i.push("".concat(d.round(t,2),"ms")),i.join(" ")},t}(),v=function(){function t(){}return t.dateParser=function(e,n){return"string"==typeof n&&t.reISO.exec(n)?new Date(n):n},t.parseWithDates=function(e){if(!c.isBlank(e))return JSON.parse(c.getNonEmpty(e),t.dateParser)},t.parse=function(e){return t.parseWithDates(e)},t.reISO=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*))(?:Z|(\+|-)([\d|:]*))?$/,t}(),m=function(){function t(){}return t.crc32hex=function(t){for(var e=(new TextEncoder).encode(t),n=new Uint32Array(256),r=0;r<256;r++){for(var o=r,i=0;i<8;i++)o=1&o?3988292384^o>>>1:o>>>1;n[r]=o>>>0}var s=~0;for(r=0;r<e.length;r++)s=s>>>8^n[255&(s^e[r])];return(s=~s>>>0).toString(16)},t}(),T=function(){function t(){}return t.deleteParamFromUrl=function(t,e){var n=new URL(t);return n.searchParams.delete(e),c.trimTrailingSlashes(n.toString())},t.extractParamFromUrl=function(t,e){return new URLSearchParams(new URL(t).search).get(e)},t.paramExistsInUrl=function(e,n){return c.notBlank(t.extractParamFromUrl(e,n))},t.extractHostFromUrl=function(t){return c.isBlank(t)?null:new URL(t).host},t.extractDomainFromUrl=function(e){var n=t.extractHostFromUrl(e);return c.isBlank(n)?null:n.split(".").slice(-2).join(".")},t}(),k=function(){function t(e){c.isBlank(e)?this.baseUrl=t.baseHostUrl():(e.endsWith("/")||(e+="/"),this.baseUrl=e.startsWith("http")?new URL(e):new URL(e,t.baseHostUrl()))}return t.baseHostUrl=function(){return new URL("".concat(window.location.protocol,"//").concat(window.location.host,"/"))},t.pagingRequestToQueryParams=function(t){return g.pagingRequestToQueryParams(t)},t.paramsToQueryString=function(t){if(!t)return"";var e=new URLSearchParams(t),n=new URLSearchParams;e.forEach((function(t,e){""!==t&&void 0!==t&&"undefined"!==t&&n.set(e,t)}));var r=n.toString();return c.isEmpty(r)?"":"?".concat(r)},t.prototype.getHeaders=function(t){var e=new Headers;return e.set("Content-Type","application/json"),Promise.resolve(e)},t.prototype.getBaseUrl=function(){return this.baseUrl},t.prototype.getUrl=function(t,e){var n=new URL(c.trimLeadingSlashes(t),this.baseUrl);return e&&Object.keys(e).forEach((function(t){var r=e[t];""!==r&&void 0!==r&&"undefined"!==r&&n.searchParams.set(t,r)})),n},t.prototype.getRequestOptions=function(t,e,n){return void 0===e&&(e="GET"),void 0===n&&(n=null),this.getHeaders(t).then((function(t){return{method:e,headers:t,body:null===n?null:n instanceof FormData?n:JSON.stringify(n)}}))},t.prototype.processRequest=function(t,e,n){return fetch(this.getUrl(t,e),n).then((function(t){if(!t.ok){var e={cause:t.status};return"application/json"===t.headers.get("Content-Type")?t.json().then((function(n){if(n.message)throw new Error(n.message,e);if(n.error)throw new Error(n.error,e);throw new Error(t.statusText,e)}),(function(){throw new Error(t.statusText,e)})):t.text().then((function(n){throw c.isEmpty(n)?new Error(t.statusText,e):new Error(n,e)}),(function(){throw new Error(t.statusText,e)}))}return t}))},t.prototype.processRequestJson=function(t,e,n){return this.processRequest(t,e,n).then((function(t){return t.text().then(v.parseWithDates)}))},t.prototype.getJson=function(t,e){var n=this;return this.getRequestOptions(t).then((function(r){return n.processRequestJson(t,e,r)}))},t.prototype.postJson=function(t,e,n){var r=this;return void 0===e&&(e=null),this.getRequestOptions(t,"POST",e).then((function(e){return r.processRequestJson(t,n,e)}))},t.prototype.postForm=function(t,e,n){var r=this;return this.getRequestOptions(t,"POST",e).then((function(e){return e.headers.delete("Content-Type"),r.processRequest(t,n,e)}))},t.prototype.postFormJson=function(t,e,n){var r=this;return this.getRequestOptions(t,"POST",e).then((function(e){return e.headers.delete("Content-Type"),r.processRequestJson(t,n,e)}))},t.prototype.putJson=function(t,e,n){var r=this;return void 0===e&&(e=null),this.getRequestOptions(t,"PUT",e).then((function(e){return r.processRequestJson(t,n,e)}))},t.prototype.get=function(t,e){var n=this;return this.getRequestOptions(t).then((function(r){return n.processRequest(t,e,r)}))},t.prototype.del=function(t,e){var n=this;return this.getRequestOptions(t,"DELETE").then((function(r){return n.processRequest(t,e,r)}))},t.prototype.post=function(t,e,n){var r=this;return void 0===e&&(e=null),this.getRequestOptions(t,"POST",e).then((function(e){return r.processRequest(t,n,e)}))},t.prototype.put=function(t,e,n){var r=this;return void 0===e&&(e=null),this.getRequestOptions(t,"PUT",e).then((function(e){return r.processRequest(t,n,e)}))},t}(),S=function(){function t(t,e){this.client=t,this.name=e}return t.prototype.loadSingle=function(t){return this.client.getJson("".concat(this.name,"/").concat(t))},t.prototype.loadPage=function(t){return this.client.getJson(this.name,k.pagingRequestToQueryParams(t))},t.prototype.save=function(t){return t.id?this.client.putJson("".concat(this.name,"/").concat(t.id),t):this.client.postJson(this.name,t)},t.prototype.delete=function(t){return this.client.del("".concat(this.name,"/").concat(t))},t}(),w=function(t){function n(e,n,r){var o=t.call(this,e,n)||this;return o.cache=new s((function(e){return t.prototype.loadSingle.call(o,e)}),r),o}return e(n,t),n.prototype.loadSingle=function(t){return this.cache.get(t)},n.prototype.save=function(e){var n=this;return t.prototype.save.call(this,e).then((function(t){return t.id&&n.cache.set(t.id,t),t}))},n.prototype.delete=function(e){var n=this;return t.prototype.delete.call(this,e).then((function(){return n.cache.reset(e)}))},n.prototype.reset=function(t){this.cache.reset(t)},n.prototype.getStats=function(){return this.cache.getStats()},n}(S),I=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return e(n,t),n.prototype.loadSingle=function(t){throw new Error("Use loadSingleStub() instead!")},n.prototype.loadSingleStub=function(t){return this.client.getJson("".concat(this.name,"/").concat(t))},n.prototype.save=function(t){throw new Error("Use saveStub() instead!")},n.prototype.saveStub=function(t){return t.id?this.client.putJson("".concat(this.name,"/").concat(t.id),t):this.client.postJson(this.name,t)},n}(S),b=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.cache=new o((function(){return r.loadAllInternal()})),r}return e(n,t),n.prototype.loadAllInternal=function(){return this.client.getJson("".concat(this.name,"/all"))},n.prototype.loadAll=function(){return this.cache.get()},n.prototype.loadSingle=function(t){var e=this;return this.loadAll().then((function(n){var r=n.find((function(e){return e.id===t}));if(void 0===t)throw new Error("".concat(e.name," id ").concat(t," not found!"));return r}))},n.prototype.save=function(e){var n=this;return t.prototype.save.call(this,e).then((function(t){return n.cache.reset(),t}))},n.prototype.delete=function(e){var n=this;return t.prototype.delete.call(this,e).then((function(){return n.cache.reset()}))},n.prototype.reset=function(){this.cache.reset()},n.prototype.getStats=function(){var t,e=null===(t=this.cache.getCache())||void 0===t?void 0:t.length;return{cachedItems:e||0,capacity:e||0}},n}(S),E=function(){function t(){this.handlers=new Map}return t.prototype.addEventListener=function(t,e){this.handlers.has(t)||this.handlers.set(t,[]),this.handlers.get(t).push(e)},t.prototype.removeEventListener=function(t,e){var n=this.handlers.get(t);n&&n.splice(n.indexOf(e),1)},t.prototype.triggerEvent=function(t,e){this.handlers.has(t)&&this.handlers.get(t).forEach((function(t){return t(e)}))},t}();!function(t){t.info="info",t.warning="warning",t.error="danger"}(r||(r={}));var x=function(){function t(t,e){void 0===t&&(t=20),void 0===e&&(e=7e3),this.maxAlerts=t,this.maxVisibilityMs=e,this.em=new E,this.alerts=[],this.visibleAlerts=[]}return t.prototype.addOnChangeHandler=function(t){this.em.addEventListener("change",t)},t.prototype.removeOnChangeHandler=function(t){this.em.removeEventListener("change",t)},t.prototype.triggerChange=function(){this.em.triggerEvent("change")},t.prototype.reset=function(){this.alerts=[],this.visibleAlerts=[],this.triggerChange()},t.prototype.hide=function(t){this.visibleAlerts.splice(this.visibleAlerts.indexOf(t),1),this.triggerChange()},t.prototype.hideAll=function(){this.visibleAlerts=[],this.triggerChange()},t.prototype.updateVisibility=function(){var t=this;this.visibleAlerts.forEach((function(e){var n=y.getSinceDurationMs(e.time)||t.maxVisibilityMs,r=t.maxVisibilityMs-n;r>0?e.remainsMs=r:(e.remainsMs=void 0,t.hide(e))})),this.triggerChange()},t.prototype.remove=function(t){this.alerts.splice(this.alerts.indexOf(t),1),this.triggerChange()},t.prototype.add=function(t){for(void 0===t.remainsMs&&(t.remainsMs=this.maxVisibilityMs),this.alerts.push(t),this.visibleAlerts.push(t);this.alerts.length>this.maxAlerts;)this.alerts.shift();this.triggerChange()},t.prototype.custom=function(t,e){this.add({time:new Date,type:t,message:e})},t.prototype.err=function(t){this.custom(r.error,"string"==typeof t?t:t.toString())},t.prototype.warn=function(t){this.custom(r.warning,t)},t.prototype.info=function(t){this.custom(r.info,t)},t.prototype.getSummary=function(){var t=new Map;Object.values(r).forEach((function(e,n){t.set(e,0)}));for(var e=0;e<this.alerts.length;e++){var n=this.alerts[e],o=t.get(n.type)||0;t.set(n.type,o+1)}return t},t}(),P=function(){function t(t,e){void 0===e&&(e=!1);var n=this;this.isCancelled={value:!1},this.throwWhenCancelled=e,this.promise=new Promise((function(e,r){t.then((function(t){if(!n.isCancelled.value)return e(t)})).catch((function(t){!n.throwWhenCancelled&&n.isCancelled.value||r(t)}))}))}return t.prototype.cancel=function(){this.isCancelled.value=!0},t}(),R=function(t){function n(e){return t.call(this,"".concat(c.trimSlashes(e),"/api/oauth"))||this}return e(n,t),n.prototype.jwks=function(){return this.getJson("jwks.json")},n.prototype.verifyIdToken=function(t){return this.getJson("id-tokens/verify/".concat(t))},n.prototype.requestIdTokenFromLogin=function(t){return this.postJson("id-tokens/from-login",t)},n.prototype.refreshIdToken=function(t){return this.postJson("id-tokens/refresh",t)},n.prototype.requestAccessToken=function(t){return this.postJson("access-tokens/from-id-token",t)},n}(k),M=function(){function t(){}return t.isValidToken=function(e){return null!=e&&c.notBlank(e.token)&&!t.isTokenExpired(e)},t.isTokenExpired=function(t){return null!=t&&(void 0!==t.expires&&null!==t.expires&&t.expires<new Date)},t.isTokenReadyForRefresh=function(e){return null!=e&&(!t.isTokenExpired(e)&&(void 0!==e.expires&&null!==e.expires&&new Date((e.expires.getTime()+e.issuedAt.getTime())/2)<new Date))},t}(),A=function(){function t(t,e,n){this.freshIdTokenProvider=n,this.audience=e,this.oAuthServer=new R(t),this.accessTokens=new Map}return t.prototype.hasValidIdToken=function(){return M.isValidToken(this.idToken)},t.prototype.hasValidAccessToken=function(t){return M.isValidToken(this.accessTokens.get(t))},t.prototype.reset=function(){return this.idToken=void 0,this.accessTokens.clear(),this.freshIdTokenProvider.reset()},t.prototype.getIdTokenInternal=function(){return void 0!==this.idToken&&this.hasValidIdToken()?Promise.resolve(this.idToken):this.freshIdTokenProvider.getIdToken()},t.prototype.getIdToken=function(){var t=this;return this.getIdTokenInternal().then((function(e){return M.isValidToken(e)?M.isTokenReadyForRefresh(e)?t.oAuthServer.refreshIdToken({idToken:e.token}).then((function(e){return t.setIdToken(e),e})):(t.setIdToken(e),Promise.resolve(e)):(console.log("invalid token",e),Promise.reject("Received invalid ID token!"))}))},t.prototype.getIdTokenRaw=function(){return this.getIdToken().then((function(t){return t.token}))},t.prototype.setIdToken=function(t){this.idToken=t},t.prototype.verifyIdToken=function(t){return this.oAuthServer.verifyIdToken(t)},t.prototype.login=function(t,e){var n=this;return this.reset(),this.oAuthServer.requestIdTokenFromLogin({login:t,password:e,targetAudience:this.audience}).then((function(t){return n.setIdToken(t)}))},t.prototype.getAccessTokenInternal=function(t){var e=this;return this.getIdTokenRaw().then((function(n){return e.oAuthServer.requestAccessToken({idToken:n,targetAudience:e.audience,privilege:t}).then((function(n){return M.isValidToken(n)?(e.accessTokens.set(t,n),n):Promise.reject("Received access token is not valid!")}))}))},t.prototype.getAccessToken=function(t){var e=this.accessTokens.get(t);return void 0!==e&&M.isValidToken(e)?(M.isTokenReadyForRefresh(e)&&this.getAccessTokenInternal(t),Promise.resolve(e.token)):this.getAccessTokenInternal(t).then((function(t){return t.token}))},t}(),N=function(){function t(t){this.value=t}return t.prototype.getSubjectType=function(){return c.isEmpty(this.value)?null:this.value.split(":")[0]},t.prototype.getSubjectContent=function(){if(c.isEmpty(this.value))return null;var t=this.value.split("//");return t.length>1?t[1]:null},t.prototype.toString=function(){return this.value},t}(),U=function(){function t(){}return t.prototype.redirectTo=function(t){return this.redirecting=t,document.location.href=t,Promise.reject("Redirecting to ".concat(t))},t.prototype.isRedirecting=function(){return c.notBlank(this.redirecting)},t.prototype.redirectingTo=function(){return c.getNonEmpty(this.redirecting)},t}(),D=function(t){function n(e,n){var r=t.call(this)||this;return r.client=e,r.tokenQueryName=n||"token",r}return e(n,t),n.prototype.redirectToLogin=function(){var t=this;return this.client.getServerInfo().then((function(e){var n=T.deleteParamFromUrl(document.location.toString(),t.tokenQueryName),r="".concat(e.oauthServerUrl,"/login?app_name=").concat(e.targetAudience,"&redirect_url=").concat(n);return t.redirectTo(r)})).catch((function(t){return console.error("Redirection failed: OAuth info not fetched:",t),Promise.reject(t)}))},n.prototype.getIdToken=function(){return this.redirectToLogin()},n.prototype.reset=function(){return Promise.resolve()},n}(U),L=function(t){function n(e,n){var r=t.call(this)||this;return r.client=e,r.tokenQueryName=n||"token",r}return e(n,t),n.prototype.getIdTokenFromUrl=function(){return T.extractParamFromUrl(document.location.toString(),this.tokenQueryName)},n.prototype.getIdToken=function(){var t=this.getIdTokenFromUrl();return null===t||c.isBlank(t)?Promise.reject("No token in URL!"):this.client.getTokenManager().then((function(e){return e.verifyIdToken(t)}))},n.prototype.reset=function(){var t=this.getIdTokenFromUrl();if(null===t||c.isBlank(t))return Promise.resolve();console.log("Token in URL, redirecting...");var e=T.deleteParamFromUrl(document.location.toString(),this.tokenQueryName);return this.redirectTo(e)},n}(U),F=function(){function t(t){this.key=t||"id-token"}return t.prototype.saveIdTokenToLocalStorage=function(t){var e=t?JSON.stringify(t):null;null!==e?localStorage.setItem(this.key,e):localStorage.removeItem(this.key)},t.prototype.getIdTokenFromLocalStorage=function(){return v.parse(localStorage.getItem(this.key))},t.prototype.getIdToken=function(){var t=this.getIdTokenFromLocalStorage();return t&&M.isValidToken(t)?Promise.resolve(t):Promise.reject("No valid token found in storage!")},t.prototype.reset=function(){return this.saveIdTokenToLocalStorage(null),Promise.resolve()},t}(),q=function(){function t(t,e,n){this.login=new D(t,n),this.url=new L(t,n),this.storage=new F(e)}return t.prototype.getIdToken=function(){var t=this;return this.url.getIdToken().catch((function(e){return console.log("No token in url, loading from storage:",e),t.storage.getIdToken().catch((function(e){return console.log("No token in storage, redirecting to login page:",e),t.login.getIdToken()}))})).then((function(e){return console.log("Token found, saving to storage..."),t.storage.saveIdTokenToLocalStorage(e),t.url.reset().then((function(){return e}))}))},t.prototype.reset=function(){var t=this;return this.storage.reset().then((function(){return t.url.reset()}))},t}(),O=function(t){function n(e,n,r){void 0===r&&(r="*");var i=t.call(this,e)||this;return i.freshIdTokenProvider=n||new q(i),i.defaultPrivilege=r,i.insecureClient=new k(e),i.serverInfo=new o((function(){return i.getServerInfoInternal()})),i.tokenManager=new o((function(){return i.getTokenManagerInternal()})),i}return e(n,t),n.prototype.getIdToken=function(){return this.getTokenManager().then((function(t){return t.getIdToken()}))},n.prototype.initialize=function(){return this.getIdToken()},n.prototype.logout=function(){var t=this;return this.reset().then((function(){return t.initialize()}))},n.prototype.reset=function(){return this.getTokenManager().then((function(t){return t.reset()}))},n.prototype.getPrivilege=function(t){return this.defaultPrivilege},n.prototype.getServerInfoInternal=function(){return this.insecureClient.getJson("status/oauth/info")},n.prototype.getServerInfo=function(){return this.serverInfo.get()},n.prototype.getTokenManagerInternal=function(){var t=this;return this.getServerInfo().then((function(e){return new A(e.oauthServerUrl,e.targetAudience,t.freshIdTokenProvider)}))},n.prototype.getTokenManager=function(){return this.tokenManager.get()},n.prototype.login=function(t,e){return this.getTokenManager().then((function(n){return n.login(t,e)}))},n.prototype.setIdToken=function(t){return this.getTokenManager().then((function(e){return e.setIdToken(t)}))},n.prototype.getHeaders=function(e){var n=this;return this.getTokenManager().then((function(t){return t.getAccessToken(n.getPrivilege(e))})).then((function(r){return t.prototype.getHeaders.call(n,e).then((function(t){return t.set("Authorization","Bearer ".concat(r)),t}))}))},n}(k),C=function(){function t(t,e){this.x=t,this.y=e}return t.prototype.distanceTo=function(t){return Math.sqrt(Math.pow(this.x-t.x,2)+Math.pow(this.y-t.y,2))},t.prototype.equalsTo=function(t){return!!t&&(this.x===t.x&&this.y===t.y)},t.prototype.size=function(){return this.distanceTo(new t(0,0))},t.prototype.inSize=function(e){var n=this.size();if(0!==n){var r=e/n;return new t(this.x*r,this.y*r)}return this},t.prototype.round=function(){return new t(Math.round(this.x),Math.round(this.y))},t.prototype.add=function(e){return new t(this.x+e.x,this.y+e.y)},t.prototype.multiply=function(e){return new t(this.x*e,this.y*e)},t.prototype.subtract=function(e){return new t(this.x-e.x,this.y-e.y)},t.prototype.sub=function(t){return this.subtract(t)},t.prototype.toArray=function(){return[this.x,this.y]},t.fromArray=function(e){if("object"==typeof e&&2===e.length)return new t(e[0],e[1])},t.prototype.clone=function(){return new t(this.x,this.y)},t.prototype.getAngleToYAxis=function(t){var e=t.subtract(this),n=e.y<0,r=e.x/e.size(),o=Math.asin(r);return(n?Math.PI-o:o)||0},t.prototype.getNeighborPositions=function(e,n){void 0===e&&(e=1),void 0===n&&(n=!1);for(var r=[],o=this.x+e,i=this.x-e;i<=o;i++)for(var s=this.y+e,u=this.y-e;u<=s;u++){var a=new t(i,u);!n&&this.equalsTo(a)||r.push(a)}return r},t.prototype.getClosest=function(t){if(!t||0===t.length)return null;if(1===t.length)return t[0];for(var e=t[0],n=this.distanceTo(e),r=1,o=t.length;r<o;r++){var i=this.distanceTo(t[r]);i<n&&(e=t[r],n=i)}return e},t.prototype.toString=function(t){return void 0===t&&(t=2),"[".concat(d.round(this.x,t),",").concat(d.round(this.y,t),"]")},t}(),j={"--self-name":"Čeština",Anonymous:"Anonym",Administrator:"Administrátor",Back:"Zpět",File:"Soubor",Language:"Jazyk",Image:"Obrázek",Status:"Stav",State:"Stav",System:"Systém",Date:"Datum",Page:"Stránka","Page size":"Velikost stránky","Total items":"Celkem záznamů","Log out":"Odhlásit",Move:"Přesunout",Delete:"Smazat",Close:"Zavřít",Edit:"Upravit",Save:"Uložit",Refresh:"Obnovit",Select:"Vybrat","More...":"Více...",New:[{tags:["feminine"],value:"Nová"},{value:"Nový"}],Name:[{tags:["neutral"],value:"Název"},{value:"Jméno"}]},z={"--self-name":"English"},B=function(){function t(t){this.data=t}return t.prototype.translate=function(t,e){var n=this.data[t];if(void 0===n||"string"==typeof n)return n;var r=n.find((function(t){return void 0===t.tags||0===t.tags.length}));if((void 0===e||void 0===e.tags||0===e.tags.length)&&void 0!==r)return r.value;var o=n.filter((function(t){return void 0!==t.tags&&0!==t.tags.length&&(e&&e.tags&&e.tags.every((function(e){return t.tags&&t.tags.includes(e)})))}));return o.length>0?o[0].value:r?r.value:void 0},t}(),J=function(t){function n(){return t.call(this,j)||this}return e(n,t),n}(B),V=function(t){function n(){return t.call(this,z)||this}return e(n,t),n}(B),H=function(){function t(t,e){this.primary=t,this.fallback=e}return t.prototype.translate=function(t,e){var n=this.primary.translate(t,e);return void 0===n?this.fallback.translate(t,e):n},t}(),Q=function(){function t(t){this.dictionaries=new Map,this.setLanguage(t)}return t.prototype.addDictionary=function(t,e){var n=this.dictionaries.get(t);n?this.dictionaries.set(t,new H(e,n)):this.dictionaries.set(t,e)},t.prototype.hasDictionary=function(t){return!!t&&this.dictionaries.has(t)},t.prototype.getLanguage=function(){return this.language},t.prototype.getLanguages=function(){return Array.from(this.dictionaries.keys())},t.prototype.setLanguage=function(t){this.language=t&&this.hasDictionary(t)?t:this.hasDictionary(navigator.language)?navigator.language:void 0},t.prototype.translate=function(t,e,n){if(!(n=n||this.language))return t;var r=this.dictionaries.get(n);if(!r)return t;var o=r.translate(t,e);return void 0===o?t:o},t}(),_=function(t){function n(e){var n=t.call(this)||this;return n.addDictionary("cs",new J),n.addDictionary("en",new V),n.setLanguage(e),n}return e(n,t),n}(Q);export{h as ArrayUtil,p as AsyncUtil,_ as BasicLocalization,f as ByteUtil,i as CacheAsync,P as CancellablePromise,J as CzechBasicDictionary,y as DateUtil,H as DictionaryWithFallback,V as EnglishBasicDictionary,w as EntityCachedClient,S as EntityClient,I as EntityClientWithStub,E as EventManager,s as HashCacheAsync,m as HashUtil,v as JsonUtil,u as Lazy,o as LazyAsync,Q as Localization,b as LookupClient,B as MemoryDictionary,d as NumberUtil,R as OAuthRestClient,N as OAuthSubject,A as OAuthTokenManager,a as ObjectUtil,g as PagingUtil,k as RestClient,O as RestClientWithOAuth,c as StringUtil,T as UrlUtil,r as UserAlertType,x as UserAlerts,C as Vector2};
1
+ var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};function e(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return n=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},n.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;var r,o=function(){function t(t){this.supplier=t}return t.prototype.get=function(){var t=this;return void 0!==this.cache?Promise.resolve(this.cache):(void 0===this.promise&&(this.promise=this.supplier().then((function(e){return t.cache=e,t.promise=void 0,Promise.resolve(e)})).catch((function(e){return t.promise=void 0,Promise.reject(e)}))),this.promise)},t.prototype.reset=function(){this.cache=void 0},t.prototype.hasCache=function(){return void 0!==this.cache},t.prototype.getCache=function(){return this.cache},t}(),i=function(t){function n(e,n){var r=t.call(this,e)||this;return r.maxAgeMs=n,r}return e(n,t),n.prototype.get=function(){return this.expires&&this.expires>new Date&&this.reset(),t.prototype.get.call(this)},n.prototype.set=function(t,e){this.cache=t,this.expires=e,this.maxAgeMs&&void 0===this.expires&&(this.expires=new Date((new Date).getTime()+this.maxAgeMs))},n}(o),s=function(){function t(t,e){this.cache=new Map,this.maxSize=100,this.supplier=t,e&&(this.maxSize=e)}return t.prototype.obtainCache=function(t){var e=this,n=this.cache.get(t);return n||(n=new i((function(){return e.supplier(t)})),this.cache.set(t,n)),n},t.prototype.get=function(t){return this.obtainCache(t).get()},t.prototype.set=function(t,e,n){this.obtainCache(t).set(e,n)},t.prototype.reset=function(t){t?this.cache.delete(t):this.cache.clear()},t.prototype.getSize=function(){return this.cache.size},t.prototype.getMaxSize=function(){return this.maxSize},t.prototype.getStats=function(){return{cachedItems:this.getSize(),capacity:this.getMaxSize()}},t.prototype.hasCache=function(t){return this.cache.has(t)},t}(),u=function(){function t(t){this.supplier=t}return t.prototype.get=function(){return void 0===this.cache&&(this.cache=this.supplier()),this.cache},t.prototype.reset=function(){this.cache=void 0},t.prototype.hasCache=function(){return void 0!==this.cache},t}(),a=function(){function t(){}return t.isEmpty=function(t){return null==t},t.notEmpty=function(e){return!t.isEmpty(e)},t.clone=function(t){if(null===t)throw new Error("Null cannot be cloned!");if("object"!=typeof t)throw new Error("Not an object, cannot be cloned!");return n({},t)},t.getNestedValue=function(t,e){if(!t||""===t)return"";for(var n=t,r=0,o=e.split(".");r<o.length;r++){var i=o[r];if(!n||"object"!=typeof n||!(i in n))return"";n=n[i]}return n},t}(),c=function(){function t(){}return t.isString=function(t){return"string"==typeof t},t.toString=function(e){var n,r;return t.isString(e)?e:null!==(r=null===(n=null==e?void 0:e.toString)||void 0===n?void 0:n.call(e))&&void 0!==r?r:""},t.isEmpty=function(t){return!!a.isEmpty(t)||0===t.length},t.notEmpty=function(e){return!t.isEmpty(e)},t.isBlank=function(e){return t.isEmpty(t.safeTrim(e))},t.notBlank=function(e){return!t.isBlank(e)},t.substr=function(t,e,n){return this.isEmpty(t)?"":t.substring(e,n)},t.replace=function(t,e,n){return this.isEmpty(t)||this.isEmpty(e)?"":t.replace(e,String(n))},t.containsLineBreaks=function(e){return!t.isBlank(e)&&e.includes("\n")},t.trimLeadingSlashes=function(e){return this.isEmpty(e)?"":t.toString(e).replace(/^\//g,"")},t.trimTrailingSlashes=function(e){return this.isEmpty(e)?"":t.toString(e).replace(/\/$/g,"")},t.trimSlashes=function(e){return this.isEmpty(e)?"":t.toString(e).replace(/^\/|\/$/g,"")},t.safeTruncate=function(e,n,r){return void 0===r&&(r=""),t.isEmpty(e)||!e?"":(e=t.toString(e)).length<=n?String(e):e.substring(0,n-r.length)+r},t.ellipsis=function(e,n,r){return void 0===r&&(r="..."),t.safeTruncate(e,n,r)},t.safeTrim=function(e){return t.isEmpty(e)?"":t.toString(e).trim()},t.safeLowercase=function(e){return t.isEmpty(e)||!e?"":t.toString(e).toLowerCase()},t.safeUppercase=function(e){return t.isEmpty(e)||!e?"":t.toString(e).toUpperCase()},t.capitalizeFirstLetter=function(e){return t.isBlank(e)?"":t.safeUppercase(e.charAt(0))+t.safeLowercase(t.substr(e,1))},t.toBigInt=function(t){return this.isEmpty(t)?null:BigInt(t)},t.getNonEmpty=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return e.find((function(e){return t.notEmpty(e)}))||""},t.getNonBlank=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return e.find((function(e){return t.notBlank(e)}))||""},t.emptyToNull=function(e){return t.isEmpty(e)?null:String(e)},t.blankToNull=function(e){return t.isBlank(e)?null:String(e)},t}(),h=function(){function t(){}return t.isEmpty=function(t){return a.isEmpty(t)||0===t.length},t.notEmpty=function(e){return!t.isEmpty(e)},t.remove=function(e,n){return t.isEmpty(e)?[]:null==e?void 0:e.filter((function(t){return t!==n}))},t}(),f=function(){function t(){}return t.sleep=function(t){return new Promise((function(e){return setTimeout(e,t)}))},t}(),p=function(){function t(){}return t.formatByteSize=function(t){var e=Number(t);if(null===e||Number.isNaN(e))return"";if(0===e)return"0";var n=Math.floor(Math.log(e)/Math.log(1024));return 1*+(e/Math.pow(1024,n)).toFixed(2)+" "+["B","kB","MB","GB","TB"][n]},t}(),l={page:0,size:10},g=function(){function t(){}return t.sortingFieldToString=function(t){if(!t)return"";var e=[];return e.push(t.name),e.push(t.desc?"desc":""),e.push(t.nullsLast?"nl":""),e.join("-")},t.sortingFieldFromString=function(t){var e=t.split("-");return{name:e[0],desc:e.length>1&&"desc"===c.safeLowercase(e[1]),nullsLast:e.length>2&&"nl"===c.safeLowercase(e[2])}},t.sortingRequestToString=function(e){return e.map((function(e){return t.sortingFieldToString(e)})).join("+")},t.sortingRequestFromString=function(e){return e?e.split("+").map((function(e){return t.sortingFieldFromString(e)})):[]},t.pagingRequestToQueryParams=function(e){if(e){var n={page:e.page,size:e.size};return e.search&&(n.search=e.search),e.sorting&&(n.sorting=t.sortingRequestToString(e.sorting)),n}},t.pagingRequestToString=function(e){if(!e)return"";var n=[];return n.push(String(e.page)),n.push(String(e.size)),n.push(c.safeTrim(e.search)),n.push(e.sorting?t.sortingRequestToString(e.sorting):""),n.join(":")},t.pagingRequestFromString=function(e){if(!e||c.isEmpty(e))return n({},l);var r=e.split(":");return r.length<4?n({},l):{page:Number(r[0]),size:Number(r[1]),search:String(r[2]),sorting:c.isEmpty(r[3])?void 0:t.sortingRequestFromString(r[3])}},t}(),y=function(){function t(){}return t.isEmpty=function(t){return null==t||Number.isNaN(t)},t.notEmpty=function(t){return!a.isEmpty(t)},t.parseNumber=function(t){if(!t)return null;var e=Number(t);return Number.isNaN(e)?null:e},t.round=function(t,e){e||(e=0);var n=Math.pow(10,e);return Math.round(t*n)/n},t.portionToPercent=function(e,n){if(null==e)return"";var r=t.round(100*e,n);return"".concat(r,"%")},t}(),d=function(){function t(){}return t.formatNumber=function(t,e){return void 0===e&&(e=2),String(t).padStart(e,"0")},t.parseDate=function(t){if(t)return"string"==typeof t?new Date(t):t},t.formatDateForHumans=function(e,n){if(void 0===n&&(n=!1),!(e=t.parseDate(e)))return"";var r=e.getFullYear(),o=t.formatNumber(e.getMonth()+1),i=t.formatNumber(e.getDate());if(!n)return"".concat(r,"-").concat(o,"-").concat(i);var s=t.formatNumber(e.getHours()),u=t.formatNumber(e.getMinutes()),a=t.formatNumber(e.getSeconds());return"".concat(r,"/").concat(o,"/").concat(i," ").concat(s,":").concat(u,":").concat(a)},t.formatDateTimeForHumans=function(e){return t.formatDateForHumans(e,!0)},t.formatDateForInput=function(e,n){if(void 0===n&&(n=!1),!(e=t.parseDate(e)))return"";var r=e.getFullYear(),o=t.formatNumber(e.getMonth()+1),i=t.formatNumber(e.getDate());if(!n)return"".concat(r,"-").concat(o,"-").concat(i);var s=t.formatNumber(e.getHours()),u=t.formatNumber(e.getMinutes()),a=t.formatNumber(e.getSeconds());return"".concat(r,"-").concat(o,"-").concat(i,"T").concat(s,":").concat(u,":").concat(a)},t.formatDateTimeForInput=function(e){return t.formatDateForInput(e,!0)},t.getDurationMs=function(e,n){if(e=t.parseDate(e),n=t.parseDate(n),a.isEmpty(e)||a.isEmpty(n))return null;try{return n.getTime()-e.getTime()}catch(t){return null}},t.getSinceDurationMs=function(e){return t.getDurationMs(e,new Date)},t.formatDuration=function(t){if(!t)return"";var e=Math.floor(t/1e3);t-=1e3*e;var n=Math.floor(e/60);e-=60*n;var r=Math.floor(n/60);n-=60*r;var o=Math.floor(r/24);r-=24*o;var i=[];return o>0&&i.push("".concat(o,"d")),r>0&&i.push("".concat(r,"h")),n>0&&i.push("".concat(n,"m")),e>0&&0===o&&0===r&&i.push("".concat(e,"s")),t>0&&0===o&&0===r&&0===n&&i.push("".concat(y.round(t,2),"ms")),i.join(" ")},t}(),v=function(){function t(){}return t.dateParser=function(e,n){return"string"==typeof n&&t.reISO.exec(n)?new Date(n):n},t.parseWithDates=function(e){if(!c.isBlank(e))return JSON.parse(c.getNonEmpty(e),t.dateParser)},t.parse=function(e){return t.parseWithDates(e)},t.reISO=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*))(?:Z|(\+|-)([\d|:]*))?$/,t}(),m=function(){function t(){}return t.crc32hex=function(t){for(var e=(new TextEncoder).encode(t),n=new Uint32Array(256),r=0;r<256;r++){for(var o=r,i=0;i<8;i++)o=1&o?3988292384^o>>>1:o>>>1;n[r]=o>>>0}var s=~0;for(r=0;r<e.length;r++)s=s>>>8^n[255&(s^e[r])];return(s=~s>>>0).toString(16)},t}(),T=function(){function t(){}return t.deleteParamFromUrl=function(t,e){var n=new URL(t);return n.searchParams.delete(e),c.trimTrailingSlashes(n.toString())},t.extractParamFromUrl=function(t,e){return new URLSearchParams(new URL(t).search).get(e)},t.paramExistsInUrl=function(e,n){return c.notBlank(t.extractParamFromUrl(e,n))},t.extractHostFromUrl=function(t){return c.isBlank(t)?null:new URL(t).host},t.extractDomainFromUrl=function(e){var n=t.extractHostFromUrl(e);return c.isBlank(n)?null:n.split(".").slice(-2).join(".")},t}(),k=function(){function t(e){c.isBlank(e)?this.baseUrl=t.baseHostUrl():(e.endsWith("/")||(e+="/"),this.baseUrl=e.startsWith("http")?new URL(e):new URL(e,t.baseHostUrl()))}return t.baseHostUrl=function(){return new URL("".concat(window.location.protocol,"//").concat(window.location.host,"/"))},t.pagingRequestToQueryParams=function(t){return g.pagingRequestToQueryParams(t)},t.paramsToQueryString=function(t){if(!t)return"";var e=new URLSearchParams(t),n=new URLSearchParams;e.forEach((function(t,e){""!==t&&void 0!==t&&"undefined"!==t&&n.set(e,t)}));var r=n.toString();return c.isEmpty(r)?"":"?".concat(r)},t.prototype.getHeaders=function(t){var e=new Headers;return e.set("Content-Type","application/json"),Promise.resolve(e)},t.prototype.getBaseUrl=function(){return this.baseUrl},t.prototype.getUrl=function(t,e){var n=new URL(c.trimLeadingSlashes(t),this.baseUrl);return e&&Object.keys(e).forEach((function(t){var r=e[t];""!==r&&void 0!==r&&"undefined"!==r&&n.searchParams.set(t,r)})),n},t.prototype.getRequestOptions=function(t,e,n){return void 0===e&&(e="GET"),void 0===n&&(n=null),this.getHeaders(t).then((function(t){return{method:e,headers:t,body:null===n?null:n instanceof FormData?n:JSON.stringify(n)}}))},t.prototype.processRequest=function(t,e,n){return fetch(this.getUrl(t,e),n).then((function(t){if(!t.ok){var e={cause:t.status};return"application/json"===t.headers.get("Content-Type")?t.json().then((function(n){if(n.message)throw new Error(n.message,e);if(n.error)throw new Error(n.error,e);throw new Error(t.statusText,e)}),(function(){throw new Error(t.statusText,e)})):t.text().then((function(n){throw c.isEmpty(n)?new Error(t.statusText,e):new Error(n,e)}),(function(){throw new Error(t.statusText,e)}))}return t}))},t.prototype.processRequestJson=function(t,e,n){return this.processRequest(t,e,n).then((function(t){return t.text().then(v.parseWithDates)}))},t.prototype.getJson=function(t,e){var n=this;return this.getRequestOptions(t).then((function(r){return n.processRequestJson(t,e,r)}))},t.prototype.postJson=function(t,e,n){var r=this;return void 0===e&&(e=null),this.getRequestOptions(t,"POST",e).then((function(e){return r.processRequestJson(t,n,e)}))},t.prototype.postForm=function(t,e,n){var r=this;return this.getRequestOptions(t,"POST",e).then((function(e){return e.headers.delete("Content-Type"),r.processRequest(t,n,e)}))},t.prototype.postFormJson=function(t,e,n){var r=this;return this.getRequestOptions(t,"POST",e).then((function(e){return e.headers.delete("Content-Type"),r.processRequestJson(t,n,e)}))},t.prototype.putJson=function(t,e,n){var r=this;return void 0===e&&(e=null),this.getRequestOptions(t,"PUT",e).then((function(e){return r.processRequestJson(t,n,e)}))},t.prototype.get=function(t,e){var n=this;return this.getRequestOptions(t).then((function(r){return n.processRequest(t,e,r)}))},t.prototype.del=function(t,e){var n=this;return this.getRequestOptions(t,"DELETE").then((function(r){return n.processRequest(t,e,r)}))},t.prototype.post=function(t,e,n){var r=this;return void 0===e&&(e=null),this.getRequestOptions(t,"POST",e).then((function(e){return r.processRequest(t,n,e)}))},t.prototype.put=function(t,e,n){var r=this;return void 0===e&&(e=null),this.getRequestOptions(t,"PUT",e).then((function(e){return r.processRequest(t,n,e)}))},t}(),S=function(){function t(t,e){this.client=t,this.name=e}return t.prototype.loadSingle=function(t){return this.client.getJson("".concat(this.name,"/").concat(t))},t.prototype.loadPage=function(t){return this.client.getJson(this.name,k.pagingRequestToQueryParams(t))},t.prototype.save=function(t){return t.id?this.client.putJson("".concat(this.name,"/").concat(t.id),t):this.client.postJson(this.name,t)},t.prototype.delete=function(t){return this.client.del("".concat(this.name,"/").concat(t))},t}(),w=function(t){function n(e,n,r){var o=t.call(this,e,n)||this;return o.cache=new s((function(e){return t.prototype.loadSingle.call(o,e)}),r),o}return e(n,t),n.prototype.loadSingle=function(t){return this.cache.get(t)},n.prototype.save=function(e){var n=this;return t.prototype.save.call(this,e).then((function(t){return t.id&&n.cache.set(t.id,t),t}))},n.prototype.delete=function(e){var n=this;return t.prototype.delete.call(this,e).then((function(){return n.cache.reset(e)}))},n.prototype.reset=function(t){this.cache.reset(t)},n.prototype.getStats=function(){return this.cache.getStats()},n}(S),R=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return e(n,t),n.prototype.loadSingle=function(t){throw new Error("Use loadSingleStub() instead!")},n.prototype.loadSingleStub=function(t){return this.client.getJson("".concat(this.name,"/").concat(t))},n.prototype.save=function(t){throw new Error("Use saveStub() instead!")},n.prototype.saveStub=function(t){return t.id?this.client.putJson("".concat(this.name,"/").concat(t.id),t):this.client.postJson(this.name,t)},n}(S),E=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.cache=new o((function(){return r.loadAllInternal()})),r}return e(n,t),n.prototype.loadAllInternal=function(){return this.client.getJson("".concat(this.name,"/all"))},n.prototype.loadAll=function(){return this.cache.get()},n.prototype.loadSingle=function(t){var e=this;return this.loadAll().then((function(n){var r=n.find((function(e){return e.id===t}));if(void 0===t)throw new Error("".concat(e.name," id ").concat(t," not found!"));return r}))},n.prototype.save=function(e){var n=this;return t.prototype.save.call(this,e).then((function(t){return n.cache.reset(),t}))},n.prototype.delete=function(e){var n=this;return t.prototype.delete.call(this,e).then((function(){return n.cache.reset()}))},n.prototype.reset=function(){this.cache.reset()},n.prototype.getStats=function(){var t,e=null===(t=this.cache.getCache())||void 0===t?void 0:t.length;return{cachedItems:e||0,capacity:e||0}},n}(S),b=function(){function t(){this.handlers=new Map}return t.prototype.addEventListener=function(t,e){this.handlers.has(t)||this.handlers.set(t,[]),this.handlers.get(t).push(e)},t.prototype.removeEventListener=function(t,e){var n=this.handlers.get(t);n&&n.splice(n.indexOf(e),1)},t.prototype.triggerEvent=function(t,e){this.handlers.has(t)&&this.handlers.get(t).forEach((function(t){return t(e)}))},t}();!function(t){t.info="info",t.warning="warning",t.error="danger"}(r||(r={}));var x=function(){function t(t,e){void 0===t&&(t=20),void 0===e&&(e=7e3),this.maxAlerts=t,this.maxVisibilityMs=e,this.em=new b,this.alerts=[],this.visibleAlerts=[]}return t.prototype.addOnChangeHandler=function(t){this.em.addEventListener("change",t)},t.prototype.removeOnChangeHandler=function(t){this.em.removeEventListener("change",t)},t.prototype.triggerChange=function(){this.em.triggerEvent("change")},t.prototype.reset=function(){this.alerts=[],this.visibleAlerts=[],this.triggerChange()},t.prototype.hide=function(t){this.visibleAlerts.splice(this.visibleAlerts.indexOf(t),1),this.triggerChange()},t.prototype.hideAll=function(){this.visibleAlerts=[],this.triggerChange()},t.prototype.updateVisibility=function(){var t=this;this.visibleAlerts.forEach((function(e){var n=d.getSinceDurationMs(e.time)||t.maxVisibilityMs,r=t.maxVisibilityMs-n;r>0?e.remainsMs=r:(e.remainsMs=void 0,t.hide(e))})),this.triggerChange()},t.prototype.remove=function(t){this.alerts.splice(this.alerts.indexOf(t),1),this.triggerChange()},t.prototype.add=function(t){for(void 0===t.remainsMs&&(t.remainsMs=this.maxVisibilityMs),this.alerts.push(t),this.visibleAlerts.push(t);this.alerts.length>this.maxAlerts;)this.alerts.shift();this.triggerChange()},t.prototype.custom=function(t,e){this.add({time:new Date,type:t,message:e})},t.prototype.err=function(t){this.custom(r.error,"string"==typeof t?t:t.toString())},t.prototype.warn=function(t){this.custom(r.warning,t)},t.prototype.info=function(t){this.custom(r.info,t)},t.prototype.getSummary=function(){var t=new Map;Object.values(r).forEach((function(e,n){t.set(e,0)}));for(var e=0;e<this.alerts.length;e++){var n=this.alerts[e],o=t.get(n.type)||0;t.set(n.type,o+1)}return t},t}(),P=function(){function t(t,e){void 0===e&&(e=!1);var n=this;this.isCancelled={value:!1},this.throwWhenCancelled=e,this.promise=new Promise((function(e,r){t.then((function(t){if(!n.isCancelled.value)return e(t)})).catch((function(t){!n.throwWhenCancelled&&n.isCancelled.value||r(t)}))}))}return t.prototype.cancel=function(){this.isCancelled.value=!0},t}(),M=function(t){function n(e){return t.call(this,"".concat(c.trimSlashes(e),"/api/oauth"))||this}return e(n,t),n.prototype.jwks=function(){return this.getJson("jwks.json")},n.prototype.verifyRefreshToken=function(t){return this.getJson("refresh-tokens/verify/".concat(t))},n.prototype.verifyAccessToken=function(t){return this.getJson("access-tokens/verify/".concat(t))},n.prototype.verifyIdToken=function(t){return this.getJson("id-tokens/verify/".concat(t))},n.prototype.requestRefreshTokenFromLogin=function(t){return this.postJson("refresh-tokens/from-login",t)},n.prototype.renewRefreshToken=function(t){return this.postJson("refresh-tokens/renew",t)},n.prototype.requestAccessToken=function(t){return this.postJson("access-tokens/from-refresh-token",t)},n}(k),N=function(){function t(){}return t.isValidToken=function(e){return a.notEmpty(e)&&c.notBlank(e.token)&&!t.isTokenExpired(e)},t.isTokenExpired=function(t){return null!=t&&(void 0!==t.expires&&null!==t.expires&&t.expires<new Date)},t.isTokenReadyForRefresh=function(e){return null!=e&&(!t.isTokenExpired(e)&&(void 0!==e.expires&&null!==e.expires&&new Date((e.expires.getTime()+e.issuedAt.getTime())/2)<new Date))},t}(),A=function(){function t(t,e,n){this.initialRefreshTokenProvider=n,this.audience=e,this.oAuthServer=new M(t),this.accessTokens=new Map}return t.prototype.hasValidRefreshToken=function(){return N.isValidToken(this.refreshToken)},t.prototype.hasValidAccessToken=function(t){return N.isValidToken(this.accessTokens.get(t))},t.prototype.reset=function(){return this.refreshToken=void 0,this.accessTokens.clear(),this.initialRefreshTokenProvider.reset()},t.prototype.getRefreshTokenInternal=function(){return this.hasValidRefreshToken()&&void 0!==this.refreshToken?Promise.resolve(this.refreshToken):this.initialRefreshTokenProvider.getRefreshToken()},t.prototype.getRefreshToken=function(){var t=this;return this.getRefreshTokenInternal().then((function(e){return N.isValidToken(e)?N.isTokenReadyForRefresh(e)?t.oAuthServer.renewRefreshToken({refreshToken:e.token}).then((function(e){return t.setRefreshToken(e),e})):(t.setRefreshToken(e),Promise.resolve(e)):(console.log("invalid token",e),Promise.reject("Received invalid ID token!"))}))},t.prototype.getRefreshTokenRaw=function(){return this.getRefreshToken().then((function(t){return t.token}))},t.prototype.setRefreshToken=function(t){this.refreshToken=t},t.prototype.verifyIdToken=function(t){return this.oAuthServer.verifyIdToken(t)},t.prototype.login=function(t,e){var n=this;return this.reset(),this.oAuthServer.requestRefreshTokenFromLogin({login:t,password:e,targetAudience:this.audience}).then((function(t){return n.setRefreshToken(t)}))},t.prototype.getAccessTokenInternal=function(t){var e=this;return this.getRefreshTokenRaw().then((function(n){return e.oAuthServer.requestAccessToken({refreshToken:n,targetAudience:e.audience,privilege:t}).then((function(n){return N.isValidToken(n)?(e.accessTokens.set(t,n),n):Promise.reject("Received access token is not valid!")}))}))},t.prototype.getAccessToken=function(t){var e=this.accessTokens.get(t);return void 0!==e&&N.isValidToken(e)?(N.isTokenReadyForRefresh(e)&&this.getAccessTokenInternal(t),Promise.resolve(e.token)):this.getAccessTokenInternal(t).then((function(t){return t.token}))},t}(),U=function(){function t(t){this.value=t}return t.prototype.getSubjectType=function(){return c.isEmpty(this.value)?null:this.value.split(":")[0]},t.prototype.getSubjectContent=function(){if(c.isEmpty(this.value))return null;var t=this.value.split("//");return t.length>1?t[1]:null},t.prototype.toString=function(){return this.value},t}(),D=function(){function t(){}return t.prototype.redirectTo=function(t){return this.redirecting=t,document.location.href=t,Promise.reject("Redirecting to ".concat(t))},t.prototype.isRedirecting=function(){return c.notBlank(this.redirecting)},t.prototype.redirectingTo=function(){return c.getNonEmpty(this.redirecting)},t}(),L=function(t){function n(e,n){var r=t.call(this)||this;return r.client=e,r.tokenQueryName=n||"token",r}return e(n,t),n.prototype.redirectToLogin=function(){var t=this;return this.client.getServerInfo().then((function(e){var n=T.deleteParamFromUrl(document.location.toString(),t.tokenQueryName),r="".concat(e.oauthServerUrl,"/login?app_name=").concat(e.targetAudience,"&redirect_url=").concat(n);return t.redirectTo(r)})).catch((function(t){return console.error("Redirection failed: OAuth info not fetched:",t),Promise.reject(t)}))},n.prototype.getRefreshToken=function(){return this.redirectToLogin()},n.prototype.reset=function(){return Promise.resolve()},n}(D),F=function(t){function n(e,n){var r=t.call(this)||this;return r.client=e,r.tokenQueryName=n||"token",r}return e(n,t),n.prototype.getRefreshTokenFromUrl=function(){return T.extractParamFromUrl(document.location.toString(),this.tokenQueryName)},n.prototype.getRefreshToken=function(){var t=this.getRefreshTokenFromUrl();return null===t||c.isBlank(t)?Promise.reject("No token in URL!"):this.client.getTokenManager().then((function(e){return e.verifyIdToken(t)}))},n.prototype.reset=function(){var t=this.getRefreshTokenFromUrl();if(null===t||c.isBlank(t))return Promise.resolve();console.log("Token in URL, redirecting...");var e=T.deleteParamFromUrl(document.location.toString(),this.tokenQueryName);return this.redirectTo(e)},n}(D),I=function(){function t(t){this.key=t||"refresh-token"}return t.prototype.saveRefreshTokenToLocalStorage=function(t){var e=t?JSON.stringify(t):null;null!==e?localStorage.setItem(this.key,e):localStorage.removeItem(this.key)},t.prototype.getRefreshTokenFromLocalStorage=function(){return v.parse(localStorage.getItem(this.key))},t.prototype.getRefreshToken=function(){var t=this.getRefreshTokenFromLocalStorage();return t&&N.isValidToken(t)?Promise.resolve(t):Promise.reject("No valid token found in storage!")},t.prototype.reset=function(){return this.saveRefreshTokenToLocalStorage(null),Promise.resolve()},t}(),q=function(){function t(t,e,n){this.login=new L(t,n),this.url=new F(t,n),this.storage=new I(e)}return t.prototype.getRefreshToken=function(){var t=this;return this.url.getRefreshToken().catch((function(e){return console.log("No token in url, loading from storage:",e),t.storage.getRefreshToken().catch((function(e){return console.log("No token in storage, redirecting to login page:",e),t.login.getRefreshToken()}))})).then((function(e){return console.log("Token found, saving to storage..."),t.storage.saveRefreshTokenToLocalStorage(e),t.url.reset().then((function(){return e}))}))},t.prototype.reset=function(){var t=this;return this.storage.reset().then((function(){return t.url.reset()}))},t}(),O=function(t){function n(e,n,r){void 0===r&&(r="*");var i=t.call(this,e)||this;return i.freshIdTokenProvider=n||new q(i),i.defaultPrivilege=r,i.insecureClient=new k(e),i.serverInfo=new o((function(){return i.getServerInfoInternal()})),i.tokenManager=new o((function(){return i.getTokenManagerInternal()})),i}return e(n,t),n.prototype.getRefreshToken=function(){return this.getTokenManager().then((function(t){return t.getRefreshToken()}))},n.prototype.initialize=function(){return this.getRefreshToken()},n.prototype.logout=function(){var t=this;return this.reset().then((function(){return t.initialize()}))},n.prototype.reset=function(){return this.getTokenManager().then((function(t){return t.reset()}))},n.prototype.getPrivilege=function(t){return this.defaultPrivilege},n.prototype.getServerInfoInternal=function(){return this.insecureClient.getJson("status/oauth/info")},n.prototype.getServerInfo=function(){return this.serverInfo.get()},n.prototype.getTokenManagerInternal=function(){var t=this;return this.getServerInfo().then((function(e){return new A(e.oauthServerUrl,e.targetAudience,t.freshIdTokenProvider)}))},n.prototype.getTokenManager=function(){return this.tokenManager.get()},n.prototype.login=function(t,e){return this.getTokenManager().then((function(n){return n.login(t,e)}))},n.prototype.setIdToken=function(t){return this.getTokenManager().then((function(e){return e.setRefreshToken(t)}))},n.prototype.getHeaders=function(e){var n=this;return this.getTokenManager().then((function(t){return t.getAccessToken(n.getPrivilege(e))})).then((function(r){return t.prototype.getHeaders.call(n,e).then((function(t){return t.set("Authorization","Bearer ".concat(r)),t}))}))},n}(k),C=function(){function t(t,e){this.x=t,this.y=e}return t.prototype.distanceTo=function(t){return Math.sqrt(Math.pow(this.x-t.x,2)+Math.pow(this.y-t.y,2))},t.prototype.equalsTo=function(t){return!!t&&(this.x===t.x&&this.y===t.y)},t.prototype.size=function(){return this.distanceTo(new t(0,0))},t.prototype.inSize=function(e){var n=this.size();if(0!==n){var r=e/n;return new t(this.x*r,this.y*r)}return this},t.prototype.round=function(){return new t(Math.round(this.x),Math.round(this.y))},t.prototype.add=function(e){return new t(this.x+e.x,this.y+e.y)},t.prototype.multiply=function(e){return new t(this.x*e,this.y*e)},t.prototype.subtract=function(e){return new t(this.x-e.x,this.y-e.y)},t.prototype.sub=function(t){return this.subtract(t)},t.prototype.toArray=function(){return[this.x,this.y]},t.fromArray=function(e){if("object"==typeof e&&2===e.length)return new t(e[0],e[1])},t.prototype.clone=function(){return new t(this.x,this.y)},t.prototype.getAngleToYAxis=function(t){var e=t.subtract(this),n=e.y<0,r=e.x/e.size(),o=Math.asin(r);return(n?Math.PI-o:o)||0},t.prototype.getNeighborPositions=function(e,n){void 0===e&&(e=1),void 0===n&&(n=!1);for(var r=[],o=this.x+e,i=this.x-e;i<=o;i++)for(var s=this.y+e,u=this.y-e;u<=s;u++){var a=new t(i,u);!n&&this.equalsTo(a)||r.push(a)}return r},t.prototype.getClosest=function(t){if(!t||0===t.length)return null;if(1===t.length)return t[0];for(var e=t[0],n=this.distanceTo(e),r=1,o=t.length;r<o;r++){var i=this.distanceTo(t[r]);i<n&&(e=t[r],n=i)}return e},t.prototype.toString=function(t){return void 0===t&&(t=2),"[".concat(y.round(this.x,t),",").concat(y.round(this.y,t),"]")},t}(),j={"--self-name":"Čeština",Anonymous:"Anonym",Administrator:"Administrátor",Back:"Zpět",File:"Soubor",Language:"Jazyk",Image:"Obrázek",Status:"Stav",State:"Stav",System:"Systém",Date:"Datum",Page:"Stránka","Page size":"Velikost stránky","Total items":"Celkem záznamů","Log out":"Odhlásit",Move:"Přesunout",Delete:"Smazat",Close:"Zavřít",Edit:"Upravit",Save:"Uložit",Refresh:"Obnovit",Select:"Vybrat","More...":"Více...",New:[{tags:["feminine"],value:"Nová"},{value:"Nový"}],Name:[{tags:["neutral"],value:"Název"},{value:"Jméno"}]},J={"--self-name":"English"},z=function(){function t(t){this.data=t}return t.prototype.translate=function(t,e){var n=this.data[t];if(void 0===n||"string"==typeof n)return n;var r=n.find((function(t){return void 0===t.tags||0===t.tags.length}));if((void 0===e||void 0===e.tags||0===e.tags.length)&&void 0!==r)return r.value;var o=n.filter((function(t){return void 0!==t.tags&&0!==t.tags.length&&(e&&e.tags&&e.tags.every((function(e){return t.tags&&t.tags.includes(e)})))}));return o.length>0?o[0].value:r?r.value:void 0},t}(),B=function(t){function n(){return t.call(this,j)||this}return e(n,t),n}(z),V=function(t){function n(){return t.call(this,J)||this}return e(n,t),n}(z),H=function(){function t(t,e){this.primary=t,this.fallback=e}return t.prototype.translate=function(t,e){var n=this.primary.translate(t,e);return void 0===n?this.fallback.translate(t,e):n},t}(),Q=function(){function t(t){this.dictionaries=new Map,this.setLanguage(t)}return t.prototype.addDictionary=function(t,e){var n=this.dictionaries.get(t);n?this.dictionaries.set(t,new H(e,n)):this.dictionaries.set(t,e)},t.prototype.hasDictionary=function(t){return!!t&&this.dictionaries.has(t)},t.prototype.getLanguage=function(){return this.language},t.prototype.getLanguages=function(){return Array.from(this.dictionaries.keys())},t.prototype.setLanguage=function(t){this.language=t&&this.hasDictionary(t)?t:this.hasDictionary(navigator.language)?navigator.language:void 0},t.prototype.translate=function(t,e,n){if(!(n=n||this.language))return t;var r=this.dictionaries.get(n);if(!r)return t;var o=r.translate(t,e);return void 0===o?t:o},t}(),_=function(t){function n(e){var n=t.call(this)||this;return n.addDictionary("cs",new B),n.addDictionary("en",new V),n.setLanguage(e),n}return e(n,t),n}(Q);export{h as ArrayUtil,f as AsyncUtil,_ as BasicLocalization,p as ByteUtil,i as CacheAsync,P as CancellablePromise,B as CzechBasicDictionary,d as DateUtil,H as DictionaryWithFallback,V as EnglishBasicDictionary,w as EntityCachedClient,S as EntityClient,R as EntityClientWithStub,b as EventManager,s as HashCacheAsync,m as HashUtil,v as JsonUtil,u as Lazy,o as LazyAsync,Q as Localization,E as LookupClient,z as MemoryDictionary,y as NumberUtil,M as OAuthRestClient,U as OAuthSubject,A as OAuthTokenManager,a as ObjectUtil,g as PagingUtil,k as RestClient,O as RestClientWithOAuth,c as StringUtil,T as UrlUtil,r as UserAlertType,x as UserAlerts,C as Vector2};
2
2
  //# sourceMappingURL=index.esm.js.map