export function divorceCostCalculator(form: FormTs) {
// Divorce types and base complexity
const divorceTypes: Record<string, { baseFee: number, hours: number }> = {
'uncontested-simple': { baseFee: 1500, hours: 5 },
'uncontested-assets': { baseFee: 3000, hours: 12 },
'mediated': { baseFee: 4500, hours: 18 },
'collaborative': { baseFee: 7500, hours: 30 },
'contested-simple': { baseFee: 8000, hours: 35 },
'contested-complex': { baseFee: 15000, hours: 60 },
'high-conflict': { baseFee: 25000, hours: 100 },
'high-net-worth': { baseFee: 35000, hours: 150 }
};
// Attorney rates
const attorneyRates: Record<string, number> = {
'associate': 275,
'senior-associate': 375,
'partner': 500,
'senior-partner': 650
};
form.addRow(row => {
row.addTextPanel('header', {
computedValue: () => 'Divorce Cost Calculator',
customStyles: { 'font-size': '1.5rem', 'font-weight': '600', 'color': '#1e293b' }
});
});
form.addSpacer({ height: 20 });
// Case Type Section
const caseSection = form.addSubform('caseType', { title: '⚖️ Case Overview' });
caseSection.addRow(row => {
row.addDropdown('type', {
label: 'Case Type',
options: [
{ id: 'uncontested-simple', name: 'Uncontested - Simple (No assets/children)' },
{ id: 'uncontested-assets', name: 'Uncontested - With Assets' },
{ id: 'mediated', name: 'Mediated Divorce' },
{ id: 'collaborative', name: 'Collaborative Divorce' },
{ id: 'contested-simple', name: 'Contested - Limited Issues' },
{ id: 'contested-complex', name: 'Contested - Complex' },
{ id: 'high-conflict', name: 'High Conflict' },
{ id: 'high-net-worth', name: 'High Net Worth' }
],
defaultValue: 'uncontested-assets',
isRequired: true
}, '1fr');
row.addDropdown('marriageLength', {
label: 'Length of Marriage',
options: [
{ id: 'short', name: 'Less than 5 years' },
{ id: 'medium', name: '5-10 years' },
{ id: 'long', name: '10-20 years (+15%)' },
{ id: 'very-long', name: '20+ years (+30%)' }
],
defaultValue: 'medium',
isRequired: true
}, '1fr');
});
caseSection.addRow(row => {
row.addDropdown('jurisdiction', {
label: 'State / Jurisdiction',
options: [
{ id: 'low-cost', name: 'Lower Cost State' },
{ id: 'average', name: 'Average Cost State' },
{ id: 'high-cost', name: 'High Cost State (CA, NY, MA)' }
],
defaultValue: 'average',
isRequired: true
}, '1fr');
row.addDropdown('attorneyLevel', {
label: 'Attorney Level',
options: [
{ id: 'associate', name: 'Associate ($275/hr)' },
{ id: 'senior-associate', name: 'Senior Associate ($375/hr)' },
{ id: 'partner', name: 'Partner ($500/hr)' },
{ id: 'senior-partner', name: 'Senior Partner ($650/hr)' }
],
defaultValue: 'senior-associate',
isRequired: true
}, '1fr');
});
// Children Section
const childrenSection = form.addSubform('children', { title: '👨👩👧👦 Children & Custody' });
childrenSection.addRow(row => {
row.addDropdown('childrenCount', {
label: 'Number of Minor Children',
options: [
{ id: '0', name: 'No minor children' },
{ id: '1', name: '1 child' },
{ id: '2', name: '2 children (+$500)' },
{ id: '3+', name: '3+ children (+$1,000)' }
],
defaultValue: '0',
isRequired: true
}, '1fr');
row.addDropdown('custodyDispute', {
label: 'Custody Situation',
options: [
{ id: 'none', name: 'N/A - No children' },
{ id: 'agreed', name: 'Custody Agreed' },
{ id: 'negotiating', name: 'Negotiating (+$2,000)' },
{ id: 'disputed', name: 'Contested Custody (+$5,000)' },
{ id: 'high-conflict', name: 'High Conflict (+$10,000)' }
],
defaultValue: 'none',
isRequired: true
}, '1fr');
});
childrenSection.addRow(row => {
row.addCheckbox('childSupport', {
label: 'Child Support Calculation (+$500)',
defaultValue: false,
isVisible: () => childrenSection.dropdown('childrenCount')?.value() !== '0'
}, '1fr');
row.addCheckbox('parentingPlan', {
label: 'Detailed Parenting Plan (+$750)',
defaultValue: false,
isVisible: () => childrenSection.dropdown('childrenCount')?.value() !== '0'
}, '1fr');
});
// Assets Section
const assetsSection = form.addSubform('assets', { title: '💰 Assets & Property' });
assetsSection.addRow(row => {
row.addDropdown('assetComplexity', {
label: 'Asset Complexity',
options: [
{ id: 'minimal', name: 'Minimal (Rent, few assets)' },
{ id: 'simple', name: 'Simple (Home, retirement)' },
{ id: 'moderate', name: 'Moderate (Multiple properties)' },
{ id: 'complex', name: 'Complex (Business interests)' },
{ id: 'very-complex', name: 'Very Complex (Multiple businesses)' }
],
defaultValue: 'simple',
isRequired: true
}, '1fr');
row.addDropdown('totalAssets', {
label: 'Estimated Marital Assets',
options: [
{ id: 'under-100k', name: 'Under $100,000' },
{ id: '100k-500k', name: '$100,000 - $500,000' },
{ id: '500k-1m', name: '$500,000 - $1 million' },
{ id: '1m-5m', name: '$1 - $5 million (+20%)' },
{ id: 'over-5m', name: 'Over $5 million (+40%)' }
],
defaultValue: '100k-500k',
isRequired: true
}, '1fr');
});
assetsSection.addRow(row => {
row.addCheckbox('businessValuation', {
label: 'Business Valuation Required (+$3,000-10,000)',
defaultValue: false
}, '1fr');
row.addCheckbox('realEstateAppraisal', {
label: 'Real Estate Appraisal (+$500-1,500)',
defaultValue: false
}, '1fr');
});
assetsSection.addRow(row => {
row.addCheckbox('retirementQdro', {
label: 'QDRO for Retirement Accounts (+$750)',
defaultValue: false
}, '1fr');
row.addCheckbox('debtDivision', {
label: 'Complex Debt Division (+$500)',
defaultValue: false
}, '1fr');
});
// Spousal Support Section
const supportSection = form.addSubform('support', { title: '💵 Spousal Support' });
supportSection.addRow(row => {
row.addDropdown('alimony', {
label: 'Spousal Support / Alimony',
options: [
{ id: 'none', name: 'Not Applicable' },
{ id: 'agreed', name: 'Amount Agreed' },
{ id: 'negotiate', name: 'Negotiating (+$1,500)' },
{ id: 'contested', name: 'Contested (+$4,000)' }
],
defaultValue: 'none',
isRequired: true
}, '1fr');
row.addCheckbox('incomeAnalysis', {
label: 'Income Analysis Required (+$1,000)',
defaultValue: false
}, '1fr');
});
// Additional Services Section
const addonsSection = form.addSubform('addons', { title: '✨ Additional Services' });
addonsSection.addRow(row => {
row.addCheckbox('mediator', {
label: 'Mediation Services (+$2,000-5,000)',
defaultValue: false
}, '1fr');
row.addCheckbox('forensicAccountant', {
label: 'Forensic Accountant (+$5,000-15,000)',
defaultValue: false
}, '1fr');
});
addonsSection.addRow(row => {
row.addCheckbox('custodyEvaluator', {
label: 'Custody Evaluator (+$3,000-8,000)',
defaultValue: false
}, '1fr');
row.addCheckbox('vocationalExpert', {
label: 'Vocational Expert (+$2,000-5,000)',
defaultValue: false
}, '1fr');
});
addonsSection.addRow(row => {
row.addCheckbox('privateInvestigator', {
label: 'Private Investigator (+$2,000-10,000)',
defaultValue: false
}, '1fr');
row.addCheckbox('therapistConsult', {
label: 'Therapist Consultation (+$500)',
defaultValue: false
}, '1fr');
});
form.addSpacer({ height: 20, showLine: true, lineStyle: 'dashed' });
// Summary Section
const summarySection = form.addSubform('summary', { title: '💰 Cost Estimate', isCollapsible: false });
summarySection.addRow(row => {
row.addPriceDisplay('attorneyFees', {
label: 'Attorney Fees',
computedValue: () => {
const type = caseSection.dropdown('type')?.value() || 'uncontested-assets';
const marriageLength = caseSection.dropdown('marriageLength')?.value() || 'medium';
const jurisdiction = caseSection.dropdown('jurisdiction')?.value() || 'average';
let fee = divorceTypes[type]?.baseFee ?? 0;
// Marriage length
const lengthMultipliers: Record<string, number> = {
'short': 0.9, 'medium': 1.0, 'long': 1.15, 'very-long': 1.3
};
fee *= lengthMultipliers[marriageLength] || 1.0;
// Jurisdiction
const jurisdictionMultipliers: Record<string, number> = {
'low-cost': 0.8, 'average': 1.0, 'high-cost': 1.4
};
fee *= jurisdictionMultipliers[jurisdiction] || 1.0;
return Math.round(fee);
},
variant: 'default'
}, '1fr');
row.addPriceDisplay('childrenFees', {
label: 'Children-Related',
computedValue: () => {
let total = 0;
const childrenCount = childrenSection.dropdown('childrenCount')?.value() || '0';
const custodyDispute = childrenSection.dropdown('custodyDispute')?.value() || 'none';
if (childrenCount === '2') total += 500;
if (childrenCount === '3+') total += 1000;
const custodyFees: Record<string, number> = {
'none': 0, 'agreed': 0, 'negotiating': 2000,
'disputed': 5000, 'high-conflict': 10000
};
total += custodyFees[custodyDispute] || 0;
if (childrenSection.checkbox('childSupport')?.value()) total += 500;
if (childrenSection.checkbox('parentingPlan')?.value()) total += 750;
return total;
},
variant: 'default',
prefix: '+'
}, '1fr');
});
summarySection.addRow(row => {
row.addPriceDisplay('assetFees', {
label: 'Asset Division',
computedValue: () => {
let total = 0;
const assetComplexity = assetsSection.dropdown('assetComplexity')?.value() || 'simple';
const totalAssets = assetsSection.dropdown('totalAssets')?.value() || '100k-500k';
// Complexity
const complexityFees: Record<string, number> = {
'minimal': 0, 'simple': 500, 'moderate': 1500,
'complex': 3500, 'very-complex': 7500
};
total += complexityFees[assetComplexity] || 0;
// Asset value multiplier
if (totalAssets === '1m-5m') total *= 1.2;
if (totalAssets === 'over-5m') total *= 1.4;
// Specific services
if (assetsSection.checkbox('businessValuation')?.value()) total += 5000;
if (assetsSection.checkbox('realEstateAppraisal')?.value()) total += 1000;
if (assetsSection.checkbox('retirementQdro')?.value()) total += 750;
if (assetsSection.checkbox('debtDivision')?.value()) total += 500;
return Math.round(total);
},
variant: 'default',
prefix: '+'
}, '1fr');
row.addPriceDisplay('supportFees', {
label: 'Spousal Support',
computedValue: () => {
let total = 0;
const alimony = supportSection.dropdown('alimony')?.value() || 'none';
const alimonyFees: Record<string, number> = {
'none': 0, 'agreed': 0, 'negotiate': 1500, 'contested': 4000
};
total += alimonyFees[alimony] || 0;
if (supportSection.checkbox('incomeAnalysis')?.value()) total += 1000;
return total;
},
variant: 'default',
prefix: '+'
}, '1fr');
});
summarySection.addRow(row => {
row.addPriceDisplay('expertFees', {
label: 'Expert & Additional',
computedValue: () => {
let total = 0;
if (addonsSection.checkbox('mediator')?.value()) total += 3500;
if (addonsSection.checkbox('forensicAccountant')?.value()) total += 10000;
if (addonsSection.checkbox('custodyEvaluator')?.value()) total += 5500;
if (addonsSection.checkbox('vocationalExpert')?.value()) total += 3500;
if (addonsSection.checkbox('privateInvestigator')?.value()) total += 6000;
if (addonsSection.checkbox('therapistConsult')?.value()) total += 500;
return total;
},
variant: 'default',
prefix: '+'
}, '1fr');
row.addPriceDisplay('courtFees', {
label: 'Est. Court Filing Fees',
computedValue: () => {
const jurisdiction = caseSection.dropdown('jurisdiction')?.value() || 'average';
const fees: Record<string, number> = {
'low-cost': 300, 'average': 450, 'high-cost': 650
};
return fees[jurisdiction] || 450;
},
variant: 'default',
prefix: '+'
}, '1fr');
});
const finalSection = form.addSubform('final', {
title: '🧾 Total Estimate',
isCollapsible: false,
sticky: 'bottom'
});
finalSection.addRow(row => {
row.addPriceDisplay('lowEstimate', {
label: 'Low Estimate',
computedValue: () => {
// Calculate all fees then apply 0.8 multiplier for low estimate
const type = caseSection.dropdown('type')?.value() || 'uncontested-assets';
const marriageLength = caseSection.dropdown('marriageLength')?.value() || 'medium';
const jurisdiction = caseSection.dropdown('jurisdiction')?.value() || 'average';
let fee = divorceTypes[type]?.baseFee ?? 0;
const lengthMultipliers: Record<string, number> = {
'short': 0.9, 'medium': 1.0, 'long': 1.15, 'very-long': 1.3
};
const jurisdictionMultipliers: Record<string, number> = {
'low-cost': 0.8, 'average': 1.0, 'high-cost': 1.4
};
fee *= lengthMultipliers[marriageLength] || 1.0;
fee *= jurisdictionMultipliers[jurisdiction] || 1.0;
// Add all other costs (simplified)
let total = fee;
// Children
const childrenCount = childrenSection.dropdown('childrenCount')?.value() || '0';
const custodyDispute = childrenSection.dropdown('custodyDispute')?.value() || 'none';
if (childrenCount === '2') total += 500;
if (childrenCount === '3+') total += 1000;
const custodyFees: Record<string, number> = { 'negotiating': 2000, 'disputed': 5000, 'high-conflict': 10000 };
total += custodyFees[custodyDispute] || 0;
if (childrenSection.checkbox('childSupport')?.value()) total += 500;
if (childrenSection.checkbox('parentingPlan')?.value()) total += 750;
// Assets
const assetComplexity = assetsSection.dropdown('assetComplexity')?.value() || 'simple';
const complexityFees: Record<string, number> = { 'simple': 500, 'moderate': 1500, 'complex': 3500, 'very-complex': 7500 };
total += complexityFees[assetComplexity] || 0;
if (assetsSection.checkbox('businessValuation')?.value()) total += 3000;
if (assetsSection.checkbox('realEstateAppraisal')?.value()) total += 500;
if (assetsSection.checkbox('retirementQdro')?.value()) total += 750;
if (assetsSection.checkbox('debtDivision')?.value()) total += 500;
// Support
const alimony = supportSection.dropdown('alimony')?.value() || 'none';
const alimonyFees: Record<string, number> = { 'negotiate': 1500, 'contested': 4000 };
total += alimonyFees[alimony] || 0;
if (supportSection.checkbox('incomeAnalysis')?.value()) total += 1000;
// Experts (low estimates)
if (addonsSection.checkbox('mediator')?.value()) total += 2000;
if (addonsSection.checkbox('forensicAccountant')?.value()) total += 5000;
if (addonsSection.checkbox('custodyEvaluator')?.value()) total += 3000;
if (addonsSection.checkbox('vocationalExpert')?.value()) total += 2000;
if (addonsSection.checkbox('privateInvestigator')?.value()) total += 2000;
if (addonsSection.checkbox('therapistConsult')?.value()) total += 500;
// Court fees
const courtFees: Record<string, number> = { 'low-cost': 300, 'average': 450, 'high-cost': 650 };
total += courtFees[jurisdiction] || 450;
return Math.round(total * 0.85);
},
variant: 'default'
}, '1fr');
row.addPriceDisplay('highEstimate', {
label: 'High Estimate',
computedValue: () => {
const type = caseSection.dropdown('type')?.value() || 'uncontested-assets';
const marriageLength = caseSection.dropdown('marriageLength')?.value() || 'medium';
const jurisdiction = caseSection.dropdown('jurisdiction')?.value() || 'average';
let fee = divorceTypes[type]?.baseFee ?? 0;
const lengthMultipliers: Record<string, number> = {
'short': 0.9, 'medium': 1.0, 'long': 1.15, 'very-long': 1.3
};
const jurisdictionMultipliers: Record<string, number> = {
'low-cost': 0.8, 'average': 1.0, 'high-cost': 1.4
};
fee *= lengthMultipliers[marriageLength] || 1.0;
fee *= jurisdictionMultipliers[jurisdiction] || 1.0;
let total = fee;
const childrenCount = childrenSection.dropdown('childrenCount')?.value() || '0';
const custodyDispute = childrenSection.dropdown('custodyDispute')?.value() || 'none';
if (childrenCount === '2') total += 500;
if (childrenCount === '3+') total += 1000;
const custodyFees: Record<string, number> = { 'negotiating': 2000, 'disputed': 5000, 'high-conflict': 10000 };
total += custodyFees[custodyDispute] || 0;
if (childrenSection.checkbox('childSupport')?.value()) total += 500;
if (childrenSection.checkbox('parentingPlan')?.value()) total += 750;
const assetComplexity = assetsSection.dropdown('assetComplexity')?.value() || 'simple';
const totalAssets = assetsSection.dropdown('totalAssets')?.value() || '100k-500k';
const complexityFees: Record<string, number> = { 'simple': 500, 'moderate': 1500, 'complex': 3500, 'very-complex': 7500 };
let assetFees = complexityFees[assetComplexity] || 0;
if (totalAssets === '1m-5m') assetFees *= 1.2;
if (totalAssets === 'over-5m') assetFees *= 1.4;
total += assetFees;
if (assetsSection.checkbox('businessValuation')?.value()) total += 10000;
if (assetsSection.checkbox('realEstateAppraisal')?.value()) total += 1500;
if (assetsSection.checkbox('retirementQdro')?.value()) total += 750;
if (assetsSection.checkbox('debtDivision')?.value()) total += 500;
const alimony = supportSection.dropdown('alimony')?.value() || 'none';
const alimonyFees: Record<string, number> = { 'negotiate': 1500, 'contested': 4000 };
total += alimonyFees[alimony] || 0;
if (supportSection.checkbox('incomeAnalysis')?.value()) total += 1000;
// Experts (high estimates)
if (addonsSection.checkbox('mediator')?.value()) total += 5000;
if (addonsSection.checkbox('forensicAccountant')?.value()) total += 15000;
if (addonsSection.checkbox('custodyEvaluator')?.value()) total += 8000;
if (addonsSection.checkbox('vocationalExpert')?.value()) total += 5000;
if (addonsSection.checkbox('privateInvestigator')?.value()) total += 10000;
if (addonsSection.checkbox('therapistConsult')?.value()) total += 500;
const courtFees: Record<string, number> = { 'low-cost': 300, 'average': 450, 'high-cost': 650 };
total += courtFees[jurisdiction] || 450;
return Math.round(total * 1.25);
},
variant: 'large'
}, '1fr');
});
finalSection.addRow(row => {
row.addTextPanel('rangeNote', {
computedValue: () => 'Estimates show typical range. Actual costs depend on case development and opposing party cooperation.',
customStyles: { 'font-size': '0.9rem', 'color': '#64748b', 'text-align': 'center' }
});
});
finalSection.addRow(row => {
row.addTextPanel('disclaimer', {
computedValue: () => 'This estimate is for planning purposes only. Divorce costs vary significantly based on case complexity, opposing counsel, and court requirements. A consultation will provide a more accurate assessment.',
customStyles: { 'font-size': '0.8rem', 'color': '#64748b', 'font-style': 'italic' }
});
});
form.configureSubmitButton({
label: 'Schedule Consultation'
});
}