`;
};
pPersApp.renderConfigTable = function() {
const tbody = document.getElementById('p-pers-data-list'); tbody.innerHTML = '';
this.personaData.forEach(d => {
const row = tbody.insertRow(); row.dataset.id = d.id;
row.innerHTML = `${d.name} ${d.role}
`;
});
};
pPersApp.openTab = function(tabName) { this.currentTab = tabName; document.querySelectorAll('.p-pers-tab-content').forEach(c => c.classList.remove('active')); document.querySelectorAll('.p-pers-tab-button').forEach(b => b.classList.remove('active')); document.getElementById(`p-pers-${tabName}`).classList.add('active'); document.querySelector(`.p-pers-tab-button[data-tab='${tabName}']`).classList.add('active'); this.updateNavButtons(); };
pPersApp.navigateTabs = function(direction) { const tabs = ['Dashboard', 'Config']; const nextIndex = tabs.indexOf(this.currentTab) + direction; if (nextIndex >= 0 && nextIndex < tabs.length) this.openTab(tabs[nextIndex]); };
pPersApp.updateNavButtons = function() { const prevBtn = document.getElementById('p-pers-prevBtn'); const nextBtn = document.getElementById('p-pers-nextBtn'); prevBtn.style.visibility = (this.currentTab === 'Dashboard') ? 'hidden' : 'visible'; nextBtn.style.visibility = (this.currentTab === 'Config') ? 'hidden' : 'visible'; };
pPersApp.generatePDF = function() {
const element = document.getElementById('p-pers-profile-card');
if (!element) { alert('Please select a persona to download.'); return; }
const personaName = this.personaData.find(p=>p.id == document.getElementById('p-pers-select').value)?.name || 'Persona';
html2pdf().from(element).set({ margin: 0.5, filename: `${personaName.replace(/\s+/g, '_')}_Profile.pdf`, image: { type: 'jpeg', quality: 0.98 }, html2canvas: { scale: 2, useCORS: true }, jsPDF: { unit: 'in', format: 'letter', orientation: 'portrait' } }).save();
};
pPersApp.init();
});
