@e-llm-studio/citation 0.0.251 → 0.0.252

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 (231) hide show
  1. package/dist/cjs/features/CognitiveCompare/CitationAnchor.js +1 -1
  2. package/dist/cjs/features/CognitiveCompare/CitationAnchor.js.map +1 -1
  3. package/dist/cjs/features/CognitiveCompare/CitationRenderer.js +1 -1
  4. package/dist/cjs/features/CognitiveCompare/CitationRenderer.js.map +1 -1
  5. package/dist/cjs/features/CognitiveCompare/CitationRendererInner.js +2 -0
  6. package/dist/cjs/features/CognitiveCompare/CitationRendererInner.js.map +1 -0
  7. package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js +1 -1
  8. package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js.map +1 -1
  9. package/dist/cjs/features/CognitiveCompare/CognitiveCompareConstants.js +1 -1
  10. package/dist/cjs/features/CognitiveCompare/CognitiveCompareConstants.js.map +1 -1
  11. package/dist/cjs/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
  12. package/dist/cjs/features/CognitiveCompare/CognitiveComparehelpers.js.map +1 -1
  13. package/dist/cjs/features/CognitiveCompare/CognitivePopup.js +1 -1
  14. package/dist/cjs/features/CognitiveCompare/CognitivePopup.js.map +1 -1
  15. package/dist/cjs/features/CognitiveCompare/CompareContext.js +1 -1
  16. package/dist/cjs/features/CognitiveCompare/CompareContext.js.map +1 -1
  17. package/dist/cjs/features/CognitiveCompare/GptWebCitationPanel.js +2 -0
  18. package/dist/cjs/features/CognitiveCompare/GptWebCitationPanel.js.map +1 -0
  19. package/dist/cjs/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js +1 -1
  20. package/dist/cjs/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js.map +1 -1
  21. package/dist/cjs/features/CognitiveCompare/Guidelines/components/WebGptPanel.js +1 -1
  22. package/dist/cjs/features/CognitiveCompare/Guidelines/components/WebGptPanel.js.map +1 -1
  23. package/dist/cjs/features/CognitiveCompare/Guidelines/utils/guidelineTargets.js +2 -0
  24. package/dist/cjs/features/CognitiveCompare/Guidelines/utils/guidelineTargets.js.map +1 -0
  25. package/dist/cjs/features/CognitiveCompare/Guidelines/utils/hasGptCitationObjects.js +2 -0
  26. package/dist/cjs/features/CognitiveCompare/Guidelines/utils/hasGptCitationObjects.js.map +1 -0
  27. package/dist/cjs/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js +1 -1
  28. package/dist/cjs/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js.map +1 -1
  29. package/dist/cjs/features/CognitiveCompare/Guidelines/utils/resolveGuidelineSelection.js +2 -0
  30. package/dist/cjs/features/CognitiveCompare/Guidelines/utils/resolveGuidelineSelection.js.map +1 -0
  31. package/dist/cjs/features/CognitiveCompare/components/GuidelineSkeletonLoader.js +2 -0
  32. package/dist/cjs/features/CognitiveCompare/components/GuidelineSkeletonLoader.js.map +1 -0
  33. package/dist/cjs/features/CognitiveCompare/components/LHSSectionRow.js +1 -1
  34. package/dist/cjs/features/CognitiveCompare/components/LHSSectionRow.js.map +1 -1
  35. package/dist/cjs/features/CognitiveCompare/components/RHSSectionRow.js +1 -1
  36. package/dist/cjs/features/CognitiveCompare/components/RHSSectionRow.js.map +1 -1
  37. package/dist/cjs/features/CognitiveCompare/components/SectionAccordion.js +1 -1
  38. package/dist/cjs/features/CognitiveCompare/components/SectionAccordion.js.map +1 -1
  39. package/dist/cjs/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
  40. package/dist/cjs/features/CognitiveCompare/components/SubSectionAccordion.js.map +1 -1
  41. package/dist/cjs/features/CognitiveCompare/components/SvgConnectors.js +1 -1
  42. package/dist/cjs/features/CognitiveCompare/components/SvgConnectors.js.map +1 -1
  43. package/dist/cjs/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
  44. package/dist/cjs/features/CognitiveCompare/hooks/memoizedMarkdown.js.map +1 -1
  45. package/dist/cjs/features/CognitiveCompare/hooks/useCompareData.js +1 -1
  46. package/dist/cjs/features/CognitiveCompare/hooks/useCompareData.js.map +1 -1
  47. package/dist/cjs/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
  48. package/dist/cjs/features/CognitiveCompare/hooks/useLinesCalculator.js.map +1 -1
  49. package/dist/cjs/features/CognitiveCompare/hooks/useOnDemandCitationCache.js +2 -0
  50. package/dist/cjs/features/CognitiveCompare/hooks/useOnDemandCitationCache.js.map +1 -0
  51. package/dist/cjs/features/CognitiveCompare/hooks/useSideBySide.js +1 -1
  52. package/dist/cjs/features/CognitiveCompare/hooks/useSideBySide.js.map +1 -1
  53. package/dist/cjs/features/CognitiveCompare/onDemandCitations/cacheKey.js +2 -0
  54. package/dist/cjs/features/CognitiveCompare/onDemandCitations/cacheKey.js.map +1 -0
  55. package/dist/cjs/features/CognitiveCompare/onDemandCitations/contextBuilder.js +2 -0
  56. package/dist/cjs/features/CognitiveCompare/onDemandCitations/contextBuilder.js.map +1 -0
  57. package/dist/cjs/features/CognitiveCompare/onDemandCitations/href.js +2 -0
  58. package/dist/cjs/features/CognitiveCompare/onDemandCitations/href.js.map +1 -0
  59. package/dist/cjs/features/CognitiveCompare/onDemandCitations/payload.js +2 -0
  60. package/dist/cjs/features/CognitiveCompare/onDemandCitations/payload.js.map +1 -0
  61. package/dist/cjs/features/CognitiveCompare/onDemandCitations/response.js +2 -0
  62. package/dist/cjs/features/CognitiveCompare/onDemandCitations/response.js.map +1 -0
  63. package/dist/cjs/features/CognitiveCompare/utils/normalizeCompactedGfmTables.js +2 -0
  64. package/dist/cjs/features/CognitiveCompare/utils/normalizeCompactedGfmTables.js.map +1 -0
  65. package/dist/cjs/features/CognitiveCompare/utils/normalizeInlineMarkdown.js +2 -0
  66. package/dist/cjs/features/CognitiveCompare/utils/normalizeInlineMarkdown.js.map +1 -0
  67. package/dist/cjs/features/CognitiveCompare/utils/normalizeRedlineMarkdown.js +2 -0
  68. package/dist/cjs/features/CognitiveCompare/utils/normalizeRedlineMarkdown.js.map +1 -0
  69. package/dist/cjs/features/SegmentReviewComponents/BoundaryCard.js +1 -1
  70. package/dist/cjs/features/SegmentReviewComponents/BoundaryCard.js.map +1 -1
  71. package/dist/cjs/features/SegmentReviewComponents/SegmentReviewPdfWrapper.js +1 -1
  72. package/dist/cjs/features/SegmentReviewComponents/SegmentReviewPdfWrapper.js.map +1 -1
  73. package/dist/features/CognitiveCompare/CitationAnchor.js +1 -1
  74. package/dist/features/CognitiveCompare/CitationAnchor.js.map +1 -1
  75. package/dist/features/CognitiveCompare/CitationRenderer.js +1 -1
  76. package/dist/features/CognitiveCompare/CitationRenderer.js.map +1 -1
  77. package/dist/features/CognitiveCompare/CitationRendererInner.js +2 -0
  78. package/dist/features/CognitiveCompare/CitationRendererInner.js.map +1 -0
  79. package/dist/features/CognitiveCompare/CognitiveCompare.js +1 -1
  80. package/dist/features/CognitiveCompare/CognitiveCompare.js.map +1 -1
  81. package/dist/features/CognitiveCompare/CognitiveCompareConstants.js +1 -1
  82. package/dist/features/CognitiveCompare/CognitiveCompareConstants.js.map +1 -1
  83. package/dist/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
  84. package/dist/features/CognitiveCompare/CognitiveComparehelpers.js.map +1 -1
  85. package/dist/features/CognitiveCompare/CognitivePopup.js +1 -1
  86. package/dist/features/CognitiveCompare/CognitivePopup.js.map +1 -1
  87. package/dist/features/CognitiveCompare/CompareContext.js +1 -1
  88. package/dist/features/CognitiveCompare/CompareContext.js.map +1 -1
  89. package/dist/features/CognitiveCompare/GptWebCitationPanel.js +2 -0
  90. package/dist/features/CognitiveCompare/GptWebCitationPanel.js.map +1 -0
  91. package/dist/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js +1 -1
  92. package/dist/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js.map +1 -1
  93. package/dist/features/CognitiveCompare/Guidelines/components/WebGptPanel.js +1 -1
  94. package/dist/features/CognitiveCompare/Guidelines/components/WebGptPanel.js.map +1 -1
  95. package/dist/features/CognitiveCompare/Guidelines/utils/guidelineTargets.js +2 -0
  96. package/dist/features/CognitiveCompare/Guidelines/utils/guidelineTargets.js.map +1 -0
  97. package/dist/features/CognitiveCompare/Guidelines/utils/hasGptCitationObjects.js +2 -0
  98. package/dist/features/CognitiveCompare/Guidelines/utils/hasGptCitationObjects.js.map +1 -0
  99. package/dist/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js +1 -1
  100. package/dist/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js.map +1 -1
  101. package/dist/features/CognitiveCompare/Guidelines/utils/resolveGuidelineSelection.js +2 -0
  102. package/dist/features/CognitiveCompare/Guidelines/utils/resolveGuidelineSelection.js.map +1 -0
  103. package/dist/features/CognitiveCompare/components/GuidelineSkeletonLoader.js +2 -0
  104. package/dist/features/CognitiveCompare/components/GuidelineSkeletonLoader.js.map +1 -0
  105. package/dist/features/CognitiveCompare/components/LHSSectionRow.js +1 -1
  106. package/dist/features/CognitiveCompare/components/LHSSectionRow.js.map +1 -1
  107. package/dist/features/CognitiveCompare/components/RHSSectionRow.js +1 -1
  108. package/dist/features/CognitiveCompare/components/RHSSectionRow.js.map +1 -1
  109. package/dist/features/CognitiveCompare/components/SectionAccordion.js +1 -1
  110. package/dist/features/CognitiveCompare/components/SectionAccordion.js.map +1 -1
  111. package/dist/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
  112. package/dist/features/CognitiveCompare/components/SubSectionAccordion.js.map +1 -1
  113. package/dist/features/CognitiveCompare/components/SvgConnectors.js +1 -1
  114. package/dist/features/CognitiveCompare/components/SvgConnectors.js.map +1 -1
  115. package/dist/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
  116. package/dist/features/CognitiveCompare/hooks/memoizedMarkdown.js.map +1 -1
  117. package/dist/features/CognitiveCompare/hooks/useCompareData.js +1 -1
  118. package/dist/features/CognitiveCompare/hooks/useCompareData.js.map +1 -1
  119. package/dist/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
  120. package/dist/features/CognitiveCompare/hooks/useLinesCalculator.js.map +1 -1
  121. package/dist/features/CognitiveCompare/hooks/useOnDemandCitationCache.js +2 -0
  122. package/dist/features/CognitiveCompare/hooks/useOnDemandCitationCache.js.map +1 -0
  123. package/dist/features/CognitiveCompare/hooks/useSideBySide.js +1 -1
  124. package/dist/features/CognitiveCompare/hooks/useSideBySide.js.map +1 -1
  125. package/dist/features/CognitiveCompare/onDemandCitations/cacheKey.js +2 -0
  126. package/dist/features/CognitiveCompare/onDemandCitations/cacheKey.js.map +1 -0
  127. package/dist/features/CognitiveCompare/onDemandCitations/contextBuilder.js +2 -0
  128. package/dist/features/CognitiveCompare/onDemandCitations/contextBuilder.js.map +1 -0
  129. package/dist/features/CognitiveCompare/onDemandCitations/href.js +2 -0
  130. package/dist/features/CognitiveCompare/onDemandCitations/href.js.map +1 -0
  131. package/dist/features/CognitiveCompare/onDemandCitations/payload.js +2 -0
  132. package/dist/features/CognitiveCompare/onDemandCitations/payload.js.map +1 -0
  133. package/dist/features/CognitiveCompare/onDemandCitations/response.js +2 -0
  134. package/dist/features/CognitiveCompare/onDemandCitations/response.js.map +1 -0
  135. package/dist/features/CognitiveCompare/utils/normalizeCompactedGfmTables.js +2 -0
  136. package/dist/features/CognitiveCompare/utils/normalizeCompactedGfmTables.js.map +1 -0
  137. package/dist/features/CognitiveCompare/utils/normalizeInlineMarkdown.js +2 -0
  138. package/dist/features/CognitiveCompare/utils/normalizeInlineMarkdown.js.map +1 -0
  139. package/dist/features/CognitiveCompare/utils/normalizeRedlineMarkdown.js +2 -0
  140. package/dist/features/CognitiveCompare/utils/normalizeRedlineMarkdown.js.map +1 -0
  141. package/dist/features/SegmentReviewComponents/BoundaryCard.js +1 -1
  142. package/dist/features/SegmentReviewComponents/BoundaryCard.js.map +1 -1
  143. package/dist/features/SegmentReviewComponents/SegmentReviewPdfWrapper.js +1 -1
  144. package/dist/features/SegmentReviewComponents/SegmentReviewPdfWrapper.js.map +1 -1
  145. package/dist/types/features/CognitiveCompare/CitationAnchor.d.ts +2 -0
  146. package/dist/types/features/CognitiveCompare/CitationAnchor.d.ts.map +1 -1
  147. package/dist/types/features/CognitiveCompare/CitationRenderer.d.ts +8 -1
  148. package/dist/types/features/CognitiveCompare/CitationRenderer.d.ts.map +1 -1
  149. package/dist/types/features/CognitiveCompare/CitationRendererInner.d.ts +13 -0
  150. package/dist/types/features/CognitiveCompare/CitationRendererInner.d.ts.map +1 -0
  151. package/dist/types/features/CognitiveCompare/CognitiveCompare.d.ts +1 -1
  152. package/dist/types/features/CognitiveCompare/CognitiveCompare.d.ts.map +1 -1
  153. package/dist/types/features/CognitiveCompare/CognitiveCompareConstants.d.ts +1 -1
  154. package/dist/types/features/CognitiveCompare/CognitiveCompareConstants.d.ts.map +1 -1
  155. package/dist/types/features/CognitiveCompare/CognitiveCompareTypes.d.ts +14 -1
  156. package/dist/types/features/CognitiveCompare/CognitiveCompareTypes.d.ts.map +1 -1
  157. package/dist/types/features/CognitiveCompare/CognitiveComparehelpers.d.ts +12 -0
  158. package/dist/types/features/CognitiveCompare/CognitiveComparehelpers.d.ts.map +1 -1
  159. package/dist/types/features/CognitiveCompare/CognitivePopup.d.ts.map +1 -1
  160. package/dist/types/features/CognitiveCompare/CompareContext.d.ts +10 -1
  161. package/dist/types/features/CognitiveCompare/CompareContext.d.ts.map +1 -1
  162. package/dist/types/features/CognitiveCompare/GptWebCitationPanel.d.ts +7 -0
  163. package/dist/types/features/CognitiveCompare/GptWebCitationPanel.d.ts.map +1 -0
  164. package/dist/types/features/CognitiveCompare/Guidelines/components/GuidelinePanel.d.ts.map +1 -1
  165. package/dist/types/features/CognitiveCompare/Guidelines/components/WebGptPanel.d.ts.map +1 -1
  166. package/dist/types/features/CognitiveCompare/Guidelines/utils/guidelineTargets.d.ts +3 -0
  167. package/dist/types/features/CognitiveCompare/Guidelines/utils/guidelineTargets.d.ts.map +1 -0
  168. package/dist/types/features/CognitiveCompare/Guidelines/utils/hasGptCitationObjects.d.ts +3 -0
  169. package/dist/types/features/CognitiveCompare/Guidelines/utils/hasGptCitationObjects.d.ts.map +1 -0
  170. package/dist/types/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.d.ts +14 -1
  171. package/dist/types/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.d.ts.map +1 -1
  172. package/dist/types/features/CognitiveCompare/Guidelines/utils/resolveGuidelineSelection.d.ts +19 -0
  173. package/dist/types/features/CognitiveCompare/Guidelines/utils/resolveGuidelineSelection.d.ts.map +1 -0
  174. package/dist/types/features/CognitiveCompare/components/GuidelineSkeletonLoader.d.ts +8 -0
  175. package/dist/types/features/CognitiveCompare/components/GuidelineSkeletonLoader.d.ts.map +1 -0
  176. package/dist/types/features/CognitiveCompare/components/LHSSectionRow.d.ts.map +1 -1
  177. package/dist/types/features/CognitiveCompare/components/RHSSectionRow.d.ts.map +1 -1
  178. package/dist/types/features/CognitiveCompare/components/SectionAccordion.d.ts.map +1 -1
  179. package/dist/types/features/CognitiveCompare/components/SubSectionAccordion.d.ts.map +1 -1
  180. package/dist/types/features/CognitiveCompare/components/SvgConnectors.d.ts +3 -2
  181. package/dist/types/features/CognitiveCompare/components/SvgConnectors.d.ts.map +1 -1
  182. package/dist/types/features/CognitiveCompare/hooks/memoizedMarkdown.d.ts +2 -1
  183. package/dist/types/features/CognitiveCompare/hooks/memoizedMarkdown.d.ts.map +1 -1
  184. package/dist/types/features/CognitiveCompare/hooks/useCompareData.d.ts +1 -1
  185. package/dist/types/features/CognitiveCompare/hooks/useCompareData.d.ts.map +1 -1
  186. package/dist/types/features/CognitiveCompare/hooks/useLinesCalculator.d.ts.map +1 -1
  187. package/dist/types/features/CognitiveCompare/hooks/useOnDemandCitationCache.d.ts +10 -0
  188. package/dist/types/features/CognitiveCompare/hooks/useOnDemandCitationCache.d.ts.map +1 -0
  189. package/dist/types/features/CognitiveCompare/hooks/useSideBySide.d.ts.map +1 -1
  190. package/dist/types/features/CognitiveCompare/onDemandCitations/cacheKey.d.ts +3 -0
  191. package/dist/types/features/CognitiveCompare/onDemandCitations/cacheKey.d.ts.map +1 -0
  192. package/dist/types/features/CognitiveCompare/onDemandCitations/contextBuilder.d.ts +16 -0
  193. package/dist/types/features/CognitiveCompare/onDemandCitations/contextBuilder.d.ts.map +1 -0
  194. package/dist/types/features/CognitiveCompare/onDemandCitations/href.d.ts +6 -0
  195. package/dist/types/features/CognitiveCompare/onDemandCitations/href.d.ts.map +1 -0
  196. package/dist/types/features/CognitiveCompare/onDemandCitations/index.d.ts +7 -0
  197. package/dist/types/features/CognitiveCompare/onDemandCitations/index.d.ts.map +1 -0
  198. package/dist/types/features/CognitiveCompare/onDemandCitations/payload.d.ts +4 -0
  199. package/dist/types/features/CognitiveCompare/onDemandCitations/payload.d.ts.map +1 -0
  200. package/dist/types/features/CognitiveCompare/onDemandCitations/response.d.ts +3 -0
  201. package/dist/types/features/CognitiveCompare/onDemandCitations/response.d.ts.map +1 -0
  202. package/dist/types/features/CognitiveCompare/onDemandCitations/types.d.ts +134 -0
  203. package/dist/types/features/CognitiveCompare/onDemandCitations/types.d.ts.map +1 -0
  204. package/dist/types/features/CognitiveCompare/utils/normalizeCompactedGfmTables.d.ts +7 -0
  205. package/dist/types/features/CognitiveCompare/utils/normalizeCompactedGfmTables.d.ts.map +1 -0
  206. package/dist/types/features/CognitiveCompare/utils/normalizeInlineMarkdown.d.ts +6 -0
  207. package/dist/types/features/CognitiveCompare/utils/normalizeInlineMarkdown.d.ts.map +1 -0
  208. package/dist/types/features/CognitiveCompare/utils/normalizeRedlineMarkdown.d.ts +6 -0
  209. package/dist/types/features/CognitiveCompare/utils/normalizeRedlineMarkdown.d.ts.map +1 -0
  210. package/dist/types/features/SegmentReviewComponents/BoundaryCard.d.ts.map +1 -1
  211. package/dist/types/features/SegmentReviewComponents/SegmentReviewPdfWrapper.d.ts +3 -1
  212. package/dist/types/features/SegmentReviewComponents/SegmentReviewPdfWrapper.d.ts.map +1 -1
  213. package/package.json +1 -1
  214. package/dist/cjs/features/Bookemon/BookemonStyles.js +0 -2
  215. package/dist/cjs/features/Bookemon/BookemonStyles.js.map +0 -1
  216. package/dist/cjs/lib/ui/icons.js +0 -2
  217. package/dist/cjs/lib/ui/icons.js.map +0 -1
  218. package/dist/cjs/lib/ui/materialCompat.js +0 -2
  219. package/dist/cjs/lib/ui/materialCompat.js.map +0 -1
  220. package/dist/features/Bookemon/BookemonStyles.js +0 -2
  221. package/dist/features/Bookemon/BookemonStyles.js.map +0 -1
  222. package/dist/lib/ui/icons.js +0 -2
  223. package/dist/lib/ui/icons.js.map +0 -1
  224. package/dist/lib/ui/materialCompat.js +0 -2
  225. package/dist/lib/ui/materialCompat.js.map +0 -1
  226. package/dist/types/features/Bookemon/BookemonStyles.d.ts +0 -6
  227. package/dist/types/features/Bookemon/BookemonStyles.d.ts.map +0 -1
  228. package/dist/types/lib/ui/icons.d.ts +0 -46
  229. package/dist/types/lib/ui/icons.d.ts.map +0 -1
  230. package/dist/types/lib/ui/materialCompat.d.ts +0 -117
  231. package/dist/types/lib/ui/materialCompat.d.ts.map +0 -1
@@ -1,2 +1,2 @@
1
- import{jsxs as e,jsx as t,Fragment as i}from"react/jsx-runtime";import{Globe as a,ChevronUp as o,ChevronDown as n,Maximize2 as r,X as l,ExternalLink as s}from"lucide-react";import{useState as c,useEffect as d,useMemo as p,useRef as u}from"react";import m from"./ResizableSplitPane.js";import h from"../PdfViewer/PdfViewer.js";import{DefaultFullScreenCloseIcon as g,DefaultFullScreenIcon as x}from"../../assests/svg/PdfViewerIcons.js";import f from"react-markdown";import b from"rehype-raw";import{Dialog as _,Box as y}from"@mui/material";import{SHARED_MARKDOWN_STYLES as w}from"./CognitiveCompareConfig.js";import"react-dom";import{useCompareContext as C}from"./CompareContext.js";import{processGuidelinesMarkdown as F}from"./Guidelines/utils/processGuidelinesMarkdown.js";import D from"../GptWebCitation/GptWebCitation.js";import{CitationType as v}from"../GptWebCitation/types.js";import"./components/SubSectionAccordion.js";import"./components/LHSSectionRow.js";import"./components/RHSSectionRow.js";const P=e=>(e?.extraMetaData||e)?.aiReasoningCitation?.gpt_citation?.[0]||null,T="https://dev-proposals-ai.techo.camp/utility/ca-workflow-composer-agent/get_citation",S="sai.siddhartha@techolution.com",k="672e32f7a0e8fe2e8e50bcba",N="TNV Sai Siddhartha",I="90vh",j=`calc(${I} - 120px)`,R=()=>"function"==typeof globalThis.crypto?.randomUUID?globalThis.crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.floor(16*Math.random());return("x"===e?t:t%4+8).toString(16)}),G=(e,t)=>{const i=(e=>e?.payloadCitationId||e?.extraMetaData?.payloadCitationId||"")(e)||t||R();return((e,t)=>{e&&"object"==typeof e&&(e.payloadCitationId=t,e.extraMetaData&&"object"==typeof e.extraMetaData&&(e.extraMetaData.payloadCitationId=t))})(e,i),i},U=({metaData:e,isFullscreen:i=!1})=>{const{gptWebCitationConfig:a}=C(),m=p(()=>(e=>({endpoint:e?.endpoint||T,userEmail:e?.userEmail||S,userId:e?.userId||k,userName:e?.userName||N,headers:e?.headers}))(a),[a]),h=e?.webGpt,g=u(null);g.current||(g.current=R());const x=p(()=>((e,t,i)=>{const a=P(e),o=a?.customMetaData||{},n=o?.value||{},r=e?.webSearchAnswer||{},l=e?.extraMetaData||e||{};return{userEmail:e?.userEmail||r?.userEmail||t?.userEmail||"",userId:e?.userId||r?.userId||t?.userId||"",userName:e?.userName||r?.userName||t?.userName||"",citationId:G(e,i),citationUrl:n?.citationUrl||r?.citationUrl||"",content:l?.Reasoning||r?.enhanced_content||"",citationType:n?.citationType||"web",citatioNumber:o?.citation_number??a?.citation_number??Number(e?.reasoningId||0)}})(h,m,g.current||void 0),[h,m]),f=p(()=>P(h),[h]),b=f?.customMetaData?.value||{},_=h?.extraMetaData||h||{},[y,w]=c(),[F,I]=c("pending"),[U,E]=c(!0);d(()=>{let e=!0;return(async()=>{if(m.endpoint&&x?.citationUrl&&x?.content){I("pending");try{const t=await fetch(m.endpoint,{method:"POST",headers:{"actor-id":x.userEmail,Accept:"application/json, text/plain, */*","Content-Type":"application/json",...m.headers||{}},body:JSON.stringify(x)});if(!t.ok)throw new Error(`Failed to fetch GPT web citation (${t.status})`);const i=await t.json();if(!e)return;w(i?.responseData||i?.result||i?.data||i),I("success")}catch(t){if(!e)return;console.error("Failed to load GPT web citation",t),I("error")}}else I("error")})(),()=>{e=!1}},[x,m]);const A=p(()=>({item:{confidence_score:Number(_?.Confidence_score||0),text:b?.paraphrase||"Web citation reasoning",dataSource:b?.text||_?.Reasoning||"",paraphrase:b?.paraphrase||""},headerTitle:"GPT Web Citation",index:Number(x?.citatioNumber||1)-1,iconsConfig:{ChevronDownIcon:n,ChevronUpIcon:o,MaximizeIcon:r,CloseIcon:l}}),[b,x?.citatioNumber,_]),H=p(()=>({...A,...i?{bodyHeight:j}:{}}),[A,i]);return t(D,{gptCitation:H,defaultCitationUrl:x?.citationUrl||"",citationType:v.GPT_WEB,webCitationData:y,webCitationStatus:F,showWebCitation:U,onToggleCitationView:()=>E(e=>!e),iconsConfig:{MaximizeIcon:r,ExternalLinkIcon:s},isFixedHeight:!0})},E=({href:e,metaData:a,citationTitle:o,citationType:n,citationReason:r,isFullscreen:l})=>{const{guidelinesData:s}=C(),{citationNumber:c,phraseToHighlight:d,citationTypeFromHref:u}=(e=>{try{const{citationNumber:t,parsedUrl:i}=(e=>{const t=e.match(/^(?:pdf_citation|deviation_summary)\$(\d+)/);if(t)try{const i=e.indexOf("?"),a=i>=0?e.slice(i):"";return{citationNumber:t[1],parsedUrl:new URL(a||"./",window.location.origin)}}catch{return{citationNumber:t[1],parsedUrl:null}}try{const t=new URL(e,window.location.origin);return{citationNumber:t.searchParams.get("citationNumber")||t.searchParams.get("citation_number"),parsedUrl:t}}catch{return{citationNumber:null,parsedUrl:null}}})(e),a=i?.searchParams.get("phrase_to_highlight")||null;return{citationNumber:t,phraseToHighlight:a,citationTypeFromHref:i?.searchParams.get("citation_type")||null}}catch{return{citationNumber:null,phraseToHighlight:null,citationTypeFromHref:null}}})(e),g=n||u||void 0,x="il_rulebook_citation"===g?"rulebook_citation":g,_=c&&a?.citations?.[c]||{},D=a?.docData?.documents||{},v=a?.docData?.input_index_map||{},P=Object.keys(a?.citations||{}).length>0||Object.keys(a?.docData||{}).length>0,T=v?.[0],S=v?.[1],k=T?D[T]:null,N=S?D[S]:null,I=T?_[T]:null,j=S?_[S]:null,R=p(()=>I&&k?t(h,{defaultScale:"PageWidth",showFullScreenAction:!1,showHighlightsAction:!1,pdfName:k?.title,pdfUrl:k?.signed_url,highlightText:[I?.highlighted_text??""],highlightPages:{1:I?.custom_metadata?.pdf_start_page_number},jumpToPageValue:1,highlightCordinatePages:[],useCoordinates:!1,useRange:!0,rangeOfPages:[I?.custom_metadata?.pdf_start_page_number,I?.custom_metadata?.pdf_end_page_number]}):null,[k?.title,k?.signed_url,I?.highlighted_text,I?.custom_metadata?.pdf_start_page_number,I?.custom_metadata?.pdf_end_page_number]),G=p(()=>j&&N?t(h,{defaultScale:"PageWidth",showFullScreenAction:!1,showHighlightsAction:!1,pdfName:N?.title,pdfUrl:N?.signed_url,jumpToPageValue:1,highlightText:[j?.highlighted_text??""],highlightPages:{1:j?.custom_metadata?.pdf_start_page_number},highlightCordinatePages:[],useCoordinates:!1,useRange:!0,rangeOfPages:[j?.custom_metadata?.pdf_start_page_number,j?.custom_metadata?.pdf_end_page_number]}):null,[N?.title,N?.signed_url,j?.highlighted_text,j?.custom_metadata?.pdf_start_page_number,j?.custom_metadata?.pdf_end_page_number]),E="dual_citation"===x,A=E&&!!a?.webGpt,H=p(()=>{if(!R)return null;const e=A?t(U,{metaData:a,isFullscreen:l}):"rulebook_citation"===x?t(i,{children:t(y,{sx:{padding:"0px 20px",backgroundColor:"#FFFFFF",borderRadius:"8px",...w,overflow:"auto"},children:t(f,{rehypePlugins:[b],children:F({guidelinesData:s,targetHighlights:[d],labelColor:"#FEF08A"})})})}):G;return e?t(m,{leftComponent:R,rightComponent:e,isFullscreen:l}):R},[R,G,x,A,a,l,s,d]);return a?.webGpt&&!P?t(U,{metaData:a,isFullscreen:l}):c?"rulebook_citation"===x?t("div",I?{style:{height:"100%",display:"flex",flexDirection:"column"},children:H}:{style:{padding:"12px",fontSize:"13px",color:"#344054",lineHeight:1.5},children:r||"Rulebook citation selected."}):E?I||j?t("div",{style:{height:"100%",display:"flex",flexDirection:"column"},children:H}):a?.webGpt?t(U,{metaData:a,isFullscreen:l}):t("div",{children:"Missing PDF Citation. Please try again later"}):["contract","clause"].includes(o)?t("div",I||j?{style:{height:"100%",display:"flex",flexDirection:"column"},children:H}:{children:"Missing PDF Citation. Please try again later"}):t("div",{children:"No Citation Found. Please try again later"}):null},A=({href:i,children:r,citationType:l,citationReason:s,metaData:p,chevronUpComponent:u=null,chevronDownComponent:m=null,customStyle:h={},defaultState:f=!1,onFullscreenChange:b})=>{const[y,w]=c(f),[C,F]=c(!1),D="string"==typeof r&&r?.split("\n")?.length>1?r.split("\n").join(" "):r;d(()=>{if(b?.(C),C)return()=>{b?.(!1)}},[C,b]);const v="string"==typeof r?r:r[0],P=u??(T=h?.arrow??{},t(o,{size:T?.fontSize??16,color:T?.color??"rgb(214, 51, 132)"}));var T;const S=m??(e=>t(n,{size:e?.fontSize??16,color:e?.color??"rgb(214, 51, 132)"}))(h?.arrow??{}),k=e("div",{style:{boxSizing:"border-box",border:C?"none":"1px solid #E4E7EC",borderRadius:C?0:"8px",overflow:"hidden",marginTop:C?0:"8px",display:"flex",flexDirection:"column",width:"100%",height:C?"100%":void 0,backgroundColor:"#FAFAFA"},children:[t("div",{style:{display:"flex",justifyContent:"flex-end",padding:"6px 10px",borderBottom:"1px solid #E4E7EC",backgroundColor:"#FFFFFF",flexShrink:0},children:t("button",{onClick:()=>{F(e=>!e)},style:{background:"none",border:"none",cursor:"pointer",padding:"4px",borderRadius:"6px",color:"#475467",marginRight:"9px"},children:t(C?g:x,{})})}),t("div",{style:{flex:1,minHeight:0,height:"100%",overflow:"hidden"},children:t(E,{href:i,children:r,metaData:p,citationTitle:v,citationType:l,citationReason:s,isFullscreen:C})})]});return e("span",{style:{display:"inline",...h.relativeWrapper||{}},children:[t("div",{style:{display:"inline",marginTop:0,...h.citationButtonWrapper||{}},children:e("button",{type:"button",onClick:()=>w(e=>!e),style:{display:p?.webGpt?"inline":"inline-flex",alignItems:p?.webGpt?void 0:"center",gap:p?.webGpt?void 0:"3px",fontFamily:'"Inter", sans-serif',backgroundColor:"transparent",padding:0,margin:0,fontSize:"13px",borderRadius:9999,cursor:"pointer",fontWeight:p?.webGpt?600:700,color:p?.webGpt?"#6D28D9":"rgb(214, 51, 132)",border:"none",textDecoration:"none",wordBreak:"break-word",whiteSpace:"normal",...h.citationButton||{}},children:[p?.webGpt&&t(a,{size:h.arrow?.fontSize??"1em",color:h.arrow?.color??"#6D28D9",style:{display:"inline-block",width:"1em",height:"1em",marginRight:"3px",verticalAlign:"-0.125em",flexShrink:0}}),t("span",{children:D}),t("span",{style:{display:"inline-flex",alignItems:"center",marginLeft:p?.webGpt?"3px":void 0,verticalAlign:p?.webGpt?"-0.125em":void 0},children:y?P:S})]})}),y&&(C?t(_,{open:C,onClose:()=>F(!1),maxWidth:!1,BackdropProps:{sx:{backgroundColor:"rgba(0, 0, 0, 0.6)",backdropFilter:"blur(4px)"}},PaperProps:{sx:{backgroundColor:"#FAFAFA",borderRadius:"16px",height:I,m:0,maxHeight:I,maxWidth:"95vw",overflow:"hidden",width:"95vw"}},children:k}):k)]})};export{A as default};
1
+ import{jsxs as e,jsx as t}from"react/jsx-runtime";import{Dialog as o}from"@mui/material";import{Globe as i,ChevronUp as n,ChevronDown as r}from"lucide-react";import{useState as a,useEffect as l,useMemo as d,useCallback as s}from"react";import{DefaultFullScreenCloseIcon as p,DefaultFullScreenIcon as c}from"../../assests/svg/PdfViewerIcons.js";import{useOptionalCompareContext as g}from"./CompareContext.js";import h from"./CitationRendererInner.js";const x="90vh",m={border:"1px solid #D0D5DD",borderRadius:"6px",background:"#FFFFFF",color:"#344054",cursor:"pointer",fontSize:"12px",fontWeight:600,padding:"3px 8px"},f=({href:f,children:u,citationType:b,citationReason:y,metaData:C,chevronUpComponent:v=null,chevronDownComponent:w=null,customStyle:F={},defaultState:D=!1,onFullscreenChange:k,onDemandCitationContext:S})=>{const z=g(),R=z?.onDemandCitationConfig,A=z?.getOnDemandCitationCacheEntry,j=z?.fetchOnDemandCitationContext,B=z?.onDemandCitationCacheVersion,[G,W]=a(D),[E,I]=a(!1),P="string"==typeof u&&u?.split("\n")?.length>1?u.split("\n").join(" "):u,T="string"==typeof u?u:u[0];l(()=>{if(k?.(E),E)return()=>{k?.(!1)}},[E,k]);const O=d(()=>S&&A?A(S):void 0,[A,B,S]),H=!!R?.enabled&&!!S,L="success"===O?.status&&O.data&&"object"==typeof O.data&&Object.keys(O.data).length>0,U=d(()=>({...C,citations:H?L?O?.data:{}:C?.citations}),[L,H,C,O?.data]),V=H&&(!O||"loading"===O.status)&&!L,q=H&&"error"===O?.status&&!L,J=H&&"success"===O?.status&&!L,K=!H||L,M=s(()=>{R?.enabled&&S&&j&&("loading"===O?.status||"success"===O?.status&&L||j(S).catch(e=>{R.debug&&console.error("[CognitiveCompare:onDemandCitations] citation fetch failed",e)}))},[j,L,O?.status,R,S]),N=v??(Q=F?.arrow??{},t(n,{size:Q?.fontSize??16,color:Q?.color??"rgb(214, 51, 132)"}));var Q;const X=w??(e=>t(r,{size:e?.fontSize??16,color:e?.color??"rgb(214, 51, 132)"}))(F?.arrow??{}),Y=e=>t("button",{type:"button",onClick:e=>{e.stopPropagation(),M()},style:{...m,...e},children:"Retry"}),Z=e("div",{style:{boxSizing:"border-box",border:E?"none":"1px solid #E4E7EC",borderRadius:E?0:"8px",overflow:"hidden",marginTop:E?0:"8px",display:"flex",flexDirection:"column",width:"100%",height:E?"100%":void 0,backgroundColor:"#FAFAFA"},children:[t("div",{style:{display:"flex",justifyContent:"flex-end",padding:"6px 10px",borderBottom:"1px solid #E4E7EC",backgroundColor:"#FFFFFF",flexShrink:0},children:t("button",{onClick:()=>{I(e=>!e)},style:{background:"none",border:"none",cursor:"pointer",padding:"4px",borderRadius:"6px",color:"#475467",marginRight:"9px"},children:t(E?p:c,{})})}),e("div",{style:{flex:1,minHeight:0,height:"100%",overflow:"hidden"},children:[V&&t("div",{style:{padding:"12px",fontSize:"13px",color:"#475467"},children:"Loading citation details..."}),q&&e("div",{style:{padding:"12px",fontSize:"13px",color:"#B42318",display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"},children:[t("span",{children:"Unable to load citation details. Please try again later."}),Y({border:"1px solid #FDA29B",color:"#B42318"})]}),J&&e("div",{style:{padding:"12px",fontSize:"13px",color:"#475467",display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"},children:[t("span",{children:"Citation details are not available for this source."}),Y()]}),K&&t(h,{href:f,children:u,metaData:U,citationTitle:T,citationType:b,citationReason:y,isFullscreen:E})]})]});return e("span",{style:{display:"inline",...F.relativeWrapper||{}},children:[t("div",{style:{display:"inline",marginTop:0,...F.citationButtonWrapper||{}},children:e("button",{type:"button",onClick:()=>{W(e=>{const t=!e;return t&&M(),t})},style:{display:C?.webGpt?"inline":"inline-flex",alignItems:C?.webGpt?void 0:"center",gap:C?.webGpt?void 0:"3px",fontFamily:'"Inter", sans-serif',backgroundColor:"transparent",padding:0,margin:0,fontSize:"13px",borderRadius:9999,cursor:"pointer",fontWeight:C?.webGpt?600:700,color:C?.webGpt?"#6D28D9":"rgb(214, 51, 132)",border:"none",textDecoration:"none",wordBreak:"break-word",whiteSpace:"normal",...F.citationButton||{}},children:[C?.webGpt&&t(i,{size:F.arrow?.fontSize??"1em",color:F.arrow?.color??"#6D28D9",style:{display:"inline-block",width:"1em",height:"1em",marginRight:"3px",verticalAlign:"-0.125em",flexShrink:0}}),t("span",{children:P}),t("span",{style:{display:"inline-flex",alignItems:"center",marginLeft:C?.webGpt?"3px":void 0,verticalAlign:C?.webGpt?"-0.125em":void 0},children:G?N:X})]})}),G&&(E?t(o,{open:E,onClose:()=>{I(!1),k?.(!1)},maxWidth:!1,BackdropProps:{sx:{backgroundColor:"rgba(0, 0, 0, 0.6)",backdropFilter:"blur(4px)"}},PaperProps:{sx:{backgroundColor:"#FAFAFA",borderRadius:"16px",height:x,m:0,maxHeight:x,maxWidth:"95vw",overflow:"hidden",width:"95vw"}},children:Z}):Z)]})};export{f as default};
2
2
  //# sourceMappingURL=CitationAnchor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CitationAnchor.js","sources":["../../../src/features/CognitiveCompare/CitationAnchor.tsx"],"sourcesContent":["// import PdfViewer from \"@e-llm-studio/citation/PdfViewer\";\nimport DOMPurify from \"dompurify\";\nimport { ChevronDown, ChevronUp, ExternalLink, Globe, Maximize2, X } from \"lucide-react\";\nimport React, {\n CSSProperties,\n useState,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport ResizableSplitPane from \"./ResizableSplitPane\";\nimport PdfViewer from \"../PdfViewer/PdfViewer\";\nimport { DefaultFullScreenIcon, DefaultFullScreenCloseIcon } from \"../../assests/svg/PdfViewerIcons\";\nimport ReactMarkdown from \"react-markdown\";\nimport rehypeRaw from \"rehype-raw\";\nimport { Box, Dialog } from '@mui/material';\nimport { SHARED_MARKDOWN_STYLES } from \"./CognitiveCompare\";\nimport { useCompareContext } from \"./CompareContext\";\nimport { processGuidelinesMarkdown } from \"./Guidelines/utils/processGuidelinesMarkdown\";\nimport GptWebCitation from \"../GptWebCitation/GptWebCitation\";\nimport { CitationType, GptWebCitationStatus, IWebCitationApiResponse } from \"../GptWebCitation/types\";\nimport { GptWebCitationConfig } from \"./CognitiveCompareTypes\";\n\ninterface CitationAnchorProps {\n href: string;\n children: any;\n citationType?: string;\n citationReason?: string;\n chevronUpComponent?: React.ReactNode;\n chevronDownComponent?: React.ReactNode;\n customStyle?: {\n citationButtonWrapper?: CSSProperties;\n arrow?: CSSProperties;\n citationButton?: CSSProperties;\n expandableContent?: CSSProperties;\n bookHeader?: CSSProperties;\n relative?: CSSProperties;\n pageColor?: CSSProperties;\n highlightedText?: CSSProperties;\n expandedWrapper?: CSSProperties;\n expandableContainer?: CSSProperties;\n bookBodyContent?: CSSProperties;\n customScrollbarClass?: CSSProperties;\n relativeWrapper?: CSSProperties;\n };\n defaultState?: boolean;\n metaData?: any;\n onFullscreenChange?: (isFullscreen: boolean) => void;\n}\ninterface CitationRendererInnerProps {\n href: string;\n children: any;\n metaData: any;\n citationTitle: string;\n citationType?: string;\n citationReason?: string;\n isFullscreen: boolean\n}\n\nconst getFirstGptCitation = (webGptMeta: any) =>\n (webGptMeta?.extraMetaData || webGptMeta)?.aiReasoningCitation?.gpt_citation?.[0] || null;\n\nconst DEFAULT_GPT_WEB_CITATION_CONFIG: GptWebCitationConfig = {\n endpoint: \"https://dev-proposals-ai.techo.camp/utility/ca-workflow-composer-agent/get_citation\",\n userEmail: \"sai.siddhartha@techolution.com\",\n userId: \"672e32f7a0e8fe2e8e50bcba\",\n userName: \"TNV Sai Siddhartha\",\n};\n\nconst CITATION_FULLSCREEN_DIALOG_HEIGHT = \"90vh\";\nconst CITATION_FULLSCREEN_GPT_BODY_HEIGHT = `calc(${CITATION_FULLSCREEN_DIALOG_HEIGHT} - 120px)`;\n\nconst resolveGptWebCitationConfig = (\n gptWebCitationConfig?: GptWebCitationConfig,\n): GptWebCitationConfig => ({\n endpoint: gptWebCitationConfig?.endpoint || DEFAULT_GPT_WEB_CITATION_CONFIG.endpoint,\n userEmail: gptWebCitationConfig?.userEmail || DEFAULT_GPT_WEB_CITATION_CONFIG.userEmail,\n userId: gptWebCitationConfig?.userId || DEFAULT_GPT_WEB_CITATION_CONFIG.userId,\n userName: gptWebCitationConfig?.userName || DEFAULT_GPT_WEB_CITATION_CONFIG.userName,\n headers: gptWebCitationConfig?.headers,\n});\n\nconst createCitationUuid = () => {\n if (typeof globalThis.crypto?.randomUUID === \"function\") {\n return globalThis.crypto.randomUUID();\n }\n\n return \"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\".replace(/[xy]/g, (char) => {\n const random = Math.floor(Math.random() * 16);\n const value = char === \"x\" ? random : (random % 4) + 8;\n return value.toString(16);\n });\n};\n\nconst getStoredPayloadCitationId = (webGptMeta: any) =>\n webGptMeta?.payloadCitationId ||\n webGptMeta?.extraMetaData?.payloadCitationId ||\n \"\";\n\nconst attachPayloadCitationId = (webGptMeta: any, payloadCitationId: string) => {\n if (!webGptMeta || typeof webGptMeta !== \"object\") return;\n\n webGptMeta.payloadCitationId = payloadCitationId;\n\n if (webGptMeta.extraMetaData && typeof webGptMeta.extraMetaData === \"object\") {\n webGptMeta.extraMetaData.payloadCitationId = payloadCitationId;\n }\n};\n\nconst getOrCreatePayloadCitationId = (webGptMeta: any, generatedCitationId?: string) => {\n const payloadCitationId =\n getStoredPayloadCitationId(webGptMeta) ||\n generatedCitationId ||\n createCitationUuid();\n\n attachPayloadCitationId(webGptMeta, payloadCitationId);\n return payloadCitationId;\n};\n\nconst buildGptWebCitationPayload = (\n webGptMeta: any,\n gptWebCitationConfig?: GptWebCitationConfig,\n generatedCitationId?: string,\n) => {\n const gptCitation = getFirstGptCitation(webGptMeta);\n const customMetaData = gptCitation?.customMetaData || {};\n const citationValue = customMetaData?.value || {};\n const webSearchAnswer = webGptMeta?.webSearchAnswer || {};\n const extraMetaData = webGptMeta?.extraMetaData || webGptMeta || {};\n\n return {\n userEmail:\n webGptMeta?.userEmail ||\n webSearchAnswer?.userEmail ||\n gptWebCitationConfig?.userEmail ||\n \"\",\n userId:\n webGptMeta?.userId ||\n webSearchAnswer?.userId ||\n gptWebCitationConfig?.userId ||\n \"\",\n userName:\n webGptMeta?.userName ||\n webSearchAnswer?.userName ||\n gptWebCitationConfig?.userName ||\n \"\",\n citationId:\n getOrCreatePayloadCitationId(webGptMeta, generatedCitationId),\n citationUrl: citationValue?.citationUrl || webSearchAnswer?.citationUrl || \"\",\n content: extraMetaData?.Reasoning || webSearchAnswer?.enhanced_content || \"\",\n citationType: citationValue?.citationType || \"web\",\n citatioNumber:\n customMetaData?.citation_number ??\n gptCitation?.citation_number ??\n Number(webGptMeta?.reasoningId || 0),\n };\n};\n\nconst GptWebCitationPanel = ({\n metaData,\n isFullscreen = false,\n}: {\n metaData: any;\n isFullscreen?: boolean;\n}) => {\n const { gptWebCitationConfig } = useCompareContext();\n const resolvedGptWebCitationConfig = useMemo(\n () => resolveGptWebCitationConfig(gptWebCitationConfig),\n [gptWebCitationConfig],\n );\n const webGptMeta = metaData?.webGpt;\n const generatedCitationIdRef = useRef<string | null>(null);\n if (!generatedCitationIdRef.current) {\n generatedCitationIdRef.current = createCitationUuid();\n }\n\n const payload = useMemo(\n () => buildGptWebCitationPayload(\n webGptMeta,\n resolvedGptWebCitationConfig,\n generatedCitationIdRef.current || undefined,\n ),\n [webGptMeta, resolvedGptWebCitationConfig],\n );\n const firstGptCitation = useMemo(() => getFirstGptCitation(webGptMeta), [webGptMeta]);\n const citationValue = firstGptCitation?.customMetaData?.value || {};\n const extraMetaData = webGptMeta?.extraMetaData || webGptMeta || {};\n const [webCitationData, setWebCitationData] = useState<IWebCitationApiResponse | undefined>();\n const [webCitationStatus, setWebCitationStatus] = useState<GptWebCitationStatus>(\"pending\");\n const [showWebCitation, setShowWebCitation] = useState(true);\n\n useEffect(() => {\n let isMounted = true;\n\n const fetchGptWebCitation = async () => {\n if (!resolvedGptWebCitationConfig.endpoint || !payload?.citationUrl || !payload?.content) {\n setWebCitationStatus(\"error\");\n return;\n }\n\n setWebCitationStatus(\"pending\");\n\n try {\n const response = await fetch(resolvedGptWebCitationConfig.endpoint, {\n method: \"POST\",\n headers: {\n \"actor-id\": payload.userEmail,\n \"Accept\": \"application/json, text/plain, */*\",\n \"Content-Type\": \"application/json\",\n ...(resolvedGptWebCitationConfig.headers || {}),\n },\n body: JSON.stringify(payload),\n });\n\n if (!response.ok) {\n throw new Error(`Failed to fetch GPT web citation (${response.status})`);\n }\n\n const rawData = await response.json();\n const data =\n rawData?.responseData ||\n rawData?.result ||\n rawData?.data ||\n rawData;\n if (!isMounted) return;\n\n setWebCitationData(data);\n setWebCitationStatus(\"success\");\n } catch (error) {\n if (!isMounted) return;\n console.error(\"Failed to load GPT web citation\", error);\n setWebCitationStatus(\"error\");\n }\n };\n\n fetchGptWebCitation();\n\n return () => {\n isMounted = false;\n };\n }, [payload, resolvedGptWebCitationConfig]);\n\n const gptCitation = useMemo(\n () => ({\n item: {\n confidence_score: Number(extraMetaData?.Confidence_score || 0),\n text: citationValue?.paraphrase || \"Web citation reasoning\",\n dataSource: citationValue?.text || extraMetaData?.Reasoning || \"\",\n paraphrase: citationValue?.paraphrase || \"\",\n },\n headerTitle: \"GPT Web Citation\",\n index: Number(payload?.citatioNumber || 1) - 1,\n iconsConfig: {\n ChevronDownIcon: ChevronDown,\n ChevronUpIcon: ChevronUp,\n MaximizeIcon: Maximize2,\n CloseIcon: X,\n },\n }),\n [citationValue, payload?.citatioNumber, extraMetaData],\n );\n\n const resolvedGptCitation = useMemo(\n () => ({\n ...gptCitation,\n ...(isFullscreen ? { bodyHeight: CITATION_FULLSCREEN_GPT_BODY_HEIGHT } : {}),\n }),\n [gptCitation, isFullscreen],\n );\n\n return (\n <GptWebCitation\n gptCitation={resolvedGptCitation}\n defaultCitationUrl={payload?.citationUrl || \"\"}\n citationType={CitationType.GPT_WEB}\n webCitationData={webCitationData}\n webCitationStatus={webCitationStatus}\n showWebCitation={showWebCitation}\n onToggleCitationView={() => setShowWebCitation((current) => !current)}\n iconsConfig={{\n MaximizeIcon: Maximize2,\n ExternalLinkIcon: ExternalLink,\n }}\n isFixedHeight\n />\n );\n};\n\nconst CitationRendererInner: React.FC<CitationRendererInnerProps> = ({\n href,\n metaData,\n citationTitle,\n citationType,\n citationReason,\n isFullscreen\n}) => {\n const { guidelinesData } = useCompareContext();\n const pdfCitationTypes = [\"contract\", \"clause\"];\n\n const getCitationUrl = (url: string) => {\n const prefixedCitationMatch = url.match(/^(?:pdf_citation|deviation_summary)\\$(\\d+)/);\n if (prefixedCitationMatch) {\n try {\n const queryStartIndex = url.indexOf(\"?\");\n const search = queryStartIndex >= 0 ? url.slice(queryStartIndex) : \"\";\n return {\n citationNumber: prefixedCitationMatch[1],\n parsedUrl: new URL(search || \"./\", window.location.origin),\n };\n } catch {\n return {\n citationNumber: prefixedCitationMatch[1],\n parsedUrl: null,\n };\n }\n }\n\n try {\n const parsedUrl = new URL(url, window.location.origin);\n const citationNumber =\n parsedUrl.searchParams.get(\"citationNumber\") ||\n parsedUrl.searchParams.get(\"citation_number\");\n return {citationNumber, parsedUrl};\n } catch {\n return {citationNumber: null, parsedUrl: null};\n }\n };\n\n const getCitationDetailsFromHref = (url: string): { citationNumber: string | null; phraseToHighlight: string | null; citationTypeFromHref: string | null } => {\n try {\n const { citationNumber, parsedUrl } = getCitationUrl(url);\n const phraseToHighlight = parsedUrl?.searchParams.get(\"phrase_to_highlight\") || null;\n const citationTypeFromHref = parsedUrl?.searchParams.get(\"citation_type\") || null;\n return {citationNumber, phraseToHighlight, citationTypeFromHref};\n } catch {\n return {citationNumber: null, phraseToHighlight: null, citationTypeFromHref: null};\n }\n };\n\n const {citationNumber, phraseToHighlight, citationTypeFromHref} = getCitationDetailsFromHref(href);\n const resolvedCitationType = citationType || citationTypeFromHref || undefined;\n const normalizedCitationType =\n resolvedCitationType === \"il_rulebook_citation\" ? \"rulebook_citation\" : resolvedCitationType;\n const citationGroup = citationNumber ? (metaData?.citations?.[citationNumber] || {}) : {};\n const documents = metaData?.docData?.documents || {};\n const inputIndexMap = metaData?.docData?.input_index_map || {};\n const hasRegularCitationData =\n Object.keys(metaData?.citations || {}).length > 0 ||\n Object.keys(metaData?.docData || {}).length > 0;\n\n const leftUuid = inputIndexMap?.[\"0\"];\n const rightUuid = inputIndexMap?.[\"1\"];\n\n const leftDocument = leftUuid ? documents[leftUuid] : null;\n const rightDocument = rightUuid ? documents[rightUuid] : null;\n const leftCitation = leftUuid ? citationGroup[leftUuid] : null;\n const rightCitation = rightUuid ? citationGroup[rightUuid] : null;\n\n const leftComponent = useMemo(() => {\n if (!leftCitation || !leftDocument) return null;\n return (\n <PdfViewer\n defaultScale={'PageWidth'}\n showFullScreenAction={false}\n showHighlightsAction={false}\n pdfName={leftDocument?.title}\n pdfUrl={leftDocument?.signed_url}\n highlightText={[leftCitation?.highlighted_text ?? '']}\n highlightPages={{ 1: leftCitation?.custom_metadata?.pdf_start_page_number }}\n jumpToPageValue={1}\n highlightCordinatePages={[]}\n useCoordinates={false}\n useRange={true}\n rangeOfPages={[leftCitation?.custom_metadata?.pdf_start_page_number, leftCitation?.custom_metadata?.pdf_end_page_number]}\n />\n );\n }, [\n leftDocument?.title,\n leftDocument?.signed_url,\n leftCitation?.highlighted_text,\n leftCitation?.custom_metadata?.pdf_start_page_number,\n leftCitation?.custom_metadata?.pdf_end_page_number\n ]);\n\n const rightComponent = useMemo(() => {\n if (!rightCitation || !rightDocument) return null;\n return (\n <PdfViewer\n defaultScale={'PageWidth'}\n showFullScreenAction={false}\n showHighlightsAction={false}\n pdfName={rightDocument?.title}\n pdfUrl={rightDocument?.signed_url}\n jumpToPageValue={1}\n highlightText={[rightCitation?.highlighted_text ?? '']}\n highlightPages={{ 1: rightCitation?.custom_metadata?.pdf_start_page_number }}\n highlightCordinatePages={[]}\n useCoordinates={false}\n useRange={true}\n rangeOfPages={[rightCitation?.custom_metadata?.pdf_start_page_number, rightCitation?.custom_metadata?.pdf_end_page_number]}\n />\n );\n }, [\n rightDocument?.title,\n rightDocument?.signed_url,\n rightCitation?.highlighted_text,\n rightCitation?.custom_metadata?.pdf_start_page_number,\n rightCitation?.custom_metadata?.pdf_end_page_number\n ]);\n\n const isDualCitationType = normalizedCitationType === \"dual_citation\";\n const isDualWebGptCitation = isDualCitationType && !!metaData?.webGpt;\n\n const splitPaneComponent = useMemo(() => {\n if (!leftComponent) return null;\n\n const rightPane =\n isDualWebGptCitation ? (\n <GptWebCitationPanel metaData={metaData} isFullscreen={isFullscreen} />\n ) : normalizedCitationType === \"rulebook_citation\" ? (\n <>\n <Box sx={{\n padding: '0px 20px',\n backgroundColor: '#FFFFFF',\n borderRadius: '8px',\n ...SHARED_MARKDOWN_STYLES,\n overflow: 'auto'\n }}>\n <ReactMarkdown rehypePlugins={[rehypeRaw as any]}>\n {processGuidelinesMarkdown({\n guidelinesData, targetHighlights: [phraseToHighlight!], labelColor: \"#FEF08A\"})}\n </ReactMarkdown>\n </Box>\n </>\n ) : (\n rightComponent\n );\n\n if (!rightPane) return leftComponent;\n\n return (\n <ResizableSplitPane\n leftComponent={leftComponent}\n rightComponent={rightPane}\n isFullscreen={isFullscreen}\n />\n );\n}, [leftComponent, rightComponent, normalizedCitationType, isDualWebGptCitation, metaData, isFullscreen, guidelinesData, phraseToHighlight]);\n\n if (metaData?.webGpt && !hasRegularCitationData) {\n return <GptWebCitationPanel metaData={metaData} isFullscreen={isFullscreen} />;\n }\n\n if (!citationNumber) return null;\n\n if (normalizedCitationType === \"rulebook_citation\") {\n if (leftCitation) {\n return (\n <div style={{ height: \"100%\", display: \"flex\", flexDirection: \"column\" }}>\n {splitPaneComponent}\n </div>\n );\n }\n\n return (\n <div style={{ padding: \"12px\", fontSize: \"13px\", color: \"#344054\", lineHeight: 1.5 }}>\n {citationReason || \"Rulebook citation selected.\"}\n </div>\n );\n }\n\n if (isDualCitationType) {\n if (leftCitation || rightCitation) {\n return (\n <div style={{ height: \"100%\", display: \"flex\", flexDirection: \"column\" }}>\n {splitPaneComponent}\n </div>\n );\n }\n\n if (metaData?.webGpt) {\n return <GptWebCitationPanel metaData={metaData} isFullscreen={isFullscreen} />;\n }\n\n return <div>Missing PDF Citation. Please try again later</div>;\n }\n\n if (pdfCitationTypes.includes(citationTitle)) {\n if (leftCitation || rightCitation) {\n return (\n <div style={{ height: \"100%\", display: \"flex\", flexDirection: \"column\" }}>\n {splitPaneComponent}\n </div>\n );\n }\n\n return <div>Missing PDF Citation. Please try again later</div>;\n }\n\n return <div>No Citation Found. Please try again later</div>;\n};\n\n\nconst CitationAnchor: React.FC<CitationAnchorProps> = ({\n href,\n children,\n citationType,\n citationReason,\n metaData,\n chevronUpComponent = null,\n chevronDownComponent = null,\n customStyle = {},\n defaultState = false,\n onFullscreenChange,\n}) => {\n const ChevronUpComponentDefault = (arrow: CSSProperties) => {\n return (\n <ChevronUp\n size={arrow?.fontSize ?? 16}\n color={arrow?.color ?? \"rgb(214, 51, 132)\"}\n />\n );\n };\n\n const ChevronDownComponentDefault = (arrow: CSSProperties) => {\n return (\n <ChevronDown\n size={arrow?.fontSize ?? 16}\n color={arrow?.color ?? \"rgb(214, 51, 132)\"}\n />\n );\n };\n const [isExpanded, setIsExpanded] = useState(defaultState);\n const [isFullscreen, setIsFullscreen] = useState(false);\n const citationDisplayTitle =\n typeof children === \"string\" && children?.split(\"\\n\")?.length > 1\n ? children.split(\"\\n\").join(\" \")\n : children;\n\n useEffect(() => {\n onFullscreenChange?.(isFullscreen);\n\n if (!isFullscreen) return;\n\n return () => {\n onFullscreenChange?.(false);\n };\n }, [isFullscreen, onFullscreenChange]);\n \n const citationTitle = typeof children === \"string\" ? children : children[0]\n\n const toggleCitation = () => setIsExpanded((prev) => !prev);\n const chevronUpComponentResolved =\n chevronUpComponent ??\n ChevronUpComponentDefault(customStyle?.arrow ?? {});\n const chevronDownComponentResolved =\n chevronDownComponent ??\n ChevronDownComponentDefault(customStyle?.arrow ?? {});\n\n const pdfCitationTypes = [\"contract\", \"clause\"];\n \nconst handleFullscreen = () => {\n setIsFullscreen((prev) => !prev);\n};\n // const jumpToPageRef = useRef<number>(item.pdf_highlight_details.pdf_page_number);\n // const highlightPagesIndexArray = {1: citationMetaData.pdf_highlight_details.pdf_page_number}\n // // const highlightTextArray = citationMetaData.pdf_highlight_details.pdf_highlight_text?.split('\\n')\n // const highlightTextArray = (() => {\n // const text = [citationMetaData.pdf_highlight_details.pdf_highlight_text ?? ''];\n // // console.log('textchecking old', text, processPdfHighlightText_Old(text[0]))\n // // console.log('textchecking new', text, processPdfHighlightText(\"payment in full for undisputed invoices shall be due within\\n**fourty-five (45) days** from invoice date unless stated otherwise in the respective SOW\"))\n // return text\n // })();\n\n const citationPanel = (\n <div\n style={{\n boxSizing: \"border-box\",\n border: isFullscreen ? \"none\" : \"1px solid #E4E7EC\",\n borderRadius: isFullscreen ? 0 : \"8px\",\n overflow: \"hidden\",\n marginTop: isFullscreen ? 0 : \"8px\",\n display: \"flex\",\n flexDirection: \"column\",\n width: \"100%\",\n height: isFullscreen ? \"100%\" : undefined,\n backgroundColor: \"#FAFAFA\",\n }}\n >\n <div style={{\n display: \"flex\",\n justifyContent: \"flex-end\",\n padding: \"6px 10px\",\n borderBottom: \"1px solid #E4E7EC\",\n backgroundColor: \"#FFFFFF\",\n flexShrink: 0,\n }}>\n <button onClick={handleFullscreen}\n style={{ background: \"none\", border: \"none\", cursor: \"pointer\", padding: \"4px\", borderRadius: \"6px\", color: \"#475467\", marginRight: \"9px\" }}>\n {isFullscreen ? <DefaultFullScreenCloseIcon /> : <DefaultFullScreenIcon />}\n </button>\n </div>\n <div style={{ flex: 1, minHeight: 0, height: \"100%\", overflow: \"hidden\" }}>\n <CitationRendererInner\n href={href}\n children={children}\n metaData={metaData}\n citationTitle={citationTitle}\n citationType={citationType}\n citationReason={citationReason}\n isFullscreen={isFullscreen}\n />\n </div>\n </div>\n );\n\n return (\n <span\n style={{\n display: \"inline\",\n ...(customStyle.relativeWrapper || {}),\n }}\n >\n <div\n style={{\n display: \"inline\",\n marginTop: 0,\n ...(customStyle.citationButtonWrapper || {}),\n }}\n >\n <button\n type=\"button\"\n onClick={toggleCitation}\n style={{\n display: metaData?.webGpt ? \"inline\" : \"inline-flex\",\n alignItems: metaData?.webGpt ? undefined : \"center\",\n gap: metaData?.webGpt ? undefined : \"3px\",\n fontFamily: '\"Inter\", sans-serif',\n backgroundColor: \"transparent\",\n padding: 0,\n margin: 0,\n fontSize: \"13px\",\n borderRadius: 9999,\n cursor: \"pointer\",\n fontWeight: (metaData?.webGpt) ? 600 : 700,\n color: (metaData?.webGpt) ? \"#6D28D9\" : \"rgb(214, 51, 132)\",\n border: \"none\",\n textDecoration: \"none\",\n wordBreak: \"break-word\",\n whiteSpace: \"normal\",\n ...(customStyle.citationButton || {}),\n }}\n >\n {metaData?.webGpt && (\n <Globe\n size={customStyle.arrow?.fontSize ?? \"1em\"}\n color={customStyle.arrow?.color ?? \"#6D28D9\"}\n style={{\n display: \"inline-block\",\n width: \"1em\",\n height: \"1em\",\n marginRight: \"3px\",\n verticalAlign: \"-0.125em\",\n flexShrink: 0,\n }}\n />\n )}\n <span>{citationDisplayTitle}</span>\n\n <span\n style={{\n display: \"inline-flex\",\n alignItems: \"center\",\n marginLeft: metaData?.webGpt ? \"3px\" : undefined,\n verticalAlign: metaData?.webGpt ? \"-0.125em\" : undefined,\n }}\n >\n {isExpanded\n ? chevronUpComponentResolved\n : chevronDownComponentResolved}\n </span>\n {/* <span>\n <ChevronDownComponentDefault />\n </span> */}\n </button>\n </div>\n {isExpanded && (\n isFullscreen ? (\n <Dialog\n open={isFullscreen}\n onClose={() => setIsFullscreen(false)}\n maxWidth={false}\n BackdropProps={{\n sx: {\n backgroundColor: \"rgba(0, 0, 0, 0.6)\",\n backdropFilter: \"blur(4px)\",\n },\n }}\n PaperProps={{\n sx: {\n backgroundColor: \"#FAFAFA\",\n borderRadius: \"16px\",\n height: CITATION_FULLSCREEN_DIALOG_HEIGHT,\n m: 0,\n maxHeight: CITATION_FULLSCREEN_DIALOG_HEIGHT,\n maxWidth: \"95vw\",\n overflow: \"hidden\",\n width: \"95vw\",\n },\n }}\n >\n {citationPanel}\n </Dialog>\n ) : (\n citationPanel\n )\n )}\n </span>\n );\n};\n\nexport default CitationAnchor;\n"],"names":["getFirstGptCitation","webGptMeta","extraMetaData","aiReasoningCitation","gpt_citation","DEFAULT_GPT_WEB_CITATION_CONFIG","CITATION_FULLSCREEN_DIALOG_HEIGHT","CITATION_FULLSCREEN_GPT_BODY_HEIGHT","createCitationUuid","globalThis","crypto","randomUUID","replace","char","random","Math","floor","toString","getOrCreatePayloadCitationId","generatedCitationId","payloadCitationId","getStoredPayloadCitationId","attachPayloadCitationId","GptWebCitationPanel","metaData","isFullscreen","gptWebCitationConfig","useCompareContext","resolvedGptWebCitationConfig","useMemo","endpoint","userEmail","userId","userName","headers","resolveGptWebCitationConfig","webGpt","generatedCitationIdRef","useRef","current","payload","gptCitation","customMetaData","citationValue","value","webSearchAnswer","citationId","citationUrl","content","Reasoning","enhanced_content","citationType","citatioNumber","citation_number","Number","reasoningId","buildGptWebCitationPayload","firstGptCitation","webCitationData","setWebCitationData","useState","webCitationStatus","setWebCitationStatus","showWebCitation","setShowWebCitation","useEffect","isMounted","async","response","fetch","method","Accept","body","JSON","stringify","ok","Error","status","rawData","json","responseData","result","data","error","console","fetchGptWebCitation","item","confidence_score","Confidence_score","text","paraphrase","dataSource","headerTitle","index","iconsConfig","ChevronDownIcon","ChevronDown","ChevronUpIcon","ChevronUp","MaximizeIcon","Maximize2","CloseIcon","X","resolvedGptCitation","bodyHeight","jsx","GptWebCitation","defaultCitationUrl","CitationType","GPT_WEB","onToggleCitationView","ExternalLinkIcon","ExternalLink","isFixedHeight","CitationRendererInner","href","citationTitle","citationReason","guidelinesData","citationNumber","phraseToHighlight","citationTypeFromHref","url","parsedUrl","prefixedCitationMatch","match","queryStartIndex","indexOf","search","slice","URL","window","location","origin","searchParams","get","getCitationUrl","getCitationDetailsFromHref","resolvedCitationType","normalizedCitationType","citationGroup","citations","documents","docData","inputIndexMap","input_index_map","hasRegularCitationData","Object","keys","length","leftUuid","rightUuid","leftDocument","rightDocument","leftCitation","rightCitation","leftComponent","PdfViewer","defaultScale","showFullScreenAction","showHighlightsAction","pdfName","title","pdfUrl","signed_url","highlightText","highlighted_text","highlightPages","custom_metadata","pdf_start_page_number","jumpToPageValue","highlightCordinatePages","useCoordinates","useRange","rangeOfPages","pdf_end_page_number","rightComponent","isDualCitationType","isDualWebGptCitation","splitPaneComponent","rightPane","Fragment","children","Box","sx","padding","backgroundColor","borderRadius","SHARED_MARKDOWN_STYLES","overflow","ReactMarkdown","rehypePlugins","rehypeRaw","processGuidelinesMarkdown","targetHighlights","labelColor","ResizableSplitPane","style","height","display","flexDirection","fontSize","color","lineHeight","includes","CitationAnchor","chevronUpComponent","chevronDownComponent","customStyle","defaultState","onFullscreenChange","isExpanded","setIsExpanded","setIsFullscreen","citationDisplayTitle","split","join","chevronUpComponentResolved","arrow","size","chevronDownComponentResolved","ChevronDownComponentDefault","citationPanel","jsxs","boxSizing","border","marginTop","width","justifyContent","borderBottom","flexShrink","onClick","prev","background","cursor","marginRight","DefaultFullScreenCloseIcon","DefaultFullScreenIcon","flex","minHeight","relativeWrapper","citationButtonWrapper","type","alignItems","gap","fontFamily","margin","fontWeight","textDecoration","wordBreak","whiteSpace","citationButton","Globe","verticalAlign","marginLeft","Dialog","open","onClose","maxWidth","BackdropProps","backdropFilter","PaperProps","m","maxHeight"],"mappings":"0+BA2DA,MAAMA,EAAuBC,IACxBA,GAAYC,eAAiBD,IAAaE,qBAAqBC,eAAe,IAAM,KAEnFC,EACQ,sFADRA,EAES,iCAFTA,EAGM,2BAHNA,EAIQ,qBAGRC,EAAoC,OACpCC,EAAsC,QAAQD,aAY9CE,EAAqB,IACsB,mBAAlCC,WAAWC,QAAQC,WACnBF,WAAWC,OAAOC,aAGtB,uCAAuCC,QAAQ,QAAUC,IAC5D,MAAMC,EAASC,KAAKC,MAAsB,GAAhBD,KAAKD,UAExB,OADgB,MAATD,EAAeC,EAAUA,EAAS,EAAK,GACxCG,SAAS,MAmBxBC,EAA+B,CAACjB,EAAiBkB,KACnD,MAAMC,EAhByB,CAACnB,GAChCA,GAAYmB,mBACZnB,GAAYC,eAAekB,mBAC3B,GAcIC,CAA2BpB,IAC3BkB,GACAX,IAGG,MAjBqB,EAACP,EAAiBmB,KACzCnB,GAAoC,iBAAfA,IAE1BA,EAAWmB,kBAAoBA,E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XC,WAAY,YACR1C,EAAY2C,gBAAkB,CAAC,GAGtCrE,SAAA,CAAA9J,GAAUY,QACPqE,EAACmJ,EAAA,CACGjC,KAAMX,EAAYU,OAAOjB,UAAY,MACrCC,MAAOM,EAAYU,OAAOhB,OAAS,UACnCL,MAAO,CACHE,QAAS,eACT4B,MAAO,MACP7B,OAAQ,MACRqC,YAAa,MACbkB,cAAe,WACfvB,WAAY,KAIpB7H,EAAC,QAAM6E,SAAqBgC,IAEhC7G,EAAC,OAAA,CACG4F,MAAO,CACHE,QAAS,cACT4C,WAAY,SACZW,WAAYtO,GAAUY,OAAS,WAAQ,EACvCyN,cAAerO,GAAUY,OAAS,gBAAa,GAGlDkJ,WACKmC,EACAG,SAOjBT,IACG1L,EACIgF,EAACsJ,EAAA,CACGC,KAAMvO,EACNwO,QAAS,IAAM5C,GAAgB,GAC/B6C,UAAU,EACVC,cAAe,CACX3E,GAAI,CACAE,gBAAiB,qBACjB0E,eAAgB,cAGxBC,WAAY,CACR7E,GAAI,CACAE,gBAAiB,UACjBC,aAAc,OACdW,OAAQhM,EACRgQ,EAAG,EACHC,UAAWjQ,EACX4P,SAAU,OACVrE,SAAU,SACVsC,MAAO,SAId7C,SAAAwC,IAGLA"}
1
+ {"version":3,"file":"CitationAnchor.js","sources":["../../../src/features/CognitiveCompare/CitationAnchor.tsx"],"sourcesContent":["import { Dialog } from \"@mui/material\";\nimport { ChevronDown, ChevronUp, Globe } from \"lucide-react\";\nimport React, {\n CSSProperties,\n useCallback,\n useEffect,\n useMemo,\n useState,\n} from \"react\";\nimport { DefaultFullScreenIcon, DefaultFullScreenCloseIcon } from \"../../assests/svg/PdfViewerIcons\";\nimport type { OnDemandCitationContext } from \"./CognitiveCompareTypes\";\nimport { useOptionalCompareContext } from \"./CompareContext\";\nimport CitationRendererInner from \"./CitationRendererInner\";\n\ninterface CitationAnchorProps {\n href: string;\n children: any;\n citationType?: string;\n citationReason?: string;\n chevronUpComponent?: React.ReactNode;\n chevronDownComponent?: React.ReactNode;\n customStyle?: {\n citationButtonWrapper?: CSSProperties;\n arrow?: CSSProperties;\n citationButton?: CSSProperties;\n expandableContent?: CSSProperties;\n bookHeader?: CSSProperties;\n relative?: CSSProperties;\n pageColor?: CSSProperties;\n highlightedText?: CSSProperties;\n expandedWrapper?: CSSProperties;\n expandableContainer?: CSSProperties;\n bookBodyContent?: CSSProperties;\n customScrollbarClass?: CSSProperties;\n relativeWrapper?: CSSProperties;\n };\n defaultState?: boolean;\n metaData?: any;\n onFullscreenChange?: (isFullscreen: boolean) => void;\n onDemandCitationContext?: OnDemandCitationContext;\n}\n\nconst CITATION_FULLSCREEN_DIALOG_HEIGHT = \"90vh\";\n\nconst retryButtonStyle: React.CSSProperties = {\n border: \"1px solid #D0D5DD\",\n borderRadius: \"6px\",\n background: \"#FFFFFF\",\n color: \"#344054\",\n cursor: \"pointer\",\n fontSize: \"12px\",\n fontWeight: 600,\n padding: \"3px 8px\",\n};\n\nconst CitationAnchor: React.FC<CitationAnchorProps> = ({\n href,\n children,\n citationType,\n citationReason,\n metaData,\n chevronUpComponent = null,\n chevronDownComponent = null,\n customStyle = {},\n defaultState = false,\n onFullscreenChange,\n onDemandCitationContext,\n}) => {\n const compareContext = useOptionalCompareContext();\n const onDemandCitationConfig = compareContext?.onDemandCitationConfig;\n const getOnDemandCitationCacheEntry = compareContext?.getOnDemandCitationCacheEntry;\n const fetchOnDemandCitationContext = compareContext?.fetchOnDemandCitationContext;\n const onDemandCitationCacheVersion = compareContext?.onDemandCitationCacheVersion;\n const [isExpanded, setIsExpanded] = useState(defaultState);\n const [isFullscreen, setIsFullscreen] = useState(false);\n\n const ChevronUpComponentDefault = (arrow: CSSProperties) => (\n <ChevronUp\n size={arrow?.fontSize ?? 16}\n color={arrow?.color ?? \"rgb(214, 51, 132)\"}\n />\n );\n\n const ChevronDownComponentDefault = (arrow: CSSProperties) => (\n <ChevronDown\n size={arrow?.fontSize ?? 16}\n color={arrow?.color ?? \"rgb(214, 51, 132)\"}\n />\n );\n\n const citationDisplayTitle =\n typeof children === \"string\" && children?.split(\"\\n\")?.length > 1\n ? children.split(\"\\n\").join(\" \")\n : children;\n const citationTitle = typeof children === \"string\" ? children : children[0];\n\n useEffect(() => {\n onFullscreenChange?.(isFullscreen);\n\n if (!isFullscreen) return;\n\n return () => {\n onFullscreenChange?.(false);\n };\n }, [isFullscreen, onFullscreenChange]);\n\n const onDemandCacheEntry = useMemo(\n () => onDemandCitationContext && getOnDemandCitationCacheEntry\n ? getOnDemandCitationCacheEntry(onDemandCitationContext)\n : undefined,\n [\n getOnDemandCitationCacheEntry,\n onDemandCitationCacheVersion,\n onDemandCitationContext,\n ],\n );\n const isOnDemandCitationEnabled =\n !!onDemandCitationConfig?.enabled &&\n !!onDemandCitationContext;\n const hasOnDemandCitationData =\n onDemandCacheEntry?.status === \"success\" &&\n onDemandCacheEntry.data &&\n typeof onDemandCacheEntry.data === \"object\" &&\n Object.keys(onDemandCacheEntry.data).length > 0;\n const effectiveMetaData = useMemo(\n () => ({\n ...metaData,\n citations: isOnDemandCitationEnabled\n ? (hasOnDemandCitationData ? onDemandCacheEntry?.data : {})\n : metaData?.citations,\n }),\n [\n hasOnDemandCitationData,\n isOnDemandCitationEnabled,\n metaData,\n onDemandCacheEntry?.data,\n ],\n );\n const shouldShowLoading =\n isOnDemandCitationEnabled &&\n (!onDemandCacheEntry || onDemandCacheEntry.status === \"loading\") &&\n !hasOnDemandCitationData;\n const shouldShowError =\n isOnDemandCitationEnabled &&\n onDemandCacheEntry?.status === \"error\" &&\n !hasOnDemandCitationData;\n const shouldShowMissing =\n isOnDemandCitationEnabled &&\n onDemandCacheEntry?.status === \"success\" &&\n !hasOnDemandCitationData;\n const shouldRenderCitationContent =\n !isOnDemandCitationEnabled || hasOnDemandCitationData;\n\n const requestOnDemandCitation = useCallback(() => {\n if (\n !onDemandCitationConfig?.enabled ||\n !onDemandCitationContext ||\n !fetchOnDemandCitationContext\n ) {\n return;\n }\n\n if (\n onDemandCacheEntry?.status === \"loading\" ||\n (onDemandCacheEntry?.status === \"success\" && hasOnDemandCitationData)\n ) {\n return;\n }\n\n fetchOnDemandCitationContext(onDemandCitationContext).catch((error) => {\n if (onDemandCitationConfig.debug) {\n console.error(\"[CognitiveCompare:onDemandCitations] citation fetch failed\", error);\n }\n });\n }, [\n fetchOnDemandCitationContext,\n hasOnDemandCitationData,\n onDemandCacheEntry?.status,\n onDemandCitationConfig,\n onDemandCitationContext,\n ]);\n\n const toggleCitation = () => {\n setIsExpanded((prev) => {\n const next = !prev;\n if (next) {\n requestOnDemandCitation();\n }\n return next;\n });\n };\n const chevronUpComponentResolved =\n chevronUpComponent ??\n ChevronUpComponentDefault(customStyle?.arrow ?? {});\n const chevronDownComponentResolved =\n chevronDownComponent ??\n ChevronDownComponentDefault(customStyle?.arrow ?? {});\n\n const handleFullscreen = () => {\n setIsFullscreen((prev) => !prev);\n };\n\n const renderRetryButton = (style?: React.CSSProperties) => (\n <button\n type=\"button\"\n onClick={(event) => {\n event.stopPropagation();\n requestOnDemandCitation();\n }}\n style={{ ...retryButtonStyle, ...style }}\n >\n Retry\n </button>\n );\n\n const citationPanel = (\n <div\n style={{\n boxSizing: \"border-box\",\n border: isFullscreen ? \"none\" : \"1px solid #E4E7EC\",\n borderRadius: isFullscreen ? 0 : \"8px\",\n overflow: \"hidden\",\n marginTop: isFullscreen ? 0 : \"8px\",\n display: \"flex\",\n flexDirection: \"column\",\n width: \"100%\",\n height: isFullscreen ? \"100%\" : undefined,\n backgroundColor: \"#FAFAFA\",\n }}\n >\n <div style={{\n display: \"flex\",\n justifyContent: \"flex-end\",\n padding: \"6px 10px\",\n borderBottom: \"1px solid #E4E7EC\",\n backgroundColor: \"#FFFFFF\",\n flexShrink: 0,\n }}>\n <button onClick={handleFullscreen}\n style={{ background: \"none\", border: \"none\", cursor: \"pointer\", padding: \"4px\", borderRadius: \"6px\", color: \"#475467\", marginRight: \"9px\" }}>\n {isFullscreen ? <DefaultFullScreenCloseIcon /> : <DefaultFullScreenIcon />}\n </button>\n </div>\n <div style={{ flex: 1, minHeight: 0, height: \"100%\", overflow: \"hidden\" }}>\n {shouldShowLoading && (\n <div style={{ padding: \"12px\", fontSize: \"13px\", color: \"#475467\" }}>\n Loading citation details...\n </div>\n )}\n {shouldShowError && (\n <div style={{ padding: \"12px\", fontSize: \"13px\", color: \"#B42318\", display: \"flex\", alignItems: \"center\", gap: \"8px\", flexWrap: \"wrap\" }}>\n <span>\n Unable to load citation details. Please try again later.\n </span>\n {renderRetryButton({\n border: \"1px solid #FDA29B\",\n color: \"#B42318\",\n })}\n </div>\n )}\n {shouldShowMissing && (\n <div style={{ padding: \"12px\", fontSize: \"13px\", color: \"#475467\", display: \"flex\", alignItems: \"center\", gap: \"8px\", flexWrap: \"wrap\" }}>\n <span>Citation details are not available for this source.</span>\n {renderRetryButton()}\n </div>\n )}\n {shouldRenderCitationContent && (\n <CitationRendererInner\n href={href}\n children={children}\n metaData={effectiveMetaData}\n citationTitle={citationTitle}\n citationType={citationType}\n citationReason={citationReason}\n isFullscreen={isFullscreen}\n />\n )}\n </div>\n </div>\n );\n\n return (\n <span\n style={{\n display: \"inline\",\n ...(customStyle.relativeWrapper || {}),\n }}\n >\n <div\n style={{\n display: \"inline\",\n marginTop: 0,\n ...(customStyle.citationButtonWrapper || {}),\n }}\n >\n <button\n type=\"button\"\n onClick={toggleCitation}\n style={{\n display: metaData?.webGpt ? \"inline\" : \"inline-flex\",\n alignItems: metaData?.webGpt ? undefined : \"center\",\n gap: metaData?.webGpt ? undefined : \"3px\",\n fontFamily: '\"Inter\", sans-serif',\n backgroundColor: \"transparent\",\n padding: 0,\n margin: 0,\n fontSize: \"13px\",\n borderRadius: 9999,\n cursor: \"pointer\",\n fontWeight: (metaData?.webGpt) ? 600 : 700,\n color: (metaData?.webGpt) ? \"#6D28D9\" : \"rgb(214, 51, 132)\",\n border: \"none\",\n textDecoration: \"none\",\n wordBreak: \"break-word\",\n whiteSpace: \"normal\",\n ...(customStyle.citationButton || {}),\n }}\n >\n {metaData?.webGpt && (\n <Globe\n size={customStyle.arrow?.fontSize ?? \"1em\"}\n color={customStyle.arrow?.color ?? \"#6D28D9\"}\n style={{\n display: \"inline-block\",\n width: \"1em\",\n height: \"1em\",\n marginRight: \"3px\",\n verticalAlign: \"-0.125em\",\n flexShrink: 0,\n }}\n />\n )}\n <span>{citationDisplayTitle}</span>\n\n <span\n style={{\n display: \"inline-flex\",\n alignItems: \"center\",\n marginLeft: metaData?.webGpt ? \"3px\" : undefined,\n verticalAlign: metaData?.webGpt ? \"-0.125em\" : undefined,\n }}\n >\n {isExpanded\n ? chevronUpComponentResolved\n : chevronDownComponentResolved}\n </span>\n </button>\n </div>\n {isExpanded && (\n isFullscreen ? (\n <Dialog\n open={isFullscreen}\n onClose={() => {\n setIsFullscreen(false);\n onFullscreenChange?.(false);\n }}\n maxWidth={false}\n BackdropProps={{\n sx: {\n backgroundColor: \"rgba(0, 0, 0, 0.6)\",\n backdropFilter: \"blur(4px)\",\n },\n }}\n PaperProps={{\n sx: {\n backgroundColor: \"#FAFAFA\",\n borderRadius: \"16px\",\n height: CITATION_FULLSCREEN_DIALOG_HEIGHT,\n m: 0,\n maxHeight: CITATION_FULLSCREEN_DIALOG_HEIGHT,\n maxWidth: \"95vw\",\n overflow: \"hidden\",\n width: \"95vw\",\n },\n }}\n >\n {citationPanel}\n </Dialog>\n ) : (\n citationPanel\n )\n )}\n </span>\n );\n};\n\nexport default CitationAnchor;\n"],"names":["CITATION_FULLSCREEN_DIALOG_HEIGHT","retryButtonStyle","border","borderRadius","background","color","cursor","fontSize","fontWeight","padding","CitationAnchor","href","children","citationType","citationReason","metaData","chevronUpComponent","chevronDownComponent","customStyle","defaultState","onFullscreenChange","onDemandCitationContext","compareContext","useOptionalCompareContext","onDemandCitationConfig","getOnDemandCitationCacheEntry","fetchOnDemandCitationContext","onDemandCitationCacheVersion","isExpanded","setIsExpanded","useState","isFullscreen","setIsFullscreen","citationDisplayTitle","split","length","join","citationTitle","useEffect","onDemandCacheEntry","useMemo","isOnDemandCitationEnabled","enabled","hasOnDemandCitationData","status","data","Object","keys","effectiveMetaData","citations","shouldShowLoading","shouldShowError","shouldShowMissing","shouldRenderCitationContent","requestOnDemandCitation","useCallback","catch","error","debug","console","chevronUpComponentResolved","arrow","jsx","ChevronUp","size","chevronDownComponentResolved","ChevronDown","ChevronDownComponentDefault","renderRetryButton","style","type","onClick","event","stopPropagation","citationPanel","jsxs","boxSizing","overflow","marginTop","display","flexDirection","width","height","backgroundColor","justifyContent","borderBottom","flexShrink","prev","marginRight","DefaultFullScreenCloseIcon","DefaultFullScreenIcon","flex","minHeight","alignItems","gap","flexWrap","CitationRendererInner","relativeWrapper","citationButtonWrapper","next","webGpt","fontFamily","margin","textDecoration","wordBreak","whiteSpace","citationButton","Globe","verticalAlign","marginLeft","Dialog","open","onClose","maxWidth","BackdropProps","sx","backdropFilter","PaperProps","m","maxHeight"],"mappings":"kcA0CA,MAAMA,EAAoC,OAEpCC,EAAwC,CAC1CC,OAAQ,oBACRC,aAAc,MACdC,WAAY,UACZC,MAAO,UACPC,OAAQ,UACRC,SAAU,OACVC,WAAY,IACZC,QAAS,WAGPC,EAAgD,EAClDC,OACAC,WACAC,eACAC,iBACAC,WACAC,qBAAqB,KACrBC,uBAAuB,KACvBC,cAAc,CAAC,EACfC,gBAAe,EACfC,qBACAC,8BAEA,MAAMC,EAAiBC,IACjBC,EAAyBF,GAAgBE,uBACzCC,EAAgCH,GAAgBG,8BAChDC,EAA+BJ,GAAgBI,6BAC/CC,EAA+BL,GAAgBK,8BAC9CC,EAAYC,GAAiBC,EAASX,IACtCY,EAAcC,GAAmBF,GAAS,GAgB3CG,EACkB,iBAAbrB,GAAyBA,GAAUsB,MAAM,OAAOC,OAAS,EAC1DvB,EAASsB,MAAM,MAAME,KAAK,KAC1BxB,EACJyB,EAAoC,iBAAbzB,EAAwBA,EAAWA,EAAS,GAEzE0B,EAAU,KAGN,GAFAlB,IAAqBW,GAEhB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AAA,CACGC,KAAMhF,EACNiF,QAAS,KACLhF,GAAgB,GAChBZ,KAAqB,IAEzB6F,UAAU,EACVC,cAAe,CACXC,GAAI,CACAhC,gBAAiB,qBACjBiC,eAAgB,cAGxBC,WAAY,CACRF,GAAI,CACAhC,gBAAiB,UACjBhF,aAAc,OACd+E,OAAQlF,EACRsH,EAAG,EACHC,UAAWvH,EACXiH,SAAU,OACVpC,SAAU,SACVI,MAAO,SAIdrE,SAAA8D,IAGLA"}
@@ -1,2 +1,2 @@
1
- import{jsx as e,jsxs as t}from"react/jsx-runtime";import{useMemo as r}from"react";import{Box as n,Typography as o}from"@mui/material";import i from"react-markdown";import a from"rehype-raw";import c from"./CitationAnchor.js";import{mergeRulebookCitationsIntoMatchingLinks as l}from"./Guidelines/utils/helper.js";const s=e=>e?`./dual-citation?citationNumber=${encodeURIComponent(e)}`:"";function d({content:d="",title:u="",citations:p={},styles:m={},docData:h={},deviationData:x=null,open:f,onCitationFullscreenChange:g}){const y=r(()=>JSON.stringify(p||{}),[p]),D=r(()=>p,[y]),b=r(()=>JSON.stringify(h||{}),[h]),w=r(()=>h,[b]),C=r(()=>({citations:D,docData:w}),[D,w]),S=r(()=>{const e=x?.web_search_answer,t=e?.extraMetaData||{};return Object.keys(t).reduce((e,t)=>{const r=((e,t)=>{if(!e||!t)return null;const r=e?.web_search_answer,n=r?.extraMetaData?.[t];return r&&n?{reasoningId:t,evaluation:e,webSearchAnswer:r,extraMetaData:n}:null})(x,t);return r&&(e[t]=r),e},{})},[x]),F=r(()=>l(d),[d]),v=r(()=>({a:({href:t="",children:r,type:n,reason:o,...i})=>{const a=i?.["data-cognitive-reasoning"],l=(d=i?.["dual-citation"],!0===d||"true"===d);var d;const u=l&&a?S[String(a)]:null;return e(c,{href:l?s(String(a||"")):t,children:r,citationType:l?"dual_citation":n,citationReason:o,metaData:{...C,...u?{webGpt:u}:{}},customStyle:u?{arrow:{color:"#6D28D9"}}:{},onFullscreenChange:g})}}),[C,S,g]);return t(n,{sx:{borderRadius:"8px",border:"1px solid #E4E7EC",bgcolor:"#FCFCFD"},children:[e(n,{sx:{px:1.5,py:.75,borderBottom:"1px solid #EAECF0"},children:e(o,{sx:{fontSize:"15px",fontWeight:600,color:"#344054",lineHeight:1.25},children:u})}),e(n,{sx:{px:1.5,py:1.1,display:"flex",flexDirection:"column",gap:.95},children:e(n,{sx:{display:"flex",flexDirection:"column"},children:e(o,{component:"div",sx:{...m},children:e(i,{components:v,rehypePlugins:[a],children:F})})})})]})}export{d as default};
1
+ import{jsx as e,jsxs as t}from"react/jsx-runtime";import{useMemo as n}from"react";import{Box as o,Typography as r}from"@mui/material";import i from"react-markdown";import a from"rehype-raw";import c from"./CitationAnchor.js";import{mergeRulebookCitationsIntoMatchingLinks as s}from"./Guidelines/utils/helper.js";import{useOptionalCompareContext as l}from"./CompareContext.js";import{buildOnDemandCitationContexts as d}from"./onDemandCitations/contextBuilder.js";import{getOnDemandCitationLinkKey as m}from"./onDemandCitations/href.js";const p=e=>e?`./dual-citation?citationNumber=${encodeURIComponent(e)}`:"";function u({content:u="",title:f="",citations:h={},styles:x={},docData:C={},deviationData:D=null,open:g,onCitationFullscreenChange:y,tabKey:b,sectionTitle:w,referenceSectionTitle:I,sourceNodeId:v,deviationKey:S,baseContentId:j,compareContentIds:F}){const E=l(),M=E?.treeData,N=E?.onDemandCitationConfig,T=n(()=>JSON.stringify(h||{}),[h]),_=n(()=>h,[T]),K=n(()=>JSON.stringify(C||{}),[C]),A=n(()=>C,[K]),O=n(()=>({citations:_,docData:A}),[_,A]),R=n(()=>{if(!N?.enabled)return new Map;return d({treeData:M,content:u,requestId:N.requestId,tabKey:b,popupNodeId:v||D?.nodeId,deviationKey:S,sectionTitle:w,referenceSectionTitle:I,docData:A,staticCitations:_,deviationData:D,cognitiveData:null,baseContentId:j,compareContentIds:F}).reduce((e,t)=>(e.set(m(t.href),t),e),new Map)},[j,F,u,D,S,N,I,w,v,_,A,b,M]),k=n(()=>{const e=D?.web_search_answer,t=e?.extraMetaData||{};return Object.keys(t).reduce((e,t)=>{const n=((e,t)=>{if(!e||!t)return null;const n=e?.web_search_answer,o=n?.extraMetaData?.[t];return n&&o?{reasoningId:t,evaluation:e,webSearchAnswer:n,extraMetaData:o}:null})(D,t);return n&&(e[t]=n),e},{})},[D]),q=n(()=>s(u),[u]),B=n(()=>({a:({href:t="",children:n,type:o,reason:r,...i})=>{const a=i?.["data-cognitive-reasoning"],s=(l=i?.["dual-citation"],!0===l||"true"===l);var l;const d=s&&a?k[String(a)]:null;return e(c,{href:s?p(String(a||"")):t,children:n,citationType:s?"dual_citation":o,citationReason:r,onDemandCitationContext:s?void 0:R.get(m(t)),metaData:{...O,...d?{webGpt:d}:{}},customStyle:d?{arrow:{color:"#6D28D9"}}:{},onFullscreenChange:y})}}),[R,O,k,y]);return t(o,{sx:{borderRadius:"8px",border:"1px solid #E4E7EC",bgcolor:"#FCFCFD"},children:[e(o,{sx:{px:1.5,py:.75,borderBottom:"1px solid #EAECF0"},children:e(r,{sx:{fontSize:"15px",fontWeight:600,color:"#344054",lineHeight:1.25},children:f})}),e(o,{sx:{px:1.5,py:1.1,display:"flex",flexDirection:"column",gap:.95},children:e(o,{sx:{display:"flex",flexDirection:"column"},children:e(r,{component:"div",sx:{...x},children:e(i,{components:B,rehypePlugins:[a],children:q})})})})]})}export{u as default};
2
2
  //# sourceMappingURL=CitationRenderer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CitationRenderer.js","sources":["../../../src/features/CognitiveCompare/CitationRenderer.tsx"],"sourcesContent":["import React, { useMemo } from 'react'\nimport { Box, Typography, IconButton } from \"@mui/material\";\nimport ReactMarkdown from \"react-markdown\";\nimport rehypeRaw from \"rehype-raw\";\nimport CitationAnchor from './CitationAnchor';\nimport { mergeRulebookCitationsIntoMatchingLinks } from './Guidelines/utils/helper';\n\ntype Props = {\n title?: string,\n content?: string,\n citations?: Record<string, any>,\n styles?: Record<string, any>\n docData?: Record<string, any> | null,\n deviationData?: Record<string, any> | null,\n open: boolean,\n onCitationFullscreenChange?: (isFullscreen: boolean) => void,\n}\n\nconst parseHref = (href: string) => {\n try {\n const baseUrl = typeof window !== \"undefined\" ? window.location.origin : \"http://localhost\";\n return new URL(href, baseUrl);\n } catch {\n return null;\n }\n};\n\nconst isDualCitation = (value: unknown) => value === true || value === \"true\";\n\nconst buildDualCitationHref = (reasoningId: string) =>\n reasoningId ? `./dual-citation?citationNumber=${encodeURIComponent(reasoningId)}` : \"\";\n\nconst buildWebGptMetaForReasoning = (\n deviationData: Record<string, any> | null | undefined,\n reasoningId: string,\n) => {\n if (!deviationData || !reasoningId) return null;\n\n const webSearchAnswer = deviationData?.web_search_answer;\n const extraMetaData = webSearchAnswer?.extraMetaData?.[reasoningId];\n if (!webSearchAnswer || !extraMetaData) return null;\n\n return {\n reasoningId,\n evaluation: deviationData,\n webSearchAnswer,\n extraMetaData,\n };\n};\n\nfunction CitationRenderer({\n content = \"\",\n title = \"\",\n citations = {},\n styles = {},\n docData = {} as Record<string, any>,\n deviationData = null,\n open,\n onCitationFullscreenChange,\n}: Props) {\n // Stabilize citations and docData — they arrive as new object references\n // on every stream tick even when content hasn't changed, which would\n // remount CitationAnchor and reset its expanded state.\n const stableCitationsStr = useMemo(() => JSON.stringify(citations || {}), [citations]);\n const stableCitations = useMemo(\n () => citations,\n [stableCitationsStr]\n );\n\n const stableDocDataStr = useMemo(() => JSON.stringify(docData || {}), [docData]);\n const stableDocData = useMemo(\n () => docData,\n [stableDocDataStr]\n );\n\n const stableMetaData = useMemo(\n () => ({ citations: stableCitations, docData: stableDocData }),\n [stableCitations, stableDocData]\n );\n\n const webGptMetaByReasoningId = useMemo(() => {\n const webSearchAnswer = deviationData?.web_search_answer;\n const extraMetaData = webSearchAnswer?.extraMetaData || {};\n\n return Object.keys(extraMetaData).reduce((acc: Record<string, any>, reasoningId) => {\n const matchedExtraMetaData = buildWebGptMetaForReasoning(deviationData, reasoningId);\n if (matchedExtraMetaData) acc[reasoningId] = matchedExtraMetaData;\n return acc;\n }, {});\n }, [deviationData]);\n\n const processedContent = useMemo(\n () => mergeRulebookCitationsIntoMatchingLinks(content),\n [content]\n );\n\n const components = useMemo(() => {\n return {\n a: ({ href = \"\", children, type, reason, ...props }: any) => {\n const reasoningId = props?.[\"data-cognitive-reasoning\"];\n const shouldUseDualCitation = isDualCitation(props?.[\"dual-citation\"]);\n const matchedExtraMetaData =\n shouldUseDualCitation && reasoningId\n ? webGptMetaByReasoningId[String(reasoningId)]\n : null;\n return (\n <CitationAnchor\n href={shouldUseDualCitation ? buildDualCitationHref(String(reasoningId || \"\")) : href}\n children={children}\n citationType={shouldUseDualCitation ? \"dual_citation\" : type}\n citationReason={reason}\n metaData={{\n ...stableMetaData,\n ...(matchedExtraMetaData ? { webGpt: matchedExtraMetaData } : {}),\n }}\n customStyle={\n matchedExtraMetaData ? \n {\n arrow: {\n color: \"#6D28D9\"\n }\n } : {}\n }\n onFullscreenChange={onCitationFullscreenChange}\n />\n );\n },\n };\n }, [stableMetaData, webGptMetaByReasoningId, onCitationFullscreenChange]);\n\n return (\n <Box\n sx={{\n borderRadius: \"8px\",\n border: \"1px solid #E4E7EC\",\n bgcolor: \"#FCFCFD\",\n }}\n >\n <Box\n sx={{ px: 1.5, py: 0.75, borderBottom: \"1px solid #EAECF0\" }}\n >\n <Typography\n sx={{\n fontSize: \"15px\",\n fontWeight: 600,\n color: \"#344054\",\n lineHeight: 1.25,\n }}\n >\n {title}\n </Typography>\n </Box>\n <Box\n sx={{\n px: 1.5,\n py: 1.1,\n display: \"flex\",\n flexDirection: \"column\",\n gap: 0.95,\n }}\n >\n <Box sx={{ display: \"flex\", flexDirection: \"column\" }}>\n <Typography\n component=\"div\"\n sx={{ ...styles }}\n >\n <ReactMarkdown components={components} rehypePlugins={[rehypeRaw as any]}>\n {processedContent}\n </ReactMarkdown>\n </Typography>\n </Box>\n </Box>\n </Box>\n )\n}\n\nexport default CitationRenderer\n"],"names":["buildDualCitationHref","reasoningId","encodeURIComponent","CitationRenderer","content","title","citations","styles","docData","deviationData","open","onCitationFullscreenChange","stableCitationsStr","useMemo","JSON","stringify","stableCitations","stableDocDataStr","stableDocData","stableMetaData","webGptMetaByReasoningId","webSearchAnswer","web_search_answer","extraMetaData","Object","keys","reduce","acc","matchedExtraMetaData","evaluation","buildWebGptMetaForReasoning","processedContent","mergeRulebookCitationsIntoMatchingLinks","components","a","href","children","type","reason","props","shouldUseDualCitation","value","String","jsx","CitationAnchor","citationType","citationReason","metaData","webGpt","customStyle","arrow","color","onFullscreenChange","jsxs","Box","sx","borderRadius","border","bgcolor","px","py","borderBottom","Typography","fontSize","fontWeight","lineHeight","display","flexDirection","gap","component","ReactMarkdown","rehypePlugins","rehypeRaw"],"mappings":"wTA2BA,MAEMA,EAAyBC,GAC3BA,EAAc,kCAAkCC,mBAAmBD,KAAiB,GAoBxF,SAASE,GAAiBC,QACtBA,EAAU,GAAAC,MACVA,EAAQ,GAAAC,UACRA,EAAY,CAAC,EAAAC,OACbA,EAAS,CAAC,EAAAC,QACVA,EAAU,CAAC,EAAAC,cACXA,EAAgB,KAAAC,KAChBA,EAAAC,2BACAA,IAKM,MAAAC,EAAqBC,EAAQ,IAAMC,KAAKC,UAAUT,GAAa,IAAK,CAACA,IACrEU,EAAkBH,EACpB,IAAMP,EACN,CAACM,IAGCK,EAAmBJ,EAAQ,IAAMC,KAAKC,UAAUP,GAAW,IAAK,CAACA,IACjEU,EAAgBL,EAClB,IAAML,EACN,CAACS,IAGCE,EAAiBN,EACnB,KAAA,CAASP,UAAWU,EAAiBR,QAASU,IAC9C,CAACF,EAAiBE,IAGhBE,EAA0BP,EAAQ,KACpC,MAAMQ,EAAkBZ,GAAea,kBACjCC,EAAgBF,GAAiBE,eAAiB,GAExD,OAAOC,OAAOC,KAAKF,GAAeG,OAAO,CAACC,EAA0B1B,KAC1D,MAAA2B,EArDkB,EAChCnB,EACAR,KAEA,IAAKQ,IAAkBR,EAAoB,OAAA,KAE3C,MAAMoB,EAAkB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AAEW,QAAS,OAAQC,cAAe,UACvC/B,SAAAO,EAACmB,EAAA,CACGO,UAAU,MACVd,GAAI,IAAKhD,GAET6B,WAACkC,EAAc,CAAArC,aAAwBsC,cAAe,CAACC,GAClDpC,SACLL,YAMxB"}
1
+ {"version":3,"file":"CitationRenderer.js","sources":["../../../src/features/CognitiveCompare/CitationRenderer.tsx"],"sourcesContent":["import React, { useMemo } from 'react'\nimport { Box, Typography, IconButton } from \"@mui/material\";\nimport ReactMarkdown from \"react-markdown\";\nimport rehypeRaw from \"rehype-raw\";\nimport CitationAnchor from './CitationAnchor';\nimport { mergeRulebookCitationsIntoMatchingLinks } from './Guidelines/utils/helper';\nimport { useOptionalCompareContext } from './CompareContext';\nimport {\n buildOnDemandCitationContexts,\n getOnDemandCitationLinkKey,\n} from './onDemandCitations';\n\ntype Props = {\n title?: string,\n content?: string,\n citations?: Record<string, any>,\n styles?: Record<string, any>\n docData?: Record<string, any> | null,\n deviationData?: Record<string, any> | null,\n open: boolean,\n onCitationFullscreenChange?: (isFullscreen: boolean) => void,\n tabKey?: \"deviation\" | \"association\",\n sectionTitle?: string,\n referenceSectionTitle?: string,\n sourceNodeId?: string,\n deviationKey?: string,\n baseContentId?: string,\n compareContentIds?: string[],\n}\n\nconst parseHref = (href: string) => {\n try {\n const baseUrl = typeof window !== \"undefined\" ? window.location.origin : \"http://localhost\";\n return new URL(href, baseUrl);\n } catch {\n return null;\n }\n};\n\nconst isDualCitation = (value: unknown) => value === true || value === \"true\";\n\nconst buildDualCitationHref = (reasoningId: string) =>\n reasoningId ? `./dual-citation?citationNumber=${encodeURIComponent(reasoningId)}` : \"\";\n\nconst buildWebGptMetaForReasoning = (\n deviationData: Record<string, any> | null | undefined,\n reasoningId: string,\n) => {\n if (!deviationData || !reasoningId) return null;\n\n const webSearchAnswer = deviationData?.web_search_answer;\n const extraMetaData = webSearchAnswer?.extraMetaData?.[reasoningId];\n if (!webSearchAnswer || !extraMetaData) return null;\n\n return {\n reasoningId,\n evaluation: deviationData,\n webSearchAnswer,\n extraMetaData,\n };\n};\n\nfunction CitationRenderer({\n content = \"\",\n title = \"\",\n citations = {},\n styles = {},\n docData = {} as Record<string, any>,\n deviationData = null,\n open,\n onCitationFullscreenChange,\n tabKey,\n sectionTitle,\n referenceSectionTitle,\n sourceNodeId,\n deviationKey,\n baseContentId,\n compareContentIds,\n}: Props) {\n const compareContext = useOptionalCompareContext();\n const treeData = compareContext?.treeData;\n const onDemandCitationConfig = compareContext?.onDemandCitationConfig;\n // Stabilize citations and docData — they arrive as new object references\n // on every stream tick even when content hasn't changed, which would\n // remount CitationAnchor and reset its expanded state.\n const stableCitationsStr = useMemo(() => JSON.stringify(citations || {}), [citations]);\n const stableCitations = useMemo(\n () => citations,\n [stableCitationsStr]\n );\n\n const stableDocDataStr = useMemo(() => JSON.stringify(docData || {}), [docData]);\n const stableDocData = useMemo(\n () => docData,\n [stableDocDataStr]\n );\n\n const stableMetaData = useMemo(\n () => ({ citations: stableCitations, docData: stableDocData }),\n [stableCitations, stableDocData]\n );\n\n const onDemandContextByLinkKey = useMemo(() => {\n if (!onDemandCitationConfig?.enabled) return new Map<string, any>();\n\n const contexts = buildOnDemandCitationContexts({\n treeData,\n content,\n requestId: onDemandCitationConfig.requestId,\n tabKey,\n popupNodeId: sourceNodeId || (deviationData as any)?.nodeId,\n deviationKey,\n sectionTitle,\n referenceSectionTitle,\n docData: stableDocData,\n staticCitations: stableCitations,\n deviationData,\n cognitiveData: null,\n baseContentId,\n compareContentIds,\n });\n\n return contexts.reduce((acc, context) => {\n acc.set(getOnDemandCitationLinkKey(context.href), context);\n return acc;\n }, new Map<string, any>());\n }, [\n baseContentId,\n compareContentIds,\n content,\n deviationData,\n deviationKey,\n onDemandCitationConfig,\n referenceSectionTitle,\n sectionTitle,\n sourceNodeId,\n stableCitations,\n stableDocData,\n tabKey,\n treeData,\n ]);\n\n const webGptMetaByReasoningId = useMemo(() => {\n const webSearchAnswer = deviationData?.web_search_answer;\n const extraMetaData = webSearchAnswer?.extraMetaData || {};\n\n return Object.keys(extraMetaData).reduce((acc: Record<string, any>, reasoningId) => {\n const matchedExtraMetaData = buildWebGptMetaForReasoning(deviationData, reasoningId);\n if (matchedExtraMetaData) acc[reasoningId] = matchedExtraMetaData;\n return acc;\n }, {});\n }, [deviationData]);\n\n const processedContent = useMemo(\n () => mergeRulebookCitationsIntoMatchingLinks(content),\n [content]\n );\n\n const components = useMemo(() => {\n return {\n a: ({ href = \"\", children, type, reason, ...props }: any) => {\n const reasoningId = props?.[\"data-cognitive-reasoning\"];\n const shouldUseDualCitation = isDualCitation(props?.[\"dual-citation\"]);\n const matchedExtraMetaData =\n shouldUseDualCitation && reasoningId\n ? webGptMetaByReasoningId[String(reasoningId)]\n : null;\n return (\n <CitationAnchor\n href={shouldUseDualCitation ? buildDualCitationHref(String(reasoningId || \"\")) : href}\n children={children}\n citationType={shouldUseDualCitation ? \"dual_citation\" : type}\n citationReason={reason}\n onDemandCitationContext={\n shouldUseDualCitation\n ? undefined\n : onDemandContextByLinkKey.get(getOnDemandCitationLinkKey(href))\n }\n metaData={{\n ...stableMetaData,\n ...(matchedExtraMetaData ? { webGpt: matchedExtraMetaData } : {}),\n }}\n customStyle={\n matchedExtraMetaData ? \n {\n arrow: {\n color: \"#6D28D9\"\n }\n } : {}\n }\n onFullscreenChange={onCitationFullscreenChange}\n />\n );\n },\n };\n }, [onDemandContextByLinkKey, stableMetaData, webGptMetaByReasoningId, onCitationFullscreenChange]);\n\n return (\n <Box\n sx={{\n borderRadius: \"8px\",\n border: \"1px solid #E4E7EC\",\n bgcolor: \"#FCFCFD\",\n }}\n >\n <Box\n sx={{ px: 1.5, py: 0.75, borderBottom: \"1px solid #EAECF0\" }}\n >\n <Typography\n sx={{\n fontSize: \"15px\",\n fontWeight: 600,\n color: \"#344054\",\n lineHeight: 1.25,\n }}\n >\n {title}\n </Typography>\n </Box>\n <Box\n sx={{\n px: 1.5,\n py: 1.1,\n display: \"flex\",\n flexDirection: \"column\",\n gap: 0.95,\n }}\n >\n <Box sx={{ display: \"flex\", flexDirection: \"column\" }}>\n <Typography\n component=\"div\"\n sx={{ ...styles }}\n >\n <ReactMarkdown components={components} rehypePlugins={[rehypeRaw as any]}>\n {processedContent}\n </ReactMarkdown>\n </Typography>\n </Box>\n </Box>\n </Box>\n )\n}\n\nexport default CitationRenderer\n"],"names":["buildDualCitationHref","reasoningId","encodeURIComponent","CitationRenderer","content","title","citations","styles","docData","deviationData","open","onCitationFullscreenChange","tabKey","sectionTitle","referenceSectionTitle","sourceNodeId","deviationKey","baseContentId","compareContentIds","compareContext","useOptionalCompareContext","treeData","onDemandCitationConfig","stableCitationsStr","useMemo","JSON","stringify","stableCitations","stableDocDataStr","stableDocData","stableMetaData","onDemandContextByLinkKey","enabled","Map","buildOnDemandCitationContexts","requestId","popupNodeId","nodeId","staticCitations","cognitiveData","reduce","acc","context","set","getOnDemandCitationLinkKey","href","webGptMetaByReasoningId","webSearchAnswer","web_search_answer","extraMetaData","Object","keys","matchedExtraMetaData","evaluation","buildWebGptMetaForReasoning","processedContent","mergeRulebookCitationsIntoMatchingLinks","components","a","children","type","reason","props","shouldUseDualCitation","value","String","jsx","CitationAnchor","citationType","citationReason","onDemandCitationContext","get","metaData","webGpt","customStyle","arrow","color","onFullscreenChange","jsxs","Box","sx","borderRadius","border","bgcolor","px","py","borderBottom","Typography","fontSize","fontWeight","lineHeight","display","flexDirection","gap","component","ReactMarkdown","rehypePlugins","rehypeRaw"],"mappings":"uhBAuCA,MAEMA,EAAyBC,GAC3BA,EAAc,kCAAkCC,mBAAmBD,KAAiB,GAoBxF,SAASE,GAAiBC,QACtBA,EAAU,GAAAC,MACVA,EAAQ,GAAAC,UACRA,EAAY,CAAC,EAAAC,OACbA,EAAS,CAAC,EAAAC,QACVA,EAAU,CAAC,EAAAC,cACXA,EAAgB,KAAAC,KAChBA,EAAAC,2BACAA,EAAAC,OACAA,EAAAC,aACAA,EAAAC,sBACAA,EAAAC,aACAA,EAAAC,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zE,GAEToD,WAACoC,EAAc,CAAAtC,aAAwBuC,cAAe,CAACC,GAClDtC,SACLJ,YAMxB"}
@@ -0,0 +1,2 @@
1
+ import{jsx as e,jsxs as t}from"react/jsx-runtime";import{Box as i}from"@mui/material";import{useMemo as a}from"react";import r from"react-markdown";import n from"rehype-raw";import l from"../PdfViewer/PdfViewer.js";import{useCompareContext as o}from"./CompareContext.js";import{SHARED_MARKDOWN_STYLES as s}from"./CognitiveCompareConfig.js";import c from"./GptWebCitationPanel.js";import{processGuidelinesMarkdown as u}from"./Guidelines/utils/processGuidelinesMarkdown.js";import d from"./ResizableSplitPane.js";const g=({label:e})=>t("div",{style:{padding:"12px",fontSize:"13px",color:"#475467",lineHeight:1.5},children:["Citation text was returned for ",e,", but a signed PDF URL is not available."]}),h=e=>({...e?.customMetaData||{},...e?.custom_metadata||{}}),m=(e,t)=>{const i=h(e);return i.signed_url||i.signedUrl||t?.signed_url||t?.signedUrl||t?.metadata?.signed_url||t?.metadata?.signedUrl||""},p=e=>{try{const{citationNumber:t,parsedUrl:i}=(e=>{const t=e.match(/^(?:pdf_citation|deviation_summary)\$(\d+)/);if(t)try{const i=e.indexOf("?"),a=i>=0?e.slice(i):"";return{citationNumber:t[1],parsedUrl:new URL(a||"./",window.location.origin)}}catch{return{citationNumber:t[1],parsedUrl:null}}try{const t=new URL(e,window.location.origin);return{citationNumber:t.searchParams.get("citationNumber")||t.searchParams.get("citation_number"),parsedUrl:t}}catch{return{citationNumber:null,parsedUrl:null}}})(e),a=i?.searchParams.get("phrase_to_highlight")||null;return{citationNumber:t,phraseToHighlight:a,citationTypeFromHref:i?.searchParams.get("citation_type")||null}}catch{return{citationNumber:null,phraseToHighlight:null,citationTypeFromHref:null}}},f=t=>e("div",{style:{height:"100%",display:"flex",flexDirection:"column"},children:t}),_=({href:t,metaData:_,citationTitle:b,citationType:P,citationReason:F,isFullscreen:w})=>{const{guidelinesData:x}=o(),{citationNumber:y,phraseToHighlight:C,citationTypeFromHref:D}=p(t),U=P||D||void 0,N="il_rulebook_citation"===U?"rulebook_citation":U,T=y&&_?.citations?.[y]||{},j=_?.docData?.documents||{},v=_?.docData?.input_index_map||{},H=Object.keys(_?.citations||{}).length>0||Object.keys(_?.docData||{}).length>0,k=v?.[0],R=v?.[1],S=k?j[k]:null,G=R?j[R]:null,A=k?T[k]:null,O=R?T[R]:null,M=h(A),V=h(O),z=m(A,S),L=m(O,G),W=a(()=>A&&S?z?e(l,{defaultScale:"PageWidth",showFullScreenAction:!1,showHighlightsAction:!1,pdfName:S?.title,pdfUrl:z,highlightText:[A?.highlighted_text??""],highlightPages:{1:M?.pdf_start_page_number},jumpToPageValue:1,highlightCordinatePages:[],useCoordinates:!1,useRange:!0,rangeOfPages:[M?.pdf_start_page_number,M?.pdf_end_page_number]}):e(g,{label:"the uploaded contract"}):null,[A,M,S,z]),E=a(()=>O&&G?L?e(l,{defaultScale:"PageWidth",showFullScreenAction:!1,showHighlightsAction:!1,pdfName:G?.title,pdfUrl:L,jumpToPageValue:1,highlightText:[O?.highlighted_text??""],highlightPages:{1:V?.pdf_start_page_number},highlightCordinatePages:[],useCoordinates:!1,useRange:!0,rangeOfPages:[V?.pdf_start_page_number,V?.pdf_end_page_number]}):e(g,{label:"the reference contract"}):null,[O,V,G,L]),$="dual_citation"===N,q=$&&!!_?.webGpt,B=a(()=>{const t=q?e(c,{metaData:_,isFullscreen:w}):"rulebook_citation"===N?e(i,{sx:{padding:"0px 20px",backgroundColor:"#FFFFFF",borderRadius:"8px",...s,overflow:"auto"},children:e(r,{rehypePlugins:[n],children:u({guidelinesData:x,targetHighlights:[C],labelColor:"#FEF08A"})})}):E;return W||t?e(d,!W&&t?{rightComponent:t,isFullscreen:w}:W&&!t?{leftComponent:W,isFullscreen:w}:{leftComponent:W,rightComponent:t,isFullscreen:w}):null},[W,E,N,q,_,w,x,C]);return _?.webGpt&&!H?e(c,{metaData:_,isFullscreen:w}):y?"rulebook_citation"===N?B?f(B):e("div",{style:{padding:"12px",fontSize:"13px",color:"#344054",lineHeight:1.5},children:F||"Rulebook citation selected."}):$?B?f(B):_?.webGpt?e(c,{metaData:_,isFullscreen:w}):e("div",{children:"Missing PDF Citation. Please try again later"}):["contract","clause"].includes(b)?B?f(B):e("div",{children:"Missing PDF Citation. Please try again later"}):e("div",{children:"No Citation Found. Please try again later"}):null};export{_ as default};
2
+ //# sourceMappingURL=CitationRendererInner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CitationRendererInner.js","sources":["../../../src/features/CognitiveCompare/CitationRendererInner.tsx"],"sourcesContent":["import { Box } from \"@mui/material\";\nimport React, { useMemo } from \"react\";\nimport ReactMarkdown from \"react-markdown\";\nimport rehypeRaw from \"rehype-raw\";\nimport PdfViewer from \"../PdfViewer/PdfViewer\";\nimport { useCompareContext } from \"./CompareContext\";\nimport { SHARED_MARKDOWN_STYLES } from \"./CognitiveCompareConfig\";\nimport GptWebCitationPanel from \"./GptWebCitationPanel\";\nimport { processGuidelinesMarkdown } from \"./Guidelines/utils/processGuidelinesMarkdown\";\nimport ResizableSplitPane from \"./ResizableSplitPane\";\n\nexport interface CitationRendererInnerProps {\n href: string;\n children: any;\n metaData: any;\n citationTitle: string;\n citationType?: string;\n citationReason?: string;\n isFullscreen: boolean\n}\n\nconst MissingPdfUrlNotice = ({ label }: { label: string }) => (\n <div style={{ padding: \"12px\", fontSize: \"13px\", color: \"#475467\", lineHeight: 1.5 }}>\n Citation text was returned for {label}, but a signed PDF URL is not available.\n </div>\n);\n\nconst getCitationCustomMetadata = (citation: any) => ({\n ...(citation?.customMetaData || {}),\n ...(citation?.custom_metadata || {}),\n});\n\nconst getSignedPdfUrl = (citation: any, document: any) => {\n const customMetadata = getCitationCustomMetadata(citation);\n return (\n customMetadata.signed_url ||\n customMetadata.signedUrl ||\n document?.signed_url ||\n document?.signedUrl ||\n document?.metadata?.signed_url ||\n document?.metadata?.signedUrl ||\n \"\"\n );\n};\n\nconst getCitationDetailsFromHref = (\n url: string,\n): {\n citationNumber: string | null;\n phraseToHighlight: string | null;\n citationTypeFromHref: string | null;\n} => {\n const getCitationUrl = (value: string) => {\n const prefixedCitationMatch = value.match(/^(?:pdf_citation|deviation_summary)\\$(\\d+)/);\n if (prefixedCitationMatch) {\n try {\n const queryStartIndex = value.indexOf(\"?\");\n const search = queryStartIndex >= 0 ? value.slice(queryStartIndex) : \"\";\n return {\n citationNumber: prefixedCitationMatch[1],\n parsedUrl: new URL(search || \"./\", window.location.origin),\n };\n } catch {\n return {\n citationNumber: prefixedCitationMatch[1],\n parsedUrl: null,\n };\n }\n }\n\n try {\n const parsedUrl = new URL(value, window.location.origin);\n const citationNumber =\n parsedUrl.searchParams.get(\"citationNumber\") ||\n parsedUrl.searchParams.get(\"citation_number\");\n return {citationNumber, parsedUrl};\n } catch {\n return {citationNumber: null, parsedUrl: null};\n }\n };\n\n try {\n const { citationNumber, parsedUrl } = getCitationUrl(url);\n const phraseToHighlight = parsedUrl?.searchParams.get(\"phrase_to_highlight\") || null;\n const citationTypeFromHref = parsedUrl?.searchParams.get(\"citation_type\") || null;\n return {citationNumber, phraseToHighlight, citationTypeFromHref};\n } catch {\n return {citationNumber: null, phraseToHighlight: null, citationTypeFromHref: null};\n }\n};\n\nconst renderCitationShell = (content: React.ReactNode) => (\n <div style={{ height: \"100%\", display: \"flex\", flexDirection: \"column\" }}>\n {content}\n </div>\n);\n\nconst CitationRendererInner: React.FC<CitationRendererInnerProps> = ({\n href,\n metaData,\n citationTitle,\n citationType,\n citationReason,\n isFullscreen\n}) => {\n const { guidelinesData } = useCompareContext();\n const pdfCitationTypes = [\"contract\", \"clause\"];\n const {citationNumber, phraseToHighlight, citationTypeFromHref} = getCitationDetailsFromHref(href);\n const resolvedCitationType = citationType || citationTypeFromHref || undefined;\n const normalizedCitationType =\n resolvedCitationType === \"il_rulebook_citation\" ? \"rulebook_citation\" : resolvedCitationType;\n const citationGroup = citationNumber ? (metaData?.citations?.[citationNumber] || {}) : {};\n const documents = metaData?.docData?.documents || {};\n const inputIndexMap = metaData?.docData?.input_index_map || {};\n const hasRegularCitationData =\n Object.keys(metaData?.citations || {}).length > 0 ||\n Object.keys(metaData?.docData || {}).length > 0;\n\n const leftUuid = inputIndexMap?.[\"0\"];\n const rightUuid = inputIndexMap?.[\"1\"];\n const leftDocument = leftUuid ? documents[leftUuid] : null;\n const rightDocument = rightUuid ? documents[rightUuid] : null;\n const leftCitation = leftUuid ? citationGroup[leftUuid] : null;\n const rightCitation = rightUuid ? citationGroup[rightUuid] : null;\n const leftCitationMetadata = getCitationCustomMetadata(leftCitation);\n const rightCitationMetadata = getCitationCustomMetadata(rightCitation);\n const leftPdfUrl = getSignedPdfUrl(leftCitation, leftDocument);\n const rightPdfUrl = getSignedPdfUrl(rightCitation, rightDocument);\n\n const leftComponent = useMemo(() => {\n if (!leftCitation || !leftDocument) return null;\n if (!leftPdfUrl) return <MissingPdfUrlNotice label=\"the uploaded contract\" />;\n return (\n <PdfViewer\n defaultScale={'PageWidth'}\n showFullScreenAction={false}\n showHighlightsAction={false}\n pdfName={leftDocument?.title}\n pdfUrl={leftPdfUrl}\n highlightText={[leftCitation?.highlighted_text ?? '']}\n highlightPages={{ 1: leftCitationMetadata?.pdf_start_page_number }}\n jumpToPageValue={1}\n highlightCordinatePages={[]}\n useCoordinates={false}\n useRange={true}\n rangeOfPages={[leftCitationMetadata?.pdf_start_page_number, leftCitationMetadata?.pdf_end_page_number]}\n />\n );\n }, [\n leftCitation,\n leftCitationMetadata,\n leftDocument,\n leftPdfUrl,\n ]);\n\n const rightComponent = useMemo(() => {\n if (!rightCitation || !rightDocument) return null;\n if (!rightPdfUrl) return <MissingPdfUrlNotice label=\"the reference contract\" />;\n return (\n <PdfViewer\n defaultScale={'PageWidth'}\n showFullScreenAction={false}\n showHighlightsAction={false}\n pdfName={rightDocument?.title}\n pdfUrl={rightPdfUrl}\n jumpToPageValue={1}\n highlightText={[rightCitation?.highlighted_text ?? '']}\n highlightPages={{ 1: rightCitationMetadata?.pdf_start_page_number }}\n highlightCordinatePages={[]}\n useCoordinates={false}\n useRange={true}\n rangeOfPages={[rightCitationMetadata?.pdf_start_page_number, rightCitationMetadata?.pdf_end_page_number]}\n />\n );\n }, [\n rightCitation,\n rightCitationMetadata,\n rightDocument,\n rightPdfUrl,\n ]);\n\n const isDualCitationType = normalizedCitationType === \"dual_citation\";\n const isDualWebGptCitation = isDualCitationType && !!metaData?.webGpt;\n\n const splitPaneComponent = useMemo(() => {\n const rightPane =\n isDualWebGptCitation ? (\n <GptWebCitationPanel metaData={metaData} isFullscreen={isFullscreen} />\n ) : normalizedCitationType === \"rulebook_citation\" ? (\n <Box sx={{\n padding: '0px 20px',\n backgroundColor: '#FFFFFF',\n borderRadius: '8px',\n ...SHARED_MARKDOWN_STYLES,\n overflow: 'auto'\n }}>\n <ReactMarkdown rehypePlugins={[rehypeRaw as any]}>\n {processGuidelinesMarkdown({\n guidelinesData, targetHighlights: [phraseToHighlight!], labelColor: \"#FEF08A\"})}\n </ReactMarkdown>\n </Box>\n ) : (\n rightComponent\n );\n\n if (!leftComponent && !rightPane) return null;\n\n if (!leftComponent && rightPane) {\n return (\n <ResizableSplitPane\n rightComponent={rightPane}\n isFullscreen={isFullscreen}\n />\n );\n }\n\n if (leftComponent && !rightPane) {\n return (\n <ResizableSplitPane\n leftComponent={leftComponent}\n isFullscreen={isFullscreen}\n />\n );\n }\n\n return (\n <ResizableSplitPane\n leftComponent={leftComponent}\n rightComponent={rightPane}\n isFullscreen={isFullscreen}\n />\n );\n }, [leftComponent, rightComponent, normalizedCitationType, isDualWebGptCitation, metaData, isFullscreen, guidelinesData, phraseToHighlight]);\n\n if (metaData?.webGpt && !hasRegularCitationData) {\n return <GptWebCitationPanel metaData={metaData} isFullscreen={isFullscreen} />;\n }\n\n if (!citationNumber) return null;\n\n if (normalizedCitationType === \"rulebook_citation\") {\n if (splitPaneComponent) return renderCitationShell(splitPaneComponent);\n\n return (\n <div style={{ padding: \"12px\", fontSize: \"13px\", color: \"#344054\", lineHeight: 1.5 }}>\n {citationReason || \"Rulebook citation selected.\"}\n </div>\n );\n }\n\n if (isDualCitationType) {\n if (splitPaneComponent) return renderCitationShell(splitPaneComponent);\n if (metaData?.webGpt) return <GptWebCitationPanel metaData={metaData} isFullscreen={isFullscreen} />;\n return <div>Missing PDF Citation. Please try again later</div>;\n }\n\n if (pdfCitationTypes.includes(citationTitle)) {\n if (splitPaneComponent) return renderCitationShell(splitPaneComponent);\n return <div>Missing PDF Citation. Please try again later</div>;\n }\n\n return <div>No Citation Found. Please try again later</div>;\n};\n\nexport default CitationRendererInner;\n"],"names":["MissingPdfUrlNotice","label","style","padding","fontSize","color","lineHeight","children","getCitationCustomMetadata","citation","customMetaData","custom_metadata","getSignedPdfUrl","document","customMetadata","signed_url","signedUrl","metadata","getCitationDetailsFromHref","url","citationNumber","parsedUrl","value","prefixedCitationMatch","match","queryStartIndex","indexOf","search","slice","URL","window","location","origin","searchParams","get","getCitationUrl","phraseToHighlight","citationTypeFromHref","renderCitationShell","content","jsx","height","display","flexDirection","CitationRendererInner","href","metaData","citationTitle","citationType","citationReason","isFullscreen","guidelinesData","useCompareContext","resolvedCitationType","normalizedCitationType","citationGroup","citations","documents","docData","inputIndexMap","input_index_map","hasRegularCitationData","Object","keys","length","leftUuid","rightUuid","leftDocument","rightDocument","leftCitation","rightCitation","leftCitationMetadata","rightCitationMetadata","leftPdfUrl","rightPdfUrl","leftComponent","useMemo","PdfViewer","defaultScale","showFullScreenAction","showHighlightsAction","pdfName","title","pdfUrl","highlightText","highlighted_text","highlightPages","pdf_start_page_number","jumpToPageValue","highlightCordinatePages","useCoordinates","useRange","rangeOfPages","pdf_end_page_number","rightComponent","isDualCitationType","isDualWebGptCitation","webGpt","splitPaneComponent","rightPane","GptWebCitationPanel","Box","sx","backgroundColor","borderRadius","SHARED_MARKDOWN_STYLES","overflow","ReactMarkdown","rehypePlugins","rehypeRaw","processGuidelinesMarkdown","targetHighlights","labelColor","ResizableSplitPane","includes"],"mappings":"+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,OAAQC,SAAU,OAAQC,MAAO,UAAWC,WAAY,KAC1EC,YAAkB,gCAK3BwF,EACIG,EAA2B5D,EAAoB4D,GAC/CpD,GAAUmD,OAAgBzD,EAAA4D,EAAA,CAAoBtD,WAAoBI,iBAC/DV,EAAC,OAAIjC,SAA4C,iDAnJnC,CAAC,WAAY,UAsJjB2G,SAASnE,GACtBmD,EAA2B5D,EAAoB4D,GAC5C1D,EAAC,OAAIjC,SAA4C,iDAGrDiC,EAAC,OAAIjC,SAAyC,8CAvBzB"}
@@ -1,2 +1,2 @@
1
- import{jsx as e,jsxs as t}from"react/jsx-runtime";import{useState as n,useRef as i,useMemo as o,useEffect as r,useCallback as s}from"react";import{Box as l,Snackbar as c,Alert as a,Tooltip as u,Typography as d,Tabs as p,Tab as f}from"@mui/material";import{ChevronDown as g}from"lucide-react";import{ButtonCognitiveIcon as h}from"../../assests/svg/ButtonCognitiveIcon.js";import m from"./OverlayComponent.js";import{safeStringify as S,extractDeviationScore as v,generateColorPalette as x,findKeyPathByNodeId as R,DEVIATION_BADGE_SEPARATOR as y,hasMeaningfulRedlineTags as b,scrollAndHighlightClause as C,scrollAndWait as w,waitForScrollIdle as B}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as _,DEFAULT_FIELD_CONFIG as I,DEFAULT_COMPARISON_CONFIG as F}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import{DEFAULT_DEVIAION_COLOR as T,EMPTY_SUMMARY_POPUP_STATE as E,DEFAULT_COMPONENT_HEADER_TEXT as A}from"./CognitiveCompareConstants.js";import D from"./CognitivePopup.js";import k from"./MoreFunctionsPopup.js";import P from"./LoaderComponent.js";import O from"./components/ThreeDotsLoader.js";import{useCognitiveTreeData as L}from"./hooks/useCompareData.js";import{useComparePopups as $}from"./hooks/useComparePopups.js";import{useSectionRefs as j}from"./hooks/useSectionRefs.js";import{useAccordionState as N}from"./hooks/useAccordionState.js";import{useDeviationNavigation as M}from"./hooks/useDeviationNavigation.js";import H from"./components/CompareHeader.js";import z from"./components/SubSectionAccordion.js";import W from"./components/LHSSectionRow.js";import q from"./components/RHSSectionRow.js";import G from"./components/CognitiveSummaryPopup.js";import{CompareContextProvider as V}from"./CompareContext.js";import{useStyleHelpers as K}from"./hooks/useStyles.js";import{useResizeHandler as J}from"./hooks/useResizeHandler.js";import{useLinesCalculator as Y}from"./hooks/useLinesCalculator.js";import{useSideBySide as X}from"./hooks/useSideBySide.js";import U from"./components/SvgConnectors.js";import Q from"./Guidelines/components/GuidelinePanel.js";import Z from"./Guidelines/components/WebGptPanel.js";const ee=({componentHeaderText:ee=A,treeData:te,comparisonConfig:ne,leftColumnTitleText:ie,rightColumnTitleText:oe,markdownStyles:re,resetTrigger:se,displayConfig:le={isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1,displayEmailNotifier:!0,isStreamingEnabled:!1},onMaintainRelativeOrderChange:ce,popupConfig:ae,deviationData:ue={},deviationNodeIdToView:de,resetDeviationNodeId:pe,isProposingFix:fe=!1,proposingFixNodeId:ge,isRedlineFlow:he,badgeStyleOverride:me,guidelinesData:Se,gptWebCitationConfig:ve})=>{const[xe,Re]=n(le.maintainRelativeOrder),ye=le?.expandLevels??0,be=!!le?.expandAllSections,Ce=!!xe||!!le?.showDeviationBadges,[we,Be]=n(!1),[_e,Ie]=n(null),[Fe]=n(te?.newEvaluationResult??le?.enableDeviationSchemaBackwardCompatibility??!0),[Te,Ee]=n(new Set),[Ae,De]=n([]),[ke,Pe]=n(!1),[Oe,Le]=n(0),$e=i(null),je=i(null),Ne=i(null),Me=i(null),He=i(null),ze=i(!1),We=i(null),qe=i({}),Ge=i([]),Ve=i(()=>{}),Ke=i(null),Je=i(()=>{}),Ye=o(()=>JSON.stringify(ue||{}),[JSON.stringify(ue)]),Xe=o(()=>ue||{},[Ye]),Ue=o(()=>te?.cognitive_decisioning||{},[te]),Qe=o(()=>({..._,...re}),[re]),Ze=i(null),et=i(null),tt=i(null),nt=i(null),it=i(null),ot=i(null),rt=i(null),st=i(null),lt=i(null),ct=i(null),{cognitivePopup:at,setCognitivePopup:ut,moreFunctions:dt,setMoreFunctions:pt,position:ft,setPosition:gt,activeBadgeId:ht,summaryPopup:mt,setSummaryPopup:St,closeSummaryPopup:vt,setActiveBadgeId:xt,popupRef:Rt,handleOpenCognitiveCompare:yt,openCognitivePopupFromState:bt,closeCognitivePopup:Ct,closeMoreFunctionsPopup:wt}=$(Ze),Bt=o(()=>({fields:ne?.fields??I,thresholds:{high:ne?.thresholds?.high??F.thresholds.high,medium:ne?.thresholds?.medium??F.thresholds.medium,exact:ne?.thresholds?.exact??F.thresholds.exact}}),[ne]),[_t,It]=n(null),Ft=te?.documents?.[te?.input_index_map?.[0]]?.title,Tt=te?.documents?.[te?.input_index_map?.[1]]?.title,Et=S(ie||Ft||"Uploaded Contract"),At=te?.documents?.[te?.input_index_map?.[0]]?.metadata?.file_name,Dt=S(At),kt=te?.documents?.[te?.input_index_map?.[1]]?.metadata?.file_name,Pt=S(kt),Ot=S(oe||Tt||"Reference Template"),{isGuidelineMode:Lt,activeProposed:$t,existingRule:jt,proposedSections:Nt,existingSections:Mt,visibleFields:Ht,parentDeviationRecord:zt,deviationNumberRegistry:Wt,deviationParentRegistry:qt,parseError:Gt}=L(te,xe,Xe,Bt,Fe,Se);r(()=>{Gt&&Ie(`Failed to load comparison: ${Gt}`)},[Gt]);const Vt=Nt.length>0||Mt.length>0,Kt=o(()=>{if(!he)return"off";let e=0,t=0;const n=i=>{Array.isArray(i)&&i.forEach(i=>{const o=i?.content||"";b(o)&&(e+=1,t+=String(o).length),i?.subsections?.length&&n(i.subsections)})};return n(Nt),n(Mt),`${e}:${t}`},[he,Nt,Mt]);r(()=>{if(Nt.length||Mt.length)if(be){const e={},t={},n=(n,i)=>{n.forEach((n,o)=>{const r=xe?`${i}-${o}`:String(o);e[r]=!0;const s=(e,n)=>{e?.forEach((e,i)=>{const o=`${n}-${i}`;t[o]=!0,e.subsections?.length&&s(e.subsections,o)})};n.subsections?.length&&s(n.subsections,String(o))})};n(Nt,"left"),n(Mt,"right"),An(e),kn(t)}else if(ye>0){const e={},t={},n=(n,i,o)=>{n.forEach((n,r)=>{if(o>=1){const t=xe?`${i}-${r}`:String(r);e[t]=!0}const s=(e,n,i)=>{i>o||e?.forEach((e,o)=>{const r=`${n}-${o}`;t[r]=!0,e.subsections?.length&&s(e.subsections,r,i+1)})};n.subsections?.length&&o>=2&&s(n.subsections,String(r),2)})};n(Nt,"left",ye),n(Mt,"right",ye),An(e),kn(t)}},[be,ye,Nt,Mt,xe]);const{leftRefs:Jt,rightRefs:Yt,sectionLeftRefs:Xt,sectionRightRefs:Ut,lhsBadgeRefs:Qt,rhsBadgeRefs:Zt,sectionRightRowRefs:en,subSectionLeftRefs:tn,subSectionRightRefs:nn,sectionRowRefs:on,getSectionRowRef:rn,getSubSectionRef:sn,getBadgeRef:ln}=j(Ht.map(({key:e})=>e),Math.max(Nt.length,Mt.length)),{isSideBySide:cn,isArrowVisible:an,setIsSideBySide:un,setIsArrowVisible:dn,isResizing:pn,setIsResizing:fn,isSideBySideLoading:gn,setIsSideBySideLoading:hn,activeSideBySideSection:mn,setActiveSideBySideSection:Sn,scrollLock:vn,sideBySideCacheRef:xn,isSideBySideRef:Rn,activeSideBySideRightSectionRef:yn,activeSideBySideSectionRef:bn,sideBySideLineRef:Cn,highlightedClauseRefs:wn,clearClauseHighlight:Bn,applyAlignmentPadding:_n,resetSideBySide:In,activateSideBySide:Fn}=X({isGuidelineMode:Lt,maintainRelativeOrder:xe,proposedSections:Nt,existingSections:Mt,leftContainerRef:st,rightContainerRef:tt,scrollContainerRef:Ze,sectionLeftRefs:Xt,sectionRightRefs:Ut,subSectionLeftRefs:tn,subSectionRightRefs:nn,lhsBadgeRefs:Qt,rhsBadgeRefs:Zt,sectionRowRefs:on,sectionRightRowRefs:en,rhsTopSpacerRef:nt,rhsBottomSpacerRef:it,lhsTopSpacerRef:ot,lhsBottomSpacerRef:rt,calculateLinesRef:Ve,setConnectedSections:Ee,setConnectedLines:De,cachedConnectedPositions:Ge,closeMoreFunctionsPopup:wt,setErrorToast:Ie,moreFunctions:dt,closeSummaryPopup:vt}),Tn=i(Fn);r(()=>{Tn.current=Fn},[Fn]);const{expandedSections:En,setExpandedSections:An,expandedSubSections:Dn,setExpandedSubSections:kn,handleSubSectionToggle:Pn,toggleSection:On,forceExpandCrossWiredSections:Ln}=N({maintainRelativeOrder:!!xe,proposedSections:Nt,existingSections:Mt,activeSideBySideSection:mn,connectedSections:Te,resetSideBySide:In,setConnectedSections:Ee,setConnectedLines:De,cachedConnectedPositions:Ge,svgContainerRef:$e,isAnimatingRef:ze,animationTimerRef:We,calculateLinesRef:Ve,sectionLeftRefs:Xt,sectionRightRefs:Ut,subSectionLeftRefs:tn,subSectionRightRefs:nn}),$n=()=>{if(null==mn)return;const e=Xt.current[mn]?.current,t=Ut.current[mn]?.current,n=tt.current;if(!e||!t||!n)return;const i=e.getBoundingClientRect(),o=t.getBoundingClientRect(),r=n.getBoundingClientRect(),s=i.top-r.top,l=o.top-r.top-s;n.scrollBy({top:l,behavior:"smooth"})},jn=s(e=>{e?.stopPropagation(),Pe(e=>{const t=!e;return t&&requestAnimationFrame(()=>{$n()}),t})},[$n]);r(()=>{he&&"off"!==Kt&&"0:0"!==Kt&&(xn.current=null,Ge.current=[],requestAnimationFrame(()=>{Ve.current?.()}))},[he,Kt]);const Nn=o(()=>{const e=new Map,t=new Map;let n=1;if(xe)Nt.forEach(t=>{!t.title&&!t.content||t.id&&e.set(t.id,n++)}),Mt.forEach(i=>{if(!i.id)return;if(!i.title&&!i.content)return;const o=Nt.filter(e=>e.refIndexes?.includes(i.selfIndex));if(o.length>0){const n=o.map(t=>e.get(t.id)).filter(Boolean);t.set(i.id,n.join(", "))}else t.set(i.id,String(n++))});else{const i=Math.max(Nt.length,Mt.length);for(let o=0;o<i;o++){const i=Nt[o],r=Mt[o];i?(e.set(i.id,n),r&&t.set(r.id,String(n)),n++):r&&t.set(r.id,String(n++))}}return{leftNums:e,rightNums:t}},[Nt,Mt,xe]),Mn=jt.analysis,Hn=S(Mn?.rule_difference_comparison?.summary?.overall_summary),zn=!!Hn.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),Wn=te?.base_root_id??"-1",qn=Fe?(ue&&ue?.[Wn]?.evaluation_result)??te?.nodes?.[Wn]?.evaluation_result??null:(ue&&ue?.[Wn]?.evaluation_result?.[0])??te?.nodes?.[Wn]?.evaluation_result?.[0]??null,Gn=v(qn);let Vn=x(qn?.evaluation_outputs?.metadata?.label_color??T);if(me){const e=me(Gn);e&&(Vn={...Vn,badgeBg:e.bg,badgeText:e.text,badgeBorder:e.border})}const Kn=i(In);r(()=>{Kn.current=In},[In]);const Jn=i(Ct);r(()=>{Jn.current=Ct},[Ct]);const Yn=s((e,t,n,i,o,r)=>no.current(e,t,n,i,o,r),[]),Xn=s((e,t,n,i,o)=>oo.current(e,t,n,i,o),[]),Un=s(()=>ro.current(),[]),Qn=s((e,t)=>so.current(e,t),[]),Zn=s(e=>lo.current(e),[]),ei=s(e=>co.current(e),[]),ti=s(()=>ao.current(),[]),ni=s(()=>{Bn(),Kn.current?.(),Pe(!1),Ee(new Set),De([]),Ge.current=[],yi([]),Ci(null),St(E),Jn.current?.(),requestAnimationFrame(()=>{Ve.current?.()})},[]),ii=i(ni);r(()=>{ii.current=ni},[ni]),r(()=>{se&&ii.current()},[se]);const oi=o(()=>({documents:te?.documents,input_index_map:te?.input_index_map}),[JSON.stringify(te?.documents),JSON.stringify(te?.input_index_map)]),[ri,si]=n(""),li=i(te);r(()=>{li.current=te;const e=te?.input_index_map?.[0],t=te?.documents?.[e]?.title;si(t)},[te]);const ci=i(Ue);r(()=>{ci.current=Ue},[Ue]);const ai=s((e,t,n,i,o,r,s)=>{const l=S(t?.id)||S(n?.id)||"",c=(l?ci.current?.[l]:null)||t?.cognitiveData||n?.cognitiveData||{section_id:l,decisioning:[],gap:[],relevance_score:0},a=on.current[i]?.current??null,u=(()=>{const e=t?.evaluationResult||n?.evaluationResult||null,o=e=>{const t=(e=>{if(!e||"object"!=typeof e)return null;const t=e?.deviation_entries;if(t&&"object"==typeof t){const e=Object.keys(t).sort((e,t)=>Number(e)-Number(t))[0];if(e&&t[e])return t[e]}const n=Object.keys(e).filter(e=>/^\d+$/.test(e)).sort((e,t)=>Number(e)-Number(t));if(n.length&&e[n[0]])return e[n[0]];const i=e?.deviations;if(i&&"object"==typeof i){const e=Object.keys(i).sort((e,t)=>Number(e)-Number(t))[0];if(e&&i[e])return i[e]}return null})(e);return t?{...e,deviation_summary:e?.deviation_summary||t?.deviation_summary,deviation_title:e?.deviation_title||t?.deviation_title,deviation_impact:e?.deviation_impact||t?.deviation_impact,deviation_explanation:e?.deviation_explanation||t?.deviation_explanation,evaluation_outputs:e?.evaluation_outputs||t?.evaluation_outputs,cognitive_decisioning:e?.cognitive_decisioning||t?.cognitive_decisioning}:e};if(!("string"==typeof i&&i.includes(y)))return o(e);const r=i.split(y)[1];if(!r)return e;const s=t?.evaluationResult||n?.evaluationResult||{},l=s?.deviation_entries?.[r]||s?.deviations?.[r]||null;return l?{...s,...l,deviation_summary:l?.deviation_summary||s?.deviation_summary,deviation_title:l?.deviation_title||s?.deviation_title,deviation_impact:l?.deviation_impact||s?.deviation_impact,deviation_explanation:l?.deviation_explanation||s?.deviation_explanation,evaluation_outputs:l?.evaluation_outputs||s?.evaluation_outputs,cognitive_decisioning:l?.cognitive_decisioning||s?.cognitive_decisioning}:o(e)})(),d=(u?.cognitive_decisioning?.decisioning_factors?.length??0)>0||(u?.cognitive_decisioning?.gaps_in_decision?.length??0)>0,p=le?.isLoading??!1;let f=!0;if(Lt){const e=u?.deviation_highlights;if(e&&"object"==typeof e){f=Object.values(e).some(e=>Array.isArray(e)&&e.length>0)}else f=!1}return{isLoading:p&&!d,open:!0,sectionTitle:t?.title?t?.title:"No Counterpart",refSectionTitle:n?.title?n?.title:"No Counterpart",cognitiveData:c,anchorEl:e,sectionAnchorEl:a,badgeStyle:r||null,sectionIdx:i,docData:oi,deviationData:u,isOrphan:!!o,hasGuidelineMatches:f}},[oi,le?.isLoading,Lt]),ui=s((e,t,n,i,o,r)=>{if(e.stopPropagation(),dt.open&&dt.sectionIdx===o)return void wt();const s=e.currentTarget;let l="left";tt.current?.contains(s)&&(l="right");Bn(),Rn.current&&In(),Ee(new Set),De([]),Ge.current=[],Ct(),mt.open?ji():vt(),requestAnimationFrame(()=>{const e=(()=>{if("string"==typeof o&&o.includes(y)){const e=o.split(y),t=`${e[0]}${y}${e[1]}`;return"right"===l?Zt.current[t]?.current:Qt.current[t]?.current}return"right"===l?Zt.current[o]?.current:Qt.current[o]?.current})()||s;pt(ai(e,t,i,o,n,r))})},[dt.open,dt.sectionIdx,wt,vt,ai]),di=s(()=>{const e=dt.sectionIdx;dt.isOrphan,wt(),vt(),null!==e&&(Ln(e),Bn(),Rn.current&&In(),De([]),Ge.current=[],Lt&&null!==e&&Le(Oi(e)),Ee(t=>t.has(e)?new Set:new Set([e])),setTimeout(()=>{Ve.current&&Ve.current()},50))},[dt.sectionIdx,dt.isOrphan,wt,vt,In]),pi=s(()=>{const e=He.current;if(!e)return;He.current=null;const t=Nt.findIndex(t=>t.id===e),n=Mt.findIndex(t=>t.id===e),i=-1===t?R(Nt,e):null,o=-1===n?R(Mt,e):null,r=-1!==t?t:i?Number(i.split("-")[0]):-1,s=-1!==n?n:o?Number(o.split("-")[0]):-1,l=(e,t,n,i)=>-1!==e?n.current[e]?.current??null:t?i.current[t]?.current??null:null,c=(e,t,n=30)=>{let i=0;const o=()=>{const r=e();r&&0!==r.getBoundingClientRect().height?(wn.current.add(r),C(r,t)):i++<n&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(xe)-1!==r&&st.current&&c(()=>l(t,i,Xt,tn),st.current),-1!==s&&tt.current&&c(()=>l(n,o,Ut,nn),tt.current);else{const e=Ze.current;if(!e)return;c(()=>-1!==r?l(t,i,Xt,tn):l(n,o,Ut,nn),e)}},[Nt,Mt,xe,Xt,Ut,tn,nn,st,tt,Ze]),fi=s(e=>{if(!e)return;Bn(),In(),Ee(new Set),De([]),Ge.current=[],vt(),Ct();const t=Nt.findIndex(t=>t.id===e),n=Mt.findIndex(t=>t.id===e),i=-1===t?R(Nt,e):null,o=-1===n?R(Mt,e):null;if(-1===t&&!i&&-1===n&&!o)return void console.warn(`scrollToAndHighlightClause: nodeId "${e}" not found`);const r=-1!==t?t:i?Number(i.split("-")[0]):-1,s=-1!==n?n:o?Number(o.split("-")[0]):-1;He.current=e,An(e=>{const t={...e};let n=!1;if(-1!==r){const e=xe?`left-${r}`:String(r);t[e]||(t[e]=!0,n=!0)}if(-1!==s){const e=xe?`right-${s}`:String(s);t[e]||(t[e]=!0,n=!0)}return n?t:e}),kn(e=>{const t={...e};let n=!1;const r=e=>{const i=e.split("-");let o=i[0];for(let e=1;e<i.length;e++)o+=`-${i[e]}`,t[o]||(t[o]=!0,n=!0)};return i&&r(i),o&&r(o),n?t:e}),setTimeout(()=>{requestAnimationFrame(()=>{He.current===e&&gi.current()})},50)},[Nt,Mt,xe,An,kn,In,vt,Ct]),gi=i(pi);r(()=>{gi.current=pi},[pi]);const hi=i(null);r(()=>{if(_t){const e=Bt.fields.find(e=>e.analysisKey===_t||e.key===_t);if(e){const t=Jt.current[e.key]||Yt.current[e.key];t?.current&&setTimeout(()=>t.current.scrollIntoView({behavior:"smooth",block:"center"}),150)}}},[_t,Bt.fields]);const mi=s(e=>{const t=Mn?.rule_difference_comparison?.fields;if(!t||!t[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};const n=t[e],i=n?.relation||n?.highlights?.ruleA_spans?.length||n?.highlights?.ruleB_spans?.length||n?.mappings&&n.mappings.length>0;if(n.mappings){const e=n.mappings[0]||{};return{score:n.score,relation:e.relation||"",highlightsA:e.highlights?.ruleA_spans||[],highlightsB:e.highlights?.ruleB_spans||[],hasContent:!!i}}return{score:n.score,relation:n.relation||"",highlightsA:n.highlights?.ruleA_spans||[],highlightsB:n.highlights?.ruleB_spans||[],hasContent:!!i}},[Mn]),{getSectionCompareStyle:Si,getSubSectionCompareStyle:vi,getDeviationStyleByKey:xi}=K({proposedSections:Nt,existingSections:Mt,maintainRelativeOrder:xe,cognitiveMap:Ue,deviationData:Xe,treeData:te,resolvedComparisonConfig:Bt,badgeStyleOverride:me}),{lines:Ri,setLines:yi,overallConnector:bi,setOverallConnector:Ci,svgDimensions:wi,calculateLines:Bi,calculateLinesDebounced:_i,handleColumnScroll:Ii}=Y({containerRef:je,leftContainerRef:st,rightContainerRef:tt,svgContainerRef:$e,pathRefs:qe,leftHeaderRef:Ne,rightHeaderRef:Me,proposedSections:Nt,existingSections:Mt,visibleFields:Ht,leftRefs:Jt,rightRefs:Yt,sectionLeftRefs:Xt,sectionRightRefs:Ut,subSectionLeftRefs:tn,subSectionRightRefs:nn,lhsBadgeRefs:Qt,rhsBadgeRefs:Zt,sectionRowRefs:on,expandedSections:En,expandedSubSections:Dn,connectedSections:Te,isSideBySide:cn,activeSideBySideSection:mn,maintainRelativeOrder:xe,isGuidelineMode:Lt,cognitiveMap:Ue,getSectionCompareStyle:Si,getSubSectionCompareStyle:vi,getDeviationStyleByKey:xi,isArrowVisible:an,isAnimatingRef:ze,isSideBySideRef:Rn,sideBySideCacheRef:xn,sideBySideLineRef:Cn,activeSideBySideSectionRef:bn,activeSideBySideRightSectionRef:yn,connectedLines:Ae,setConnectedLines:De,cachedConnectedPositions:Ge,calculateLinesRef:Ve,resizeTimerRef:Ke,scrollLock:vn,scrollSyncLocked:ke,handleResizeRef:Je,activeProposed:$t,existingRule:jt,analysisData:Mn,pendingScrollTargetRef:lt,pendingScrollCallbackRef:ct,resolvedComparisonConfig:Bt,getFieldData:mi});r(()=>{mt.anchorEl&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{Ve.current?.()})})},[mt.anchorEl,ke]);const Fi=s(()=>{Bn(),Pe(!1),An({}),kn({}),In(),Ee(new Set),De([]),Ge.current=[],vt(),Ct(),wt(),requestAnimationFrame(()=>{Ve.current&&Ve.current()})},[An,kn,In,vt,Ct,wt]);r(()=>{cn||0!==Te.size||Pe(!1)},[cn,Te]);const Ti=o(()=>Object.values(En).some(Boolean)||Object.values(Dn).some(Boolean),[En,Dn]),Ei=i(null),Ai=i(0),Di=i(0),ki=i(0),{handleResize:Pi}=J({timerRef:Ei,ruleComponentRef:et,scrollContainerRef:Ze,containerRef:je,maintainRelativeOrder:xe,proposedSections:Nt,existingSections:Mt,isSideBySideRef:Rn,activeSideBySideSectionRef:bn,activeSideBySideRightSectionRef:yn,sectionRowRefs:on,sectionRightRowRefs:en,sectionLeftRefs:Xt,sectionRightRefs:Ut,subSectionLeftRefs:tn,subSectionRightRefs:nn,lhsBadgeRefs:Qt,rhsBadgeRefs:Zt,leftContainerRef:st,rightContainerRef:tt,calculateLinesRef:Ve,handleResizeRef:Je,setIsResizing:fn,setIsArrowVisible:dn,sideBySideCacheRef:xn,cachedConnectedPositions:Ge});r(()=>{Je.current=Pi},[Pi,Je]),r(()=>{const e=(e,t,n,i,o)=>{t.current=e.getBoundingClientRect().width;const r=new ResizeObserver(e=>{null!==n.current&&cancelAnimationFrame(n.current),n.current=requestAnimationFrame(()=>{n.current=null;const r=e[e.length-1];if(!r)return;const s=r.borderBoxSize?.[0]?.inlineSize??r.contentRect.width;Math.abs(s-t.current)<1?o():(t.current=s,i())})});return r.observe(e),r},t={current:null},n={current:null},i={current:null},o=[],r=[t,n,i];return et.current&&o.push(e(et.current,Ai,t,()=>Je.current(),()=>{})),Ze.current&&o.push(e(Ze.current,Di,n,()=>Je.current(),()=>Ve.current())),je.current&&o.push(e(je.current,ki,i,()=>Je.current(),()=>Ve.current())),()=>{o.forEach(e=>e.disconnect()),r.forEach(e=>{null!==e.current&&(cancelAnimationFrame(e.current),e.current=null)})}},[]),r(()=>{Rn.current=cn},[cn]),r(()=>{bn.current=mn},[mn]);const Oi=s(e=>{let t="",n="0";if("number"==typeof e)t=Nt[e]?.nodeId||Nt[e]?.id||"";else{const i=String(e).split(y);t=i[0],n=i[1]||"0"}const i=Xe?.[t]?.evaluation_result,o=Array.isArray(i)?i[parseInt(n,10)]:i?.[n];return!1===o?.evaluation_outputs?.guideline_flag?.rulebook_used?1:0},[Nt,Xe]),Li=s(e=>{const t=document.querySelectorAll('[id^="guideline-target-"], [data-web-gpt-active="true"]'),n=st.current,i=tt.current,o="string"==typeof e&&e.includes(y);let r=e;if(o){const t=e.split(y);t.length>=2&&(r=`${t[0]}${y}${t[1]}`)}const s=Qt.current[r]?.current||Qt.current[e]?.current;if(t.length>0&&s&&n&&i){const e=t[0];ot.current&&(ot.current.style.height="0px"),nt.current&&(nt.current.style.height="0px"),rt.current&&(rt.current.style.height="0px"),it.current&&(it.current.style.height="0px"),requestAnimationFrame(()=>{const t=s.getBoundingClientRect(),o=e.getBoundingClientRect(),r=n.getBoundingClientRect(),l=i.getBoundingClientRect(),c=n.scrollTop+(t.top-r.top)+t.height/2,a=i.scrollTop+(o.top-l.top)+o.height/2,u=c-r.height/2,d=Math.max(0,u),p=n.scrollHeight-n.clientHeight,f=d>p?d-p:0,g=r.top+c-d;let h=l.top+a-g,m=0;h<0&&(m=Math.abs(h),h=0);const S=i.scrollHeight-i.clientHeight+m,v=h>S?h-S:0;rt.current&&(rt.current.style.height=`${f}px`),nt.current&&(nt.current.style.height=`${m}px`),it.current&&(it.current.style.height=`${v}px`),requestAnimationFrame(()=>{n.scrollTo({top:d,behavior:"smooth"}),i.scrollTo({top:h,behavior:"smooth"}),Ve.current&&setTimeout(()=>Ve.current(),50)})})}},[y]),$i=s(()=>{const e=dt.sectionIdx,t=dt.isOrphan;if(vt(),null==e)return;let n="left";dt.anchorEl&&tt.current?.contains(dt.anchorEl)&&(n="right"),Ln(e),Lt&&(Le(Oi(e)),Ee(new Set([e]))),Fn(e,t,{sourceSide:n,onReady:()=>{Lt&&setTimeout(()=>Li(String(e)),150)}})},[Fn,dt.isOrphan,dt.sectionIdx,dt.anchorEl,vt,Ln,Lt,Li,Oi]),ji=s(()=>{vt(),In(),Ee(new Set),De([]),Ge.current=[]},[vt,In]),Ni=null!==dt.sectionIdx&&Te.has(dt.sectionIdx),{showDeviationNavigation:Mi,showOpenNodeRef:Hi,adjustScrollForPopup:zi}=M({proposedSections:Nt,existingSections:Mt,parentDeviationRecord:zt,expandedSections:En,maintainRelativeOrder:!!xe,scrollContainerRef:Ze,leftContainerRef:st,rightContainerRef:tt,lhsBadgeRefs:Qt,rhsBadgeRefs:Zt}),Wi=s((e,t,n,i,o)=>{const r="string"==typeof i?S(i).trim():S(i?.deviation_summary).trim(),s=e.currentTarget;Ct();let l="left";tt.current?.contains(s)&&(l="right");const c=()=>{if("string"==typeof t&&t.includes(y)){const e=t.split(y),n=`${e[0]}${y}${e[1]}`;return"right"===l?Zt.current[n]?.current:Qt.current[n]?.current}return"right"===l?Zt.current[t]?.current:Qt.current[t]?.current};if(n&&!Lt)return In(),Ee(new Set),De([]),Ge.current=[],void(r&&(Ln(t),requestAnimationFrame(()=>{const e=c()||s;if(e){e.getBoundingClientRect().top>.8*window.innerHeight&&e.scrollIntoView({behavior:"smooth",block:"center"})}St({open:!0,anchorEl:e,summary:i,displayImpact:o})})));Ln(t),Lt&&(Le(Oi(t)),Ee(new Set([t]))),r?setTimeout(()=>{Fn(t,n,{toggleIfSame:!1,sourceSide:l,onReady:()=>{const e=c()||s;if(Lt)setTimeout(()=>Li(t),150);else if(e){const t=e.getBoundingClientRect();if(t.top>.8*window.innerHeight||t.top<100){const e=t.top-window.innerHeight/2;xe?(st.current?.scrollBy({top:e,behavior:"smooth"}),tt.current?.scrollBy({top:e,behavior:"smooth"})):Ze.current?.scrollBy({top:e,behavior:"smooth"})}}St({open:!0,anchorEl:e,summary:i,displayImpact:o})}})},350):setTimeout(()=>{Fn(t,n,{toggleIfSame:!1,sourceSide:l}),Lt&&setTimeout(()=>Li(t),150)},350)},[Fn,Ct,St,In,Ln,Lt,xe,Li,Xe]),qi=o(()=>{if(!de)return null;const e=de?.id?.split(":")[0];for(const t in zt){if((zt[t]||[]).some(t=>t.id===e))return t}return null},[de,zt]),Gi=i({id:null,triggerMs:null}),Vi=i(null);r(()=>{if(!de?.id)return;const e=Number(de.trigger),t=Gi.current;if(t?.id===de.id&&t?.triggerMs===e)return;if(!(de.id.includes(":")&&/:\d+$/.test(de.id))){Gi.current={id:de.id,triggerMs:e},fi(de.id);const t=Nt.findIndex(e=>e.id===de.id),n=Mt.findIndex(e=>e.id===de.id);return void(-1===t&&-1===n||setTimeout(()=>{const e=-1!==t?t:n,i=-1===t;Lt&&Le(Oi(e)),Ee(new Set([e])),Tn.current(e,i,{sourceSide:i?"right":"left",onReady:()=>{Lt&&setTimeout(()=>Li(String(e)),150)}})},400))}const[n,i]=de.id.split(":"),o=i??"0",r=`${de.id}:${e}`;Vi.current!==r&&(vt(),Ct(),In(),Ee(new Set),De([]),Ge.current=[],Vi.current=r);let s=!1,l=0;let c=null,a=null,u=!1;const d=(e,t)=>{const n=(e,i)=>{if(!e)return null;if(t.includes(e.id)||t.includes(e.nodeId)||t.includes(e.contentId))return i;if(!Array.isArray(e.subsections))return null;for(let t=0;t<e.subsections.length;t++){const o=n(e.subsections[t],`${i}-${t}`);if(o)return o}return null};for(let t=0;t<e.length;t++){const i=n(e[t],String(t));if(i)return i}return null},p=()=>{if(s)return;const t=()=>{Gi.current={id:de.id,triggerMs:e}};let i=null,r=null;for(const e in zt){const t=zt[e].find(e=>e.id===n||e.nodeId===n||e.contentId===n||e.evaluationResult?.nodeId===n);if(t){i=e,r=t;break}}if(!r||!i)return l++,void(l<30&&(c=setTimeout(p,100)));const f=Array.from(new Set([n,r.id,r.nodeId,r.contentId,r.evaluationResult?.nodeId].filter(Boolean))),g=Nt.findIndex(e=>e.id===i),h=Mt.findIndex(e=>e.id===i),m=-1===g&&-1!==h,S=d(Nt,f);let v=d(Mt,f);if(S&&!v&&!m){const e=S.split("-");let t=Number(e[0]);if(xe){const e=Nt[t]?.refIndexes?.[0],n=Mt.findIndex(t=>t.selfIndex===e);-1!==n&&(t=n)}v=[t,...e.slice(1)].join("-")}if(!S&&!v)return l++,void(l<30&&(c=setTimeout(p,100)));const x=S?Number(S.split("-")[0]):g,R=v?Number(v.split("-")[0]):h,b=R>=0?R:v?Number(v.split("-")[0]):-1,C=Nt[x],_=Mt[b],I=C&&!C.title&&!C.content,F=_&&!_.title&&!_.content,T=m||(!S&&!!v||I&&!F);if(T){if(!(xe?!!io.current[`right-${R}`]:!!io.current[String(R)])&&R>=0)return On(R,"right"),void(c=setTimeout(p,200))}else{if(!(xe?!!io.current[`left-${x}`]:!!io.current[String(x)])&&x>=0)return On(x,"left"),void(c=setTimeout(p,200))}const E=S||"",A=v||"",D=f.map(e=>`${e}${y}${o}`),k=D[0],P=()=>{for(const e of D){const t=Qt.current[e]?.current||null,n=Zt.current[e]?.current||null;if(t||n)return{refId:e,left:t,right:n}}return{refId:k,left:null,right:null}},O=e=>`${e}${y}${E}${y}${A}`;if(!u){Ln(O(k)),u=!0,l=0;const e=()=>{const{left:e,right:t}=P();return T||!e&&!!t?t:e};return a?.(),void(c=setTimeout(()=>{s||(a=((e,t)=>{let n,i=0,o=null,r=null;const l=performance.now(),c=()=>{if(s)return;if(performance.now()-l>3e3)return void t();const a=e();if(!a||0===a.getBoundingClientRect().height)return void(n=requestAnimationFrame(c));const u=a.getBoundingClientRect(),d=u.top,p=u.height,f=null!==o&&Math.abs(d-o)<.5,g=null!==r&&Math.abs(p-r)<.5;if(f&&g){if(i++,i>=5)return void t()}else i=0;o=d,r=p,n=requestAnimationFrame(c)};return n=requestAnimationFrame(c),()=>cancelAnimationFrame(n)})(e,()=>{s||(a=null,p())}))},300))}const{refId:L,left:$,right:j}=P(),N=O(L);if(!$&&!j)return l++,void(l<30&&(c=setTimeout(p,100)));const M=T||!$&&!!j,H=M?j:$,z=xe?M?tt.current:st.current:Ze.current;if(!H||!z)return l++,void(l<30&&(c=setTimeout(p,100)));const W=H.getBoundingClientRect();if(0===W.height)return l++,void(l<30&&(c=setTimeout(p,100)));const q=z.getBoundingClientRect(),G=W.top-q.top+z.scrollTop-q.height/2+W.height/2,V=S?.includes("-")||v?.includes("-"),K=async()=>{if(s)return;t();const e=H instanceof Element?window.getComputedStyle(H).color:"";[$,j].forEach(t=>{t&&(t.style.transition="box-shadow 300ms ease-in-out",t.style.boxShadow=`0 0 10px ${e}`)}),setTimeout(()=>{[$,j].forEach(e=>{e&&(e.style.boxShadow="")})},2e3);const n=r.evaluationResult?.deviations?.[o]||r,i=r.evaluationResult?.evaluation_outputs||r.evaluation_outputs;if(!(!!$&&!!j)&&!Lt){const e=M?Zt.current[V?L:R]?.current||j:Qt.current[V?L:x]?.current||$;return zi(e,()=>{St({open:!0,anchorEl:e,displayImpact:de.displayImpact,summary:{...n,evaluation_outputs:i}})},{skipScroll:!0}),void pe?.()}const l=(e,t)=>Promise.race([e,new Promise(e=>setTimeout(e,t))]);xe&&await Promise.all([st.current?l(B(st.current),600):Promise.resolve(),tt.current?l(B(tt.current),600):Promise.resolve()]),Lt&&(Le(Oi(N)),Ee(new Set([N]))),Tn.current(N,!1,{toggleIfSame:!1,sourceSide:m?"right":"left",onReady:()=>{t();const e=M?Zt.current[L]?.current||j:Qt.current[L]?.current||$;if(Lt)setTimeout(()=>Li(N),150);else{const e=Qt.current[L]?.current||$,t=Zt.current[L]?.current||j;e&&(e.style.scrollMarginTop="150px",e.scrollIntoView({behavior:"smooth",block:"start"})),t&&(t.style.scrollMarginTop="150px",t.scrollIntoView({behavior:"smooth",block:"start"}))}St({open:!0,anchorEl:e,displayImpact:de.displayImpact,summary:{...n}}),pe?.()}})};Math.abs(z.scrollTop-G)<=2?K():w(z,G,K)};return c=setTimeout(p,100),()=>{s=!0,c&&clearTimeout(c),a?.()}},[de?.id,de?.trigger,de?.displayImpact,zt,Nt,Mt,xe,St,fi,Lt,Oi,Li]),r(()=>{if(!mt.open)return;const e=mt.anchorEl;if(!e)return;if(e.isConnected)return;const t=t=>{for(const[n,i]of Object.entries(t))if(i.current?.textContent===e.textContent)return n;return null},n=e.dataset?.deviationRefId||t(Qt.current)||t(Zt.current);if(!n)return;const i=Zt.current[n]?.current||Qt.current[n]?.current;i&&i.isConnected&&St(e=>({...e,anchorEl:i}))},[mt.open,mt.anchorEl,ke,Te,En]);const{open:Ki,sectionIdx:Ji,isOrphan:Yi,badgeStyle:Xi,anchorEl:Ui,sectionAnchorEl:Qi}=at;r(()=>{if(!le.isStreamingEnabled)return;if(!Ki||null==Ji)return;if(Ji===Wn)return;const e="string"==typeof Ji?Ji.split(y)[0]:null,t=(e,n)=>{if(!e||!Array.isArray(e))return null;for(const i of e){if(i.id===n)return i;if(i.subsections?.length){const e=t(i.subsections,n);if(e)return e}}return null},n=e&&"string"==typeof e?t(Nt,e):null,i=e&&"string"==typeof e?t(Mt,e):null,o="number"==typeof Ji?Nt[Ji]||null:n||e&&(te?.nodes?.[e]||te?.[e])||null,r="number"==typeof Ji?Mt[Ji]||null:i,s=ai(Ui,o,r,Ji,Yi,Xi);ut(e=>{if(!e.open)return e;return S(e.cognitiveData)===S(s.cognitiveData)&&S(e.deviationData)===S(s.deviationData)&&e.sectionTitle===s.sectionTitle&&e.refSectionTitle===s.refSectionTitle?e:{...e,...s,open:!0,anchorEl:e.anchorEl,sectionAnchorEl:e.sectionAnchorEl}})},[Ki,Ji,Yi,Xi,Ui,Qi,Nt,Mt,ai]);const Zi=s(({section:t,keyPath:n,depth:i=0,columnKey:o="left",parentNodeId:r="",sectionOffset:s,rhsOrphanVisualIndexes:l})=>e(z,{section:t,keyPath:n,depth:i,columnKey:o,parentNodeId:r,sectionOffset:s,rhsOrphanVisualIndexes:l}),[]),eo=o(()=>Nt.map((t,n)=>{const i=!t?.title&&!t?.content,o=!t?.refIndexes||0===t.refIndexes.length;return i&&o&&xe?null:e(W,{section:t,idx:n},t?.layoutKey??t?.id??`left-row-${n}`)}),[Nt,xe]),to=o(()=>Mt.map((t,n)=>{const i=!t?.title&&!t?.content,o=!t?.refIndexes||0===t.refIndexes.length;return i&&o&&xe?null:e(q,{section:t,idx:n},t?.layoutKey??t?.id??`right-row-${n}`)}),[Mt,xe]),no=i(ui);r(()=>{no.current=ui},[ui]);const io=i(En);r(()=>{io.current=En},[En]);const oo=i(Wi);r(()=>{oo.current=Wi},[Wi]);const ro=i(ji);r(()=>{ro.current=ji},[ji]);const so=i(On);r(()=>{so.current=On},[On]);const lo=i(Pn);r(()=>{lo.current=Pn},[Pn]);const co=i(Zi);r(()=>{co.current=Zi},[Zi]);const ao=i(In);r(()=>{ao.current=In},[In]);const uo=o(()=>({isGuidelineMode:Lt,maintainRelativeOrder:!!xe,showDeviationBadges:Ce,isProposingFix:fe,proposingFixNodeId:ge,isRedlineFlow:he,isSideBySide:cn,activeSideBySideSection:mn,scrollSyncLocked:ke,toggleScrollSyncLocked:jn,summaryPopupAnchorEl:mt.anchorEl,connectedSections:Te,proposedSections:Nt,existingSections:Mt,deviationNumberRegistry:Wt,deviationParentRegistry:qt,treeData:te,displayConfig:le,resolvedMarkdownStyles:Qe,unifiedNumbering:Nn,expandedSections:En,expandedSubSections:Dn,setExpandedSubSections:kn,getSectionCompareStyle:Si,getSubSectionCompareStyle:vi,getBadgeRef:ln,getSectionRowRef:rn,getSubSectionRef:sn,sectionLeftRefs:Xt,sectionRightRefs:Ut,sectionRowRefs:on,sectionRightRowRefs:en,subSectionLeftRefs:tn,subSectionRightRefs:nn,lhsBadgeRefs:Qt,rhsBadgeRefs:Zt,openMoreFunctionsPopup:Yn,handleOpenSummaryPopup:Xn,openSummaryPopup:Xn,handleCloseSummaryPopup:Un,toggleSection:Qn,handleSubSectionToggle:Zn,renderSubSectionAccordion:ei,resetSideBySide:ti,setConnectedSections:Ee,setConnectedLines:De,cachedConnectedPositions:Ge,showDeviationNavigation:Mi,showOpenNodeRef:Hi,deviationNodeIdToView:de?.id,deviationTargetParentId:qi,guidelinesData:Se,gptWebCitationConfig:ve}),[Lt,xe,Ce,fe,ge,he,cn,mn,ke,jn,mt.anchorEl,Te,Nt,Mt,Wt,le,Qe,Nn,En,Dn,kn,Si,vi,ln,rn,sn,Mi,Hi,de,qi,Se,ve]),po=S(at.sectionTitle||Dt||Et),fo=S(Lt?Pt||Ot||at.refSectionTitle:at.refSectionTitle||Pt||Ot);return e(V,{value:uo,children:t(l,{ref:et,sx:{display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif',overflow:"visible",position:"relative"},children:[we&&e(l,{sx:{position:"absolute",inset:0,bgcolor:"rgba(255, 255, 255, 0.6)",backdropFilter:"blur(10px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"8px"},children:e(P,{})}),mt.open&&e(G,{open:mt.open,anchorEl:mt.anchorEl,containerEl:hi.current,clipTopEl:Ne.current,scrollContainerEl:Ze.current,onClose:ji,summary:mt.summary,displayImpact:mt.displayImpact,isScrollLocked:ke}),e(k,{open:dt.open,anchorEl:dt.anchorEl,maintainRelativeOrder:!!xe,sectionTitle:dt.sectionTitle,referenceSectionTitle:dt.refSectionTitle,onClose:wt,onOpenCognitiveCompare:yt,onOpenSideBySide:$i,onConnect:di,isConnected:Ni,isOrphan:!Lt&&!!dt.isOrphan,isGuidelineMode:Lt,hasGuidelineMatches:dt.hasGuidelineMatches}),at.open&&e(D,{open:at.open,popupRef:Rt,position:ft,popupConfig:ae,onClose:()=>{gt(null),ut(e=>({...e,open:!1})),xt(null)},markdownStyles:re,sectionTitle:po,referenceSectionTitle:fo,cognitiveData:at.cognitiveData,anchorEl:at.anchorEl,sectionAnchorEl:at.sectionAnchorEl,scrollContainerEl:Ze.current,badgeStyle:at.badgeStyle,docData:at.docData,deviationData:at.deviationData,isLoading:at.isLoading}),e(c,{open:!!_e,autoHideDuration:8e3,onClose:()=>Ie(null),anchorOrigin:{vertical:"top",horizontal:"center"},children:e(a,{onClose:()=>Ie(null),severity:"error",sx:{width:"100%",whiteSpace:"pre-line"},children:_e})}),e(H,{componentHeaderText:ee,displayConfig:le,maintainRelativeOrder:xe,onCollapseAll:Fi,showCollapseAll:Ti,onToggleView:e=>{Be(!0),setTimeout(()=>{Re(!e),ce?.(!e),Pe(!1),In(),vt(),Ee(new Set),De([]),Ge.current=[],requestAnimationFrame(()=>{requestAnimationFrame(()=>{setTimeout(()=>{Be(!1)},600)})})},50)}}),e(l,{ref:Ze,onScroll:Ii,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:xe?"visible":"auto",borderTop:Hn&&zn?"none":"1.5px solid #EEF0F4"},children:e(l,{sx:{display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px",...xe?{flex:1}:{}},children:t(l,{ref:je,sx:{display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"100px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0,...xe?{flex:1,overflow:"visible"}:{}},children:[e(U,{svgContainerRef:$e,svgDimensions:wi,isResizing:pn,overallConnector:bi,rootDeviationStyle:Vn,lines:Ri,isSideBySide:cn,activeSideBySideSection:mn,isArrowVisible:an,maintainRelativeOrder:xe,proposedSections:Nt,existingSections:Mt,cognitivePopup:at,activeBadgeId:ht,closeCognitivePopup:Ct,setActiveBadgeId:xt,openCognitivePopupFromState:bt,buildSectionPopupState:ai,connectedLines:Ae,isGuidelineMode:Lt,pathRefs:qe}),t(l,{sx:{border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)",...xe?{flex:1,overflow:"visible"}:{}},children:[e(l,{ref:Ne,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center",minHeight:"40px",overflow:"hidden",minWidth:0},children:e(u,{title:Et,placement:"top",children:e(d,{sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"},children:Et})})}),t(l,{ref:st,onScroll:Ii,sx:{p:"12px",display:"flex",flexDirection:"column",...xe?{maxHeight:"calc(100vh - 250px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-180px",pr:"192px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{}},children:[e("div",{ref:ot,style:{width:"100%",height:"0px",flexShrink:0}}),Vt&&eo,e("div",{ref:rt,style:{width:"100%",height:"0px",flexShrink:0}})]})]}),e(l,{ref:hi,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"},children:e(l,{sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0},children:t(l,{onClick:e=>{e.stopPropagation(),at.open&&ht===Wn?Ct():(xt(Wn),bt(ai(e.currentTarget,{title:ri,content:"",evaluationResult:qn,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,Wn,!0,{...Vn,label:""})))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:Vn.badgeBg,color:Vn.badgeText,border:`1px solid ${Vn.badgeBorder}`,fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"},children:[Gn??e(O,{}),e(l,{component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}},children:e(h,{})}),e(g,{size:11,style:{transform:at.open&&ht===Wn?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]})})}),t(l,{sx:{border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0,...xe?{flex:1,overflow:"visible",minHeight:0}:{}},children:[gn&&e(m,{sections:11}),e(l,{ref:Me,sx:{p:"8px",bgcolor:Lt?"#F1F3F5":"#F7F8FA",borderBottom:"1px solid #D7DCE2",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center",...xe?{maxHeight:"calc(100vh - 250px)",overflowY:"auto",overflowX:"hidden",minHeight:0,...Lt?{"&::-webkit-scrollbar":{width:"6px",display:"block"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{background:"#CBD5E1",borderRadius:"10px"},"&::-webkit-scrollbar-thumb:hover":{background:"#94A3B8"},scrollbarWidth:"thin",scrollbarColor:"#CBD5E1 transparent"}:{"&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}}:{}},children:Lt?t(p,{value:Oe,onChange:(e,t)=>Le(t),variant:"fullWidth",TabIndicatorProps:{sx:{display:"none"}},sx:{width:"100%",minHeight:"36px","& .MuiTab-root":{minHeight:"36px",px:1,py:0,borderRadius:"8px",fontSize:"14px",lineHeight:1,fontWeight:500,textTransform:"none",color:"#374151",minWidth:0,transition:"background-color 160ms ease, box-shadow 160ms ease"},"& .Mui-selected":{color:"#374151",bgcolor:"#FFFFFF"}},children:[e(f,{label:e(u,{title:Ot,placement:"top",children:e(l,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block",width:"100%"},children:"Redline Guidelines"})})}),e(f,{label:e(u,{title:"Web & GPT Sources",placement:"top",children:e(l,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block",width:"100%"},children:"Web & GPT Sources"})})})]}):e(u,{title:Ot,placement:"top",children:e(d,{sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"},children:Ot})})}),t(l,{ref:tt,onScroll:Ii,sx:{p:Lt?"0px":"12px",display:"flex",flexDirection:"column",...xe?{maxHeight:"calc(100vh - 250px)",...!Lt&&{flex:1},overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-150px",pl:"165px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{}},children:[e("div",{ref:nt,style:{width:"100%",height:"0px",flexShrink:0}}),Lt?0===Oe?e(Q,{guidelinesData:Se,deviationData:ue,connectedSections:Te,proposedSections:Nt}):e(Z,{deviationData:ue,connectedSections:Te,proposedSections:Nt}):Vt&&to,e("div",{ref:it,style:{width:"100%",height:"0px",flexShrink:0}})]})]})]})})})]})})};export{ee as default};
1
+ import{jsx as e,jsxs as t}from"react/jsx-runtime";import{useState as n,useRef as i,useMemo as o,useEffect as r,useCallback as s}from"react";import{Box as l,Snackbar as c,Alert as a,Tooltip as u,Typography as d,Tabs as p,Tab as f}from"@mui/material";import{ChevronDown as g}from"lucide-react";import{ButtonCognitiveIcon as h}from"../../assests/svg/ButtonCognitiveIcon.js";import m from"./OverlayComponent.js";import{safeStringify as S,extractDeviationScore as v,generateColorPalette as x,DEVIATION_BADGE_SEPARATOR as y,findKeyPathByNodeId as R,hasMeaningfulRedlineTags as b,scrollAndHighlightClause as C,scrollAndWait as w,waitForScrollIdle as I}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as _,DEFAULT_FIELD_CONFIG as B,DEFAULT_COMPARISON_CONFIG as T}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import{DEFAULT_DEVIAION_COLOR as F,EMPTY_SUMMARY_POPUP_STATE as E,DEFAULT_COMPONENT_HEADER_TEXT as A}from"./CognitiveCompareConstants.js";import D from"./CognitivePopup.js";import O from"./MoreFunctionsPopup.js";import k from"./LoaderComponent.js";import P from"./components/ThreeDotsLoader.js";import{useCognitiveTreeData as j}from"./hooks/useCompareData.js";import{useComparePopups as L}from"./hooks/useComparePopups.js";import{useSectionRefs as $}from"./hooks/useSectionRefs.js";import{useAccordionState as N}from"./hooks/useAccordionState.js";import{useDeviationNavigation as M}from"./hooks/useDeviationNavigation.js";import{useOnDemandCitationCache as H}from"./hooks/useOnDemandCitationCache.js";import z from"./components/CompareHeader.js";import G from"./components/SubSectionAccordion.js";import W from"./components/LHSSectionRow.js";import q from"./components/RHSSectionRow.js";import V from"./components/CognitiveSummaryPopup.js";import{CompareContextProvider as K}from"./CompareContext.js";import{useStyleHelpers as J}from"./hooks/useStyles.js";import{useResizeHandler as Y}from"./hooks/useResizeHandler.js";import{useLinesCalculator as X}from"./hooks/useLinesCalculator.js";import{useSideBySide as U}from"./hooks/useSideBySide.js";import Q from"./components/SvgConnectors.js";import Z from"./Guidelines/components/GuidelinePanel.js";import ee from"./Guidelines/components/WebGptPanel.js";import{GuidelineSkeleton as te}from"./components/GuidelineSkeletonLoader.js";import{getVisibleGuidelineTargets as ne}from"./Guidelines/utils/guidelineTargets.js";import{hasGptCitationObjects as ie}from"./Guidelines/utils/hasGptCitationObjects.js";const oe=({componentHeaderText:oe=A,treeData:re,comparisonConfig:se,leftColumnTitleText:le,rightColumnTitleText:ce,markdownStyles:ae,resetTrigger:ue,displayConfig:de={isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1,displayEmailNotifier:!0,isStreamingEnabled:!1},deviationAnalysisStatus:pe,onMaintainRelativeOrderChange:fe,popupConfig:ge,deviationData:he={},deviationNodeIdToView:me,resetDeviationNodeId:Se,isProposingFix:ve=!1,proposingFixNodeId:xe,isRedlineFlow:ye,badgeStyleOverride:Re,guidelinesData:be,isGuidelineMode:Ce,gptWebCitationConfig:we,onDemandCitationConfig:Ie})=>{const[_e,Be]=n(de.maintainRelativeOrder),Te=de?.expandLevels??0,Fe=!!de?.expandAllSections,Ee=!!_e||!!de?.showDeviationBadges,[Ae,De]=n(!1),[Oe,ke]=n(null),[Pe]=n(re?.newEvaluationResult??de?.enableDeviationSchemaBackwardCompatibility??!0),[je,Le]=n(new Set),[$e,Ne]=n([]),[Me,He]=n(!1),[ze,Ge]=n(0),We=pe??(de?.isLoading?"deviations_streaming":"complete"),qe="mapping_ready"===We||"deviations_streaming"===We,Ve=i(null),Ke=i(null),Je=i(null),Ye=i(null),Xe=i(null),Ue=i(!1),Qe=i(null),Ze=i({}),et=i([]),tt=i(()=>{}),nt=i(null),it=i(()=>{}),ot=o(()=>JSON.stringify(he||{}),[JSON.stringify(he)]),rt=o(()=>he||{},[ot]),st=o(()=>ie(rt),[rt]),lt=o(()=>re?.cognitive_decisioning||{},[re]),ct=o(()=>({..._,...ae}),[ae]),at=i(null),ut=i(null),dt=i(null),pt=i(null),ft=i(null),gt=i(null),ht=i(null),mt=i(null),St=i(null),vt=i(null),{cognitivePopup:xt,setCognitivePopup:yt,moreFunctions:Rt,setMoreFunctions:bt,position:Ct,setPosition:wt,activeBadgeId:It,summaryPopup:_t,setSummaryPopup:Bt,closeSummaryPopup:Tt,setActiveBadgeId:Ft,popupRef:Et,handleOpenCognitiveCompare:At,openCognitivePopupFromState:Dt,closeCognitivePopup:Ot,closeMoreFunctionsPopup:kt}=L(at),Pt=o(()=>({fields:se?.fields??B,thresholds:{high:se?.thresholds?.high??T.thresholds.high,medium:se?.thresholds?.medium??T.thresholds.medium,exact:se?.thresholds?.exact??T.thresholds.exact}}),[se]),[jt,Lt]=n(null),$t=re?.documents?.[re?.input_index_map?.[0]]?.title,Nt=re?.documents?.[re?.input_index_map?.[1]]?.title,Mt=S(le||$t||"Uploaded Contract"),Ht=re?.documents?.[re?.input_index_map?.[0]]?.metadata?.file_name,zt=S(Ht),Gt=re?.documents?.[re?.input_index_map?.[1]]?.metadata?.file_name,Wt=S(Gt),qt=S(ce||Nt||"Reference Template"),{isGuidelineMode:Vt,activeProposed:Kt,existingRule:Jt,proposedSections:Yt,existingSections:Xt,visibleFields:Ut,parentDeviationRecord:Qt,deviationNumberRegistry:Zt,deviationParentRegistry:en,parseError:tn}=j(re,_e,rt,Pt,Pe,be,Ce);r(()=>{tn&&ke(`Failed to load comparison: ${tn}`)},[tn]);const nn=Yt.length>0||Xt.length>0,on=o(()=>{if(!ye)return"off";let e=0,t=0;const n=i=>{Array.isArray(i)&&i.forEach(i=>{const o=i?.content||"";b(o)&&(e+=1,t+=String(o).length),i?.subsections?.length&&n(i.subsections)})};return n(Yt),n(Xt),`${e}:${t}`},[ye,Yt,Xt]);r(()=>{if(Yt.length||Xt.length)if(Fe){const e={},t={},n=(n,i)=>{n.forEach((n,o)=>{const r=_e?`${i}-${o}`:String(o);e[r]=!0;const s=(e,n)=>{e?.forEach((e,i)=>{const o=`${n}-${i}`;t[o]=!0,e.subsections?.length&&s(e.subsections,o)})};n.subsections?.length&&s(n.subsections,String(o))})};n(Yt,"left"),n(Xt,"right"),Hn(e),Gn(t)}else if(Te>0){const e={},t={},n=(n,i,o)=>{n.forEach((n,r)=>{if(o>=1){const t=_e?`${i}-${r}`:String(r);e[t]=!0}const s=(e,n,i)=>{i>o||e?.forEach((e,o)=>{const r=`${n}-${o}`;t[r]=!0,e.subsections?.length&&s(e.subsections,r,i+1)})};n.subsections?.length&&o>=2&&s(n.subsections,String(r),2)})};n(Yt,"left",Te),n(Xt,"right",Te),Hn(e),Gn(t)}},[Fe,Te,Yt,Xt,_e]);const{leftRefs:rn,rightRefs:sn,sectionLeftRefs:ln,sectionRightRefs:cn,lhsBadgeRefs:an,rhsBadgeRefs:un,sectionRightRowRefs:dn,subSectionLeftRefs:pn,subSectionRightRefs:fn,sectionRowRefs:gn,getSectionRowRef:hn,getSubSectionRef:mn,getBadgeRef:Sn}=$(Ut.map(({key:e})=>e),Math.max(Yt.length,Xt.length)),{isSideBySide:vn,isArrowVisible:xn,setIsSideBySide:yn,setIsArrowVisible:Rn,isResizing:bn,setIsResizing:Cn,isSideBySideLoading:wn,setIsSideBySideLoading:In,activeSideBySideSection:_n,setActiveSideBySideSection:Bn,scrollLock:Tn,sideBySideCacheRef:Fn,isSideBySideRef:En,activeSideBySideRightSectionRef:An,activeSideBySideSectionRef:Dn,sideBySideLineRef:On,highlightedClauseRefs:kn,clearClauseHighlight:Pn,applyAlignmentPadding:jn,resetSideBySide:Ln,activateSideBySide:$n}=U({isGuidelineMode:Vt,maintainRelativeOrder:_e,proposedSections:Yt,existingSections:Xt,leftContainerRef:mt,rightContainerRef:dt,scrollContainerRef:at,sectionLeftRefs:ln,sectionRightRefs:cn,subSectionLeftRefs:pn,subSectionRightRefs:fn,lhsBadgeRefs:an,rhsBadgeRefs:un,sectionRowRefs:gn,sectionRightRowRefs:dn,rhsTopSpacerRef:pt,rhsBottomSpacerRef:ft,lhsTopSpacerRef:gt,lhsBottomSpacerRef:ht,calculateLinesRef:tt,setConnectedSections:Le,setConnectedLines:Ne,cachedConnectedPositions:et,closeMoreFunctionsPopup:kt,setErrorToast:ke,moreFunctions:Rt,closeSummaryPopup:Tt}),Nn=i($n);r(()=>{Nn.current=$n},[$n]);const{expandedSections:Mn,setExpandedSections:Hn,expandedSubSections:zn,setExpandedSubSections:Gn,handleSubSectionToggle:Wn,toggleSection:qn,forceExpandCrossWiredSections:Vn}=N({maintainRelativeOrder:!!_e,proposedSections:Yt,existingSections:Xt,activeSideBySideSection:_n,connectedSections:je,resetSideBySide:Ln,setConnectedSections:Le,setConnectedLines:Ne,cachedConnectedPositions:et,svgContainerRef:Ve,isAnimatingRef:Ue,animationTimerRef:Qe,calculateLinesRef:tt,sectionLeftRefs:ln,sectionRightRefs:cn,subSectionLeftRefs:pn,subSectionRightRefs:fn}),Kn=()=>{if(null==_n)return;const e=ln.current[_n]?.current,t=cn.current[_n]?.current,n=dt.current;if(!e||!t||!n)return;const i=e.getBoundingClientRect(),o=t.getBoundingClientRect(),r=n.getBoundingClientRect(),s=i.top-r.top,l=o.top-r.top-s;n.scrollBy({top:l,behavior:"smooth"})},Jn=s(e=>{e?.stopPropagation(),He(e=>{const t=!e;return t&&requestAnimationFrame(()=>{Kn()}),t})},[Kn]);r(()=>{ye&&"off"!==on&&"0:0"!==on&&(Fn.current=null,et.current=[],requestAnimationFrame(()=>{tt.current?.()}))},[ye,on]);const Yn=o(()=>{const e=new Map,t=new Map;let n=1;if(_e)Yt.forEach(t=>{!t.title&&!t.content||t.id&&e.set(t.id,n++)}),Xt.forEach(i=>{if(!i.id)return;if(!i.title&&!i.content)return;const o=Yt.filter(e=>e.refIndexes?.includes(i.selfIndex));if(o.length>0){const n=o.map(t=>e.get(t.id)).filter(Boolean);t.set(i.id,n.join(", "))}else t.set(i.id,String(n++))});else{const i=Math.max(Yt.length,Xt.length);for(let o=0;o<i;o++){const i=Yt[o],r=Xt[o];i?(e.set(i.id,n),r&&t.set(r.id,String(n)),n++):r&&t.set(r.id,String(n++))}}return{leftNums:e,rightNums:t}},[Yt,Xt,_e]),Xn=Jt.analysis,Un=S(Xn?.rule_difference_comparison?.summary?.overall_summary),Qn=!!Un.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),Zn=re?.base_root_id??"-1",ei=Pe?(he&&he?.[Zn]?.evaluation_result)??re?.nodes?.[Zn]?.evaluation_result??null:(he&&he?.[Zn]?.evaluation_result?.[0])??re?.nodes?.[Zn]?.evaluation_result?.[0]??null,ti=v(ei),ni=qe&&null==ei,ii=ni?null:ti??("complete"===We&&null==ei?"Same":null);let oi=x(ei?.evaluation_outputs?.metadata?.label_color??F);if(Re){const e=Re(ti);e&&(oi={...oi,badgeBg:e.bg,badgeText:e.text,badgeBorder:e.border})}const ri=i(Ln);r(()=>{ri.current=Ln},[Ln]);const si=i(Ot);r(()=>{si.current=Ot},[Ot]);const li=s((e,t,n,i,o,r)=>vo.current(e,t,n,i,o,r),[]),ci=s((e,t,n,i,o)=>yo.current(e,t,n,i,o),[]),ai=s(()=>Ro.current(),[]),ui=s((e,t)=>bo.current(e,t),[]),di=s(e=>Co.current(e),[]),pi=s(e=>wo.current(e),[]),fi=s(()=>Io.current(),[]),gi=s(()=>{Pn(),ri.current?.(),He(!1),Le(new Set),Ne([]),et.current=[],ki([]),ji(null),Bt(E),si.current?.(),requestAnimationFrame(()=>{tt.current?.()})},[]),hi=i(gi);r(()=>{hi.current=gi},[gi]),r(()=>{ue&&hi.current()},[ue]);const mi=o(()=>({documents:re?.documents,input_index_map:re?.input_index_map}),[JSON.stringify(re?.documents),JSON.stringify(re?.input_index_map)]),[Si,vi]=n(""),xi=S(Nt),yi=i(re);r(()=>{yi.current=re;const e=re?.input_index_map?.[0],t=re?.documents?.[e]?.title;vi(t)},[re]);const Ri=i(lt);r(()=>{Ri.current=lt},[lt]);const bi=s((e,t,n,i,o,r,s)=>{const l=S(t?.id)||S(n?.id)||"",c="string"==typeof i?i.split(y):[],a=c[0]||S(t?.nodeId)||S(n?.nodeId)||S(t?.id).split(y)[0]||S(n?.id).split(y)[0]||void 0,u=c.length>1&&void 0!==c[1]?c[1]:void 0,d=(l?Ri.current?.[l]:null)||t?.cognitiveData||n?.cognitiveData||{section_id:l,decisioning:[],gap:[],relevance_score:0},p=gn.current[i]?.current??null,f=(()=>{const e=t?.evaluationResult||n?.evaluationResult||null,o=e=>{const t=(e=>{if(!e||"object"!=typeof e)return null;const t=e?.deviation_entries;if(t&&"object"==typeof t){const e=Object.keys(t).sort((e,t)=>Number(e)-Number(t))[0];if(e&&t[e])return t[e]}const n=Object.keys(e).filter(e=>/^\d+$/.test(e)).sort((e,t)=>Number(e)-Number(t));if(n.length&&e[n[0]])return e[n[0]];const i=e?.deviations;if(i&&"object"==typeof i){const e=Object.keys(i).sort((e,t)=>Number(e)-Number(t))[0];if(e&&i[e])return i[e]}return null})(e);return t?{...e,deviation_summary:e?.deviation_summary||t?.deviation_summary,deviation_title:e?.deviation_title||t?.deviation_title,deviation_impact:e?.deviation_impact||t?.deviation_impact,deviation_explanation:e?.deviation_explanation||t?.deviation_explanation,evaluation_outputs:e?.evaluation_outputs||t?.evaluation_outputs,cognitive_decisioning:e?.cognitive_decisioning||t?.cognitive_decisioning}:e};if(!("string"==typeof i&&i.includes(y)))return o(e);const r=i.split(y)[1];if(!r)return e;const s=t?.evaluationResult||n?.evaluationResult||{},l=s?.deviation_entries?.[r]||s?.deviations?.[r]||null;return l?{...s,...l,deviation_summary:l?.deviation_summary||s?.deviation_summary,deviation_title:l?.deviation_title||s?.deviation_title,deviation_impact:l?.deviation_impact||s?.deviation_impact,deviation_explanation:l?.deviation_explanation||s?.deviation_explanation,evaluation_outputs:l?.evaluation_outputs||s?.evaluation_outputs,cognitive_decisioning:l?.cognitive_decisioning||s?.cognitive_decisioning}:o(e)})(),g=(f?.cognitive_decisioning?.decisioning_factors?.length??0)>0||(f?.cognitive_decisioning?.gaps_in_decision?.length??0)>0,h=qe;let m=!0;if(Vt){const e=f?.deviation_highlights;if(e&&"object"==typeof e){m=Object.values(e).some(e=>Array.isArray(e)&&e.length>0)}else m=!1}return{isLoading:h&&!g,open:!0,sectionTitle:t?.title?t?.title:"No Counterpart",refSectionTitle:n?.title?n?.title:"No Counterpart",cognitiveData:d,anchorEl:e,sectionAnchorEl:p,badgeStyle:r||null,sectionIdx:i,docData:mi,deviationData:f,isOrphan:!!o,hasGuidelineMatches:m,sourceNodeId:a,deviationKey:u,baseContentId:t?.contentId,compareContentIds:[...n?.contentId?[n.contentId]:[],...t?.refContentIds||[],...n?.refContentIds||[]].filter(Boolean)}},[mi,qe,Vt]),Ci=s((e,t,n,i,o,r)=>{if(e.stopPropagation(),Rt.open&&Rt.sectionIdx===o)return void kt();const s=e.currentTarget;let l="left";dt.current?.contains(s)&&(l="right");Pn(),En.current&&Ln(),Le(new Set),Ne([]),et.current=[],Ot(),_t.open?Zi():Tt(),requestAnimationFrame(()=>{const e=(()=>{if("string"==typeof o&&o.includes(y)){const e=o.split(y),t=`${e[0]}${y}${e[1]}`;return"right"===l?un.current[t]?.current:an.current[t]?.current}return"right"===l?un.current[o]?.current:an.current[o]?.current})()||s;bt(bi(e,t,i,o,n,r))})},[Rt.open,Rt.sectionIdx,kt,Tt,bi]),wi=s(()=>{const e=Rt.sectionIdx;Rt.isOrphan,kt(),Tt(),null!==e&&(Vn(e),Pn(),En.current&&Ln(),Ne([]),et.current=[],Vt&&null!==e&&Ge(Ji(e)),Le(t=>t.has(e)?new Set:new Set([e])),setTimeout(()=>{tt.current&&tt.current()},50))},[Rt.sectionIdx,Rt.isOrphan,kt,Tt,Ln]),Ii=s(()=>{const e=Xe.current;if(!e)return;Xe.current=null;const t=Yt.findIndex(t=>t.id===e),n=Xt.findIndex(t=>t.id===e),i=-1===t?R(Yt,e):null,o=-1===n?R(Xt,e):null,r=-1!==t?t:i?Number(i.split("-")[0]):-1,s=-1!==n?n:o?Number(o.split("-")[0]):-1,l=(e,t,n,i)=>-1!==e?n.current[e]?.current??null:t?i.current[t]?.current??null:null,c=(e,t,n=30)=>{let i=0;const o=()=>{const r=e();r&&0!==r.getBoundingClientRect().height?(kn.current.add(r),C(r,t)):i++<n&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(_e)-1!==r&&mt.current&&c(()=>l(t,i,ln,pn),mt.current),-1!==s&&dt.current&&c(()=>l(n,o,cn,fn),dt.current);else{const e=at.current;if(!e)return;c(()=>-1!==r?l(t,i,ln,pn):l(n,o,cn,fn),e)}},[Yt,Xt,_e,ln,cn,pn,fn,mt,dt,at]),_i=s(e=>{if(!e)return;Pn(),Ln(),Le(new Set),Ne([]),et.current=[],Tt(),Ot();const t=Yt.findIndex(t=>t.id===e),n=Xt.findIndex(t=>t.id===e),i=-1===t?R(Yt,e):null,o=-1===n?R(Xt,e):null;if(-1===t&&!i&&-1===n&&!o)return void console.warn(`scrollToAndHighlightClause: nodeId "${e}" not found`);const r=-1!==t?t:i?Number(i.split("-")[0]):-1,s=-1!==n?n:o?Number(o.split("-")[0]):-1;Xe.current=e,Hn(e=>{const t={...e};let n=!1;if(-1!==r){const e=_e?`left-${r}`:String(r);t[e]||(t[e]=!0,n=!0)}if(-1!==s){const e=_e?`right-${s}`:String(s);t[e]||(t[e]=!0,n=!0)}return n?t:e}),Gn(e=>{const t={...e};let n=!1;const r=e=>{const i=e.split("-");let o=i[0];for(let e=1;e<i.length;e++)o+=`-${i[e]}`,t[o]||(t[o]=!0,n=!0)};return i&&r(i),o&&r(o),n?t:e}),setTimeout(()=>{requestAnimationFrame(()=>{Xe.current===e&&Bi.current()})},50)},[Yt,Xt,_e,Hn,Gn,Ln,Tt,Ot]),Bi=i(Ii);r(()=>{Bi.current=Ii},[Ii]);const Ti=i(null);r(()=>{if(jt){const e=Pt.fields.find(e=>e.analysisKey===jt||e.key===jt);if(e){const t=rn.current[e.key]||sn.current[e.key];t?.current&&setTimeout(()=>t.current.scrollIntoView({behavior:"smooth",block:"center"}),150)}}},[jt,Pt.fields]);const Fi=s(e=>{const t=Xn?.rule_difference_comparison?.fields;if(!t||!t[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};const n=t[e],i=n?.relation||n?.highlights?.ruleA_spans?.length||n?.highlights?.ruleB_spans?.length||n?.mappings&&n.mappings.length>0;if(n.mappings){const e=n.mappings[0]||{};return{score:n.score,relation:e.relation||"",highlightsA:e.highlights?.ruleA_spans||[],highlightsB:e.highlights?.ruleB_spans||[],hasContent:!!i}}return{score:n.score,relation:n.relation||"",highlightsA:n.highlights?.ruleA_spans||[],highlightsB:n.highlights?.ruleB_spans||[],hasContent:!!i}},[Xn]),{getSectionCompareStyle:Ei,getSubSectionCompareStyle:Ai,getDeviationStyleByKey:Di}=J({proposedSections:Yt,existingSections:Xt,maintainRelativeOrder:_e,cognitiveMap:lt,deviationData:rt,treeData:re,resolvedComparisonConfig:Pt,badgeStyleOverride:Re}),{lines:Oi,setLines:ki,overallConnector:Pi,setOverallConnector:ji,svgDimensions:Li,calculateLines:$i,calculateLinesDebounced:Ni,handleColumnScroll:Mi}=X({containerRef:Ke,leftContainerRef:mt,rightContainerRef:dt,svgContainerRef:Ve,pathRefs:Ze,leftHeaderRef:Je,rightHeaderRef:Ye,proposedSections:Yt,existingSections:Xt,visibleFields:Ut,leftRefs:rn,rightRefs:sn,sectionLeftRefs:ln,sectionRightRefs:cn,subSectionLeftRefs:pn,subSectionRightRefs:fn,lhsBadgeRefs:an,rhsBadgeRefs:un,sectionRowRefs:gn,expandedSections:Mn,expandedSubSections:zn,connectedSections:je,isSideBySide:vn,activeSideBySideSection:_n,maintainRelativeOrder:_e,isGuidelineMode:Vt,cognitiveMap:lt,getSectionCompareStyle:Ei,getSubSectionCompareStyle:Ai,getDeviationStyleByKey:Di,isArrowVisible:xn,isAnimatingRef:Ue,isSideBySideRef:En,sideBySideCacheRef:Fn,sideBySideLineRef:On,activeSideBySideSectionRef:Dn,activeSideBySideRightSectionRef:An,connectedLines:$e,setConnectedLines:Ne,cachedConnectedPositions:et,calculateLinesRef:tt,resizeTimerRef:nt,scrollLock:Tn,scrollSyncLocked:Me,handleResizeRef:it,activeProposed:Kt,existingRule:Jt,analysisData:Xn,pendingScrollTargetRef:St,pendingScrollCallbackRef:vt,resolvedComparisonConfig:Pt,getFieldData:Fi});r(()=>{_t.anchorEl&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{tt.current?.()})})},[_t.anchorEl,Me]);const Hi=s(()=>{Pn(),He(!1),Hn({}),Gn({}),Ln(),Le(new Set),Ne([]),et.current=[],Tt(),Ot(),kt(),requestAnimationFrame(()=>{tt.current&&tt.current()})},[Hn,Gn,Ln,Tt,Ot,kt]);r(()=>{vn||0!==je.size||He(!1)},[vn,je]);const zi=o(()=>Object.values(Mn).some(Boolean)||Object.values(zn).some(Boolean),[Mn,zn]),Gi=i(null),Wi=i(0),qi=i(0),Vi=i(0),{handleResize:Ki}=Y({timerRef:Gi,ruleComponentRef:ut,scrollContainerRef:at,containerRef:Ke,maintainRelativeOrder:_e,proposedSections:Yt,existingSections:Xt,isSideBySideRef:En,activeSideBySideSectionRef:Dn,activeSideBySideRightSectionRef:An,sectionRowRefs:gn,sectionRightRowRefs:dn,sectionLeftRefs:ln,sectionRightRefs:cn,subSectionLeftRefs:pn,subSectionRightRefs:fn,lhsBadgeRefs:an,rhsBadgeRefs:un,leftContainerRef:mt,rightContainerRef:dt,calculateLinesRef:tt,handleResizeRef:it,setIsResizing:Cn,setIsArrowVisible:Rn,sideBySideCacheRef:Fn,cachedConnectedPositions:et});r(()=>{it.current=Ki},[Ki,it]),r(()=>{const e=(e,t,n,i,o)=>{t.current=e.getBoundingClientRect().width;const r=new ResizeObserver(e=>{null!==n.current&&cancelAnimationFrame(n.current),n.current=requestAnimationFrame(()=>{n.current=null;const r=e[e.length-1];if(!r)return;const s=r.borderBoxSize?.[0]?.inlineSize??r.contentRect.width;Math.abs(s-t.current)<1?o():(t.current=s,i())})});return r.observe(e),r},t={current:null},n={current:null},i={current:null},o=[],r=[t,n,i];return ut.current&&o.push(e(ut.current,Wi,t,()=>it.current(),()=>{})),at.current&&o.push(e(at.current,qi,n,()=>it.current(),()=>tt.current())),Ke.current&&o.push(e(Ke.current,Vi,i,()=>it.current(),()=>tt.current())),()=>{o.forEach(e=>e.disconnect()),r.forEach(e=>{null!==e.current&&(cancelAnimationFrame(e.current),e.current=null)})}},[]),r(()=>{En.current=vn},[vn]),r(()=>{Dn.current=_n},[_n]);const Ji=s(e=>{let t="",n="0";if("number"==typeof e)t=Yt[e]?.nodeId||Yt[e]?.id||"";else{const i=String(e).split(y);t=i[0],n=i[1]||"0"}const i=rt?.[t]?.evaluation_result,o=Array.isArray(i)?i[parseInt(n,10)]:i?.[n];return!1===o?.evaluation_outputs?.guideline_flag?.rulebook_used&&ie(o)?1:0},[Yt,rt]),Yi=s(()=>{Ln(),Le(new Set),Ne([]),et.current=[]},[Ln]),Xi=s((e,t)=>{t!==ze&&(Yi(),Ge(t))},[ze,Yi]);r(()=>{st||0===ze||(Yi(),Ge(0))},[ze,st,Yi]);const Ui=s(e=>{const t=mt.current,n=dt.current,i=ne(n);if(!n)return;const o="string"==typeof e&&e.includes(y);let r=e;if(o){const t=e.split(y);t.length>=2&&(r=`${t[0]}${y}${t[1]}`)}const s=an.current[r]?.current||an.current[e]?.current;if(i.length>0&&s&&t&&n){const e=i[0];gt.current&&(gt.current.style.height="0px"),pt.current&&(pt.current.style.height="0px"),ht.current&&(ht.current.style.height="0px"),ft.current&&(ft.current.style.height="0px"),requestAnimationFrame(()=>{const i=s.getBoundingClientRect(),o=e.getBoundingClientRect(),r=t.getBoundingClientRect(),l=n.getBoundingClientRect(),c=t.scrollTop+(i.top-r.top)+i.height/2,a=n.scrollTop+(o.top-l.top)+o.height/2,u=c-r.height/2,d=Math.max(0,u),p=t.scrollHeight-t.clientHeight,f=d>p?d-p:0,g=r.top+c-d;let h=l.top+a-g,m=0;h<0&&(m=Math.abs(h),h=0);const S=n.scrollHeight-n.clientHeight+m,v=h>S?h-S:0;ht.current&&(ht.current.style.height=`${f}px`),pt.current&&(pt.current.style.height=`${m}px`),ft.current&&(ft.current.style.height=`${v}px`),requestAnimationFrame(()=>{t.scrollTo({top:d,behavior:"smooth"}),n.scrollTo({top:h,behavior:"smooth"}),tt.current&&setTimeout(()=>tt.current(),50)})})}},[y]),Qi=s(()=>{const e=Rt.sectionIdx,t=Rt.isOrphan;if(Tt(),null==e)return;let n="left";Rt.anchorEl&&dt.current?.contains(Rt.anchorEl)&&(n="right"),Vn(e),Vt&&(Ge(Ji(e)),Le(new Set([e]))),$n(e,t,{sourceSide:n,onReady:()=>{Vt&&setTimeout(()=>Ui(String(e)),150)}})},[$n,Rt.isOrphan,Rt.sectionIdx,Rt.anchorEl,Tt,Vn,Vt,Ui,Ji]),Zi=s(()=>{Tt(),Ln(),Le(new Set),Ne([]),et.current=[]},[Tt,Ln]),eo=null!==Rt.sectionIdx&&je.has(Rt.sectionIdx),{showDeviationNavigation:to,showOpenNodeRef:no,adjustScrollForPopup:io}=M({proposedSections:Yt,existingSections:Xt,parentDeviationRecord:Qt,expandedSections:Mn,maintainRelativeOrder:!!_e,scrollContainerRef:at,leftContainerRef:mt,rightContainerRef:dt,lhsBadgeRefs:an,rhsBadgeRefs:un}),oo=s((e,t,n,i,o)=>{const r="string"==typeof i?S(i).trim():S(i?.deviation_summary).trim(),s=e.currentTarget;Ot();let l="left";dt.current?.contains(s)&&(l="right");const c=()=>{if("string"==typeof t&&t.includes(y)){const e=t.split(y),n=`${e[0]}${y}${e[1]}`;return"right"===l?un.current[n]?.current:an.current[n]?.current}return"right"===l?un.current[t]?.current:an.current[t]?.current};if(n&&!Vt)return Ln(),Le(new Set),Ne([]),et.current=[],void(r&&(Vn(t),requestAnimationFrame(()=>{const e=c()||s;if(e){e.getBoundingClientRect().top>.8*window.innerHeight&&e.scrollIntoView({behavior:"smooth",block:"center"})}Bt({open:!0,anchorEl:e,summary:i,displayImpact:o})})));Vn(t),Vt&&(Ge(Ji(t)),Le(new Set([t]))),r?setTimeout(()=>{$n(t,n,{toggleIfSame:!1,sourceSide:l,onReady:()=>{const e=c()||s;if(Vt)setTimeout(()=>Ui(t),150);else if(e){const t=e.getBoundingClientRect();if(t.top>.8*window.innerHeight||t.top<100){const e=t.top-window.innerHeight/2;_e?(mt.current?.scrollBy({top:e,behavior:"smooth"}),dt.current?.scrollBy({top:e,behavior:"smooth"})):at.current?.scrollBy({top:e,behavior:"smooth"})}}Bt({open:!0,anchorEl:e,summary:i,displayImpact:o})}})},350):setTimeout(()=>{$n(t,n,{toggleIfSame:!1,sourceSide:l}),Vt&&setTimeout(()=>Ui(t),150)},350)},[$n,Ot,Bt,Ln,Vn,Vt,_e,Ui,rt]),ro=o(()=>{if(!me)return null;const e=me?.id?.split(":")[0];for(const t in Qt){if((Qt[t]||[]).some(t=>t.id===e))return t}return null},[me,Qt]),so=i({id:null,triggerMs:null}),lo=i(null);r(()=>{if(!me?.id)return;const e=Number(me.trigger),t=so.current;if(t?.id===me.id&&t?.triggerMs===e)return;if(!(me.id.includes(":")&&/:\d+$/.test(me.id))){so.current={id:me.id,triggerMs:e},_i(me.id);const t=Yt.findIndex(e=>e.id===me.id),n=Xt.findIndex(e=>e.id===me.id);return void(-1===t&&-1===n||setTimeout(()=>{const e=-1!==t?t:n,i=-1===t;Vt&&Ge(Ji(e)),Le(new Set([e])),Nn.current(e,i,{sourceSide:i?"right":"left",onReady:()=>{Vt&&setTimeout(()=>Ui(String(e)),150)}})},400))}const[n,i]=me.id.split(":"),o=i??"0",r=`${me.id}:${e}`;lo.current!==r&&(Tt(),Ot(),Ln(),Le(new Set),Ne([]),et.current=[],lo.current=r);let s=!1,l=0;let c=null,a=null,u=!1;const d=(e,t)=>{const n=(e,i)=>{if(!e)return null;if(t.includes(e.id)||t.includes(e.nodeId)||t.includes(e.contentId))return i;if(!Array.isArray(e.subsections))return null;for(let t=0;t<e.subsections.length;t++){const o=n(e.subsections[t],`${i}-${t}`);if(o)return o}return null};for(let t=0;t<e.length;t++){const i=n(e[t],String(t));if(i)return i}return null},p=()=>{if(s)return;const t=()=>{so.current={id:me.id,triggerMs:e}};let i=null,r=null;for(const e in Qt){const t=Qt[e].find(e=>e.id===n||e.nodeId===n||e.contentId===n||e.evaluationResult?.nodeId===n);if(t){i=e,r=t;break}}if(!r||!i)return l++,void(l<30&&(c=setTimeout(p,100)));const f=Array.from(new Set([n,r.id,r.nodeId,r.contentId,r.evaluationResult?.nodeId].filter(Boolean))),g=Yt.findIndex(e=>e.id===i),h=Xt.findIndex(e=>e.id===i),m=-1===g&&-1!==h,S=d(Yt,f);let v=d(Xt,f);if(S&&!v&&!m){const e=S.split("-");let t=Number(e[0]);if(_e){const e=Yt[t]?.refIndexes?.[0],n=Xt.findIndex(t=>t.selfIndex===e);-1!==n&&(t=n)}v=[t,...e.slice(1)].join("-")}if(!S&&!v)return l++,void(l<30&&(c=setTimeout(p,100)));const x=S?Number(S.split("-")[0]):g,R=v?Number(v.split("-")[0]):h,b=R>=0?R:v?Number(v.split("-")[0]):-1,C=Yt[x],_=Xt[b],B=C&&!C.title&&!C.content,T=_&&!_.title&&!_.content,F=m||(!S&&!!v||B&&!T);if(F){if(!(_e?!!xo.current[`right-${R}`]:!!xo.current[String(R)])&&R>=0)return qn(R,"right"),void(c=setTimeout(p,200))}else{if(!(_e?!!xo.current[`left-${x}`]:!!xo.current[String(x)])&&x>=0)return qn(x,"left"),void(c=setTimeout(p,200))}const E=S||"",A=v||"",D=f.map(e=>`${e}${y}${o}`),O=D[0],k=()=>{for(const e of D){const t=an.current[e]?.current||null,n=un.current[e]?.current||null;if(t||n)return{refId:e,left:t,right:n}}return{refId:O,left:null,right:null}},P=e=>`${e}${y}${E}${y}${A}`;if(!u){Vn(P(O)),u=!0,l=0;const e=()=>{const{left:e,right:t}=k();return F||!e&&!!t?t:e};return a?.(),void(c=setTimeout(()=>{s||(a=((e,t)=>{let n,i=0,o=null,r=null;const l=performance.now(),c=()=>{if(s)return;if(performance.now()-l>3e3)return void t();const a=e();if(!a||0===a.getBoundingClientRect().height)return void(n=requestAnimationFrame(c));const u=a.getBoundingClientRect(),d=u.top,p=u.height,f=null!==o&&Math.abs(d-o)<.5,g=null!==r&&Math.abs(p-r)<.5;if(f&&g){if(i++,i>=5)return void t()}else i=0;o=d,r=p,n=requestAnimationFrame(c)};return n=requestAnimationFrame(c),()=>cancelAnimationFrame(n)})(e,()=>{s||(a=null,p())}))},300))}const{refId:j,left:L,right:$}=k(),N=P(j);if(!L&&!$)return l++,void(l<30&&(c=setTimeout(p,100)));const M=F||!L&&!!$,H=M?$:L,z=_e?M?dt.current:mt.current:at.current;if(!H||!z)return l++,void(l<30&&(c=setTimeout(p,100)));const G=H.getBoundingClientRect();if(0===G.height)return l++,void(l<30&&(c=setTimeout(p,100)));const W=z.getBoundingClientRect(),q=G.top-W.top+z.scrollTop-W.height/2+G.height/2,V=S?.includes("-")||v?.includes("-"),K=async()=>{if(s)return;t();const e=H instanceof Element?window.getComputedStyle(H).color:"";[L,$].forEach(t=>{t&&(t.style.transition="box-shadow 300ms ease-in-out",t.style.boxShadow=`0 0 10px ${e}`)}),setTimeout(()=>{[L,$].forEach(e=>{e&&(e.style.boxShadow="")})},2e3);const n=r.evaluationResult?.deviations?.[o]||r,i=r.evaluationResult?.evaluation_outputs||r.evaluation_outputs;if(!(!!L&&!!$)&&!Vt){const e=M?un.current[V?j:R]?.current||$:an.current[V?j:x]?.current||L;return io(e,()=>{Bt({open:!0,anchorEl:e,displayImpact:me.displayImpact,summary:{...n,evaluation_outputs:i}})},{skipScroll:!0}),void Se?.()}const l=(e,t)=>Promise.race([e,new Promise(e=>setTimeout(e,t))]);_e&&await Promise.all([mt.current?l(I(mt.current),600):Promise.resolve(),dt.current?l(I(dt.current),600):Promise.resolve()]),Vt&&(Ge(Ji(N)),Le(new Set([N]))),Nn.current(N,!1,{toggleIfSame:!1,sourceSide:m?"right":"left",onReady:()=>{t();const e=M?un.current[j]?.current||$:an.current[j]?.current||L;if(Vt)setTimeout(()=>Ui(N),150);else{const e=an.current[j]?.current||L,t=un.current[j]?.current||$;e&&(e.style.scrollMarginTop="150px",e.scrollIntoView({behavior:"smooth",block:"start"})),t&&(t.style.scrollMarginTop="150px",t.scrollIntoView({behavior:"smooth",block:"start"}))}Bt({open:!0,anchorEl:e,displayImpact:me.displayImpact,summary:{...n}}),Se?.()}})};Math.abs(z.scrollTop-q)<=2?K():w(z,q,K)};return c=setTimeout(p,100),()=>{s=!0,c&&clearTimeout(c),a?.()}},[me?.id,me?.trigger,me?.displayImpact,Qt,Yt,Xt,_e,Bt,_i,Vt,Ji,Ui]),r(()=>{if(!_t.open)return;const e=_t.anchorEl;if(!e)return;if(e.isConnected)return;const t=t=>{for(const[n,i]of Object.entries(t))if(i.current?.textContent===e.textContent)return n;return null},n=e.dataset?.deviationRefId||t(an.current)||t(un.current);if(!n)return;const i=un.current[n]?.current||an.current[n]?.current;i&&i.isConnected&&Bt(e=>({...e,anchorEl:i}))},[_t.open,_t.anchorEl,Me,je,Mn]);const{open:co,sectionIdx:ao,isOrphan:uo,badgeStyle:po,anchorEl:fo,sectionAnchorEl:go}=xt;r(()=>{if(!de.isStreamingEnabled)return;if(!co||null==ao)return;if(ao===Zn)return;const e="string"==typeof ao?ao.split(y)[0]:null,t=(e,n)=>{if(!e||!Array.isArray(e))return null;for(const i of e){if(i.id===n)return i;if(i.subsections?.length){const e=t(i.subsections,n);if(e)return e}}return null},n=e&&"string"==typeof e?t(Yt,e):null,i=e&&"string"==typeof e?t(Xt,e):null,o="number"==typeof ao?Yt[ao]||null:n||e&&(re?.nodes?.[e]||re?.[e])||null,r="number"==typeof ao?Xt[ao]||null:i,s=bi(fo,o,r,ao,uo,po);yt(e=>{if(!e.open)return e;return S(e.cognitiveData)===S(s.cognitiveData)&&S(e.deviationData)===S(s.deviationData)&&e.sectionTitle===s.sectionTitle&&e.refSectionTitle===s.refSectionTitle?e:{...e,...s,open:!0,anchorEl:e.anchorEl,sectionAnchorEl:e.sectionAnchorEl}})},[co,ao,uo,po,fo,go,Yt,Xt,bi]);const ho=s(({section:t,keyPath:n,depth:i=0,columnKey:o="left",parentNodeId:r="",sectionOffset:s,rhsOrphanVisualIndexes:l})=>e(G,{section:t,keyPath:n,depth:i,columnKey:o,parentNodeId:r,sectionOffset:s,rhsOrphanVisualIndexes:l}),[]),mo=o(()=>Yt.map((t,n)=>{const i=!t?.title&&!t?.content,o=!t?.refIndexes||0===t.refIndexes.length;return i&&o&&_e?null:e(W,{section:t,idx:n},t?.layoutKey??t?.id??`left-row-${n}`)}),[Yt,_e]),So=o(()=>Xt.map((t,n)=>{const i=!t?.title&&!t?.content,o=!t?.refIndexes||0===t.refIndexes.length;return i&&o&&_e?null:e(q,{section:t,idx:n},t?.layoutKey??t?.id??`right-row-${n}`)}),[Xt,_e]),vo=i(Ci);r(()=>{vo.current=Ci},[Ci]);const xo=i(Mn);r(()=>{xo.current=Mn},[Mn]);const yo=i(oo);r(()=>{yo.current=oo},[oo]);const Ro=i(Zi);r(()=>{Ro.current=Zi},[Zi]);const bo=i(qn);r(()=>{bo.current=qn},[qn]);const Co=i(Wn);r(()=>{Co.current=Wn},[Wn]);const wo=i(ho);r(()=>{wo.current=ho},[ho]);const Io=i(Ln);r(()=>{Io.current=Ln},[Ln]);const{cacheVersion:_o,getCacheKey:Bo,getCacheEntry:To,fetchCitationContext:Fo,prefetchCitationContexts:Eo,abortCitationContexts:Ao}=H(Ie),Do=o(()=>({isGuidelineMode:Vt,maintainRelativeOrder:!!_e,showDeviationBadges:Ee,isProposingFix:ve,proposingFixNodeId:xe,isRedlineFlow:ye,isSideBySide:vn,activeSideBySideSection:_n,scrollSyncLocked:Me,toggleScrollSyncLocked:Jn,summaryPopupAnchorEl:_t.anchorEl,connectedSections:je,proposedSections:Yt,existingSections:Xt,deviationNumberRegistry:Zt,deviationParentRegistry:en,treeData:re,displayConfig:de,deviationAnalysisStatus:We,resolvedMarkdownStyles:ct,unifiedNumbering:Yn,expandedSections:Mn,expandedSubSections:zn,setExpandedSubSections:Gn,getSectionCompareStyle:Ei,getSubSectionCompareStyle:Ai,getBadgeRef:Sn,getSectionRowRef:hn,getSubSectionRef:mn,sectionLeftRefs:ln,sectionRightRefs:cn,sectionRowRefs:gn,sectionRightRowRefs:dn,subSectionLeftRefs:pn,subSectionRightRefs:fn,lhsBadgeRefs:an,rhsBadgeRefs:un,openMoreFunctionsPopup:li,handleOpenSummaryPopup:ci,openSummaryPopup:ci,handleCloseSummaryPopup:ai,toggleSection:ui,handleSubSectionToggle:di,renderSubSectionAccordion:pi,resetSideBySide:fi,setConnectedSections:Le,setConnectedLines:Ne,cachedConnectedPositions:et,showDeviationNavigation:to,showOpenNodeRef:no,deviationNodeIdToView:me?.id,deviationTargetParentId:ro,guidelinesData:be,gptWebCitationConfig:we,onDemandCitationConfig:Ie,onDemandCitationCacheVersion:_o,getOnDemandCitationCacheKey:Bo,getOnDemandCitationCacheEntry:To,fetchOnDemandCitationContext:Fo,prefetchOnDemandCitationContexts:Eo,abortOnDemandCitationContexts:Ao}),[Vt,_e,Ee,ve,xe,ye,vn,_n,Me,Jn,_t.anchorEl,je,Yt,Xt,Zt,de,We,ct,Yn,Mn,zn,Gn,Ei,Ai,Sn,hn,mn,to,no,me,ro,be,we,Ie,_o,Bo,To,Fo,Eo,Ao]),Oo=S(xt.sectionTitle||zt||Mt),ko=S(Vt?Wt||qt||xt.refSectionTitle:xt.refSectionTitle||Wt||qt);return e(K,{value:Do,children:t(l,{ref:ut,sx:{display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif',overflow:"visible",position:"relative"},children:[Ae&&e(l,{sx:{position:"absolute",inset:0,bgcolor:"rgba(255, 255, 255, 0.6)",backdropFilter:"blur(10px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"8px"},children:e(k,{})}),_t.open&&e(V,{open:_t.open,anchorEl:_t.anchorEl,containerEl:Ti.current,clipTopEl:Je.current,scrollContainerEl:at.current,onClose:Zi,summary:_t.summary,displayImpact:_t.displayImpact,isScrollLocked:Me}),e(O,{open:Rt.open,anchorEl:Rt.anchorEl,maintainRelativeOrder:!!_e,sectionTitle:Rt.sectionTitle,referenceSectionTitle:Rt.refSectionTitle,onClose:kt,onOpenCognitiveCompare:At,onOpenSideBySide:Qi,onConnect:wi,isConnected:eo,isOrphan:!Vt&&!!Rt.isOrphan,isGuidelineMode:Vt,hasGuidelineMatches:Rt.hasGuidelineMatches}),xt.open&&e(D,{open:xt.open,popupRef:Et,position:Ct,popupConfig:ge,onClose:()=>{wt(null),yt(e=>({...e,open:!1})),Ft(null)},markdownStyles:ae,sectionTitle:Oo,referenceSectionTitle:ko,cognitiveData:xt.cognitiveData,anchorEl:xt.anchorEl,sectionAnchorEl:xt.sectionAnchorEl,scrollContainerEl:at.current,badgeStyle:xt.badgeStyle,docData:xt.docData,deviationData:xt.deviationData,isLoading:xt.isLoading,sourceNodeId:xt.sourceNodeId,deviationKey:xt.deviationKey,baseContentId:xt.baseContentId,compareContentIds:xt.compareContentIds}),e(c,{open:!!Oe,autoHideDuration:8e3,onClose:()=>ke(null),anchorOrigin:{vertical:"top",horizontal:"center"},children:e(a,{onClose:()=>ke(null),severity:"error",sx:{width:"100%",whiteSpace:"pre-line"},children:Oe})}),e(z,{componentHeaderText:oe,displayConfig:de,maintainRelativeOrder:_e,onCollapseAll:Hi,showCollapseAll:zi,onToggleView:e=>{De(!0),setTimeout(()=>{Be(!e),fe?.(!e),He(!1),Ln(),Tt(),Le(new Set),Ne([]),et.current=[],requestAnimationFrame(()=>{requestAnimationFrame(()=>{setTimeout(()=>{De(!1)},600)})})},50)}}),e(l,{ref:at,onScroll:Mi,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:_e?"stretch":"flex-start",bgcolor:"#FFFFFF",overflowY:_e?"visible":"auto",borderTop:Un&&Qn?"none":"1.5px solid #EEF0F4"},children:e(l,{sx:{display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px",minHeight:0,..._e?{flex:1}:{}},children:t(l,{ref:Ke,sx:{display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"100px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0,..._e?{flex:1,overflow:"visible"}:{}},children:[e(Q,{svgContainerRef:Ve,svgDimensions:Li,isResizing:bn,overallConnector:Pi,rootDeviationStyle:oi,lines:Oi,isSideBySide:vn,activeSideBySideSection:_n,isArrowVisible:xn,maintainRelativeOrder:_e,proposedSections:Yt,existingSections:Xt,cognitivePopup:xt,activeBadgeId:It,closeCognitivePopup:Ot,setActiveBadgeId:Ft,openCognitivePopupFromState:Dt,buildSectionPopupState:bi,connectedLines:$e,isGuidelineMode:Vt,deviationAnalysisStatus:We,pathRefs:Ze}),t(l,{sx:{border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)",..._e?{flex:1,overflow:"visible",minHeight:0}:{}},children:[e(l,{ref:Je,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center",minHeight:"40px",overflow:"hidden",minWidth:0},children:e(u,{title:Mt,placement:"top",children:e(d,{sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"},children:Mt})})}),t(l,{ref:mt,onScroll:Mi,sx:{p:"12px",display:"flex",flexDirection:"column",..._e?{flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-180px",pr:"192px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{}},children:[e("div",{ref:gt,style:{width:"100%",height:"0px",flexShrink:0}}),nn&&mo,e("div",{ref:ht,style:{width:"100%",height:"0px",flexShrink:0}})]})]}),e(l,{ref:Ti,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"},children:e(l,{sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0},children:t(l,{onClick:e=>{e.stopPropagation(),xt.open&&It===Zn?Ot():(Ft(Zn),Dt(bi(e.currentTarget,{title:Si,content:"",evaluationResult:ei,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},{title:xi,content:""},Zn,!0,{...oi,label:""})))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:oi.badgeBg,color:oi.badgeText,border:`1px solid ${oi.badgeBorder}`,fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"},children:[ni?e(u,{title:"Deviation data generation in progress",placement:"top",arrow:!0,children:e(l,{component:"span",sx:{display:"inline-flex",alignItems:"center"},children:e(P,{color:oi.badgeText})})}):ii??e(P,{color:oi.badgeText}),e(l,{component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}},children:e(h,{})}),e(g,{size:11,style:{transform:xt.open&&It===Zn?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]})})}),t(l,{sx:{border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0,..._e?{flex:1,overflow:"visible",minHeight:0}:{}},children:[wn&&e(m,{sections:11}),e(l,{ref:Ye,sx:{p:"8px",bgcolor:Vt?"#F1F3F5":"#F7F8FA",borderBottom:"1px solid #D7DCE2",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center",flexShrink:0},children:Vt?t(p,{value:ze,onChange:Xi,variant:"fullWidth",TabIndicatorProps:{sx:{display:"none"}},sx:{width:"100%",minHeight:"36px","& .MuiTab-root":{minHeight:"36px",px:1,py:0,borderRadius:"8px",fontSize:"14px",lineHeight:1,fontWeight:500,textTransform:"none",color:"#374151",minWidth:0,transition:"background-color 160ms ease, box-shadow 160ms ease"},"& .Mui-selected":{color:"#374151",bgcolor:"#FFFFFF"}},children:[e(f,{label:e(u,{title:qt,placement:"top",children:e(l,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block",width:"100%"},children:"Redline Guidelines"})})}),st&&e(f,{label:e(u,{title:"Web & GPT Sources",placement:"top",children:e(l,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block",width:"100%"},children:"Web & GPT Sources"})})})]}):e(u,{title:qt,placement:"top",children:e(d,{sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"},children:qt})})}),t(l,{ref:dt,onScroll:Mi,sx:{p:Vt?"0px":"12px",display:"flex",flexDirection:"column",..._e?{flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-150px",pl:"165px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{}},children:[e("div",{ref:pt,style:{width:"100%",height:"0px",flexShrink:0}}),Vt?be?0!==ze&&st?e(ee,{deviationData:he,connectedSections:je,proposedSections:Yt}):e(Z,{guidelinesData:be,deviationData:he,connectedSections:je,proposedSections:Yt}):e(te,{}):nn&&So,e("div",{ref:ft,style:{width:"100%",height:"0px",flexShrink:0}})]})]})]})})})]})})};export{oe as default};
2
2
  //# sourceMappingURL=CognitiveCompare.js.map