@arbidocs/react 0.5.120 → 0.5.122

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 (100) 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/ai/MessageArtifactCard.js +9 -1
  5. package/dist/ai/MessageArtifactCard.js.map +2 -2
  6. package/dist/annotations/freeze/index.d.ts +1 -1
  7. package/dist/artifacts/artifact-kind.js +1 -0
  8. package/dist/artifacts/artifact-kind.js.map +2 -2
  9. package/dist/artifacts/index.cjs +3 -2
  10. package/dist/artifacts/index.cjs.map +1 -1
  11. package/dist/artifacts/index.d.ts +3 -2
  12. package/dist/calls/livekit/index.cjs +51 -51
  13. package/dist/chat/chat-artifacts.js +0 -1
  14. package/dist/chat/chat-artifacts.js.map +2 -2
  15. package/dist/chat/open-document.js +3 -1
  16. package/dist/chat/open-document.js.map +2 -2
  17. package/dist/chat/turn-flush.js +16 -0
  18. package/dist/chat/turn-flush.js.map +7 -0
  19. package/dist/chat/useConversationActions.js +3 -0
  20. package/dist/chat/useConversationActions.js.map +2 -2
  21. package/dist/{chunk-QP3WQSAA.cjs → chunk-4B2GW3AY.cjs} +3 -3
  22. package/dist/{chunk-QP3WQSAA.cjs.map → chunk-4B2GW3AY.cjs.map} +1 -1
  23. package/dist/{chunk-YMB6XUR2.cjs → chunk-7L7QRIQ2.cjs} +11 -7
  24. package/dist/chunk-7L7QRIQ2.cjs.map +1 -0
  25. package/dist/{chunk-KDYYAZXP.cjs → chunk-DLEHM4IA.cjs} +227 -155
  26. package/dist/chunk-DLEHM4IA.cjs.map +1 -0
  27. package/dist/{chunk-5TRUFWKT.cjs → chunk-FAJLJDWS.cjs} +12 -12
  28. package/dist/{chunk-5TRUFWKT.cjs.map → chunk-FAJLJDWS.cjs.map} +1 -1
  29. package/dist/{PdfViewerImpl-QUSDLNNM.cjs → chunk-ICBT2XGF.cjs} +5 -2
  30. package/dist/chunk-ICBT2XGF.cjs.map +1 -0
  31. package/dist/{chunk-RLSBRZ6Z.cjs → chunk-IX4HOS5Z.cjs} +2 -3
  32. package/dist/chunk-IX4HOS5Z.cjs.map +1 -0
  33. package/dist/{chunk-AJRYZ3IC.cjs → chunk-K6ELFSG6.cjs} +3 -3
  34. package/dist/{chunk-AJRYZ3IC.cjs.map → chunk-K6ELFSG6.cjs.map} +1 -1
  35. package/dist/chunk-MAOGK7IC.cjs +61 -0
  36. package/dist/chunk-MAOGK7IC.cjs.map +1 -0
  37. package/dist/{chunk-C72FSQUE.cjs → chunk-WUYSVTKE.cjs} +14 -12
  38. package/dist/chunk-WUYSVTKE.cjs.map +1 -0
  39. package/dist/datasets/sources/documents.js +1 -1
  40. package/dist/datasets/sources/documents.js.map +2 -2
  41. package/dist/document-tools/core.cjs +80 -80
  42. package/dist/document-tools/images-to-pdf.js +43 -0
  43. package/dist/document-tools/images-to-pdf.js.map +7 -0
  44. package/dist/document-tools/index.cjs +184 -80
  45. package/dist/document-tools/index.cjs.map +1 -1
  46. package/dist/document-tools/index.d.ts +41 -1
  47. package/dist/document-tools/index.js +6 -1
  48. package/dist/document-tools/index.js.map +2 -2
  49. package/dist/document-tools/pdf-attachments.js +63 -0
  50. package/dist/document-tools/pdf-attachments.js.map +7 -0
  51. package/dist/entities/DocumentEntity.js +7 -2
  52. package/dist/entities/DocumentEntity.js.map +2 -2
  53. package/dist/entities/file-type.js +14 -2
  54. package/dist/entities/file-type.js.map +2 -2
  55. package/dist/entities/index.js +9 -1
  56. package/dist/entities/index.js.map +2 -2
  57. package/dist/icons/PresIcon.js +53 -0
  58. package/dist/icons/PresIcon.js.map +7 -0
  59. package/dist/icons/colors.js +2 -0
  60. package/dist/icons/colors.js.map +2 -2
  61. package/dist/icons/file-type.js +3 -0
  62. package/dist/icons/file-type.js.map +2 -2
  63. package/dist/icons/index.js +2 -0
  64. package/dist/icons/index.js.map +2 -2
  65. package/dist/index.cjs +964 -919
  66. package/dist/index.cjs.map +1 -1
  67. package/dist/{index.d-DYlUprG9.d.ts → index.d-D2puqWeN.d.ts} +17 -3
  68. package/dist/{index.d-oR5FKZpJ.d.ts → index.d-KbsNPTEN.d.ts} +7 -5
  69. package/dist/index.d.ts +46 -12
  70. package/dist/index.js +1 -0
  71. package/dist/index.js.map +2 -2
  72. package/dist/pdf-region-impl-ZG5G2OX2.cjs +98 -0
  73. package/dist/pdf-region-impl-ZG5G2OX2.cjs.map +1 -0
  74. package/dist/session/documents.js +9 -5
  75. package/dist/session/documents.js.map +2 -2
  76. package/dist/shell/index.cjs +54 -50
  77. package/dist/shell/index.d.ts +1 -1
  78. package/dist/ui/index.cjs +182 -170
  79. package/dist/ui/index.d.ts +1 -1
  80. package/dist/ui/slider.js +7 -1
  81. package/dist/ui/slider.js.map +2 -2
  82. package/dist/viewers/PdfViewer.cjs +3 -3
  83. package/dist/viewers/PdfViewer.d.ts +2 -2
  84. package/dist/viewers/PdfViewerImpl.js +4 -1
  85. package/dist/viewers/PdfViewerImpl.js.map +2 -2
  86. package/dist/viewers/index.cjs +28 -3
  87. package/dist/viewers/index.cjs.map +1 -1
  88. package/dist/viewers/index.d.ts +68 -2
  89. package/dist/viewers/index.js +14 -0
  90. package/dist/viewers/index.js.map +2 -2
  91. package/dist/viewers/pdf-region-impl.js +96 -0
  92. package/dist/viewers/pdf-region-impl.js.map +7 -0
  93. package/dist/viewers/pdf-region.js +57 -0
  94. package/dist/viewers/pdf-region.js.map +7 -0
  95. package/package.json +3 -3
  96. package/dist/PdfViewerImpl-QUSDLNNM.cjs.map +0 -1
  97. package/dist/chunk-C72FSQUE.cjs.map +0 -1
  98. package/dist/chunk-KDYYAZXP.cjs.map +0 -1
  99. package/dist/chunk-RLSBRZ6Z.cjs.map +0 -1
  100. package/dist/chunk-YMB6XUR2.cjs.map +0 -1
@@ -266,6 +266,7 @@ function PdfViewer({
266
266
  style: { touchAction: "pan-x pan-y", scrollbarGutter: "stable" },
267
267
  role: "region",
268
268
  "aria-label": "PDF document viewer",
269
+ "data-slot": "pdf-scroller",
269
270
  "data-testid": "pdf-viewer",
270
271
  children: /* @__PURE__ */ jsxRuntime.jsx(
271
272
  reactPdf.Document,
@@ -375,6 +376,8 @@ function PdfViewer({
375
376
  );
376
377
  }
377
378
 
379
+ exports.DEFAULT_ASSETS = DEFAULT_ASSETS;
378
380
  exports.PdfViewer = PdfViewer;
379
- //# sourceMappingURL=PdfViewerImpl-QUSDLNNM.cjs.map
380
- //# sourceMappingURL=PdfViewerImpl-QUSDLNNM.cjs.map
381
+ exports.ensurePdfWorker = ensurePdfWorker;
382
+ //# sourceMappingURL=chunk-ICBT2XGF.cjs.map
383
+ //# sourceMappingURL=chunk-ICBT2XGF.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/viewers/PdfViewerImpl.tsx"],"names":["installPdfjsPolyfills","pdfjs","useState","INITIAL_LAZY_LOAD_BUFFER","useMemo","useEffect","useRef","useCallback","LAZY_LOAD_BUFFER_BEFORE","LAZY_LOAD_BUFFER_AFTER","handle","fitPageWidth","contentBoxWidth","currentPage","usePageIntersectionObserver","useScrollAnchor","usePinchZoom","jsx","Document","jsxs","Fragment","Page","ratio","renderDpr"],"mappings":";;;;;;;;;;AAiDO,IAAM,cAAA,GAA4C;AAAA,EACvD,SAAA,EAAW,qBAAA;AAAA,EACX,OAAA,EAAS,SAAA;AAAA,EACT,mBAAA,EAAqB,kBAAA;AAAA,EACrB,OAAA,EAAS;AACX;AAMO,SAAS,gBAAgB,SAAA,EAAmB;AACjD,EAAAA,uCAAA,EAAsB;AACtB,EAAA,IAAIC,cAAA,CAAM,mBAAA,CAAoB,SAAA,KAAc,SAAA,EAAW;AACrD,IAAAA,cAAA,CAAM,oBAAoB,SAAA,GAAY,SAAA;AAAA,EACxC;AACF;AAM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AAEJ","file":"chunk-ICBT2XGF.cjs","sourcesContent":["/**\n * PdfViewer — paged PDF rendering with bidirectional page synchronisation.\n *\n * Uses IntersectionObserver to track the visible page and to drive two separate\n * lazy-load windows: a wide canvas buffer (so a page image is ready before the\n * user scrolls to it) and a narrow text-layer window (text spans are expensive\n * DOM, so they only exist for the active reading area).\n *\n * DECOUPLED FOR REUSE: page changes are reported through `onPageChange` rather\n * than written to an app store, and the pdf.js asset URLs are props rather than\n * hardcoded paths, because a consuming app decides where it serves the worker,\n * cmaps and standard fonts from.\n *\n * `react-pdf` and `pdfjs-dist` are OPTIONAL peer dependencies — install them\n * only if you render PDFs. The consuming app must also serve the pdf.js worker\n * (see `assets.workerSrc`).\n */\n\nimport { useState, useEffect, useRef, useCallback, useMemo, type ReactNode } from 'react'\nimport { Document, Page, pdfjs } from 'react-pdf'\nimport 'react-pdf/dist/Page/AnnotationLayer.css'\nimport 'react-pdf/dist/Page/TextLayer.css'\nimport { installPdfjsPolyfills } from './pdfjs-polyfills'\nimport { usePageIntersectionObserver } from './usePageIntersectionObserver'\nimport { useScrollAnchor } from './page-scroll'\nimport { contentBoxWidth, fitPageWidth, renderDpr, usePinchZoom } from './viewer-zoom'\nimport {\n LAZY_LOAD_BUFFER_BEFORE,\n LAZY_LOAD_BUFFER_AFTER,\n INITIAL_LAZY_LOAD_BUFFER,\n} from './pdf-viewer-constants'\n\n/** Where the app serves the pdf.js runtime assets from. */\nexport interface PdfViewerAssets {\n /** pdf.js worker bundle. Default `/pdf.worker.min.mjs`. */\n workerSrc?: string\n /** Directory of pdf.js character maps. Default `/cmaps/`. */\n cMapUrl?: string\n /** Directory of pdf.js standard font data. Default `/standard_fonts/`. */\n standardFontDataUrl?: string\n /**\n * Directory of the pdf.js wasm decoders (openjpeg for JPEG 2000, jbig2,\n * qcms). Scanned PDFs routinely embed JPX/JBIG2-compressed page images;\n * without these modules pdf.js fails image decoding with only a console\n * warning and renders blank white pages. Default `/wasm/`.\n */\n wasmUrl?: string\n}\n\nexport const DEFAULT_ASSETS: Required<PdfViewerAssets> = {\n workerSrc: '/pdf.worker.min.mjs',\n cMapUrl: '/cmaps/',\n standardFontDataUrl: '/standard_fonts/',\n wasmUrl: '/wasm/',\n}\n\n/**\n * Ready pdf.js before any Document mounts: the built-ins it needs on this thread (older browsers\n * lack them and every page render would throw), and the worker, re-set only if it changed.\n */\nexport function ensurePdfWorker(workerSrc: string) {\n installPdfjsPolyfills()\n if (pdfjs.GlobalWorkerOptions.workerSrc !== workerSrc) {\n pdfjs.GlobalWorkerOptions.workerSrc = workerSrc\n }\n}\n\n// Page rendering constants\n// Height / width used for a page until its real size is known (the first page is read as soon as\n// the document opens, every other page as it renders). A placeholder that differs from the real\n// page shifts everything below it when the page renders.\nconst DEFAULT_PAGE_ASPECT_RATIO = 1.414 // A4 (√2)\n/** The page wrapper's own border (border, top + bottom), included in its fixed height. */\nconst PAGE_BORDER_PX = 2\n/** Wait for the zoom to settle before re-rasterising every visible page. */\nconst RERENDER_DEBOUNCE_MS = 250\n/** Above this zoom a page canvas is large enough that the render window shrinks. */\nconst ZOOMED_BUFFER_THRESHOLD = 1.5\n\n/** Same set contents: lets a state setter bail out instead of re-rendering on every scroll tick. */\nfunction sameSet(a: ReadonlySet<number>, b: ReadonlySet<number>): boolean {\n if (a.size !== b.size) return false\n for (const v of a) if (!b.has(v)) return false\n return true\n}\n\n// Text layer is enabled for pages within 1 page of the visible set — enough for smooth\n// scrolling while keeping DOM node count low on large documents.\nconst TEXT_LAYER_BUFFER = 1\n\ninterface PdfPageSize {\n getViewport: (options: { scale: number }) => { width: number; height: number }\n}\nconst ratioOf = (page: PdfPageSize): number => {\n const { width, height } = page.getViewport({ scale: 1 })\n return width > 0 && height > 0 ? height / width : DEFAULT_PAGE_ASPECT_RATIO\n}\n\nexport interface PdfViewerProps {\n file: string | Blob\n currentPage?: number\n onLoadSuccess?: (numPages: number) => void\n /** Incremented to trigger scroll to currentPage */\n scrollTrigger?: number\n /** Zoom as a multiplier of the fit-width size (1 = fit width). Default 1. */\n zoom?: number\n /** Called by pinch and double-tap; the host owns the value (its buttons change it too). */\n onZoomChange?: (zoom: number) => void\n /**\n * Called as the user scrolls, with the page occupying most of the viewport.\n * This is the reusable form of the monolith's `setViewingDocumentPage`.\n */\n onPageChange?: (pageNumber: number) => void\n /**\n * Force pdf.js to rasterise fonts onto the canvas instead of using @font-face.\n * Required when rendering into a different document (e.g. a popped-out window),\n * where @font-face rules from the opener do not apply.\n */\n disableFontFace?: boolean\n /** Where the app serves the pdf.js worker, cmaps and standard fonts from. */\n assets?: PdfViewerAssets\n /**\n * Content drawn over every page, inside its border box (e.g. the annotation layer). It fills the\n * page area and moves and scales with it. `pageWidthPt` is the page's width in PDF points once\n * known, so overlays can size strokes and text to match what a later export draws.\n */\n renderPageOverlay?: (page: { pageNumber: number; pageWidthPt: number | undefined }) => ReactNode\n}\n\nexport function PdfViewer({\n file,\n currentPage,\n onLoadSuccess,\n scrollTrigger,\n zoom = 1,\n onZoomChange,\n onPageChange,\n disableFontFace = false,\n assets,\n renderPageOverlay,\n}: PdfViewerProps) {\n const workerSrc = assets?.workerSrc ?? DEFAULT_ASSETS.workerSrc\n const cMapUrl = assets?.cMapUrl ?? DEFAULT_ASSETS.cMapUrl\n const standardFontDataUrl = assets?.standardFontDataUrl ?? DEFAULT_ASSETS.standardFontDataUrl\n const wasmUrl = assets?.wasmUrl ?? DEFAULT_ASSETS.wasmUrl\n\n // Ensure the pdf.js worker is configured before any Document mounts\n ensurePdfWorker(workerSrc)\n\n const [numPages, setNumPages] = useState<number>(0)\n const [containerWidth, setContainerWidth] = useState<number>(0)\n // Real height/width of the document's pages: the first page's, then each page as it loads.\n const [defaultRatio, setDefaultRatio] = useState<number>(DEFAULT_PAGE_ASPECT_RATIO)\n const [pageRatios, setPageRatios] = useState<ReadonlyMap<number, number>>(new Map())\n // Each page's width in PDF points, for overlays that must size strokes and text like an export.\n const [pageWidthsPt, setPageWidthsPt] = useState<ReadonlyMap<number, number>>(new Map())\n const [loadError, setLoadError] = useState<Error | null>(null)\n const [documentKey, setDocumentKey] = useState<string>(() => `pdf-${Date.now()}`)\n\n // Initialize with pages around the current page (or first 3 pages if no current page).\n // Start with a small initial buffer so the first paint is cheap; expand to the full\n // buffer lazily via requestIdleCallback after the first render settles.\n const initialPage = currentPage || 1\n const [renderedPages, setRenderedPages] = useState<Set<number>>(\n new Set([\n Math.max(1, initialPage - INITIAL_LAZY_LOAD_BUFFER.before),\n initialPage,\n initialPage + INITIAL_LAZY_LOAD_BUFFER.after,\n ])\n )\n\n // Pages currently in/near the viewport — used to gate the text layer.\n // Keeping this separate from renderedPages lets the canvas still render on buffer pages\n // while text DOM nodes are only created for the user's active reading area.\n const [visiblePages, setVisiblePages] = useState<Set<number>>(new Set([initialPage]))\n\n // A late PDF.js completion belongs only to the file that started it.\n const loadLifetime = useMemo(() => ({ file, active: true }), [file])\n useEffect(() => {\n loadLifetime.active = true\n return () => {\n loadLifetime.active = false\n }\n }, [loadLifetime])\n\n // Reset document key when file changes to force remount\n useEffect(() => {\n setDocumentKey(`pdf-${Date.now()}`)\n setNumPages(0)\n setLoadError(null)\n }, [file])\n\n const containerRef = useRef<HTMLDivElement>(null)\n const pageRefs = useRef<Map<number, HTMLDivElement>>(new Map())\n\n // Handle document load success\n const onDocumentLoadSuccess = useCallback(\n (pdf: { numPages: number; getPage?: (n: number) => Promise<PdfPageSize> }) => {\n if (!loadLifetime.active) return\n const n = pdf.numPages\n void pdf\n .getPage?.(1)\n .then((page) => {\n if (loadLifetime.active) setDefaultRatio(ratioOf(page))\n })\n .catch(() => {})\n setNumPages(n)\n setLoadError(null) // Clear any previous errors\n\n try {\n onLoadSuccess?.(n)\n } catch (error) {\n console.error('Error in onLoadSuccess callback:', error)\n }\n },\n [onLoadSuccess, loadLifetime]\n )\n\n // Expand only while this file is mounted. Cancellation also guards callbacks\n // that were already queued when the idle/timer handle was cancelled.\n useEffect(() => {\n if (numPages === 0) return\n let cancelled = false\n const expand = () => {\n if (cancelled || !loadLifetime.active) return\n setRenderedPages((prev) => {\n if (prev.size === 0) return prev\n const newSet = new Set(prev)\n const anchor = currentPage || 1\n for (\n let i = Math.max(1, anchor - LAZY_LOAD_BUFFER_BEFORE);\n i <= Math.min(numPages, anchor + LAZY_LOAD_BUFFER_AFTER);\n i++\n ) {\n newSet.add(i)\n }\n return newSet\n })\n }\n if (typeof requestIdleCallback !== 'undefined') {\n const handle = requestIdleCallback(expand, { timeout: 500 })\n return () => {\n cancelled = true\n if (typeof cancelIdleCallback !== 'undefined') cancelIdleCallback(handle)\n }\n }\n const handle = setTimeout(expand, 500)\n return () => {\n cancelled = true\n clearTimeout(handle)\n }\n }, [numPages, currentPage, loadLifetime])\n\n // Handle document load error\n const onDocumentLoadError = useCallback((error: Error) => {\n console.error('PDF loading error:', error)\n setLoadError(error)\n setNumPages(0)\n }, [])\n\n // react-pdf calls this when the PDF is encrypted (reason === 1) or the\n // supplied password was wrong (reason === 2). Default behaviour is a\n // window.prompt() that, when cancelled, never resolves the password\n // callback — pdf.js then leaves the document load Promise pending forever\n // and the viewer is stuck on \"Loading PDF...\".\n //\n // Always call updatePassword exactly once. On cancel we surface a\n // synthetic load error so onLoadError → setLoadError fires the standard\n // error UI instead of the indefinite spinner.\n const onPassword = useCallback((updatePassword: (password: string) => void, reason: number) => {\n const message =\n reason === 2\n ? 'Incorrect password. Enter the password to unlock this PDF:'\n : 'This PDF is password-protected. Enter the password to view it:'\n const password = window.prompt(message)\n if (password === null) {\n // Cancelled. Synthesise a load error so the error UI takes over.\n setLoadError(new Error('Password required to open this PDF'))\n setNumPages(0)\n return\n }\n updatePassword(password)\n }, [])\n\n // Fit width: the scroller's content box (inside its padding AND its vertical scrollbar) less the\n // page's own border. `offsetWidth` would count the scrollbar and overflow sideways by its width.\n useEffect(() => {\n const container = containerRef.current\n if (!container) return\n const setFromContentWidth = (contentWidth: number) =>\n setContainerWidth(fitPageWidth(contentWidth, PAGE_BORDER_PX))\n\n setFromContentWidth(contentBoxWidth(container))\n\n // Re-measure on any change of the content box: a panel resize, or the vertical scrollbar\n // appearing once the pages are taller than the scroller.\n const resizeObserver = new ResizeObserver((entries) => {\n const entry = entries[entries.length - 1]\n const box = entry?.contentBoxSize?.[0]\n setFromContentWidth(box ? box.inlineSize : (entry?.contentRect.width ?? 0))\n })\n resizeObserver.observe(container)\n\n return () => {\n resizeObserver.disconnect()\n }\n }, [])\n\n // Track whether initial scroll has completed to prevent feedback loop\n const scrollCompleteRef = useRef(false)\n\n // Scroll to page ONLY when PDF loads - not when page number updates from scrolling\n useEffect(() => {\n if (numPages === 0) return\n\n // If we already scrolled, don't scroll again\n if (scrollCompleteRef.current) return\n\n // Ensure the target page and surrounding pages are rendered\n if (currentPage) {\n setRenderedPages((prev) => {\n const newSet = new Set(prev)\n for (\n let i = Math.max(1, currentPage - LAZY_LOAD_BUFFER_BEFORE);\n i <= Math.min(numPages, currentPage + LAZY_LOAD_BUFFER_AFTER);\n i++\n ) {\n newSet.add(i)\n }\n return newSet\n })\n\n // Wait for DOM update, then scroll\n requestAnimationFrame(() => {\n const pageElement = pageRefs.current.get(currentPage)\n if (pageElement) {\n pageElement.scrollIntoView({ behavior: 'auto', block: 'start' })\n }\n // Wait for scroll to complete before allowing page number updates\n setTimeout(() => {\n scrollCompleteRef.current = true\n }, 100)\n })\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [numPages]) // Note: currentPage is intentionally NOT a dependency to prevent feedback loop\n\n // The page the last explicit request (overlay arrows, typed number) asked for. Read when the\n // trigger fires; scrolling itself changes `currentPage` and must NOT re-run the scroll below,\n // or every page the user scrolls past would pull the view back to that page's top.\n const currentPageRef = useRef(currentPage)\n currentPageRef.current = currentPage\n\n // Scroll to page when scrollTrigger changes (user entered a page number)\n useEffect(() => {\n const currentPage = currentPageRef.current\n if (!scrollTrigger || numPages === 0 || !currentPage) return\n\n // Temporarily disable observer updates during manual scroll\n scrollCompleteRef.current = false\n\n // Ensure the target page and surrounding pages are rendered\n setRenderedPages((prev) => {\n const newSet = new Set(prev)\n for (\n let i = Math.max(1, currentPage - LAZY_LOAD_BUFFER_BEFORE);\n i <= Math.min(numPages, currentPage + LAZY_LOAD_BUFFER_AFTER);\n i++\n ) {\n newSet.add(i)\n }\n return newSet\n })\n\n // Double-rAF: first frame lets React commit the setRenderedPages update so\n // pages before the target are in the DOM at their correct heights; second\n // frame scrolls after layout has settled. Instant scroll avoids a race\n // where smooth-scroll animation is still running when the observer\n // re-enables and reports the wrong page.\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n const pageElement = pageRefs.current.get(currentPage)\n if (pageElement) {\n pageElement.scrollIntoView({ behavior: 'instant', block: 'start' })\n }\n scrollCompleteRef.current = true\n })\n })\n }, [scrollTrigger, numPages])\n\n // Handle lazy loading based on visible pages\n const handleVisibilityUpdate = useCallback(\n (visibilityMap: Map<number, number>) => {\n const visiblePageNums = Array.from(visibilityMap.entries())\n .filter(([, ratio]) => ratio > 0)\n .map(([pageNum]) => pageNum)\n\n if (visiblePageNums.length > 0) {\n const minVisible = Math.min(...visiblePageNums)\n const maxVisible = Math.max(...visiblePageNums)\n\n // Update canvas render buffer (wider window for smooth pre-loading). Zoomed pages are\n // big canvases: keep fewer of them alive so far pages release their memory.\n const zoomed = zoom > ZOOMED_BUFFER_THRESHOLD\n const before = zoomed ? 1 : LAZY_LOAD_BUFFER_BEFORE\n const after = zoomed ? 2 : LAZY_LOAD_BUFFER_AFTER\n const pagesToRender = new Set<number>()\n for (\n let i = Math.max(1, minVisible - before);\n i <= Math.min(numPages, maxVisible + after);\n i++\n ) {\n pagesToRender.add(i)\n }\n setRenderedPages((prev) => (sameSet(prev, pagesToRender) ? prev : pagesToRender))\n\n // Update text-layer set (narrow window — text layer is expensive DOM)\n const nearViewport = new Set<number>()\n for (\n let i = Math.max(1, minVisible - TEXT_LAYER_BUFFER);\n i <= Math.min(numPages, maxVisible + TEXT_LAYER_BUFFER);\n i++\n ) {\n nearViewport.add(i)\n }\n setVisiblePages((prev) => (sameSet(prev, nearViewport) ? prev : nearViewport))\n }\n },\n [numPages, zoom]\n )\n\n // Memoize options to prevent unnecessary Document reloads.\n // When the options object changes reference, react-pdf reloads the document,\n // which fails if the source Blob's ArrayBuffer was already transferred to the worker.\n const documentOptions = useMemo(\n () => ({\n standardFontDataUrl,\n cMapUrl,\n cMapPacked: true,\n wasmUrl,\n ...(disableFontFace && { disableFontFace: true }),\n }),\n [standardFontDataUrl, cMapUrl, wasmUrl, disableFontFace]\n )\n\n // Observer callback is optional for consumers that don't track the page.\n const handlePageChange = useCallback(\n (pageNumber: number) => onPageChange?.(pageNumber),\n [onPageChange]\n )\n\n // Use IntersectionObserver to track visible pages and update page number\n usePageIntersectionObserver({\n containerRef,\n scrollCompleteRef,\n isEnabled: numPages > 0,\n getPageElements: () => Array.from(pageRefs.current.values()),\n getPageNumber: (element) => parseInt(element.getAttribute('data-page-number') ?? '0'),\n onPageChange: handlePageChange,\n onVisibilityUpdate: handleVisibilityUpdate,\n observeKey: `${numPages}:${containerWidth > 0}`,\n })\n\n // Pages above the reading position change height as they load their real size.\n useScrollAnchor(containerRef, `${numPages}:${containerWidth > 0}`)\n\n // Pinch / double-tap, and the focal point kept still for every zoom change.\n usePinchZoom({ containerRef, zoom, onZoomChange })\n\n // Layout follows `zoom` at once (a CSS scale of the already rendered canvas, so the gesture is\n // smooth); the canvases are re-rendered at the new resolution once the zoom has settled. Without\n // this the bitmap is only magnified and stays blurry.\n const [renderZoom, setRenderZoom] = useState(zoom)\n useEffect(() => {\n if (zoom === renderZoom) return\n const timer = setTimeout(() => setRenderZoom(zoom), RERENDER_DEBOUNCE_MS)\n return () => clearTimeout(timer)\n }, [zoom, renderZoom])\n\n return (\n <div\n ref={containerRef}\n className=\"w-full h-full overflow-auto bg-muted flex flex-col items-start p-4 pb-20\"\n // Two-finger gestures belong to the viewer (real zoom), not to the browser (bitmap zoom).\n // The scrollbar's gutter is always reserved, so the fit width does not change (and every page\n // re-rasterise) when the scrollbar appears, and cannot flip back and forth at the threshold.\n style={{ touchAction: 'pan-x pan-y', scrollbarGutter: 'stable' }}\n role=\"region\"\n aria-label=\"PDF document viewer\"\n data-slot=\"pdf-scroller\"\n data-testid=\"pdf-viewer\"\n >\n <Document\n // Wider than the scroller when zoomed in: the scroller pans horizontally over it.\n className=\"flex w-max min-w-full flex-col\"\n key={documentKey}\n // react-pdf 11 suspends while loading and sends failures to an error boundary. This viewer\n // owns its loading and error UI (and the password flow), so keep the callback behaviour.\n suspense={false}\n file={file}\n onLoadSuccess={onDocumentLoadSuccess}\n onLoadError={onDocumentLoadError}\n onPassword={onPassword}\n options={documentOptions}\n loading={\n <div className=\"flex items-center justify-center h-full\">\n <div className=\"text-sm text-muted-foreground\">Loading PDF...</div>\n </div>\n }\n error={\n <div className=\"flex flex-col items-center justify-center h-full gap-4 p-8\">\n <div className=\"text-destructive text-center\">\n {loadError?.message ===\n \"Cannot read properties of null (reading 'sendWithPromise')\" ? (\n <>\n <p className=\"font-semibold mb-2\">PDF viewer initialization failed</p>\n <p className=\"text-sm text-muted-foreground\">Please refresh the page to retry</p>\n </>\n ) : (\n <>\n <p className=\"font-semibold mb-2\">Failed to load PDF</p>\n {loadError && (\n <p className=\"text-sm text-muted-foreground\">{loadError.message}</p>\n )}\n </>\n )}\n </div>\n </div>\n }\n >\n {containerWidth > 0 &&\n Array.from(new Array(numPages), (_, index) => {\n const pageNumber = index + 1\n const shouldRender = renderedPages.has(pageNumber)\n const ratio = pageRatios.get(pageNumber) ?? defaultRatio\n const pageWidth = containerWidth * zoom\n const pageHeight = pageWidth * ratio\n // Resolution the canvas is (re-)rendered at, and how far it is CSS-scaled meanwhile.\n const renderWidth = containerWidth * renderZoom\n const scale = zoom / renderZoom\n // Only enable the text layer for pages in/near the viewport.\n // Pages in the wider render buffer get a canvas (so the image is ready when\n // the user scrolls to them) but no text spans until they're nearby — this\n // avoids committing thousands of DOM nodes synchronously on large documents.\n const shouldRenderTextLayer = visiblePages.has(pageNumber)\n\n return (\n <div\n key={`page_${pageNumber}`}\n ref={(el) => {\n if (el) {\n pageRefs.current.set(pageNumber, el)\n } else {\n pageRefs.current.delete(pageNumber)\n }\n }}\n data-page-number={pageNumber}\n // Fixed height in every state: a flex item would otherwise shrink (it is a\n // scroller itself via blocks.css) and a placeholder/real mismatch would shift the\n // pages below.\n className=\"relative mx-auto mb-6 shrink-0 shadow-xl bg-white border border-border\"\n style={{ width: pageWidth + PAGE_BORDER_PX, height: pageHeight + PAGE_BORDER_PX }}\n role=\"article\"\n aria-label={`Page ${pageNumber} of ${numPages}`}\n >\n {shouldRender ? (\n <div\n data-testid={`pdf-page-scaler-${pageNumber}`}\n style={\n scale === 1\n ? undefined\n : { transform: `scale(${scale})`, transformOrigin: '0 0' }\n }\n >\n <Page\n pageNumber={pageNumber}\n width={renderWidth}\n renderTextLayer={shouldRenderTextLayer}\n renderAnnotationLayer={false}\n onLoadSuccess={(page: { originalWidth: number; originalHeight: number }) => {\n setPageWidthsPt((prev) =>\n prev.get(pageNumber) === page.originalWidth\n ? prev\n : new Map(prev).set(pageNumber, page.originalWidth)\n )\n const ratio = page.originalHeight / page.originalWidth\n setPageRatios((prev) =>\n Math.abs((prev.get(pageNumber) ?? defaultRatio) - ratio) < 0.001\n ? prev\n : new Map(prev).set(pageNumber, ratio)\n )\n }}\n // DPR capped at 2x and lowered further when the page would exceed the canvas\n // pixel budget (zoomed pages are big; iOS Safari fails above ~16.7M pixels).\n devicePixelRatio={renderDpr(\n renderWidth,\n renderWidth * ratio,\n window.devicePixelRatio || 1\n )}\n loading={\n <div\n className=\"flex items-center justify-center bg-muted\"\n style={{ width: renderWidth, height: renderWidth * ratio }}\n >\n <div className=\"text-sm text-muted-foreground\">\n Loading page {pageNumber}...\n </div>\n </div>\n }\n />\n </div>\n ) : (\n <div\n className=\"flex items-center justify-center bg-muted\"\n style={{ width: pageWidth, height: pageHeight }}\n >\n <div className=\"text-sm text-muted-foreground\">Page {pageNumber}</div>\n </div>\n )}\n {renderPageOverlay?.({ pageNumber, pageWidthPt: pageWidthsPt.get(pageNumber) })}\n </div>\n )\n })}\n </Document>\n </div>\n )\n}\n"]}
@@ -157,7 +157,6 @@ function recordChatArtifact(event, conversationId) {
157
157
  docExtId: event.doc_ext_id,
158
158
  title: event.title,
159
159
  content: event.content,
160
- // The backend schema lags the 'react' mode it also sends; the value passes through unchanged.
161
160
  mode: event.mode,
162
161
  isComplete: event.is_complete,
163
162
  version: event.version,
@@ -214,5 +213,5 @@ exports.selectUnread = selectUnread;
214
213
  exports.useChatArtifact = useChatArtifact;
215
214
  exports.useMessageChatArtifact = useMessageChatArtifact;
216
215
  exports.useNotify = useNotify;
217
- //# sourceMappingURL=chunk-RLSBRZ6Z.cjs.map
218
- //# sourceMappingURL=chunk-RLSBRZ6Z.cjs.map
216
+ //# sourceMappingURL=chunk-IX4HOS5Z.cjs.map
217
+ //# sourceMappingURL=chunk-IX4HOS5Z.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/notifications/notify-store.ts","../src/chat/chat-artifacts.ts"],"names":["create","renderToStaticMarkup","toast","saved","useSyncExternalStore"],"mappings":";;;;;;;;AAsFO,IAAM,yBAAA,GAA4B;AAuBzC,IAAI,GAAA,GAAM,CAAA;AACV,IAAM,GAAA,GAAM,MAAM,CAAA,CAAA,EAAI,IAAA,CAAK,GAAA,EAAI,CAAE,QAAA,CAAS,EAAE,CAAC,CAAA,EAAA,CAAI,GAAA,EAAA,EAAO,QAAA,CAAS,EAAE,CAAC,CAAA,CAAA;AAGpE,SAAS,WAAW,KAAA,EAA6C;AAC/D,EAAA,IAAI,OAAA,GAAU,CAAA;AACd,EAAA,OAAO,KAAA,CAAM,OAAO,CAAC,CAAA,KAAM,EAAE,MAAA,IAAU,EAAE,WAAW,yBAAyB,CAAA;AAC/E;AAEO,IAAM,SAAA,GAAYA,cAAA,CAAoB,CAAC,GAAA,MAAS;AAAA,EACrD,eAAe,EAAC;AAAA,EAChB,KAAA,EAAO,KA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AC;AACT,EAAA,IAAA,EAAK;AACP;AAGO,SAAS,gBAAA,GAA2D;AACzE,EAAA,OAAO,SAAA;AACT;AAGO,SAAS,gBAAgB,UAAA,EAAuC;AACrE,EAAA,OAAO,UAAA,GAAa,SAAA,CAAU,UAAU,CAAA,GAAI,MAAA;AAC9C;AAGO,SAAS,gBAAgB,UAAA,EAAuC;AACrE,EAAA,OAAOC,0BAAA;AAAA,IACL,SAAA;AAAA,IACA,MAAM,gBAAgB,UAAU,CAAA;AAAA,IAChC,MAAM;AAAA,GACR;AACF;AAGO,SAAS,uBAAuB,SAAA,EAAsC;AAC3E,EAAA,OAAOA,0BAAA;AAAA,IACL,SAAA;AAAA,IACA,MACE,SAAA,GACI,MAAA,CAAO,MAAA,CAAO,SAAS,CAAA,CAAE,IAAA,CAAK,CAAC,QAAA,KAAa,QAAA,CAAS,YAAA,KAAiB,SAAS,CAAA,GAC/E,MAAA;AAAA,IACN,MAAM;AAAA,GACR;AACF","file":"chunk-IX4HOS5Z.cjs","sourcesContent":["/**\n * The one notification history: every `notify.*` call pops a transient toast (rendered by\n * <Toaster/>, on sonner) and, unless `{ record: false }`, records an entry. The same entries feed\n * the topbar bell (<NotificationBell/>), its unread badge and a host's notification page; backend\n * bridges reconcile their own slices into it with {@link syncSource}.\n *\n * notify.success('Saved') // toast + entry\n * notify.error('Upload failed', { record: false }) // toast only\n * notify.info('Opening workspace…', { ambient: true }) // a log line: never badges\n *\n * sonner owns the transient toast lifecycle (stacking, timing, dismissal); this store owns the\n * history, the mute switch and what a host configures once (workspace glyph and link, see\n * {@link configureNotify}; persistence, see {@link persistNotifyHistory}). Brand-neutral: no seed\n * data, no app imports. For full sonner power the raw `toast` is re-exported.\n */\nimport { type ReactNode } from 'react'\nimport { renderToStaticMarkup } from 'react-dom/server'\n// This module IS the sanctioned toast engine home — the app-level rule that\n// steers callers to notify() doesn't apply here.\n// eslint-disable-next-line no-restricted-imports\nimport { toast } from 'sonner'\nimport { create } from 'zustand'\n\nexport { toast }\n\nexport type NotifyVariant = 'success' | 'error' | 'info' | 'warning'\n\nexport interface AppNotification {\n id: string\n title: string\n description?: string\n variant: NotifyVariant\n /** Epoch ms the entry was recorded. */\n ts: number\n read: boolean\n /** Optional in-app link the entry deep-links to (passed to the bell's onNavigate). */\n href?: string\n /** Optional click action — wins over `href` when both are present. Session\n * history only: never persisted, so a closure is safe here. */\n onSelect?: () => void\n /** The label of the action `onSelect` runs (\"Reply\", \"View\"). */\n actionLabel?: string\n /** Workspace the entry belongs to. */\n workspaceId?: string\n /** Markup of a rich (non-string) toast message, for a log that shows it as it was toasted. */\n html?: string\n /** Routine session activity (\"Opening workspace…\", \"Saved\") — kept for the\n * log but not something that demands attention: excluded from the unread\n * badge and from the bell's list. */\n ambient?: boolean\n /** Where the entry comes from. Session entries (`notify.*`) have none; a\n * backend bridge stamps its own (e.g. 'server') so {@link syncSource} can\n * replace exactly its slice on every refetch without touching the rest. */\n source?: string\n}\n\nexport interface NotifyOptions {\n /** Shown under the title in the toast; a string description is also recorded. */\n description?: ReactNode\n /** Record an entry in the history (default true). False pops the toast only — for an event\n * whose entry arrives another way (a server-persisted notification synced by a bridge). */\n record?: boolean\n /** Pop the transient toast (default true unless muted). False records the entry only. */\n toast?: boolean\n /** Recorded title for a rich (non-string) toast title. Default: the string title, else the\n * rich title's text. */\n recordTitle?: string\n /** Recorded markup for a rich toast title (default: the title rendered to static markup). */\n html?: string\n href?: string\n /** Workspace the notification belongs to: its glyph shows in the toast and its link is the\n * entry's default `href` (both as configured with {@link configureNotify}). */\n workspaceId?: string\n duration?: number\n /** A toast action button (sonner). Clicking the entry runs it too. */\n action?: { label: ReactNode; onClick: () => void }\n /** Override the toast glyph (sonner). */\n icon?: ReactNode\n /** Extra class on the toast (sonner). */\n className?: string\n /** Record as routine session activity (see {@link AppNotification.ambient}): born read. */\n ambient?: boolean\n}\n\n/** Session entries kept (oldest dropped first) — a safety net against pathological growth; a\n * large upload can log many entries, so it is generous. Source slices are bounded by their source. */\nexport const MAX_SESSION_NOTIFICATIONS = 5000\n\ninterface NotifyState {\n notifications: AppNotification[]\n /** Toasts are muted: entries are still recorded — the history is what the user comes back to. */\n muted: boolean\n setMuted: (muted: boolean) => void\n markRead: (id: string) => void\n markAllRead: () => void\n removeNotification: (id: string) => void\n removeNotifications: (ids: readonly string[]) => void\n clearNotifications: () => void\n /** Replace the history (e.g. seed a demo/initial set). */\n seed: (items: AppNotification[]) => void\n /** Record an entry (used by `notify.*`; sonner renders the toast). */\n record: (note: AppNotification) => void\n /** Reconcile one source's slice with fresh truth (e.g. a backend list on\n * every refetch): entries stamped with `source` are replaced wholesale —\n * including their read state, which the source owns — while entries from\n * other sources (session activity) stay untouched. Newest first. */\n syncSource: (source: string, items: AppNotification[]) => void\n}\n\nlet seq = 0\nconst uid = () => `n${Date.now().toString(36)}${(seq++).toString(36)}`\n\n/** Keep at most {@link MAX_SESSION_NOTIFICATIONS} session entries (newest first). */\nfunction capSession(items: AppNotification[]): AppNotification[] {\n let session = 0\n return items.filter((n) => n.source || ++session <= MAX_SESSION_NOTIFICATIONS)\n}\n\nexport const useNotify = create<NotifyState>((set) => ({\n notifications: [],\n muted: false,\n setMuted: (muted) => set({ muted }),\n markRead: (id) =>\n set((s) => ({\n notifications: s.notifications.map((n) => (n.id === id ? { ...n, read: true } : n)),\n })),\n markAllRead: () =>\n set((s) => ({ notifications: s.notifications.map((n) => ({ ...n, read: true })) })),\n removeNotification: (id) =>\n set((s) => ({ notifications: s.notifications.filter((n) => n.id !== id) })),\n removeNotifications: (ids) => {\n const drop = new Set(ids)\n set((s) => ({ notifications: s.notifications.filter((n) => !drop.has(n.id)) }))\n },\n clearNotifications: () => set({ notifications: [] }),\n seed: (items) => set({ notifications: items }),\n record: (note) => set((s) => ({ notifications: capSession([note, ...s.notifications]) })),\n syncSource: (source, items) =>\n set((s) => ({\n notifications: [\n ...items.map((n) => ({ ...n, source })),\n ...s.notifications.filter((n) => n.source !== source),\n ].sort((a, b) => b.ts - a.ts),\n })),\n}))\n\n/** What a host configures once for every `notify.*` call. */\nexport interface NotifyConfig {\n /** The toast glyph of a notification that names a workspace. */\n workspaceIcon?: (workspaceId: string) => ReactNode\n /** The default link of an entry that names a workspace. */\n workspaceHref?: (workspaceId: string) => string | undefined\n /** The default of {@link NotifyOptions.ambient} for calls that do not say: a host whose own\n * toasts are mostly confirmations (\"Saved\") records them as log lines, and passes\n * `ambient: false` for what should claim attention. Default false. */\n ambient?: boolean\n}\n\nlet config: NotifyConfig = {}\n\n/** Set the host's workspace glyph and link (merged into what is configured). */\nexport function configureNotify(next: NotifyConfig): void {\n config = { ...config, ...next }\n}\n\nfunction richMarkup(title: ReactNode): string | undefined {\n try {\n return renderToStaticMarkup(title)\n } catch {\n return undefined\n }\n}\n\nconst textOf = (html: string | undefined) =>\n (html ?? '')\n .replace(/<[^>]+>/g, ' ')\n .replace(/\\s+/g, ' ')\n .trim()\n\n/** Ergonomic helper — `notify.success('Saved')` — toast (sonner) + optional entry. */\nfunction make(variant: NotifyVariant) {\n return (title: ReactNode, opts: NotifyOptions = {}): string => {\n const { workspaceId } = opts\n const ambient = opts.ambient ?? config.ambient ?? false\n if (opts.toast !== false && !useNotify.getState().muted) {\n toast[variant](title, {\n description: opts.description,\n duration: opts.duration,\n action: opts.action,\n icon: opts.icon ?? (workspaceId ? config.workspaceIcon?.(workspaceId) : undefined),\n className: opts.className,\n })\n }\n const id = uid()\n if (opts.record !== false) {\n const html =\n opts.html ?? (typeof title === 'string' || title == null ? undefined : richMarkup(title))\n useNotify.getState().record({\n id,\n // A rich toast still needs a READABLE title — \"Passage copied: gamma-services p.1\",\n // not \"Notification\" — so it comes from the rendered markup, tags stripped.\n title:\n opts.recordTitle ?? (typeof title === 'string' ? title : textOf(html) || 'Notification'),\n description: typeof opts.description === 'string' ? opts.description : undefined,\n variant,\n ts: Date.now(),\n // Ambient activity is a log line, not a claim on attention: it never wears an unread dot.\n read: ambient,\n // Clicking the entry goes where the notification points: its action (when it has one),\n // an explicit link, or the workspace it happened in.\n href: opts.href ?? (workspaceId ? config.workspaceHref?.(workspaceId) : undefined),\n onSelect: opts.action?.onClick,\n actionLabel: opts.action ? String(opts.action.label) : undefined,\n workspaceId,\n html,\n ambient,\n })\n }\n return id\n }\n}\nexport const notify = {\n success: make('success'),\n error: make('error'),\n info: make('info'),\n warning: make('warning'),\n}\n\n/** Replace the history — inject a seed/initial set. */\nexport function seedNotifications(items: AppNotification[]): void {\n useNotify.getState().seed(items)\n}\n\ninterface SavedHistory {\n muted?: boolean\n notifications?: AppNotification[]\n}\n\n/**\n * Keep the session history and the mute switch across reloads in `storage` under `key`: restores\n * them now and saves every change. Source slices are not saved (their source re-syncs them), and\n * neither are actions — a closure does not survive a reload. Returns the unsubscribe.\n */\nexport function persistNotifyHistory(\n key: string,\n storage: Pick<Storage, 'getItem' | 'setItem'> | undefined = globalThis.localStorage\n): () => void {\n if (!storage) return () => {}\n try {\n const saved = JSON.parse(storage.getItem(key) ?? 'null') as SavedHistory | null\n if (saved) {\n const known = new Set(useNotify.getState().notifications.map((n) => n.id))\n useNotify.setState((s) => ({\n muted: saved.muted ?? s.muted,\n notifications: capSession(\n [\n ...s.notifications,\n ...(saved.notifications ?? []).filter((n) => !n.source && !known.has(n.id)),\n ].sort((a, b) => b.ts - a.ts)\n ),\n }))\n }\n } catch {\n // Unreadable or blocked storage: start empty.\n }\n let saved: AppNotification[] = []\n let savedMuted: boolean | undefined\n return useNotify.subscribe((s) => {\n const session = s.notifications.filter((n) => !n.source)\n // A backend re-sync or a read change elsewhere leaves the session slice as it was.\n if (\n s.muted === savedMuted &&\n session.length === saved.length &&\n session.every((n, i) => n === saved[i])\n )\n return\n saved = session\n savedMuted = s.muted\n // JSON drops the undefined fields: an action's closure cannot be saved, nor its label alone.\n const notifications = session.map((n) => ({\n ...n,\n onSelect: undefined,\n actionLabel: undefined,\n }))\n try {\n storage.setItem(key, JSON.stringify({ muted: s.muted, notifications }))\n } catch {\n // Full or blocked storage: the in-memory history still works.\n }\n })\n}\n\n/** Unread count selector for the topbar bell — ambient session activity never\n * demands attention, so it never counts. */\nexport const selectUnread = (s: NotifyState): number =>\n s.notifications.filter((n) => !n.read && !n.ambient).length\n\n/** Default glyph colour per variant (raw palette, override via `toneClassNames`). */\nexport const DEFAULT_NOTIFY_TONE: Record<NotifyVariant, string> = {\n success: 'text-green-600',\n error: 'text-destructive',\n warning: 'text-amber-500',\n info: 'text-blue-500',\n}\n","import { useSyncExternalStore } from 'react'\nimport type { ArtifactEvent } from '@arbidocs/sdk/browser'\n\n/**\n * The documents the assistant is writing (or wrote) in this tab's chats, as their artifact events\n * stream in: the chat engine records every one (`recordChatArtifact`), before the host's\n * `chat.onArtifact` shows it. One store for every surface that shows a draft as it is written: the\n * answer's artifact card, the document viewer, and a drafting chat's document pane.\n *\n * A module-level store, like the open-document registry: a chat and a viewer agree wherever they\n * sit in the tree. It holds what streamed in this tab only; a saved draft is read from the\n * documents list. Cleared on sign-out (`clearChatArtifacts`).\n */\n\n/** An artifact as it streams: what the events said so far. */\nexport interface ChatArtifact {\n /** The document it is written into (`doc-…`). */\n docExtId: string\n title: string\n /** The content so far (Markdown, or the html/react source of a live artifact). */\n content: string\n /**\n * `markdown` / `text` are document drafts (stored by the server as Word documents); `html` /\n * `react` are live artifacts; `image` is a generated image; `presentation` a slide deck (.pptx).\n */\n mode: ArtifactEvent['mode']\n isComplete: boolean\n version?: number | null\n /** The answer that writes it. */\n messageExtId?: string\n /** The conversation it is written in (`new` until the server named it). */\n conversationId: string\n createdAt: string\n}\n\nlet artifacts: Record<string, ChatArtifact> = {}\n/** Document ids, most recently started last. */\nlet order: string[] = []\nconst listeners = new Set<() => void>()\n\nfunction subscribe(listener: () => void): () => void {\n listeners.add(listener)\n return () => listeners.delete(listener)\n}\n\nfunction emit() {\n listeners.forEach((listener) => listener())\n}\n\n/** Record an artifact event of a chat turn in `conversationId`. */\nexport function recordChatArtifact(event: ArtifactEvent, conversationId: string): void {\n const previous = artifacts[event.doc_ext_id]\n const artifact: ChatArtifact = {\n docExtId: event.doc_ext_id,\n title: event.title,\n content: event.content,\n mode: event.mode,\n isComplete: event.is_complete,\n version: event.version,\n createdAt: new Date().toISOString(),\n messageExtId: event.message_ext_id ?? undefined,\n conversationId,\n }\n artifacts = { ...artifacts, [artifact.docExtId]: artifact }\n if (!previous) order = [...order, artifact.docExtId]\n emit()\n}\n\n/** Forget every streamed artifact (sign-out). */\nexport function clearChatArtifacts(): void {\n if (order.length === 0) return\n artifacts = {}\n order = []\n emit()\n}\n\n/** Every artifact streamed in this tab, by document id. */\nexport function getChatArtifacts(): Readonly<Record<string, ChatArtifact>> {\n return artifacts\n}\n\n/** The artifact streaming (or streamed) into this document, if one did in this tab. */\nexport function getChatArtifact(documentId: string | null | undefined) {\n return documentId ? artifacts[documentId] : undefined\n}\n\n/** The artifact streaming into this document, if one is. Re-renders as it streams. */\nexport function useChatArtifact(documentId: string | null | undefined) {\n return useSyncExternalStore(\n subscribe,\n () => getChatArtifact(documentId),\n () => undefined\n )\n}\n\n/** The artifact this answer writes (or wrote), if it did in this tab. */\nexport function useMessageChatArtifact(messageId: string | null | undefined) {\n return useSyncExternalStore(\n subscribe,\n () =>\n messageId\n ? Object.values(artifacts).find((artifact) => artifact.messageExtId === messageId)\n : undefined,\n () => undefined\n )\n}\n"]}
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  var chunk3JAEX57E_cjs = require('./chunk-3JAEX57E.cjs');
4
- var chunkO32T7XRD_cjs = require('./chunk-O32T7XRD.cjs');
5
4
  var chunkSUZORMAB_cjs = require('./chunk-SUZORMAB.cjs');
6
5
  var chunk2IJP73ZG_cjs = require('./chunk-2IJP73ZG.cjs');
6
+ var chunkO32T7XRD_cjs = require('./chunk-O32T7XRD.cjs');
7
7
  var chunkNDIKMOBJ_cjs = require('./chunk-NDIKMOBJ.cjs');
8
8
  var react = require('react');
9
9
  var reactQuery = require('@tanstack/react-query');
@@ -1087,5 +1087,5 @@ exports.useSignerCandidates = useSignerCandidates;
1087
1087
  exports.useStoreSavedSignature = useStoreSavedSignature;
1088
1088
  exports.useVoidSignatureRequest = useVoidSignatureRequest;
1089
1089
  exports.versionsWithMarkup = versionsWithMarkup;
1090
- //# sourceMappingURL=chunk-AJRYZ3IC.cjs.map
1091
- //# sourceMappingURL=chunk-AJRYZ3IC.cjs.map
1090
+ //# sourceMappingURL=chunk-K6ELFSG6.cjs.map
1091
+ //# sourceMappingURL=chunk-K6ELFSG6.cjs.map