1import{r as a,b as k,e as _,u as w,j as e,A as S,m as E,Z as D,X as A,s as m}from"./index-KSWbwNeY.js";import{C as I}from"./clock-CzRotAbS.js";const R=3*60*60*1e3,q=["/admin","/checkout","/auth","/visual-stories"],O=()=>{const[g,b]=a.useState(!1),[l,c]=a.useState(!1),[o,x]=a.useState(0),[d,j]=a.useState(null),{pathname:N}=k(),v=_(),{user:r}=w();a.useEffect(()=>{if(!r){c(!1);return}(async()=>{try{const[t,i,n]=await Promise.all([m.from("profiles").select("created_at").eq("id",r.id).single(),m.from("user_subscriptions").select("id").eq("user_id",r.id).eq("status","active").maybeSingle(),m.from("subscription_plans").select("id, name, price_inr").eq("billing_period","yearly").eq("is_active",!0).eq("includes_print",!1).order("display_order",{ascending:!0}).limit(1).single()]);if(t.error||!t.data||i.data||n.error||!n.data)return;const h=new Date(t.data.created_at).getTime()+R-Date.now();h>0&&(x(h),j(n.data),c(!0))}catch(t){console.error("Welcome offer check failed:",t)}})()},[r]),a.useEffect(()=>{if(!l||o<=0)return;const s=setInterval(()=>{x(t=>{const i=t-1e3;return i<=0?(c(!1),clearInterval(s),0):i})},1e3);return()=>clearInterval(s)},[l]);const u=a.useCallback(s=>{const t=Math.max(0,Math.floor(s/1e3)),i=Math.floor(t/3600),n=Math.floor(t%3600/60),p=t%60;return`${i.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}:${p.toString().padStart(2,"0")}`},[]);if(q.some(s=>N.startsWith(s))||!l||!d||g)return null;const f=d.price_inr/100,y=Math.round(f/2);return e.jsx(S,{children:e.jsx(E.div,{initial:{y:100,opacity:0},animate:{y:0,opacity:1},exit:{y:100,opacity:0},transition:{delay:.5,duration:.5,ease:[.25,.46,.45,.94]},className:"fixed bottom-0 left-0 right-0 z-50",children:e.jsx("div",{className:"w-full",children:e.jsxs("div",{className:"relative overflow-hidden bg-foreground
1/95 backdrop-blur-md text-background shadow-[0_-4px_30px_rgba(0,0,0,0.3)]",children:[e.jsx("div",{className:"absolute top-0 left-0 right-0 h-[2px]",children:e.jsx("div",{className:"h-full bg-gradient-to-r from-amber-400 via-orange-500 to-red-500 animate-pulse"})}),e.jsxs("div",{className:"px-4 sm:px-6 py-3 sm:py-4",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-0.5 bg-amber-500/20 text-amber-400 rounded-full text-[10px] font-bold tracking-widest uppercase",children:[e.jsx(D,{className:"w-3 h-3"}),"Limited Time Offer"]}),e.jsxs("span",{className:"text-[11px] sm:text-xs text-background/50",children:["One-time welcome discount · Expires in"," ",e.jsx("span",{className:"font-mono font-semibold text-amber-400",children:u(o)})]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("div",{className:"flex items-center gap-3 min-w-0 flex-1 justify-center sm:justify-start",children:e.jsxs("p",{className:"text-sm sm:text-base font-medium",children:[e.jsx("span",{className:"font-semibold",children:"Avail 50% off"}),e.jsx("span",{className:"mx-1.5 text-background/30",children:"·"}),e.jsxs("span",{className:"text-background/80",children:["Digital Yearly at"," ",e.jsxs("span",{className:"font-bold text-amber-400 text-base sm:text-lg",children:["â¹",y.toLocaleString("en-IN")]}),e.jsxs("span",{className:"ml-1.5 line-through text-background/40 text-xs",children:["â¹",f.toLocaleString("en-IN")]})]}),e.jsx("span",{className:"hidden sm:inline mx-1.5 text-background/30",children:"·"}),e.jsx("span",{className:"hidden sm:inline text-[11px] text-background/50",children:"for the next 3 hours only"})]})}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("div",{className:"flex sm:hidden items-center gap-1 text-[11px] font-mono text-background/60",children:[e.jsx(I,{className:"w-3 h-3"}),e.jsx("span",{children:u(o)})]}),e.jsx("button",{onClick:()=>v(`/checkout?plan=${d.id}&welcome_offer=true`),className:"inline-flex items-center gap-1.5 px-5 py-2 bg-amber-500 text-slate-900 text-xs sm:text-sm font-bold rounded-lg hover:bg-amber-400 transition-all duration-200 hover:scale-[1.03] active:scale-[0.97] shadow-lg shadow-amber-500/20",children:"Claim Now"}),e.jsx("button",{onClick:()=>b(!0),className:"p-1.5 rounded-md text-background/40 hover:text-background/80 transition-colors","aria-label":"Dismiss",children:e.jsx(A,{className:"h-4 w-4"})})]})]})]})]})})})})};export{O as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.