(function(){(function(){(function(){(function(){(function(){(function(){(function(){(function(){console.log("[FillyDash] storage.js loading...");var o=window.CoverLetterGen=window.CoverLetterGen||{};console.log("[FillyDash] CLG namespace created:",!!o);var c="http://localhost:3000";o.storage={keys:{apiKey:"groqApiKey",groqApiTokens:"groqApiTokens",profile:"userProfile",lastCoverLetter:"lastCoverLetter",lastJobDescription:"lastJobDescription",customQuestionsAnswers:"customQuestionsAnswers",apiBaseUrl:"fillydashApiBaseUrl",extensionToken:"fillydashExtensionToken"},getDefaultApiBaseUrl:function(){return c.replace(/\/$/,"")},get:function(e,t){typeof e=="string"&&(e=[e]),chrome.storage.local.get(e,t||function(){})},set:function(e,t){chrome.storage.local.set(e,t||function(){})},getLastCoverLetter:function(e){this.get(this.keys.lastCoverLetter,function(t){e(t[o.storage.keys.lastCoverLetter]||"")})},getLastJobDescription:function(e){this.get(this.keys.lastJobDescription,function(t){e(t[o.storage.keys.lastJobDescription]||"")})},getApiKeyAndProfile:function(e){this.get([this.keys.apiKey,this.keys.groqApiTokens,this.keys.profile],function(t){var s=t[o.storage.keys.groqApiTokens],n=t[o.storage.keys.apiKey]||"";if(Array.isArray(s)&&s.length>0){var i=s[0];i&&(i.apiKey||"").trim()&&(n=(i.apiKey||"").trim())}e({apiKey:(n||"").trim(),userProfile:t[o.storage.keys.profile]||{}})})},setLastCoverLetter:function(e,t){var s=this.keys.lastCoverLetter;this.set({[s]:e},t)},setLastJobDescription:function(e,t){var s=this.keys.lastJobDescription;this.set({[s]:e},t)},setLastCoverLetterAndJobDescription:function(e,t,s){this.set({[this.keys.lastCoverLetter]:e,[this.keys.lastJobDescription]:t},s)},getCustomQuestionsAnswers:function(e){this.get(this.keys.customQuestionsAnswers,function(t){var s=t[o.storage.keys.customQuestionsAnswers];e(Array.isArray(s)?s:[])})},setCustomQuestionsAnswers:function(e,t){this.set({[this.keys.customQuestionsAnswers]:e},t||function(){})},getApiBaseUrl:function(e){this.get(this.keys.apiBaseUrl,function(t){var s=(t[o.storage.keys.apiBaseUrl]||"").trim();s||(s=o.storage.getDefaultApiBaseUrl()),e(s?s.replace(/\/$/,""):"")})},setApiBaseUrl:function(e,t){this.set({[o.storage.keys.apiBaseUrl]:(e||"").trim().replace(/\/$/,"")},t||function(){})},getExtensionToken:function(e){this.get(this.keys.extensionToken,function(t){e((t[o.storage.keys.extensionToken]||"").trim())})},setExtensionToken:function(e,t){this.set({[o.storage.keys.extensionToken]:(e||"").trim()},t||function(){})},_normalizeQA:function(e){return typeof e!="string"?"":e.trim().toLowerCase().replace(/\*/g,"").replace(/\s+/g," ").trim()},addOrUpdateQA:function(e,t,s){var n=this,i=String(e||"").trim(),u=String(t||"").trim();if(!i||!u){s&&s(!1);return}this.getCustomQuestionsAnswers(function(r){for(var l=n._normalizeQA(i),f=!1,a=0;a<r.length;a++)if(n._normalizeQA(r[a].question)===l){r[a].answer=u,r[a].question=i,f=!0;break}f||r.push({question:i,answer:u}),n.setCustomQuestionsAnswers(r,function(){s&&s(!0)})})}}})();
//# sourceMappingURL=storage.js-o-L7oEgY.js.map
})()
})()
})()
})()
})()
})()
})()
