/* ═══════════════════════════════════════════════════════════ SOUL BLUEPRINT MATRIX - PERSONAL CLIENT PDF EXPORTER Module: src/js/pdf_exporter.js ═══════════════════════════════════════════════════════════ */ function exportClientPDF() { let name, dobStr; if (readingMode === 'single') { name = document.getElementById('i-name').value.trim() || 'Client'; const day = document.getElementById('i-day').value; const mon = document.getElementById('i-mon').value; const yr = document.getElementById('i-yr').value; dobStr = `${String(day).padStart(2,'0')}.${String(mon).padStart(2,'0')}.${yr}`; } else { name = `${document.getElementById('i-name1').value.trim() || 'Partner 1'} & ${document.getElementById('i-name2').value.trim() || 'Partner 2'}`; dobStr = 'Compatibility Matrix'; } const svgContent = document.getElementById('msv').outerHTML; const db = (typeof INTERP !== 'undefined') ? INTERP : (typeof database !== 'undefined' ? database : {}); function getPositionReadingsHtml(posKey, numVal, allowPrograms) { if (!db || !db[posKey] || !numVal || numVal === '–') return ''; let html = ''; const posData = db[posKey]; for (const modId in posData) { if (!allowPrograms && (modId === 'programs' || modId === 'compat_programs')) continue; const modData = posData[modId]; for (const secKey in modData) { const textMap = modData[secKey]; if (textMap && (textMap[numVal] || textMap[String(numVal)])) { const text = textMap[numVal] || textMap[String(numVal)]; const secTitle = secKey.replace(/_/g, ' ').replace(/\b\w/g, c => c.toUpperCase()); const modTitle = modId.replace(/_/g, ' ').replace(/\b\w/g, c => c.toUpperCase()); html += `
${modTitle} — ${secTitle}
${text}
`; } } } return html; } const coordKeys = [ { key:'A', label:'Point A (Visiting Card / Day)' }, { key:'B', label:'Point B (Spiritual Talent / Month)' }, { key:'C', label:'Point C (Material Task / Year)' }, { key:'D', label:'Point D (Karmic Task / Social Purpose)' }, { key:'E', label:'Point E (Soul Comfort Zone / Center)' }, { key:'M_N_D', label:'Karmic Tail Program (M – N – D)' }, { key:'L', label:'Point L (Central Balance Point)' }, { key:'R2', label:'Point R2 (Profession / Financial Success)' }, { key:'M', label:'Point M (Ideal Partner / Meeting Place)' }, { key:'N', label:'Point N (Suitable Niche / Profession)' }, { key:'O', label:'Point O (Material Emotional Closeness)' }, { key:'P', label:'Point P (Spiritual Emotional Closeness)' }, { key:'OP', label:'Point OP (Emotional Closeness Synthesis)' }, { key:'EARTH', label:'Earth Line (Physical Purpose)' }, { key:'SKY', label:'Sky Line (Spiritual Purpose)' }, { key:'PERSONAL_PURPOSE', label:'1st Soul Purpose (Ages 20–40)' }, { key:'PATERNAL_LINE', label:'Paternal Lines (Male Ancestry)' }, { key:'MATERNAL_LINE', label:'Maternal Lines (Female Ancestry)' }, { key:'SOCIAL_PURPOSE', label:'2nd Soul Purpose (Ages 40–60)' }, { key:'SPIRITUAL_PURPOSE', label:'3rd Soul Purpose (Ages 60+)' }, { key:'PLANETARY_MISSION', label:'4th Soul Purpose (Planetary Mission)' } ]; let tableRows = ''; let detailedReadingsHtml = ''; coordKeys.forEach(item => { let val = ''; let nameText = ''; let themeText = ''; if (item.key === 'M_N_D') { const mVal = currentVals.M ?? '–'; const nVal = currentVals.N ?? '–'; const dVal = currentVals.D ?? '–'; val = `${mVal} – ${nVal} – ${dVal}`; nameText = 'Karmic Tail Program'; themeText = 'Uncovering ancestral lessons, releasing karmic blocks'; } else { val = currentVals[item.key] ?? '–'; const pos = (typeof getPositionMeta === 'function') ? getPositionMeta(item.key) : (POSITIONS[item.key] || {}); nameText = pos.name || item.key; themeText = pos.zone || 'Core energy coordinate'; } tableRows += ` ${item.label} ${val} ${nameText} ${themeText} `; // Generate detailed interpretation readings if text exists in database let readings; if (item.key === 'M_N_D') { // Karmic Tail stored as 'M-N-D' in CSV with compound number key like '15-20-5' const csvVal = `${currentVals.M ?? ''}-${currentVals.N ?? ''}-${currentVals.D ?? ''}`; readings = getPositionReadingsHtml('M-N-D', csvVal, true); } else { readings = getPositionReadingsHtml(item.key, val); } if (readings) { detailedReadingsHtml += `

${item.label} (Code ${val})

${readings}
`; } }); // Active 3-Number Programs const activeProgs = (typeof getActivePrograms === 'function') ? getActivePrograms() : []; let progHtml = ''; if (activeProgs.length > 0) { progHtml = `

CHAPTER 3: ACTIVE COMBINATION PROGRAMS

Special 3-number energetic codes detected in your Destiny Matrix chart:

${activeProgs.map(prog => `

Program: ${prog.name} (${prog.locationLabel || prog.positions} · Code: ${prog.code})

${prog.text}
`).join('')} `; } const win = window.open('', '_blank'); if (!win) { alert('Popup window was blocked by your browser. Please allow popups for this site to view and save your PDF report!'); return; } win.document.write(` Destiny Matrix Report — ${name}

THE MATRIX OF DESTINY

Your Personal Soul Book & Life Guide

FULL DESTINY MATRIX CHART ANALYSIS: ${name} (${dobStr})

Dear ${name}!
Welcome to the opening of your personal Destiny Matrix Chart! This document is your soul's digital blueprint and master life guide, calculated strictly from the energetic frequency of your date of birth (${dobStr}). In this report, every chapter is dedicated to your personal growth, inner peace, emotional healing, and spiritual abundance. Use this book as a manual whenever you need to make important life decisions, regain inner tranquility, or unlock a new level of your potential!

CHAPTER 1: MATRIX SUMMARY DIAGRAM

${svgContent}

CHAPTER 2: MATRIX SUMMARY DIAGRAM & CORE CODES

Below is the complete calculation of your primary coordinates and key codes within the Destiny Matrix system:

${tableRows}
Matrix Coordinate Code / Energy Arcana English Arcana Name Key Life Theme
${detailedReadingsHtml ? `

DETAILED POSITION READINGS

${detailedReadingsHtml}
` : ''} ${progHtml}

CHAPTER 4: 7-CHAKRA HEALTH MATRIX ANALYSIS

Your complete health map from Sahasrara to Muladhara, detailing physical, energy, and emotional levels.

${currentVals.derived?.chakras?.map((c, i) => ` `).join('') || ''}
ChakraPhysical LevelEnergy LevelEmotional Level
${c.name} (${c.zone}) ${c.physical} ${c.energy} ${c.emotional}
${(() => { let ckHtml = ''; for (let i = 7; i >= 1; i--) { const key = `CK_${i}`; const val = currentVals[key] || '–'; const readings = getPositionReadingsHtml(key, val); if (readings) { const pos = POSITIONS[key] || {}; ckHtml += `

${pos.name || key} (Code ${val})

${readings}
`; } } return ckHtml ? `

DETAILED CHAKRA READINGS

${ckHtml}
` : ''; })()} `); win.document.close(); }