@deepcitation/deepcitation-js 1.1.27 → 1.1.29

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 (82) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +253 -253
  3. package/lib/chunk-2IZXUOQR.js +66 -0
  4. package/lib/chunk-3GR7VKUJ.cjs +1 -0
  5. package/lib/chunk-4FGOHQFP.cjs +66 -0
  6. package/lib/chunk-CFXDRAJL.cjs +1 -0
  7. package/lib/chunk-F2MMVEVC.cjs +1 -0
  8. package/lib/chunk-LSKISWWH.cjs +2 -0
  9. package/lib/chunk-O2XFH626.js +1 -0
  10. package/lib/chunk-QGXCOW3E.js +1 -0
  11. package/lib/chunk-RCHWBA6D.js +2 -0
  12. package/lib/chunk-RQPZSRID.js +1 -0
  13. package/lib/client/index.cjs +1 -0
  14. package/lib/client/{DeepCitation.d.ts → index.d.cts} +159 -3
  15. package/lib/client/index.d.ts +342 -2
  16. package/lib/client/index.js +1 -1
  17. package/lib/index.cjs +1 -0
  18. package/lib/index.d.cts +105 -0
  19. package/lib/index.d.ts +103 -21
  20. package/lib/index.js +1 -20
  21. package/lib/prompts/index.cjs +1 -0
  22. package/lib/prompts/index.d.cts +196 -0
  23. package/lib/prompts/index.d.ts +196 -3
  24. package/lib/prompts/index.js +1 -3
  25. package/lib/react/index.cjs +4 -0
  26. package/lib/react/{types.d.ts → index.d.cts} +173 -22
  27. package/lib/react/index.d.ts +461 -12
  28. package/lib/react/index.js +4 -20
  29. package/lib/types/index.cjs +1 -0
  30. package/lib/types/index.d.cts +96 -0
  31. package/lib/types/index.d.ts +96 -11
  32. package/lib/types/index.js +1 -7
  33. package/lib/utils-CSqRI6NU.d.cts +45 -0
  34. package/lib/{react/utils.d.ts → utils-D_wxy_ni.d.ts} +13 -12
  35. package/package.json +46 -11
  36. package/lib/client/DeepCitation.js +0 -374
  37. package/lib/client/types.d.ts +0 -154
  38. package/lib/client/types.js +0 -1
  39. package/lib/parsing/normalizeCitation.d.ts +0 -5
  40. package/lib/parsing/normalizeCitation.js +0 -198
  41. package/lib/parsing/parseCitation.d.ts +0 -79
  42. package/lib/parsing/parseCitation.js +0 -431
  43. package/lib/parsing/parseWorkAround.d.ts +0 -2
  44. package/lib/parsing/parseWorkAround.js +0 -73
  45. package/lib/prompts/citationPrompts.d.ts +0 -138
  46. package/lib/prompts/citationPrompts.js +0 -168
  47. package/lib/prompts/promptCompression.d.ts +0 -14
  48. package/lib/prompts/promptCompression.js +0 -127
  49. package/lib/prompts/types.d.ts +0 -4
  50. package/lib/prompts/types.js +0 -1
  51. package/lib/react/CitationComponent.d.ts +0 -106
  52. package/lib/react/CitationComponent.js +0 -419
  53. package/lib/react/CitationVariants.d.ts +0 -132
  54. package/lib/react/CitationVariants.js +0 -277
  55. package/lib/react/DiffDisplay.d.ts +0 -10
  56. package/lib/react/DiffDisplay.js +0 -33
  57. package/lib/react/Popover.d.ts +0 -15
  58. package/lib/react/Popover.js +0 -20
  59. package/lib/react/UrlCitationComponent.d.ts +0 -83
  60. package/lib/react/UrlCitationComponent.js +0 -224
  61. package/lib/react/VerificationTabs.d.ts +0 -10
  62. package/lib/react/VerificationTabs.js +0 -36
  63. package/lib/react/icons.d.ts +0 -22
  64. package/lib/react/icons.js +0 -16
  65. package/lib/react/primitives.d.ts +0 -99
  66. package/lib/react/primitives.js +0 -187
  67. package/lib/react/types.js +0 -1
  68. package/lib/react/useSmartDiff.d.ts +0 -16
  69. package/lib/react/useSmartDiff.js +0 -64
  70. package/lib/react/utils.js +0 -88
  71. package/lib/types/boxes.d.ts +0 -11
  72. package/lib/types/boxes.js +0 -1
  73. package/lib/types/citation.d.ts +0 -39
  74. package/lib/types/citation.js +0 -1
  75. package/lib/types/search.d.ts +0 -19
  76. package/lib/types/search.js +0 -1
  77. package/lib/types/verification.d.ts +0 -27
  78. package/lib/types/verification.js +0 -11
  79. package/lib/utils/diff.d.ts +0 -60
  80. package/lib/utils/diff.js +0 -414
  81. package/lib/utils/sha.d.ts +0 -10
  82. package/lib/utils/sha.js +0 -108
@@ -1,17 +1,466 @@
1
+ import { Citation, Verification, SearchStatus, CitationStatus } from '../types/index.js';
2
+ export { C as CITATION_X_PADDING, c as CITATION_Y_PADDING, h as classNames, b as generateCitationInstanceId, g as generateCitationKey, d as getCitationDisplayText, f as getCitationKeySpanText, e as getCitationNumber } from '../utils-D_wxy_ni.js';
3
+ import React$1 from 'react';
4
+ import * as react_jsx_runtime from 'react/jsx-runtime';
5
+
1
6
  /**
2
- * DeepCitation React Utilities
7
+ * Visual style variants for citations.
3
8
  *
4
- * Note: UI components have been moved to a shadcn-style copy-paste pattern.
5
- * See the documentation at https://deepcitation.com/docs/components for
6
- * ready-to-use React components.
9
+ * | Variant | Description |
10
+ * |---------------|------------------------------------------------|
11
+ * | `chip` | Pill/badge style with background color |
12
+ * | `brackets` | [text✓] with square brackets (default) |
13
+ * | `text` | Plain text, inherits parent styling |
14
+ * | `superscript` | Small raised text like footnotes¹ |
15
+ * | `minimal` | Compact text with indicator, truncated |
16
+ */
17
+ type CitationVariant = "chip" | "brackets" | "text" | "superscript" | "minimal";
18
+ /**
19
+ * Content to display in the citation.
20
+ *
21
+ * | Content | Description |
22
+ * |---------------|------------------------------------------------|
23
+ * | `keySpan` | Descriptive text (e.g., "Revenue Growth") |
24
+ * | `number` | Citation number (e.g., "1", "2", "3") |
25
+ * | `indicator` | Only the status icon (✓/⚠), no text |
26
+ *
27
+ * Default content per variant:
28
+ * - `chip` → `keySpan`
29
+ * - `brackets` → `number`
30
+ * - `text` → `keySpan`
31
+ * - `superscript` → `number`
32
+ * - `minimal` → `number`
33
+ */
34
+ type CitationContent = "keySpan" | "number" | "indicator";
35
+ /**
36
+ * URL fetch status for URL citations.
37
+ */
38
+ type UrlFetchStatus = "verified" | "partial" | "pending" | "blocked_antibot" | "blocked_login" | "blocked_paywall" | "blocked_geo" | "blocked_rate_limit" | "error_timeout" | "error_not_found" | "error_server" | "error_network" | "unknown";
39
+ /**
40
+ * URL citation metadata.
41
+ */
42
+ interface UrlCitationMeta {
43
+ /** The full URL */
44
+ url: string;
45
+ /** Display domain (e.g., "example.com") */
46
+ domain?: string;
47
+ /** Page title if fetched */
48
+ title?: string;
49
+ /** Fetch/verification status */
50
+ fetchStatus: UrlFetchStatus;
51
+ /** When the URL was last verified */
52
+ verifiedAt?: Date | string;
53
+ /** HTTP status code if available */
54
+ httpStatus?: number;
55
+ /** Error message if applicable */
56
+ errorMessage?: string;
57
+ /** Favicon URL if available */
58
+ faviconUrl?: string;
59
+ }
60
+ /**
61
+ * Style configuration for the citation component.
62
+ * All properties are optional class name strings.
63
+ */
64
+ interface CitationStyles {
65
+ /** Container wrapper class */
66
+ container?: string;
67
+ /** Citation number bracket wrapper */
68
+ bracketWrapper?: string;
69
+ /** Inner bracket content */
70
+ bracketContent?: string;
71
+ /** Citation text/number itself */
72
+ citationText?: string;
73
+ /** Verified status indicator */
74
+ verifiedIcon?: string;
75
+ /** Partial match indicator */
76
+ partialIcon?: string;
77
+ /** Pending/loading state */
78
+ pendingText?: string;
79
+ }
80
+ /**
81
+ * State classes applied based on citation verification status
82
+ */
83
+ interface CitationStateClasses {
84
+ /** Applied when citation is verified (found in document) */
85
+ verified?: string;
86
+ /** Applied when citation is a miss (not found) */
87
+ miss?: string;
88
+ /** Applied when citation is a partial match */
89
+ partial?: string;
90
+ /** Applied when citation verification is pending */
91
+ pending?: string;
92
+ }
93
+ /**
94
+ * Cursor classes for different zoom states
95
+ */
96
+ interface CitationCursorClasses {
97
+ zoomIn?: string;
98
+ zoomOut?: string;
99
+ pointer?: string;
100
+ }
101
+ /**
102
+ * Props for the base CitationComponent
103
+ */
104
+ interface BaseCitationProps {
105
+ /** The citation data to display */
106
+ citation: Citation;
107
+ /** Child content to render before the citation bracket */
108
+ children?: React.ReactNode;
109
+ /** Additional class name for the container */
110
+ className?: string;
111
+ /** Class name for controlling inner content width */
112
+ innerWidthClassName?: string;
113
+ /**
114
+ * Visual style variant for the citation.
115
+ * @default "brackets"
116
+ */
117
+ variant?: CitationVariant;
118
+ /**
119
+ * What content to display in the citation.
120
+ * If not specified, defaults based on variant:
121
+ * - `chip` → `keySpan`
122
+ * - `brackets` → `number`
123
+ * - `text` → `keySpan`
124
+ * - `superscript` → `number`
125
+ * - `minimal` → `number`
126
+ */
127
+ content?: CitationContent;
128
+ /** Fallback display text when citation keySpan is empty */
129
+ fallbackDisplay?: string | null;
130
+ }
131
+ /**
132
+ * Visual style variants for URL citations.
133
+ */
134
+ type UrlCitationVariant = "chip" | "inline" | "bracket";
135
+ /**
136
+ * Props for URL citation component
137
+ */
138
+ interface UrlCitationProps extends Omit<BaseCitationProps, "citation" | "variant"> {
139
+ /** Visual style variant for the URL citation */
140
+ variant?: UrlCitationVariant;
141
+ /** URL metadata including fetch status */
142
+ urlMeta: UrlCitationMeta;
143
+ /** The citation data (optional, will be derived from urlMeta if not provided) */
144
+ citation?: Citation;
145
+ /** Whether to show the full URL on hover */
146
+ showFullUrlOnHover?: boolean;
147
+ /** Whether to show favicon */
148
+ showFavicon?: boolean;
149
+ /** Whether to show the page title instead of domain */
150
+ showTitle?: boolean;
151
+ /** Maximum characters for truncated display */
152
+ maxDisplayLength?: number;
153
+ /** Custom render for the blocked status indicator */
154
+ renderBlockedIndicator?: (status: UrlFetchStatus, errorMessage?: string) => React.ReactNode;
155
+ /** Click handler for the URL */
156
+ onUrlClick?: (url: string, event: React.MouseEvent) => void;
157
+ /** Event handlers for citation interactions */
158
+ eventHandlers?: CitationEventHandlers;
159
+ /** Whether tooltips should be prevented */
160
+ preventTooltips?: boolean;
161
+ }
162
+ /**
163
+ * Extended props for the citation content renderer
164
+ */
165
+ interface CitationContentProps extends BaseCitationProps {
166
+ /** Unique key for this citation */
167
+ citationKey: string;
168
+ /** Unique instance ID for this citation render */
169
+ citationInstanceId: string;
170
+ /** Found citation highlight data */
171
+ verification: Verification | null | undefined;
172
+ /** Search status */
173
+ searchStatus: SearchStatus | undefined | null;
174
+ /** Actual page number where citation was found */
175
+ actualPageNumber?: number | null;
176
+ /** Page number from citation data */
177
+ citationPageNumber?: number | null;
178
+ /** Unique highlight ID */
179
+ highlightId?: string;
180
+ /** Citation verification status */
181
+ status: CitationStatus;
182
+ /** Whether tooltips should be suppressed */
183
+ preventTooltips?: boolean;
184
+ /** Whether on mobile device */
185
+ isMobile?: boolean;
186
+ /** Style configuration */
187
+ styles?: CitationStyles;
188
+ /** State-based classes */
189
+ stateClasses?: CitationStateClasses;
190
+ /** Cursor classes */
191
+ cursorClasses?: CitationCursorClasses;
192
+ }
193
+ /**
194
+ * Render props for custom citation rendering
195
+ */
196
+ interface CitationRenderProps {
197
+ /** The citation data */
198
+ citation: Citation;
199
+ /** Citation verification status */
200
+ status: CitationStatus;
201
+ /** The citation key */
202
+ citationKey: string;
203
+ /** Display text for the citation */
204
+ displayText: string;
205
+ /** Whether this is a merged keySpan display */
206
+ isMergedDisplay: boolean;
207
+ }
208
+ /**
209
+ * Event handlers for citation interactions
210
+ */
211
+ interface CitationEventHandlers {
212
+ /** Called when mouse enters citation */
213
+ onMouseEnter?: (citation: Citation, citationKey: string) => void;
214
+ /** Called when mouse leaves citation */
215
+ onMouseLeave?: (citation: Citation, citationKey: string) => void;
216
+ /** Called when citation is clicked */
217
+ onClick?: (citation: Citation, citationKey: string, event: React.MouseEvent | React.TouchEvent) => void;
218
+ /** Called on touch end (mobile) */
219
+ onTouchEnd?: (citation: Citation, citationKey: string, event: React.TouchEvent) => void;
220
+ }
221
+ /**
222
+ * Context provided to behavior handlers for making decisions.
223
+ */
224
+ interface CitationBehaviorContext {
225
+ /** The citation data */
226
+ citation: Citation;
227
+ /** Unique key for this citation */
228
+ citationKey: string;
229
+ /** Verification result if available */
230
+ verification: Verification | null;
231
+ /** Whether the popover is currently pinned open */
232
+ isTooltipExpanded: boolean;
233
+ /** Whether the full-size image overlay is currently open */
234
+ isImageExpanded: boolean;
235
+ /** Whether a verification image is available */
236
+ hasImage: boolean;
237
+ }
238
+ /**
239
+ * Actions that can be performed by the citation component.
240
+ * These are returned by behavior handlers to control component state.
241
+ */
242
+ interface CitationBehaviorActions {
243
+ /** Pin or unpin the popover (keeps it visible without hover) */
244
+ setTooltipExpanded?: boolean;
245
+ /** Open or close the full-size image overlay */
246
+ setImageExpanded?: boolean | string;
247
+ /** Expand or collapse the search phrases list (for miss/partial states) */
248
+ setPhrasesExpanded?: boolean;
249
+ }
250
+ /**
251
+ * Configuration for click behavior.
252
+ * Return actions to perform, or `false` to prevent default behavior.
253
+ */
254
+ type CitationClickBehavior = (context: CitationBehaviorContext, event: React.MouseEvent | React.TouchEvent) => CitationBehaviorActions | false | void;
255
+ /**
256
+ * Configuration for hover behavior.
257
+ */
258
+ interface CitationHoverBehavior {
259
+ /** Called when mouse enters the citation */
260
+ onEnter?: (context: CitationBehaviorContext) => void;
261
+ /** Called when mouse leaves the citation */
262
+ onLeave?: (context: CitationBehaviorContext) => void;
263
+ }
264
+ /**
265
+ * Configuration for customizing default citation behaviors.
266
+ *
267
+ * When you provide `onClick` or `onHover`, they REPLACE the corresponding default behaviors.
268
+ * Use `eventHandlers` for side effects that should run alongside defaults.
269
+ *
270
+ * @example Custom click behavior (replaces default)
271
+ * ```tsx
272
+ * <CitationComponent
273
+ * citation={citation}
274
+ * verification={verification}
275
+ * behaviorConfig={{
276
+ * onClick: (context, event) => {
277
+ * if (context.hasImage) {
278
+ * return { setImageExpanded: true };
279
+ * }
280
+ * }
281
+ * }}
282
+ * />
283
+ * ```
7
284
  *
8
- * This module exports utilities and types that are useful for building
9
- * your own citation components.
285
+ * @example Disable click behavior entirely
286
+ * ```tsx
287
+ * <CitationComponent
288
+ * citation={citation}
289
+ * verification={verification}
290
+ * behaviorConfig={{ onClick: () => false }}
291
+ * />
292
+ * ```
293
+ */
294
+ interface CitationBehaviorConfig {
295
+ /**
296
+ * Custom click behavior handler. When provided, REPLACES the default click behavior.
297
+ *
298
+ * Return values:
299
+ * - `CitationBehaviorActions`: Apply specific state changes
300
+ * - `false`: Prevent any state changes
301
+ * - `void`/`undefined`: No state changes
302
+ */
303
+ onClick?: CitationClickBehavior;
304
+ /**
305
+ * Custom hover behavior handlers. When provided, REPLACE the default hover behavior.
306
+ */
307
+ onHover?: CitationHoverBehavior;
308
+ }
309
+ /**
310
+ * Props for the tooltip wrapper component
311
+ */
312
+ interface CitationTooltipProps {
313
+ children: React.ReactNode;
314
+ citation: Citation;
315
+ verification?: Verification | null;
316
+ shouldShowTooltip: boolean;
317
+ }
318
+
319
+ /**
320
+ * Extracts domain from URL for compact display.
321
+ */
322
+ declare function extractDomain(url: string): string;
323
+ /**
324
+ * Checks if status is a blocked status.
325
+ */
326
+ declare function isBlockedStatus(status: UrlFetchStatus): boolean;
327
+ /**
328
+ * Checks if status is an error status.
329
+ */
330
+ declare function isErrorStatus(status: UrlFetchStatus): boolean;
331
+ /**
332
+ * Checks if URL was successfully verified.
333
+ */
334
+ declare function isVerifiedStatus(status: UrlFetchStatus): boolean;
335
+
336
+ /**
337
+ * Props for the CitationComponent.
10
338
  *
11
- * @packageDocumentation
339
+ * ## Behavior
340
+ *
341
+ * Default interaction pattern:
342
+ * - **Hover**: Shows popover with verification image/details
343
+ * - **Click**: Opens full-size image overlay (zoom)
344
+ * - **Escape / Click outside / Click overlay**: Closes image overlay
345
+ *
346
+ * Custom behavior:
347
+ * - Use `behaviorConfig.onClick` to replace the default click behavior
348
+ * - Use `eventHandlers.onClick` to add side effects (disables default)
349
+ *
350
+ * @example Default usage
351
+ * ```tsx
352
+ * <CitationComponent
353
+ * citation={citation}
354
+ * verification={verification}
355
+ * />
356
+ * ```
357
+ *
358
+ * @example Custom click behavior
359
+ * ```tsx
360
+ * <CitationComponent
361
+ * citation={citation}
362
+ * verification={verification}
363
+ * behaviorConfig={{
364
+ * onClick: (context) => {
365
+ * // Custom action
366
+ * console.log('Clicked:', context.citationKey);
367
+ * return { setImageExpanded: true };
368
+ * }
369
+ * }}
370
+ * />
371
+ * ```
372
+ */
373
+ interface CitationComponentProps extends BaseCitationProps {
374
+ /** Verification result from the DeepCitation API */
375
+ verification?: Verification | null;
376
+ /**
377
+ * Explicitly show loading spinner. When true, displays spinner regardless
378
+ * of verification status. Use this when verification is in-flight.
379
+ */
380
+ isLoading?: boolean;
381
+ /**
382
+ * Visual style variant for the citation.
383
+ * - `chip`: Pill/badge style with background color
384
+ * - `brackets`: [text✓] with square brackets (default)
385
+ * - `text`: Plain text, inherits parent styling
386
+ * - `superscript`: Small raised text like footnotes¹
387
+ * - `minimal`: Compact text with indicator, truncated
388
+ */
389
+ variant?: CitationVariant;
390
+ /**
391
+ * What content to display in the citation.
392
+ * - `keySpan`: Descriptive text (e.g., "Revenue Growth")
393
+ * - `number`: Citation number (e.g., "1", "2", "3")
394
+ * - `indicator`: Only the status icon, no text
395
+ *
396
+ * Defaults based on variant:
397
+ * - `chip` → `keySpan`
398
+ * - `brackets` → `keySpan`
399
+ * - `text` → `keySpan`
400
+ * - `superscript` → `number`
401
+ * - `minimal` → `number`
402
+ */
403
+ content?: CitationContent;
404
+ /** Event handlers for citation interactions */
405
+ eventHandlers?: CitationEventHandlers;
406
+ /**
407
+ * Configuration for customizing default click/hover behaviors.
408
+ * Providing onClick REPLACES the default click behavior.
409
+ */
410
+ behaviorConfig?: CitationBehaviorConfig;
411
+ /** Enable mobile touch handlers */
412
+ isMobile?: boolean;
413
+ /** Custom render function for the status indicator */
414
+ renderIndicator?: (status: CitationStatus) => React$1.ReactNode;
415
+ /** Custom render function for entire citation content */
416
+ renderContent?: (props: CitationRenderProps) => React$1.ReactNode;
417
+ /** Position of popover. Use "hidden" to disable. */
418
+ popoverPosition?: "top" | "bottom" | "hidden";
419
+ /** Custom render function for popover content */
420
+ renderPopoverContent?: (props: {
421
+ citation: BaseCitationProps["citation"];
422
+ verification: Verification | null;
423
+ status: CitationStatus;
424
+ }) => React$1.ReactNode;
425
+ }
426
+ /**
427
+ * CitationComponent displays a citation with verification status.
428
+ *
429
+ * ## Interaction Pattern
430
+ *
431
+ * - **Hover**: Shows popover with verification image or details
432
+ * - **Click**: Opens full-size image overlay (if image available)
433
+ * - **Escape / Click overlay**: Closes the image overlay
434
+ *
435
+ * ## Customization
436
+ *
437
+ * Use `behaviorConfig.onClick` to completely replace the click behavior,
438
+ * or `eventHandlers.onClick` to add side effects (which disables defaults).
439
+ */
440
+ declare const CitationComponent: React$1.ForwardRefExoticComponent<CitationComponentProps & React$1.RefAttributes<HTMLSpanElement>>;
441
+ declare const MemoizedCitationComponent: React$1.NamedExoticComponent<CitationComponentProps & React$1.RefAttributes<HTMLSpanElement>>;
442
+
443
+ /**
444
+ * DeepCitation icon SVG (no dependencies)
445
+ */
446
+ declare const DeepCitationIcon: ({ className }: {
447
+ className?: string;
448
+ }) => react_jsx_runtime.JSX.Element;
449
+ /**
450
+ * Check icon SVG (no dependencies)
451
+ */
452
+ declare const CheckIcon: ({ className }: {
453
+ className?: string;
454
+ }) => react_jsx_runtime.JSX.Element;
455
+ /**
456
+ * Warning icon SVG (no dependencies)
12
457
  */
13
- export type { CitationContentProps, CitationRenderProps, CitationTooltipProps, CitationStyles, CitationStateClasses, CitationCursorClasses, CitationEventHandlers, CitationVariant as CitationVariantType, CitationContent, UrlFetchStatus, UrlCitationMeta, UrlCitationProps, UrlCitationVariant, CitationBehaviorConfig, CitationBehaviorContext, CitationBehaviorActions, CitationClickBehavior, CitationHoverBehavior, } from "./types.js";
14
- export { extractDomain, isBlockedStatus, isErrorStatus, isVerifiedStatus, } from "./UrlCitationComponent.js";
15
- export { generateCitationKey, generateCitationInstanceId, getCitationDisplayText, getCitationNumber, getCitationKeySpanText, classNames, CITATION_X_PADDING, CITATION_Y_PADDING, } from "./utils.js";
16
- export { CitationComponent, MemoizedCitationComponent, type CitationVariant, type CitationComponentProps, } from "./CitationComponent.js";
17
- export { DeepCitationIcon, CheckIcon, SpinnerIcon, WarningIcon, } from "./icons.js";
458
+ declare const WarningIcon: ({ className }: {
459
+ className?: string;
460
+ }) => react_jsx_runtime.JSX.Element;
461
+ /** Spinner component for loading/pending state */
462
+ declare const SpinnerIcon: ({ className }: {
463
+ className?: string;
464
+ }) => react_jsx_runtime.JSX.Element;
465
+
466
+ export { CheckIcon, type CitationBehaviorActions, type CitationBehaviorConfig, type CitationBehaviorContext, type CitationClickBehavior, CitationComponent, type CitationComponentProps, type CitationContent, type CitationContentProps, type CitationCursorClasses, type CitationEventHandlers, type CitationHoverBehavior, type CitationRenderProps, type CitationStateClasses, type CitationStyles, type CitationTooltipProps, type CitationVariant, type CitationVariant as CitationVariantType, DeepCitationIcon, MemoizedCitationComponent, SpinnerIcon, type UrlCitationMeta, type UrlCitationProps, type UrlCitationVariant, type UrlFetchStatus, WarningIcon, extractDomain, isBlockedStatus, isErrorStatus, isVerifiedStatus };
@@ -1,20 +1,4 @@
1
- /**
2
- * DeepCitation React Utilities
3
- *
4
- * Note: UI components have been moved to a shadcn-style copy-paste pattern.
5
- * See the documentation at https://deepcitation.com/docs/components for
6
- * ready-to-use React components.
7
- *
8
- * This module exports utilities and types that are useful for building
9
- * your own citation components.
10
- *
11
- * @packageDocumentation
12
- */
13
- // URL Utilities - For handling URL citation metadata
14
- export { extractDomain, isBlockedStatus, isErrorStatus, isVerifiedStatus, } from "./UrlCitationComponent.js";
15
- // Utilities - For generating citation keys and display text
16
- export { generateCitationKey, generateCitationInstanceId, getCitationDisplayText, getCitationNumber, getCitationKeySpanText, classNames, CITATION_X_PADDING, CITATION_Y_PADDING, } from "./utils.js";
17
- // Components
18
- export { CitationComponent, MemoizedCitationComponent, } from "./CitationComponent.js";
19
- // Icons
20
- export { DeepCitationIcon, CheckIcon, SpinnerIcon, WarningIcon, } from "./icons.js";
1
+ import {h,j,n,g}from'../chunk-QGXCOW3E.js';export{o as CITATION_X_PADDING,p as CITATION_Y_PADDING,n as classNames,j as generateCitationInstanceId,h as generateCitationKey,k as getCitationDisplayText,m as getCitationKeySpanText,l as getCitationNumber}from'../chunk-QGXCOW3E.js';import'../chunk-O2XFH626.js';import*as Ie from'react';import {forwardRef,useMemo,useCallback,memo,useState,useRef,useEffect}from'react';import {jsxs,Fragment,jsx}from'react/jsx-runtime';import {createPortal}from'react-dom';import*as R from'@radix-ui/react-popover';function le(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e.replace(/^https?:\/\/(www\.)?/,"").split("/")[0]}}function ye(e,t){return e.length<=t?e:e.slice(0,t-1)+"\u2026"}function at(e){try{let t=new URL(e),n=t.pathname+t.search;return n==="/"?"":n}catch{return ""}}var ke={verified:{icon:"\u2713",label:"Verified",className:"text-green-600 dark:text-green-500"},partial:{icon:"~",label:"Partial match",className:"text-amber-600 dark:text-amber-500"},pending:{icon:"\u2026",label:"Verifying",className:"text-gray-400 dark:text-gray-500"},blocked_antibot:{icon:"\u{1F6E1}",label:"Blocked by anti-bot",className:"text-amber-600 dark:text-amber-500"},blocked_login:{icon:"\u{1F512}",label:"Login required",className:"text-amber-600 dark:text-amber-500"},blocked_paywall:{icon:"\u{1F4B3}",label:"Paywall",className:"text-amber-600 dark:text-amber-500"},blocked_geo:{icon:"\u{1F30D}",label:"Geo-restricted",className:"text-amber-600 dark:text-amber-500"},blocked_rate_limit:{icon:"\u23F1",label:"Rate limited",className:"text-amber-600 dark:text-amber-500"},error_timeout:{icon:"\u23F0",label:"Timed out",className:"text-red-500 dark:text-red-400"},error_not_found:{icon:"404",label:"Not found",className:"text-red-500 dark:text-red-400"},error_server:{icon:"\u26A0",label:"Server error",className:"text-red-500 dark:text-red-400"},error_network:{icon:"\u26A1",label:"Network error",className:"text-red-500 dark:text-red-400"},unknown:{icon:"?",label:"Unknown status",className:"text-gray-400 dark:text-gray-500"}};function Pe(e){return e.startsWith("blocked_")}function Ne(e){return e.startsWith("error_")}function rt(e){return e==="verified"||e==="partial"}var ot=({status:e,errorMessage:t})=>{let n$1=ke[e];return jsx("span",{className:n("inline-flex items-center gap-1",n$1.className),title:t||n$1.label,"aria-label":n$1.label,children:jsx("span",{className:"text-[0.9em]","aria-hidden":"true",children:n$1.icon})})},ie=({url:e,faviconUrl:t})=>{let n=le(e),r=t||`https://www.google.com/s2/favicons?domain=${n}&sz=16`;return jsx("img",{src:r,alt:"",className:"w-3.5 h-3.5 rounded-sm",width:14,height:14,loading:"lazy",onError:a=>{a.target.style.display="none";}})},we=forwardRef(({urlMeta:e,citation:t,children:n$1,className:r,variant:a="chip",showFullUrlOnHover:o=true,showFavicon:i=true,showTitle:d=false,maxDisplayLength:s=30,renderBlockedIndicator:l,onUrlClick:u,eventHandlers:p,preventTooltips:h$1=false},P)=>{let{url:g,domain:A,title:N,fetchStatus:C,faviconUrl:w,errorMessage:B}=e,v=useMemo(()=>t||{value:g,fullPhrase:N||g},[t,g,N]),m=useMemo(()=>h(v),[v]),K=useMemo(()=>j(m),[m]),M=useMemo(()=>A||le(g),[A,g]),L=useMemo(()=>at(g),[g]),D=useMemo(()=>{if(d&&N)return ye(N,s);let b=L?ye(L,s-M.length-1):"";return b?`${M}${b}`:M},[d,N,M,L,s]),S=ke[C],Z=Pe(C),ee=Ne(C),te=C==="verified",G=C==="partial",T=C==="pending",O=useCallback(b=>{b.preventDefault(),b.stopPropagation(),u?u(g,b):window.open(g,"_blank","noopener,noreferrer"),p?.onClick?.(v,m,b);},[u,g,p,v,m]),y=useCallback(()=>{p?.onMouseEnter?.(v,m);},[p,v,m]),E=useCallback(()=>{p?.onMouseLeave?.(v,m);},[p,v,m]),_=()=>Z||ee?l?l(C,B):jsx(ot,{status:C,errorMessage:B}):te?jsx("span",{className:"text-[0.85em] text-green-600 dark:text-green-500","aria-hidden":"true",title:"Verified",children:"\u2713"}):G?jsx("span",{className:"text-[0.85em] text-amber-600 dark:text-amber-500","aria-hidden":"true",title:"Partial match",children:"~"}):T?jsx("span",{className:"opacity-70","aria-hidden":"true",children:"\u2026"}):null;return a==="chip"?jsxs(Fragment,{children:[n$1,jsxs("span",{ref:P,"data-citation-id":m,"data-citation-instance":K,"data-url":g,"data-fetch-status":C,"data-variant":"chip",className:n("inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-sm cursor-pointer transition-colors no-underline","bg-blue-100 dark:bg-blue-900/30",S.className,r),title:o?g:void 0,onMouseEnter:h$1?void 0:y,onMouseLeave:h$1?void 0:E,onMouseDown:O,onClick:b=>b.stopPropagation(),role:"link","aria-label":`Link to ${M}: ${S.label}`,children:[i&&jsx(ie,{url:g,faviconUrl:w}),jsx("span",{className:"max-w-[200px] overflow-hidden text-ellipsis whitespace-nowrap",children:D}),_()]})]}):a==="inline"?jsxs(Fragment,{children:[n$1,jsxs("a",{ref:P,href:g,"data-citation-id":m,"data-citation-instance":K,"data-fetch-status":C,"data-variant":"inline",className:n("inline-flex items-center gap-1 cursor-pointer transition-colors no-underline border-b border-dotted border-current",S.className,r),title:o?g:void 0,onMouseEnter:h$1?void 0:y,onMouseLeave:h$1?void 0:E,onClick:b=>{b.preventDefault(),O(b);},target:"_blank",rel:"noopener noreferrer","aria-label":`Link to ${M}: ${S.label}`,children:[i&&jsx(ie,{url:g,faviconUrl:w}),jsx("span",{children:D}),_()]})]}):jsxs(Fragment,{children:[n$1,jsxs("span",{ref:P,"data-citation-id":m,"data-citation-instance":K,"data-url":g,"data-fetch-status":C,"data-variant":"bracket",className:n("cursor-pointer transition-colors",S.className,r),title:o?g:void 0,onMouseEnter:h$1?void 0:y,onMouseLeave:h$1?void 0:E,onMouseDown:O,onClick:b=>b.stopPropagation(),role:"link","aria-label":`Link to ${M}: ${S.label}`,children:["[",i&&jsx(ie,{url:g,faviconUrl:w}),jsx("span",{className:"max-w-[200px] overflow-hidden text-ellipsis whitespace-nowrap",children:D}),_(),"]"]})]})});we.displayName="UrlCitationComponent";memo(we);var it=({className:e})=>jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"square",shapeRendering:"crispEdges",className:e,children:[jsx("path",{d:"M7 3 L3 3 L3 21 L7 21"}),jsx("path",{d:"M17 3 L21 3 L21 21 L17 21"})]}),Q=({className:e})=>jsx("svg",{className:g("w-[0.7em] h-[0.7em]",e),viewBox:"0 0 256 256",fill:"currentColor","aria-hidden":"true",children:jsx("path",{d:"M229.66,77.66l-128,128a8,8,0,0,1-11.32,0l-56-56a8,8,0,0,1,11.32-11.32L96,188.69,218.34,66.34a8,8,0,0,1,11.32,11.32Z"})}),ce=({className:e})=>jsx("svg",{className:g("w-[0.7em] h-[0.7em]",e),viewBox:"0 0 256 256",fill:"currentColor","aria-hidden":"true",children:jsx("path",{d:"M236.8,188.09,149.35,36.22h0a24.76,24.76,0,0,0-42.7,0L19.2,188.09a23.51,23.51,0,0,0,0,23.72A24.35,24.35,0,0,0,40.55,224h174.9a24.35,24.35,0,0,0,21.33-12.19A23.51,23.51,0,0,0,236.8,188.09ZM120,104a8,8,0,0,1,16,0v40a8,8,0,0,1-16,0Zm8,88a12,12,0,1,1,12-12A12,12,0,0,1,128,192Z"})}),de=({className:e})=>jsxs("svg",{className:g("w-[0.7em] h-[0.7em] animate-spin",e),xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]});function st(...e){return e.filter(Boolean).join(" ")}var Ee=R.Root,_e=R.Trigger;var ue=Ie.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},a)=>jsx(R.Portal,{children:jsx(R.Content,{ref:a,align:t,sideOffset:n,className:st("z-50 max-w-sm rounded-md border bg-white p-1 shadow-md outline-none","border-gray-200 dark:border-gray-700 dark:bg-gray-900","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95","data-[side=bottom]:slide-in-from-top-2","data-[side=left]:slide-in-from-right-2","data-[side=right]:slide-in-from-left-2","data-[side=top]:slide-in-from-bottom-2",e),...r})}));ue.displayName=R.Content.displayName;function Ve(e,t,n=(r,a)=>r===a){let r=e.length,a=t.length;if(r===0&&a===0)return [];if(r===0)return [{value:t.join(""),added:true,count:t.length}];if(a===0)return [{value:e.join(""),removed:true,count:e.length}];let o=0;for(;o<r&&o<a&&n(e[o],t[o]);)o++;let i=0;for(;i<r-o&&i<a-o&&n(e[r-1-i],t[a-1-i]);)i++;let d=e.slice(o,r-i),s=t.slice(o,a-i);if(d.length===0&&s.length===0)return [{value:e.join(""),count:e.length}];let l=lt(d,s,n),u=[];return o>0&&u.push({value:e.slice(0,o).join(""),count:o}),u.push(...l),i>0&&u.push({value:e.slice(r-i).join(""),count:i}),Te(u)}function lt(e,t,n){let r=e.length,a=t.length,o=r+a,i={1:0},d=[];e:for(let s=0;s<=o;s++){d.push({...i});for(let l=-s;l<=s;l+=2){let u;l===-s||l!==s&&i[l-1]<i[l+1]?u=i[l+1]:u=i[l-1]+1;let p=u-l;for(;u<r&&p<a&&n(e[u],t[p]);)u++,p++;if(i[l]=u,u>=r&&p>=a)break e}}return ct(d,e,t)}function ct(e,t,n){let r=[],a=t.length,o=n.length;for(let i=e.length-1;i>=0;i--){let d=e[i],s=a-o,l;s===-i||s!==i&&d[s-1]<d[s+1]?l=s+1:l=s-1;let u=d[l]??0,p=u-l;for(;a>u&&o>p;)a--,o--,r.unshift({value:t[a],count:1});i>0&&(a===u?(o--,r.unshift({value:n[o],added:true,count:1})):(a--,r.unshift({value:t[a],removed:true,count:1})));}return r}function Te(e){if(e.length===0)return [];let t=[];for(let n of e){let r=t[t.length-1];r&&r.added===n.added&&r.removed===n.removed?(r.value+=n.value,r.count=(r.count||1)+(n.count||1)):t.push({...n});}return t}function Le(e){if(!e)return [];let t=[],n="";for(let r=0;r<e.length;r++){let a=e[r];n+=a,a===`
2
+ `&&(t.push(n),n="");}return n.length>0&&t.push(n),t}var De="a-zA-Z0-9_\\u00AD\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02C6\\u02C8-\\u02D7\\u02DE-\\u02FF\\u1E00-\\u1EFF",dt=new RegExp(`[${De}]+|\\s+|[^${De}]`,"gu");function Re(e){return e?e.match(dt)||[]:[]}function Be(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;return e.slice(0,n)}function pe(e,t){let n=0;for(;n<e.length&&n<t.length&&e[e.length-1-n]===t[t.length-1-n];)n++;return e.slice(e.length-n)}function ut(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r.removed&&e[n+1]?.added){let a=r,o=e[n+1],d=Be(a.value,o.value).match(/^\s*/)?.[0]||"",s=a.value.slice(d.length),l=o.value.slice(d.length),p=pe(s,l).match(/\s*$/)?.[0]||"";d&&t.push({value:d,count:1});let h=a.value.slice(d.length,a.value.length-p.length),P=o.value.slice(d.length,o.value.length-p.length);h&&t.push({value:h,removed:true,count:1}),P&&t.push({value:P,added:true,count:1}),p&&t.push({value:p,count:1}),n++;continue}if(r.added&&n>0&&!e[n-1].added&&!e[n-1].removed){let a=t[t.length-1];if(a&&!a.added&&!a.removed){let o=r.value.match(/^\s*/)?.[0]||"",i=a.value.match(/\s*$/)?.[0]||"";if(o&&i){let d=pe(i,o);if(d){t.push({value:r.value.slice(d.length),added:true,count:1});continue}}}}if(r.removed&&!e[n+1]?.added&&n>0&&!e[n-1]?.added&&!e[n-1]?.removed){let a=t[t.length-1],o=e[n+1];if(a&&o&&!o.added&&!o.removed){let i=r.value.match(/^\s*/)?.[0]||"",d=r.value.match(/\s*$/)?.[0]||"",s=a.value.match(/\s*$/)?.[0]||"",l=o.value.match(/^\s*/)?.[0]||"";if(i&&s&&pe(s,i).length===i.length){t.push({value:r.value.slice(i.length),removed:true,count:1});continue}if(d&&l&&Be(d,l).length===d.length){t.push({value:r.value.slice(0,-d.length)||r.value,removed:true,count:1});continue}}}t.push({...r});}return Te(t)}function Ue(e,t){let n=Le(e),r=Le(t);return Ve(n,r)}function We(e,t){let n=Re(e),r=Re(t),a=Ve(n,r);return ut(a)}var Ae=(e="",t="")=>useMemo(()=>{let n=(e||"").trim().replace(/\r\n/g,`
3
+ `),r=(t||"").trim().replace(/\r\n/g,`
4
+ `),a=Ue(n,r),o=[],i=false,d=0;for(let u=0;u<a.length;u++){let p=a[u],h=a[u+1];if(p.removed&&h&&h.added){let P=We(p.value,h.value);o.push({type:"modified",parts:P}),i=true,d+=Math.abs(p.value.length-h.value.length),u++;}else p.added||p.removed?(o.push({type:p.added?"added":"removed",parts:[{value:p.value,added:p.added,removed:p.removed}]}),i=true,d+=p.value.length):o.push({type:"unchanged",parts:[{value:p.value}]});}let s=Math.max(n.length,r.length),l=s===0?1:1-d/s;return {diffResult:o,hasDiff:i,similarity:l,isHighVariance:l<.6}},[e,t]);function xt(e){switch(e){case "chip":case "text":case "brackets":return "keySpan";default:return "number"}}function ht(e){return e.replace(/^\[+\s*/,"").replace(/\s*\]+$/,"")}function vt(e,t,n){if(t==="indicator")return "";if(t==="keySpan"){let r=e.keySpan?.toString()||e.citationNumber?.toString()||n||"1";return ht(r)}return e.citationNumber?.toString()||"1"}function Ct(e){return e.isVerified&&!e.isPartialMatch?"Verified":e.isPartialMatch?"Partial Match":e.isMiss?"Not Found":e.isPending?"Verifying...":""}function bt(e){let t=e?.status;if(!e||!t)return {isVerified:false,isMiss:false,isPartialMatch:false,isPending:false};let n=t==="not_found",r=t==="pending"||t==="loading",a=t==="partial_text_found"||t==="found_on_other_page"||t==="found_on_other_line"||t==="first_word_found";return {isVerified:t==="found"||t==="found_key_span_only"||t==="found_phrase_missed_value"||a,isMiss:n,isPartialMatch:a,isPending:r}}function yt({src:e,alt:t,onClose:n}){return useEffect(()=>{let r=a=>{a.key==="Escape"&&n();};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[n]),createPortal(jsx("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/80 backdrop-blur-sm animate-in fade-in-0",onClick:n,role:"dialog","aria-modal":"true","aria-label":"Full size verification image",children:jsx("div",{className:"relative max-w-[95vw] max-h-[95vh] cursor-zoom-out",children:jsx("img",{src:e,alt:t,className:"max-w-full max-h-[95vh] object-contain rounded-lg shadow-2xl",draggable:false})})}),document.body)}var kt=()=>jsx("span",{className:"inline-flex relative ml-0.5 text-green-600 dark:text-green-500","aria-hidden":"true",children:jsx(Q,{})}),Pt=()=>jsx("span",{className:"inline-flex relative ml-0.5 text-amber-600 dark:text-amber-500","aria-hidden":"true",children:jsx(Q,{})}),Nt=()=>jsx("span",{className:"inline-flex ml-1 text-gray-400 dark:text-gray-500","aria-hidden":"true",children:jsx(de,{})}),wt=()=>jsx("span",{className:"inline-flex relative ml-0.5 text-red-500 dark:text-red-400","aria-hidden":"true",children:jsx(ce,{})});function Mt({citation:e,verification:t,status:n,onImageClick:r}){let a=t?.verificationImageBase64,{isMiss:o,isPartialMatch:i}=n;if(a)return jsxs("div",{className:"p-1",children:[jsx("button",{type:"button",className:"block cursor-zoom-in",onClick:u=>{u.preventDefault(),u.stopPropagation(),r?.();},"aria-label":"Click to view full size",children:jsx("img",{src:t.verificationImageBase64,alt:"Citation verification",className:"max-w-[700px] max-h-[500px] w-auto h-auto object-contain rounded bg-gray-50 dark:bg-gray-800",loading:"lazy"})}),(o||i)&&jsx(Oe,{citation:e,verification:t,status:n})]});let d=Ct(n),s=t?.verifiedMatchSnippet,l=t?.verifiedPageNumber;return !s&&!d?null:jsxs("div",{className:"p-3 flex flex-col gap-2 min-w-[200px] max-w-[400px]",children:[d&&jsx("span",{className:g("text-xs font-medium",n.isVerified&&!n.isPartialMatch&&"text-green-600 dark:text-green-500",n.isPartialMatch&&"text-amber-600 dark:text-amber-500",n.isMiss&&"text-red-600 dark:text-red-500",n.isPending&&"text-gray-500 dark:text-gray-400"),children:d}),s&&jsxs("span",{className:"text-sm text-gray-700 dark:text-gray-300 italic",children:['"',t.verifiedMatchSnippet,'"']}),l&&l>0&&jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Page ",l]}),(o||i)&&jsx(Oe,{citation:e,verification:t,status:n})]})}function Oe({citation:e,verification:t,status:n}){let{isMiss:r,isPartialMatch:a}=n,o=e.fullPhrase||e.keySpan?.toString()||"",i=t?.verifiedMatchSnippet||"",{diffResult:d,hasDiff:s,isHighVariance:l}=Ae(o,i);if(!r&&!a)return null;let u=e.lineIds,p=t?.verifiedLineIds,h=u&&p&&JSON.stringify(u)!==JSON.stringify(p),P=e.pageNumber,g=t?.verifiedPageNumber,A=P!=null&&g!=null&&P!==g;return r?jsxs("div",{className:"mt-2 pt-2 border-t border-gray-200 dark:border-gray-700 text-xs space-y-2",children:[o&&jsxs("div",{children:[jsx("span",{className:"text-gray-500 dark:text-gray-400 font-medium uppercase text-[10px]",children:"Expected"}),jsx("p",{className:"mt-1 p-2 bg-gray-100 dark:bg-gray-800 rounded font-mono text-[11px] break-words text-red-600 dark:text-red-400 line-through opacity-70",children:o.length>100?o.slice(0,100)+"\u2026":o})]}),jsxs("div",{children:[jsx("span",{className:"text-gray-500 dark:text-gray-400 font-medium uppercase text-[10px]",children:"Found"}),jsx("p",{className:"mt-1 p-2 bg-gray-100 dark:bg-gray-800 rounded font-mono text-[11px] text-amber-600 dark:text-amber-500 italic",children:"Not found in source"})]})]}):jsxs("div",{className:"mt-2 pt-2 border-t border-gray-200 dark:border-gray-700 text-xs space-y-2",children:[o&&i&&s?jsxs("div",{children:[jsx("span",{className:"text-gray-500 dark:text-gray-400 font-medium uppercase text-[10px]",children:"Diff"}),jsx("div",{className:"mt-1 p-2 bg-gray-100 dark:bg-gray-800 rounded font-mono text-[11px] break-words text-gray-700 dark:text-gray-300",children:l?jsxs("div",{className:"space-y-2",children:[jsxs("div",{children:[jsxs("span",{className:"text-gray-500 dark:text-gray-400 text-[10px]",children:["Expected:"," "]}),jsx("span",{className:"text-red-600 dark:text-red-400 line-through opacity-70",children:o.length>100?o.slice(0,100)+"\u2026":o})]}),jsxs("div",{children:[jsxs("span",{className:"text-gray-500 dark:text-gray-400 text-[10px]",children:["Found:"," "]}),jsx("span",{className:"text-green-600 dark:text-green-400",children:i.length>100?i.slice(0,100)+"\u2026":i})]})]}):d.map((N,C)=>jsx("span",{children:N.parts.map((w,B)=>{let v=`p-${C}-${B}`;return w.removed?jsx("span",{className:"bg-red-200 dark:bg-red-900/50 text-red-700 dark:text-red-300 line-through",title:"Expected text",children:w.value},v):w.added?jsx("span",{className:"bg-green-200 dark:bg-green-900/50 text-green-700 dark:text-green-300",title:"Actual text found",children:w.value},v):jsx("span",{children:w.value},v)})},`block-${C}`))})]}):o&&!s?jsxs("div",{children:[jsx("span",{className:"text-gray-500 dark:text-gray-400 font-medium uppercase text-[10px]",children:"Text"}),jsx("p",{className:"mt-1 p-2 bg-gray-100 dark:bg-gray-800 rounded font-mono text-[11px] break-words text-gray-700 dark:text-gray-300",children:o.length>100?o.slice(0,100)+"\u2026":o})]}):null,A&&jsxs("div",{children:[jsx("span",{className:"text-gray-500 dark:text-gray-400 font-medium uppercase text-[10px]",children:"Page"}),jsxs("p",{className:"mt-1 font-mono text-[11px] text-gray-700 dark:text-gray-300",children:[jsx("span",{className:"text-red-600 dark:text-red-400 line-through opacity-70",children:P})," \u2192 ",g]})]}),h&&jsxs("div",{children:[jsx("span",{className:"text-gray-500 dark:text-gray-400 font-medium uppercase text-[10px]",children:"Line"}),jsxs("p",{className:"mt-1 font-mono text-[11px] text-gray-700 dark:text-gray-300",children:[jsx("span",{className:"text-red-600 dark:text-red-400 line-through opacity-70",children:u?.join(", ")})," \u2192 ",p?.join(", ")]})]})]})}var xe=forwardRef(({citation:e,children:t,className:n,fallbackDisplay:r,verification:a,isLoading:o=false,variant:i="brackets",content:d,eventHandlers:s,behaviorConfig:l,isMobile:u=false,renderIndicator:p,renderContent:h$1,popoverPosition:P="top",renderPopoverContent:g$1},A)=>{let N=useMemo(()=>d||xt(i),[d,i]),[C,w]=useState(false),[B,v]=useState(null),m=useMemo(()=>h(e),[e]),K=useMemo(()=>j(m),[m]),M=useMemo(()=>bt(a),[a]),{isMiss:L,isPartialMatch:D,isVerified:S,isPending:Z}=M,ee=5e3,[te,G]=useState(false),T=useRef(null),O=a?.verificationImageBase64||a?.status==="found"||a?.status==="found_key_span_only"||a?.status==="found_phrase_missed_value"||a?.status==="not_found"||a?.status==="partial_text_found"||a?.status==="found_on_other_page"||a?.status==="found_on_other_line"||a?.status==="first_word_found",y=(o||Z)&&!O&&!te;useEffect(()=>(T.current&&(clearTimeout(T.current),T.current=null),(o||Z)&&!O?(G(false),T.current=setTimeout(()=>{G(true);},ee)):G(false),()=>{T.current&&clearTimeout(T.current);}),[o,Z,O]);let E=useMemo(()=>vt(e,N,r),[e,N,r]),_=useCallback(()=>({citation:e,citationKey:m,verification:a??null,isTooltipExpanded:C,isImageExpanded:!!B,hasImage:!!a?.verificationImageBase64}),[e,m,a,C,B]),b=useCallback(x=>{x.setImageExpanded!==void 0&&(typeof x.setImageExpanded=="string"?v(x.setImageExpanded):x.setImageExpanded===true&&a?.verificationImageBase64?v(a.verificationImageBase64):x.setImageExpanded===false&&v(null));},[a?.verificationImageBase64]),ze=useCallback(x=>{x.preventDefault(),x.stopPropagation();let X=_();if(l?.onClick){let re=l.onClick(X,x);re&&typeof re=="object"&&b(re),s?.onClick?.(e,m,x);return}if(s?.onClick){s.onClick(e,m,x);return}a?.verificationImageBase64&&v(a.verificationImageBase64);},[l,s,e,m,a?.verificationImageBase64,_,b]),he=150,$=useRef(null),ne=useRef(false),U=useCallback(()=>{$.current&&(clearTimeout($.current),$.current=null);},[]),je=useCallback(()=>{U(),w(true),l?.onHover?.onEnter&&l.onHover.onEnter(_()),s?.onMouseEnter?.(e,m);},[s,l,e,m,_,U]),Fe=useCallback(()=>{U(),$.current=setTimeout(()=>{ne.current||(w(false),l?.onHover?.onLeave&&l.onHover.onLeave(_()),s?.onMouseLeave?.(e,m));},he);},[s,l,e,m,_,U]),He=useCallback(()=>{U(),ne.current=true;},[U]),Ke=useCallback(()=>{ne.current=false,U(),$.current=setTimeout(()=>{w(false),l?.onHover?.onLeave&&l.onHover.onLeave(_()),s?.onMouseLeave?.(e,m);},he);},[s,l,e,m,_,U]);useEffect(()=>()=>{$.current&&clearTimeout($.current);},[]);let Ze=useCallback(x=>{u&&(x.preventDefault(),x.stopPropagation(),s?.onTouchEnd?.(e,m,x));},[s,e,m,u]);if(r!=null&&N==="keySpan"&&L)return jsx("span",{className:g("text-gray-400 dark:text-gray-500",n),children:r});let ae=g((S||D)&&i==="brackets"&&"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 hover:underline",L&&"opacity-70 line-through text-gray-400 dark:text-gray-500",y&&"text-gray-500 dark:text-gray-400"),z=()=>p?p(M):y?jsx(Nt,{}):L?jsx(wt,{}):D?jsx(Pt,{}):S?jsx(kt,{}):null,ve=()=>{if(h$1)return h$1({citation:e,status:M,citationKey:m,displayText:E,isMergedDisplay:N==="keySpan"});if(N==="indicator")return jsx("span",{children:z()});if(i==="chip"){let x=g(S&&!D&&!y&&"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",D&&!y&&"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400",L&&!y&&"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400 line-through",y&&"bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-400",!S&&!L&&!y&&"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400");return jsxs("span",{className:g("inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-sm font-medium",x),children:[jsx("span",{className:"max-w-60 overflow-hidden text-ellipsis whitespace-nowrap",children:E}),z()]})}if(i==="superscript"){let x=g(S&&!D&&!y&&"text-green-600 dark:text-green-500",D&&!y&&"text-amber-600 dark:text-amber-500",L&&!y&&"text-red-500 dark:text-red-400 line-through",y&&"text-gray-400 dark:text-gray-500",!S&&!L&&!y&&"text-blue-600 dark:text-blue-400");return jsxs("sup",{className:g("text-xs font-medium transition-colors hover:underline",x),children:["[",E,z(),"]"]})}return i==="text"?jsxs("span",{className:ae,children:[E,z()]}):i==="minimal"?jsxs("span",{className:g("max-w-80 overflow-hidden text-ellipsis",ae),children:[E,z()]}):jsxs("span",{className:g("inline-flex items-baseline gap-0.5 whitespace-nowrap","font-mono text-xs leading-tight","text-gray-500 dark:text-gray-400","transition-colors"),"aria-hidden":"true",children:["[",jsxs("span",{className:g("max-w-80 overflow-hidden text-ellipsis",ae),children:[E,z()]}),"]"]})},Ge=!(P==="hidden")&&a&&(a.verificationImageBase64||a.verifiedMatchSnippet),Xe=!!a?.verificationImageBase64,Ce=B?jsx(yt,{src:B,alt:"Citation verification - full size",onClose:()=>v(null)}):null,be={"data-citation-id":m,"data-citation-instance":K,className:g("relative inline-flex items-baseline cursor-pointer","px-0.5 -mx-0.5 rounded-sm","transition-all duration-150","hover:bg-blue-500/10 dark:hover:bg-blue-400/10",Xe&&"hover:cursor-zoom-in",n),onMouseEnter:je,onMouseLeave:Fe,onClick:ze,onTouchEndCapture:u?Ze:void 0,"aria-label":E?`[${E}]`:void 0};if(Ge){let x=g$1?g$1({citation:e,verification:a??null,status:M}):jsx(Mt,{citation:e,verification:a??null,status:M,onImageClick:()=>{a?.verificationImageBase64&&v(a.verificationImageBase64);}});return jsxs(Fragment,{children:[t,jsxs(Ee,{open:C,children:[jsx(_e,{asChild:true,children:jsx("span",{ref:A,...be,children:ve()})}),jsx(ue,{side:P==="bottom"?"bottom":"top",onPointerDownOutside:X=>X.preventDefault(),onInteractOutside:X=>X.preventDefault(),onMouseEnter:He,onMouseLeave:Ke,children:x})]}),Ce]})}return jsxs(Fragment,{children:[t,jsx("span",{ref:A,...be,children:ve()}),Ce]})});xe.displayName="CitationComponent";var St=memo(xe);export{Q as CheckIcon,xe as CitationComponent,it as DeepCitationIcon,St as MemoizedCitationComponent,de as SpinnerIcon,ce as WarningIcon,le as extractDomain,Pe as isBlockedStatus,Ne as isErrorStatus,rt as isVerifiedStatus};
@@ -0,0 +1 @@
1
+ 'use strict';var chunkCFXDRAJL_cjs=require('../chunk-CFXDRAJL.cjs');require('../chunk-F2MMVEVC.cjs');Object.defineProperty(exports,"BLANK_VERIFICATION",{enumerable:true,get:function(){return chunkCFXDRAJL_cjs.d}});Object.defineProperty(exports,"DEFAULT_OUTPUT_IMAGE_FORMAT",{enumerable:true,get:function(){return chunkCFXDRAJL_cjs.a}});Object.defineProperty(exports,"NOT_FOUND_VERIFICATION_INDEX",{enumerable:true,get:function(){return chunkCFXDRAJL_cjs.b}});Object.defineProperty(exports,"PENDING_VERIFICATION_INDEX",{enumerable:true,get:function(){return chunkCFXDRAJL_cjs.c}});
@@ -0,0 +1,96 @@
1
+ interface PdfSpaceItem extends ScreenBox {
2
+ text?: string;
3
+ }
4
+ type IVertex = {
5
+ x: number;
6
+ y: number;
7
+ };
8
+ interface ScreenBox extends IVertex {
9
+ width: number;
10
+ height: number;
11
+ }
12
+
13
+ type SearchStatus = "loading" | "pending" | "not_found" | "partial_text_found" | "found" | "found_key_span_only" | "found_phrase_missed_value" | "found_on_other_page" | "found_on_other_line" | "first_word_found" | "timestamp_wip";
14
+ type SearchMethod = "exact_line_match" | "line_with_buffer" | "current_page" | "keyspan_fallback" | "adjacent_pages" | "expanded_window" | "regex_search" | "bm25_search" | "fuzzy_regex" | "first_word_fallback";
15
+ interface SearchAttempt {
16
+ method: SearchMethod;
17
+ success: boolean;
18
+ searchPhrases: string[];
19
+ pageSearched?: number;
20
+ matchedPhrases?: string[];
21
+ matchedVariation?: string;
22
+ phraseVariations?: string[];
23
+ matchQuality?: string;
24
+ isPartialMatch?: boolean;
25
+ matchScore?: number;
26
+ matchSnippet?: string;
27
+ notes?: string;
28
+ startTime?: number;
29
+ endTime?: number;
30
+ durationMs?: number;
31
+ }
32
+
33
+ declare const NOT_FOUND_VERIFICATION_INDEX = -1;
34
+ declare const PENDING_VERIFICATION_INDEX = -2;
35
+ declare const BLANK_VERIFICATION: Verification;
36
+ interface Verification {
37
+ attachmentId?: string | null;
38
+ label?: string | null;
39
+ citation?: Citation;
40
+ status?: SearchStatus | null;
41
+ searchAttempts?: SearchAttempt[];
42
+ highlightColor?: string | null;
43
+ verifiedPageNumber?: number | null;
44
+ verifiedLineIds?: number[] | null;
45
+ verifiedTimestamps?: {
46
+ startTime?: string;
47
+ endTime?: string;
48
+ } | null;
49
+ verifiedFullPhrase?: string | null;
50
+ verifiedKeySpan?: string | null;
51
+ verifiedMatchSnippet?: string | null;
52
+ hitIndexWithinPage?: number | null;
53
+ pdfSpaceItem?: PdfSpaceItem;
54
+ verificationImageBase64?: string | null;
55
+ verifiedAt?: Date;
56
+ }
57
+
58
+ type OutputImageFormat = "jpeg" | "png" | "avif" | undefined | null;
59
+ declare const DEFAULT_OUTPUT_IMAGE_FORMAT: "avif";
60
+ interface VerifyCitationResponse {
61
+ verifications: {
62
+ [key: string]: Verification;
63
+ };
64
+ }
65
+ interface VerifyCitationRequest {
66
+ attachmentId: string;
67
+ citations: {
68
+ [key: string]: Citation;
69
+ };
70
+ outputImageFormat?: OutputImageFormat;
71
+ apiKey?: string;
72
+ }
73
+ interface Citation {
74
+ attachmentId?: string;
75
+ fullPhrase?: string | null;
76
+ keySpan?: string | null;
77
+ startPageKey?: string | null;
78
+ lineIds?: number[] | null;
79
+ reasoning?: string | null;
80
+ selection?: ScreenBox | null;
81
+ citationNumber?: number;
82
+ pageNumber?: number | null;
83
+ timestamps?: {
84
+ endTime?: string;
85
+ startTime?: string;
86
+ };
87
+ beforeCite?: string;
88
+ }
89
+ interface CitationStatus {
90
+ isVerified: boolean;
91
+ isMiss: boolean;
92
+ isPartialMatch: boolean;
93
+ isPending: boolean;
94
+ }
95
+
96
+ export { BLANK_VERIFICATION, type Citation, type CitationStatus, DEFAULT_OUTPUT_IMAGE_FORMAT, type IVertex, NOT_FOUND_VERIFICATION_INDEX, type OutputImageFormat, PENDING_VERIFICATION_INDEX, type PdfSpaceItem, type ScreenBox, type SearchAttempt, type SearchMethod, type SearchStatus, type Verification, type VerifyCitationRequest, type VerifyCitationResponse };