import{j as e}from"./query-DJMphkOq.js";import{a as m,n as w,T as L,o as S,p as T}from"./icons-B6XnNDpJ.js";import{b as O,L as j}from"./react-vendor-wls9bBVT.js";import{u as G,B as P,a as D}from"./index-BaQQEgxi.js";import"./supabase-BiHzSKx7.js";function R(a){const i=(a==null?void 0:a.replace(/<[^>]+>/g,""))||"";return Math.max(1,Math.round(i.trim().split(/\s+/).length/200))}function n(a,i,r=!1){const t=r?`meta[property="${a}"]`:`meta[name="${a}"]`;let c=document.querySelector(t);c||(c=document.createElement("meta"),r?c.setAttribute("property",a):c.setAttribute("name",a),document.head.appendChild(c)),c.setAttribute("content",i)}function q(a,i){let r=document.getElementById(a);r||(r=document.createElement("script"),r.id=a,r.type="application/ld+json",document.head.appendChild(r)),r.textContent=JSON.stringify(i)}const k={blue:"bg-blue-100/20 text-blue-300 border-blue-400/30",red:"bg-red-100/20 text-red-300 border-red-400/30",indigo:"bg-indigo-100/20 text-indigo-300 border-indigo-400/30",gray:"bg-gray-100/20 text-gray-300 border-gray-400/30",green:"bg-green-100/20 text-green-300 border-green-400/30",orange:"bg-orange-100/20 text-orange-300 border-orange-400/30",purple:"bg-purple-100/20 text-purple-300 border-purple-400/30",cyan:"bg-cyan-100/20 text-cyan-300 border-cyan-400/30"};function W(){const{slug:a}=O(),{lang:i}=G(),r=i==="cy",[t,c]=m.useState(null),[E,$]=m.useState([]),[z,I]=m.useState(!0),[M,A]=m.useState(!1);m.useEffect(()=>{Promise.all([P.filter({slug:a,status:"published"}),D.filter({is_active:!0},"sort_order")]).then(([o,s])=>{o.length>0?c(o[0]):A(!0),$(s),I(!1)})},[a]),m.useEffect(()=>{if(!t)return;const o=r&&t.title_cy?t.title_cy:t.title,s=r&&t.excerpt_cy?t.excerpt_cy:t.excerpt||t.title,l=`https://cefnitech.co.uk/blog/${t.slug}`,p=t.cover_image||"https://cefnitech.co.uk/og-image.jpg",H=t.author||"CefniTech",x=t.created_date?new Date(t.created_date).toISOString():void 0;document.title=`${o} | CefniTech Blog`,n("description",s.substring(0,160)),n("keywords",`${t.category}, IT support, CefniTech`),n("robots","index, follow"),n("author",H),n("og:type","article",!0),n("og:url",l,!0),n("og:title",o,!0),n("og:description",s.substring(0,200),!0),n("og:image",p,!0),n("og:site_name","CefniTech",!0),n("og:locale",r?"cy_GB":"en_GB",!0),x&&n("article:published_time",x,!0),n("twitter:card","summary_large_image"),n("twitter:title",o),n("twitter:description",s.substring(0,200)),n("twitter:image",p);let u=document.querySelector("link[rel='canonical']");u||(u=document.createElement("link"),u.rel="canonical",document.head.appendChild(u)),u.href=l;const f=(y,b,B)=>{let d=document.getElementById(B);d||(d=document.createElement("link"),d.id=B,d.rel="alternate",document.head.appendChild(d)),d.setAttribute("hreflang",y),d.setAttribute("href",b)};f("en-gb",l,"hreflang-en"),f("cy",`${l}?lang=cy`,"hreflang-cy"),f("x-default",l,"hreflang-default");let g=document.getElementById("blog-breadcrumb-ld");return g||(g=document.createElement("script"),g.id="blog-breadcrumb-ld",g.type="application/ld+json",document.head.appendChild(g)),g.textContent=JSON.stringify({"@context":"https://schema.org","@type":"BreadcrumbList",itemListElement:[{"@type":"ListItem",position:1,name:"Home",item:"https://cefnitech.co.uk"},{"@type":"ListItem",position:2,name:"Blog",item:"https://cefnitech.co.uk/blog"},{"@type":"ListItem",position:3,name:r&&t.title_cy?t.title_cy:t.title,item:l}]}),q("blog-post-ld",{"@context":"https://schema.org","@type":"Article",headline:o,description:s.substring(0,200),image:p,url:l,datePublished:x,dateModified:t.updated_date?new Date(t.updated_date).toISOString():x,author:{"@type":"Organization",name:"CefniTech Solutions Ltd",url:"https://cefnitech.co.uk"},publisher:{"@type":"Organization",name:"CefniTech Solutions Ltd",logo:{"@type":"ImageObject",url:"https://assets.cefnitech.co.uk/ctech-media/website-media/CefniTech_Main_Logo.png"}},mainEntityOfPage:{"@type":"WebPage","@id":l},articleSection:t.category,inLanguage:r?"cy":"en-GB"}),()=>{["blog-post-ld","blog-breadcrumb-ld","hreflang-en","hreflang-cy","hreflang-default"].forEach(y=>{const b=document.getElementById(y);b&&b.remove()})}},[t,r]);const h=o=>r&&o.title_cy?o.title_cy:o.title,v=o=>r&&o.content_cy?o.content_cy:o.content,N=o=>r&&o.excerpt_cy?o.excerpt_cy:o.excerpt,_=o=>{const s=E.find(l=>l.name===o);return s&&k[s.color]||k.blue},C=t?R(v(t)):0;return z?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-white dark:bg-gray-950",children:e.jsx("div",{className:"w-8 h-8 border-4 border-blue-600 border-t-transparent rounded-full animate-spin"})}):M||!t?e.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center bg-white dark:bg-gray-950 text-center px-6",children:[e.jsx("h1",{className:"text-3xl font-black text-gray-900 dark:text-white mb-4",children:r?"Nid yw'r erthygl hon i'w gweld":"Article not found"}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-8",children:r?"Mae'n bosib bod yr erthygl hon wedi'i symud neu ei dileu.":"This article may have been moved or removed."}),e.jsxs(j,{to:"/Blog",className:"text-blue-600 font-semibold hover:underline flex items-center gap-2",children:[e.jsx(w,{className:"w-4 h-4"})," ",r?"Yn ôl i'r Blog":"Back to Blog"]})]}):e.jsxs("div",{className:"bg-white dark:bg-gray-950 min-h-screen",children:[e.jsx("style",{children:`
        .blog-content { font-size: 1.0625rem; line-height: 1.85; }
        .blog-content h2 { font-size: 1.45rem; font-weight: 800; color: #111827; margin-top: 2.25rem; margin-bottom: 0.75rem; line-height: 1.3; }
        .blog-content h3 { font-size: 1.15rem; font-weight: 700; color: #1f2937; margin-top: 1.75rem; margin-bottom: 0.5rem; }
        .blog-content p { margin-bottom: 1.35rem; line-height: 1.85; color: #374151; }
        .blog-content ul { margin-bottom: 1.35rem; padding-left: 1.75rem; list-style-type: disc; }
        .blog-content ul li { margin-bottom: 0.5rem; line-height: 1.75; color: #374151; }
        .blog-content ol { margin-bottom: 1.35rem; padding-left: 1.75rem; list-style-type: decimal; }
        .blog-content ol li { margin-bottom: 0.5rem; line-height: 1.75; color: #374151; }
        .blog-content strong { font-weight: 700; color: #111827; }
        .blog-content a { color: #3189d0; text-decoration: underline; text-underline-offset: 2px; }
        .blog-content a:hover { color: #2165a8; }
        .blog-content blockquote { border-left: 4px solid #3189d0; padding: 0.75rem 1.25rem; margin: 2rem 0; background: #f0f7ff; border-radius: 0 8px 8px 0; color: #1e40af; font-style: italic; }
        .blog-content hr { border: none; border-top: 1px solid #e5e7eb; margin: 2.5rem 0; }
        .blog-content img { max-width: 100%; height: auto; border-radius: 12px; margin: 2rem auto; display: block; }
        .blog-content pre { background: #1e293b; color: #e2e8f0; padding: 1.25rem; border-radius: 10px; overflow-x: auto; margin: 1.5rem 0; font-size: 0.875rem; }
        .blog-content code { background: #f1f5f9; color: #1e293b; padding: 0.15em 0.4em; border-radius: 4px; font-size: 0.875em; }
        .blog-content pre code { background: none; color: inherit; padding: 0; }
        .dark .blog-content h2 { color: #f9fafb; }
        .dark .blog-content h3 { color: #f3f4f6; }
        .dark .blog-content p { color: #d1d5db; }
        .dark .blog-content ul li, .dark .blog-content ol li { color: #d1d5db; }
        .dark .blog-content strong { color: #f9fafb; }
        .dark .blog-content blockquote { background: #1e3a5f; color: #93c5fd; border-left-color: #3189d0; }
        .dark .blog-content code { background: #1e293b; color: #e2e8f0; }
      `}),t.cover_image?e.jsxs("div",{className:"relative w-full overflow-hidden",style:{height:"460px"},children:[e.jsx("img",{src:t.cover_image,alt:h(t),loading:"eager",className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-gray-950 via-gray-950/60 to-gray-950/10"}),e.jsx("div",{className:"absolute top-0 left-0 right-0 px-6 pt-6",children:e.jsx("div",{className:"max-w-4xl mx-auto",children:e.jsxs(j,{to:"/Blog",className:"inline-flex items-center gap-1.5 text-white/70 hover:text-white text-xs font-bold uppercase tracking-widest transition-colors group",children:[e.jsx(w,{className:"w-3.5 h-3.5 group-hover:-translate-x-0.5 transition-transform"}),r?"Yn ôl i'r Blog":"Back to Blog"]})})}),e.jsx("div",{className:"absolute bottom-0 left-0 right-0 px-6 pb-8",children:e.jsxs("div",{className:"max-w-4xl mx-auto",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3 mb-4",children:[e.jsxs("span",{className:`text-xs font-bold px-3 py-1.5 rounded-full border flex items-center gap-1.5 ${_(t.category)}`,children:[e.jsx(L,{className:"w-3 h-3"}),t.category]}),e.jsxs("span",{className:"text-white/50 text-xs flex items-center gap-1.5",children:[e.jsx(S,{className:"w-3.5 h-3.5"}),new Date(t.created_date).toLocaleDateString(r?"cy-GB":"en-GB",{day:"numeric",month:"long",year:"numeric"})]}),e.jsxs("span",{className:"text-white/50 text-xs flex items-center gap-1.5",children:[e.jsx(T,{className:"w-3.5 h-3.5"}),C," ",r?"mun darllen":"min read"]})]}),e.jsx("h1",{className:"text-3xl md:text-5xl font-black text-white tracking-tight leading-[1.1] drop-shadow-lg",children:h(t)})]})})]}):e.jsx("div",{className:"bg-gray-950 border-b border-white/5 px-6 py-10",children:e.jsxs("div",{className:"max-w-4xl mx-auto",children:[e.jsxs(j,{to:"/Blog",className:"inline-flex items-center gap-1.5 text-blue-400 hover:text-blue-300 text-xs font-bold uppercase tracking-widest mb-6 transition-colors group",children:[e.jsx(w,{className:"w-3.5 h-3.5 group-hover:-translate-x-0.5 transition-transform"}),r?"Yn ôl i'r Blog":"Back to Blog"]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 mb-4",children:[e.jsxs("span",{className:`text-xs font-bold px-3 py-1.5 rounded-full border flex items-center gap-1.5 ${_(t.category)}`,children:[e.jsx(L,{className:"w-3 h-3"}),t.category]}),e.jsxs("span",{className:"text-gray-500 text-xs flex items-center gap-1.5",children:[e.jsx(S,{className:"w-3.5 h-3.5"}),new Date(t.created_date).toLocaleDateString(r?"cy-GB":"en-GB",{day:"numeric",month:"long",year:"numeric"})]}),e.jsxs("span",{className:"text-gray-500 text-xs flex items-center gap-1.5",children:[e.jsx(T,{className:"w-3.5 h-3.5"}),C," ",r?"mun darllen":"min read"]})]}),e.jsx("h1",{className:"text-3xl md:text-5xl font-black text-white tracking-tight leading-[1.1]",children:h(t)})]})}),e.jsxs("div",{className:"max-w-4xl mx-auto px-6 py-12",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3 mb-10 pb-8 border-b border-gray-100 dark:border-gray-800",children:[e.jsx("div",{className:"w-9 h-9 rounded-full bg-blue-600 flex items-center justify-center text-white text-xs font-black shrink-0",children:"G"}),e.jsxs("div",{className:"shrink-0",children:[e.jsx("p",{className:"text-sm font-bold text-gray-900 dark:text-white whitespace-nowrap",children:"Gethyn Jones"}),e.jsx("p",{className:"text-xs text-gray-400",children:"CefniTech"})]}),N(t)&&e.jsx("p",{className:"text-gray-500 dark:text-gray-400 text-sm leading-relaxed border-l border-gray-200 dark:border-gray-700 pl-4 hidden md:block line-clamp-2 flex-1 min-w-0",children:N(t)})]}),e.jsx("article",{className:"blog-content",dangerouslySetInnerHTML:{__html:v(t)}}),(t.source_url||t.source_feed)&&e.jsxs("div",{className:"mt-10 bg-blue-50 dark:bg-blue-950/40 border border-blue-100 dark:border-blue-900 rounded-2xl p-5",children:[e.jsx("p",{className:"text-xs text-blue-500 font-bold uppercase tracking-wider mb-1",children:r?"Ffynhonnell a Chredyd":"Source & Attribution"}),e.jsxs("p",{className:"text-gray-600 dark:text-gray-400 text-sm",children:[r?"Ysbrydolwyd yr erthygl hon gan gynnwys o ":"This article was inspired by content from ",t.source_url?e.jsx("a",{href:t.source_url,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 dark:text-blue-400 hover:underline font-medium",children:t.source_feed||t.source_url}):e.jsx("span",{className:"font-medium",children:t.source_feed}),r?". Mae'r cynnwys wedi'i ailysgrifennu yn llawn gan CefniTech.":". Content has been fully rewritten by CefniTech."]})]}),e.jsxs("div",{className:"mt-8 pt-8 border-t border-gray-100 dark:border-gray-800 flex items-center gap-3 flex-wrap",children:[e.jsx("span",{className:"text-xs text-gray-400 font-bold uppercase tracking-wider mr-1",children:r?"Rhannu":"Share"}),[{href:`https://www.facebook.com/sharer/sharer.php?u=https://cefnitech.co.uk/blog/${t.slug}`,label:"Facebook",color:"bg-blue-600",svg:e.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"})})},{href:`https://twitter.com/intent/tweet?url=https://cefnitech.co.uk/blog/${t.slug}&text=${encodeURIComponent(h(t))}`,label:"X",color:"bg-gray-900",svg:e.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})})},{href:`https://wa.me/?text=${encodeURIComponent(h(t)+" - https://cefnitech.co.uk/blog/"+t.slug)}`,label:"WhatsApp",color:"bg-green-500",svg:e.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z"})})},{href:`https://www.linkedin.com/sharing/share-offsite/?url=https://cefnitech.co.uk/blog/${t.slug}`,label:"LinkedIn",color:"bg-blue-700",svg:e.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.062 2.062 0 01-2.063-2.065 2.064 2.064 0 112.063 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"})})}].map(o=>e.jsx("a",{href:o.href,target:"_blank",rel:"noopener noreferrer","aria-label":`Share on ${o.label}`,className:`w-9 h-9 rounded-xl ${o.color} flex items-center justify-center text-white hover:opacity-80 hover:scale-105 transition-all`,children:o.svg},o.label))]})]})]})}export{W as default};