"use strict";const t=require("./externalizeComponent-CkVWk2F_.cjs"),o=require("@mui/material"),l=require("lodash-es"),a=require("react"),c=require("axios");function m(e){try{return JSON.stringify(e)}catch{return}}function g(e,r){throw new Error(r+` ${JSON.stringify(e)}`)}function d(e){var r,s,n,i;return e instanceof c.AxiosError&&e.code==="ERR_NETWORK"?"Failed to connect to the server. Please check your internet connection.":e instanceof c.AxiosError&&e.response?`${(r=e.response)==null?void 0:r.status} ${(s=e.response)==null?void 0:s.statusText} from ${(n=e.response)==null?void 0:n.config.url}: ${JSON.stringify((i=e.response)==null?void 0:i.data)}`:e instanceof Error?e.message:`Unexpected error: ${m(e)||e}`}const h=e=>{const r=e.softTimeout||3e3,[s,n]=a.useState(!1),i=o.useTheme();return a.useEffect(()=>{const x=setTimeout(()=>{n(!0)},r);return()=>clearTimeout(x)}),t.jsxRuntimeExports.jsx(o.Stack,{width:"100%",height:"100%",alignItems:"center",justifyContent:"center",sx:{color:i.palette.text.primary},children:e.error?t.jsxRuntimeExports.jsx(u,{loadingMessage:e.message,error:e.error}):t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(o.CircularProgress,{sx:{marginBottom:"24px"}}),!!e.message&&t.jsxRuntimeExports.jsx("div",{children:e.message}),t.jsxRuntimeExports.jsx(o.Stack,{sx:{visibility:s?"visible":"hidden",marginTop:"1rem",color:i.palette.text.secondary},children:"This is taking longer than expected..."})]})})},u=e=>{const r=d(e.error),s=e.error instanceof Error?e.error.stack:null,n=o.useTheme();return t.jsxRuntimeExports.jsxs(o.Stack,{sx:{maxHeight:"100%",maxWidth:"min(100%, 800px)",padding:2,overflow:"auto",color:n.palette.error.main,"& pre":{whiteSpace:"pre-wrap",wordBreak:"break-word",paddingBottom:"3rem"}},children:[(e.loadingMessage?`Error while ${l.lowerFirst(o.capitalize(e.loadingMessage))} - `:"")+r,t.jsxRuntimeExports.jsx("br",{}),s&&t.jsxRuntimeExports.jsx("pre",{children:s})]})};exports.LoadingCover=h;exports.LoadingErrorMessage=u;exports.assertUnreachable=g;
//# sourceMappingURL=LoadingCover-CukpS_aj.cjs.map
