@cause-911/core
Version:
Run `npm install @cause-911/core --save` to add this library to your project
2 lines • 25.8 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@ngx-translate/core"),require("@angular/core"),require("rxjs"),require("@angular/common/http"),require("rxjs/operators"),require("@angular/material")):"function"==typeof define&&define.amd?define("@cause-911/core",["exports","@ngx-translate/core","@angular/core","rxjs","@angular/common/http","rxjs/operators","@angular/material"],t):t(((e=e||self)["cause-911"]=e["cause-911"]||{},e["cause-911"].core={}),e.core,e.ng.core,e.rxjs,e.ng.common.http,e.rxjs.operators,e.ng.material)}(this,function(e,t,n,r,o,i,s){"use strict";var a=function(){this.apiUrl="",this.languages=["fr","en"],this.loginURL="/login/",this.refreshLoginURL="",this.allowRefreshToken=!1,this.libraries=[],this.locale="",this.nbRetryOnNetworkError=0,this.contentSecurityPolicyActivated=!1},c=new n.InjectionToken("cause-core-module-options",{providedIn:"root",factory:u});function u(){return new a}var h=function(){function e(e){this.libraries=[],this.loginURL="",this.refreshLoginURL="",this.allowRefreshToken=!0,this.apiUrl="",this.nbRetryOnNetworkError=0,this.contentSecurityPolicyActivated=!1,this.useCharset="UTF-8",this.useAuthorizationType="Bearer",this.useAccessToken="",this.useRefreshToken="",this.useCSRFToken="",this.useLocale=e.locale||"fr",this.useLanguages=e.languages||["fr"],this.libraries=e.libraries||[],this.apiUrl=e.apiUrl||"/api/",this.allowRefreshToken=e.allowRefreshToken||!0,this.loginURL=e.loginURL||"/login/",this.refreshLoginURL=e.refreshLoginURL||"",this.nbRetryOnNetworkError=e.nbRetryOnNetworkError||0,this.contentSecurityPolicyActivated=e.contentSecurityPolicyActivated||!1}return Object.defineProperty(e.prototype,"locale",{get:function(){return this.useLocale},set:function(e){this.useLocale=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"languages",{get:function(){return this.useLanguages},set:function(e){this.useLanguages=e,this.setDefaultLocale()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"charset",{get:function(){return this.useCharset},set:function(e){this.useCharset=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"authorizationType",{get:function(){return this.useAuthorizationType},set:function(e){this.useAuthorizationType=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"refreshToken",{get:function(){return this.contentSecurityPolicyActivated&&!this.useRefreshToken?this.useRefreshToken=localStorage.getItem("refreshToken"):this.useRefreshToken||(this.useRefreshToken=sessionStorage.getItem("refreshToken")),this.useRefreshToken},set:function(e){this.contentSecurityPolicyActivated?localStorage.setItem("refreshToken",e):sessionStorage.setItem("refreshToken",e),this.useRefreshToken=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"accessToken",{get:function(){return this.contentSecurityPolicyActivated&&!this.useAccessToken?this.useAccessToken=localStorage.getItem("accessToken"):this.useAccessToken||(this.useAccessToken=sessionStorage.getItem("accessToken")),this.useAccessToken},set:function(e){this.contentSecurityPolicyActivated?localStorage.setItem("accessToken",e):sessionStorage.setItem("accessToken",e),this.useAccessToken=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"CSRFToken",{get:function(){return this.contentSecurityPolicyActivated&&!this.useAccessToken?this.useCSRFToken=localStorage.getItem("CSRFToken"):this.useCSRFToken||(this.useCSRFToken=sessionStorage.getItem("CSRFToken")),this.useCSRFToken},set:function(e){this.contentSecurityPolicyActivated?localStorage.setItem("CSRFToken",e):sessionStorage.setItem("CSRFToken",e),this.useCSRFToken=e},enumerable:!0,configurable:!0}),e.prototype.setDefaultLocale=function(){if(!this.useLocale)if(navigator&&navigator.language.indexOf("-")>-1){if(this.languages.indexOf(navigator.language)>-1)return void(this.locale=navigator.language);var e=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s}(navigator.language.split("-"),2),t=e[0];e[1];if(this.languages.indexOf(t)>-1)return void(this.locale=t)}else if(navigator&&navigator.languages.length>0)for(var n in navigator.languages)if(this.languages.indexOf(navigator.languages[n])>-1)return void(this.locale=navigator.languages[n])},e}(),l=function(){function e(e,t){this.translateService=t,this.config=new h(e),this.config.locale=localStorage.getItem("locale")||this.config.locale||"fr",this.config.languages=this.config.languages||["fr","en"],this.translateService.addLangs(this.config.languages),this.translateService.setDefaultLang(this.config.locale),this.translateService.use(this.config.locale)}return e.prototype.getConfig=function(){return this.config},e.prototype.toggleLanguage=function(){if(this.config.languages.length<2)throw new Error("You need to configure at least two languages.");2===this.config.languages.length&&localStorage.setItem("locale","fr"===this.config.locale?"en":"fr")},e.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.ctorParameters=function(){return[{type:a,decorators:[{type:n.Inject,args:[c]}]},{type:t.TranslateService}]},e.ngInjectableDef=n.ɵɵdefineInjectable({factory:function(){return new e(n.ɵɵinject(c),n.ɵɵinject(t.TranslateService))},token:e,providedIn:"root"}),e}(),p=function(){function e(e){this.http=e,this.http=e}return e.prototype.getIpInformation=function(){var e=this;return new r.Observable(function(t){e.lookupIpWith_IpApi().subscribe(function(e){t.next(e),t.complete()},function(){e.lookupIpWith_GeoIpDb().subscribe(function(e){t.next(e),t.complete()},function(){t.error("Can't lookup the IP address")})})})},e.prototype.lookupIpWith_GeoIpDb=function(){var e=this;return new r.Observable(function(t){e.http.get("http://geoip-db.com/json").subscribe(function(e){t.next({country:e.country_code,countryName:e.country_name,stateName:e.state,cityName:e.city,longitude:e.longitude,latitude:e.latitude}),t.complete()},function(e){t.error(e)})})},e.prototype.lookupIpWith_IpApi=function(){var e=this;return new r.Observable(function(t){e.http.get("http://ip-api.com/json").subscribe(function(e){t.next({country:e.countryCode,countryName:e.country,state:e.region,stateName:e.regionName,cityName:e.city,isp:e.isp,longitude:e.lon,latitude:e.lat}),t.complete()},function(e){t.error(e)})})},e.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.ctorParameters=function(){return[{type:o.HttpClient}]},e.ngInjectableDef=n.ɵɵdefineInjectable({factory:function(){return new e(n.ɵɵinject(o.HttpClient))},token:e,providedIn:"root"}),e}(),f=function(){function e(){this.browserName="unknown",this.browserVersion="unknown",this.engineName="unknown",this.engineVersion="unknown",this.agent="object"==typeof navigator?navigator.userAgent.toLowerCase():"",this.detectBrowser(),this.detectVersion()}return e.prototype.toString=function(){return"Browser: "+this.browserName+" ("+this.browserVersion+"), Engine: "+this.engineName+" ("+this.engineVersion+")"},e.prototype.detectVersion=function(){if("unknown"===this.browserVersion){var e=this.agent.match(this.pattern.browser);this.browserVersion=e?e[2]?e[2]:e[1]:"unknown"}if("unknown"===this.engineVersion){var t=this.agent.match(this.pattern.engine);this.engineVersion=t?t[1]:"unknown"}},e.prototype.detectBrowser=function(){this.agent.match(/webkit/)?this.detectWebkitBrowser():this.agent.match(/trident|msie/)?this.detectTridentBrowser():this.agent.match(/gecko/)?this.detectGeckoBrowser():this.agent.match(/presto/)&&(this.pattern={browser:/version\/([0-9\.]+)/,engine:/presto\/([0-9\.]+)/},this.engineName="presto",this.browserName="opera")},e.prototype.detectGeckoBrowser=function(){this.pattern={browser:/gecko\/([0-9\.]+)/,engine:/rv:([0-9\.]+)/},this.engineName="gecko",this.agent.match(/firefox/)&&(this.pattern.browser=/firefox\/([0-9\.]+)/,this.browserName="firefox")},e.prototype.detectTridentBrowser=function(){this.pattern={browser:/msie ([0-9\.]+)/,engine:/trident\/([0-9\.]+)/},this.engineName="trident",this.browserName="msie",this.agent.match(/rv:/)?this.pattern.browser=/rv:([0-9\.]+)/:this.agent.match(/msie/)||(this.browserVersion="11.0")},e.prototype.detectWebkitBrowser=function(){this.pattern={browser:/webkit\/([0-9\.]+)/,engine:/applewebkit\/([0-9\.]+)/},this.engineName="webkit",this.agent.match(/edge/)?(this.pattern.browser=/edge\/([0-9\.]+)/,this.engineName="edgeHTML",this.browserName="edge"):this.agent.match(/chrome/)?(this.engineName="blink",this.agent.match(/vivaldi/)?(this.pattern.browser=/vivaldi\/([0-9\.]+)/,this.browserName="vivaldi"):this.agent.match(/opr/)?(this.pattern.browser=/opr\/([0-9\.]+)/,this.browserName="opera"):this.agent.match(/crios/)?(this.pattern.browser=/crios\/([0-9\.]+)/,this.browserName="chrome"):(this.pattern.browser=/chrom(e|ium)\/([0-9\.]+)/,this.browserName="chrome")):this.agent.match(/safari/)&&(this.pattern.browser=/version\/([0-9\.]+)/,this.browserName="safari")},e}(),g=function(){function e(){this.name="unknown",this.version="unknown",this.agent="object"==typeof navigator?navigator.userAgent.toLowerCase():"",this.detect()}return e.prototype.toString=function(){return"OS: "+this.name+" ("+this.version+")"},e.prototype.detect=function(){for(var e=[{name:"iOS",pattern:/iphone|ipad|ipod/},{name:"Android",pattern:/android/},{name:"Blackberry",pattern:/blackberry/},{name:"Windows",pattern:/win/},{name:"Chrome OS",pattern:/cros/},{name:"Mac OS",pattern:/mac/},{name:"Linux",pattern:/linux|x11/},{name:"Open BSD",pattern:/openbsd/},{name:"Unix",pattern:/unix/},{name:"Sun OS",pattern:/sunos/},{name:"beOS",pattern:/beos/},{name:"QNX",pattern:/qnx/},{name:"os2",pattern:/os\/2/}],t=0,n=e.length;t<n;t++)if(this.agent.match(e[t].pattern)){this.name=e[t].name;break}this.detectVersion()},e.prototype.detectVersion=function(){if("Windows"===this.name)this.agent.match(/phone/)?this.detectVersionWindowsPhone():this.detectVersionWindows();else if("Mac OS"===this.name)this.detectVersionMac();else if("Android"===this.name){var e=this.agent.match(/android ([0-9\.]+)/);this.version=e?" "+e[1]:""}else if("iOS"===this.name){var t=this.agent.match(/os ([0-9\_]+)/);this.version=t?" "+t[1].replace("_","."):""}},e.prototype.detectVersionWindows=function(){this.name="Windows";for(var e=[{name:"10",pattern:/windows nt 10.0|windows 10.0/},{name:"10 Technical Preview",pattern:/windows nt 6.4/},{name:"8.1",pattern:/windows nt 6.3|windows 8.1/},{name:"8",pattern:/windows nt 6.2|windows 8.0|wow64/},{name:"7 / Server 2008 RC2",pattern:/windows nt 6.1|windows 7/},{name:"Vista",pattern:/windows nt 6.0/},{name:"Server 2003",pattern:/windows nt 5.2/},{name:"XP",pattern:/windows nt 5.1|windows xp/},{name:"2000",pattern:/windows nt 5.0|windows 2000/},{name:"NT 4.0",pattern:/windows nt 4.0|winnt4.0|winnt|windows nt/},{name:"CE",pattern:/windows ce/},{name:"ME",pattern:/windows me/},{name:"98",pattern:/windows 98|win98/},{name:"95",pattern:/windows 95|win95|windows_95/},{name:"3.11",pattern:/win16/}],t=0,n=e.length;t<n;t++)if(this.agent.match(e[t].pattern)){this.version=e[t].name;break}},e.prototype.detectVersionWindowsPhone=function(){this.name="Windows Phone";for(var e=[{name:"10",pattern:/windows phone 10/},{name:"8.1",pattern:/windows phone 8.1/},{name:"8",pattern:/windows phone 8/},{name:"7.5",pattern:/windows phone os 7.5/},{name:"7",pattern:/windows phone os 7/}],t=0,n=e.length;t<n;t++)if(this.agent.match(e[t].pattern)){this.version=e[t].name;break}},e.prototype.detectVersionMac=function(){if(this.agent.match(/mac os x/)){var e=this.agent.match(/mac os x ([0-9\_]+)/);this.name="Mac OS X",this.version=e?" "+e[1].replace("_","."):""}else this.agent.match(/macppc|macintel|mac_powerpc|macintosh/)&&(this.name="Mac OS")},e}(),d=function(){function e(e,t){var r=this;this.apiLookup=t,this.visibilityChange=new n.EventEmitter,this.config=e.getConfig(),document.addEventListener("visibilitychange webkitvisibilitychange mozvisibilitychange msvisibilitychange",function(){return r.onVisibilityChange("visible"===document.visibilityState)})}return e.prototype.getCoordinates=function(){var e=this;return new r.Observable(function(t){navigator&&"geolocation"in navigator?navigator.geolocation.getCurrentPosition(function(e){t.next([e.coords.longitude,e.coords.latitude]),t.complete()},function(){return e.getCoordinatesWithClientIP(t)}):e.getCoordinatesWithClientIP(t)})},e.prototype.getLanguage=function(){var e=this;return new r.Observable(function(t){var n=[e.config.locale];navigator&&"languages"in navigator?n=navigator.languages:navigator&&"language"in navigator?n=[navigator.language]:navigator&&"userLanguage"in navigator&&(n=[navigator.userLanguage]),t.next(n),t.complete()})},e.prototype.getBrowser=function(){return new r.Observable(function(e){var t=new f;e.next(t),e.complete()})},e.prototype.getOperatingSystem=function(){return new r.Observable(function(e){var t=new g;e.next(t),e.complete()})},e.prototype.getCoordinatesWithClientIP=function(e){this.apiLookup.getIpInformation().subscribe(function(t){e.next([t.longitude,t.latitude]),e.complete()},function(){e.next([-71,48]),e.error("Can't find the client location")})},e.prototype.onVisibilityChange=function(e){this.visibilityChange.emit(e)},e.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.ctorParameters=function(){return[{type:l},{type:p}]},e.propDecorators={visibilityChange:[{type:n.Output}]},e.ngInjectableDef=n.ɵɵdefineInjectable({factory:function(){return new e(n.ɵɵinject(l),n.ɵɵinject(p))},token:e,providedIn:"root"}),e}(),m=function(){function e(){var e=this;this.statusChange=new n.EventEmitter,document.addEventListener("fullscreenchange webkitfullscreenchange mozfullscreenchange msfullscreenchange",function(){return e.onChange()})}return e.prototype.show=function(e){e||(e=document.querySelector("body")),e.requestFullscreen?e.requestFullscreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.msRequestFullscreen&&e.msRequestFullscreen()},e.prototype.exit=function(){document.querySelector("body").classList.remove("is-fullscreen"),document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msRequestFullscreen&&document.msRequestFullscreen()},e.prototype.isActived=function(){return(screen.availHeight||screen.height-30)<=window.innerHeight},e.prototype.onChange=function(){this.isActived()?document.querySelector("body").classList.add("is-fullscreen"):document.querySelector("body").classList.remove("is-fullscreen"),this.statusChange.emit(this.isActived())},e.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.ctorParameters=function(){return[]},e.propDecorators={statusChange:[{type:n.Output}]},e.ngInjectableDef=n.ɵɵdefineInjectable({factory:function(){return new e},token:e,providedIn:"root"}),e}(),w=function(){function e(){}return e.prototype.compress=function(e,t,n){var o=this;void 0===t&&(t=0),void 0===n&&(n=0);var i=e.name,s=new FileReader;return new r.Observable(function(r){s.readAsDataURL(e),s.onload=function(s){var a=new Image;a.src=s.target.result.toString(),a.onload=function(){var s=o.findRatio(a,t,n);if(null!==s){var c=document.createElement("canvas");c.width=s.width,c.height=s.height;var u=c.getContext("2d");u.drawImage(a,0,0,s.width,s.height),u.canvas.toBlob(function(t){var n=new File([t],i,{type:e.type,lastModified:Date.now()});r.next(n)},e.type,1)}else r.next(e)}}})},e.prototype.findRatio=function(e,t,n){if(void 0===t&&(t=0),void 0===n&&(n=0),0===t&&0===n)return null;var r=e.width/e.height,o=r>1?"horizontal":"vertical";return t=t||e.width,n=n||e.height,e.width<t&&e.height<n?null:"horizontal"===o&&t<e.width?{width:t,height:t/r}:{width:n*r,height:n}},e.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.ctorParameters=function(){return[]},e.ngInjectableDef=n.ɵɵdefineInjectable({factory:function(){return new e},token:e,providedIn:"root"}),e}(),y=function(){function e(){this.qualities=[{type:"GPRS",minimum:20480,estimate:"50 Kb/s (max estimate)"},{type:"Regular2G",minimum:51200,estimate:"250 Kb/s (max estimate)"},{type:"Good2G",minimum:256e3,estimate:"450 Kb/s (max estimate)"},{type:"Regular3G",minimum:460800,estimate:"750 Kb/s (max estimate)"},{type:"Good3G",minimum:768e3,estimate:"1.5 Mb/s (max estimate)"},{type:"DSL",minimum:1572864,estimate:""},{type:"Regular4G",minimum:3145728,estimate:"4 Mb/s (max estimate)"},{type:"WIFI",minimum:15728640,estimate:"30 Mb/s (min estimate)"},{type:"Fiber",minimum:31457280,estimate:"30 Mb/s (max estimate)"},{type:"LAN",minimum:536870912,estimate:"500 Mb/s (min estimate)"}]}return e.prototype.estimate=function(e){var t="";return this.qualities.forEach(function(n){e>n.minimum&&(t=n.estimate)}),t},e}(),v=function(){function e(){var e=this;this.estimates=new y,this.statusChange=new n.EventEmitter,window.addEventListener("online",function(){return e.onStatusChange(!0)}),window.addEventListener("offline",function(){return e.onStatusChange(!1)})}return e.prototype.getConnectionSpeed=function(){var e=this;return new r.Observable(function(t){navigator&&"connection"in navigator?(t.next(navigator.connection.downlink+" Mb/s"),t.complete()):e.estimateDownlink(t)})},e.prototype.estimateDownlink=function(e){var t=this,n=(new Date).getTime(),r=new Image;r.onload=function(){var r=838860800/(((new Date).getTime()-n)/1e3);e.next(t.estimates.estimate(r)),e.complete()},r.onerror=function(t){e.error(t)},r.src="https://speed.hetzner.de/100MB.bin?_="+n},e.prototype.onStatusChange=function(e){this.statusChange.emit(e)},e.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.ctorParameters=function(){return[]},e.propDecorators={statusChange:[{type:n.Output}]},e.ngInjectableDef=n.ɵɵdefineInjectable({factory:function(){return new e},token:e,providedIn:"root"}),e}(),b=function(){function e(){}return e.prototype.hslToRgb=function(e,t,n){var r,o,i;if(0===t)r=o=i=n;else{var s=n<.5?n*(1+t):n+t-n*t,a=2*n-s,c=function(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+(t-e)*(2/3-n)*6:e};r=c(a,s,e+1/3),o=c(a,s,e),i=c(a,s,e-1/3)}return[Math.floor(255*r),Math.floor(255*o),Math.floor(255*i)]},e.prototype.getContrast50=function(e){return parseInt(e,16)>8388607.5?"black":"white"},e.prototype.getContrastYIQ=function(e){return(299*parseInt(e.substr(0,2),16)+587*parseInt(e.substr(2,2),16)+114*parseInt(e.substr(4,2),16))/1e3>=128?"black":"white"},e}(),k=function(){function e(){}return e.prototype.ngOnInit=function(){},e.decorators=[{type:n.Component,args:[{selector:"cause-page-not-found",template:'<div class="middle">\n <h1>Ooops... page not found</h1>\n</div>',styles:[".middle{max-width:600px;margin:0 auto}.middle h1{text-align:center}"]}]}],e.ctorParameters=function(){return[]},e}(),T=function(){function e(){}return e.prototype.ngOnInit=function(){},e.decorators=[{type:n.Component,args:[{selector:"cause-core",template:"<div>{{'core.noGenericComponentOnThisLibrary' | translate}}</div>"}]}],e.ctorParameters=function(){return[]},e}(),C=function(){function e(){}return e.prototype.intercept=function(e,t){var n=this;return e=e.clone(),navigator.onLine?t.handle(e).pipe(i.catchError(function(e){return 0===e.status?n.onOffline(e):r.throwError(e)})):this.onOffline(new o.HttpErrorResponse({headers:e.headers,status:408,statusText:"Offline",url:e.url}))},e.prototype.onOffline=function(e){return r.throwError(e)},e.decorators=[{type:n.Injectable}],e.ctorParameters=function(){return[]},e}(),S=function(){function e(e,t){this.http=new o.HttpClient(t),this.config=e.getConfig()}return e.prototype.intercept=function(e,t){var n=this;return this.requestOriginal=e,e=e.clone({headers:this.addSettings()}),t.handle(e).pipe(i.catchError(function(o){return n.checkIfWeCanManageError(o).pipe(i.switchMap(function(r){return e=r.clone({headers:n.addSettings()}),t.handle(e)}),i.catchError(function(e){return r.throwError(e)}))}))},e.prototype.addSettings=function(){var e=this.requestOriginal.headers,t=this.requestOriginal.body instanceof FormData;return!e.has("Authorization")&&this.config.accessToken&&(e=e.set("Authorization",this.config.authorizationType+" "+this.config.accessToken)),!e.has("X-CSRF-Token")&&this.config.CSRFToken&&(e=e.set("X-CSRF-Token",""+this.config.CSRFToken)),e.has("Content-Type")||t||(e=e.set("Content-Type","application/json; charset="+this.config.charset)),e.has("Language-Code")||(e=e.set("Language-Code",this.config.locale)),e},e.prototype.checkIfWeCanManageError=function(e){var t=this;if(401===e.status&&this.config.accessToken&&this.config.allowRefreshToken)return this.checkRefreshToken().pipe(i.map(function(e){return e||(location.href=t.config.loginURL),t.requestOriginal}));if(401===e.status&&this.config.accessToken)location.href=this.config.loginURL;else if(200===e.status&&e.message&&0===e.message.indexOf("Http failure during parsing for"))return r.of(this.resendAsHTML());return r.throwError(e)},e.prototype.checkRefreshToken=function(){var e=this;return this.postRefreshToken().pipe(i.map(function(t){return e.config.accessToken=t.accessToken||"",!!t.accessToken}),i.catchError(function(t){return e.config.accessToken="",r.of(!1)}))},e.prototype.postRefreshToken=function(){var e=this.config.refreshLoginURL;e||(e="/api/Authentification/Refresh");var t={accessToken:this.config.accessToken,refreshToken:this.config.refreshToken};return this.http.post(e,t)},e.prototype.resendAsHTML=function(){var e=this.requestOriginal.headers;return e=e.set("Content-Type","text/html; charset="+this.config.charset),this.requestOriginal.clone({responseType:"text",headers:e})},e.decorators=[{type:n.Injectable}],e.ctorParameters=function(){return[{type:l},{type:o.HttpBackend}]},e}(),I=function(){function e(e){this.coreService=e}return e.prototype.intercept=function(e,t){var n=this;return t.handle(e).pipe(i.map(function(e){return e.headers&&e.headers.get("x-csrf-token")&&(n.coreService.getConfig().CSRFToken=e.headers.get("x-csrf-token")),e}))},e.decorators=[{type:n.Injectable}],e.ctorParameters=function(){return[{type:l}]},e}(),R=function(){function e(e){this.config=e.get(l).getConfig();try{this.snackBar=e.get(s.MatSnackBar)}catch(e){console.log('No material snackbar can\'t be injected. You could "imports" the module "MatSnackBarModule" to use it.')}}return e.prototype.intercept=function(e,t){var n=this;return t.handle(e).pipe(i.retryWhen(function(e){return n.handleRetry(e)}),i.catchError(function(e){return n.handleError(e)}))},e.prototype.handleRetry=function(e){var t=this;return e.pipe(i.scan(function(e,n,r){var o=t.config.nbRetryOnNetworkError>0&&r<t.config.nbRetryOnNetworkError,i=[0,408,502,503,504].includes(n.status);if(o&&i)return r+1;throw n},0))},e.prototype.handleError=function(e){return e instanceof o.HttpErrorResponse&&(e.error instanceof ErrorEvent?this.showError(e.error.message):0===e.status?this.showError("La demande ne peut être complétée."):400===e.status?e.error?this.showError(e.error.title?e.error.title:e.error):e.statusText?this.showError(e.status+" "+e.statusText):this.showError("La demande ne peut pas être complétée."):404===e.status?this.showError("Le URL demandé n'existe pas."):500===e.status?this.showError("Erreur de communication."):200!==e.status&&401!==e.status&&this.showError("Erreur : "+e.status+" "+e.statusText)),r.throwError(e)},e.prototype.showError=function(e){this.snackBar?this.snackBar.open(e,"",{panelClass:["error-snackbar"],duration:5e3}):window.alert(e)},e.decorators=[{type:n.Injectable}],e.ctorParameters=function(){return[{type:n.Injector}]},e}(),x=function(){function e(){}return e.prototype.handle=function(e){return'i18n "'+e.key+'" is missing'},e}(),O=function(){function e(e,t){var n=this;this.resources=[{prefix:"/assets/i18n/",suffix:".json"},{prefix:"/assets/i18n/cause/",suffix:"-core.json"}],this.http=new o.HttpClient(e),t&&t.libraries&&t.libraries.forEach(function(e){n.resources.push({prefix:"/assets/i18n/cause/",suffix:"-"+e+".json"})})}return e.prototype.getTranslation=function(e){var t=this;return r.forkJoin(this.resources.map(function(n){return t.getOneRessourceTranslation(e,n)})).pipe(i.map(function(e){return e.reduce(function(e,t){return Object.assign(e,t)})}))},e.prototype.getOneRessourceTranslation=function(e,t){return this.http.get(""+t.prefix+e+t.suffix).pipe(i.catchError(function(e){return r.of({})}))},e}();function E(e){return e.getConfig().locale}var L={loader:{provide:t.TranslateLoader,useClass:O,deps:[o.HttpBackend,c]},missingTranslationHandler:{provide:t.MissingTranslationHandler,useClass:x},useDefaultLang:!1},j=function(){function e(){}return e.decorators=[{type:n.NgModule,args:[{declarations:[T,k],exports:[T,k,t.TranslateModule],imports:[o.HttpClientModule,t.TranslateModule.forRoot(L)],providers:[l,{provide:o.HTTP_INTERCEPTORS,useClass:C,multi:!0},{provide:o.HTTP_INTERCEPTORS,useClass:S,multi:!0},{provide:o.HTTP_INTERCEPTORS,useClass:I,multi:!0},{provide:o.HTTP_INTERCEPTORS,useClass:R,multi:!0},{provide:n.LOCALE_ID,useFactory:E,deps:[l]}]}]}],e}();Object.defineProperty(e,"TranslateService",{enumerable:!0,get:function(){return t.TranslateService}}),e.Browser=f,e.CAUSE_CORE_MODULE_OPTIONS=c,e.CauseCoreModule=j,e.ClientInformationService=d,e.Color=b,e.Configuration=h,e.CoreComponent=T,e.CoreModuleOptions=a,e.CoreService=l,e.FullscreenService=m,e.ImageService=w,e.NetworkInformationService=v,e.OperatingSystem=g,e.PageNotFoundComponent=k,e.configFactory=E,e.ɵa=u,e.ɵb=p,e.ɵc=O,e.ɵd=x,e.ɵe=C,e.ɵf=S,e.ɵg=I,e.ɵh=R,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=cause-911-core.umd.min.js.map