Repository navigation
Expand file tree
/
Copy pathpricing-calculator.js
More file actions
762 lines (694 loc) · 32.4 KB
/
Copy pathpricing-calculator.js
File metadata and controls
762 lines (694 loc) · 32.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
/**
* pricing-calculator.js
* Purchasing Power Parity (PPP) & Tier Rate Calculator Engine
* Handles parity tier multipliers, client mode (individual vs business),
* multi-service selection, extra seat calculations, and dynamic UI updates across pricing.html.
*/
(function (root, factory) {
if (typeof module === 'object' && module.exports) {
// Node.js environment
module.exports = factory();
} else {
// Browser environment
root.PricingCalculator = factory();
}
}(typeof self !== 'undefined' ? self : this, function () {
const PARITY_TIERS = {
1: {
id: 1,
name: "Tier 1: Developed Nations (100% Standard Rate)",
shortName: "Tier 1: Developed",
multiplier: 1.0,
discountPercent: 0,
badgeText: "TIER 01 · HIGH-INCOME ECONOMIES",
badgeColor: "#38bdf8",
badgeBg: "rgba(56, 189, 248, 0.15)",
badgeBorder: "rgba(56, 189, 248, 0.4)",
note: "100% Standard Commercial Rate · Multiplier 1.0x",
isCustom: false
},
2: {
id: 2,
name: "Tier 2: Upper-Middle-Income Economies (25% Discount / 75% Rate)",
shortName: "Tier 2: Upper-Middle",
multiplier: 0.75,
discountPercent: 25,
badgeText: "TIER 02 · UPPER-MIDDLE-INCOME",
badgeColor: "#fbbf24",
badgeBg: "rgba(251, 191, 36, 0.15)",
badgeBorder: "rgba(251, 191, 36, 0.4)",
note: "25% Parity Discount · 75% Base Rate · Multiplier 0.75x",
isCustom: false
},
3: {
id: 3,
name: "Tier 3: Lower-Middle & Low-Income Economies (50% Rate)",
shortName: "Tier 3: Lower-Middle & Low-Income",
multiplier: 0.5,
discountPercent: 50,
badgeText: "TIER 03 · LOWER-MIDDLE & LOW-INCOME",
badgeColor: "#34d399",
badgeBg: "rgba(52, 211, 153, 0.15)",
badgeBorder: "rgba(52, 211, 153, 0.4)",
note: "50% Parity Discount · 50% Base Rate · Multiplier 0.50x",
isCustom: false
},
4: {
id: 4,
name: "Tier 4: Early-Stage Startups (50% Flat Discount)",
shortName: "Tier 4: Startups",
multiplier: 0.5,
discountPercent: 50,
badgeText: "TIER 04 · EARLY-STAGE STARTUPS",
badgeColor: "#f472b6",
badgeBg: "rgba(244, 114, 182, 0.15)",
badgeBorder: "rgba(244, 114, 182, 0.4)",
note: "50% Flat Startup Discount (<$1M Raised) · Multiplier 0.50x",
isCustom: false
},
5: {
id: 5,
name: "Tier 5: Non-Profits & Academia (75% Discount / 25% Rate)",
shortName: "Tier 5: Academia & Non-Profit",
multiplier: 0.25,
discountPercent: 75,
badgeText: "TIER 05 · ACADEMIA & NON-PROFITS",
badgeColor: "#c084fc",
badgeBg: "rgba(192, 132, 252, 0.15)",
badgeBorder: "rgba(192, 132, 252, 0.4)",
note: "75% Flat Discount · 25% Base Rate · Multiplier 0.25x",
isCustom: false
},
6: {
id: 6,
name: "Tier 6: Crisis-Affected & Under-Resourced Builders (Custom Subsidized Quote)",
shortName: "Tier 6: Crisis-Affected & Under-Resourced",
multiplier: 0.1,
discountPercent: 90,
badgeText: "TIER 06 · CRISIS-AFFECTED & UNDER-RESOURCED",
badgeColor: "#00f0ff",
badgeBg: "rgba(0, 240, 255, 0.18)",
badgeBorder: "rgba(0, 240, 255, 0.45)",
note: "Custom Subsidized Quotes & Micro-Rates (Up to 90%+ Relief)",
isCustom: true
}
};
const ALL_SERVICES_DATA = [
{ slug: "service-generative-ai-transformation", title: "Generative AI Transformation" },
{ slug: "service-knowledge-graphs", title: "Knowledge Graphs" },
{ slug: "service-local-ai-for-sensitive-data", title: "Local AI for Sensitive Data" },
{ slug: "service-local-llms-cost-slashing", title: "Local LLMs & Cost Slashing" },
{ slug: "service-claude-agents-orchestration", title: "Claude Agent Orchestration" },
{ slug: "service-agentic-assistants", title: "Agentic Assistants Training" },
{ slug: "service-workflow-automations", title: "Workflow Automations" },
{ slug: "service-ai-budget-cost-control", title: "AI Budget & Cost Control" },
{ slug: "service-ai-developer-training", title: "AI Developer Training" },
{ slug: "service-advanced-ai-agents", title: "Advanced AI Agents" },
{ slug: "service-competitor-research", title: "Competitor Research & Intelligence" },
{ slug: "service-ai-assisted-leads-magnet", title: "AI Leads Magnet & Conversion Systems" },
{ slug: "service-ai-second-brain", title: "AI Second Brain" },
{ slug: "service-continuous-learning", title: "Continuous Learning & Synthesis" },
{ slug: "service-gemini-research-training", title: "Gemini Research Training" },
{ slug: "service-claude-research-training", title: "Claude Research Training" }
];
/**
* Pure calculation function
* @param {Object} params
* @param {number} params.tierId 1 to 6
* @param {string} params.clientMode "business" or "individual"
* @param {string} params.packageType "pick-services" | "pkg-business" | "pkg-personal" | "custom"
* @param {Array<string>} params.selectedServices Array of service slugs
* @param {number} params.participants Total participant count
* @param {number} [params.customBase] Optional custom base price
* @returns {Object} Calculated pricing details
*/
function calculatePricing(params) {
if (!params) params = {};
const parsedTierId = parseInt(params.tierId, 10) || 1;
const tier = PARITY_TIERS[parsedTierId] || PARITY_TIERS[1];
const tierId = tier.id;
const clientMode = params.clientMode === "individual" ? "individual" : "business";
const packageType = params.packageType || "pick-services";
const selectedServices = Array.isArray(params.selectedServices)
? params.selectedServices
: (params.selectedServices ? [params.selectedServices] : ["service-generative-ai-transformation"]);
const ratePerSvc = 100;
let basePrice = 1000;
if (packageType === "pick-services") {
const count = selectedServices.length;
basePrice = count * ratePerSvc;
} else if (packageType === "pkg-business") {
basePrice = 1000;
} else if (packageType === "pkg-personal") {
basePrice = 1000;
} else if (packageType === "custom" && typeof params.customBase === 'number') {
basePrice = Math.max(0, params.customBase);
}
const matchingFlagshipPrice = 1000;
let flagshipCheaper = false;
let flagshipPrice = matchingFlagshipPrice;
if (packageType === "pick-services") {
const count = selectedServices.length;
if (count > 0 && count * ratePerSvc >= matchingFlagshipPrice) {
flagshipCheaper = true;
flagshipPrice = matchingFlagshipPrice;
}
}
const includedSeats = packageType === "pick-services" ? 1 : 10;
let rawParticipants = parseInt(params.participants, 10);
if (isNaN(rawParticipants) || rawParticipants < 1) {
rawParticipants = includedSeats;
}
let participants = Math.min(20, rawParticipants);
const extraParticipants = basePrice > 0
? (packageType === "pick-services" ? Math.max(0, participants - includedSeats) : Math.max(0, participants - 10))
: 0;
const extraHeadRate = Math.round(extraParticipants * 100 * tier.multiplier);
const baseTierPrice = Math.round(basePrice * tier.multiplier);
const finalPrice = basePrice === 0 ? 0 : baseTierPrice + extraHeadRate;
const baseSavings = Math.round(basePrice * (tier.discountPercent / 100));
const extraSavings = Math.round(extraParticipants * 100 * (tier.discountPercent / 100));
const totalSavings = basePrice === 0 ? 0 : baseSavings + extraSavings;
return {
tierId,
tier,
clientMode,
packageType,
serviceCount: selectedServices.length,
ratePerService: ratePerSvc,
basePrice,
participants,
extraParticipants,
extraHeadRate,
baseTierPrice,
finalPrice,
totalSavings,
isCustom: tier.isCustom,
flagshipCheaper,
flagshipPrice
};
}
/**
* DOM Controller for pricing.html
*/
function initDOMController() {
if (typeof document === 'undefined') return;
let activeTier = 1;
let clientMode = "business"; // "business" or "individual"
let standardBasePrice = 1000;
let selectedServices = ["service-generative-ai-transformation"];
const btnModeBusiness = document.getElementById("btn-mode-business");
const btnModeIndividual = document.getElementById("btn-mode-individual");
const calcPackage = document.getElementById("calc-package");
const servicesMultiSelectWrap = document.getElementById("services-multi-select-wrap");
const servicesCheckboxGrid = document.getElementById("services-checkbox-grid");
const selectedServiceCountLabel = document.getElementById("selected-service-count-label");
const btnSelectAllServices = document.getElementById("btn-select-all-services");
const btnClearServices = document.getElementById("btn-clear-services");
const calcCustomAmount = document.getElementById("calc-custom-amount");
const calcParticipants = document.getElementById("calc-participants");
const calcParticipantsHint = document.getElementById("calc-participants-hint");
const calcParticipantsDesc = document.getElementById("calc-participants-desc");
const calcScopeVal = document.getElementById("calc-scope-val");
const calcCohortVal = document.getElementById("calc-cohort-val");
const calcCountry = document.getElementById("calc-country");
const calcTierButtons = document.querySelectorAll("#calc-tier-buttons .calc-tier-btn, .calc-tier-btn[data-tier]");
const calcResultBox = document.getElementById("calc-result-box");
const calcTierBadge = document.getElementById("calc-tier-badge");
const calcDisplayPrice = document.getElementById("calc-display-price");
const calcDisplayNote = document.getElementById("calc-display-note");
const calcSavingsBadge = document.getElementById("calc-savings-badge");
const calcBaseValue = document.getElementById("calc-base-value");
const calcAppliedTier = document.getElementById("calc-applied-tier");
const calcAdjustmentVal = document.getElementById("calc-adjustment-val");
const calcCtaBtn = document.getElementById("calc-cta-btn");
// Populate Checkbox Grid
if (servicesCheckboxGrid) {
servicesCheckboxGrid.innerHTML = ALL_SERVICES_DATA.map((s) => {
const isChecked = selectedServices.includes(s.slug) ? "checked" : "";
return `
<label style="display:flex;align-items:center;gap:0.45rem;background:rgba(255,255,255,0.02);padding:0.35rem 0.55rem;border-radius:6px;border:1px solid rgba(255,255,255,0.06);cursor:pointer;font-size:0.8rem;color:var(--text-secondary);">
<input type="checkbox" class="service-pick-cb" value="${s.slug}" ${isChecked} style="accent-color:var(--cyan);cursor:pointer;" />
<span style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">${s.title}</span>
</label>
`;
}).join("");
servicesCheckboxGrid.querySelectorAll(".service-pick-cb").forEach(cb => {
const handleCb = function () {
if (this.checked) {
if (!selectedServices.includes(this.value)) selectedServices.push(this.value);
} else {
selectedServices = selectedServices.filter(slug => slug !== this.value);
}
updateFromServicesSelection();
};
cb.addEventListener("change", handleCb);
cb.addEventListener("input", handleCb);
cb.addEventListener("click", handleCb);
});
}
function updateFromServicesSelection() {
const ratePerSvc = 100;
const count = selectedServices.length;
standardBasePrice = count * ratePerSvc;
if (selectedServiceCountLabel) {
selectedServiceCountLabel.textContent = `${count} Service${count === 1 ? '' : 's'} Selected ($${(count * ratePerSvc).toLocaleString("en-US")} USD)`;
}
const tier = PARITY_TIERS[activeTier];
if (calcCustomAmount && tier) {
calcCustomAmount.value = Math.round(standardBasePrice * tier.multiplier);
}
updateCalculator();
}
if (btnSelectAllServices) {
btnSelectAllServices.addEventListener("click", () => {
selectedServices = ALL_SERVICES_DATA.map(s => s.slug);
if (servicesCheckboxGrid) {
servicesCheckboxGrid.querySelectorAll(".service-pick-cb").forEach(cb => cb.checked = true);
}
updateFromServicesSelection();
});
}
if (btnClearServices) {
btnClearServices.addEventListener("click", () => {
selectedServices = [];
if (servicesCheckboxGrid) {
servicesCheckboxGrid.querySelectorAll(".service-pick-cb").forEach(cb => {
cb.checked = false;
});
}
updateFromServicesSelection();
});
}
if (btnModeBusiness && btnModeIndividual) {
btnModeBusiness.addEventListener("click", () => setClientMode("business"));
btnModeIndividual.addEventListener("click", () => setClientMode("individual"));
}
function setClientMode(mode) {
clientMode = mode;
if (mode === "business") {
btnModeBusiness.classList.add("active");
btnModeIndividual.classList.remove("active");
if (calcParticipants) {
calcParticipants.value = Math.max(10, parseInt(calcParticipants.value, 10) || 10);
calcParticipants.disabled = false;
}
if (calcParticipantsHint) calcParticipantsHint.textContent = "Flagships: 10 Included · Service Picks: 1 Included (+$100/extra seat, max 20)";
if (calcParticipantsDesc) calcParticipantsDesc.textContent = "Flagships include up to 10 participants and Service Picks include 1 seat (additional seats are $100 USD per seat scaled by country parity, up to 20 seats max).";
} else {
btnModeIndividual.classList.add("active");
btnModeBusiness.classList.remove("active");
if (calcParticipants) {
calcParticipants.disabled = false;
calcParticipants.value = Math.min(20, Math.max(1, parseInt(calcParticipants.value, 10) || 10));
}
if (calcParticipantsHint) calcParticipantsHint.textContent = "Personal Flagship: 10 Included · Service Picks: 1 Included (+$100/extra seat, max 20)";
if (calcParticipantsDesc) calcParticipantsDesc.textContent = "Personal Flagship includes up to 10 participants and Personal Service Picks include 1 seat (additional seats are $100 USD per seat scaled by country parity, up to 20 seats max).";
}
if (calcPackage && calcPackage.value === "pick-services") {
updateFromServicesSelection();
} else if (calcPackage && calcPackage.value === "pkg-business" && mode === "individual") {
calcPackage.value = "pkg-personal";
standardBasePrice = 1000;
const tier = PARITY_TIERS[activeTier];
if (calcCustomAmount && tier) calcCustomAmount.value = Math.round(1000 * tier.multiplier);
updateCalculator();
} else if (calcPackage && calcPackage.value === "pkg-personal" && mode === "business") {
calcPackage.value = "pkg-business";
standardBasePrice = 1000;
const tier = PARITY_TIERS[activeTier];
if (calcCustomAmount && tier) calcCustomAmount.value = Math.round(1000 * tier.multiplier);
updateCalculator();
} else {
updateCalculator();
}
}
/**
* Updates the 16 service cards in #individual-services-list
* to reflect the active parity tier multiplier dynamically
*/
function updateIndividualServiceCards(tier) {
const indivCards = document.querySelectorAll("#individual-services-list .price-card-faq");
if (!indivCards || indivCards.length === 0) return;
const mult = tier.multiplier;
indivCards.forEach(card => {
const indivPriceEl = card.querySelector(".svc-indiv-price");
const bizPriceEl = card.querySelector(".svc-biz-price");
const indivTiersEl = card.querySelector(".svc-indiv-tiers");
const bizTiersEl = card.querySelector(".svc-biz-tiers");
if (indivPriceEl) {
if (tier.isCustom) {
indivPriceEl.textContent = "Custom quote - contact Thomas";
indivPriceEl.style.color = "#00f0ff";
} else {
const calculated = Math.round(100 * mult);
indivPriceEl.textContent = "$" + calculated.toLocaleString("en-US") + " USD" + (tier.id > 1 ? ` (T${tier.id})` : "");
indivPriceEl.style.color = tier.badgeColor;
}
}
if (bizPriceEl) {
if (tier.isCustom) {
bizPriceEl.textContent = "Custom quote - contact Thomas";
bizPriceEl.style.color = "#00f0ff";
} else {
const calculated = Math.round(100 * mult);
bizPriceEl.textContent = "$" + calculated.toLocaleString("en-US") + " USD" + (tier.id > 1 ? ` (T${tier.id})` : "");
bizPriceEl.style.color = tier.badgeColor;
}
}
// Highlight matching tier in tier preview string
if (indivTiersEl) {
indivTiersEl.style.color = tier.id > 1 ? "var(--text-secondary)" : "var(--text-muted)";
}
if (bizTiersEl) {
bizTiersEl.style.color = tier.id > 1 ? "var(--text-secondary)" : "var(--text-muted)";
}
});
}
function updateCalculator() {
if (!calcCustomAmount) return;
if (!activeTier || !PARITY_TIERS[activeTier]) {
activeTier = 1;
}
const tier = PARITY_TIERS[activeTier];
const result = calculatePricing({
tierId: activeTier,
clientMode: clientMode,
packageType: calcPackage ? calcPackage.value : "pick-services",
selectedServices: selectedServices,
participants: calcParticipants ? calcParticipants.value : 20,
customBase: standardBasePrice
});
// Update Base Value Row
if (calcBaseValue) calcBaseValue.textContent = "$" + result.basePrice.toLocaleString("en-US") + " USD";
if (calcAppliedTier) {
calcAppliedTier.textContent = tier.shortName;
calcAppliedTier.style.color = tier.badgeColor;
}
// Scope description
if (calcScopeVal) {
if (result.packageType === "pkg-business") {
calcScopeVal.textContent = "Business Training Flagship (60 Days: 30d + 30d, 4h/day)";
calcScopeVal.style.color = "var(--cyan)";
} else if (result.packageType === "pkg-personal") {
calcScopeVal.textContent = "Personal Training Flagship (60 Days: 30d + 30d, 4h/day)";
calcScopeVal.style.color = "var(--gold)";
} else if (result.packageType === "pick-services") {
calcScopeVal.textContent = `${result.serviceCount} Selected Service${result.serviceCount === 1 ? '' : 's'} (${result.clientMode === "business" ? "Business" : "Individual"}, ${result.serviceCount * 5}d + ${result.serviceCount * 5}d support)`;
calcScopeVal.style.color = result.clientMode === "business" ? "#38bdf8" : "var(--gold)";
} else {
calcScopeVal.textContent = "Custom Engineered Scope";
calcScopeVal.style.color = "var(--text-secondary)";
}
}
// Participants & Extra Head Scaling
if (calcCohortVal) {
if (result.clientMode === "individual") {
calcCohortVal.textContent = "1 Person Only (Private 1-on-1)";
calcCohortVal.style.color = "var(--gold)";
} else {
if (result.participants <= 10) {
calcCohortVal.textContent = result.participants + (result.participants === 1 ? " Participant (Included in Base)" : " Participants (Included in Base)");
calcCohortVal.style.color = "var(--gold)";
} else {
calcCohortVal.textContent = result.participants + " Heads (+" + result.extraParticipants + " Extra @ +$" + result.extraHeadRate.toLocaleString("en-US") + " USD)";
calcCohortVal.style.color = "#38bdf8";
}
}
}
// Update Badge
if (calcTierBadge) {
calcTierBadge.textContent = tier.badgeText;
calcTierBadge.style.color = tier.badgeColor;
calcTierBadge.style.background = tier.badgeBg;
calcTierBadge.style.borderColor = tier.badgeBorder;
}
// Dynamic Accent on Result Box Border
if (calcResultBox) {
calcResultBox.style.borderColor = tier.badgeColor;
calcResultBox.style.boxShadow = "0 0 28px " + tier.badgeBg.replace("0.15", "0.25").replace("0.18", "0.25") + ", 0 10px 30px rgba(0,0,0,0.6)";
}
if (result.basePrice === 0 && result.packageType === "pick-services") {
if (calcDisplayPrice) {
calcDisplayPrice.textContent = "$0 USD";
calcDisplayPrice.style.fontSize = "clamp(2.1rem, 3.8vw, 2.85rem)";
calcDisplayPrice.style.color = "var(--text-muted)";
calcDisplayPrice.style.textShadow = "none";
}
if (calcDisplayNote) {
calcDisplayNote.textContent = "0 services selected · Please select at least one service above";
calcDisplayNote.style.color = "var(--text-muted)";
}
if (calcAdjustmentVal) {
calcAdjustmentVal.textContent = "$0 USD";
calcAdjustmentVal.style.color = "var(--text-muted)";
}
if (calcSavingsBadge) {
calcSavingsBadge.innerHTML = '<span>No services selected ($0 USD)</span>';
calcSavingsBadge.style.color = "var(--text-muted)";
calcSavingsBadge.style.borderColor = "rgba(255, 255, 255, 0.15)";
calcSavingsBadge.style.background = "rgba(255, 255, 255, 0.05)";
}
if (calcCtaBtn) {
calcCtaBtn.textContent = "Select at Least 1 Service to Proceed ($0 USD)";
calcCtaBtn.style.borderColor = "var(--border)";
calcCtaBtn.href = "#services-multi-select-wrap";
}
} else if (tier.isCustom) {
// Tier 6 Subsidized
if (calcDisplayPrice) {
calcDisplayPrice.textContent = "Custom subsidized quote - contact Thomas";
calcDisplayPrice.style.fontSize = "clamp(1.35rem, 2.4vw, 1.75rem)";
calcDisplayPrice.style.color = tier.badgeColor;
calcDisplayPrice.style.textShadow = "0 0 18px rgba(0, 240, 255, 0.45)";
}
if (calcDisplayNote) {
calcDisplayNote.textContent = "Custom subsidized relief - contact Thomas directly";
calcDisplayNote.style.color = "#7dd3fc";
}
if (calcAdjustmentVal) {
calcAdjustmentVal.textContent = "Custom Subsidized Quote";
calcAdjustmentVal.style.color = tier.badgeColor;
}
if (calcSavingsBadge) {
calcSavingsBadge.innerHTML = '<span>Radical Equity: Custom subsidized rates tailored to your local budget</span>';
calcSavingsBadge.style.color = tier.badgeColor;
calcSavingsBadge.style.borderColor = tier.badgeBorder;
calcSavingsBadge.style.background = tier.badgeBg;
}
if (calcCtaBtn) {
calcCtaBtn.textContent = "Contact Thomas for Custom Subsidized Quote →";
calcCtaBtn.style.borderColor = tier.badgeColor;
const pkgVal = calcPackage ? calcPackage.value : "";
calcCtaBtn.href = "contact.html?tier=" + tier.tier + "&offer=" + encodeURIComponent(pkgVal) + "&budget=Custom%20Subsidized%20Quote&participants=" + result.participants;
}
} else {
// Tiers 1-5
if (calcDisplayPrice) {
calcDisplayPrice.textContent = "$" + result.finalPrice.toLocaleString("en-US") + " USD";
calcDisplayPrice.style.fontSize = "clamp(2.1rem, 3.8vw, 2.85rem)";
calcDisplayPrice.style.color = tier.badgeColor;
calcDisplayPrice.style.textShadow = "0 0 22px " + tier.badgeBg.replace("0.15", "0.45");
}
if (calcDisplayNote) {
if (result.extraParticipants > 0) {
calcDisplayNote.innerHTML = tier.note + " · Plus " + result.extraParticipants + " extra seats (+$" + result.extraHeadRate.toLocaleString("en-US") + ")";
} else {
calcDisplayNote.innerHTML = tier.note + (result.clientMode === "business" ? " · Base covers up to 10 participants" : " · Strictly 1 person only");
}
calcDisplayNote.style.color = tier.badgeColor;
}
if (calcAdjustmentVal && calcSavingsBadge) {
if (tier.discountPercent === 0) {
calcAdjustmentVal.textContent = "$0 USD (Standard Rate)";
calcAdjustmentVal.style.color = "var(--text-muted)";
calcSavingsBadge.innerHTML = '<span>Standard Commercial Rate (0% Discount)</span>';
calcSavingsBadge.style.color = "#38bdf8";
calcSavingsBadge.style.borderColor = "rgba(56, 189, 248, 0.4)";
calcSavingsBadge.style.background = "rgba(56, 189, 248, 0.12)";
} else {
calcAdjustmentVal.textContent = "-$" + result.totalSavings.toLocaleString("en-US") + " USD (" + tier.discountPercent + "% Off)";
calcAdjustmentVal.style.color = "#34d399";
calcSavingsBadge.innerHTML = '<span>You Save $' + result.totalSavings.toLocaleString("en-US") + ' USD (' + tier.discountPercent + '% Parity Subsidy)</span>';
calcSavingsBadge.style.color = "#34d399";
calcSavingsBadge.style.borderColor = "rgba(52, 211, 153, 0.4)";
calcSavingsBadge.style.background = "rgba(52, 211, 153, 0.15)";
}
}
if (calcCtaBtn) {
calcCtaBtn.textContent = "Lock in " + tier.shortName + " Rate ($" + result.finalPrice.toLocaleString("en-US") + ") →";
calcCtaBtn.style.borderColor = tier.badgeColor;
const pkgVal = calcPackage ? calcPackage.value : "";
calcCtaBtn.href = "contact.html?tier=" + tier.id + "&offer=" + encodeURIComponent(pkgVal) + "&budget=" + result.finalPrice + "&participants=" + result.participants;
}
}
// Flagship Cheaper Nudge (2.1)
const calcFlagshipNudge = document.getElementById("calc-flagship-nudge");
if (calcFlagshipNudge) {
if (result.flagshipCheaper) {
const isBiz = result.clientMode === "business";
const pkgTitle = isBiz ? "Business Flagship" : "Personal Flagship";
const flagshipCostStr = "$" + result.flagshipPrice.toLocaleString("en-US");
const trainingDays = isBiz ? "20 days training + 20 days guidance (20 working days over 4 weeks, 4 hours/day)" : "20 days training + 20 days guidance (20 working days over 4 weeks, 4 hours/day)";
const targetPkgVal = isBiz ? "pkg-business" : "pkg-personal";
calcFlagshipNudge.style.display = "block";
calcFlagshipNudge.innerHTML = `
<div style="display:flex;flex-direction:column;gap:0.5rem;">
<span style="font-weight:600;color:#fef08a;">The ${pkgTitle} (${flagshipCostStr}, ${trainingDays}) costs less than this selection. Switch to it?</span>
<button type="button" id="btn-switch-flagship" style="align-self:flex-start;background:var(--gold);color:#020408;border:none;border-radius:6px;padding:0.4rem 0.85rem;font-weight:700;font-size:0.85rem;cursor:pointer;transition:transform 0.15s ease;">Switch to ${pkgTitle}</button>
</div>
`;
const btnSwitch = document.getElementById("btn-switch-flagship");
if (btnSwitch) {
btnSwitch.onclick = function() {
if (calcPackage) {
calcPackage.value = targetPkgVal;
calcPackage.dispatchEvent(new Event("change"));
}
};
}
} else {
calcFlagshipNudge.style.display = "none";
calcFlagshipNudge.innerHTML = "";
}
}
// Update 16 individual service cards across the page
updateIndividualServiceCards(tier);
}
function setActiveTier(tierNum) {
const parsed = parseInt(tierNum, 10);
if (!isNaN(parsed) && PARITY_TIERS[parsed]) {
activeTier = parsed;
} else {
return;
}
calcTierButtons.forEach(btn => {
if (parseInt(btn.getAttribute("data-tier"), 10) === activeTier) {
btn.classList.add("active");
} else {
btn.classList.remove("active");
}
});
if (calcCountry) {
let matchingOpt = calcCountry.querySelector('option[data-tier="' + activeTier + '"]');
if (matchingOpt && calcCountry.selectedOptions[0]?.getAttribute("data-tier") != activeTier) {
matchingOpt.selected = true;
}
}
const tier = PARITY_TIERS[activeTier];
if (calcCustomAmount && tier) {
const tierPrice = Math.round(standardBasePrice * tier.multiplier);
calcCustomAmount.value = tierPrice;
}
updateCalculator();
}
if (calcPackage) {
const handlePackageChange = function () {
const selectedOpt = this.options[this.selectedIndex];
if (!selectedOpt) return;
if (selectedOpt.value === "pick-services") {
if (servicesMultiSelectWrap) servicesMultiSelectWrap.style.display = "block";
updateFromServicesSelection();
} else {
if (servicesMultiSelectWrap) servicesMultiSelectWrap.style.display = "none";
if (selectedOpt.value === "pkg-business") {
setClientMode("business");
standardBasePrice = 1000;
} else if (selectedOpt.value === "pkg-personal") {
setClientMode("individual");
standardBasePrice = 1000;
} else if (selectedOpt.value === "custom") {
calcCustomAmount.focus();
calcCustomAmount.select();
}
const tier = PARITY_TIERS[activeTier];
if (calcCustomAmount && tier && selectedOpt.value !== "custom") {
calcCustomAmount.value = Math.round(standardBasePrice * tier.multiplier);
}
updateCalculator();
}
};
calcPackage.addEventListener("change", handlePackageChange);
calcPackage.addEventListener("input", handlePackageChange);
}
if (calcCustomAmount) {
const handleCustomInput = function () {
const currentVal = parseFloat(this.value);
const tier = PARITY_TIERS[activeTier];
if (!isNaN(currentVal) && currentVal >= 0 && tier) {
standardBasePrice = Math.round(currentVal / (tier.multiplier || 1));
}
if (calcPackage) {
let matched = false;
for (let opt of calcPackage.options) {
if (parseFloat(opt.getAttribute("data-price")) === standardBasePrice) {
calcPackage.value = opt.value;
matched = true;
break;
}
}
if (!matched) {
calcPackage.value = "custom";
if (servicesMultiSelectWrap) servicesMultiSelectWrap.style.display = "none";
}
}
updateCalculator();
};
calcCustomAmount.addEventListener("input", handleCustomInput);
calcCustomAmount.addEventListener("change", handleCustomInput);
calcCustomAmount.addEventListener("keyup", handleCustomInput);
}
if (calcParticipants) {
const handleParticipants = function () {
updateCalculator();
};
calcParticipants.addEventListener("input", handleParticipants);
calcParticipants.addEventListener("change", handleParticipants);
calcParticipants.addEventListener("keyup", handleParticipants);
calcParticipants.addEventListener("mouseup", handleParticipants);
}
if (calcCountry) {
const handleCountry = function () {
const selectedOption = this.options[this.selectedIndex];
const tier = selectedOption ? selectedOption.getAttribute("data-tier") : null;
if (tier) setActiveTier(tier);
};
calcCountry.addEventListener("change", handleCountry);
calcCountry.addEventListener("input", handleCountry);
}
calcTierButtons.forEach(btn => {
btn.addEventListener("click", function () {
const tier = this.getAttribute("data-tier");
setActiveTier(tier);
});
});
window.selectTierAndScroll = function (tierNum) {
setActiveTier(tierNum);
const calcSection = document.getElementById("parity-calculator");
if (calcSection) {
calcSection.scrollIntoView({ behavior: "smooth", block: "start" });
}
if (calcResultBox) {
calcResultBox.classList.remove("tier-pulse");
void calcResultBox.offsetWidth;
calcResultBox.classList.add("tier-pulse");
}
};
// Run initial update
updateCalculator();
}
// Auto-init when DOM ready if in browser
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initDOMController);
} else {
initDOMController();
}
}
return {
PARITY_TIERS,
ALL_SERVICES_DATA,
calculatePricing,
initDOMController
};
}));