import{e as d,f as T,g as h,h as S}from"./chunk-CUIDVWNH.js";import{La as b,za as c}from"./chunk-5YPL7P3G.js";import{b as l,c as g}from"./chunk-IBUDDWQO.js";import{Sd as p,na as E,r as n,ta as t,ya as s}from"./chunk-XJKQ67XR.js";import{e as v}from"./chunk-SZAW6ZBW.js";var i,j,k=v(()=>{E();T();p();b();S();g();i=function(e){return e[e.success=200]="success",e[e.badRequest=400]="badRequest",e[e.notFound=404]="notFound",e[e.serverError=500]="serverError",e[e.forbidden=403]="forbidden",e}(i||{}),j=(()=>{class e{constructor(r,a,o){this.confirmationService=r,this.applicationErrorService=a,this.translatorService=o}handleError(r,a=null){switch(console.error(r),r.status){case i.serverError:this.handleServerError(r);break;case i.forbidden:this.handleForbiddenError(r.error);break;case i.badRequest:this.handleBadRequest(r.error,this.translatorService.translate("lblError"));break;case i.notFound:this.handleBadRequest(r.error,this.translatorService.translate("lblError"),this.translatorService.translate(a)||"Item not found");break;default:this.handleGenericError(r)}return n()}handleBadRequest(r,a=this.translatorService.translate("AnErrorOccured"),o=this.translatorService.translate("AnErrorOccured")){typeof r=="string"&&(r={message:`${r}`}),this.confirmationService.confirm({key:"globalInfos",header:`${a}`,message:r?.Message||r?.message||o})}handleForbiddenError(r,a=this.translatorService.translate("ShowAccessDenied")){let o=r.translationKey?this.translatorService.translate(r.translationKey):r.Message||r.message;this.confirmationService.confirm({key:"globalInfos",header:`${a}`,message:o})}handleGenericError(r){this.sendToApplicationError(r.message,r.statusText)}handleServerError(r){r.error&&(r.error.exceptionMessage||r.error.message)?this.sendToApplicationError(r.error.message,r.statusText,r.error.exceptionMessage,r.error.exceptionType,r.error.stackTrace):this.handleGenericError(r)}sendToApplicationError(r,a,o,f,m){this.applicationErrorService.pushError(new d({message:r,statusText:a,exceptionMessage:o,exceptionType:f,stackTrace:m,fatal:!1}))}static{this.\u0275fac=function(a){return new(a||e)(s(c),s(h),s(l))}}static{this.\u0275prov=t({token:e,factory:e.\u0275fac,providedIn:"root"})}}return e})()});export{j as a,k as b};
