@shiodome47/planner 0.2.0 → 0.3.0

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.
@@ -1,4 +1,4 @@
1
- import { type BoardHorizon, type Habit, type Horizon, type MonthDay, type Period, type PlannerData, type Priority, type Project, type Task } from './types';
1
+ import { type BoardHorizon, type Habit, type HabitEnd, type Horizon, type MonthDay, type Period, type PlannerData, type Priority, type Project, type Task } from './types';
2
2
  /**
3
3
  * 時間軸ボードの決まりごと(画面に依存しない計算)。
4
4
  *
@@ -93,6 +93,8 @@ export interface ColumnView {
93
93
  tomorrow: TaskView[];
94
94
  /** 今週の列だけ:来週の欄 */
95
95
  nextWeek: TaskView[];
96
+ /** この列の期間の、終えた習慣(卒業・お休み。新しく終えた順)。一番下の「これまでの習慣」に出す */
97
+ ended: Habit[];
96
98
  }
97
99
  export declare function buildColumns(data: PlannerData, now: Date): ColumnView[];
98
100
  /**
@@ -144,6 +146,22 @@ export declare function newHabit(data: PlannerData, input: {
144
146
  }, now: Date): Habit;
145
147
  /** 習慣のチェックを付ける・外す(今の期間の分) */
146
148
  export declare function toggleHabit(habit: Habit, now: Date): Habit;
149
+ /** 習慣の記録を残す日数の上限 */
150
+ export declare const HABIT_HISTORY_LIMIT = 800;
151
+ /** 終えた習慣(卒業・お休み)だけを、新しく終えた順に */
152
+ export declare function endedHabits(habits: Habit[]): Habit[];
153
+ /**
154
+ * 習慣を終える(卒業・お休み)。チェックの記録は残し、時間軸・プロジェクトのチェックの一覧からは外す
155
+ * (一番下の「これまでの習慣」に出る)。下ろした先で、まだ終えていないやることは消す。
156
+ * もう終えている習慣なら、終えた日はそのままで、終え方とひとことだけを変える
157
+ */
158
+ export declare function endHabit(data: PlannerData, habit: Habit, as: HabitEnd, endNote: string, now: Date): Changes;
159
+ /**
160
+ * 終えた習慣を、また始める(同じ期間の習慣の一番下へ)。
161
+ * 終えた日と同じ日なら、終えたのを取り消すだけ。別の日なら、休んでいた間(breaks)を残す
162
+ * (振り返りで、休んでいた日を「できなかった日」に数えないため)
163
+ */
164
+ export declare function resumeHabit(data: PlannerData, habit: Habit, now: Date): Changes;
147
165
  export declare function newProject(data: PlannerData, input: {
148
166
  name: string;
149
167
  color: string;
@@ -7,6 +7,26 @@ import type { Habit, Horizon, PlannerData, Project, Task } from './types';
7
7
  export declare function habitDays(habit: Habit): Set<string>;
8
8
  /** その日に、その習慣が済んでいたか(毎週・毎月などは、その日を含む期間にチェックがあれば済み) */
9
9
  export declare function habitDoneOn(habit: Habit, day: Date): boolean;
10
+ /**
11
+ * その日に、その習慣を続けていたか(振り返り・カレンダーの「毎日 3/4」の数に入れるか)。
12
+ * 始めた日より前・終えた日(卒業・お休み)から後・休んでいた間は数えない。チェックがある日は数える
13
+ */
14
+ export declare function habitActiveOn(habit: Habit, day: Date): boolean;
15
+ export interface HabitRecord {
16
+ /** 始めた日 */
17
+ start: Date;
18
+ /** 終えた日(終えていなければ無し) */
19
+ end?: Date;
20
+ /** 続けていた期間(毎日なら日、毎週なら週…)のうち、できた数 */
21
+ done: number;
22
+ /** 続けていた期間の数 */
23
+ total: number;
24
+ }
25
+ /**
26
+ * 習慣の、始めてから終えるまで(終えていなければ今日まで)の記録。
27
+ * 休んでいた間は数えない。最後の期間(終えた日・今日を含む日・週…)は、できていれば数える
28
+ */
29
+ export declare function habitRecord(habit: Habit, now: Date): HabitRecord;
10
30
  /** 続いている日数(毎日の習慣だけ。今日まだなら昨日から数える) */
11
31
  export declare function streak(habit: Habit, now: Date): number;
12
32
  export interface DoneItem {
@@ -75,9 +75,30 @@ export interface Habit {
75
75
  */
76
76
  yearDay?: string;
77
77
  projectId?: string;
78
+ /**
79
+ * 終えた日時(卒業・お休み)。あれば時間軸・プロジェクトのチェックの一覧には出さず、
80
+ * 一番下の「これまでの習慣」に出す。チェックの記録(history)は消さない
81
+ */
82
+ endedAt?: string;
83
+ /** どう終えたか(endedAt と一緒に付ける) */
84
+ endedAs?: HabitEnd;
85
+ /** 終えたときのひとこと(理由・気づいたこと) */
86
+ endNote?: string;
87
+ /** 前に終えて、また始めたときの記録(古い順)。休んでいた間は、振り返りの数に入れない */
88
+ breaks?: HabitBreak[];
78
89
  createdAt: string;
79
90
  updatedAt: string;
80
91
  }
92
+ /** 習慣の終え方。graduated 卒業(身についた)/paused お休み(続かなかった・今はやめる) */
93
+ export type HabitEnd = 'graduated' | 'paused';
94
+ /** 習慣を終えて、また始めるまでの間 */
95
+ export interface HabitBreak {
96
+ endedAt: string;
97
+ endedAs: HabitEnd;
98
+ endNote?: string;
99
+ /** また始めた日時 */
100
+ resumedAt: string;
101
+ }
81
102
  /** 毎月の「その日」(Habit.day) */
82
103
  export type MonthDay = number | 'end' | `w${1 | 2 | 3 | 4 | 5 | 'L'}-${0 | 1 | 2 | 3 | 4 | 5 | 6}`;
83
104
  /**
package/dist/core.js CHANGED
@@ -301,7 +301,7 @@ function ue(t, n) {
301
301
  };
302
302
  return e.map((e) => {
303
303
  let i = t.tasks.filter((t) => P(t, n) === e && F(t, n)), a = e === "today" ? i.filter((e) => !A(e, n)) : e === "week" ? i.filter((e) => !O(e, n)) : i, o = e === "today" ? i.filter((e) => A(e, n)) : [], c = e === "week" ? i.filter((e) => O(e, n)) : [], u = l[e], f = (e, i, a) => {
304
- let o = d(e.period, e.checkedAt, n), s = Z(e, t.tasks, n);
304
+ let o = d(e.period, e.checkedAt, n), s = X(e, t.tasks, n);
305
305
  return {
306
306
  habit: e,
307
307
  checked: o,
@@ -311,18 +311,19 @@ function ue(t, n) {
311
311
  auto: i,
312
312
  dueDay: a ?? C(e, n)
313
313
  };
314
- }, p = u ? t.habits.filter((e) => e.period === u).sort(z).map((e) => f(e, !1)) : [], m = [];
315
- for (let r of t.habits.filter((e) => e.period !== u).sort(z)) {
316
- let t = w(r, e, n);
317
- t && m.push(f(r, !0, t));
314
+ }, p = t.habits.filter((e) => !e.endedAt), m = u ? p.filter((e) => e.period === u).sort(z).map((e) => f(e, !1)) : [], h = [];
315
+ for (let t of p.filter((e) => e.period !== u).sort(z)) {
316
+ let r = w(t, e, n);
317
+ r && h.push(f(t, !0, r));
318
318
  }
319
319
  return {
320
320
  horizon: e,
321
321
  habitPeriod: u,
322
- habits: [...p, ...m],
322
+ habits: [...m, ...h],
323
323
  tasks: R(a).map(({ task: e, label: t }) => s(e, t)),
324
324
  tomorrow: R(o).map(({ task: e, label: t }) => s(e, t)),
325
- nextWeek: R(c).map(({ task: e, label: t }) => s(e, t))
325
+ nextWeek: R(c).map(({ task: e, label: t }) => s(e, t)),
326
+ ended: u ? K(t.habits.filter((e) => e.period === u)) : []
326
327
  };
327
328
  });
328
329
  }
@@ -347,8 +348,8 @@ function H(e, t, n) {
347
348
  updatedAt: r
348
349
  };
349
350
  }
350
- function U(e, t, n, r) {
351
- let i = B(r), a = n === "tomorrow" ? "today" : n === "nextweek" ? "week" : n, o = I(t, e.tasks, r), s = o && !o.doneAt ? W(e.tasks, o.id, r).concat(o.id) : [];
351
+ function de(e, t, n, r) {
352
+ let i = B(r), a = n === "tomorrow" ? "today" : n === "nextweek" ? "week" : n, o = I(t, e.tasks, r), s = o && !o.doneAt ? U(e.tasks, o.id, r).concat(o.id) : [];
352
353
  return {
353
354
  tasks: [{
354
355
  id: crypto.randomUUID(),
@@ -367,10 +368,10 @@ function U(e, t, n, r) {
367
368
  deleteTaskIds: s
368
369
  };
369
370
  }
370
- function de(e, t, n) {
371
- return { deleteTaskIds: [t.id, ...W(e.tasks, t.id, n)] };
371
+ function fe(e, t, n) {
372
+ return { deleteTaskIds: [t.id, ...U(e.tasks, t.id, n)] };
372
373
  }
373
- function fe(e, t, n, r) {
374
+ function pe(e, t, n, r) {
374
375
  if (t.horizon === n) return {};
375
376
  let { placedFor: i, ...a } = t;
376
377
  return { tasks: [{
@@ -380,13 +381,13 @@ function fe(e, t, n, r) {
380
381
  updatedAt: B(r)
381
382
  }] };
382
383
  }
383
- function W(e, t, n) {
384
+ function U(e, t, n) {
384
385
  let r = [];
385
- for (let i of e) i.parentId === t && !D(i, n) && r.push(i.id, ...W(e, i.id, n));
386
+ for (let i of e) i.parentId === t && !D(i, n) && r.push(i.id, ...U(e, i.id, n));
386
387
  return r;
387
388
  }
388
- function G(e, t, n) {
389
- let r = new Map(e.tasks.map((e) => [e.id, e])), i = /* @__PURE__ */ new Set([t.id, ...W(e.tasks, t.id, n)]);
389
+ function W(e, t, n) {
390
+ let r = new Map(e.tasks.map((e) => [e.id, e])), i = /* @__PURE__ */ new Set([t.id, ...U(e.tasks, t.id, n)]);
390
391
  for (let e = t.parentId ? r.get(t.parentId) : void 0; e; e = e.parentId ? r.get(e.parentId) : void 0) i.add(e.id);
391
392
  let a = B(n), o = !t.doneAt, s = [...i].map((e) => r.get(e)).filter((e) => !!e).map((e) => {
392
393
  let { doneAt: t, ...n } = e;
@@ -401,10 +402,10 @@ function G(e, t, n) {
401
402
  }), c = t.habitId ? e.habits.find((e) => e.id === t.habitId) : void 0;
402
403
  return c && d(c.period, c.checkedAt, n) !== o ? {
403
404
  tasks: s,
404
- habits: [K(c, n)]
405
+ habits: [G(c, n)]
405
406
  } : { tasks: s };
406
407
  }
407
- function pe(e, t, n, r) {
408
+ function me(e, t, n, r) {
408
409
  let i = e.tasks.filter((e) => e.horizon === t.horizon && e.priority === t.priority && F(e, r) && A(e, r) === A(t, r)).sort(z), a = i.findIndex((e) => e.id === t.id), o = a + n;
409
410
  if (a < 0 || o < 0 || o >= i.length) return {};
410
411
  let s = B(r), c = [...i];
@@ -416,7 +417,7 @@ function pe(e, t, n, r) {
416
417
  updatedAt: s
417
418
  })).filter((e) => l.get(e.id) !== e.order) };
418
419
  }
419
- function me(e, t, n, r) {
420
+ function he(e, t, n, r) {
420
421
  return t.priority === n ? {} : { tasks: [{
421
422
  ...t,
422
423
  priority: n,
@@ -424,10 +425,10 @@ function me(e, t, n, r) {
424
425
  updatedAt: B(r)
425
426
  }] };
426
427
  }
427
- function he(e, t, n) {
428
- return { deleteTaskIds: [t.id, ...W(e.tasks, t.id, n)] };
429
- }
430
428
  function ge(e, t, n) {
429
+ return { deleteTaskIds: [t.id, ...U(e.tasks, t.id, n)] };
430
+ }
431
+ function _e(e, t, n) {
431
432
  let r = e.habits.filter((e) => e.period === t.period), i = B(n);
432
433
  return {
433
434
  id: crypto.randomUUID(),
@@ -439,7 +440,7 @@ function ge(e, t, n) {
439
440
  updatedAt: i
440
441
  };
441
442
  }
442
- function K(e, t) {
443
+ function G(e, t) {
443
444
  let { checkedAt: r, ...i } = e, a = B(t), o = e.history ?? [];
444
445
  if (d(e.period, e.checkedAt, t)) {
445
446
  let t = n(new Date(e.checkedAt));
@@ -449,7 +450,7 @@ function K(e, t) {
449
450
  updatedAt: a
450
451
  };
451
452
  }
452
- let s = n(t), c = o.includes(s) ? o : [...o, s].sort().slice(-_e);
453
+ let s = n(t), c = o.includes(s) ? o : [...o, s].sort().slice(-800);
453
454
  return {
454
455
  ...i,
455
456
  checkedAt: a,
@@ -457,8 +458,39 @@ function K(e, t) {
457
458
  updatedAt: a
458
459
  };
459
460
  }
460
- var _e = 800;
461
- function ve(e, t, n) {
461
+ var ve = 800;
462
+ function K(e) {
463
+ return e.filter((e) => e.endedAt).sort((e, t) => t.endedAt.localeCompare(e.endedAt));
464
+ }
465
+ function ye(e, t, n, r, i) {
466
+ let a = B(i), { endNote: o, ...s } = t, c = r.trim(), l = {
467
+ ...s,
468
+ endedAt: t.endedAt ?? a,
469
+ endedAs: n,
470
+ ...c ? { endNote: c } : {},
471
+ updatedAt: a
472
+ }, u = t.endedAt ? [] : e.tasks.filter((e) => e.habitId === t.id && !e.doneAt && !D(e, i));
473
+ return {
474
+ habits: [l],
475
+ ...u.length ? { deleteTaskIds: u.map((e) => e.id) } : {}
476
+ };
477
+ }
478
+ function be(e, t, r) {
479
+ if (!t.endedAt) return {};
480
+ let i = B(r), { endedAt: a, endedAs: o, endNote: s, breaks: c, ...l } = t, u = n(new Date(a)) === n(r), d = {
481
+ endedAt: a,
482
+ endedAs: o ?? "paused",
483
+ ...s ? { endNote: s } : {},
484
+ resumedAt: i
485
+ }, f = u ? t.breaks ?? [] : [...t.breaks ?? [], d], p = e.habits.filter((e) => e.period === t.period && !e.endedAt && e.id !== t.id), m = p.length === 0 ? 0 : Math.max(...p.map((e) => e.order)) + 1;
486
+ return { habits: [{
487
+ ...l,
488
+ ...f.length ? { breaks: f } : {},
489
+ order: m,
490
+ updatedAt: i
491
+ }] };
492
+ }
493
+ function xe(e, t, n) {
462
494
  let r = B(n), i = e.projects.filter((e) => e.parentId === t.parentId);
463
495
  return {
464
496
  id: crypto.randomUUID(),
@@ -473,11 +505,11 @@ function ve(e, t, n) {
473
505
  function q(e, t) {
474
506
  return e.projects.filter((e) => e.parentId === t).sort((e, t) => e.order - t.order);
475
507
  }
476
- function ye(e) {
508
+ function Se(e) {
477
509
  let t = new Set(e.projects.map((e) => e.id));
478
510
  return e.projects.filter((e) => !e.parentId || !t.has(e.parentId)).sort((e, t) => e.order - t.order);
479
511
  }
480
- function be(e, t) {
512
+ function Ce(e, t) {
481
513
  let n = /* @__PURE__ */ new Set([t.id, ...q(e, t.id).map((e) => e.id)]);
482
514
  return {
483
515
  deleteProjectIds: [...n],
@@ -485,7 +517,7 @@ function be(e, t) {
485
517
  deleteHabitIds: e.habits.filter((e) => e.projectId && n.has(e.projectId)).map((e) => e.id)
486
518
  };
487
519
  }
488
- function J(e, t, n, r) {
520
+ function we(e, t, n, r) {
489
521
  if (n === t.parentId || n === t.id || n && q(e, t.id).length > 0) return {};
490
522
  let i = e.projects.filter((e) => e.parentId === n && e.id !== t.id), { parentId: a, ...o } = t;
491
523
  return { projects: [{
@@ -495,28 +527,28 @@ function J(e, t, n, r) {
495
527
  updatedAt: B(r)
496
528
  }] };
497
529
  }
498
- function Y(e, t = [], n = []) {
530
+ function J(e, t = [], n = []) {
499
531
  let r = new Set(n), i = new Map(t.map((e) => [e.id, e])), a = e.filter((e) => !r.has(e.id)).map((e) => i.get(e.id) ?? e), o = t.filter((t) => !e.some((e) => e.id === t.id) && !r.has(t.id));
500
532
  return [...a, ...o];
501
533
  }
502
- function xe(e, t) {
534
+ function Te(e, t) {
503
535
  return {
504
536
  ...e,
505
- tasks: Y(e.tasks, t.tasks, t.deleteTaskIds),
506
- habits: Y(e.habits, t.habits, t.deleteHabitIds),
507
- projects: Y(e.projects, t.projects, t.deleteProjectIds)
537
+ tasks: J(e.tasks, t.tasks, t.deleteTaskIds),
538
+ habits: J(e.habits, t.habits, t.deleteHabitIds),
539
+ projects: J(e.projects, t.projects, t.deleteProjectIds)
508
540
  };
509
541
  }
510
- function X(e, t, n) {
542
+ function Y(e, t, n) {
511
543
  let r = [...e], [i] = r.splice(t, 1);
512
544
  return r.splice(n, 0, i), r;
513
545
  }
514
- function Se(e, n, r, i, a) {
546
+ function Ee(e, n, r, i, a) {
515
547
  let o = n.indexOf(r), s = n.indexOf(i);
516
548
  if (o < 0 || s < 0 || o === s) return {};
517
549
  let c = new Map(e.tasks.map((e) => [e.id, e])), l = c.get(i), u = c.get(r);
518
550
  if (!l || !u) return {};
519
- let d = l.priority, f = X(n, o, s).map((e) => c.get(e)).filter((e) => !!e).map((e) => e.id === r ? {
551
+ let d = l.priority, f = Y(n, o, s).map((e) => c.get(e)).filter((e) => !!e).map((e) => e.id === r ? {
520
552
  ...e,
521
553
  priority: d
522
554
  } : e), p = B(a), m = [];
@@ -530,11 +562,11 @@ function Se(e, n, r, i, a) {
530
562
  });
531
563
  return { tasks: m };
532
564
  }
533
- function Ce(e, t, n, r, i) {
565
+ function De(e, t, n, r, i) {
534
566
  let a = t.indexOf(n), o = t.indexOf(r);
535
567
  if (a < 0 || o < 0 || a === o) return {};
536
568
  let s = new Map(e.habits.map((e) => [e.id, e])), c = B(i);
537
- return { habits: X(t, a, o).map((e, t) => ({
569
+ return { habits: Y(t, a, o).map((e, t) => ({
538
570
  habit: s.get(e),
539
571
  order: t
540
572
  })).filter((e) => !!e.habit && e.habit.order !== e.order).map(({ habit: e, order: t }) => ({
@@ -543,11 +575,11 @@ function Ce(e, t, n, r, i) {
543
575
  updatedAt: c
544
576
  })) };
545
577
  }
546
- function we(e, t, n, r) {
578
+ function Oe(e, t, n, r) {
547
579
  let i = e.projects.find((e) => e.id === t), a = [...e.projects].filter((e) => e.parentId === i?.parentId).sort((e, t) => e.order - t.order).map((e) => e.id), o = a.indexOf(t), s = a.indexOf(n);
548
580
  if (o < 0 || s < 0 || o === s) return {};
549
581
  let c = new Map(e.projects.map((e) => [e.id, e])), l = B(r);
550
- return { projects: X(a, o, s).map((e, t) => ({
582
+ return { projects: Y(a, o, s).map((e, t) => ({
551
583
  project: c.get(e),
552
584
  order: t
553
585
  })).filter(({ project: e, order: t }) => e.order !== t).map(({ project: e, order: t }) => ({
@@ -556,14 +588,14 @@ function we(e, t, n, r) {
556
588
  updatedAt: l
557
589
  })) };
558
590
  }
559
- function Z(e, t, n) {
591
+ function X(e, t, n) {
560
592
  return t.find((t) => t.habitId === e.id && !D(t, n));
561
593
  }
562
- function Te(e) {
594
+ function ke(e) {
563
595
  return L(_(e.period));
564
596
  }
565
- function Ee(e, t, n, r) {
566
- let i = B(r), a = n === "tomorrow" ? "today" : n === "nextweek" ? "week" : n, o = Z(t, e.tasks, r);
597
+ function Ae(e, t, n, r) {
598
+ let i = B(r), a = n === "tomorrow" ? "today" : n === "nextweek" ? "week" : n, o = X(t, e.tasks, r);
567
599
  return {
568
600
  tasks: [{
569
601
  id: crypto.randomUUID(),
@@ -581,8 +613,8 @@ function Ee(e, t, n, r) {
581
613
  deleteTaskIds: o && !o.doneAt ? [o.id] : []
582
614
  };
583
615
  }
584
- function De(e, t, n) {
585
- let r = K(t, n), i = d(r.period, r.checkedAt, n), a = Z(t, e.tasks, n);
616
+ function je(e, t, n) {
617
+ let r = G(t, n), i = d(r.period, r.checkedAt, n), a = X(t, e.tasks, n);
586
618
  if (!a || !!a.doneAt === i) return { habits: [r] };
587
619
  let o = B(n), { doneAt: s, ...c } = a;
588
620
  return {
@@ -597,7 +629,7 @@ function De(e, t, n) {
597
629
  }]
598
630
  };
599
631
  }
600
- function Oe(e, t, n) {
632
+ function Me(e, t, n) {
601
633
  let r = H(e, {
602
634
  title: t.title,
603
635
  horizon: _(t.period),
@@ -612,10 +644,10 @@ function Oe(e, t, n) {
612
644
  deleteHabitIds: [t.id]
613
645
  };
614
646
  }
615
- function ke(e, t) {
647
+ function Ne(e, t) {
616
648
  if (e.day) return b(e.day, t);
617
649
  }
618
- function Ae(e, t) {
650
+ function Pe(e, t) {
619
651
  let { due: n, ...r } = e, i = (/* @__PURE__ */ new Date()).toISOString();
620
652
  return { tasks: [t ? {
621
653
  ...r,
@@ -626,7 +658,7 @@ function Ae(e, t) {
626
658
  updatedAt: i
627
659
  }] };
628
660
  }
629
- function je(e, t) {
661
+ function Fe(e, t) {
630
662
  let { day: n, ...r } = e;
631
663
  return {
632
664
  ...r,
@@ -634,7 +666,7 @@ function je(e, t) {
634
666
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
635
667
  };
636
668
  }
637
- function Me(e, t, r) {
669
+ function Ie(e, t, r) {
638
670
  let i = n(t), a = e.history ?? [], o = B(r), c = s(e.period, t) === s(e.period, r);
639
671
  if (a.includes(i)) {
640
672
  let { checkedAt: t, ...r } = e, s = a.filter((e) => e !== i);
@@ -652,10 +684,10 @@ function Me(e, t, r) {
652
684
  updatedAt: o
653
685
  };
654
686
  }
655
- function Ne(e, t, r, i) {
656
- return G(e, t, n(r) === n(i) ? i : new Date(r.getFullYear(), r.getMonth(), r.getDate(), 12));
687
+ function Le(e, t, r, i) {
688
+ return W(e, t, n(r) === n(i) ? i : new Date(r.getFullYear(), r.getMonth(), r.getDate(), 12));
657
689
  }
658
- function Pe(e, t) {
690
+ function Re(e, t) {
659
691
  let r = B(t), i = n(u(t, 1));
660
692
  return j(e) ? { tasks: [{
661
693
  ...e,
@@ -668,7 +700,7 @@ function Pe(e, t) {
668
700
  updatedAt: r
669
701
  }] };
670
702
  }
671
- function Fe(e, t) {
703
+ function ze(e, t) {
672
704
  let r = B(t);
673
705
  if (j(e)) return { tasks: [{
674
706
  ...e,
@@ -687,22 +719,22 @@ function Fe(e, t) {
687
719
  updatedAt: r
688
720
  }] };
689
721
  }
690
- function Ie(e, t) {
722
+ function Be(e, t) {
691
723
  let n = e.tasks.filter((e) => M(e) && e.projectId === t), r = n.filter((e) => !e.doneAt), i = (e) => e.goalOrder ?? (e.due ? 2 ** 53 - 1 : -(2 ** 53 - 1)), a = [...r].sort((e, t) => i(e) - i(t) || e.createdAt.localeCompare(t.createdAt)), o = r.filter((e) => e.due).sort((e, t) => t.due.localeCompare(e.due) || e.createdAt.localeCompare(t.createdAt)), s = 0;
692
724
  return {
693
725
  open: a.map((e) => e.due ? o[s++] : e),
694
726
  done: n.filter((e) => e.doneAt).sort((e, t) => (t.due ?? "").localeCompare(e.due ?? "") || e.createdAt.localeCompare(t.createdAt))
695
727
  };
696
728
  }
697
- function Le(e, t) {
729
+ function Ve(e, t) {
698
730
  let n = e.tasks.filter((e) => e.projectId === t && e.goalOrder !== void 0).map((e) => e.goalOrder), r = e.tasks.filter((e) => M(e) && e.projectId === t).length;
699
731
  return Math.max(r, ...n.map((e) => e + 1));
700
732
  }
701
- function Re(e, t, n, r, i) {
733
+ function He(e, t, n, r, i) {
702
734
  let a = t.indexOf(n), o = t.indexOf(r);
703
735
  if (a < 0 || o < 0 || a === o) return {};
704
736
  let s = new Map(e.tasks.map((e) => [e.id, e])), c = B(i);
705
- return { tasks: X(t, a, o).map((e, t) => ({
737
+ return { tasks: Y(t, a, o).map((e, t) => ({
706
738
  task: s.get(e),
707
739
  goalOrder: t
708
740
  })).filter((e) => !!e.task && e.task.goalOrder !== e.goalOrder).map(({ task: e, goalOrder: t }) => ({
@@ -712,22 +744,22 @@ function Re(e, t, n, r, i) {
712
744
  })) };
713
745
  }
714
746
  // src/core/labels.ts
715
- var Q = {
747
+ var Z = {
716
748
  today: "今日",
717
749
  week: "今週",
718
750
  month: "数か月",
719
751
  year: "今年",
720
752
  life: "一生"
721
- }, ze = {
753
+ }, Ue = {
722
754
  today: "Action",
723
755
  week: "Week",
724
756
  month: "Month",
725
757
  year: "Year",
726
758
  life: "⭐"
727
- }, Be = {
728
- ...Q,
759
+ }, We = {
760
+ ...Z,
729
761
  pool: "未定(置き場)"
730
- }, Ve = {
762
+ }, Ge = {
731
763
  today: "今日やる",
732
764
  tomorrow: "明日やる",
733
765
  nextweek: "来週やる",
@@ -735,7 +767,7 @@ var Q = {
735
767
  month: "数か月以内にやる",
736
768
  year: "今年やる",
737
769
  life: "一生のうちに"
738
- }, He = {
770
+ }, Ke = {
739
771
  today: "今日",
740
772
  tomorrow: "明日",
741
773
  nextweek: "来週",
@@ -743,25 +775,25 @@ var Q = {
743
775
  month: "数か月",
744
776
  year: "今年",
745
777
  life: "一生"
746
- }, Ue = {
778
+ }, qe = {
747
779
  A: "重要・緊急",
748
780
  B: "重要",
749
781
  C: "通常",
750
782
  D: "低",
751
783
  P: "Private"
752
- }, We = {
784
+ }, Je = {
753
785
  day: "毎日",
754
786
  week: "毎週",
755
787
  month: "毎月",
756
788
  year: "毎年"
757
789
  };
758
790
  // src/core/review.ts
759
- function $(e) {
791
+ function Q(e) {
760
792
  let t = new Set(e.history ?? []);
761
793
  return e.checkedAt && t.add(n(new Date(e.checkedAt))), t;
762
794
  }
763
- function Ge(e, t) {
764
- let r = $(e);
795
+ function Ye(e, t) {
796
+ let r = Q(e);
765
797
  if (e.period === "day") return r.has(n(t));
766
798
  let i = s(e.period, t);
767
799
  for (let t of r) {
@@ -770,13 +802,51 @@ function Ge(e, t) {
770
802
  }
771
803
  return !1;
772
804
  }
773
- function Ke(e, t) {
805
+ function $(e) {
806
+ if (!e) return;
807
+ let t = new Date(e);
808
+ return Number.isNaN(t.getTime()) ? void 0 : n(t);
809
+ }
810
+ function Xe(e, t) {
811
+ let n = $(e.createdAt) ?? "", r = e.history ?? [], i = [...t].sort()[0];
812
+ return r.length >= 800 && r[0] > n ? r[0] : i && i < n ? i : n;
813
+ }
814
+ function Ze(e, t, n, r) {
815
+ if (t.has(n)) return !0;
816
+ if (n < r) return !1;
817
+ let i = $(e.endedAt);
818
+ return i && n >= i ? !1 : !(e.breaks ?? []).some((e) => {
819
+ let t = $(e.endedAt), r = $(e.resumedAt);
820
+ return !!t && !!r && n >= t && n < r;
821
+ });
822
+ }
823
+ function Qe(e, t) {
824
+ let r = Q(e);
825
+ return Ze(e, r, n(t), Xe(e, r));
826
+ }
827
+ function $e(e, t) {
828
+ let r = Q(e), i = Xe(e, r), a = e.endedAt ? new Date(e.endedAt) : void 0, o = a && !Number.isNaN(a.getTime()) ? a : void 0, c = o ?? t, l = n(c), [d, f, p] = (i || l).split("-").map(Number), m = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Set();
829
+ for (let t = new Date(d, f - 1, p); n(t) <= l; t = u(t, 1)) {
830
+ let a = n(t);
831
+ if (!Ze(e, r, a, i)) continue;
832
+ let o = s(e.period, t);
833
+ m.add(o), r.has(a) && h.add(o);
834
+ }
835
+ let g = s(e.period, c);
836
+ return h.has(g) || m.delete(g), {
837
+ start: new Date(d, f - 1, p),
838
+ ...o ? { end: o } : {},
839
+ done: h.size,
840
+ total: m.size
841
+ };
842
+ }
843
+ function et(e, t) {
774
844
  if (e.period !== "day") return 0;
775
- let r = $(e), i = r.has(n(t)) ? t : u(t, -1), a = 0;
845
+ let r = Q(e), i = r.has(n(t)) ? t : u(t, -1), a = 0;
776
846
  for (; r.has(n(i));) a++, i = u(i, -1);
777
847
  return a;
778
848
  }
779
- function qe(e, t, r) {
849
+ function tt(e, t, r) {
780
850
  let i = n(t), a = new Map(e.projects.map((e) => [e.id, e])), o = new Set(e.tasks.filter((e) => e.parentId && e.doneAt).map((e) => e.parentId));
781
851
  return e.tasks.filter((e) => e.doneAt && n(new Date(e.doneAt)) === i && !o.has(e.id)).sort((e, t) => e.doneAt.localeCompare(t.doneAt)).map((e) => ({
782
852
  task: e,
@@ -784,7 +854,7 @@ function qe(e, t, r) {
784
854
  project: e.projectId ? a.get(e.projectId) : void 0
785
855
  }));
786
856
  }
787
- function Je(e, t) {
857
+ function nt(e, t) {
788
858
  return Array.from({ length: t }, (n, r) => u(e, r - t + 1));
789
859
  }
790
- export { e as HORIZONS, l as HORIZON_HABIT_PERIOD, Q as HORIZON_NAME, Be as HORIZON_OPTION, c as HORIZON_PERIOD, ze as HORIZON_SUB, We as PERIOD_NAME, He as PLACED_MARK, Ve as PLACE_LABEL, t as PRIORITIES, Ue as PRIORITY_NAME, I as activeChild, Z as activeHabitChild, u as addDays, xe as applyChanges, w as autoDue, Fe as bringToToday, ue as buildColumns, q as childProjects, n as dayKey, v as dayLabel, h as daysUntil, qe as doneOn, m as dueLabel, ee as dueLabelWeekday, P as effectiveHorizon, Ne as finishOnDay, j as followsDue, k as goalDueNextWeek, $ as habitDays, Ge as habitDoneOn, Te as habitPlaceTargets, Oe as habitToTask, S as hasWhen, N as horizonForDue, d as inSamePeriod, D as isExpired, O as isForNextWeek, A as isForTomorrow, oe as isMonthOnly, M as isProjectGoal, F as isVisible, Je as lastDays, Y as mergeById, b as monthDayDate, a as monthKey, ke as monthlyDueDate, J as moveProject, pe as moveStep, fe as moveTo, ge as newHabit, ve as newProject, H as newTask, Le as nextGoalOrder, R as numbered, y as parseNthWeekday, x as parseYearDay, _ as periodHorizon, s as periodKey, p as periodLabel, U as placeDown, Ee as placeHabitDown, L as placeTargets, E as placedForKey, Pe as postponeToTomorrow, Ie as projectGoals, le as quickTarget, be as removeProject, he as removeTask, Re as reorderGoals, Ce as reorderHabits, we as reorderProjects, Se as reorderTasks, de as returnUp, Ae as setDue, me as setPriority, te as shortDueLabel, Ke as streak, G as toggleDone, K as toggleHabit, De as toggleHabitAll, Me as toggleHabitOnDay, ye as topProjects, r as weekKey, i as weekStart, C as whenDate, re as whenLabel, je as withDay, ae as withWhen, o as yearKey };
860
+ export { ve as HABIT_HISTORY_LIMIT, e as HORIZONS, l as HORIZON_HABIT_PERIOD, Z as HORIZON_NAME, We as HORIZON_OPTION, c as HORIZON_PERIOD, Ue as HORIZON_SUB, Je as PERIOD_NAME, Ke as PLACED_MARK, Ge as PLACE_LABEL, t as PRIORITIES, qe as PRIORITY_NAME, I as activeChild, X as activeHabitChild, u as addDays, Te as applyChanges, w as autoDue, ze as bringToToday, ue as buildColumns, q as childProjects, n as dayKey, v as dayLabel, h as daysUntil, tt as doneOn, m as dueLabel, ee as dueLabelWeekday, P as effectiveHorizon, ye as endHabit, K as endedHabits, Le as finishOnDay, j as followsDue, k as goalDueNextWeek, Qe as habitActiveOn, Q as habitDays, Ye as habitDoneOn, ke as habitPlaceTargets, $e as habitRecord, Me as habitToTask, S as hasWhen, N as horizonForDue, d as inSamePeriod, D as isExpired, O as isForNextWeek, A as isForTomorrow, oe as isMonthOnly, M as isProjectGoal, F as isVisible, nt as lastDays, J as mergeById, b as monthDayDate, a as monthKey, Ne as monthlyDueDate, we as moveProject, me as moveStep, pe as moveTo, _e as newHabit, xe as newProject, H as newTask, Ve as nextGoalOrder, R as numbered, y as parseNthWeekday, x as parseYearDay, _ as periodHorizon, s as periodKey, p as periodLabel, de as placeDown, Ae as placeHabitDown, L as placeTargets, E as placedForKey, Re as postponeToTomorrow, Be as projectGoals, le as quickTarget, Ce as removeProject, ge as removeTask, He as reorderGoals, De as reorderHabits, Oe as reorderProjects, Ee as reorderTasks, be as resumeHabit, fe as returnUp, Pe as setDue, he as setPriority, te as shortDueLabel, et as streak, W as toggleDone, G as toggleHabit, je as toggleHabitAll, Ie as toggleHabitOnDay, Se as topProjects, r as weekKey, i as weekStart, C as whenDate, re as whenLabel, Fe as withDay, ae as withWhen, o as yearKey };