Repository navigation
Expand file tree
/
Copy pathconstants.js
More file actions
324 lines (315 loc) · 20.9 KB
/
Copy pathconstants.js
File metadata and controls
324 lines (315 loc) · 20.9 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
/*
* constants.js - Pure, module-level constant literals for ClickCount, extracted
* verbatim from index.html.
*
* Loaded as a classic <script src="constants.js"> in <head>, BEFORE the main IIFE.
* These top-level `const` declarations live in the shared global lexical scope,
* so the main script in index.html resolves them by bare name.
*
* Everything here is a plain literal/object/array with no reference to `state`,
* `window`, `location`, the live `supabase` client, or icon data. Environment
* reads (SUPABASE_*, BACKUP_PDF_TO_INDEXEDDB, IS_DEV_HOST), icon-derived consts,
* and all function-local consts stay in index.html. No build step.
*/
// --- Domain enums & defaults ---
const TOOL = { NONE: 0, SCALE: 1, LINE: 2, POLYLINE: 3, COUNTER: 4, EDIT_POLY: 5, MEASURE: 6, HIGHLIGHT: 7, NOTE: 8, MULTIPLY_ZONE: 9, DELETE_ZONE: 10, SCALE_ZONE: 11, ROOM: 12, CHAIN: 13, GHOST: 14, DROP: 15, DUCT: 16, SCHEDULE: 17 }; // SCHEDULE (S6): drag a box over a fixture schedule → counters
const SCALE_MODES = { NONE: 0, POINT_A: 1, POINT_B: 2 };
const PLUMBING_DEFAULTS = {
sizes: ['0.5in', '0.75in', '1in', '1.25in', '1.5in', '2in'],
types: ['Tee', 'Coupling', '90', 'Reducer', 'Drop Ear', 'Male Adapter', 'Female Adapter', 'Ball Valve'],
materials: ['PEX', 'Brass', 'BI', 'Galv']
};
const LINE_DEFAULTS = {
sizes: ['0.5in', '0.75in', '1in', '1.25in', '1.5in', '2in', '3in', '4in'],
materials: ['PEX', 'Copper', 'PVC', 'Brass', 'BI', 'Galv']
};
// --- Trades (Electrical, First-Class S1) ---
// One machine, one Trade switch: `state.trade` ('plumbing' | 'electrical' |
// 'hvac' | null) is per project (null = never chosen = plumbing behavior). The
// Quick creator keeps ONE panel and ONE store shape for every trade — the three
// modifier lists stay `sizes` / `types` / `materials` in storage; a trade
// profile only relabels them and decides the name order. Non-plumbing profiles
// live under `plumbingModifiers.profiles[trade]` so they ride the cloud
// Artboard's existing JSON column with no migration.
const TRADES = ['plumbing', 'electrical', 'hvac'];
const TRADE_LABELS = { plumbing: 'Plumbing', electrical: 'Electrical', hvac: 'HVAC' };
const TRADE_QUICK_PROFILES = {
plumbing: { labels: ['Size', 'Type', 'Material'], nameOrder: ['size', 'material', 'type'], fallbackName: 'Plumbing', placeholder: 'e.g. 1/2" Copper Pipe' },
// Electrical reads Category / Variant / Rating: "Duplex Receptacle 20A".
electrical: { labels: ['Category', 'Variant', 'Rating'], nameOrder: ['type', 'size', 'material'], fallbackName: 'Device', placeholder: 'e.g. Duplex Receptacle 20A' },
hvac: { labels: ['Size', 'Type', 'Material'], nameOrder: ['size', 'material', 'type'], fallbackName: 'HVAC', placeholder: 'e.g. 12" Supply Diffuser' }
};
// Electrical vocabulary: `sizes` = categories, `types` = variants, `materials`
// = ratings ('' = no rating). `mountByType` is the default mount height in
// inches AFF keyed by variant, then category (absent = at the ceiling / no
// default vertical). `iconNameByType` names the bundled symbol
// (my-counters/electrical/*.svg → CUSTOM_ICONS) a variant starts with; resolved
// by name at read time so the store never hard-codes path data.
const ELECTRICAL_DEFAULTS = {
sizes: ['Receptacle', 'Switch', 'Fixture', 'Panel', 'Junction Box', 'Disconnect', 'Motor', 'Data', 'Fire Alarm', 'Low Voltage'],
types: ['Duplex', 'Quad', 'GFCI', 'Dedicated', 'Floor', 'Single Pole', '3-Way', '4-Way', 'Dimmer', 'Occupancy',
'2x4 Troffer', '2x2 Troffer', 'Downlight', 'Wall Pack', 'Exit', 'Emergency', 'Pendant', 'Strip', 'High Bay', 'Sconce',
'Panelboard', 'Disconnect', 'Motor', 'Transformer', 'J-Box', 'Meter',
'Data Outlet', 'Phone', 'TV', 'WAP', 'Speaker', 'Camera', 'Thermostat', 'Card Reader',
'Smoke Detector', 'Heat Detector', 'Pull Station', 'Horn/Strobe'],
materials: ['', '15A', '20A', '30A', '50A', '120V', '208V', '277V', '480V'],
mountByType: {
Duplex: 18, Quad: 18, GFCI: 44, Dedicated: 18,
'Single Pole': 48, '3-Way': 48, '4-Way': 48, Dimmer: 48, Occupancy: 48,
'Wall Pack': 96, Exit: 90, Emergency: 90, Sconce: 72,
Panelboard: 78, Disconnect: 60, Meter: 60,
'Data Outlet': 18, Phone: 18, TV: 18, Thermostat: 48, 'Card Reader': 42, Speaker: 96, Camera: 108,
'Pull Station': 48, 'Horn/Strobe': 80,
Receptacle: 18, Switch: 48, Panel: 78, Data: 18, 'Fire Alarm': 80, 'Low Voltage': 18
},
iconNameByType: {
Duplex: 'Duplex Receptacle', Quad: 'Quad Receptacle', GFCI: 'GFCI Receptacle', Dedicated: 'Dedicated Receptacle', Floor: 'Floor Receptacle',
'Single Pole': 'Single Pole Switch', '3-Way': 'Three-Way Switch', '4-Way': 'Four-Way Switch', Dimmer: 'Dimmer Switch', Occupancy: 'Occupancy Sensor Switch',
'2x4 Troffer': '2x4 Troffer', '2x2 Troffer': '2x2 Troffer', Downlight: 'Downlight', 'Wall Pack': 'Wall Pack', Exit: 'Exit Sign', Emergency: 'Emergency Light',
Pendant: 'Pendant Light', Strip: 'Strip Light', 'High Bay': 'High Bay', Sconce: 'Wall Sconce',
Panelboard: 'Panelboard', Disconnect: 'Disconnect Switch', Motor: 'Motor', Transformer: 'Transformer', 'J-Box': 'Junction Box', Meter: 'Meter',
'Data Outlet': 'Data Outlet', Phone: 'Telephone Outlet', TV: 'TV Outlet', WAP: 'Wireless Access Point', Speaker: 'Speaker', Camera: 'Camera', Thermostat: 'Thermostat', 'Card Reader': 'Card Reader',
'Smoke Detector': 'Smoke Detector', 'Heat Detector': 'Heat Detector', 'Pull Station': 'Pull Station', 'Horn/Strobe': 'Horn Strobe'
}
};
const HVAC_DEFAULTS = {
sizes: ['6"', '8"', '10"', '12"', '14"', '12x12', '24x24'],
types: ['Supply Diffuser', 'Return Grille', 'Exhaust Grille', 'Linear Diffuser', 'Thermostat', 'VAV Box', 'Fan Coil', 'RTU', 'Exhaust Fan', 'Damper', 'Fire Damper'],
materials: ['', 'Lay-in', 'Surface', 'Round Neck'],
// D16: the bundled HVAC symbol (my-counters/hvac/*.svg → CUSTOM_ICONS, set
// 'hvac') a type starts with — same by-name resolution as electrical. Types
// without a symbol (Thermostat, Fan Coil, …) keep the picker's default.
iconNameByType: {
'Supply Diffuser': 'Supply Diffuser', 'Linear Diffuser': 'Supply Diffuser',
'Return Grille': 'Return Grille', 'Exhaust Grille': 'Return Grille',
'VAV Box': 'VAV Box', RTU: 'RTU', Damper: 'Fire/Smoke Damper', 'Fire Damper': 'Fire/Smoke Damper',
Thermostat: 'Thermostat' // the electrical set's ring-T — the same symbol on an M-sheet
}
};
// The project-level defaults behind "vertical by default" (S2): a device at
// `mountHeightIn` under a `ceilingHeightFt` ceiling gets ceiling − mount +
// make-up feet of vertical written by the Chain tool. 1 ft of make-up is the
// trade's working figure; null ceiling = the feature is off for the project.
const DEFAULT_MAKE_UP_FT = 1;
// --- Codes & jurisdiction (rulebook slice 4) ---
// Which editions the rulebook's values resolve against for a project, per trade,
// plus the jurisdiction whose amendments apply. `state.codes` holds only what the
// project chose (null = never chosen); getProjectCodes() in app.js layers the
// device default and CODE_DEFAULTS under it. The lists are what the rule pages
// have been checked against or are likely to be asked for.
const CODE_EDITIONS = {
plumbing: ['IPC 2015', 'IPC 2018', 'IPC 2021', 'IPC 2024', 'UPC 2018', 'UPC 2021', 'UPC 2024'],
electrical: ['NEC 2017', 'NEC 2020', 'NEC 2023'],
hvac: ['SMACNA 2005', 'SMACNA 2020'],
};
const CODE_DEFAULTS = { plumbing: 'IPC 2021', electrical: 'NEC 2023', hvac: 'SMACNA 2020' };
// A saved/imported `codes` blob → the shape the app stores, or null when it holds
// nothing. Unknown editions are kept (a newer app may know them); non-strings drop.
function normalizeProjectCodes(raw) {
if (!raw || typeof raw !== 'object') return null;
const out = {};
['plumbing', 'electrical', 'hvac'].forEach((t) => { if (typeof raw[t] === 'string' && raw[t].trim()) out[t] = raw[t].trim(); });
if (typeof raw.jurisdiction === 'string' && raw.jurisdiction.trim()) out.jurisdiction = raw.jurisdiction.trim();
// WATER-PLAN rung 1: the fixture-unit column the project reads (public | private).
if (raw.occupancy === 'public' || raw.occupancy === 'private') out.occupancy = raw.occupancy;
return Object.keys(out).length ? out : null;
}
// MAP-SETTINGS (2026-09-26): the Counter and Line Type display settings (marker size,
// opacity, rings, number size, outline, line width, drop size, label sizes, Snap 45°, the
// Lines this-sheet toggle) are a DEVICE preference: app.js starts state from these
// defaults, merges localStorage `counterSettings` / `lineTypeSettings` over them at boot,
// and writes the blob back on every change (saveDisplaySettings). Never in the project.
// ringSize is a percent of the marker, on the Ring size slider's 50 to 200 (MAP-RING-DEFAULT:
// it was 1 until 2026-09-26, a ring 1% of the marker that drew nothing, under the slider).
const COUNTER_SETTINGS_DEFAULTS = { size: 22, opacity: 1, showRings: false, numberSize: 10, ringSize: 100, ringOpacity: 1, ringSolid: true, outlineSize: 0, showOnlyCountersOnCurrentPage: false, autoPick: false }; // autoPick: the plan's tags pick the counter (AUTO-PICK, features/tag-reader.js)
const LINE_TYPE_SETTINGS_DEFAULTS = { opacity: 1, lineSize: 2, dropXSize: 10, dropIconStyle: 'circle', orientLengthWithLine: true, parallelEndsSize: 10, lengthLabelSize: 12, snapToHorizontalVertical: false, showOnlyLineTypesOnCurrentPage: false, showOnlyLinesOnCurrentPage: false };
// The sidebar filter scope and its two legacy page-only booleans keep their own device
// keys (counterSidebarFilterScope / lineTypeSidebarFilterScope), so the blob leaves them out.
const DISPLAY_SETTINGS_SCOPE_FIELDS = ['sidebarFilterScope', 'showOnlyCountersOnCurrentPage', 'showOnlyLineTypesOnCurrentPage'];
// A number under its slider's minimum (app/index.html) is not one the dialog can show: a
// stored one reads as the default. The ring size is the one that happened: devices that
// saved their settings while its default was 1 stored that 1 (MAP-RING-DEFAULT).
const DISPLAY_SETTINGS_MINIMUMS = { ringSize: 50 };
// The fields of `raw` worth keeping for a device: only the defaults' own keys, each the
// default's type (a number finite), the scope fields left out. Used both ways: what is
// written from state, and what a stored (maybe stale or corrupt) blob may set at boot.
function displaySettingsFields(defaults, raw) {
const out = {};
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return out;
Object.keys(defaults).forEach((k) => {
if (DISPLAY_SETTINGS_SCOPE_FIELDS.includes(k)) return;
const v = raw[k];
if (typeof v !== typeof defaults[k]) return;
if (typeof v === 'number' && !Number.isFinite(v)) return;
if (typeof v === 'number' && k in DISPLAY_SETTINGS_MINIMUMS && v < DISPLAY_SETTINGS_MINIMUMS[k]) return;
out[k] = v;
});
return out;
}
const COLORS = ['#e85447','#4a9eff','#e8c547','#47c88e','#a47fff','#ff7a47','#47d4d4','#ff47b0','#bfff47','#2c3e50','#8b4513','#ff6b6b','#6366f1','#059669','#f59e0b','#0ea5e9','#7c3aed','#e11d48'];
const SCALE_PRESETS = [
{ label: '1/6" = 1\'', pixelsPerUnit: 12, unit: 'ft' },
{ label: '1/16" = 1\'', pixelsPerUnit: 72 / 16, unit: 'ft' },
{ label: '3/32" = 1\'', pixelsPerUnit: 72 * 3 / 32, unit: 'ft' },
{ label: '1/8" = 1\'', pixelsPerUnit: 72 / 8, unit: 'ft' },
{ label: '3/16" = 1\'', pixelsPerUnit: 72 * 3 / 16, unit: 'ft' },
{ label: '1/4" = 1\'', pixelsPerUnit: 72 / 4, unit: 'ft' },
{ label: '3/8" = 1\'', pixelsPerUnit: 72 * 3 / 8, unit: 'ft' },
{ label: '1/2" = 1\'', pixelsPerUnit: 72 / 2, unit: 'ft' },
{ label: '3/4" = 1\'', pixelsPerUnit: 72 * 3 / 4, unit: 'ft' },
{ label: '1" = 1\'', pixelsPerUnit: 72, unit: 'ft' },
{ label: '1 1/2" = 1\'', pixelsPerUnit: 72 * 1.5, unit: 'ft' },
{ label: '3" = 1\'', pixelsPerUnit: 72 * 3, unit: 'ft' },
{ label: '1" = 10\'', pixelsPerUnit: 72 / 10, unit: 'ft' },
{ label: '1" = 20\'', pixelsPerUnit: 72 / 20, unit: 'ft' },
{ label: '1" = 30\'', pixelsPerUnit: 72 / 30, unit: 'ft' },
{ label: '1" = 40\'', pixelsPerUnit: 72 / 40, unit: 'ft' },
{ label: '1" = 50\'', pixelsPerUnit: 72 / 50, unit: 'ft' },
{ label: '1" = 60\'', pixelsPerUnit: 72 / 60, unit: 'ft' },
{ label: '1" = 70\'', pixelsPerUnit: 72 / 70, unit: 'ft' },
{ label: '1" = 80\'', pixelsPerUnit: 72 / 80, unit: 'ft' },
{ label: '1" = 90\'', pixelsPerUnit: 72 / 90, unit: 'ft' },
{ label: '1" = 100\'', pixelsPerUnit: 72 / 100, unit: 'ft' }
];
// --- Autosave / checkout timing & thresholds ---
const AUTO_SAVE_INTERVAL_MS = 5000;
const AUTOSAVE_TIMEOUT_MS = 15000;
const STORAGE_INFO_TIMEOUT_MS = 3000;
const CLIENT_PROBE_TIMEOUT_MS = 5000;
const CLIENT_RECYCLE_COOLDOWN_MS = 30000;
const DIRTY_SNAPSHOT_THRESHOLD_MS = 10 * 60 * 1000;
// The legend's size range (legendSettings.legendScale): the Summary Legend
// size slider's 25%..400% and the corner grip's clamp, one place.
const LEGEND_SCALE_MIN = 0.25;
const LEGEND_SCALE_MAX = 4;
const CHECK_IN_TIMEOUT_MS = 10000;
const LONG_IDLE_PROBE_MS = 5 * 60 * 1000;
const TURN_IN_STALENESS_MS = 5 * 60 * 1000;
const AUTOSAVE_BACKOFF_LEVELS_MS = [5000, 15000, 30000, 60000];
const AUTOSAVE_BANNER_THRESHOLD = 3;
const AUTOSAVE_RECOVERY_THRESHOLD = 5;
const AUTOSAVE_RECOVERY_TIMEOUT_MS = 5000;
const AUTOSAVE_SLOW_MS = 1000;
const AUTOSAVE_SLOW_WINDOW = 20;
const AUTOSAVE_SLOW_DEBOUNCE_MS = 60000;
const AUTOSAVE_SLOW_MIN_SAMPLES = 10;
const GLOBAL_RELOAD_STAMP_KEY = 'clickcount-last-global-reload';
const CHECKOUT_INACTIVITY_MS = 30 * 60 * 1000;
const CHECKOUT_REFRESH_DEBOUNCE_MS = 2 * 60 * 1000;
const CHECKOUT_KEEPALIVE_MS = 10 * 60 * 1000;
const CHECKOUT_NEAR_EXPIRY_MS = 5 * 60 * 1000;
const CHECKOUT_SOFT_GRACE_MS = 60 * 1000;
const AUTO_RECHECKOUT_MAX_PER_PROJECT = 3;
const AUTO_RECHECKOUT_MIN_GAP_MS = 5000;
const AUTO_RECHECKOUT_COOLDOWN_MS = 30 * 60 * 1000;
// After OUR OWN check_in_project succeeds (Turn In, close, load another,
// sign-out), the realtime UPDATE + the post-release permissions refresh both
// see "was editor, now viewer, lock not stale" — the shape of an external
// force. Any refresh inside this window is our own release, not a force
// (field report 2026-09-15: "keeps kicking me to view only" was the Turn In
// button's own tab getting the "an admin turned this in" notice).
const SELF_RELEASE_GRACE_MS = 15 * 1000;
const REFRESH_PERMISSIONS_TIMEOUT_MS = 8000;
const PROJECTS_CHECKOUT_RECONNECT_BACKOFF_MS = [1000, 3000, 10000, 30000];
const PDF_ONESHOT_BACKOFF_MS = 30000;
// Background autosave-tick first-PDF uploads of LARGE files back off much harder
// so they don't burn a long upload every few seconds; explicit Save / Turn In
// (which pass ignoreBackoff) carry the big upload instead.
const PDF_ONESHOT_LARGE_BACKOFF_MS = 5 * 60 * 1000;
// --- Activity / presence ---
const ACTIVITY_HIGH_FREQ_MS = 60000;
const ACTIVITY_PROJECT_SAVE_MS = 5 * 60 * 1000;
// --- Save Status log & checkout messages ---
const SAVE_STATUS_LOG_MS = 300000;
const SAVE_STATUS_LOG_VERBOSE_MS = 3600000;
const CHECKOUT_EXPIRED_SAVE_STATUS_MSG = 'Edit session expired; check out again to continue editing.';
const CHECKOUT_EXPIRED_TOAST_MSG = 'Your edit session expired while idle. Check out again to keep editing.';
// --- Global force reload stamps ---
const PENDING_GLOBAL_RELOAD_STAMP_KEY = 'clickcount-pending-global-reload';
// --- Undo/redo ---
// 50, up from the original 5. The old cap dated from when EVERY snapshot
// deep-copied the whole project; the high-frequency sites (counter/line/note
// placement etc.) now push page-scoped snapshots — O(current page), not
// O(project) — so a deep stack is cheap where it matters. The rare cross-page
// cascades (counter/line-type/group delete) still push full snapshots, but
// nobody performs 50 of those in a row, so the mixed stack stays small in
// practice. Rapid counter placement burns 5 steps in seconds; 50 gives a real
// safety margin.
const UNDO_STACK_SIZE = 50;
// Ghost overlay opacity. Low enough to read instantly as "not part of the
// takeoff", high enough to trace against at working zoom.
const GHOST_ALPHA = 0.35;
// --- IndexedDB store names & caps ---
const PDF_CACHE_DB = 'clickcount-pdf-cache';
const PDF_CACHE_STORE = 'pdfs';
const PDF_CACHE_META_STORE = 'meta';
const VIEW_PDFS_STORE = 'view_pdfs';
const VIEW_PDFS_META_STORE = 'view_pdfs_meta';
const TAKEOFF_BACKUP_STORE = 'takeoff_backup';
const TAKEOFF_BACKUP_META_STORE = 'takeoff_backup_meta';
const CUSTOM_ICONS_STORE = 'custom_icons';
const SAVE_LOGS_SNAPSHOT_STORE = 'save_logs_snapshots';
const PDF_UPLOAD_RESUME_STORE = 'pdf_upload_resume';
// Persistent zoom-rung bitmaps (the cross-session pyramid): compressed webp
// blobs keyed by document hash + page + rotation + rung + effDpr, so daily
// projects reopen with yesterday's zoom ladder already warm.
const ZOOM_RUNGS_STORE = 'zoom_rungs';
const ZOOM_RUNGS_MAX_PER_DOC = 24; // entries per document
const ZOOM_RUNGS_MAX_BYTES = 100663296; // ~96MB across all documents
const PDF_CACHE_MAX_ENTRIES = 10;
const PDF_CACHE_MAX_BYTES = 500 * 1024 * 1024;
const TAKEOFF_BACKUP_MAX_ENTRIES = 5;
const TAKEOFF_BACKUP_MAX_BYTES = 200 * 1024 * 1024;
// The boot key-aside record: a promptable 'local' takeoff backup is moved to
// this key before anything can make the backup writer's guard pass, so no
// post-boot write can clobber it while the "Project from Last Session"
// Keep/Discard prompt is unresolved. Same takeoff_backup store, just another
// record key — no IDB schema/version change. Consumed on Keep/Discard (or by
// the same-PDF re-upload re-apply in features/pdf-intake.js).
const TAKEOFF_BACKUP_HELD_ID = 'local-held';
const SAVE_LOGS_SNAPSHOT_MAX_ENTRIES = 10;
const CUSTOM_ICONS_KEY = 'user';
// --- PDF / misc ---
const PDF_MAX_SIZE_BYTES = 50 * 1024 * 1024; // 50MB (Supabase storage limit)
// PDF upload timeout budget. A fixed 60s timeout is far too short for a
// multi-megabyte PDF on a slow uplink (it falsely fails Turn In), so the upload
// timeout is sized from the byte count at an assumed conservative throughput,
// floored at BASE and capped at MAX. See pdfUploadTimeoutMs in save-utils.js.
const PDF_UPLOAD_TIMEOUT_BASE_MS = 60000; // floor for any upload
const PDF_UPLOAD_ASSUMED_BPS = 100 * 1024; // ~100 KB/s conservative uplink (bytes/sec)
const PDF_UPLOAD_TIMEOUT_SLACK_MS = 15000; // fixed slack added to the size-based budget
const PDF_UPLOAD_TIMEOUT_MAX_MS = 8 * 60 * 1000; // cap (covers the 50 MB limit at the assumed rate)
const PDF_UPLOAD_VERIFY_ATTEMPTS = 3; // storage.info() polls after an upload timeout
const PDF_UPLOAD_VERIFY_GAP_MS = 4000; // spacing between verify polls
const PDF_RESUMABLE_THRESHOLD_BYTES = 8 * 1024 * 1024; // use resumable/TUS upload above this size
const LOAD_TEST_PDF_URL = 'https://mozilla.github.io/pdf.js/web/compressed.tracemonkey-pldi-09.pdf';
const USER_ACTIVITY_TZ = 'America/Chicago';
// Node test harness only: in a classic browser <script> `module` is undefined,
// so this is a no-op there and the declarations above stay plain globals.
if (typeof module !== 'undefined' && module.exports) {
module.exports = {
TOOL, SCALE_MODES, PLUMBING_DEFAULTS, LINE_DEFAULTS, COLORS, SCALE_PRESETS,
TRADES, TRADE_LABELS, TRADE_QUICK_PROFILES, ELECTRICAL_DEFAULTS, HVAC_DEFAULTS, DEFAULT_MAKE_UP_FT, CODE_EDITIONS, CODE_DEFAULTS, normalizeProjectCodes,
COUNTER_SETTINGS_DEFAULTS, LINE_TYPE_SETTINGS_DEFAULTS, DISPLAY_SETTINGS_SCOPE_FIELDS, DISPLAY_SETTINGS_MINIMUMS, displaySettingsFields,
AUTO_SAVE_INTERVAL_MS, AUTOSAVE_TIMEOUT_MS, STORAGE_INFO_TIMEOUT_MS, CLIENT_PROBE_TIMEOUT_MS,
CLIENT_RECYCLE_COOLDOWN_MS, DIRTY_SNAPSHOT_THRESHOLD_MS, LEGEND_SCALE_MIN, LEGEND_SCALE_MAX, CHECK_IN_TIMEOUT_MS, LONG_IDLE_PROBE_MS,
TURN_IN_STALENESS_MS, AUTOSAVE_BACKOFF_LEVELS_MS, AUTOSAVE_BANNER_THRESHOLD, AUTOSAVE_RECOVERY_THRESHOLD,
AUTOSAVE_RECOVERY_TIMEOUT_MS, AUTOSAVE_SLOW_MS, AUTOSAVE_SLOW_WINDOW, AUTOSAVE_SLOW_DEBOUNCE_MS,
AUTOSAVE_SLOW_MIN_SAMPLES, GLOBAL_RELOAD_STAMP_KEY, CHECKOUT_INACTIVITY_MS, CHECKOUT_REFRESH_DEBOUNCE_MS,
CHECKOUT_KEEPALIVE_MS, CHECKOUT_NEAR_EXPIRY_MS, CHECKOUT_SOFT_GRACE_MS, AUTO_RECHECKOUT_MAX_PER_PROJECT, SELF_RELEASE_GRACE_MS,
AUTO_RECHECKOUT_MIN_GAP_MS, AUTO_RECHECKOUT_COOLDOWN_MS, REFRESH_PERMISSIONS_TIMEOUT_MS,
PROJECTS_CHECKOUT_RECONNECT_BACKOFF_MS, PDF_ONESHOT_BACKOFF_MS, PDF_ONESHOT_LARGE_BACKOFF_MS,
ACTIVITY_HIGH_FREQ_MS, ACTIVITY_PROJECT_SAVE_MS,
SAVE_STATUS_LOG_MS, SAVE_STATUS_LOG_VERBOSE_MS, CHECKOUT_EXPIRED_SAVE_STATUS_MSG, CHECKOUT_EXPIRED_TOAST_MSG,
PENDING_GLOBAL_RELOAD_STAMP_KEY, UNDO_STACK_SIZE, GHOST_ALPHA, PDF_CACHE_DB, PDF_CACHE_STORE, PDF_CACHE_META_STORE, VIEW_PDFS_STORE, VIEW_PDFS_META_STORE,
TAKEOFF_BACKUP_STORE, TAKEOFF_BACKUP_META_STORE, CUSTOM_ICONS_STORE, SAVE_LOGS_SNAPSHOT_STORE,
PDF_UPLOAD_RESUME_STORE, ZOOM_RUNGS_STORE, ZOOM_RUNGS_MAX_PER_DOC, ZOOM_RUNGS_MAX_BYTES,
PDF_CACHE_MAX_ENTRIES, PDF_CACHE_MAX_BYTES, TAKEOFF_BACKUP_MAX_ENTRIES, TAKEOFF_BACKUP_MAX_BYTES,
TAKEOFF_BACKUP_HELD_ID,
SAVE_LOGS_SNAPSHOT_MAX_ENTRIES, CUSTOM_ICONS_KEY,
PDF_MAX_SIZE_BYTES, LOAD_TEST_PDF_URL, USER_ACTIVITY_TZ,
PDF_UPLOAD_TIMEOUT_BASE_MS, PDF_UPLOAD_ASSUMED_BPS, PDF_UPLOAD_TIMEOUT_SLACK_MS,
PDF_UPLOAD_TIMEOUT_MAX_MS, PDF_UPLOAD_VERIFY_ATTEMPTS, PDF_UPLOAD_VERIFY_GAP_MS,
PDF_RESUMABLE_THRESHOLD_BYTES
};
}