{"version":3,"file":"LocalStorage.DSP4xHM1.mjs","names":[],"sources":["https:/framerusercontent.com/modules/Q70GysxGEEGNZ5kgxFcP/CYjjkbuAdjCJtQ89rYU9/LocalStorage.js"],"sourcesContent":["/**\n * Shared Storage Utilities\n */// ===== Storage Keys =====\nexport const STORAGE_KEYS={CALCULATOR:\"ferox-calculator\",LEAD:\"ferox-lead\",SESSION:\"ferox-session\",ESTIMATE:\"ferox-estimate\",// Analysis journey keys\nTRUCK_SELECTION:\"ferox-truck-selection\",ANALYSIS_RESULTS:\"ferox-analysis-results\",PILOT_DATES:\"ferox-pilot-dates\",VALIDATED_TRUCKS:\"ferox-validated-trucks\",// Manual upload data\nMANUAL_UPLOAD_DATA:\"ferox-manual-upload-data\"};// ===== Core Functions =====\nexport function load(key,defaultValue){if(typeof window===\"undefined\")return defaultValue;try{const stored=localStorage.getItem(key);if(stored){return{...defaultValue,...JSON.parse(stored)};}}catch(e){console.error(`Storage [${key}]: Load failed`,e);}return defaultValue;}export function save(key,data){try{localStorage.setItem(key,JSON.stringify(data));}catch(e){console.error(`Storage [${key}]: Save failed`,e);}}export function read(key){if(typeof window===\"undefined\")return null;try{const stored=localStorage.getItem(key);return stored?JSON.parse(stored):null;}catch(e){console.error(`Storage [${key}]: Read failed`,e);return null;}}export function clear(key){if(typeof window===\"undefined\")return;localStorage.removeItem(key);}/**\n * Try to save data, but gracefully handle quota exceeded.\n * Returns true if saved successfully, false if quota exceeded.\n */export function trySave(key,data){try{localStorage.setItem(key,JSON.stringify(data));return true;}catch(e){if(e instanceof DOMException&&e.name===\"QuotaExceededError\"){console.warn(`Storage [${key}]: Quota exceeded, data not saved`);return false;}console.error(`Storage [${key}]: Save failed`,e);return false;}}// ===== Session Functions =====\n/**\n * Clear the authentication session.\n * Use when logging out or when session expires.\n */export function clearSession(){console.log(\"[Storage] Clearing session\");clear(STORAGE_KEYS.SESSION);}// ===== Journey Clear Functions =====\n// Call these when starting a new journey to ensure fresh state.\n// Lead info (ferox-lead) is intentionally NOT cleared - valuable for returning users.\n/**\n * Clear calculator journey data.\n * Call when user lands on calculator-signup page.\n */export function clearCalculatorJourney(){console.log(\"[Storage] Clearing calculator journey\");clear(STORAGE_KEYS.CALCULATOR);}/**\n * Clear estimate journey data.\n * Call when user lands on signup-estimate pages.\n */export function clearEstimateJourney(){console.log(\"[Storage] Clearing estimate journey\");clearSession();clear(STORAGE_KEYS.ESTIMATE);}/**\n * Clear pilot analysis journey data.\n * Call when user lands on signup-pilot pages.\n */export function clearPilotJourney(){console.log(\"[Storage] Clearing pilot journey\");clearSession();clear(STORAGE_KEYS.TRUCK_SELECTION);clear(STORAGE_KEYS.ANALYSIS_RESULTS);clear(STORAGE_KEYS.PILOT_DATES);clear(STORAGE_KEYS.VALIDATED_TRUCKS);clear(STORAGE_KEYS.MANUAL_UPLOAD_DATA);}/**\n * Clear all stored data except lead info.\n * Use for \"start over\" or debugging.\n */export function clearAllJourneys(){console.log(\"[Storage] Clearing all journeys\");clearCalculatorJourney();clearEstimateJourney();clearPilotJourney();}/**\n * Clear everything including lead info.\n * Use for complete reset / logout.\n */export function clearEverything(){console.log(\"[Storage] Clearing everything\");clearAllJourneys();clear(STORAGE_KEYS.LEAD);}/**\n * Save manually uploaded telematics data to local storage.\n * \n * Args:\n *     data: Parsed and validated upload data with time series per truck\n * \n * Returns:\n *     true if saved successfully, false if quota exceeded\n */export function saveUploadedData(data){console.log(`[Storage] Saving manual upload data for ${Object.keys(data.truckData).length} trucks`);return trySave(STORAGE_KEYS.MANUAL_UPLOAD_DATA,data);}/**\n * Load manually uploaded telematics data from local storage.\n * \n * Returns:\n *     Saved upload data or null if not found\n */export function loadUploadedData(){const data=read(STORAGE_KEYS.MANUAL_UPLOAD_DATA);if(data){console.log(`[Storage] Loaded manual upload data for ${Object.keys(data.truckData).length} trucks`);}return data;}/**\n * Clear manually uploaded data.\n */export function clearUploadedData(){console.log(\"[Storage] Clearing manual upload data\");clear(STORAGE_KEYS.MANUAL_UPLOAD_DATA);}/**\n * MCP COMPATIBILITY FOOTER. DO NOT MODIFY.\n * FEROX SYSTEMS 2025\n * @framerDisableUnlink\n */export function withMcp(Component){return Component;}\nexport const __FramerMetadata__ = {\"exports\":{\"clearEverything\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"clearAllJourneys\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"clearEstimateJourney\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"clearSession\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"load\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"STORAGE_KEYS\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"read\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"saveUploadedData\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withMcp\":{\"type\":\"reactHoc\",\"name\":\"withMcp\",\"annotations\":{\"framerDisableUnlink\":\"\",\"framerContractVersion\":\"1\"}},\"UploadedTimeSeriesData\":{\"type\":\"tsType\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"loadUploadedData\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"clearCalculatorJourney\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"trySave\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"clear\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"ManualUploadData\":{\"type\":\"tsType\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"clearPilotJourney\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"save\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"clearUploadedData\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sour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