// @requirements REQ-PRODUCT-PRIVACY-SIGNALS
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 signalFiles(base){
const config=exampleConsentConfig(base);config.site.id='juniper-privacy-signals';
const template=config.purposes[0];const memory=config.purposes.find(p=>p.id==='remember-choices');
config.purposes=[{...template,id:'optional-features',name:'Optional features',description:'Run fictional optional services to demonstrate independent cookie permission and processing restrictions.',dataCategories:['Synthetic first-party sample request'],retention:'No application record is created by these first-party sample requests.'},memory];
config.services=[{id:'sample-advertising',name:'Sample advertising',provider:'Juniper Notes (fictional)',location:'This local demo only',purposeIds:['optional-features'],processingActivities:['sharing','targeted-advertising']},{id:'sample-tools',name:'Sample local tools',provider:'Juniper Notes (fictional)',location:'This local demo only',purposeIds:['optional-features'],processingActivities:[]},{...config.services.find(s=>s.id==='privacy-choices'),processingActivities:[]}];
config.storage=config.storage.filter(s=>s.serviceId==='privacy-choices');for(const item of config.storage)item.name=item.name.replace('juniper-choices',config.site.id);
config.consent.purposes=[{id:'optional-features',scope:'sample-1'}];config.consent.services=[{id:'sample-advertising',scope:'sample-1'},{id:'sample-tools',scope:'sample-1'}];
config.privacySignals={globalPrivacyControl:{appliesTo:['sale','sharing','targeted-advertising'],explanation:'In this fictional browser example, an observed Global Privacy Control signal restricts services declared for sale, sharing or targeted advertising. Cookie permission is separate and does not override that restriction. Both services make only first-party sample requests. No account-wide or downstream processing is represented; an actual operator must explain and implement that handling separately.'}};
for(const [kind,doc] of Object.entries(config.documents))doc.route=`/privacy-signals/${kind}`;
const build=compileLegalDocuments(config,{mode:'preview',stylesheetUrl:'/assets/notabenda.css'});
return {...build.files,'privacy-signals/site.json':JSON.stringify(build.publicConfig),'privacy-signals/sample.json':'{"fictional":true}',
'assets/privacy-signals.mjs':await readFile(new URL('./client.mjs',import.meta.url),'utf8'),
'privacy-signals/index.html':`
Cookie permission and processing restrictions answer different questions. Allowing optional cookies does not override Global Privacy Control.
Your current state
Cookie permission:
GPC:
Sample advertising:
Sample local tools:
Optional requests initiated this page:
Cookie choices and processing restrictions
After allowing optional features, simulate a GPC signal. Advertising stops while local tools can continue under the same cookie choice. The simulation is labeled and stays in this demo URL across reloads.