@nice2dev/templates 1.0.11 โ†’ 1.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var se=Object.defineProperty;var ne=(o,e,s)=>e in o?se(o,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):o[e]=s;var j=(o,e,s)=>ne(o,typeof e!="symbol"?e+"":e,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),f=require("react"),re=[{id:"apple",name:"Apple",servingSize:1,servingUnit:"medium",calories:95,protein:.5,carbs:25,fat:.3,fiber:4.4},{id:"banana",name:"Banana",servingSize:1,servingUnit:"medium",calories:105,protein:1.3,carbs:27,fat:.4,fiber:3.1},{id:"chicken-breast",name:"Chicken Breast",servingSize:100,servingUnit:"g",calories:165,protein:31,carbs:0,fat:3.6},{id:"brown-rice",name:"Brown Rice",servingSize:1,servingUnit:"cup",calories:216,protein:5,carbs:45,fat:1.8,fiber:3.5},{id:"egg",name:"Egg",servingSize:1,servingUnit:"large",calories:78,protein:6,carbs:.6,fat:5},{id:"salmon",name:"Salmon",servingSize:100,servingUnit:"g",calories:208,protein:20,carbs:0,fat:13},{id:"broccoli",name:"Broccoli",servingSize:1,servingUnit:"cup",calories:55,protein:3.7,carbs:11,fat:.6,fiber:5.1},{id:"oatmeal",name:"Oatmeal",servingSize:1,servingUnit:"cup",calories:158,protein:6,carbs:27,fat:3.2,fiber:4},{id:"greek-yogurt",name:"Greek Yogurt",servingSize:1,servingUnit:"cup",calories:100,protein:17,carbs:6,fat:.7},{id:"almonds",name:"Almonds",servingSize:1,servingUnit:"oz",calories:164,protein:6,carbs:6,fat:14,fiber:3.5}];class L{constructor(){j(this,"workouts",new Map);j(this,"meals",new Map);j(this,"sleep",new Map);j(this,"medicalRecords",new Map);j(this,"medications",new Map);j(this,"medicationLogs",[]);j(this,"vitals",[]);j(this,"goals",[]);j(this,"foodDatabase",[...re])}addWorkout(e){const s=this.generateId(),n={...e,id:s};return this.workouts.set(s,n),n}updateWorkout(e,s){const n=this.workouts.get(e);n&&this.workouts.set(e,{...n,...s,id:e})}deleteWorkout(e){this.workouts.delete(e)}getAllWorkouts(){return Array.from(this.workouts.values()).sort((e,s)=>new Date(s.date).getTime()-new Date(e.date).getTime())}getWorkoutsForPeriod(e,s){return this.getAllWorkouts().filter(n=>{const r=new Date(n.date);return r>=e&&r<=s})}getWorkoutStats(e=7){const s=new Date(Date.now()-e*864e5),n=this.getWorkoutsForPeriod(s,new Date),r=new Map;for(const i of n)r.set(i.type,(r.get(i.type)||0)+1);return{totalWorkouts:n.length,totalDuration:n.reduce((i,a)=>i+a.duration,0),totalCalories:n.reduce((i,a)=>i+a.caloriesBurned,0),avgDuration:n.length>0?n.reduce((i,a)=>i+a.duration,0)/n.length:0,byType:Array.from(r.entries()).map(([i,a])=>({type:i,count:a}))}}addMeal(e){const s=this.generateId(),n=this.calculateMealTotals(e.foods),r={...e,id:s,...n};return this.meals.set(s,r),r}calculateMealTotals(e){return e.reduce((s,{item:n,servings:r})=>({totalCalories:s.totalCalories+n.calories*r,totalProtein:s.totalProtein+n.protein*r,totalCarbs:s.totalCarbs+n.carbs*r,totalFat:s.totalFat+n.fat*r}),{totalCalories:0,totalProtein:0,totalCarbs:0,totalFat:0})}deleteMeal(e){this.meals.delete(e)}getAllMeals(){return Array.from(this.meals.values()).sort((e,s)=>new Date(s.date).getTime()-new Date(e.date).getTime())}getMealsForDate(e){const s=new Date(e);s.setHours(0,0,0,0);const n=new Date(s.getTime()+864e5);return this.getAllMeals().filter(r=>{const i=new Date(r.date);return i>=s&&i<n})}getDailyNutrition(e){const s=this.getMealsForDate(e);return{calories:s.reduce((n,r)=>n+r.totalCalories,0),protein:s.reduce((n,r)=>n+r.totalProtein,0),carbs:s.reduce((n,r)=>n+r.totalCarbs,0),fat:s.reduce((n,r)=>n+r.totalFat,0),meals:s.length}}searchFoods(e){const s=e.toLowerCase();return this.foodDatabase.filter(n=>n.name.toLowerCase().includes(s))}addCustomFood(e){const s=this.generateId(),n={...e,id:s};return this.foodDatabase.push(n),n}addSleepEntry(e){const s=this.generateId(),n=(new Date(e.wakeTime).getTime()-new Date(e.bedtime).getTime())/36e5,r={...e,id:s,duration:n};return this.sleep.set(s,r),r}updateSleepEntry(e,s){const n=this.sleep.get(e);if(n){let r=n.duration;if(s.bedtime||s.wakeTime){const i=s.bedtime||n.bedtime,a=s.wakeTime||n.wakeTime;r=(new Date(a).getTime()-new Date(i).getTime())/36e5}this.sleep.set(e,{...n,...s,id:e,duration:r})}}deleteSleepEntry(e){this.sleep.delete(e)}getAllSleepEntries(){return Array.from(this.sleep.values()).sort((e,s)=>new Date(s.date).getTime()-new Date(e.date).getTime())}getSleepStats(e=7){const s=new Date(Date.now()-e*864e5),n=this.getAllSleepEntries().filter(a=>new Date(a.date)>=s),r={poor:1,fair:2,good:3,excellent:4},i=new Map;for(const a of n)i.set(a.quality,(i.get(a.quality)||0)+1);return{avgDuration:n.length>0?n.reduce((a,l)=>a+l.duration,0)/n.length:0,avgQuality:n.length>0?n.reduce((a,l)=>a+r[l.quality],0)/n.length:0,totalEntries:n.length,qualityDistribution:Array.from(i.entries()).map(([a,l])=>({quality:a,count:l}))}}addMedicalRecord(e){const s=this.generateId(),n={...e,id:s};return this.medicalRecords.set(s,n),n}updateMedicalRecord(e,s){const n=this.medicalRecords.get(e);n&&this.medicalRecords.set(e,{...n,...s,id:e})}deleteMedicalRecord(e){this.medicalRecords.delete(e)}getAllMedicalRecords(){return Array.from(this.medicalRecords.values()).sort((e,s)=>new Date(s.date).getTime()-new Date(e.date).getTime())}getMedicalRecordsByType(e){return this.getAllMedicalRecords().filter(s=>s.type===e)}getUpcomingFollowUps(e=30){const s=new Date,n=new Date(s.getTime()+e*864e5);return this.getAllMedicalRecords().filter(r=>r.followUp&&new Date(r.followUp)>=s&&new Date(r.followUp)<=n)}addMedication(e){const s=this.generateId(),n={...e,id:s};return this.medications.set(s,n),n}updateMedication(e,s){const n=this.medications.get(e);n&&this.medications.set(e,{...n,...s,id:e})}deleteMedication(e){this.medications.delete(e),this.medicationLogs=this.medicationLogs.filter(s=>s.medicationId!==e)}getAllMedications(){return Array.from(this.medications.values())}getActiveMedications(){return this.getAllMedications().filter(e=>e.isActive)}logMedication(e,s,n,r){const i={id:this.generateId(),medicationId:e,scheduledTime:s,takenTime:n?new Date:void 0,skipped:!n,notes:r};this.medicationLogs.push(i)}getMedicationLogsForDate(e){const s=new Date(e);s.setHours(0,0,0,0);const n=new Date(s.getTime()+864e5);return this.medicationLogs.filter(r=>{const i=new Date(r.scheduledTime);return i>=s&&i<n})}getTodayMedicationSchedule(){const e=new Date,s=this.getMedicationLogsForDate(e),n=[];for(const r of this.getActiveMedications())for(const i of r.times){const a=s.find(l=>l.medicationId===r.id&&new Date(l.scheduledTime).toTimeString().startsWith(i));n.push({medication:r,time:i,taken:(a==null?void 0:a.takenTime)!==void 0})}return n.sort((r,i)=>r.time.localeCompare(i.time))}recordVitals(e){this.vitals.push(e),this.vitals.sort((s,n)=>new Date(n.date).getTime()-new Date(s.date).getTime())}getVitalsHistory(){return[...this.vitals]}getLatestVitals(){return this.vitals[0]}getWeightHistory(e=30){const s=new Date(Date.now()-e*864e5);return this.vitals.filter(n=>n.weight!==void 0&&new Date(n.date)>=s).map(n=>({date:n.date,weight:n.weight}))}setGoal(e){const s=this.goals.findIndex(n=>n.id===e.id);s>=0?this.goals[s]=e:this.goals.push(e)}getGoals(){return[...this.goals]}updateGoalProgress(e,s){const n=this.goals.find(r=>r.id===e);n&&(n.current=s)}generateId(){return Date.now().toString(36)+Math.random().toString(36).substring(2,8)}clear(){this.workouts.clear(),this.meals.clear(),this.sleep.clear(),this.medicalRecords.clear(),this.medications.clear(),this.medicationLogs=[],this.vitals=[],this.goals=[]}}function ie(){return new L}const U=f.createContext(null);function oe(){const o=f.useContext(U);if(!o)throw new Error("useHealth must be used within HealthProvider");return o}const g={container:{display:"flex",height:"100%",fontFamily:"'Inter', sans-serif",backgroundColor:"#f5f7fa"},sidebar:{width:"200px",backgroundColor:"#fff",borderRight:"1px solid #e0e0e0",padding:"20px 0"},main:{flex:1,padding:"20px",overflow:"auto"},navItem:{padding:"12px 24px",cursor:"pointer",display:"flex",alignItems:"center",gap:"12px",borderLeft:"3px solid transparent"},grid:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(280px, 1fr))",gap:"20px",marginBottom:"20px"},card:{backgroundColor:"#fff",borderRadius:"12px",padding:"20px",boxShadow:"0 2px 8px rgba(0,0,0,0.08)"},cardTitle:{fontSize:"16px",fontWeight:600,marginBottom:"16px",color:"#1a1a2e"},statValue:{fontSize:"32px",fontWeight:700,color:"#1976d2"},statLabel:{fontSize:"12px",color:"#666",textTransform:"uppercase",letterSpacing:"1px"},progressBar:{height:"8px",backgroundColor:"#e0e0e0",borderRadius:"4px",overflow:"hidden"},listItem:{display:"flex",alignItems:"center",gap:"12px",padding:"12px 0",borderBottom:"1px solid #f0f0f0"}};function ae({service:o,className:e,style:s}){const[,n]=f.useState(0),[r,i]=f.useState("overview"),a=f.useCallback(()=>n(u=>u+1),[]),l={service:o,refresh:a},d=[{id:"overview",icon:"๐Ÿ“Š",label:"Overview"},{id:"workouts",icon:"๐Ÿ‹๏ธ",label:"Workouts"},{id:"nutrition",icon:"๐Ÿฅ—",label:"Nutrition"},{id:"sleep",icon:"๐Ÿ˜ด",label:"Sleep"},{id:"medical",icon:"๐Ÿฅ",label:"Medical"},{id:"medications",icon:"๐Ÿ’Š",label:"Medications"}];return t.jsx(U.Provider,{value:l,children:t.jsxs("div",{className:e,style:{...g.container,...s},children:[t.jsx("div",{style:g.sidebar,children:d.map(u=>t.jsxs("div",{onClick:()=>i(u.id),style:{...g.navItem,backgroundColor:r===u.id?"#e3f2fd":"transparent",borderLeftColor:r===u.id?"#1976d2":"transparent",fontWeight:r===u.id?600:400},children:[t.jsx("span",{children:u.icon}),t.jsx("span",{children:u.label})]},u.id))}),t.jsxs("div",{style:g.main,children:[r==="overview"&&t.jsx(le,{service:o}),r==="workouts"&&t.jsx(de,{service:o,refresh:a}),r==="nutrition"&&t.jsx(ce,{service:o}),r==="sleep"&&t.jsx(ue,{service:o}),r==="medical"&&t.jsx(ge,{service:o}),r==="medications"&&t.jsx(he,{service:o,refresh:a})]})]})})}function le({service:o}){const e=o.getWorkoutStats(7),s=o.getSleepStats(7),n=o.getDailyNutrition(new Date),r=o.getLatestVitals(),i=o.getTodayMedicationSchedule();return t.jsxs("div",{children:[t.jsx("h2",{style:{marginBottom:"20px"},children:"Health Overview"}),t.jsxs("div",{style:g.grid,children:[t.jsxs("div",{style:g.card,children:[t.jsx("div",{style:g.cardTitle,children:"This Week's Workouts"}),t.jsx("div",{style:g.statValue,children:e.totalWorkouts}),t.jsx("div",{style:g.statLabel,children:"Workouts"}),t.jsxs("div",{style:{marginTop:"12px",display:"flex",gap:"20px"},children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:"18px",fontWeight:600},children:e.totalDuration}),t.jsx("div",{style:{fontSize:"12px",color:"#666"},children:"Minutes"})]}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:"18px",fontWeight:600},children:e.totalCalories}),t.jsx("div",{style:{fontSize:"12px",color:"#666"},children:"Calories"})]})]})]}),t.jsxs("div",{style:g.card,children:[t.jsx("div",{style:g.cardTitle,children:"Sleep (7-Day Average)"}),t.jsxs("div",{style:g.statValue,children:[s.avgDuration.toFixed(1),"h"]}),t.jsx("div",{style:g.statLabel,children:"Per Night"}),t.jsx("div",{style:{marginTop:"12px"},children:t.jsxs("div",{style:{fontSize:"14px",color:"#666"},children:["Quality: ",s.avgQuality.toFixed(1),"/4"]})})]}),t.jsxs("div",{style:g.card,children:[t.jsx("div",{style:g.cardTitle,children:"Today's Nutrition"}),t.jsx("div",{style:g.statValue,children:n.calories}),t.jsx("div",{style:g.statLabel,children:"Calories"}),t.jsxs("div",{style:{marginTop:"12px",display:"flex",gap:"16px",fontSize:"14px"},children:[t.jsxs("div",{children:["P: ",n.protein,"g"]}),t.jsxs("div",{children:["C: ",n.carbs,"g"]}),t.jsxs("div",{children:["F: ",n.fat,"g"]})]})]}),t.jsxs("div",{style:g.card,children:[t.jsx("div",{style:g.cardTitle,children:"Latest Vitals"}),r?t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"},children:[r.weight&&t.jsxs("div",{children:[t.jsxs("div",{style:{fontSize:"18px",fontWeight:600},children:[r.weight," ",r.weightUnit||"kg"]}),t.jsx("div",{style:{fontSize:"12px",color:"#666"},children:"Weight"})]}),r.bloodPressureSystolic&&t.jsxs("div",{children:[t.jsxs("div",{style:{fontSize:"18px",fontWeight:600},children:[r.bloodPressureSystolic,"/",r.bloodPressureDiastolic]}),t.jsx("div",{style:{fontSize:"12px",color:"#666"},children:"Blood Pressure"})]}),r.heartRate&&t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:"18px",fontWeight:600},children:r.heartRate}),t.jsx("div",{style:{fontSize:"12px",color:"#666"},children:"Heart Rate"})]})]}):t.jsx("div",{style:{color:"#999"},children:"No vitals recorded"})]})]}),t.jsxs("div",{style:g.card,children:[t.jsx("div",{style:g.cardTitle,children:"Today's Medications"}),i.length===0?t.jsx("div",{style:{color:"#999",textAlign:"center",padding:"20px"},children:"No medications scheduled"}):i.map((a,l)=>t.jsxs("div",{style:g.listItem,children:[t.jsx("span",{style:{width:"60px",fontWeight:500},children:a.time}),t.jsxs("span",{style:{flex:1},children:[a.medication.name," (",a.medication.dosage,")"]}),t.jsx("span",{style:{padding:"4px 12px",borderRadius:"12px",fontSize:"12px",backgroundColor:a.taken?"#e8f5e9":"#fff3e0",color:a.taken?"#2e7d32":"#ef6c00"},children:a.taken?"Taken":"Pending"})]},l))]})]})}function de({service:o,refresh:e}){const s=o.getAllWorkouts(),n=o.getWorkoutStats(30);return t.jsxs("div",{children:[t.jsx("h2",{style:{marginBottom:"20px"},children:"Workouts"}),t.jsxs("div",{style:g.grid,children:[t.jsxs("div",{style:g.card,children:[t.jsx("div",{style:g.statValue,children:n.totalWorkouts}),t.jsx("div",{style:g.statLabel,children:"Workouts (30 days)"})]}),t.jsxs("div",{style:g.card,children:[t.jsx("div",{style:g.statValue,children:n.totalDuration}),t.jsx("div",{style:g.statLabel,children:"Total Minutes"})]}),t.jsxs("div",{style:g.card,children:[t.jsx("div",{style:g.statValue,children:n.totalCalories}),t.jsx("div",{style:g.statLabel,children:"Calories Burned"})]})]}),t.jsxs("div",{style:g.card,children:[t.jsx("div",{style:g.cardTitle,children:"Recent Workouts"}),s.length===0?t.jsx("div",{style:{color:"#999",textAlign:"center",padding:"30px"},children:"No workouts logged yet"}):s.slice(0,10).map(r=>t.jsxs("div",{style:g.listItem,children:[t.jsxs("div",{style:{flex:1},children:[t.jsx("div",{style:{fontWeight:500},children:r.name}),t.jsxs("div",{style:{fontSize:"12px",color:"#666"},children:[new Date(r.date).toLocaleDateString()," โ€ข ",r.duration," min โ€ข"," ",r.caloriesBurned," cal"]})]}),t.jsx("span",{style:{padding:"4px 8px",borderRadius:"4px",fontSize:"12px",backgroundColor:"#e3f2fd",color:"#1565c0",textTransform:"capitalize"},children:r.type})]},r.id))]})]})}function ce({service:o}){const e=o.getDailyNutrition(new Date),s=o.getMealsForDate(new Date),n={calories:2e3,protein:150,carbs:250,fat:65};return t.jsxs("div",{children:[t.jsx("h2",{style:{marginBottom:"20px"},children:"Nutrition"}),t.jsx("div",{style:g.grid,children:[{label:"Calories",value:e.calories,target:n.calories,unit:""},{label:"Protein",value:e.protein,target:n.protein,unit:"g"},{label:"Carbs",value:e.carbs,target:n.carbs,unit:"g"},{label:"Fat",value:e.fat,target:n.fat,unit:"g"}].map(r=>t.jsxs("div",{style:g.card,children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"8px"},children:[t.jsx("span",{style:{fontWeight:500},children:r.label}),t.jsxs("span",{children:[r.value,r.unit," / ",r.target,r.unit]})]}),t.jsx("div",{style:g.progressBar,children:t.jsx("div",{style:{width:`${Math.min(100,r.value/r.target*100)}%`,height:"100%",backgroundColor:r.value>r.target?"#f44336":"#4caf50",borderRadius:"4px"}})})]},r.label))}),t.jsxs("div",{style:g.card,children:[t.jsx("div",{style:g.cardTitle,children:"Today's Meals"}),s.length===0?t.jsx("div",{style:{color:"#999",textAlign:"center",padding:"30px"},children:"No meals logged today"}):s.map(r=>t.jsxs("div",{style:g.listItem,children:[t.jsx("span",{style:{textTransform:"capitalize",fontWeight:500,width:"80px"},children:r.type}),t.jsxs("div",{style:{flex:1},children:[t.jsx("div",{children:r.foods.map(i=>i.item.name).join(", ")}),t.jsxs("div",{style:{fontSize:"12px",color:"#666"},children:[r.totalCalories," cal โ€ข P:",r.totalProtein,"g C:",r.totalCarbs,"g F:",r.totalFat,"g"]})]})]},r.id))]})]})}function ue({service:o}){const e=o.getSleepStats(7),s=o.getAllSleepEntries(),n={poor:"#f44336",fair:"#ff9800",good:"#4caf50",excellent:"#2196f3"};return t.jsxs("div",{children:[t.jsx("h2",{style:{marginBottom:"20px"},children:"Sleep Tracking"}),t.jsxs("div",{style:g.grid,children:[t.jsxs("div",{style:g.card,children:[t.jsxs("div",{style:g.statValue,children:[e.avgDuration.toFixed(1),"h"]}),t.jsx("div",{style:g.statLabel,children:"Avg Sleep (7 days)"})]}),t.jsxs("div",{style:g.card,children:[t.jsxs("div",{style:g.statValue,children:[e.avgQuality.toFixed(1),"/4"]}),t.jsx("div",{style:g.statLabel,children:"Avg Quality"})]})]}),t.jsxs("div",{style:g.card,children:[t.jsx("div",{style:g.cardTitle,children:"Sleep History"}),s.length===0?t.jsx("div",{style:{color:"#999",textAlign:"center",padding:"30px"},children:"No sleep data logged"}):s.slice(0,10).map(r=>t.jsxs("div",{style:g.listItem,children:[t.jsx("span",{style:{width:"100px"},children:new Date(r.date).toLocaleDateString()}),t.jsxs("span",{style:{flex:1},children:[r.duration.toFixed(1)," hours"]}),t.jsx("span",{style:{padding:"4px 12px",borderRadius:"12px",fontSize:"12px",backgroundColor:n[r.quality]+"20",color:n[r.quality],textTransform:"capitalize"},children:r.quality})]},r.id))]})]})}function ge({service:o}){const e=o.getAllMedicalRecords(),s=o.getUpcomingFollowUps(),n={appointment:"๐Ÿ“…","lab-result":"๐Ÿงช",vaccination:"๐Ÿ’‰",prescription:"๐Ÿ“",procedure:"๐Ÿฅ",diagnosis:"๐Ÿฉบ",note:"๐Ÿ“‹"};return t.jsxs("div",{children:[t.jsx("h2",{style:{marginBottom:"20px"},children:"Medical Records"}),s.length>0&&t.jsxs("div",{style:{...g.card,marginBottom:"20px",backgroundColor:"#fff3e0"},children:[t.jsx("div",{style:g.cardTitle,children:"Upcoming Follow-ups"}),s.map(r=>t.jsxs("div",{style:g.listItem,children:[t.jsx("span",{children:n[r.type]}),t.jsx("span",{style:{flex:1},children:r.title}),t.jsx("span",{style:{color:"#ef6c00"},children:new Date(r.followUp).toLocaleDateString()})]},r.id))]}),t.jsxs("div",{style:g.card,children:[t.jsx("div",{style:g.cardTitle,children:"All Records"}),e.length===0?t.jsx("div",{style:{color:"#999",textAlign:"center",padding:"30px"},children:"No medical records"}):e.slice(0,15).map(r=>t.jsxs("div",{style:g.listItem,children:[t.jsx("span",{style:{fontSize:"20px"},children:n[r.type]}),t.jsxs("div",{style:{flex:1},children:[t.jsx("div",{style:{fontWeight:500},children:r.title}),t.jsxs("div",{style:{fontSize:"12px",color:"#666"},children:[new Date(r.date).toLocaleDateString(),r.provider&&` โ€ข ${r.provider}`]})]})]},r.id))]})]})}function he({service:o,refresh:e}){o.getAllMedications();const s=o.getActiveMedications(),n=o.getTodayMedicationSchedule(),r=i=>{const a=new Date;a.setHours(parseInt(i.times[0].split(":")[0]),parseInt(i.times[0].split(":")[1]),0),o.logMedication(i.id,a,!0),e()};return t.jsxs("div",{children:[t.jsx("h2",{style:{marginBottom:"20px"},children:"Medications"}),t.jsxs("div",{style:{...g.card,marginBottom:"20px"},children:[t.jsx("div",{style:g.cardTitle,children:"Today's Schedule"}),n.length===0?t.jsx("div",{style:{color:"#999",textAlign:"center",padding:"20px"},children:"No medications scheduled"}):n.map((i,a)=>t.jsxs("div",{style:g.listItem,children:[t.jsx("span",{style:{width:"60px",fontWeight:500},children:i.time}),t.jsxs("div",{style:{flex:1},children:[t.jsx("div",{style:{fontWeight:500},children:i.medication.name}),t.jsx("div",{style:{fontSize:"12px",color:"#666"},children:i.medication.dosage})]}),!i.taken&&t.jsx("button",{onClick:()=>r(i.medication),style:{padding:"6px 16px",border:"none",borderRadius:"6px",backgroundColor:"#4caf50",color:"#fff",cursor:"pointer",fontSize:"12px"},children:"Mark Taken"}),i.taken&&t.jsx("span",{style:{color:"#4caf50",fontSize:"12px"},children:"โœ“ Taken"})]},a))]}),t.jsxs("div",{style:g.card,children:[t.jsx("div",{style:g.cardTitle,children:"Active Medications"}),s.length===0?t.jsx("div",{style:{color:"#999",textAlign:"center",padding:"30px"},children:"No active medications"}):s.map(i=>t.jsxs("div",{style:g.listItem,children:[t.jsx("span",{style:{fontSize:"24px"},children:"๐Ÿ’Š"}),t.jsxs("div",{style:{flex:1},children:[t.jsx("div",{style:{fontWeight:500},children:i.name}),t.jsxs("div",{style:{fontSize:"12px",color:"#666"},children:[i.dosage," โ€ข ",i.frequency," โ€ข ",i.times.join(", ")]})]})]},i.id))]})]})}const pe=[{id:"income",name:"Income",icon:"๐Ÿ’ฐ",color:"#4caf50"},{id:"salary",name:"Salary",icon:"๐Ÿ’ต",color:"#4caf50",parent:"income"},{id:"interest",name:"Interest",icon:"๐Ÿฆ",color:"#4caf50",parent:"income"},{id:"housing",name:"Housing",icon:"๐Ÿ ",color:"#2196f3"},{id:"rent",name:"Rent",icon:"๐Ÿ ",color:"#2196f3",parent:"housing"},{id:"utilities",name:"Utilities",icon:"๐Ÿ’ก",color:"#2196f3",parent:"housing"},{id:"food",name:"Food & Dining",icon:"๐Ÿ”",color:"#ff9800"},{id:"groceries",name:"Groceries",icon:"๐Ÿ›’",color:"#ff9800",parent:"food"},{id:"restaurants",name:"Restaurants",icon:"๐Ÿฝ๏ธ",color:"#ff9800",parent:"food"},{id:"transport",name:"Transportation",icon:"๐Ÿš—",color:"#9c27b0"},{id:"gas",name:"Gas",icon:"โ›ฝ",color:"#9c27b0",parent:"transport"},{id:"parking",name:"Parking",icon:"๐Ÿ…ฟ๏ธ",color:"#9c27b0",parent:"transport"},{id:"shopping",name:"Shopping",icon:"๐Ÿ›๏ธ",color:"#e91e63"},{id:"entertainment",name:"Entertainment",icon:"๐ŸŽฌ",color:"#673ab7"},{id:"health",name:"Health",icon:"๐Ÿฅ",color:"#f44336"},{id:"personal",name:"Personal",icon:"๐Ÿ‘ค",color:"#607d8b"},{id:"education",name:"Education",icon:"๐Ÿ“š",color:"#00bcd4"},{id:"travel",name:"Travel",icon:"โœˆ๏ธ",color:"#009688"},{id:"subscriptions",name:"Subscriptions",icon:"๐Ÿ“ฑ",color:"#795548"},{id:"transfer",name:"Transfer",icon:"โ†”๏ธ",color:"#9e9e9e"},{id:"other",name:"Other",icon:"๐Ÿ“ฆ",color:"#9e9e9e"}];class N{constructor(){j(this,"accounts",new Map);j(this,"transactions",new Map);j(this,"budgets",new Map);j(this,"bills",new Map);j(this,"investments",new Map);j(this,"categories",[...pe]);j(this,"netWorthHistory",[])}addAccount(e){const s=this.generateId(),n={...e,id:s};return this.accounts.set(s,n),n}updateAccount(e,s){const n=this.accounts.get(e);n&&this.accounts.set(e,{...n,...s,id:e})}deleteAccount(e){this.accounts.delete(e);for(const[s,n]of this.transactions)n.accountId===e&&this.transactions.delete(s)}getAllAccounts(){return Array.from(this.accounts.values())}getAccountsByType(e){return this.getAllAccounts().filter(s=>s.type===e)}calculateTotalAssets(){return this.getAllAccounts().filter(e=>["checking","savings","investment","cash","crypto"].includes(e.type)).reduce((e,s)=>e+s.balance,0)}calculateTotalLiabilities(){return this.getAllAccounts().filter(e=>["credit-card","loan","mortgage"].includes(e.type)).reduce((e,s)=>e+Math.abs(s.balance),0)}calculateNetWorth(){return this.calculateTotalAssets()-this.calculateTotalLiabilities()}recordNetWorthSnapshot(){const e={date:new Date,assets:this.calculateTotalAssets(),liabilities:this.calculateTotalLiabilities(),netWorth:this.calculateNetWorth()};this.netWorthHistory.push(e)}getNetWorthHistory(){return[...this.netWorthHistory]}addTransaction(e){const s=this.generateId(),n={...e,id:s};this.transactions.set(s,n);const r=this.accounts.get(e.accountId);if(r){const i=e.type==="income"?e.amount:-e.amount;r.balance+=i,this.accounts.set(r.id,r)}if(e.categoryId&&e.type==="expense"){const i=this.getBudgetByCategory(e.categoryId);i&&(i.spent+=e.amount,this.budgets.set(i.id,i))}return n}updateTransaction(e,s){const n=this.transactions.get(e);n&&this.transactions.set(e,{...n,...s,id:e})}deleteTransaction(e){const s=this.transactions.get(e);if(s){const n=this.accounts.get(s.accountId);if(n){const r=s.type==="income"?-s.amount:s.amount;n.balance+=r,this.accounts.set(n.id,n)}this.transactions.delete(e)}}getAllTransactions(){return Array.from(this.transactions.values()).sort((e,s)=>new Date(s.date).getTime()-new Date(e.date).getTime())}getTransactionsForAccount(e){return this.getAllTransactions().filter(s=>s.accountId===e)}getTransactionsForPeriod(e,s){return this.getAllTransactions().filter(n=>{const r=new Date(n.date);return r>=e&&r<=s})}getTransactionsByCategory(e){return this.getAllTransactions().filter(s=>s.categoryId===e)}autoCategorize(e){const s=[{pattern:/walmart|target|costco|grocery|supermarket/i,categoryId:"groceries"},{pattern:/starbucks|mcdonalds|restaurant|cafe|pizza/i,categoryId:"restaurants"},{pattern:/shell|exxon|chevron|gas|fuel/i,categoryId:"gas"},{pattern:/netflix|spotify|hulu|subscription/i,categoryId:"subscriptions"},{pattern:/amazon|ebay|shopping/i,categoryId:"shopping"},{pattern:/uber|lyft|taxi|parking/i,categoryId:"transport"},{pattern:/rent|mortgage|lease/i,categoryId:"rent"},{pattern:/electric|water|internet|phone/i,categoryId:"utilities"},{pattern:/doctor|pharmacy|hospital|medical/i,categoryId:"health"},{pattern:/payroll|salary|paycheck|deposit/i,categoryId:"salary"}];for(const n of s)if(n.pattern.test(e))return n.categoryId}getAllCategories(){return[...this.categories]}getTopLevelCategories(){return this.categories.filter(e=>!e.parent)}getSubCategories(e){return this.categories.filter(s=>s.parent===e)}addCategory(e){this.categories.push(e)}addBudget(e){const s=this.generateId(),n={...e,id:s,spent:0};return this.budgets.set(s,n),n}updateBudget(e,s){const n=this.budgets.get(e);n&&this.budgets.set(e,{...n,...s,id:e})}deleteBudget(e){this.budgets.delete(e)}getAllBudgets(){return Array.from(this.budgets.values())}getBudgetByCategory(e){return this.getAllBudgets().find(s=>s.categoryId===e)}resetBudgetSpending(){for(const[e,s]of this.budgets)s.rollover||(s.spent=0),this.budgets.set(e,s)}calculateBudgetStatus(){const e=this.getAllBudgets(),s=e.reduce((i,a)=>i+a.amount,0),n=e.reduce((i,a)=>i+a.spent,0),r=e.filter(i=>i.spent>i.amount);return{total:s,used:n,remaining:s-n,overBudget:r}}addBill(e){const s=this.generateId(),n={...e,id:s};return this.bills.set(s,n),n}updateBill(e,s){const n=this.bills.get(e);n&&this.bills.set(e,{...n,...s,id:e})}deleteBill(e){this.bills.delete(e)}markBillPaid(e){const s=this.bills.get(e);s&&(s.lastPaid=new Date,this.bills.set(e,s))}getAllBills(){return Array.from(this.bills.values())}getUpcomingBills(e=30){const n=new Date().getDate();return this.getAllBills().filter(r=>{let i=r.dueDate-n;return i<0&&(i+=30),i<=e}).sort((r,i)=>r.dueDate-i.dueDate)}calculateMonthlyBillTotal(){return this.getAllBills().filter(e=>e.frequency==="monthly").reduce((e,s)=>e+s.amount,0)}addInvestment(e){const s=this.generateId(),n=e.shares*e.currentPrice,r=n-e.costBasis,i=e.costBasis>0?r/e.costBasis*100:0,a={...e,id:s,currentValue:n,gain:r,gainPercent:i};return this.investments.set(s,a),a}updateInvestmentPrice(e,s){const n=this.investments.get(e);n&&(n.currentPrice=s,n.currentValue=n.shares*s,n.gain=n.currentValue-n.costBasis,n.gainPercent=n.costBasis>0?n.gain/n.costBasis*100:0,this.investments.set(e,n))}deleteInvestment(e){this.investments.delete(e)}getAllInvestments(){return Array.from(this.investments.values())}getInvestmentsByAccount(e){return this.getAllInvestments().filter(s=>s.accountId===e)}calculateTotalInvestmentValue(){return this.getAllInvestments().reduce((e,s)=>e+s.currentValue,0)}calculateTotalGain(){return this.getAllInvestments().reduce((e,s)=>e+s.gain,0)}getPortfolioAllocation(){const e=this.getAllInvestments(),s=this.calculateTotalInvestmentValue(),n=new Map;for(const r of e)n.set(r.type,(n.get(r.type)||0)+r.currentValue);return Array.from(n.entries()).map(([r,i])=>({type:r,value:i,percentage:s>0?i/s*100:0}))}getSpendingSummary(e,s){const n=this.getTransactionsForPeriod(e,s).filter(a=>a.type==="expense"),r=new Map;let i=0;for(const a of n){const l=a.categoryId||"other",d=r.get(l)||{amount:0,count:0};d.amount+=a.amount,d.count++,r.set(l,d),i+=a.amount}return Array.from(r.entries()).map(([a,l])=>{const d=this.categories.find(u=>u.id===a);return{categoryId:a,categoryName:(d==null?void 0:d.name)||"Other",amount:l.amount,percentage:i>0?l.amount/i*100:0,transactions:l.count,trend:"stable"}}).sort((a,l)=>l.amount-a.amount)}getMonthlyIncome(){const e=new Date,s=new Date(e.getFullYear(),e.getMonth(),1);return this.getTransactionsForPeriod(s,e).filter(r=>r.type==="income").reduce((r,i)=>r+i.amount,0)}getMonthlyExpenses(){const e=new Date,s=new Date(e.getFullYear(),e.getMonth(),1);return this.getTransactionsForPeriod(s,e).filter(r=>r.type==="expense").reduce((r,i)=>r+i.amount,0)}getSavingsRate(){const e=this.getMonthlyIncome(),s=this.getMonthlyExpenses();return e===0?0:(e-s)/e*100}generateId(){return Date.now().toString(36)+Math.random().toString(36).substring(2,8)}clear(){this.accounts.clear(),this.transactions.clear(),this.budgets.clear(),this.bills.clear(),this.investments.clear(),this.netWorthHistory=[]}exportData(){return JSON.stringify({accounts:this.getAllAccounts(),transactions:this.getAllTransactions(),budgets:this.getAllBudgets(),bills:this.getAllBills(),investments:this.getAllInvestments(),categories:this.categories,netWorthHistory:this.netWorthHistory},null,2)}}function xe(){return new N}const H=f.createContext(null);function fe(){const o=f.useContext(H);if(!o)throw new Error("usePersonalFinance must be used within PersonalFinanceProvider");return o}const x={container:{display:"flex",height:"100%",fontFamily:"'Inter', sans-serif",backgroundColor:"#f5f7fa"},sidebar:{width:"250px",backgroundColor:"#1a1a2e",color:"#fff",padding:"20px"},main:{flex:1,padding:"20px",overflow:"auto"},netWorth:{textAlign:"center",padding:"20px 0",borderBottom:"1px solid rgba(255,255,255,0.1)",marginBottom:"20px"},netWorthLabel:{fontSize:"12px",color:"rgba(255,255,255,0.6)",textTransform:"uppercase",letterSpacing:"1px"},netWorthValue:{fontSize:"28px",fontWeight:700,marginTop:"8px"},accountList:{marginTop:"20px"},accountItem:{display:"flex",justifyContent:"space-between",padding:"12px",borderRadius:"8px",marginBottom:"8px",backgroundColor:"rgba(255,255,255,0.05)",cursor:"pointer"},grid:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(300px, 1fr))",gap:"20px",marginBottom:"20px"},card:{backgroundColor:"#fff",borderRadius:"12px",padding:"20px",boxShadow:"0 2px 8px rgba(0,0,0,0.08)"},cardTitle:{fontSize:"16px",fontWeight:600,marginBottom:"16px",color:"#1a1a2e"},transactionRow:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px 0",borderBottom:"1px solid #f0f0f0"},progressBar:{height:"8px",backgroundColor:"#e0e0e0",borderRadius:"4px",overflow:"hidden",marginTop:"8px"}};function me({service:o,className:e,style:s}){const[,n]=f.useState(0),[r,i]=f.useState("overview"),a=f.useCallback(()=>n(h=>h+1),[]),l={service:o,refresh:a},d=h=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(h),u=o.getAllAccounts(),c=o.calculateNetWorth();return t.jsx(H.Provider,{value:l,children:t.jsxs("div",{className:e,style:{...x.container,...s},children:[t.jsxs("div",{style:x.sidebar,children:[t.jsxs("div",{style:x.netWorth,children:[t.jsx("div",{style:x.netWorthLabel,children:"Net Worth"}),t.jsx("div",{style:{...x.netWorthValue,color:c>=0?"#4caf50":"#f44336"},children:d(c)})]}),t.jsx("div",{children:["overview","accounts","transactions","budgets","bills","investments"].map(h=>t.jsx("div",{onClick:()=>i(h),style:{padding:"12px 16px",borderRadius:"8px",cursor:"pointer",marginBottom:"4px",backgroundColor:r===h?"rgba(255,255,255,0.1)":"transparent",textTransform:"capitalize"},children:h},h))}),t.jsxs("div",{style:x.accountList,children:[t.jsx("div",{style:{fontSize:"12px",color:"rgba(255,255,255,0.6)",marginBottom:"12px",textTransform:"uppercase"},children:"Accounts"}),u.slice(0,5).map(h=>t.jsxs("div",{style:x.accountItem,children:[t.jsx("span",{children:h.name}),t.jsx("span",{style:{color:h.balance>=0?"#4caf50":"#f44336"},children:d(h.balance)})]},h.id))]})]}),t.jsxs("div",{style:x.main,children:[r==="overview"&&t.jsx(ye,{service:o}),r==="accounts"&&t.jsx(be,{service:o,refresh:a}),r==="transactions"&&t.jsx(ve,{service:o}),r==="budgets"&&t.jsx(je,{service:o}),r==="bills"&&t.jsx(we,{service:o}),r==="investments"&&t.jsx(Se,{service:o})]})]})})}function ye({service:o}){const e=u=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(u),s=o.getMonthlyIncome(),n=o.getMonthlyExpenses(),r=o.getSavingsRate(),i=o.calculateBudgetStatus(),a=o.getUpcomingBills(14),l=new Date,d=o.getSpendingSummary(new Date(l.getFullYear(),l.getMonth(),1),l);return t.jsxs("div",{children:[t.jsx("h2",{style:{marginBottom:"20px"},children:"Financial Overview"}),t.jsxs("div",{style:x.grid,children:[t.jsxs("div",{style:x.card,children:[t.jsx("div",{style:x.cardTitle,children:"This Month"}),t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"12px"},children:[t.jsx("span",{children:"Income"}),t.jsx("span",{style:{color:"#4caf50",fontWeight:600},children:e(s)})]}),t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"12px"},children:[t.jsx("span",{children:"Expenses"}),t.jsx("span",{style:{color:"#f44336",fontWeight:600},children:e(n)})]}),t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",borderTop:"1px solid #f0f0f0",paddingTop:"12px"},children:[t.jsx("span",{children:"Savings Rate"}),t.jsxs("span",{style:{fontWeight:600},children:[r.toFixed(1),"%"]})]})]}),t.jsxs("div",{style:x.card,children:[t.jsx("div",{style:x.cardTitle,children:"Budget Status"}),t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"8px"},children:[t.jsx("span",{children:"Used"}),t.jsxs("span",{children:[e(i.used)," / ",e(i.total)]})]}),t.jsx("div",{style:x.progressBar,children:t.jsx("div",{style:{width:`${Math.min(100,i.used/i.total*100)}%`,height:"100%",backgroundColor:i.used>i.total?"#f44336":"#4caf50",borderRadius:"4px"}})}),i.overBudget.length>0&&t.jsxs("div",{style:{color:"#f44336",fontSize:"12px",marginTop:"8px"},children:[i.overBudget.length," categories over budget"]})]}),t.jsxs("div",{style:x.card,children:[t.jsx("div",{style:x.cardTitle,children:"Upcoming Bills (14 days)"}),a.length===0?t.jsx("div",{style:{color:"#999",textAlign:"center",padding:"20px"},children:"No upcoming bills"}):a.slice(0,4).map(u=>t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",padding:"8px 0",borderBottom:"1px solid #f0f0f0"},children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontWeight:500},children:u.name}),t.jsxs("div",{style:{fontSize:"12px",color:"#666"},children:["Due: ",u.dueDate,"th"]})]}),t.jsx("span",{style:{fontWeight:600},children:e(u.amount)})]},u.id))]}),t.jsxs("div",{style:x.card,children:[t.jsx("div",{style:x.cardTitle,children:"Spending by Category"}),d.slice(0,5).map(u=>t.jsxs("div",{style:{marginBottom:"12px"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"4px"},children:[t.jsx("span",{children:u.categoryName}),t.jsxs("span",{children:[e(u.amount)," (",u.percentage.toFixed(0),"%)"]})]}),t.jsx("div",{style:x.progressBar,children:t.jsx("div",{style:{width:`${u.percentage}%`,height:"100%",backgroundColor:"#1976d2",borderRadius:"4px"}})})]},u.categoryId))]})]})]})}function be({service:o,refresh:e}){const s=a=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(a);o.getAllAccounts();const n=o.calculateTotalAssets(),r=o.calculateTotalLiabilities(),i=["checking","savings","credit-card","investment","loan","cash"];return t.jsxs("div",{children:[t.jsx("h2",{style:{marginBottom:"20px"},children:"Accounts"}),t.jsxs("div",{style:x.grid,children:[t.jsxs("div",{style:x.card,children:[t.jsx("div",{style:x.cardTitle,children:"Assets"}),t.jsx("div",{style:{fontSize:"24px",fontWeight:600,color:"#4caf50"},children:s(n)})]}),t.jsxs("div",{style:x.card,children:[t.jsx("div",{style:x.cardTitle,children:"Liabilities"}),t.jsx("div",{style:{fontSize:"24px",fontWeight:600,color:"#f44336"},children:s(r)})]})]}),i.map(a=>{const l=o.getAccountsByType(a);return l.length===0?null:t.jsxs("div",{style:{...x.card,marginBottom:"20px"},children:[t.jsx("div",{style:x.cardTitle,children:a.replace("-"," ").replace(/\b\w/g,d=>d.toUpperCase())}),l.map(d=>t.jsxs("div",{style:x.transactionRow,children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontWeight:500},children:d.name}),t.jsx("div",{style:{fontSize:"12px",color:"#666"},children:d.institution})]}),t.jsx("span",{style:{fontWeight:600,color:d.balance>=0?"#333":"#f44336"},children:s(d.balance)})]},d.id))]},a)})]})}function ve({service:o}){const e=i=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(i),s=o.getAllTransactions(),n=o.getAllCategories(),r=i=>{var a;return((a=n.find(l=>l.id===i))==null?void 0:a.name)||"Uncategorized"};return t.jsxs("div",{children:[t.jsx("h2",{style:{marginBottom:"20px"},children:"Transactions"}),t.jsx("div",{style:x.card,children:s.length===0?t.jsx("div",{style:{color:"#999",textAlign:"center",padding:"40px"},children:"No transactions"}):s.slice(0,20).map(i=>t.jsxs("div",{style:x.transactionRow,children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontWeight:500},children:i.description}),t.jsxs("div",{style:{fontSize:"12px",color:"#666"},children:[new Date(i.date).toLocaleDateString()," โ€ข ",r(i.categoryId)]})]}),t.jsxs("span",{style:{fontWeight:600,color:i.type==="income"?"#4caf50":"#f44336"},children:[i.type==="income"?"+":"-",e(i.amount)]})]},i.id))})]})}function je({service:o}){const e=i=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(i),s=o.getAllBudgets(),n=o.getAllCategories(),r=i=>{var a;return((a=n.find(l=>l.id===i))==null?void 0:a.name)||"Unknown"};return t.jsxs("div",{children:[t.jsx("h2",{style:{marginBottom:"20px"},children:"Budgets"}),t.jsx("div",{style:x.card,children:s.length===0?t.jsx("div",{style:{color:"#999",textAlign:"center",padding:"40px"},children:"No budgets set"}):s.map(i=>{const a=i.spent/i.amount*100,l=i.spent>i.amount;return t.jsxs("div",{style:{marginBottom:"20px",paddingBottom:"20px",borderBottom:"1px solid #f0f0f0"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"8px"},children:[t.jsx("span",{style:{fontWeight:500},children:r(i.categoryId)}),t.jsxs("span",{children:[e(i.spent)," / ",e(i.amount)]})]}),t.jsx("div",{style:x.progressBar,children:t.jsx("div",{style:{width:`${Math.min(100,a)}%`,height:"100%",backgroundColor:l?"#f44336":a>80?"#ff9800":"#4caf50",borderRadius:"4px"}})}),t.jsx("div",{style:{fontSize:"12px",color:l?"#f44336":"#666",marginTop:"4px"},children:l?`Over by ${e(i.spent-i.amount)}`:`${e(i.amount-i.spent)} remaining`})]},i.id)})})]})}function we({service:o}){const e=r=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(r),s=o.getAllBills(),n=o.calculateMonthlyBillTotal();return t.jsxs("div",{children:[t.jsx("h2",{style:{marginBottom:"20px"},children:"Bills & Subscriptions"}),t.jsxs("div",{style:{...x.card,marginBottom:"20px"},children:[t.jsx("div",{style:x.cardTitle,children:"Monthly Bills Total"}),t.jsx("div",{style:{fontSize:"24px",fontWeight:600},children:e(n)})]}),t.jsx("div",{style:x.card,children:s.length===0?t.jsx("div",{style:{color:"#999",textAlign:"center",padding:"40px"},children:"No bills tracked"}):s.map(r=>t.jsxs("div",{style:x.transactionRow,children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontWeight:500},children:r.name}),t.jsxs("div",{style:{fontSize:"12px",color:"#666"},children:["Due: ",r.dueDate,"th โ€ข ",r.frequency,r.autoPay&&" โ€ข Auto-pay"]})]}),t.jsx("span",{style:{fontWeight:600},children:e(r.amount)})]},r.id))})]})}function Se({service:o}){const e=a=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(a),s=o.getAllInvestments(),n=o.calculateTotalInvestmentValue(),r=o.calculateTotalGain(),i=o.getPortfolioAllocation();return t.jsxs("div",{children:[t.jsx("h2",{style:{marginBottom:"20px"},children:"Investments"}),t.jsxs("div",{style:x.grid,children:[t.jsxs("div",{style:x.card,children:[t.jsx("div",{style:x.cardTitle,children:"Portfolio Value"}),t.jsx("div",{style:{fontSize:"24px",fontWeight:600},children:e(n)})]}),t.jsxs("div",{style:x.card,children:[t.jsx("div",{style:x.cardTitle,children:"Total Gain/Loss"}),t.jsxs("div",{style:{fontSize:"24px",fontWeight:600,color:r>=0?"#4caf50":"#f44336"},children:[r>=0?"+":"",e(r)]})]})]}),t.jsxs("div",{style:{...x.card,marginBottom:"20px"},children:[t.jsx("div",{style:x.cardTitle,children:"Asset Allocation"}),i.map(a=>t.jsxs("div",{style:{marginBottom:"12px"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"4px"},children:[t.jsx("span",{style:{textTransform:"capitalize"},children:a.type}),t.jsxs("span",{children:[a.percentage.toFixed(1),"%"]})]}),t.jsx("div",{style:x.progressBar,children:t.jsx("div",{style:{width:`${a.percentage}%`,height:"100%",backgroundColor:"#1976d2",borderRadius:"4px"}})})]},a.type))]}),t.jsxs("div",{style:x.card,children:[t.jsx("div",{style:x.cardTitle,children:"Holdings"}),s.length===0?t.jsx("div",{style:{color:"#999",textAlign:"center",padding:"40px"},children:"No investments tracked"}):s.map(a=>t.jsxs("div",{style:x.transactionRow,children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontWeight:500},children:a.symbol}),t.jsxs("div",{style:{fontSize:"12px",color:"#666"},children:[a.shares," shares @ ",e(a.currentPrice)]})]}),t.jsxs("div",{style:{textAlign:"right"},children:[t.jsx("div",{style:{fontWeight:600},children:e(a.currentValue)}),t.jsxs("div",{style:{fontSize:"12px",color:a.gain>=0?"#4caf50":"#f44336"},children:[a.gain>=0?"+":"",e(a.gain)," (",a.gainPercent.toFixed(1),"%)"]})]})]},a.id))]})]})}const F={urgent:0,high:1,medium:2,low:3,none:4};class ${constructor(){j(this,"tasks",new Map);j(this,"projects",new Map);j(this,"tags",new Map);j(this,"timeBlocks",new Map)}addTask(e){const s=this.generateId(),n=new Date,r={...e,id:s,subtasks:[],createdAt:n,updatedAt:n};return this.tasks.set(s,r),r}updateTask(e,s){const n=this.tasks.get(e);n&&this.tasks.set(e,{...n,...s,id:e,updatedAt:new Date})}deleteTask(e){const s=this.tasks.get(e);if(s){for(const n of s.subtasks)this.deleteTask(n.id);for(const n of s.timeBlocks)this.timeBlocks.delete(n.id);this.tasks.delete(e)}}getTask(e){return this.tasks.get(e)}getAllTasks(){return Array.from(this.tasks.values())}quickAddTask(e){const s=this.parseQuickAdd(e);return this.addTask({title:s.title,status:"inbox",priority:s.priority,projectId:s.projectId,tags:s.tags,dueDate:s.dueDate,timeBlocks:[],notes:"",attachments:[]})}parseQuickAdd(e){let s=e,n="none",r;const i=[];let a;e.includes("!!!")?(n="urgent",s=s.replace("!!!","")):e.includes("!!")?(n="high",s=s.replace("!!","")):e.includes("!")&&(n="medium",s=s.replace("!",""));const l=e.match(/#(\w+)/);if(l){const c=Array.from(this.projects.values()).find(h=>h.name.toLowerCase()===l[1].toLowerCase());c&&(r=c.id,s=s.replace(l[0],""))}const d=e.matchAll(/@(\w+)/g);for(const c of d){const h=Array.from(this.tags.values()).find(m=>m.name.toLowerCase()===c[1].toLowerCase());h&&(i.push(h.id),s=s.replace(c[0],""))}const u=[{pattern:/\btoday\b/i,offset:()=>new Date},{pattern:/\btomorrow\b/i,offset:()=>new Date(Date.now()+864e5)},{pattern:/\bnext week\b/i,offset:()=>new Date(Date.now()+7*864e5)},{pattern:/\bnext month\b/i,offset:()=>{const c=new Date;return c.setMonth(c.getMonth()+1),c}}];for(const{pattern:c,offset:h}of u)if(c.test(e)){a=h(),a.setHours(23,59,59,999),s=s.replace(c,"");break}return{title:s.trim(),priority:n,projectId:r,tags:i,dueDate:a}}completeTask(e){const s=this.tasks.get(e);s&&(s.status="done",s.completedDate=new Date,s.updatedAt=new Date,s.recurrence&&this.createRecurringTask(s),this.tasks.set(e,s))}createRecurringTask(e){const s=this.calculateNextRecurrence(e);s&&this.addTask({title:e.title,description:e.description,status:"todo",priority:e.priority,projectId:e.projectId,tags:e.tags,dueDate:s,recurrence:e.recurrence,timeBlocks:[],notes:"",attachments:[]})}calculateNextRecurrence(e){if(!e.recurrence||!e.dueDate)return null;const{pattern:s,interval:n,endDate:r,endAfterOccurrences:i}=e.recurrence,a=new Date(e.dueDate);let l;switch(s){case"daily":l=new Date(a.getTime()+n*864e5);break;case"weekdays":l=new Date(a);do l.setDate(l.getDate()+1);while(l.getDay()===0||l.getDay()===6);break;case"weekly":l=new Date(a.getTime()+n*7*864e5);break;case"bi-weekly":l=new Date(a.getTime()+14*864e5);break;case"monthly":l=new Date(a),l.setMonth(l.getMonth()+n);break;case"yearly":l=new Date(a),l.setFullYear(l.getFullYear()+n);break;default:return null}return r&&l>r?null:l}filterTasks(e){var n,r,i;let s=this.getAllTasks();if((n=e.status)!=null&&n.length&&(s=s.filter(a=>e.status.includes(a.status))),(r=e.priority)!=null&&r.length&&(s=s.filter(a=>e.priority.includes(a.priority))),e.projectId!==void 0&&(s=s.filter(a=>a.projectId===e.projectId)),(i=e.tags)!=null&&i.length&&(s=s.filter(a=>e.tags.some(l=>a.tags.includes(l)))),e.dueDateRange){const{start:a,end:l}=e.dueDateRange;s=s.filter(d=>{if(!d.dueDate)return!1;const u=new Date(d.dueDate);return!(a&&u<a||l&&u>l)})}if(e.search){const a=e.search.toLowerCase();s=s.filter(l=>{var d;return l.title.toLowerCase().includes(a)||((d=l.description)==null?void 0:d.toLowerCase().includes(a))||l.notes.toLowerCase().includes(a)})}return s}sortTasks(e,s="dueDate",n="asc"){return[...e].sort((i,a)=>{let l=0;switch(s){case"dueDate":const d=i.dueDate?new Date(i.dueDate).getTime():1/0,u=a.dueDate?new Date(a.dueDate).getTime():1/0;l=d-u;break;case"priority":l=F[i.priority]-F[a.priority];break;case"createdAt":l=new Date(i.createdAt).getTime()-new Date(a.createdAt).getTime();break;case"title":l=i.title.localeCompare(a.title);break;case"status":l=i.status.localeCompare(a.status);break}return n==="asc"?l:-l})}getInbox(){return this.filterTasks({status:["inbox"]})}getToday(){const e=new Date;e.setHours(0,0,0,0);const s=new Date(e.getTime()+864e5);return this.filterTasks({status:["todo","in-progress"],dueDateRange:{end:s}})}getUpcoming(e=7){const s=new Date;s.setHours(0,0,0,0);const n=new Date(s.getTime()+e*864e5);return this.filterTasks({status:["todo","in-progress"],dueDateRange:{start:s,end:n}})}getOverdue(){const e=new Date;return e.setHours(0,0,0,0),this.getAllTasks().filter(s=>s.dueDate&&new Date(s.dueDate)<e&&!["done","cancelled"].includes(s.status))}getPriorityMatrix(){const e=this.filterTasks({status:["todo","in-progress"]}),s=r=>r.dueDate?Math.ceil((new Date(r.dueDate).getTime()-Date.now())/864e5)<=2:!1,n=r=>["urgent","high"].includes(r.priority);return{doFirst:{name:"Do First",description:"Urgent and Important",tasks:e.filter(r=>s(r)&&n(r))},schedule:{name:"Schedule",description:"Important but Not Urgent",tasks:e.filter(r=>!s(r)&&n(r))},delegate:{name:"Delegate",description:"Urgent but Not Important",tasks:e.filter(r=>s(r)&&!n(r))},eliminate:{name:"Eliminate",description:"Neither Urgent nor Important",tasks:e.filter(r=>!s(r)&&!n(r))}}}addTimeBlock(e){const s=this.generateId(),n={...e,id:s};if(this.timeBlocks.set(s,n),e.taskId){const r=this.tasks.get(e.taskId);r&&(r.timeBlocks.push(n),this.tasks.set(e.taskId,r))}return n}updateTimeBlock(e,s){const n=this.timeBlocks.get(e);n&&this.timeBlocks.set(e,{...n,...s,id:e})}deleteTimeBlock(e){const s=this.timeBlocks.get(e);if(s!=null&&s.taskId){const n=this.tasks.get(s.taskId);n&&(n.timeBlocks=n.timeBlocks.filter(r=>r.id!==e),this.tasks.set(n.id,n))}this.timeBlocks.delete(e)}getTimeBlocksForDate(e){const s=new Date(e);s.setHours(0,0,0,0);const n=new Date(s.getTime()+864e5);return Array.from(this.timeBlocks.values()).filter(r=>{const i=new Date(r.start);return i>=s&&i<n})}addProject(e){const s=this.generateId(),n={...e,id:s,order:this.projects.size,createdAt:new Date};return this.projects.set(s,n),n}updateProject(e,s){const n=this.projects.get(e);n&&this.projects.set(e,{...n,...s,id:e})}deleteProject(e){this.projects.delete(e);for(const[s,n]of this.tasks)n.projectId===e&&(n.projectId=void 0,this.tasks.set(s,n))}getAllProjects(){return Array.from(this.projects.values()).sort((e,s)=>e.order-s.order)}getProjectTasks(e){return this.filterTasks({projectId:e})}getProjectProgress(e){const s=this.getProjectTasks(e),n=s.filter(r=>r.status==="done").length;return{total:s.length,completed:n,percentage:s.length>0?Math.round(n/s.length*100):0}}addTag(e){const s=this.generateId(),n={...e,id:s};return this.tags.set(s,n),n}deleteTag(e){this.tags.delete(e);for(const[s,n]of this.tasks)n.tags.includes(e)&&(n.tags=n.tags.filter(r=>r!==e),this.tasks.set(s,n))}getAllTags(){return Array.from(this.tags.values())}getStatistics(){const e=this.getAllTasks(),s=new Date;s.setHours(0,0,0,0);const n=new Date(s.getTime()+864e5),r=e.filter(d=>d.status==="done").length,i=this.getOverdue().length,a=e.filter(d=>d.dueDate&&new Date(d.dueDate)>=s&&new Date(d.dueDate)<n&&d.status!=="done").length,l=e.filter(d=>d.status==="in-progress").length;return{total:e.length,completed:r,overdue:i,dueToday:a,inProgress:l,completionRate:e.length>0?Math.round(r/e.length*100):0}}generateId(){return Date.now().toString(36)+Math.random().toString(36).substring(2,8)}clear(){this.tasks.clear(),this.projects.clear(),this.tags.clear(),this.timeBlocks.clear()}}function ke(){return new $}const E=f.createContext(null);function Te(){const o=f.useContext(E);if(!o)throw new Error("useTaskManager must be used within TaskManagerProvider");return o}const w={container:{display:"flex",height:"100%",fontFamily:"'Inter', sans-serif",backgroundColor:"#f5f7fa"},sidebar:{width:"250px",backgroundColor:"#fff",borderRight:"1px solid #e0e0e0",padding:"20px",overflow:"auto"},main:{flex:1,padding:"20px",overflow:"auto"},menuItem:{display:"flex",alignItems:"center",gap:"12px",padding:"12px 16px",borderRadius:"8px",cursor:"pointer",marginBottom:"4px",transition:"background-color 0.2s"},badge:{backgroundColor:"#1976d2",color:"#fff",borderRadius:"10px",padding:"2px 8px",fontSize:"12px",marginLeft:"auto"},sectionTitle:{fontSize:"11px",fontWeight:600,color:"#999",textTransform:"uppercase",letterSpacing:"1px",margin:"20px 0 12px"},header:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"20px"},title:{fontSize:"24px",fontWeight:600,color:"#1a1a2e"},taskInput:{width:"100%",padding:"12px 16px",border:"1px solid #e0e0e0",borderRadius:"8px",fontSize:"14px",marginBottom:"20px",outline:"none"},taskItem:{display:"flex",alignItems:"flex-start",gap:"12px",padding:"12px 16px",backgroundColor:"#fff",borderRadius:"8px",marginBottom:"8px",boxShadow:"0 1px 3px rgba(0,0,0,0.08)",cursor:"pointer"},checkbox:{width:"20px",height:"20px",borderRadius:"50%",border:"2px solid #ccc",cursor:"pointer",flexShrink:0,marginTop:"2px"},taskContent:{flex:1,minWidth:0},taskTitle:{fontSize:"14px",fontWeight:500,color:"#333",marginBottom:"4px"},taskMeta:{display:"flex",alignItems:"center",gap:"8px",fontSize:"12px",color:"#666"},priorityIndicator:{width:"4px",borderRadius:"2px",alignSelf:"stretch"},matrixGrid:{display:"grid",gridTemplateColumns:"1fr 1fr",gridTemplateRows:"1fr 1fr",gap:"16px",height:"calc(100% - 60px)"},matrixQuadrant:{backgroundColor:"#fff",borderRadius:"12px",padding:"16px",overflow:"auto"}},W={urgent:"#f44336",high:"#ff9800",medium:"#2196f3",low:"#4caf50",none:"#e0e0e0"};function De({service:o,className:e,style:s}){var A;const[,n]=f.useState(0),[r,i]=f.useState("inbox"),[a,l]=f.useState(null),[d,u]=f.useState(""),c=f.useCallback(()=>n(S=>S+1),[]),h={service:o,refresh:c},m=o.getStatistics(),p=o.getAllProjects(),b=()=>{d.trim()&&(o.quickAddTask(d),u(""),c())},k=(S,M)=>{i(S),l(M??null)};return t.jsx(E.Provider,{value:h,children:t.jsxs("div",{className:e,style:{...w.container,...s},children:[t.jsxs("div",{style:w.sidebar,children:[t.jsxs("div",{onClick:()=>k("inbox"),style:{...w.menuItem,backgroundColor:r==="inbox"?"#e3f2fd":"transparent"},children:[t.jsx("span",{children:"๐Ÿ“ฅ"}),t.jsx("span",{children:"Inbox"}),m.total-m.completed>0&&t.jsx("span",{style:w.badge,children:o.getInbox().length})]}),t.jsxs("div",{onClick:()=>k("today"),style:{...w.menuItem,backgroundColor:r==="today"?"#e3f2fd":"transparent"},children:[t.jsx("span",{children:"๐Ÿ“…"}),t.jsx("span",{children:"Today"}),m.dueToday>0&&t.jsx("span",{style:w.badge,children:m.dueToday})]}),t.jsxs("div",{onClick:()=>k("upcoming"),style:{...w.menuItem,backgroundColor:r==="upcoming"?"#e3f2fd":"transparent"},children:[t.jsx("span",{children:"๐Ÿ—“๏ธ"}),t.jsx("span",{children:"Upcoming"})]}),t.jsxs("div",{onClick:()=>k("matrix"),style:{...w.menuItem,backgroundColor:r==="matrix"?"#e3f2fd":"transparent"},children:[t.jsx("span",{children:"โฌœ"}),t.jsx("span",{children:"Priority Matrix"})]}),t.jsxs("div",{onClick:()=>k("all"),style:{...w.menuItem,backgroundColor:r==="all"?"#e3f2fd":"transparent"},children:[t.jsx("span",{children:"๐Ÿ“‹"}),t.jsx("span",{children:"All Tasks"})]}),m.overdue>0&&t.jsxs("div",{style:{...w.menuItem,color:"#f44336"},children:[t.jsx("span",{children:"โš ๏ธ"}),t.jsx("span",{children:"Overdue"}),t.jsx("span",{style:{...w.badge,backgroundColor:"#f44336"},children:m.overdue})]}),t.jsx("div",{style:w.sectionTitle,children:"Projects"}),p.map(S=>{const M=o.getProjectProgress(S.id);return t.jsxs("div",{onClick:()=>k("project",S.id),style:{...w.menuItem,backgroundColor:r==="project"&&a===S.id?"#e3f2fd":"transparent"},children:[t.jsx("span",{style:{width:"10px",height:"10px",borderRadius:"50%",backgroundColor:S.color}}),t.jsx("span",{style:{flex:1},children:S.name}),t.jsxs("span",{style:{fontSize:"12px",color:"#999"},children:[M.percentage,"%"]})]},S.id)})]}),t.jsxs("div",{style:w.main,children:[t.jsxs("div",{style:w.header,children:[t.jsxs("div",{style:w.title,children:[r==="inbox"&&"Inbox",r==="today"&&"Today",r==="upcoming"&&"Upcoming",r==="matrix"&&"Priority Matrix",r==="all"&&"All Tasks",r==="project"&&((A=p.find(S=>S.id===a))==null?void 0:A.name)]}),t.jsxs("div",{style:{fontSize:"14px",color:"#666"},children:[m.completed,"/",m.total," completed"]})]}),r!=="matrix"&&t.jsx("input",{type:"text",placeholder:"Quick add task (e.g., 'Buy groceries tomorrow #shopping !')",value:d,onChange:S=>u(S.target.value),onKeyDown:S=>S.key==="Enter"&&b(),style:w.taskInput}),r==="matrix"?t.jsx(Ie,{service:o,onComplete:c}):t.jsx(Ce,{service:o,view:r,projectId:a,onComplete:c})]})]})})}function Ce({service:o,view:e,projectId:s,onComplete:n}){const r=f.useMemo(()=>{switch(e){case"inbox":return o.getInbox();case"today":return o.getToday();case"upcoming":return o.getUpcoming();case"all":return o.sortTasks(o.filterTasks({status:["inbox","todo","in-progress"]}),"dueDate");case"project":return s?o.filterTasks({projectId:s,status:["inbox","todo","in-progress"]}):[];default:return[]}},[o,e,s]);return r.length===0?t.jsxs("div",{style:{textAlign:"center",padding:"60px",color:"#999"},children:[t.jsx("div",{style:{fontSize:"48px",marginBottom:"16px"},children:"โœจ"}),t.jsx("div",{children:"No tasks here!"})]}):t.jsx("div",{children:r.map(i=>t.jsx(V,{task:i,service:o,onComplete:n},i.id))})}function V({task:o,service:e,onComplete:s}){const n=a=>{a.stopPropagation(),e.completeTask(o.id),s()},r=a=>{const l=new Date(a),d=new Date;d.setHours(0,0,0,0);const u=new Date(d.getTime()+864e5);return l<d?"Overdue":l.toDateString()===d.toDateString()?"Today":l.toDateString()===u.toDateString()?"Tomorrow":l.toLocaleDateString("en-US",{month:"short",day:"numeric"})},i=o.dueDate&&new Date(o.dueDate)<new Date&&o.status!=="done";return t.jsxs("div",{style:w.taskItem,children:[t.jsx("div",{style:{...w.priorityIndicator,backgroundColor:W[o.priority]}}),t.jsx("div",{onClick:n,style:{...w.checkbox,borderColor:W[o.priority]}}),t.jsxs("div",{style:w.taskContent,children:[t.jsx("div",{style:w.taskTitle,children:o.title}),t.jsxs("div",{style:w.taskMeta,children:[o.dueDate&&t.jsxs("span",{style:{color:i?"#f44336":"#666"},children:["๐Ÿ“… ",r(o.dueDate)]}),o.estimatedMinutes&&t.jsxs("span",{children:["โฑ๏ธ ",o.estimatedMinutes,"m"]}),o.recurrence&&t.jsx("span",{children:"๐Ÿ”„"})]})]})]})}function Ie({service:o,onComplete:e}){const s=o.getPriorityMatrix(),n={doFirst:{bg:"#ffebee",border:"#f44336"},schedule:{bg:"#fff3e0",border:"#ff9800"},delegate:{bg:"#e3f2fd",border:"#2196f3"},eliminate:{bg:"#f5f5f5",border:"#9e9e9e"}};return t.jsx("div",{style:w.matrixGrid,children:["doFirst","schedule","delegate","eliminate"].map(r=>{const i=s[r],a=n[r];return t.jsxs("div",{style:{...w.matrixQuadrant,backgroundColor:a.bg,borderLeft:`4px solid ${a.border}`},children:[t.jsx("div",{style:{fontWeight:600,marginBottom:"8px"},children:i.name}),t.jsx("div",{style:{fontSize:"12px",color:"#666",marginBottom:"12px"},children:i.description}),i.tasks.map(l=>t.jsx(V,{task:l,service:o,onComplete:e},l.id)),i.tasks.length===0&&t.jsx("div",{style:{color:"#999",textAlign:"center",padding:"20px"},children:"Empty"})]},r)})})}class O{constructor(){j(this,"kpis",new Map);j(this,"goals",new Map);j(this,"habits",new Map);j(this,"moodEntries",new Map);j(this,"financeSummary",{netWorth:0,monthlyIncome:0,monthlyExpenses:0,savings:0,savingsRate:0,debts:0,investments:0,budgetUsed:0,budgetTotal:0,categories:[]})}addKPI(e){const s=this.generateId(),n={...e,id:s};return this.kpis.set(s,n),n}updateKPI(e,s){const n=this.kpis.get(e);n&&this.kpis.set(e,{...n,...s,id:e})}recordKPIValue(e,s){const n=this.kpis.get(e);if(n){const r=n.currentValue;n.currentValue=s,n.history.push({date:new Date,value:s}),n.trend=s>r?"up":s<r?"down":"stable",this.kpis.set(e,n)}}getAllKPIs(){return Array.from(this.kpis.values())}getKPIsByCategory(e){return this.getAllKPIs().filter(s=>s.category===e)}calculateKPIProgress(e){return e.targetValue===0?100:Math.min(100,e.currentValue/e.targetValue*100)}addGoal(e){const s=this.generateId(),n={...e,id:s};return this.goals.set(s,n),n}updateGoal(e,s){const n=this.goals.get(e);n&&this.goals.set(e,{...n,...s,id:e})}completeGoalMilestone(e,s){const n=this.goals.get(e);if(n){const r=n.milestones.find(i=>i.id===s);r&&(r.completed=!0,r.completedDate=new Date,n.progress=this.calculateGoalProgress(n),this.goals.set(e,n))}}calculateGoalProgress(e){if(e.milestones.length===0)return e.progress;const s=e.milestones.filter(n=>n.completed).length;return Math.round(s/e.milestones.length*100)}getAllGoals(){return Array.from(this.goals.values())}getActiveGoals(){return this.getAllGoals().filter(e=>e.status==="in-progress")}getGoalsByCategory(e){return this.getAllGoals().filter(s=>s.category===e)}getUpcomingDeadlines(e=30){const s=new Date,n=new Date(s.getTime()+e*24*60*60*1e3);return this.getActiveGoals().filter(r=>r.targetDate<=n).sort((r,i)=>r.targetDate.getTime()-i.targetDate.getTime())}addHabit(e){const s=this.generateId(),n={...e,id:s,streak:0,longestStreak:0,completions:[],createdAt:new Date};return this.habits.set(s,n),n}completeHabit(e,s=1,n){const r=this.habits.get(e);if(r){const i=new Date;i.setHours(0,0,0,0);const a=r.completions.find(l=>new Date(l.date).toDateString()===i.toDateString());a?(a.count+=s,n&&(a.note=n)):r.completions.push({date:i,count:s,note:n}),this.updateStreak(r),this.habits.set(e,r)}}updateStreak(e){const s=[...e.completions].sort((i,a)=>new Date(a.date).getTime()-new Date(i.date).getTime());if(s.length===0){e.streak=0;return}let n=0;const r=new Date;r.setHours(0,0,0,0);for(let i=0;i<s.length;i++){const a=new Date(s[i].date);a.setHours(0,0,0,0);const l=new Date(r.getTime()-i*24*60*60*1e3);if(a.getTime()===l.getTime())if(s[i].count>=e.targetPerPeriod)n++;else break;else break}e.streak=n,n>e.longestStreak&&(e.longestStreak=n)}getAllHabits(){return Array.from(this.habits.values())}getHabitCompletionRate(e,s=30){const n=this.habits.get(e);if(!n)return 0;const r=new Date,i=new Date(r.getTime()-s*24*60*60*1e3),a=n.completions.filter(l=>new Date(l.date)>=i&&l.count>=n.targetPerPeriod);return Math.round(a.length/s*100)}getTodayHabitStatus(){const e=new Date().toDateString();return this.getAllHabits().map(s=>{const n=s.completions.find(r=>new Date(r.date).toDateString()===e);return{habit:s,completed:n?n.count>=s.targetPerPeriod:!1,count:(n==null?void 0:n.count)??0}})}addMoodEntry(e){const s=this.generateId(),n={...e,id:s};return this.moodEntries.set(s,n),n}getAllMoodEntries(){return Array.from(this.moodEntries.values()).sort((e,s)=>new Date(s.date).getTime()-new Date(e.date).getTime())}getMoodEntriesForPeriod(e,s){return this.getAllMoodEntries().filter(n=>new Date(n.date)>=e&&new Date(n.date)<=s)}getAverageMood(e=7){const s=new Date,n=new Date(s.getTime()-e*24*60*60*1e3),r=this.getMoodEntriesForPeriod(n,s);return r.length===0?0:r.reduce((i,a)=>i+a.mood,0)/r.length}getAverageSleep(e=7){const s=new Date,n=new Date(s.getTime()-e*24*60*60*1e3),r=this.getMoodEntriesForPeriod(n,s);return r.length===0?0:r.reduce((i,a)=>i+a.sleep,0)/r.length}getMoodCorrelations(){const e=this.getAllMoodEntries();if(e.length<5)return[];const s=[],n=this.calculateCorrelation(e.map(i=>i.sleep),e.map(i=>i.mood));s.push({factor:"Sleep",correlation:n});const r=this.calculateCorrelation(e.map(i=>i.stress),e.map(i=>i.mood));return s.push({factor:"Stress",correlation:r}),s.sort((i,a)=>Math.abs(a.correlation)-Math.abs(i.correlation))}calculateCorrelation(e,s){const n=e.length;if(n===0)return 0;const r=e.reduce((h,m)=>h+m,0),i=s.reduce((h,m)=>h+m,0),a=e.reduce((h,m,p)=>h+m*s[p],0),l=e.reduce((h,m)=>h+m*m,0),d=s.reduce((h,m)=>h+m*m,0),u=n*a-r*i,c=Math.sqrt((n*l-r**2)*(n*d-i**2));return c===0?0:u/c}setFinanceSummary(e){this.financeSummary=e}getFinanceSummary(){return{...this.financeSummary}}calculateFinanceHealth(){const e=[],s=Math.min(100,this.financeSummary.savingsRate/20*100);e.push({name:"Savings Rate",score:s});const n=this.financeSummary.budgetTotal>0?Math.min(100,(1-this.financeSummary.budgetUsed/this.financeSummary.budgetTotal)*100+50):50;e.push({name:"Budget Adherence",score:n});const r=this.financeSummary.monthlyIncome>0?this.financeSummary.debts/(this.financeSummary.monthlyIncome*12):0,i=Math.max(0,100-r*100);e.push({name:"Debt Management",score:i});const a=this.financeSummary.monthlyExpenses>0?this.financeSummary.savings/this.financeSummary.monthlyExpenses:0,l=Math.min(100,a/6*100);e.push({name:"Emergency Fund",score:l});const d=e.reduce((u,c)=>u+c.score,0)/e.length;return{score:Math.round(d),factors:e}}generateDailyInsights(){const e=[],s=this.getAllKPIs(),n=s.filter(u=>u.currentValue>=u.targetValue);n.length>0&&e.push(`You've achieved ${n.length} of ${s.length} KPI targets!`);const r=this.getTodayHabitStatus(),i=r.filter(u=>u.completed);i.length===r.length&&r.length>0?e.push("All habits completed today! Keep it up!"):i.length>0&&e.push(`${i.length}/${r.length} habits completed today.`);const a=this.getAllHabits().reduce((u,c)=>Math.max(u,c.streak),0);a>=7&&e.push(`Amazing ${a}-day streak! You're building a strong routine.`);const l=this.getUpcomingDeadlines(7);l.length>0&&e.push(`${l.length} goal deadline(s) coming up this week.`);const d=this.getAverageMood(7);return d>=4?e.push("Your mood has been great this week!"):d<3&&d>0&&e.push("Your mood has been lower than usual. Consider some self-care activities."),e}generateId(){return Date.now().toString(36)+Math.random().toString(36).substring(2,8)}clear(){this.kpis.clear(),this.goals.clear(),this.habits.clear(),this.moodEntries.clear()}}function Ae(){return new O}const G=f.createContext(null);function Be(){const o=f.useContext(G);if(!o)throw new Error("useLifeDashboard must be used within LifeDashboardProvider");return o}const v={dashboard:{display:"flex",flexDirection:"column",height:"100%",fontFamily:"'Inter', sans-serif",backgroundColor:"#f5f7fa",padding:"20px",gap:"20px",overflow:"auto"},header:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px"},title:{fontSize:"24px",fontWeight:600,color:"#1a1a2e"},grid:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(300px, 1fr))",gap:"20px"},card:{backgroundColor:"#fff",borderRadius:"12px",padding:"20px",boxShadow:"0 2px 8px rgba(0,0,0,0.08)"},cardTitle:{fontSize:"16px",fontWeight:600,color:"#1a1a2e",marginBottom:"16px"},progressBar:{height:"8px",backgroundColor:"#e0e0e0",borderRadius:"4px",overflow:"hidden"},progressFill:{height:"100%",borderRadius:"4px",transition:"width 0.3s ease"},statRow:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"8px 0",borderBottom:"1px solid #f0f0f0"},habitItem:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 0",borderBottom:"1px solid #f0f0f0"},habitCheck:{width:"24px",height:"24px",borderRadius:"50%",border:"2px solid #1976d2",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},moodEmoji:{fontSize:"28px",textAlign:"center"},insight:{backgroundColor:"#e3f2fd",borderRadius:"8px",padding:"12px 16px",marginBottom:"8px",fontSize:"14px",color:"#1565c0"}};function Me({service:o,className:e,style:s}){const[,n]=f.useState(0),r=f.useCallback(()=>{n(p=>p+1)},[]),i={service:o,refresh:r},a=o.generateDailyInsights(),l=o.getAllKPIs(),d=o.getTodayHabitStatus(),u=o.getActiveGoals(),c=o.getFinanceSummary(),h=o.calculateFinanceHealth(),m=p=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(p);return t.jsx(G.Provider,{value:i,children:t.jsxs("div",{className:e,style:{...v.dashboard,...s},children:[t.jsxs("div",{style:v.header,children:[t.jsx("div",{style:v.title,children:"Life Dashboard"}),t.jsx("div",{style:{color:"#666"},children:new Date().toLocaleDateString("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric"})})]}),a.length>0&&t.jsx("div",{children:a.map((p,b)=>t.jsx("div",{style:v.insight,children:p},b))}),t.jsxs("div",{style:v.grid,children:[t.jsxs("div",{style:v.card,children:[t.jsx("div",{style:v.cardTitle,children:"Personal KPIs"}),l.length===0?t.jsx("div",{style:{color:"#999",textAlign:"center",padding:"20px"},children:"No KPIs defined yet"}):l.slice(0,5).map(p=>{const b=o.calculateKPIProgress(p);return t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"4px"},children:[t.jsx("span",{style:{fontWeight:500},children:p.name}),t.jsxs("span",{style:{color:"#666"},children:[p.currentValue,p.unit?` ${p.unit}`:""," / ",p.targetValue,p.trend==="up"&&" โ†‘",p.trend==="down"&&" โ†“"]})]}),t.jsx("div",{style:v.progressBar,children:t.jsx("div",{style:{...v.progressFill,width:`${b}%`,backgroundColor:b>=100?"#4caf50":"#1976d2"}})})]},p.id)})]}),t.jsxs("div",{style:v.card,children:[t.jsx("div",{style:v.cardTitle,children:"Active Goals"}),u.length===0?t.jsx("div",{style:{color:"#999",textAlign:"center",padding:"20px"},children:"No active goals"}):u.slice(0,4).map(p=>t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"4px"},children:[t.jsx("span",{style:{fontWeight:500},children:p.title}),t.jsxs("span",{style:{color:"#666"},children:[p.progress,"%"]})]}),t.jsx("div",{style:v.progressBar,children:t.jsx("div",{style:{...v.progressFill,width:`${p.progress}%`,backgroundColor:"#ff9800"}})}),t.jsxs("div",{style:{fontSize:"12px",color:"#999",marginTop:"4px"},children:["Due: ",new Date(p.targetDate).toLocaleDateString()]})]},p.id))]}),t.jsxs("div",{style:v.card,children:[t.jsx("div",{style:v.cardTitle,children:"Today's Habits"}),d.length===0?t.jsx("div",{style:{color:"#999",textAlign:"center",padding:"20px"},children:"No habits tracked yet"}):d.map(({habit:p,completed:b,count:k})=>t.jsxs("div",{style:v.habitItem,children:[t.jsx("div",{style:{...v.habitCheck,backgroundColor:b?"#4caf50":"transparent",borderColor:b?"#4caf50":"#ccc"},onClick:()=>{o.completeHabit(p.id),r()},children:b&&t.jsx("span",{style:{color:"#fff"},children:"โœ“"})}),t.jsxs("div",{style:{flex:1},children:[t.jsx("div",{style:{fontWeight:500},children:p.name}),t.jsxs("div",{style:{fontSize:"12px",color:"#666"},children:[k,"/",p.targetPerPeriod," โ€ข ",p.streak," day streak"]})]})]},p.id))]}),t.jsxs("div",{style:v.card,children:[t.jsx("div",{style:v.cardTitle,children:"Finance Overview"}),t.jsxs("div",{style:v.statRow,children:[t.jsx("span",{children:"Net Worth"}),t.jsx("span",{style:{fontWeight:600},children:m(c.netWorth)})]}),t.jsxs("div",{style:v.statRow,children:[t.jsx("span",{children:"Monthly Income"}),t.jsx("span",{style:{color:"#4caf50"},children:m(c.monthlyIncome)})]}),t.jsxs("div",{style:v.statRow,children:[t.jsx("span",{children:"Monthly Expenses"}),t.jsx("span",{style:{color:"#f44336"},children:m(c.monthlyExpenses)})]}),t.jsxs("div",{style:v.statRow,children:[t.jsx("span",{children:"Savings Rate"}),t.jsxs("span",{children:[c.savingsRate.toFixed(1),"%"]})]}),t.jsxs("div",{style:{marginTop:"16px"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"8px"},children:[t.jsx("span",{children:"Finance Health"}),t.jsxs("span",{style:{fontWeight:600},children:[h.score,"/100"]})]}),t.jsx("div",{style:v.progressBar,children:t.jsx("div",{style:{...v.progressFill,width:`${h.score}%`,backgroundColor:h.score>=70?"#4caf50":h.score>=40?"#ff9800":"#f44336"}})})]})]}),t.jsxs("div",{style:v.card,children:[t.jsx("div",{style:v.cardTitle,children:"Mood & Health"}),t.jsxs("div",{style:{display:"flex",justifyContent:"space-around",marginBottom:"20px"},children:[t.jsxs("div",{style:{textAlign:"center"},children:[t.jsx("div",{style:v.moodEmoji,children:Re(Math.round(o.getAverageMood(7)))}),t.jsx("div",{style:{fontSize:"12px",color:"#666"},children:"Avg Mood (7d)"})]}),t.jsxs("div",{style:{textAlign:"center"},children:[t.jsxs("div",{style:{fontSize:"28px",fontWeight:600},children:[o.getAverageSleep(7).toFixed(1),"h"]}),t.jsx("div",{style:{fontSize:"12px",color:"#666"},children:"Avg Sleep (7d)"})]})]}),o.getMoodCorrelations().slice(0,2).map(p=>t.jsxs("div",{style:v.statRow,children:[t.jsx("span",{children:p.factor}),t.jsxs("span",{style:{color:p.correlation>0?"#4caf50":"#f44336"},children:[p.correlation>0?"โ†‘":"โ†“"," ",Math.abs(p.correlation*100).toFixed(0),"%"]})]},p.factor))]})]})]})})}function Re(o){return{1:"๐Ÿ˜ข",2:"๐Ÿ˜•",3:"๐Ÿ˜",4:"๐Ÿ˜Š",5:"๐Ÿ˜„"}[o]||"๐Ÿ˜"}const Pe={colors:{background:"#1a1a2e",surface:"#16213e",primary:"#0f3460",secondary:"#e94560",success:"#00c853",warning:"#ffab00",error:"#ff1744",text:"#ffffff",textSecondary:"#a0a0a0",border:"#2a2a4a"},spacing:{xs:"4px",sm:"8px",md:"16px",lg:"24px",xl:"32px"},borderRadius:"8px",fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"},ze=[{id:"name",label:"Name",sortable:!0,visible:!0},{id:"size",label:"Size",width:"100px",sortable:!0,visible:!0},{id:"progress",label:"Progress",width:"150px",sortable:!0,visible:!0},{id:"status",label:"Status",width:"100px",sortable:!0,visible:!0},{id:"seeds",label:"Seeds",width:"80px",sortable:!0,visible:!0},{id:"peers",label:"Peers",width:"80px",sortable:!0,visible:!0},{id:"downloadSpeed",label:"Down",width:"100px",sortable:!0,visible:!0},{id:"uploadSpeed",label:"Up",width:"100px",sortable:!0,visible:!0},{id:"eta",label:"ETA",width:"100px",sortable:!0,visible:!0},{id:"ratio",label:"Ratio",width:"80px",sortable:!0,visible:!0}],q=f.createContext(null);function T(){const o=f.useContext(q);if(!o)throw new Error("useTorrentUI must be used within TorrentUIProvider");return o}function B(o,e=2){if(o===0)return"0 B";const s=1024,n=["B","KB","MB","GB","TB","PB"],r=Math.floor(Math.log(o)/Math.log(s));return`${parseFloat((o/Math.pow(s,r)).toFixed(e))} ${n[r]}`}function R(o){return`${B(o)}/s`}function K(o){if(!o||o<=0)return"โˆž";if(o<60)return`${o}s`;if(o<3600)return`${Math.floor(o/60)}m`;if(o<86400){const n=Math.floor(o/3600),r=Math.floor(o%3600/60);return`${n}h ${r}m`}const e=Math.floor(o/86400),s=Math.floor(o%86400/3600);return`${e}d ${s}h`}function P(o){return o.toFixed(2)}function z(o,e){switch(o){case"downloading":return e.colors.primary;case"seeding":return e.colors.success;case"paused":return e.colors.textSecondary;case"checking":return e.colors.warning;case"error":return e.colors.error;case"queued":return e.colors.textSecondary;default:return e.colors.text}}function Q({client:o,config:e={},children:s}){const n=f.useMemo(()=>({...Pe,...e.theme}),[e.theme]),[r,i]=f.useState([]),[a,l]=f.useState(null),[d,u]=f.useState("all"),[c,h]=f.useState(""),m=f.useCallback(()=>{i(o.getAllTorrents())},[o]);f.useEffect(()=>{m();const b=setInterval(m,e.refreshInterval||1e3),k=()=>m(),A=()=>m();return o.on("torrent_added",k),o.on("torrent_removed",A),()=>{clearInterval(b),o.off("torrent_added",k),o.off("torrent_removed",A)}},[o,e.refreshInterval,m]);const p={client:o,config:e,theme:n,torrents:r,selectedTorrent:a,setSelectedTorrent:l,filter:d,setFilter:u,searchQuery:c,setSearchQuery:h,refresh:m};return t.jsx(q.Provider,{value:p,children:t.jsx("div",{style:{fontFamily:n.fontFamily,color:n.colors.text},children:s})})}function Y({progress:o,status:e,showLabel:s=!0,height:n="20px",className:r,style:i}){const{theme:a}=T(),l=Math.min(100,Math.max(0,o*100)),d=z(e,a);return t.jsxs("div",{className:r,style:{display:"flex",alignItems:"center",gap:a.spacing.sm,...i},children:[t.jsx("div",{style:{flex:1,height:n,backgroundColor:a.colors.border,borderRadius:a.borderRadius,overflow:"hidden"},children:t.jsx("div",{style:{width:`${l}%`,height:"100%",backgroundColor:d,transition:"width 0.3s ease-in-out"}})}),s&&t.jsxs("span",{style:{fontSize:"12px",minWidth:"45px",textAlign:"right"},children:[l.toFixed(1),"%"]})]})}function _({status:o,className:e,style:s}){const{theme:n}=T(),r=z(o,n),i={downloading:"Downloading",seeding:"Seeding",paused:"Paused",checking:"Checking",error:"Error",queued:"Queued"};return t.jsxs("span",{className:e,style:{display:"inline-flex",alignItems:"center",gap:n.spacing.xs,padding:`${n.spacing.xs} ${n.spacing.sm}`,backgroundColor:`${r}20`,color:r,borderRadius:n.borderRadius,fontSize:"12px",fontWeight:500,textTransform:"capitalize",...s},children:[t.jsx("span",{style:{width:"8px",height:"8px",borderRadius:"50%",backgroundColor:r}}),i[o]]})}function X({onTorrentSelect:o,onTorrentDoubleClick:e,className:s,style:n}){const{theme:r,torrents:i,filter:a,searchQuery:l,selectedTorrent:d,setSelectedTorrent:u,config:c}=T(),[h,m]=f.useState(c.defaultSortBy||"name"),[p,b]=f.useState(c.defaultSortOrder||"asc"),k=c.columns||ze,A=f.useMemo(()=>i.filter(y=>{if(a!=="all"){if(a==="completed"){if(y.stats.progress<1)return!1}else if(a==="active"){if(y.status!=="downloading"&&y.status!=="seeding")return!1}else if(y.status!==a)return!1}if(l){const D=l.toLowerCase();if(!y.metadata.name.toLowerCase().includes(D))return!1}return!0}),[i,a,l]),S=f.useMemo(()=>[...A].sort((y,D)=>{let C,I;switch(h){case"name":C=y.metadata.name.toLowerCase(),I=D.metadata.name.toLowerCase();break;case"size":C=y.metadata.size,I=D.metadata.size;break;case"progress":C=y.stats.progress,I=D.stats.progress;break;case"status":C=y.status,I=D.status;break;case"downloadSpeed":C=y.stats.downloadSpeed,I=D.stats.downloadSpeed;break;case"uploadSpeed":C=y.stats.uploadSpeed,I=D.stats.uploadSpeed;break;case"ratio":C=y.stats.ratio,I=D.stats.ratio;break;default:C=y.metadata.name,I=D.metadata.name}return C<I?p==="asc"?-1:1:C>I?p==="asc"?1:-1:0}),[A,h,p]),M=y=>{h===y?b(p==="asc"?"desc":"asc"):(m(y),b("asc"))},te=y=>{u(y),o==null||o(y)};return t.jsxs("div",{className:s,style:{backgroundColor:r.colors.surface,borderRadius:r.borderRadius,overflow:"hidden",...n},children:[t.jsx("div",{style:{display:"grid",gridTemplateColumns:k.filter(y=>y.visible!==!1).map(y=>y.width||"1fr").join(" "),padding:`${r.spacing.sm} ${r.spacing.md}`,backgroundColor:r.colors.primary,borderBottom:`1px solid ${r.colors.border}`,fontSize:"12px",fontWeight:600,textTransform:"uppercase"},children:k.filter(y=>y.visible!==!1).map(y=>t.jsxs("div",{onClick:()=>y.sortable&&M(y.id),style:{cursor:y.sortable?"pointer":"default",display:"flex",alignItems:"center",gap:r.spacing.xs},children:[y.label,h===y.id&&t.jsx("span",{children:p==="asc"?"โ†‘":"โ†“"})]},y.id))}),t.jsx("div",{style:{maxHeight:"500px",overflowY:"auto"},children:S.length===0?t.jsx("div",{style:{padding:r.spacing.xl,textAlign:"center",color:r.colors.textSecondary},children:"No torrents found"}):S.map(y=>t.jsx(Fe,{torrent:y,columns:k,isSelected:d===y.metadata.infoHash,onClick:()=>te(y.metadata.infoHash),onDoubleClick:()=>e==null?void 0:e(y.metadata.infoHash)},y.metadata.infoHash))})]})}function Fe({torrent:o,columns:e,isSelected:s,onClick:n,onDoubleClick:r}){const{theme:i}=T(),{metadata:a,stats:l,status:d}=o,u=c=>{switch(c){case"name":return t.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[t.jsx("span",{style:{fontWeight:500},children:a.name}),t.jsxs("span",{style:{fontSize:"11px",color:i.colors.textSecondary},children:[a.infoHash.substring(0,8),"..."]})]});case"size":return B(a.size);case"progress":return t.jsx(Y,{progress:l.progress,status:d,height:"16px"});case"status":return t.jsx(_,{status:d});case"seeds":return l.seeds;case"peers":return l.peers;case"downloadSpeed":return l.downloadSpeed>0?R(l.downloadSpeed):"-";case"uploadSpeed":return l.uploadSpeed>0?R(l.uploadSpeed):"-";case"eta":return d==="downloading"?K(l.eta):"-";case"ratio":return P(l.ratio);default:return"-"}};return t.jsx("div",{onClick:n,onDoubleClick:r,style:{display:"grid",gridTemplateColumns:e.filter(c=>c.visible!==!1).map(c=>c.width||"1fr").join(" "),padding:`${i.spacing.sm} ${i.spacing.md}`,backgroundColor:s?i.colors.primary:"transparent",borderBottom:`1px solid ${i.colors.border}`,cursor:"pointer",transition:"background-color 0.15s",fontSize:"13px"},children:e.filter(c=>c.visible!==!1).map(c=>t.jsx("div",{style:{display:"flex",alignItems:"center",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u(c.id)},c.id))})}function J({className:o,style:e}){const{theme:s,filter:n,setFilter:r,searchQuery:i,setSearchQuery:a,torrents:l}=T(),d=f.useMemo(()=>{const c={all:l.length,downloading:0,seeding:0,paused:0,checking:0,error:0,completed:0,active:0};for(const h of l)h.status==="downloading"&&c.downloading++,h.status==="seeding"&&c.seeding++,h.status==="paused"&&c.paused++,h.status==="checking"&&c.checking++,h.status==="error"&&c.error++,h.stats.progress>=1&&c.completed++,(h.status==="downloading"||h.status==="seeding")&&c.active++;return c},[l]),u=[{id:"all",label:"All"},{id:"downloading",label:"Downloading"},{id:"seeding",label:"Seeding"},{id:"completed",label:"Completed"},{id:"active",label:"Active"},{id:"paused",label:"Paused"},{id:"error",label:"Error"}];return t.jsxs("div",{className:o,style:{display:"flex",alignItems:"center",gap:s.spacing.md,padding:s.spacing.md,backgroundColor:s.colors.surface,borderRadius:s.borderRadius,...e},children:[t.jsx("div",{style:{display:"flex",gap:s.spacing.xs},children:u.map(c=>t.jsxs("button",{onClick:()=>r(c.id),style:{padding:`${s.spacing.xs} ${s.spacing.sm}`,backgroundColor:n===c.id?s.colors.primary:"transparent",color:n===c.id?s.colors.text:s.colors.textSecondary,border:"none",borderRadius:s.borderRadius,cursor:"pointer",fontSize:"13px",transition:"all 0.15s"},children:[c.label," (",d[c.id],")"]},c.id))}),t.jsx("div",{style:{flex:1}}),t.jsx("input",{type:"text",placeholder:"Search torrents...",value:i,onChange:c=>a(c.target.value),style:{padding:`${s.spacing.sm} ${s.spacing.md}`,backgroundColor:s.colors.background,color:s.colors.text,border:`1px solid ${s.colors.border}`,borderRadius:s.borderRadius,outline:"none",fontSize:"13px",width:"250px"}})]})}function Z({infoHash:o,className:e,style:s}){const{theme:n,client:r}=T(),[i,a]=f.useState("files"),l=r==null?void 0:r.getTorrent(o);if(!l)return null;const{metadata:d,stats:u,files:c,peers:h,trackers:m}=l,p=[{id:"files",label:`Files (${c.length})`},{id:"peers",label:`Peers (${h.length})`},{id:"trackers",label:`Trackers (${m.length})`},{id:"info",label:"Info"}];return t.jsxs("div",{className:e,style:{backgroundColor:n.colors.surface,borderRadius:n.borderRadius,overflow:"hidden",...s},children:[t.jsx("div",{style:{display:"flex",borderBottom:`1px solid ${n.colors.border}`},children:p.map(b=>t.jsx("button",{onClick:()=>a(b.id),style:{padding:`${n.spacing.sm} ${n.spacing.md}`,backgroundColor:i===b.id?n.colors.primary:"transparent",color:i===b.id?n.colors.text:n.colors.textSecondary,border:"none",cursor:"pointer",fontSize:"13px",fontWeight:500},children:b.label},b.id))}),t.jsxs("div",{style:{padding:n.spacing.md,maxHeight:"300px",overflowY:"auto"},children:[i==="files"&&t.jsx(We,{files:c}),i==="peers"&&t.jsx(Le,{peers:h}),i==="trackers"&&t.jsx(Ue,{trackers:m}),i==="info"&&t.jsx(Ne,{metadata:d,stats:u,addedAt:l.addedAt})]})]})}function We({files:o}){const{theme:e}=T();return t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:e.spacing.xs},children:o.map((s,n)=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:e.spacing.md,padding:e.spacing.sm,backgroundColor:e.colors.background,borderRadius:e.borderRadius,fontSize:"13px"},children:[t.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis"},children:s.path}),t.jsx("span",{style:{color:e.colors.textSecondary},children:B(s.size)}),t.jsxs("span",{style:{width:"50px",textAlign:"right"},children:[(s.progress*100).toFixed(0),"%"]})]},n))})}function Le({peers:o}){const{theme:e}=T();return t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:e.spacing.xs},children:o.length===0?t.jsx("div",{style:{color:e.colors.textSecondary},children:"No peers connected"}):o.map(s=>t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 80px 100px 100px 80px",alignItems:"center",padding:e.spacing.sm,backgroundColor:e.colors.background,borderRadius:e.borderRadius,fontSize:"12px"},children:[t.jsxs("span",{children:[s.ip,":",s.port,s.isUTP&&t.jsx("span",{style:{marginLeft:"4px",color:e.colors.secondary},children:"ยตTP"}),s.isEncrypted&&t.jsx("span",{style:{marginLeft:"4px"},children:"๐Ÿ”’"})]}),t.jsx("span",{style:{color:e.colors.textSecondary},children:s.client||"Unknown"}),t.jsxs("span",{style:{color:e.colors.success},children:["โ†“ ",R(s.downloadSpeed)]}),t.jsxs("span",{style:{color:e.colors.warning},children:["โ†‘ ",R(s.uploadSpeed)]}),t.jsxs("span",{children:[(s.progress*100).toFixed(0),"%"]})]},s.id))})}function Ue({trackers:o}){const{theme:e}=T();return t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:e.spacing.xs},children:o.map((s,n)=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:e.spacing.md,padding:e.spacing.sm,backgroundColor:e.colors.background,borderRadius:e.borderRadius,fontSize:"12px"},children:[t.jsx("span",{style:{width:"8px",height:"8px",borderRadius:"50%",backgroundColor:s.status==="working"?e.colors.success:s.status==="error"?e.colors.error:e.colors.textSecondary}}),t.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis"},children:s.url}),t.jsxs("span",{style:{color:e.colors.textSecondary},children:["S: ",s.seeds," | L: ",s.leechers]})]},n))})}function Ne({metadata:o,stats:e,addedAt:s}){const{theme:n}=T(),r=[{label:"Name",value:o.name},{label:"Info Hash",value:o.infoHash},{label:"Size",value:B(o.size)},{label:"Pieces",value:`${e.piecesComplete} / ${e.piecesTotal}`},{label:"Downloads",value:B(e.downloaded)},{label:"Uploaded",value:B(e.uploaded)},{label:"Ratio",value:P(e.ratio)},{label:"Availability",value:e.availability.toFixed(2)},{label:"Wasted",value:B(e.wastedBytes)},{label:"Hash Fails",value:e.hashFailures},{label:"Added",value:s.toLocaleString()},{label:"Comment",value:o.comment||"-"},{label:"Private",value:o.isPrivate?"Yes":"No"}];return t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:n.spacing.xs},children:r.map(i=>t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",padding:`${n.spacing.xs} ${n.spacing.sm}`,fontSize:"13px"},children:[t.jsx("span",{style:{color:n.colors.textSecondary},children:i.label}),t.jsx("span",{style:{fontFamily:"monospace"},children:i.value})]},i.label))})}function ee({isOpen:o,onClose:e,onAdd:s,className:n}){const{theme:r,config:i,client:a}=T(),[l,d]=f.useState(""),[u,c]=f.useState(""),[h,m]=f.useState(!1);if(!o)return null;const p=b=>{b.preventDefault(),l.trim()&&(s(l.trim(),{path:u||void 0,paused:h}),d(""),c(""),m(!1),e())};return t.jsx("div",{className:n,style:{position:"fixed",inset:0,backgroundColor:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},onClick:e,children:t.jsxs("div",{style:{backgroundColor:r.colors.surface,borderRadius:r.borderRadius,padding:r.spacing.lg,width:"500px",maxWidth:"90vw"},onClick:b=>b.stopPropagation(),children:[t.jsx("h2",{style:{margin:0,marginBottom:r.spacing.md},children:"Add Torrent"}),t.jsxs("form",{onSubmit:p,style:{display:"flex",flexDirection:"column",gap:r.spacing.md},children:[t.jsxs("div",{children:[t.jsx("label",{style:{display:"block",marginBottom:r.spacing.xs,fontSize:"13px"},children:"Magnet URI or .torrent file path"}),t.jsx("input",{type:"text",value:l,onChange:b=>d(b.target.value),placeholder:"magnet:?xt=urn:btih:... or C:\\path\\to\\file.torrent",style:{width:"100%",padding:r.spacing.sm,backgroundColor:r.colors.background,color:r.colors.text,border:`1px solid ${r.colors.border}`,borderRadius:r.borderRadius,outline:"none",fontSize:"13px"}})]}),t.jsxs("div",{children:[t.jsx("label",{style:{display:"block",marginBottom:r.spacing.xs,fontSize:"13px"},children:"Save Location"}),t.jsx("input",{type:"text",value:u,onChange:b=>c(b.target.value),placeholder:"Leave empty for default",style:{width:"100%",padding:r.spacing.sm,backgroundColor:r.colors.background,color:r.colors.text,border:`1px solid ${r.colors.border}`,borderRadius:r.borderRadius,outline:"none",fontSize:"13px"}})]}),t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:r.spacing.sm,fontSize:"13px"},children:[t.jsx("input",{type:"checkbox",checked:h,onChange:b=>m(b.target.checked)}),"Start paused"]}),t.jsxs("div",{style:{display:"flex",gap:r.spacing.sm,justifyContent:"flex-end"},children:[t.jsx("button",{type:"button",onClick:e,style:{padding:`${r.spacing.sm} ${r.spacing.md}`,backgroundColor:"transparent",color:r.colors.text,border:`1px solid ${r.colors.border}`,borderRadius:r.borderRadius,cursor:"pointer"},children:"Cancel"}),t.jsx("button",{type:"submit",style:{padding:`${r.spacing.sm} ${r.spacing.md}`,backgroundColor:r.colors.primary,color:r.colors.text,border:"none",borderRadius:r.borderRadius,cursor:"pointer"},children:"Add Torrent"})]})]})]})})}function He({client:o,config:e,className:s,style:n}){const[r,i]=f.useState(!1),[a,l]=f.useState(null);return t.jsx(Q,{client:o,config:e,children:t.jsxs("div",{className:s,style:{display:"flex",flexDirection:"column",gap:"16px",height:"100%",...n},children:[t.jsx("div",{style:{display:"flex",gap:"8px"},children:t.jsx("button",{onClick:()=>i(!0),style:{padding:"8px 16px",backgroundColor:"#0f3460",color:"white",border:"none",borderRadius:"8px",cursor:"pointer"},children:"+ Add Torrent"})}),t.jsx(J,{}),t.jsx(X,{onTorrentSelect:l,style:{flex:1}}),a&&t.jsx(Z,{infoHash:a}),t.jsx(ee,{isOpen:r,onClose:()=>i(!1),onAdd:(d,u)=>o.addTorrent(d,u)})]})})}exports.AddTorrentDialog=ee;exports.FilterBar=J;exports.HealthService=L;exports.LifeDashboardService=O;exports.NiceHealth=ae;exports.NiceLifeDashboard=Me;exports.NicePersonalFinance=me;exports.NiceTaskManager=De;exports.NiceTorrentUI=He;exports.PersonalFinanceService=N;exports.ProgressBar=Y;exports.StatusBadge=_;exports.TaskManagerService=$;exports.TorrentDetails=Z;exports.TorrentList=X;exports.TorrentUIProvider=Q;exports.createHealthService=ie;exports.createLifeDashboardService=Ae;exports.createPersonalFinanceService=xe;exports.createTaskManagerService=ke;exports.formatBytes=B;exports.formatETA=K;exports.formatRatio=P;exports.formatSpeed=R;exports.getStatusColor=z;exports.useHealth=oe;exports.useLifeDashboard=Be;exports.usePersonalFinance=fe;exports.useTaskManager=Te;exports.useTorrentUI=T;
1
+ "use strict";var se=Object.defineProperty;var ne=(o,e,s)=>e in o?se(o,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):o[e]=s;var j=(o,e,s)=>ne(o,typeof e!="symbol"?e+"":e,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),f=require("react"),re=[{id:"apple",name:"Apple",servingSize:1,servingUnit:"medium",calories:95,protein:.5,carbs:25,fat:.3,fiber:4.4},{id:"banana",name:"Banana",servingSize:1,servingUnit:"medium",calories:105,protein:1.3,carbs:27,fat:.4,fiber:3.1},{id:"chicken-breast",name:"Chicken Breast",servingSize:100,servingUnit:"g",calories:165,protein:31,carbs:0,fat:3.6},{id:"brown-rice",name:"Brown Rice",servingSize:1,servingUnit:"cup",calories:216,protein:5,carbs:45,fat:1.8,fiber:3.5},{id:"egg",name:"Egg",servingSize:1,servingUnit:"large",calories:78,protein:6,carbs:.6,fat:5},{id:"salmon",name:"Salmon",servingSize:100,servingUnit:"g",calories:208,protein:20,carbs:0,fat:13},{id:"broccoli",name:"Broccoli",servingSize:1,servingUnit:"cup",calories:55,protein:3.7,carbs:11,fat:.6,fiber:5.1},{id:"oatmeal",name:"Oatmeal",servingSize:1,servingUnit:"cup",calories:158,protein:6,carbs:27,fat:3.2,fiber:4},{id:"greek-yogurt",name:"Greek Yogurt",servingSize:1,servingUnit:"cup",calories:100,protein:17,carbs:6,fat:.7},{id:"almonds",name:"Almonds",servingSize:1,servingUnit:"oz",calories:164,protein:6,carbs:6,fat:14,fiber:3.5}];class L{constructor(){j(this,"workouts",new Map);j(this,"meals",new Map);j(this,"sleep",new Map);j(this,"medicalRecords",new Map);j(this,"medications",new Map);j(this,"medicationLogs",[]);j(this,"vitals",[]);j(this,"goals",[]);j(this,"foodDatabase",[...re])}addWorkout(e){const s=this.generateId(),n={...e,id:s};return this.workouts.set(s,n),n}updateWorkout(e,s){const n=this.workouts.get(e);n&&this.workouts.set(e,{...n,...s,id:e})}deleteWorkout(e){this.workouts.delete(e)}getAllWorkouts(){return Array.from(this.workouts.values()).sort((e,s)=>new Date(s.date).getTime()-new Date(e.date).getTime())}getWorkoutsForPeriod(e,s){return this.getAllWorkouts().filter(n=>{const r=new Date(n.date);return r>=e&&r<=s})}getWorkoutStats(e=7){const s=new Date(Date.now()-e*864e5),n=this.getWorkoutsForPeriod(s,new Date),r=new Map;for(const i of n)r.set(i.type,(r.get(i.type)||0)+1);return{totalWorkouts:n.length,totalDuration:n.reduce((i,a)=>i+a.duration,0),totalCalories:n.reduce((i,a)=>i+a.caloriesBurned,0),avgDuration:n.length>0?n.reduce((i,a)=>i+a.duration,0)/n.length:0,byType:Array.from(r.entries()).map(([i,a])=>({type:i,count:a}))}}addMeal(e){const s=this.generateId(),n=this.calculateMealTotals(e.foods),r={...e,id:s,...n};return this.meals.set(s,r),r}calculateMealTotals(e){return e.reduce((s,{item:n,servings:r})=>({totalCalories:s.totalCalories+n.calories*r,totalProtein:s.totalProtein+n.protein*r,totalCarbs:s.totalCarbs+n.carbs*r,totalFat:s.totalFat+n.fat*r}),{totalCalories:0,totalProtein:0,totalCarbs:0,totalFat:0})}deleteMeal(e){this.meals.delete(e)}getAllMeals(){return Array.from(this.meals.values()).sort((e,s)=>new Date(s.date).getTime()-new Date(e.date).getTime())}getMealsForDate(e){const s=new Date(e);s.setHours(0,0,0,0);const n=new Date(s.getTime()+864e5);return this.getAllMeals().filter(r=>{const i=new Date(r.date);return i>=s&&i<n})}getDailyNutrition(e){const s=this.getMealsForDate(e);return{calories:s.reduce((n,r)=>n+r.totalCalories,0),protein:s.reduce((n,r)=>n+r.totalProtein,0),carbs:s.reduce((n,r)=>n+r.totalCarbs,0),fat:s.reduce((n,r)=>n+r.totalFat,0),meals:s.length}}searchFoods(e){const s=e.toLowerCase();return this.foodDatabase.filter(n=>n.name.toLowerCase().includes(s))}addCustomFood(e){const s=this.generateId(),n={...e,id:s};return this.foodDatabase.push(n),n}addSleepEntry(e){const s=this.generateId(),n=(new Date(e.wakeTime).getTime()-new Date(e.bedtime).getTime())/36e5,r={...e,id:s,duration:n};return this.sleep.set(s,r),r}updateSleepEntry(e,s){const n=this.sleep.get(e);if(n){let r=n.duration;if(s.bedtime||s.wakeTime){const i=s.bedtime||n.bedtime,a=s.wakeTime||n.wakeTime;r=(new Date(a).getTime()-new Date(i).getTime())/36e5}this.sleep.set(e,{...n,...s,id:e,duration:r})}}deleteSleepEntry(e){this.sleep.delete(e)}getAllSleepEntries(){return Array.from(this.sleep.values()).sort((e,s)=>new Date(s.date).getTime()-new Date(e.date).getTime())}getSleepStats(e=7){const s=new Date(Date.now()-e*864e5),n=this.getAllSleepEntries().filter(a=>new Date(a.date)>=s),r={poor:1,fair:2,good:3,excellent:4},i=new Map;for(const a of n)i.set(a.quality,(i.get(a.quality)||0)+1);return{avgDuration:n.length>0?n.reduce((a,l)=>a+l.duration,0)/n.length:0,avgQuality:n.length>0?n.reduce((a,l)=>a+r[l.quality],0)/n.length:0,totalEntries:n.length,qualityDistribution:Array.from(i.entries()).map(([a,l])=>({quality:a,count:l}))}}addMedicalRecord(e){const s=this.generateId(),n={...e,id:s};return this.medicalRecords.set(s,n),n}updateMedicalRecord(e,s){const n=this.medicalRecords.get(e);n&&this.medicalRecords.set(e,{...n,...s,id:e})}deleteMedicalRecord(e){this.medicalRecords.delete(e)}getAllMedicalRecords(){return Array.from(this.medicalRecords.values()).sort((e,s)=>new Date(s.date).getTime()-new Date(e.date).getTime())}getMedicalRecordsByType(e){return this.getAllMedicalRecords().filter(s=>s.type===e)}getUpcomingFollowUps(e=30){const s=new Date,n=new Date(s.getTime()+e*864e5);return this.getAllMedicalRecords().filter(r=>r.followUp&&new Date(r.followUp)>=s&&new Date(r.followUp)<=n)}addMedication(e){const s=this.generateId(),n={...e,id:s};return this.medications.set(s,n),n}updateMedication(e,s){const n=this.medications.get(e);n&&this.medications.set(e,{...n,...s,id:e})}deleteMedication(e){this.medications.delete(e),this.medicationLogs=this.medicationLogs.filter(s=>s.medicationId!==e)}getAllMedications(){return Array.from(this.medications.values())}getActiveMedications(){return this.getAllMedications().filter(e=>e.isActive)}logMedication(e,s,n,r){const i={id:this.generateId(),medicationId:e,scheduledTime:s,takenTime:n?new Date:void 0,skipped:!n,notes:r};this.medicationLogs.push(i)}getMedicationLogsForDate(e){const s=new Date(e);s.setHours(0,0,0,0);const n=new Date(s.getTime()+864e5);return this.medicationLogs.filter(r=>{const i=new Date(r.scheduledTime);return i>=s&&i<n})}getTodayMedicationSchedule(){const e=new Date,s=this.getMedicationLogsForDate(e),n=[];for(const r of this.getActiveMedications())for(const i of r.times){const a=s.find(l=>l.medicationId===r.id&&new Date(l.scheduledTime).toTimeString().startsWith(i));n.push({medication:r,time:i,taken:(a==null?void 0:a.takenTime)!==void 0})}return n.sort((r,i)=>r.time.localeCompare(i.time))}recordVitals(e){this.vitals.push(e),this.vitals.sort((s,n)=>new Date(n.date).getTime()-new Date(s.date).getTime())}getVitalsHistory(){return[...this.vitals]}getLatestVitals(){return this.vitals[0]}getWeightHistory(e=30){const s=new Date(Date.now()-e*864e5);return this.vitals.filter(n=>n.weight!==void 0&&new Date(n.date)>=s).map(n=>({date:n.date,weight:n.weight}))}setGoal(e){const s=this.goals.findIndex(n=>n.id===e.id);s>=0?this.goals[s]=e:this.goals.push(e)}getGoals(){return[...this.goals]}updateGoalProgress(e,s){const n=this.goals.find(r=>r.id===e);n&&(n.current=s)}generateId(){return Date.now().toString(36)+Math.random().toString(36).substring(2,8)}clear(){this.workouts.clear(),this.meals.clear(),this.sleep.clear(),this.medicalRecords.clear(),this.medications.clear(),this.medicationLogs=[],this.vitals=[],this.goals=[]}}function ie(){return new L}const U=f.createContext(null);function oe(){const o=f.useContext(U);if(!o)throw new Error("useHealth must be used within HealthProvider");return o}const g={container:{display:"flex",height:"100%",fontFamily:"'Inter', sans-serif",backgroundColor:"#f5f7fa"},sidebar:{width:"200px",backgroundColor:"#fff",borderRight:"1px solid #e0e0e0",padding:"20px 0"},main:{flex:1,padding:"20px",overflow:"auto"},navItem:{padding:"12px 24px",cursor:"pointer",display:"flex",alignItems:"center",gap:"12px",borderLeft:"3px solid transparent"},grid:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(280px, 1fr))",gap:"20px",marginBottom:"20px"},card:{backgroundColor:"#fff",borderRadius:"12px",padding:"20px",boxShadow:"0 2px 8px rgba(0,0,0,0.08)"},cardTitle:{fontSize:"16px",fontWeight:600,marginBottom:"16px",color:"#1a1a2e"},statValue:{fontSize:"32px",fontWeight:700,color:"#1976d2"},statLabel:{fontSize:"12px",color:"#666",textTransform:"uppercase",letterSpacing:"1px"},progressBar:{height:"8px",backgroundColor:"#e0e0e0",borderRadius:"4px",overflow:"hidden"},listItem:{display:"flex",alignItems:"center",gap:"12px",padding:"12px 0",borderBottom:"1px solid #f0f0f0"}};function ae({service:o,className:e,style:s}){const[,n]=f.useState(0),[r,i]=f.useState("overview"),a=f.useCallback(()=>n(u=>u+1),[]),l={service:o,refresh:a},d=[{id:"overview",icon:"๐Ÿ“Š",label:"Overview"},{id:"workouts",icon:"๐Ÿ‹๏ธ",label:"Workouts"},{id:"nutrition",icon:"๐Ÿฅ—",label:"Nutrition"},{id:"sleep",icon:"๐Ÿ˜ด",label:"Sleep"},{id:"medical",icon:"๐Ÿฅ",label:"Medical"},{id:"medications",icon:"๐Ÿ’Š",label:"Medications"}];return t.jsx(U.Provider,{value:l,children:t.jsxs("div",{className:e,style:{...g.container,...s},children:[t.jsx("div",{style:g.sidebar,children:d.map(u=>t.jsxs("div",{onClick:()=>i(u.id),style:{...g.navItem,backgroundColor:r===u.id?"#e3f2fd":"transparent",borderLeftColor:r===u.id?"#1976d2":"transparent",fontWeight:r===u.id?600:400},children:[t.jsx("span",{children:u.icon}),t.jsx("span",{children:u.label})]},u.id))}),t.jsxs("div",{style:g.main,children:[r==="overview"&&t.jsx(le,{service:o}),r==="workouts"&&t.jsx(de,{service:o,refresh:a}),r==="nutrition"&&t.jsx(ce,{service:o}),r==="sleep"&&t.jsx(ue,{service:o}),r==="medical"&&t.jsx(ge,{service:o}),r==="medications"&&t.jsx(he,{service:o,refresh:a})]})]})})}function le({service:o}){const e=o.getWorkoutStats(7),s=o.getSleepStats(7),n=o.getDailyNutrition(new Date),r=o.getLatestVitals(),i=o.getTodayMedicationSchedule();return t.jsxs("div",{children:[t.jsx("h2",{style:{marginBottom:"20px"},children:"Health Overview"}),t.jsxs("div",{style:g.grid,children:[t.jsxs("div",{style:g.card,children:[t.jsx("div",{style:g.cardTitle,children:"This Week's Workouts"}),t.jsx("div",{style:g.statValue,children:e.totalWorkouts}),t.jsx("div",{style:g.statLabel,children:"Workouts"}),t.jsxs("div",{style:{marginTop:"12px",display:"flex",gap:"20px"},children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:"18px",fontWeight:600},children:e.totalDuration}),t.jsx("div",{style:{fontSize:"12px",color:"#666"},children:"Minutes"})]}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:"18px",fontWeight:600},children:e.totalCalories}),t.jsx("div",{style:{fontSize:"12px",color:"#666"},children:"Calories"})]})]})]}),t.jsxs("div",{style:g.card,children:[t.jsx("div",{style:g.cardTitle,children:"Sleep (7-Day Average)"}),t.jsxs("div",{style:g.statValue,children:[s.avgDuration.toFixed(1),"h"]}),t.jsx("div",{style:g.statLabel,children:"Per Night"}),t.jsx("div",{style:{marginTop:"12px"},children:t.jsxs("div",{style:{fontSize:"14px",color:"#666"},children:["Quality: ",s.avgQuality.toFixed(1),"/4"]})})]}),t.jsxs("div",{style:g.card,children:[t.jsx("div",{style:g.cardTitle,children:"Today's Nutrition"}),t.jsx("div",{style:g.statValue,children:n.calories}),t.jsx("div",{style:g.statLabel,children:"Calories"}),t.jsxs("div",{style:{marginTop:"12px",display:"flex",gap:"16px",fontSize:"14px"},children:[t.jsxs("div",{children:["P: ",n.protein,"g"]}),t.jsxs("div",{children:["C: ",n.carbs,"g"]}),t.jsxs("div",{children:["F: ",n.fat,"g"]})]})]}),t.jsxs("div",{style:g.card,children:[t.jsx("div",{style:g.cardTitle,children:"Latest Vitals"}),r?t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"},children:[r.weight&&t.jsxs("div",{children:[t.jsxs("div",{style:{fontSize:"18px",fontWeight:600},children:[r.weight," ",r.weightUnit||"kg"]}),t.jsx("div",{style:{fontSize:"12px",color:"#666"},children:"Weight"})]}),r.bloodPressureSystolic&&t.jsxs("div",{children:[t.jsxs("div",{style:{fontSize:"18px",fontWeight:600},children:[r.bloodPressureSystolic,"/",r.bloodPressureDiastolic]}),t.jsx("div",{style:{fontSize:"12px",color:"#666"},children:"Blood Pressure"})]}),r.heartRate&&t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:"18px",fontWeight:600},children:r.heartRate}),t.jsx("div",{style:{fontSize:"12px",color:"#666"},children:"Heart Rate"})]})]}):t.jsx("div",{style:{color:"#999"},children:"No vitals recorded"})]})]}),t.jsxs("div",{style:g.card,children:[t.jsx("div",{style:g.cardTitle,children:"Today's Medications"}),i.length===0?t.jsx("div",{style:{color:"#999",textAlign:"center",padding:"20px"},children:"No medications scheduled"}):i.map((a,l)=>t.jsxs("div",{style:g.listItem,children:[t.jsx("span",{style:{width:"60px",fontWeight:500},children:a.time}),t.jsxs("span",{style:{flex:1},children:[a.medication.name," (",a.medication.dosage,")"]}),t.jsx("span",{style:{padding:"4px 12px",borderRadius:"12px",fontSize:"12px",backgroundColor:a.taken?"#e8f5e9":"#fff3e0",color:a.taken?"#2e7d32":"#ef6c00"},children:a.taken?"Taken":"Pending"})]},l))]})]})}function de({service:o,refresh:e}){const s=o.getAllWorkouts(),n=o.getWorkoutStats(30);return t.jsxs("div",{children:[t.jsx("h2",{style:{marginBottom:"20px"},children:"Workouts"}),t.jsxs("div",{style:g.grid,children:[t.jsxs("div",{style:g.card,children:[t.jsx("div",{style:g.statValue,children:n.totalWorkouts}),t.jsx("div",{style:g.statLabel,children:"Workouts (30 days)"})]}),t.jsxs("div",{style:g.card,children:[t.jsx("div",{style:g.statValue,children:n.totalDuration}),t.jsx("div",{style:g.statLabel,children:"Total Minutes"})]}),t.jsxs("div",{style:g.card,children:[t.jsx("div",{style:g.statValue,children:n.totalCalories}),t.jsx("div",{style:g.statLabel,children:"Calories Burned"})]})]}),t.jsxs("div",{style:g.card,children:[t.jsx("div",{style:g.cardTitle,children:"Recent Workouts"}),s.length===0?t.jsx("div",{style:{color:"#999",textAlign:"center",padding:"30px"},children:"No workouts logged yet"}):s.slice(0,10).map(r=>t.jsxs("div",{style:g.listItem,children:[t.jsxs("div",{style:{flex:1},children:[t.jsx("div",{style:{fontWeight:500},children:r.name}),t.jsxs("div",{style:{fontSize:"12px",color:"#666"},children:[new Date(r.date).toLocaleDateString()," โ€ข ",r.duration," min โ€ข"," ",r.caloriesBurned," cal"]})]}),t.jsx("span",{style:{padding:"4px 8px",borderRadius:"4px",fontSize:"12px",backgroundColor:"#e3f2fd",color:"#1565c0",textTransform:"capitalize"},children:r.type})]},r.id))]})]})}function ce({service:o}){const e=o.getDailyNutrition(new Date),s=o.getMealsForDate(new Date),n={calories:2e3,protein:150,carbs:250,fat:65};return t.jsxs("div",{children:[t.jsx("h2",{style:{marginBottom:"20px"},children:"Nutrition"}),t.jsx("div",{style:g.grid,children:[{label:"Calories",value:e.calories,target:n.calories,unit:""},{label:"Protein",value:e.protein,target:n.protein,unit:"g"},{label:"Carbs",value:e.carbs,target:n.carbs,unit:"g"},{label:"Fat",value:e.fat,target:n.fat,unit:"g"}].map(r=>t.jsxs("div",{style:g.card,children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"8px"},children:[t.jsx("span",{style:{fontWeight:500},children:r.label}),t.jsxs("span",{children:[r.value,r.unit," / ",r.target,r.unit]})]}),t.jsx("div",{style:g.progressBar,children:t.jsx("div",{style:{width:`${Math.min(100,r.value/r.target*100)}%`,height:"100%",backgroundColor:r.value>r.target?"#f44336":"#4caf50",borderRadius:"4px"}})})]},r.label))}),t.jsxs("div",{style:g.card,children:[t.jsx("div",{style:g.cardTitle,children:"Today's Meals"}),s.length===0?t.jsx("div",{style:{color:"#999",textAlign:"center",padding:"30px"},children:"No meals logged today"}):s.map(r=>t.jsxs("div",{style:g.listItem,children:[t.jsx("span",{style:{textTransform:"capitalize",fontWeight:500,width:"80px"},children:r.type}),t.jsxs("div",{style:{flex:1},children:[t.jsx("div",{children:r.foods.map(i=>i.item.name).join(", ")}),t.jsxs("div",{style:{fontSize:"12px",color:"#666"},children:[r.totalCalories," cal โ€ข P:",r.totalProtein,"g C:",r.totalCarbs,"g F:",r.totalFat,"g"]})]})]},r.id))]})]})}function ue({service:o}){const e=o.getSleepStats(7),s=o.getAllSleepEntries(),n={poor:"#f44336",fair:"#ff9800",good:"#4caf50",excellent:"#2196f3"};return t.jsxs("div",{children:[t.jsx("h2",{style:{marginBottom:"20px"},children:"Sleep Tracking"}),t.jsxs("div",{style:g.grid,children:[t.jsxs("div",{style:g.card,children:[t.jsxs("div",{style:g.statValue,children:[e.avgDuration.toFixed(1),"h"]}),t.jsx("div",{style:g.statLabel,children:"Avg Sleep (7 days)"})]}),t.jsxs("div",{style:g.card,children:[t.jsxs("div",{style:g.statValue,children:[e.avgQuality.toFixed(1),"/4"]}),t.jsx("div",{style:g.statLabel,children:"Avg Quality"})]})]}),t.jsxs("div",{style:g.card,children:[t.jsx("div",{style:g.cardTitle,children:"Sleep History"}),s.length===0?t.jsx("div",{style:{color:"#999",textAlign:"center",padding:"30px"},children:"No sleep data logged"}):s.slice(0,10).map(r=>t.jsxs("div",{style:g.listItem,children:[t.jsx("span",{style:{width:"100px"},children:new Date(r.date).toLocaleDateString()}),t.jsxs("span",{style:{flex:1},children:[r.duration.toFixed(1)," hours"]}),t.jsx("span",{style:{padding:"4px 12px",borderRadius:"12px",fontSize:"12px",backgroundColor:n[r.quality]+"20",color:n[r.quality],textTransform:"capitalize"},children:r.quality})]},r.id))]})]})}function ge({service:o}){const e=o.getAllMedicalRecords(),s=o.getUpcomingFollowUps(),n={appointment:"๐Ÿ“…","lab-result":"๐Ÿงช",vaccination:"๐Ÿ’‰",prescription:"๐Ÿ“",procedure:"๐Ÿฅ",diagnosis:"๐Ÿฉบ",note:"๐Ÿ“‹"};return t.jsxs("div",{children:[t.jsx("h2",{style:{marginBottom:"20px"},children:"Medical Records"}),s.length>0&&t.jsxs("div",{style:{...g.card,marginBottom:"20px",backgroundColor:"#fff3e0"},children:[t.jsx("div",{style:g.cardTitle,children:"Upcoming Follow-ups"}),s.map(r=>t.jsxs("div",{style:g.listItem,children:[t.jsx("span",{children:n[r.type]}),t.jsx("span",{style:{flex:1},children:r.title}),t.jsx("span",{style:{color:"#ef6c00"},children:new Date(r.followUp).toLocaleDateString()})]},r.id))]}),t.jsxs("div",{style:g.card,children:[t.jsx("div",{style:g.cardTitle,children:"All Records"}),e.length===0?t.jsx("div",{style:{color:"#999",textAlign:"center",padding:"30px"},children:"No medical records"}):e.slice(0,15).map(r=>t.jsxs("div",{style:g.listItem,children:[t.jsx("span",{style:{fontSize:"20px"},children:n[r.type]}),t.jsxs("div",{style:{flex:1},children:[t.jsx("div",{style:{fontWeight:500},children:r.title}),t.jsxs("div",{style:{fontSize:"12px",color:"#666"},children:[new Date(r.date).toLocaleDateString(),r.provider&&` โ€ข ${r.provider}`]})]})]},r.id))]})]})}function he({service:o,refresh:e}){o.getAllMedications();const s=o.getActiveMedications(),n=o.getTodayMedicationSchedule(),r=i=>{const a=new Date;a.setHours(parseInt(i.times[0].split(":")[0]),parseInt(i.times[0].split(":")[1]),0),o.logMedication(i.id,a,!0),e()};return t.jsxs("div",{children:[t.jsx("h2",{style:{marginBottom:"20px"},children:"Medications"}),t.jsxs("div",{style:{...g.card,marginBottom:"20px"},children:[t.jsx("div",{style:g.cardTitle,children:"Today's Schedule"}),n.length===0?t.jsx("div",{style:{color:"#999",textAlign:"center",padding:"20px"},children:"No medications scheduled"}):n.map((i,a)=>t.jsxs("div",{style:g.listItem,children:[t.jsx("span",{style:{width:"60px",fontWeight:500},children:i.time}),t.jsxs("div",{style:{flex:1},children:[t.jsx("div",{style:{fontWeight:500},children:i.medication.name}),t.jsx("div",{style:{fontSize:"12px",color:"#666"},children:i.medication.dosage})]}),!i.taken&&t.jsx("button",{onClick:()=>r(i.medication),style:{padding:"6px 16px",border:"none",borderRadius:"6px",backgroundColor:"#4caf50",color:"#fff",cursor:"pointer",fontSize:"12px"},children:"Mark Taken"}),i.taken&&t.jsx("span",{style:{color:"#4caf50",fontSize:"12px"},children:"โœ“ Taken"})]},a))]}),t.jsxs("div",{style:g.card,children:[t.jsx("div",{style:g.cardTitle,children:"Active Medications"}),s.length===0?t.jsx("div",{style:{color:"#999",textAlign:"center",padding:"30px"},children:"No active medications"}):s.map(i=>t.jsxs("div",{style:g.listItem,children:[t.jsx("span",{style:{fontSize:"24px"},children:"๐Ÿ’Š"}),t.jsxs("div",{style:{flex:1},children:[t.jsx("div",{style:{fontWeight:500},children:i.name}),t.jsxs("div",{style:{fontSize:"12px",color:"#666"},children:[i.dosage," โ€ข ",i.frequency," โ€ข ",i.times.join(", ")]})]})]},i.id))]})]})}const pe=[{id:"income",name:"Income",icon:"๐Ÿ’ฐ",color:"#4caf50"},{id:"salary",name:"Salary",icon:"๐Ÿ’ต",color:"#4caf50",parent:"income"},{id:"interest",name:"Interest",icon:"๐Ÿฆ",color:"#4caf50",parent:"income"},{id:"housing",name:"Housing",icon:"๐Ÿ ",color:"#2196f3"},{id:"rent",name:"Rent",icon:"๐Ÿ ",color:"#2196f3",parent:"housing"},{id:"utilities",name:"Utilities",icon:"๐Ÿ’ก",color:"#2196f3",parent:"housing"},{id:"food",name:"Food & Dining",icon:"๐Ÿ”",color:"#ff9800"},{id:"groceries",name:"Groceries",icon:"๐Ÿ›’",color:"#ff9800",parent:"food"},{id:"restaurants",name:"Restaurants",icon:"๐Ÿฝ๏ธ",color:"#ff9800",parent:"food"},{id:"transport",name:"Transportation",icon:"๐Ÿš—",color:"#9c27b0"},{id:"gas",name:"Gas",icon:"โ›ฝ",color:"#9c27b0",parent:"transport"},{id:"parking",name:"Parking",icon:"๐Ÿ…ฟ๏ธ",color:"#9c27b0",parent:"transport"},{id:"shopping",name:"Shopping",icon:"๐Ÿ›๏ธ",color:"#e91e63"},{id:"entertainment",name:"Entertainment",icon:"๐ŸŽฌ",color:"#673ab7"},{id:"health",name:"Health",icon:"๐Ÿฅ",color:"#f44336"},{id:"personal",name:"Personal",icon:"๐Ÿ‘ค",color:"#607d8b"},{id:"education",name:"Education",icon:"๐Ÿ“š",color:"#00bcd4"},{id:"travel",name:"Travel",icon:"โœˆ๏ธ",color:"#009688"},{id:"subscriptions",name:"Subscriptions",icon:"๐Ÿ“ฑ",color:"#795548"},{id:"transfer",name:"Transfer",icon:"โ†”๏ธ",color:"#9e9e9e"},{id:"other",name:"Other",icon:"๐Ÿ“ฆ",color:"#9e9e9e"}];class N{constructor(){j(this,"accounts",new Map);j(this,"transactions",new Map);j(this,"budgets",new Map);j(this,"bills",new Map);j(this,"investments",new Map);j(this,"categories",[...pe]);j(this,"netWorthHistory",[])}addAccount(e){const s=this.generateId(),n={...e,id:s};return this.accounts.set(s,n),n}updateAccount(e,s){const n=this.accounts.get(e);n&&this.accounts.set(e,{...n,...s,id:e})}deleteAccount(e){this.accounts.delete(e);for(const[s,n]of this.transactions)n.accountId===e&&this.transactions.delete(s)}getAllAccounts(){return Array.from(this.accounts.values())}getAccountsByType(e){return this.getAllAccounts().filter(s=>s.type===e)}calculateTotalAssets(){return this.getAllAccounts().filter(e=>["checking","savings","investment","cash","crypto"].includes(e.type)).reduce((e,s)=>e+s.balance,0)}calculateTotalLiabilities(){return this.getAllAccounts().filter(e=>["credit-card","loan","mortgage"].includes(e.type)).reduce((e,s)=>e+Math.abs(s.balance),0)}calculateNetWorth(){return this.calculateTotalAssets()-this.calculateTotalLiabilities()}recordNetWorthSnapshot(){const e={date:new Date,assets:this.calculateTotalAssets(),liabilities:this.calculateTotalLiabilities(),netWorth:this.calculateNetWorth()};this.netWorthHistory.push(e)}getNetWorthHistory(){return[...this.netWorthHistory]}addTransaction(e){const s=this.generateId(),n={...e,id:s};this.transactions.set(s,n);const r=this.accounts.get(e.accountId);if(r){const i=e.type==="income"?e.amount:-e.amount;r.balance+=i,this.accounts.set(r.id,r)}if(e.categoryId&&e.type==="expense"){const i=this.getBudgetByCategory(e.categoryId);i&&(i.spent+=e.amount,this.budgets.set(i.id,i))}return n}updateTransaction(e,s){const n=this.transactions.get(e);n&&this.transactions.set(e,{...n,...s,id:e})}deleteTransaction(e){const s=this.transactions.get(e);if(s){const n=this.accounts.get(s.accountId);if(n){const r=s.type==="income"?-s.amount:s.amount;n.balance+=r,this.accounts.set(n.id,n)}this.transactions.delete(e)}}getAllTransactions(){return Array.from(this.transactions.values()).sort((e,s)=>new Date(s.date).getTime()-new Date(e.date).getTime())}getTransactionsForAccount(e){return this.getAllTransactions().filter(s=>s.accountId===e)}getTransactionsForPeriod(e,s){return this.getAllTransactions().filter(n=>{const r=new Date(n.date);return r>=e&&r<=s})}getTransactionsByCategory(e){return this.getAllTransactions().filter(s=>s.categoryId===e)}autoCategorize(e){const s=[{pattern:/walmart|target|costco|grocery|supermarket/i,categoryId:"groceries"},{pattern:/starbucks|mcdonalds|restaurant|cafe|pizza/i,categoryId:"restaurants"},{pattern:/shell|exxon|chevron|gas|fuel/i,categoryId:"gas"},{pattern:/netflix|spotify|hulu|subscription/i,categoryId:"subscriptions"},{pattern:/amazon|ebay|shopping/i,categoryId:"shopping"},{pattern:/uber|lyft|taxi|parking/i,categoryId:"transport"},{pattern:/rent|mortgage|lease/i,categoryId:"rent"},{pattern:/electric|water|internet|phone/i,categoryId:"utilities"},{pattern:/doctor|pharmacy|hospital|medical/i,categoryId:"health"},{pattern:/payroll|salary|paycheck|deposit/i,categoryId:"salary"}];for(const n of s)if(n.pattern.test(e))return n.categoryId}getAllCategories(){return[...this.categories]}getTopLevelCategories(){return this.categories.filter(e=>!e.parent)}getSubCategories(e){return this.categories.filter(s=>s.parent===e)}addCategory(e){this.categories.push(e)}addBudget(e){const s=this.generateId(),n={...e,id:s,spent:0};return this.budgets.set(s,n),n}updateBudget(e,s){const n=this.budgets.get(e);n&&this.budgets.set(e,{...n,...s,id:e})}deleteBudget(e){this.budgets.delete(e)}getAllBudgets(){return Array.from(this.budgets.values())}getBudgetByCategory(e){return this.getAllBudgets().find(s=>s.categoryId===e)}resetBudgetSpending(){for(const[e,s]of this.budgets)s.rollover||(s.spent=0),this.budgets.set(e,s)}calculateBudgetStatus(){const e=this.getAllBudgets(),s=e.reduce((i,a)=>i+a.amount,0),n=e.reduce((i,a)=>i+a.spent,0),r=e.filter(i=>i.spent>i.amount);return{total:s,used:n,remaining:s-n,overBudget:r}}addBill(e){const s=this.generateId(),n={...e,id:s};return this.bills.set(s,n),n}updateBill(e,s){const n=this.bills.get(e);n&&this.bills.set(e,{...n,...s,id:e})}deleteBill(e){this.bills.delete(e)}markBillPaid(e){const s=this.bills.get(e);s&&(s.lastPaid=new Date,this.bills.set(e,s))}getAllBills(){return Array.from(this.bills.values())}getUpcomingBills(e=30){const n=new Date().getDate();return this.getAllBills().filter(r=>{let i=r.dueDate-n;return i<0&&(i+=30),i<=e}).sort((r,i)=>r.dueDate-i.dueDate)}calculateMonthlyBillTotal(){return this.getAllBills().filter(e=>e.frequency==="monthly").reduce((e,s)=>e+s.amount,0)}addInvestment(e){const s=this.generateId(),n=e.shares*e.currentPrice,r=n-e.costBasis,i=e.costBasis>0?r/e.costBasis*100:0,a={...e,id:s,currentValue:n,gain:r,gainPercent:i};return this.investments.set(s,a),a}updateInvestmentPrice(e,s){const n=this.investments.get(e);n&&(n.currentPrice=s,n.currentValue=n.shares*s,n.gain=n.currentValue-n.costBasis,n.gainPercent=n.costBasis>0?n.gain/n.costBasis*100:0,this.investments.set(e,n))}deleteInvestment(e){this.investments.delete(e)}getAllInvestments(){return Array.from(this.investments.values())}getInvestmentsByAccount(e){return this.getAllInvestments().filter(s=>s.accountId===e)}calculateTotalInvestmentValue(){return this.getAllInvestments().reduce((e,s)=>e+s.currentValue,0)}calculateTotalGain(){return this.getAllInvestments().reduce((e,s)=>e+s.gain,0)}getPortfolioAllocation(){const e=this.getAllInvestments(),s=this.calculateTotalInvestmentValue(),n=new Map;for(const r of e)n.set(r.type,(n.get(r.type)||0)+r.currentValue);return Array.from(n.entries()).map(([r,i])=>({type:r,value:i,percentage:s>0?i/s*100:0}))}getSpendingSummary(e,s){const n=this.getTransactionsForPeriod(e,s).filter(a=>a.type==="expense"),r=new Map;let i=0;for(const a of n){const l=a.categoryId||"other",d=r.get(l)||{amount:0,count:0};d.amount+=a.amount,d.count++,r.set(l,d),i+=a.amount}return Array.from(r.entries()).map(([a,l])=>{const d=this.categories.find(u=>u.id===a);return{categoryId:a,categoryName:(d==null?void 0:d.name)||"Other",amount:l.amount,percentage:i>0?l.amount/i*100:0,transactions:l.count,trend:"stable"}}).sort((a,l)=>l.amount-a.amount)}getMonthlyIncome(){const e=new Date,s=new Date(e.getFullYear(),e.getMonth(),1);return this.getTransactionsForPeriod(s,e).filter(r=>r.type==="income").reduce((r,i)=>r+i.amount,0)}getMonthlyExpenses(){const e=new Date,s=new Date(e.getFullYear(),e.getMonth(),1);return this.getTransactionsForPeriod(s,e).filter(r=>r.type==="expense").reduce((r,i)=>r+i.amount,0)}getSavingsRate(){const e=this.getMonthlyIncome(),s=this.getMonthlyExpenses();return e===0?0:(e-s)/e*100}generateId(){return Date.now().toString(36)+Math.random().toString(36).substring(2,8)}clear(){this.accounts.clear(),this.transactions.clear(),this.budgets.clear(),this.bills.clear(),this.investments.clear(),this.netWorthHistory=[]}exportData(){return JSON.stringify({accounts:this.getAllAccounts(),transactions:this.getAllTransactions(),budgets:this.getAllBudgets(),bills:this.getAllBills(),investments:this.getAllInvestments(),categories:this.categories,netWorthHistory:this.netWorthHistory},null,2)}}function xe(){return new N}const H=f.createContext(null);function fe(){const o=f.useContext(H);if(!o)throw new Error("usePersonalFinance must be used within PersonalFinanceProvider");return o}const x={container:{display:"flex",height:"100%",fontFamily:"'Inter', sans-serif",backgroundColor:"#f5f7fa"},sidebar:{width:"250px",backgroundColor:"#1a1a2e",color:"#fff",padding:"20px"},main:{flex:1,padding:"20px",overflow:"auto"},netWorth:{textAlign:"center",padding:"20px 0",borderBottom:"1px solid rgba(255,255,255,0.1)",marginBottom:"20px"},netWorthLabel:{fontSize:"12px",color:"rgba(255,255,255,0.6)",textTransform:"uppercase",letterSpacing:"1px"},netWorthValue:{fontSize:"28px",fontWeight:700,marginTop:"8px"},accountList:{marginTop:"20px"},accountItem:{display:"flex",justifyContent:"space-between",padding:"12px",borderRadius:"8px",marginBottom:"8px",backgroundColor:"rgba(255,255,255,0.05)",cursor:"pointer"},grid:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(300px, 1fr))",gap:"20px",marginBottom:"20px"},card:{backgroundColor:"#fff",borderRadius:"12px",padding:"20px",boxShadow:"0 2px 8px rgba(0,0,0,0.08)"},cardTitle:{fontSize:"16px",fontWeight:600,marginBottom:"16px",color:"#1a1a2e"},transactionRow:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px 0",borderBottom:"1px solid #f0f0f0"},progressBar:{height:"8px",backgroundColor:"#e0e0e0",borderRadius:"4px",overflow:"hidden",marginTop:"8px"}};function me({service:o,className:e,style:s}){const[,n]=f.useState(0),[r,i]=f.useState("overview"),a=f.useCallback(()=>n(h=>h+1),[]),l={service:o,refresh:a},d=h=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(h),u=o.getAllAccounts(),c=o.calculateNetWorth();return t.jsx(H.Provider,{value:l,children:t.jsxs("div",{className:e,style:{...x.container,...s},children:[t.jsxs("div",{style:x.sidebar,children:[t.jsxs("div",{style:x.netWorth,children:[t.jsx("div",{style:x.netWorthLabel,children:"Net Worth"}),t.jsx("div",{style:{...x.netWorthValue,color:c>=0?"#4caf50":"#f44336"},children:d(c)})]}),t.jsx("div",{children:["overview","accounts","transactions","budgets","bills","investments"].map(h=>t.jsx("div",{onClick:()=>i(h),style:{padding:"12px 16px",borderRadius:"8px",cursor:"pointer",marginBottom:"4px",backgroundColor:r===h?"rgba(255,255,255,0.1)":"transparent",textTransform:"capitalize"},children:h},h))}),t.jsxs("div",{style:x.accountList,children:[t.jsx("div",{style:{fontSize:"12px",color:"rgba(255,255,255,0.6)",marginBottom:"12px",textTransform:"uppercase"},children:"Accounts"}),u.slice(0,5).map(h=>t.jsxs("div",{style:x.accountItem,children:[t.jsx("span",{children:h.name}),t.jsx("span",{style:{color:h.balance>=0?"#4caf50":"#f44336"},children:d(h.balance)})]},h.id))]})]}),t.jsxs("div",{style:x.main,children:[r==="overview"&&t.jsx(ye,{service:o}),r==="accounts"&&t.jsx(be,{service:o,refresh:a}),r==="transactions"&&t.jsx(ve,{service:o}),r==="budgets"&&t.jsx(je,{service:o}),r==="bills"&&t.jsx(we,{service:o}),r==="investments"&&t.jsx(Se,{service:o})]})]})})}function ye({service:o}){const e=u=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(u),s=o.getMonthlyIncome(),n=o.getMonthlyExpenses(),r=o.getSavingsRate(),i=o.calculateBudgetStatus(),a=o.getUpcomingBills(14),l=new Date,d=o.getSpendingSummary(new Date(l.getFullYear(),l.getMonth(),1),l);return t.jsxs("div",{children:[t.jsx("h2",{style:{marginBottom:"20px"},children:"Financial Overview"}),t.jsxs("div",{style:x.grid,children:[t.jsxs("div",{style:x.card,children:[t.jsx("div",{style:x.cardTitle,children:"This Month"}),t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"12px"},children:[t.jsx("span",{children:"Income"}),t.jsx("span",{style:{color:"#4caf50",fontWeight:600},children:e(s)})]}),t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"12px"},children:[t.jsx("span",{children:"Expenses"}),t.jsx("span",{style:{color:"#f44336",fontWeight:600},children:e(n)})]}),t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",borderTop:"1px solid #f0f0f0",paddingTop:"12px"},children:[t.jsx("span",{children:"Savings Rate"}),t.jsxs("span",{style:{fontWeight:600},children:[r.toFixed(1),"%"]})]})]}),t.jsxs("div",{style:x.card,children:[t.jsx("div",{style:x.cardTitle,children:"Budget Status"}),t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"8px"},children:[t.jsx("span",{children:"Used"}),t.jsxs("span",{children:[e(i.used)," / ",e(i.total)]})]}),t.jsx("div",{style:x.progressBar,children:t.jsx("div",{style:{width:`${Math.min(100,i.used/i.total*100)}%`,height:"100%",backgroundColor:i.used>i.total?"#f44336":"#4caf50",borderRadius:"4px"}})}),i.overBudget.length>0&&t.jsxs("div",{style:{color:"#f44336",fontSize:"12px",marginTop:"8px"},children:[i.overBudget.length," categories over budget"]})]}),t.jsxs("div",{style:x.card,children:[t.jsx("div",{style:x.cardTitle,children:"Upcoming Bills (14 days)"}),a.length===0?t.jsx("div",{style:{color:"#999",textAlign:"center",padding:"20px"},children:"No upcoming bills"}):a.slice(0,4).map(u=>t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",padding:"8px 0",borderBottom:"1px solid #f0f0f0"},children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontWeight:500},children:u.name}),t.jsxs("div",{style:{fontSize:"12px",color:"#666"},children:["Due: ",u.dueDate,"th"]})]}),t.jsx("span",{style:{fontWeight:600},children:e(u.amount)})]},u.id))]}),t.jsxs("div",{style:x.card,children:[t.jsx("div",{style:x.cardTitle,children:"Spending by Category"}),d.slice(0,5).map(u=>t.jsxs("div",{style:{marginBottom:"12px"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"4px"},children:[t.jsx("span",{children:u.categoryName}),t.jsxs("span",{children:[e(u.amount)," (",u.percentage.toFixed(0),"%)"]})]}),t.jsx("div",{style:x.progressBar,children:t.jsx("div",{style:{width:`${u.percentage}%`,height:"100%",backgroundColor:"#1976d2",borderRadius:"4px"}})})]},u.categoryId))]})]})]})}function be({service:o,refresh:e}){const s=a=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(a);o.getAllAccounts();const n=o.calculateTotalAssets(),r=o.calculateTotalLiabilities(),i=["checking","savings","credit-card","investment","loan","cash"];return t.jsxs("div",{children:[t.jsx("h2",{style:{marginBottom:"20px"},children:"Accounts"}),t.jsxs("div",{style:x.grid,children:[t.jsxs("div",{style:x.card,children:[t.jsx("div",{style:x.cardTitle,children:"Assets"}),t.jsx("div",{style:{fontSize:"24px",fontWeight:600,color:"#4caf50"},children:s(n)})]}),t.jsxs("div",{style:x.card,children:[t.jsx("div",{style:x.cardTitle,children:"Liabilities"}),t.jsx("div",{style:{fontSize:"24px",fontWeight:600,color:"#f44336"},children:s(r)})]})]}),i.map(a=>{const l=o.getAccountsByType(a);return l.length===0?null:t.jsxs("div",{style:{...x.card,marginBottom:"20px"},children:[t.jsx("div",{style:x.cardTitle,children:a.replace("-"," ").replace(/\b\w/g,d=>d.toUpperCase())}),l.map(d=>t.jsxs("div",{style:x.transactionRow,children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontWeight:500},children:d.name}),t.jsx("div",{style:{fontSize:"12px",color:"#666"},children:d.institution})]}),t.jsx("span",{style:{fontWeight:600,color:d.balance>=0?"#333":"#f44336"},children:s(d.balance)})]},d.id))]},a)})]})}function ve({service:o}){const e=i=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(i),s=o.getAllTransactions(),n=o.getAllCategories(),r=i=>{var a;return((a=n.find(l=>l.id===i))==null?void 0:a.name)||"Uncategorized"};return t.jsxs("div",{children:[t.jsx("h2",{style:{marginBottom:"20px"},children:"Transactions"}),t.jsx("div",{style:x.card,children:s.length===0?t.jsx("div",{style:{color:"#999",textAlign:"center",padding:"40px"},children:"No transactions"}):s.slice(0,20).map(i=>t.jsxs("div",{style:x.transactionRow,children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontWeight:500},children:i.description}),t.jsxs("div",{style:{fontSize:"12px",color:"#666"},children:[new Date(i.date).toLocaleDateString()," โ€ข ",r(i.categoryId)]})]}),t.jsxs("span",{style:{fontWeight:600,color:i.type==="income"?"#4caf50":"#f44336"},children:[i.type==="income"?"+":"-",e(i.amount)]})]},i.id))})]})}function je({service:o}){const e=i=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(i),s=o.getAllBudgets(),n=o.getAllCategories(),r=i=>{var a;return((a=n.find(l=>l.id===i))==null?void 0:a.name)||"Unknown"};return t.jsxs("div",{children:[t.jsx("h2",{style:{marginBottom:"20px"},children:"Budgets"}),t.jsx("div",{style:x.card,children:s.length===0?t.jsx("div",{style:{color:"#999",textAlign:"center",padding:"40px"},children:"No budgets set"}):s.map(i=>{const a=i.spent/i.amount*100,l=i.spent>i.amount;return t.jsxs("div",{style:{marginBottom:"20px",paddingBottom:"20px",borderBottom:"1px solid #f0f0f0"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"8px"},children:[t.jsx("span",{style:{fontWeight:500},children:r(i.categoryId)}),t.jsxs("span",{children:[e(i.spent)," / ",e(i.amount)]})]}),t.jsx("div",{style:x.progressBar,children:t.jsx("div",{style:{width:`${Math.min(100,a)}%`,height:"100%",backgroundColor:l?"#f44336":a>80?"#ff9800":"#4caf50",borderRadius:"4px"}})}),t.jsx("div",{style:{fontSize:"12px",color:l?"#f44336":"#666",marginTop:"4px"},children:l?`Over by ${e(i.spent-i.amount)}`:`${e(i.amount-i.spent)} remaining`})]},i.id)})})]})}function we({service:o}){const e=r=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(r),s=o.getAllBills(),n=o.calculateMonthlyBillTotal();return t.jsxs("div",{children:[t.jsx("h2",{style:{marginBottom:"20px"},children:"Bills & Subscriptions"}),t.jsxs("div",{style:{...x.card,marginBottom:"20px"},children:[t.jsx("div",{style:x.cardTitle,children:"Monthly Bills Total"}),t.jsx("div",{style:{fontSize:"24px",fontWeight:600},children:e(n)})]}),t.jsx("div",{style:x.card,children:s.length===0?t.jsx("div",{style:{color:"#999",textAlign:"center",padding:"40px"},children:"No bills tracked"}):s.map(r=>t.jsxs("div",{style:x.transactionRow,children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontWeight:500},children:r.name}),t.jsxs("div",{style:{fontSize:"12px",color:"#666"},children:["Due: ",r.dueDate,"th โ€ข ",r.frequency,r.autoPay&&" โ€ข Auto-pay"]})]}),t.jsx("span",{style:{fontWeight:600},children:e(r.amount)})]},r.id))})]})}function Se({service:o}){const e=a=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(a),s=o.getAllInvestments(),n=o.calculateTotalInvestmentValue(),r=o.calculateTotalGain(),i=o.getPortfolioAllocation();return t.jsxs("div",{children:[t.jsx("h2",{style:{marginBottom:"20px"},children:"Investments"}),t.jsxs("div",{style:x.grid,children:[t.jsxs("div",{style:x.card,children:[t.jsx("div",{style:x.cardTitle,children:"Portfolio Value"}),t.jsx("div",{style:{fontSize:"24px",fontWeight:600},children:e(n)})]}),t.jsxs("div",{style:x.card,children:[t.jsx("div",{style:x.cardTitle,children:"Total Gain/Loss"}),t.jsxs("div",{style:{fontSize:"24px",fontWeight:600,color:r>=0?"#4caf50":"#f44336"},children:[r>=0?"+":"",e(r)]})]})]}),t.jsxs("div",{style:{...x.card,marginBottom:"20px"},children:[t.jsx("div",{style:x.cardTitle,children:"Asset Allocation"}),i.map(a=>t.jsxs("div",{style:{marginBottom:"12px"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"4px"},children:[t.jsx("span",{style:{textTransform:"capitalize"},children:a.type}),t.jsxs("span",{children:[a.percentage.toFixed(1),"%"]})]}),t.jsx("div",{style:x.progressBar,children:t.jsx("div",{style:{width:`${a.percentage}%`,height:"100%",backgroundColor:"#1976d2",borderRadius:"4px"}})})]},a.type))]}),t.jsxs("div",{style:x.card,children:[t.jsx("div",{style:x.cardTitle,children:"Holdings"}),s.length===0?t.jsx("div",{style:{color:"#999",textAlign:"center",padding:"40px"},children:"No investments tracked"}):s.map(a=>t.jsxs("div",{style:x.transactionRow,children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontWeight:500},children:a.symbol}),t.jsxs("div",{style:{fontSize:"12px",color:"#666"},children:[a.shares," shares @ ",e(a.currentPrice)]})]}),t.jsxs("div",{style:{textAlign:"right"},children:[t.jsx("div",{style:{fontWeight:600},children:e(a.currentValue)}),t.jsxs("div",{style:{fontSize:"12px",color:a.gain>=0?"#4caf50":"#f44336"},children:[a.gain>=0?"+":"",e(a.gain)," (",a.gainPercent.toFixed(1),"%)"]})]})]},a.id))]})]})}const F={urgent:0,high:1,medium:2,low:3,none:4};class ${constructor(){j(this,"tasks",new Map);j(this,"projects",new Map);j(this,"tags",new Map);j(this,"timeBlocks",new Map)}addTask(e){const s=this.generateId(),n=new Date,r={...e,id:s,subtasks:[],createdAt:n,updatedAt:n};return this.tasks.set(s,r),r}updateTask(e,s){const n=this.tasks.get(e);n&&this.tasks.set(e,{...n,...s,id:e,updatedAt:new Date})}deleteTask(e){const s=this.tasks.get(e);if(s){for(const n of s.subtasks)this.deleteTask(n.id);for(const n of s.timeBlocks)this.timeBlocks.delete(n.id);this.tasks.delete(e)}}getTask(e){return this.tasks.get(e)}getAllTasks(){return Array.from(this.tasks.values())}quickAddTask(e){const s=this.parseQuickAdd(e);return this.addTask({title:s.title,status:"inbox",priority:s.priority,projectId:s.projectId,tags:s.tags,dueDate:s.dueDate,timeBlocks:[],notes:"",attachments:[]})}parseQuickAdd(e){let s=e,n="none",r;const i=[];let a;e.includes("!!!")?(n="urgent",s=s.replace("!!!","")):e.includes("!!")?(n="high",s=s.replace("!!","")):e.includes("!")&&(n="medium",s=s.replace("!",""));const l=e.match(/#(\w+)/);if(l){const c=Array.from(this.projects.values()).find(h=>h.name.toLowerCase()===l[1].toLowerCase());c&&(r=c.id,s=s.replace(l[0],""))}const d=e.matchAll(/@(\w+)/g);for(const c of d){const h=Array.from(this.tags.values()).find(m=>m.name.toLowerCase()===c[1].toLowerCase());h&&(i.push(h.id),s=s.replace(c[0],""))}const u=[{pattern:/\btoday\b/i,offset:()=>new Date},{pattern:/\btomorrow\b/i,offset:()=>new Date(Date.now()+864e5)},{pattern:/\bnext week\b/i,offset:()=>new Date(Date.now()+7*864e5)},{pattern:/\bnext month\b/i,offset:()=>{const c=new Date;return c.setMonth(c.getMonth()+1),c}}];for(const{pattern:c,offset:h}of u)if(c.test(e)){a=h(),a.setHours(23,59,59,999),s=s.replace(c,"");break}return{title:s.trim(),priority:n,projectId:r,tags:i,dueDate:a}}completeTask(e){const s=this.tasks.get(e);s&&(s.status="done",s.completedDate=new Date,s.updatedAt=new Date,s.recurrence&&this.createRecurringTask(s),this.tasks.set(e,s))}createRecurringTask(e){const s=this.calculateNextRecurrence(e);s&&this.addTask({title:e.title,description:e.description,status:"todo",priority:e.priority,projectId:e.projectId,tags:e.tags,dueDate:s,recurrence:e.recurrence,timeBlocks:[],notes:"",attachments:[]})}calculateNextRecurrence(e){if(!e.recurrence||!e.dueDate)return null;const{pattern:s,interval:n,endDate:r,endAfterOccurrences:i}=e.recurrence,a=new Date(e.dueDate);let l;switch(s){case"daily":l=new Date(a.getTime()+n*864e5);break;case"weekdays":l=new Date(a);do l.setDate(l.getDate()+1);while(l.getDay()===0||l.getDay()===6);break;case"weekly":l=new Date(a.getTime()+n*7*864e5);break;case"bi-weekly":l=new Date(a.getTime()+14*864e5);break;case"monthly":l=new Date(a),l.setMonth(l.getMonth()+n);break;case"yearly":l=new Date(a),l.setFullYear(l.getFullYear()+n);break;default:return null}return r&&l>r?null:l}filterTasks(e){var n,r,i;let s=this.getAllTasks();if((n=e.status)!=null&&n.length&&(s=s.filter(a=>e.status.includes(a.status))),(r=e.priority)!=null&&r.length&&(s=s.filter(a=>e.priority.includes(a.priority))),e.projectId!==void 0&&(s=s.filter(a=>a.projectId===e.projectId)),(i=e.tags)!=null&&i.length&&(s=s.filter(a=>e.tags.some(l=>a.tags.includes(l)))),e.dueDateRange){const{start:a,end:l}=e.dueDateRange;s=s.filter(d=>{if(!d.dueDate)return!1;const u=new Date(d.dueDate);return!(a&&u<a||l&&u>l)})}if(e.search){const a=e.search.toLowerCase();s=s.filter(l=>{var d;return l.title.toLowerCase().includes(a)||((d=l.description)==null?void 0:d.toLowerCase().includes(a))||l.notes.toLowerCase().includes(a)})}return s}sortTasks(e,s="dueDate",n="asc"){return[...e].sort((i,a)=>{let l=0;switch(s){case"dueDate":{const d=i.dueDate?new Date(i.dueDate).getTime():1/0,u=a.dueDate?new Date(a.dueDate).getTime():1/0;l=d-u;break}case"priority":l=F[i.priority]-F[a.priority];break;case"createdAt":l=new Date(i.createdAt).getTime()-new Date(a.createdAt).getTime();break;case"title":l=i.title.localeCompare(a.title);break;case"status":l=i.status.localeCompare(a.status);break}return n==="asc"?l:-l})}getInbox(){return this.filterTasks({status:["inbox"]})}getToday(){const e=new Date;e.setHours(0,0,0,0);const s=new Date(e.getTime()+864e5);return this.filterTasks({status:["todo","in-progress"],dueDateRange:{end:s}})}getUpcoming(e=7){const s=new Date;s.setHours(0,0,0,0);const n=new Date(s.getTime()+e*864e5);return this.filterTasks({status:["todo","in-progress"],dueDateRange:{start:s,end:n}})}getOverdue(){const e=new Date;return e.setHours(0,0,0,0),this.getAllTasks().filter(s=>s.dueDate&&new Date(s.dueDate)<e&&!["done","cancelled"].includes(s.status))}getPriorityMatrix(){const e=this.filterTasks({status:["todo","in-progress"]}),s=r=>r.dueDate?Math.ceil((new Date(r.dueDate).getTime()-Date.now())/864e5)<=2:!1,n=r=>["urgent","high"].includes(r.priority);return{doFirst:{name:"Do First",description:"Urgent and Important",tasks:e.filter(r=>s(r)&&n(r))},schedule:{name:"Schedule",description:"Important but Not Urgent",tasks:e.filter(r=>!s(r)&&n(r))},delegate:{name:"Delegate",description:"Urgent but Not Important",tasks:e.filter(r=>s(r)&&!n(r))},eliminate:{name:"Eliminate",description:"Neither Urgent nor Important",tasks:e.filter(r=>!s(r)&&!n(r))}}}addTimeBlock(e){const s=this.generateId(),n={...e,id:s};if(this.timeBlocks.set(s,n),e.taskId){const r=this.tasks.get(e.taskId);r&&(r.timeBlocks.push(n),this.tasks.set(e.taskId,r))}return n}updateTimeBlock(e,s){const n=this.timeBlocks.get(e);n&&this.timeBlocks.set(e,{...n,...s,id:e})}deleteTimeBlock(e){const s=this.timeBlocks.get(e);if(s!=null&&s.taskId){const n=this.tasks.get(s.taskId);n&&(n.timeBlocks=n.timeBlocks.filter(r=>r.id!==e),this.tasks.set(n.id,n))}this.timeBlocks.delete(e)}getTimeBlocksForDate(e){const s=new Date(e);s.setHours(0,0,0,0);const n=new Date(s.getTime()+864e5);return Array.from(this.timeBlocks.values()).filter(r=>{const i=new Date(r.start);return i>=s&&i<n})}addProject(e){const s=this.generateId(),n={...e,id:s,order:this.projects.size,createdAt:new Date};return this.projects.set(s,n),n}updateProject(e,s){const n=this.projects.get(e);n&&this.projects.set(e,{...n,...s,id:e})}deleteProject(e){this.projects.delete(e);for(const[s,n]of this.tasks)n.projectId===e&&(n.projectId=void 0,this.tasks.set(s,n))}getAllProjects(){return Array.from(this.projects.values()).sort((e,s)=>e.order-s.order)}getProjectTasks(e){return this.filterTasks({projectId:e})}getProjectProgress(e){const s=this.getProjectTasks(e),n=s.filter(r=>r.status==="done").length;return{total:s.length,completed:n,percentage:s.length>0?Math.round(n/s.length*100):0}}addTag(e){const s=this.generateId(),n={...e,id:s};return this.tags.set(s,n),n}deleteTag(e){this.tags.delete(e);for(const[s,n]of this.tasks)n.tags.includes(e)&&(n.tags=n.tags.filter(r=>r!==e),this.tasks.set(s,n))}getAllTags(){return Array.from(this.tags.values())}getStatistics(){const e=this.getAllTasks(),s=new Date;s.setHours(0,0,0,0);const n=new Date(s.getTime()+864e5),r=e.filter(d=>d.status==="done").length,i=this.getOverdue().length,a=e.filter(d=>d.dueDate&&new Date(d.dueDate)>=s&&new Date(d.dueDate)<n&&d.status!=="done").length,l=e.filter(d=>d.status==="in-progress").length;return{total:e.length,completed:r,overdue:i,dueToday:a,inProgress:l,completionRate:e.length>0?Math.round(r/e.length*100):0}}generateId(){return Date.now().toString(36)+Math.random().toString(36).substring(2,8)}clear(){this.tasks.clear(),this.projects.clear(),this.tags.clear(),this.timeBlocks.clear()}}function ke(){return new $}const E=f.createContext(null);function Te(){const o=f.useContext(E);if(!o)throw new Error("useTaskManager must be used within TaskManagerProvider");return o}const w={container:{display:"flex",height:"100%",fontFamily:"'Inter', sans-serif",backgroundColor:"#f5f7fa"},sidebar:{width:"250px",backgroundColor:"#fff",borderRight:"1px solid #e0e0e0",padding:"20px",overflow:"auto"},main:{flex:1,padding:"20px",overflow:"auto"},menuItem:{display:"flex",alignItems:"center",gap:"12px",padding:"12px 16px",borderRadius:"8px",cursor:"pointer",marginBottom:"4px",transition:"background-color 0.2s"},badge:{backgroundColor:"#1976d2",color:"#fff",borderRadius:"10px",padding:"2px 8px",fontSize:"12px",marginLeft:"auto"},sectionTitle:{fontSize:"11px",fontWeight:600,color:"#999",textTransform:"uppercase",letterSpacing:"1px",margin:"20px 0 12px"},header:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"20px"},title:{fontSize:"24px",fontWeight:600,color:"#1a1a2e"},taskInput:{width:"100%",padding:"12px 16px",border:"1px solid #e0e0e0",borderRadius:"8px",fontSize:"14px",marginBottom:"20px",outline:"none"},taskItem:{display:"flex",alignItems:"flex-start",gap:"12px",padding:"12px 16px",backgroundColor:"#fff",borderRadius:"8px",marginBottom:"8px",boxShadow:"0 1px 3px rgba(0,0,0,0.08)",cursor:"pointer"},checkbox:{width:"20px",height:"20px",borderRadius:"50%",border:"2px solid #ccc",cursor:"pointer",flexShrink:0,marginTop:"2px"},taskContent:{flex:1,minWidth:0},taskTitle:{fontSize:"14px",fontWeight:500,color:"#333",marginBottom:"4px"},taskMeta:{display:"flex",alignItems:"center",gap:"8px",fontSize:"12px",color:"#666"},priorityIndicator:{width:"4px",borderRadius:"2px",alignSelf:"stretch"},matrixGrid:{display:"grid",gridTemplateColumns:"1fr 1fr",gridTemplateRows:"1fr 1fr",gap:"16px",height:"calc(100% - 60px)"},matrixQuadrant:{backgroundColor:"#fff",borderRadius:"12px",padding:"16px",overflow:"auto"}},W={urgent:"#f44336",high:"#ff9800",medium:"#2196f3",low:"#4caf50",none:"#e0e0e0"};function De({service:o,className:e,style:s}){var I;const[,n]=f.useState(0),[r,i]=f.useState("inbox"),[a,l]=f.useState(null),[d,u]=f.useState(""),c=f.useCallback(()=>n(S=>S+1),[]),h={service:o,refresh:c},m=o.getStatistics(),p=o.getAllProjects(),b=()=>{d.trim()&&(o.quickAddTask(d),u(""),c())},k=(S,M)=>{i(S),l(M??null)};return t.jsx(E.Provider,{value:h,children:t.jsxs("div",{className:e,style:{...w.container,...s},children:[t.jsxs("div",{style:w.sidebar,children:[t.jsxs("div",{onClick:()=>k("inbox"),style:{...w.menuItem,backgroundColor:r==="inbox"?"#e3f2fd":"transparent"},children:[t.jsx("span",{children:"๐Ÿ“ฅ"}),t.jsx("span",{children:"Inbox"}),m.total-m.completed>0&&t.jsx("span",{style:w.badge,children:o.getInbox().length})]}),t.jsxs("div",{onClick:()=>k("today"),style:{...w.menuItem,backgroundColor:r==="today"?"#e3f2fd":"transparent"},children:[t.jsx("span",{children:"๐Ÿ“…"}),t.jsx("span",{children:"Today"}),m.dueToday>0&&t.jsx("span",{style:w.badge,children:m.dueToday})]}),t.jsxs("div",{onClick:()=>k("upcoming"),style:{...w.menuItem,backgroundColor:r==="upcoming"?"#e3f2fd":"transparent"},children:[t.jsx("span",{children:"๐Ÿ—“๏ธ"}),t.jsx("span",{children:"Upcoming"})]}),t.jsxs("div",{onClick:()=>k("matrix"),style:{...w.menuItem,backgroundColor:r==="matrix"?"#e3f2fd":"transparent"},children:[t.jsx("span",{children:"โฌœ"}),t.jsx("span",{children:"Priority Matrix"})]}),t.jsxs("div",{onClick:()=>k("all"),style:{...w.menuItem,backgroundColor:r==="all"?"#e3f2fd":"transparent"},children:[t.jsx("span",{children:"๐Ÿ“‹"}),t.jsx("span",{children:"All Tasks"})]}),m.overdue>0&&t.jsxs("div",{style:{...w.menuItem,color:"#f44336"},children:[t.jsx("span",{children:"โš ๏ธ"}),t.jsx("span",{children:"Overdue"}),t.jsx("span",{style:{...w.badge,backgroundColor:"#f44336"},children:m.overdue})]}),t.jsx("div",{style:w.sectionTitle,children:"Projects"}),p.map(S=>{const M=o.getProjectProgress(S.id);return t.jsxs("div",{onClick:()=>k("project",S.id),style:{...w.menuItem,backgroundColor:r==="project"&&a===S.id?"#e3f2fd":"transparent"},children:[t.jsx("span",{style:{width:"10px",height:"10px",borderRadius:"50%",backgroundColor:S.color}}),t.jsx("span",{style:{flex:1},children:S.name}),t.jsxs("span",{style:{fontSize:"12px",color:"#999"},children:[M.percentage,"%"]})]},S.id)})]}),t.jsxs("div",{style:w.main,children:[t.jsxs("div",{style:w.header,children:[t.jsxs("div",{style:w.title,children:[r==="inbox"&&"Inbox",r==="today"&&"Today",r==="upcoming"&&"Upcoming",r==="matrix"&&"Priority Matrix",r==="all"&&"All Tasks",r==="project"&&((I=p.find(S=>S.id===a))==null?void 0:I.name)]}),t.jsxs("div",{style:{fontSize:"14px",color:"#666"},children:[m.completed,"/",m.total," completed"]})]}),r!=="matrix"&&t.jsx("input",{type:"text",placeholder:"Quick add task (e.g., 'Buy groceries tomorrow #shopping !')",value:d,onChange:S=>u(S.target.value),onKeyDown:S=>S.key==="Enter"&&b(),style:w.taskInput}),r==="matrix"?t.jsx(Ae,{service:o,onComplete:c}):t.jsx(Ce,{service:o,view:r,projectId:a,onComplete:c})]})]})})}function Ce({service:o,view:e,projectId:s,onComplete:n}){const r=f.useMemo(()=>{switch(e){case"inbox":return o.getInbox();case"today":return o.getToday();case"upcoming":return o.getUpcoming();case"all":return o.sortTasks(o.filterTasks({status:["inbox","todo","in-progress"]}),"dueDate");case"project":return s?o.filterTasks({projectId:s,status:["inbox","todo","in-progress"]}):[];default:return[]}},[o,e,s]);return r.length===0?t.jsxs("div",{style:{textAlign:"center",padding:"60px",color:"#999"},children:[t.jsx("div",{style:{fontSize:"48px",marginBottom:"16px"},children:"โœจ"}),t.jsx("div",{children:"No tasks here!"})]}):t.jsx("div",{children:r.map(i=>t.jsx(V,{task:i,service:o,onComplete:n},i.id))})}function V({task:o,service:e,onComplete:s}){const n=a=>{a.stopPropagation(),e.completeTask(o.id),s()},r=a=>{const l=new Date(a),d=new Date;d.setHours(0,0,0,0);const u=new Date(d.getTime()+864e5);return l<d?"Overdue":l.toDateString()===d.toDateString()?"Today":l.toDateString()===u.toDateString()?"Tomorrow":l.toLocaleDateString("en-US",{month:"short",day:"numeric"})},i=o.dueDate&&new Date(o.dueDate)<new Date&&o.status!=="done";return t.jsxs("div",{style:w.taskItem,children:[t.jsx("div",{style:{...w.priorityIndicator,backgroundColor:W[o.priority]}}),t.jsx("div",{onClick:n,style:{...w.checkbox,borderColor:W[o.priority]}}),t.jsxs("div",{style:w.taskContent,children:[t.jsx("div",{style:w.taskTitle,children:o.title}),t.jsxs("div",{style:w.taskMeta,children:[o.dueDate&&t.jsxs("span",{style:{color:i?"#f44336":"#666"},children:["๐Ÿ“… ",r(o.dueDate)]}),o.estimatedMinutes&&t.jsxs("span",{children:["โฑ๏ธ ",o.estimatedMinutes,"m"]}),o.recurrence&&t.jsx("span",{children:"๐Ÿ”„"})]})]})]})}function Ae({service:o,onComplete:e}){const s=o.getPriorityMatrix(),n={doFirst:{bg:"#ffebee",border:"#f44336"},schedule:{bg:"#fff3e0",border:"#ff9800"},delegate:{bg:"#e3f2fd",border:"#2196f3"},eliminate:{bg:"#f5f5f5",border:"#9e9e9e"}};return t.jsx("div",{style:w.matrixGrid,children:["doFirst","schedule","delegate","eliminate"].map(r=>{const i=s[r],a=n[r];return t.jsxs("div",{style:{...w.matrixQuadrant,backgroundColor:a.bg,borderLeft:`4px solid ${a.border}`},children:[t.jsx("div",{style:{fontWeight:600,marginBottom:"8px"},children:i.name}),t.jsx("div",{style:{fontSize:"12px",color:"#666",marginBottom:"12px"},children:i.description}),i.tasks.map(l=>t.jsx(V,{task:l,service:o,onComplete:e},l.id)),i.tasks.length===0&&t.jsx("div",{style:{color:"#999",textAlign:"center",padding:"20px"},children:"Empty"})]},r)})})}class O{constructor(){j(this,"kpis",new Map);j(this,"goals",new Map);j(this,"habits",new Map);j(this,"moodEntries",new Map);j(this,"financeSummary",{netWorth:0,monthlyIncome:0,monthlyExpenses:0,savings:0,savingsRate:0,debts:0,investments:0,budgetUsed:0,budgetTotal:0,categories:[]})}addKPI(e){const s=this.generateId(),n={...e,id:s};return this.kpis.set(s,n),n}updateKPI(e,s){const n=this.kpis.get(e);n&&this.kpis.set(e,{...n,...s,id:e})}recordKPIValue(e,s){const n=this.kpis.get(e);if(n){const r=n.currentValue;n.currentValue=s,n.history.push({date:new Date,value:s}),n.trend=s>r?"up":s<r?"down":"stable",this.kpis.set(e,n)}}getAllKPIs(){return Array.from(this.kpis.values())}getKPIsByCategory(e){return this.getAllKPIs().filter(s=>s.category===e)}calculateKPIProgress(e){return e.targetValue===0?100:Math.min(100,e.currentValue/e.targetValue*100)}addGoal(e){const s=this.generateId(),n={...e,id:s};return this.goals.set(s,n),n}updateGoal(e,s){const n=this.goals.get(e);n&&this.goals.set(e,{...n,...s,id:e})}completeGoalMilestone(e,s){const n=this.goals.get(e);if(n){const r=n.milestones.find(i=>i.id===s);r&&(r.completed=!0,r.completedDate=new Date,n.progress=this.calculateGoalProgress(n),this.goals.set(e,n))}}calculateGoalProgress(e){if(e.milestones.length===0)return e.progress;const s=e.milestones.filter(n=>n.completed).length;return Math.round(s/e.milestones.length*100)}getAllGoals(){return Array.from(this.goals.values())}getActiveGoals(){return this.getAllGoals().filter(e=>e.status==="in-progress")}getGoalsByCategory(e){return this.getAllGoals().filter(s=>s.category===e)}getUpcomingDeadlines(e=30){const s=new Date,n=new Date(s.getTime()+e*24*60*60*1e3);return this.getActiveGoals().filter(r=>r.targetDate<=n).sort((r,i)=>r.targetDate.getTime()-i.targetDate.getTime())}addHabit(e){const s=this.generateId(),n={...e,id:s,streak:0,longestStreak:0,completions:[],createdAt:new Date};return this.habits.set(s,n),n}completeHabit(e,s=1,n){const r=this.habits.get(e);if(r){const i=new Date;i.setHours(0,0,0,0);const a=r.completions.find(l=>new Date(l.date).toDateString()===i.toDateString());a?(a.count+=s,n&&(a.note=n)):r.completions.push({date:i,count:s,note:n}),this.updateStreak(r),this.habits.set(e,r)}}updateStreak(e){const s=[...e.completions].sort((i,a)=>new Date(a.date).getTime()-new Date(i.date).getTime());if(s.length===0){e.streak=0;return}let n=0;const r=new Date;r.setHours(0,0,0,0);for(let i=0;i<s.length;i++){const a=new Date(s[i].date);a.setHours(0,0,0,0);const l=new Date(r.getTime()-i*24*60*60*1e3);if(a.getTime()===l.getTime())if(s[i].count>=e.targetPerPeriod)n++;else break;else break}e.streak=n,n>e.longestStreak&&(e.longestStreak=n)}getAllHabits(){return Array.from(this.habits.values())}getHabitCompletionRate(e,s=30){const n=this.habits.get(e);if(!n)return 0;const r=new Date,i=new Date(r.getTime()-s*24*60*60*1e3),a=n.completions.filter(l=>new Date(l.date)>=i&&l.count>=n.targetPerPeriod);return Math.round(a.length/s*100)}getTodayHabitStatus(){const e=new Date().toDateString();return this.getAllHabits().map(s=>{const n=s.completions.find(r=>new Date(r.date).toDateString()===e);return{habit:s,completed:n?n.count>=s.targetPerPeriod:!1,count:(n==null?void 0:n.count)??0}})}addMoodEntry(e){const s=this.generateId(),n={...e,id:s};return this.moodEntries.set(s,n),n}getAllMoodEntries(){return Array.from(this.moodEntries.values()).sort((e,s)=>new Date(s.date).getTime()-new Date(e.date).getTime())}getMoodEntriesForPeriod(e,s){return this.getAllMoodEntries().filter(n=>new Date(n.date)>=e&&new Date(n.date)<=s)}getAverageMood(e=7){const s=new Date,n=new Date(s.getTime()-e*24*60*60*1e3),r=this.getMoodEntriesForPeriod(n,s);return r.length===0?0:r.reduce((i,a)=>i+a.mood,0)/r.length}getAverageSleep(e=7){const s=new Date,n=new Date(s.getTime()-e*24*60*60*1e3),r=this.getMoodEntriesForPeriod(n,s);return r.length===0?0:r.reduce((i,a)=>i+a.sleep,0)/r.length}getMoodCorrelations(){const e=this.getAllMoodEntries();if(e.length<5)return[];const s=[],n=this.calculateCorrelation(e.map(i=>i.sleep),e.map(i=>i.mood));s.push({factor:"Sleep",correlation:n});const r=this.calculateCorrelation(e.map(i=>i.stress),e.map(i=>i.mood));return s.push({factor:"Stress",correlation:r}),s.sort((i,a)=>Math.abs(a.correlation)-Math.abs(i.correlation))}calculateCorrelation(e,s){const n=e.length;if(n===0)return 0;const r=e.reduce((h,m)=>h+m,0),i=s.reduce((h,m)=>h+m,0),a=e.reduce((h,m,p)=>h+m*s[p],0),l=e.reduce((h,m)=>h+m*m,0),d=s.reduce((h,m)=>h+m*m,0),u=n*a-r*i,c=Math.sqrt((n*l-r**2)*(n*d-i**2));return c===0?0:u/c}setFinanceSummary(e){this.financeSummary=e}getFinanceSummary(){return{...this.financeSummary}}calculateFinanceHealth(){const e=[],s=Math.min(100,this.financeSummary.savingsRate/20*100);e.push({name:"Savings Rate",score:s});const n=this.financeSummary.budgetTotal>0?Math.min(100,(1-this.financeSummary.budgetUsed/this.financeSummary.budgetTotal)*100+50):50;e.push({name:"Budget Adherence",score:n});const r=this.financeSummary.monthlyIncome>0?this.financeSummary.debts/(this.financeSummary.monthlyIncome*12):0,i=Math.max(0,100-r*100);e.push({name:"Debt Management",score:i});const a=this.financeSummary.monthlyExpenses>0?this.financeSummary.savings/this.financeSummary.monthlyExpenses:0,l=Math.min(100,a/6*100);e.push({name:"Emergency Fund",score:l});const d=e.reduce((u,c)=>u+c.score,0)/e.length;return{score:Math.round(d),factors:e}}generateDailyInsights(){const e=[],s=this.getAllKPIs(),n=s.filter(u=>u.currentValue>=u.targetValue);n.length>0&&e.push(`You've achieved ${n.length} of ${s.length} KPI targets!`);const r=this.getTodayHabitStatus(),i=r.filter(u=>u.completed);i.length===r.length&&r.length>0?e.push("All habits completed today! Keep it up!"):i.length>0&&e.push(`${i.length}/${r.length} habits completed today.`);const a=this.getAllHabits().reduce((u,c)=>Math.max(u,c.streak),0);a>=7&&e.push(`Amazing ${a}-day streak! You're building a strong routine.`);const l=this.getUpcomingDeadlines(7);l.length>0&&e.push(`${l.length} goal deadline(s) coming up this week.`);const d=this.getAverageMood(7);return d>=4?e.push("Your mood has been great this week!"):d<3&&d>0&&e.push("Your mood has been lower than usual. Consider some self-care activities."),e}generateId(){return Date.now().toString(36)+Math.random().toString(36).substring(2,8)}clear(){this.kpis.clear(),this.goals.clear(),this.habits.clear(),this.moodEntries.clear()}}function Ie(){return new O}const G=f.createContext(null);function Be(){const o=f.useContext(G);if(!o)throw new Error("useLifeDashboard must be used within LifeDashboardProvider");return o}const v={dashboard:{display:"flex",flexDirection:"column",height:"100%",fontFamily:"'Inter', sans-serif",backgroundColor:"#f5f7fa",padding:"20px",gap:"20px",overflow:"auto"},header:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px"},title:{fontSize:"24px",fontWeight:600,color:"#1a1a2e"},grid:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(300px, 1fr))",gap:"20px"},card:{backgroundColor:"#fff",borderRadius:"12px",padding:"20px",boxShadow:"0 2px 8px rgba(0,0,0,0.08)"},cardTitle:{fontSize:"16px",fontWeight:600,color:"#1a1a2e",marginBottom:"16px"},progressBar:{height:"8px",backgroundColor:"#e0e0e0",borderRadius:"4px",overflow:"hidden"},progressFill:{height:"100%",borderRadius:"4px",transition:"width 0.3s ease"},statRow:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"8px 0",borderBottom:"1px solid #f0f0f0"},habitItem:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 0",borderBottom:"1px solid #f0f0f0"},habitCheck:{width:"24px",height:"24px",borderRadius:"50%",border:"2px solid #1976d2",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},moodEmoji:{fontSize:"28px",textAlign:"center"},insight:{backgroundColor:"#e3f2fd",borderRadius:"8px",padding:"12px 16px",marginBottom:"8px",fontSize:"14px",color:"#1565c0"}};function Me({service:o,className:e,style:s}){const[,n]=f.useState(0),r=f.useCallback(()=>{n(p=>p+1)},[]),i={service:o,refresh:r},a=o.generateDailyInsights(),l=o.getAllKPIs(),d=o.getTodayHabitStatus(),u=o.getActiveGoals(),c=o.getFinanceSummary(),h=o.calculateFinanceHealth(),m=p=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(p);return t.jsx(G.Provider,{value:i,children:t.jsxs("div",{className:e,style:{...v.dashboard,...s},children:[t.jsxs("div",{style:v.header,children:[t.jsx("div",{style:v.title,children:"Life Dashboard"}),t.jsx("div",{style:{color:"#666"},children:new Date().toLocaleDateString("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric"})})]}),a.length>0&&t.jsx("div",{children:a.map((p,b)=>t.jsx("div",{style:v.insight,children:p},b))}),t.jsxs("div",{style:v.grid,children:[t.jsxs("div",{style:v.card,children:[t.jsx("div",{style:v.cardTitle,children:"Personal KPIs"}),l.length===0?t.jsx("div",{style:{color:"#999",textAlign:"center",padding:"20px"},children:"No KPIs defined yet"}):l.slice(0,5).map(p=>{const b=o.calculateKPIProgress(p);return t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"4px"},children:[t.jsx("span",{style:{fontWeight:500},children:p.name}),t.jsxs("span",{style:{color:"#666"},children:[p.currentValue,p.unit?` ${p.unit}`:""," / ",p.targetValue,p.trend==="up"&&" โ†‘",p.trend==="down"&&" โ†“"]})]}),t.jsx("div",{style:v.progressBar,children:t.jsx("div",{style:{...v.progressFill,width:`${b}%`,backgroundColor:b>=100?"#4caf50":"#1976d2"}})})]},p.id)})]}),t.jsxs("div",{style:v.card,children:[t.jsx("div",{style:v.cardTitle,children:"Active Goals"}),u.length===0?t.jsx("div",{style:{color:"#999",textAlign:"center",padding:"20px"},children:"No active goals"}):u.slice(0,4).map(p=>t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"4px"},children:[t.jsx("span",{style:{fontWeight:500},children:p.title}),t.jsxs("span",{style:{color:"#666"},children:[p.progress,"%"]})]}),t.jsx("div",{style:v.progressBar,children:t.jsx("div",{style:{...v.progressFill,width:`${p.progress}%`,backgroundColor:"#ff9800"}})}),t.jsxs("div",{style:{fontSize:"12px",color:"#999",marginTop:"4px"},children:["Due: ",new Date(p.targetDate).toLocaleDateString()]})]},p.id))]}),t.jsxs("div",{style:v.card,children:[t.jsx("div",{style:v.cardTitle,children:"Today's Habits"}),d.length===0?t.jsx("div",{style:{color:"#999",textAlign:"center",padding:"20px"},children:"No habits tracked yet"}):d.map(({habit:p,completed:b,count:k})=>t.jsxs("div",{style:v.habitItem,children:[t.jsx("div",{style:{...v.habitCheck,backgroundColor:b?"#4caf50":"transparent",borderColor:b?"#4caf50":"#ccc"},onClick:()=>{o.completeHabit(p.id),r()},children:b&&t.jsx("span",{style:{color:"#fff"},children:"โœ“"})}),t.jsxs("div",{style:{flex:1},children:[t.jsx("div",{style:{fontWeight:500},children:p.name}),t.jsxs("div",{style:{fontSize:"12px",color:"#666"},children:[k,"/",p.targetPerPeriod," โ€ข ",p.streak," day streak"]})]})]},p.id))]}),t.jsxs("div",{style:v.card,children:[t.jsx("div",{style:v.cardTitle,children:"Finance Overview"}),t.jsxs("div",{style:v.statRow,children:[t.jsx("span",{children:"Net Worth"}),t.jsx("span",{style:{fontWeight:600},children:m(c.netWorth)})]}),t.jsxs("div",{style:v.statRow,children:[t.jsx("span",{children:"Monthly Income"}),t.jsx("span",{style:{color:"#4caf50"},children:m(c.monthlyIncome)})]}),t.jsxs("div",{style:v.statRow,children:[t.jsx("span",{children:"Monthly Expenses"}),t.jsx("span",{style:{color:"#f44336"},children:m(c.monthlyExpenses)})]}),t.jsxs("div",{style:v.statRow,children:[t.jsx("span",{children:"Savings Rate"}),t.jsxs("span",{children:[c.savingsRate.toFixed(1),"%"]})]}),t.jsxs("div",{style:{marginTop:"16px"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"8px"},children:[t.jsx("span",{children:"Finance Health"}),t.jsxs("span",{style:{fontWeight:600},children:[h.score,"/100"]})]}),t.jsx("div",{style:v.progressBar,children:t.jsx("div",{style:{...v.progressFill,width:`${h.score}%`,backgroundColor:h.score>=70?"#4caf50":h.score>=40?"#ff9800":"#f44336"}})})]})]}),t.jsxs("div",{style:v.card,children:[t.jsx("div",{style:v.cardTitle,children:"Mood & Health"}),t.jsxs("div",{style:{display:"flex",justifyContent:"space-around",marginBottom:"20px"},children:[t.jsxs("div",{style:{textAlign:"center"},children:[t.jsx("div",{style:v.moodEmoji,children:Re(Math.round(o.getAverageMood(7)))}),t.jsx("div",{style:{fontSize:"12px",color:"#666"},children:"Avg Mood (7d)"})]}),t.jsxs("div",{style:{textAlign:"center"},children:[t.jsxs("div",{style:{fontSize:"28px",fontWeight:600},children:[o.getAverageSleep(7).toFixed(1),"h"]}),t.jsx("div",{style:{fontSize:"12px",color:"#666"},children:"Avg Sleep (7d)"})]})]}),o.getMoodCorrelations().slice(0,2).map(p=>t.jsxs("div",{style:v.statRow,children:[t.jsx("span",{children:p.factor}),t.jsxs("span",{style:{color:p.correlation>0?"#4caf50":"#f44336"},children:[p.correlation>0?"โ†‘":"โ†“"," ",Math.abs(p.correlation*100).toFixed(0),"%"]})]},p.factor))]})]})]})})}function Re(o){return{1:"๐Ÿ˜ข",2:"๐Ÿ˜•",3:"๐Ÿ˜",4:"๐Ÿ˜Š",5:"๐Ÿ˜„"}[o]||"๐Ÿ˜"}const Pe={colors:{background:"#1a1a2e",surface:"#16213e",primary:"#0f3460",secondary:"#e94560",success:"#00c853",warning:"#ffab00",error:"#ff1744",text:"#ffffff",textSecondary:"#a0a0a0",border:"#2a2a4a"},spacing:{xs:"4px",sm:"8px",md:"16px",lg:"24px",xl:"32px"},borderRadius:"8px",fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"},ze=[{id:"name",label:"Name",sortable:!0,visible:!0},{id:"size",label:"Size",width:"100px",sortable:!0,visible:!0},{id:"progress",label:"Progress",width:"150px",sortable:!0,visible:!0},{id:"status",label:"Status",width:"100px",sortable:!0,visible:!0},{id:"seeds",label:"Seeds",width:"80px",sortable:!0,visible:!0},{id:"peers",label:"Peers",width:"80px",sortable:!0,visible:!0},{id:"downloadSpeed",label:"Down",width:"100px",sortable:!0,visible:!0},{id:"uploadSpeed",label:"Up",width:"100px",sortable:!0,visible:!0},{id:"eta",label:"ETA",width:"100px",sortable:!0,visible:!0},{id:"ratio",label:"Ratio",width:"80px",sortable:!0,visible:!0}],q=f.createContext(null);function T(){const o=f.useContext(q);if(!o)throw new Error("useTorrentUI must be used within TorrentUIProvider");return o}function B(o,e=2){if(o===0)return"0 B";const s=1024,n=["B","KB","MB","GB","TB","PB"],r=Math.floor(Math.log(o)/Math.log(s));return`${parseFloat((o/Math.pow(s,r)).toFixed(e))} ${n[r]}`}function R(o){return`${B(o)}/s`}function K(o){if(!o||o<=0)return"โˆž";if(o<60)return`${o}s`;if(o<3600)return`${Math.floor(o/60)}m`;if(o<86400){const n=Math.floor(o/3600),r=Math.floor(o%3600/60);return`${n}h ${r}m`}const e=Math.floor(o/86400),s=Math.floor(o%86400/3600);return`${e}d ${s}h`}function P(o){return o.toFixed(2)}function z(o,e){switch(o){case"downloading":return e.colors.primary;case"seeding":return e.colors.success;case"paused":return e.colors.textSecondary;case"checking":return e.colors.warning;case"error":return e.colors.error;case"queued":return e.colors.textSecondary;default:return e.colors.text}}function Q({client:o,config:e={},children:s}){const n=f.useMemo(()=>({...Pe,...e.theme}),[e.theme]),[r,i]=f.useState([]),[a,l]=f.useState(null),[d,u]=f.useState("all"),[c,h]=f.useState(""),m=f.useCallback(()=>{i(o.getAllTorrents())},[o]);f.useEffect(()=>{m();const b=setInterval(m,e.refreshInterval||1e3),k=()=>m(),I=()=>m();return o.on("torrent_added",k),o.on("torrent_removed",I),()=>{clearInterval(b),o.off("torrent_added",k),o.off("torrent_removed",I)}},[o,e.refreshInterval,m]);const p={client:o,config:e,theme:n,torrents:r,selectedTorrent:a,setSelectedTorrent:l,filter:d,setFilter:u,searchQuery:c,setSearchQuery:h,refresh:m};return t.jsx(q.Provider,{value:p,children:t.jsx("div",{style:{fontFamily:n.fontFamily,color:n.colors.text},children:s})})}function Y({progress:o,status:e,showLabel:s=!0,height:n="20px",className:r,style:i}){const{theme:a}=T(),l=Math.min(100,Math.max(0,o*100)),d=z(e,a);return t.jsxs("div",{className:r,style:{display:"flex",alignItems:"center",gap:a.spacing.sm,...i},children:[t.jsx("div",{style:{flex:1,height:n,backgroundColor:a.colors.border,borderRadius:a.borderRadius,overflow:"hidden"},children:t.jsx("div",{style:{width:`${l}%`,height:"100%",backgroundColor:d,transition:"width 0.3s ease-in-out"}})}),s&&t.jsxs("span",{style:{fontSize:"12px",minWidth:"45px",textAlign:"right"},children:[l.toFixed(1),"%"]})]})}function _({status:o,className:e,style:s}){const{theme:n}=T(),r=z(o,n),i={downloading:"Downloading",seeding:"Seeding",paused:"Paused",checking:"Checking",error:"Error",queued:"Queued"};return t.jsxs("span",{className:e,style:{display:"inline-flex",alignItems:"center",gap:n.spacing.xs,padding:`${n.spacing.xs} ${n.spacing.sm}`,backgroundColor:`${r}20`,color:r,borderRadius:n.borderRadius,fontSize:"12px",fontWeight:500,textTransform:"capitalize",...s},children:[t.jsx("span",{style:{width:"8px",height:"8px",borderRadius:"50%",backgroundColor:r}}),i[o]]})}function X({onTorrentSelect:o,onTorrentDoubleClick:e,className:s,style:n}){const{theme:r,torrents:i,filter:a,searchQuery:l,selectedTorrent:d,setSelectedTorrent:u,config:c}=T(),[h,m]=f.useState(c.defaultSortBy||"name"),[p,b]=f.useState(c.defaultSortOrder||"asc"),k=c.columns||ze,I=f.useMemo(()=>i.filter(y=>{if(a!=="all"){if(a==="completed"){if(y.stats.progress<1)return!1}else if(a==="active"){if(y.status!=="downloading"&&y.status!=="seeding")return!1}else if(y.status!==a)return!1}if(l){const D=l.toLowerCase();if(!y.metadata.name.toLowerCase().includes(D))return!1}return!0}),[i,a,l]),S=f.useMemo(()=>[...I].sort((y,D)=>{let C,A;switch(h){case"name":C=y.metadata.name.toLowerCase(),A=D.metadata.name.toLowerCase();break;case"size":C=y.metadata.size,A=D.metadata.size;break;case"progress":C=y.stats.progress,A=D.stats.progress;break;case"status":C=y.status,A=D.status;break;case"downloadSpeed":C=y.stats.downloadSpeed,A=D.stats.downloadSpeed;break;case"uploadSpeed":C=y.stats.uploadSpeed,A=D.stats.uploadSpeed;break;case"ratio":C=y.stats.ratio,A=D.stats.ratio;break;default:C=y.metadata.name,A=D.metadata.name}return C<A?p==="asc"?-1:1:C>A?p==="asc"?1:-1:0}),[I,h,p]),M=y=>{h===y?b(p==="asc"?"desc":"asc"):(m(y),b("asc"))},te=y=>{u(y),o==null||o(y)};return t.jsxs("div",{className:s,style:{backgroundColor:r.colors.surface,borderRadius:r.borderRadius,overflow:"hidden",...n},children:[t.jsx("div",{style:{display:"grid",gridTemplateColumns:k.filter(y=>y.visible!==!1).map(y=>y.width||"1fr").join(" "),padding:`${r.spacing.sm} ${r.spacing.md}`,backgroundColor:r.colors.primary,borderBottom:`1px solid ${r.colors.border}`,fontSize:"12px",fontWeight:600,textTransform:"uppercase"},children:k.filter(y=>y.visible!==!1).map(y=>t.jsxs("div",{onClick:()=>y.sortable&&M(y.id),style:{cursor:y.sortable?"pointer":"default",display:"flex",alignItems:"center",gap:r.spacing.xs},children:[y.label,h===y.id&&t.jsx("span",{children:p==="asc"?"โ†‘":"โ†“"})]},y.id))}),t.jsx("div",{style:{maxHeight:"500px",overflowY:"auto"},children:S.length===0?t.jsx("div",{style:{padding:r.spacing.xl,textAlign:"center",color:r.colors.textSecondary},children:"No torrents found"}):S.map(y=>t.jsx(Fe,{torrent:y,columns:k,isSelected:d===y.metadata.infoHash,onClick:()=>te(y.metadata.infoHash),onDoubleClick:()=>e==null?void 0:e(y.metadata.infoHash)},y.metadata.infoHash))})]})}function Fe({torrent:o,columns:e,isSelected:s,onClick:n,onDoubleClick:r}){const{theme:i}=T(),{metadata:a,stats:l,status:d}=o,u=c=>{switch(c){case"name":return t.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[t.jsx("span",{style:{fontWeight:500},children:a.name}),t.jsxs("span",{style:{fontSize:"11px",color:i.colors.textSecondary},children:[a.infoHash.substring(0,8),"..."]})]});case"size":return B(a.size);case"progress":return t.jsx(Y,{progress:l.progress,status:d,height:"16px"});case"status":return t.jsx(_,{status:d});case"seeds":return l.seeds;case"peers":return l.peers;case"downloadSpeed":return l.downloadSpeed>0?R(l.downloadSpeed):"-";case"uploadSpeed":return l.uploadSpeed>0?R(l.uploadSpeed):"-";case"eta":return d==="downloading"?K(l.eta):"-";case"ratio":return P(l.ratio);default:return"-"}};return t.jsx("div",{onClick:n,onDoubleClick:r,style:{display:"grid",gridTemplateColumns:e.filter(c=>c.visible!==!1).map(c=>c.width||"1fr").join(" "),padding:`${i.spacing.sm} ${i.spacing.md}`,backgroundColor:s?i.colors.primary:"transparent",borderBottom:`1px solid ${i.colors.border}`,cursor:"pointer",transition:"background-color 0.15s",fontSize:"13px"},children:e.filter(c=>c.visible!==!1).map(c=>t.jsx("div",{style:{display:"flex",alignItems:"center",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u(c.id)},c.id))})}function J({className:o,style:e}){const{theme:s,filter:n,setFilter:r,searchQuery:i,setSearchQuery:a,torrents:l}=T(),d=f.useMemo(()=>{const c={all:l.length,downloading:0,seeding:0,paused:0,checking:0,error:0,completed:0,active:0};for(const h of l)h.status==="downloading"&&c.downloading++,h.status==="seeding"&&c.seeding++,h.status==="paused"&&c.paused++,h.status==="checking"&&c.checking++,h.status==="error"&&c.error++,h.stats.progress>=1&&c.completed++,(h.status==="downloading"||h.status==="seeding")&&c.active++;return c},[l]),u=[{id:"all",label:"All"},{id:"downloading",label:"Downloading"},{id:"seeding",label:"Seeding"},{id:"completed",label:"Completed"},{id:"active",label:"Active"},{id:"paused",label:"Paused"},{id:"error",label:"Error"}];return t.jsxs("div",{className:o,style:{display:"flex",alignItems:"center",gap:s.spacing.md,padding:s.spacing.md,backgroundColor:s.colors.surface,borderRadius:s.borderRadius,...e},children:[t.jsx("div",{style:{display:"flex",gap:s.spacing.xs},children:u.map(c=>t.jsxs("button",{onClick:()=>r(c.id),style:{padding:`${s.spacing.xs} ${s.spacing.sm}`,backgroundColor:n===c.id?s.colors.primary:"transparent",color:n===c.id?s.colors.text:s.colors.textSecondary,border:"none",borderRadius:s.borderRadius,cursor:"pointer",fontSize:"13px",transition:"all 0.15s"},children:[c.label," (",d[c.id],")"]},c.id))}),t.jsx("div",{style:{flex:1}}),t.jsx("input",{type:"text",placeholder:"Search torrents...",value:i,onChange:c=>a(c.target.value),style:{padding:`${s.spacing.sm} ${s.spacing.md}`,backgroundColor:s.colors.background,color:s.colors.text,border:`1px solid ${s.colors.border}`,borderRadius:s.borderRadius,outline:"none",fontSize:"13px",width:"250px"}})]})}function Z({infoHash:o,className:e,style:s}){const{theme:n,client:r}=T(),[i,a]=f.useState("files"),l=r==null?void 0:r.getTorrent(o);if(!l)return null;const{metadata:d,stats:u,files:c,peers:h,trackers:m}=l,p=[{id:"files",label:`Files (${c.length})`},{id:"peers",label:`Peers (${h.length})`},{id:"trackers",label:`Trackers (${m.length})`},{id:"info",label:"Info"}];return t.jsxs("div",{className:e,style:{backgroundColor:n.colors.surface,borderRadius:n.borderRadius,overflow:"hidden",...s},children:[t.jsx("div",{style:{display:"flex",borderBottom:`1px solid ${n.colors.border}`},children:p.map(b=>t.jsx("button",{onClick:()=>a(b.id),style:{padding:`${n.spacing.sm} ${n.spacing.md}`,backgroundColor:i===b.id?n.colors.primary:"transparent",color:i===b.id?n.colors.text:n.colors.textSecondary,border:"none",cursor:"pointer",fontSize:"13px",fontWeight:500},children:b.label},b.id))}),t.jsxs("div",{style:{padding:n.spacing.md,maxHeight:"300px",overflowY:"auto"},children:[i==="files"&&t.jsx(We,{files:c}),i==="peers"&&t.jsx(Le,{peers:h}),i==="trackers"&&t.jsx(Ue,{trackers:m}),i==="info"&&t.jsx(Ne,{metadata:d,stats:u,addedAt:l.addedAt})]})]})}function We({files:o}){const{theme:e}=T();return t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:e.spacing.xs},children:o.map((s,n)=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:e.spacing.md,padding:e.spacing.sm,backgroundColor:e.colors.background,borderRadius:e.borderRadius,fontSize:"13px"},children:[t.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis"},children:s.path}),t.jsx("span",{style:{color:e.colors.textSecondary},children:B(s.size)}),t.jsxs("span",{style:{width:"50px",textAlign:"right"},children:[(s.progress*100).toFixed(0),"%"]})]},n))})}function Le({peers:o}){const{theme:e}=T();return t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:e.spacing.xs},children:o.length===0?t.jsx("div",{style:{color:e.colors.textSecondary},children:"No peers connected"}):o.map(s=>t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 80px 100px 100px 80px",alignItems:"center",padding:e.spacing.sm,backgroundColor:e.colors.background,borderRadius:e.borderRadius,fontSize:"12px"},children:[t.jsxs("span",{children:[s.ip,":",s.port,s.isUTP&&t.jsx("span",{style:{marginLeft:"4px",color:e.colors.secondary},children:"ยตTP"}),s.isEncrypted&&t.jsx("span",{style:{marginLeft:"4px"},children:"๐Ÿ”’"})]}),t.jsx("span",{style:{color:e.colors.textSecondary},children:s.client||"Unknown"}),t.jsxs("span",{style:{color:e.colors.success},children:["โ†“ ",R(s.downloadSpeed)]}),t.jsxs("span",{style:{color:e.colors.warning},children:["โ†‘ ",R(s.uploadSpeed)]}),t.jsxs("span",{children:[(s.progress*100).toFixed(0),"%"]})]},s.id))})}function Ue({trackers:o}){const{theme:e}=T();return t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:e.spacing.xs},children:o.map((s,n)=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:e.spacing.md,padding:e.spacing.sm,backgroundColor:e.colors.background,borderRadius:e.borderRadius,fontSize:"12px"},children:[t.jsx("span",{style:{width:"8px",height:"8px",borderRadius:"50%",backgroundColor:s.status==="working"?e.colors.success:s.status==="error"?e.colors.error:e.colors.textSecondary}}),t.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis"},children:s.url}),t.jsxs("span",{style:{color:e.colors.textSecondary},children:["S: ",s.seeds," | L: ",s.leechers]})]},n))})}function Ne({metadata:o,stats:e,addedAt:s}){const{theme:n}=T(),r=[{label:"Name",value:o.name},{label:"Info Hash",value:o.infoHash},{label:"Size",value:B(o.size)},{label:"Pieces",value:`${e.piecesComplete} / ${e.piecesTotal}`},{label:"Downloads",value:B(e.downloaded)},{label:"Uploaded",value:B(e.uploaded)},{label:"Ratio",value:P(e.ratio)},{label:"Availability",value:e.availability.toFixed(2)},{label:"Wasted",value:B(e.wastedBytes)},{label:"Hash Fails",value:e.hashFailures},{label:"Added",value:s.toLocaleString()},{label:"Comment",value:o.comment||"-"},{label:"Private",value:o.isPrivate?"Yes":"No"}];return t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:n.spacing.xs},children:r.map(i=>t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",padding:`${n.spacing.xs} ${n.spacing.sm}`,fontSize:"13px"},children:[t.jsx("span",{style:{color:n.colors.textSecondary},children:i.label}),t.jsx("span",{style:{fontFamily:"monospace"},children:i.value})]},i.label))})}function ee({isOpen:o,onClose:e,onAdd:s,className:n}){const{theme:r,config:i,client:a}=T(),[l,d]=f.useState(""),[u,c]=f.useState(""),[h,m]=f.useState(!1);if(!o)return null;const p=b=>{b.preventDefault(),l.trim()&&(s(l.trim(),{path:u||void 0,paused:h}),d(""),c(""),m(!1),e())};return t.jsx("div",{className:n,style:{position:"fixed",inset:0,backgroundColor:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},onClick:e,children:t.jsxs("div",{style:{backgroundColor:r.colors.surface,borderRadius:r.borderRadius,padding:r.spacing.lg,width:"500px",maxWidth:"90vw"},onClick:b=>b.stopPropagation(),children:[t.jsx("h2",{style:{margin:0,marginBottom:r.spacing.md},children:"Add Torrent"}),t.jsxs("form",{onSubmit:p,style:{display:"flex",flexDirection:"column",gap:r.spacing.md},children:[t.jsxs("div",{children:[t.jsx("label",{style:{display:"block",marginBottom:r.spacing.xs,fontSize:"13px"},children:"Magnet URI or .torrent file path"}),t.jsx("input",{type:"text",value:l,onChange:b=>d(b.target.value),placeholder:"magnet:?xt=urn:btih:... or C:\\path\\to\\file.torrent",style:{width:"100%",padding:r.spacing.sm,backgroundColor:r.colors.background,color:r.colors.text,border:`1px solid ${r.colors.border}`,borderRadius:r.borderRadius,outline:"none",fontSize:"13px"}})]}),t.jsxs("div",{children:[t.jsx("label",{style:{display:"block",marginBottom:r.spacing.xs,fontSize:"13px"},children:"Save Location"}),t.jsx("input",{type:"text",value:u,onChange:b=>c(b.target.value),placeholder:"Leave empty for default",style:{width:"100%",padding:r.spacing.sm,backgroundColor:r.colors.background,color:r.colors.text,border:`1px solid ${r.colors.border}`,borderRadius:r.borderRadius,outline:"none",fontSize:"13px"}})]}),t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:r.spacing.sm,fontSize:"13px"},children:[t.jsx("input",{type:"checkbox",checked:h,onChange:b=>m(b.target.checked)}),"Start paused"]}),t.jsxs("div",{style:{display:"flex",gap:r.spacing.sm,justifyContent:"flex-end"},children:[t.jsx("button",{type:"button",onClick:e,style:{padding:`${r.spacing.sm} ${r.spacing.md}`,backgroundColor:"transparent",color:r.colors.text,border:`1px solid ${r.colors.border}`,borderRadius:r.borderRadius,cursor:"pointer"},children:"Cancel"}),t.jsx("button",{type:"submit",style:{padding:`${r.spacing.sm} ${r.spacing.md}`,backgroundColor:r.colors.primary,color:r.colors.text,border:"none",borderRadius:r.borderRadius,cursor:"pointer"},children:"Add Torrent"})]})]})]})})}function He({client:o,config:e,className:s,style:n}){const[r,i]=f.useState(!1),[a,l]=f.useState(null);return t.jsx(Q,{client:o,config:e,children:t.jsxs("div",{className:s,style:{display:"flex",flexDirection:"column",gap:"16px",height:"100%",...n},children:[t.jsx("div",{style:{display:"flex",gap:"8px"},children:t.jsx("button",{onClick:()=>i(!0),style:{padding:"8px 16px",backgroundColor:"#0f3460",color:"white",border:"none",borderRadius:"8px",cursor:"pointer"},children:"+ Add Torrent"})}),t.jsx(J,{}),t.jsx(X,{onTorrentSelect:l,style:{flex:1}}),a&&t.jsx(Z,{infoHash:a}),t.jsx(ee,{isOpen:r,onClose:()=>i(!1),onAdd:(d,u)=>o.addTorrent(d,u)})]})})}exports.AddTorrentDialog=ee;exports.FilterBar=J;exports.HealthService=L;exports.LifeDashboardService=O;exports.NiceHealth=ae;exports.NiceLifeDashboard=Me;exports.NicePersonalFinance=me;exports.NiceTaskManager=De;exports.NiceTorrentUI=He;exports.PersonalFinanceService=N;exports.ProgressBar=Y;exports.StatusBadge=_;exports.TaskManagerService=$;exports.TorrentDetails=Z;exports.TorrentList=X;exports.TorrentUIProvider=Q;exports.createHealthService=ie;exports.createLifeDashboardService=Ie;exports.createPersonalFinanceService=xe;exports.createTaskManagerService=ke;exports.formatBytes=B;exports.formatETA=K;exports.formatRatio=P;exports.formatSpeed=R;exports.getStatusColor=z;exports.useHealth=oe;exports.useLifeDashboard=Be;exports.usePersonalFinance=fe;exports.useTaskManager=Te;exports.useTorrentUI=T;
package/dist/index.mjs CHANGED
@@ -1805,7 +1805,12 @@ class pe {
1805
1805
  calculateNextRecurrence(e) {
1806
1806
  if (!e.recurrence || !e.dueDate)
1807
1807
  return null;
1808
- const { pattern: t, interval: n, endDate: r, endAfterOccurrences: s } = e.recurrence, l = new Date(e.dueDate);
1808
+ const {
1809
+ pattern: t,
1810
+ interval: n,
1811
+ endDate: r,
1812
+ endAfterOccurrences: s
1813
+ } = e.recurrence, l = new Date(e.dueDate);
1809
1814
  let d;
1810
1815
  switch (t) {
1811
1816
  case "daily":
@@ -1864,10 +1869,11 @@ class pe {
1864
1869
  return [...e].sort((s, l) => {
1865
1870
  let d = 0;
1866
1871
  switch (t) {
1867
- case "dueDate":
1872
+ case "dueDate": {
1868
1873
  const c = s.dueDate ? new Date(s.dueDate).getTime() : 1 / 0, g = l.dueDate ? new Date(l.dueDate).getTime() : 1 / 0;
1869
1874
  d = c - g;
1870
1875
  break;
1876
+ }
1871
1877
  case "priority":
1872
1878
  d = j[s.priority] - j[l.priority];
1873
1879
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nice2dev/templates",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "Nice2Dev Templates - Ready-to-use application templates (Health, PersonalFinance, TaskManager, LifeDashboard, TorrentUI)",
5
5
  "type": "module",
6
6
  "sideEffects": [