1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[823],{90823:(e,r,t)=>{t.d(r,{enhancedFetchWrapper:()=>n});var o=t(36489),a=t(68267);class i{url(e){let r=this.baseUrl.replace(/\/+$/,""),t=e.replace(/^\/+/,"");return"".concat(r,"/").concat(t)}async getToken(){try{let e=await (0,o.getSession)();return(null==e?void 0:e.accessToken)||null}catch(e){return null}}async getHeaders(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],r={"Content-Type":"application/json"};{let e=window.location.pathname.match(/^\/(fr|en)/);(null==e?void 0:e[1])&&(r["Accept-Language"]=e[1])}if(e){let e=await this.getToken();if(e){r.Authorization="Bearer ".concat(e);try{let r=this.decodeToken(e),t=Math.floor(Date.now()/1e3);r.exp<t&&await this.handleExpiredToken()}catch(e){}}}return r}decodeToken(e){try{let r=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),t=decodeURIComponent(atob(r).split("").map(function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)}).join(""));return JSON.parse(t)}catch(e){throw Error("Invalid token format")}}async handleExpiredToken(){this.showNotification("Session expir\xe9e","Veuillez vous reconnecter","error"),await (0,o.signOut)({callbackUrl:"/signin"})}showNotification(e,r){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"error";window.showToast?window.showToast({title:e,message:r,type:t}):this.createSimpleNotification(e,r,t)}createSimpleNotification(e,r,t){let o=document.createElement("div");o.className="fixed top-4 right-4 z-50 p-4 rounded-lg shadow-lg max-w-sm ".concat("error"===t?"bg-red-500 text-white":"warning"===t?"bg-yellow-500 text-black":"bg-blue-500 text-white");let a=document.createElement("div");a.className="flex items-center justify-between";let i=document.createElement("div"),n=document.createElement("h4");n.className="font-semibold",n.textContent=e;let s=document.createElement("p");s.className="text-sm",s.textContent=r,i.appendChild(n),i.appendChild(s);let l=document.createElement("button");l.className="ml-4 text-lg",l.textContent="\xd7",l.addEventListener("click",()=>o.remove()),a.appendChild(i),a.appendChild(l),o.appendChild(a),document.body.appendChild(o),setTimeout(()=>{o.parentNode&&o.parentNode.removeChild(o)},5e3)}async handleResponse(e){let r,t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=await e.text();try{r=JSON.parse(o)}catch(e){r=o}if(e.ok)return r||e.statusText;if(401===e.status){if(!t){this.showNotification("Acc\xe8s refus\xe9","Votre session a expir\xe9. Reconnexion en cours...","error"),await this.handleExpiredToken();return}let e=Error("Session expir\xe9e");throw e.status=401,e.errorType="auth",e.data=r,e.retryable=!1,e}let a="string"==typeof r?r:r.message||r.title||e.statusText,i=a;if(r&&"object"==typeof r){if(r.errors&&"object"==typeof r.errors){let e=Object.entries(r.errors).map(e=>{let[r,t]=e;return"".concat(r,": ").concat(Array.isArray(t)?t.join(", "):t)}).join("; ");e&&(i="".concat(a," - ").concat(e))}r.detail&&(i="".concat(a," - ").concat(r.detail))}let{errorType:n,retryable:s}=function(e,r){let t="string"==typeof r?r:(null==r?void 0:r.message)||(null==r?void 0:r.detail)||(null==r?void 0:r.title)||"";return t.includes("compute time quota")||t.includes("XX000")?{errorType:"quota",retryable:!1}:0===e?{errorType:"network",retryable:!0}:401===e?{errorType:"auth",retryable:!1}:403===e&&(null==r?void 0:r.blocked)===!0?{errorType:"subscription",retryable:!1}:e>=400&&e<500?{errorType:"validation",retryable:!1}:e>=500?{errorType:"server",retryable:!0}:{errorType:"unknown",retryable:!1}}(e.status,r);if(!t){let e=null,r="",t="error";switch(n){case"quota":e="Serveur surcharg\xe9",r="Le serveur est temporairement surcharg\xe9. Veuillez r\xe9essayer dans quelques instants.",t="warning";break;case"server":e="Erreur serveur",r=i||"Une erreur interne est survenue.",t="error";break;case"network":e="Erreur r\xe9seau",r="Impossible de contacter le serveur. V\xe9rifiez votre connexion.",t="error"}e&&this.showNotification(e,r,t)}let l=Error(i);throw l.status=e.status,l.errorType=n,l.data=r,l.retryable=s,l}async get(e){let r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],t=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=await this.getHeaders(r);try{let r=await fetch(this.url(e),{method:"GET",headers:o});return this.handleResponse(r,t)}catch(r){if(t||this.showNotification("Erreur r\xe9seau","Impossible de contacter le serveur","error"),null==r?void 0:r.errorType)throw r;let e=Error("Network error occurred");throw e.status=0,e.errorType="network",e.retryable=!0,e}}async post(e,r){let t=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=arguments.length>4?arguments[4]:void 0,i={...await this.getHeaders(t),...a};try{let t=await fetch(this.url(e),{method:"POST",headers:i,body:r?JSON.stringify(r):void 0});return this.handleResponse(t,o)}catch(r){if(o||this.showNotification("Erreur r\xe9seau","Impossible de contacter le serveur","error"),null==r?void 0:r.errorType)throw r;let e=Error("Network error occurred");throw e.status=0,e.errorType="network",e.retryable=!0,e}}async put(e,r){let t=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=await this.getHeaders(t);try{let t=await fetch(this.url(e),{method:"PUT",headers:a,body:r?JSON.stringify(r):void 0});return this.handleResponse(t,o)}catch(r){if(o||this.showNotification("Erreur r\xe9seau","Impossible de contacter le serveur","error"),null==r?void 0:r.errorType)throw r;let e=Error("Network error occurred");throw e.status=0,e.errorType="network",e.retryable=!0,e}}async patch(e,r){let t=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=await this.getHeaders(t);try{let t=await fetch(this.url(e),{method:"PATCH",headers:a,body:r?JSON.stringify(r):void 0});return this.handleResponse(t,o)}catch(r){if(o||this.showNotification("Erreur r\xe9seau","Impossible de contacter le serveur","error"),null==r?void 0:r.errorType)throw r;let e=Error("Network error occurred");throw e.status=0,e.errorType="network",e.retryable=!0,e}}async delete(e){let r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],t=arguments.length>2?arguments[2]:void 0,o=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=await this.getHeaders(r);try{let r=await fetch(this.url(e),{method:"DELETE",headers:a,body:t?JSON.stringify(t):void 0});return this.handleResponse(r,o)}catch(r){if(o||this.showNotification("Erreur r\xe9seau","Impossible de contacter le serveur","error"),null==r?void 0:r.errorType)throw r;let e=Error("Network error occurred");throw e.status=0,e.errorType="network",e.retryable=!0,e}}async upload(e,r){let t=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o={};{let e=window.location.pathname.match(/^\/(fr|en)/);(null==e?void 0:e[1])&&(o["Accept-Language"]=e[1])}if(t){let e=await this.getToken();e&&(o.Authorization="Bearer ".concat(e))}try{let t=await fetch(this.url(e),{method:"POST",headers:o,body:r});return this.handleResponse(t)}catch(r){if(null==r?void 0:r.errorType)throw r;this.showNotification("Erreur d'upload","\xc9chec du t\xe9l\xe9chargement du fichier","error");let e=Error("Upload failed");throw e.status=0,e.errorType="network",e.retryable=!0,e}}constructor(){this.baseUrl=a.i.baseUrl}}let n=new i}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.