import{i as e}from"./chunk-B3pr0VN8.js";import{n as t,t as n}from"./jsx-runtime-wTfS3W87.js";import{t as r}from"./client-DDZ1qWKB.js";var i=e(r(),1),a=e(t(),1),o=n();function s(e){let{args:t,onResolve:n}=e;(0,a.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n(`cancel`)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]);let r=t.mode===`auto`?`当前为自动兜底模式：系统会先自动尝试可用替代模型，全部失败后再提示你手动处理。`:`当前为每次失败先征求我模式，不会擅自替你换模型。`,i=String(t.reason||``).trim();return(0,o.jsx)(`div`,{className:`ui-overlay`,style:{display:`flex`,alignItems:`center`,justifyContent:`center`,padding:16},onClick:()=>n(`cancel`),children:(0,o.jsxs)(`div`,{className:`ui-modal`,style:{width:`min(560px, 100%)`,maxHeight:`min(88vh, 760px)`,overflowY:`auto`},onClick:e=>e.stopPropagation(),children:[(0,o.jsxs)(`div`,{style:{padding:20,borderBottom:`1px solid var(--border)`,display:`flex`,alignItems:`flex-start`,justifyContent:`space-between`,gap:12},children:[(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`div`,{style:{fontSize:18,fontWeight:700,color:`var(--text-1)`},children:`当前模型未成功`}),(0,o.jsx)(`div`,{style:{marginTop:6,fontSize:13,lineHeight:1.6,color:`var(--text-2)`},children:r})]}),(0,o.jsx)(`button`,{type:`button`,className:`btn-ghost`,onClick:()=>n(`cancel`),"aria-label":`关闭`,children:`关闭`})]}),(0,o.jsxs)(`div`,{style:{padding:20,display:`grid`,gap:14},children:[(0,o.jsx)(`div`,{className:`ui-alert ui-alert-warn`,style:{whiteSpace:`pre-wrap`},children:`失败原因：${i||`模型暂时不可用，请稍后重试。`}`}),(0,o.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr`,gap:12},children:[(0,o.jsxs)(`div`,{style:{border:`1px solid var(--border)`,borderRadius:14,padding:14,background:`var(--surface2)`},children:[(0,o.jsx)(`div`,{style:{fontSize:12,color:`var(--text-2)`},children:`当前模型`}),(0,o.jsx)(`div`,{style:{marginTop:6,fontSize:16,fontWeight:700,color:`var(--text-1)`},children:t.currentLabel}),(0,o.jsx)(`div`,{style:{marginTop:6,fontSize:12,color:`var(--text-2)`},children:`计费：以积分预检与实际 token 落账为准`}),(0,o.jsx)(`div`,{style:{marginTop:4,fontSize:12,color:`var(--text-2)`},children:`本次失败不按失败模型扣积分`})]}),(0,o.jsxs)(`div`,{style:{border:`1px solid rgba(200,90,34,0.22)`,borderRadius:14,padding:14,background:`var(--accent-lt)`},children:[(0,o.jsx)(`div`,{style:{fontSize:12,color:`var(--text-2)`},children:`建议替代模型`}),(0,o.jsx)(`div`,{style:{marginTop:6,fontSize:16,fontWeight:700,color:`var(--text-1)`},children:t.nextLabel}),(0,o.jsx)(`div`,{style:{marginTop:6,fontSize:12,color:`var(--text-2)`},children:`计费：切换后按新模型价格重新预检`}),(0,o.jsx)(`div`,{style:{marginTop:4,fontSize:12,color:`var(--text-2)`},children:`重新生成前会重新确认余额`})]})]}),(0,o.jsxs)(`div`,{style:{border:`1px solid var(--border)`,borderRadius:14,padding:14,background:`var(--surface)`},children:[(0,o.jsx)(`div`,{style:{fontSize:13,fontWeight:700,color:`var(--text-1)`},children:`计费说明`}),(0,o.jsx)(`div`,{style:{marginTop:8,fontSize:13,lineHeight:1.75,color:`var(--text-2)`,whiteSpace:`pre-wrap`},children:`- 当前失败模型的这次生成不会按失败模型扣积分
- 若该次请求已产生预扣，会先退回，再按新模型重新扣积分
- 最终以实际成功模型的 Token、阶梯价格和统一安全系数记账`})]})]}),(0,o.jsxs)(`div`,{style:{padding:20,borderTop:`1px solid var(--border)`,display:`flex`,justifyContent:`flex-end`,gap:10,flexWrap:`wrap`},children:[(0,o.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>n(`manual_always`),children:`始终手动确认`}),(0,o.jsx)(`button`,{type:`button`,className:`btn-primary`,onClick:()=>n(`switch_once`),children:`仅本次自动切换`})]})]})})}var c=e=>new Promise(t=>{let n=document.createElement(`div`);document.body.appendChild(n);let r=(0,i.createRoot)(n);r.render((0,o.jsx)(s,{args:e,onResolve:e=>{try{r.unmount()}catch{}try{n.remove()}catch{}t(e)}}))});export{c as showModelFallbackDialog};