<?php
require_once __DIR__.'/../../_bootstrap.php';
afSyncLegalDocuments($pdo);
$docs=[];
if(afPrivacyTableExists($pdo,'af_legal_documents')){
 $rows=$pdo->query('SELECT id,document_key,version_key,title,summary,content_hash,content_html,required_acceptance,audience,effective_at FROM af_legal_documents WHERE active=1 ORDER BY id')->fetchAll()?:[];
 foreach($rows as $row){$row['id']=(int)$row['id'];$row['required_acceptance']=(bool)$row['required_acceptance'];$docs[]=$row;}
}
jsonResponse(['ok'=>true,'privacy_center_version'=>PRIVACY_CENTER_VERSION,'documents'=>$docs]);
