import('./js/storage.js').then(({ getAllProducts }) => {
  const products = getAllProducts().filter(p => p.available !== false);
  const baseUrl = 'https://' + window.location.hostname;
  
  let xml = `<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url><loc>${baseUrl}/</loc><priority>1.0</priority></url>
  <url><loc>${baseUrl}/about.html</loc><priority>0.8</priority></url>
  <url><loc>${baseUrl}/blog.html</loc><priority>0.8</priority></url>
`;

  products.forEach(p => {
    xml += `  <url>
    <loc>${baseUrl}/product.html?id=${p.id}</loc>
    <lastmod>${new Date().toISOString().split('T')[0]}</lastmod>
    <priority>0.9</priority>
  </url>\n`;
  });

  xml += `</urlset>`;

  console.log("СКОПИРУЙ ЭТОТ ТЕКСТ, СОЗДАЙ ФАЙЛ sitemap.xml И ПОЛОЖИ В ПАПКУ ПРОЕКТА:");
  console.log(xml);
});