"use strict";(()=>{var e={};e.id=962,e.ids=[962],e.modules={53524:e=>{e.exports=require("@prisma/client")},30517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},27900:(e,t,r)=>{r.r(t),r.d(t,{headerHooks:()=>h,originalPathname:()=>v,patchFetch:()=>y,requestAsyncStorage:()=>f,routeModule:()=>u,serverHooks:()=>p,staticGenerationAsyncStorage:()=>m,staticGenerationBailout:()=>g});var n={};r.r(n),r.d(n,{GET:()=>d});var i=r(95419),a=r(69108),o=r(99678),s=r(78070),l=r(34490),c=r(17288);async function d(e,{params:t}){let{slug:r}=t,n=await l.prisma.page.findUnique({where:{slug:r}});if(!n||"PUBLISHED"!==n.status)return new s.Z("Page not found",{status:404});let i=n.aiGeneratedContent;if(!i?.htmlContent)return new s.Z("No HTML content",{status:404});let a=(n.pageConfig||{}).hiddenSections||[],o=i.htmlContent;a.length>0&&(o=function(e,t){let r=e;for(let e of t){let t=RegExp(`<!-- SECTION:${e} -->[\\s\\S]*?<!-- \\/SECTION:${e} -->`,"g");r=r.replace(t,"")}return r}(o,a));let d=i.meta||{},u=(0,c.B)(o,{title:d.title||n.title,description:d.description||""},n.id,n.leadsEnabled);return new s.Z(u,{headers:{"Content-Type":"text/html; charset=utf-8","Cache-Control":"public, max-age=60"}})}let u=new i.AppRouteRouteModule({definition:{kind:a.x.APP_ROUTE,page:"/api/render/[slug]/route",pathname:"/api/render/[slug]",filename:"route",bundlePath:"app/api/render/[slug]/route"},resolvedPagePath:"C:\\test2\\pagecraft-ai\\src\\app\\api\\render\\[slug]\\route.ts",nextConfigOutput:"standalone",userland:n}),{requestAsyncStorage:f,staticGenerationAsyncStorage:m,serverHooks:p,headerHooks:h,staticGenerationBailout:g}=u,v="/api/render/[slug]/route";function y(){return(0,o.patchFetch)({serverHooks:p,staticGenerationAsyncStorage:m})}},17288:(e,t,r)=>{r.d(t,{B:()=>n});function n(e,t,r,n){let i=r?`<script>
(function(){
  var d={pageId:"${r}",referrer:document.referrer,w:window.innerWidth};
  fetch("/api/analytics/track",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)}).catch(function(){});
  document.querySelectorAll("a[href],button").forEach(function(el){
    el.addEventListener("click",function(){
      fetch("/api/analytics/track",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pageId:d.pageId,eventType:"cta_click",label:el.textContent.trim().slice(0,50)})}).catch(function(){});
    });
  });
})();
</script>`:"",a=r&&n?`<script>
(function(){
  // Detect device type from user agent
  function getDevice() {
    var ua = navigator.userAgent;
    if (/iPhone|iPad|iPod/.test(ua)) return "iOS";
    if (/Android/.test(ua)) return "Android";
    if (/Windows/.test(ua)) return "Windows";
    if (/Macintosh|Mac OS/.test(ua)) return "macOS";
    if (/Linux/.test(ua)) return "Linux";
    return ua.slice(0, 50);
  }
  document.querySelectorAll("form").forEach(function(form) {
    form.addEventListener("submit", function(e) {
      e.preventDefault();
      var data = { pageId: "${r}", source: document.title, device: getDevice() };
      var emailEl = form.querySelector("input[type=email], input[name=email]");
      var nameEl = form.querySelector("input[name=name], input[placeholder*='name' i], input[placeholder*='اسم']");
      var phoneEl = form.querySelector("input[type=tel], input[name=phone]");
      var messageEl = form.querySelector("textarea");
      var selectEl = form.querySelector("select");
      if (emailEl) data.email = emailEl.value;
      if (nameEl) data.name = nameEl.value;
      if (phoneEl) data.phone = phoneEl.value;
      if (messageEl) data.message = messageEl.value;
      if (selectEl) data.country = selectEl.options[selectEl.selectedIndex].text;
      if (!data.email && !data.phone && !data.name) {
        alert(document.documentElement.lang === "ar" ? "يرجى تعبئة البيانات المطلوبة." : "Please fill in the required fields.");
        return;
      }
      fetch("/api/leads", {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify(data)
      }).then(function(r){ return r.json(); }).then(function(res){
        if (res.success) {
          var isRtl = document.documentElement.dir === "rtl" || document.documentElement.lang === "ar" || document.body.dir === "rtl";
          var msg = isRtl ? "شكراً! سنتواصل معك قريباً." : "Thank you! We'll be in touch soon.";
          form.innerHTML = "<p style='text-align:center;padding:24px;color:#16a34a;font-size:1.1em'>✅ " + msg + "</p>";
        }
      }).catch(function(){});
    });
  });
})();
</script>`:"",o=`<script>
(function(){
  // Find the section that contains a form (the order/CTA section)
  var formEl = document.querySelector("form");
  if (!formEl) return;
  var formSection = formEl.closest("section,div[id],div[class]") || formEl.parentElement;
  if (!formSection) return;
  if (!formSection.id) formSection.id = "order-form";
  var targetId = formSection.id;

  // Make all buttons/links without a real external href scroll to the form
  document.querySelectorAll("a,button").forEach(function(el){
    // Skip: buttons inside forms (they handle submission)
    if (el.tagName === "BUTTON" && el.closest("form")) return;
    var href = el.getAttribute("href") || "";
    // Skip: external links, mailto, tel, or already pointing to a section anchor
    if (href.startsWith("http") || href.startsWith("mailto") || href.startsWith("tel")) return;
    // Skip: anchors already pointing to something other than # or empty
    if (href.startsWith("#") && href.length > 1 && href !== "#order-form") return;
    el.addEventListener("click", function(e){
      e.preventDefault();
      var target = document.getElementById(targetId);
      if (target) target.scrollIntoView({ behavior: "smooth", block: "start" });
    });
  });
})();
</script>`,s=`<script>
(function(){
  var ss=document.querySelectorAll('section');
  if(!ss.length)return;
  ss.forEach(function(s,i){if(i>0)s.classList.add('sr-hidden')});
  var n=ss.length-1;
  if(n<1)return;
  var o=new IntersectionObserver(function(ee){
    ee.forEach(function(e){
      if(e.isIntersecting){
        e.target.classList.remove('sr-hidden');
        e.target.classList.add('sr-visible');
        o.unobserve(e.target);
        n--;if(n<=0)o.disconnect();
      }
    });
  },{threshold:0.1,rootMargin:'0px 0px -50px 0px'});
  ss.forEach(function(s,i){if(i>0)o.observe(s)});
})();
</script>`;return`<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>${t.title||"PageCraft AI"}</title>
  <meta name="description" content="${t.description||""}" />
  
  <script src="https://cdn.tailwindcss.com"></script>
  
  <link rel="preconnect" href="https://fonts.googleapis.com" />
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
  <link href="https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800;900&family=Inter:wght@300;400;500;600;700;800;900&display=swap" rel="stylesheet" />
  
  <style>
    * { margin: 0; padding: 0; box-sizing: border-box; }
    body { font-family: 'Inter', sans-serif; }
    [dir="rtl"], [dir="rtl"] * { font-family: 'Cairo', sans-serif; }
    img { max-width: 100%; height: auto; }
    html { scroll-behavior: smooth; }
    section:first-of-type { padding-top: 2.5rem !important; padding-bottom: 2.5rem !important; }
    .sr-hidden { opacity: 0; transform: translateY(30px); transition: opacity 0.8s ease-out, transform 0.8s ease-out; }
    .sr-visible { opacity: 1; transform: translateY(0); }
  </style>
</head>
<body>
  ${e}
  ${i}
  ${a}
  ${o}
  ${s}
</body>
</html>`}},34490:(e,t,r)=>{r.d(t,{prisma:()=>i});var n=r(53524);let i=globalThis.prisma??new n.PrismaClient}};var t=require("../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),n=t.X(0,[1638,6206],()=>r(27900));module.exports=n})();