import{a as e,n as t,t as n}from"./jsx-runtime-CutOxEx1.js";import{i as r}from"./authSession-Dulxhbeq.js";import{s as i}from"./billing-dVtO8VuE.js";var a=e(t(),1),o=n();async function s(e){let t=await fetch(`${i()}/api/billing/compensation-notice`,{headers:{Authorization:`Bearer ${e}`}});return t.ok?(await t.json()).notice??null:null}async function c(e,t){await fetch(`${i()}/api/billing/compensation-notice/ack`,{method:`POST`,headers:{Authorization:`Bearer ${t}`,"Content-Type":`application/json`},body:JSON.stringify({id:e})})}function l(){let[e,t]=(0,a.useState)(null);return(0,a.useEffect)(()=>{let e=()=>{let e=r()?.accessToken;e&&s(e).then(e=>{e&&t(e)}).catch(()=>{})};e();let n=()=>{document.visibilityState===`visible`&&e()};return document.addEventListener(`visibilitychange`,n),()=>document.removeEventListener(`visibilitychange`,n)},[]),e?(0,o.jsx)(`div`,{style:{position:`fixed`,inset:0,zIndex:9999,background:`rgba(0,0,0,0.5)`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,o.jsxs)(`div`,{style:{background:`var(--bg-card, #fff)`,border:`1px solid var(--border-subtle, #e5e7eb)`,borderRadius:16,padding:`32px 28px`,maxWidth:380,width:`90vw`,textAlign:`center`,boxShadow:`0 8px 40px rgba(0,0,0,0.18)`},children:[(0,o.jsx)(`div`,{style:{fontSize:40,marginBottom:12},children:`礼`}),(0,o.jsx)(`h2`,{style:{fontSize:18,fontWeight:700,color:`var(--text-1,#111)`,marginBottom:8},children:`积分补发通知`}),(0,o.jsx)(`p`,{style:{fontSize:14,color:`var(--text-2,#555)`,marginBottom:6,lineHeight:1.6},children:`您好，我们发现您此前的订阅积分未能及时到账，已为您补发：`}),(0,o.jsxs)(`div`,{style:{fontSize:36,fontWeight:800,color:`var(--accent-ochre,#c97c2b)`,margin:`12px 0`},children:[`+`,e.points,` 积分`]}),(0,o.jsx)(`p`,{style:{fontSize:13,color:`var(--text-3,#888)`,marginBottom:24},children:`感谢您的耐心等待，积分已到账可直接使用。`}),(0,o.jsx)(`button`,{onClick:async()=>{let n=r()?.accessToken;n&&c(e.id,n).catch(()=>{}),t(null)},style:{width:`100%`,padding:`10px 0`,background:`var(--accent-ochre,#c97c2b)`,color:`#fff`,border:`none`,borderRadius:8,fontSize:15,fontWeight:600,cursor:`pointer`},children:`好的，知道了`})]})}):null}export{l as CompensationNotice};