import{t as e}from"./vendor-db-laug4hUC.js";var t=new Set([`Зарядка 30 мин`,`Прогулка / спорт`,`Медитация 30 мин`,`Чтение / обучение`,`Белок 120 г`,`Завтрак`,`Обед`,`Ужин`,`Сон до 00:00`,`Подъём 08:00`]),n=[/^Зарядка \d+\s*мин$/,/^Медитация \d+\s*мин$/,/^Белок \d+\s*г$/,/^Сон до .+$/,/^Подъём .+$/];function r(e){let r=e.trim();return t.has(r)?!0:n.some(e=>e.test(r))}function i(){return crypto.randomUUID?.()??`_${Date.now()}_${Math.random().toString(36).slice(2)}`}async function a(e){let t=await w.habits.orderBy(`group`).toArray();return e?.activeOnly?t.filter(e=>e.active):t}async function o(){return(await w.habits.toArray()).filter(e=>e.active&&e.type===`daily`).length}function s(e){let t=e?.trim();if(!t)return;let n=/^(\d{1,2}):(\d{2})$/.exec(t);if(!n)return;let r=Number(n[1]),i=Number(n[2]);if(!(r<0||r>23||i<0||i>59))return`${String(r).padStart(2,`0`)}:${String(i).padStart(2,`0`)}`}async function c(e){let t=new Date().toISOString(),n={id:i(),name:e.name,type:e.type,targetMonthlyCount:e.targetMonthlyCount??null,target:e.target??null,active:e.active??!0,group:e.group,daysOfWeek:e.daysOfWeek&&e.daysOfWeek.length>0?e.daysOfWeek:void 0,notes:e.notes?.trim()||void 0,preferredTimeHHMM:s(e.preferredTimeHHMM),createdAt:t,updatedAt:t};return await w.habits.add(n),n}async function l(e,t){let n=await w.habits.get(e);if(!n)return;let r=`preferredTimeHHMM`in t?s(t.preferredTimeHHMM):n.preferredTimeHHMM,i={...n,...t,preferredTimeHHMM:r,updatedAt:new Date().toISOString()};return await w.habits.put(i),i}async function u(e){return w.habitLogs.where(`date`).equals(e).toArray()}async function d(e,t,n){let r=await w.habitLogs.where(`[habitId+date]`).equals([e,t]).first();if(r)return r;let a={id:i(),habitId:e,date:t,value:n,note:null};return await w.habitLogs.add(a),a}async function f(e,t,n){let r=await d(e,t,!1);await w.habitLogs.update(r.id,{value:n})}async function p(e,t,n){let r=await d(e,t,0),i=typeof r.value==`number`?r.value:0;await w.habitLogs.update(r.id,{value:i+n})}async function m(e){let t=(await w.habits.toArray()).filter(e=>e.type===`daily_numeric`).map(e=>e.id);return t.length===0?0:(await w.habitLogs.where(`date`).equals(e).toArray()).filter(e=>t.includes(e.habitId)).reduce((e,t)=>e+(typeof t.value==`number`?t.value:0),0)}function h(e,t){if(e.type===`daily_numeric`)return!1;let n=new Date(t+`T12:00:00`).getDay();return e.type===`monthly`?!e.daysOfWeek||e.daysOfWeek.length===0?!0:e.daysOfWeek.includes(n):!e.daysOfWeek||e.daysOfWeek.length===0?e.type===`daily`||e.type===`weekly`||e.type===`monthly`:e.daysOfWeek.includes(n)}async function g(e,t){return(await a(t)).filter(t=>h(t,e))}async function _(e){let t=(await g(e,{activeOnly:!0})).filter(e=>e.type===`daily`||e.type===`weekly`||e.type===`monthly`),n=t.length;return{done:(await u(e)).filter(e=>t.find(t=>t.id===e.habitId)&&e.value===!0).length,total:n}}async function v(e,t){let n=await w.habitLogs.where(`[habitId+date]`).equals([e,t]).first();n&&await w.habitLogs.update(n.id,{value:0})}async function y(){let e=await w.habits.toArray();return e.find(e=>e.type===`daily_numeric`&&/вода/i.test(e.name))||(e.find(e=>e.type===`daily_numeric`)??null)}async function b(e){return await y()||c({name:`Вода (мл)`,group:`Питание`,type:`daily_numeric`,target:e??null,active:!0})}function x(e){return e.type===`daily_numeric`&&/шаг/i.test(e.name)}async function S(e){await w.transaction(`rw`,w.habits,w.habitLogs,async()=>{await w.habitLogs.where(`habitId`).equals(e).delete(),await w.habits.delete(e)})}var C=`RMSLifeTracker`,w=new class extends e{tasks;habits;habitLogs;transactions;settings;savingsGoals;savingsContributions;debts;debtPayments;foods;mealEntries;mealPlans;mealPlanItems;recipes;userFoodCatalog;pantryItems;trainingScheduleItems;trainingCompletionLogs;supplementPlanItems;supplementIntakeLogs;chatThreads;chatMessages;labResults;supplementProducts;supplementPlanProductLinks;supplementProductTemplates;supplementReminders;subscriptions;subscriptionReminders;holidays;authSession;constructor(){super(C),this.version(2).stores({tasks:`id, status, dueDate, createdAt, topPriorityOrder`,habits:`id, active, group`,habitLogs:`id, habitId, date, [habitId+date]`,transactions:`id, date, type, category`,settings:`id`,savingsGoals:`id, active, name`,savingsContributions:`id, goalId, dateISO`}).upgrade(async e=>{let t=e.table(`settings`),n=e.table(`savingsGoals`),r=await t.get(`singleton`);if(!r||(await n.toArray()).length>0)return;let i=r.move,a=i?.moveFundGoal??3e5,o=i?.moveFundSaved??0,s=new Date().toISOString(),c=typeof crypto<`u`&&`randomUUID`in crypto&&crypto.randomUUID()||`goal_${Date.now()}`;await n.add({id:c,name:`Переезд`,targetRub:Math.max(0,Math.round(a)),savedRub:Math.max(0,Math.round(o)),active:!0,createdAt:s,updatedAt:s})}),this.version(3).stores({tasks:`id, status, dueDate, createdAt, topPriorityOrder`,habits:`id, active, group`,habitLogs:`id, habitId, date, [habitId+date]`,transactions:`id, date, type, category`,settings:`id`,savingsGoals:`id, active, name, createdAt`,savingsContributions:`id, goalId, dateISO`}),this.version(4).stores({tasks:`id, status, dueDate, createdAt, topPriorityOrder`,habits:`id, active, group`,habitLogs:`id, habitId, date, [habitId+date]`,transactions:`id, date, type, category`,settings:`id`,savingsGoals:`id, active, name, createdAt`,savingsContributions:`id, goalId, dateISO`,debts:`id, active, name, createdAt`,debtPayments:`id, debtId, dateISO`}),this.version(5).stores({tasks:`id, status, dueDate, createdAt, topPriorityOrder`,habits:`id, active, group`,habitLogs:`id, habitId, date, [habitId+date]`,transactions:`id, date, type, category`,settings:`id`,savingsGoals:`id, active, name, createdAt`,savingsContributions:`id, goalId, dateISO`,debts:`id, active, name, createdAt`,debtPayments:`id, debtId, dateISO`,foods:`id, name, createdAt`,mealEntries:`id, dateISO, timeHHMM, foodId`}),this.version(6).stores({tasks:`id, status, dueDate, createdAt, topPriorityOrder`,habits:`id, active, group`,habitLogs:`id, habitId, date, [habitId+date]`,transactions:`id, date, type, category`,settings:`id`,savingsGoals:`id, active, name, createdAt`,savingsContributions:`id, goalId, dateISO`,debts:`id, active, name, createdAt`,debtPayments:`id, debtId, dateISO`,foods:`id, name, createdAt`,mealEntries:`id, dateISO, timeHHMM, foodId, mealGroupId`}),this.version(7).stores({tasks:`id, status, dueDate, createdAt, topPriorityOrder`,habits:`id, active, group`,habitLogs:`id, habitId, date, [habitId+date]`,transactions:`id, date, type, category`,settings:`id`,savingsGoals:`id, active, name, createdAt`,savingsContributions:`id, goalId, dateISO`,debts:`id, active, name, createdAt`,debtPayments:`id, debtId, dateISO`,foods:`id, name, createdAt`,mealEntries:`id, dateISO, timeHHMM, foodId, mealGroupId`,mealPlans:`id, weekStartISO, createdAtISO, updatedAtISO`,mealPlanItems:`id, planId, dateISO, mealIndex, [planId+dateISO+mealIndex]`}),this.version(8).stores({tasks:`id, status, dueDate, createdAt, topPriorityOrder`,habits:`id, active, group`,habitLogs:`id, habitId, date, [habitId+date]`,transactions:`id, date, type, category`,settings:`id`,savingsGoals:`id, active, name, createdAt`,savingsContributions:`id, goalId, dateISO`,debts:`id, active, name, createdAt`,debtPayments:`id, debtId, dateISO`,foods:`id, name, createdAt`,mealEntries:`id, dateISO, timeHHMM, foodId, mealGroupId`,mealPlans:`id, weekStartISO, createdAtISO, updatedAtISO`,mealPlanItems:`id, planId, dateISO, mealIndex, [planId+dateISO+mealIndex]`,recipes:`id, source, createdAt`}),this.version(9).stores({tasks:`id, status, dueDate, createdAt, topPriorityOrder`,habits:`id, active, group`,habitLogs:`id, habitId, date, [habitId+date]`,transactions:`id, date, type, category`,settings:`id`,savingsGoals:`id, active, name, createdAt`,savingsContributions:`id, goalId, dateISO`,debts:`id, active, name, createdAt`,debtPayments:`id, debtId, dateISO`,foods:`id, name, createdAt`,mealEntries:`id, dateISO, timeHHMM, foodId, mealGroupId`,mealPlans:`id, weekStartISO, createdAtISO, updatedAtISO`,mealPlanItems:`id, planId, dateISO, mealIndex, [planId+dateISO+mealIndex]`,recipes:`id, source, createdAt`,userFoodCatalog:`id, group, createdAt`}),this.version(10).stores({tasks:`id, status, dueDate, createdAt, topPriorityOrder`,habits:`id, active, group`,habitLogs:`id, habitId, date, [habitId+date]`,transactions:`id, date, type, category`,settings:`id`,savingsGoals:`id, active, name, createdAt`,savingsContributions:`id, goalId, dateISO`,debts:`id, active, name, createdAt`,debtPayments:`id, debtId, dateISO`,foods:`id, name, createdAt`,mealEntries:`id, dateISO, timeHHMM, foodId, mealGroupId`,mealPlans:`id, weekStartISO, createdAtISO, updatedAtISO`,mealPlanItems:`id, planId, dateISO, mealIndex, [planId+dateISO+mealIndex]`,recipes:`id, source, createdAt`,userFoodCatalog:`id, group, createdAt`,pantryItems:`id, &userProductId, updatedAtISO`}).upgrade(async e=>{let t=e.table(`pantryItems`),n=await t.toArray();if(n.length===0)return;let r=new Map;for(let e of n){let t=e.userProductId;if(!t)continue;let n=r.get(t);if(!n){r.set(t,e);continue}let i=n.updatedAtISO??``;(e.updatedAtISO??``)>i&&r.set(t,e)}await t.clear();let i=Array.from(r.values());i.length>0&&await t.bulkAdd(i)}),this.version(11).stores({tasks:`id, status, dueDate, createdAt, topPriorityOrder`,habits:`id, active, group`,habitLogs:`id, habitId, date, [habitId+date]`,transactions:`id, date, type, category`,settings:`id`,savingsGoals:`id, active, name, createdAt`,savingsContributions:`id, goalId, dateISO`,debts:`id, active, name, createdAt`,debtPayments:`id, debtId, dateISO`,foods:`id, name, createdAt`,mealEntries:`id, dateISO, timeHHMM, foodId, mealGroupId`,mealPlans:`id, weekStartISO, createdAtISO, updatedAtISO`,mealPlanItems:`id, planId, dateISO, mealIndex, [planId+dateISO+mealIndex]`,recipes:`id, source, createdAt`,userFoodCatalog:`id, group, createdAt`,pantryItems:`id, &userProductId, updatedAtISO`,trainingScheduleItems:`id, active, recurrence, dateISO, timeHHMM`,supplementPlanItems:`id, active, supplementCatalogId, timing`}),this.version(12).stores({tasks:`id, status, dueDate, createdAt, topPriorityOrder`,habits:`id, active, group`,habitLogs:`id, habitId, date, [habitId+date]`,transactions:`id, date, type, category`,settings:`id`,savingsGoals:`id, active, name, createdAt`,savingsContributions:`id, goalId, dateISO`,debts:`id, active, name, createdAt`,debtPayments:`id, debtId, dateISO`,foods:`id, name, createdAt`,mealEntries:`id, dateISO, timeHHMM, foodId, mealGroupId`,mealPlans:`id, weekStartISO, createdAtISO, updatedAtISO`,mealPlanItems:`id, planId, dateISO, mealIndex, [planId+dateISO+mealIndex]`,recipes:`id, source, createdAt`,userFoodCatalog:`id, group, createdAt`,pantryItems:`id, &userProductId, updatedAtISO`,trainingScheduleItems:`id, active, recurrence, dateISO, timeHHMM`,supplementPlanItems:`id, active, supplementCatalogId, timing`,supplementIntakeLogs:`id, planItemId, supplementCatalogId, supplementKnowledgeId, dateISO, status, source, [dateISO+planItemId], [dateISO+status]`}),this.version(13).stores({tasks:`id, status, dueDate, createdAt, topPriorityOrder`,habits:`id, active, group`,habitLogs:`id, habitId, date, [habitId+date]`,transactions:`id, date, type, category`,settings:`id`,savingsGoals:`id, active, name, createdAt`,savingsContributions:`id, goalId, dateISO`,debts:`id, active, name, createdAt`,debtPayments:`id, debtId, dateISO`,foods:`id, name, createdAt`,mealEntries:`id, dateISO, timeHHMM, foodId, mealGroupId`,mealPlans:`id, weekStartISO, createdAtISO, updatedAtISO`,mealPlanItems:`id, planId, dateISO, mealIndex, [planId+dateISO+mealIndex]`,recipes:`id, source, createdAt`,userFoodCatalog:`id, group, createdAt`,pantryItems:`id, &userProductId, updatedAtISO`,trainingScheduleItems:`id, active, recurrence, dateISO, timeHHMM`,trainingCompletionLogs:`id, dateISO, trainingId, [dateISO+trainingId], [dateISO+title]`,supplementPlanItems:`id, active, supplementCatalogId, timing`,supplementIntakeLogs:`id, planItemId, supplementCatalogId, supplementKnowledgeId, dateISO, status, source, [dateISO+planItemId], [dateISO+status]`}),this.version(14).stores({tasks:`id, status, dueDate, createdAt, topPriorityOrder`,habits:`id, active, group`,habitLogs:`id, habitId, date, [habitId+date]`,transactions:`id, date, type, category`,settings:`id`,savingsGoals:`id, active, name, createdAt`,savingsContributions:`id, goalId, dateISO`,debts:`id, active, name, createdAt`,debtPayments:`id, debtId, dateISO`,foods:`id, name, createdAt`,mealEntries:`id, dateISO, timeHHMM, foodId, mealGroupId`,mealPlans:`id, weekStartISO, createdAtISO, updatedAtISO`,mealPlanItems:`id, planId, dateISO, mealIndex, [planId+dateISO+mealIndex]`,recipes:`id, source, createdAt`,userFoodCatalog:`id, group, createdAt`,pantryItems:`id, &userProductId, updatedAtISO`,trainingScheduleItems:`id, active, recurrence, dateISO, timeHHMM`,trainingCompletionLogs:`id, dateISO, trainingId, [dateISO+trainingId], [dateISO+title]`,supplementPlanItems:`id, active, supplementCatalogId, timing`,supplementIntakeLogs:`id, planItemId, supplementCatalogId, supplementKnowledgeId, dateISO, status, source, [dateISO+planItemId], [dateISO+status]`,chatThreads:`id, updatedAtISO, lastMessageAtISO, archived`,chatMessages:`id, threadId, createdAtISO, status, source, cloudActionId, telegramMessageId`}),this.version(15).stores({tasks:`id, status, dueDate, createdAt, topPriorityOrder`,habits:`id, active, group`,habitLogs:`id, habitId, date, [habitId+date]`,transactions:`id, date, type, category`,settings:`id`,savingsGoals:`id, active, name, createdAt`,savingsContributions:`id, goalId, dateISO`,debts:`id, active, name, createdAt`,debtPayments:`id, debtId, dateISO`,foods:`id, name, createdAt`,mealEntries:`id, dateISO, timeHHMM, foodId, mealGroupId`,mealPlans:`id, weekStartISO, createdAtISO, updatedAtISO`,mealPlanItems:`id, planId, dateISO, mealIndex, [planId+dateISO+mealIndex]`,recipes:`id, source, createdAt`,userFoodCatalog:`id, group, createdAt`,pantryItems:`id, &userProductId, updatedAtISO`,trainingScheduleItems:`id, active, recurrence, dateISO, timeHHMM`,trainingCompletionLogs:`id, dateISO, trainingId, [dateISO+trainingId], [dateISO+title]`,supplementPlanItems:`id, active, supplementCatalogId, timing`,supplementIntakeLogs:`id, planItemId, supplementCatalogId, supplementKnowledgeId, dateISO, status, source, [dateISO+planItemId], [dateISO+status]`,chatThreads:`id, updatedAtISO, lastMessageAtISO, archived`,chatMessages:`id, threadId, createdAtISO, status, source, cloudActionId, telegramMessageId`,labResults:`id, biomarkerId, collectedAtISO, [biomarkerId+collectedAtISO]`}),this.version(16).stores({tasks:`id, status, dueDate, createdAt, topPriorityOrder`,habits:`id, active, group`,habitLogs:`id, habitId, date, [habitId+date]`,transactions:`id, date, type, category`,settings:`id`,savingsGoals:`id, active, name, createdAt`,savingsContributions:`id, goalId, dateISO`,debts:`id, active, name, createdAt`,debtPayments:`id, debtId, dateISO`,foods:`id, name, createdAt`,mealEntries:`id, dateISO, timeHHMM, foodId, mealGroupId`,mealPlans:`id, weekStartISO, createdAtISO, updatedAtISO`,mealPlanItems:`id, planId, dateISO, mealIndex, [planId+dateISO+mealIndex]`,recipes:`id, source, createdAt`,userFoodCatalog:`id, group, createdAt`,pantryItems:`id, &userProductId, updatedAtISO`,trainingScheduleItems:`id, active, recurrence, dateISO, timeHHMM`,trainingCompletionLogs:`id, dateISO, trainingId, [dateISO+trainingId], [dateISO+title]`,supplementPlanItems:`id, active, supplementCatalogId, timing`,supplementIntakeLogs:`id, planItemId, supplementCatalogId, supplementKnowledgeId, dateISO, status, source, [dateISO+planItemId], [dateISO+status]`,chatThreads:`id, updatedAtISO, lastMessageAtISO, archived`,chatMessages:`id, threadId, createdAtISO, status, source, cloudActionId, telegramMessageId`,labResults:`id, biomarkerId, collectedAtISO, [biomarkerId+collectedAtISO]`,supplementProducts:`id, supplementKnowledgeId, supplementCatalogId, name, brand, form, expiresAtISO, updatedAtISO`,supplementPlanProductLinks:`id, planItemId, productId, isActive, [planItemId+isActive], [productId+isActive], updatedAtISO`}),this.version(17).stores({tasks:`id, status, dueDate, createdAt, topPriorityOrder`,habits:`id, active, group`,habitLogs:`id, habitId, date, [habitId+date]`,transactions:`id, date, type, category`,settings:`id`,savingsGoals:`id, active, name, createdAt`,savingsContributions:`id, goalId, dateISO`,debts:`id, active, name, createdAt`,debtPayments:`id, debtId, dateISO`,foods:`id, name, createdAt`,mealEntries:`id, dateISO, timeHHMM, foodId, mealGroupId`,mealPlans:`id, weekStartISO, createdAtISO, updatedAtISO`,mealPlanItems:`id, planId, dateISO, mealIndex, [planId+dateISO+mealIndex]`,recipes:`id, source, createdAt`,userFoodCatalog:`id, group, createdAt`,pantryItems:`id, &userProductId, updatedAtISO`,trainingScheduleItems:`id, active, recurrence, dateISO, timeHHMM`,trainingCompletionLogs:`id, dateISO, trainingId, [dateISO+trainingId], [dateISO+title]`,supplementPlanItems:`id, active, supplementCatalogId, timing`,supplementIntakeLogs:`id, planItemId, supplementCatalogId, supplementKnowledgeId, dateISO, status, source, [dateISO+planItemId], [dateISO+status]`,chatThreads:`id, updatedAtISO, lastMessageAtISO, archived`,chatMessages:`id, threadId, createdAtISO, status, source, cloudActionId, telegramMessageId`,labResults:`id, biomarkerId, collectedAtISO, [biomarkerId+collectedAtISO]`,supplementProducts:`id, supplementKnowledgeId, supplementCatalogId, name, brand, form, expiresAtISO, archivedAtISO, updatedAtISO`,supplementPlanProductLinks:`id, planItemId, productId, isActive, [planItemId+isActive], [productId+isActive], updatedAtISO`}),this.version(18).stores({tasks:`id, status, dueDate, createdAt, topPriorityOrder`,habits:`id, active, group`,habitLogs:`id, habitId, date, [habitId+date]`,transactions:`id, date, type, category`,settings:`id`,savingsGoals:`id, active, name, createdAt`,savingsContributions:`id, goalId, dateISO`,debts:`id, active, name, createdAt`,debtPayments:`id, debtId, dateISO`,foods:`id, name, createdAt`,mealEntries:`id, dateISO, timeHHMM, foodId, mealGroupId`,mealPlans:`id, weekStartISO, createdAtISO, updatedAtISO`,mealPlanItems:`id, planId, dateISO, mealIndex, [planId+dateISO+mealIndex]`,recipes:`id, source, createdAt`,userFoodCatalog:`id, group, createdAt`,pantryItems:`id, &userProductId, updatedAtISO`,trainingScheduleItems:`id, active, recurrence, dateISO, timeHHMM`,trainingCompletionLogs:`id, dateISO, trainingId, [dateISO+trainingId], [dateISO+title]`,supplementPlanItems:`id, active, supplementCatalogId, timing`,supplementIntakeLogs:`id, planItemId, supplementCatalogId, supplementKnowledgeId, dateISO, status, source, [dateISO+planItemId], [dateISO+status]`,chatThreads:`id, updatedAtISO, lastMessageAtISO, archived`,chatMessages:`id, threadId, createdAtISO, status, source, cloudActionId, telegramMessageId`,labResults:`id, biomarkerId, collectedAtISO, [biomarkerId+collectedAtISO]`,supplementProducts:`id, supplementKnowledgeId, supplementCatalogId, name, brand, form, expiresAtISO, archivedAtISO, updatedAtISO`,supplementPlanProductLinks:`id, planItemId, productId, isActive, [planItemId+isActive], [productId+isActive], updatedAtISO`,supplementProductTemplates:`id, barcode, name, brand, form, updatedAtISO`}),this.version(19).stores({tasks:`id, status, dueDate, createdAt, topPriorityOrder`,habits:`id, active, group`,habitLogs:`id, habitId, date, [habitId+date]`,transactions:`id, date, type, category`,settings:`id`,savingsGoals:`id, active, name, createdAt`,savingsContributions:`id, goalId, dateISO`,debts:`id, active, name, createdAt`,debtPayments:`id, debtId, dateISO`,foods:`id, name, createdAt`,mealEntries:`id, dateISO, timeHHMM, foodId, mealGroupId`,mealPlans:`id, weekStartISO, createdAtISO, updatedAtISO`,mealPlanItems:`id, planId, dateISO, mealIndex, [planId+dateISO+mealIndex]`,recipes:`id, source, createdAt`,userFoodCatalog:`id, group, createdAt`,pantryItems:`id, &userProductId, updatedAtISO`,trainingScheduleItems:`id, active, recurrence, dateISO, timeHHMM`,trainingCompletionLogs:`id, dateISO, trainingId, [dateISO+trainingId], [dateISO+title]`,supplementPlanItems:`id, active, supplementCatalogId, timing`,supplementIntakeLogs:`id, planItemId, supplementCatalogId, supplementKnowledgeId, dateISO, status, source, [dateISO+planItemId], [dateISO+status]`,chatThreads:`id, updatedAtISO, lastMessageAtISO, archived`,chatMessages:`id, threadId, createdAtISO, status, source, cloudActionId, telegramMessageId`,labResults:`id, biomarkerId, collectedAtISO, [biomarkerId+collectedAtISO]`,supplementProducts:`id, supplementKnowledgeId, supplementCatalogId, name, brand, form, expiresAtISO, archivedAtISO, updatedAtISO`,supplementPlanProductLinks:`id, planItemId, productId, isActive, [planItemId+isActive], [productId+isActive], updatedAtISO`,supplementProductTemplates:`id, barcode, name, brand, form, updatedAtISO`,supplementReminders:`id, kind, dedupeKey, dateISO, status, notifyAtISO, entityId, [dateISO+status], [kind+dateISO]`}),this.version(20).stores({tasks:`id, status, dueDate, createdAt, topPriorityOrder`,habits:`id, active, group`,habitLogs:`id, habitId, date, [habitId+date]`,transactions:`id, date, type, category, createdAt`,settings:`id`,savingsGoals:`id, active, name, createdAt`,savingsContributions:`id, goalId, dateISO`,debts:`id, active, name, createdAt`,debtPayments:`id, debtId, dateISO`,foods:`id, name, createdAt`,mealEntries:`id, dateISO, timeHHMM, foodId, mealGroupId`,mealPlans:`id, weekStartISO, createdAtISO, updatedAtISO`,mealPlanItems:`id, planId, dateISO, mealIndex, [planId+dateISO+mealIndex]`,recipes:`id, source, createdAt`,userFoodCatalog:`id, group, createdAt`,pantryItems:`id, &userProductId, updatedAtISO`,trainingScheduleItems:`id, active, recurrence, dateISO, timeHHMM`,trainingCompletionLogs:`id, dateISO, trainingId, [dateISO+trainingId], [dateISO+title]`,supplementPlanItems:`id, active, supplementCatalogId, timing`,supplementIntakeLogs:`id, planItemId, supplementCatalogId, supplementKnowledgeId, dateISO, status, source, [dateISO+planItemId], [dateISO+status]`,chatThreads:`id, updatedAtISO, lastMessageAtISO, archived`,chatMessages:`id, threadId, createdAtISO, status, source, cloudActionId, telegramMessageId`,labResults:`id, biomarkerId, collectedAtISO, [biomarkerId+collectedAtISO]`,supplementProducts:`id, supplementKnowledgeId, supplementCatalogId, name, brand, form, expiresAtISO, archivedAtISO, updatedAtISO`,supplementPlanProductLinks:`id, planItemId, productId, isActive, [planItemId+isActive], [productId+isActive], updatedAtISO`,supplementProductTemplates:`id, barcode, name, brand, form, updatedAtISO`,supplementReminders:`id, kind, dedupeKey, dateISO, status, notifyAtISO, entityId, [dateISO+status], [kind+dateISO]`}),this.version(21).stores({tasks:`id, status, dueDate, createdAt, topPriorityOrder`,habits:`id, active, group`,habitLogs:`id, habitId, date, [habitId+date]`,transactions:`id, date, type, category, createdAt`,settings:`id`,savingsGoals:`id, active, name, createdAt`,savingsContributions:`id, goalId, dateISO`,debts:`id, active, name, createdAt`,debtPayments:`id, debtId, dateISO`,foods:`id, name, createdAt`,mealEntries:`id, dateISO, timeHHMM, foodId, mealGroupId`,mealPlans:`id, weekStartISO, createdAtISO, updatedAtISO`,mealPlanItems:`id, planId, dateISO, mealIndex, [planId+dateISO+mealIndex]`,recipes:`id, source, createdAt`,userFoodCatalog:`id, group, createdAt`,pantryItems:`id, &userProductId, updatedAtISO`,trainingScheduleItems:`id, active, recurrence, dateISO, timeHHMM`,trainingCompletionLogs:`id, dateISO, trainingId, [dateISO+trainingId], [dateISO+title]`,supplementPlanItems:`id, active, supplementCatalogId, timing`,supplementIntakeLogs:`id, planItemId, supplementCatalogId, supplementKnowledgeId, dateISO, status, source, [dateISO+planItemId], [dateISO+status]`,chatThreads:`id, updatedAtISO, lastMessageAtISO, archived`,chatMessages:`id, threadId, createdAtISO, status, source, cloudActionId, telegramMessageId`,labResults:`id, biomarkerId, collectedAtISO, [biomarkerId+collectedAtISO]`,supplementProducts:`id, supplementKnowledgeId, supplementCatalogId, name, brand, form, expiresAtISO, archivedAtISO, updatedAtISO`,supplementPlanProductLinks:`id, planItemId, productId, isActive, [planItemId+isActive], [productId+isActive], updatedAtISO`,supplementProductTemplates:`id, barcode, name, brand, form, updatedAtISO`,supplementReminders:`id, kind, dedupeKey, dateISO, status, notifyAtISO, entityId, [dateISO+status], [kind+dateISO]`,authSession:`id`}),this.version(22).stores({tasks:`id, status, dueDate, createdAt, topPriorityOrder`,habits:`id, active, group`,habitLogs:`id, habitId, date, [habitId+date]`,transactions:`id, date, type, category, createdAt`,settings:`id`,savingsGoals:`id, active, name, createdAt`,savingsContributions:`id, goalId, dateISO`,debts:`id, active, name, createdAt`,debtPayments:`id, debtId, dateISO`,foods:`id, name, createdAt`,mealEntries:`id, dateISO, timeHHMM, foodId, mealGroupId`,mealPlans:`id, weekStartISO, createdAtISO, updatedAtISO`,mealPlanItems:`id, planId, dateISO, mealIndex, [planId+dateISO+mealIndex]`,recipes:`id, source, createdAt`,userFoodCatalog:`id, group, createdAt`,pantryItems:`id, &userProductId, updatedAtISO`,trainingScheduleItems:`id, active, recurrence, dateISO, timeHHMM`,trainingCompletionLogs:`id, dateISO, trainingId, [dateISO+trainingId], [dateISO+title]`,supplementPlanItems:`id, active, supplementCatalogId, timing`,supplementIntakeLogs:`id, planItemId, supplementCatalogId, supplementKnowledgeId, dateISO, status, source, [dateISO+planItemId], [dateISO+status]`,chatThreads:`id, updatedAtISO, lastMessageAtISO, archived`,chatMessages:`id, threadId, createdAtISO, status, source, cloudActionId, telegramMessageId`,labResults:`id, biomarkerId, collectedAtISO, [biomarkerId+collectedAtISO]`,supplementProducts:`id, supplementKnowledgeId, supplementCatalogId, name, brand, form, expiresAtISO, archivedAtISO, updatedAtISO`,supplementPlanProductLinks:`id, planItemId, productId, isActive, [planItemId+isActive], [productId+isActive], updatedAtISO`,supplementProductTemplates:`id, barcode, name, brand, form, updatedAtISO`,supplementReminders:`id, kind, dedupeKey, dateISO, status, notifyAtISO, entityId, [dateISO+status], [kind+dateISO]`,subscriptions:`id, active, nextChargeDateISO, createdAt`,subscriptionReminders:`id, subscriptionId, dedupeKey, status, notifyAtISO, chargeDateISO, [subscriptionId+chargeDateISO]`,holidays:`id, active, dateISO, kind, createdAt`,authSession:`id`}),this.version(23).stores({tasks:`id, status, dueDate, createdAt, topPriorityOrder`,habits:`id, active, group`,habitLogs:`id, habitId, date, [habitId+date]`,transactions:`id, date, type, category, createdAt`,settings:`id`,savingsGoals:`id, active, name, createdAt`,savingsContributions:`id, goalId, dateISO`,debts:`id, active, name, createdAt`,debtPayments:`id, debtId, dateISO`,foods:`id, name, createdAt`,mealEntries:`id, dateISO, timeHHMM, foodId, mealGroupId`,mealPlans:`id, weekStartISO, createdAtISO, updatedAtISO`,mealPlanItems:`id, planId, dateISO, mealIndex, [planId+dateISO+mealIndex]`,recipes:`id, source, createdAt`,userFoodCatalog:`id, group, createdAt`,pantryItems:`id, &userProductId, updatedAtISO`,trainingScheduleItems:`id, active, recurrence, dateISO, timeHHMM`,trainingCompletionLogs:`id, dateISO, trainingId, [dateISO+trainingId], [dateISO+title]`,supplementPlanItems:`id, active, supplementCatalogId, timing`,supplementIntakeLogs:`id, planItemId, supplementCatalogId, supplementKnowledgeId, dateISO, status, source, [dateISO+planItemId], [dateISO+status]`,chatThreads:`id, updatedAtISO, lastMessageAtISO, archived`,chatMessages:`id, threadId, createdAtISO, status, source, cloudActionId, telegramMessageId`,labResults:`id, biomarkerId, collectedAtISO, [biomarkerId+collectedAtISO]`,supplementProducts:`id, supplementKnowledgeId, supplementCatalogId, name, brand, form, expiresAtISO, archivedAtISO, updatedAtISO`,supplementPlanProductLinks:`id, planItemId, productId, isActive, [planItemId+isActive], [productId+isActive], updatedAtISO`,supplementProductTemplates:`id, barcode, name, brand, form, updatedAtISO`,supplementReminders:`id, kind, dedupeKey, dateISO, status, notifyAtISO, entityId, [dateISO+status], [kind+dateISO]`,subscriptions:`id, active, nextChargeDateISO, createdAt`,subscriptionReminders:`id, subscriptionId, dedupeKey, status, notifyAtISO, chargeDateISO, [subscriptionId+chargeDateISO]`,holidays:`id, active, dateISO, kind, createdAt`,authSession:`id`}),this.version(24).stores({tasks:`id, status, dueDate, createdAt, topPriorityOrder`,habits:`id, active, group`,habitLogs:`id, habitId, date, [habitId+date]`,transactions:`id, date, type, category, createdAt`,settings:`id`,savingsGoals:`id, active, name, createdAt`,savingsContributions:`id, goalId, dateISO`,debts:`id, active, name, createdAt`,debtPayments:`id, debtId, dateISO`,foods:`id, name, createdAt`,mealEntries:`id, dateISO, timeHHMM, foodId, mealGroupId`,mealPlans:`id, weekStartISO, createdAtISO, updatedAtISO`,mealPlanItems:`id, planId, dateISO, mealIndex, [planId+dateISO+mealIndex]`,recipes:`id, source, createdAt`,userFoodCatalog:`id, group, createdAt`,pantryItems:`id, &userProductId, updatedAtISO`,trainingScheduleItems:`id, active, recurrence, dateISO, timeHHMM`,trainingCompletionLogs:`id, dateISO, trainingId, [dateISO+trainingId], [dateISO+title]`,supplementPlanItems:`id, active, supplementCatalogId, timing`,supplementIntakeLogs:`id, planItemId, supplementCatalogId, supplementKnowledgeId, dateISO, status, source, [dateISO+planItemId], [dateISO+status]`,chatThreads:`id, updatedAtISO, lastMessageAtISO, archived`,chatMessages:`id, threadId, createdAtISO, status, source, cloudActionId, telegramMessageId`,labResults:`id, biomarkerId, collectedAtISO, [biomarkerId+collectedAtISO]`,supplementProducts:`id, supplementKnowledgeId, supplementCatalogId, name, brand, form, expiresAtISO, archivedAtISO, updatedAtISO`,supplementPlanProductLinks:`id, planItemId, productId, isActive, [planItemId+isActive], [productId+isActive], updatedAtISO`,supplementProductTemplates:`id, barcode, name, brand, form, updatedAtISO`,supplementReminders:`id, kind, dedupeKey, dateISO, status, notifyAtISO, entityId, [dateISO+status], [kind+dateISO]`,subscriptions:`id, active, nextChargeDateISO, createdAt`,subscriptionReminders:`id, subscriptionId, dedupeKey, status, notifyAtISO, chargeDateISO, [subscriptionId+chargeDateISO]`,holidays:`id, active, dateISO, kind, createdAt`,authSession:`id`}).upgrade(async e=>{let t=e.table(`habits`),n=e.table(`habitLogs`),i=e.table(`savingsGoals`),a=e.table(`savingsContributions`),o=(await t.toArray()).filter(e=>r(e.name));for(let e of o)await n.where(`habitId`).equals(e.id).delete(),await t.delete(e.id);let s=(await i.toArray()).filter(e=>e.name===`Переезд`&&e.savedRub===0&&e.targetRub===3e5);for(let e of s)await a.where(`goalId`).equals(e.id).delete(),await i.delete(e.id)}),this.version(25).stores({tasks:`id, status, dueDate, createdAt, topPriorityOrder`,habits:`id, active, group`,habitLogs:`id, habitId, date, [habitId+date]`,transactions:`id, date, type, category, createdAt`,settings:`id`,savingsGoals:`id, active, name, createdAt`,savingsContributions:`id, goalId, dateISO`,debts:`id, active, name, createdAt`,debtPayments:`id, debtId, dateISO`,foods:`id, name, createdAt`,mealEntries:`id, dateISO, timeHHMM, foodId, mealGroupId`,mealPlans:`id, weekStartISO, createdAtISO, updatedAtISO`,mealPlanItems:`id, planId, dateISO, mealIndex, [planId+dateISO+mealIndex]`,recipes:`id, source, createdAt`,userFoodCatalog:`id, group, createdAt`,pantryItems:`id, &userProductId, updatedAtISO`,trainingScheduleItems:`id, active, recurrence, dateISO, timeHHMM`,trainingCompletionLogs:`id, dateISO, trainingId, [dateISO+trainingId], [dateISO+title]`,supplementPlanItems:`id, active, supplementCatalogId, timing`,supplementIntakeLogs:`id, planItemId, supplementCatalogId, supplementKnowledgeId, dateISO, status, source, [dateISO+planItemId], [dateISO+status]`,chatThreads:`id, updatedAtISO, lastMessageAtISO, archived`,chatMessages:`id, threadId, createdAtISO, status, source, cloudActionId, telegramMessageId`,labResults:`id, biomarkerId, collectedAtISO, [biomarkerId+collectedAtISO]`,supplementProducts:`id, supplementKnowledgeId, supplementCatalogId, name, brand, form, expiresAtISO, archivedAtISO, updatedAtISO`,supplementPlanProductLinks:`id, planItemId, productId, isActive, [planItemId+isActive], [productId+isActive], updatedAtISO`,supplementProductTemplates:`id, barcode, name, brand, form, updatedAtISO`,supplementReminders:`id, kind, dedupeKey, dateISO, status, notifyAtISO, entityId, [dateISO+status], [kind+dateISO]`,subscriptions:`id, active, nextChargeDateISO, createdAt`,subscriptionReminders:`id, subscriptionId, dedupeKey, status, notifyAtISO, chargeDateISO, [subscriptionId+chargeDateISO]`,holidays:`id, active, dateISO, kind, createdAt`,authSession:`id`}).upgrade(async e=>{let t=e.table(`habits`),n=e.table(`habitLogs`),r=(await t.toArray()).filter(e=>x(e));for(let e of r)await n.where(`habitId`).equals(e.id).delete(),await t.delete(e.id);let i=e.table(`settings`),a=await i.get(`singleton`);if(a?.app){let e={...a.app};delete e.stepsTrackingEnabled,delete e.stepsTargetDaily,delete e.stepsQuickAdd,await i.put({...a,app:e})}})}};export{b as a,a as c,y as d,m as f,l as g,f as h,S as i,_ as l,v as m,p as n,o,h as p,c as r,u as s,w as t,g as u};