-`,x=l=>{var j;const{t:r}=S(),{variant:O="text",error:v}=l,i=v,[s,m]=f.useState(void 0);if(f.useEffect(()=>{if(typeof i=="object"&&i!==null&&i.data instanceof Blob)i.data.text().then(n=>{try{const o=JSON.parse(n);m({...i,data:o})}catch{m({...i,data:n})}});else{if(i===void 0)throw new Error("Invalid input");m(i)}},[i]),s===void 0)return e.jsx(k,{variant:"medium"});if(typeof s=="string")return e.jsx(d,{children:e.jsx(c,{children:e.jsxs(a,{children:[e.jsx("h2",{children:r("error-title")}),e.jsx("p",{children:s})]})})});if(typeof s=="object"&&s!==null)if(T(s.data)){const t=s.data,n=t.data;let o=e.jsx(e.Fragment,{});if(E(n)){const _=window.location.href.replace(location.hash,"");o=e.jsx("a",{href:`${_}#${n.block_id}`,children:r("go-to-error")})}return e.jsx(d,{children:e.jsxs(c,{children:[e.jsxs(a,{children:[e.jsxs("h2",{children:[r("error-title")," ",s.status,": ",t.title]}),e.jsx("p",{children:t.message})]}),e.jsx(p,{children:t.source&&e.jsxs("details",{children:[e.jsx("summary",{children:r("show-error-source")}),e.jsx("ul",{children:e.jsx("li",{children:e.jsx("pre",{children:t.source})})})]})}),t.data&&e.jsx(a,{children:o})]})})}else if(s.isAxiosError){const t=s,n=(j=t.response)==null?void 0:j.data,o=typeof n=="object"&&n!==null&&"message"in n?n.message:void 0;return e.jsx(d,{children:e.jsxs(c,{children:[e.jsxs(a,{children:[e.jsxs("h2",{children:[r("error-title"),": ",t.message]}),o&&e.jsx("p",{children:o})]}),e.jsx(p,{children:!!n&&e.jsxs("details",{children:[e.jsx("summary",{children:r("show-error-source")}),e.jsx("ul",{children:e.jsx("li",{children:e.jsx("pre",{children:JSON.stringify(n,void 0,2)})})})]})})]})})}else{if(s.status!==void 0&&s.statusText!==void 0&&typeof s.request=="object"&&s.request.responseURL!==void 0)return e.jsx(d,{children:e.jsxs(c,{children:[e.jsxs(a,{children:[e.jsxs("h2",{children:[r("error-title")," ",s.status,": ",s.statusText]}),e.jsx("p",{children:s.request.responseURL})]}),e.jsx(p,{children:s.data&&e.jsxs("details",{children:[e.jsx("summary",{children:r("show-error-source")}),e.jsx("ul",{children:e.jsx("li",{children:e.jsx("pre",{children:JSON.stringify(s.data,void 0,2)})})})]})})]})});if(s instanceof Error)return e.jsx(d,{children:e.jsxs(c,{children:[e.jsx(a,{children:e.jsxs("h2",{children:[r("error-title"),s.message&&`: ${s.message}`]})}),e.jsx(p,{children:e.jsxs("details",{children:[e.jsx("summary",{children:r("show-error-source")}),e.jsx("ul",{children:e.jsx("li",{children:e.jsxs("pre",{children:[s.toString(),e.jsx("br",{}),s.stack]})})})]})})]})})}return e.jsx(d,{children:e.jsxs(c,{children:[e.jsx(a,{children:e.jsx("h2",{children:r("error-title")})}),e.jsx(p,{children:e.jsxs("details",{children:[e.jsx("summary",{children:r("show-error-source")}),e.jsx("ul",{children:e.jsx("li",{children:e.jsx("pre",{children:JSON.stringify(s,void 0,2)})})})]})})]})})};try{x.displayName="ErrorBanner",x.__docgenInfo={description:"",displayName:"ErrorBanner",props:{variant:{defaultValue:null,description:"",name:"variant",required:!1,type:{name:"enum",value:[{value:'"link"'},{value:'"text"'},{value:'"readOnly"'}]}},error:{defaultValue:null,description:"",name:"error",required:!0,type:{name:"unknown"}}}}}catch{}const U={component:x,parameters:{docs:{description:{component:"Use this component to display an error banner. The error can be either a string or an Error object."}}}},u={args:{error:"This is an error message."}};var y,b,w;u.parameters={...u.parameters,docs:{...(y=u.parameters)==null?void 0:y.docs,source:{originalSource:`{
0 commit comments