import{i as e}from"./chunk-B3pr0VN8.js";import{n as t,t as n}from"./jsx-runtime-wTfS3W87.js";var r=e(t(),1),i=n();function a(...e){return e.filter(Boolean).join(` `)}var o={network:{title:`网络有点不稳`,desc:`请检查网络后重试；如果一直失败，可以换个时间再来。`},permission:{title:`需要先登录`,desc:`此功能需要登录后使用，登录后即可继续。`},service:{title:`服务繁忙`,desc:`我们正在处理，请稍后再试。`},unknown:{title:`出了点小问题`,desc:`请稍后重试，或联系我们获取帮助。`}},s={network:`var(--ds-status-warning)`,permission:`var(--ds-status-info)`,service:`var(--ds-status-warning)`,unknown:`var(--ds-status-danger)`};function c(e,t){if(!e)return null;let n=e.variant??t,r=a(`ds-btn`,n===`primary`&&`ds-btn-primary`,n===`secondary`&&`ds-btn-secondary`,n===`ghost`&&`ds-btn-ghost`);return e.href?(0,i.jsx)(`a`,{href:e.href,className:r,children:e.label}):(0,i.jsx)(`button`,{type:`button`,onClick:e.onClick,className:r,children:e.label})}var l=(()=>{try{return!0}catch{return!1}})(),u=({level:e=`unknown`,title:t,description:n,retry:r,secondary:u,contact:d,detail:f,showDetail:p,className:m})=>{let h=o[e],g=s[e],_=p??!l;return(0,i.jsxs)(`div`,{className:a(`flex flex-col items-center justify-center rounded-ds-lg px-6 py-10 text-center`,m),style:{background:`var(--ds-bg-surface)`,border:`1px solid var(--ds-border-default)`,color:`var(--ds-text-secondary)`},role:`alert`,children:[(0,i.jsx)(`div`,{className:`mb-3 flex h-12 w-12 items-center justify-center rounded-full`,style:{background:`var(--ds-bg-subtle)`,color:g},"aria-hidden":`true`,children:(0,i.jsx)(`svg`,{width:`22`,height:`22`,viewBox:`0 0 24 24`,fill:`none`,children:(0,i.jsx)(`path`,{d:`M12 8v5m0 3.2v.1M4.5 19.5h15a1 1 0 0 0 .87-1.5l-7.5-13a1 1 0 0 0-1.74 0l-7.5 13a1 1 0 0 0 .87 1.5Z`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`})})}),(0,i.jsx)(`h3`,{className:`text-[15px] font-semibold`,style:{color:`var(--ds-text-primary)`},children:t??h.title}),(0,i.jsx)(`p`,{className:`mt-1 max-w-md text-[13px] leading-5`,children:n??h.desc}),(0,i.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-center gap-2`,children:[c(r,`primary`),c(u,`secondary`),c(d,`ghost`)]}),f&&_?(0,i.jsx)(`pre`,{className:`mt-4 w-full max-w-xl overflow-auto rounded-ds-sm p-3 text-left text-[12px]`,style:{background:`var(--ds-bg-subtle)`,color:`var(--ds-text-muted)`,whiteSpace:`pre-wrap`,wordBreak:`break-word`},children:f}):null]})},d={ink:{50:`#FCFBF8`,100:`#F5F0E7`,200:`#ECE5D7`,300:`#C5BFB5`,400:`#8A8278`,500:`#4A4540`,600:`#2E2A24`,700:`#1F1C18`,800:`#1A1815`,900:`#100E0B`},ochre:{300:`#E0BE7A`,400:`#D49E48`,500:`#C5832E`,600:`#A66B22`},apricot:{400:`#FFA36B`,500:`#FF7A3A`,600:`#E2612A`},gray:{0:`#FFFFFF`,50:`#F8F7F5`,100:`#EFEDE9`,200:`#DEDAD3`,300:`#C5BFB5`,400:`#9C9489`,500:`#6E665C`,600:`#4B453D`,700:`#2E2A24`,800:`#1C1915`,900:`#100E0B`},functional:{success:`#2E9B6B`,warning:`#E5A23B`,danger:`#D6483A`,info:`#3D7DD6`}};d.gray[50],d.gray[0],d.gray[0],d.gray[100],d.ink[100],d.gray[900],d.gray[600],d.gray[500],d.gray[0],d.gray[200],d.gray[300],d.ink[800],d.ink[500],d.apricot[500],d.apricot[600],d.ochre[500],d.functional.success,d.functional.warning,d.functional.danger,d.functional.info,d.gray[900],d.gray[800],d.gray[700],d.gray[800],d.gray[700],d.gray[50],d.gray[300],d.gray[400],d.gray[900],d.gray[700],d.gray[600],d.gray[50],d.gray[200],d.apricot[400],d.apricot[500],d.ochre[500],d.functional.success,d.functional.warning,d.functional.danger,d.functional.info;var f=e=>{if(!e)return``;let t=String(e.name||`Error`),n=String(e.message||``),r=String(e.stack||``);return[t&&n?`${t}: ${n}`:n||t,r].filter(Boolean).join(`

`)},p=class extends r.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){try{console.error(`[ExtensionCrashBoundary]`,e,t)}catch{}}reset=()=>{if(this.props.onReset){this.props.onReset();return}try{globalThis.location?.reload?.()}catch{try{globalThis.history?.go?.(0)}catch{}}};render(){let{error:e}=this.state;return e?(0,i.jsx)(`div`,{className:`flex min-h-full w-full items-center justify-center p-3`,style:{background:`var(--ds-bg-canvas)`},children:(0,i.jsx)(u,{level:`unknown`,title:`插件页面异常`,description:this.props.surface===`popup`?`弹窗加载失败，请刷新后重试。`:`侧边栏加载失败，请刷新后重试。`,retry:{label:`刷新插件页面`,onClick:this.reset},detail:f(e)})}):this.props.children}};export{p as t};