File: /var/www/quadcode.com/.svelte-kit/adapter-node/entries/endpoints/sitemap.xml/_server.ts.js
import{b as u}from"../../../chunks/shared-server.js";import{P as s}from"../../../chunks/public.js";import{e as w}from"../../../chunks/index.js";import{g as x}from"../../../chunks/blog.js";const r=["en","pt","th","es","ru","vi"],n="en",v=60*60*1e3*24;let i=null,f=0;async function R(){const c=Date.now();if(i&&c-f<v)return new Response(i,{headers:{"X-Cache":"HIT","Content-Type":"application/xml","Cache-Control":"public, max-age=86400, stale-while-revalidate=3600"}});if(!u?.PRIVATE_WP_URL)throw w(404,{message:".env PRIVATE_WP_URL: undefined"});let m;const g=e=>{let t=`<url><loc>${s}/${e}</loc>`;return r.map(l=>{l!==n&&(t+=`<xhtml:link rel="alternate" hreflang="${l}" href="${s}/${l}/${e}"/>`)}),t+="</url>",t},d=["","about/","back-office/","cookie-policy/","events/","blog/","news/","marketing-guide/","privacy-policy/","team/","terms-and-conditions/","trading-platform/","turnkey-solution/","under-construction/","video-tutorials/","vulnerability-disclosure-policy/","webinars/","white-label-broker/","glossary/","business-plan/","prop-firm/","white-label-binary-options/","for-traders/"];try{[m]=await Promise.all([fetch(`${u.PRIVATE_WP_URL}/wp-json/api/v1/sitemap`,{headers:{"content-type":"Application/json"}})])}catch{throw w(500,"Could not load data for param values.")}const p=await m.json(),a=[];for(const e of p){let t="";t+=`<url><loc>${s}${e.url}</loc>`;const l=e.alternatives;r.filter(o=>o!==n).map(o=>{l&&Array.from(Object.keys(l)).includes(o)?t+=`<xhtml:link rel="alternate" hreflang="${o}" href="${s}/${o}${l[o]}"/>`:t+=`<xhtml:link rel="alternate" hreflang="${o}" href="${s}/${o}${e.url}"/>`}),t+="</url>",a.push(t)}const $=x(),b=new Set(p.map(e=>e.url));for(const e of $){const t=`/blog/${e}`;if(!b.has(t)){let l=`<url><loc>${s}${t}</loc>`;r.filter(o=>o!==n).forEach(o=>{l+=`<xhtml:link rel="alternate" hreflang="${o}" href="${s}/${o}${t}"/>`}),l+="</url>",a.push(l)}}const h=`
<?xml version="1.0" encoding="UTF-8" ?>
<urlset
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0"
xmlns:news="http://www.google.com/schemas/sitemap-news/0.9"
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"
>
${d.map(e=>g(e)).join("")}
${a.map(e=>e).join("")}
</urlset>`.trim();return i=h,f=c,new Response(h,{headers:{"X-Cache":"MISS","Content-Type":"application/xml","Cache-Control":"public, max-age=86400, stale-while-revalidate=3600"}})}export{R as GET};