import"../chunks/DToMSu1u.js";import{i as g}from"../chunks/Z7XlGwft.js";import{p,a as T,$ as b}from"../chunks/DkzsT1tV.js";import{h as f}from"../chunks/t-9fuuam.js";import{o as w}from"../chunks/BUyMPgut.js";import{f as l,u as m,T as _,R as e,O as E,g as v,C as x,i as y,j as C,k as N,F as h,l as S,m as A,q as F,x as L,y as D}from"../chunks/DQBHV93I.js";const u=l.createContext({state:"loading",tabsApi:null,error:void 0}),H=()=>l.useContext(u),z=({children:n})=>{const{fin:t}=m(),[a,i]=l.useState({state:"loading",tabsApi:null,error:void 0});return l.useEffect(()=>{t&&(async()=>{try{const r=await _.initialize(t);i({state:"loaded",tabsApi:r})}catch(r){i({state:"error",error:r,tabsApi:null})}})()},[t]),e.createElement(u.Provider,{value:a},n)},P="_landingContainer_zdptl_1",$="_landingHeader_zdptl_13",I="_landingHeaderText_zdptl_20",k="_landingTimeStamp_zdptl_29",O="_landingDateText_zdptl_37",R="_landingTimeText_zdptl_45",M="_landingFooter_zdptl_53",j="_landingNewTabLogo_zdptl_61",o={landingContainer:P,landingHeader:$,landingHeaderText:I,landingTimeStamp:k,landingDateText:O,landingTimeText:R,landingFooter:M,landingNewTabLogo:j};function U(){const[n,t]=l.useState(null);if(l.useEffect(()=>{t(new Date);const r=setInterval(()=>{t(new Date)},1e3);return()=>clearInterval(r)},[]),!n)return e.createElement(e.Fragment,null);const a=n.toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric"}),i=n.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0});return e.createElement("div",{className:o.landingTimeStamp},e.createElement("span",{className:o.landingDateText},a),e.createElement("span",{className:o.landingTimeText},i))}function V(){return e.createElement(E,null,e.createElement(v,null,e.createElement(x,{skip:["launcher"]},e.createElement(z,null,e.createElement(q,null)))))}const q=()=>{const{logo:n}=y(),{fin:t}=m(),{tabsApi:a}=H(),i=l.useCallback(async r=>{if(!t||!a)return console.error("Fin or TabsApi not available");const s=r.type==="supertab"?C(r):N(r),c=await t.Platform.Layout.getLayoutByViewIdentity(t.me.identity),d=c.identity.layoutName;(await c.getCurrentViews()).length===1?await a.replaceTab({layoutName:d,tab:s,activate:!0}):await a.addTab({tab:s,activate:!0,target:{targetLayoutName:d,position:"after"}})},[t,a]);return e.createElement(e.Fragment,null,e.createElement("div",{className:o.landingContainer},e.createElement("div",{className:o.landingHeader},e.createElement("span",{className:o.landingHeaderText},"Featured Content"),e.createElement(U,null)),e.createElement(h,{launchApp:i,launchSuperTab:i})),e.createElement("div",{className:o.landingNewTabLogo},e.createElement("img",{src:n.newTab,width:32,height:32,alt:"New Tab Logo"})),e.createElement("footer",{className:o.landingFooter}))};function Y(n,t){p(t,!1),w(async()=>{await A.getInstance().connect({connectionInheritance:"enabled"})});const a=S({NewTab:V},{ReactDOM:D,createPortal:L.createPortal,renderToString:F.renderToString});g(),f(i=>{b.title="New Tab"}),a.NewTab(n,{}),T()}export{Y as component};
