const i="coral-usage-statistics",o=()=>({totalPromptsExecuted:0,totalJobsCompleted:0,totalQueuedPrompts:0,successfulExecutions:0,failedExecutions:0,totalExecutionTime:0,averageExecutionTime:0,firstUsed:Date.now(),lastUsed:Date.now(),estimatedTokensUsed:0,estimatedCost:0,totalCharactersProcessed:0,promptsSaved:0,sequencesSaved:0,templatesSaved:0,wordListsSaved:0,platformUsage:{chatgpt:0,claude:0,gemini:0,perplexity:0,midjourney:0,other:0},dailyActivity:[],totalSessions:0,averageSessionDuration:0,currentSession:null,featureUsage:{compose:0,multiplier:0,sequences:0,history:0,library:0,magicPlanner:0,crossTab:0},productivityMetrics:{mostProductiveHour:0,mostProductiveDay:"Monday",longestStreak:0},currentStreak:0});async function a(){try{return typeof chrome<"u"&&chrome.storage&&(await chrome.storage.local.get(i))[i]||o()}catch(t){return console.error("[UsageStats] Error fetching stats:",t),o()}}async function r(t){try{typeof chrome<"u"&&chrome.storage&&await chrome.storage.local.set({[i]:t})}catch(e){console.error("[UsageStats] Error saving stats:",e)}}async function u(t){const e=await a();switch(e.lastUsed=Date.now(),t){case"prompt":e.promptsSaved++;break;case"sequence":e.sequencesSaved++;break;case"template":e.templatesSaved++;break;case"wordlist":e.wordListsSaved++;break}await r(e)}async function l(){const t=await a();t.currentSession&&await c(),t.currentSession={startTime:Date.now(),promptsExecuted:0},t.totalSessions++,await r(t)}async function c(){const t=await a();if(t.currentSession){const e=Date.now()-t.currentSession.startTime,s=t.averageSessionDuration*(t.totalSessions-1)+e;t.averageSessionDuration=s/t.totalSessions,t.currentSession=null,await r(t)}}async function d(){const t=o();await r(t)}async function S(){const t=await a();return JSON.stringify(t,null,2)}async function m(){const t=await a(),e=Math.max(1,Math.floor((Date.now()-t.firstUsed)/(1e3*60*60*24)));return{totalPrompts:t.totalPromptsExecuted,totalJobs:t.totalJobsCompleted,successRate:t.totalPromptsExecuted>0?Math.round(t.successfulExecutions/t.totalPromptsExecuted*100):0,totalSaved:t.promptsSaved+t.sequencesSaved+t.templatesSaved+t.wordListsSaved,libraryBreakdown:{prompts:t.promptsSaved,sequences:t.sequencesSaved,templates:t.templatesSaved,wordLists:t.wordListsSaved},avgExecutionTime:Math.round(t.averageExecutionTime/1e3),totalTokens:t.estimatedTokensUsed,estimatedCost:(t.estimatedCost/100).toFixed(2),daysSinceFirstUse:e,dailyAverage:Math.round(t.totalPromptsExecuted/e),currentStreak:t.currentStreak,longestStreak:t.productivityMetrics.longestStreak,platforms:t.platformUsage,recentActivity:t.dailyActivity.slice(-7),totalSessions:t.totalSessions,avgSessionDuration:Math.round(t.averageSessionDuration/(1e3*60)),topFeatures:Object.entries(t.featureUsage).sort(([,s],[,n])=>n-s).slice(0,3).map(([s,n])=>({name:s,count:n}))}}export{a,S as e,m as g,d as r,l as s,u as t};
