import {build as bundle} from 'esbuild';
// @requirements REQ-PRODUCT-DISCOVERY
import {readFile} from 'node:fs/promises';
import {compileLegalDocuments} from 'notabenda/content';
import {renderLegalLinks} from 'notabenda';
import {exampleConsentConfig} from '../static/choices-build.mjs';
export async function discoveryFiles(base){
const config=exampleConsentConfig(base);config.site.id='juniper-discovery';config.purposes=config.purposes.filter(p=>p.id!=='suggestions');config.services=config.services.filter(s=>s.id!=='sample-suggestions');config.storage=config.storage.filter(s=>s.serviceId!=='sample-suggestions');
config.consent.purposes=config.consent.purposes.filter(p=>p.id==='measurement');config.consent.services=config.consent.services.filter(s=>s.id==='sample-measurements');
config.purposes[0].name='Sample memory';config.purposes[0].description='Create one fictional local marker for this discovery demonstration.';config.services[0].name='Sample memory';
config.storage.find(s=>s.serviceId==='sample-measurements').name='juniper-discovery-memory';
for(const item of config.storage)if(item.serviceId==='privacy-choices')item.name=item.name.replace('juniper-choices',config.site.id);
const files={};
for(const dark of [false,true]){
const themed=structuredClone(config),route=(dark?'/dark':'')+'/discovery';for(const [kind,doc] of Object.entries(themed.documents))doc.route=route+'/'+kind;
const css=dark?'/assets/dark.css':'/assets/notabenda.css',build=compileLegalDocuments(themed,{mode:'preview',stylesheetUrl:css});Object.assign(files,build.files);files[route.slice(1)+'/site.json']=JSON.stringify(build.publicConfig);
files[route.slice(1)+'/index.html']=`
Download the capture, compare it with your inventory through the CLI, and review the candidates. Same-origin requests are not automatically essential, and a name match does not establish a legal basis.