import * as i0 from '@angular/core';
import { Injectable, NgModule, Directive, ɵcreateInjector, InjectionToken, Optional, Inject, EventEmitter, Output, HostListener, Input, forwardRef } from '@angular/core';
import { format } from 'date-fns';
import { enUS } from 'date-fns/locale';
import { Subject, from, map, ReplaySubject, throttleTime, take, switchMap, BehaviorSubject, distinctUntilChanged, interval, takeUntil, timer, filter, delay, range, toArray, mergeAll, mergeWith, catchError, throwError } from 'rxjs';
import { mixinErrorState } from '@angular/material/core';
import { CommonModule, DatePipe } from '@angular/common';
import { ConnectionPositionPair } from '@angular/cdk/overlay';
import { NG_VALIDATORS, FormsModule } from '@angular/forms';

/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */
/**
 * Global property bag for copy paste
 */
class DejaClipboardService {
    constructor() {
        this.clipboard = {};
    }
    get(key) {
        return this.clipboard[key];
    }
    set(key, value) {
        this.clipboard[key] = value;
    }
    isAvailable(key) {
        return !!this.clipboard[key];
    }
    clear() {
        this.clipboard = {};
    }
}
DejaClipboardService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: DejaClipboardService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
DejaClipboardService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: DejaClipboardService, providedIn: 'root' });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: DejaClipboardService, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root'
                }]
        }] });

/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */
class DejaClipboardModule {
}
DejaClipboardModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: DejaClipboardModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
DejaClipboardModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: DejaClipboardModule });
DejaClipboardModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: DejaClipboardModule });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: DejaClipboardModule, decorators: [{
            type: NgModule
        }] });

/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */
// default Locale in date-fns is en-US: https://github.com/date-fns/date-fns/blob/master/src/format/index.js
let globalLocale = enUS;
const setLocale = (locale) => {
    globalLocale = locale;
};
const formatWithLocale = (date, dateFormat) => format(date, dateFormat, { locale: globalLocale });

/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */

/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */
// eslint-disable-next-line @angular-eslint/directive-class-suffix
class Destroy {
    constructor() {
        this.destroyed$ = new Subject();
    }
    ngOnDestroy() {
        if (this.destroyed$.closed) {
            // Observable already unsubscribed
            // eslint-disable-next-line no-debugger
            debugger;
            return;
        }
        this.destroyed$.next();
        this.destroyed$.unsubscribe();
    }
}
Destroy.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: Destroy, deps: [], target: i0.ɵɵFactoryTarget.Directive });
Destroy.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.1", type: Destroy, ngImport: i0 });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: Destroy, decorators: [{
            type: Directive
        }] });

/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */

/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */
/**
 * Remove diacritics (accent and other marks) on characters, and dissociate double characters.
 * Based on the character map of http://lehelk.com/2011/05/06/script-to-remove-diacritics/
 * but per-character walk (improved performance).
 *
 * Licensed under WTFPL v2 http://sam.zoy.org/wtfpl/COPYING
 */
class DiacriticService {
    remove(str) {
        const newStr = [];
        let alter = false;
        const length = str?.length || 0;
        try {
            // eslint-disable-next-line no-loops/no-loops
            for (let i = 0; i < length; i++) {
                const c = str.charCodeAt(i);
                // eslint-disable-next-line @typescript-eslint/no-explicit-any
                const replacement = DiacriticService.MAP[c];
                if (replacement) {
                    newStr.push(replacement);
                    alter = true;
                }
                else {
                    newStr.push(str.charAt(i));
                }
            }
            if (alter) {
                str = newStr.join('');
            }
        }
        catch (e) {
            alert(e);
        }
        return str;
    }
}
// eslint-disable-next-line @typescript-eslint/naming-convention
DiacriticService.MAP = { 9398: 'A', 65313: 'A', 192: 'A', 193: 'A', 194: 'A', 7846: 'A', 7844: 'A', 7850: 'A', 7848: 'A', 195: 'A', 256: 'A', 258: 'A', 7856: 'A', 7854: 'A', 7860: 'A', 7858: 'A', 550: 'A', 480: 'A', 196: 'A', 478: 'A', 7842: 'A', 197: 'A', 506: 'A', 461: 'A', 512: 'A', 514: 'A', 7840: 'A', 7852: 'A', 7862: 'A', 7680: 'A', 260: 'A', 570: 'A', 11375: 'A', 42802: 'AA', 198: 'AE', 508: 'AE', 482: 'AE', 42804: 'AO', 42806: 'AU', 42808: 'AV', 42810: 'AV', 42812: 'AY', 9399: 'B', 65314: 'B', 7682: 'B', 7684: 'B', 7686: 'B', 579: 'B', 386: 'B', 385: 'B', 9400: 'C', 65315: 'C', 262: 'C', 264: 'C', 266: 'C', 268: 'C', 199: 'C', 7688: 'C', 391: 'C', 571: 'C', 42814: 'C', 9401: 'D', 65316: 'D', 7690: 'D', 270: 'D', 7692: 'D', 7696: 'D', 7698: 'D', 7694: 'D', 272: 'D', 395: 'D', 394: 'D', 393: 'D', 42873: 'D', 497: 'DZ', 452: 'DZ', 498: 'Dz', 453: 'Dz', 9402: 'E', 65317: 'E', 200: 'E', 201: 'E', 202: 'E', 7872: 'E', 7870: 'E', 7876: 'E', 7874: 'E', 7868: 'E', 274: 'E', 7700: 'E', 7702: 'E', 276: 'E', 278: 'E', 203: 'E', 7866: 'E', 282: 'E', 516: 'E', 518: 'E', 7864: 'E', 7878: 'E', 552: 'E', 7708: 'E', 280: 'E', 7704: 'E', 7706: 'E', 400: 'E', 398: 'E', 9403: 'F', 65318: 'F', 7710: 'F', 401: 'F', 42875: 'F', 9404: 'G', 65319: 'G', 500: 'G', 284: 'G', 7712: 'G', 286: 'G', 288: 'G', 486: 'G', 290: 'G', 484: 'G', 403: 'G', 42912: 'G', 42877: 'G', 42878: 'G', 9405: 'H', 65320: 'H', 292: 'H', 7714: 'H', 7718: 'H', 542: 'H', 7716: 'H', 7720: 'H', 7722: 'H', 294: 'H', 11367: 'H', 11381: 'H', 42893: 'H', 9406: 'I', 65321: 'I', 204: 'I', 205: 'I', 206: 'I', 296: 'I', 298: 'I', 300: 'I', 304: 'I', 207: 'I', 7726: 'I', 7880: 'I', 463: 'I', 520: 'I', 522: 'I', 7882: 'I', 302: 'I', 7724: 'I', 407: 'I', 9407: 'J', 65322: 'J', 308: 'J', 584: 'J', 9408: 'K', 65323: 'K', 7728: 'K', 488: 'K', 7730: 'K', 310: 'K', 7732: 'K', 408: 'K', 11369: 'K', 42816: 'K', 42818: 'K', 42820: 'K', 42914: 'K', 9409: 'L', 65324: 'L', 319: 'L', 313: 'L', 317: 'L', 7734: 'L', 7736: 'L', 315: 'L', 7740: 'L', 7738: 'L', 321: 'L', 573: 'L', 11362: 'L', 11360: 'L', 42824: 'L', 42822: 'L', 42880: 'L', 455: 'LJ', 456: 'Lj', 9410: 'M', 65325: 'M', 7742: 'M', 7744: 'M', 7746: 'M', 11374: 'M', 412: 'M', 9411: 'N', 65326: 'N', 504: 'N', 323: 'N', 209: 'N', 7748: 'N', 327: 'N', 7750: 'N', 325: 'N', 7754: 'N', 7752: 'N', 544: 'N', 413: 'N', 42896: 'N', 42916: 'N', 458: 'NJ', 459: 'Nj', 9412: 'O', 65327: 'O', 210: 'O', 211: 'O', 212: 'O', 7890: 'O', 7888: 'O', 7894: 'O', 7892: 'O', 213: 'O', 7756: 'O', 556: 'O', 7758: 'O', 332: 'O', 7760: 'O', 7762: 'O', 334: 'O', 558: 'O', 560: 'O', 214: 'O', 554: 'O', 7886: 'O', 336: 'O', 465: 'O', 524: 'O', 526: 'O', 416: 'O', 7900: 'O', 7898: 'O', 7904: 'O', 7902: 'O', 7906: 'O', 7884: 'O', 7896: 'O', 490: 'O', 492: 'O', 216: 'O', 510: 'O', 390: 'O', 415: 'O', 42826: 'O', 42828: 'O', 338: 'OE', 418: 'OI', 42830: 'OO', 546: 'OU', 9413: 'P', 65328: 'P', 7764: 'P', 7766: 'P', 420: 'P', 11363: 'P', 42832: 'P', 42834: 'P', 42836: 'P', 9414: 'Q', 65329: 'Q', 42838: 'Q', 42840: 'Q', 586: 'Q', 9415: 'R', 65330: 'R', 340: 'R', 7768: 'R', 344: 'R', 528: 'R', 530: 'R', 7770: 'R', 7772: 'R', 342: 'R', 7774: 'R', 588: 'R', 11364: 'R', 42842: 'R', 42918: 'R', 42882: 'R', 9416: 'S', 65331: 'S', 346: 'S', 7780: 'S', 348: 'S', 7776: 'S', 352: 'S', 7782: 'S', 7778: 'S', 7784: 'S', 536: 'S', 350: 'S', 11390: 'S', 42920: 'S', 42884: 'S', 7838: 'SS', 9417: 'T', 65332: 'T', 7786: 'T', 356: 'T', 7788: 'T', 538: 'T', 354: 'T', 7792: 'T', 7790: 'T', 358: 'T', 428: 'T', 430: 'T', 574: 'T', 42886: 'T', 42792: 'TZ', 9418: 'U', 65333: 'U', 217: 'U', 218: 'U', 219: 'U', 360: 'U', 7800: 'U', 362: 'U', 7802: 'U', 364: 'U', 220: 'U', 475: 'U', 471: 'U', 469: 'U', 473: 'U', 7910: 'U', 366: 'U', 368: 'U', 467: 'U', 532: 'U', 534: 'U', 431: 'U', 7914: 'U', 7912: 'U', 7918: 'U', 7916: 'U', 7920: 'U', 7908: 'U', 7794: 'U', 370: 'U', 7798: 'U', 7796: 'U', 580: 'U', 9419: 'V', 65334: 'V', 7804: 'V', 7806: 'V', 434: 'V', 42846: 'V', 581: 'V', 42848: 'VY', 9420: 'W', 65335: 'W', 7808: 'W', 7810: 'W', 372: 'W', 7814: 'W', 7812: 'W', 7816: 'W', 11378: 'W', 9421: 'X', 65336: 'X', 7818: 'X', 7820: 'X', 9422: 'Y', 65337: 'Y', 7922: 'Y', 221: 'Y', 374: 'Y', 7928: 'Y', 562: 'Y', 7822: 'Y', 376: 'Y', 7926: 'Y', 7924: 'Y', 435: 'Y', 590: 'Y', 7934: 'Y', 9423: 'Z', 65338: 'Z', 377: 'Z', 7824: 'Z', 379: 'Z', 381: 'Z', 7826: 'Z', 7828: 'Z', 437: 'Z', 548: 'Z', 11391: 'Z', 11371: 'Z', 42850: 'Z', 9424: 'a', 65345: 'a', 7834: 'a', 224: 'a', 225: 'a', 226: 'a', 7847: 'a', 7845: 'a', 7851: 'a', 7849: 'a', 227: 'a', 257: 'a', 259: 'a', 7857: 'a', 7855: 'a', 7861: 'a', 7859: 'a', 551: 'a', 481: 'a', 228: 'a', 479: 'a', 7843: 'a', 229: 'a', 507: 'a', 462: 'a', 513: 'a', 515: 'a', 7841: 'a', 7853: 'a', 7863: 'a', 7681: 'a', 261: 'a', 11365: 'a', 592: 'a', 42803: 'aa', 230: 'ae', 509: 'ae', 483: 'ae', 42805: 'ao', 42807: 'au', 42809: 'av', 42811: 'av', 42813: 'ay', 9425: 'b', 65346: 'b', 7683: 'b', 7685: 'b', 7687: 'b', 384: 'b', 387: 'b', 595: 'b', 9426: 'c', 65347: 'c', 263: 'c', 265: 'c', 267: 'c', 269: 'c', 231: 'c', 7689: 'c', 392: 'c', 572: 'c', 42815: 'c', 8580: 'c', 9427: 'd', 65348: 'd', 7691: 'd', 271: 'd', 7693: 'd', 7697: 'd', 7699: 'd', 7695: 'd', 273: 'd', 396: 'd', 598: 'd', 599: 'd', 42874: 'd', 499: 'dz', 454: 'dz', 9428: 'e', 65349: 'e', 232: 'e', 233: 'e', 234: 'e', 7873: 'e', 7871: 'e', 7877: 'e', 7875: 'e', 7869: 'e', 275: 'e', 7701: 'e', 7703: 'e', 277: 'e', 279: 'e', 235: 'e', 7867: 'e', 283: 'e', 517: 'e', 519: 'e', 7865: 'e', 7879: 'e', 553: 'e', 7709: 'e', 281: 'e', 7705: 'e', 7707: 'e', 583: 'e', 603: 'e', 477: 'e', 9429: 'f', 65350: 'f', 7711: 'f', 402: 'f', 42876: 'f', 9430: 'g', 65351: 'g', 501: 'g', 285: 'g', 7713: 'g', 287: 'g', 289: 'g', 487: 'g', 291: 'g', 485: 'g', 608: 'g', 42913: 'g', 7545: 'g', 42879: 'g', 9431: 'h', 65352: 'h', 293: 'h', 7715: 'h', 7719: 'h', 543: 'h', 7717: 'h', 7721: 'h', 7723: 'h', 7830: 'h', 295: 'h', 11368: 'h', 11382: 'h', 613: 'h', 405: 'hv', 9432: 'i', 65353: 'i', 236: 'i', 237: 'i', 238: 'i', 297: 'i', 299: 'i', 301: 'i', 239: 'i', 7727: 'i', 7881: 'i', 464: 'i', 521: 'i', 523: 'i', 7883: 'i', 303: 'i', 7725: 'i', 616: 'i', 305: 'i', 9433: 'j', 65354: 'j', 309: 'j', 496: 'j', 585: 'j', 9434: 'k', 65355: 'k', 7729: 'k', 489: 'k', 7731: 'k', 311: 'k', 7733: 'k', 409: 'k', 11370: 'k', 42817: 'k', 42819: 'k', 42821: 'k', 42915: 'k', 9435: 'l', 65356: 'l', 320: 'l', 314: 'l', 318: 'l', 7735: 'l', 7737: 'l', 316: 'l', 7741: 'l', 7739: 'l', 322: 'l', 410: 'l', 619: 'l', 11361: 'l', 42825: 'l', 42881: 'l', 42823: 'l', 457: 'lj', 9436: 'm', 65357: 'm', 7743: 'm', 7745: 'm', 7747: 'm', 625: 'm', 623: 'm', 9437: 'n', 65358: 'n', 505: 'n', 324: 'n', 241: 'n', 7749: 'n', 328: 'n', 7751: 'n', 326: 'n', 7755: 'n', 7753: 'n', 414: 'n', 626: 'n', 329: 'n', 42897: 'n', 42917: 'n', 460: 'nj', 9438: 'o', 65359: 'o', 242: 'o', 243: 'o', 244: 'o', 7891: 'o', 7889: 'o', 7895: 'o', 7893: 'o', 245: 'o', 7757: 'o', 557: 'o', 7759: 'o', 333: 'o', 7761: 'o', 7763: 'o', 335: 'o', 559: 'o', 561: 'o', 246: 'o', 555: 'o', 7887: 'o', 337: 'o', 466: 'o', 525: 'o', 527: 'o', 417: 'o', 7901: 'o', 7899: 'o', 7905: 'o', 7903: 'o', 7907: 'o', 7885: 'o', 7897: 'o', 491: 'o', 493: 'o', 248: 'o', 511: 'o', 596: 'o', 42827: 'o', 42829: 'o', 629: 'o', 339: 'oe', 630: 'oe', 419: 'oi', 547: 'ou', 42831: 'oo', 9439: 'p', 65360: 'p', 7765: 'p', 7767: 'p', 421: 'p', 7549: 'p', 42833: 'p', 42835: 'p', 42837: 'p', 9440: 'q', 65361: 'q', 587: 'q', 42839: 'q', 42841: 'q', 9441: 'r', 65362: 'r', 341: 'r', 7769: 'r', 345: 'r', 529: 'r', 531: 'r', 7771: 'r', 7773: 'r', 343: 'r', 7775: 'r', 589: 'r', 637: 'r', 42843: 'r', 42919: 'r', 42883: 'r', 9442: 's', 65363: 's', 347: 's', 7781: 's', 349: 's', 7777: 's', 353: 's', 7783: 's', 7779: 's', 7785: 's', 537: 's', 351: 's', 575: 's', 42921: 's', 42885: 's', 383: 's', 7835: 's', 223: 'ss', 9443: 't', 65364: 't', 7787: 't', 7831: 't', 357: 't', 7789: 't', 539: 't', 355: 't', 7793: 't', 7791: 't', 359: 't', 429: 't', 648: 't', 11366: 't', 42887: 't', 42793: 'tz', 9444: 'u', 65365: 'u', 249: 'u', 250: 'u', 251: 'u', 361: 'u', 7801: 'u', 363: 'u', 7803: 'u', 365: 'u', 252: 'u', 476: 'u', 472: 'u', 470: 'u', 474: 'u', 7911: 'u', 367: 'u', 369: 'u', 468: 'u', 533: 'u', 535: 'u', 432: 'u', 7915: 'u', 7913: 'u', 7919: 'u', 7917: 'u', 7921: 'u', 7909: 'u', 7795: 'u', 371: 'u', 7799: 'u', 7797: 'u', 649: 'u', 9445: 'v', 65366: 'v', 7805: 'v', 7807: 'v', 651: 'v', 42847: 'v', 652: 'v', 42849: 'vy', 9446: 'w', 65367: 'w', 7809: 'w', 7811: 'w', 373: 'w', 7815: 'w', 7813: 'w', 7832: 'w', 7817: 'w', 11379: 'w', 9447: 'x', 65368: 'x', 7819: 'x', 7821: 'x', 9448: 'y', 65369: 'y', 7923: 'y', 253: 'y', 375: 'y', 7929: 'y', 563: 'y', 7823: 'y', 255: 'y', 7927: 'y', 7833: 'y', 7925: 'y', 436: 'y', 591: 'y', 7935: 'y', 9449: 'z', 65370: 'z', 378: 'z', 7825: 'z', 380: 'z', 382: 'z', 7827: 'z', 7829: 'z', 438: 'z', 549: 'z', 576: 'z', 11372: 'z', 42851: 'z', 65296: '0', 8320: '0', 9450: '0', 8304: '0', 185: '1', 9332: '1', 8321: '1', 10102: '1', 9461: '1', 9352: '1', 9312: '1', 65297: '1', 178: '2', 10103: '2', 9333: '2', 65298: '2', 8322: '2', 9462: '2', 9313: '2', 9353: '2', 179: '3', 65299: '3', 9354: '3', 9334: '3', 8323: '3', 10104: '3', 9463: '3', 9314: '3', 9464: '4', 9315: '4', 9355: '4', 65300: '4', 8308: '4', 8324: '4', 10105: '4', 9335: '4', 9356: '5', 8325: '5', 9465: '5', 9336: '5', 10106: '5', 9316: '5', 65301: '5', 8309: '5', 9337: '6', 8310: '6', 65302: '6', 10107: '6', 8326: '6', 9317: '6', 9466: '6', 9357: '6', 65303: '7', 8311: '7', 10108: '7', 9467: '7', 9358: '7', 8327: '7', 9338: '7', 9318: '7', 9319: '8', 9359: '8', 9468: '8', 9339: '8', 8312: '8', 65304: '8', 10109: '8', 8328: '8', 9469: '9', 65305: '9', 9360: '9', 10110: '9', 9340: '9', 8329: '9', 9320: '9', 8313: '9' };
DiacriticService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: DiacriticService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
DiacriticService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: DiacriticService, providedIn: 'root' });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: DiacriticService, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root'
                }]
        }] });

/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */

/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */

/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */

/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */
class MatInputBase {
    constructor(_defaultErrorStateMatcher, _parentForm, _parentFormGroup, ngControl) {
        this._defaultErrorStateMatcher = _defaultErrorStateMatcher;
        this._parentForm = _parentForm;
        this._parentFormGroup = _parentFormGroup;
        this.ngControl = ngControl;
    }
}
const _MatInputMixinBase = mixinErrorState(MatInputBase);

/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */

/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */
/** Classe de génération d'un guid. */
class IdService {
    /** Renvoie le guid sous format string. */
    generate() {
        let d = new Date().getTime();
        if (window.performance !== undefined) {
            if (typeof window.performance.now === 'function') {
                d += performance.now();
            }
        }
        return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
            // eslint-disable-next-line no-bitwise
            const r = (d + Math.random() * 16) % 16 | 0;
            d = Math.floor(d / 16);
            // eslint-disable-next-line no-bitwise
            return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);
        });
    }
}
IdService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: IdService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
IdService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: IdService, providedIn: 'root' });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: IdService, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root'
                }]
        }] });

/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */

class AbstractLazyModule {
    constructor(componentType) {
        this.componentType = componentType;
    }
}
class LazyLoaderService {
    constructor(injector) {
        this.injector = injector;
    }
    loadModule$(path) {
        return from(path).pipe(map(elementModuleOrFactory => {
            const injector = ɵcreateInjector(elementModuleOrFactory, this.injector);
            return {
                injector,
                module: injector.get(elementModuleOrFactory)
            };
        }));
    }
}
LazyLoaderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: LazyLoaderService, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
LazyLoaderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: LazyLoaderService, providedIn: 'root' });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: LazyLoaderService, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root'
                }]
        }], ctorParameters: function () { return [{ type: i0.Injector }]; } });

/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */
class DialogService {
    constructor(lazyLoaderService, dialog, matDialogConfig) {
        this.lazyLoaderService = lazyLoaderService;
        this.dialog = dialog;
        this.openDialogSub$ = new ReplaySubject(1);
        this.dialogResponse$ = this.openDialogSub$.pipe(throttleTime(10), take(1), switchMap(dialogConfig => this.lazyLoaderService.loadModule$(this.getModule()).pipe(switchMap(moduleInfos => {
            const config = { ...matDialogConfig || {}, ...dialogConfig };
            config.minWidth = config.minWidth || '400px';
            // injector is private in MatDialog
            // eslint-disable-next-line @typescript-eslint/dot-notation
            this.dialog['_injector'] = moduleInfos.injector;
            this.dialogRef = this.dialog.open(moduleInfos.module.componentType, config);
            return this.dialogRef.afterClosed();
        }))));
    }
    openDialog$(dialogData, dialogConfig) {
        dialogConfig = dialogConfig || {};
        dialogConfig.data = dialogData || {};
        this.openDialogSub$.next(dialogConfig);
        return this.dialogResponse$;
    }
    closeDialog() {
        this.dialogRef.close();
    }
}

/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */

/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */
// eslint-disable-next-line @typescript-eslint/naming-convention
const MEDIA_QUERY_DEFINITIONS = new InjectionToken('MEDIA_QUERY_DEFINITIONS');
// eslint-disable-next-line @typescript-eslint/naming-convention
const DEFAULT_MEDIA_QUERY_DEFINITIONS = [
    {
        alias: 'xs',
        mediaQuery: '(min-width: 0px) and (max-width: 599px)'
    },
    {
        alias: 'gt-xs',
        overlapping: true,
        mediaQuery: '(min-width: 600px)'
    },
    {
        alias: 'lt-sm',
        overlapping: true,
        mediaQuery: '(max-width: 599px)'
    },
    {
        alias: 'sm',
        mediaQuery: '(min-width: 600px) and (max-width: 959px)'
    },
    {
        alias: 'gt-sm',
        overlapping: true,
        mediaQuery: '(min-width: 960px)'
    },
    {
        alias: 'lt-md',
        overlapping: true,
        mediaQuery: '(max-width: 959px)'
    },
    {
        alias: 'md',
        mediaQuery: '(min-width: 960px) and (max-width: 1279px)'
    },
    {
        alias: 'gt-md',
        overlapping: true,
        mediaQuery: '(min-width: 1280px)'
    },
    {
        alias: 'lt-lg',
        overlapping: true,
        mediaQuery: '(max-width: 1279px)'
    },
    {
        alias: 'lg',
        mediaQuery: '(min-width: 1280px) and (max-width: 1919px)'
    },
    {
        alias: 'gt-lg',
        overlapping: true,
        mediaQuery: '(min-width: 1920px)'
    },
    {
        alias: 'lt-xl',
        overlapping: true,
        mediaQuery: '(max-width: 1920px)'
    },
    {
        alias: 'xl',
        mediaQuery: '(min-width: 1920px) and (max-width: 5000px)'
    }
];
// eslint-disable-next-line @typescript-eslint/naming-convention
const SIMPLIFIED_MEDIA_QUERY_DEFINITIONS = [
    {
        alias: 'xs',
        mediaQuery: '(max-width: 599px)'
    }, {
        alias: 'sm',
        mediaQuery: '(min-width: 600px) and (max-width: 959px)'
    }, {
        alias: 'md',
        mediaQuery: '(min-width: 860px) and (max-width: 1279px)'
    }, {
        alias: 'lg',
        mediaQuery: '(min-width: 1280px)'
    }
];
class MediaService {
    constructor(zone, mediaDefinitions) {
        this.zone = zone;
        this.mql = {};
        if (!mediaDefinitions) {
            mediaDefinitions = SIMPLIFIED_MEDIA_QUERY_DEFINITIONS;
        }
        mediaDefinitions.forEach(mediaDefinition => {
            const { alias, mediaQuery } = mediaDefinition;
            this.mql[alias] = window.matchMedia(mediaQuery);
            // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
            this.mql[alias].addEventListener('change', this.onMqlEvent.bind(this, alias));
            if (this.mql[alias].matches) {
                this.mediaChanged$ = new BehaviorSubject(alias);
            }
        });
        this.isMobile$ = this.mediaChanged$.pipe(map(alias => alias === 'xs' || alias === 'sm'), distinctUntilChanged());
    }
    ngOnDestroy() {
        Object.keys(this.mql).forEach(alias => {
            // eslint-disable-next-line @typescript-eslint/unbound-method
            this.mql[alias].removeEventListener('change', this.onMqlEvent);
            delete this.mql[alias];
        });
    }
    onMqlEvent(alias, event) {
        this.zone.run(() => {
            if (event.matches) {
                this.mediaChanged$.next(alias);
            }
        });
    }
}
MediaService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: MediaService, deps: [{ token: i0.NgZone }, { token: MEDIA_QUERY_DEFINITIONS, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
MediaService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: MediaService });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: MediaService, decorators: [{
            type: Injectable
        }], ctorParameters: function () { return [{ type: i0.NgZone }, { type: undefined, decorators: [{
                    type: Optional
                }, {
                    type: Inject,
                    args: [MEDIA_QUERY_DEFINITIONS]
                }] }]; } });

/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */
class MediaModule {
}
MediaModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: MediaModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
MediaModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: MediaModule, imports: [CommonModule] });
MediaModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: MediaModule, providers: [MediaService], imports: [[CommonModule]] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: MediaModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [CommonModule],
                    providers: [MediaService]
                }]
        }] });

/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */

/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */

/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */
class DejaConnectionPositionPair extends ConnectionPositionPair {
    static parse(value) {
        const values = value.trim().split(',');
        const positions = [];
        values.forEach(pos => {
            const poss = pos.trim().split(' ');
            if (poss.length !== 4) {
                throw new Error('Invalid positions property for DejaMenuComponent. String entry must be of type \'positions="start top end bottom"\'');
            }
            const originPosition = {
                originX: poss[0],
                originY: poss[1]
            };
            const overlayPosition = {
                overlayX: poss[2],
                overlayY: poss[3]
            };
            positions.push(new DejaConnectionPositionPair(originPosition, overlayPosition));
        });
        return positions;
    }
}
// eslint-disable-next-line @typescript-eslint/naming-convention
DejaConnectionPositionPair.default = DejaConnectionPositionPair.parse('start bottom start top,start top start bottom,end bottom end top,end top end bottom');

/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */

/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */
class DejaResizeListenerDirective {
    constructor(elementRef) {
        this.elementRef = elementRef;
        this.sizeChanged = new EventEmitter();
        this.element = elementRef.nativeElement;
        this.resizeSensor = document.createElement('div');
        this.resizeSensor.dir = 'ltr';
        this.resizeSensor.className = 'resize-sensor';
        const style = 'position: absolute; left: -10px; top: -10px; right: 0; bottom: 0; overflow: hidden; z-index: -1; visibility: hidden;';
        const styleChild = 'position: absolute; left: 0; top: 0; transition: 0s;';
        this.resizeSensor.style.cssText = style;
        this.resizeSensor.innerHTML =
            `<div class="resize-sensor-expand" style="${style}">
                <div style="${styleChild}"></div>
            </div>
            <div class="resize-sensor-shrink" style="${style}">
                <div style="${styleChild}width: 200%; height: 200%"></div>
            </div>`;
        this.element.appendChild(this.resizeSensor);
        const expand = this.resizeSensor.children[0];
        const expandChild = expand.children[0];
        const shrink = this.resizeSensor.children[1];
        const position = window.getComputedStyle(this.element).getPropertyPriority('position');
        if ('absolute' !== position && 'relative' !== position && 'fixed' !== position) {
            this.element.style.position = 'relative';
        }
        const getElementSize = (e) => {
            if (!e.getBoundingClientRect) {
                return {
                    width: e.offsetWidth,
                    height: e.offsetHeight
                };
            }
            const rect = e.getBoundingClientRect();
            return {
                width: Math.round(rect.width),
                height: Math.round(rect.height)
            };
        };
        let rafId;
        const size = getElementSize(this.element);
        let lastWidth = size.width;
        let lastHeight = size.height;
        const reset = () => {
            // set display to block, necessary otherwise hidden elements won't ever work
            const invisible = this.element.offsetWidth === 0 && this.element.offsetHeight === 0;
            const saveDisplay = invisible && this.element.style.display;
            if (invisible) {
                this.element.style.display = 'block';
            }
            expandChild.style.width = expandChild.style.height = '100000px';
            expand.scrollLeft = expand.scrollTop = shrink.scrollLeft = shrink.scrollTop = 100000;
            if (invisible) {
                this.element.style.display = saveDisplay;
            }
        };
        const onScroll = () => {
            const s = getElementSize(this.element);
            const newWidth = s.width;
            const newHeight = s.height;
            const onResized = () => {
                rafId = 0;
                if (newWidth === lastWidth && newHeight === lastHeight) {
                    return;
                }
                lastWidth = newWidth;
                lastHeight = newHeight;
                this.sizeChanged.emit();
            };
            if ((newWidth !== lastWidth || newHeight !== lastHeight) && !rafId) {
                rafId = requestAnimationFrame(onResized);
            }
            reset();
        };
        expand.addEventListener('scroll', onScroll);
        shrink.addEventListener('scroll', onScroll);
        // Fix for custom Elements
        requestAnimationFrame(reset);
    }
    ngOnDestroy() {
        if (this.resizeSensor) {
            if (this.element.contains(this.resizeSensor)) {
                this.element.removeChild(this.resizeSensor);
            }
            delete this.resizeSensor;
        }
    }
}
DejaResizeListenerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: DejaResizeListenerDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
DejaResizeListenerDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.1", type: DejaResizeListenerDirective, selector: "[resize-listener]", outputs: { sizeChanged: "sizeChanged" }, ngImport: i0 });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: DejaResizeListenerDirective, decorators: [{
            type: Directive,
            args: [{
                    selector: '[resize-listener]'
                }]
        }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { sizeChanged: [{
                type: Output
            }] } });

/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */
class ResizeListenerModule {
}
ResizeListenerModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: ResizeListenerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
ResizeListenerModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: ResizeListenerModule, declarations: [DejaResizeListenerDirective], exports: [DejaResizeListenerDirective] });
ResizeListenerModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: ResizeListenerModule });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: ResizeListenerModule, decorators: [{
            type: NgModule,
            args: [{
                    declarations: [
                        DejaResizeListenerDirective
                    ],
                    exports: [
                        DejaResizeListenerDirective
                    ]
                }]
        }] });

/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */
const defaults = {
    width: 'auto',
    height: '100%',
    size: '7px',
    color: '#000',
    position: 'right',
    distance: '1px',
    start: 'top',
    opacity: 0.4,
    transition: 0.3,
    alwaysVisible: false,
    disableFadeOut: false,
    railVisible: false,
    railColor: '#333',
    railOpacity: 0.2,
    railClass: 'slimScrollRail',
    barClass: 'slimScrollBar',
    wrapperClass: 'slimScrollDiv',
    allowPageScroll: false,
    wheelStep: 20,
    touchScrollStep: 200,
    borderRadius: '7px',
    railBorderRadius: '7px',
    scrollTo: 0,
    autoScrollToBottom: false,
    maxHeightBeforeEnable: undefined
};
class DejaSlimScrollDirective extends Destroy {
    constructor(rendererFactory, elementRef) {
        super();
        this._minBarHeight = 30;
        this._releaseScroll = false;
        this.trackPanelHeightChanged = () => {
            this._previousHeight = this._me.scrollHeight;
            interval(1000).pipe(takeUntil(this.destroyed$)).subscribe(() => {
                if (this._previousHeight !== this._me.scrollHeight) {
                    this._previousHeight = this._me.scrollHeight;
                    this.init();
                    if (this._options.autoScrollToBottom) {
                        this._renderer.setStyle(this._bar, 'top', `${this._me.offsetHeight - this._bar.offsetHeight}px`);
                        this.scrollContent(0, true);
                    }
                }
            });
        };
        this._renderer = rendererFactory.createRenderer(null, null);
        this._me = elementRef.nativeElement;
        this._options = { ...defaults };
        /* eslint-disable @typescript-eslint/no-unsafe-assignment */
        this.showBar = this.showBar.bind(this);
        this.hideBar = this.hideBar.bind(this);
        this.onWheel = this.onWheel.bind(this);
        this.barMouseMove = this.barMouseMove.bind(this);
        this.barMouseUp = this.barMouseUp.bind(this);
        this.barMouseDown = this.barMouseDown.bind(this);
        this.railMouseDown = this.railMouseDown.bind(this);
        /* eslint-enable @typescript-eslint/no-unsafe-assignment */
    }
    onResize() {
        this.init();
    }
    ngOnInit() {
        this.init();
    }
    ngOnDestroy() {
        super.ngOnDestroy();
        if (window.removeEventListener) {
            window.removeEventListener('DOMMouseScroll', this.onWheel);
            window.removeEventListener('mousewheel', this.onWheel);
        }
        else {
            document.removeEventListener('mousewheel', this.onWheel);
        }
        document.removeEventListener('mousemove', this.barMouseMove, false);
        document.removeEventListener('mouseup', this.barMouseUp, false);
    }
    set width(value) {
        this._options.width = value || defaults.width;
    }
    set height(value) {
        this._options.height = value || defaults.height;
    }
    set size(value) {
        this._options.size = value || defaults.size;
    }
    set color(value) {
        this._options.color = value || defaults.color;
    }
    set position(value) {
        this._options.position = value || defaults.position;
    }
    set distance(value) {
        this._options.distance = value || defaults.distance;
    }
    set start(value) {
        this._options.start = value || defaults.start;
    }
    set opacity(value) {
        this._options.opacity = value || defaults.opacity;
    }
    set transition(value) {
        this._options.transition = value || defaults.transition;
    }
    set alwaysVisible(value) {
        this._options.alwaysVisible = value || defaults.alwaysVisible;
    }
    set disableFadeOut(value) {
        this._options.disableFadeOut = value || defaults.disableFadeOut;
    }
    set railVisible(value) {
        this._options.railVisible = value || defaults.railVisible;
    }
    set railColor(value) {
        this._options.railColor = value || defaults.railColor;
    }
    set railOpacity(value) {
        this._options.railOpacity = value || defaults.railOpacity;
    }
    set railClass(value) {
        this._options.railClass = value || defaults.railClass;
    }
    set barClass(value) {
        this._options.barClass = value || defaults.barClass;
    }
    set wrapperClass(value) {
        this._options.wrapperClass = value || defaults.wrapperClass;
    }
    set allowPageScroll(value) {
        this._options.allowPageScroll = value || defaults.allowPageScroll;
    }
    set wheelStep(value) {
        this._options.wheelStep = value || defaults.wheelStep;
    }
    set touchScrollStep(value) {
        this._options.touchScrollStep = value || defaults.touchScrollStep;
    }
    set borderRadius(value) {
        this._options.borderRadius = value || defaults.borderRadius;
    }
    set railBorderRadius(value) {
        this._options.railBorderRadius = value || defaults.railBorderRadius;
    }
    set scrollTo(value) {
        this._options.scrollTo = value || defaults.scrollTo;
    }
    set autoScrollToBottom(value) {
        this._options.autoScrollToBottom = value || defaults.autoScrollToBottom;
    }
    set maxHeightBeforeEnable(value) {
        this._options.maxHeightBeforeEnable = value || defaults.maxHeightBeforeEnable;
    }
    scrollContent(y, isWheel, isJump = false) {
        this._releaseScroll = false;
        let delta = y;
        const maxTop = this._me.offsetHeight - this._bar.offsetHeight;
        if (isWheel) {
            // move bar with mouse wheel
            delta = parseInt(this._bar.style.top, 10) + y * this._options.wheelStep / 100 * this._bar.offsetHeight;
            // move bar, make sure it doesn't go out
            delta = Math.min(Math.max(delta, 0), maxTop);
            // if scrolling down, make sure a fractional change to the
            // scroll position isn't rounded away when the scrollbar's CSS is set
            // this flooring of delta would happened automatically when
            // bar.css is set below, but we floor here for clarity
            delta = (y > 0) ? Math.ceil(delta) : Math.floor(delta);
            // scroll the scrollbar
            this._renderer.setStyle(this._bar, 'top', `${delta}px`);
        }
        // calculate actual scroll amount
        this._percentScroll = parseInt(this._bar.style.top, 10) / (this._me.offsetHeight - this._bar.offsetHeight);
        delta = this._percentScroll * (this._me.scrollHeight - this._me.offsetHeight);
        if (isJump) {
            delta = y;
            let offsetTop = delta / this._me.scrollHeight * this._me.offsetHeight;
            offsetTop = Math.min(Math.max(offsetTop, 0), maxTop);
            this._renderer.setStyle(this._bar, 'top', `${offsetTop}px`);
        }
        // scroll content
        this._me.scrollTop = delta;
        // ensure bar is visible
        this.showBar();
        // trigger hide when scroll is stopped
        this.hideBar();
    }
    init() {
        // ensure we are not binding it again
        if (this._bar && this._rail) {
            this.refresh();
        }
        else {
            this.setup();
        }
    }
    hasParentClass(e, className) {
        if (!e) {
            return false;
        }
        if (e.classList.contains(this._options.wrapperClass)) {
            return true;
        }
        return this.hasParentClass(e.parentElement, className);
    }
    onWheel(e) {
        // use mouse wheel only when mouse is over
        if (!this._isOverPanel) {
            return;
        }
        let delta = 0;
        if (e.deltaY) {
            delta = e.deltaY / 120;
        }
        if (e.detail) {
            delta = e.detail / 3;
        }
        const target = (e.target || e.currentTarget || e.relatedTarget);
        if (this.hasParentClass(target, this._options.wrapperClass)) {
            // scroll content
            this.scrollContent(delta, true);
        }
        // stop window scroll
        if (e.preventDefault && !this._releaseScroll) {
            e.preventDefault();
        }
        if (!this._releaseScroll) {
            e.returnValue = false;
        }
    }
    attachWheel(target) {
        if (window.addEventListener) {
            target.addEventListener('DOMMouseScroll', this.onWheel, false);
            target.addEventListener('mousewheel', this.onWheel, false);
        }
        else {
            document.addEventListener('mousewheel', this.onWheel, false);
        }
    }
    showBar() {
        // recalculate bar height
        this.getBarHeight();
        if (this._queueHide) {
            this._queueHide.unsubscribe();
            this._queueHide = null;
        }
        // when bar reached top or bottom
        // eslint-disable-next-line no-bitwise
        if (this._percentScroll === ~~this._percentScroll) {
            // release wheel
            this._releaseScroll = this._options.allowPageScroll;
        }
        else {
            this._releaseScroll = false;
        }
        // show only when required
        if (this._barHeight >= this._me.offsetHeight) {
            // allow window scroll
            this._releaseScroll = true;
            return;
        }
        this._renderer.setStyle(this._bar, 'opacity', this._options.opacity.toString());
        this._renderer.setStyle(this._rail, 'opacity', this._options.railOpacity.toString());
    }
    hideBar() {
        // only hide when options allow it
        if (!this._options.alwaysVisible && !(this._options.disableFadeOut && this._isOverPanel) && !this._isOverBar && !this._isDragg) {
            this._queueHide = timer(1000).pipe(take(1), filter(() => !this._queueHide), takeUntil(this.destroyed$)).subscribe(() => {
                this._renderer.setStyle(this._bar, 'opacity', '0');
                this._renderer.setStyle(this._rail, 'opacity', '0');
            });
        }
    }
    getBarHeight() {
        // calculate scrollbar height and make sure it is not too small
        this._barHeight = Math.max(this._me.offsetHeight / (this._me.scrollHeight === 0 ? 1 : this._me.scrollHeight) * this._me.offsetHeight, this._minBarHeight);
        this._renderer.setStyle(this._bar, 'height', `${this._barHeight}px`);
        // hide scrollbar if content is not long enough
        const display = this._barHeight === this._me.offsetHeight ? 'none' : 'block';
        this._renderer.setStyle(this._bar, 'display', display);
    }
    refresh() {
        this.getBarHeight();
        // Pass height: auto to an existing slimscroll object to force a resize after contents have changed
        if ('height' in this._options && this._options.height === 'auto') {
            this._renderer.setStyle(this._me.parentElement, 'height', 'auto');
            this._renderer.setStyle(this._me, 'height', 'auto');
            const height = this._me.parentElement.clientHeight;
            this._renderer.setStyle(this._me.parentElement, 'height', `${height}px`);
            this._renderer.setStyle(this._me, 'height', `${height}px`);
        }
        else if ('height' in this._options) {
            const h = this._options.height;
            this._renderer.setStyle(this._me.parentElement, 'height', h);
            this._renderer.setStyle(this._me, 'height', h);
        }
    }
    railMouseDown(event) {
        const clientRects = this._rail.getBoundingClientRect();
        const elementOffsetTop = clientRects.top + window.scrollY;
        const moveTo = event.pageY - elementOffsetTop - (this._barHeight / 2);
        const scrollTo = this._me.scrollHeight * (moveTo / clientRects.height);
        this._renderer.setStyle(this._bar, 'top', `${(moveTo >= 0 ? moveTo : 0)}px`);
        this.scrollContent(scrollTo, false, true);
    }
    barMouseMove(event) {
        const currTop = this._startBarTop + event.pageY - this._barMouseDownPageY;
        this._renderer.setStyle(this._bar, 'top', `${(currTop >= 0 ? currTop : 0)}px`);
        const position = this._bar.getClientRects()[0];
        if (position) {
            this.scrollContent(0, position.top > 0);
        }
    }
    barMouseUp() {
        this._isDragg = false;
        // return normal text selection
        const body = document.body;
        this._renderer.setStyle(body, '-webkit-user-select', 'initial');
        this._renderer.setStyle(body, '-moz-user-select', 'initial');
        this._renderer.setStyle(body, '-ms-user-select', 'initial');
        this._renderer.setStyle(body, 'user-select', 'initial');
        this.hideBar();
        document.removeEventListener('mousemove', this.barMouseMove, false);
        document.removeEventListener('mouseup', this.barMouseUp, false);
    }
    barMouseDown(e) {
        this._isDragg = true;
        // disable text selection
        const body = document.body;
        this._renderer.setStyle(body, '-webkit-user-select', 'none');
        this._renderer.setStyle(body, '-moz-user-select', 'none');
        this._renderer.setStyle(body, '-ms-user-select', 'none');
        this._renderer.setStyle(body, 'user-select', 'none');
        this._barMouseDownPageY = e.pageY;
        this._startBarTop = parseFloat(this._bar.style.top);
        document.addEventListener('mousemove', this.barMouseMove, false);
        document.addEventListener('mouseup', this.barMouseUp, false);
        return false;
    }
    setup() {
        // check whether it changes in content
        this.trackPanelHeightChanged();
        if (this._options.maxHeightBeforeEnable && this._me.scrollHeight <= this._options.maxHeightBeforeEnable) {
            return;
        }
        // wrap content
        const wrapper = document.createElement('div');
        this._renderer.addClass(wrapper, this._options.wrapperClass);
        this._renderer.setStyle(wrapper, 'position', 'relative');
        this._renderer.setStyle(wrapper, 'overflow', 'hidden');
        this._renderer.setStyle(wrapper, 'width', this._options.width);
        this._renderer.setStyle(wrapper, 'height', this._options.height);
        // update style for the div
        this._renderer.setStyle(this._me, 'overflow', 'hidden');
        this._renderer.setStyle(this._me, 'width', this._options.width);
        this._renderer.setStyle(this._me, 'height', this._options.height);
        // create scrollbar rail
        this._rail = document.createElement('div');
        this._renderer.addClass(this._rail, this._options.railClass);
        this._renderer.setStyle(this._rail, 'width', this._options.size);
        this._renderer.setStyle(this._rail, 'height', '100%');
        this._renderer.setStyle(this._rail, 'position', 'absolute');
        this._renderer.setStyle(this._rail, 'top', '0');
        this._renderer.setStyle(this._rail, 'display', this._options.railVisible ? 'block' : 'none');
        this._renderer.setStyle(this._rail, 'border-radius', this._options.railBorderRadius);
        this._renderer.setStyle(this._rail, 'background', this._options.railColor);
        this._renderer.setStyle(this._rail, 'opacity', this._options.railOpacity.toString());
        this._renderer.setStyle(this._rail, 'transition', `opacity ${this._options.transition}s`);
        this._renderer.setStyle(this._rail, 'z-index', '90');
        // create scrollbar
        this._bar = document.createElement('div');
        this._renderer.addClass(this._bar, this._options.barClass);
        this._renderer.setStyle(this._bar, 'background', this._options.color);
        this._renderer.setStyle(this._bar, 'width', this._options.size);
        this._renderer.setStyle(this._bar, 'position', 'absolute');
        this._renderer.setStyle(this._bar, 'top', '0');
        this._renderer.setStyle(this._bar, 'opacity', this._options.opacity.toString());
        this._renderer.setStyle(this._bar, 'transition', `opacity ${this._options.transition}s`);
        this._renderer.setStyle(this._bar, 'display', this._options.alwaysVisible ? 'block' : 'none');
        this._renderer.setStyle(this._bar, 'border-radius', this._options.borderRadius);
        this._renderer.setStyle(this._bar, 'webkit-border-radius', this._options.borderRadius);
        this._renderer.setStyle(this._bar, 'moz-border-radius', this._options.borderRadius);
        this._renderer.setStyle(this._bar, 'z-index', '99');
        // set position
        if (this._options.position === 'right') {
            this._renderer.setStyle(this._rail, 'right', this._options.distance);
            this._renderer.setStyle(this._bar, 'right', this._options.distance);
        }
        else {
            this._renderer.setStyle(this._rail, 'left', this._options.distance);
            this._renderer.setStyle(this._bar, 'left', this._options.distance);
        }
        // wrap it
        this._me.parentElement.insertBefore(wrapper, this._me);
        wrapper.appendChild(this._me);
        if (this._options.scrollTo > 0) {
            // jump to a static point
            this.scrollContent(this._options.scrollTo, false, true);
        }
        // append to parent div
        this._me.parentElement.appendChild(this._bar);
        this._me.parentElement.appendChild(this._rail);
        this._bar.addEventListener('mousedown', this.barMouseDown, false);
        // on rail over
        this._rail.addEventListener('mouseenter', this.showBar, false);
        this._rail.addEventListener('mouseleave', this.hideBar, false);
        this._rail.addEventListener('mousedown', this.railMouseDown, false);
        // on bar over
        this._bar.addEventListener('mouseenter', () => this._isOverBar = true, false);
        this._bar.addEventListener('mouseleave', () => this._isOverBar = false, false);
        // show on parent mouseover
        this._me.addEventListener('mouseenter', () => {
            this._isOverPanel = true;
            this.showBar();
            this.hideBar();
        }, false);
        this._me.addEventListener('mouseleave', () => {
            this._isOverPanel = false;
            this.hideBar();
        }, false);
        // support for mobile
        this._me.addEventListener('touchstart', e => {
            if (e.touches.length) {
                // record where touch started
                this._touchDif = e.touches[0].pageY;
            }
        }, false);
        this._me.addEventListener('touchmove', e => {
            // prevent scrolling the page if necessary
            if (!this._releaseScroll) {
                e.preventDefault();
            }
            if (e.touches.length) {
                // see how far user swiped
                const diff = (this._touchDif - e.touches[0].pageY) / this._options.touchScrollStep;
                // scroll content
                this.scrollContent(diff, true);
                this._touchDif = e.touches[0].pageY;
            }
        }, false);
        // set up initial height
        this.getBarHeight();
        // hide bar on init if alwaysVisible equal false
        this.hideBar();
        // check start position
        if (this._options.start === 'bottom') {
            // scroll content to bottom
            this._renderer.setStyle(this._bar, 'top', `${this._me.offsetHeight - this._bar.offsetHeight}px`);
            this.scrollContent(0, true);
        }
        // attach scroll events
        this.attachWheel(window);
    }
}
DejaSlimScrollDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: DejaSlimScrollDirective, deps: [{ token: i0.RendererFactory2 }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
DejaSlimScrollDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.1", type: DejaSlimScrollDirective, selector: "[slimScroll]", inputs: { width: "width", height: "height", size: "size", color: "color", position: "position", distance: "distance", start: "start", opacity: "opacity", transition: "transition", alwaysVisible: "alwaysVisible", disableFadeOut: "disableFadeOut", railVisible: "railVisible", railColor: "railColor", railOpacity: "railOpacity", railClass: "railClass", barClass: "barClass", wrapperClass: "wrapperClass", allowPageScroll: "allowPageScroll", wheelStep: "wheelStep", touchScrollStep: "touchScrollStep", borderRadius: "borderRadius", railBorderRadius: "railBorderRadius", scrollTo: "scrollTo", autoScrollToBottom: "autoScrollToBottom", maxHeightBeforeEnable: "maxHeightBeforeEnable" }, host: { listeners: { "window:resize": "onResize($event)" } }, usesInheritance: true, ngImport: i0 });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: DejaSlimScrollDirective, decorators: [{
            type: Directive,
            args: [{
                    selector: '[slimScroll]'
                }]
        }], ctorParameters: function () { return [{ type: i0.RendererFactory2 }, { type: i0.ElementRef }]; }, propDecorators: { onResize: [{
                type: HostListener,
                args: ['window:resize', ['$event']]
            }], width: [{
                type: Input
            }], height: [{
                type: Input
            }], size: [{
                type: Input
            }], color: [{
                type: Input
            }], position: [{
                type: Input
            }], distance: [{
                type: Input
            }], start: [{
                type: Input
            }], opacity: [{
                type: Input
            }], transition: [{
                type: Input
            }], alwaysVisible: [{
                type: Input
            }], disableFadeOut: [{
                type: Input
            }], railVisible: [{
                type: Input
            }], railColor: [{
                type: Input
            }], railOpacity: [{
                type: Input
            }], railClass: [{
                type: Input
            }], barClass: [{
                type: Input
            }], wrapperClass: [{
                type: Input
            }], allowPageScroll: [{
                type: Input
            }], wheelStep: [{
                type: Input
            }], touchScrollStep: [{
                type: Input
            }], borderRadius: [{
                type: Input
            }], railBorderRadius: [{
                type: Input
            }], scrollTo: [{
                type: Input
            }], autoScrollToBottom: [{
                type: Input
            }], maxHeightBeforeEnable: [{
                type: Input
            }] } });

/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */
class DejaSlimScrollModule {
}
DejaSlimScrollModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: DejaSlimScrollModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
DejaSlimScrollModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: DejaSlimScrollModule, declarations: [DejaSlimScrollDirective], exports: [DejaSlimScrollDirective] });
DejaSlimScrollModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: DejaSlimScrollModule });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: DejaSlimScrollModule, decorators: [{
            type: NgModule,
            args: [{
                    declarations: [
                        DejaSlimScrollDirective
                    ],
                    exports: [
                        DejaSlimScrollDirective
                    ]
                }]
        }] });

/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */
/**
 * Service to measure the theorical size of a text inside a container
 */
class DejaTextMetricsService extends Destroy {
    /**
     * Constructor
     * Add observable to wait for element to be set. And then take its properties to measure all ASCII char size.
     */
    constructor() {
        super();
        this.element$ = new Subject();
        this.charSize$ = new BehaviorSubject(null);
        this.element$.pipe(delay(1), take(1), switchMap(element => range(0, 255).pipe(map(i => this.getTextWidth(String.fromCharCode(i), element)), toArray())), takeUntil(this.destroyed$)).subscribe(charSize => this.charSize$.next(charSize));
    }
    /** Setter for base element */
    set metricsElem(elem) {
        this.element$.next(elem);
    }
    /**
     * Calcule la longeur (en pixels) d'une chaine de caractères
     *
     * @param text Le texte à mesurer
     * @param elem Le conteneur du texte
     *
     * @return la largeur du texte donné
     */
    getTextWidth(text, elem) {
        this.computedStyles = window.getComputedStyle(elem);
        const font = `${this.computedStyles.fontSize} ${this.computedStyles.fontFamily}`;
        const canvas = this.canvas || (this.canvas = document.createElement('canvas'));
        const context = canvas.getContext('2d');
        context.font = font;
        const metrics = context.measureText(text);
        return metrics.width * 1.1; // Correction for letter-spacing
    }
    /**
     * Retourne la largeur maximum d'un tableau de strings.
     *
     * @param texts les textes à comparer.
     * @param elem Le conteneur du texte
     *
     * @return la width du texte le plus long dans le tableau donné en param.
     */
    getTextMaxWidth(texts, elem) {
        let maxWidth = 0;
        texts.forEach(text => {
            const width = this.getTextWidth(text, elem);
            if (width > maxWidth) {
                maxWidth = width;
            }
        });
        return maxWidth;
    }
    /**
     * Mesure la heuteur théorique d'un texte contenu dans un conteneur d'une taille donnée.
     *
     * @param maxWidth taille du conteneur
     * @param text texte à mesurer
     *
     * @return Hauteur théorique du conteneur.
     */
    // eslint-disable-next-line rxjs/finnish
    getTextHeight(maxWidth, text) {
        return this.getNumberOfLines(maxWidth, text).pipe(map(numberOfLines => {
            const computedLineHeight = parseInt(this.computedStyles.lineHeight.replace('px', ''), 10);
            const lineHeight = (!isNaN(computedLineHeight)) ?
                computedLineHeight :
                Math.floor(parseInt(this.computedStyles.fontSize.replace('px', ''), 10) * 1.5);
            return lineHeight * +numberOfLines;
        }));
    }
    /**
     * Calcule le nombre de lignes qu'un texte va prendre en fonction de la largeur de son conteneur.
     *
     * @param maxWidth taille du conteneur
     * @param text texte à mesurer
     *
     * @return Nombre de lignes théoriques du conteneur.
     */
    // eslint-disable-next-line rxjs/finnish
    getNumberOfLines(maxWidth, text) {
        return this.charSize$.pipe(filter(charSize => charSize !== null), map(charSize => {
            let tmpSize = 0;
            let numberOfLines = 1;
            let averageCharSize = 0;
            if (text.length > 0) {
                const arr = text.split(' ');
                let spaceWidth = 0;
                const printableCharSizeArray = charSize.filter(size => size > 0);
                averageCharSize = printableCharSizeArray.reduce((a, b) => a + b, 0) / printableCharSizeArray.length;
                arr.forEach((txt) => {
                    let w = 0;
                    // eslint-disable-next-line no-loops/no-loops
                    for (let j = 0; j < txt.length; j++) {
                        const charCode = txt.charCodeAt(j);
                        // Si le caractère fait partie de la table ascii qu'on a calculé dans this.getAllCharsize() on incrémente la taille du mot de sa taille.
                        // Sinon, on ajoute la moyenne des tailles calculées (qui correspond théoriquement à la taille moyenne d'un caractère)
                        w += (charSize[charCode]) ? charSize[charCode] : averageCharSize;
                    }
                    if ((tmpSize + w + spaceWidth) > maxWidth) {
                        tmpSize = w;
                        numberOfLines++;
                    }
                    else {
                        tmpSize += w + spaceWidth;
                    }
                    if (spaceWidth === 0) {
                        spaceWidth = charSize[32];
                    }
                });
            }
            return numberOfLines;
        }));
    }
}

/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */
class DejaTextMetricsModule {
}
DejaTextMetricsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: DejaTextMetricsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
DejaTextMetricsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: DejaTextMetricsModule, imports: [CommonModule] });
DejaTextMetricsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: DejaTextMetricsModule, providers: [DejaTextMetricsService], imports: [[CommonModule]] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: DejaTextMetricsModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [CommonModule],
                    providers: [DejaTextMetricsService]
                }]
        }] });

/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */
class HtmlUtils {
    // eslint-disable-next-line @typescript-eslint/naming-convention
    static getEncodedURIComponent(jsonObjParameters) {
        if (jsonObjParameters) {
            const params = [];
            // eslint-disable-next-line no-loops/no-loops
            for (const p in jsonObjParameters) {
                // eslint-disable-next-line no-prototype-builtins
                if (jsonObjParameters.hasOwnProperty(p)) {
                    params.push(`${encodeURIComponent(p)}=${encodeURIComponent(jsonObjParameters[p])}`);
                }
            }
            return params.join('&');
        }
        return '';
    }
}

/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */
class RegExpUtils {
    /**
     * escape all regexp special chars.
     *
     * @param value
     * @returns the regexp special chars escaped string
     */
    static escapeRegExp(value) {
        if (!value) {
            return value;
        }
        return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
    }
}

/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */
/**
 * Date conversion for DPI standards
 */
class DateUtils {
    /**
     * Fromat a javascript date object to a 'yyyy-MM-dd HH:mm:ss' String Format
     * @param date
     */
    static formatSystem(date) {
        return DateUtils.DATE_PIPE.transform(date, DateUtils.SYSTEM_DATE_FORMAT);
    }
}
DateUtils.SYSTEM_DATE_FORMAT = 'yyyy-MM-dd HH:mm:ss';
DateUtils.DATE_PIPE = new DatePipe('fr-CH');

/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */

/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */
class DejaChildValidatorDirective {
    validate() {
        return this.parentControl?.errors;
    }
}
DejaChildValidatorDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: DejaChildValidatorDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
DejaChildValidatorDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.1", type: DejaChildValidatorDirective, selector: "[deja-child-validator]", providers: [
        {
            provide: NG_VALIDATORS,
            useExisting: forwardRef(() => DejaChildValidatorDirective),
            multi: true
        }
    ], ngImport: i0 });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: DejaChildValidatorDirective, decorators: [{
            type: Directive,
            args: [{
                    providers: [
                        {
                            provide: NG_VALIDATORS,
                            useExisting: forwardRef(() => DejaChildValidatorDirective),
                            multi: true
                        }
                    ],
                    selector: '[deja-child-validator]'
                }]
        }] });

/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */

/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */
// Attention, spécifier ici que les messages génériques. Créez votre propre objet pour les messages spécifiques à votre page
class ValidationMessages {
    constructor() {
        this.messages = {
            duplicatename: 'Ce nom existe déjà.',
            invalideDate: 'Date invalide',
            required: 'Ce champ est obligatoire.'
        };
    }
    getMessage(key) {
        return this.messages[key];
    }
}

/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */
class DejaChildValidatorModule {
}
DejaChildValidatorModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: DejaChildValidatorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
DejaChildValidatorModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: DejaChildValidatorModule, declarations: [DejaChildValidatorDirective], imports: [CommonModule,
        FormsModule], exports: [DejaChildValidatorDirective] });
DejaChildValidatorModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: DejaChildValidatorModule, imports: [[
            CommonModule,
            FormsModule
        ]] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: DejaChildValidatorModule, decorators: [{
            type: NgModule,
            args: [{
                    declarations: [
                        DejaChildValidatorDirective
                    ],
                    exports: [
                        DejaChildValidatorDirective
                    ],
                    imports: [
                        CommonModule,
                        FormsModule
                    ]
                }]
        }] });

/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */
/* eslint-disable @typescript-eslint/naming-convention */
var KeyCodes;
(function (KeyCodes) {
    KeyCodes["Backspace"] = "Backspace";
    KeyCodes["Tab"] = "Tab";
    KeyCodes["Enter"] = "Enter";
    KeyCodes["Shift"] = "Shift";
    KeyCodes["Ctrl"] = "Ctrl";
    KeyCodes["Alt"] = "Alt";
    KeyCodes["Pause"] = "Pause";
    KeyCodes["CapsLock"] = "CapsLock";
    KeyCodes["Escape"] = "Escape";
    KeyCodes["Space"] = "Space";
    KeyCodes["PageUp"] = "PageUp";
    KeyCodes["PageDown"] = "PageDown";
    KeyCodes["End"] = "End";
    KeyCodes["Home"] = "Home";
    KeyCodes["LeftArrow"] = "ArrowLeft";
    KeyCodes["UpArrow"] = "ArrowUp";
    KeyCodes["RightArrow"] = "ArrowRight";
    KeyCodes["DownArrow"] = "ArrowDown";
    KeyCodes["Insert"] = "Insert";
    KeyCodes["Delete"] = "Delete";
    KeyCodes["Key0"] = "Key0";
    KeyCodes["Key1"] = "Key1";
    KeyCodes["Key2"] = "Key2";
    KeyCodes["Key3"] = "Key3";
    KeyCodes["Key4"] = "Key4";
    KeyCodes["Key5"] = "Key5";
    KeyCodes["Key6"] = "Key6";
    KeyCodes["Key7"] = "Key7";
    KeyCodes["Key8"] = "Key8";
    KeyCodes["Key9"] = "Key9";
    KeyCodes["KeyA"] = "KeyA";
    KeyCodes["KeyB"] = "KeyB";
    KeyCodes["KeyC"] = "KeyC";
    KeyCodes["KeyD"] = "KeyD";
    KeyCodes["KeyE"] = "KeyE";
    KeyCodes["KeyF"] = "KeyF";
    KeyCodes["KeyG"] = "KeyG";
    KeyCodes["KeyH"] = "KeyH";
    KeyCodes["KeyI"] = "KeyI";
    KeyCodes["KeyJ"] = "KeyJ";
    KeyCodes["KeyK"] = "KeyK";
    KeyCodes["KeyL"] = "KeyL";
    KeyCodes["KeyM"] = "KeyM";
    KeyCodes["KeyN"] = "KeyN";
    KeyCodes["KeyO"] = "KeyO";
    KeyCodes["KeyP"] = "KeyP";
    KeyCodes["KeyQ"] = "KeyQ";
    KeyCodes["KeyR"] = "KeyR";
    KeyCodes["KeyS"] = "KeyS";
    KeyCodes["KeyT"] = "KeyT";
    KeyCodes["KeyU"] = "KeyU";
    KeyCodes["KeyV"] = "KeyV";
    KeyCodes["KeyW"] = "KeyW";
    KeyCodes["KeyX"] = "KeyX";
    KeyCodes["KeyY"] = "KeyY";
    KeyCodes["KeyZ"] = "KeyZ";
    KeyCodes["LeftMeta"] = "LeftMeta";
    KeyCodes["RightMeta"] = "RightMeta";
    KeyCodes["Select"] = "Select";
    KeyCodes["Numpad0"] = "Numpad0";
    KeyCodes["Numpad1"] = "Numpad1";
    KeyCodes["Numpad2"] = "Numpad2";
    KeyCodes["Numpad3"] = "Numpad3";
    KeyCodes["Numpad4"] = "Numpad4";
    KeyCodes["Numpad5"] = "Numpad5";
    KeyCodes["Numpad6"] = "Numpad6";
    KeyCodes["Numpad7"] = "Numpad7";
    KeyCodes["Numpad8"] = "Numpad8";
    KeyCodes["Numpad9"] = "Numpad9";
    KeyCodes["Multiply"] = "Multiply";
    KeyCodes["Add"] = "Add";
    KeyCodes["Subtract"] = "Subtract";
    KeyCodes["Decimal"] = "Decimal";
    KeyCodes["Divide"] = "Divide";
    KeyCodes["F1"] = "F1";
    KeyCodes["F2"] = "F2";
    KeyCodes["F3"] = "F3";
    KeyCodes["F4"] = "F4";
    KeyCodes["F5"] = "F5";
    KeyCodes["F6"] = "F6";
    KeyCodes["F7"] = "F7";
    KeyCodes["F8"] = "F8";
    KeyCodes["F9"] = "F9";
    KeyCodes["F10"] = "F10";
    KeyCodes["F11"] = "F11";
    KeyCodes["F12"] = "F12";
    KeyCodes["NumLock"] = "NumLock";
    KeyCodes["ScrollLock"] = "ScrollLock";
    KeyCodes["Semicolon"] = "Semicolon";
    KeyCodes["Equals"] = "Equals";
    KeyCodes["Comma"] = "Comma";
    KeyCodes["Dash"] = "Dash";
    KeyCodes["Period"] = "Period";
    KeyCodes["ForwardSlash"] = "ForwardSlash";
    KeyCodes["GraveAccent"] = "GraveAccent";
    KeyCodes["OpenBracket"] = "OpenBracket";
    KeyCodes["BackSlash"] = "BackSlash";
    KeyCodes["CloseBracket"] = "CloseBracket";
    KeyCodes["SingleQuote"] = "SingleQuote";
})(KeyCodes || (KeyCodes = {}));

/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */
// Will subscribe to all passed observables with the source observable, but publish only the source observable.
const subscribeWith = (...others) => (source$) => {
    const argsOrArgArray = (args) => args.length === 1 && Array.isArray(args[0]) ? args[0] : args;
    const others$ = argsOrArgArray(others);
    return from(others$).pipe(mergeAll(), filter(() => false), // stop all the passed observables
    map(() => undefined), mergeWith(source$) // and just publish the source
    );
};

/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */
class Cache extends Map {
    constructor(duty = 86400000) {
        super();
        this.duty = duty;
    }
    clear(timeStamp) {
        this.forEach((value, key) => {
            if (!timeStamp || (value.timeStamp && value.timeStamp <= timeStamp)) {
                this.delete(key);
            }
        });
    }
    getCache(key, defaultValueFn) {
        const now = Date.now();
        // clear obsolete caches
        this.clear(now);
        let entry = super.get(key);
        if (!entry && defaultValueFn) {
            super.set(key, entry = {
                timeStamp: this.duty ? now + this.duty : 0,
                data$: defaultValueFn(now)
            });
        }
        return entry?.data$;
    }
    setCache(key, value) {
        super.set(key, {
            timeStamp: this.duty ? Date.now() + this.duty : 0,
            data$: value
        });
    }
}
class ObservableCache extends Cache {
    // eslint-disable-next-line rxjs/finnish
    getCache(key, defaultValueFn) {
        const data$ = super.getCache(key, defaultValueFn);
        return data$.pipe(catchError((err) => {
            // Clear cache entry in case of observable failure
            this.delete(key);
            return throwError(() => err);
        }));
    }
}

/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */
if (!document.doctype) {
    console.warn('[DejaJS] Current document does not have a doctype. This may cause some components not to behave as expected.');
}

/**
 * Generated bundle index. Do not edit.
 */

export { AbstractLazyModule, Cache, DEFAULT_MEDIA_QUERY_DEFINITIONS, DateUtils, DejaChildValidatorDirective, DejaChildValidatorModule, DejaClipboardModule, DejaClipboardService, DejaConnectionPositionPair, DejaResizeListenerDirective, DejaSlimScrollDirective, DejaSlimScrollModule, DejaTextMetricsModule, DejaTextMetricsService, Destroy, DiacriticService, DialogService, HtmlUtils, IdService, KeyCodes, LazyLoaderService, MEDIA_QUERY_DEFINITIONS, MatInputBase, MediaModule, MediaService, ObservableCache, RegExpUtils, ResizeListenerModule, SIMPLIFIED_MEDIA_QUERY_DEFINITIONS, ValidationMessages, _MatInputMixinBase, formatWithLocale, setLocale, subscribeWith };
//# sourceMappingURL=deja-js-component-core.mjs.map
