export function businessLicenseCalculator(form: FormTs) {
// Business types and complexity
const businessTypes: Record<string, { baseComplexity: number, typicalLicenses: number }> = {
'general-retail': { baseComplexity: 1.0, typicalLicenses: 2 },
'restaurant-food': { baseComplexity: 1.8, typicalLicenses: 5 },
'bar-alcohol': { baseComplexity: 2.2, typicalLicenses: 4 },
'healthcare-medical': { baseComplexity: 2.5, typicalLicenses: 6 },
'construction': { baseComplexity: 1.5, typicalLicenses: 3 },
'professional-services': { baseComplexity: 1.2, typicalLicenses: 2 },
'manufacturing': { baseComplexity: 1.8, typicalLicenses: 4 },
'transportation': { baseComplexity: 2.0, typicalLicenses: 4 },
'childcare': { baseComplexity: 2.0, typicalLicenses: 5 },
'real-estate': { baseComplexity: 1.4, typicalLicenses: 2 },
'finance-insurance': { baseComplexity: 2.3, typicalLicenses: 4 },
'cannabis': { baseComplexity: 3.0, typicalLicenses: 8 },
'home-based': { baseComplexity: 0.8, typicalLicenses: 1 },
'ecommerce': { baseComplexity: 0.9, typicalLicenses: 2 },
'franchise': { baseComplexity: 1.6, typicalLicenses: 3 }
};
// Service packages
const servicePackages: Record<string, { baseFee: number, description: string }> = {
'research-only': { baseFee: 350, description: 'License requirements research' },
'basic': { baseFee: 750, description: 'Research + Application prep' },
'standard': { baseFee: 1500, description: 'Full service single location' },
'premium': { baseFee: 2500, description: 'Full service + expedited handling' },
'enterprise': { baseFee: 5000, description: 'Multi-location comprehensive' }
};
form.addRow(row => {
row.addTextPanel('header', {
computedValue: () => 'Business License Cost Calculator',
customStyles: { 'font-size': '1.5rem', 'font-weight': '600', 'color': '#1e293b' }
});
});
form.addSpacer({ height: 20 });
// Business Details Section
const businessSection = form.addSubform('business', { title: '๐ข Business Details' });
businessSection.addRow(row => {
row.addDropdown('type', {
label: 'Business Type',
options: [
{ id: 'general-retail', name: 'General Retail' },
{ id: 'restaurant-food', name: 'Restaurant / Food Service' },
{ id: 'bar-alcohol', name: 'Bar / Alcohol Sales' },
{ id: 'healthcare-medical', name: 'Healthcare / Medical' },
{ id: 'construction', name: 'Construction / Contracting' },
{ id: 'professional-services', name: 'Professional Services' },
{ id: 'manufacturing', name: 'Manufacturing' },
{ id: 'transportation', name: 'Transportation / Logistics' },
{ id: 'childcare', name: 'Childcare / Education' },
{ id: 'real-estate', name: 'Real Estate' },
{ id: 'finance-insurance', name: 'Finance / Insurance' },
{ id: 'cannabis', name: 'Cannabis (where legal)' },
{ id: 'home-based', name: 'Home-Based Business' },
{ id: 'ecommerce', name: 'E-commerce / Online' },
{ id: 'franchise', name: 'Franchise' }
],
defaultValue: 'general-retail',
isRequired: true
}, '1fr');
row.addDropdown('structure', {
label: 'Business Structure',
options: [
{ id: 'sole-proprietor', name: 'Sole Proprietorship' },
{ id: 'partnership', name: 'Partnership' },
{ id: 'llc', name: 'LLC' },
{ id: 'corporation', name: 'Corporation' },
{ id: 's-corp', name: 'S-Corporation' },
{ id: 'nonprofit', name: 'Non-Profit' }
],
defaultValue: 'llc',
isRequired: true
}, '1fr');
});
businessSection.addRow(row => {
row.addDropdown('locations', {
label: 'Number of Locations',
options: [
{ id: '1', name: '1 Location' },
{ id: '2-3', name: '2-3 Locations (+$500/location)' },
{ id: '4-10', name: '4-10 Locations (+$400/location)' },
{ id: '10+', name: '10+ Locations (Custom quote)' }
],
defaultValue: '1',
isRequired: true
}, '1fr');
row.addCheckbox('newBusiness', {
label: 'New Business (not existing)',
defaultValue: true
}, '1fr');
});
// Location & Jurisdiction Section
const locationSection = form.addSubform('location', { title: '๐ Location & Jurisdiction' });
locationSection.addRow(row => {
row.addDropdown('stateComplexity', {
label: 'State Regulatory Complexity',
options: [
{ id: 'low', name: 'Low (TX, FL, NV)' },
{ id: 'medium', name: 'Medium (Most states)' },
{ id: 'high', name: 'High (CA, NY, MA)' }
],
defaultValue: 'medium',
isRequired: true
}, '1fr');
row.addDropdown('localRequirements', {
label: 'Local Licensing Requirements',
options: [
{ id: 'minimal', name: 'Minimal' },
{ id: 'standard', name: 'Standard' },
{ id: 'extensive', name: 'Extensive (Major cities)' }
],
defaultValue: 'standard',
isRequired: true
}, '1fr');
});
locationSection.addRow(row => {
row.addCheckbox('zoningReview', {
label: 'Zoning Compliance Review (+$300)',
defaultValue: false
}, '1fr');
row.addCheckbox('permitAssistance', {
label: 'Building/Health Permit Assistance (+$400)',
defaultValue: false
}, '1fr');
});
// Service Package Section
const serviceSection = form.addSubform('service', { title: '๐ฆ Service Package' });
serviceSection.addRow(row => {
row.addRadioButton('package', {
label: 'Service Level',
options: [
{ id: 'research-only', name: 'Research Only ($350) - Requirements analysis' },
{ id: 'basic', name: 'Basic ($750) - Research + application prep' },
{ id: 'standard', name: 'Standard ($1,500) - Full service' },
{ id: 'premium', name: 'Premium ($2,500) - Full service + expedited' },
{ id: 'enterprise', name: 'Enterprise ($5,000) - Multi-location' }
],
defaultValue: 'standard',
isRequired: true
});
});
serviceSection.addRow(row => {
row.addDropdown('urgency', {
label: 'Timeline',
options: [
{ id: 'standard', name: 'Standard (4-6 weeks)' },
{ id: 'expedited', name: 'Expedited (2-3 weeks) (+25%)' },
{ id: 'rush', name: 'Rush (1-2 weeks) (+50%)' }
],
defaultValue: 'standard',
isRequired: true
}, '1fr');
row.addCheckbox('filingFees', {
label: 'Include Estimated Filing Fees',
defaultValue: true
}, '1fr');
});
// Additional Services Section
const addonsSection = form.addSubform('addons', { title: 'โจ Additional Services' });
addonsSection.addRow(row => {
row.addCheckbox('einRegistration', {
label: 'EIN Registration (+$100)',
defaultValue: false
}, '1fr');
row.addCheckbox('dbaFiling', {
label: 'DBA / Trade Name Filing (+$150)',
defaultValue: false
}, '1fr');
});
addonsSection.addRow(row => {
row.addCheckbox('stateRegistration', {
label: 'State Business Registration (+$200)',
defaultValue: false
}, '1fr');
row.addCheckbox('salesTaxPermit', {
label: 'Sales Tax Permit (+$150)',
defaultValue: false
}, '1fr');
});
addonsSection.addRow(row => {
row.addCheckbox('professionalLicense', {
label: 'Professional License Application (+$400)',
defaultValue: false
}, '1fr');
row.addCheckbox('renewalSetup', {
label: 'Renewal Tracking Setup (+$200)',
defaultValue: false
}, '1fr');
});
addonsSection.addRow(row => {
row.addCheckbox('complianceCalendar', {
label: 'Compliance Calendar (+$150)',
defaultValue: false
}, '1fr');
row.addCheckbox('ongoingSupport', {
label: 'Ongoing Support (12 mo) (+$600)',
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('serviceFee', {
label: 'Service Package Fee',
computedValue: () => {
const pkg = serviceSection.radioButton('package')?.value() || 'standard';
const businessType = businessSection.dropdown('type')?.value() || 'general-retail';
const stateComplexity = locationSection.dropdown('stateComplexity')?.value() || 'medium';
const packageInfo = servicePackages[pkg] || servicePackages['standard'];
let fee = packageInfo?.baseFee ?? 0;
const typeInfo = businessTypes[businessType] || businessTypes['general-retail'];
// Complexity multiplier
fee *= typeInfo?.baseComplexity ?? 0;
// State complexity
const stateMultipliers: Record<string, number> = {
'low': 0.85, 'medium': 1.0, 'high': 1.3
};
fee *= stateMultipliers[stateComplexity] || 1.0;
return Math.round(fee);
},
variant: 'default'
}, '1fr');
row.addPriceDisplay('locationFee', {
label: 'Additional Locations',
computedValue: () => {
const locations = businessSection.dropdown('locations')?.value() || '1';
if (locations === '1') return 0;
if (locations === '2-3') return 1000; // 2 additional at $500
if (locations === '4-10') return 2400; // 6 additional at $400
return 0;
},
variant: 'default',
prefix: '+'
}, '1fr');
});
summarySection.addRow(row => {
row.addPriceDisplay('additionalServices', {
label: 'Additional Services',
computedValue: () => {
let total = 0;
if (locationSection.checkbox('zoningReview')?.value()) total += 300;
if (locationSection.checkbox('permitAssistance')?.value()) total += 400;
if (addonsSection.checkbox('einRegistration')?.value()) total += 100;
if (addonsSection.checkbox('dbaFiling')?.value()) total += 150;
if (addonsSection.checkbox('stateRegistration')?.value()) total += 200;
if (addonsSection.checkbox('salesTaxPermit')?.value()) total += 150;
if (addonsSection.checkbox('professionalLicense')?.value()) total += 400;
if (addonsSection.checkbox('renewalSetup')?.value()) total += 200;
if (addonsSection.checkbox('complianceCalendar')?.value()) total += 150;
if (addonsSection.checkbox('ongoingSupport')?.value()) total += 600;
return total;
},
variant: 'default',
prefix: '+'
}, '1fr');
row.addPriceDisplay('urgencyFee', {
label: 'Urgency Premium',
computedValue: () => {
const pkg = serviceSection.radioButton('package')?.value() || 'standard';
const urgency = serviceSection.dropdown('urgency')?.value() || 'standard';
const packageInfo = servicePackages[pkg] || servicePackages['standard'];
const baseFee = packageInfo?.baseFee ?? 0;
const urgencyMultipliers: Record<string, number> = {
'standard': 0, 'expedited': 0.25, 'rush': 0.50
};
return Math.round(baseFee * (urgencyMultipliers[urgency] || 0));
},
variant: 'default',
prefix: '+'
}, '1fr');
});
summarySection.addRow(row => {
row.addPriceDisplay('filingFeesEstimate', {
label: 'Est. Filing Fees',
computedValue: () => {
if (!serviceSection.checkbox('filingFees')?.value()) return 0;
const businessType = businessSection.dropdown('type')?.value() || 'general-retail';
const stateComplexity = locationSection.dropdown('stateComplexity')?.value() || 'medium';
const typeInfo = businessTypes[businessType] || businessTypes['general-retail'];
// Base filing fees per license
let perLicenseFee = 75;
if (stateComplexity === 'high') perLicenseFee = 150;
return (typeInfo?.typicalLicenses ?? 0) * perLicenseFee;
},
variant: 'default',
prefix: '+',
suffix: ' (gov fees)'
}, '1fr');
});
const finalSection = form.addSubform('final', {
title: '๐งพ Total Estimate',
isCollapsible: false,
sticky: 'bottom'
});
finalSection.addRow(row => {
row.addPriceDisplay('totalFee', {
label: 'Estimated Total',
computedValue: () => {
const pkg = serviceSection.radioButton('package')?.value() || 'standard';
const businessType = businessSection.dropdown('type')?.value() || 'general-retail';
const stateComplexity = locationSection.dropdown('stateComplexity')?.value() || 'medium';
const locations = businessSection.dropdown('locations')?.value() || '1';
const urgency = serviceSection.dropdown('urgency')?.value() || 'standard';
// Base service fee
const packageInfo = servicePackages[pkg] || servicePackages['standard'];
let fee = packageInfo?.baseFee ?? 0;
const typeInfo = businessTypes[businessType] || businessTypes['general-retail'];
fee *= typeInfo?.baseComplexity ?? 0;
const stateMultipliers: Record<string, number> = {
'low': 0.85, 'medium': 1.0, 'high': 1.3
};
fee *= stateMultipliers[stateComplexity] || 1.0;
// Locations
if (locations === '2-3') fee += 1000;
if (locations === '4-10') fee += 2400;
// Additional services
if (locationSection.checkbox('zoningReview')?.value()) fee += 300;
if (locationSection.checkbox('permitAssistance')?.value()) fee += 400;
if (addonsSection.checkbox('einRegistration')?.value()) fee += 100;
if (addonsSection.checkbox('dbaFiling')?.value()) fee += 150;
if (addonsSection.checkbox('stateRegistration')?.value()) fee += 200;
if (addonsSection.checkbox('salesTaxPermit')?.value()) fee += 150;
if (addonsSection.checkbox('professionalLicense')?.value()) fee += 400;
if (addonsSection.checkbox('renewalSetup')?.value()) fee += 200;
if (addonsSection.checkbox('complianceCalendar')?.value()) fee += 150;
if (addonsSection.checkbox('ongoingSupport')?.value()) fee += 600;
// Urgency
const urgencyMultipliers: Record<string, number> = {
'standard': 1.0, 'expedited': 1.25, 'rush': 1.50
};
fee *= urgencyMultipliers[urgency] || 1.0;
// Filing fees
if (serviceSection.checkbox('filingFees')?.value()) {
let perLicenseFee = 75;
if (stateComplexity === 'high') perLicenseFee = 150;
fee += (typeInfo?.typicalLicenses ?? 0) * perLicenseFee;
}
return Math.round(fee);
},
variant: 'large'
});
});
finalSection.addRow(row => {
row.addTextPanel('licenseCount', {
computedValue: () => {
const businessType = businessSection.dropdown('type')?.value() || 'general-retail';
const typeInfo = businessTypes[businessType] || businessTypes['general-retail'];
return `Typical licenses required: ${typeInfo?.typicalLicenses ?? 0}`;
},
customStyles: { 'font-size': '0.9rem', 'color': '#64748b', 'text-align': 'center' }
});
});
finalSection.addRow(row => {
row.addTextPanel('disclaimer', {
computedValue: () => 'This is an estimate. License requirements vary by location and business type. A consultation will confirm exact requirements and government filing fees for your specific situation.',
customStyles: { 'font-size': '0.8rem', 'color': '#64748b', 'font-style': 'italic' }
});
});
form.configureSubmitButton({
label: 'Get License Assessment'
});
}