@free-intelligence/core 1.3.0 → 1.12.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.
Files changed (41) hide show
  1. package/README.md +1 -0
  2. package/dist/availability/index.d.ts +132 -0
  3. package/dist/availability/index.js +278 -0
  4. package/dist/availability/index.js.map +1 -0
  5. package/dist/index.d.ts +907 -112
  6. package/dist/index.js +448 -9
  7. package/dist/index.js.map +1 -1
  8. package/package.json +31 -2
  9. package/src/agent/conversation-state-vectors.test.ts +125 -0
  10. package/src/agent/conversation-state.test.ts +320 -0
  11. package/src/agent/conversation-state.ts +278 -0
  12. package/src/agent/events.ts +50 -1
  13. package/src/agent/hook.ts +26 -2
  14. package/src/agent/sse-fixture.test.ts +53 -0
  15. package/src/agent/sse.ts +26 -0
  16. package/src/agent/state.test.ts +60 -0
  17. package/src/agent/state.ts +44 -0
  18. package/src/agent/transcript.test.ts +166 -15
  19. package/src/agent/transcript.ts +92 -13
  20. package/src/agent/turn-vectors.test.ts +75 -0
  21. package/src/agent/wire-map.ts +131 -0
  22. package/src/agent/wire.generated.ts +265 -0
  23. package/src/availability/availability.test.ts +130 -0
  24. package/src/availability/defaults.ts +89 -0
  25. package/src/availability/index.ts +6 -0
  26. package/src/availability/time.ts +38 -0
  27. package/src/availability/types.ts +69 -0
  28. package/src/availability/validation.ts +133 -0
  29. package/src/availability/week.ts +50 -0
  30. package/src/chat/message.ts +81 -2
  31. package/src/chat/record.generated.ts +156 -0
  32. package/src/conversation/derivations-vectors.test.ts +65 -0
  33. package/src/conversation/helpers.test.ts +329 -0
  34. package/src/conversation/helpers.ts +248 -3
  35. package/src/conversation/index.ts +17 -0
  36. package/src/conversation/library.ts +12 -0
  37. package/src/conversation/markdown.test.ts +84 -0
  38. package/src/conversation/markdown.ts +67 -0
  39. package/src/conversation/record.ts +29 -1
  40. package/src/copy.generated.ts +19 -0
  41. package/src/index.ts +55 -3
package/README.md CHANGED
@@ -18,6 +18,7 @@ is the glassmorphism skin built on top of it.
18
18
  | `AgentHook` | The transport interface a consumer implements: `{ turn, isStreaming, send, reset, abort }`. |
19
19
  | `ChatMessage`, `ConversationSummary` | Plain message / conversation shapes shared across the surface. |
20
20
  | conversation helpers | Pure helpers for building and merging conversation transcripts. |
21
+ | `@free-intelligence/core/availability` | Weekly hours, date exceptions and booking rules: types, validation and week math. |
21
22
 
22
23
  ## Install
23
24
 
@@ -0,0 +1,132 @@
1
+ /** `HH:mm`, 24 h. */
2
+ type TimeOfDay = string;
3
+ /** `YYYY-MM-DD`. */
4
+ type CalendarDate = string;
5
+ interface WeeklySlot {
6
+ /** As JavaScript counts it: 0 is Sunday. */
7
+ day: number;
8
+ start: TimeOfDay;
9
+ end: TimeOfDay;
10
+ label?: string;
11
+ }
12
+ /** Replaces the weekly pattern on one date. Without `fullDayClosed` it carries its own hours. */
13
+ interface DateOverride {
14
+ date: CalendarDate;
15
+ start?: TimeOfDay;
16
+ end?: TimeOfDay;
17
+ fullDayClosed: boolean;
18
+ reason?: string;
19
+ }
20
+ /** Durations are minutes. */
21
+ interface SchedulingRules {
22
+ breakStart?: TimeOfDay;
23
+ breakEnd?: TimeOfDay;
24
+ minSlotDuration?: number;
25
+ maxPatientsPerHour?: number;
26
+ bufferBetweenAppointments?: number;
27
+ }
28
+ interface DoctorAvailability {
29
+ version: number;
30
+ weeklySchedule: WeeklySlot[];
31
+ overrides: DateOverride[];
32
+ rules: SchedulingRules;
33
+ }
34
+ type AvailabilityErrorType = 'overlap' | 'invalid_time' | 'end_before_start' | 'duplicate_date';
35
+ interface AvailabilityError {
36
+ type: AvailabilityErrorType;
37
+ day?: number;
38
+ date?: CalendarDate;
39
+ /** Position in that day's list, when the error belongs to one slot. */
40
+ slotIndex?: number;
41
+ message: string;
42
+ severity: 'error' | 'warning';
43
+ }
44
+ /** Editing keeps the slots of a day that was switched off, so switching it back restores them. */
45
+ interface DaySchedule {
46
+ isWorking: boolean;
47
+ slots: WeeklySlot[];
48
+ }
49
+ type WeekSchedule = Record<number, DaySchedule>;
50
+ interface AvailabilityTemplate {
51
+ id: string;
52
+ name: string;
53
+ description: string;
54
+ weeklySchedule: WeeklySlot[];
55
+ }
56
+
57
+ declare const AVAILABILITY_VERSION = 1;
58
+ declare const DAYS_OF_WEEK: readonly [{
59
+ readonly value: 0;
60
+ readonly label: "Domingo";
61
+ readonly short: "Dom";
62
+ readonly abbr: "D";
63
+ }, {
64
+ readonly value: 1;
65
+ readonly label: "Lunes";
66
+ readonly short: "Lun";
67
+ readonly abbr: "L";
68
+ }, {
69
+ readonly value: 2;
70
+ readonly label: "Martes";
71
+ readonly short: "Mar";
72
+ readonly abbr: "M";
73
+ }, {
74
+ readonly value: 3;
75
+ readonly label: "Miércoles";
76
+ readonly short: "Mié";
77
+ readonly abbr: "X";
78
+ }, {
79
+ readonly value: 4;
80
+ readonly label: "Jueves";
81
+ readonly short: "Jue";
82
+ readonly abbr: "J";
83
+ }, {
84
+ readonly value: 5;
85
+ readonly label: "Viernes";
86
+ readonly short: "Vie";
87
+ readonly abbr: "V";
88
+ }, {
89
+ readonly value: 6;
90
+ readonly label: "Sábado";
91
+ readonly short: "Sáb";
92
+ readonly abbr: "S";
93
+ }];
94
+ declare const WEEKDAYS: readonly [1, 2, 3, 4, 5];
95
+ declare const WEEKEND: readonly [0, 6];
96
+ declare const DEFAULT_WORK_START = "09:00";
97
+ declare const DEFAULT_WORK_END = "18:00";
98
+ declare const DEFAULT_BREAK_START = "13:00";
99
+ declare const DEFAULT_BREAK_END = "14:00";
100
+ declare const SLOT_DURATION_CHOICES: readonly [15, 20, 30, 45, 60];
101
+ declare const DEFAULT_RULES: Readonly<SchedulingRules>;
102
+ declare const COMMON_EXCEPTION_REASONS: readonly ["Vacaciones", "Día festivo", "Conferencia", "Capacitación", "Cita personal", "Enfermedad", "Emergencia familiar"];
103
+ declare function emptyAvailability(): DoctorAvailability;
104
+ declare const AVAILABILITY_TEMPLATES: AvailabilityTemplate[];
105
+
106
+ declare const MINUTES_PER_DAY: number;
107
+ declare function timeToMinutes(time: TimeOfDay): number;
108
+ declare function minutesToTime(minutes: number): TimeOfDay;
109
+ declare function isValidTime(time: string): boolean;
110
+ declare function isEndAfterStart(start: TimeOfDay, end: TimeOfDay): boolean;
111
+ declare function isValidDate(date: string): boolean;
112
+ /** Local calendar date; `toISOString` would roll to tomorrow in the evening west of Greenwich. */
113
+ declare function toCalendarDate(date: Date): CalendarDate;
114
+
115
+ declare function slotsOverlap(a: WeeklySlot, b: WeeklySlot): boolean;
116
+ declare function validateAvailability(availability: DoctorAvailability): AvailabilityError[];
117
+ declare function hasBlockingErrors(errors: AvailabilityError[]): boolean;
118
+ interface ScheduleGap {
119
+ day: number;
120
+ from: string;
121
+ to: string;
122
+ }
123
+ declare function findGaps(slots: WeeklySlot[]): ScheduleGap[];
124
+
125
+ declare function groupByDay(weeklySchedule: WeeklySlot[]): WeekSchedule;
126
+ declare function availabilityFromWeek(week: WeekSchedule, overrides: DateOverride[], rules: SchedulingRules): DoctorAvailability;
127
+ /** `null` when the day has no room left before midnight. */
128
+ declare function suggestNextSlot(day: number, existing: WeeklySlot[]): WeeklySlot | null;
129
+ declare function weeklyHours(availability: DoctorAvailability): number;
130
+ declare function workingDays(availability: DoctorAvailability): number[];
131
+
132
+ export { AVAILABILITY_TEMPLATES, AVAILABILITY_VERSION, type AvailabilityError, type AvailabilityErrorType, type AvailabilityTemplate, COMMON_EXCEPTION_REASONS, type CalendarDate, DAYS_OF_WEEK, DEFAULT_BREAK_END, DEFAULT_BREAK_START, DEFAULT_RULES, DEFAULT_WORK_END, DEFAULT_WORK_START, type DateOverride, type DaySchedule, type DoctorAvailability, MINUTES_PER_DAY, SLOT_DURATION_CHOICES, type ScheduleGap, type SchedulingRules, type TimeOfDay, WEEKDAYS, WEEKEND, type WeekSchedule, type WeeklySlot, availabilityFromWeek, emptyAvailability, findGaps, groupByDay, hasBlockingErrors, isEndAfterStart, isValidDate, isValidTime, minutesToTime, slotsOverlap, suggestNextSlot, timeToMinutes, toCalendarDate, validateAvailability, weeklyHours, workingDays };
@@ -0,0 +1,278 @@
1
+ // src/availability/defaults.ts
2
+ var AVAILABILITY_VERSION = 1;
3
+ var DAYS_OF_WEEK = [
4
+ { value: 0, label: "Domingo", short: "Dom", abbr: "D" },
5
+ { value: 1, label: "Lunes", short: "Lun", abbr: "L" },
6
+ { value: 2, label: "Martes", short: "Mar", abbr: "M" },
7
+ { value: 3, label: "Mi\xE9rcoles", short: "Mi\xE9", abbr: "X" },
8
+ { value: 4, label: "Jueves", short: "Jue", abbr: "J" },
9
+ { value: 5, label: "Viernes", short: "Vie", abbr: "V" },
10
+ { value: 6, label: "S\xE1bado", short: "S\xE1b", abbr: "S" }
11
+ ];
12
+ var WEEKDAYS = [1, 2, 3, 4, 5];
13
+ var WEEKEND = [0, 6];
14
+ var DEFAULT_WORK_START = "09:00";
15
+ var DEFAULT_WORK_END = "18:00";
16
+ var DEFAULT_BREAK_START = "13:00";
17
+ var DEFAULT_BREAK_END = "14:00";
18
+ var SLOT_DURATION_CHOICES = [15, 20, 30, 45, 60];
19
+ var DEFAULT_RULES = {
20
+ minSlotDuration: 15,
21
+ maxPatientsPerHour: 4,
22
+ bufferBetweenAppointments: 5
23
+ };
24
+ var COMMON_EXCEPTION_REASONS = [
25
+ "Vacaciones",
26
+ "D\xEDa festivo",
27
+ "Conferencia",
28
+ "Capacitaci\xF3n",
29
+ "Cita personal",
30
+ "Enfermedad",
31
+ "Emergencia familiar"
32
+ ];
33
+ function emptyAvailability() {
34
+ return { version: AVAILABILITY_VERSION, weeklySchedule: [], overrides: [], rules: { ...DEFAULT_RULES } };
35
+ }
36
+ var everyDay = (days, ...hours) => days.flatMap((day) => hours.map((slot) => ({ day, ...slot })));
37
+ var AVAILABILITY_TEMPLATES = [
38
+ {
39
+ id: "standard-9-5",
40
+ name: "Est\xE1ndar 9-18 (L-V)",
41
+ description: "9:00 - 18:00, lunes a viernes, fines de semana libres",
42
+ weeklySchedule: everyDay(WEEKDAYS, { start: "09:00", end: "18:00" })
43
+ },
44
+ {
45
+ id: "morning-clinic",
46
+ name: "Cl\xEDnica Matutina (L-V)",
47
+ description: "8:00 - 14:00, lunes a viernes",
48
+ weeklySchedule: everyDay(WEEKDAYS, { start: "08:00", end: "14:00" })
49
+ },
50
+ {
51
+ id: "afternoon-clinic",
52
+ name: "Cl\xEDnica Vespertina (L-V)",
53
+ description: "15:00 - 21:00, lunes a viernes",
54
+ weeklySchedule: everyDay(WEEKDAYS, { start: "15:00", end: "21:00" })
55
+ },
56
+ {
57
+ id: "split-shift",
58
+ name: "Turno Partido (L-V)",
59
+ description: "9:00 - 13:00 y 16:00 - 20:00, lunes a viernes",
60
+ weeklySchedule: everyDay(
61
+ WEEKDAYS,
62
+ { start: "09:00", end: "13:00", label: "Ma\xF1ana" },
63
+ { start: "16:00", end: "20:00", label: "Tarde" }
64
+ )
65
+ },
66
+ {
67
+ id: "weekend-doctor",
68
+ name: "Doctor de Fin de Semana",
69
+ description: "10:00 - 14:00, s\xE1bado y domingo",
70
+ weeklySchedule: everyDay(WEEKEND, { start: "10:00", end: "14:00" })
71
+ },
72
+ {
73
+ id: "full-week",
74
+ name: "Semana Completa",
75
+ description: "9:00 - 18:00, todos los d\xEDas",
76
+ weeklySchedule: everyDay([0, ...WEEKDAYS, 6], { start: "09:00", end: "18:00" })
77
+ }
78
+ ];
79
+
80
+ // src/availability/time.ts
81
+ var MINUTES_PER_DAY = 24 * 60;
82
+ var TIME_PATTERN = /^([01]\d|2[0-3]):[0-5]\d$/;
83
+ var DATE_PATTERN = /^(\d{4})-(\d{2})-(\d{2})$/;
84
+ var twoDigits = (value) => String(value).padStart(2, "0");
85
+ function timeToMinutes(time) {
86
+ const [hours, minutes] = time.split(":").map(Number);
87
+ return hours * 60 + minutes;
88
+ }
89
+ function minutesToTime(minutes) {
90
+ return `${twoDigits(Math.floor(minutes / 60) % 24)}:${twoDigits(minutes % 60)}`;
91
+ }
92
+ function isValidTime(time) {
93
+ return TIME_PATTERN.test(time);
94
+ }
95
+ function isEndAfterStart(start, end) {
96
+ return timeToMinutes(end) > timeToMinutes(start);
97
+ }
98
+ function isValidDate(date) {
99
+ const match = DATE_PATTERN.exec(date);
100
+ if (!match) return false;
101
+ const [year, month, day] = match.slice(1).map(Number);
102
+ const parsed = new Date(Date.UTC(year, month - 1, day));
103
+ return parsed.getUTCMonth() === month - 1 && parsed.getUTCDate() === day;
104
+ }
105
+ function toCalendarDate(date) {
106
+ return `${date.getFullYear()}-${twoDigits(date.getMonth() + 1)}-${twoDigits(date.getDate())}`;
107
+ }
108
+
109
+ // src/availability/validation.ts
110
+ var MIN_SLOT_DURATION = 5;
111
+ function problemInHours(start, end) {
112
+ if (!isValidTime(start)) return { type: "invalid_time", message: `Hora de inicio inv\xE1lida: ${start}` };
113
+ if (!isValidTime(end)) return { type: "invalid_time", message: `Hora de fin inv\xE1lida: ${end}` };
114
+ if (!isEndAfterStart(start, end)) {
115
+ return {
116
+ type: "end_before_start",
117
+ message: `La hora de fin (${end}) debe ser posterior a la de inicio (${start})`
118
+ };
119
+ }
120
+ return null;
121
+ }
122
+ function problemInOverride(override) {
123
+ if (!isValidDate(override.date)) return { type: "invalid_time", message: `Fecha inv\xE1lida: ${override.date}` };
124
+ if (override.fullDayClosed) return null;
125
+ if (!override.start || !override.end) {
126
+ return { type: "invalid_time", message: "Debe especificar hora de inicio y fin, o marcar como d\xEDa libre" };
127
+ }
128
+ return problemInHours(override.start, override.end);
129
+ }
130
+ function problemsInRules(rules) {
131
+ const errors = [];
132
+ const { breakStart, breakEnd, minSlotDuration, maxPatientsPerHour } = rules;
133
+ if (breakStart && breakEnd) {
134
+ const problem = problemInHours(breakStart, breakEnd);
135
+ if (problem) errors.push({ ...problem, message: `Descanso: ${problem.message}`, severity: "error" });
136
+ } else if (breakStart || breakEnd) {
137
+ errors.push({
138
+ type: "invalid_time",
139
+ message: "Debe especificar tanto inicio como fin del descanso",
140
+ severity: "warning"
141
+ });
142
+ }
143
+ if (minSlotDuration !== void 0 && minSlotDuration < MIN_SLOT_DURATION) {
144
+ errors.push({
145
+ type: "invalid_time",
146
+ message: `La duraci\xF3n m\xEDnima debe ser al menos ${MIN_SLOT_DURATION} minutos`,
147
+ severity: "error"
148
+ });
149
+ }
150
+ if (maxPatientsPerHour !== void 0 && maxPatientsPerHour < 1) {
151
+ errors.push({ type: "invalid_time", message: "Debe permitir al menos 1 paciente por hora", severity: "error" });
152
+ }
153
+ return errors;
154
+ }
155
+ function slotsOverlap(a, b) {
156
+ return a.day === b.day && timeToMinutes(a.start) < timeToMinutes(b.end) && timeToMinutes(b.start) < timeToMinutes(a.end);
157
+ }
158
+ function slotsByDay(slots) {
159
+ const days = /* @__PURE__ */ new Map();
160
+ for (const slot of slots) days.set(slot.day, [...days.get(slot.day) ?? [], slot]);
161
+ return days;
162
+ }
163
+ function problemsInDay(day, slots) {
164
+ const errors = [];
165
+ slots.forEach((slot, slotIndex) => {
166
+ const problem = problemInHours(slot.start, slot.end);
167
+ if (problem) errors.push({ ...problem, day, slotIndex, severity: "error" });
168
+ slots.slice(0, slotIndex).forEach((earlier) => {
169
+ if (!slotsOverlap(earlier, slot)) return;
170
+ errors.push({
171
+ type: "overlap",
172
+ day,
173
+ slotIndex,
174
+ message: `Solapamiento detectado: ${earlier.start}-${earlier.end} y ${slot.start}-${slot.end}`,
175
+ severity: "error"
176
+ });
177
+ });
178
+ });
179
+ return errors;
180
+ }
181
+ function problemsInOverrides(overrides) {
182
+ const errors = [];
183
+ const seen = /* @__PURE__ */ new Set();
184
+ for (const override of overrides) {
185
+ const { date } = override;
186
+ const problem = problemInOverride(override);
187
+ if (problem) errors.push({ ...problem, date, severity: "error" });
188
+ if (seen.has(date)) {
189
+ errors.push({ type: "duplicate_date", date, message: `Fecha duplicada: ${date}`, severity: "error" });
190
+ }
191
+ seen.add(date);
192
+ }
193
+ return errors;
194
+ }
195
+ function validateAvailability(availability) {
196
+ const weekly = [...slotsByDay(availability.weeklySchedule)].flatMap(([day, slots]) => problemsInDay(day, slots));
197
+ return [...weekly, ...problemsInOverrides(availability.overrides), ...problemsInRules(availability.rules)];
198
+ }
199
+ function hasBlockingErrors(errors) {
200
+ return errors.some((error) => error.severity === "error");
201
+ }
202
+ function findGaps(slots) {
203
+ return [...slotsByDay(slots)].flatMap(([day, daySlots]) => {
204
+ const sorted = [...daySlots].sort((a, b) => timeToMinutes(a.start) - timeToMinutes(b.start));
205
+ return sorted.slice(1).flatMap((next, i) => {
206
+ const previous = sorted[i];
207
+ return isEndAfterStart(previous.end, next.start) ? [{ day, from: previous.end, to: next.start }] : [];
208
+ });
209
+ });
210
+ }
211
+
212
+ // src/availability/week.ts
213
+ var GAP_BEFORE_NEW_SLOT = 60;
214
+ var NEW_SLOT_LENGTH = 4 * 60;
215
+ var SHORTEST_NEW_SLOT = 30;
216
+ var LAST_MINUTE = MINUTES_PER_DAY - 1;
217
+ function groupByDay(weeklySchedule) {
218
+ return Object.fromEntries(
219
+ DAYS_OF_WEEK.map(({ value }) => {
220
+ const slots = weeklySchedule.filter((slot) => slot.day === value).sort((a, b) => timeToMinutes(a.start) - timeToMinutes(b.start));
221
+ return [value, { isWorking: slots.length > 0, slots }];
222
+ })
223
+ );
224
+ }
225
+ function availabilityFromWeek(week, overrides, rules) {
226
+ const weeklySchedule = Object.values(week).flatMap((day) => day.isWorking ? day.slots : []);
227
+ return { version: AVAILABILITY_VERSION, weeklySchedule, overrides, rules };
228
+ }
229
+ function suggestNextSlot(day, existing) {
230
+ const last = existing[existing.length - 1];
231
+ if (!last) return { day, start: DEFAULT_WORK_START, end: DEFAULT_WORK_END };
232
+ const start = timeToMinutes(last.end) + GAP_BEFORE_NEW_SLOT;
233
+ const end = Math.min(start + NEW_SLOT_LENGTH, LAST_MINUTE);
234
+ if (!(end - start >= SHORTEST_NEW_SLOT)) return null;
235
+ return { day, start: minutesToTime(start), end: minutesToTime(end) };
236
+ }
237
+ function weeklyHours(availability) {
238
+ const minutes = availability.weeklySchedule.reduce(
239
+ (total, slot) => total + timeToMinutes(slot.end) - timeToMinutes(slot.start),
240
+ 0
241
+ );
242
+ return minutes / 60;
243
+ }
244
+ function workingDays(availability) {
245
+ return [...new Set(availability.weeklySchedule.map((slot) => slot.day))].sort();
246
+ }
247
+ export {
248
+ AVAILABILITY_TEMPLATES,
249
+ AVAILABILITY_VERSION,
250
+ COMMON_EXCEPTION_REASONS,
251
+ DAYS_OF_WEEK,
252
+ DEFAULT_BREAK_END,
253
+ DEFAULT_BREAK_START,
254
+ DEFAULT_RULES,
255
+ DEFAULT_WORK_END,
256
+ DEFAULT_WORK_START,
257
+ MINUTES_PER_DAY,
258
+ SLOT_DURATION_CHOICES,
259
+ WEEKDAYS,
260
+ WEEKEND,
261
+ availabilityFromWeek,
262
+ emptyAvailability,
263
+ findGaps,
264
+ groupByDay,
265
+ hasBlockingErrors,
266
+ isEndAfterStart,
267
+ isValidDate,
268
+ isValidTime,
269
+ minutesToTime,
270
+ slotsOverlap,
271
+ suggestNextSlot,
272
+ timeToMinutes,
273
+ toCalendarDate,
274
+ validateAvailability,
275
+ weeklyHours,
276
+ workingDays
277
+ };
278
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/availability/defaults.ts","../../src/availability/time.ts","../../src/availability/validation.ts","../../src/availability/week.ts"],"sourcesContent":["import type { AvailabilityTemplate, DoctorAvailability, SchedulingRules, WeeklySlot } from './types';\n\nexport const AVAILABILITY_VERSION = 1;\n\nexport const DAYS_OF_WEEK = [\n { value: 0, label: 'Domingo', short: 'Dom', abbr: 'D' },\n { value: 1, label: 'Lunes', short: 'Lun', abbr: 'L' },\n { value: 2, label: 'Martes', short: 'Mar', abbr: 'M' },\n { value: 3, label: 'Miércoles', short: 'Mié', abbr: 'X' },\n { value: 4, label: 'Jueves', short: 'Jue', abbr: 'J' },\n { value: 5, label: 'Viernes', short: 'Vie', abbr: 'V' },\n { value: 6, label: 'Sábado', short: 'Sáb', abbr: 'S' },\n] as const;\n\nexport const WEEKDAYS = [1, 2, 3, 4, 5] as const;\nexport const WEEKEND = [0, 6] as const;\n\nexport const DEFAULT_WORK_START = '09:00';\nexport const DEFAULT_WORK_END = '18:00';\nexport const DEFAULT_BREAK_START = '13:00';\nexport const DEFAULT_BREAK_END = '14:00';\n\nexport const SLOT_DURATION_CHOICES = [15, 20, 30, 45, 60] as const;\n\nexport const DEFAULT_RULES: Readonly<SchedulingRules> = {\n minSlotDuration: 15,\n maxPatientsPerHour: 4,\n bufferBetweenAppointments: 5,\n};\n\nexport const COMMON_EXCEPTION_REASONS = [\n 'Vacaciones',\n 'Día festivo',\n 'Conferencia',\n 'Capacitación',\n 'Cita personal',\n 'Enfermedad',\n 'Emergencia familiar',\n] as const;\n\nexport function emptyAvailability(): DoctorAvailability {\n return { version: AVAILABILITY_VERSION, weeklySchedule: [], overrides: [], rules: { ...DEFAULT_RULES } };\n}\n\nconst everyDay = (days: readonly number[], ...hours: Omit<WeeklySlot, 'day'>[]): WeeklySlot[] =>\n days.flatMap((day) => hours.map((slot) => ({ day, ...slot })));\n\nexport const AVAILABILITY_TEMPLATES: AvailabilityTemplate[] = [\n {\n id: 'standard-9-5',\n name: 'Estándar 9-18 (L-V)',\n description: '9:00 - 18:00, lunes a viernes, fines de semana libres',\n weeklySchedule: everyDay(WEEKDAYS, { start: '09:00', end: '18:00' }),\n },\n {\n id: 'morning-clinic',\n name: 'Clínica Matutina (L-V)',\n description: '8:00 - 14:00, lunes a viernes',\n weeklySchedule: everyDay(WEEKDAYS, { start: '08:00', end: '14:00' }),\n },\n {\n id: 'afternoon-clinic',\n name: 'Clínica Vespertina (L-V)',\n description: '15:00 - 21:00, lunes a viernes',\n weeklySchedule: everyDay(WEEKDAYS, { start: '15:00', end: '21:00' }),\n },\n {\n id: 'split-shift',\n name: 'Turno Partido (L-V)',\n description: '9:00 - 13:00 y 16:00 - 20:00, lunes a viernes',\n weeklySchedule: everyDay(\n WEEKDAYS,\n { start: '09:00', end: '13:00', label: 'Mañana' },\n { start: '16:00', end: '20:00', label: 'Tarde' },\n ),\n },\n {\n id: 'weekend-doctor',\n name: 'Doctor de Fin de Semana',\n description: '10:00 - 14:00, sábado y domingo',\n weeklySchedule: everyDay(WEEKEND, { start: '10:00', end: '14:00' }),\n },\n {\n id: 'full-week',\n name: 'Semana Completa',\n description: '9:00 - 18:00, todos los días',\n weeklySchedule: everyDay([0, ...WEEKDAYS, 6], { start: '09:00', end: '18:00' }),\n },\n];\n","import type { CalendarDate, TimeOfDay } from './types';\n\nexport const MINUTES_PER_DAY = 24 * 60;\n\nconst TIME_PATTERN = /^([01]\\d|2[0-3]):[0-5]\\d$/;\nconst DATE_PATTERN = /^(\\d{4})-(\\d{2})-(\\d{2})$/;\n\nconst twoDigits = (value: number): string => String(value).padStart(2, '0');\n\nexport function timeToMinutes(time: TimeOfDay): number {\n const [hours, minutes] = time.split(':').map(Number);\n return hours * 60 + minutes;\n}\n\nexport function minutesToTime(minutes: number): TimeOfDay {\n return `${twoDigits(Math.floor(minutes / 60) % 24)}:${twoDigits(minutes % 60)}`;\n}\n\nexport function isValidTime(time: string): boolean {\n return TIME_PATTERN.test(time);\n}\n\nexport function isEndAfterStart(start: TimeOfDay, end: TimeOfDay): boolean {\n return timeToMinutes(end) > timeToMinutes(start);\n}\n\nexport function isValidDate(date: string): boolean {\n const match = DATE_PATTERN.exec(date);\n if (!match) return false;\n const [year, month, day] = match.slice(1).map(Number);\n const parsed = new Date(Date.UTC(year, month - 1, day));\n return parsed.getUTCMonth() === month - 1 && parsed.getUTCDate() === day;\n}\n\n/** Local calendar date; `toISOString` would roll to tomorrow in the evening west of Greenwich. */\nexport function toCalendarDate(date: Date): CalendarDate {\n return `${date.getFullYear()}-${twoDigits(date.getMonth() + 1)}-${twoDigits(date.getDate())}`;\n}\n","import { isEndAfterStart, isValidDate, isValidTime, timeToMinutes } from './time';\nimport type {\n AvailabilityError,\n DateOverride,\n DoctorAvailability,\n SchedulingRules,\n WeeklySlot,\n} from './types';\n\nconst MIN_SLOT_DURATION = 5;\n\ntype Problem = Pick<AvailabilityError, 'type' | 'message'>;\n\nfunction problemInHours(start: string, end: string): Problem | null {\n if (!isValidTime(start)) return { type: 'invalid_time', message: `Hora de inicio inválida: ${start}` };\n if (!isValidTime(end)) return { type: 'invalid_time', message: `Hora de fin inválida: ${end}` };\n if (!isEndAfterStart(start, end)) {\n return {\n type: 'end_before_start',\n message: `La hora de fin (${end}) debe ser posterior a la de inicio (${start})`,\n };\n }\n return null;\n}\n\nfunction problemInOverride(override: DateOverride): Problem | null {\n if (!isValidDate(override.date)) return { type: 'invalid_time', message: `Fecha inválida: ${override.date}` };\n if (override.fullDayClosed) return null;\n if (!override.start || !override.end) {\n return { type: 'invalid_time', message: 'Debe especificar hora de inicio y fin, o marcar como día libre' };\n }\n return problemInHours(override.start, override.end);\n}\n\nfunction problemsInRules(rules: SchedulingRules): AvailabilityError[] {\n const errors: AvailabilityError[] = [];\n const { breakStart, breakEnd, minSlotDuration, maxPatientsPerHour } = rules;\n\n if (breakStart && breakEnd) {\n const problem = problemInHours(breakStart, breakEnd);\n if (problem) errors.push({ ...problem, message: `Descanso: ${problem.message}`, severity: 'error' });\n } else if (breakStart || breakEnd) {\n errors.push({\n type: 'invalid_time',\n message: 'Debe especificar tanto inicio como fin del descanso',\n severity: 'warning',\n });\n }\n if (minSlotDuration !== undefined && minSlotDuration < MIN_SLOT_DURATION) {\n errors.push({\n type: 'invalid_time',\n message: `La duración mínima debe ser al menos ${MIN_SLOT_DURATION} minutos`,\n severity: 'error',\n });\n }\n if (maxPatientsPerHour !== undefined && maxPatientsPerHour < 1) {\n errors.push({ type: 'invalid_time', message: 'Debe permitir al menos 1 paciente por hora', severity: 'error' });\n }\n return errors;\n}\n\nexport function slotsOverlap(a: WeeklySlot, b: WeeklySlot): boolean {\n return (\n a.day === b.day &&\n timeToMinutes(a.start) < timeToMinutes(b.end) &&\n timeToMinutes(b.start) < timeToMinutes(a.end)\n );\n}\n\nfunction slotsByDay(slots: WeeklySlot[]): Map<number, WeeklySlot[]> {\n const days = new Map<number, WeeklySlot[]>();\n for (const slot of slots) days.set(slot.day, [...(days.get(slot.day) ?? []), slot]);\n return days;\n}\n\nfunction problemsInDay(day: number, slots: WeeklySlot[]): AvailabilityError[] {\n const errors: AvailabilityError[] = [];\n slots.forEach((slot, slotIndex) => {\n const problem = problemInHours(slot.start, slot.end);\n if (problem) errors.push({ ...problem, day, slotIndex, severity: 'error' });\n slots.slice(0, slotIndex).forEach((earlier) => {\n if (!slotsOverlap(earlier, slot)) return;\n errors.push({\n type: 'overlap',\n day,\n slotIndex,\n message: `Solapamiento detectado: ${earlier.start}-${earlier.end} y ${slot.start}-${slot.end}`,\n severity: 'error',\n });\n });\n });\n return errors;\n}\n\nfunction problemsInOverrides(overrides: DateOverride[]): AvailabilityError[] {\n const errors: AvailabilityError[] = [];\n const seen = new Set<string>();\n for (const override of overrides) {\n const { date } = override;\n const problem = problemInOverride(override);\n if (problem) errors.push({ ...problem, date, severity: 'error' });\n if (seen.has(date)) {\n errors.push({ type: 'duplicate_date', date, message: `Fecha duplicada: ${date}`, severity: 'error' });\n }\n seen.add(date);\n }\n return errors;\n}\n\nexport function validateAvailability(availability: DoctorAvailability): AvailabilityError[] {\n const weekly = [...slotsByDay(availability.weeklySchedule)].flatMap(([day, slots]) => problemsInDay(day, slots));\n return [...weekly, ...problemsInOverrides(availability.overrides), ...problemsInRules(availability.rules)];\n}\n\nexport function hasBlockingErrors(errors: AvailabilityError[]): boolean {\n return errors.some((error) => error.severity === 'error');\n}\n\nexport interface ScheduleGap {\n day: number;\n from: string;\n to: string;\n}\n\nexport function findGaps(slots: WeeklySlot[]): ScheduleGap[] {\n return [...slotsByDay(slots)].flatMap(([day, daySlots]) => {\n const sorted = [...daySlots].sort((a, b) => timeToMinutes(a.start) - timeToMinutes(b.start));\n return sorted.slice(1).flatMap((next, i) => {\n const previous = sorted[i];\n return isEndAfterStart(previous.end, next.start) ? [{ day, from: previous.end, to: next.start }] : [];\n });\n });\n}\n","import { AVAILABILITY_VERSION, DAYS_OF_WEEK, DEFAULT_WORK_END, DEFAULT_WORK_START } from './defaults';\nimport { MINUTES_PER_DAY, minutesToTime, timeToMinutes } from './time';\nimport type { DateOverride, DoctorAvailability, SchedulingRules, WeeklySlot, WeekSchedule } from './types';\n\nconst GAP_BEFORE_NEW_SLOT = 60;\nconst NEW_SLOT_LENGTH = 4 * 60;\nconst SHORTEST_NEW_SLOT = 30;\nconst LAST_MINUTE = MINUTES_PER_DAY - 1;\n\nexport function groupByDay(weeklySchedule: WeeklySlot[]): WeekSchedule {\n return Object.fromEntries(\n DAYS_OF_WEEK.map(({ value }) => {\n const slots = weeklySchedule\n .filter((slot) => slot.day === value)\n .sort((a, b) => timeToMinutes(a.start) - timeToMinutes(b.start));\n return [value, { isWorking: slots.length > 0, slots }];\n }),\n );\n}\n\nexport function availabilityFromWeek(\n week: WeekSchedule,\n overrides: DateOverride[],\n rules: SchedulingRules,\n): DoctorAvailability {\n const weeklySchedule = Object.values(week).flatMap((day) => (day.isWorking ? day.slots : []));\n return { version: AVAILABILITY_VERSION, weeklySchedule, overrides, rules };\n}\n\n/** `null` when the day has no room left before midnight. */\nexport function suggestNextSlot(day: number, existing: WeeklySlot[]): WeeklySlot | null {\n const last = existing[existing.length - 1];\n if (!last) return { day, start: DEFAULT_WORK_START, end: DEFAULT_WORK_END };\n const start = timeToMinutes(last.end) + GAP_BEFORE_NEW_SLOT;\n const end = Math.min(start + NEW_SLOT_LENGTH, LAST_MINUTE);\n if (!(end - start >= SHORTEST_NEW_SLOT)) return null;\n return { day, start: minutesToTime(start), end: minutesToTime(end) };\n}\n\nexport function weeklyHours(availability: DoctorAvailability): number {\n const minutes = availability.weeklySchedule.reduce(\n (total, slot) => total + timeToMinutes(slot.end) - timeToMinutes(slot.start),\n 0,\n );\n return minutes / 60;\n}\n\nexport function workingDays(availability: DoctorAvailability): number[] {\n return [...new Set(availability.weeklySchedule.map((slot) => slot.day))].sort();\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