ocean-brain 0.6.3 → 0.7.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.
- package/dist/mcp.js +79 -24
- package/package.json +2 -1
- package/server/client/dist/assets/{Calendar-DbPut8EU.js → Calendar-B2_OJcHD.js} +1 -1
- package/server/client/dist/assets/{Callout-DfX-gIUB.js → Callout-BvXAlA5k.js} +1 -1
- package/server/client/dist/assets/{Graph-yHE9m5fy.js → Graph-DO35UCPM.js} +1 -1
- package/server/client/dist/assets/{Image.es-CtMc7BW4.js → Image.es-DLqLiGdW.js} +1 -1
- package/server/client/dist/assets/Note-AaTlS352.js +22 -0
- package/server/client/dist/assets/{Plus.es-BGVIIQtM.js → Plus.es-I7xuoJ9B.js} +1 -1
- package/server/client/dist/assets/{Reminders-CvEJf0eQ.js → Reminders-B0LJeSlu.js} +1 -1
- package/server/client/dist/assets/{Search-CKZhztuV.js → Search-xbDSlNOT.js} +1 -1
- package/server/client/dist/assets/{SurfaceCard-Bnfo5EOl.js → SurfaceCard-Brd1cMxi.js} +1 -1
- package/server/client/dist/assets/{Tag-C4oAwjs0.js → Tag-2PlhkjwY.js} +1 -1
- package/server/client/dist/assets/{TagNotes-Rl1ZSJP6.js → TagNotes-1yUBLqhX.js} +1 -1
- package/server/client/dist/assets/{Trash.es-BcwUz2yM.js → Trash.es-B-7U25B6.js} +1 -1
- package/server/client/dist/assets/{ViewNotes-B9Yc0A87.js → ViewNotes-D4X-MCTk.js} +1 -1
- package/server/client/dist/assets/{ViewSectionTableRenderer-C5yJBO7C.js → ViewSectionTableRenderer-FuqBpQts.js} +1 -1
- package/server/client/dist/assets/{Views-Bqq0pUEE.js → Views-CBEimWY8.js} +1 -1
- package/server/client/dist/assets/{image.api-CuGTgzyQ.js → image.api-BtadKO98.js} +1 -1
- package/server/client/dist/assets/{index-CDjYEIVf.css → index-BFkZTZ6v.css} +1 -1
- package/server/client/dist/assets/{index-B43ulIPo.js → index-BgnmVjeF.js} +45 -11
- package/server/client/dist/assets/{index-BQDR6hIA.js → index-sGhvnErO.js} +1 -1
- package/server/client/dist/assets/{manage-image-Bs4Kmevx.js → manage-image-B4UZ-ZQx.js} +1 -1
- package/server/client/dist/assets/{manage-image-detail-WARala-v.js → manage-image-detail-ejAh3nCL.js} +1 -1
- package/server/client/dist/assets/{mcp-C0Z3vKBa.js → mcp-aIwuouT9.js} +1 -1
- package/server/client/dist/assets/{placeholder-D080guzn.js → placeholder-B_9Hnm7h.js} +4 -4
- package/server/client/dist/assets/{properties-DbnmfbT5.js → properties-D8oLyTCD.js} +1 -1
- package/server/client/dist/assets/{trash-D5ZiZfTk.js → trash-w7Hhxckg.js} +1 -1
- package/server/client/dist/assets/{useReminderMutate-h7d_S_X2.js → useReminderMutate--RlAj_Gg.js} +1 -1
- package/server/client/dist/index.html +2 -2
- package/server/dist/features/note/graphql/note.query.resolver.js +88 -47
- package/server/dist/features/note/graphql/note.query.resolver.js.map +1 -1
- package/server/dist/features/note/graphql/note.type-defs.js +32 -0
- package/server/dist/features/note/graphql/note.type-defs.js.map +1 -1
- package/server/dist/features/note/http/mcp.js +32 -0
- package/server/dist/features/note/http/mcp.js.map +1 -1
- package/server/dist/features/note/services/markdown-intent-write.js +3 -3
- package/server/dist/features/note/services/markdown-intent-write.js.map +1 -1
- package/server/dist/features/note/services/markdown-patch.js +34 -4
- package/server/dist/features/note/services/markdown-patch.js.map +1 -1
- package/server/dist/features/note/services/snapshot.js +159 -0
- package/server/dist/features/note/services/snapshot.js.map +1 -1
- package/server/dist/modules/blocknote.js +171 -17
- package/server/dist/modules/blocknote.js.map +1 -1
- package/server/dist/routes/mcp.js +5 -0
- package/server/dist/routes/mcp.js.map +1 -1
- package/server/client/dist/assets/Note-BECn-AoI.js +0 -21
package/dist/mcp.js
CHANGED
|
@@ -223,11 +223,15 @@ var createMcpWriteSafetyCoordinator = (options = {}) => {
|
|
|
223
223
|
};
|
|
224
224
|
|
|
225
225
|
// src/mcp-note-output.ts
|
|
226
|
+
var formatBackReferenceLink = (backReference) => {
|
|
227
|
+
return `[[${backReference.title}]](note:${backReference.id})`;
|
|
228
|
+
};
|
|
226
229
|
var formatBackReferenceLine = (backReference) => {
|
|
230
|
+
const referenceLink = formatBackReferenceLink(backReference);
|
|
227
231
|
if (backReference.updatedAt) {
|
|
228
|
-
return `- ${
|
|
232
|
+
return `- ${referenceLink} (updated: ${backReference.updatedAt})`;
|
|
229
233
|
}
|
|
230
|
-
return `- ${
|
|
234
|
+
return `- ${referenceLink}`;
|
|
231
235
|
};
|
|
232
236
|
var formatPropertyLine = (property) => {
|
|
233
237
|
const displayValue = (property.option?.label ?? property.value) || "(empty)";
|
|
@@ -315,6 +319,7 @@ var markdownWritePolicySchema = z2.object({
|
|
|
315
319
|
allowNoop: z2.boolean().optional(),
|
|
316
320
|
maxChangedChars: z2.number().int().nonnegative().optional(),
|
|
317
321
|
maxChangedLines: z2.number().int().nonnegative().optional(),
|
|
322
|
+
diffPreviewMaxChars: z2.number().int().nonnegative().optional(),
|
|
318
323
|
preserveTags: z2.union([z2.boolean(), z2.literal("warn")]).optional(),
|
|
319
324
|
preserveReferences: z2.union([z2.boolean(), z2.literal("warn")]).optional()
|
|
320
325
|
}).optional();
|
|
@@ -364,6 +369,19 @@ var metadataPropertyPatchSchema = z2.object({
|
|
|
364
369
|
}
|
|
365
370
|
}).optional();
|
|
366
371
|
var sha256 = (value) => crypto2.createHash("sha256").update(value).digest("hex");
|
|
372
|
+
var isRecord = (value) => {
|
|
373
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
374
|
+
};
|
|
375
|
+
var stableJsonStringify = (value) => {
|
|
376
|
+
if (Array.isArray(value)) {
|
|
377
|
+
return `[${value.map(stableJsonStringify).join(",")}]`;
|
|
378
|
+
}
|
|
379
|
+
if (isRecord(value)) {
|
|
380
|
+
const properties = Object.keys(value).filter((key) => value[key] !== void 0).sort().map((key) => `${JSON.stringify(key)}:${stableJsonStringify(value[key])}`);
|
|
381
|
+
return `{${properties.join(",")}}`;
|
|
382
|
+
}
|
|
383
|
+
return JSON.stringify(value) ?? "null";
|
|
384
|
+
};
|
|
367
385
|
var normalizeServerUrl = (serverUrl) => {
|
|
368
386
|
try {
|
|
369
387
|
const url = new URL(serverUrl);
|
|
@@ -373,9 +391,17 @@ var normalizeServerUrl = (serverUrl) => {
|
|
|
373
391
|
return serverUrl.replace(/\/$/, "");
|
|
374
392
|
}
|
|
375
393
|
};
|
|
394
|
+
var normalizeIntentWritePayloadForFingerprint = (toolName, payload) => {
|
|
395
|
+
const normalizedPayload = { ...payload };
|
|
396
|
+
if (toolName === "ocean_brain_append_note_markdown") {
|
|
397
|
+
normalizedPayload.placement ??= { type: "end" };
|
|
398
|
+
normalizedPayload.separator ??= "\n\n";
|
|
399
|
+
}
|
|
400
|
+
return normalizedPayload;
|
|
401
|
+
};
|
|
376
402
|
var createIntentWriteOperationFingerprint = (serverUrl, token, toolName, payload) => {
|
|
377
|
-
return sha256(
|
|
378
|
-
payload,
|
|
403
|
+
return sha256(stableJsonStringify({
|
|
404
|
+
payload: normalizeIntentWritePayloadForFingerprint(toolName, payload),
|
|
379
405
|
serverUrl: normalizeServerUrl(serverUrl),
|
|
380
406
|
tokenDigest: token ? sha256(token) : null,
|
|
381
407
|
toolName
|
|
@@ -384,6 +410,24 @@ var createIntentWriteOperationFingerprint = (serverUrl, token, toolName, payload
|
|
|
384
410
|
var getErrorDetail = (error) => {
|
|
385
411
|
return error instanceof Error ? error.message : "Unknown MCP write error";
|
|
386
412
|
};
|
|
413
|
+
var requireCommitConfirmationFields = (request) => {
|
|
414
|
+
if (request.dryRun !== false) {
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
if (!request.operationId || !request.confirmToken) {
|
|
418
|
+
throw new Error("Commit mode requires both operationId and confirmToken from the dry-run response.");
|
|
419
|
+
}
|
|
420
|
+
};
|
|
421
|
+
var resolvePayloadWithBaseline = async (fetchNoteWriteBaseline, writeToken, id, payload) => {
|
|
422
|
+
if (typeof payload.expectedUpdatedAt === "string" || typeof payload.baseMarkdownSha256 === "string") {
|
|
423
|
+
return payload;
|
|
424
|
+
}
|
|
425
|
+
const baseline = await fetchNoteWriteBaseline(id, writeToken);
|
|
426
|
+
return {
|
|
427
|
+
...payload,
|
|
428
|
+
expectedUpdatedAt: baseline.updatedAt
|
|
429
|
+
};
|
|
430
|
+
};
|
|
387
431
|
var prepareConfirmedWriteOperation = (writeSafety, result, input) => {
|
|
388
432
|
if (result.status !== "dry_run") {
|
|
389
433
|
return result;
|
|
@@ -434,6 +478,7 @@ var executeConfirmedWrite = async (writeSafety, operation, request) => {
|
|
|
434
478
|
}
|
|
435
479
|
};
|
|
436
480
|
var registerIntentWriteTools = (server, {
|
|
481
|
+
fetchNoteWriteBaseline,
|
|
437
482
|
jsonRequest: jsonRequest2,
|
|
438
483
|
requireWriteToken: requireWriteToken2,
|
|
439
484
|
serverUrl,
|
|
@@ -446,8 +491,8 @@ var registerIntentWriteTools = (server, {
|
|
|
446
491
|
"Patch a small part of an Ocean Brain note. Dry-run is the default; commit requires operationId and confirmToken from the dry-run result.",
|
|
447
492
|
{
|
|
448
493
|
id: z2.string().describe("Note ID to patch"),
|
|
449
|
-
expectedUpdatedAt: z2.string().optional().describe("Expected note updatedAt from a prior read.
|
|
450
|
-
baseMarkdownSha256: z2.string().optional().describe("SHA-256 of the current markdown.
|
|
494
|
+
expectedUpdatedAt: z2.string().optional().describe("Expected note updatedAt from a prior read. Auto-fetched when omitted unless baseMarkdownSha256 is provided."),
|
|
495
|
+
baseMarkdownSha256: z2.string().optional().describe("SHA-256 of the current markdown. Optional alternative to expectedUpdatedAt."),
|
|
451
496
|
intent: z2.string().describe("Human-readable reason for the patch."),
|
|
452
497
|
selector: markdownPatchSelectorSchema.describe("Exact text or previously returned match candidate."),
|
|
453
498
|
operation: markdownPatchOperationSchema.describe("replace, insert_before, or insert_after."),
|
|
@@ -456,7 +501,8 @@ var registerIntentWriteTools = (server, {
|
|
|
456
501
|
},
|
|
457
502
|
async ({ id, expectedUpdatedAt, baseMarkdownSha256, intent, selector, operation, policy, dryRun, operationId, confirmToken }) => {
|
|
458
503
|
const writeToken = requireWriteToken2(token, tools.patchNoteMarkdown);
|
|
459
|
-
|
|
504
|
+
requireCommitConfirmationFields({ dryRun, operationId, confirmToken });
|
|
505
|
+
const payload = await resolvePayloadWithBaseline(fetchNoteWriteBaseline, writeToken, id, {
|
|
460
506
|
id,
|
|
461
507
|
...expectedUpdatedAt ? { expectedUpdatedAt } : {},
|
|
462
508
|
...baseMarkdownSha256 ? { baseMarkdownSha256 } : {},
|
|
@@ -464,9 +510,9 @@ var registerIntentWriteTools = (server, {
|
|
|
464
510
|
selector,
|
|
465
511
|
operation,
|
|
466
512
|
...policy ? { policy } : {}
|
|
467
|
-
};
|
|
513
|
+
});
|
|
468
514
|
const operationFingerprint = createIntentWriteOperationFingerprint(serverUrl, writeToken, tools.patchNoteMarkdown, payload);
|
|
469
|
-
if (dryRun) {
|
|
515
|
+
if (dryRun ?? true) {
|
|
470
516
|
const result2 = await jsonRequest2(serverUrl, writeToken, "/api/mcp/notes/patch-markdown", {
|
|
471
517
|
...payload,
|
|
472
518
|
dryRun: true
|
|
@@ -514,8 +560,8 @@ var registerIntentWriteTools = (server, {
|
|
|
514
560
|
"Append markdown to a note without replacing existing body content. Dry-run is the default; commit requires operationId and confirmToken.",
|
|
515
561
|
{
|
|
516
562
|
id: z2.string().describe("Note ID to append to"),
|
|
517
|
-
expectedUpdatedAt: z2.string().optional().describe("Expected note updatedAt from a prior read.
|
|
518
|
-
baseMarkdownSha256: z2.string().optional().describe("SHA-256 of the current markdown.
|
|
563
|
+
expectedUpdatedAt: z2.string().optional().describe("Expected note updatedAt from a prior read. Auto-fetched when omitted unless baseMarkdownSha256 is provided."),
|
|
564
|
+
baseMarkdownSha256: z2.string().optional().describe("SHA-256 of the current markdown. Optional alternative to expectedUpdatedAt."),
|
|
519
565
|
intent: z2.string().describe("Human-readable reason for the append."),
|
|
520
566
|
insertion: z2.string().describe("Markdown to append. Tags are body tokens such as [@tag] or [#tag]."),
|
|
521
567
|
placement: markdownAppendPlacementSchema.optional().describe("Default is end. after_heading requires one unique matching heading."),
|
|
@@ -525,7 +571,8 @@ var registerIntentWriteTools = (server, {
|
|
|
525
571
|
},
|
|
526
572
|
async ({ id, expectedUpdatedAt, baseMarkdownSha256, intent, insertion, placement, separator, policy, dryRun, operationId, confirmToken }) => {
|
|
527
573
|
const writeToken = requireWriteToken2(token, tools.appendNoteMarkdown);
|
|
528
|
-
|
|
574
|
+
requireCommitConfirmationFields({ dryRun, operationId, confirmToken });
|
|
575
|
+
const payload = await resolvePayloadWithBaseline(fetchNoteWriteBaseline, writeToken, id, {
|
|
529
576
|
id,
|
|
530
577
|
...expectedUpdatedAt ? { expectedUpdatedAt } : {},
|
|
531
578
|
...baseMarkdownSha256 ? { baseMarkdownSha256 } : {},
|
|
@@ -534,9 +581,9 @@ var registerIntentWriteTools = (server, {
|
|
|
534
581
|
...placement ? { placement } : {},
|
|
535
582
|
...separator ? { separator } : {},
|
|
536
583
|
...policy ? { policy } : {}
|
|
537
|
-
};
|
|
584
|
+
});
|
|
538
585
|
const operationFingerprint = createIntentWriteOperationFingerprint(serverUrl, writeToken, tools.appendNoteMarkdown, payload);
|
|
539
|
-
if (dryRun) {
|
|
586
|
+
if (dryRun ?? true) {
|
|
540
587
|
const result2 = await jsonRequest2(serverUrl, writeToken, "/api/mcp/notes/append-markdown", {
|
|
541
588
|
...payload,
|
|
542
589
|
dryRun: true
|
|
@@ -584,7 +631,7 @@ var registerIntentWriteTools = (server, {
|
|
|
584
631
|
"Update note title/layout/properties. For properties, call ocean_brain_list_properties first. Use existing property key and string value only; do not send valueType. select=option.value, date=YYYY-MM-DD, boolean=true/false, number=finite string, url=http(s). Use deleteKeys to remove values. Definitions are not created.",
|
|
585
632
|
{
|
|
586
633
|
id: z2.string().describe("Note ID to update"),
|
|
587
|
-
expectedUpdatedAt: z2.string().describe("Expected note updatedAt from a prior read."),
|
|
634
|
+
expectedUpdatedAt: z2.string().optional().describe("Expected note updatedAt from a prior read. Auto-fetched when omitted."),
|
|
588
635
|
title: z2.string().optional().describe("New note title"),
|
|
589
636
|
layout: z2.enum(["narrow", "wide", "full"]).optional().describe("New note layout"),
|
|
590
637
|
properties: metadataPropertyPatchSchema.describe("Patch existing shared property values. Include set and/or deleteKeys; empty patches are rejected."),
|
|
@@ -592,16 +639,17 @@ var registerIntentWriteTools = (server, {
|
|
|
592
639
|
},
|
|
593
640
|
async ({ id, expectedUpdatedAt, title, layout, properties, dryRun, operationId, confirmToken }) => {
|
|
594
641
|
const writeToken = requireWriteToken2(token, tools.updateNoteMetadata);
|
|
595
|
-
|
|
642
|
+
requireCommitConfirmationFields({ dryRun, operationId, confirmToken });
|
|
643
|
+
const payload = await resolvePayloadWithBaseline(fetchNoteWriteBaseline, writeToken, id, {
|
|
596
644
|
id,
|
|
597
|
-
expectedUpdatedAt,
|
|
645
|
+
...expectedUpdatedAt ? { expectedUpdatedAt } : {},
|
|
598
646
|
...title !== void 0 ? { title } : {},
|
|
599
647
|
...layout ? { layout } : {},
|
|
600
648
|
...properties ? { properties } : {}
|
|
601
|
-
};
|
|
649
|
+
});
|
|
602
650
|
const summary = properties ? `Update note ${id} metadata and properties` : `Update note ${id} metadata`;
|
|
603
651
|
const operationFingerprint = createIntentWriteOperationFingerprint(serverUrl, writeToken, tools.updateNoteMetadata, payload);
|
|
604
|
-
if (dryRun) {
|
|
652
|
+
if (dryRun ?? true) {
|
|
605
653
|
const result2 = await jsonRequest2(serverUrl, writeToken, "/api/mcp/notes/metadata", {
|
|
606
654
|
...payload,
|
|
607
655
|
dryRun: true
|
|
@@ -649,8 +697,8 @@ var registerIntentWriteTools = (server, {
|
|
|
649
697
|
"Replace a note body as a high-impact full overwrite. Dry-run returns a full diff; commit requires operationId and confirmToken.",
|
|
650
698
|
{
|
|
651
699
|
id: z2.string().describe("Note ID to replace"),
|
|
652
|
-
expectedUpdatedAt: z2.string().optional().describe("Expected note updatedAt from a prior read.
|
|
653
|
-
baseMarkdownSha256: z2.string().optional().describe("SHA-256 of the current markdown.
|
|
700
|
+
expectedUpdatedAt: z2.string().optional().describe("Expected note updatedAt from a prior read. Auto-fetched when omitted unless baseMarkdownSha256 is provided."),
|
|
701
|
+
baseMarkdownSha256: z2.string().optional().describe("SHA-256 of the current markdown. Optional alternative to expectedUpdatedAt."),
|
|
654
702
|
intent: z2.string().describe("Human-readable reason for the full replace."),
|
|
655
703
|
replacement: z2.string().describe("Complete replacement markdown body. Tags are body tokens such as [@tag] or [#tag]."),
|
|
656
704
|
policy: markdownWritePolicySchema,
|
|
@@ -658,16 +706,17 @@ var registerIntentWriteTools = (server, {
|
|
|
658
706
|
},
|
|
659
707
|
async ({ id, expectedUpdatedAt, baseMarkdownSha256, intent, replacement, policy, dryRun, operationId, confirmToken }) => {
|
|
660
708
|
const writeToken = requireWriteToken2(token, tools.replaceNoteMarkdown);
|
|
661
|
-
|
|
709
|
+
requireCommitConfirmationFields({ dryRun, operationId, confirmToken });
|
|
710
|
+
const payload = await resolvePayloadWithBaseline(fetchNoteWriteBaseline, writeToken, id, {
|
|
662
711
|
id,
|
|
663
712
|
...expectedUpdatedAt ? { expectedUpdatedAt } : {},
|
|
664
713
|
...baseMarkdownSha256 ? { baseMarkdownSha256 } : {},
|
|
665
714
|
intent,
|
|
666
715
|
replacement,
|
|
667
716
|
...policy ? { policy } : {}
|
|
668
|
-
};
|
|
717
|
+
});
|
|
669
718
|
const operationFingerprint = createIntentWriteOperationFingerprint(serverUrl, writeToken, tools.replaceNoteMarkdown, payload);
|
|
670
|
-
if (dryRun) {
|
|
719
|
+
if (dryRun ?? true) {
|
|
671
720
|
const result2 = await jsonRequest2(serverUrl, writeToken, "/api/mcp/notes/replace-markdown", {
|
|
672
721
|
...payload,
|
|
673
722
|
dryRun: true
|
|
@@ -841,6 +890,10 @@ async function jsonRequest(serverUrl, token, pathName, body) {
|
|
|
841
890
|
}
|
|
842
891
|
return result;
|
|
843
892
|
}
|
|
893
|
+
var fetchMcpNoteWriteBaseline = async (serverUrl, token, id, request = jsonRequest) => {
|
|
894
|
+
const result = await request(serverUrl, token, "/api/mcp/notes/baseline", { id });
|
|
895
|
+
return result.note;
|
|
896
|
+
};
|
|
844
897
|
var requireWriteToken = (token, toolName) => {
|
|
845
898
|
if (token) {
|
|
846
899
|
return token;
|
|
@@ -985,6 +1038,7 @@ async function startMcpServer(serverUrl, token, options = {}) {
|
|
|
985
1038
|
}
|
|
986
1039
|
);
|
|
987
1040
|
registerIntentWriteTools(server, {
|
|
1041
|
+
fetchNoteWriteBaseline: (id, writeToken) => fetchMcpNoteWriteBaseline(serverUrl, writeToken, id),
|
|
988
1042
|
jsonRequest,
|
|
989
1043
|
requireWriteToken,
|
|
990
1044
|
serverUrl,
|
|
@@ -1494,5 +1548,6 @@ async function startMcpServer(serverUrl, token, options = {}) {
|
|
|
1494
1548
|
}
|
|
1495
1549
|
export {
|
|
1496
1550
|
OCEAN_BRAIN_MCP_TOOLS,
|
|
1551
|
+
fetchMcpNoteWriteBaseline,
|
|
1497
1552
|
startMcpServer
|
|
1498
1553
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ocean-brain",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
39
39
|
"@prisma/client": "^6.19.3",
|
|
40
40
|
"commander": "^14.0.3",
|
|
41
|
+
"diff": "^9.0.0",
|
|
41
42
|
"express": "^5.2.1",
|
|
42
43
|
"express-rate-limit": "8.5.1",
|
|
43
44
|
"express-session": "^1.19.0",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e}from"./note-vendor-uuJO2MTD.js";import{T as b,L as te,N as se,c as q,d as f,s as re,a as ae,M as S,b as ne,S as oe,e as F,B as O,f as ie,g as ce,u as H,q as z,h as K,P as le,i as de,j as ue,C as me}from"./index-
|
|
1
|
+
import{j as e}from"./note-vendor-uuJO2MTD.js";import{T as b,L as te,N as se,c as q,d as f,s as re,a as ae,M as S,b as ne,S as oe,e as F,B as O,f as ie,g as ce,u as H,q as z,h as K,P as le,i as de,j as ue,C as me}from"./index-BgnmVjeF.js";import{a as d}from"./graph-vendor-CUxe67Lr.js";import{C as he}from"./Callout-BvXAlA5k.js";import"./note-core-DMZcZ4yV.js";const ge=({day:r,cellClassName:t,dayNumberClassName:s,isCurrentMonth:i,items:o,overflowCount:c,onOpenOverflow:m})=>e.jsxs("div",{className:`min-h-[196px] rounded-[16px] border p-2.5 ${t}`.trim(),children:[e.jsx("div",{className:"mb-2.5 flex justify-end",children:e.jsx(b,{as:"span",variant:"label",className:`flex h-7 w-7 items-center justify-center rounded-[10px] ${s}`.trim(),children:r})}),i&&o.length>0?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[o,c>0?e.jsxs("button",{type:"button",onClick:m,className:"focus-ring-soft w-full rounded-[10px] border border-dashed border-border-subtle/70 bg-subtle/70 py-1 text-center text-micro font-semibold text-fg-tertiary outline-none transition-colors hover:border-border-secondary/70 hover:bg-hover-subtle hover:text-fg-secondary",children:["+",c," more"]}):null]}):null]}),V=({params:r,toneClassName:t="",header:s,title:i,meta:o,titleClassName:c=""})=>e.jsx(te,{to:se,params:r,className:"focus-ring-soft group block rounded-[8px] outline-none",children:e.jsxs("div",{className:q("flex items-start gap-1.5 rounded-[8px] px-1.5 py-1 transition-colors group-hover:bg-hover-subtle",t),children:[s?e.jsx("span",{className:"mt-[2px] flex h-4 w-4 shrink-0 items-center justify-center text-fg-tertiary",children:s}):e.jsx("span",{"aria-hidden":"true",className:"mt-[6px] h-1.5 w-1.5 shrink-0 rounded-full bg-fg-placeholder"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(b,{as:"div",variant:"label",weight:"medium",tone:"secondary",className:q("line-clamp-1",c),children:i}),o?e.jsx(b,{as:"div",variant:"micro",weight:"medium",tone:"tertiary",className:"mt-0.5",children:o}):null]})]})}),xe=({note:r,type:t})=>e.jsx(V,{params:{id:r.id},header:e.jsx(re,{size:12}),title:r.title,meta:f(Number(t==="create"?r.createdAt:r.updatedAt)).format("HH:mm")}),pe=({reminder:r})=>e.jsx(V,{params:{id:String(r.note?.id??r.noteId)},header:e.jsx(ae,{size:12}),title:r.content||r.note?.title||"No title",titleClassName:r.completed?"line-through":"",meta:f(Number(r.reminderDate)).format("HH:mm")}),L=3,Q=(r,t)=>r.map(s=>s.type==="note"?e.jsx(xe,{note:s.item,type:t},`note-${s.item.id}`):e.jsx(pe,{reminder:s.item},`reminder-${s.item.id}`)),ye=({year:r,month:t,day:s,isCurrentMonth:i,isSunday:o,isToday:c,isPast:m,notes:h,reminders:g,type:N})=>{const[M,v]=d.useState(!1),p=d.useMemo(()=>{const a=h.map(u=>({type:"note",item:u})),l=g.map(u=>({type:"reminder",item:u}));return m?[...a,...l]:[...l,...a]},[m,h,g]),D=p.length>L,w=d.useMemo(()=>Q(p.slice(0,L),N),[p,N]),$=d.useMemo(()=>Q(p,N),[p,N]),k=d.useCallback(()=>v(!0),[]),C=d.useCallback(()=>v(!1),[]),E=()=>i?c?"border-border-secondary/70 bg-[color:color-mix(in_srgb,var(--surface)_88%,var(--accent-soft-primary)_12%)]":"bg-surface border-border-subtle":"bg-muted/18 border-border-subtle/70",I=()=>c?"bg-cta text-fg-on-filled font-semibold":i?o?"text-fg-weekend font-bold":"text-fg-secondary font-bold":"text-fg-disabled opacity-55";return e.jsxs(e.Fragment,{children:[e.jsx(ge,{day:s,cellClassName:E(),dayNumberClassName:I(),isCurrentMonth:i,items:w,overflowCount:D?p.length-L:0,onOpenOverflow:k}),D&&e.jsxs(S,{isOpen:M,onClose:C,variant:"inspect",children:[e.jsx(S.Header,{title:`${r}/${String(t).padStart(2,"0")}/${String(s).padStart(2,"0")}`,onClose:C}),e.jsxs(S.Body,{children:[e.jsxs(S.Description,{className:"sr-only",children:["View all notes and reminders scheduled for day ",s,"."]}),e.jsx("div",{className:"flex max-h-[60vh] flex-col gap-2 overflow-y-auto",children:$})]})]})]})},fe=d.memo(ye),be=["January","February","March","April","May","June","July","August","September","October","November","December"],je=({month:r,year:t,type:s,onPrevMonth:i,onNextMonth:o,onToday:c,onTypeChange:m})=>e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-end lg:justify-between",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex flex-wrap items-end gap-x-2.5 gap-y-1",children:[e.jsx(b,{as:"h1",variant:"display",weight:"bold",tracking:"tighter",className:"text-2xl leading-none sm:text-[2.15rem]",children:be[r-1]}),e.jsx(b,{as:"span",variant:"subheading",weight:"medium",tone:"secondary",tracking:"tight",className:"pb-0.5",children:t})]}),e.jsx(b,{as:"p",variant:"meta",weight:"medium",tone:"secondary",children:"Track note activity and reminders across the month"})]}),e.jsx("div",{className:"flex lg:justify-end",children:e.jsxs("div",{className:"surface-base inline-flex flex-wrap items-center gap-3 rounded-[16px] px-3.5 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ne,{className:"h-4 w-4 shrink-0 text-fg-tertiary"}),e.jsx(b,{as:"span",variant:"label",weight:"medium",tone:"tertiary",children:"Note date"}),e.jsxs(oe,{value:s,onValueChange:g=>m(g),variant:"ghost",size:"sm",children:[e.jsx(F,{value:"create",children:"Created"}),e.jsx(F,{value:"update",children:"Updated"})]})]}),e.jsx("div",{className:"h-5 w-px bg-divider"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(O,{variant:"ghost",size:"sm",onClick:c,children:"Today"}),e.jsx(O,{variant:"ghost",size:"icon-sm",onClick:i,children:e.jsx(ie,{width:18,height:18})}),e.jsx(O,{variant:"ghost",size:"icon-sm",onClick:o,children:e.jsx(ce,{width:18,height:18})})]})]})})]}),Ne=`
|
|
2
2
|
query NotesInDateRange($dateRange: DateRangeInput) {
|
|
3
3
|
notesInDateRange(dateRange: $dateRange) {
|
|
4
4
|
id
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as n}from"./note-vendor-uuJO2MTD.js";import{p as m,T as d}from"./index-
|
|
1
|
+
import{j as n}from"./note-vendor-uuJO2MTD.js";import{p as m,T as d}from"./index-BgnmVjeF.js";import{a as e}from"./graph-vendor-CUxe67Lr.js";const p=new Map([["bold",e.createElement(e.Fragment,null,e.createElement("path",{d:"M108,84a16,16,0,1,1,16,16A16,16,0,0,1,108,84Zm128,44A108,108,0,1,1,128,20,108.12,108.12,0,0,1,236,128Zm-24,0a84,84,0,1,0-84,84A84.09,84.09,0,0,0,212,128Zm-72,36.68V132a20,20,0,0,0-20-20,12,12,0,0,0-4,23.32V168a20,20,0,0,0,20,20,12,12,0,0,0,4-23.32Z"}))],["duotone",e.createElement(e.Fragment,null,e.createElement("path",{d:"M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z",opacity:"0.2"}),e.createElement("path",{d:"M144,176a8,8,0,0,1-8,8,16,16,0,0,1-16-16V128a8,8,0,0,1,0-16,16,16,0,0,1,16,16v40A8,8,0,0,1,144,176Zm88-48A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128ZM124,96a12,12,0,1,0-12-12A12,12,0,0,0,124,96Z"}))],["fill",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm-4,48a12,12,0,1,1-12,12A12,12,0,0,1,124,72Zm12,112a16,16,0,0,1-16-16V128a8,8,0,0,1,0-16,16,16,0,0,1,16,16v40a8,8,0,0,1,0,16Z"}))],["light",e.createElement(e.Fragment,null,e.createElement("path",{d:"M142,176a6,6,0,0,1-6,6,14,14,0,0,1-14-14V128a2,2,0,0,0-2-2,6,6,0,0,1,0-12,14,14,0,0,1,14,14v40a2,2,0,0,0,2,2A6,6,0,0,1,142,176ZM124,94a10,10,0,1,0-10-10A10,10,0,0,0,124,94Zm106,34A102,102,0,1,1,128,26,102.12,102.12,0,0,1,230,128Zm-12,0a90,90,0,1,0-90,90A90.1,90.1,0,0,0,218,128Z"}))],["regular",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm16-40a8,8,0,0,1-8,8,16,16,0,0,1-16-16V128a8,8,0,0,1,0-16,16,16,0,0,1,16,16v40A8,8,0,0,1,144,176ZM112,84a12,12,0,1,1,12,12A12,12,0,0,1,112,84Z"}))],["thin",e.createElement(e.Fragment,null,e.createElement("path",{d:"M140,176a4,4,0,0,1-4,4,12,12,0,0,1-12-12V128a4,4,0,0,0-4-4,4,4,0,0,1,0-8,12,12,0,0,1,12,12v40a4,4,0,0,0,4,4A4,4,0,0,1,140,176ZM124,92a8,8,0,1,0-8-8A8,8,0,0,0,124,92Zm104,36A100,100,0,1,1,128,28,100.11,100.11,0,0,1,228,128Zm-8,0a92,92,0,1,0-92,92A92.1,92.1,0,0,0,220,128Z"}))]]),g=new Map([["bold",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,20A108,108,0,1,0,236,128,108.12,108.12,0,0,0,128,20Zm0,192a84,84,0,1,1,84-84A84.09,84.09,0,0,1,128,212Zm-12-80V80a12,12,0,0,1,24,0v52a12,12,0,0,1-24,0Zm28,40a16,16,0,1,1-16-16A16,16,0,0,1,144,172Z"}))],["duotone",e.createElement(e.Fragment,null,e.createElement("path",{d:"M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z",opacity:"0.2"}),e.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm-8-80V80a8,8,0,0,1,16,0v56a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,172Z"}))],["fill",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm-8,56a8,8,0,0,1,16,0v56a8,8,0,0,1-16,0Zm8,104a12,12,0,1,1,12-12A12,12,0,0,1,128,184Z"}))],["light",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,26A102,102,0,1,0,230,128,102.12,102.12,0,0,0,128,26Zm0,192a90,90,0,1,1,90-90A90.1,90.1,0,0,1,128,218Zm-6-82V80a6,6,0,0,1,12,0v56a6,6,0,0,1-12,0Zm16,36a10,10,0,1,1-10-10A10,10,0,0,1,138,172Z"}))],["regular",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm-8-80V80a8,8,0,0,1,16,0v56a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,172Z"}))],["thin",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,28A100,100,0,1,0,228,128,100.11,100.11,0,0,0,128,28Zm0,192a92,92,0,1,1,92-92A92.1,92.1,0,0,1,128,220Zm-4-84V80a4,4,0,0,1,8,0v56a4,4,0,0,1-8,0Zm12,36a8,8,0,1,1-8-8A8,8,0,0,1,136,172Z"}))]]),l=e.forwardRef((a,t)=>e.createElement(m,{ref:t,...a,weights:p}));l.displayName="InfoIcon";const E=l,c=e.forwardRef((a,t)=>e.createElement(m,{ref:t,...a,weights:g}));c.displayName="WarningCircleIcon";const i=c,f=({children:a,className:t="",tone:r="info"})=>{const o=r==="danger"?i:E,Z=r==="danger"?"border-border-error/70 bg-accent-soft-danger/60":"border-border-subtle bg-hover-subtle/50",s=r==="danger"?"text-fg-error":"text-fg-tertiary",A=r==="danger"?"error":"secondary";return n.jsxs("div",{className:`flex items-center gap-2.5 rounded-[12px] border px-4 py-3 ${Z} ${t}`,children:[n.jsx(o,{className:`h-4 w-4 shrink-0 ${s}`}),n.jsx(d,{as:"div",variant:"meta",weight:"medium",tone:A,children:a})]})};export{f as C,i as m};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as t}from"./note-vendor-uuJO2MTD.js";import{a0 as _,P as C,a3 as U,i as G,a4 as J,a5 as Y,a6 as X,a7 as ee,q as ne,N as te,J as re,T as N,a8 as oe}from"./index-
|
|
1
|
+
import{j as t}from"./note-vendor-uuJO2MTD.js";import{a0 as _,P as C,a3 as U,i as G,a4 as J,a5 as Y,a6 as X,a7 as ee,q as ne,N as te,J as re,T as N,a8 as oe}from"./index-BgnmVjeF.js";import{a as i,F as se}from"./graph-vendor-CUxe67Lr.js";import"./note-core-DMZcZ4yV.js";const ae=s=>{let a=0;for(let r=0;r<s.length;r++)a+=s.charCodeAt(r);return a},ie={background:"#f4f6f8",nodeHub:"#2c2f36",nodeSelected:"#111318",nodeConnected:"#636b76",nodeDefault:["#d6dbe1","#c8ced6","#b7bec7","#a7afb9"],nodeDimmed:["rgba(214,219,225,0.28)","rgba(200,206,214,0.24)","rgba(183,190,199,0.24)","rgba(167,175,185,0.2)"],nodeHubDimmed:"rgba(44,47,54,0.16)",nodeStroke:"#eef1f4",nodeSelectedStroke:"#a6b0bc",labelBackground:"rgba(246,248,250,0.92)",labelText:"#222831",labelFontFamily:"Pretendard Variable, Pretendard, system-ui, sans-serif",linkIdle:"rgba(99, 107, 117, 0.34)",linkConnected:"#68717c",linkDimmed:"rgba(127, 136, 146, 0.12)",legendHub:"#2c2f36"},le={background:"#121316",nodeHub:"#d6dce3",nodeSelected:"#eef1f5",nodeConnected:"#9099a4",nodeDefault:["#343a43","#2d333c","#262c35","#20262f"],nodeDimmed:["rgba(52,58,67,0.28)","rgba(45,51,60,0.24)","rgba(38,44,53,0.22)","rgba(32,38,47,0.2)"],nodeHubDimmed:"rgba(214,220,227,0.16)",nodeStroke:"#171c23",nodeSelectedStroke:"#7f8a97",labelBackground:"rgba(16,18,22,0.9)",labelText:"#eef2f6",labelFontFamily:"Pretendard Variable, Pretendard, system-ui, sans-serif",linkIdle:"rgba(118, 127, 138, 0.42)",linkConnected:"#a2abb6",linkDimmed:"rgba(118, 127, 138, 0.1)",legendHub:"#d6dce3"};function D(s){return s==="dark"?le:ie}function de(s,a){const r=D(s),{connections:g,colorIndex:y,selectedNodeId:d,nodeId:b,isConnected:c}=a,h=d===b;return d!==null&&!h&&!c?g>3?r.nodeHubDimmed:r.nodeDimmed[y%r.nodeDimmed.length]:h?r.nodeSelected:c?r.nodeConnected:g>3?r.nodeHub:r.nodeDefault[y%r.nodeDefault.length]}function ce(s,a){const r=D(s);return a.selectedNodeId!==null&&!a.isConnected?r.linkDimmed:a.isConnected?r.linkConnected:r.linkIdle}function ue(s,a){const r=D(s);return`${a.emphasize?"700":"400"} ${a.fontSize}px ${r.labelFontFamily}`}function z(s){return s<=1?3.5:s<=3?4.5:s<=6?5.5:Math.min(7,5.5+Math.sqrt(s)*.5)}const fe=t.jsx(C,{title:"Knowledge Graph",description:t.jsx(G,{width:184,height:16,className:"rounded-full"}),children:t.jsx("div",{className:"flex h-[600px] items-center justify-center",children:t.jsx(G,{width:"100%",height:"100%"})})});function he(){const s=J(),a=i.useRef(null),r=i.useRef(null),[g,y]=i.useState({width:800,height:600}),[d,b]=i.useState(null),{theme:c}=Y(e=>e),h=D(c),v=i.useRef(h);v.current=h;const{data:w}=X({queryKey:ne.notes.graph(),queryFn:async()=>{const e=await ee();if(e.type==="error")throw e;return e.noteGraph}}),l=i.useMemo(()=>{if(w.nodes.length===0)return null;const e=w.nodes.filter(o=>o.connections>0);if(e.length===0)return null;const n=new Set(e.map(o=>o.id));return{nodes:e,links:w.links.filter(o=>n.has(o.source)&&n.has(o.target))}},[w]);i.useEffect(()=>{if(!l)return;const e=()=>{if(!a.current)return;const n=a.current.getBoundingClientRect();y({width:n.width,height:Math.max(600,window.innerHeight-150)})};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[l]),i.useEffect(()=>{if(!l||!r.current)return;const e=window.setTimeout(()=>{r.current?.zoomToFit(400,50)},500);return()=>window.clearTimeout(e)},[l]);const R=i.useRef(d);R.current=d;const B=i.useCallback(e=>{if(R.current===e.id){s({to:te,params:{id:e.id}});return}b(e.id)},[s]),L=i.useCallback(()=>{b(null)},[]),K=i.useCallback(e=>{a.current&&(a.current.style.cursor=e?"pointer":"default")},[]),I=i.useRef(!1),q=i.useCallback(()=>{I.current||(I.current=!0,r.current?.enableZoomInteraction(!1))},[]),A=i.useCallback(()=>{I.current=!1,r.current?.enableZoomInteraction(!0)},[]),H=i.useRef(new Map),O=i.useMemo(()=>{const e=new Map;if(l)for(const n of l.links)e.has(n.source)||e.set(n.source,new Set),e.has(n.target)||e.set(n.target,new Set),e.get(n.source)?.add(n.target),e.get(n.target)?.add(n.source);return e},[l]);H.current=O;const Z=i.useCallback((e,n,o)=>{const u=v.current,f=d,p=H.current,m=z(e.connections),x=e.x||0,S=e.y||0,k=f===e.id,T=f?p.get(f)?.has(e.id)??!1:!1,V=f!==null&&!k&&!T,W=ae(e.id);if(n.beginPath(),n.arc(x,S,m,0,Math.PI*2),n.fillStyle=de(c,{connections:e.connections,colorIndex:W,selectedNodeId:f,nodeId:e.id,isConnected:T}),n.fill(),V)return;n.strokeStyle=u.nodeStroke,n.lineWidth=(k?2:1)/o,n.stroke(),k&&(n.beginPath(),n.arc(x,S,m+2/o,0,Math.PI*2),n.strokeStyle=u.nodeSelectedStroke,n.lineWidth=1.5/o,n.stroke());const Q=T&&e.connections>=4;if(k||Q||o>2.5){const P=e.title||"Untitled",E=Math.max(10/o,2.5);n.font=ue(c,{fontSize:E,emphasize:k}),n.textAlign="center",n.textBaseline="top";const M=n.measureText(P).width,j=2/o,F=S+m+3/o;n.fillStyle=u.labelBackground,n.fillRect(x-M/2-j,F,M+j*2,E+j*2),n.fillStyle=u.labelText,n.fillText(P,x,F+j)}},[d,c]),$=i.useCallback((e,n,o)=>{const u=d,f=e.source,p=e.target,m=u?f.id===u||p.id===u:!1;n.beginPath(),n.moveTo(f.x||0,f.y||0),n.lineTo(p.x||0,p.y||0),n.strokeStyle=ce(c,{selectedNodeId:u,isConnected:m}),n.lineWidth=m?2/o:.5/o,n.stroke()},[d,c]);return l?t.jsx(C,{title:"Knowledge Graph",description:`${l.nodes.length} linked notes, ${l.links.length} connections`,children:t.jsxs("div",{ref:a,className:"surface-base graph-canvas relative overflow-hidden",style:{"--graph-bg":h.background},children:[d&&(()=>{const e=l.nodes.find(n=>n.id===d);return e?t.jsxs("div",{className:"surface-floating absolute top-3 left-3 z-10 flex items-center gap-2 px-3 py-2",children:[t.jsx(N,{as:"span",variant:"meta",weight:"semibold",truncate:!0,className:"max-w-48",children:e.title}),t.jsxs(N,{as:"span",variant:"label",tone:"tertiary",children:[e.connections," links"]}),t.jsx("button",{type:"button",onClick:()=>b(null),className:"focus-ring-soft ml-1 flex h-6 w-6 cursor-pointer items-center justify-center rounded-[8px] text-fg-tertiary transition-colors hover:bg-hover-subtle hover:text-fg-default","aria-label":"Deselect node",children:t.jsx(oe,{className:"h-3.5 w-3.5"})})]}):null})(),t.jsxs("div",{className:"surface-floating absolute top-3 right-3 z-10 flex flex-col gap-1.5 px-3 py-2.5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"legend-dot h-2.5 w-2.5 shrink-0 rounded-full",style:{"--legend-color":h.legendHub}}),t.jsx(N,{as:"span",variant:"label",weight:"medium",tone:"secondary",children:"Hub notes (4+ connections)"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"legend-dot h-2.5 w-2.5 shrink-0 rounded-full",style:{"--legend-color":h.nodeConnected}}),t.jsx(N,{as:"span",variant:"label",weight:"medium",tone:"secondary",children:"Connected notes"})]})]}),t.jsx(se,{ref:r,graphData:l,width:g.width,height:g.height,nodeId:"id",nodeLabel:"",nodeCanvasObject:Z,nodePointerAreaPaint:(e,n,o)=>{o.beginPath(),o.arc(e.x||0,e.y||0,Math.max(z(e.connections)+4,10),0,2*Math.PI),o.fillStyle=n,o.fill()},linkCanvasObject:$,linkCanvasObjectMode:()=>"replace",linkDirectionalParticles:0,onNodeClick:B,onNodeHover:K,onBackgroundClick:L,onNodeDrag:q,onNodeDragEnd:A,warmupTicks:30,cooldownTicks:80,d3AlphaDecay:.05,d3VelocityDecay:.3,enableZoomInteraction:!0,enablePanInteraction:!0,minZoom:.3,maxZoom:5})]})}):t.jsx(C,{title:"Knowledge Graph",description:"0 linked notes, 0 connections",children:t.jsx(re,{title:"No constellations yet",description:"Link your notes together and watch your own starry sky unfold"})})}function ke(){return t.jsx(_,{fallback:fe,errorTitle:"Failed to load graph",errorDescription:"Retry loading your linked note constellation",renderError:({error:s,retry:a})=>t.jsx(C,{title:"Knowledge Graph",children:t.jsx(U,{title:"Failed to load graph",description:"Retry loading your linked note constellation",error:s,onRetry:a})}),children:t.jsx(he,{})})}export{ke as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./graph-vendor-CUxe67Lr.js";import{p as m}from"./index-
|
|
1
|
+
import{a}from"./graph-vendor-CUxe67Lr.js";import{p as m}from"./index-BgnmVjeF.js";const n=new Map([["bold",a.createElement(a.Fragment,null,a.createElement("path",{d:"M144,96a16,16,0,1,1,16,16A16,16,0,0,1,144,96Zm92-40V200a20,20,0,0,1-20,20H40a20,20,0,0,1-20-20V56A20,20,0,0,1,40,36H216A20,20,0,0,1,236,56ZM44,60v79.72l33.86-33.86a20,20,0,0,1,28.28,0L147.31,147l17.18-17.17a20,20,0,0,1,28.28,0L212,149.09V60Zm0,136H162.34L92,125.66l-48,48Zm168,0V183l-33.37-33.37L164.28,164l32,32Z"}))],["duotone",a.createElement(a.Fragment,null,a.createElement("path",{d:"M224,56V178.06l-39.72-39.72a8,8,0,0,0-11.31,0L147.31,164,97.66,114.34a8,8,0,0,0-11.32,0L32,168.69V56a8,8,0,0,1,8-8H216A8,8,0,0,1,224,56Z",opacity:"0.2"}),a.createElement("path",{d:"M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40Zm0,16V158.75l-26.07-26.06a16,16,0,0,0-22.63,0l-20,20-44-44a16,16,0,0,0-22.62,0L40,149.37V56ZM40,172l52-52,80,80H40Zm176,28H194.63l-36-36,20-20L216,181.38V200ZM144,100a12,12,0,1,1,12,12A12,12,0,0,1,144,100Z"}))],["fill",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40ZM156,88a12,12,0,1,1-12,12A12,12,0,0,1,156,88Zm60,112H40V160.69l46.34-46.35a8,8,0,0,1,11.32,0h0L165,181.66a8,8,0,0,0,11.32-11.32l-17.66-17.65L173,138.34a8,8,0,0,1,11.31,0L216,170.07V200Z"}))],["light",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216,42H40A14,14,0,0,0,26,56V200a14,14,0,0,0,14,14H216a14,14,0,0,0,14-14V56A14,14,0,0,0,216,42ZM40,54H216a2,2,0,0,1,2,2V163.57L188.53,134.1a14,14,0,0,0-19.8,0l-21.42,21.42L101.9,110.1a14,14,0,0,0-19.8,0L38,154.2V56A2,2,0,0,1,40,54ZM38,200V171.17l52.58-52.58a2,2,0,0,1,2.84,0L176.83,202H40A2,2,0,0,1,38,200Zm178,2H193.8l-38-38,21.41-21.42a2,2,0,0,1,2.83,0l38,38V200A2,2,0,0,1,216,202ZM146,100a10,10,0,1,1,10,10A10,10,0,0,1,146,100Z"}))],["regular",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40Zm0,16V158.75l-26.07-26.06a16,16,0,0,0-22.63,0l-20,20-44-44a16,16,0,0,0-22.62,0L40,149.37V56ZM40,172l52-52,80,80H40Zm176,28H194.63l-36-36,20-20L216,181.38V200ZM144,100a12,12,0,1,1,12,12A12,12,0,0,1,144,100Z"}))],["thin",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216,44H40A12,12,0,0,0,28,56V200a12,12,0,0,0,12,12H216a12,12,0,0,0,12-12V56A12,12,0,0,0,216,44ZM40,52H216a4,4,0,0,1,4,4V168.4l-32.89-32.89a12,12,0,0,0-17,0l-22.83,22.83-46.82-46.83a12,12,0,0,0-17,0L36,159V56A4,4,0,0,1,40,52ZM36,200V170.34l53.17-53.17a4,4,0,0,1,5.66,0L181.66,204H40A4,4,0,0,1,36,200Zm180,4H193l-40-40,22.83-22.83a4,4,0,0,1,5.66,0L220,179.71V200A4,4,0,0,1,216,204ZM148,100a8,8,0,1,1,8,8A8,8,0,0,1,148,100Z"}))]]),e=a.forwardRef((l,t)=>a.createElement(m,{ref:t,...l,weights:n}));e.displayName="ImageIcon";const Z=e;export{Z as I};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import{j as e,i as qe,k as ra,U as dt,y as ut,v as na,X as sa,F as oa}from"./note-vendor-uuJO2MTD.js";import{af as la,p as Qe,T as h,c as q,M as H,x as fe,B as S,k as je,u as ye,ag as ia,q as T,ah as ca,ai as da,aj as ua,ak as pa,d as G,m as Ye,a6 as pt,al as fa,n as Me,I as $e,w as ma,o as ha,r as De,v as ft,D as mt,l as ht,g as xa,am as ga,a as ya,an as xt,ao as va,ap as gt,a4 as yt,N as be,ad as ba,z as wa,aq as ja,a5 as Na,ar as Ie,as as ve,a0 as Ue,P as We,a3 as Ze,at as Ca,au as ka,av as Aa,aw as Sa,ax as tt,ay as Ra,i as ie,L as Ke,j as Ta,az as Ea,aA as Ma,aB as at,H as Da,aC as Ha,S as rt,e as He,a8 as La,aD as Fa,aE as Va,aF as Pa,aG as Oa,aH as _a,aI as Ba,aJ as nt,aK as $a,aL as Ia}from"./index-BgnmVjeF.js";import{a}from"./graph-vendor-CUxe67Lr.js";import{C as st,m as Ua}from"./Callout-BvXAlA5k.js";import{S as Za}from"./SurfaceCard-Brd1cMxi.js";import{u as Ka,R as za}from"./useReminderMutate--RlAj_Gg.js";import{n as ze}from"./Plus.es-I7xuoJ9B.js";import{u as qa}from"./image.api-BtadKO98.js";import{A as Qa,G as Ya,a3 as vt,a4 as Wa}from"./note-core-DMZcZ4yV.js";function Ga(t,r){if(t===void 0)return{shouldBlockFn:()=>!0,withResolver:!1};if("shouldBlockFn"in t)return t;if(typeof t=="function")return{shouldBlockFn:async()=>await t(),enableBeforeUnload:!0,withResolver:!1};const n=!!(t.condition??!0),i=t.blockerFn;return{shouldBlockFn:async()=>n&&i!==void 0?await i():n,enableBeforeUnload:n,withResolver:i===void 0}}function Ja(t,r){const{shouldBlockFn:n,enableBeforeUnload:i=!0,disabled:s=!1,withResolver:d=!1}=Ga(t),o=la(),{history:p}=o,[c,g]=a.useState({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0});return a.useEffect(()=>{const m=async C=>{function j(M){const u=o.parseLocation(M),y=o.getMatchedRoutes(u.pathname);return y.foundRoute===void 0?{routeId:"__notFound__",fullPath:u.pathname,pathname:u.pathname,params:y.routeParams,search:o.options.parseSearch(M.search)}:{routeId:y.foundRoute.id,fullPath:y.foundRoute.fullPath,pathname:u.pathname,params:y.routeParams,search:o.options.parseSearch(M.search)}}const x=j(C.currentLocation),A=j(C.nextLocation);if(x.routeId==="__notFound__"&&A.routeId!=="__notFound__")return!1;const k=await n({action:C.action,current:x,next:A});if(!d)return k;if(!k)return!1;const F=await new Promise(M=>{g({status:"blocked",current:x,next:A,action:C.action,proceed:()=>M(!1),reset:()=>M(!0)})});return g({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0}),F};return s?void 0:p.block({blockerFn:m,enableBeforeUnload:i})},[n,i,s,d,p,o]),c}const Xa=new Map([["bold",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216,28H88A12,12,0,0,0,76,40V76H40A12,12,0,0,0,28,88V216a12,12,0,0,0,12,12H168a12,12,0,0,0,12-12V180h36a12,12,0,0,0,12-12V40A12,12,0,0,0,216,28ZM156,204H52V100H156Zm48-48H180V88a12,12,0,0,0-12-12H100V52H204Z"}))],["duotone",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216,40V168H168V88H88V40Z",opacity:"0.2"}),a.createElement("path",{d:"M216,32H88a8,8,0,0,0-8,8V80H40a8,8,0,0,0-8,8V216a8,8,0,0,0,8,8H168a8,8,0,0,0,8-8V176h40a8,8,0,0,0,8-8V40A8,8,0,0,0,216,32ZM160,208H48V96H160Zm48-48H176V88a8,8,0,0,0-8-8H96V48H208Z"}))],["fill",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216,32H88a8,8,0,0,0-8,8V80H40a8,8,0,0,0-8,8V216a8,8,0,0,0,8,8H168a8,8,0,0,0,8-8V176h40a8,8,0,0,0,8-8V40A8,8,0,0,0,216,32Zm-8,128H176V88a8,8,0,0,0-8-8H96V48H208Z"}))],["light",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216,34H88a6,6,0,0,0-6,6V82H40a6,6,0,0,0-6,6V216a6,6,0,0,0,6,6H168a6,6,0,0,0,6-6V174h42a6,6,0,0,0,6-6V40A6,6,0,0,0,216,34ZM162,210H46V94H162Zm48-48H174V88a6,6,0,0,0-6-6H94V46H210Z"}))],["regular",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216,32H88a8,8,0,0,0-8,8V80H40a8,8,0,0,0-8,8V216a8,8,0,0,0,8,8H168a8,8,0,0,0,8-8V176h40a8,8,0,0,0,8-8V40A8,8,0,0,0,216,32ZM160,208H48V96H160Zm48-48H176V88a8,8,0,0,0-8-8H96V48H208Z"}))],["thin",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216,36H88a4,4,0,0,0-4,4V84H40a4,4,0,0,0-4,4V216a4,4,0,0,0,4,4H168a4,4,0,0,0,4-4V172h44a4,4,0,0,0,4-4V40A4,4,0,0,0,216,36ZM164,212H44V92H164Zm48-48H172V88a4,4,0,0,0-4-4H92V44H212Z"}))]]),er=new Map([["bold",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216.49,79.52l-56-56A12,12,0,0,0,152,20H56A20,20,0,0,0,36,40V216a20,20,0,0,0,20,20H200a20,20,0,0,0,20-20V88A12,12,0,0,0,216.49,79.52ZM160,57l23,23H160ZM60,212V44h76V92a12,12,0,0,0,12,12h48V212Z"}))],["duotone",a.createElement(a.Fragment,null,a.createElement("path",{d:"M208,88H152V32Z",opacity:"0.2"}),a.createElement("path",{d:"M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM160,51.31,188.69,80H160ZM200,216H56V40h88V88a8,8,0,0,0,8,8h48V216Z"}))],["fill",a.createElement(a.Fragment,null,a.createElement("path",{d:"M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM152,88V44l44,44Z"}))],["light",a.createElement(a.Fragment,null,a.createElement("path",{d:"M212.24,83.76l-56-56A6,6,0,0,0,152,26H56A14,14,0,0,0,42,40V216a14,14,0,0,0,14,14H200a14,14,0,0,0,14-14V88A6,6,0,0,0,212.24,83.76ZM158,46.48,193.52,82H158ZM200,218H56a2,2,0,0,1-2-2V40a2,2,0,0,1,2-2h90V88a6,6,0,0,0,6,6h50V216A2,2,0,0,1,200,218Z"}))],["regular",a.createElement(a.Fragment,null,a.createElement("path",{d:"M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM160,51.31,188.69,80H160ZM200,216H56V40h88V88a8,8,0,0,0,8,8h48V216Z"}))],["thin",a.createElement(a.Fragment,null,a.createElement("path",{d:"M210.83,85.17l-56-56A4,4,0,0,0,152,28H56A12,12,0,0,0,44,40V216a12,12,0,0,0,12,12H200a12,12,0,0,0,12-12V88A4,4,0,0,0,210.83,85.17ZM156,41.65,198.34,84H156ZM200,220H56a4,4,0,0,1-4-4V40a4,4,0,0,1,4-4h92V88a4,4,0,0,0,4,4h52V216A4,4,0,0,1,200,220Z"}))]]),tr=new Map([["bold",a.createElement(a.Fragment,null,a.createElement("path",{d:"M87.5,151.52l64-64a12,12,0,0,1,17,17l-64,64a12,12,0,0,1-17-17Zm131-114a60.08,60.08,0,0,0-84.87,0L103.51,67.61a12,12,0,0,0,17,17l30.07-30.06a36,36,0,0,1,50.93,50.92L171.4,135.52a12,12,0,1,0,17,17l30.08-30.06A60.09,60.09,0,0,0,218.45,37.55ZM135.52,171.4l-30.07,30.08a36,36,0,0,1-50.92-50.93l30.06-30.07a12,12,0,0,0-17-17L37.55,133.58a60,60,0,0,0,84.88,84.87l30.06-30.07a12,12,0,0,0-17-17Z"}))],["duotone",a.createElement(a.Fragment,null,a.createElement("path",{d:"M209.94,113.94l-96,96a48,48,0,0,1-67.88-67.88l96-96a48,48,0,0,1,67.88,67.88Z",opacity:"0.2"}),a.createElement("path",{d:"M165.66,90.34a8,8,0,0,1,0,11.32l-64,64a8,8,0,0,1-11.32-11.32l64-64A8,8,0,0,1,165.66,90.34ZM215.6,40.4a56,56,0,0,0-79.2,0L106.34,70.45a8,8,0,0,0,11.32,11.32l30.06-30a40,40,0,0,1,56.57,56.56l-30.07,30.06a8,8,0,0,0,11.31,11.32L215.6,119.6a56,56,0,0,0,0-79.2ZM138.34,174.22l-30.06,30.06a40,40,0,1,1-56.56-56.57l30.05-30.05a8,8,0,0,0-11.32-11.32L40.4,136.4a56,56,0,0,0,79.2,79.2l30.06-30.07a8,8,0,0,0-11.32-11.31Z"}))],["fill",a.createElement(a.Fragment,null,a.createElement("path",{d:"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM144.56,173.66l-21.45,21.45a44,44,0,0,1-62.22-62.22l21.45-21.46a8,8,0,0,1,11.32,11.31L72.2,144.2a28,28,0,0,0,39.6,39.6l21.45-21.46a8,8,0,0,1,11.31,11.32Zm-34.9-16a8,8,0,0,1-11.32-11.32l48-48a8,8,0,0,1,11.32,11.32Zm85.45-34.55-21.45,21.45a8,8,0,0,1-11.32-11.31L183.8,111.8a28,28,0,0,0-39.6-39.6L122.74,93.66a8,8,0,0,1-11.31-11.32l21.46-21.45a44,44,0,0,1,62.22,62.22Z"}))],["light",a.createElement(a.Fragment,null,a.createElement("path",{d:"M164.25,91.75a6,6,0,0,1,0,8.49l-64,64a6,6,0,0,1-8.49-8.48l64-64A6,6,0,0,1,164.25,91.75ZM214.2,41.8a54.07,54.07,0,0,0-76.38,0L107.75,71.85a6,6,0,0,0,8.49,8.49l30.07-30.06a42,42,0,0,1,59.41,59.41l-30.08,30.07a6,6,0,1,0,8.49,8.49l30.07-30.07A54,54,0,0,0,214.2,41.8ZM139.76,175.64l-30.07,30.08a42,42,0,0,1-59.41-59.41l30.06-30.07a6,6,0,0,0-8.49-8.49l-30,30.07a54,54,0,0,0,76.38,76.39l30.07-30.08a6,6,0,0,0-8.49-8.49Z"}))],["regular",a.createElement(a.Fragment,null,a.createElement("path",{d:"M165.66,90.34a8,8,0,0,1,0,11.32l-64,64a8,8,0,0,1-11.32-11.32l64-64A8,8,0,0,1,165.66,90.34ZM215.6,40.4a56,56,0,0,0-79.2,0L106.34,70.45a8,8,0,0,0,11.32,11.32l30.06-30a40,40,0,0,1,56.57,56.56l-30.07,30.06a8,8,0,0,0,11.31,11.32L215.6,119.6a56,56,0,0,0,0-79.2ZM138.34,174.22l-30.06,30.06a40,40,0,1,1-56.56-56.57l30.05-30.05a8,8,0,0,0-11.32-11.32L40.4,136.4a56,56,0,0,0,79.2,79.2l30.06-30.07a8,8,0,0,0-11.32-11.31Z"}))],["thin",a.createElement(a.Fragment,null,a.createElement("path",{d:"M162.84,93.16a4,4,0,0,1,0,5.66l-64,64a4,4,0,0,1-5.66-5.66l64-64A4,4,0,0,1,162.84,93.16Zm49.95-49.95a52.07,52.07,0,0,0-73.56,0L109.17,73.27a4,4,0,0,0,5.65,5.66l30.07-30.06a44,44,0,0,1,62.24,62.24l-30.07,30.06a4,4,0,0,0,5.66,5.66l30.07-30.06A52.07,52.07,0,0,0,212.79,43.21ZM141.17,177.06l-30.06,30.07a44,44,0,0,1-62.24-62.24l30.06-30.06a4,4,0,0,0-5.66-5.66L43.21,139.23a52,52,0,0,0,73.56,73.56l30.06-30.07a4,4,0,1,0-5.66-5.66Z"}))]]),bt=a.forwardRef((t,r)=>a.createElement(Qe,{ref:r,...t,weights:Xa}));bt.displayName="CopyIcon";const ar=bt,wt=a.forwardRef((t,r)=>a.createElement(Qe,{ref:r,...t,weights:er}));wt.displayName="FileIcon";const rr=wt,jt=a.forwardRef((t,r)=>a.createElement(Qe,{ref:r,...t,weights:tr}));jt.displayName="LinkSimpleIcon";const Nt=jt;function Ct({icon:t,title:r,className:n}){return e.jsxs("div",{className:q("flex items-center gap-2",n),children:[e.jsx("div",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center text-current",children:t}),e.jsx(h,{as:"span",variant:"label",weight:"semibold",className:"text-current",children:r})]})}function Ge({title:t,icon:r,action:n,titleButtonProps:i,ariaLabel:s,className:d,children:o}){const p=o!=null&&o!==!1,c=n!=null&&n!==!1,g=e.jsx(Ct,{icon:r,title:t,className:"text-fg-tertiary"});return e.jsxs("section",{className:q("surface-base mb-5 p-4",d),"aria-label":s??t,children:[e.jsxs("div",{className:q("relative",c&&"pr-44 sm:pr-48",p&&"mb-3"),children:[i?e.jsx("button",{...i,type:"button",className:q("focus-ring-soft -m-1 flex items-center gap-2 rounded-[10px] p-1 text-fg-tertiary transition-colors hover:bg-hover-subtle hover:text-fg-default",i.className),children:g}):g,c&&e.jsx("div",{className:"absolute top-1/2 right-0 flex -translate-y-1/2 items-center gap-2",children:n})]}),o]})}function ue({title:t,description:r,selected:n=!1,onClick:i,children:s}){return e.jsxs("button",{type:"button","aria-pressed":n,className:`focus-ring-soft flex w-full items-start justify-between gap-3 p-3 text-left transition-colors sm:p-4 ${n?"surface-floating bg-elevated":"rounded-[14px] border border-border-subtle bg-transparent hover:border-border-secondary hover:bg-hover-subtle"}`,onClick:i,children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(h,{as:"div",variant:"body",weight:"semibold",tone:n?"default":"secondary",children:t}),e.jsx(h,{as:"div",variant:"meta",weight:"medium",tone:n?"secondary":"tertiary",className:"mt-1",children:r})]}),s?e.jsx("div",{className:"shrink-0",children:s}):null]})}const nr=[{value:"narrow",label:"Narrow",description:"Optimized for reading long-form content"},{value:"wide",label:"Wide",description:"Balanced width suitable for most content"},{value:"full",label:"Full Width",description:"Maximize screen space utilization"}];function sr({isOpen:t,onClose:r,onSave:n,currentLayout:i="wide"}){const[s,d]=a.useState(i);a.useEffect(()=>{t&&d(i)},[t,i]);const o=()=>{n(s),r()};return e.jsxs(H,{isOpen:t,onClose:r,variant:"compact",children:[e.jsx(H.Header,{title:"Layout Settings",onClose:r}),e.jsx(H.Body,{children:e.jsx("div",{className:"flex flex-col gap-3 sm:gap-4",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(h,{as:"div",variant:"body",weight:"semibold",tone:"secondary",children:"Note layout"}),e.jsx("div",{className:"flex flex-col gap-2",children:nr.map(p=>e.jsx(ue,{title:p.label,description:p.description,selected:s===p.value,onClick:()=>d(p.value)},p.value))})]})})}),e.jsx(H.Footer,{children:e.jsxs(fe,{children:[e.jsx(S,{variant:"ghost",size:"sm",onClick:r,children:"Cancel"}),e.jsx(S,{variant:"primary",size:"sm",onClick:o,children:"Apply"})]})})]})}const kt=t=>t==="mcp"?{actor:"An MCP client",place:"through MCP",target:"the MCP update"}:t==="web"?{actor:"Another browser tab",place:"in another tab",target:"the tab update"}:{actor:"Another editor",place:"elsewhere",target:"the outside change"},or=({isDeleted:t,isConflict:r,source:n})=>{const i=kt(n);return t?`This note was moved to trash ${i.place}`:r?`Save paused: note changed ${i.place}`:`This note changed ${i.place}`},lr=({isDeleted:t,isConflict:r,hasDraft:n,source:i})=>{const s=kt(i);return t?`${s.actor} moved this note to trash. Open trash to review or restore it.`:r&&n?`Your draft is saved locally. Reload the latest note, overwrite ${s.target}, or clone your draft into a new note.`:r?`The layout change is paused because the note changed ${s.place}. Reload the latest note or overwrite only the layout.`:`${s.actor} changed this note while it was open here. Reload the latest version before continuing.`};function ir({isOpen:t,isDeleted:r,isConflict:n,hasDraft:i,source:s,isReloading:d,onReload:o,onOverwrite:p,onCloneDraft:c,onOpenTrash:g}){return e.jsxs(H,{isOpen:t,onClose:()=>{},variant:"inspect",children:[e.jsx(H.Header,{title:or({isDeleted:r,isConflict:n,source:s})}),e.jsx(H.Body,{children:e.jsx(h,{as:"p",variant:"body",tone:"secondary",className:"leading-6",children:lr({isDeleted:r,isConflict:n,hasDraft:i,source:s})})}),e.jsx(H.Footer,{children:e.jsx(fe,{children:r?e.jsx(S,{type:"button",variant:"primary",size:"sm",onClick:g,children:"Open trash"}):n?e.jsxs(e.Fragment,{children:[e.jsx(S,{type:"button",variant:"subtle",size:"sm",isLoading:d,onClick:o,children:"Reload latest"}),i&&e.jsx(S,{type:"button",variant:"ghost",size:"sm",onClick:c,children:"Clone draft"}),e.jsx(S,{type:"button",variant:"danger",size:"sm",onClick:p,children:"Overwrite"})]}):e.jsx(S,{type:"button",variant:"primary",size:"sm",isLoading:d,onClick:o,children:"Reload latest"})})})]})}const ot=(t,r)=>t||(r==="mobile"?"Mobile browser":r==="mcp"?"MCP":"Web browser");function cr({isOpen:t,noteId:r,onClose:n,onRestored:i}){const s=Ye(),d=je(),[o,p]=a.useState(null),[c,g]=a.useState("diff"),m=a.useRef(null),C=ye({queryKey:T.notes.snapshots(r),queryFn:async()=>{const u=await ia(r);if(u.type==="error")throw u;return u.noteSnapshots},enabled:t}),j=ca({mutationFn:da,onSuccess:async u=>{if(u.type==="error"){s(u.errors[0].message);return}await Promise.all([d.invalidateQueries({queryKey:T.notes.detail(r),exact:!0}),d.invalidateQueries({queryKey:T.notes.listAll(),exact:!1}),d.invalidateQueries({queryKey:T.notes.tagListAll(),exact:!1}),d.invalidateQueries({queryKey:T.notes.tagNameListAll(),exact:!1}),d.invalidateQueries({queryKey:T.notes.pinned(),exact:!0}),d.invalidateQueries({queryKey:T.notes.backReferencesAll(),exact:!1}),d.invalidateQueries({queryKey:T.notes.graph(),exact:!0}),d.invalidateQueries({queryKey:T.notes.snapshots(r),exact:!1}),d.invalidateQueries({queryKey:T.views.sectionNotesAll(),exact:!1}),d.invalidateQueries({queryKey:T.tags.all(),exact:!1})]),s("Previous version restored."),i?.(u.restoreNoteSnapshot),p(null),n()}}),x=C.data?.find(u=>u.id===o)??null,A=ye({queryKey:[...T.notes.snapshotDetail(o??"pending"),"diff"],queryFn:async()=>{if(!o)throw new Error("SNAPSHOT_NOT_SELECTED");const u=await ua(o,"current");if(u.type==="error")throw u;if(!u.noteSnapshotDiff)throw new Error("SNAPSHOT_DIFF_NOT_FOUND");return u.noteSnapshotDiff},enabled:!!o&&c==="diff"}),k=ye({queryKey:T.notes.snapshotDetail(o??"pending"),queryFn:async()=>{if(!o)throw new Error("SNAPSHOT_NOT_SELECTED");const u=await pa(o);if(u.type==="error")throw u;if(!u.noteSnapshot)throw new Error("SNAPSHOT_NOT_FOUND");return u.noteSnapshot},enabled:!!o&&c==="content"}),D=k.data?.contentAsMarkdown.trim()??"";a.useEffect(()=>{o&&m.current?.focus()},[o]);const F=(u,y)=>{g(y),p(u)},M=()=>{p(null),g("diff"),n()};return e.jsxs(H,{isOpen:t,onClose:M,variant:"inspect",children:[e.jsx(H.Header,{title:x?c==="diff"?"Snapshot Diff":"Snapshot Content":"Restore Previous Version",onClose:M}),e.jsx(H.Description,{className:"sr-only",children:x?c==="diff"?"Review the markdown diff between this snapshot and the current note.":"Read this snapshot content before restoring it.":"Choose a previous snapshot to restore."}),e.jsx(H.Body,{children:x?e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(h,{as:"p",variant:"body",weight:"semibold",truncate:!0,children:x.title}),e.jsxs(h,{as:"p",variant:"label",tone:"tertiary",children:["Before"," ",ot(x.meta.label,x.meta.entrypoint)," ","edit - ",G(x.createdAt).format("YYYY-MM-DD HH:mm:ss")]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(S,{variant:c==="diff"?"primary":"subtle",size:"sm",onClick:()=>g("diff"),children:"Show diff"}),e.jsx(S,{variant:c==="content"?"primary":"subtle",size:"sm",onClick:()=>g("content"),children:"View content"})]}),c==="diff"?A.isLoading?e.jsx(h,{as:"p",variant:"meta",tone:"secondary",className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3",children:"Loading snapshot diff..."}):A.isError?e.jsx(h,{as:"p",variant:"meta",tone:"secondary",className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3",children:"Snapshot diff could not be loaded."}):A.data?e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(h,{as:"p",variant:"meta",tone:"secondary",children:"Changes from this snapshot to the current note. Red lines were in the snapshot; green lines are in the current note."}),e.jsx("pre",{className:"max-h-[60vh] overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-words rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-0 py-3 text-xs leading-5 text-fg-secondary",children:A.data.diff.markdown.split(`
|
|
2
|
+
`).map((u,y)=>{const v=u.startsWith("+")&&!u.startsWith("+++")?"bg-emerald-500/12 text-emerald-700 dark:text-emerald-200":u.startsWith("-")&&!u.startsWith("---")?"bg-rose-500/12 text-rose-700 dark:text-rose-200":u.startsWith("@@")?"bg-sky-500/12 text-sky-700 dark:text-sky-200":"text-fg-secondary";return e.jsx("span",{className:`block min-w-full whitespace-pre-wrap break-words px-4 ${v}`,children:u||" "},`${y}-${u}`)})})]}):null:k.isLoading?e.jsx(h,{as:"p",variant:"meta",tone:"secondary",className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3",children:"Loading snapshot content..."}):k.isError?e.jsx(h,{as:"p",variant:"meta",tone:"secondary",className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3",children:"Snapshot content could not be loaded."}):D?e.jsx("pre",{className:"max-h-[60vh] overflow-auto whitespace-pre-wrap break-words rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3 text-sm leading-6 text-fg-secondary",children:D}):e.jsx(h,{as:"p",variant:"meta",tone:"secondary",className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3",children:"No readable content was found for this snapshot."})]}):e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(h,{as:"p",variant:"meta",tone:"secondary",children:"Choose a previous snapshot to restore this note back to that state."}),C.isLoading&&e.jsx(h,{as:"div",variant:"meta",tone:"secondary",children:"Loading previous versions..."}),!C.isLoading&&C.data?.length===0&&e.jsx(h,{as:"div",variant:"meta",tone:"secondary",className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3",children:"A recovery snapshot appears before the first edit in a session. Up to 10 recent snapshots are kept for 7 days, and identical versions are skipped."}),!C.isLoading&&C.data&&C.data.length>0&&e.jsx("div",{className:"flex flex-col gap-2",children:C.data.map(u=>e.jsx(Za,{padding:"compact",children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs(h,{as:"p",variant:"body",weight:"semibold",children:["Before"," ",ot(u.meta.label,u.meta.entrypoint)," ","edit"]}),e.jsx(h,{as:"p",variant:"meta",truncate:!0,tone:"secondary",children:u.title}),e.jsx(h,{as:"p",variant:"label",tone:"tertiary",children:G(u.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),e.jsxs("div",{className:"flex shrink-0 flex-wrap gap-2 sm:justify-end",children:[e.jsx(S,{variant:"subtle",size:"sm",onClick:()=>F(u.id,"diff"),children:"Compare"}),e.jsx(S,{size:"sm",isLoading:j.isPending,onClick:()=>j.mutate(u.id),children:"Restore"})]})]}),u.contentPreview&&e.jsx("div",{className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-3 py-2",children:e.jsx(h,{as:"p",variant:"meta",tone:"secondary",className:"line-clamp-4 whitespace-pre-wrap break-words",children:u.contentPreview})})]})},u.id))})]})}),x&&e.jsx(H.Footer,{children:e.jsxs(fe,{children:[e.jsx(S,{ref:m,variant:"subtle",onClick:()=>{p(null),g("diff")},children:"Back"}),e.jsx(S,{isLoading:j.isPending,onClick:()=>j.mutate(x.id),children:"Restore this version"})]})})]})}const dr=t=>{const{data:r}=pt({queryKey:T.notes.backReferences(t.noteId),async queryFn(){const n=await fa(t.noteId);if(n.type==="error")throw n;return n.backReferences}});return t.render(r)};let ur="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",pr=(t=21)=>{let r="",n=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)r+=ur[n[t]&63];return r};const lt={low:{active:"border-border-secondary bg-elevated text-fg-default",inactive:"border-transparent bg-transparent text-fg-muted hover:bg-hover-subtle"},medium:{active:"border-border-secondary bg-elevated text-fg-default",inactive:"border-transparent bg-transparent text-fg-muted hover:bg-hover-subtle"},high:{active:"border-border-secondary bg-elevated text-fg-default",inactive:"border-transparent bg-transparent text-fg-muted hover:bg-hover-subtle"}};function fr({isOpen:t,onClose:r,onSave:n,reminder:i,mode:s}){const[d,o]=a.useState(new Date),[p,c]=a.useState("medium"),[g,m]=a.useState("");a.useEffect(()=>{t&&s==="edit"&&i?(o(new Date(Number(i.reminderDate))),c(i.priority||"medium"),m(i.content||"")):t&&s==="create"&&(o(new Date),c("medium"),m(""))},[t,s,i]);const C=()=>{n(d,p,g||void 0),r()},j=x=>p===x?lt[x].active:lt[x].inactive;return e.jsxs(H,{isOpen:t,onClose:r,variant:"form",children:[e.jsx(H.Header,{title:s==="create"?"Create Reminder":"Edit Reminder",onClose:r}),e.jsx(H.Body,{children:e.jsxs("div",{className:"flex flex-col gap-3 sm:gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(Me,{children:"Date & Time"}),e.jsx($e,{type:"datetime-local",size:"sm",value:G(d).format("YYYY-MM-DDTHH:mm"),onChange:x=>o(new Date(x.target.value))})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(Me,{children:"Content"}),e.jsx(ma,{size:"sm",placeholder:"Enter reminder content (optional)",value:g,onChange:x=>m(x.target.value)})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(Me,{children:"Priority"}),e.jsxs(ha,{type:"single",variant:"quiet",value:p,onValueChange:x=>x&&c(x),className:"gap-1.5 border-none rounded-[14px] bg-muted/70 p-1 sm:gap-2",children:[e.jsx(De,{value:"low",className:`flex-1 rounded-[10px] border ${j("low")}`,children:e.jsx(h,{as:"span",weight:"medium",className:"text-current",children:"Low"})}),e.jsx(De,{value:"medium",className:`flex-1 rounded-[10px] border ${j("medium")}`,children:e.jsx(h,{as:"span",weight:"medium",className:"text-current",children:"Medium"})}),e.jsx(De,{value:"high",className:`flex-1 rounded-[10px] border ${j("high")}`,children:e.jsx(h,{as:"span",weight:"medium",className:"text-current",children:"High"})})]})]})]})}),e.jsx(H.Footer,{children:e.jsxs(fe,{children:[e.jsx(S,{variant:"ghost",size:"sm",onClick:r,children:"Cancel"}),e.jsx(S,{variant:"primary",size:"sm",onClick:C,children:s==="create"?"Create":"Save"})]})})]})}function mr({noteId:t}){const[r,n]=a.useState(!1),[i,s]=a.useState(!1),[d,o]=a.useState("create"),[p,c]=a.useState(void 0),{onCreate:g,onUpdate:m,onDelete:C}=Ka(),j=()=>{o("create"),c(void 0),s(!0)},x=u=>{o("edit"),c(u),s(!0)},A=(u,y,v)=>{d==="create"?g(t,u,y,()=>{s(!1)},v):d==="edit"&&p&&m(p.id,t,{reminderDate:u,priority:y,content:v},()=>{s(!1)})},k=u=>{m(u.id,t,{completed:!u.completed})},D=u=>{const y=G(Number(u)),v=G();return y.isSame(v,"day")?`Today at ${y.format("HH:mm")}`:y.isSame(v.add(1,"day"),"day")?`Tomorrow at ${y.format("HH:mm")}`:y.format("YYYY-MM-DD HH:mm")},F=u=>{const y=G(Number(u)),v=G(),P=y.diff(v,"hour");return P<=6?"high":P<=24?"medium":"low"},M=u=>{const y=G(Number(u)),v=G(),P=y.diff(v,"hour"),B=y.diff(v,"minute")%60;return P<0||B<0?"Overdue":P===0?`${B}m remaining`:`${P}h ${B}m remaining`};return e.jsxs(e.Fragment,{children:[e.jsx(Ge,{title:"Reminders",icon:e.jsx(ya,{className:"h-3.5 w-3.5"}),action:e.jsxs(e.Fragment,{children:[!r&&e.jsxs(S,{size:"sm",variant:"ghost",onClick:j,children:[e.jsx(ze,{className:"w-3 h-3"}),e.jsx(h,{as:"span",variant:"label",className:"hidden sm:inline",children:"Add"})]}),e.jsxs(S,{type:"button",size:"sm",variant:"ghost","aria-label":r?"Expand reminders":"Collapse reminders","aria-expanded":!r,onClick:()=>n(!r),children:[r?e.jsx(xa,{className:"h-3.5 w-3.5"}):e.jsx(ga,{className:"h-3.5 w-3.5"}),r?"Expand":"Collapse"]})]}),children:!r&&e.jsx(za,{noteId:t,searchParams:{offset:0,limit:9999},render:({reminders:u,totalCount:y})=>e.jsx("div",{className:"flex flex-col gap-2",children:u.length===0?e.jsx(h,{as:"p",variant:"meta",tone:"secondary",className:"py-3 text-center",children:y===0?"No reminders yet":"All reminders complete"}):e.jsx("div",{className:"flex flex-col",children:u.map(v=>{const P=v.priority||F(v.reminderDate),B=M(v.reminderDate),L=B==="Overdue";return e.jsxs("div",{className:q("flex items-center gap-2.5 px-2 py-1.5"),children:[e.jsx(ft,{checked:v.completed,onChange:()=>k(v),size:"sm"}),e.jsx(h,{as:"div",variant:"body",weight:"medium",className:q("truncate flex-1 min-w-0",v.completed&&"line-through opacity-40"),children:v.content||D(v.reminderDate)}),e.jsxs("div",{className:q("shrink-0 flex items-center gap-1",v.completed&&"opacity-40"),children:[v.content&&e.jsx(h,{as:"span",variant:"meta",tone:"secondary",children:D(v.reminderDate)}),!v.completed&&e.jsx(h,{as:"span",variant:"label",weight:"medium",tone:L||P==="high"?"error":"tertiary",className:q(v.content&&'before:content-["·"] before:mr-1'),children:B})]}),e.jsx(mt,{button:e.jsx(ht,{label:"Reminder actions"}),items:[{name:"Edit",onClick:()=>x(v)},{name:"Delete",onClick:()=>C(v.id,t)}]})]},v.id)})})})})}),e.jsx(fr,{isOpen:i,onClose:()=>s(!1),onSave:A,reminder:p,mode:d})]})}const hr=({editor:t})=>e.jsx(qe,{triggerCharacter:"/",getItems:async r=>Qa([...ra(t).filter(n=>n.title!=="Audio"&&n.title!=="Video"&&n.title!=="File"),{title:"Table of Contents",subtext:"Insert a table of contents based on headings",onItemClick:()=>{t.insertBlocks([{type:"tableOfContents"}],t.getTextCursorPosition().block,"after")},aliases:["toc","table of contents","contents","outline","index"],group:"Other",icon:e.jsx(xt,{})}],r)}),xr=(t,r)=>r?t.filter(n=>n.id!==r):t,gr=({currentNoteId:t,onClick:r})=>e.jsx(qe,{triggerCharacter:"[",getItems:async n=>{const i=await va({query:n,limit:5});return i.type==="error"?[]:xr(i.allNotes.notes,t).map(d=>({title:d.title,onItemClick:()=>r({type:"reference",props:{id:d.id,title:d.title}})}))}}),yr="pointer-events-auto inline-flex h-7 cursor-pointer select-none items-center gap-1.5 rounded-[8px] border border-white/10 bg-white/10 px-2.5 text-xs font-medium text-white/60 opacity-75 shadow-[0_8px_18px_-14px_rgba(0,0,0,0.45)] backdrop-blur-sm transition-colors hover:bg-white/20 hover:text-white/90 hover:opacity-100 focus-ring-soft focus:text-white/90 focus:opacity-100",vr={idle:"",copied:"text-accent-success hover:text-accent-success focus:text-accent-success",failed:"text-fg-error hover:text-fg-error focus:text-fg-error"},br={idle:"Copy",copied:"Copied",failed:"Copy failed"},wr=({getText:t,resetDelayMs:r=2e3})=>{const[n,i]=a.useState("idle"),s=a.useRef(null),d=a.useCallback(()=>{s.current&&(clearTimeout(s.current),s.current=null)},[]),o=a.useCallback(()=>{d(),s.current=setTimeout(()=>{i("idle"),s.current=null},r)},[d,r]);a.useEffect(()=>d,[d]);const p=m=>{m.stopPropagation()},c=m=>{m.preventDefault(),m.stopPropagation()},g=async m=>{p(m);try{await navigator.clipboard.writeText(t()),i("copied")}catch{i("failed")}o()};return e.jsx("div",{className:"pointer-events-none absolute right-3 top-2 z-[1]",contentEditable:!1,onMouseDown:c,children:e.jsxs("button",{type:"button",className:q(yr,vr[n]),contentEditable:!1,onClick:g,children:[e.jsx(ar,{className:"h-3.5 w-3.5"}),e.jsx("span",{"aria-live":"polite",children:br[n]})]})})},jr=({contentRef:t})=>{const r=a.useRef(null),n=a.useCallback(i=>{r.current=i,t(i)},[t]);return e.jsxs(e.Fragment,{children:[e.jsx("pre",{children:e.jsx("code",{ref:n})}),e.jsx(wr,{getText:()=>r.current?.textContent?.trimEnd()??""})]})},Nr="_Reference_102im_1",Cr={Reference:Nr},kr=gt.bind(Cr),Ar={type:"reference",propSchema:{id:{default:""},title:{default:"Unknown"}},content:"none"};function Sr(t){const r=yt(),n=()=>{t.editor.blur(),r({to:be,params:{id:t.inlineContent.props.id}})},i=s=>{s.preventDefault(),s.stopPropagation()};return e.jsx("span",{role:"link",tabIndex:0,contentEditable:!1,className:kr("Reference"),onMouseDown:i,onClick:s=>{i(s),n()},onKeyDown:s=>{s.key!=="Enter"&&s.key!==" "||(i(s),n())},children:e.jsxs("span",{children:["[",t.inlineContent.props.title,"]"]})})}const Rr=dt(Ar,{render:t=>e.jsx(Sr,{...t})}),Tr=()=>{const t=na(),[r,n]=a.useState([]),i={1:"pl-3",2:"pl-[26px]",3:"pl-[40px]",4:"pl-[54px]",5:"pl-[68px]",6:"pl-[82px]"};a.useEffect(()=>{const o=()=>{const c=t.document,g=[],m=C=>{for(const j of C){if(j.type==="heading"){const x=j,A=x.props.level||1,k=x.content?.map(D=>D.text||"").join("")||"";k.trim()&&g.push({id:j.id,level:A,text:k})}j.children&&Array.isArray(j.children)&&m(j.children)}};m(c),n(g)};o();const p=t.onChange?.(o);return()=>{p&&p()}},[t]);const s=o=>{t.setTextCursorPosition(o);const p=document.querySelector(`[data-id="${o}"]`);p&&p.scrollIntoView({behavior:"smooth",block:"center"})},d=e.jsx(Ct,{icon:e.jsx(xt,{className:"h-3.5 w-3.5"}),title:"Table of Contents",className:"text-fg-tertiary"});return r.length===0?e.jsxs("div",{className:"surface-base w-full p-4",children:[d,e.jsx(h,{as:"p",variant:"meta",tone:"secondary",className:"mt-2",children:"Add headings to your document to generate a table of contents"})]}):e.jsxs("div",{className:"surface-base w-full p-4",children:[e.jsx("div",{className:"mb-2",children:d}),e.jsx("nav",{className:"space-y-0.5",children:r.map(o=>{const p=o.level===1;return e.jsxs("button",{type:"button",onClick:()=>s(o.id),className:q("focus-ring-soft","flex","w-full","items-center","gap-2","rounded-[10px]","px-2.5","py-1.5",i[o.level]??"pl-2.5","text-left","transition-colors","hover:bg-hover-subtle",p?"text-fg-default":"text-fg-secondary"),children:[e.jsxs(h,{as:"span",variant:"label",weight:"medium",tone:"tertiary",className:"min-w-[1.5rem]",children:["H",o.level]}),e.jsx(h,{as:"span",variant:"body",weight:p?"semibold":"medium",className:"line-clamp-2 text-current",children:o.text})]},o.id)})})]})},Er=ut({type:"tableOfContents",propSchema:{},content:"none"},{render:()=>e.jsx(Tr,{})})(),Mr="_Tag_1gb8h_1",Dr={Tag:Mr},Hr=gt.bind(Dr),Lr={type:"tag",propSchema:{id:{default:""},tag:{default:"@Unknown"}},content:"none"};function Fr(t){const r=yt(),n=()=>{t.editor.blur(),r({to:ba,params:{id:t.inlineContent.props.id},search:{page:1}})},i=s=>{s.preventDefault(),s.stopPropagation()};return e.jsx("span",{role:"link",tabIndex:0,contentEditable:!1,className:Hr("Tag"),onMouseDown:i,onClick:s=>{i(s),n()},onKeyDown:s=>{s.key!=="Enter"&&s.key!==" "||(i(s),n())},children:e.jsx("span",{children:t.inlineContent.props.tag})})}const Vr=dt(Lr,{render:t=>e.jsx(Fr,{...t})}),Pr=t=>t,Or=t=>t,_r=Pr({tag:Vr,reference:Rr}),Br=Or({tableOfContents:Er}),se=vt.codeBlock,it=ut(se.config,{meta:se.implementation.meta,parse:se.implementation.parse,parseContent:se.implementation.parseContent,runsBefore:se.implementation.runsBefore,render:jr})(),$r={...it,extensions:se.extensions,implementation:{...it.implementation,toExternalHTML:se.implementation.toExternalHTML}},Ir=Ya.create({inlineContentSpecs:{...Wa,..._r},blockSpecs:{...vt,codeBlock:$r,...Br}}),Ur=(t,r)=>r.some(n=>n.name===`@${t}`),Zr=({onClick:t})=>e.jsx(qe,{triggerCharacter:"@",getItems:async r=>{const n=await wa({query:r,limit:5});if(n.type==="error")return[];const{tags:i}=n.allTags,s=Ur(r,i),d=[{title:"Add a new tag",onItemClick:async()=>{const o=await ja({name:"@"+r});if(o.type==="error")return;const{id:p,name:c}=o.createTag;t({type:"tag",props:{id:p,tag:c}})}}];return i.length===0?d:i.map(o=>({title:o.name,onItemClick:()=>t({type:"tag",props:{id:o.id,tag:o.name}})})).concat(r&&!s?d:[])}}),Kr=new Set(["tableOfContents"]),zr="OCEAN_BRAIN_TAG_",qr="_TOKEN",Qr=t=>`${zr}${t}${qr}`,Yr=t=>!Array.isArray(t)&&t?.type==="tableContent",Wr=(t,r)=>Array.isArray(t)?t.map(r):Yr(t)?{...t,rows:t.rows?.map(n=>({...n,cells:n.cells?.map(i=>({...i,content:i.content?.map(r)}))}))}:t,At=(t,r)=>t.filter(n=>!Kr.has(n.type)).map(n=>({...n,content:r(n.content),children:n.children?.length?At(n.children,r):[]}));function Gr(t){const r=new Map;let n=0;return{blocks:At(t,s=>Wr(s,d=>{if(d.type==="reference"){const o=String(d.props?.id||""),p=String(d.props?.title||d.props?.id||"");return{type:"text",text:o?`[[${p}]](note:${o})`:`[[${p}]]`,styles:{}}}if(d.type==="tag"){const o=d.props?.tag||"",p=Qr(n);return n+=1,r.set(p,o),{type:"text",text:p,styles:{}}}return d})),placeholderToTag:r}}function Jr(t,r){let n=t;for(const[i,s]of r.entries())n=n.split(i).join(`[${s}]`);return n}async function Xr(t){return new Promise((r,n)=>{const i=new FileReader;i.readAsDataURL(t),i.onload=()=>r(i.result),i.onerror=s=>n(s)})}const en=a.forwardRef(({content:t,currentNoteId:r,editable:n,onChange:i},s)=>{const{theme:d}=Na(p=>p),o=sa({schema:Ir,initialContent:t&&JSON.parse(t)||void 0,uploadFile:async p=>qa({base64:await Xr(p)})},[]);return a.useImperativeHandle(s,()=>({getContent:()=>JSON.stringify(o.document),getMarkdown:()=>{const p=Gr(o.document),c=o.blocksToMarkdownLossy(p.blocks);return Jr(c,p.placeholderToTag)},getHtml:()=>o.blocksToHTMLLossy(o.document)})),e.jsxs(oa,{slashMenu:!1,theme:d,editor:o,editable:n,onChange:i,children:[e.jsx(hr,{editor:o}),e.jsx(gr,{currentNoteId:r,onClick:p=>{o.insertInlineContent([p," "])}}),e.jsx(Zr,{onClick:p=>{o.insertInlineContent([p," "])}})]})}),Je=t=>`ocean-brain.note-draft.${t}`,tn=t=>{if(typeof window>"u")return null;try{const r=window.localStorage.getItem(Je(t));if(!r)return null;const n=JSON.parse(r);return typeof n.title!="string"||typeof n.content!="string"||typeof n.baseUpdatedAt!="string"?null:{title:n.title,content:n.content,baseUpdatedAt:n.baseUpdatedAt,createdAt:typeof n.createdAt=="number"?n.createdAt:Date.now(),...n.layout==="narrow"||n.layout==="wide"||n.layout==="full"?{layout:n.layout}:{}}}catch{return null}},Le=(t,r)=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Je(t),JSON.stringify(r))}catch{}},Fe=t=>{if(!(typeof window>"u"))try{window.localStorage.removeItem(Je(t))}catch{}},an=1e3,rn="NOTE_UPDATE_CONFLICT";function nn({noteId:t,initialContent:r,initialUpdatedAt:n,editSessionIdRef:i,getContent:s,onSaved:d,onConflict:o,onError:p}){const c=je(),g=a.useRef(null),m=a.useRef(null),C=a.useRef(!1),j=a.useRef(null),x=a.useRef(!1),A=a.useRef(n),k=a.useRef(!1),D=a.useRef(!0),F=a.useRef(d),M=a.useRef(o),u=a.useRef(p),[y,v]=a.useState("saved"),[P,B]=a.useState(null),L=a.useCallback(()=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null)},[]),O=a.useCallback(R=>{D.current&&v(R)},[]),J=a.useCallback(R=>{A.current=R},[]),Y=a.useCallback((R,_={})=>({title:R,content:s()??r,createdAt:Date.now(),baseUpdatedAt:A.current,..._.layout?{layout:_.layout}:{}}),[s,r]),re=a.useCallback(()=>{m.current&&Le(t,m.current)},[t]),W=a.useCallback(R=>{k.current=!0,O("conflict"),M.current(R??A.current)},[O]),Q=a.useCallback(async({ignoreConflict:R=!1,silent:_=!1}={})=>{if(C.current)return x.current=!0,j.current??"idle";const $=m.current;if(!$)return x.current=!1,"idle";m.current=null,x.current=!1,L(),C.current=!0,_||O("saving");const U=(async()=>{let Z;try{Z=await Ie({id:t,title:$.title,content:$.content,...$.layout?{layout:$.layout}:{},editSessionId:i.current,...R?{force:!0}:{expectedUpdatedAt:$.baseUpdatedAt}})}catch{Z={type:"error",category:"network",errors:[{code:"NETWORK_ERROR",message:"Failed to save note."}]}}if(C.current=!1,j.current=null,Z.type==="error"){m.current||(m.current=$),re();const X=Z.errors[0];if(X.code===rn&&!R){const N=X.details?.extensions?.currentUpdatedAt;return k.current=!0,!_&&D.current&&(O("conflict"),M.current(N??A.current)),"conflict"}return!_&&D.current&&(O("error"),u.current(X.message)),"error"}k.current=!1,A.current=Z.updateNote.updatedAt;const K=!_&&D.current,ne=T.notes.detail(t);await c.cancelQueries({queryKey:ne,exact:!0}),K&&F.current(Z.updateNote.updatedAt),c.setQueryData(ne,X=>X&&{...X,title:Z.updateNote.title,content:$.content,...$.layout?{layout:$.layout}:{},updatedAt:Z.updateNote.updatedAt}),ve({noteId:t,updatedAt:Z.updateNote.updatedAt,editSessionId:i.current});const I=m.current;return I?.baseUpdatedAt===$.baseUpdatedAt?(m.current={...I,baseUpdatedAt:Z.updateNote.updatedAt},re()):I||Fe(t),K&&(m.current?v("pending"):(v("saved"),c.invalidateQueries({queryKey:T.notes.listAll(),exact:!1}),c.invalidateQueries({queryKey:T.notes.tagListAll(),exact:!1}),c.invalidateQueries({queryKey:T.notes.backReferencesAll(),exact:!1}),c.invalidateQueries({queryKey:T.notes.graph(),exact:!0}))),m.current||x.current?Q({silent:_}):"saved"})();return j.current=U,U},[L,i,t,re,c,O]),f=a.useCallback((R,_={})=>{if(m.current=R,Le(t,R),k.current){O("conflict");return}if(O("pending"),L(),_.immediate){Q();return}g.current=window.setTimeout(()=>{Q()},an)},[L,Q,t,O]),E=a.useCallback(R=>{if(m.current=R,Le(t,R),B(null),R.baseUpdatedAt!==A.current){W(A.current);return}f(R)},[t,f,W]),w=a.useCallback(()=>{L(),m.current=null,j.current=null,x.current=!1,k.current=!1,Fe(t),B(null),v("saved")},[L,t]),V=a.useCallback(()=>{L(),j.current=null,x.current=!1,k.current=!1,O(m.current?"pending":"saved")},[L,O]),Ne=a.useCallback(()=>{Fe(t),B(null)},[t]),oe=a.useCallback(()=>m.current,[]),Ce=a.useCallback(R=>{L(),W(R)},[L,W]);return a.useEffect(()=>{M.current=o,u.current=p,F.current=d},[o,p,d]),a.useEffect(()=>(D.current=!0,()=>{D.current=!1}),[]),a.useEffect(()=>{m.current||C.current||k.current||(A.current=n,v("saved"))},[n]),a.useEffect(()=>{m.current=null,C.current=!1,j.current=null,x.current=!1,k.current=!1,A.current=n,B(tn(t)),v("saved")},[t]),a.useEffect(()=>{const R=_=>{!m.current&&!C.current&&!k.current||(_.preventDefault(),_.returnValue="")};return window.addEventListener("beforeunload",R),()=>{window.removeEventListener("beforeunload",R)}},[]),a.useEffect(()=>()=>{L(),m.current&&!k.current&&Q({silent:!0})},[L,Q]),{saveStatus:y,localDraft:P,serverUpdatedAtRef:A,hasUnsavedChanges:y!=="saved",buildDraft:Y,queueSave:f,flushPendingSave:Q,restoreLocalDraft:E,discardLocalDraft:Ne,clearDrafts:w,resolveConflict:V,pauseForConflict:Ce,getPendingDraft:oe,setServerUpdatedAt:J}}const sn=/[:{}[\],&*#?|<>=!%@`-]/,on=t=>t.trim().toLowerCase().replace(/\s+/g,"-").replace(/[\\/:*?"<>|]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")||"untitled-note",ln=t=>t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),ge=t=>t?sn.test(t)||/^\s|\s$/.test(t)?JSON.stringify(t):t:'""',we=t=>{if(!t)return;const r=Number(t);return Number.isFinite(r)?new Date(r).toISOString():t},Ve=(t,r)=>`${on(t)}.${r}`,cn=({id:t,title:r,createdAt:n,updatedAt:i})=>{const s=["---",`title: ${ge(r)}`,`note_id: ${ge(t)}`],d=we(n),o=we(i);return d&&s.push(`created_at: ${ge(d)}`),o&&s.push(`updated_at: ${ge(o)}`),s.push("source: ocean-brain","---"),s.join(`
|
|
3
|
+
`)},dn=(t,r,n=!1)=>n?`${cn(r)}
|
|
4
|
+
|
|
5
|
+
${t}`:t,un=(t,r,{includeMetadata:n=!1,mode:i="fragment"}={})=>{const s=n?`<!--
|
|
6
|
+
source: ocean-brain
|
|
7
|
+
note_id: ${r.id}
|
|
8
|
+
title: ${r.title}
|
|
9
|
+
created_at: ${we(r.createdAt)??""}
|
|
10
|
+
updated_at: ${we(r.updatedAt)??""}
|
|
11
|
+
-->
|
|
12
|
+
`:"";return i==="fragment"?`${s}${t}`:`<!doctype html>
|
|
13
|
+
<html lang="ko">
|
|
14
|
+
<head>
|
|
15
|
+
<meta charset="utf-8" />
|
|
16
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
17
|
+
<title>${ln(r.title)}</title>
|
|
18
|
+
</head>
|
|
19
|
+
<body>
|
|
20
|
+
${s}${t}
|
|
21
|
+
</body>
|
|
22
|
+
</html>`},Pe=(t,r,n)=>{const i=new Blob([t],{type:n}),s=URL.createObjectURL(i),d=document.createElement("a");d.href=s,d.download=r,document.body.appendChild(d),d.click(),d.remove(),URL.revokeObjectURL(s)},St=Ta(be),pe=t=>{const r=/^\d+$/.test(t)?Number(t):Date.parse(t);return Number.isFinite(r)?r:null},Oe=t=>{const r=pe(t);return G(r??Number(t)).format("YYYY-MM-DD HH:mm:ss")},pn=(t,r)=>Ea(pe(t),r),_e=()=>pr(),fn="NOTE_UPDATE_CONFLICT",mn=2200,hn=t=>t?.extensions?.currentUpdatedAt,ct=(t,r)=>{const n=pe(t),i=pe(r);return n===null||i===null?t===r?0:1:n-i},xn=t=>{const r=t.trim();if(!r)return null;try{const n=new URL(r);return n.protocol==="http:"||n.protocol==="https:"?n.toString():null}catch{return null}},gn={narrow:"max-w-[640px]",wide:"max-w-[896px]",full:"max-w-full px-4"},yn=e.jsx(We,{title:"Loading note",variant:"none",children:e.jsxs("main",{className:"mx-auto max-w-[896px]",children:[e.jsx(ie,{className:"mb-8",height:"66px"}),e.jsx(ie,{className:"ml-12 mb-8",height:"150px"}),e.jsx(ie,{className:"mb-5",height:"80px"}),e.jsx(ie,{height:"80px"})]})}),vn=t=>({id:t?.key??"",key:t?.key??"",name:t?.name??"",value:t?.value??"",valueType:t?.valueType??"text",persistedKey:t?.key}),bn=t=>{if(Array.isArray(t))return t;const r=t?.keys;return Array.isArray(r)?r:[]},Be=(t=[])=>t.map(vn),Rt=(t,r)=>{const n=[],i=new Set(r);for(const s of t){const d=s.key.trim();if(!d)continue;const o=s.value.trim(),p=!!s.persistedKey&&(s.valueType==="number"||s.valueType==="date"||s.valueType==="select"||s.valueType==="url");if(!o&&p){i.add(s.persistedKey);continue}!o&&s.valueType!=="text"&&s.valueType!=="boolean"||n.push({key:d,name:s.name.trim()||d,value:s.valueType==="boolean"?o||"false":o,valueType:s.valueType})}return{set:n.sort((s,d)=>s.key.localeCompare(d.key)),deleteKeys:Array.from(i).sort()}},le=(t,r=[])=>JSON.stringify(Rt(t,r)),wn=({noteId:t,properties:r=[],expectedUpdatedAt:n,editSessionId:i,disabled:s,onSaved:d})=>{const o=Ye(),p=je(),[c,g]=a.useState(()=>Be(r)),[m,C]=a.useState([]),[j,x]=a.useState("idle"),A=a.useRef(c),k=a.useRef(m),D=a.useRef(n),F=a.useRef(le(c)),M=a.useRef(null),u=a.useRef(!1),y=a.useRef(!1),v=ye({queryKey:T.notes.propertyKeys({limit:50}),queryFn:async()=>{const f=await Da({limit:50});if(f.type==="error")throw f;return f.notePropertyKeys.keys}});a.useEffect(()=>{const f=Be(r);g(f),C([]),F.current=le(f),x("idle")},[r]),a.useEffect(()=>{A.current=c},[c]),a.useEffect(()=>{k.current=m},[m]),a.useEffect(()=>{D.current=n},[n]);const P=bn(v.data),B=P.filter(f=>!c.some(E=>E.key===f.key)),L=P.length>0,O=a.useCallback(async()=>{const f=le(A.current,k.current);if(s||f===F.current)return;if(u.current){y.current=!0;return}const E=Rt(A.current,k.current);if(!(E.set.length===0&&E.deleteKeys.length===0)){u.current=!0,y.current=!1,x("saving");try{const w=await Ha({id:t,set:E.set,deleteKeys:E.deleteKeys,editSessionId:i,expectedUpdatedAt:D.current});if(w.type==="error"){x("error"),o(w.errors[0]?.message??"Failed to save properties.");return}D.current=w.updateNoteProperties.updatedAt,F.current=le(Be(w.updateNoteProperties.properties??[])),d(w.updateNoteProperties),p.invalidateQueries({queryKey:T.notes.propertyKeysAll(),exact:!1}),x("saved")}catch{x("error"),o("Failed to save properties.")}finally{u.current=!1,y.current&&(y.current=!1,O())}}},[s,i,t,d,p,o]);a.useEffect(()=>{if(M.current&&clearTimeout(M.current),!(s||le(c,m)===F.current))return M.current=setTimeout(()=>{O()},500),()=>{M.current&&clearTimeout(M.current)}},[m,s,c,O]);const J=f=>{g(E=>[...E,{id:f.key,key:f.key,name:f.name,value:"",valueType:f.valueType,persistedKey:void 0}]),C(E=>E.filter(w=>w!==f.key))},Y=(f,E)=>{g(w=>w.map(V=>V.id===f?{...V,...E}:V))},re=f=>{f.persistedKey&&C(E=>[...new Set([...E,f.persistedKey])]),g(E=>E.filter(w=>w.id!==f.id))},W=le(c,m)!==F.current,Q=s||!W&&j==="idle"?null:j==="saving"?"Saving...":j==="error"?"Save failed":W?"Waiting...":"Saved";return e.jsxs(Ge,{title:"Properties",icon:e.jsx(Ia,{className:"h-3.5 w-3.5"}),ariaLabel:"Note properties",action:e.jsxs(e.Fragment,{children:[Q&&e.jsx(h,{as:"span",variant:"micro",tone:j==="error"?"error":"tertiary",className:"px-1",children:Q}),L&&e.jsx(S,{asChild:!0,size:"sm",variant:"ghost",children:e.jsxs(Ke,{to:nt,search:{page:1},children:[e.jsx($a,{className:"h-3 w-3"}),"Manage"]})})]}),children:[c.length===0?e.jsx(h,{as:"p",variant:"label",tone:"tertiary",className:"px-1 py-2",children:"No properties yet."}):e.jsx("div",{className:"divide-y divide-border-subtle",children:c.map(f=>{const E=f.valueType==="url"?xn(f.value):null;return e.jsxs("div",{className:"group grid gap-2 py-2 sm:grid-cols-[minmax(0,180px)_minmax(0,1fr)_auto] sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-1",children:[e.jsx(h,{as:"span",variant:"label",tone:"secondary",className:"truncate",children:f.name}),e.jsx(h,{as:"span",variant:"micro",tone:"tertiary",className:"hidden truncate font-mono sm:inline",children:f.key})]}),f.valueType==="boolean"?e.jsxs(rt,{size:"sm",variant:"ghost",value:f.value||"false",disabled:s,onValueChange:w=>Y(f.id,{value:w}),children:[e.jsx(He,{value:"false",children:"False"}),e.jsx(He,{value:"true",children:"True"})]}):f.valueType==="select"?e.jsx(rt,{size:"sm",variant:"ghost",value:f.value,placeholder:"Select option",disabled:s,onValueChange:w=>Y(f.id,{value:w}),children:(P.find(w=>w.key===f.key)?.options??[]).map(w=>e.jsx(He,{value:w.value,children:w.label},w.id))}):f.valueType==="url"?e.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[e.jsx($e,{className:"min-w-0",size:"sm",variant:"ghost",type:"url","aria-label":"Property value",placeholder:"https://example.com",value:f.value,disabled:s,onChange:w=>Y(f.id,{value:w.target.value})}),E?e.jsx(S,{asChild:!0,size:"icon-sm",variant:"ghost","aria-label":`Open ${f.name}`,className:"shrink-0 text-fg-tertiary",children:e.jsx("a",{href:E,target:"_blank",rel:"noopener noreferrer",title:E,children:e.jsx(Nt,{className:"h-4 w-4"})})}):null]}):e.jsx($e,{size:"sm",variant:"ghost",type:f.valueType==="date"?"date":f.valueType==="number"?"number":"text","aria-label":"Property value",placeholder:"Value",value:f.value,disabled:s,onChange:w=>Y(f.id,{value:w.target.value})}),e.jsx(S,{type:"button",size:"icon-sm",variant:"ghost","aria-label":`Remove ${f.name}`,disabled:s,className:"justify-self-end text-fg-tertiary sm:opacity-0 sm:group-hover:opacity-100 sm:focus-visible:opacity-100",onClick:()=>re(f),children:e.jsx(La,{className:"h-4 w-4"})})]},f.id)})}),e.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:v.isLoading?e.jsx(S,{type:"button",size:"sm",variant:"ghost",disabled:!0,children:"Loading properties..."}):B.length>0?e.jsxs(Fa,{children:[e.jsx(Va,{asChild:!0,children:e.jsxs(S,{type:"button",size:"sm",variant:"ghost",disabled:s,children:[e.jsx(ze,{className:"h-4 w-4"}),"Add property"]})}),e.jsxs(Pa,{align:"start",sideOffset:6,className:"max-h-80 w-[min(22rem,calc(100vw-2rem))]",style:{overflowY:"auto"},children:[e.jsx(Oa,{children:e.jsx(h,{as:"span",variant:"label",weight:"semibold",children:"Add property"})}),e.jsx(_a,{}),B.map(f=>e.jsxs(Ba,{className:"flex-col items-start gap-0.5 whitespace-normal",onClick:()=>J(f),children:[e.jsxs("span",{className:"flex w-full min-w-0 items-center justify-between gap-3",children:[e.jsx(h,{as:"span",variant:"label",weight:"medium",className:"truncate",children:f.name}),e.jsx(h,{as:"span",variant:"micro",tone:"tertiary",className:"shrink-0 capitalize",children:f.valueType})]}),e.jsx(h,{as:"span",variant:"micro",tone:"tertiary",className:"font-mono",children:f.key})]},f.key))]})]}):L?e.jsx(h,{as:"span",variant:"micro",tone:"tertiary",className:"px-1",children:"All shared properties are attached."}):e.jsxs(Ke,{to:nt,search:{page:1},className:"focus-ring-soft inline-flex items-center gap-2 rounded-[12px] px-2.5 py-1.5 text-sm font-medium text-fg-secondary outline-none hover:bg-hover-subtle hover:text-fg-default",children:[e.jsx(ze,{className:"h-4 w-4"}),"Create property definition"]})})]})};function jn({id:t}){const r=Ye(),n=St.useNavigate(),i=je(),s=a.useRef(null),d=a.useRef(null),o=a.useRef(_e()),p=pt({queryKey:T.notes.detail(t),queryFn:async()=>{const l=await Ca(t);if(l.type==="error")throw l;return l.note},gcTime:0}),c=p.data,[g,m]=a.useState(c.title),[C,j]=a.useState(()=>Oe(c.updatedAt)),[x,A]=a.useState(c.updatedAt),[k,D]=a.useState(()=>Date.now()),[F,M]=a.useState(c.pinned),[u,y]=a.useState(c.layout||"wide"),[v,P]=a.useState(!1),[B,L]=a.useState(!1),[O,J]=a.useState(!1),[Y,re]=a.useState("markdown"),[W,Q]=a.useState(!1),[f,E]=a.useState("fragment"),[w,V]=a.useState(null),[Ne,oe]=a.useState(null),[Ce,R]=a.useState(0),[_,$]=a.useState(!1),U=a.useRef(c.updatedAt),Z=a.useRef(t),K=a.useRef(null),ne=a.useRef(!1),I=a.useCallback(l=>{j(Oe(l)),A(l),D(Date.now())},[]),X=nn({noteId:t,initialContent:c.content,initialUpdatedAt:c.updatedAt,editSessionIdRef:o,getContent:()=>s.current?.getContent(),onSaved:l=>{K.current=null,U.current=l,I(l),$(!0)},onConflict:l=>{V({type:"updated",updatedAt:l,source:"unknown"}),r("This note changed elsewhere. Choose how to resolve the draft.")},onError:r}),{saveStatus:N,localDraft:ee,serverUpdatedAtRef:te,hasUnsavedChanges:ce,buildDraft:me,queueSave:he,flushPendingSave:xe,restoreLocalDraft:Tt,discardLocalDraft:Et,clearDrafts:ke,resolveConflict:Mt,pauseForConflict:de,getPendingDraft:Ae,setServerUpdatedAt:ae}=X,Dt=a.useCallback(async()=>{if(ne.current)return ne.current=!1,!1;if(N==="conflict")return r("Resolve the note conflict before leaving."),!0;const l=await xe();return l==="error"?(r("Save failed. Stay on this note and try again."),!0):l==="conflict"},[xe,N,r]);Ja({disabled:N==="saved",enableBeforeUnload:!1,shouldBlockFn:Dt}),a.useEffect(()=>{if(ce){c.updatedAt!==te.current&&ct(c.updatedAt,te.current)>0&&de(c.updatedAt);return}const l=U.current;if(!(c.updatedAt!==l&&ct(c.updatedAt,l)<0)&&(M(c.pinned),y(c.layout||"wide"),ae(c.updatedAt),m(c.title),I(c.updatedAt),l!==c.updatedAt)){const b=s.current?.getContent();U.current=c.updatedAt,(b===void 0||b!==c.content)&&(oe(null),R(z=>z+1))}},[ce,c.layout,c.pinned,c.title,c.updatedAt,de,te,ae,I]),a.useEffect(()=>{Z.current!==t&&(Z.current=t,o.current=_e(),U.current=c.updatedAt,K.current=null,V(null),oe(null),R(l=>l+1),$(!1))},[t,c.updatedAt]),a.useEffect(()=>{if(N!=="saved")return;const l=window.setTimeout(()=>{D(Date.now())},ka(pe(x),k));return()=>window.clearTimeout(l)},[x,k,N]),a.useEffect(()=>{if(!_)return;const l=window.setTimeout(()=>{$(!1)},mn);return()=>window.clearTimeout(l)},[_]),a.useEffect(()=>{w?.type!=="updated"||N==="conflict"||w.updatedAt!==c.updatedAt||(U.current=c.updatedAt,ae(c.updatedAt),I(c.updatedAt),V(null))},[w,c.updatedAt,N,ae,I]),a.useEffect(()=>Aa(l=>{if(l.noteId===t&&!(l.source==="web"&&l.editSessionId===o.current)){if(l.type==="mcp.note.updated"||l.type==="web.note.updated"){if(l.updatedAt===c.updatedAt||l.updatedAt===te.current)return;if(ce){de(l.updatedAt),V({type:"updated",updatedAt:l.updatedAt,source:l.source});return}V({type:"updated",updatedAt:l.updatedAt,source:l.source});return}l.type==="mcp.note.deleted"&&V({type:"deleted",source:l.source})}}),[ce,t,c.updatedAt,de,te]);const{onCreate:Ht,onDelete:Lt,onPinned:Ft,deleteWarningDialog:Vt}=Sa(),Pt=()=>{he(me(g))},Ot=l=>{m(l),he(me(l))},Xe=()=>{he(me(g),{immediate:!0})},_t=async l=>{if(ce){y(l),he(me(g,{layout:l}),{immediate:!0}),r("Layout will be saved with your draft.");return}const b=await Ie({id:t,layout:l,editSessionId:o.current,expectedUpdatedAt:te.current});if(b.type==="error"){b.errors[0].code===fn&&(K.current=l,y(l),de(hn(b.errors[0].details)??te.current)),r(b.errors[0].message);return}K.current=null,await i.cancelQueries({queryKey:T.notes.detail(t),exact:!0}),U.current=b.updateNote.updatedAt,ae(b.updateNote.updatedAt),i.setQueryData(T.notes.detail(t),z=>z&&{...z,layout:l,updatedAt:b.updateNote.updatedAt}),ve({noteId:t,updatedAt:b.updateNote.updatedAt,editSessionId:o.current}),I(b.updateNote.updatedAt),y(l),r("Layout has been updated.")},Bt=()=>({id:t,title:g,createdAt:c.createdAt,updatedAt:te.current||c.updatedAt}),$t=async()=>{const l=s.current?.getMarkdown();if(l===void 0){r("Markdown is not ready yet.");return}try{await navigator.clipboard.writeText(l),r("Copied note as Markdown.")}catch{r("Failed to copy Markdown.")}},It=()=>{const l=s.current?.getMarkdown();if(l===void 0){r("Markdown is not ready yet.");return}try{Pe(l,Ve(g,"md"),"text/markdown;charset=utf-8"),r("Downloaded note as Markdown.")}catch{r("Failed to download Markdown.")}},Ut=()=>{const l=Bt();try{if(Y==="markdown"){const b=s.current?.getMarkdown();if(b===void 0){r("Markdown is not ready yet.");return}Pe(dn(b,l,W),Ve(g,"md"),"text/markdown;charset=utf-8")}else{const b=s.current?.getHtml();if(b===void 0){r("HTML is not ready yet.");return}Pe(un(b,l,{includeMetadata:W,mode:f}),Ve(g,"html"),"text/html;charset=utf-8")}J(!1),r("Downloaded note.")}catch{r("Failed to download note.")}},Zt=async()=>{const l=await p.refetch();if(l.error||!l.data){r("Failed to reload the latest note state.");return}ke(),K.current=null,U.current=l.data.updatedAt,ae(l.data.updatedAt),m(l.data.title),y(l.data.layout||"wide"),I(l.data.updatedAt),oe(null),R(b=>b+1),V(null)},Kt=async()=>{if(Ae()){K.current=null,V(null),await xe({ignoreConflict:!0});return}const b=K.current;if(b){const z=await Ie({id:t,layout:b,editSessionId:o.current,force:!0});if(z.type==="error"){r(z.errors[0].message);return}K.current=null,await i.cancelQueries({queryKey:T.notes.detail(t),exact:!0}),U.current=z.updateNote.updatedAt,Mt(),V(null),ae(z.updateNote.updatedAt),i.setQueryData(T.notes.detail(t),Ee=>Ee&&{...Ee,layout:b,updatedAt:z.updateNote.updatedAt}),ve({noteId:t,updatedAt:z.updateNote.updatedAt,editSessionId:o.current}),I(z.updateNote.updatedAt),y(b);return}V(null),await xe({ignoreConflict:!0})},et=async()=>{const l=Ae();if(!l)return;const b=await Ma({title:at(l.title||"untitled"),content:at(l.content),layout:l.layout??u});if(b.type==="error"){r(b.errors[0].message);return}ne.current=!0,K.current=null,V(null),ke(),Promise.resolve(n({to:be,params:{id:b.createNote.id}})).finally(()=>{ne.current=!1})},zt=()=>{ee&&(m(ee.title),ee.layout&&y(ee.layout),oe(ee.content),R(l=>l+1),Tt(ee))},qt=()=>{Et()},Qt=ee?G(ee.createdAt).format("YYYY-MM-DD HH:mm:ss"):null,Se=N==="saved"&&_,Yt=pn(x,k),Wt=Oe(c.createdAt),Gt=N==="pending"?"Saving...":N==="saving"?"Saving now...":N==="error"?"Save failed. Try again.":N==="conflict"?"Save paused: changed elsewhere":`Saved ${Yt}`,Jt=q("inline-flex items-center gap-2 transition-colors",N==="saved"&&!Se&&"text-fg-secondary",Se&&"text-accent-success",(N==="pending"||N==="saving")&&"text-fg-default",(N==="error"||N==="conflict")&&"text-fg-error"),Re=q("save-progress-ring flex h-4 w-4 shrink-0 items-center justify-center rounded-full",(N==="pending"||N==="saving")&&"save-progress-ring-active",N==="saved"&&Se&&"save-progress-ring-complete",(N==="error"||N==="conflict")&&"save-progress-ring-error"),Xt=N==="saving"?e.jsx("span",{className:Re,"aria-hidden":!0,children:e.jsx("span",{className:"h-2 w-2 rounded-full bg-elevated"})}):N==="pending"?e.jsx("span",{className:Re,"aria-hidden":!0,children:e.jsx("span",{className:"h-2 w-2 rounded-full bg-elevated"})}):N==="error"||N==="conflict"?e.jsx(Ua,{className:"h-3.5 w-3.5",weight:"fill"}):e.jsx("span",{className:Re,"aria-hidden":!0,children:e.jsx("span",{className:"h-2 w-2 rounded-full bg-elevated"})}),ea=e.jsxs(h,{as:"span",variant:"label",weight:"medium",className:Jt,role:"status","aria-live":"polite",title:C,children:[Xt,Gt]}),Te=N==="conflict"&&w?.type==="updated",ta=Te?Ae():null,aa=w!==null&&!(w.type==="updated"&&!Te&&w.updatedAt===c.updatedAt);return e.jsx(We,{title:g,variant:"none",children:e.jsxs("main",{className:q("mx-auto",gn[u]),children:[e.jsx("div",{className:"surface-floating sticky top-20 z-[1001] mb-7 px-5 pt-4 pb-3.5",children:e.jsxs("div",{className:"flex flex-col gap-3.5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-5",children:[e.jsxs("div",{className:"min-w-0 flex-1 pt-0.5",children:[e.jsx(h,{as:"div",variant:"micro",weight:"semibold",tracking:"widest",transform:"uppercase",tone:"tertiary",className:"mb-1.5",children:"Thought in progress"}),e.jsx("input",{ref:d,placeholder:"Title",className:"text-heading sm:text-display w-full bg-transparent font-semibold leading-[1.25] tracking-[-0.02em] outline-none",type:"text",value:g,onChange:l=>Ot(l.target.value)})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx(mt,{button:e.jsx(ht,{label:"Note actions",size:"lg"}),items:[{name:"Copy Markdown",onClick:$t},{name:"Download Markdown",onClick:It},{name:"Download in another format",onClick:()=>J(!0)},{type:"separator",key:"export-separator"},{name:F?"Unpin":"Pin",onClick:()=>Ft(t,F,()=>{M(l=>!l)})},{name:"Change layout",onClick:()=>P(!0)},{type:"separator"},{name:"Clone this note",onClick:()=>Ht(d.current?.value||"untitled",s.current?.getContent()||"",u)},{name:"Restore previous version",onClick:()=>L(!0)},{type:"separator"},{name:"Delete",onClick:()=>Lt(t,()=>{n({to:tt,search:{page:1}})})}]}),e.jsx(S,{size:"sm",variant:"subtle",isLoading:N==="saving",disabled:N==="conflict",onClick:Xe,children:"Save"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2.5 gap-y-1.5 border-t border-border-subtle/80 pt-3",children:[F&&e.jsxs(h,{as:"span",variant:"label",weight:"medium",tone:"secondary",className:"inline-flex items-center gap-1.5",children:[e.jsx(Ra,{className:"h-3 w-3",weight:"fill"}),"Pinned"]}),F&&e.jsx("span",{className:"h-1 w-1 rounded-full bg-border-secondary"}),ea,e.jsx("span",{className:"h-1 w-1 rounded-full bg-border-secondary"}),e.jsxs(h,{as:"span",variant:"micro",weight:"medium",tone:"tertiary",children:["Created ",Wt]})]})]})}),ee&&e.jsx(st,{tone:"danger",className:"mb-6",children:e.jsxs("div",{className:"flex w-full flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("span",{children:["A draft from ",Qt," is saved only in this browser."]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(S,{type:"button",size:"sm",variant:"subtle",className:"self-start",onClick:zt,children:"Restore draft"}),e.jsx(S,{type:"button",size:"sm",variant:"ghost",className:"self-start",onClick:qt,children:"Discard"})]})]})}),N==="error"&&e.jsx(st,{tone:"danger",className:"mb-6",children:e.jsxs("div",{className:"flex w-full flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx("span",{children:"Save failed. Your latest draft is still available here. Retry before leaving this note."}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(S,{type:"button",size:"sm",variant:"subtle",className:"self-start",onClick:Xe,children:"Retry save"}),e.jsx(S,{type:"button",size:"sm",variant:"ghost",className:"self-start",onClick:()=>{et()},children:"Save as new note"})]})]})}),e.jsx(wn,{noteId:t,properties:c.properties,expectedUpdatedAt:te.current,editSessionId:o.current,disabled:N!=="saved",onSaved:l=>{U.current=l.updatedAt,ae(l.updatedAt),I(l.updatedAt),$(!0),i.setQueryData(T.notes.detail(t),b=>b&&{...b,updatedAt:l.updatedAt,properties:l.properties}),ve({noteId:t,updatedAt:l.updatedAt,editSessionId:o.current})}}),e.jsx(en,{ref:s,content:Ne??c.content,currentNoteId:t,onChange:Pt},`${t}:${Ce}`),e.jsx(Ue,{fallback:e.jsx(ie,{className:"mb-5",height:"80px"}),errorTitle:"Failed to load reminders",errorDescription:"Retry loading reminder details for this note.",renderError:({error:l,retry:b})=>e.jsx(Ze,{title:"Failed to load reminders",description:"Retry loading reminder details for this note.",error:l,onRetry:b,showBackAction:!1,showHomeAction:!1}),children:e.jsx(mr,{noteId:t})}),e.jsx(Ue,{fallback:e.jsx(ie,{height:"80px"}),errorTitle:"Failed to load back references",errorDescription:"Retry loading notes that link back here.",renderError:({error:l,retry:b})=>e.jsx(Ze,{title:"Failed to load back references",description:"Retry loading notes that link back here.",error:l,onRetry:b,showBackAction:!1,showHomeAction:!1}),children:e.jsx(dr,{noteId:t,render:l=>l&&l.length>0&&e.jsx(Ge,{icon:e.jsx(Nt,{className:"h-3.5 w-3.5"}),title:"Back References",children:e.jsx("ul",{className:"flex flex-col",children:l.map(b=>e.jsx("li",{children:e.jsxs(Ke,{to:be,params:{id:b.id},className:"flex items-center gap-2 rounded-[10px] px-2.5 py-1.5 text-fg-secondary transition-colors hover:bg-hover-subtle hover:text-fg-default",children:[e.jsx(rr,{className:"h-3.5 w-3.5 shrink-0 text-fg-tertiary"}),e.jsx(h,{as:"span",variant:"body",weight:"medium",className:"text-current",children:b.title})]})},b.id))})})})}),e.jsx(sr,{isOpen:v,onClose:()=>P(!1),onSave:_t,currentLayout:u}),e.jsx(ir,{isOpen:aa,isDeleted:w?.type==="deleted",isConflict:Te,hasDraft:ta!==null,source:w?.source??"unknown",isReloading:p.isRefetching,onReload:Zt,onOverwrite:()=>{Kt()},onCloneDraft:()=>{et()},onOpenTrash:()=>n({to:tt,search:{page:1}})}),e.jsxs(H,{isOpen:O,onClose:()=>J(!1),variant:"compact",children:[e.jsx(H.Header,{title:"Download in another format",onClose:()=>J(!1)}),e.jsx(H.Body,{children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(h,{as:"div",variant:"body",weight:"semibold",tone:"secondary",children:"Format"}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsx(ue,{title:"Markdown",description:"Good for GitHub, static blogs, and other note apps.",selected:Y==="markdown",onClick:()=>re("markdown")}),e.jsx(ue,{title:"HTML",description:"Good for web documents or CMS editors.",selected:Y==="html",onClick:()=>re("html")})]})]}),e.jsxs("div",{className:"flex items-start gap-3 rounded-[14px] border border-border-subtle bg-subtle/60 p-3",children:[e.jsx(ft,{size:"sm",checked:W,onChange:l=>Q(l.target.checked),className:"mt-0.5","aria-label":"Include metadata"}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(h,{as:"span",variant:"body",weight:"semibold",children:"Include metadata"}),e.jsx(h,{as:"span",variant:"label",tone:"tertiary",children:"Add the title, note id, timestamps, and Ocean Brain source information."})]})]}),Y==="html"&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(h,{as:"div",variant:"body",weight:"semibold",tone:"secondary",children:"HTML style"}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsx(ue,{title:"Content only",description:"Save only the note body HTML.",selected:f==="fragment",onClick:()=>E("fragment")}),e.jsx(ue,{title:"Full HTML document",description:"Save a complete HTML file that opens in a browser.",selected:f==="standalone",onClick:()=>E("standalone")})]})]})]})}),e.jsx(H.Footer,{children:e.jsxs(fe,{children:[e.jsx(S,{variant:"ghost",size:"sm",onClick:()=>J(!1),children:"Cancel"}),e.jsx(S,{variant:"primary",size:"sm",onClick:Ut,children:"Download"})]})})]}),e.jsx(cr,{isOpen:B,noteId:t,onClose:()=>L(!1),onRestored:l=>{o.current=_e(),ke(),K.current=null,U.current=l.updatedAt,V(null),ae(l.updatedAt),I(l.updatedAt)}}),Vt]})})}function Dn(){const{id:t}=St.useParams();if(!t)throw new Error("Note id is required.");return e.jsx(Ue,{fallback:yn,errorTitle:"Failed to load note",errorDescription:"Retry loading the note editor.",resetKeys:[t],renderError:({error:r,retry:n})=>e.jsx(We,{title:"Note",variant:"none",children:e.jsx(Ze,{title:"Failed to load note",description:"Retry loading the note editor.",error:r,onRetry:n})}),children:e.jsx(jn,{id:t},t)})}export{jn as NoteContent,Dn as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./graph-vendor-CUxe67Lr.js";import{p as l}from"./index-
|
|
1
|
+
import{a as e}from"./graph-vendor-CUxe67Lr.js";import{p as l}from"./index-BgnmVjeF.js";const r=new Map([["bold",e.createElement(e.Fragment,null,e.createElement("path",{d:"M228,128a12,12,0,0,1-12,12H140v76a12,12,0,0,1-24,0V140H40a12,12,0,0,1,0-24h76V40a12,12,0,0,1,24,0v76h76A12,12,0,0,1,228,128Z"}))],["duotone",e.createElement(e.Fragment,null,e.createElement("path",{d:"M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z",opacity:"0.2"}),e.createElement("path",{d:"M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z"}))],["fill",e.createElement(e.Fragment,null,e.createElement("path",{d:"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM184,136H136v48a8,8,0,0,1-16,0V136H72a8,8,0,0,1,0-16h48V72a8,8,0,0,1,16,0v48h48a8,8,0,0,1,0,16Z"}))],["light",e.createElement(e.Fragment,null,e.createElement("path",{d:"M222,128a6,6,0,0,1-6,6H134v82a6,6,0,0,1-12,0V134H40a6,6,0,0,1,0-12h82V40a6,6,0,0,1,12,0v82h82A6,6,0,0,1,222,128Z"}))],["regular",e.createElement(e.Fragment,null,e.createElement("path",{d:"M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z"}))],["thin",e.createElement(e.Fragment,null,e.createElement("path",{d:"M220,128a4,4,0,0,1-4,4H132v84a4,4,0,0,1-8,0V132H40a4,4,0,0,1,0-8h84V40a4,4,0,0,1,8,0v84h84A4,4,0,0,1,220,128Z"}))]]),a=e.forwardRef((t,n)=>e.createElement(l,{ref:n,...t,weights:r}));a.displayName="PlusIcon";const c=a;export{c as n};
|