import{j as e}from"./radix-ui-CVZWoPyd.js";import{r as t}from"./react-vendor-BmlOtb7g.js";import{L as s}from"./react-router-DzDVDRUd.js";import{S as r}from"./SEO-BGpcOjpb.js";import{A as a}from"./AppSidebar-BQ3UxiE1.js";import"./index-BCSgDlp8.js";import"./supabase-C8kocL5G.js";import"./utils-Ceo22G_t.js";import"./use-mobile-onbIdywO.js";import"./CheckoutButton-BXcL0vXQ.js";import"./analytics-CgKQjs6u.js";import"./arrow-right-CcptuZBy.js";import"./wrench-n19foI4n.js";import"./x-DIEzjPMA.js";import"./log-out-DrMwdybL.js";import"./briefcase-Cj6O7NU7.js";import"./circle-plus-C5zM2HoU.js";import"./sparkles-D1jOictl.js";import"./trending-up-DMpQ-MB3.js";import"./building-2-xmYyS5DZ.js";import"./book-open-D7nUFbtH.js";import"./settings-BQk8nNSr.js";import"./chevron-right-D_Z5YBDv.js";import"./chevron-left-D5q9zZf8.js";import"./credit-card-CUy9-vWB.js";const o=["https://images.unsplash.com/photo-1552664730-d307ca884978?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80","https://images.unsplash.com/photo-1460925895917-afdab827c52f?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80","https://images.unsplash.com/photo-1553877522-43269d4ea984?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80","https://images.unsplash.com/photo-1551288049-bebda4e38f71?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80","https://images.unsplash.com/photo-1556761175-b413da4baf72?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80","https://images.unsplash.com/photo-1554774853-aae0a22c8aa4?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80","https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80","https://images.unsplash.com/photo-1521737604893-d14cc237f11d?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80","https://images.unsplash.com/photo-1542744173-8e7e53415bb0?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80","https://images.unsplash.com/photo-1517048676732-d65bc937f952?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80"],l=()=>{const[l,i]=t.useState([]),[n,d]=t.useState(!0),[c,m]=t.useState(null),[h,u]=t.useState(1);t.useEffect(()=>{var e,t,s;e=void 0,t=null,s=function*(){try{d(!0);const e=yield fetch("/api/blog-posts");if(!e.ok)throw new Error(`HTTP error! status: ${e.status}`);const t=yield e.json();i(t.posts||[])}catch(e){m(e instanceof Error?e.message:"Failed to load posts"),console.error("Error fetching blog posts:",e)}finally{d(!1)}},new Promise((r,a)=>{var o=e=>{try{i(s.next(e))}catch(t){a(t)}},l=e=>{try{i(s.throw(e))}catch(t){a(t)}},i=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,l);i((s=s.apply(e,t)).next())})},[]);const x=Math.ceil(l.length/10),p=10*(h-1),g=p+10,b=l.slice(p,g),f=e=>{u(e),window.scrollTo({top:0,behavior:"smooth"})},j=e=>{let t=0;for(let r=0;r<e.length;r++){t=(t<<5)-t+e.charCodeAt(r),t&=t}const s=Math.abs(t)%o.length;return o[s]};return e.jsxs("div",{className:"flex h-screen",children:[e.jsx(r,{title:"Marketing Automation Blog",description:"Stay updated with the latest marketing news, tips, and insights from the MarketingGuide AI team. Explore articles on AI in marketing, strategy, and more.",canonical:"undefined"!=typeof window?window.location.href:"/blog",keywords:["marketing automation blog","business growth strategies","marketing tips","AI marketing","digital marketing insights","marketing automation strategies","business marketing blog","marketing best practices"]}),e.jsx(a,{}),e.jsx("div",{className:"flex-1 overflow-y-auto bg-slate-50",children:e.jsxs("div",{className:"container mx-auto px-4 sm:px-6 lg:px-8 py-12",children:[e.jsxs("div",{className:"text-center mb-12",children:[e.jsxs("h1",{className:"text-4xl sm:text-5xl md:text-6xl font-bold tracking-tight text-slate-900 leading-tight mb-4",children:["Blogs on ",e.jsx("span",{className:"text-gradient",children:"marketing automation"})," & business growth"]}),e.jsx("p",{className:"text-lg text-slate-600 leading-relaxed max-w-2xl mx-auto",children:"Insights, strategies, and expert advice to help you master marketing automation and grow your business."})]}),n?e.jsx("div",{className:"text-center py-16",children:e.jsxs("div",{className:"inline-flex items-center gap-3 text-slate-600",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"}),e.jsx("span",{className:"text-lg",children:"Loading articles..."})]})}):c?e.jsx("div",{className:"text-center py-16",children:e.jsxs("div",{className:"bg-red-50 border border-red-200 rounded-xl p-6 max-w-md mx-auto",children:[e.jsx("p",{className:"text-red-600 font-medium",children:"Error loading posts"}),e.jsx("p",{className:"text-red-500 text-sm mt-1",children:c})]})}):0===l.length?e.jsx("div",{className:"text-center py-16",children:e.jsxs("div",{className:"bg-slate-50 rounded-2xl p-8 max-w-md mx-auto",children:[e.jsx("div",{className:"w-16 h-16 bg-gradient-to-r from-blue-100 to-blue-50 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx("svg",{className:"w-8 h-8 text-slate-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 20H5a2 2 0 01-2-2V6a2 2 0 012-2h10a2 2 0 012 2v1m2 13a2 2 0 01-2-2V7m2 13a2 2 0 01-2-2V9a2 2 0 00-2-2h-2m-4-3H9M7 16h6M7 8h6v4H7V8z"})})}),e.jsx("h3",{className:"text-xl font-semibold text-slate-800 mb-2",children:"No Posts Yet"}),e.jsx("p",{className:"text-slate-600",children:"We're working on some great content for you. Check back soon!"})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between items-center mb-8",children:[e.jsxs("p",{className:"text-sm text-slate-600",children:["Showing ",p+1,"-",Math.min(g,l.length)," of ",l.length," articles"]}),e.jsxs("p",{className:"text-sm text-slate-500",children:["Page ",h," of ",x]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 lg:gap-8",children:b.map(t=>{var r;return e.jsxs("div",{className:"bg-white/80 backdrop-blur-sm rounded-xl shadow-lg border border-slate-200/60 hover:shadow-xl transition-all duration-500 group overflow-hidden",children:[e.jsx(s,{to:`/blog/${t.slug}`,className:"block",children:e.jsxs("div",{className:"aspect-video overflow-hidden bg-slate-100",children:[e.jsx("img",{src:t.featured_image_url||j(t.id),alt:t.title,className:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-105",onError:e=>{if(t.featured_image_url&&e.currentTarget.src===t.featured_image_url)e.currentTarget.src=j(t.id);else{e.currentTarget.style.display="none";const t=e.currentTarget.nextElementSibling;t&&(t.style.display="flex")}}}),e.jsx("div",{className:"w-full h-full bg-gradient-to-br from-blue-100 to-blue-50 flex items-center justify-center",style:{display:"none"},children:e.jsx("div",{className:"text-center",children:e.jsx("div",{className:"w-16 h-16 bg-gradient-to-r from-blue-600 to-blue-500 rounded-xl flex items-center justify-center mx-auto mb-2",children:e.jsx("svg",{className:"w-8 h-8 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})})})})]})}),e.jsx("div",{className:"bg-blue-500/15 p-6 border-b border-slate-200/60",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"w-12 h-12 bg-gradient-to-r from-blue-600 to-blue-500 rounded-xl flex items-center justify-center shrink-0",children:e.jsx("svg",{className:"w-6 h-6 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-xl font-semibold text-slate-800 leading-normal mb-1",children:t.title}),e.jsxs("p",{className:"text-xs text-slate-500 leading-normal uppercase tracking-wider",children:[(null==(r=t.categories)?void 0:r[0])||t.category||"BLOG POST"," • ",new Date(t.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})]})]})]})}),e.jsxs("div",{className:"p-6",children:[e.jsx("p",{className:"text-base text-slate-700 leading-relaxed mb-6",children:t.excerpt||t.summary||(t.content?t.content.substring(0,150)+"...":"Read this insightful article about marketing automation and business growth strategies.")}),e.jsxs(s,{to:`/blog/${t.slug}`,className:"w-full inline-flex items-center justify-center px-6 py-2 bg-blue-50 hover:bg-blue-100 text-blue-700 rounded-full text-sm font-medium transition-all duration-200 border border-blue-200 hover:shadow-md hover:scale-105 focus:ring-2 focus:ring-blue-300 focus:outline-none group-hover:bg-blue-600 group-hover:text-white group-hover:border-blue-600",children:["Read Article",e.jsx("svg",{className:"ml-2 h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]})]})]},t.id)})}),x>1&&e.jsxs("div",{className:"flex justify-center items-center gap-2 mt-12",children:[e.jsx("button",{onClick:()=>f(h-1),disabled:1===h,className:"px-4 py-2 rounded-lg font-medium transition-all duration-200 "+(1===h?"bg-slate-100 text-slate-400 cursor-not-allowed":"bg-white text-slate-700 hover:bg-blue-50 hover:text-blue-600 border border-slate-200 hover:border-blue-200 shadow-sm hover:shadow"),children:"Previous"}),e.jsx("div",{className:"flex gap-1",children:Array.from({length:x},(e,t)=>t+1).map(t=>1===t||t===x||t>=h-1&&t<=h+1?e.jsx("button",{onClick:()=>f(t),className:"w-10 h-10 rounded-lg font-medium transition-all duration-200 "+(h===t?"bg-blue-600 text-white shadow-lg":"bg-white text-slate-700 hover:bg-blue-50 hover:text-blue-600 border border-slate-200 hover:border-blue-200 shadow-sm hover:shadow"),children:t},t):t===h-2||t===h+2?e.jsx("span",{className:"px-3 py-2 text-slate-500",children:"..."},t):null)}),e.jsx("button",{onClick:()=>f(h+1),disabled:h===x,className:"px-4 py-2 rounded-lg font-medium transition-all duration-200 "+(h===x?"bg-slate-100 text-slate-400 cursor-not-allowed":"bg-white text-slate-700 hover:bg-blue-50 hover:text-blue-600 border border-slate-200 hover:border-blue-200 shadow-sm hover:shadow"),children:"Next"})]}),0===l.length&&!n&&!c&&e.jsx("div",{className:"text-center py-12",children:e.jsx("p",{className:"text-base text-slate-600 leading-relaxed",children:"No blog posts available at the moment."})})]})]})})]})};export{l as default};