@1agents/dsh-plugin-todo 0.0.0-stage → 0.1.1

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/client.js ADDED
@@ -0,0 +1,967 @@
1
+ window.__ModuleLoader__.load({id:"@1agents/dsh-plugin-todo",dependencies:["react","react/jsx-runtime"],factory:(require)=>{var module={exports:{}};var exports=module.exports;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/client.jsx
21
+ var client_exports = {};
22
+ __export(client_exports, {
23
+ apply: () => apply,
24
+ inject: () => inject
25
+ });
26
+ module.exports = __toCommonJS(client_exports);
27
+ var import_react = require("react");
28
+
29
+ // src/contract.js
30
+ var SERVICE = "iosAgenda";
31
+ var PACKAGE = "@1agents/dsh-plugin-todo";
32
+ var PANEL_ID = "ios-agenda";
33
+ var METHODS = ["authorize", "snapshot", "createReminder", "completeReminder", "deleteReminder", "createEvent", "deleteEvent"];
34
+ function objectOf(value) {
35
+ if (!value || typeof value !== "object" || Array.isArray(value)) return {};
36
+ return value;
37
+ }
38
+ function resultOf(value) {
39
+ if (value && typeof value === "object" && (value.ok === true || value.ok === false)) return value;
40
+ throw new Error("\u539F\u751F\u7A0B\u5E8F\u8FD4\u56DE\u4E86\u65E0\u6CD5\u8BC6\u522B\u7684\u7ED3\u679C");
41
+ }
42
+ var codec = (name, parse) => ({
43
+ mode: "strict",
44
+ typeSymbol: `${PACKAGE}#${name}`,
45
+ create: () => ({ parse })
46
+ });
47
+ var contribution = {
48
+ package: PACKAGE,
49
+ descriptors: METHODS.map((method) => ({
50
+ id: `${PACKAGE}#${method}`,
51
+ service: SERVICE,
52
+ namespace: SERVICE,
53
+ method,
54
+ invocation: { kind: "direct" },
55
+ cancellation: { parameter: "signal" },
56
+ parameters: [
57
+ { name: "input", wire: "input", source: "json", codec: codec("Input", objectOf) }
58
+ ],
59
+ result: codec("Result", resultOf)
60
+ }))
61
+ };
62
+
63
+ // src/client.jsx
64
+ var import_jsx_runtime = require("react/jsx-runtime");
65
+ var NS = "iosAgenda";
66
+ var zh = {
67
+ panel: "\u65E5\u7A0B",
68
+ refresh: "\u5237\u65B0",
69
+ loading: "\u6B63\u5728\u8BFB\u53D6\u672C\u673A\u6570\u636E\u2026",
70
+ unavailable: "\u9875\u9762\u8FD8\u6CA1\u6709\u8FDE\u4E0A\u672C\u673A\u8BFB\u5199\u7A0B\u5E8F",
71
+ newReminder: "\u65B0\u63D0\u9192",
72
+ newEvent: "\u65B0\u65E5\u7A0B",
73
+ titleField: "\u6807\u9898",
74
+ start: "\u5F00\u59CB",
75
+ end: "\u7ED3\u675F",
76
+ add: "\u6DFB\u52A0",
77
+ complete: "\u5B8C\u6210",
78
+ remove: "\u5220\u9664",
79
+ permission: "\u9700\u8981\u5728\u7CFB\u7EDF\u8BBE\u7F6E\u91CC\u5141\u8BB8 IosAgenda.app\uFF08work.1agents.ios-agenda\uFF09\u8BBF\u95EE\u63D0\u9192\u4E8B\u9879\u548C\u65E5\u5386\u3002",
80
+ authorize: "\u6388\u6743",
81
+ openSettings: "\u6253\u5F00\u7CFB\u7EDF\u8BBE\u7F6E",
82
+ authTitle: "\u9700\u8981\u8BBF\u95EE\u63D0\u9192\u4E8B\u9879\u548C\u65E5\u5386",
83
+ authBody: "\u70B9\u6388\u6743\u540E\u4F1A\u5F39\u51FA\u7CFB\u7EDF\u8BF7\u6C42\u3002\u5982\u679C\u4E4B\u524D\u62D2\u7EDD\u8FC7\uFF0C\u4F1A\u6253\u5F00\u7CFB\u7EDF\u8BBE\u7F6E\u91CC\u7684\u5BF9\u5E94\u5F00\u5173\u3002",
84
+ authGranted: "\u5DF2\u5141\u8BB8",
85
+ authNeeded: "\u672A\u5141\u8BB8",
86
+ authSettings: "\u7CFB\u7EDF\u8BBE\u7F6E\u5DF2\u6253\u5F00\u3002\u6253\u5F00\u5F00\u5173\u540E\u70B9\u5237\u65B0\u3002",
87
+ reminders: "\u63D0\u9192\u4E8B\u9879",
88
+ allDay: "\u5168\u5929",
89
+ continues: "\u7EED",
90
+ overdue: "\u903E\u671F",
91
+ undated: "\u65E0\u65E5\u671F",
92
+ emptyDay: "\u8FD9\u4E00\u5929\u6CA1\u6709\u5B89\u6392",
93
+ today: "\u4ECA\u5929",
94
+ week: "\u672C\u5468",
95
+ prevMonth: "\u4E0A\u4E2A\u6708",
96
+ nextMonth: "\u4E0B\u4E2A\u6708",
97
+ untitled: "\u672A\u547D\u540D",
98
+ lists: "\u5217\u8868",
99
+ calendars: "\u65E5\u5386"
100
+ };
101
+ var en = {
102
+ panel: "Agenda",
103
+ refresh: "Refresh",
104
+ loading: "Reading local data\u2026",
105
+ unavailable: "The local agenda program is not connected",
106
+ newReminder: "New reminder",
107
+ newEvent: "New event",
108
+ titleField: "Title",
109
+ start: "Start",
110
+ end: "End",
111
+ add: "Add",
112
+ complete: "Complete",
113
+ remove: "Delete",
114
+ permission: "Allow IosAgenda.app (work.1agents.ios-agenda) to access Reminders and Calendar in System Settings.",
115
+ authorize: "Allow access",
116
+ openSettings: "Open System Settings",
117
+ authTitle: "Reminders and Calendar access",
118
+ authBody: "Allow access to show the system prompt. If access was denied, this opens the matching switch in System Settings.",
119
+ authGranted: "Allowed",
120
+ authNeeded: "Not allowed",
121
+ authSettings: "System Settings is open. Turn the switch on, then refresh.",
122
+ reminders: "Reminders",
123
+ allDay: "All day",
124
+ continues: "Continues",
125
+ overdue: "Overdue",
126
+ undated: "No date",
127
+ emptyDay: "Nothing scheduled",
128
+ today: "Today",
129
+ week: "This week",
130
+ prevMonth: "Previous month",
131
+ nextMonth: "Next month",
132
+ untitled: "Untitled",
133
+ lists: "Lists",
134
+ calendars: "Calendars"
135
+ };
136
+ var VIEW_PREFERENCE_KEY = "dsh.ios-agenda.view";
137
+ function hexColor(value) {
138
+ return typeof value === "string" && /^#[0-9A-Fa-f]{6}$/.test(value) ? value : "";
139
+ }
140
+ function idList(value) {
141
+ if (!Array.isArray(value)) return [];
142
+ return value.filter((item) => typeof item === "string" && item);
143
+ }
144
+ function readViewPreference() {
145
+ const empty = { mode: "day", hiddenLists: [], hiddenCalendars: [] };
146
+ if (typeof localStorage === "undefined") return empty;
147
+ try {
148
+ const parsed = JSON.parse(localStorage.getItem(VIEW_PREFERENCE_KEY) || "null");
149
+ if (!parsed || typeof parsed !== "object") return empty;
150
+ return {
151
+ mode: parsed.mode === "week" ? "week" : "day",
152
+ hiddenLists: idList(parsed.hiddenLists),
153
+ hiddenCalendars: idList(parsed.hiddenCalendars)
154
+ };
155
+ } catch {
156
+ return empty;
157
+ }
158
+ }
159
+ function accessGranted(status) {
160
+ return status === "fullAccess" || status === "authorized";
161
+ }
162
+ function accessBlocked(status) {
163
+ return status === "denied" || status === "restricted" || status === "writeOnly";
164
+ }
165
+ function soleAccent(colors) {
166
+ const unique = new Set(colors.filter(Boolean));
167
+ return unique.size === 1 ? [...unique][0] : "";
168
+ }
169
+ function startOfDay(date) {
170
+ const next = new Date(date);
171
+ next.setHours(0, 0, 0, 0);
172
+ return next;
173
+ }
174
+ function addDays(date, days) {
175
+ const next = new Date(date);
176
+ next.setDate(next.getDate() + days);
177
+ return next;
178
+ }
179
+ function startOfWeek(date) {
180
+ const day = startOfDay(date);
181
+ const weekday = day.getDay();
182
+ return addDays(day, weekday === 0 ? -6 : 1 - weekday);
183
+ }
184
+ function monthGrid(year, month) {
185
+ const start = startOfWeek(new Date(year, month, 1));
186
+ return Array.from({ length: 42 }, (_, index) => addDays(start, index));
187
+ }
188
+ function sameDay(left, right) {
189
+ return left.getFullYear() === right.getFullYear() && left.getMonth() === right.getMonth() && left.getDate() === right.getDate();
190
+ }
191
+ function dayKey(date) {
192
+ const month = String(date.getMonth() + 1).padStart(2, "0");
193
+ const day = String(date.getDate()).padStart(2, "0");
194
+ return `${date.getFullYear()}-${month}-${day}`;
195
+ }
196
+ function parseDate(value) {
197
+ if (!value) return null;
198
+ const date = new Date(value);
199
+ return Number.isNaN(date.getTime()) ? null : date;
200
+ }
201
+ function hasClock(date) {
202
+ return date.getHours() !== 0 || date.getMinutes() !== 0;
203
+ }
204
+ function clock(date) {
205
+ return new Intl.DateTimeFormat(void 0, { hour: "2-digit", minute: "2-digit", hourCycle: "h23" }).format(date);
206
+ }
207
+ function monthHeading(year, month) {
208
+ return new Intl.DateTimeFormat(void 0, { year: "numeric", month: "long" }).format(new Date(year, month, 1));
209
+ }
210
+ function dayHeading(date) {
211
+ return new Intl.DateTimeFormat(void 0, { month: "long", day: "numeric", weekday: "short" }).format(date);
212
+ }
213
+ function shortDate(date) {
214
+ return new Intl.DateTimeFormat(void 0, { month: "short", day: "numeric" }).format(date);
215
+ }
216
+ function weekdayNarrow(index) {
217
+ const monday = new Date(2026, 0, 5);
218
+ return new Intl.DateTimeFormat(void 0, { weekday: "narrow" }).format(addDays(monday, index));
219
+ }
220
+ function weekdayShort(date) {
221
+ return new Intl.DateTimeFormat(void 0, { weekday: "short" }).format(date);
222
+ }
223
+ function localInputValue(date) {
224
+ const month = String(date.getMonth() + 1).padStart(2, "0");
225
+ const day = String(date.getDate()).padStart(2, "0");
226
+ const hour = String(date.getHours()).padStart(2, "0");
227
+ const minute = String(date.getMinutes()).padStart(2, "0");
228
+ return `${date.getFullYear()}-${month}-${day}T${hour}:${minute}`;
229
+ }
230
+ function eventOverlapsDay(event, day) {
231
+ const start = parseDate(event.start);
232
+ if (!start) return false;
233
+ const end = parseDate(event.end);
234
+ const dayStart = startOfDay(day);
235
+ const dayEnd = addDays(dayStart, 1);
236
+ const eventEnd = end && end > start ? end : new Date(start.getTime() + (event.allDay ? 864e5 : 0));
237
+ return start < dayEnd && eventEnd > dayStart;
238
+ }
239
+ function reminderOnDay(item, day) {
240
+ const due = parseDate(item.due);
241
+ return Boolean(due && sameDay(due, day));
242
+ }
243
+ function isOverdue(item, today) {
244
+ const due = parseDate(item.due);
245
+ return Boolean(due && startOfDay(due) < startOfDay(today));
246
+ }
247
+ function eventTimeLabel(event, day, t) {
248
+ if (event.allDay) return t("allDay");
249
+ const start = parseDate(event.start);
250
+ const end = parseDate(event.end);
251
+ if (!start) return "";
252
+ const startsToday = sameDay(start, day);
253
+ const endsToday = Boolean(end && sameDay(end, day));
254
+ if (startsToday && endsToday) return `${clock(start)}\u2013${clock(end)}`;
255
+ if (startsToday) return end ? `${clock(start)}\u2013` : clock(start);
256
+ if (endsToday) return `\u2013${clock(end)}`;
257
+ return t("continues");
258
+ }
259
+ function reminderTimeLabel(item) {
260
+ const due = parseDate(item.due);
261
+ if (!due || !hasClock(due)) return "";
262
+ return clock(due);
263
+ }
264
+ function overdueTimeLabel(item) {
265
+ const due = parseDate(item.due);
266
+ if (!due) return "";
267
+ return hasClock(due) ? `${shortDate(due)} ${clock(due)}` : shortDate(due);
268
+ }
269
+ function dayBlocks(day, events, reminders) {
270
+ const timed = [];
271
+ const later = [];
272
+ events.filter((event) => eventOverlapsDay(event, day)).forEach((event) => {
273
+ const block = { kind: "event", id: event.id, event, day, at: parseDate(event.start)?.getTime() ?? 0 };
274
+ (event.allDay ? later : timed).push(block);
275
+ });
276
+ reminders.filter((item) => reminderOnDay(item, day)).forEach((reminder) => {
277
+ const due = parseDate(reminder.due);
278
+ const block = { kind: "reminder", id: reminder.id, reminder, day, at: due?.getTime() ?? 0 };
279
+ (due && hasClock(due) ? timed : later).push(block);
280
+ });
281
+ timed.sort((left, right) => left.at - right.at || left.id.localeCompare(right.id));
282
+ return [...timed, ...later];
283
+ }
284
+ function visibleRange(year, month) {
285
+ const days = monthGrid(year, month);
286
+ const from = days[0];
287
+ const to = addDays(days[days.length - 1], 1);
288
+ return { from: from.toISOString(), to: to.toISOString(), key: `${dayKey(from)}/${dayKey(to)}`, days };
289
+ }
290
+ async function invoke(agenda, method, input) {
291
+ if (!agenda?.[method]) return { ok: false, error: { code: "UNAVAILABLE", message: "remote missing" } };
292
+ const result = await agenda[method](input, new AbortController().signal);
293
+ if (!result?.ok) return { ok: false, error: result?.error ?? { code: "FAILED", message: "\u8C03\u7528\u5931\u8D25" } };
294
+ return result.value;
295
+ }
296
+ var ENTRY_ICON = '<svg viewBox="0 0 24 24" aria-hidden="true"><rect x="3" y="5" width="18" height="16" rx="2" fill="none" stroke="currentColor" stroke-width="1.6"></rect><path d="M3 10h18M8 3v4M16 3v4" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"></path></svg>';
297
+ var ENTRY_STYLE = `
298
+ [data-dsh-ios-agenda-entry] {
299
+ box-sizing: border-box; flex: none; min-height: 36px; margin: 0 2px 4px;
300
+ color: var(--dsw-alias-label-primary); cursor: pointer; white-space: nowrap;
301
+ background: transparent; border: none; border-radius: var(--dsw-radius-md);
302
+ align-items: center; gap: 8px; padding: 7px 8px; font: inherit; line-height: 22px;
303
+ text-align: left; display: flex;
304
+ }
305
+ [data-dsh-ios-agenda-entry]:hover { background: var(--dsw-alias-interactive-bg-hover); }
306
+ [data-dsh-ios-agenda-entry]:focus-visible {
307
+ outline: var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary));
308
+ outline-offset: -2px;
309
+ }
310
+ [data-dsh-ios-agenda-entry] .ia-icon { flex: none; display: inline-flex; align-items: center; justify-content: center; }
311
+ [data-dsh-ios-agenda-entry] .ia-icon svg { width: 16px; height: 16px; }
312
+ [data-dsh-ios-agenda-entry] .ia-label { min-width: 0; text-overflow: ellipsis; overflow: hidden; }
313
+ [data-dsh-frame][data-sidebar-collapsed] [data-dsh-ios-agenda-entry],
314
+ [data-sidebar-collapsed] [data-dsh-ios-agenda-entry] {
315
+ justify-content: center; width: 36px; height: 36px; margin: 0 0 12px; padding: 0;
316
+ }
317
+ [data-sidebar-collapsed] [data-dsh-ios-agenda-entry] .ia-icon svg { width: 18px; height: 18px; }
318
+ [data-dsh-frame][data-sidebar-collapsed] [data-dsh-ios-agenda-entry] .ia-label,
319
+ [data-sidebar-collapsed] [data-dsh-ios-agenda-entry] .ia-label { display: none; }
320
+ `;
321
+ function escapeText(value) {
322
+ return String(value).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
323
+ }
324
+ function mountSidebarEntry({ label, onOpen }) {
325
+ if (typeof document === "undefined") return () => {
326
+ };
327
+ if (document.getElementById("ios-agenda-sidebar-style") === null) {
328
+ const style = document.createElement("style");
329
+ style.id = "ios-agenda-sidebar-style";
330
+ style.textContent = ENTRY_STYLE;
331
+ (document.head ?? document.documentElement).appendChild(style);
332
+ }
333
+ const button = document.createElement("button");
334
+ button.type = "button";
335
+ button.setAttribute("data-dsh-ios-agenda-entry", "");
336
+ button.setAttribute("data-dsh-plugin", "ios-agenda");
337
+ button.setAttribute("data-dsh-part", "sidebar-entry");
338
+ button.addEventListener("click", onOpen);
339
+ const paint = () => {
340
+ const text = label();
341
+ button.title = text;
342
+ button.setAttribute("aria-label", text);
343
+ if (button.dataset.label === text) return;
344
+ button.dataset.label = text;
345
+ button.innerHTML = `<span class="ia-icon">${ENTRY_ICON}</span><span class="ia-label">${escapeText(text)}</span>`;
346
+ };
347
+ const place = () => {
348
+ const sidebar = document.querySelector('[data-pane="sidebar"], [class*="sidebarCol"]');
349
+ const column = sidebar?.querySelector('[class*="logoRow"]')?.parentElement ?? sidebar?.firstElementChild;
350
+ if (!column) return;
351
+ paint();
352
+ const history = column.querySelector("[data-dsh-session-reader-entry]");
353
+ if (history) {
354
+ if (button.nextElementSibling !== history) column.insertBefore(button, history);
355
+ return;
356
+ }
357
+ const newer = column.querySelector('button[class*="newSession"]');
358
+ if (newer) {
359
+ if (button.previousElementSibling !== newer) newer.insertAdjacentElement("afterend", button);
360
+ return;
361
+ }
362
+ if (button.parentElement !== column) column.appendChild(button);
363
+ };
364
+ place();
365
+ const observer = new MutationObserver(place);
366
+ observer.observe(document.documentElement, { childList: true, subtree: true });
367
+ return () => {
368
+ observer.disconnect();
369
+ button.remove();
370
+ };
371
+ }
372
+ function AgendaRow({ compact, time, title, source, location, notes, overdue, accent, onComplete, onDelete, t, busy }) {
373
+ const style = accent ? { "--ia-accent": accent } : void 0;
374
+ if (compact) {
375
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", { className: overdue ? "ia-compact is-overdue" : "ia-compact", style, children: [
376
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "ia-compact-top", children: [
377
+ onComplete ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "checkbox", checked: false, "aria-label": t("complete"), disabled: busy, onChange: onComplete }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "ia-time", children: time }),
378
+ onComplete ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "ia-time", children: time }) : null,
379
+ onDelete ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "ia-delete", disabled: busy, onClick: onDelete, children: t("remove") }) : null
380
+ ] }),
381
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { className: "ia-title", children: title || t("untitled") }),
382
+ source ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "ia-source", children: source }) : null
383
+ ] });
384
+ }
385
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", { className: overdue ? "ia-row is-overdue" : "ia-row", style, children: [
386
+ onComplete ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "checkbox", checked: false, "aria-label": t("complete"), disabled: busy, onChange: onComplete }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "ia-check-spacer" }),
387
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "ia-time", children: time }),
388
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "ia-main", children: [
389
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { className: "ia-title", children: title || t("untitled") }),
390
+ notes ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "ia-detail", children: notes }) : null
391
+ ] }),
392
+ source ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "ia-source", children: source }) : null,
393
+ location ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "ia-location", children: location }) : null,
394
+ onDelete ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "ia-delete", disabled: busy, onClick: onDelete, children: t("remove") }) : null
395
+ ] });
396
+ }
397
+ function AgendaBlocks({ blocks, overdueIds, listColors, calendarColors, t, busy, onComplete, onDelete, compact }) {
398
+ return blocks.map((block) => {
399
+ if (block.kind === "event") {
400
+ const { event, day } = block;
401
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
402
+ AgendaRow,
403
+ {
404
+ compact,
405
+ time: eventTimeLabel(event, day, t),
406
+ title: event.title,
407
+ source: event.calendar,
408
+ location: compact ? "" : event.location,
409
+ notes: compact ? "" : event.notes,
410
+ accent: calendarColors.get(event.calendarId) || "",
411
+ onDelete: () => onDelete("deleteEvent", event.id),
412
+ t,
413
+ busy
414
+ },
415
+ `event:${event.id}:${dayKey(day)}`
416
+ );
417
+ }
418
+ const { reminder } = block;
419
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
420
+ AgendaRow,
421
+ {
422
+ compact,
423
+ time: reminderTimeLabel(reminder),
424
+ title: reminder.title,
425
+ source: reminder.list,
426
+ notes: compact ? "" : reminder.notes,
427
+ overdue: overdueIds.has(reminder.id),
428
+ accent: listColors.get(reminder.listId) || "",
429
+ onComplete: () => onComplete(reminder.id),
430
+ onDelete: () => onDelete("deleteReminder", reminder.id),
431
+ t,
432
+ busy
433
+ },
434
+ `reminder:${reminder.id}`
435
+ );
436
+ });
437
+ }
438
+ function FilterList({ label, items, hidden, onToggle }) {
439
+ const rowsRef = (0, import_react.useRef)(null);
440
+ const positions = (0, import_react.useRef)(/* @__PURE__ */ new Map());
441
+ const ordered = (0, import_react.useMemo)(() => {
442
+ const shown = [];
443
+ const concealed = [];
444
+ items.forEach((item) => (hidden.has(item.id) ? concealed : shown).push(item));
445
+ return [...shown, ...concealed];
446
+ }, [items, hidden]);
447
+ (0, import_react.useLayoutEffect)(() => {
448
+ const root = rowsRef.current;
449
+ if (!root) return;
450
+ const next = /* @__PURE__ */ new Map();
451
+ root.querySelectorAll("[data-filter-id]").forEach((node) => {
452
+ const id = node.getAttribute("data-filter-id");
453
+ const top = node.getBoundingClientRect().top;
454
+ const previous = positions.current.get(id);
455
+ if (previous != null && previous !== top) {
456
+ const delta = previous - top;
457
+ node.style.transition = "none";
458
+ node.style.transform = `translateY(${delta}px)`;
459
+ node.getBoundingClientRect();
460
+ requestAnimationFrame(() => {
461
+ requestAnimationFrame(() => {
462
+ node.style.transition = "transform 220ms ease";
463
+ node.style.transform = "";
464
+ });
465
+ });
466
+ }
467
+ next.set(id, top);
468
+ });
469
+ positions.current = next;
470
+ }, [ordered]);
471
+ if (items.length === 0) return null;
472
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "ia-filter-block", children: [
473
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "ia-filter-head", children: label }),
474
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: rowsRef, children: ordered.map((item) => {
475
+ const color = hexColor(item.color);
476
+ const checked = !hidden.has(item.id);
477
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
478
+ "label",
479
+ {
480
+ "data-filter-id": item.id,
481
+ className: checked ? "ia-filter-row" : "ia-filter-row is-off",
482
+ title: item.title,
483
+ style: color ? { "--ia-swatch": color } : void 0,
484
+ children: [
485
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "checkbox", checked, onChange: () => onToggle(item.id) }),
486
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("i", { className: "ia-swatch" }),
487
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "ia-filter-name", children: item.title })
488
+ ]
489
+ },
490
+ item.id
491
+ );
492
+ }) })
493
+ ] });
494
+ }
495
+ function AgendaPage({ t, agenda }) {
496
+ const today = startOfDay(/* @__PURE__ */ new Date());
497
+ const [cursor, setCursor] = (0, import_react.useState)(() => startOfDay(/* @__PURE__ */ new Date()));
498
+ const [month, setMonth] = (0, import_react.useState)(() => {
499
+ const now = /* @__PURE__ */ new Date();
500
+ return { year: now.getFullYear(), month: now.getMonth() };
501
+ });
502
+ const [viewPreference] = (0, import_react.useState)(readViewPreference);
503
+ const [mode, setMode] = (0, import_react.useState)(viewPreference.mode);
504
+ const [data, setData] = (0, import_react.useState)(null);
505
+ const [loadedKey, setLoadedKey] = (0, import_react.useState)("");
506
+ const [error, setError] = (0, import_react.useState)("");
507
+ const [auth, setAuth] = (0, import_react.useState)(null);
508
+ const [busy, setBusy] = (0, import_react.useState)(false);
509
+ const [revision, setRevision] = (0, import_react.useState)(0);
510
+ const [hiddenLists, setHiddenLists] = (0, import_react.useState)(() => new Set(viewPreference.hiddenLists));
511
+ const [hiddenCalendars, setHiddenCalendars] = (0, import_react.useState)(() => new Set(viewPreference.hiddenCalendars));
512
+ const [reminderTitle, setReminderTitle] = (0, import_react.useState)("");
513
+ const [eventOpen, setEventOpen] = (0, import_react.useState)(false);
514
+ const [eventTitle, setEventTitle] = (0, import_react.useState)("");
515
+ const [eventStart, setEventStart] = (0, import_react.useState)("");
516
+ const [eventEnd, setEventEnd] = (0, import_react.useState)("");
517
+ const requestRef = (0, import_react.useRef)(0);
518
+ const overdueRef = (0, import_react.useRef)(null);
519
+ const undatedRef = (0, import_react.useRef)(null);
520
+ const range = (0, import_react.useMemo)(() => visibleRange(month.year, month.month), [month.year, month.month]);
521
+ (0, import_react.useEffect)(() => {
522
+ const requestId = ++requestRef.current;
523
+ let active = true;
524
+ (async () => {
525
+ setBusy(true);
526
+ const result = await invoke(agenda, "snapshot", { from: range.from, to: range.to, limit: 500 });
527
+ if (!active || requestId !== requestRef.current) return;
528
+ setBusy(false);
529
+ if (!result.ok) {
530
+ if (result.error?.code === "ACCESS_DENIED") {
531
+ setAuth({
532
+ reminders: result.error.access?.reminders || "notDetermined",
533
+ events: result.error.access?.events || "notDetermined",
534
+ openedSettings: false
535
+ });
536
+ setError("");
537
+ return;
538
+ }
539
+ setAuth(null);
540
+ setError(result.error?.message || t("unavailable"));
541
+ return;
542
+ }
543
+ setAuth(null);
544
+ setError("");
545
+ setData(result.data);
546
+ setLoadedKey(range.key);
547
+ })();
548
+ return () => {
549
+ active = false;
550
+ };
551
+ }, [agenda, range.from, range.to, range.key, revision]);
552
+ (0, import_react.useEffect)(() => {
553
+ if (typeof localStorage === "undefined") return;
554
+ try {
555
+ localStorage.setItem(VIEW_PREFERENCE_KEY, JSON.stringify({
556
+ mode,
557
+ hiddenLists: [...hiddenLists],
558
+ hiddenCalendars: [...hiddenCalendars]
559
+ }));
560
+ } catch {
561
+ }
562
+ }, [mode, hiddenLists, hiddenCalendars]);
563
+ async function authorize() {
564
+ setBusy(true);
565
+ const result = await invoke(agenda, "authorize", {});
566
+ setBusy(false);
567
+ if (!result.ok) {
568
+ setError(result.error?.message || t("unavailable"));
569
+ return;
570
+ }
571
+ const report = result.data?.access ?? {};
572
+ if (result.data?.granted) {
573
+ setAuth(null);
574
+ setRevision((value) => value + 1);
575
+ return;
576
+ }
577
+ setAuth({
578
+ reminders: report.reminders || "notDetermined",
579
+ events: report.events || "notDetermined",
580
+ openedSettings: Boolean(result.data?.openedSettings)
581
+ });
582
+ }
583
+ function selectDay(date) {
584
+ const day = startOfDay(date);
585
+ setCursor(day);
586
+ if (day.getFullYear() !== month.year || day.getMonth() !== month.month) {
587
+ setMonth({ year: day.getFullYear(), month: day.getMonth() });
588
+ }
589
+ }
590
+ function shiftMonth(delta) {
591
+ const next = new Date(month.year, month.month + delta, 1);
592
+ const year = next.getFullYear();
593
+ const nextMonth = next.getMonth();
594
+ setMonth({ year, month: nextMonth });
595
+ const selectedHere = cursor.getFullYear() === year && cursor.getMonth() === nextMonth;
596
+ if (selectedHere) return;
597
+ const todayHere = today.getFullYear() === year && today.getMonth() === nextMonth;
598
+ setCursor(todayHere ? today : next);
599
+ }
600
+ async function submit(method, input, clear) {
601
+ setBusy(true);
602
+ const result = await invoke(agenda, method, input);
603
+ setBusy(false);
604
+ if (!result.ok) {
605
+ setError(result.error?.message || t("unavailable"));
606
+ return;
607
+ }
608
+ clear();
609
+ setRevision((value) => value + 1);
610
+ }
611
+ function openEvent() {
612
+ if (!eventStart || !eventEnd) {
613
+ const start = new Date(cursor);
614
+ start.setHours(9, 0, 0, 0);
615
+ const end = new Date(cursor);
616
+ end.setHours(10, 0, 0, 0);
617
+ if (!eventStart) setEventStart(localInputValue(start));
618
+ if (!eventEnd) setEventEnd(localInputValue(end));
619
+ }
620
+ setEventOpen(true);
621
+ }
622
+ const ready = data && loadedKey === range.key ? data : null;
623
+ const lists = ready?.lists ?? [];
624
+ const calendars = ready?.calendars ?? [];
625
+ const listIdsKey = lists.map((list) => list.id).join("\n");
626
+ const calendarIdsKey = calendars.map((calendar) => calendar.id).join("\n");
627
+ const listColors = new Map(lists.map((list) => [list.id, hexColor(list.color)]));
628
+ const calendarColors = new Map(calendars.map((calendar) => [calendar.id, hexColor(calendar.color)]));
629
+ const reminders = (ready?.reminders ?? []).filter((item) => !item.completed && !hiddenLists.has(item.listId));
630
+ const events = (ready?.events ?? []).filter((item) => !hiddenCalendars.has(item.calendarId));
631
+ (0, import_react.useEffect)(() => {
632
+ if (!ready) return;
633
+ const listIds = new Set(listIdsKey ? listIdsKey.split("\n") : []);
634
+ const calendarIds = new Set(calendarIdsKey ? calendarIdsKey.split("\n") : []);
635
+ setHiddenLists((current) => {
636
+ const next = [...current].filter((id) => listIds.has(id));
637
+ return next.length === current.size ? current : new Set(next);
638
+ });
639
+ setHiddenCalendars((current) => {
640
+ const next = [...current].filter((id) => calendarIds.has(id));
641
+ return next.length === current.size ? current : new Set(next);
642
+ });
643
+ }, [ready, listIdsKey, calendarIdsKey]);
644
+ function toggleHidden(kind, id) {
645
+ const setter = kind === "list" ? setHiddenLists : setHiddenCalendars;
646
+ setter((current) => {
647
+ const next = new Set(current);
648
+ if (next.has(id)) next.delete(id);
649
+ else next.add(id);
650
+ return next;
651
+ });
652
+ }
653
+ const overdueIds = new Set(reminders.filter((item) => isOverdue(item, today)).map((item) => item.id));
654
+ const weekDays = Array.from({ length: 7 }, (_, index) => addDays(startOfWeek(cursor), index));
655
+ const visibleDays = mode === "week" ? weekDays : [cursor];
656
+ const shownIds = new Set(visibleDays.flatMap((day) => reminders.filter((item) => reminderOnDay(item, day)).map((item) => item.id)));
657
+ const overdueItems = reminders.filter((item) => overdueIds.has(item.id) && !shownIds.has(item.id)).sort((left, right) => (parseDate(left.due)?.getTime() ?? 0) - (parseDate(right.due)?.getTime() ?? 0));
658
+ const undatedItems = reminders.filter((item) => !item.due);
659
+ const marks = new Map(range.days.map((day) => {
660
+ const key = dayKey(day);
661
+ const dayEvents = events.filter((event) => eventOverlapsDay(event, day));
662
+ const dayReminders = reminders.filter((item) => reminderOnDay(item, day));
663
+ return [key, {
664
+ event: dayEvents.length > 0,
665
+ reminder: dayReminders.length > 0,
666
+ eventColor: soleAccent(dayEvents.map((event) => calendarColors.get(event.calendarId))),
667
+ reminderColor: soleAccent(dayReminders.map((item) => listColors.get(item.listId)))
668
+ }];
669
+ }));
670
+ function scrollTo(target) {
671
+ target.current?.scrollIntoView({ block: "start" });
672
+ }
673
+ const dayList = dayBlocks(cursor, events, reminders);
674
+ const weekLabel = `${shortDate(weekDays[0])} \u2013 ${shortDate(weekDays[6])}`;
675
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "ios-agenda", "aria-busy": busy, children: [
676
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("style", { children: css }),
677
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "ia-body", children: [
678
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("aside", { className: "ia-side", children: [
679
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "ia-month", children: [
680
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", "aria-label": t("prevMonth"), onClick: () => shiftMonth(-1), children: "\u2039" }),
681
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: monthHeading(month.year, month.month) }),
682
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", "aria-label": t("nextMonth"), onClick: () => shiftMonth(1), children: "\u203A" })
683
+ ] }),
684
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "ia-weekdays", "aria-hidden": "true", children: Array.from({ length: 7 }, (_, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: weekdayNarrow(index) }, index)) }),
685
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "ia-cal", children: range.days.map((day) => {
686
+ const outside = day.getMonth() !== month.month;
687
+ const selected = sameDay(day, cursor);
688
+ const mark = marks.get(dayKey(day)) ?? { event: false, reminder: false };
689
+ const className = [
690
+ "ia-day",
691
+ outside ? "is-outside" : "",
692
+ sameDay(day, today) ? "is-today" : "",
693
+ selected ? "is-selected" : ""
694
+ ].filter(Boolean).join(" ");
695
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
696
+ "button",
697
+ {
698
+ type: "button",
699
+ className,
700
+ "aria-current": sameDay(day, today) ? "date" : void 0,
701
+ "aria-pressed": selected,
702
+ onClick: () => selectDay(day),
703
+ children: [
704
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: day.getDate() }),
705
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "ia-dots", children: [
706
+ mark.event ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("i", { className: "ia-dot ia-dot-event", style: mark.eventColor ? { background: mark.eventColor } : void 0 }) : null,
707
+ mark.reminder ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("i", { className: "ia-dot ia-dot-reminder", style: mark.reminderColor ? { background: mark.reminderColor } : void 0 }) : null
708
+ ] })
709
+ ]
710
+ },
711
+ dayKey(day)
712
+ );
713
+ }) }),
714
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "ia-jumps", children: [
715
+ overdueItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", className: "ia-jump-overdue", onClick: () => scrollTo(overdueRef), children: [
716
+ t("overdue"),
717
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: overdueItems.length })
718
+ ] }),
719
+ undatedItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", onClick: () => scrollTo(undatedRef), children: [
720
+ t("undated"),
721
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: undatedItems.length })
722
+ ] })
723
+ ] }),
724
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FilterList, { label: t("lists"), items: lists, hidden: hiddenLists, onToggle: (id) => toggleHidden("list", id) }),
725
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FilterList, { label: t("calendars"), items: calendars, hidden: hiddenCalendars, onToggle: (id) => toggleHidden("calendar", id) })
726
+ ] }),
727
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "ia-board", children: [
728
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "ia-board-scroll", children: [
729
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("header", { className: "ia-board-head", children: [
730
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", { children: mode === "week" ? weekLabel : dayHeading(cursor) }),
731
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "ia-modes", role: "group", children: [
732
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", "aria-pressed": mode === "day" && sameDay(cursor, today), onClick: () => {
733
+ setMode("day");
734
+ selectDay(today);
735
+ }, children: t("today") }),
736
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", "aria-pressed": mode === "week", onClick: () => setMode("week"), children: t("week") })
737
+ ] }),
738
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "ia-refresh", onClick: () => setRevision((value) => value + 1), disabled: busy, children: t("refresh") })
739
+ ] }),
740
+ auth && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "ia-auth", children: [
741
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { children: t("authTitle") }),
742
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: t("authBody") }),
743
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "ia-auth-row", children: [
744
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: t("reminders") }),
745
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: accessGranted(auth.reminders) ? t("authGranted") : t("authNeeded") })
746
+ ] }),
747
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "ia-auth-row", children: [
748
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: t("calendars") }),
749
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: accessGranted(auth.events) ? t("authGranted") : t("authNeeded") })
750
+ ] }),
751
+ auth.openedSettings && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "ia-auth-hint", children: t("authSettings") }),
752
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", onClick: authorize, disabled: busy, children: accessBlocked(auth.reminders) || accessBlocked(auth.events) ? t("openSettings") : t("authorize") })
753
+ ] }),
754
+ error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "ios-agenda-error", role: "alert", children: error }),
755
+ !ready && !error && !auth && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "ios-agenda-muted", children: t("loading") }),
756
+ ready && !auth && mode === "day" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("section", { className: "ia-day-list", children: dayList.length ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AgendaBlocks, { blocks: dayList, overdueIds, listColors, calendarColors, t, busy, onComplete: (id) => submit("completeReminder", { id, completed: true }, () => {
757
+ }), onDelete: (method, id) => submit(method, { id }, () => {
758
+ }) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "ios-agenda-muted", children: t("emptyDay") }) }),
759
+ ready && !auth && mode === "week" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "ia-week-scroll", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "ia-week", children: weekDays.map((day) => {
760
+ const blocks = dayBlocks(day, events, reminders);
761
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: sameDay(day, cursor) ? "ia-week-col is-selected" : "ia-week-col", children: [
762
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", className: sameDay(day, today) ? "ia-week-head is-today" : "ia-week-head", onClick: () => selectDay(day), children: [
763
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: weekdayShort(day) }),
764
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: day.getDate() })
765
+ ] }),
766
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AgendaBlocks, { compact: true, blocks, overdueIds, listColors, calendarColors, t, busy, onComplete: (id) => submit("completeReminder", { id, completed: true }, () => {
767
+ }), onDelete: (method, id) => submit(method, { id }, () => {
768
+ }) })
769
+ ] }, dayKey(day));
770
+ }) }) }),
771
+ ready && !auth && overdueItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "ia-group", ref: overdueRef, children: [
772
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { children: t("overdue") }),
773
+ overdueItems.map((item) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
774
+ AgendaRow,
775
+ {
776
+ time: overdueTimeLabel(item),
777
+ title: item.title,
778
+ source: item.list,
779
+ notes: item.notes,
780
+ overdue: true,
781
+ accent: listColors.get(item.listId) || "",
782
+ onComplete: () => submit("completeReminder", { id: item.id, completed: true }, () => {
783
+ }),
784
+ onDelete: () => submit("deleteReminder", { id: item.id }, () => {
785
+ }),
786
+ t,
787
+ busy
788
+ },
789
+ `overdue:${item.id}`
790
+ ))
791
+ ] }),
792
+ ready && !auth && undatedItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "ia-group", ref: undatedRef, children: [
793
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { children: t("undated") }),
794
+ undatedItems.map((item) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
795
+ AgendaRow,
796
+ {
797
+ time: "",
798
+ title: item.title,
799
+ source: item.list,
800
+ notes: item.notes,
801
+ accent: listColors.get(item.listId) || "",
802
+ onComplete: () => submit("completeReminder", { id: item.id, completed: true }, () => {
803
+ }),
804
+ onDelete: () => submit("deleteReminder", { id: item.id }, () => {
805
+ }),
806
+ t,
807
+ busy
808
+ },
809
+ `undated:${item.id}`
810
+ ))
811
+ ] })
812
+ ] }),
813
+ !auth && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", { className: "ia-composer", onSubmit: (event) => {
814
+ event.preventDefault();
815
+ if (!reminderTitle.trim()) return;
816
+ submit("createReminder", { title: reminderTitle.trim() }, () => setReminderTitle(""));
817
+ }, children: [
818
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { "aria-label": t("titleField"), value: reminderTitle, placeholder: t("newReminder"), onChange: (event) => setReminderTitle(event.target.value) }),
819
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "submit", disabled: busy || !reminderTitle.trim(), children: t("add") }),
820
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", onClick: () => eventOpen ? setEventOpen(false) : openEvent(), children: t("newEvent") })
821
+ ] }),
822
+ !auth && eventOpen && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", { className: "ia-event-form", onSubmit: (event) => {
823
+ event.preventDefault();
824
+ if (!eventTitle.trim() || !eventStart || !eventEnd) return;
825
+ submit("createEvent", {
826
+ title: eventTitle.trim(),
827
+ start: new Date(eventStart).toISOString(),
828
+ end: new Date(eventEnd).toISOString()
829
+ }, () => {
830
+ setEventTitle("");
831
+ setEventStart("");
832
+ setEventEnd("");
833
+ setEventOpen(false);
834
+ });
835
+ }, children: [
836
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { "aria-label": t("titleField"), value: eventTitle, placeholder: t("newEvent"), onChange: (event) => setEventTitle(event.target.value) }),
837
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { "aria-label": t("start"), type: "datetime-local", value: eventStart, onChange: (event) => setEventStart(event.target.value) }),
838
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { "aria-label": t("end"), type: "datetime-local", value: eventEnd, onChange: (event) => setEventEnd(event.target.value) }),
839
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "submit", disabled: busy || !eventTitle.trim() || !eventStart || !eventEnd, children: t("add") })
840
+ ] })
841
+ ] })
842
+ ] })
843
+ ] });
844
+ }
845
+ var css = `
846
+ .ios-agenda { --ia-danger: var(--dsw-alias-state-danger, #d14343); box-sizing: border-box; height: 100%; overflow: hidden; color: var(--dsw-alias-label-primary); background: var(--dsw-alias-bg-base); }
847
+ .ios-agenda * { box-sizing: border-box; }
848
+ .ios-agenda button, .ios-agenda input { font: inherit; color: inherit; }
849
+ .ia-body { height: 100%; display: grid; grid-template-columns: 320px minmax(0, 1fr); min-height: 0; }
850
+ .ia-side { min-height: 0; overflow: auto; padding: 16px 16px 20px; border-right: 1px solid var(--dsw-alias-border-default); }
851
+ .ia-month { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
852
+ .ia-month strong { font-size: 15px; font-weight: 600; }
853
+ .ia-month button, .ia-refresh, .ia-composer button, .ia-event-form button { border: 1px solid var(--dsw-alias-border-default); background: var(--dsw-alias-bg-layer-1); border-radius: 8px; padding: 4px 10px; cursor: pointer; }
854
+ .ia-month button { width: 32px; height: 32px; padding: 0; border: none; background: transparent; }
855
+ .ia-month button:hover { background: var(--dsw-alias-interactive-bg-hover); }
856
+ .ia-composer button[type="submit"], .ia-event-form button[type="submit"] { border-color: transparent; background: var(--dsw-alias-state-business-primary); color: var(--dsw-alias-bg-base); }
857
+ .ia-weekdays, .ia-cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
858
+ .ia-weekdays { margin-bottom: 4px; color: var(--dsw-alias-label-secondary); font-size: 12px; text-align: center; }
859
+ .ia-day { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; aspect-ratio: 1; border: none; border-radius: 8px; background: transparent; cursor: pointer; padding: 0; }
860
+ .ia-day:hover { background: var(--dsw-alias-interactive-bg-hover); }
861
+ .ia-day.is-outside { color: var(--dsw-alias-label-secondary); opacity: 0.45; }
862
+ .ia-day.is-today > span:first-child { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--dsw-alias-state-business-primary); color: var(--dsw-alias-bg-base); font-weight: 600; }
863
+ .ia-day.is-selected { background: var(--dsw-alias-bg-layer-1); box-shadow: inset 0 0 0 1.5px var(--dsw-alias-state-business-primary); color: var(--dsw-alias-label-primary); opacity: 1; }
864
+ .ia-day:focus-visible, .ia-week-head:focus-visible, .ia-modes button:focus-visible, .ia-filter-row:focus-visible { outline: var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary)); outline-offset: -2px; }
865
+ .ia-dots { display: flex; gap: 3px; height: 5px; }
866
+ .ia-dot { width: 5px; height: 5px; border-radius: 50%; }
867
+ .ia-dot-event { background: var(--dsw-alias-state-business-primary); }
868
+ .ia-dot-reminder { background: var(--dsw-alias-label-secondary); }
869
+ .ia-jumps { display: flex; flex-direction: column; gap: 4px; margin-top: 14px; }
870
+ .ia-jumps button, .ia-modes button, .ia-filter-row { border: none; background: transparent; border-radius: 8px; cursor: pointer; }
871
+ .ia-jumps button { display: flex; justify-content: space-between; width: 100%; padding: 6px 8px; text-align: left; }
872
+ .ia-jumps button:hover, .ia-modes button:hover, .ia-filter-row:hover { background: var(--dsw-alias-interactive-bg-hover); }
873
+ .ia-jumps strong { font-weight: 600; }
874
+ .ia-jump-overdue strong { color: var(--ia-danger); }
875
+ .ia-filter-block { margin-top: 16px; }
876
+ .ia-filter-head { margin: 0 8px 4px; color: var(--dsw-alias-label-secondary); font-size: 12px; }
877
+ .ia-filter-row { display: flex; align-items: center; gap: 8px; width: 100%; padding: 5px 8px; text-align: left; color: var(--dsw-alias-label-primary); cursor: pointer; }
878
+ .ia-filter-row.is-off { color: var(--dsw-alias-label-secondary); }
879
+ .ia-filter-row.is-off .ia-swatch { opacity: 0.4; }
880
+ .ia-filter-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
881
+ .ia-swatch { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--ia-swatch, var(--dsw-alias-label-secondary)); }
882
+ .ia-board { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
883
+ .ia-board-scroll { flex: 1; min-height: 0; overflow: auto; padding: 16px 24px 8px; }
884
+ .ia-board-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 12px; margin-bottom: 12px; padding-bottom: 10px; background: var(--dsw-alias-bg-base); }
885
+ .ia-board-head h1 { margin: 0; flex: 1; min-width: 0; font-size: 22px; font-weight: 600; }
886
+ .ia-modes { display: flex; gap: 2px; padding: 2px; border-radius: 10px; background: var(--dsw-alias-bg-layer-1); }
887
+ .ia-modes button { padding: 6px 10px; color: var(--dsw-alias-label-secondary); }
888
+ .ia-modes button[aria-pressed="true"] { background: var(--dsw-alias-bg-base); color: var(--dsw-alias-label-primary); box-shadow: inset 0 0 0 1px var(--dsw-alias-border-default); }
889
+ .ia-row, .ia-compact { box-shadow: inset 3px 0 0 var(--ia-accent, transparent); }
890
+ .ia-row { display: grid; grid-template-columns: 16px 9.5rem minmax(0, 1fr) auto auto auto; gap: 12px; align-items: center; padding: 8px 10px; border-radius: 8px; }
891
+ .ia-row:hover { background: var(--dsw-alias-interactive-bg-hover); }
892
+ .ia-check-spacer { width: 16px; height: 16px; }
893
+ .ia-time { font-variant-numeric: tabular-nums; color: var(--dsw-alias-label-secondary); white-space: nowrap; }
894
+ .ia-main { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
895
+ .ia-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
896
+ .ia-source, .ia-location, .ia-detail, .ios-agenda-muted { color: var(--dsw-alias-label-secondary); }
897
+ .ia-source, .ia-location { white-space: nowrap; font-size: 13px; }
898
+ .ia-detail { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 400; }
899
+ .ia-delete { opacity: 0; border: none; background: transparent; color: var(--dsw-alias-label-secondary); cursor: pointer; padding: 4px 6px; }
900
+ .ia-row:hover .ia-delete, .ia-compact:hover .ia-delete, .ia-delete:focus-visible { opacity: 1; }
901
+ .is-overdue .ia-time { color: var(--ia-danger); }
902
+ .ia-group { margin-top: 22px; scroll-margin-top: 64px; }
903
+ .ia-group h2 { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--dsw-alias-label-secondary); }
904
+ .ia-week-scroll { overflow-x: auto; }
905
+ .ia-week { display: grid; grid-template-columns: repeat(7, minmax(160px, 1fr)); gap: 8px; min-width: 100%; }
906
+ .ia-week-col { min-width: 0; padding: 8px; border-radius: 10px; background: var(--dsw-alias-bg-layer-1); }
907
+ .ia-week-col.is-selected { box-shadow: inset 0 0 0 1.5px var(--dsw-alias-state-business-primary); }
908
+ .ia-week-head { display: flex; justify-content: space-between; width: 100%; margin-bottom: 8px; border: none; background: transparent; cursor: pointer; padding: 2px 2px 6px; color: var(--dsw-alias-label-secondary); }
909
+ .ia-week-head strong { color: var(--dsw-alias-label-primary); }
910
+ .ia-week-head.is-today strong { color: var(--dsw-alias-state-business-primary); }
911
+ .ia-compact { position: relative; display: flex; flex-direction: column; gap: 2px; padding: 6px 4px; border-radius: 8px; }
912
+ .ia-compact:hover { background: var(--dsw-alias-interactive-bg-hover); }
913
+ .ia-compact-top { display: flex; align-items: center; gap: 6px; min-height: 18px; }
914
+ .ia-compact .ia-title, .ia-compact .ia-source { display: block; }
915
+ .ia-compact .ia-source { font-size: 12px; }
916
+ .ia-compact .ia-delete { position: absolute; top: 2px; right: 0; }
917
+ .ia-composer, .ia-event-form { display: flex; gap: 8px; align-items: center; padding: 10px 24px; }
918
+ .ia-composer { border-top: 1px solid var(--dsw-alias-border-default); }
919
+ .ia-event-form { padding-top: 0; padding-bottom: 14px; }
920
+ .ia-composer input, .ia-event-form input { flex: 1; min-width: 0; border: 1px solid var(--dsw-alias-border-default); background: var(--dsw-alias-bg-layer-1); border-radius: 8px; padding: 8px 10px; }
921
+ .ia-auth { max-width: 440px; margin: 12px 0 20px; padding: 16px; border: 1px solid var(--dsw-alias-border-default); border-radius: 12px; background: var(--dsw-alias-bg-layer-1); }
922
+ .ia-auth h2 { margin: 0 0 6px; font-size: 16px; font-weight: 600; }
923
+ .ia-auth p, .ia-auth-hint { margin: 0 0 12px; color: var(--dsw-alias-label-secondary); }
924
+ .ia-auth-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; }
925
+ .ia-auth button { margin-top: 8px; border: none; border-radius: 8px; padding: 8px 14px; cursor: pointer; background: var(--dsw-alias-state-business-primary); color: var(--dsw-alias-bg-base); }
926
+ .ios-agenda-error { margin: 0 0 12px; padding: 8px 10px; border-radius: 8px; background: var(--dsw-alias-bg-layer-1); }
927
+ .ios-agenda input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--dsw-alias-state-business-primary); }
928
+ .ia-filter-row input[type="checkbox"] { flex: none; accent-color: var(--ia-swatch, var(--dsw-alias-state-business-primary)); }
929
+ button:disabled { cursor: default; opacity: 0.6; }
930
+ @media (max-width: 860px) {
931
+ .ia-body { grid-template-columns: 1fr; }
932
+ .ia-side { border-right: none; border-bottom: 1px solid var(--dsw-alias-border-default); }
933
+ .ia-cal { max-width: 320px; }
934
+ }
935
+ `;
936
+ var inject = ["slots", "locale", "remote"];
937
+ async function apply(ctx) {
938
+ const release = await ctx.remote.$mount(contribution);
939
+ ctx.effect(() => release);
940
+ await ctx.plugin({
941
+ name: `${contribution.package}/page`,
942
+ inject: ["slots", "locale", "layout", `remote.${SERVICE}`],
943
+ apply(pageCtx) {
944
+ const agenda = pageCtx.remote[SERVICE];
945
+ pageCtx.effect(() => pageCtx.locale.register(NS, { zh, en }));
946
+ const t = pageCtx.locale.bind(NS);
947
+ pageCtx.effect(() => pageCtx.slots.inject("main", () => pageCtx.slots.register({
948
+ name: "main",
949
+ key: PANEL_ID,
950
+ locale: NS,
951
+ inject: () => ({ agenda })
952
+ }, AgendaPage)));
953
+ pageCtx.effect(() => mountSidebarEntry({
954
+ label: () => t("panel"),
955
+ onOpen: () => {
956
+ try {
957
+ pageCtx.layout.selectPanel(PANEL_ID);
958
+ } catch (error) {
959
+ console.error("[ios-agenda] \u65E0\u6CD5\u6253\u5F00\u9875\u9762", error);
960
+ }
961
+ }
962
+ }));
963
+ }
964
+ });
965
+ }
966
+
967
+ return module.exports;}});