export function homeSecuritySystemCalculator(form: FormTs) {
form.addRow(row => {
row.addTextPanel('header', {
computedValue: () => 'Home Security System Calculator',
customStyles: { 'font-size': '1.5rem', 'font-weight': '600', 'color': '#1e293b' }
});
});
form.addSpacer({ height: 20 });
// Service Location Section
const locationSection = form.addSubform('serviceLocation', { title: '📍 Installation Location' });
locationSection.addRow(row => {
row.addAddress('propertyAddress', {
label: 'Property Address',
placeholder: 'Enter your property address...',
showMap: true,
showDistance: true,
referenceAddress: {
formattedAddress: 'Service Center, Denver, CO',
coordinates: { lat: 39.7392, lng: -104.9903 }
},
restrictToCountries: ['US', 'CA'],
distanceUnit: 'miles',
isRequired: true
});
});
locationSection.addRow(row => {
row.addTextPanel('serviceAreaInfo', {
computedValue: () => {
const addressField = locationSection.address('propertyAddress');
const miles = addressField?.distance();
if (miles == null) return '📍 Enter address to check service area';
if (miles <= 25) return '📍 Within service area - No travel fee';
if (miles <= 50) return '📍 Extended area - $50 travel fee';
if (miles <= 75) return '📍 Remote area - $100 travel fee';
return '📍 Outside service area - Please call for availability';
},
customStyles: { 'font-size': '0.9rem', 'color': '#0369a1', 'background': '#e0f2fe', 'padding': '10px', 'border-radius': '6px' }
});
});
// Property Details Section
const propertySection = form.addSubform('property', { title: '🏠 Property Details' });
propertySection.addRow(row => {
row.addDropdown('propertyType', {
label: 'Property Type',
options: [
{ id: 'house', name: 'Single Family House' },
{ id: 'apartment', name: 'Apartment/Condo' },
{ id: 'townhouse', name: 'Townhouse' },
{ id: 'commercial', name: 'Small Business' }
],
defaultValue: 'house',
isRequired: true
}, '1fr');
row.addDropdown('propertySize', {
label: 'Property Size',
options: [
{ id: 'small', name: 'Small (1-2 BR)' },
{ id: 'medium', name: 'Medium (3-4 BR)' },
{ id: 'large', name: 'Large (5+ BR)' },
{ id: 'xlarge', name: 'Extra Large/Estate' }
],
defaultValue: 'medium',
isRequired: true
}, '1fr');
});
propertySection.addRow(row => {
row.addInteger('entryPoints', {
label: 'Entry Points (Doors/Windows)',
min: 1,
max: 50,
defaultValue: 10,
tooltip: 'Total number of doors and windows to monitor'
}, '1fr');
row.addInteger('floors', {
label: 'Number of Floors',
min: 1,
max: 5,
defaultValue: 2
}, '1fr');
});
// System Package Section
const packageSection = form.addSubform('package', { title: '📦 System Package' });
packageSection.addRow(row => {
row.addRadioButton('systemTier', {
label: 'System Tier',
options: [
{ id: 'basic', name: 'Basic ($199) - Door/window sensors, control panel' },
{ id: 'standard', name: 'Standard ($399) - Basic + motion sensors, keypad' },
{ id: 'premium', name: 'Premium ($699) - Standard + cameras, smart lock' },
{ id: 'ultimate', name: 'Ultimate ($1,199) - Premium + video doorbell, full automation' }
],
defaultValue: 'standard',
isRequired: true
});
});
packageSection.addRow(row => {
row.addDropdown('installationType', {
label: 'Installation Type',
options: [
{ id: 'diy', name: 'DIY Installation (Free)' },
{ id: 'professional', name: 'Professional Installation (+$199)' },
{ id: 'premium-install', name: 'Premium Installation (+$399)' }
],
defaultValue: 'professional',
tooltip: 'Professional installation includes setup, testing, and training'
});
});
// Equipment Add-ons Section
const equipmentSection = form.addSubform('equipment', { title: '🔧 Additional Equipment' });
equipmentSection.addRow(row => {
row.addInteger('extraDoorSensors', {
label: 'Extra Door/Window Sensors',
min: 0,
max: 30,
defaultValue: 0,
tooltip: '$25 each'
}, '1fr');
row.addInteger('motionSensors', {
label: 'Motion Sensors',
min: 0,
max: 10,
defaultValue: 0,
tooltip: '$40 each'
}, '1fr');
});
equipmentSection.addRow(row => {
row.addInteger('indoorCameras', {
label: 'Indoor Cameras',
min: 0,
max: 10,
defaultValue: 0,
tooltip: '$129 each'
}, '1fr');
row.addInteger('outdoorCameras', {
label: 'Outdoor Cameras',
min: 0,
max: 10,
defaultValue: 0,
tooltip: '$199 each'
}, '1fr');
});
equipmentSection.addRow(row => {
row.addCheckbox('videoDoorbell', {
label: 'Video Doorbell ($179)',
defaultValue: false
}, '1fr');
row.addCheckbox('smartLock', {
label: 'Smart Lock ($229)',
defaultValue: false
}, '1fr');
});
equipmentSection.addRow(row => {
row.addCheckbox('glassBreakSensor', {
label: 'Glass Break Sensors ($99)',
defaultValue: false
}, '1fr');
row.addCheckbox('smokeDetector', {
label: 'Smart Smoke/CO Detector ($89)',
defaultValue: false
}, '1fr');
});
equipmentSection.addRow(row => {
row.addCheckbox('waterSensor', {
label: 'Water Leak Sensor ($49)',
defaultValue: false
}, '1fr');
row.addCheckbox('panicButton', {
label: 'Panic Button ($39)',
defaultValue: false
}, '1fr');
});
// Monitoring Plan Section
const monitoringSection = form.addSubform('monitoring', { title: '📡 Monitoring Plan' });
monitoringSection.addRow(row => {
row.addRadioButton('monitoringPlan', {
label: 'Monitoring Service',
options: [
{ id: 'self', name: 'Self Monitoring (Free) - App alerts only' },
{ id: 'basic', name: 'Basic ($14.99/mo) - 24/7 monitoring, police dispatch' },
{ id: 'plus', name: 'Plus ($24.99/mo) - Basic + fire/medical response' },
{ id: 'premium', name: 'Premium ($34.99/mo) - Plus + video verification, cellular backup' }
],
defaultValue: 'plus',
isRequired: true
});
});
monitoringSection.addRow(row => {
row.addDropdown('contractLength', {
label: 'Contract Length',
options: [
{ id: 'monthly', name: 'Month-to-Month' },
{ id: '12', name: '12 Months (5% discount)' },
{ id: '24', name: '24 Months (10% discount)' },
{ id: '36', name: '36 Months (15% discount on equipment)' }
],
defaultValue: '24'
});
});
form.addSpacer({ height: 20, showLine: true, lineStyle: 'dashed' });
// Helper to calculate travel fee
const getTravelFee = () => {
const addressField = locationSection.address('propertyAddress');
const miles = addressField?.distance();
if (miles == null || miles <= 25) return 0;
if (miles <= 50) return 50;
if (miles <= 75) return 100;
return 150;
};
// Cost Breakdown Section
const breakdownSection = form.addSubform('breakdown', { title: '📊 Cost Breakdown', isCollapsible: true });
breakdownSection.addRow(row => {
row.addPriceDisplay('equipmentCost', {
label: 'Equipment Cost',
computedValue: () => {
const tier = packageSection.radioButton('systemTier')?.value() || 'standard';
const extraDoorSensors = equipmentSection.integer('extraDoorSensors')?.value() || 0;
const motionSensors = equipmentSection.integer('motionSensors')?.value() || 0;
const indoorCameras = equipmentSection.integer('indoorCameras')?.value() || 0;
const outdoorCameras = equipmentSection.integer('outdoorCameras')?.value() || 0;
const videoDoorbell = equipmentSection.checkbox('videoDoorbell')?.value() || false;
const smartLock = equipmentSection.checkbox('smartLock')?.value() || false;
const glassBreak = equipmentSection.checkbox('glassBreakSensor')?.value() || false;
const smoke = equipmentSection.checkbox('smokeDetector')?.value() || false;
const water = equipmentSection.checkbox('waterSensor')?.value() || false;
const panic = equipmentSection.checkbox('panicButton')?.value() || false;
const tierPrices = { basic: 199, standard: 399, premium: 699, ultimate: 1199 };
let total = tierPrices[tier] || 399;
total += extraDoorSensors * 25;
total += motionSensors * 40;
total += indoorCameras * 129;
total += outdoorCameras * 199;
if (videoDoorbell) total += 179;
if (smartLock) total += 229;
if (glassBreak) total += 99;
if (smoke) total += 89;
if (water) total += 49;
if (panic) total += 39;
return total;
},
variant: 'default'
}, '1fr');
row.addPriceDisplay('installationCost', {
label: 'Installation Cost',
computedValue: () => {
const installation = packageSection.dropdown('installationType')?.value() || 'professional';
const installPrices = { diy: 0, professional: 199, 'premium-install': 399 };
return installPrices[installation] || 0;
},
variant: 'default'
}, '1fr');
});
breakdownSection.addRow(row => {
row.addPriceDisplay('travelFee', {
label: 'Travel Fee',
computedValue: () => getTravelFee(),
variant: 'default',
prefix: '+',
isVisible: () => getTravelFee() > 0
});
});
breakdownSection.addRow(row => {
row.addPriceDisplay('monthlyMonitoring', {
label: 'Monthly Monitoring',
computedValue: () => {
const plan = monitoringSection.radioButton('monitoringPlan')?.value() || 'plus';
const contract = monitoringSection.dropdown('contractLength')?.value() || '24';
const planPrices = { self: 0, basic: 14.99, plus: 24.99, premium: 34.99 };
let monthly = planPrices[plan] || 24.99;
if (contract === '12') monthly *= 0.95;
else if (contract === '24') monthly *= 0.90;
return Math.round(monthly * 100) / 100;
},
variant: 'default'
});
});
// Summary Section
const summarySection = form.addSubform('summary', {
title: '💰 Total Investment',
isCollapsible: false,
sticky: 'bottom'
});
summarySection.addRow(row => {
row.addPriceDisplay('upfrontCost', {
label: 'Upfront Cost',
computedValue: () => {
const tier = packageSection.radioButton('systemTier')?.value() || 'standard';
const installation = packageSection.dropdown('installationType')?.value() || 'professional';
const contract = monitoringSection.dropdown('contractLength')?.value() || '24';
const extraDoorSensors = equipmentSection.integer('extraDoorSensors')?.value() || 0;
const motionSensors = equipmentSection.integer('motionSensors')?.value() || 0;
const indoorCameras = equipmentSection.integer('indoorCameras')?.value() || 0;
const outdoorCameras = equipmentSection.integer('outdoorCameras')?.value() || 0;
const videoDoorbell = equipmentSection.checkbox('videoDoorbell')?.value() || false;
const smartLock = equipmentSection.checkbox('smartLock')?.value() || false;
const glassBreak = equipmentSection.checkbox('glassBreakSensor')?.value() || false;
const smoke = equipmentSection.checkbox('smokeDetector')?.value() || false;
const water = equipmentSection.checkbox('waterSensor')?.value() || false;
const panic = equipmentSection.checkbox('panicButton')?.value() || false;
const tierPrices = { basic: 199, standard: 399, premium: 699, ultimate: 1199 };
const installPrices = { diy: 0, professional: 199, 'premium-install': 399 };
let equipment = tierPrices[tier] || 399;
equipment += extraDoorSensors * 25;
equipment += motionSensors * 40;
equipment += indoorCameras * 129;
equipment += outdoorCameras * 199;
if (videoDoorbell) equipment += 179;
if (smartLock) equipment += 229;
if (glassBreak) equipment += 99;
if (smoke) equipment += 89;
if (water) equipment += 49;
if (panic) equipment += 39;
if (contract === '36') equipment *= 0.85;
const travelFee = getTravelFee();
return Math.round((equipment + (installPrices[installation] || 0) + travelFee) * 100) / 100;
},
variant: 'success'
}, '1fr');
row.addPriceDisplay('monthlyTotal', {
label: 'Monthly Cost',
computedValue: () => {
const plan = monitoringSection.radioButton('monitoringPlan')?.value() || 'plus';
const contract = monitoringSection.dropdown('contractLength')?.value() || '24';
const planPrices = { self: 0, basic: 14.99, plus: 24.99, premium: 34.99 };
let monthly = planPrices[plan] || 24.99;
if (contract === '12') monthly *= 0.95;
else if (contract === '24') monthly *= 0.90;
return Math.round(monthly * 100) / 100;
},
variant: 'large'
}, '1fr');
});
summarySection.addRow(row => {
row.addTextPanel('firstYearCost', {
computedValue: () => {
const tier = packageSection.radioButton('systemTier')?.value() || 'standard';
const installation = packageSection.dropdown('installationType')?.value() || 'professional';
const plan = monitoringSection.radioButton('monitoringPlan')?.value() || 'plus';
const contract = monitoringSection.dropdown('contractLength')?.value() || '24';
const extraDoorSensors = equipmentSection.integer('extraDoorSensors')?.value() || 0;
const motionSensors = equipmentSection.integer('motionSensors')?.value() || 0;
const indoorCameras = equipmentSection.integer('indoorCameras')?.value() || 0;
const outdoorCameras = equipmentSection.integer('outdoorCameras')?.value() || 0;
const videoDoorbell = equipmentSection.checkbox('videoDoorbell')?.value() || false;
const smartLock = equipmentSection.checkbox('smartLock')?.value() || false;
const glassBreak = equipmentSection.checkbox('glassBreakSensor')?.value() || false;
const smoke = equipmentSection.checkbox('smokeDetector')?.value() || false;
const water = equipmentSection.checkbox('waterSensor')?.value() || false;
const panic = equipmentSection.checkbox('panicButton')?.value() || false;
const tierPrices = { basic: 199, standard: 399, premium: 699, ultimate: 1199 };
const installPrices = { diy: 0, professional: 199, 'premium-install': 399 };
const planPrices = { self: 0, basic: 14.99, plus: 24.99, premium: 34.99 };
let equipment = tierPrices[tier] || 399;
equipment += extraDoorSensors * 25 + motionSensors * 40;
equipment += indoorCameras * 129 + outdoorCameras * 199;
if (videoDoorbell) equipment += 179;
if (smartLock) equipment += 229;
if (glassBreak) equipment += 99;
if (smoke) equipment += 89;
if (water) equipment += 49;
if (panic) equipment += 39;
if (contract === '36') equipment *= 0.85;
let monthly = planPrices[plan] || 24.99;
if (contract === '12') monthly *= 0.95;
else if (contract === '24') monthly *= 0.90;
const travelFee = getTravelFee();
const firstYear = equipment + (installPrices[installation] || 0) + travelFee + (monthly * 12);
return `First Year Total: $${(Number(firstYear) || 0).toFixed(2)}`;
},
customStyles: { 'font-size': '1rem', 'font-weight': '600', 'text-align': 'center', 'color': '#1e293b' }
});
});
summarySection.addRow(row => {
row.addTextPanel('disclaimer', {
computedValue: () => 'Prices are estimates. Actual costs may vary based on property assessment and local requirements.',
customStyles: { 'font-size': '0.8rem', 'color': '#64748b', 'text-align': 'center' }
});
});
form.configureSubmitButton({
label: 'Get Free Quote'
});
}