Inground Pool Calculator

Turn pool shoppers into site visits with a calculator that prices the whole backyard. The visitor says what the pool is for, and the purpose sets the size, the depth and the steps; then they pick the type (fiberglass shell, vinyl liner or gunite), the shape, the entry, the equipment, the heater, the cover, the finish, the deck, the barrier, the lights and the water features. The calculator sizes the pump and the heater from the gallons, prices the dig from the cubic yards with surcharges for rock, clay, a high water table and a narrow side yard, adds a crane when a fiberglass shell will not fit through the access, and shows a price range stage by stage: permit and dig, shell, equipment, surroundings, cover and water. It also tells the visitor which months they can swim and what a season costs to run, warns that a heater without a cover heats the sky, and generates a PDF with the configuration and the estimate.

Home Services

Try the Calculator

Inground Pool Estimate
Say what the pool is for, pick the type, the size, the equipment and the finishes. The pump, the filter and the heater are sized from the gallons, and you see a price range broken down by stage.
Your Pool
 
Your Yard
12ft
12 ft
526
Pool Type
 
Fastest: the shell arrives finished and is in the ground in a few days. Shapes and sizes from the catalog, up to 40 x 16 ft. It has to come through in one piece or fly over on a crane. Warranty: lifetime structural, 15 years on the gelcoat.
Size and Shape
 
28ft
28 ft
1244
14ft
14 ft
820
3.5ft
3.5 ft
36.5
5.5ft
5.5 ft
39
Water surface 384 sq ft, 11500 gallons to fill (about $103 of water). Every inground pool needs a building permit and a barrier to code.
Water and Equipment
Flow 40 GPM: 11500 gallons through the filter every 6 h. Pump 1 HP variable speed with a cartridge filter, skimmer, returns and main drain: $6,500 with the plumbing.
 
 
Heat and Cover
 
 
Heat pump 110k BTU/h (about 8 BTU/h per gallon) | Swim season March to November (9 months) | Water on a summer morning about 82°F | Heating per season $110, pump, water and chemicals $655
Finishes and Surroundings
 
 
 
Scope and Timing
 
 
25mi
25 mi
0300

Your Estimate by Stage
$ 13,362
+
$ 62,343
+
$ 14,650
+
$ 21,548
+
$ 19,020

$ 117,800
$ 144,000
$ 766
/season
Range of ±10%, sales tax as applicable. Within 5 business days we come out to measure the yard, check the access and do a test hole, then you get the drawings and the final quote. Permit about 4 weeks, build 8 weeks from the signed contract.
Summary
$ 130,924
Book a Site Visit
 
 
 
 
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
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
export function ingroundPoolCalculator(form: FormTs) {
// Price list in USD: the shell by type and square foot of water, the dig, equipment sized
// from the gallons, heating, covers, deck, barrier, features and the running costs of a season.
const prices = {
// Pool shell
fiberglassBase: 22000,
fiberglassSqFt: 75,
fiberglassMaxLength: 40,
fiberglassMaxWidth: 16,
vinylBase: 18000,
vinylSqFt: 60,
guniteBase: 28000,
guniteSqFt: 110,
freeformPct: 12,
builtSteps: 3500,
tanningLedge: 2800,
bench: 1800,
overflowPct: 30,
finishUpgrade: 2400,
pebbleSqFt: 12,
// Excavation and base
excavationCuYd: 48,
baseSqFt: 12,
rockPct: 60,
clayPct: 15,
dewatering: 5500,
crane: 4500,
narrowAccess: 3500,
permit: 1200,
// Equipment
turnoverHours: 6,
equipmentBase: 6500,
equipmentGpm: 40,
salt: 2400,
automation: 3800,
locationPad: 1200,
locationHouse: 2800,
locationShed: 6500,
// Heating
gasBtuPerGal: 25,
gasBase: 3200,
gasKbtu: 4,
hpBtuPerGal: 8,
hpBase: 4200,
hpKbtu: 25,
solar: 6500,
tempHeated: 84,
tempUnheated: 78,
dropOpen: 6,
dropCovered: 2,
kbtuOpen: 90,
kbtuCovered: 35,
gasEfficiencyPct: 84,
heatPumpCop: 5,
// Covers
autoBase: 12000,
autoSqFt: 18,
recessedPct: 35,
blanketSqFt: 1.2,
reel: 450,
lowBase: 18000,
lowSqFt: 60,
highBase: 45000,
highSqFt: 95,
// Barrier
fenceLf: 45,
gate: 650,
screenSqFt: 18,
// Deck
travertineLf: 42,
paversLf: 34,
concreteLf: 28,
travertineSqFt: 22,
paversSqFt: 16,
concreteSqFt: 9,
ledEach: 1100,
stripLf: 28,
// Features and extras
swimJet: 11500,
wallJets: 3200,
bubbler: 1400,
waterfall: 4800,
spa: 18000,
hotTub: 9500,
// Service
installPct: 12,
waterKgal: 9,
freeMiles: 60,
mileRate: 6,
minimum: 45000,
hoaWeeks: 3,
permitWeeks: 4,
leadWeeks: 8,
visitDays: 5,
// Running costs
kwhPrice: 0.14,
thermPrice: 1.4,
seasonDays: 210,
pumpHours: 10,
chemicalsSeason: 600,
// Discounts and result
promoPct: 0,
promoText: 'Book before pool season',
rangePct: 10,
validityDays: 30
};
 
// ---- helpers ------------------------------------------------------------------
 
const money = (value: number): string => {
const rounded = Math.round(Math.abs(value));
let digits = String(rounded);
let grouped = '';
while (digits.length > 3) {
grouped = ',' + digits.slice(-3) + grouped;
digits = digits.slice(0, -3);
}
return (value < 0 ? '-$' : '$') + digits + grouped;
};
const feetInches = (ft: number): string => {
const inches = Math.round(ft * 12);
const f = Math.floor(inches / 12);
const i = inches % 12;
return i === 0 ? f + ' ft' : f + ' ft ' + i + ' in';
};
const priceTag = (price: number) => price > 0 ? ' (+' + money(price) + ')' : '';
// The option label up to its explanation: 'Heat pump: heats from the air' -> 'Heat pump'
const short = (text: string, separator: string): string => {
const at = text.indexOf(separator);
return at < 0 ? text : text.slice(0, at);
};
const GAL_PER_CUFT = 7.48052;
 
// ---- tables -------------------------------------------------------------------
 
// What the pool is for, and the pool each purpose starts from, in feet
const PURPOSES: Record<string, { name: string; length: number; width: number; shallow: number; deep: number; entry: string; shape: string }> = {
family: { name: 'Family fun: shallow by the steps, a tanning ledge, safe for kids', length: 28, width: 14, shallow: 3.5, deep: 5.5, entry: 'ledge', shape: 'rounded' },
laps: { name: 'Lap swimming: a long pool, one depth', length: 40, width: 14, shallow: 4, deep: 4, entry: 'corner', shape: 'rectangle' },
oasis: { name: 'Backyard oasis: shape, water color, deck and evening light', length: 32, width: 16, shallow: 3.5, deep: 6, entry: 'full', shape: 'kidney' },
plunge: { name: 'Cold plunge: a small, deep pool next to the sauna', length: 12, width: 8, shallow: 5, deep: 5, entry: 'ladder', shape: 'rectangle' },
guests: { name: 'Guests and rental: more swimmers, salt and automation', length: 36, width: 18, shallow: 3.5, deep: 7, entry: 'ledge', shape: 'rounded' }
};
const TYPES: Record<string, { name: string; base: number; sqFt: number; warranty: string }> = {
fiberglass: { name: 'Fiberglass shell', base: prices.fiberglassBase, sqFt: prices.fiberglassSqFt, warranty: 'lifetime structural, 15 years on the gelcoat' },
vinyl: { name: 'Vinyl liner', base: prices.vinylBase, sqFt: prices.vinylSqFt, warranty: '25 years on the walls, 5 on the liner seams' },
gunite: { name: 'Gunite', base: prices.guniteBase, sqFt: prices.guniteSqFt, warranty: 'lifetime on the shell, 10 years on the finish' }
};
const SHAPES: Record<string, string> = { rectangle: 'Rectangle', rounded: 'Rounded corners', oval: 'Oval', kidney: 'Kidney' };
const ENTRIES: Record<string, string> = {
ledge: 'Tanning ledge: a foot-deep sun shelf, then steps',
full: 'Full-width steps',
corner: 'Corner steps',
roman: 'Roman end: a half-round bay of steps',
ladder: 'Ladder'
};
const FINISHES: Record<string, string> = { white: 'White', sand: 'Sandstone', blue: 'Light blue', midnight: 'Midnight', pebble: 'Pebble' };
const SANITIZERS: Record<string, { name: string; price: number }> = {
chlorine: { name: 'Chlorine tablets', price: 0 },
salt: { name: 'Salt system: chlorine from salt, softer water', price: prices.salt }
};
const LOCATIONS: Record<string, { name: string; price: number }> = {
pad: { name: 'Pad by the pool, behind a privacy screen', price: prices.locationPad },
house: { name: 'Garage or pool house', price: prices.locationHouse },
shed: { name: 'Equipment enclosure', price: prices.locationShed }
};
const HEATERS: Record<string, string> = {
heatpump: 'Heat pump: heats from the air, cheapest to run',
gas: 'Gas heater: fast, warm water on demand',
solar: 'Solar heating: free while the sun shines',
none: 'No heater: summer water, about 76-80°F'
};
const COVERS: Record<string, string> = {
auto: 'Automatic cover on tracks',
auto_recessed: 'Recessed automatic cover (tracks under the coping)',
blanket: 'Solar blanket on a reel',
enclosure_low: 'Low retractable enclosure',
enclosure_high: 'Walk-in enclosure',
none: 'No cover (a winter cover only)'
};
const BARRIERS: Record<string, string> = {
fence: '4-ft aluminum pool fence with a self-closing gate',
screen: 'Screen enclosure over the pool and deck',
existing: 'Yard fence already to code'
};
const COPINGS: Record<string, { name: string; lf: number; sqFt: number }> = {
travertine: { name: 'Travertine', lf: prices.travertineLf, sqFt: prices.travertineSqFt },
pavers: { name: 'Pavers', lf: prices.paversLf, sqFt: prices.paversSqFt },
concrete: { name: 'Concrete', lf: prices.concreteLf, sqFt: prices.concreteSqFt }
};
const DECKS: Record<string, string> = { none: 'Coping only (a band about 18 in wide)', walkway: 'Walkway around (a 4-ft deck all the way round)', patio: 'Patio to the house' };
const LIGHTS: Record<string, string> = { white: 'One white LED light (included)', led: 'Color LED lights', strips: 'Color LED lights and strips under the coping' };
const LIGHT_COLORS: Record<string, string> = { blue: 'Blue', teal: 'Teal', purple: 'Purple', white: 'White', warm: 'Warm white' };
const FEATURES: Record<string, { name: string; price: number }> = {
swimjet: { name: 'Swim jet', price: prices.swimJet },
jets: { name: 'Wall jets by the shallow end', price: prices.wallJets },
bubbler: { name: 'Bubbler on the ledge', price: prices.bubbler },
waterfall: { name: 'Sheer descent waterfall', price: prices.waterfall }
};
const EXTRAS: Record<string, { name: string; price: number }> = {
spa: { name: 'Attached spa spilling into the pool', price: prices.spa },
hottub: { name: 'Hot tub on the deck', price: prices.hotTub }
};
const SCOPES: Record<string, string> = {
kit: 'Pool and equipment only: the dig and the deck are yours',
install: 'Installed pool: with the dig and the base; deck and barrier yours',
turnkey: 'Turnkey backyard: with the deck, the barrier and the fill'
};
const SOILS: Record<string, string> = { unknown: 'Not sure', sand: 'Sandy loam', clay: 'Clay (+' + prices.clayPct + '% on the dig)', rock: 'Limestone (+' + prices.rockPct + '% on the dig)' };
const TIMINGS: Record<string, string> = { season: 'This season', nextyear: 'Next year', exploring: 'Just exploring' };
const BUDGETS: Record<string, string> = { none: 'Prefer not to say', to60: 'Under $60k', to90: '$60-90k', to150: '$90-150k', over: 'Over $150k' };
const MONTHS = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
 
// The sizes heaters and heat pumps are made in (thousands of BTU/h), and the flows pumps come for (GPM)
const GAS_SIZES = [150, 200, 250, 300, 400];
const HP_SIZES = [50, 85, 110, 140];
const FLOWS = [40, 50, 60, 70, 80, 100, 120, 140];
const firstAtLeast = (sizes: number[], needed: number): number => {
for (const s of sizes) if (s >= needed) return s;
return sizes[sizes.length - 1] || 0;
};
 
form.addRow(row => {
row.addTextPanel('header', {
computedValue: () => 'Inground Pool Estimate',
customStyles: { 'font-size': '1.5rem', 'font-weight': '600', 'color': '#1e293b' }
});
});
form.addRow(row => {
row.addTextPanel('intro', {
computedValue: () => 'Say what the pool is for, pick the type, the size, the equipment and the finishes. The pump, the filter and the heater are sized from the gallons, and you see a price range broken down by stage.',
customStyles: { 'font-size': '0.95rem', 'color': '#64748b' }
});
});
 
form.addSpacer({ height: 20 });
 
// ---- Purpose --------------------------------------------------------------------
 
const purposeSection = form.addSubform('purpose', { title: 'Your Pool' });
 
// The purpose sets the pool it starts from: size, depth, entry, shape
const applyPurpose = (id: string) => {
const p = PURPOSES[id] || PURPOSES['family']!;
sizeSection.slider('length')?.setValue(p.length);
sizeSection.slider('width')?.setValue(p.width);
sizeSection.slider('shallow')?.setValue(p.shallow);
sizeSection.slider('deep')?.setValue(p.deep);
sizeSection.radioButton('floor')?.setValue(p.shallow === p.deep ? 'flat' : 'sloped');
sizeSection.dropdown('shape')?.setValue(p.shape);
sizeSection.dropdown('entry')?.setValue(p.entry);
};
 
purposeSection.addRow(row => {
row.addRadioButton('purpose', {
label: 'What is the pool for?',
tooltip: 'The size, the depth and the entry follow from it; you can change each below',
options: Object.keys(PURPOSES).map(id => ({ id, name: PURPOSES[id]!.name })),
defaultValue: 'family',
orientation: 'vertical',
isRequired: true,
onValueChange: value => applyPurpose(value || 'family')
});
});
 
const purpose = () => purposeSection.radioButton('purpose')?.value() || 'family';
 
// ---- Yard -----------------------------------------------------------------------
 
const yardSection = form.addSubform('yard', { title: 'Your Yard' });
 
yardSection.addRow(row => {
row.addSlider('access', {
label: 'Narrowest point on the way to the backyard (gate or side yard)',
unit: 'ft',
min: 5,
max: 26,
step: 0.5,
defaultValue: 12
}, '1fr');
row.addDropdown('hoa', {
label: 'Homeowners association?',
tooltip: 'An HOA usually has to approve the plan before the permit',
options: [{ id: 'no', name: 'No HOA' }, { id: 'yes', name: 'Yes, an HOA' }],
defaultValue: 'no'
}, '1fr');
});
 
yardSection.addRow(row => {
row.addDropdown('soil', {
label: 'Soil under the lawn',
options: Object.keys(SOILS).map(id => ({ id, name: SOILS[id]! })),
defaultValue: 'unknown'
}, '1fr');
row.addDropdown('waterTable', {
label: 'Water table',
options: [{ id: 'unknown', name: 'Not sure' }, { id: 'normal', name: 'Normal' }, { id: 'high', name: 'High' + priceTag(prices.dewatering) + ' for dewatering' }],
defaultValue: 'unknown'
}, '1fr');
});
 
const access = () => yardSection.slider('access')?.value() || 12;
const hoa = () => yardSection.dropdown('hoa')?.value() === 'yes';
const soil = () => yardSection.dropdown('soil')?.value() || 'unknown';
const waterTable = () => yardSection.dropdown('waterTable')?.value() || 'unknown';
const narrowAccess = () => access() < 8;
 
// ---- Type -----------------------------------------------------------------------
 
const typeSection = form.addSubform('type', { title: 'Pool Type' });
 
typeSection.addRow(row => {
row.addRadioButton('type', {
label: 'What should the pool be built from?',
options: [
{ id: 'fiberglass', name: 'Fiberglass shell: finished at the factory, set in a few days (from ' + money(prices.fiberglassBase) + ' + $' + prices.fiberglassSqFt + '/sq ft)' },
{ id: 'vinyl', name: 'Vinyl liner: steel walls and a liner, any size (from ' + money(prices.vinylBase) + ' + $' + prices.vinylSqFt + '/sq ft)' },
{ id: 'gunite', name: 'Gunite: any shape, plaster or pebble, built to last (from ' + money(prices.guniteBase) + ' + $' + prices.guniteSqFt + '/sq ft)' }
],
defaultValue: 'fiberglass',
orientation: 'vertical',
isRequired: true
}, '1fr');
row.addRadioButton('overflow', {
label: 'How does the water get back to the filter?',
options: [
{ id: 'skimmer', name: 'Skimmers: water 4 in under the coping' },
{ id: 'overflow', name: 'Perimeter overflow: water level with the deck (+' + prices.overflowPct + '% on the shell)' }
],
defaultValue: 'skimmer',
orientation: 'vertical',
isVisible: () => poolType() === 'gunite'
}, '1fr');
});
 
const poolType = () => {
const chosen = typeSection.radioButton('type')?.value() || 'fiberglass';
return chosen in TYPES ? chosen : 'fiberglass';
};
const builtInPlace = () => poolType() !== 'fiberglass';
const overflow = () => poolType() === 'gunite' && typeSection.radioButton('overflow')?.value() === 'overflow';
 
typeSection.addRow(row => {
row.addTextPanel('typeInfo', {
computedValue: () => {
if (poolType() === 'fiberglass') return 'Fastest: the shell arrives finished and is in the ground in a few days. Shapes and sizes from the catalog, up to ' + prices.fiberglassMaxLength + ' x ' + prices.fiberglassMaxWidth + ' ft. It has to come through in one piece or fly over on a crane. Warranty: ' + TYPES['fiberglass']!.warranty + '.';
if (poolType() === 'vinyl') return 'Any size, no concrete: steel walls are set on site and the liner goes in, so it comes through a narrow side yard. A couple of weeks longer than fiberglass; the liner is replaced every 10 to 15 years. Warranty: ' + TYPES['vinyl']!.warranty + '.';
return 'No limits: shotcrete with plaster or pebble, any shape, a perimeter overflow, steps, benches and an attached spa. The longest build and the most expensive, but it lasts for decades. Warranty: ' + TYPES['gunite']!.warranty + '.';
},
customStyles: { 'font-size': '0.9rem', 'color': '#0369a1', 'background': '#e0f2fe', 'padding': '10px', 'border-radius': '6px' }
});
});
 
// ---- Size and shape -------------------------------------------------------------
 
const sizeSection = form.addSubform('size', { title: 'Size and Shape' });
 
sizeSection.addRow(row => {
row.addDropdown('shape', {
label: 'Shape',
options: () => Object.keys(SHAPES).map(id => ({ id, name: SHAPES[id]! + ((id === 'oval' || id === 'kidney') && builtInPlace() ? ' (+' + prices.freeformPct + '%, custom formed)' : '') })),
defaultValue: 'rounded',
isRequired: true
}, '1fr');
row.addRadioButton('floor', {
label: 'Floor',
options: [{ id: 'flat', name: 'Flat' }, { id: 'sloped', name: 'Sloping deeper' }],
defaultValue: 'sloped',
orientation: 'horizontal'
}, '1fr');
});
 
sizeSection.addRow(row => {
row.addSlider('length', { label: 'Length (inside, without a Roman end)', unit: 'ft', min: 12, max: 44, step: 1, defaultValue: 28 }, '1fr');
row.addSlider('width', { label: 'Width', unit: 'ft', min: 8, max: 20, step: 1, defaultValue: 14 }, '1fr');
});
 
sizeSection.addRow(row => {
row.addSlider('shallow', { label: () => sloped() ? 'Depth by the steps' : 'Depth', unit: 'ft', min: 3, max: 6.5, step: 0.5, defaultValue: 3.5 }, '1fr');
row.addSlider('deep', { label: 'At the deep end', unit: 'ft', min: 3, max: 9, step: 0.5, defaultValue: 5.5, isVisible: () => sloped() }, '1fr');
});
 
const length = () => sizeSection.slider('length')?.value() || 28;
const width = () => sizeSection.slider('width')?.value() || 14;
const sloped = () => sizeSection.radioButton('floor')?.value() !== 'flat';
const shallow = () => sizeSection.slider('shallow')?.value() || 3.5;
const deep = () => sloped() ? Math.max(shallow(), sizeSection.slider('deep')?.value() || 5.5) : shallow();
const shape = () => {
const chosen = sizeSection.dropdown('shape')?.value() || 'rounded';
return chosen in SHAPES ? chosen : 'rounded';
};
 
// A Roman end needs a straight short wall, corner steps a square corner
const entryPossible = (id: string): boolean => {
if (id === 'roman') return shape() === 'rectangle' || shape() === 'rounded';
if (id === 'corner') return shape() === 'rectangle';
return true;
};
const entryPrice = (id: string) => builtInPlace() && id !== 'ladder' ? prices.builtSteps + (id === 'ledge' ? prices.tanningLedge : 0) : 0;
 
sizeSection.addRow(row => {
row.addDropdown('entry', {
label: 'Steps',
options: () => Object.keys(ENTRIES).filter(entryPossible).map(id => ({ id, name: ENTRIES[id]! + priceTag(entryPrice(id)) })),
defaultValue: 'ledge',
isRequired: true
}, '1fr');
row.addCheckbox('bench', {
label: () => 'Bench in the deep end' + (builtInPlace() ? priceTag(prices.bench) : ''),
defaultValue: false
}, '1fr');
});
 
const entry = () => {
const chosen = sizeSection.dropdown('entry')?.value() || 'ledge';
return chosen in ENTRIES && entryPossible(chosen) ? chosen : 'full';
};
const bench = () => sizeSection.checkbox('bench')?.value() === true;
 
// ---- Measurements: surface, gallons, perimeter (feet) ------------------------------
 
// The corner radius and the Roman bay, as the pool is formed
const geometry = (): { area: number; perimeter: number; bay: number } => {
const l = length();
const w = width();
if (shape() === 'oval' || shape() === 'kidney') {
const r = Math.min(w, l) / 2;
const stadium = (l - 2 * r) * w + Math.PI * r * r;
const perimeter = 2 * (l - 2 * r) + 2 * Math.PI * r;
return shape() === 'kidney'
? { area: stadium - 0.106 * w * l, perimeter: perimeter * 1.05, bay: 0 }
: { area: stadium, perimeter, bay: 0 };
}
const rc = shape() === 'rounded' ? Math.min(3, w * 0.25, l * 0.2) : poolType() === 'gunite' ? 0.07 : 0.33;
let bay = 0;
if (entry() === 'roman') {
const radius = Math.min(4.75, w / 2 - rc - 0.8);
bay = radius > 1 ? radius : 0;
}
const area = l * w - (4 - Math.PI) * rc * rc + Math.PI * bay * bay / 2;
const perimeter = 2 * (l + w) - (8 - 2 * Math.PI) * rc + (bay > 0 ? Math.PI * bay - 2 * bay : 0);
return { area, perimeter, bay };
};
 
// Mean depth over the length: shallow flat, a slope, deep flat, as the floor is laid
const meanDepth = () => shallow() * 0.45 + (shallow() + deep()) / 2 * 0.27 + deep() * 0.28;
const surface = () => geometry().area;
const perimeter = () => geometry().perimeter;
const gallons = () => surface() * (meanDepth() - (overflow() ? 0.08 : 0.33)) * GAL_PER_CUFT;
const gallonsText = () => Math.round(gallons() / 100) * 100;
const dimsText = () => length() + ' x ' + width() + ' ft, ' + (sloped() ? feetInches(shallow()) + ' to ' + feetInches(deep()) : feetInches(shallow())) + ' deep';
const tooBigForFiberglass = () => poolType() === 'fiberglass' && (length() > prices.fiberglassMaxLength || width() > prices.fiberglassMaxWidth);
 
sizeSection.addRow(row => {
row.addTextPanel('sizeInfo', {
computedValue: () => 'Water surface ' + Math.round(surface()) + ' sq ft, ' + gallonsText() + ' gallons to fill (about ' + money(gallons() / 1000 * prices.waterKgal) + ' of water). '
+ 'Every inground pool needs a building permit and a barrier to code' + (hoa() ? '; the HOA approves the plan first' : '') + '.'
+ (tooBigForFiberglass() ? ' A fiberglass shell that size cannot ship (up to ' + prices.fiberglassMaxLength + ' x ' + prices.fiberglassMaxWidth + ' ft): we build it in vinyl or gunite.' : '')
+ (purpose() === 'family' && shallow() > 4.1 ? ' Deep for a family pool: 3 ft 6 in to 4 ft by the steps lets a child stand with their head above water.' : ''),
customStyles: { 'font-size': '0.9rem', 'color': '#0369a1', 'background': '#e0f2fe', 'padding': '10px', 'border-radius': '6px' }
});
});
 
// ---- Water and equipment --------------------------------------------------------
 
const waterSection = form.addSubform('water', { title: 'Water and Equipment' });
 
// The pump is sized from the gallons: all the water through the filter in the set hours
const flow = () => firstAtLeast(FLOWS, gallons() / (prices.turnoverHours * 60));
const pumpKw = (gpm: number) => gpm <= 60 ? 0.55 : gpm <= 80 ? 0.75 : gpm <= 100 ? 1.1 : 1.5;
const pumpHp = (gpm: number) => gpm <= 60 ? '1 HP' : gpm <= 80 ? '1.5 HP' : gpm <= 100 ? '2 HP' : '2.7 HP';
const equipmentBaseAmount = () => prices.equipmentBase + Math.max(0, flow() - 60) * prices.equipmentGpm;
 
waterSection.addRow(row => {
row.addTextPanel('equipmentInfo', {
computedValue: () => 'Flow ' + flow() + ' GPM: ' + gallonsText() + ' gallons through the filter every ' + prices.turnoverHours + ' h. Pump ' + pumpHp(flow()) + ' variable speed with a cartridge filter, skimmer, returns and main drain: ' + money(equipmentBaseAmount()) + ' with the plumbing.',
customStyles: { 'font-size': '0.9rem', 'color': '#0369a1', 'background': '#e0f2fe', 'padding': '10px', 'border-radius': '6px' }
});
});
 
waterSection.addRow(row => {
row.addRadioButton('sanitizer', {
label: 'Sanitizer',
options: Object.keys(SANITIZERS).map(id => ({ id, name: SANITIZERS[id]!.name + priceTag(SANITIZERS[id]!.price) })),
defaultValue: 'chlorine',
orientation: 'vertical'
}, '1fr');
row.addRadioButton('location', {
label: 'Where does the equipment go?',
options: Object.keys(LOCATIONS).map(id => ({ id, name: LOCATIONS[id]!.name + priceTag(LOCATIONS[id]!.price) })),
defaultValue: 'pad',
orientation: 'vertical'
}, '1fr');
});
 
waterSection.addRow(row => {
row.addCheckbox('automation', {
label: 'Pool automation: pump, heater, lights and features from your phone' + priceTag(prices.automation),
defaultValue: false
});
});
 
const sanitizer = () => {
const chosen = waterSection.radioButton('sanitizer')?.value() || 'chlorine';
return chosen in SANITIZERS ? chosen : 'chlorine';
};
const location = () => {
const chosen = waterSection.radioButton('location')?.value() || 'pad';
return chosen in LOCATIONS ? chosen : 'pad';
};
const automation = () => waterSection.checkbox('automation')?.value() === true;
 
// ---- Heat and cover -------------------------------------------------------------
 
const heatSection = form.addSubform('heat', { title: 'Heat and Cover' });
 
const gasSize = () => firstAtLeast(GAS_SIZES, gallons() * prices.gasBtuPerGal / 1000);
const hpSize = () => firstAtLeast(HP_SIZES, gallons() * prices.hpBtuPerGal / 1000);
const heaterPrice = (id: string) => {
if (id === 'heatpump') return prices.hpBase + hpSize() * prices.hpKbtu;
if (id === 'gas') return prices.gasBase + gasSize() * prices.gasKbtu;
if (id === 'solar') return prices.solar;
return 0;
};
// The area a cover covers: the water for an automatic cover or a blanket, the pool with its coping for an enclosure
const coverPrice = (id: string) => {
const water = surface();
const enclosed = (length() + geometry().bay + 4) * (width() + 3.6);
if (id === 'auto') return prices.autoBase + prices.autoSqFt * water;
if (id === 'auto_recessed') return (prices.autoBase + prices.autoSqFt * water) * (1 + prices.recessedPct / 100);
if (id === 'blanket') return prices.blanketSqFt * water + prices.reel;
if (id === 'enclosure_low') return prices.lowBase + prices.lowSqFt * enclosed;
if (id === 'enclosure_high') return prices.highBase + prices.highSqFt * enclosed;
return 0;
};
 
heatSection.addRow(row => {
row.addRadioButton('heater', {
label: 'Heater',
options: () => Object.keys(HEATERS).map(id => ({ id, name: HEATERS[id]! + priceTag(Math.round(heaterPrice(id))) })),
defaultValue: 'heatpump',
orientation: 'vertical'
}, '1fr');
row.addRadioButton('cover', {
label: 'Cover',
options: () => Object.keys(COVERS).map(id => ({ id, name: COVERS[id]! + priceTag(Math.round(coverPrice(id))) })),
defaultValue: 'auto',
orientation: 'vertical'
}, '1fr');
});
 
const heater = () => {
const chosen = heatSection.radioButton('heater')?.value() || 'heatpump';
return chosen in HEATERS ? chosen : 'heatpump';
};
const heated = () => heater() !== 'none';
const cover = () => {
const chosen = heatSection.radioButton('cover')?.value() || 'auto';
return chosen in COVERS ? chosen : 'auto';
};
const keepsHeat = () => cover() !== 'none';
const heaterSize = () => heater() === 'gas' ? gasSize() : hpSize();
 
// The months the pool is pleasant to swim in (0 = January), from how it is heated and covered
const swimSeason = (heating: string, covering: string): { from: number; to: number } => {
const enclosure = covering === 'enclosure_low' || covering === 'enclosure_high';
if (heating === 'none') {
if (covering === 'enclosure_high') return { from: 2, to: 10 };
if (enclosure) return { from: 3, to: 9 };
return covering === 'none' ? { from: 4, to: 8 } : { from: 3, to: 9 };
}
if (covering === 'none') return { from: 3, to: 9 };
const sun = heating === 'solar' ? 1 : 0;
if (covering === 'enclosure_high') return { from: 1 + sun, to: 11 - sun };
return { from: 2 + sun, to: 10 - sun };
};
const seasonText = (season: { from: number; to: number }) => MONTHS[season.from] + ' to ' + MONTHS[season.to] + ' (' + (season.to - season.from + 1) + ' months)';
const tempDay = () => heated() ? prices.tempHeated : prices.tempUnheated;
const tempMorning = () => tempDay() - (keepsHeat() ? prices.dropCovered : prices.dropOpen);
 
// A season's heating: the heat the water loses, through gas at the heater's efficiency or the heat pump's COP
const heatingCost = (id: string, covered: boolean) => {
const kbtu = surface() * (covered ? prices.kbtuCovered : prices.kbtuOpen);
if (id === 'gas') return kbtu / 100 / (prices.gasEfficiencyPct / 100) * prices.thermPrice;
if (id === 'heatpump') return kbtu * 0.293 / prices.heatPumpCop * prices.kwhPrice;
return 0;
};
// Pump electricity, the water topped up (about four feet of evaporation a season, a third under a cover), the chemicals
const runningCost = () => {
const electricity = pumpKw(flow()) * prices.pumpHours * prices.seasonDays * prices.kwhPrice;
const topUp = surface() * (keepsHeat() ? 1.3 : 4) * GAL_PER_CUFT / 1000 * prices.waterKgal;
const chemicals = prices.chemicalsSeason * gallons() / 15000 * (sanitizer() === 'salt' ? 0.5 : 1);
return electricity + topUp + chemicals;
};
 
heatSection.addRow(row => {
row.addTextPanel('seasonInfo', {
computedValue: () => {
const lines: string[] = [];
if (heater() === 'heatpump') lines.push('Heat pump ' + heaterSize() + 'k BTU/h (about ' + prices.hpBtuPerGal + ' BTU/h per gallon)');
if (heater() === 'gas') lines.push('Gas heater ' + heaterSize() + 'k BTU/h (about ' + prices.gasBtuPerGal + ' BTU/h per gallon)');
lines.push('Swim season ' + seasonText(swimSeason(heater(), cover())));
lines.push('Water on a summer morning about ' + tempMorning() + '°F');
lines.push('Heating per season ' + (heated() ? money(heatingCost(heater(), keepsHeat())) : 'no cost') + ', pump, water and chemicals ' + money(runningCost()));
if (heated() && heater() !== 'solar' && !keepsHeat()) {
lines.push('A heater without a cover heats the sky: an open pool loses about ' + prices.dropOpen + '°F overnight and heating costs ' + money(heatingCost(heater(), false)) + ' instead of ' + money(heatingCost(heater(), true)) + ' a season');
}
return lines.join(' | ');
},
customStyles: { 'font-size': '0.9rem', 'color': '#0369a1', 'background': '#e0f2fe', 'padding': '10px', 'border-radius': '6px' }
});
});
 
// ---- Finishes -------------------------------------------------------------------
 
const finishSection = form.addSubform('finishes', { title: 'Finishes and Surroundings' });
 
const finishPrice = () => poolType() !== 'gunite' ? prices.finishUpgrade : prices.pebbleSqFt * (surface() + perimeter() * meanDepth());
const deckArea = (id: string) => {
if (id === 'walkway') return perimeter() * 4 + 64;
if (id === 'patio') return (length() + geometry().bay + 8) * (width() + 15) - surface();
return 0;
};
const deckPrice = (copingId: string, deckId: string) => COPINGS[copingId]!.lf * perimeter() + deckArea(deckId) * COPINGS[copingId]!.sqFt;
// The deck's outer rectangle: what a fence runs round and a screen cage stands over
const barrierPrice = (id: string, deckId: string) => {
const reach = deckId === 'none' ? 1.5 : 4;
const boxLength = length() + geometry().bay + 2 * reach;
const boxWidth = width() + (deckId === 'patio' ? 15 : 2 * reach);
if (id === 'fence') return prices.fenceLf * (2 * (boxLength + boxWidth) + 16) + prices.gate;
if (id === 'screen') return prices.screenSqFt * (boxLength + 3.3) * (boxWidth + 3.3);
return 0;
};
// One LED light for every twelve feet of length begun
const lamps = () => Math.max(1, Math.ceil(length() / 12));
const lightsPrice = (id: string) => {
if (id === 'led') return lamps() * prices.ledEach;
if (id === 'strips') return lamps() * prices.ledEach + perimeter() * prices.stripLf;
return 0;
};
 
finishSection.addRow(row => {
row.addDropdown('finish', {
label: 'Interior finish',
tooltip: 'White turns the water turquoise, sandstone a lagoon green, midnight a dark mirror like a lake',
options: () => Object.keys(FINISHES).map(id => ({ id, name: FINISHES[id]! + (id === 'pebble' ? priceTag(Math.round(finishPrice())) : '') })),
defaultValue: 'blue'
}, '1fr');
row.addDropdown('coping', {
label: 'Coping and deck material',
options: Object.keys(COPINGS).map(id => ({ id, name: COPINGS[id]!.name + ' ($' + COPINGS[id]!.lf + '/ft of coping, $' + COPINGS[id]!.sqFt + '/sq ft of deck)' })),
defaultValue: 'travertine'
}, '1fr');
});
 
finishSection.addRow(row => {
row.addDropdown('deck', {
label: 'Around the pool',
options: () => Object.keys(DECKS).map(id => ({ id, name: DECKS[id]! + (id === 'none' ? '' : ' - ' + Math.round(deckArea(id)) + ' sq ft') })),
defaultValue: 'walkway'
}, '1fr');
row.addDropdown('barrier', {
label: 'Pool barrier (required by code before the pool is filled)',
options: () => Object.keys(BARRIERS).map(id => ({ id, name: BARRIERS[id]! + priceTag(Math.round(barrierPrice(id, deck()))) })),
defaultValue: 'fence'
}, '1fr');
});
 
const finish = () => {
const chosen = finishSection.dropdown('finish')?.value() || 'blue';
return chosen in FINISHES ? chosen : 'blue';
};
const coping = () => {
const chosen = finishSection.dropdown('coping')?.value() || 'travertine';
return chosen in COPINGS ? chosen : 'travertine';
};
const deck = () => {
const chosen = finishSection.dropdown('deck')?.value() || 'walkway';
return chosen in DECKS ? chosen : 'walkway';
};
const barrier = () => {
const chosen = finishSection.dropdown('barrier')?.value() || 'fence';
return chosen in BARRIERS ? chosen : 'fence';
};
 
finishSection.addRow(row => {
row.addRadioButton('lights', {
label: () => 'Lighting (' + lamps() + ' light' + (lamps() === 1 ? '' : 's') + ' for this length)',
options: () => Object.keys(LIGHTS).map(id => ({ id, name: LIGHTS[id]! + priceTag(Math.round(lightsPrice(id))) })),
defaultValue: 'led',
orientation: 'vertical'
}, '1fr');
row.addDropdown('lightColor', {
label: 'Light color to start with',
tooltip: 'You change the color later from the remote or the app',
options: Object.keys(LIGHT_COLORS).map(id => ({ id, name: LIGHT_COLORS[id]! })),
defaultValue: 'blue',
isVisible: () => lights() !== 'white'
}, '1fr');
});
 
const lights = () => {
const chosen = finishSection.radioButton('lights')?.value() || 'led';
return chosen in LIGHTS ? chosen : 'led';
};
const lightColor = () => finishSection.dropdown('lightColor')?.value() || 'blue';
 
finishSection.addRow(row => {
row.addCheckboxList('features', {
label: 'Water features',
options: Object.keys(FEATURES).map(id => ({ id, name: FEATURES[id]!.name + priceTag(FEATURES[id]!.price) })),
defaultValue: [],
orientation: 'vertical'
}, '1fr');
row.addCheckboxList('extras', {
label: 'Spa',
options: Object.keys(EXTRAS).map(id => ({ id, name: EXTRAS[id]!.name + ' (from ' + money(EXTRAS[id]!.price) + ')' })),
defaultValue: [],
orientation: 'vertical'
}, '1fr');
});
 
const features = () => (finishSection.checkboxList('features')?.value() || []).filter(id => id in FEATURES);
const extras = () => (finishSection.checkboxList('extras')?.value() || []).filter(id => id in EXTRAS);
 
// ---- Scope and timing -----------------------------------------------------------
 
const scopeSection = form.addSubform('scope', { title: 'Scope and Timing' });
 
scopeSection.addRow(row => {
row.addRadioButton('scope', {
label: 'What should we do?',
options: Object.keys(SCOPES).map(id => ({ id, name: SCOPES[id]! })),
defaultValue: 'turnkey',
orientation: 'vertical',
isRequired: true
}, '1fr');
row.addRadioButton('whoDigs', {
label: 'Who does the dig?',
options: [{ id: 'us', name: 'Your crew' }, { id: 'owner', name: 'My own contractor' }],
defaultValue: 'us',
orientation: 'vertical',
isVisible: () => scope() !== 'kit'
}, '1fr');
});
 
scopeSection.addRow(row => {
row.addSlider('distance', {
label: 'Distance from our office (free up to ' + prices.freeMiles + ' mi, then $' + prices.mileRate + '/mi)',
unit: 'mi',
min: 0,
max: 300,
step: 5,
defaultValue: 25
}, '1fr');
row.addDropdown('timing', {
label: 'When do you want to swim?',
options: Object.keys(TIMINGS).map(id => ({ id, name: TIMINGS[id]! })),
defaultValue: 'season'
}, '1fr');
});
 
scopeSection.addRow(row => {
row.addDropdown('budget', {
label: 'Budget (optional, but it helps us pick the right option)',
options: Object.keys(BUDGETS).map(id => ({ id, name: BUDGETS[id]! })),
defaultValue: 'none'
}, '1fr');
});
 
const scope = () => {
const chosen = scopeSection.radioButton('scope')?.value() || 'turnkey';
return chosen in SCOPES ? chosen : 'turnkey';
};
const ownerDigs = () => scope() !== 'kit' && scopeSection.radioButton('whoDigs')?.value() === 'owner';
const distance = () => scopeSection.slider('distance')?.value() || 0;
const timing = () => scopeSection.dropdown('timing')?.value() || 'season';
const budget = () => scopeSection.dropdown('budget')?.value() || 'none';
 
// ---- Price logic ------------------------------------------------------------------
 
const shellAmount = () => {
const t = TYPES[poolType()]!;
let amount = t.base + t.sqFt * surface();
if (builtInPlace() && (shape() === 'oval' || shape() === 'kidney')) amount *= 1 + prices.freeformPct / 100;
if (overflow()) amount *= 1 + prices.overflowPct / 100;
amount += entryPrice(entry());
if (builtInPlace() && bench()) amount += prices.bench;
return amount;
};
const finishAmount = () => finish() === 'pebble' ? finishPrice() : 0;
const equipmentAmount = () => equipmentBaseAmount() + SANITIZERS[sanitizer()]!.price + (automation() ? prices.automation : 0) + LOCATIONS[location()]!.price;
const heaterAmount = () => heaterPrice(heater());
const coverAmount = () => coverPrice(cover());
const craneNeeded = () => poolType() === 'fiberglass' && access() < width() + 1.2;
const excavationAmount = () => {
if (scope() === 'kit') return 0;
const bay = geometry().bay;
const cubicYards = (length() + bay + 3.3) * (width() + 3.3) * (deep() + 1.15) / 27;
const soilPct = soil() === 'rock' ? prices.rockPct : soil() === 'clay' ? prices.clayPct : 0;
const digging = ownerDigs() ? 0 : cubicYards * prices.excavationCuYd * (1 + soilPct / 100) + (narrowAccess() ? prices.narrowAccess : 0);
const base = (length() + bay + 2) * (width() + 2) * prices.baseSqFt;
return digging + base + (waterTable() === 'high' ? prices.dewatering : 0);
};
const deckAmount = () => scope() === 'turnkey' ? deckPrice(coping(), deck()) : 0;
const barrierAmount = () => scope() === 'turnkey' ? barrierPrice(barrier(), deck()) : 0;
const lightsAmount = () => lightsPrice(lights());
const featuresAmount = () => features().reduce((sum, id) => sum + FEATURES[id]!.price, 0);
const extrasAmount = () => extras().reduce((sum, id) => sum + EXTRAS[id]!.price, 0);
const installAmount = () => (shellAmount() + finishAmount() + equipmentAmount()) * prices.installPct / 100;
const craneAmount = () => craneNeeded() ? prices.crane : 0;
const travelAmount = () => Math.max(0, distance() - prices.freeMiles) * prices.mileRate;
const waterAmount = () => scope() === 'turnkey' ? gallons() / 1000 * prices.waterKgal : 0;
 
// The build, stage by stage, as the estimate shows it
const stageGround = () => excavationAmount() + prices.permit;
const stageShell = () => shellAmount() + finishAmount() + installAmount() + craneAmount() + travelAmount();
const stageEquipment = () => equipmentAmount() + heaterAmount();
const stageSurroundings = () => deckAmount() + barrierAmount() + lightsAmount() + featuresAmount();
const stageFinal = () => waterAmount() + coverAmount() + extrasAmount();
 
const net = () => stageGround() + stageShell() + stageEquipment() + stageSurroundings() + stageFinal();
const promo = () => net() * prices.promoPct / 100;
// The minimum holds last: a promotion never takes a job below what the crew costs
const total = () => Math.max(Math.round(net() - promo()), prices.minimum);
const priceFrom = () => Math.round(total() * (1 - prices.rangePct / 100) / 100) * 100;
const priceTo = () => Math.round(total() * (1 + prices.rangePct / 100) / 100) * 100;
const seasonCost = () => heatingCost(heater(), keepsHeat()) + runningCost();
 
const heaterText = () => short((HEATERS[heater()] || ''), ':') + (heater() === 'heatpump' || heater() === 'gas' ? ' ' + heaterSize() + 'k BTU/h' : '');
const listText = (ids: string[], table: Record<string, { name: string; price: number }>) => ids.map(id => table[id]!.name).join(', ') || 'none';
 
form.addSpacer({ height: 20, showLine: true, lineStyle: 'dashed' });
 
// ---- Estimate ---------------------------------------------------------------------
 
const summarySection = form.addSubform('summary', { title: 'Your Estimate by Stage', isCollapsible: false });
 
summarySection.addRow(row => {
row.addPriceDisplay('groundCost', {
label: () => scope() === 'kit' ? 'Permit (dig and base on your side)' : ownerDigs() ? 'Permit and base' : 'Permit, dig and base',
computedValue: () => Math.round(stageGround()),
decimals: 0,
variant: 'default'
}, '1fr');
row.addPriceDisplay('shellCost', {
label: () => TYPES[poolType()]!.name + ' set and plumbed (' + dimsText() + ')',
computedValue: () => Math.round(stageShell()),
decimals: 0,
variant: 'default',
prefix: '+'
}, '1fr');
});
summarySection.addRow(row => {
row.addPriceDisplay('equipmentCost', {
label: () => 'Equipment' + (heated() ? ' and heater' : ''),
computedValue: () => Math.round(stageEquipment()),
decimals: 0,
variant: 'default',
prefix: '+'
}, '1fr');
row.addPriceDisplay('surroundingsCost', {
label: () => scope() === 'turnkey' ? 'Deck, barrier, lights and features' : 'Lights and features',
computedValue: () => Math.round(stageSurroundings()),
decimals: 0,
variant: 'default',
prefix: '+'
}, '1fr');
});
summarySection.addRow(row => {
row.addPriceDisplay('finalCost', {
label: () => (cover() !== 'none' ? 'Cover' : 'Filling') + (scope() === 'turnkey' ? ', water' : '') + (extras().length > 0 ? ' and spa' : ''),
computedValue: () => Math.round(stageFinal()),
decimals: 0,
variant: 'default',
prefix: '+'
}, '1fr');
row.addPriceDisplay('promoDiscount', {
label: () => prices.promoText + ' (-' + prices.promoPct + '%)',
computedValue: () => -Math.round(promo()),
decimals: 0,
variant: 'success',
isVisible: () => promo() > 0
}, '1fr');
});
 
summarySection.addRow(row => {
row.addTextPanel('minimumNote', {
computedValue: () => 'The estimate was raised to the minimum job of ' + money(prices.minimum) + '.',
customStyles: { 'font-size': '0.85rem', 'color': '#b45309' },
isVisible: () => total() > Math.round(net() - promo())
});
});
 
summarySection.addSpacer({ showLine: true, lineStyle: 'solid', lineColor: '#e2e8f0' });
 
summarySection.addRow(row => {
row.addPriceDisplay('priceFrom', { label: 'Your pool: from', computedValue: () => priceFrom(), decimals: 0, variant: 'large' }, '1fr');
row.addPriceDisplay('priceTo', { label: 'to', computedValue: () => priceTo(), decimals: 0, variant: 'large' }, '1fr');
});
 
summarySection.addRow(row => {
row.addPriceDisplay('seasonCost', {
label: 'Running cost of a season (heating, pump, water, chemicals)',
computedValue: () => Math.round(seasonCost()),
decimals: 0,
variant: 'default',
suffix: '/season'
});
});
 
summarySection.addRow(row => {
row.addTextPanel('rangeNote', {
computedValue: () => 'Range of ±' + prices.rangePct + '%, sales tax as applicable. Within ' + prices.visitDays + ' business days we come out to measure the yard, check the access and do a test hole, then you get the drawings and the final quote. '
+ (hoa() ? 'HOA approval about ' + prices.hoaWeeks + ' weeks, then the permit about ' + prices.permitWeeks + ' weeks' : 'Permit about ' + prices.permitWeeks + ' weeks')
+ ', build ' + prices.leadWeeks + ' weeks from the signed contract.',
customStyles: { 'font-size': '0.85rem', 'color': '#64748b', 'font-style': 'italic' }
});
});
 
// ---- Sticky total ---------------------------------------------------------------
 
const finalSection = form.addSubform('final', { title: 'Summary', isCollapsible: false, sticky: 'bottom' });
 
finalSection.addRow(row => {
row.addPriceDisplay('totalEstimate', {
label: () => 'Estimated total (about ' + money(priceFrom()) + ' - ' + money(priceTo()) + ')',
computedValue: () => total(),
decimals: 0,
variant: 'large'
});
});
 
// ---- Contact -------------------------------------------------------------------
 
const contactSection = form.addSubform('contact', { title: 'Book a Site Visit' });
 
contactSection.addRow(row => {
row.addTextbox('name', { label: 'Full name', placeholder: 'John Smith', isRequired: true }, '1fr');
row.addTextbox('phone', { label: 'Phone', placeholder: '(512) 555-0100', isRequired: true }, '1fr');
});
contactSection.addRow(row => {
row.addEmail('email', { label: 'Email (where we send the PDF with your configuration)', placeholder: 'john@example.com', isRequired: true }, '1fr');
row.addTextbox('zip', { label: 'ZIP code of the property', placeholder: '78701', isRequired: true }, '1fr');
});
contactSection.addRow(row => {
row.addTextarea('notes', {
label: 'Anything else we should know?',
placeholder: 'E.g. the yard slopes toward the back fence, there is a septic tank on the left, we want the pool visible from the kitchen',
rows: 3,
maxLength: 1500
});
});
 
// ---- PDF -----------------------------------------------------------------------
 
form.configurePdf('estimate', pdf => {
pdf.configure({
filename: 'inground-pool-estimate',
pageSize: 'Letter',
allowUserDownload: true,
downloadButtonLabel: 'Download the configuration as PDF',
header: { title: 'Pool estimate and configuration', subtitle: TYPES[poolType()]!.name + ', ' + dimsText() },
footer: { text: 'Estimate based on the configuration from the form, valid for ' + prices.validityDays + ' days. A binding quote follows the site visit within ' + prices.visitDays + ' business days.', showPageNumbers: true }
});
 
pdf.addSection('Pool', section => {
section.addRow(row => {
row.addField('Type', TYPES[poolType()]!.name + (overflow() ? ', perimeter overflow' : ''));
row.addField('Shape', SHAPES[shape()] || '');
row.addField('Size', dimsText());
});
section.addRow(row => {
row.addField('Water surface', Math.round(surface()) + ' sq ft');
row.addField('Water', gallonsText() + ' gal');
row.addField('Steps', short((ENTRIES[entry()] || ''), ':') + (bench() ? ', bench' : ''));
});
section.addRow(row => {
row.addField('Equipment', flow() + ' GPM, ' + pumpHp(flow()) + ' pump, ' + (LOCATIONS[location()]!.name).toLowerCase());
row.addField('Sanitizer', short(SANITIZERS[sanitizer()]!.name, ':') + (automation() ? ', automation' : ''));
row.addField('Heater', heaterText());
row.addField('Cover', short((COVERS[cover()] || ''), ' ('));
});
section.addRow(row => {
row.addField('Swim season', seasonText(swimSeason(heater(), cover())));
row.addField('Water by day', 'about ' + tempDay() + '°F, ' + tempMorning() + '°F on a summer morning');
});
section.addRow(row => {
row.addField('Interior finish', FINISHES[finish()] || '');
row.addField('Coping and deck', COPINGS[coping()]!.name + (deck() !== 'none' ? ', ' + short((DECKS[deck()] || ''), ' (').toLowerCase() : ''));
row.addField('Barrier', BARRIERS[barrier()] || '');
row.addField('Lights', short((LIGHTS[lights()] || ''), ' (') + (lights() !== 'white' ? ', ' + lamps() + ', ' + (LIGHT_COLORS[lightColor()] || 'blue').toLowerCase() : ''));
});
section.addRow(row => {
row.addField('Features', listText(features(), FEATURES));
row.addField('Spa', listText(extras(), EXTRAS));
});
});
 
pdf.addSection('Yard and scope', section => {
section.addRow(row => {
row.addField('Access', feetInches(access()) + (craneNeeded() ? ', crane over the house' : narrowAccess() ? ', mini excavator' : ''));
row.addField('Soil', short((SOILS[soil()] || ''), ' ('));
row.addField('Water table', waterTable());
row.addField('Paperwork', 'building permit' + (hoa() ? ', HOA approval' : '') + ', barrier to code');
});
section.addRow(row => {
row.addField('Scope', short((SCOPES[scope()] || ''), ':') + (ownerDigs() ? ', dig by your contractor' : ''));
row.addField('Timing', TIMINGS[timing()] || '');
row.addField('Budget', BUDGETS[budget()] || '');
});
});
 
pdf.addSection('Estimate', section => {
const rows: string[][] = [
[scope() === 'kit' ? 'Permit' : ownerDigs() ? 'Permit and base' : 'Permit, dig and base', scope() === 'kit' ? 'dig and base on your side' : soil() === 'unknown' ? 'soil confirmed with a test hole' : short((SOILS[soil()] || ''), ' ('), money(stageGround())],
[TYPES[poolType()]!.name + ' set and plumbed', dimsText() + ', ' + short((ENTRIES[entry()] || ''), ':').toLowerCase() + (finish() === 'pebble' ? ', pebble finish' : '') + ', installation ' + prices.installPct + '%', money(stageShell())],
['Equipment' + (heated() ? ' and heater' : ''), flow() + ' GPM, ' + short(SANITIZERS[sanitizer()]!.name, ':').toLowerCase() + (heated() ? ', ' + heaterText().toLowerCase() : ''), money(stageEquipment())],
[scope() === 'turnkey' ? 'Deck, barrier, lights and features' : 'Lights and features', (scope() === 'turnkey' ? COPINGS[coping()]!.name.toLowerCase() + ' deck, ' + short((BARRIERS[barrier()] || ''), ' (').toLowerCase() + ', ' : '') + short((LIGHTS[lights()] || ''), ' (').toLowerCase(), money(stageSurroundings())],
[(cover() !== 'none' ? 'Cover' : 'Filling') + (scope() === 'turnkey' ? ', water' : '') + (extras().length > 0 ? ' and spa' : ''), short((COVERS[cover()] || ''), ' (').toLowerCase() + (extras().length > 0 ? ', ' + listText(extras(), EXTRAS).toLowerCase() : ''), money(stageFinal())],
['Total before discounts', '', money(net())]
];
if (promo() > 0) rows.push([prices.promoText, prices.promoPct + '%', '-' + money(promo())]);
rows.push(['Estimate', 'range ±' + prices.rangePct + '%, sales tax as applicable', money(priceFrom()) + ' - ' + money(priceTo())]);
rows.push(['Running cost of a season', 'heating, pump electricity, water topped up, chemicals', money(seasonCost())]);
section.addTable(['Stage', 'Details', 'Amount'], rows);
if (total() > Math.round(net() - promo())) {
section.addText('The estimate was raised to the minimum job of ' + money(prices.minimum) + '.');
}
});
 
pdf.addSection('What happens next', section => {
section.addText('1. Site visit within ' + prices.visitDays + ' business days: we measure the yard, check the access and the panel and do a test hole.');
section.addText('2. ' + (hoa() ? 'HOA approval, about ' + prices.hoaWeeks + ' weeks, then the building permit, about ' + prices.permitWeeks + ' weeks.' : 'Building permit, about ' + prices.permitWeeks + ' weeks.'));
section.addText('3. You receive the drawings, the final quote and the contract; until it is signed you can change the finish, the cover and the equipment.');
section.addText('4. Build ' + prices.leadWeeks + ' weeks from the signed contract; the barrier goes up before the pool is filled.');
});
 
const notes = contactSection.textarea('notes')?.value();
if (notes) {
pdf.addSection('Notes', section => section.addText(notes));
}
});
 
form.configureSubmitButton({ label: 'Send and book a site visit' });
 
form.configureCompletionScreen({
type: 'text',
title: 'We have your request',
message: 'We will call to schedule the site visit. The size, the equipment and the finishes from the form are the starting point for the design of your pool.'
});
}
 

Frequently Asked Questions

Can I price fiberglass, vinyl and gunite pools differently?

Yes. Each type has its own starting price and rate per square foot of water, and gunite gets the extras it allows: a perimeter overflow, a pebble finish, steps and benches formed on site. All of it is named constants at the top of the code.

How does the calculator size the equipment and the heater?

From the gallons in the pool. The pump flow turns all the water over in the hours you set, rounded up to the flows pumps come in, and a gas heater or heat pump is sized in BTU per gallon, rounded up to the sizes they are made in. Change the rules to match the brands you install.

Does it account for the dig and the site conditions?

Yes. Excavation is priced per cubic yard from the pool dimensions, with percentage surcharges for rock and clay, a flat charge for dewatering when the water table is high, a mini excavator for a narrow side yard and a crane when a fiberglass shell cannot come through the access.

Can I offer the pool with or without the deck and the fence?

Yes. The scope choice prices a pool with equipment only, an installed pool with the dig and the base, or a turnkey backyard with the deck, the barrier and the fill. The customer can also say their own contractor does the dig.

What does the customer see at the end?

A price range broken down by stage, the running cost of a season (heating, pump, water and chemicals), the swim season for the chosen heater and cover, and a PDF with the whole configuration. You receive the lead with the same details and the customer's contact information.