import{E as e,r as s,z as a}from"./vendor-s2rfM_Vj.js";import{g as t,L as r,H as o,s as n}from"./apis-DdFSvwR4.js";import{f as i}from"./newtab-BWIjnu6l.js";import"./constant-Dkm_Y9q1.js";import"./index-Bf7N7lFc.js";import"./t-r-vendor-gn7FMrPE.js";const l=""+new URL("history-today-CjOzpEm4.jpeg",import.meta.url).href,d=e("div")({name:"WrapUI",class:"w1h5769q",propsAsIs:!1}),p=e("div")({name:"ContentUI",class:"c10urs1h",propsAsIs:!1}),c=e("div")({name:"AppHeaderUI",class:"a14qhrd4",propsAsIs:!1}),m=e("i")({name:"AppHeaderPaginationUI",class:"a18b74sz",propsAsIs:!1,vars:{"a18b74sz-0":[e=>e.disable?"var(--white3)":"var(--white)"],"a18b74sz-1":[e=>e.disable?"not-allowed":"pointer"]}}),h=e("div")({name:"AppContentUI",class:"au139fy",propsAsIs:!1}),j=({iframe:e,icon:j})=>{const[g,x]=s.useState([]),[v,w]=s.useState(0),u=s.useMemo((()=>g[v]),[g,v]),{handleMessage:I}=i(),f=(e,s)=>{e.stopPropagation();let a=v+s;a<0?a=g.length-1:a>=g.length&&(a=0),w(a)};return s.useEffect((()=>{(()=>{const e=((new Date).getMonth()+1).toString().padStart(2,"0"),s=(new Date).getDate().toString().padStart(2,"0"),a=t(r.HISTORY_TODAY_KEY);a&&a.date===`${(new Date).getFullYear()}-${e}-${s} `?x(a.data):o(e,s).then((({code:a,data:t,msg:o})=>{200===a?(x(t),n(r.HISTORY_TODAY_KEY,{data:t,date:`${(new Date).getFullYear()}-${e}-${s}`})):(I.error("获取历史上的今天数据失败"),console.error(o))}))})()}),[]),a.jsx(d,{onClick:()=>{u&&window.open(u.link)},children:a.jsxs(p,{children:[a.jsx("img",{loading:"lazy",src:l,fetchPriority:"low",decoding:"async",alt:"historyToday"}),a.jsxs(c,{children:[a.jsx(m,{disable:0,className:"ovo previous",onClick:e=>f(e,-1)}),a.jsx("div",{children:"历史上的今天"}),a.jsx(m,{disable:0,className:"ovo next",onClick:e=>f(e,1)})]}),a.jsx(h,{children:u&&a.jsxs(a.Fragment,{children:[a.jsx("b",{children:u.title}),a.jsx("p",{children:+u.year>0?`公元${u.year}年`:`公元前${-u.year}年`})]})})]})})};export{j as default};
