import json

with open("D:/Evolução categorias/.worktrees/comissao/all_produtos_parados.json", encoding="utf-8") as f:
    all_prod = json.load(f)

prod_js = json.dumps(all_prod, ensure_ascii=False, separators=(',',':'))

with open("D:/Evolução categorias/.worktrees/comissao/dashboard_estoque.html", encoding="utf-8") as f:
    html = f.read()

# Localizar e substituir o bloco top_produtos_parados
start_marker = "  top_produtos_parados: ["
end_marker   = "\n};"

idx_start = html.find(start_marker)
idx_end   = html.find(end_marker, idx_start) + len(end_marker)
html = html[:idx_start] + f"  top_produtos_parados: {prod_js}\n}};" + html[idx_end:]

with open("D:/Evolução categorias/.worktrees/comissao/dashboard_estoque.html", "w", encoding="utf-8") as f:
    f.write(html)

print("Produtos re-embarcados com nomes completos.")
print(f"Tamanho: {len(html)//1024} KB")
