@arbidocs/react 0.5.119 → 0.5.121

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/dist/PdfViewerImpl-ZVJZ4KNW.cjs +22 -0
  2. package/dist/PdfViewerImpl-ZVJZ4KNW.cjs.map +1 -0
  3. package/dist/{PdfViewerImpl.d-B28hLEuj.d.ts → PdfViewerImpl.d-CqnEzQO7.d.ts} +9 -1
  4. package/dist/annotations/freeze/index.d.ts +1 -1
  5. package/dist/artifacts/artifact-kind.js +1 -0
  6. package/dist/artifacts/artifact-kind.js.map +2 -2
  7. package/dist/artifacts/index.cjs +3 -2
  8. package/dist/artifacts/index.cjs.map +1 -1
  9. package/dist/artifacts/index.d.ts +3 -2
  10. package/dist/calls/livekit/index.cjs +41 -41
  11. package/dist/chat/turn-flush.js +16 -0
  12. package/dist/chat/turn-flush.js.map +7 -0
  13. package/dist/chat/useConversationActions.js +3 -0
  14. package/dist/chat/useConversationActions.js.map +2 -2
  15. package/dist/{chunk-QP3WQSAA.cjs → chunk-4B2GW3AY.cjs} +3 -3
  16. package/dist/{chunk-QP3WQSAA.cjs.map → chunk-4B2GW3AY.cjs.map} +1 -1
  17. package/dist/{chunk-YMB6XUR2.cjs → chunk-7L7QRIQ2.cjs} +11 -7
  18. package/dist/chunk-7L7QRIQ2.cjs.map +1 -0
  19. package/dist/{chunk-LBAG7KL7.cjs → chunk-DLEHM4IA.cjs} +328 -180
  20. package/dist/chunk-DLEHM4IA.cjs.map +1 -0
  21. package/dist/{PdfViewerImpl-QUSDLNNM.cjs → chunk-ICBT2XGF.cjs} +5 -2
  22. package/dist/chunk-ICBT2XGF.cjs.map +1 -0
  23. package/dist/chunk-MAOGK7IC.cjs +61 -0
  24. package/dist/chunk-MAOGK7IC.cjs.map +1 -0
  25. package/dist/{chunk-5TRUFWKT.cjs → chunk-X5OZRLFZ.cjs} +5 -5
  26. package/dist/{chunk-5TRUFWKT.cjs.map → chunk-X5OZRLFZ.cjs.map} +1 -1
  27. package/dist/datasets/sources/documents.js +1 -1
  28. package/dist/datasets/sources/documents.js.map +2 -2
  29. package/dist/document-tools/images-to-pdf.js +43 -0
  30. package/dist/document-tools/images-to-pdf.js.map +7 -0
  31. package/dist/document-tools/index.cjs +104 -0
  32. package/dist/document-tools/index.cjs.map +1 -1
  33. package/dist/document-tools/index.d.ts +41 -1
  34. package/dist/document-tools/index.js +6 -1
  35. package/dist/document-tools/index.js.map +2 -2
  36. package/dist/document-tools/pdf-attachments.js +63 -0
  37. package/dist/document-tools/pdf-attachments.js.map +7 -0
  38. package/dist/entities/DocumentEntity.js +7 -2
  39. package/dist/entities/DocumentEntity.js.map +2 -2
  40. package/dist/entities/SharingEntity.js +85 -0
  41. package/dist/entities/SharingEntity.js.map +7 -0
  42. package/dist/entities/file-type.js +14 -2
  43. package/dist/entities/file-type.js.map +2 -2
  44. package/dist/entities/index.js +17 -1
  45. package/dist/entities/index.js.map +2 -2
  46. package/dist/icons/PresIcon.js +53 -0
  47. package/dist/icons/PresIcon.js.map +7 -0
  48. package/dist/icons/colors.js +2 -0
  49. package/dist/icons/colors.js.map +2 -2
  50. package/dist/icons/file-type.js +3 -0
  51. package/dist/icons/file-type.js.map +2 -2
  52. package/dist/icons/index.js +2 -0
  53. package/dist/icons/index.js.map +2 -2
  54. package/dist/index.cjs +834 -789
  55. package/dist/index.cjs.map +1 -1
  56. package/dist/{index.d-CYXcTKYt.d.ts → index.d-D2puqWeN.d.ts} +47 -3
  57. package/dist/index.d.ts +50 -8
  58. package/dist/index.js +1 -0
  59. package/dist/index.js.map +2 -2
  60. package/dist/pdf-region-impl-ZG5G2OX2.cjs +98 -0
  61. package/dist/pdf-region-impl-ZG5G2OX2.cjs.map +1 -0
  62. package/dist/session/documents.js +9 -5
  63. package/dist/session/documents.js.map +2 -2
  64. package/dist/ui/index.cjs +182 -158
  65. package/dist/ui/index.d.ts +1 -1
  66. package/dist/ui/slider.js +7 -1
  67. package/dist/ui/slider.js.map +2 -2
  68. package/dist/viewers/PdfViewer.cjs +3 -3
  69. package/dist/viewers/PdfViewer.d.ts +2 -2
  70. package/dist/viewers/PdfViewerImpl.js +4 -1
  71. package/dist/viewers/PdfViewerImpl.js.map +2 -2
  72. package/dist/viewers/index.cjs +30 -4
  73. package/dist/viewers/index.cjs.map +1 -1
  74. package/dist/viewers/index.d.ts +72 -2
  75. package/dist/viewers/index.js +14 -0
  76. package/dist/viewers/index.js.map +2 -2
  77. package/dist/viewers/pdf-region-impl.js +96 -0
  78. package/dist/viewers/pdf-region-impl.js.map +7 -0
  79. package/dist/viewers/pdf-region.js +57 -0
  80. package/dist/viewers/pdf-region.js.map +7 -0
  81. package/dist/viewers/useProcessedChunks.js +2 -1
  82. package/dist/viewers/useProcessedChunks.js.map +2 -2
  83. package/package.json +3 -3
  84. package/dist/PdfViewerImpl-QUSDLNNM.cjs.map +0 -1
  85. package/dist/chunk-LBAG7KL7.cjs.map +0 -1
  86. package/dist/chunk-YMB6XUR2.cjs.map +0 -1
@@ -0,0 +1,98 @@
1
+ 'use strict';
2
+
3
+ var chunkMAOGK7IC_cjs = require('./chunk-MAOGK7IC.cjs');
4
+ var chunkICBT2XGF_cjs = require('./chunk-ICBT2XGF.cjs');
5
+ require('./chunk-PWGSIM3F.cjs');
6
+ require('./chunk-IU2CJNTB.cjs');
7
+ require('./chunk-T5FZICXN.cjs');
8
+ var reactPdf = require('react-pdf');
9
+
10
+ var RENDER_SLOTS = 2;
11
+ var documents = /* @__PURE__ */ new WeakMap();
12
+ function documentFor(request) {
13
+ const cached = documents.get(request.file);
14
+ if (cached) return cached;
15
+ const assets = { ...chunkICBT2XGF_cjs.DEFAULT_ASSETS, ...request.assets };
16
+ chunkICBT2XGF_cjs.ensurePdfWorker(assets.workerSrc);
17
+ const loading = request.file.arrayBuffer().then(
18
+ (buffer) => reactPdf.pdfjs.getDocument({
19
+ data: new Uint8Array(buffer),
20
+ cMapUrl: assets.cMapUrl,
21
+ cMapPacked: true,
22
+ standardFontDataUrl: assets.standardFontDataUrl,
23
+ wasmUrl: assets.wasmUrl
24
+ }).promise
25
+ );
26
+ loading.catch(() => documents.delete(request.file));
27
+ documents.set(request.file, loading);
28
+ return loading;
29
+ }
30
+ function releaseSource(file) {
31
+ const loading = documents.get(file);
32
+ if (!loading) return;
33
+ documents.delete(file);
34
+ void loading.then((doc) => doc.loadingTask.destroy()).catch(() => void 0);
35
+ }
36
+ var running = 0;
37
+ var waiting = [];
38
+ async function slot() {
39
+ if (running >= RENDER_SLOTS) await new Promise((resolve) => waiting.push(resolve));
40
+ running++;
41
+ return () => {
42
+ running--;
43
+ waiting.shift()?.();
44
+ };
45
+ }
46
+ var aborted = () => new DOMException("The clip render was superseded", "AbortError");
47
+ async function renderRegion(request) {
48
+ const { signal } = request;
49
+ const release = await slot();
50
+ try {
51
+ if (signal?.aborted) throw aborted();
52
+ const doc = await documentFor(request);
53
+ const page = await doc.getPage(request.page);
54
+ const base = page.getViewport({ scale: 1 });
55
+ const geometry = chunkMAOGK7IC_cjs.regionGeometry(
56
+ base,
57
+ request.rect,
58
+ request.width,
59
+ request.maxPixels ?? chunkMAOGK7IC_cjs.PDF_REGION_MAX_PIXELS
60
+ );
61
+ if (!geometry.width) throw new RangeError("The clip is empty");
62
+ const viewport = page.getViewport({
63
+ scale: geometry.scale,
64
+ offsetX: geometry.offsetX,
65
+ offsetY: geometry.offsetY
66
+ });
67
+ const canvas = document.createElement("canvas");
68
+ canvas.width = geometry.width;
69
+ canvas.height = geometry.height;
70
+ const task = page.render({ canvas, viewport });
71
+ const cancel = () => task.cancel();
72
+ signal?.addEventListener("abort", cancel);
73
+ try {
74
+ await task.promise;
75
+ } finally {
76
+ signal?.removeEventListener("abort", cancel);
77
+ }
78
+ if (signal?.aborted) throw aborted();
79
+ const masks = chunkMAOGK7IC_cjs.regionMasks(request.rect, request.masks ?? [], geometry);
80
+ if (masks.length) {
81
+ const context = canvas.getContext("2d");
82
+ if (!context) throw new Error("Could not draw the redactions");
83
+ context.fillStyle = "#000";
84
+ for (const m of masks) context.fillRect(m.x, m.y, m.width, m.height);
85
+ }
86
+ if (typeof createImageBitmap !== "function") return canvas;
87
+ const bitmap = await createImageBitmap(canvas);
88
+ canvas.width = canvas.height = 0;
89
+ return bitmap;
90
+ } finally {
91
+ release();
92
+ }
93
+ }
94
+
95
+ exports.releaseSource = releaseSource;
96
+ exports.renderRegion = renderRegion;
97
+ //# sourceMappingURL=pdf-region-impl-ZG5G2OX2.cjs.map
98
+ //# sourceMappingURL=pdf-region-impl-ZG5G2OX2.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/viewers/pdf-region-impl.ts"],"names":["DEFAULT_ASSETS","ensurePdfWorker","pdfjs","regionGeometry","PDF_REGION_MAX_PIXELS","regionMasks"],"mappings":";;;;;;;;;AAqBA,IAAM,YAAA,GAAe,CAAA;AAErB,IAAM,SAAA,uBAAgB,OAAA,EAAoC;AAE1D,SAAS,YAAY,OAAA,EAAiD;AACpE,EAAA,MAAM,MAAA,GAAS,SAAA,CAAU,GAAA,CAAI,OAAA,CAAQ,IAAI,CAAA;AACzC,EAAA,IAAI,QAAQ,OAAO,MAAA;AACnB,EAAA,MAAM,SAAS,EAAE,GAAGA,gCAAA,EAAgB,GAAG,QAAQ,MAAA,EAAO;AACtD,EAAAC,iCAAA,CAAgB,OAAO,SAAS,CAAA;AAChC,EAAA,MAAM,OAAA,GAAU,OAAA,CAAQ,IAAA,CAAK,WAAA,EAAY,CAAE,IAAA;AAAA,IACzC,CAAC,MAAA,KACCC,cAAA,CAAM,WAAA,CAAY;AAAA,MAChB,IAAA,EAAM,IAAI,UAAA,CAAW,MAAM,CAAA;AAAA,MAC3B,SAAS,MAAA,CAAO,OAAA;AAAA,MAChB,UAAA,EAAY,IAAA;AAAA,MACZ,qBAAqB,MAAA,CAAO,mBAAA;AAAA,MAC5B,SAAS,MAAA,CAAO;AAAA,KACjB,CAAA,CAAE;AAAA,GACP;AAEA,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B,MAAA,MAAM,OAAA,GAAU,MAAA,CAAO,UAAA,CAAW,IAAI,CAAA;AACtC,MAAA,IAAI,CAAC,OAAA,EAAS,MAAM,IAAI,MAAM,+BAA+B,CAAA;AAC7D,MAAA,OAAA,CAAQ,SAAA,GAAY,MAAA;AACpB,MAAA,KAAA,MAAW,CAAA,IAAK,KAAA,EAAO,OAAA,CAAQ,QAAA,CAAS,CAAA,CAAE,CAAA,EAAG,CAAA,CAAE,CAAA,EAAG,CAAA,CAAE,KAAA,EAAO,CAAA,CAAE,MAAM,CAAA;AAAA,IACrE;AAEA,IAAA,IAAI,OAAO,iBAAA,KAAsB,UAAA,EAAY,OAAO,MAAA;AACpD,IAAA,MAAM,MAAA,GAAS,MAAM,iBAAA,CAAkB,MAAM,CAAA;AAC7C,IAAA,MAAA,CAAO,KAAA,GAAQ,OAAO,MAAA,GAAS,CAAA;AAC/B,IAAA,OAAO,MAAA;AAAA,EACT,CAAA,SAAE;AACA,IAAA,OAAA,EAAQ;AAAA,EACV;AACF","file":"pdf-region-impl-ZG5G2OX2.cjs","sourcesContent":["/**\n * The pdf.js side of `renderPdfRegion`: one loaded document per file, shared by every clip from it;\n * a page region drawn into a canvas of exactly the output size and handed back as a bitmap (no\n * image encoding). At most RENDER_SLOTS regions render at once, and a request whose signal aborts\n * is dropped before it starts or cancelled while it renders, so resizing or scrolling a clip never\n * queues up stale work.\n */\n\nimport { pdfjs } from 'react-pdf'\nimport { DEFAULT_ASSETS, ensurePdfWorker } from './PdfViewerImpl'\nimport {\n regionGeometry,\n regionMasks,\n PDF_REGION_MAX_PIXELS,\n type PdfRegionImage,\n type PdfRegionRequest,\n} from './pdf-region'\n\ntype PdfDocument = Awaited<ReturnType<typeof pdfjs.getDocument>['promise']>\n\n/** Regions rendering at once: enough to fill a slide quickly, few enough to keep the page smooth. */\nconst RENDER_SLOTS = 2\n\nconst documents = new WeakMap<Blob, Promise<PdfDocument>>()\n\nfunction documentFor(request: PdfRegionRequest): Promise<PdfDocument> {\n const cached = documents.get(request.file)\n if (cached) return cached\n const assets = { ...DEFAULT_ASSETS, ...request.assets }\n ensurePdfWorker(assets.workerSrc)\n const loading = request.file.arrayBuffer().then(\n (buffer) =>\n pdfjs.getDocument({\n data: new Uint8Array(buffer),\n cMapUrl: assets.cMapUrl,\n cMapPacked: true,\n standardFontDataUrl: assets.standardFontDataUrl,\n wasmUrl: assets.wasmUrl,\n }).promise\n )\n // A failed load is not kept: the next render tries again.\n loading.catch(() => documents.delete(request.file))\n documents.set(request.file, loading)\n return loading\n}\n\nexport function releaseSource(file: Blob): void {\n const loading = documents.get(file)\n if (!loading) return\n documents.delete(file)\n void loading.then((doc) => doc.loadingTask.destroy()).catch(() => undefined)\n}\n\nlet running = 0\nconst waiting: (() => void)[] = []\n\n/** Wait for a render slot; the returned function gives it back. */\nasync function slot(): Promise<() => void> {\n if (running >= RENDER_SLOTS) await new Promise<void>((resolve) => waiting.push(resolve))\n running++\n return () => {\n running--\n waiting.shift()?.()\n }\n}\n\nconst aborted = () => new DOMException('The clip render was superseded', 'AbortError')\n\nexport async function renderRegion(request: PdfRegionRequest): Promise<PdfRegionImage> {\n const { signal } = request\n const release = await slot()\n try {\n if (signal?.aborted) throw aborted()\n const doc = await documentFor(request)\n const page = await doc.getPage(request.page)\n const base = page.getViewport({ scale: 1 })\n const geometry = regionGeometry(\n base,\n request.rect,\n request.width,\n request.maxPixels ?? PDF_REGION_MAX_PIXELS\n )\n if (!geometry.width) throw new RangeError('The clip is empty')\n const viewport = page.getViewport({\n scale: geometry.scale,\n offsetX: geometry.offsetX,\n offsetY: geometry.offsetY,\n })\n const canvas = document.createElement('canvas')\n canvas.width = geometry.width\n canvas.height = geometry.height\n const task = page.render({ canvas, viewport })\n const cancel = () => task.cancel()\n signal?.addEventListener('abort', cancel)\n try {\n await task.promise\n } finally {\n signal?.removeEventListener('abort', cancel)\n }\n if (signal?.aborted) throw aborted()\n const masks = regionMasks(request.rect, request.masks ?? [], geometry)\n if (masks.length) {\n const context = canvas.getContext('2d')\n if (!context) throw new Error('Could not draw the redactions')\n context.fillStyle = '#000'\n for (const m of masks) context.fillRect(m.x, m.y, m.width, m.height)\n }\n // A bitmap draws fast in any window; without the API, the canvas itself is drawable.\n if (typeof createImageBitmap !== 'function') return canvas\n const bitmap = await createImageBitmap(canvas)\n canvas.width = canvas.height = 0\n return bitmap\n } finally {\n release()\n }\n}\n"]}
@@ -5,7 +5,8 @@ const VIEWER_TABS = [
5
5
  "docx",
6
6
  "xlsx",
7
7
  "versions",
8
- "preview"
8
+ "preview",
9
+ "slides"
9
10
  ];
10
11
  const DEFAULT_DOCUMENT_VIEWER_STATE = {
11
12
  tab: "pdf",
@@ -15,7 +16,8 @@ const DEFAULT_DOCUMENT_VIEWER_STATE = {
15
16
  phonePdfChosen: false,
16
17
  commentTarget: null,
17
18
  unsavedChanges: false,
18
- detached: false
19
+ detached: false,
20
+ presenting: false
19
21
  };
20
22
  const NO_PASSAGE_CITATION = {
21
23
  active: null,
@@ -37,7 +39,8 @@ const DRAFT_TITLES = {
37
39
  text: "New Doc",
38
40
  audio: "New Audio",
39
41
  photo: "New Photo",
40
- video: "New Video"
42
+ video: "New Video",
43
+ presentation: "New Presentation"
41
44
  };
42
45
  function nextViewingDocument(current, input) {
43
46
  if (!input) return null;
@@ -140,7 +143,7 @@ function createArbiDocumentSessionStore({
140
143
  draftDocuments: { ...state.draftDocuments, [id]: draft },
141
144
  viewingDocument: { id, page: null, passageId: null },
142
145
  // A text draft is written in the editor; a capture's recorder replaces the tabs.
143
- documentViewer: kind === "text" ? { ...state.documentViewer, tab: "edit" } : state.documentViewer
146
+ documentViewer: kind === "text" ? { ...state.documentViewer, tab: "edit" } : kind === "presentation" ? { ...state.documentViewer, tab: "slides" } : state.documentViewer
144
147
  });
145
148
  showViewer?.();
146
149
  return id;
@@ -171,7 +174,8 @@ function createArbiDocumentSessionStore({
171
174
  tabRequest: null,
172
175
  commentTarget: null,
173
176
  unsavedChanges: false,
174
- detached: false
177
+ detached: false,
178
+ presenting: false
175
179
  }
176
180
  }),
177
181
  reset: () => update({
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/session/documents.ts"],
4
- "sourcesContent": ["/**\n * The documents part of the session: the document being viewed and the viewer's own state, the\n * documents selected in lists, the document pinned to the chat, the drafts the user started on the\n * client (no backend record until saved), the citation picking passages in the viewer, and the\n * documents related to each one (near duplicates).\n *\n * {@link createArbiDocumentSessionStore} keeps it in memory; given a `persist`, the place in the\n * documents (the viewed document and its page, the pinned one, the viewer's tab and text size) is\n * read back synchronously when the store is made, so a reload shows the document at once.\n */\n\nimport type { RelatedDocsMap } from '../documents/related-documents'\n\n/** The document being viewed. */\nexport interface ArbiViewingDocument {\n /** The document (`doc-\u2026`), or a version reference (`doc-\u2026@v2`) while an earlier version shows. */\n id: string\n /** The page being read, when known. */\n page: number | null\n /** The passage being read, when one is. */\n passageId: string | null\n}\n\n/** What to view: page and passage are left unchanged when omitted. */\nexport interface ArbiViewingDocumentInput {\n id: string\n page?: number | null\n passageId?: string | null\n}\n\n/** A tab of the document viewer. */\nexport type ArbiViewerTab = 'pdf' | 'edit' | 'html' | 'docx' | 'xlsx' | 'versions' | 'preview'\n\nconst VIEWER_TABS: readonly ArbiViewerTab[] = [\n 'pdf',\n 'edit',\n 'html',\n 'docx',\n 'xlsx',\n 'versions',\n 'preview',\n]\n\n/** A comment of a Word document to open when it shows (a notification, a link). */\nexport interface ArbiDocumentCommentTarget {\n documentId: string\n commentId: string\n}\n\n/**\n * The document viewer's own state, shared with whatever opens documents (a citation opens the text\n * view, Compare from a documents list opens the redline): the open tab, the document compared with\n * the one viewed, and a tab asked for when a document was opened (applied once it has loaded).\n */\nexport interface ArbiDocumentViewerState {\n tab: ArbiViewerTab\n /** The document (or version reference) compared with the viewed one, or null. */\n compareId: string | null\n /** A tab to show once `documentId` has loaded (a signature request opens on the PDF). */\n tabRequest: { documentId: string; tab: ArbiViewerTab } | null\n /** The text view's size, a multiplier of the normal size: a reading preference. */\n textScale: number\n /** A phone user picked the PDF by hand: documents stop opening on the text view. */\n phonePdfChosen: boolean\n /** The Word comment to open in the viewed document, or null. */\n commentTarget: ArbiDocumentCommentTarget | null\n /** The open document has edits not saved yet: closing the viewer asks first. */\n unsavedChanges: boolean\n /** The viewer shows in a window of its own (popped out). */\n detached: boolean\n}\n\n/** What a draft is: a text document, or a capture (a voice note, a photo, a video). */\nexport type ArbiDraftKind = 'text' | 'audio' | 'photo' | 'video'\n\n/**\n * A document the user started on the client (a blank document, a capture), with no backend record\n * until it is saved. Its id is minted here (`draft-\u2026`), never sent to the server.\n */\nexport interface ArbiDraftDocument {\n id: string\n title: string\n kind: ArbiDraftKind\n /** A text draft's Markdown. Empty for captures. */\n content: string\n /** A capture's recording or picture, once taken; null before (and after a kind switch). */\n mediaBlob: Blob | null\n createdAt: string\n}\n\n/** A passage picked for a citation: its chunk and, when known, its page. */\nexport interface ArbiPickedPassage {\n chunk_id: string\n page?: number\n}\n\n/**\n * A citation picking passages in the viewer (a fact's sources, a field's), handed between the\n * viewer and the page that edits the citation.\n */\nexport interface ArbiPassageCitationState {\n /** The citation picking now: the document it picks in and its key (null while unsaved). */\n active: { documentId: string; key: string | null } | null\n /** Passages to light (a fact's cited passages while its sources are open). */\n highlighted: readonly string[]\n /** Passages picked in the viewer, not yet taken by the citation. */\n picked: readonly ArbiPickedPassage[]\n /** Passages unpicked in the viewer, not yet taken off the citation. */\n unpicked: readonly string[]\n}\n\n/** The documents being viewed and selected. */\nexport interface ArbiDocumentSessionState {\n viewingDocument: ArbiViewingDocument | null\n documentViewer: ArbiDocumentViewerState\n /** The documents selected in document lists. */\n selectedDocumentIds: readonly string[]\n /** Documents to select in the documents list once they are listed (a thread's sources). */\n documentsToSelect: readonly string[] | null\n /** The document read in full with each turn (one at a time). */\n pinnedDocumentId: string | null\n /** The documents related to each listed one (near duplicates), from the documents list. */\n relatedDocuments: RelatedDocsMap\n /** The drafts started on the client, by id. */\n draftDocuments: Readonly<Record<string, ArbiDraftDocument>>\n passageCitation: ArbiPassageCitationState\n}\n\n/** The documents' changes (the session store has them). */\nexport interface ArbiDocumentSessionActions {\n /**\n * View a document, or none. Viewing another document resets the page; `page` and `passageId`\n * set them when given.\n */\n setViewingDocument(document: ArbiViewingDocumentInput | null): void\n /** Change the document viewer's state; fields not given stay. */\n setDocumentViewer(change: Partial<ArbiDocumentViewerState>): void\n setSelectedDocumentIds(ids: string[]): void\n /** Ask the documents list to select these once they are listed (null: done). */\n setDocumentsToSelect(ids: string[] | null): void\n setPinnedDocumentId(id: string | null): void\n setRelatedDocuments(related: RelatedDocsMap): void\n /** Change the passage citation; fields not given stay. */\n setPassageCitation(change: Partial<ArbiPassageCitationState>): void\n /** Show a document the session just got (a chat writing one), on `tab`, in the viewer. */\n showNewDocument(documentId: string, tab?: ArbiViewerTab): void\n /** Start a draft of `kind`, view it and show the viewer. Returns its id. */\n startDraftDocument(kind: ArbiDraftKind): string\n /** Change a draft's content, capture or title. */\n updateDraftDocument(\n id: string,\n change: Partial<Pick<ArbiDraftDocument, 'content' | 'mediaBlob' | 'title'>>\n ): void\n /**\n * Switch a draft's kind. The capture is dropped (it belonged to the other kind), and a default\n * title follows the kind; a title the user typed stays.\n */\n setDraftDocumentKind(id: string, kind: ArbiDraftKind): void\n /** Forget a draft (saved or discarded). */\n clearDraftDocument(id: string): void\n}\n\n/** The documents part of a session store. */\nexport interface ArbiDocumentSessionStore extends ArbiDocumentSessionActions {\n /** The current state. The same object until something in it changes. */\n getState(): ArbiDocumentSessionState\n subscribe(listener: () => void): () => void\n /** The workspace is being left: nothing is viewed, selected, pinned or picked. */\n leave(): void\n /** Start over (sign-in, sign-out): only the reading preference (the text size) stays. */\n reset(): void\n}\n\n/** What the documents part keeps across reloads. */\nexport interface ArbiSavedDocuments {\n version: 1\n viewingDocument: { id: string; page: number | null } | null\n pinnedDocumentId: string | null\n tab: ArbiViewerTab\n textScale: number\n}\n\n/**\n * Where the documents part keeps what it saves. `load` is synchronous (localStorage), so the store\n * starts from it and nothing waits; `save` may write later (the latest value wins).\n */\nexport interface ArbiDocumentsPersist {\n /** What was saved (any shape: it is checked), or null. Never throws. */\n load(): unknown\n save(saved: ArbiSavedDocuments): void\n}\n\nexport interface ArbiDocumentSessionStoreOptions {\n initial?: Partial<ArbiDocumentSessionState>\n /** Keep the place in the documents across reloads. */\n persist?: ArbiDocumentsPersist\n /** Show the viewer for a document the session just got (a new draft, a chat's document). */\n showViewer?: () => void\n}\n\nexport const DEFAULT_DOCUMENT_VIEWER_STATE: ArbiDocumentViewerState = {\n tab: 'pdf',\n compareId: null,\n tabRequest: null,\n textScale: 1,\n phonePdfChosen: false,\n commentTarget: null,\n unsavedChanges: false,\n detached: false,\n}\n\nconst NO_PASSAGE_CITATION: ArbiPassageCitationState = {\n active: null,\n highlighted: [],\n picked: [],\n unpicked: [],\n}\n\nexport const EMPTY_DOCUMENT_STATE: ArbiDocumentSessionState = {\n viewingDocument: null,\n documentViewer: DEFAULT_DOCUMENT_VIEWER_STATE,\n selectedDocumentIds: [],\n documentsToSelect: null,\n pinnedDocumentId: null,\n relatedDocuments: new Map(),\n draftDocuments: {},\n passageCitation: NO_PASSAGE_CITATION,\n}\n\n/** A draft's default title, by kind; a title still at one of these follows a kind switch. */\nconst DRAFT_TITLES: Record<ArbiDraftKind, string> = {\n text: 'New Doc',\n audio: 'New Audio',\n photo: 'New Photo',\n video: 'New Video',\n}\n\n/** The next viewing document, given the current one (shared by every store implementation). */\nexport function nextViewingDocument(\n current: ArbiViewingDocument | null,\n input: ArbiViewingDocumentInput | null\n): ArbiViewingDocument | null {\n if (!input) return null\n const same = current?.id === input.id\n return {\n id: input.id,\n page: input.page !== undefined ? input.page : same ? (current?.page ?? null) : null,\n passageId: input.passageId !== undefined ? input.passageId : (current?.passageId ?? null),\n }\n}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value)\nconst isPage = (value: unknown): value is number =>\n typeof value === 'number' && Number.isInteger(value) && value >= 1\n\n/**\n * Read a saved place in the documents. Each field is checked on its own: an unreadable one keeps\n * its default. Null when there is nothing readable at all.\n */\nexport function parseSavedDocuments(saved: unknown): ArbiSavedDocuments | null {\n if (!isRecord(saved) || saved.version !== 1) return null\n const viewing = isRecord(saved.viewingDocument) ? saved.viewingDocument : null\n return {\n version: 1,\n viewingDocument:\n viewing && typeof viewing.id === 'string' && viewing.id\n ? { id: viewing.id, page: isPage(viewing.page) ? viewing.page : null }\n : null,\n pinnedDocumentId: typeof saved.pinnedDocumentId === 'string' ? saved.pinnedDocumentId : null,\n tab: VIEWER_TABS.includes(saved.tab as ArbiViewerTab)\n ? (saved.tab as ArbiViewerTab)\n : DEFAULT_DOCUMENT_VIEWER_STATE.tab,\n textScale:\n typeof saved.textScale === 'number' && Number.isFinite(saved.textScale) && saved.textScale > 0\n ? saved.textScale\n : DEFAULT_DOCUMENT_VIEWER_STATE.textScale,\n }\n}\n\n/** What of `state` is kept across reloads. */\nexport function savedDocumentsOf(state: ArbiDocumentSessionState): ArbiSavedDocuments {\n return {\n version: 1,\n viewingDocument: state.viewingDocument\n ? { id: state.viewingDocument.id, page: state.viewingDocument.page }\n : null,\n pinnedDocumentId: state.pinnedDocumentId,\n tab: state.documentViewer.tab,\n textScale: state.documentViewer.textScale,\n }\n}\n\n/** The state a saved place puts back (over `base`). */\nexport function restoreSavedDocuments(\n base: ArbiDocumentSessionState,\n saved: ArbiSavedDocuments\n): ArbiDocumentSessionState {\n return {\n ...base,\n viewingDocument: saved.viewingDocument\n ? { id: saved.viewingDocument.id, page: saved.viewingDocument.page, passageId: null }\n : null,\n pinnedDocumentId: saved.pinnedDocumentId,\n documentViewer: { ...base.documentViewer, tab: saved.tab, textScale: saved.textScale },\n }\n}\n\n/** The documents part, in memory (and, given a `persist`, kept across reloads). */\nexport function createArbiDocumentSessionStore({\n initial = {},\n persist,\n showViewer,\n}: ArbiDocumentSessionStoreOptions = {}): ArbiDocumentSessionStore {\n let state: ArbiDocumentSessionState = { ...EMPTY_DOCUMENT_STATE, ...initial }\n if (persist) {\n const saved = parseSavedDocuments(persist.load())\n if (saved) state = restoreSavedDocuments(state, saved)\n }\n const listeners = new Set<() => void>()\n const update = (patch: Partial<ArbiDocumentSessionState>) => {\n const previous = state\n state = { ...state, ...patch }\n if (\n persist &&\n (state.viewingDocument !== previous.viewingDocument ||\n state.pinnedDocumentId !== previous.pinnedDocumentId ||\n state.documentViewer.tab !== previous.documentViewer.tab ||\n state.documentViewer.textScale !== previous.documentViewer.textScale)\n )\n persist.save(savedDocumentsOf(state))\n listeners.forEach((listener) => listener())\n }\n const setDocumentViewer = (change: Partial<ArbiDocumentViewerState>) => {\n const next = { ...state.documentViewer, ...change }\n const keys = Object.keys(change) as (keyof ArbiDocumentViewerState)[]\n if (keys.some((key) => next[key] !== state.documentViewer[key]))\n update({ documentViewer: next })\n }\n const updateDraft = (id: string, change: (draft: ArbiDraftDocument) => ArbiDraftDocument) => {\n const draft = state.draftDocuments[id]\n if (draft) update({ draftDocuments: { ...state.draftDocuments, [id]: change(draft) } })\n }\n return {\n getState: () => state,\n subscribe: (listener) => {\n listeners.add(listener)\n return () => listeners.delete(listener)\n },\n setViewingDocument: (input) =>\n update({ viewingDocument: nextViewingDocument(state.viewingDocument, input) }),\n setDocumentViewer,\n setSelectedDocumentIds: (ids) => update({ selectedDocumentIds: ids }),\n setDocumentsToSelect: (ids) => update({ documentsToSelect: ids }),\n setPinnedDocumentId: (pinnedDocumentId) => update({ pinnedDocumentId }),\n setRelatedDocuments: (relatedDocuments) => update({ relatedDocuments }),\n setPassageCitation: (change) =>\n update({ passageCitation: { ...state.passageCitation, ...change } }),\n showNewDocument: (documentId, tab) => {\n update({\n viewingDocument: { id: documentId, page: null, passageId: null },\n documentViewer: tab ? { ...state.documentViewer, tab } : state.documentViewer,\n })\n showViewer?.()\n },\n startDraftDocument: (kind) => {\n const id = `draft-${crypto.randomUUID()}`\n const draft: ArbiDraftDocument = {\n id,\n title: DRAFT_TITLES[kind],\n kind,\n content: '',\n mediaBlob: null,\n createdAt: new Date().toISOString(),\n }\n update({\n draftDocuments: { ...state.draftDocuments, [id]: draft },\n viewingDocument: { id, page: null, passageId: null },\n // A text draft is written in the editor; a capture's recorder replaces the tabs.\n documentViewer:\n kind === 'text' ? { ...state.documentViewer, tab: 'edit' } : state.documentViewer,\n })\n showViewer?.()\n return id\n },\n updateDraftDocument: (id, change) => updateDraft(id, (draft) => ({ ...draft, ...change })),\n setDraftDocumentKind: (id, kind) =>\n updateDraft(id, (draft) => ({\n ...draft,\n kind,\n mediaBlob: null,\n title: Object.values(DRAFT_TITLES).includes(draft.title) ? DRAFT_TITLES[kind] : draft.title,\n })),\n clearDraftDocument: (id) => {\n if (!(id in state.draftDocuments)) return\n const rest = { ...state.draftDocuments }\n delete rest[id]\n update({ draftDocuments: rest })\n },\n leave: () =>\n update({\n viewingDocument: null,\n selectedDocumentIds: [],\n documentsToSelect: null,\n pinnedDocumentId: null,\n relatedDocuments: new Map(),\n passageCitation: NO_PASSAGE_CITATION,\n documentViewer: {\n ...state.documentViewer,\n compareId: null,\n tabRequest: null,\n commentTarget: null,\n unsavedChanges: false,\n detached: false,\n },\n }),\n reset: () =>\n update({\n ...EMPTY_DOCUMENT_STATE,\n relatedDocuments: new Map(),\n documentViewer: {\n ...DEFAULT_DOCUMENT_VIEWER_STATE,\n textScale: state.documentViewer.textScale,\n },\n }),\n }\n}\n"],
5
- "mappings": "AAiCA,MAAM,cAAwC;AAAA,EAC5C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AA+JO,MAAM,gCAAyD;AAAA,EACpE,KAAK;AAAA,EACL,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,gBAAgB;AAAA,EAChB,eAAe;AAAA,EACf,gBAAgB;AAAA,EAChB,UAAU;AACZ;AAEA,MAAM,sBAAgD;AAAA,EACpD,QAAQ;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MACL,iBAAiB;AAAA,MACjB,qBAAqB,CAAC;AAAA,MACtB,mBAAmB;AAAA,MACnB,kBAAkB;AAAA,MAClB,kBAAkB,oBAAI,IAAI;AAAA,MAC1B,iBAAiB;AAAA,MACjB,gBAAgB;AAAA,QACd,GAAG,MAAM;AAAA,QACT,WAAW;AAAA,QACX,YAAY;AAAA,QACZ,eAAe;AAAA,QACf,gBAAgB;AAAA,QAChB,UAAU;AAAA,MACZ;AAAA,IACF,CAAC;AAAA,IACH,OAAO,MACL,OAAO;AAAA,MACL,GAAG;AAAA,MACH,kBAAkB,oBAAI,IAAI;AAAA,MAC1B,gBAAgB;AAAA,QACd,GAAG;AAAA,QACH,WAAW,MAAM,eAAe;AAAA,MAClC;AAAA,IACF,CAAC;AAAA,EACL;AACF;",
4
+ "sourcesContent": ["/**\n * The documents part of the session: the document being viewed and the viewer's own state, the\n * documents selected in lists, the document pinned to the chat, the drafts the user started on the\n * client (no backend record until saved), the citation picking passages in the viewer, and the\n * documents related to each one (near duplicates).\n *\n * {@link createArbiDocumentSessionStore} keeps it in memory; given a `persist`, the place in the\n * documents (the viewed document and its page, the pinned one, the viewer's tab and text size) is\n * read back synchronously when the store is made, so a reload shows the document at once.\n */\n\nimport type { RelatedDocsMap } from '../documents/related-documents'\n\n/** The document being viewed. */\nexport interface ArbiViewingDocument {\n /** The document (`doc-\u2026`), or a version reference (`doc-\u2026@v2`) while an earlier version shows. */\n id: string\n /** The page being read, when known. */\n page: number | null\n /** The passage being read, when one is. */\n passageId: string | null\n}\n\n/** What to view: page and passage are left unchanged when omitted. */\nexport interface ArbiViewingDocumentInput {\n id: string\n page?: number | null\n passageId?: string | null\n}\n\n/** A tab of the document viewer. */\nexport type ArbiViewerTab =\n | 'pdf'\n | 'edit'\n | 'html'\n | 'docx'\n | 'xlsx'\n | 'versions'\n | 'preview'\n /** A presentation's slides, edited. */\n | 'slides'\n\nconst VIEWER_TABS: readonly ArbiViewerTab[] = [\n 'pdf',\n 'edit',\n 'html',\n 'docx',\n 'xlsx',\n 'versions',\n 'preview',\n 'slides',\n]\n\n/** A comment of a Word document to open when it shows (a notification, a link). */\nexport interface ArbiDocumentCommentTarget {\n documentId: string\n commentId: string\n}\n\n/**\n * The document viewer's own state, shared with whatever opens documents (a citation opens the text\n * view, Compare from a documents list opens the redline): the open tab, the document compared with\n * the one viewed, and a tab asked for when a document was opened (applied once it has loaded).\n */\nexport interface ArbiDocumentViewerState {\n tab: ArbiViewerTab\n /** The document (or version reference) compared with the viewed one, or null. */\n compareId: string | null\n /** A tab to show once `documentId` has loaded (a signature request opens on the PDF). */\n tabRequest: { documentId: string; tab: ArbiViewerTab } | null\n /** The text view's size, a multiplier of the normal size: a reading preference. */\n textScale: number\n /** A phone user picked the PDF by hand: documents stop opening on the text view. */\n phonePdfChosen: boolean\n /** The Word comment to open in the viewed document, or null. */\n commentTarget: ArbiDocumentCommentTarget | null\n /** The open document has edits not saved yet: closing the viewer asks first. */\n unsavedChanges: boolean\n /** The viewer shows in a window of its own (popped out). */\n detached: boolean\n /**\n * Popped out, the viewer shows only the document (no header, bars or controls): a clean view to\n * share in a call or put full screen. Applies while `detached`.\n */\n presenting: boolean\n}\n\n/** What a draft is: a text document, a capture (a voice note, a photo, a video), or a presentation. */\nexport type ArbiDraftKind = 'text' | 'audio' | 'photo' | 'video' | 'presentation'\n\n/**\n * A document the user started on the client (a blank document, a capture), with no backend record\n * until it is saved. Its id is minted here (`draft-\u2026`), never sent to the server.\n */\nexport interface ArbiDraftDocument {\n id: string\n title: string\n kind: ArbiDraftKind\n /** A text draft's Markdown. Empty for captures. */\n content: string\n /** A capture's recording or picture, once taken; null before (and after a kind switch). */\n mediaBlob: Blob | null\n createdAt: string\n}\n\n/** A passage picked for a citation: its chunk and, when known, its page. */\nexport interface ArbiPickedPassage {\n chunk_id: string\n page?: number\n}\n\n/**\n * A citation picking passages in the viewer (a fact's sources, a field's), handed between the\n * viewer and the page that edits the citation.\n */\nexport interface ArbiPassageCitationState {\n /** The citation picking now: the document it picks in and its key (null while unsaved). */\n active: { documentId: string; key: string | null } | null\n /** Passages to light (a fact's cited passages while its sources are open). */\n highlighted: readonly string[]\n /** Passages picked in the viewer, not yet taken by the citation. */\n picked: readonly ArbiPickedPassage[]\n /** Passages unpicked in the viewer, not yet taken off the citation. */\n unpicked: readonly string[]\n}\n\n/** The documents being viewed and selected. */\nexport interface ArbiDocumentSessionState {\n viewingDocument: ArbiViewingDocument | null\n documentViewer: ArbiDocumentViewerState\n /** The documents selected in document lists. */\n selectedDocumentIds: readonly string[]\n /** Documents to select in the documents list once they are listed (a thread's sources). */\n documentsToSelect: readonly string[] | null\n /** The document read in full with each turn (one at a time). */\n pinnedDocumentId: string | null\n /** The documents related to each listed one (near duplicates), from the documents list. */\n relatedDocuments: RelatedDocsMap\n /** The drafts started on the client, by id. */\n draftDocuments: Readonly<Record<string, ArbiDraftDocument>>\n passageCitation: ArbiPassageCitationState\n}\n\n/** The documents' changes (the session store has them). */\nexport interface ArbiDocumentSessionActions {\n /**\n * View a document, or none. Viewing another document resets the page; `page` and `passageId`\n * set them when given.\n */\n setViewingDocument(document: ArbiViewingDocumentInput | null): void\n /** Change the document viewer's state; fields not given stay. */\n setDocumentViewer(change: Partial<ArbiDocumentViewerState>): void\n setSelectedDocumentIds(ids: string[]): void\n /** Ask the documents list to select these once they are listed (null: done). */\n setDocumentsToSelect(ids: string[] | null): void\n setPinnedDocumentId(id: string | null): void\n setRelatedDocuments(related: RelatedDocsMap): void\n /** Change the passage citation; fields not given stay. */\n setPassageCitation(change: Partial<ArbiPassageCitationState>): void\n /** Show a document the session just got (a chat writing one), on `tab`, in the viewer. */\n showNewDocument(documentId: string, tab?: ArbiViewerTab): void\n /** Start a draft of `kind`, view it and show the viewer. Returns its id. */\n startDraftDocument(kind: ArbiDraftKind): string\n /** Change a draft's content, capture or title. */\n updateDraftDocument(\n id: string,\n change: Partial<Pick<ArbiDraftDocument, 'content' | 'mediaBlob' | 'title'>>\n ): void\n /**\n * Switch a draft's kind. The capture is dropped (it belonged to the other kind), and a default\n * title follows the kind; a title the user typed stays.\n */\n setDraftDocumentKind(id: string, kind: ArbiDraftKind): void\n /** Forget a draft (saved or discarded). */\n clearDraftDocument(id: string): void\n}\n\n/** The documents part of a session store. */\nexport interface ArbiDocumentSessionStore extends ArbiDocumentSessionActions {\n /** The current state. The same object until something in it changes. */\n getState(): ArbiDocumentSessionState\n subscribe(listener: () => void): () => void\n /** The workspace is being left: nothing is viewed, selected, pinned or picked. */\n leave(): void\n /** Start over (sign-in, sign-out): only the reading preference (the text size) stays. */\n reset(): void\n}\n\n/** What the documents part keeps across reloads. */\nexport interface ArbiSavedDocuments {\n version: 1\n viewingDocument: { id: string; page: number | null } | null\n pinnedDocumentId: string | null\n tab: ArbiViewerTab\n textScale: number\n}\n\n/**\n * Where the documents part keeps what it saves. `load` is synchronous (localStorage), so the store\n * starts from it and nothing waits; `save` may write later (the latest value wins).\n */\nexport interface ArbiDocumentsPersist {\n /** What was saved (any shape: it is checked), or null. Never throws. */\n load(): unknown\n save(saved: ArbiSavedDocuments): void\n}\n\nexport interface ArbiDocumentSessionStoreOptions {\n initial?: Partial<ArbiDocumentSessionState>\n /** Keep the place in the documents across reloads. */\n persist?: ArbiDocumentsPersist\n /** Show the viewer for a document the session just got (a new draft, a chat's document). */\n showViewer?: () => void\n}\n\nexport const DEFAULT_DOCUMENT_VIEWER_STATE: ArbiDocumentViewerState = {\n tab: 'pdf',\n compareId: null,\n tabRequest: null,\n textScale: 1,\n phonePdfChosen: false,\n commentTarget: null,\n unsavedChanges: false,\n detached: false,\n presenting: false,\n}\n\nconst NO_PASSAGE_CITATION: ArbiPassageCitationState = {\n active: null,\n highlighted: [],\n picked: [],\n unpicked: [],\n}\n\nexport const EMPTY_DOCUMENT_STATE: ArbiDocumentSessionState = {\n viewingDocument: null,\n documentViewer: DEFAULT_DOCUMENT_VIEWER_STATE,\n selectedDocumentIds: [],\n documentsToSelect: null,\n pinnedDocumentId: null,\n relatedDocuments: new Map(),\n draftDocuments: {},\n passageCitation: NO_PASSAGE_CITATION,\n}\n\n/** A draft's default title, by kind; a title still at one of these follows a kind switch. */\nconst DRAFT_TITLES: Record<ArbiDraftKind, string> = {\n text: 'New Doc',\n audio: 'New Audio',\n photo: 'New Photo',\n video: 'New Video',\n presentation: 'New Presentation',\n}\n\n/** The next viewing document, given the current one (shared by every store implementation). */\nexport function nextViewingDocument(\n current: ArbiViewingDocument | null,\n input: ArbiViewingDocumentInput | null\n): ArbiViewingDocument | null {\n if (!input) return null\n const same = current?.id === input.id\n return {\n id: input.id,\n page: input.page !== undefined ? input.page : same ? (current?.page ?? null) : null,\n passageId: input.passageId !== undefined ? input.passageId : (current?.passageId ?? null),\n }\n}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value)\nconst isPage = (value: unknown): value is number =>\n typeof value === 'number' && Number.isInteger(value) && value >= 1\n\n/**\n * Read a saved place in the documents. Each field is checked on its own: an unreadable one keeps\n * its default. Null when there is nothing readable at all.\n */\nexport function parseSavedDocuments(saved: unknown): ArbiSavedDocuments | null {\n if (!isRecord(saved) || saved.version !== 1) return null\n const viewing = isRecord(saved.viewingDocument) ? saved.viewingDocument : null\n return {\n version: 1,\n viewingDocument:\n viewing && typeof viewing.id === 'string' && viewing.id\n ? { id: viewing.id, page: isPage(viewing.page) ? viewing.page : null }\n : null,\n pinnedDocumentId: typeof saved.pinnedDocumentId === 'string' ? saved.pinnedDocumentId : null,\n tab: VIEWER_TABS.includes(saved.tab as ArbiViewerTab)\n ? (saved.tab as ArbiViewerTab)\n : DEFAULT_DOCUMENT_VIEWER_STATE.tab,\n textScale:\n typeof saved.textScale === 'number' && Number.isFinite(saved.textScale) && saved.textScale > 0\n ? saved.textScale\n : DEFAULT_DOCUMENT_VIEWER_STATE.textScale,\n }\n}\n\n/** What of `state` is kept across reloads. */\nexport function savedDocumentsOf(state: ArbiDocumentSessionState): ArbiSavedDocuments {\n return {\n version: 1,\n viewingDocument: state.viewingDocument\n ? { id: state.viewingDocument.id, page: state.viewingDocument.page }\n : null,\n pinnedDocumentId: state.pinnedDocumentId,\n tab: state.documentViewer.tab,\n textScale: state.documentViewer.textScale,\n }\n}\n\n/** The state a saved place puts back (over `base`). */\nexport function restoreSavedDocuments(\n base: ArbiDocumentSessionState,\n saved: ArbiSavedDocuments\n): ArbiDocumentSessionState {\n return {\n ...base,\n viewingDocument: saved.viewingDocument\n ? { id: saved.viewingDocument.id, page: saved.viewingDocument.page, passageId: null }\n : null,\n pinnedDocumentId: saved.pinnedDocumentId,\n documentViewer: { ...base.documentViewer, tab: saved.tab, textScale: saved.textScale },\n }\n}\n\n/** The documents part, in memory (and, given a `persist`, kept across reloads). */\nexport function createArbiDocumentSessionStore({\n initial = {},\n persist,\n showViewer,\n}: ArbiDocumentSessionStoreOptions = {}): ArbiDocumentSessionStore {\n let state: ArbiDocumentSessionState = { ...EMPTY_DOCUMENT_STATE, ...initial }\n if (persist) {\n const saved = parseSavedDocuments(persist.load())\n if (saved) state = restoreSavedDocuments(state, saved)\n }\n const listeners = new Set<() => void>()\n const update = (patch: Partial<ArbiDocumentSessionState>) => {\n const previous = state\n state = { ...state, ...patch }\n if (\n persist &&\n (state.viewingDocument !== previous.viewingDocument ||\n state.pinnedDocumentId !== previous.pinnedDocumentId ||\n state.documentViewer.tab !== previous.documentViewer.tab ||\n state.documentViewer.textScale !== previous.documentViewer.textScale)\n )\n persist.save(savedDocumentsOf(state))\n listeners.forEach((listener) => listener())\n }\n const setDocumentViewer = (change: Partial<ArbiDocumentViewerState>) => {\n const next = { ...state.documentViewer, ...change }\n const keys = Object.keys(change) as (keyof ArbiDocumentViewerState)[]\n if (keys.some((key) => next[key] !== state.documentViewer[key]))\n update({ documentViewer: next })\n }\n const updateDraft = (id: string, change: (draft: ArbiDraftDocument) => ArbiDraftDocument) => {\n const draft = state.draftDocuments[id]\n if (draft) update({ draftDocuments: { ...state.draftDocuments, [id]: change(draft) } })\n }\n return {\n getState: () => state,\n subscribe: (listener) => {\n listeners.add(listener)\n return () => listeners.delete(listener)\n },\n setViewingDocument: (input) =>\n update({ viewingDocument: nextViewingDocument(state.viewingDocument, input) }),\n setDocumentViewer,\n setSelectedDocumentIds: (ids) => update({ selectedDocumentIds: ids }),\n setDocumentsToSelect: (ids) => update({ documentsToSelect: ids }),\n setPinnedDocumentId: (pinnedDocumentId) => update({ pinnedDocumentId }),\n setRelatedDocuments: (relatedDocuments) => update({ relatedDocuments }),\n setPassageCitation: (change) =>\n update({ passageCitation: { ...state.passageCitation, ...change } }),\n showNewDocument: (documentId, tab) => {\n update({\n viewingDocument: { id: documentId, page: null, passageId: null },\n documentViewer: tab ? { ...state.documentViewer, tab } : state.documentViewer,\n })\n showViewer?.()\n },\n startDraftDocument: (kind) => {\n const id = `draft-${crypto.randomUUID()}`\n const draft: ArbiDraftDocument = {\n id,\n title: DRAFT_TITLES[kind],\n kind,\n content: '',\n mediaBlob: null,\n createdAt: new Date().toISOString(),\n }\n update({\n draftDocuments: { ...state.draftDocuments, [id]: draft },\n viewingDocument: { id, page: null, passageId: null },\n // A text draft is written in the editor; a capture's recorder replaces the tabs.\n documentViewer:\n kind === 'text'\n ? { ...state.documentViewer, tab: 'edit' }\n : kind === 'presentation'\n ? { ...state.documentViewer, tab: 'slides' }\n : state.documentViewer,\n })\n showViewer?.()\n return id\n },\n updateDraftDocument: (id, change) => updateDraft(id, (draft) => ({ ...draft, ...change })),\n setDraftDocumentKind: (id, kind) =>\n updateDraft(id, (draft) => ({\n ...draft,\n kind,\n mediaBlob: null,\n title: Object.values(DRAFT_TITLES).includes(draft.title) ? DRAFT_TITLES[kind] : draft.title,\n })),\n clearDraftDocument: (id) => {\n if (!(id in state.draftDocuments)) return\n const rest = { ...state.draftDocuments }\n delete rest[id]\n update({ draftDocuments: rest })\n },\n leave: () =>\n update({\n viewingDocument: null,\n selectedDocumentIds: [],\n documentsToSelect: null,\n pinnedDocumentId: null,\n relatedDocuments: new Map(),\n passageCitation: NO_PASSAGE_CITATION,\n documentViewer: {\n ...state.documentViewer,\n compareId: null,\n tabRequest: null,\n commentTarget: null,\n unsavedChanges: false,\n detached: false,\n presenting: false,\n },\n }),\n reset: () =>\n update({\n ...EMPTY_DOCUMENT_STATE,\n relatedDocuments: new Map(),\n documentViewer: {\n ...DEFAULT_DOCUMENT_VIEWER_STATE,\n textScale: state.documentViewer.textScale,\n },\n }),\n }\n}\n"],
5
+ "mappings": "AA0CA,MAAM,cAAwC;AAAA,EAC5C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAoKO,MAAM,gCAAyD;AAAA,EACpE,KAAK;AAAA,EACL,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,gBAAgB;AAAA,EAChB,eAAe;AAAA,EACf,gBAAgB;AAAA,EAChB,UAAU;AAAA,EACV,YAAY;AACd;AAEA,MAAM,sBAAgD;AAAA,EACpD,QAAQ;AAAA,EACR,aAAa,CAAC;AAAA,EACd,QAAQ,CAAC;AAAA,EACT,UAAU,CAAC;AACb;AAEO,MAAM,uBAAiD;AAAA,EAC5D,iBAAiB;AAAA,EACjB,gBAAgB;AAAA,EAChB,qBAAqB,CAAC;AAAA,EACtB,mBAAmB;AAAA,EACnB,kBAAkB;AAAA,EAClB,kBAAkB,oBAAI,IAAI;AAAA,EAC1B,gBAAgB,CAAC;AAAA,EACjB,iBAAiB;AACnB;AAGA,MAAM,eAA8C;AAAA,EAClD,MAAM;AAAA,EACN,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,cAAc;AAChB;AAGO,SAAS,oBACd,SACA,OAC4B;AAC5B,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,OAAO,SAAS,OAAO,MAAM;AACnC,SAAO;AAAA,IACL,IAAI,MAAM;AAAA,IACV,MAAM,MAAM,SAAS,SAAY,MAAM,OAAO,OAAQ,SAAS,QAAQ,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