@e-llm-studio/citation 0.0.251-beta.1 → 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 (213) 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
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("lucide-react"),i=require("react"),a=require("./ResizableSplitPane.js"),n=require("../PdfViewer/PdfViewer.js"),r=require("../../assests/svg/PdfViewerIcons.js"),o=require("react-markdown"),s=require("rehype-raw"),l=require("@mui/material"),c=require("./CognitiveCompareConfig.js");require("react-dom");var d=require("./CompareContext.js"),u=require("./Guidelines/utils/processGuidelinesMarkdown.js"),p=require("../GptWebCitation/GptWebCitation.js"),h=require("../GptWebCitation/types.js");function g(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("./components/SubSectionAccordion.js"),require("./components/LHSSectionRow.js"),require("./components/RHSSectionRow.js");var m=g(o),x=g(s);const f=e=>(e?.extraMetaData||e)?.aiReasoningCitation?.gpt_citation?.[0]||null,b="https://dev-proposals-ai.techo.camp/utility/ca-workflow-composer-agent/get_citation",_="sai.siddhartha@techolution.com",y="672e32f7a0e8fe2e8e50bcba",w="TNV Sai Siddhartha",C="90vh",j=`calc(${C} - 120px)`,v=()=>"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)}),D=(e,t)=>{const i=(e=>e?.payloadCitationId||e?.extraMetaData?.payloadCitationId||"")(e)||t||v();return((e,t)=>{e&&"object"==typeof e&&(e.payloadCitationId=t,e.extraMetaData&&"object"==typeof e.extraMetaData&&(e.extraMetaData.payloadCitationId=t))})(e,i),i},F=({metaData:a,isFullscreen:n=!1})=>{const{gptWebCitationConfig:r}=d.useCompareContext(),o=i.useMemo(()=>(e=>({endpoint:e?.endpoint||b,userEmail:e?.userEmail||_,userId:e?.userId||y,userName:e?.userName||w,headers:e?.headers}))(r),[r]),s=a?.webGpt,l=i.useRef(null);l.current||(l.current=v());const c=i.useMemo(()=>((e,t,i)=>{const a=f(e),n=a?.customMetaData||{},r=n?.value||{},o=e?.webSearchAnswer||{},s=e?.extraMetaData||e||{};return{userEmail:e?.userEmail||o?.userEmail||t?.userEmail||"",userId:e?.userId||o?.userId||t?.userId||"",userName:e?.userName||o?.userName||t?.userName||"",citationId:D(e,i),citationUrl:r?.citationUrl||o?.citationUrl||"",content:s?.Reasoning||o?.enhanced_content||"",citationType:r?.citationType||"web",citatioNumber:n?.citation_number??a?.citation_number??Number(e?.reasoningId||0)}})(s,o,l.current||void 0),[s,o]),u=i.useMemo(()=>f(s),[s]),g=u?.customMetaData?.value||{},m=s?.extraMetaData||s||{},[x,C]=i.useState(),[F,S]=i.useState("pending"),[P,T]=i.useState(!0);i.useEffect(()=>{let e=!0;return(async()=>{if(o.endpoint&&c?.citationUrl&&c?.content){S("pending");try{const t=await fetch(o.endpoint,{method:"POST",headers:{"actor-id":c.userEmail,Accept:"application/json, text/plain, */*","Content-Type":"application/json",...o.headers||{}},body:JSON.stringify(c)});if(!t.ok)throw new Error(`Failed to fetch GPT web citation (${t.status})`);const i=await t.json();if(!e)return;C(i?.responseData||i?.result||i?.data||i),S("success")}catch(t){if(!e)return;console.error("Failed to load GPT web citation",t),S("error")}}else S("error")})(),()=>{e=!1}},[c,o]);const k=i.useMemo(()=>({item:{confidence_score:Number(m?.Confidence_score||0),text:g?.paraphrase||"Web citation reasoning",dataSource:g?.text||m?.Reasoning||"",paraphrase:g?.paraphrase||""},headerTitle:"GPT Web Citation",index:Number(c?.citatioNumber||1)-1,iconsConfig:{ChevronDownIcon:t.ChevronDown,ChevronUpIcon:t.ChevronUp,MaximizeIcon:t.Maximize2,CloseIcon:t.X}}),[g,c?.citatioNumber,m]),M=i.useMemo(()=>({...k,...n?{bodyHeight:j}:{}}),[k,n]);return e.jsx(p.default,{gptCitation:M,defaultCitationUrl:c?.citationUrl||"",citationType:h.CitationType.GPT_WEB,webCitationData:x,webCitationStatus:F,showWebCitation:P,onToggleCitationView:()=>T(e=>!e),iconsConfig:{MaximizeIcon:t.Maximize2,ExternalLinkIcon:t.ExternalLink},isFixedHeight:!0})},S=({href:t,metaData:r,citationTitle:o,citationType:s,citationReason:p,isFullscreen:h})=>{const{guidelinesData:g}=d.useCompareContext(),{citationNumber:f,phraseToHighlight:b,citationTypeFromHref:_}=(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}}})(t),y=s||_||void 0,w="il_rulebook_citation"===y?"rulebook_citation":y,C=f&&r?.citations?.[f]||{},j=r?.docData?.documents||{},v=r?.docData?.input_index_map||{},D=Object.keys(r?.citations||{}).length>0||Object.keys(r?.docData||{}).length>0,S=v?.[0],P=v?.[1],T=S?j[S]:null,k=P?j[P]:null,M=S?C[S]:null,N=P?C[P]:null,I=i.useMemo(()=>M&&T?e.jsx(n.default,{defaultScale:"PageWidth",showFullScreenAction:!1,showHighlightsAction:!1,pdfName:T?.title,pdfUrl:T?.signed_url,highlightText:[M?.highlighted_text??""],highlightPages:{1:M?.custom_metadata?.pdf_start_page_number},jumpToPageValue:1,highlightCordinatePages:[],useCoordinates:!1,useRange:!0,rangeOfPages:[M?.custom_metadata?.pdf_start_page_number,M?.custom_metadata?.pdf_end_page_number]}):null,[T?.title,T?.signed_url,M?.highlighted_text,M?.custom_metadata?.pdf_start_page_number,M?.custom_metadata?.pdf_end_page_number]),R=i.useMemo(()=>N&&k?e.jsx(n.default,{defaultScale:"PageWidth",showFullScreenAction:!1,showHighlightsAction:!1,pdfName:k?.title,pdfUrl:k?.signed_url,jumpToPageValue:1,highlightText:[N?.highlighted_text??""],highlightPages:{1:N?.custom_metadata?.pdf_start_page_number},highlightCordinatePages:[],useCoordinates:!1,useRange:!0,rangeOfPages:[N?.custom_metadata?.pdf_start_page_number,N?.custom_metadata?.pdf_end_page_number]}):null,[k?.title,k?.signed_url,N?.highlighted_text,N?.custom_metadata?.pdf_start_page_number,N?.custom_metadata?.pdf_end_page_number]),G="dual_citation"===w,U=G&&!!r?.webGpt,E=i.useMemo(()=>{if(!I)return null;const t=U?e.jsx(F,{metaData:r,isFullscreen:h}):"rulebook_citation"===w?e.jsx(e.Fragment,{children:e.jsx(l.Box,{sx:{padding:"0px 20px",backgroundColor:"#FFFFFF",borderRadius:"8px",...c.SHARED_MARKDOWN_STYLES,overflow:"auto"},children:e.jsx(m.default,{rehypePlugins:[x.default],children:u.processGuidelinesMarkdown({guidelinesData:g,targetHighlights:[b],labelColor:"#FEF08A"})})})}):R;return t?e.jsx(a.default,{leftComponent:I,rightComponent:t,isFullscreen:h}):I},[I,R,w,U,r,h,g,b]);return r?.webGpt&&!D?e.jsx(F,{metaData:r,isFullscreen:h}):f?"rulebook_citation"===w?M?e.jsx("div",{style:{height:"100%",display:"flex",flexDirection:"column"},children:E}):e.jsx("div",{style:{padding:"12px",fontSize:"13px",color:"#344054",lineHeight:1.5},children:p||"Rulebook citation selected."}):G?M||N?e.jsx("div",{style:{height:"100%",display:"flex",flexDirection:"column"},children:E}):r?.webGpt?e.jsx(F,{metaData:r,isFullscreen:h}):e.jsx("div",{children:"Missing PDF Citation. Please try again later"}):["contract","clause"].includes(o)?M||N?e.jsx("div",{style:{height:"100%",display:"flex",flexDirection:"column"},children:E}):e.jsx("div",{children:"Missing PDF Citation. Please try again later"}):e.jsx("div",{children:"No Citation Found. Please try again later"}):null};exports.default=({href:a,children:n,citationType:o,citationReason:s,metaData:c,chevronUpComponent:d=null,chevronDownComponent:u=null,customStyle:p={},defaultState:h=!1,onFullscreenChange:g})=>{const[m,x]=i.useState(h),[f,b]=i.useState(!1),_="string"==typeof n&&n?.split("\n")?.length>1?n.split("\n").join(" "):n;i.useEffect(()=>{if(g?.(f),f)return()=>{g?.(!1)}},[f,g]);const y="string"==typeof n?n:n[0],w=d??(j=p?.arrow??{},e.jsx(t.ChevronUp,{size:j?.fontSize??16,color:j?.color??"rgb(214, 51, 132)"}));var j;const v=u??(i=>e.jsx(t.ChevronDown,{size:i?.fontSize??16,color:i?.color??"rgb(214, 51, 132)"}))(p?.arrow??{}),D=e.jsxs("div",{style:{boxSizing:"border-box",border:f?"none":"1px solid #E4E7EC",borderRadius:f?0:"8px",overflow:"hidden",marginTop:f?0:"8px",display:"flex",flexDirection:"column",width:"100%",height:f?"100%":void 0,backgroundColor:"#FAFAFA"},children:[e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",padding:"6px 10px",borderBottom:"1px solid #E4E7EC",backgroundColor:"#FFFFFF",flexShrink:0},children:e.jsx("button",{onClick:()=>{b(e=>!e)},style:{background:"none",border:"none",cursor:"pointer",padding:"4px",borderRadius:"6px",color:"#475467",marginRight:"9px"},children:f?e.jsx(r.DefaultFullScreenCloseIcon,{}):e.jsx(r.DefaultFullScreenIcon,{})})}),e.jsx("div",{style:{flex:1,minHeight:0,height:"100%",overflow:"hidden"},children:e.jsx(S,{href:a,children:n,metaData:c,citationTitle:y,citationType:o,citationReason:s,isFullscreen:f})})]});return e.jsxs("span",{style:{display:"inline",...p.relativeWrapper||{}},children:[e.jsx("div",{style:{display:"inline",marginTop:0,...p.citationButtonWrapper||{}},children:e.jsxs("button",{type:"button",onClick:()=>x(e=>!e),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",...p.citationButton||{}},children:[c?.webGpt&&e.jsx(t.Globe,{size:p.arrow?.fontSize??"1em",color:p.arrow?.color??"#6D28D9",style:{display:"inline-block",width:"1em",height:"1em",marginRight:"3px",verticalAlign:"-0.125em",flexShrink:0}}),e.jsx("span",{children:_}),e.jsx("span",{style:{display:"inline-flex",alignItems:"center",marginLeft:c?.webGpt?"3px":void 0,verticalAlign:c?.webGpt?"-0.125em":void 0},children:m?w:v})]})}),m&&(f?e.jsx(l.Dialog,{open:f,onClose:()=>b(!1),maxWidth:!1,BackdropProps:{sx:{backgroundColor:"rgba(0, 0, 0, 0.6)",backdropFilter:"blur(4px)"}},PaperProps:{sx:{backgroundColor:"#FAFAFA",borderRadius:"16px",height:C,m:0,maxHeight:C,maxWidth:"95vw",overflow:"hidden",width:"95vw"}},children:D}):D)]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("@mui/material"),o=require("lucide-react"),n=require("react"),i=require("../../assests/svg/PdfViewerIcons.js"),r=require("./CompareContext.js"),a=require("./CitationRendererInner.js");const s="90vh",l={border:"1px solid #D0D5DD",borderRadius:"6px",background:"#FFFFFF",color:"#344054",cursor:"pointer",fontSize:"12px",fontWeight:600,padding:"3px 8px"};exports.default=({href:d,children:c,citationType:p,citationReason:x,metaData:u,chevronUpComponent:g=null,chevronDownComponent:h=null,customStyle:b={},defaultState:f=!1,onFullscreenChange:m,onDemandCitationContext:C})=>{const y=r.useOptionalCompareContext(),v=y?.onDemandCitationConfig,j=y?.getOnDemandCitationCacheEntry,w=y?.fetchOnDemandCitationContext,F=y?.onDemandCitationCacheVersion,[D,k]=n.useState(f),[S,z]=n.useState(!1),R="string"==typeof c&&c?.split("\n")?.length>1?c.split("\n").join(" "):c,A="string"==typeof c?c:c[0];n.useEffect(()=>{if(m?.(S),S)return()=>{m?.(!1)}},[S,m]);const G=n.useMemo(()=>C&&j?j(C):void 0,[j,F,C]),I=!!v?.enabled&&!!C,B="success"===G?.status&&G.data&&"object"==typeof G.data&&Object.keys(G.data).length>0,E=n.useMemo(()=>({...u,citations:I?B?G?.data:{}:u?.citations}),[B,I,u,G?.data]),W=I&&(!G||"loading"===G.status)&&!B,q=I&&"error"===G?.status&&!B,P=I&&"success"===G?.status&&!B,O=!I||B,T=n.useCallback(()=>{v?.enabled&&C&&w&&("loading"===G?.status||"success"===G?.status&&B||w(C).catch(e=>{v.debug&&console.error("[CognitiveCompare:onDemandCitations] citation fetch failed",e)}))},[w,B,G?.status,v,C]),M=g??(U=b?.arrow??{},e.jsx(o.ChevronUp,{size:U?.fontSize??16,color:U?.color??"rgb(214, 51, 132)"}));var U;const H=h??(t=>e.jsx(o.ChevronDown,{size:t?.fontSize??16,color:t?.color??"rgb(214, 51, 132)"}))(b?.arrow??{}),L=t=>e.jsx("button",{type:"button",onClick:e=>{e.stopPropagation(),T()},style:{...l,...t},children:"Retry"}),V=e.jsxs("div",{style:{boxSizing:"border-box",border:S?"none":"1px solid #E4E7EC",borderRadius:S?0:"8px",overflow:"hidden",marginTop:S?0:"8px",display:"flex",flexDirection:"column",width:"100%",height:S?"100%":void 0,backgroundColor:"#FAFAFA"},children:[e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",padding:"6px 10px",borderBottom:"1px solid #E4E7EC",backgroundColor:"#FFFFFF",flexShrink:0},children:e.jsx("button",{onClick:()=>{z(e=>!e)},style:{background:"none",border:"none",cursor:"pointer",padding:"4px",borderRadius:"6px",color:"#475467",marginRight:"9px"},children:S?e.jsx(i.DefaultFullScreenCloseIcon,{}):e.jsx(i.DefaultFullScreenIcon,{})})}),e.jsxs("div",{style:{flex:1,minHeight:0,height:"100%",overflow:"hidden"},children:[W&&e.jsx("div",{style:{padding:"12px",fontSize:"13px",color:"#475467"},children:"Loading citation details..."}),q&&e.jsxs("div",{style:{padding:"12px",fontSize:"13px",color:"#B42318",display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"},children:[e.jsx("span",{children:"Unable to load citation details. Please try again later."}),L({border:"1px solid #FDA29B",color:"#B42318"})]}),P&&e.jsxs("div",{style:{padding:"12px",fontSize:"13px",color:"#475467",display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"},children:[e.jsx("span",{children:"Citation details are not available for this source."}),L()]}),O&&e.jsx(a.default,{href:d,children:c,metaData:E,citationTitle:A,citationType:p,citationReason:x,isFullscreen:S})]})]});return e.jsxs("span",{style:{display:"inline",...b.relativeWrapper||{}},children:[e.jsx("div",{style:{display:"inline",marginTop:0,...b.citationButtonWrapper||{}},children:e.jsxs("button",{type:"button",onClick:()=>{k(e=>{const t=!e;return t&&T(),t})},style:{display:u?.webGpt?"inline":"inline-flex",alignItems:u?.webGpt?void 0:"center",gap:u?.webGpt?void 0:"3px",fontFamily:'"Inter", sans-serif',backgroundColor:"transparent",padding:0,margin:0,fontSize:"13px",borderRadius:9999,cursor:"pointer",fontWeight:u?.webGpt?600:700,color:u?.webGpt?"#6D28D9":"rgb(214, 51, 132)",border:"none",textDecoration:"none",wordBreak:"break-word",whiteSpace:"normal",...b.citationButton||{}},children:[u?.webGpt&&e.jsx(o.Globe,{size:b.arrow?.fontSize??"1em",color:b.arrow?.color??"#6D28D9",style:{display:"inline-block",width:"1em",height:"1em",marginRight:"3px",verticalAlign:"-0.125em",flexShrink:0}}),e.jsx("span",{children:R}),e.jsx("span",{style:{display:"inline-flex",alignItems:"center",marginLeft:u?.webGpt?"3px":void 0,verticalAlign:u?.webGpt?"-0.125em":void 0},children:D?M:H})]})}),D&&(S?e.jsx(t.Dialog,{open:S,onClose:()=>{z(!1),m?.(!1)},maxWidth:!1,BackdropProps:{sx:{backgroundColor:"rgba(0, 0, 0, 0.6)",backdropFilter:"blur(4px)"}},PaperProps:{sx:{backgroundColor:"#FAFAFA",borderRadius:"16px",height:s,m:0,maxHeight:s,maxWidth:"95vw",overflow:"hidden",width:"95vw"}},children:V}):V)]})};
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","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":"ozBA2DA,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,EAE3BnB,EAAWC,eAAqD,iBAA7BD,EAAWC,gBAC9CD,EAAWC,cAAckB,kBAAoBA,KAUjDE,CAAwBrB,EAAYmB,GAC7BA,GA0CLG,EAAsB,EACxBC,WACAC,gBAAe,MAKT,MAAAC,qBAAEA,GAAyBC,EAAAA,oBAC3BC,EAA+BC,EAAAA,QACjC,IA/F4B,CAChCH,IACwB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Y,sBACZ1D,gBAAiB,cACjBD,QAAS,EACT4D,OAAQ,EACR5C,SAAU,OACVd,aAAc,KACd8C,OAAQ,UACRa,WAAa9N,GAAUY,OAAU,IAAM,IACvCsK,MAAQlL,GAAUY,OAAU,UAAY,oBACxC4L,OAAQ,OACRuB,eAAgB,OAChBC,UAAW,aACXC,WAAY,YACR1C,EAAY2C,gBAAkB,CAAC,GAGtCpE,SAAA,CAAA9J,GAAUY,QACPqE,EAAAA,IAACkJ,EAAAA,MAAA,CACGjC,KAAMX,EAAYU,OAAOhB,UAAY,MACrCC,MAAOK,EAAYU,OAAOf,OAAS,UACnCL,MAAO,CACHE,QAAS,eACT2B,MAAO,MACP5B,OAAQ,MACRoC,YAAa,MACbkB,cAAe,WACfvB,WAAY,KAIpB5H,EAAAA,IAAC,QAAM6E,SAAqB+B,IAEhC5G,EAAAA,IAAC,OAAA,CACG4F,MAAO,CACHE,QAAS,cACT2C,WAAY,SACZW,WAAYrO,GAAUY,OAAS,WAAQ,EACvCwN,cAAepO,GAAUY,OAAS,gBAAa,GAGlDkJ,WACKkC,EACAG,SAOjBT,IACGzL,EACIgF,EAAAA,IAACqJ,EAAAA,OAAA,CACGC,KAAMtO,EACNuO,QAAS,IAAM5C,GAAgB,GAC/B6C,UAAU,EACVC,cAAe,CACX1E,GAAI,CACAE,gBAAiB,qBACjByE,eAAgB,cAGxBC,WAAY,CACR5E,GAAI,CACAE,gBAAiB,UACjBC,aAAc,OACdW,OAAQhM,EACR+P,EAAG,EACHC,UAAWhQ,EACX2P,SAAU,OACVpE,SAAU,SACVqC,MAAO,SAId5C,SAAAuC,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","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":"ySA0CA,MAAMA,EAAoC,OAEpCC,EAAwC,CAC1CC,OAAQ,oBACRC,aAAc,MACdC,WAAY,UACZC,MAAO,UACPC,OAAQ,UACRC,SAAU,OACVC,WAAY,IACZC,QAAS,2BAGyC,EAClDC,OACAC,WACAC,eACAC,iBACAC,WACAC,qBAAqB,KACrBC,uBAAuB,KACvBC,cAAc,CAAC,EACfC,gBAAe,EACfC,qBACAC,8BAEA,MAAMC,EAAiBC,EAAAA,4BACjBC,EAAyBF,GAAgBE,uBACzCC,EAAgCH,GAAgBG,8BAChDC,EAA+BJ,GAAgBI,6BAC/CC,EAA+BL,GAAgBK,8BAC9CC,EAAYC,G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F,SAAA,CAAAG,GAAUqF,QACPtC,EAAAA,IAAC6C,EAAAA,MAAA,CACG3C,KAAM9C,EAAY2C,OAAOrD,UAAY,MACrCF,MAAOY,EAAY2C,OAAOvD,OAAS,UACnC+D,MAAO,CACHU,QAAS,eACTE,MAAO,MACPC,OAAQ,MACRM,YAAa,MACboB,cAAe,WACftB,WAAY,KAIxBxB,EAAAA,IAAC,QAAMlD,SAAqBqB,IAE5B6B,EAAAA,IAAC,OAAA,CACGO,MAAO,CACHU,QAAS,cACTc,WAAY,SACZgB,WAAY9F,GAAUqF,OAAS,WAAQ,EACvCQ,cAAe7F,GAAUqF,OAAS,gBAAa,GAGlDxF,WACKgD,EACAK,SAIjBrC,IACGG,EACI+B,EAAAA,IAACgD,EAAAA,OAAA,CACGC,KAAMhF,EACNiF,QAAS,KACLhF,GAAgB,GAChBZ,KAAqB,IAEzB6F,UAAU,EACVC,cAAe,CACXC,GAAI,CACAhC,gBAAiB,qBACjBiC,eAAgB,cAGxBC,WAAY,CACRF,GAAI,CACAhC,gBAAiB,UACjB/E,aAAc,OACd8E,OAAQjF,EACRqH,EAAG,EACHC,UAAWtH,EACXgH,SAAU,OACVpC,SAAU,SACVI,MAAO,SAIdrE,SAAA8D,IAGLA"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("@mui/material"),n=require("react-markdown"),o=require("rehype-raw"),i=require("./CitationAnchor.js"),a=require("./Guidelines/utils/helper.js");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=s(n),l=s(o);const u=e=>e?`./dual-citation?citationNumber=${encodeURIComponent(e)}`:"";exports.default=function({content:n="",title:o="",citations:s={},styles:d={},docData:x={},deviationData:p=null,open:h,onCitationFullscreenChange:m}){const f=t.useMemo(()=>JSON.stringify(s||{}),[s]),y=t.useMemo(()=>s,[f]),g=t.useMemo(()=>JSON.stringify(x||{}),[x]),j=t.useMemo(()=>x,[g]),b=t.useMemo(()=>({citations:y,docData:j}),[y,j]),M=t.useMemo(()=>{const e=p?.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})(p,t);return r&&(e[t]=r),e},{})},[p]),D=t.useMemo(()=>a.mergeRulebookCitationsIntoMatchingLinks(n),[n]),w=t.useMemo(()=>({a:({href:t="",children:r,type:n,reason:o,...a})=>{const s=a?.["data-cognitive-reasoning"],c=(l=a?.["dual-citation"],!0===l||"true"===l);var l;const d=c&&s?M[String(s)]:null;return e.jsx(i.default,{href:c?u(String(s||"")):t,children:r,citationType:c?"dual_citation":n,citationReason:o,metaData:{...b,...d?{webGpt:d}:{}},customStyle:d?{arrow:{color:"#6D28D9"}}:{},onFullscreenChange:m})}}),[b,M,m]);return e.jsxs(r.Box,{sx:{borderRadius:"8px",border:"1px solid #E4E7EC",bgcolor:"#FCFCFD"},children:[e.jsx(r.Box,{sx:{px:1.5,py:.75,borderBottom:"1px solid #EAECF0"},children:e.jsx(r.Typography,{sx:{fontSize:"15px",fontWeight:600,color:"#344054",lineHeight:1.25},children:o})}),e.jsx(r.Box,{sx:{px:1.5,py:1.1,display:"flex",flexDirection:"column",gap:.95},children:e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column"},children:e.jsx(r.Typography,{component:"div",sx:{...d},children:e.jsx(c.default,{components:w,rehypePlugins:[l.default],children:D})})})})]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),n=require("@mui/material"),o=require("react-markdown"),i=require("rehype-raw"),r=require("./CitationAnchor.js"),a=require("./Guidelines/utils/helper.js"),s=require("./CompareContext.js"),c=require("./onDemandCitations/contextBuilder.js"),u=require("./onDemandCitations/href.js");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=d(o),p=d(i);const x=e=>e?`./dual-citation?citationNumber=${encodeURIComponent(e)}`:"";exports.default=function({content:o="",title:i="",citations:d={},styles:m={},docData:C={},deviationData:f=null,open:h,onCitationFullscreenChange:y,tabKey:D,sectionTitle:g,referenceSectionTitle:b,sourceNodeId:j,deviationKey:M,baseContentId:v,compareContentIds:q}){const w=s.useOptionalCompareContext(),I=w?.treeData,S=w?.onDemandCitationConfig,O=t.useMemo(()=>JSON.stringify(d||{}),[d]),T=t.useMemo(()=>d,[O]),_=t.useMemo(()=>JSON.stringify(C||{}),[C]),k=t.useMemo(()=>C,[_]),B=t.useMemo(()=>({citations:T,docData:k}),[T,k]),F=t.useMemo(()=>{if(!S?.enabled)return new Map;return c.buildOnDemandCitationContexts({treeData:I,content:o,requestId:S.requestId,tabKey:D,popupNodeId:j||f?.nodeId,deviationKey:M,sectionTitle:g,referenceSectionTitle:b,docData:k,staticCitations:T,deviationData:f,cognitiveData:null,baseContentId:v,compareContentIds:q}).reduce((e,t)=>(e.set(u.getOnDemandCitationLinkKey(t.href),t),e),new Map)},[v,q,o,f,M,S,b,g,j,T,k,D,I]),K=t.useMemo(()=>{const e=f?.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})(f,t);return n&&(e[t]=n),e},{})},[f]),E=t.useMemo(()=>a.mergeRulebookCitationsIntoMatchingLinks(o),[o]),N=t.useMemo(()=>({a:({href:t="",children:n,type:o,reason:i,...a})=>{const s=a?.["data-cognitive-reasoning"],c=(d=a?.["dual-citation"],!0===d||"true"===d);var d;const l=c&&s?K[String(s)]:null;return e.jsx(r.default,{href:c?x(String(s||"")):t,children:n,citationType:c?"dual_citation":o,citationReason:i,onDemandCitationContext:c?void 0:F.get(u.getOnDemandCitationLinkKey(t)),metaData:{...B,...l?{webGpt:l}:{}},customStyle:l?{arrow:{color:"#6D28D9"}}:{},onFullscreenChange:y})}}),[F,B,K,y]);return e.jsxs(n.Box,{sx:{borderRadius:"8px",border:"1px solid #E4E7EC",bgcolor:"#FCFCFD"},children:[e.jsx(n.Box,{sx:{px:1.5,py:.75,borderBottom:"1px solid #EAECF0"},children:e.jsx(n.Typography,{sx:{fontSize:"15px",fontWeight:600,color:"#344054",lineHeight:1.25},children:i})}),e.jsx(n.Box,{sx:{px:1.5,py:1.1,display:"flex",flexDirection:"column",gap:.95},children:e.jsx(n.Box,{sx:{display:"flex",flexDirection:"column"},children:e.jsx(n.Typography,{component:"div",sx:{...m},children:e.jsx(l.default,{components:N,rehypePlugins:[p.default],children:E})})})})]})};
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","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":"8WA2BA,MAEMA,EAAyBC,GAC3BA,EAAc,kCAAkCC,mBAAmBD,KAAiB,mBAoBxF,UAA0BE,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,UAAQ,IAAMC,KAAKC,UAAUT,GAAa,IAAK,CAACA,IACrEU,EAAkBH,EAAAA,QACpB,IAAMP,EACN,CAACM,IAGCK,EAAmBJ,UAAQ,IAAMC,KAAKC,UAAUP,GAAW,IAAK,CAACA,IACjEU,EAAgBL,EAAAA,QAClB,IAAML,EACN,CAACS,IAGCE,EAAiBN,EAAAA,QACnB,KAAA,CAASP,UAAWU,EAAiBR,QAASU,IAC9C,CAACF,EAAiBE,IAGhBE,EAA0BP,EAAAA,QAAQ,KACpC,MAAMQ,EAAkBZ,GAAea,kBACjCC,EAAgBF,GAAiBE,eAAiB,GAExD,OAAOC,OAAOC,KAAKF,GAAeG,OAAO,CAACC,EAA0BzB,KAC1D,MAAA0B,EArDkB,EAChCnB,EACAP,KAEA,IAAKO,IAAkBP,EAAoB,OAAA,KAE3C,MAAMmB,EAAkBZ,GAAea,kBACjCC,EAAgBF,GAAiBE,gBAAgBrB,GACvD,OAAKmB,GAAoBE,EAElB,CACHrB,cACA2B,WAAYpB,EACZY,kBACAE,iBAN2C,MA6CVO,CAA4BrB,EAAeP,GAEjE,OADH0B,IAA0BD,EAAAzB,GAAe0B,GACtCD,GACR,CAAE,IACN,CAAClB,IAEEsB,EAAmBlB,EAAAA,QACrB,IAAMmB,EAAAA,wCAAwC5B,GAC9C,CAACA,IAGC6B,EAAapB,EAAAA,QAAQ,KAChB,CACHqB,EAAG,EAAGC,OAAO,GAAIC,WAAUC,OAAMC,YAAWC,MAClC,MAAArC,EAAcqC,IAAQ,4BACtBC,GAzEEC,EAyEqCF,IAAQ,kBAzEhB,IAAVE,GAA4B,SAAVA,GAAtC,IAACA,EA0ER,MAAMb,EACFY,GAAyBtC,EACnBkB,EAAwBsB,OAAOxC,IAC/B,KAEN,OAAAyC,EAAAA,IAACC,EAAA,QAAA,CACGT,KAAMK,EAAwBvC,EAAsByC,OAAOxC,GAAe,KAAOiC,EACjFC,WACAS,aAAcL,EAAwB,gBAAkBH,EACxDS,eAAgBR,EAChBS,SAAU,IACH5B,KACCS,EAAuB,CAAEoB,OAAQpB,GAAyB,CAAC,GAEnEqB,YACIrB,EACA,CACIsB,MAAO,CACHC,MAAO,YAEX,CAAC,EAETC,mBAAoBzC,OAKrC,CAACQ,EAAgBC,EAAyBT,IAGzC,OAAA0C,EAAAA,KAACC,EAAAA,IAAA,CACGC,GAAI,CACAC,aAAc,MACdC,OAAQ,oBACRC,QAAS,WAGbtB,SAAA,CAAAO,EAAAA,IAACW,EAAAA,IAAA,CACGC,GAAI,CAAEI,GAAI,IAAKC,GAAI,IAAMC,aAAc,qBAEvCzB,SAAAO,EAAAA,IAACmB,EAAAA,WAAA,CACGP,GAAI,CACAQ,SAAU,OACVC,WAAY,IACZb,MAAO,UACPc,WAAY,MAGf7B,SAAA/B,MAGTsC,EAAAA,IAACW,EAAAA,IAAA,CACGC,GAAI,CACAI,GAAI,IACJC,GAAI,IACJM,QAAS,OACTC,cAAe,SACfC,IAAK,KAGThC,SAAAO,EAAAA,IAACW,OAAIC,GAAI,CAAEW,QAAS,OAAQC,cAAe,UACvC/B,SAAAO,EAAAA,IAACmB,EAAAA,WAAA,CACGO,UAAU,MACVd,GAAI,IAAKhD,GAET6B,eAACkC,EAAc,QAAA,CAAArC,aAAwBsC,cAAe,CAACC,WAClDpC,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","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":"2eAuCA,MAEMA,EAAyBC,GAC3BA,EAAc,kCAAkCC,mBAAmBD,KAAiB,mBAoBxF,UAA0BE,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,aACAA,EAAAC,cACAA,EAAAC,kBACAA,IAEA,MAAMC,EAAiBC,EAAAA,4BACjBC,EAAWF,GAAgBE,SAC3BC,EAAyBH,GAAgBG,uBAIzCC,EAAqBC,UAAQ,IAAMC,KAAKC,UAAUpB,GAAa,IAAK,CAACA,IACrEqB,EAAkBH,EAAAA,QACpB,IAAMlB,EACN,CAACiB,IAGCK,EAAmBJ,UAAQ,IAAMC,KAAKC,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YAMxB"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("@mui/material"),i=require("react"),a=require("react-markdown"),r=require("rehype-raw"),n=require("../PdfViewer/PdfViewer.js"),l=require("./CompareContext.js"),o=require("./CognitiveCompareConfig.js"),s=require("./GptWebCitationPanel.js"),u=require("./Guidelines/utils/processGuidelinesMarkdown.js"),d=require("./ResizableSplitPane.js");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var g=c(a),h=c(r);const p=({label:t})=>e.jsxs("div",{style:{padding:"12px",fontSize:"13px",color:"#475467",lineHeight:1.5},children:["Citation text was returned for ",t,", but a signed PDF URL is not available."]}),m=e=>({...e?.customMetaData||{},...e?.custom_metadata||{}}),f=(e,t)=>{const i=m(e);return i.signed_url||i.signedUrl||t?.signed_url||t?.signedUrl||t?.metadata?.signed_url||t?.metadata?.signedUrl||""},_=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}}},x=t=>e.jsx("div",{style:{height:"100%",display:"flex",flexDirection:"column"},children:t});exports.default=({href:a,metaData:r,citationTitle:c,citationType:b,citationReason:j,isFullscreen:P})=>{const{guidelinesData:F}=l.useCompareContext(),{citationNumber:y,phraseToHighlight:C,citationTypeFromHref:w}=_(a),D=b||w||void 0,v="il_rulebook_citation"===D?"rulebook_citation":D,N=y&&r?.citations?.[y]||{},T=r?.docData?.documents||{},U=r?.docData?.input_index_map||{},H=Object.keys(r?.citations||{}).length>0||Object.keys(r?.docData||{}).length>0,k=U?.[0],q=U?.[1],R=k?T[k]:null,M=q?T[q]:null,S=k?N[k]:null,A=q?N[q]:null,G=m(S),O=m(A),L=f(S,R),V=f(A,M),W=i.useMemo(()=>S&&R?L?e.jsx(n.default,{defaultScale:"PageWidth",showFullScreenAction:!1,showHighlightsAction:!1,pdfName:R?.title,pdfUrl:L,highlightText:[S?.highlighted_text??""],highlightPages:{1:G?.pdf_start_page_number},jumpToPageValue:1,highlightCordinatePages:[],useCoordinates:!1,useRange:!0,rangeOfPages:[G?.pdf_start_page_number,G?.pdf_end_page_number]}):e.jsx(p,{label:"the uploaded contract"}):null,[S,G,R,L]),z=i.useMemo(()=>A&&M?V?e.jsx(n.default,{defaultScale:"PageWidth",showFullScreenAction:!1,showHighlightsAction:!1,pdfName:M?.title,pdfUrl:V,jumpToPageValue:1,highlightText:[A?.highlighted_text??""],highlightPages:{1:O?.pdf_start_page_number},highlightCordinatePages:[],useCoordinates:!1,useRange:!0,rangeOfPages:[O?.pdf_start_page_number,O?.pdf_end_page_number]}):e.jsx(p,{label:"the reference contract"}):null,[A,O,M,V]),E="dual_citation"===v,B=E&&!!r?.webGpt,K=i.useMemo(()=>{const i=B?e.jsx(s.default,{metaData:r,isFullscreen:P}):"rulebook_citation"===v?e.jsx(t.Box,{sx:{padding:"0px 20px",backgroundColor:"#FFFFFF",borderRadius:"8px",...o.SHARED_MARKDOWN_STYLES,overflow:"auto"},children:e.jsx(g.default,{rehypePlugins:[h.default],children:u.processGuidelinesMarkdown({guidelinesData:F,targetHighlights:[C],labelColor:"#FEF08A"})})}):z;return W||i?!W&&i?e.jsx(d.default,{rightComponent:i,isFullscreen:P}):W&&!i?e.jsx(d.default,{leftComponent:W,isFullscreen:P}):e.jsx(d.default,{leftComponent:W,rightComponent:i,isFullscreen:P}):null},[W,z,v,B,r,P,F,C]);return r?.webGpt&&!H?e.jsx(s.default,{metaData:r,isFullscreen:P}):y?"rulebook_citation"===v?K?x(K):e.jsx("div",{style:{padding:"12px",fontSize:"13px",color:"#344054",lineHeight:1.5},children:j||"Rulebook citation selected."}):E?K?x(K):r?.webGpt?e.jsx(s.default,{metaData:r,isFullscreen:P}):e.jsx("div",{children:"Missing PDF Citation. Please try again later"}):["contract","clause"].includes(c)?K?x(K):e.jsx("div",{children:"Missing PDF Citation. Please try again later"}):e.jsx("div",{children:"No Citation Found. Please try again later"}):null};
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","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":"4hBAqBA,MAAMA,EAAsB,EAAGC,kBAC1B,MAAI,CAAAC,MAAO,CAAEC,QAAS,OAAQC,SAAU,OAAQC,MAAO,UAAWC,WAAY,KAAOC,SAAA,CAAA,kCAClDN,EAAM,8CAIxCO,EAA6BC,IAAmB,IAC9CA,GAAUC,gBAAkB,CAAC,KAC7BD,GAAUE,iBAAmB,CAAC,IAGhCC,EAAkB,CAACH,EAAeI,KAC9B,MAAAC,EAAiBN,EAA0BC,GACjD,OACIK,EAAeC,YACfD,EAAeE,WACfH,GAAUE,YACVF,GAAUG,WACVH,GAAUI,UAAUF,YACpBF,GAAUI,UAAUD,WACpB,IAIFE,EACFC,IAmCI,IACA,MAAMC,eAAEA,EAAAC,UAAgBA,GA9BL,CAACC,IACd,MAAAC,EAAwBD,EAAME,MAAM,8CAC1C,GAAID,EACI,IACM,MAAAE,EAAkBH,EAAMI,QAAQ,KAChCC,EAASF,GAAmB,EAAIH,EAAMM,MAAMH,GAAmB,GAC9D,MAAA,CACHL,eAAgBG,EAAsB,GACtCF,UAAW,IAAIQ,IAAIF,GAAU,KAAMG,OAAOC,SAASC,QACvD,CACI,MACG,MAAA,CACHZ,eAAgBG,EAAsB,GACtCF,UAAW,KAEnB,CAGA,IACA,MAAMA,EAAY,IAAIQ,IAAIP,EAAOQ,OAAOC,SAASC,QAI1C,MAAA,CAACZ,eAFJC,EAAUY,aAAaC,IAAI,mBAC3Bb,EAAUY,aAAaC,IAAI,mBACPb,YAAS,CAC7B,MACJ,MAAO,CAACD,eAAgB,KAAMC,UAAW,KAC7C,GAIsCc,CAAehB,GAC/CiB,EAAoBf,GAAWY,aAAaC,IAAI,wBAA0B,KAEzE,MAAA,CAACd,iBAAgBgB,oBAAmBC,qBADdhB,GAAWY,aAAaC,IAAI,kBAAoB,KACd,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iBAMRT,EAAAA,IAACwE,EAAA,QAAA,CACGtC,gBACAmB,eAAgBK,EAChBjD,iBAxBiC,MA2B1C,CAACyB,EAAemB,EAAgBxC,EAAwB0C,EAAsBlD,EAAUI,EAAcC,EAAgBd,IAErH,OAAAS,GAAUmD,SAAWpC,EACdpB,EAAAA,IAAC2D,EAAoB,QAAA,CAAAtD,WAAoBI,iBAG/C7B,EAE0B,sBAA3BiC,EACI4C,EAA2B3D,EAAoB2D,GAG9CzD,EAAAA,IAAA,MAAA,CAAItC,MAAO,CAAEC,QAAS,OAAQC,SAAU,OAAQC,MAAO,UAAWC,WAAY,KAC1EC,YAAkB,gCAK3BuF,EACIG,EAA2B3D,EAAoB2D,GAC/CpD,GAAUmD,OAAgBxD,EAAAA,IAAA2D,EAAA,QAAA,CAAoBtD,WAAoBI,iBAC/DT,EAAAA,IAAC,OAAIjC,SAA4C,iDAnJnC,CAAC,WAAY,UAsJjB0G,SAASnE,GACtBmD,EAA2B3D,EAAoB2D,GAC5CzD,EAAAA,IAAC,OAAIjC,SAA4C,iDAGrDiC,EAAAA,IAAC,OAAIjC,SAAyC,8CAvBzB"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),n=require("@mui/material"),i=require("lucide-react"),o=require("../../assests/svg/ButtonCognitiveIcon.js"),r=require("./OverlayComponent.js"),s=require("./CognitiveComparehelpers.js"),l=require("./CognitiveCompareConfig.js"),c=require("./CognitiveCompareConstants.js"),a=require("./CognitivePopup.js"),u=require("./MoreFunctionsPopup.js"),d=require("./LoaderComponent.js"),f=require("./components/ThreeDotsLoader.js"),p=require("./hooks/useCompareData.js"),g=require("./hooks/useComparePopups.js"),h=require("./hooks/useSectionRefs.js"),m=require("./hooks/useAccordionState.js"),S=require("./hooks/useDeviationNavigation.js"),R=require("./components/CompareHeader.js"),x=require("./components/SubSectionAccordion.js"),v=require("./components/LHSSectionRow.js"),y=require("./components/RHSSectionRow.js"),b=require("./components/CognitiveSummaryPopup.js"),C=require("./CompareContext.js"),E=require("./hooks/useStyles.js"),A=require("./hooks/useResizeHandler.js"),_=require("./hooks/useLinesCalculator.js"),T=require("./hooks/useSideBySide.js"),I=require("./components/SvgConnectors.js"),w=require("./Guidelines/components/GuidelinePanel.js"),B=require("./Guidelines/components/WebGptPanel.js");exports.SHARED_MARKDOWN_STYLES=l.SHARED_MARKDOWN_STYLES,exports.default=({componentHeaderText:D=c.DEFAULT_COMPONENT_HEADER_TEXT,treeData:O,comparisonConfig:F,leftColumnTitleText:j,rightColumnTitleText:P,markdownStyles:k,resetTrigger:N,displayConfig:M={isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1,displayEmailNotifier:!0,isStreamingEnabled:!1},onMaintainRelativeOrderChange:L,popupConfig:q,deviationData:$={},deviationNodeIdToView:H,resetDeviationNodeId:G,isProposingFix:V=!1,proposingFixNodeId:W,isRedlineFlow:z,badgeStyleOverride:K,guidelinesData:U,gptWebCitationConfig:Y})=>{const[J,X]=t.useState(M.maintainRelativeOrder),Q=M?.expandLevels??0,Z=!!M?.expandAllSections,ee=!!J||!!M?.showDeviationBadges,[te,ne]=t.useState(!1),[ie,oe]=t.useState(null),[re]=t.useState(O?.newEvaluationResult??M?.enableDeviationSchemaBackwardCompatibility??!0),[se,le]=t.useState(new Set),[ce,ae]=t.useState([]),[ue,de]=t.useState(!1),[fe,pe]=t.useState(0),ge=t.useRef(null),he=t.useRef(null),me=t.useRef(null),Se=t.useRef(null),Re=t.useRef(null),xe=t.useRef(!1),ve=t.useRef(null),ye=t.useRef({}),be=t.useRef([]),Ce=t.useRef(()=>{}),Ee=t.useRef(null),Ae=t.useRef(()=>{}),_e=t.useMemo(()=>JSON.stringify($||{}),[JSON.stringify($)]),Te=t.useMemo(()=>$||{},[_e]),Ie=t.useMemo(()=>O?.cognitive_decisioning||{},[O]),we=t.useMemo(()=>({...l.SHARED_MARKDOWN_STYLES,...k}),[k]),Be=t.useRef(null),De=t.useRef(null),Oe=t.useRef(null),Fe=t.useRef(null),je=t.useRef(null),Pe=t.useRef(null),ke=t.useRef(null),Ne=t.useRef(null),Me=t.useRef(null),Le=t.useRef(null),{cognitivePopup:qe,setCognitivePopup:$e,moreFunctions:He,setMoreFunctions:Ge,position:Ve,setPosition:We,activeBadgeId:ze,summaryPopup:Ke,setSummaryPopup:Ue,closeSummaryPopup:Ye,setActiveBadgeId:Je,popupRef:Xe,handleOpenCognitiveCompare:Qe,openCognitivePopupFromState:Ze,closeCognitivePopup:et,closeMoreFunctionsPopup:tt}=g.useComparePopups(Be),nt=t.useMemo(()=>({fields:F?.fields??l.DEFAULT_FIELD_CONFIG,thresholds:{high:F?.thresholds?.high??l.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:F?.thresholds?.medium??l.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:F?.thresholds?.exact??l.DEFAULT_COMPARISON_CONFIG.thresholds.exact}}),[F]),[it,ot]=t.useState(null),rt=O?.documents?.[O?.input_index_map?.[0]]?.title,st=O?.documents?.[O?.input_index_map?.[1]]?.title,lt=s.safeStringify(j||rt||"Uploaded Contract"),ct=O?.documents?.[O?.input_index_map?.[0]]?.metadata?.file_name,at=s.safeStringify(ct),ut=O?.documents?.[O?.input_index_map?.[1]]?.metadata?.file_name,dt=s.safeStringify(ut),ft=s.safeStringify(P||st||"Reference Template"),{isGuidelineMode:pt,activeProposed:gt,existingRule:ht,proposedSections:mt,existingSections:St,visibleFields:Rt,parentDeviationRecord:xt,deviationNumberRegistry:vt,deviationParentRegistry:yt,parseError:bt}=p.useCognitiveTreeData(O,J,Te,nt,re,U);t.useEffect(()=>{bt&&oe(`Failed to load comparison: ${bt}`)},[bt]);const Ct=mt.length>0||St.length>0,Et=t.useMemo(()=>{if(!z)return"off";let e=0,t=0;const n=i=>{Array.isArray(i)&&i.forEach(i=>{const o=i?.content||"";s.hasMeaningfulRedlineTags(o)&&(e+=1,t+=String(o).length),i?.subsections?.length&&n(i.subsections)})};return n(mt),n(St),`${e}:${t}`},[z,mt,St]);t.useEffect(()=>{if(mt.length||St.length)if(Z){const e={},t={},n=(n,i)=>{n.forEach((n,o)=>{const r=J?`${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(mt,"left"),n(St,"right"),cn(e),un(t)}else if(Q>0){const e={},t={},n=(n,i,o)=>{n.forEach((n,r)=>{if(o>=1){const t=J?`${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(mt,"left",Q),n(St,"right",Q),cn(e),un(t)}},[Z,Q,mt,St,J]);const{leftRefs:At,rightRefs:_t,sectionLeftRefs:Tt,sectionRightRefs:It,lhsBadgeRefs:wt,rhsBadgeRefs:Bt,sectionRightRowRefs:Dt,subSectionLeftRefs:Ot,subSectionRightRefs:Ft,sectionRowRefs:jt,getSectionRowRef:Pt,getSubSectionRef:kt,getBadgeRef:Nt}=h.useSectionRefs(Rt.map(({key:e})=>e),Math.max(mt.length,St.length)),{isSideBySide:Mt,isArrowVisible:Lt,setIsSideBySide:qt,setIsArrowVisible:$t,isResizing:Ht,setIsResizing:Gt,isSideBySideLoading:Vt,setIsSideBySideLoading:Wt,activeSideBySideSection:zt,setActiveSideBySideSection:Kt,scrollLock:Ut,sideBySideCacheRef:Yt,isSideBySideRef:Jt,activeSideBySideRightSectionRef:Xt,activeSideBySideSectionRef:Qt,sideBySideLineRef:Zt,highlightedClauseRefs:en,clearClauseHighlight:tn,applyAlignmentPadding:nn,resetSideBySide:on,activateSideBySide:rn}=T.useSideBySide({isGuidelineMode:pt,maintainRelativeOrder:J,proposedSections:mt,existingSections:St,leftContainerRef:Ne,rightContainerRef:Oe,scrollContainerRef:Be,sectionLeftRefs:Tt,sectionRightRefs:It,subSectionLeftRefs:Ot,subSectionRightRefs:Ft,lhsBadgeRefs:wt,rhsBadgeRefs:Bt,sectionRowRefs:jt,sectionRightRowRefs:Dt,rhsTopSpacerRef:Fe,rhsBottomSpacerRef:je,lhsTopSpacerRef:Pe,lhsBottomSpacerRef:ke,calculateLinesRef:Ce,setConnectedSections:le,setConnectedLines:ae,cachedConnectedPositions:be,closeMoreFunctionsPopup:tt,setErrorToast:oe,moreFunctions:He,closeSummaryPopup:Ye}),sn=t.useRef(rn);t.useEffect(()=>{sn.current=rn},[rn]);const{expandedSections:ln,setExpandedSections:cn,expandedSubSections:an,setExpandedSubSections:un,handleSubSectionToggle:dn,toggleSection:fn,forceExpandCrossWiredSections:pn}=m.useAccordionState({maintainRelativeOrder:!!J,proposedSections:mt,existingSections:St,activeSideBySideSection:zt,connectedSections:se,resetSideBySide:on,setConnectedSections:le,setConnectedLines:ae,cachedConnectedPositions:be,svgContainerRef:ge,isAnimatingRef:xe,animationTimerRef:ve,calculateLinesRef:Ce,sectionLeftRefs:Tt,sectionRightRefs:It,subSectionLeftRefs:Ot,subSectionRightRefs:Ft}),gn=()=>{if(null==zt)return;const e=Tt.current[zt]?.current,t=It.current[zt]?.current,n=Oe.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"})},hn=t.useCallback(e=>{e?.stopPropagation(),de(e=>{const t=!e;return t&&requestAnimationFrame(()=>{gn()}),t})},[gn]);t.useEffect(()=>{z&&"off"!==Et&&"0:0"!==Et&&(Yt.current=null,be.current=[],requestAnimationFrame(()=>{Ce.current?.()}))},[z,Et]);const mn=t.useMemo(()=>{const e=new Map,t=new Map;let n=1;if(J)mt.forEach(t=>{!t.title&&!t.content||t.id&&e.set(t.id,n++)}),St.forEach(i=>{if(!i.id)return;if(!i.title&&!i.content)return;const o=mt.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(mt.length,St.length);for(let o=0;o<i;o++){const i=mt[o],r=St[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}},[mt,St,J]),Sn=ht.analysis,Rn=s.safeStringify(Sn?.rule_difference_comparison?.summary?.overall_summary),xn=!!Rn.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),vn=O?.base_root_id??"-1",yn=re?($&&$?.[vn]?.evaluation_result)??O?.nodes?.[vn]?.evaluation_result??null:($&&$?.[vn]?.evaluation_result?.[0])??O?.nodes?.[vn]?.evaluation_result?.[0]??null,bn=s.extractDeviationScore(yn);let Cn=s.generateColorPalette(yn?.evaluation_outputs?.metadata?.label_color??c.DEFAULT_DEVIAION_COLOR);if(K){const e=K(bn);e&&(Cn={...Cn,badgeBg:e.bg,badgeText:e.text,badgeBorder:e.border})}const En=t.useRef(on);t.useEffect(()=>{En.current=on},[on]);const An=t.useRef(et);t.useEffect(()=>{An.current=et},[et]);const _n=t.useCallback((e,t,n,i,o,r)=>Fi.current(e,t,n,i,o,r),[]),Tn=t.useCallback((e,t,n,i,o)=>Pi.current(e,t,n,i,o),[]),In=t.useCallback(()=>ki.current(),[]),wn=t.useCallback((e,t)=>Ni.current(e,t),[]),Bn=t.useCallback(e=>Mi.current(e),[]),Dn=t.useCallback(e=>Li.current(e),[]),On=t.useCallback(()=>qi.current(),[]),Fn=t.useCallback(()=>{tn(),En.current?.(),de(!1),le(new Set),ae([]),be.current=[],Qn([]),ei(null),Ue(c.EMPTY_SUMMARY_POPUP_STATE),An.current?.(),requestAnimationFrame(()=>{Ce.current?.()})},[]),jn=t.useRef(Fn);t.useEffect(()=>{jn.current=Fn},[Fn]),t.useEffect(()=>{N&&jn.current()},[N]);const Pn=t.useMemo(()=>({documents:O?.documents,input_index_map:O?.input_index_map}),[JSON.stringify(O?.documents),JSON.stringify(O?.input_index_map)]),[kn,Nn]=t.useState(""),Mn=t.useRef(O);t.useEffect(()=>{Mn.current=O;const e=O?.input_index_map?.[0],t=O?.documents?.[e]?.title;Nn(t)},[O]);const Ln=t.useRef(Ie);t.useEffect(()=>{Ln.current=Ie},[Ie]);const qn=t.useCallback((e,t,n,i,o,r,l)=>{const c=s.safeStringify(t?.id)||s.safeStringify(n?.id)||"",a=(c?Ln.current?.[c]:null)||t?.cognitiveData||n?.cognitiveData||{section_id:c,decisioning:[],gap:[],relevance_score:0},u=jt.current[i]?.current??null,d=(()=>{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(s.DEVIATION_BADGE_SEPARATOR)))return o(e);const r=i.split(s.DEVIATION_BADGE_SEPARATOR)[1];if(!r)return e;const l=t?.evaluationResult||n?.evaluationResult||{},c=l?.deviation_entries?.[r]||l?.deviations?.[r]||null;return c?{...l,...c,deviation_summary:c?.deviation_summary||l?.deviation_summary,deviation_title:c?.deviation_title||l?.deviation_title,deviation_impact:c?.deviation_impact||l?.deviation_impact,deviation_explanation:c?.deviation_explanation||l?.deviation_explanation,evaluation_outputs:c?.evaluation_outputs||l?.evaluation_outputs,cognitive_decisioning:c?.cognitive_decisioning||l?.cognitive_decisioning}:o(e)})(),f=(d?.cognitive_decisioning?.decisioning_factors?.length??0)>0||(d?.cognitive_decisioning?.gaps_in_decision?.length??0)>0,p=M?.isLoading??!1;let g=!0;if(pt){const e=d?.deviation_highlights;if(e&&"object"==typeof e){g=Object.values(e).some(e=>Array.isArray(e)&&e.length>0)}else g=!1}return{isLoading:p&&!f,open:!0,sectionTitle:t?.title?t?.title:"No Counterpart",refSectionTitle:n?.title?n?.title:"No Counterpart",cognitiveData:a,anchorEl:e,sectionAnchorEl:u,badgeStyle:r||null,sectionIdx:i,docData:Pn,deviationData:d,isOrphan:!!o,hasGuidelineMatches:g}},[Pn,M?.isLoading,pt]),$n=t.useCallback((e,t,n,i,o,r)=>{if(e.stopPropagation(),He.open&&He.sectionIdx===o)return void tt();const l=e.currentTarget;let c="left";Oe.current?.contains(l)&&(c="right");tn(),Jt.current&&on(),le(new Set),ae([]),be.current=[],et(),Ke.open?hi():Ye(),requestAnimationFrame(()=>{const e=(()=>{if("string"==typeof o&&o.includes(s.DEVIATION_BADGE_SEPARATOR)){const e=o.split(s.DEVIATION_BADGE_SEPARATOR),t=`${e[0]}${s.DEVIATION_BADGE_SEPARATOR}${e[1]}`;return"right"===c?Bt.current[t]?.current:wt.current[t]?.current}return"right"===c?Bt.current[o]?.current:wt.current[o]?.current})()||l;Ge(qn(e,t,i,o,n,r))})},[He.open,He.sectionIdx,tt,Ye,qn]),Hn=t.useCallback(()=>{const e=He.sectionIdx;He.isOrphan,tt(),Ye(),null!==e&&(pn(e),tn(),Jt.current&&on(),ae([]),be.current=[],pt&&null!==e&&pe(fi(e)),le(t=>t.has(e)?new Set:new Set([e])),setTimeout(()=>{Ce.current&&Ce.current()},50))},[He.sectionIdx,He.isOrphan,tt,Ye,on]),Gn=t.useCallback(()=>{const e=Re.current;if(!e)return;Re.current=null;const t=mt.findIndex(t=>t.id===e),n=St.findIndex(t=>t.id===e),i=-1===t?s.findKeyPathByNodeId(mt,e):null,o=-1===n?s.findKeyPathByNodeId(St,e):null,r=-1!==t?t:i?Number(i.split("-")[0]):-1,l=-1!==n?n:o?Number(o.split("-")[0]):-1,c=(e,t,n,i)=>-1!==e?n.current[e]?.current??null:t?i.current[t]?.current??null:null,a=(e,t,n=30)=>{let i=0;const o=()=>{const r=e();r&&0!==r.getBoundingClientRect().height?(en.current.add(r),s.scrollAndHighlightClause(r,t)):i++<n&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(J)-1!==r&&Ne.current&&a(()=>c(t,i,Tt,Ot),Ne.current),-1!==l&&Oe.current&&a(()=>c(n,o,It,Ft),Oe.current);else{const e=Be.current;if(!e)return;a(()=>-1!==r?c(t,i,Tt,Ot):c(n,o,It,Ft),e)}},[mt,St,J,Tt,It,Ot,Ft,Ne,Oe,Be]),Vn=t.useCallback(e=>{if(!e)return;tn(),on(),le(new Set),ae([]),be.current=[],Ye(),et();const t=mt.findIndex(t=>t.id===e),n=St.findIndex(t=>t.id===e),i=-1===t?s.findKeyPathByNodeId(mt,e):null,o=-1===n?s.findKeyPathByNodeId(St,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,l=-1!==n?n:o?Number(o.split("-")[0]):-1;Re.current=e,cn(e=>{const t={...e};let n=!1;if(-1!==r){const e=J?`left-${r}`:String(r);t[e]||(t[e]=!0,n=!0)}if(-1!==l){const e=J?`right-${l}`:String(l);t[e]||(t[e]=!0,n=!0)}return n?t:e}),un(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(()=>{Re.current===e&&Wn.current()})},50)},[mt,St,J,cn,un,on,Ye,et]),Wn=t.useRef(Gn);t.useEffect(()=>{Wn.current=Gn},[Gn]);const zn=t.useRef(null);t.useEffect(()=>{if(it){const e=nt.fields.find(e=>e.analysisKey===it||e.key===it);if(e){const t=At.current[e.key]||_t.current[e.key];t?.current&&setTimeout(()=>t.current.scrollIntoView({behavior:"smooth",block:"center"}),150)}}},[it,nt.fields]);const Kn=t.useCallback(e=>{const t=Sn?.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}},[Sn]),{getSectionCompareStyle:Un,getSubSectionCompareStyle:Yn,getDeviationStyleByKey:Jn}=E.useStyleHelpers({proposedSections:mt,existingSections:St,maintainRelativeOrder:J,cognitiveMap:Ie,deviationData:Te,treeData:O,resolvedComparisonConfig:nt,badgeStyleOverride:K}),{lines:Xn,setLines:Qn,overallConnector:Zn,setOverallConnector:ei,svgDimensions:ti,calculateLines:ni,calculateLinesDebounced:ii,handleColumnScroll:oi}=_.useLinesCalculator({containerRef:he,leftContainerRef:Ne,rightContainerRef:Oe,svgContainerRef:ge,pathRefs:ye,leftHeaderRef:me,rightHeaderRef:Se,proposedSections:mt,existingSections:St,visibleFields:Rt,leftRefs:At,rightRefs:_t,sectionLeftRefs:Tt,sectionRightRefs:It,subSectionLeftRefs:Ot,subSectionRightRefs:Ft,lhsBadgeRefs:wt,rhsBadgeRefs:Bt,sectionRowRefs:jt,expandedSections:ln,expandedSubSections:an,connectedSections:se,isSideBySide:Mt,activeSideBySideSection:zt,maintainRelativeOrder:J,isGuidelineMode:pt,cognitiveMap:Ie,getSectionCompareStyle:Un,getSubSectionCompareStyle:Yn,getDeviationStyleByKey:Jn,isArrowVisible:Lt,isAnimatingRef:xe,isSideBySideRef:Jt,sideBySideCacheRef:Yt,sideBySideLineRef:Zt,activeSideBySideSectionRef:Qt,activeSideBySideRightSectionRef:Xt,connectedLines:ce,setConnectedLines:ae,cachedConnectedPositions:be,calculateLinesRef:Ce,resizeTimerRef:Ee,scrollLock:Ut,scrollSyncLocked:ue,handleResizeRef:Ae,activeProposed:gt,existingRule:ht,analysisData:Sn,pendingScrollTargetRef:Me,pendingScrollCallbackRef:Le,resolvedComparisonConfig:nt,getFieldData:Kn});t.useEffect(()=>{Ke.anchorEl&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{Ce.current?.()})})},[Ke.anchorEl,ue]);const ri=t.useCallback(()=>{tn(),de(!1),cn({}),un({}),on(),le(new Set),ae([]),be.current=[],Ye(),et(),tt(),requestAnimationFrame(()=>{Ce.current&&Ce.current()})},[cn,un,on,Ye,et,tt]);t.useEffect(()=>{Mt||0!==se.size||de(!1)},[Mt,se]);const si=t.useMemo(()=>Object.values(ln).some(Boolean)||Object.values(an).some(Boolean),[ln,an]),li=t.useRef(null),ci=t.useRef(0),ai=t.useRef(0),ui=t.useRef(0),{handleResize:di}=A.useResizeHandler({timerRef:li,ruleComponentRef:De,scrollContainerRef:Be,containerRef:he,maintainRelativeOrder:J,proposedSections:mt,existingSections:St,isSideBySideRef:Jt,activeSideBySideSectionRef:Qt,activeSideBySideRightSectionRef:Xt,sectionRowRefs:jt,sectionRightRowRefs:Dt,sectionLeftRefs:Tt,sectionRightRefs:It,subSectionLeftRefs:Ot,subSectionRightRefs:Ft,lhsBadgeRefs:wt,rhsBadgeRefs:Bt,leftContainerRef:Ne,rightContainerRef:Oe,calculateLinesRef:Ce,handleResizeRef:Ae,setIsResizing:Gt,setIsArrowVisible:$t,sideBySideCacheRef:Yt,cachedConnectedPositions:be});t.useEffect(()=>{Ae.current=di},[di,Ae]),t.useEffect(()=>{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 De.current&&o.push(e(De.current,ci,t,()=>Ae.current(),()=>{})),Be.current&&o.push(e(Be.current,ai,n,()=>Ae.current(),()=>Ce.current())),he.current&&o.push(e(he.current,ui,i,()=>Ae.current(),()=>Ce.current())),()=>{o.forEach(e=>e.disconnect()),r.forEach(e=>{null!==e.current&&(cancelAnimationFrame(e.current),e.current=null)})}},[]),t.useEffect(()=>{Jt.current=Mt},[Mt]),t.useEffect(()=>{Qt.current=zt},[zt]);const fi=t.useCallback(e=>{let t="",n="0";if("number"==typeof e)t=mt[e]?.nodeId||mt[e]?.id||"";else{const i=String(e).split(s.DEVIATION_BADGE_SEPARATOR);t=i[0],n=i[1]||"0"}const i=Te?.[t]?.evaluation_result,o=Array.isArray(i)?i[parseInt(n,10)]:i?.[n];return!1===o?.evaluation_outputs?.guideline_flag?.rulebook_used?1:0},[mt,Te]),pi=t.useCallback(e=>{const t=document.querySelectorAll('[id^="guideline-target-"], [data-web-gpt-active="true"]'),n=Ne.current,i=Oe.current,o="string"==typeof e&&e.includes(s.DEVIATION_BADGE_SEPARATOR);let r=e;if(o){const t=e.split(s.DEVIATION_BADGE_SEPARATOR);t.length>=2&&(r=`${t[0]}${s.DEVIATION_BADGE_SEPARATOR}${t[1]}`)}const l=wt.current[r]?.current||wt.current[e]?.current;if(t.length>0&&l&&n&&i){const e=t[0];Pe.current&&(Pe.current.style.height="0px"),Fe.current&&(Fe.current.style.height="0px"),ke.current&&(ke.current.style.height="0px"),je.current&&(je.current.style.height="0px"),requestAnimationFrame(()=>{const t=l.getBoundingClientRect(),o=e.getBoundingClientRect(),r=n.getBoundingClientRect(),s=i.getBoundingClientRect(),c=n.scrollTop+(t.top-r.top)+t.height/2,a=i.scrollTop+(o.top-s.top)+o.height/2,u=c-r.height/2,d=Math.max(0,u),f=n.scrollHeight-n.clientHeight,p=d>f?d-f:0,g=r.top+c-d;let h=s.top+a-g,m=0;h<0&&(m=Math.abs(h),h=0);const S=i.scrollHeight-i.clientHeight+m,R=h>S?h-S:0;ke.current&&(ke.current.style.height=`${p}px`),Fe.current&&(Fe.current.style.height=`${m}px`),je.current&&(je.current.style.height=`${R}px`),requestAnimationFrame(()=>{n.scrollTo({top:d,behavior:"smooth"}),i.scrollTo({top:h,behavior:"smooth"}),Ce.current&&setTimeout(()=>Ce.current(),50)})})}},[s.DEVIATION_BADGE_SEPARATOR]),gi=t.useCallback(()=>{const e=He.sectionIdx,t=He.isOrphan;if(Ye(),null==e)return;let n="left";He.anchorEl&&Oe.current?.contains(He.anchorEl)&&(n="right"),pn(e),pt&&(pe(fi(e)),le(new Set([e]))),rn(e,t,{sourceSide:n,onReady:()=>{pt&&setTimeout(()=>pi(String(e)),150)}})},[rn,He.isOrphan,He.sectionIdx,He.anchorEl,Ye,pn,pt,pi,fi]),hi=t.useCallback(()=>{Ye(),on(),le(new Set),ae([]),be.current=[]},[Ye,on]),mi=null!==He.sectionIdx&&se.has(He.sectionIdx),{showDeviationNavigation:Si,showOpenNodeRef:Ri,adjustScrollForPopup:xi}=S.useDeviationNavigation({proposedSections:mt,existingSections:St,parentDeviationRecord:xt,expandedSections:ln,maintainRelativeOrder:!!J,scrollContainerRef:Be,leftContainerRef:Ne,rightContainerRef:Oe,lhsBadgeRefs:wt,rhsBadgeRefs:Bt}),vi=t.useCallback((e,t,n,i,o)=>{const r="string"==typeof i?s.safeStringify(i).trim():s.safeStringify(i?.deviation_summary).trim(),l=e.currentTarget;et();let c="left";Oe.current?.contains(l)&&(c="right");const a=()=>{if("string"==typeof t&&t.includes(s.DEVIATION_BADGE_SEPARATOR)){const e=t.split(s.DEVIATION_BADGE_SEPARATOR),n=`${e[0]}${s.DEVIATION_BADGE_SEPARATOR}${e[1]}`;return"right"===c?Bt.current[n]?.current:wt.current[n]?.current}return"right"===c?Bt.current[t]?.current:wt.current[t]?.current};if(n&&!pt)return on(),le(new Set),ae([]),be.current=[],void(r&&(pn(t),requestAnimationFrame(()=>{const e=a()||l;if(e){e.getBoundingClientRect().top>.8*window.innerHeight&&e.scrollIntoView({behavior:"smooth",block:"center"})}Ue({open:!0,anchorEl:e,summary:i,displayImpact:o})})));pn(t),pt&&(pe(fi(t)),le(new Set([t]))),r?setTimeout(()=>{rn(t,n,{toggleIfSame:!1,sourceSide:c,onReady:()=>{const e=a()||l;if(pt)setTimeout(()=>pi(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;J?(Ne.current?.scrollBy({top:e,behavior:"smooth"}),Oe.current?.scrollBy({top:e,behavior:"smooth"})):Be.current?.scrollBy({top:e,behavior:"smooth"})}}Ue({open:!0,anchorEl:e,summary:i,displayImpact:o})}})},350):setTimeout(()=>{rn(t,n,{toggleIfSame:!1,sourceSide:c}),pt&&setTimeout(()=>pi(t),150)},350)},[rn,et,Ue,on,pn,pt,J,pi,Te]),yi=t.useMemo(()=>{if(!H)return null;const e=H?.id?.split(":")[0];for(const t in xt){if((xt[t]||[]).some(t=>t.id===e))return t}return null},[H,xt]),bi=t.useRef({id:null,triggerMs:null}),Ci=t.useRef(null);t.useEffect(()=>{if(!H?.id)return;const e=Number(H.trigger),t=bi.current;if(t?.id===H.id&&t?.triggerMs===e)return;if(!(H.id.includes(":")&&/:\d+$/.test(H.id))){bi.current={id:H.id,triggerMs:e},Vn(H.id);const t=mt.findIndex(e=>e.id===H.id),n=St.findIndex(e=>e.id===H.id);return void(-1===t&&-1===n||setTimeout(()=>{const e=-1!==t?t:n,i=-1===t;pt&&pe(fi(e)),le(new Set([e])),sn.current(e,i,{sourceSide:i?"right":"left",onReady:()=>{pt&&setTimeout(()=>pi(String(e)),150)}})},400))}const[n,i]=H.id.split(":"),o=i??"0",r=`${H.id}:${e}`;Ci.current!==r&&(Ye(),et(),on(),le(new Set),ae([]),be.current=[],Ci.current=r);let l=!1,c=0;let a=null,u=null,d=!1;const f=(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(l)return;const t=()=>{bi.current={id:H.id,triggerMs:e}};let i=null,r=null;for(const e in xt){const t=xt[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 c++,void(c<30&&(a=setTimeout(p,100)));const g=Array.from(new Set([n,r.id,r.nodeId,r.contentId,r.evaluationResult?.nodeId].filter(Boolean))),h=mt.findIndex(e=>e.id===i),m=St.findIndex(e=>e.id===i),S=-1===h&&-1!==m,R=f(mt,g);let x=f(St,g);if(R&&!x&&!S){const e=R.split("-");let t=Number(e[0]);if(J){const e=mt[t]?.refIndexes?.[0],n=St.findIndex(t=>t.selfIndex===e);-1!==n&&(t=n)}x=[t,...e.slice(1)].join("-")}if(!R&&!x)return c++,void(c<30&&(a=setTimeout(p,100)));const v=R?Number(R.split("-")[0]):h,y=x?Number(x.split("-")[0]):m,b=y>=0?y:x?Number(x.split("-")[0]):-1,C=mt[v],E=St[b],A=C&&!C.title&&!C.content,_=E&&!E.title&&!E.content,T=S||(!R&&!!x||A&&!_);if(T){if(!(J?!!ji.current[`right-${y}`]:!!ji.current[String(y)])&&y>=0)return fn(y,"right"),void(a=setTimeout(p,200))}else{if(!(J?!!ji.current[`left-${v}`]:!!ji.current[String(v)])&&v>=0)return fn(v,"left"),void(a=setTimeout(p,200))}const I=R||"",w=x||"",B=g.map(e=>`${e}${s.DEVIATION_BADGE_SEPARATOR}${o}`),D=B[0],O=()=>{for(const e of B){const t=wt.current[e]?.current||null,n=Bt.current[e]?.current||null;if(t||n)return{refId:e,left:t,right:n}}return{refId:D,left:null,right:null}},F=e=>`${e}${s.DEVIATION_BADGE_SEPARATOR}${I}${s.DEVIATION_BADGE_SEPARATOR}${w}`;if(!d){pn(F(D)),d=!0,c=0;const e=()=>{const{left:e,right:t}=O();return T||!e&&!!t?t:e};return u?.(),void(a=setTimeout(()=>{l||(u=((e,t)=>{let n,i=0,o=null,r=null;const s=performance.now(),c=()=>{if(l)return;if(performance.now()-s>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,f=u.height,p=null!==o&&Math.abs(d-o)<.5,g=null!==r&&Math.abs(f-r)<.5;if(p&&g){if(i++,i>=5)return void t()}else i=0;o=d,r=f,n=requestAnimationFrame(c)};return n=requestAnimationFrame(c),()=>cancelAnimationFrame(n)})(e,()=>{l||(u=null,p())}))},300))}const{refId:j,left:P,right:k}=O(),N=F(j);if(!P&&!k)return c++,void(c<30&&(a=setTimeout(p,100)));const M=T||!P&&!!k,L=M?k:P,q=J?M?Oe.current:Ne.current:Be.current;if(!L||!q)return c++,void(c<30&&(a=setTimeout(p,100)));const $=L.getBoundingClientRect();if(0===$.height)return c++,void(c<30&&(a=setTimeout(p,100)));const V=q.getBoundingClientRect(),W=$.top-V.top+q.scrollTop-V.height/2+$.height/2,z=R?.includes("-")||x?.includes("-"),K=async()=>{if(l)return;t();const e=L instanceof Element?window.getComputedStyle(L).color:"";[P,k].forEach(t=>{t&&(t.style.transition="box-shadow 300ms ease-in-out",t.style.boxShadow=`0 0 10px ${e}`)}),setTimeout(()=>{[P,k].forEach(e=>{e&&(e.style.boxShadow="")})},2e3);const n=r.evaluationResult?.deviations?.[o]||r,i=r.evaluationResult?.evaluation_outputs||r.evaluation_outputs;if(!(!!P&&!!k)&&!pt){const e=M?Bt.current[z?j:y]?.current||k:wt.current[z?j:v]?.current||P;return xi(e,()=>{Ue({open:!0,anchorEl:e,displayImpact:H.displayImpact,summary:{...n,evaluation_outputs:i}})},{skipScroll:!0}),void G?.()}const c=(e,t)=>Promise.race([e,new Promise(e=>setTimeout(e,t))]);J&&await Promise.all([Ne.current?c(s.waitForScrollIdle(Ne.current),600):Promise.resolve(),Oe.current?c(s.waitForScrollIdle(Oe.current),600):Promise.resolve()]),pt&&(pe(fi(N)),le(new Set([N]))),sn.current(N,!1,{toggleIfSame:!1,sourceSide:S?"right":"left",onReady:()=>{t();const e=M?Bt.current[j]?.current||k:wt.current[j]?.current||P;if(pt)setTimeout(()=>pi(N),150);else{const e=wt.current[j]?.current||P,t=Bt.current[j]?.current||k;e&&(e.style.scrollMarginTop="150px",e.scrollIntoView({behavior:"smooth",block:"start"})),t&&(t.style.scrollMarginTop="150px",t.scrollIntoView({behavior:"smooth",block:"start"}))}Ue({open:!0,anchorEl:e,displayImpact:H.displayImpact,summary:{...n}}),G?.()}})};Math.abs(q.scrollTop-W)<=2?K():s.scrollAndWait(q,W,K)};return a=setTimeout(p,100),()=>{l=!0,a&&clearTimeout(a),u?.()}},[H?.id,H?.trigger,H?.displayImpact,xt,mt,St,J,Ue,Vn,pt,fi,pi]),t.useEffect(()=>{if(!Ke.open)return;const e=Ke.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(wt.current)||t(Bt.current);if(!n)return;const i=Bt.current[n]?.current||wt.current[n]?.current;i&&i.isConnected&&Ue(e=>({...e,anchorEl:i}))},[Ke.open,Ke.anchorEl,ue,se,ln]);const{open:Ei,sectionIdx:Ai,isOrphan:_i,badgeStyle:Ti,anchorEl:Ii,sectionAnchorEl:wi}=qe;t.useEffect(()=>{if(!M.isStreamingEnabled)return;if(!Ei||null==Ai)return;if(Ai===vn)return;const e="string"==typeof Ai?Ai.split(s.DEVIATION_BADGE_SEPARATOR)[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(mt,e):null,i=e&&"string"==typeof e?t(St,e):null,o="number"==typeof Ai?mt[Ai]||null:n||e&&(O?.nodes?.[e]||O?.[e])||null,r="number"==typeof Ai?St[Ai]||null:i,l=qn(Ii,o,r,Ai,_i,Ti);$e(e=>{if(!e.open)return e;return s.safeStringify(e.cognitiveData)===s.safeStringify(l.cognitiveData)&&s.safeStringify(e.deviationData)===s.safeStringify(l.deviationData)&&e.sectionTitle===l.sectionTitle&&e.refSectionTitle===l.refSectionTitle?e:{...e,...l,open:!0,anchorEl:e.anchorEl,sectionAnchorEl:e.sectionAnchorEl}})},[Ei,Ai,_i,Ti,Ii,wi,mt,St,qn]);const Bi=t.useCallback(({section:t,keyPath:n,depth:i=0,columnKey:o="left",parentNodeId:r="",sectionOffset:s,rhsOrphanVisualIndexes:l})=>e.jsx(x.default,{section:t,keyPath:n,depth:i,columnKey:o,parentNodeId:r,sectionOffset:s,rhsOrphanVisualIndexes:l}),[]),Di=t.useMemo(()=>mt.map((t,n)=>{const i=!t?.title&&!t?.content,o=!t?.refIndexes||0===t.refIndexes.length;return i&&o&&J?null:e.jsx(v.default,{section:t,idx:n},t?.layoutKey??t?.id??`left-row-${n}`)}),[mt,J]),Oi=t.useMemo(()=>St.map((t,n)=>{const i=!t?.title&&!t?.content,o=!t?.refIndexes||0===t.refIndexes.length;return i&&o&&J?null:e.jsx(y.default,{section:t,idx:n},t?.layoutKey??t?.id??`right-row-${n}`)}),[St,J]),Fi=t.useRef($n);t.useEffect(()=>{Fi.current=$n},[$n]);const ji=t.useRef(ln);t.useEffect(()=>{ji.current=ln},[ln]);const Pi=t.useRef(vi);t.useEffect(()=>{Pi.current=vi},[vi]);const ki=t.useRef(hi);t.useEffect(()=>{ki.current=hi},[hi]);const Ni=t.useRef(fn);t.useEffect(()=>{Ni.current=fn},[fn]);const Mi=t.useRef(dn);t.useEffect(()=>{Mi.current=dn},[dn]);const Li=t.useRef(Bi);t.useEffect(()=>{Li.current=Bi},[Bi]);const qi=t.useRef(on);t.useEffect(()=>{qi.current=on},[on]);const $i=t.useMemo(()=>({isGuidelineMode:pt,maintainRelativeOrder:!!J,showDeviationBadges:ee,isProposingFix:V,proposingFixNodeId:W,isRedlineFlow:z,isSideBySide:Mt,activeSideBySideSection:zt,scrollSyncLocked:ue,toggleScrollSyncLocked:hn,summaryPopupAnchorEl:Ke.anchorEl,connectedSections:se,proposedSections:mt,existingSections:St,deviationNumberRegistry:vt,deviationParentRegistry:yt,treeData:O,displayConfig:M,resolvedMarkdownStyles:we,unifiedNumbering:mn,expandedSections:ln,expandedSubSections:an,setExpandedSubSections:un,getSectionCompareStyle:Un,getSubSectionCompareStyle:Yn,getBadgeRef:Nt,getSectionRowRef:Pt,getSubSectionRef:kt,sectionLeftRefs:Tt,sectionRightRefs:It,sectionRowRefs:jt,sectionRightRowRefs:Dt,subSectionLeftRefs:Ot,subSectionRightRefs:Ft,lhsBadgeRefs:wt,rhsBadgeRefs:Bt,openMoreFunctionsPopup:_n,handleOpenSummaryPopup:Tn,openSummaryPopup:Tn,handleCloseSummaryPopup:In,toggleSection:wn,handleSubSectionToggle:Bn,renderSubSectionAccordion:Dn,resetSideBySide:On,setConnectedSections:le,setConnectedLines:ae,cachedConnectedPositions:be,showDeviationNavigation:Si,showOpenNodeRef:Ri,deviationNodeIdToView:H?.id,deviationTargetParentId:yi,guidelinesData:U,gptWebCitationConfig:Y}),[pt,J,ee,V,W,z,Mt,zt,ue,hn,Ke.anchorEl,se,mt,St,vt,M,we,mn,ln,an,un,Un,Yn,Nt,Pt,kt,Si,Ri,H,yi,U,Y]),Hi=s.safeStringify(qe.sectionTitle||at||lt),Gi=s.safeStringify(pt?dt||ft||qe.refSectionTitle:qe.refSectionTitle||dt||ft);return e.jsx(C.CompareContextProvider,{value:$i,children:e.jsxs(n.Box,{ref:De,sx:{display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif',overflow:"visible",position:"relative"},children:[te&&e.jsx(n.Box,{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.jsx(d.default,{})}),Ke.open&&e.jsx(b.default,{open:Ke.open,anchorEl:Ke.anchorEl,containerEl:zn.current,clipTopEl:me.current,scrollContainerEl:Be.current,onClose:hi,summary:Ke.summary,displayImpact:Ke.displayImpact,isScrollLocked:ue}),e.jsx(u.default,{open:He.open,anchorEl:He.anchorEl,maintainRelativeOrder:!!J,sectionTitle:He.sectionTitle,referenceSectionTitle:He.refSectionTitle,onClose:tt,onOpenCognitiveCompare:Qe,onOpenSideBySide:gi,onConnect:Hn,isConnected:mi,isOrphan:!pt&&!!He.isOrphan,isGuidelineMode:pt,hasGuidelineMatches:He.hasGuidelineMatches}),qe.open&&e.jsx(a.default,{open:qe.open,popupRef:Xe,position:Ve,popupConfig:q,onClose:()=>{We(null),$e(e=>({...e,open:!1})),Je(null)},markdownStyles:k,sectionTitle:Hi,referenceSectionTitle:Gi,cognitiveData:qe.cognitiveData,anchorEl:qe.anchorEl,sectionAnchorEl:qe.sectionAnchorEl,scrollContainerEl:Be.current,badgeStyle:qe.badgeStyle,docData:qe.docData,deviationData:qe.deviationData,isLoading:qe.isLoading}),e.jsx(n.Snackbar,{open:!!ie,autoHideDuration:8e3,onClose:()=>oe(null),anchorOrigin:{vertical:"top",horizontal:"center"},children:e.jsx(n.Alert,{onClose:()=>oe(null),severity:"error",sx:{width:"100%",whiteSpace:"pre-line"},children:ie})}),e.jsx(R.default,{componentHeaderText:D,displayConfig:M,maintainRelativeOrder:J,onCollapseAll:ri,showCollapseAll:si,onToggleView:e=>{ne(!0),setTimeout(()=>{X(!e),L?.(!e),de(!1),on(),Ye(),le(new Set),ae([]),be.current=[],requestAnimationFrame(()=>{requestAnimationFrame(()=>{setTimeout(()=>{ne(!1)},600)})})},50)}}),e.jsx(n.Box,{ref:Be,onScroll:oi,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:J?"visible":"auto",borderTop:Rn&&xn?"none":"1.5px solid #EEF0F4"},children:e.jsx(n.Box,{sx:{display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px",...J?{flex:1}:{}},children:e.jsxs(n.Box,{ref:he,sx:{display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"100px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0,...J?{flex:1,overflow:"visible"}:{}},children:[e.jsx(I.default,{svgContainerRef:ge,svgDimensions:ti,isResizing:Ht,overallConnector:Zn,rootDeviationStyle:Cn,lines:Xn,isSideBySide:Mt,activeSideBySideSection:zt,isArrowVisible:Lt,maintainRelativeOrder:J,proposedSections:mt,existingSections:St,cognitivePopup:qe,activeBadgeId:ze,closeCognitivePopup:et,setActiveBadgeId:Je,openCognitivePopupFromState:Ze,buildSectionPopupState:qn,connectedLines:ce,isGuidelineMode:pt,pathRefs:ye}),e.jsxs(n.Box,{sx:{border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)",...J?{flex:1,overflow:"visible"}:{}},children:[e.jsx(n.Box,{ref:me,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.jsx(n.Tooltip,{title:lt,placement:"top",children:e.jsx(n.Typography,{sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"},children:lt})})}),e.jsxs(n.Box,{ref:Ne,onScroll:oi,sx:{p:"12px",display:"flex",flexDirection:"column",...J?{maxHeight:"calc(100vh - 250px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-180px",pr:"192px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{}},children:[e.jsx("div",{ref:Pe,style:{width:"100%",height:"0px",flexShrink:0}}),Ct&&Di,e.jsx("div",{ref:ke,style:{width:"100%",height:"0px",flexShrink:0}})]})]}),e.jsx(n.Box,{ref:zn,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"},children:e.jsx(n.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0},children:e.jsxs(n.Box,{onClick:e=>{e.stopPropagation(),qe.open&&ze===vn?et():(Je(vn),Ze(qn(e.currentTarget,{title:kn,content:"",evaluationResult:yn,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,vn,!0,{...Cn,label:""})))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:Cn.badgeBg,color:Cn.badgeText,border:`1px solid ${Cn.badgeBorder}`,fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"},children:[bn??e.jsx(f.default,{}),e.jsx(n.Box,{component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}},children:e.jsx(o.ButtonCognitiveIcon,{})}),e.jsx(i.ChevronDown,{size:11,style:{transform:qe.open&&ze===vn?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]})})}),e.jsxs(n.Box,{sx:{border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0,...J?{flex:1,overflow:"visible",minHeight:0}:{}},children:[Vt&&e.jsx(r.default,{sections:11}),e.jsx(n.Box,{ref:Se,sx:{p:"8px",bgcolor:pt?"#F1F3F5":"#F7F8FA",borderBottom:"1px solid #D7DCE2",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center",...J?{maxHeight:"calc(100vh - 250px)",overflowY:"auto",overflowX:"hidden",minHeight:0,...pt?{"&::-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:pt?e.jsxs(n.Tabs,{value:fe,onChange:(e,t)=>pe(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.jsx(n.Tab,{label:e.jsx(n.Tooltip,{title:ft,placement:"top",children:e.jsx(n.Box,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block",width:"100%"},children:"Redline Guidelines"})})}),e.jsx(n.Tab,{label:e.jsx(n.Tooltip,{title:"Web & GPT Sources",placement:"top",children:e.jsx(n.Box,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block",width:"100%"},children:"Web & GPT Sources"})})})]}):e.jsx(n.Tooltip,{title:ft,placement:"top",children:e.jsx(n.Typography,{sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"},children:ft})})}),e.jsxs(n.Box,{ref:Oe,onScroll:oi,sx:{p:pt?"0px":"12px",display:"flex",flexDirection:"column",...J?{maxHeight:"calc(100vh - 250px)",...!pt&&{flex:1},overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-150px",pl:"165px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{}},children:[e.jsx("div",{ref:Fe,style:{width:"100%",height:"0px",flexShrink:0}}),pt?0===fe?e.jsx(w.default,{guidelinesData:U,deviationData:$,connectedSections:se,proposedSections:mt}):e.jsx(B.default,{deviationData:$,connectedSections:se,proposedSections:mt}):Ct&&Oi,e.jsx("div",{ref:je,style:{width:"100%",height:"0px",flexShrink:0}})]})]})]})})})]})})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),n=require("@mui/material"),i=require("lucide-react"),o=require("../../assests/svg/ButtonCognitiveIcon.js"),r=require("./OverlayComponent.js"),s=require("./CognitiveComparehelpers.js"),l=require("./CognitiveCompareConfig.js"),a=require("./CognitiveCompareConstants.js"),c=require("./CognitivePopup.js"),u=require("./MoreFunctionsPopup.js"),d=require("./LoaderComponent.js"),f=require("./components/ThreeDotsLoader.js"),p=require("./hooks/useCompareData.js"),g=require("./hooks/useComparePopups.js"),h=require("./hooks/useSectionRefs.js"),m=require("./hooks/useAccordionState.js"),S=require("./hooks/useDeviationNavigation.js"),x=require("./hooks/useOnDemandCitationCache.js"),R=require("./components/CompareHeader.js"),v=require("./components/SubSectionAccordion.js"),y=require("./components/LHSSectionRow.js"),b=require("./components/RHSSectionRow.js"),C=require("./components/CognitiveSummaryPopup.js"),E=require("./CompareContext.js"),A=require("./hooks/useStyles.js"),I=require("./hooks/useResizeHandler.js"),_=require("./hooks/useLinesCalculator.js"),T=require("./hooks/useSideBySide.js"),B=require("./components/SvgConnectors.js"),w=require("./Guidelines/components/GuidelinePanel.js"),D=require("./Guidelines/components/WebGptPanel.js"),O=require("./components/GuidelineSkeletonLoader.js"),j=require("./Guidelines/utils/guidelineTargets.js"),F=require("./Guidelines/utils/hasGptCitationObjects.js");exports.SHARED_MARKDOWN_STYLES=l.SHARED_MARKDOWN_STYLES,exports.default=({componentHeaderText:P=a.DEFAULT_COMPONENT_HEADER_TEXT,treeData:k,comparisonConfig:N,leftColumnTitleText:M,rightColumnTitleText:L,markdownStyles:q,resetTrigger:G,displayConfig:$={isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1,displayEmailNotifier:!0,isStreamingEnabled:!1},deviationAnalysisStatus:V,onMaintainRelativeOrderChange:H,popupConfig:z,deviationData:W={},deviationNodeIdToView:K,resetDeviationNodeId:U,isProposingFix:Y=!1,proposingFixNodeId:J,isRedlineFlow:X,badgeStyleOverride:Q,guidelinesData:Z,isGuidelineMode:ee,gptWebCitationConfig:te,onDemandCitationConfig:ne})=>{const[ie,oe]=t.useState($.maintainRelativeOrder),re=$?.expandLevels??0,se=!!$?.expandAllSections,le=!!ie||!!$?.showDeviationBadges,[ae,ce]=t.useState(!1),[ue,de]=t.useState(null),[fe]=t.useState(k?.newEvaluationResult??$?.enableDeviationSchemaBackwardCompatibility??!0),[pe,ge]=t.useState(new Set),[he,me]=t.useState([]),[Se,xe]=t.useState(!1),[Re,ve]=t.useState(0),ye=V??($?.isLoading?"deviations_streaming":"complete"),be="mapping_ready"===ye||"deviations_streaming"===ye,Ce=t.useRef(null),Ee=t.useRef(null),Ae=t.useRef(null),Ie=t.useRef(null),_e=t.useRef(null),Te=t.useRef(!1),Be=t.useRef(null),we=t.useRef({}),De=t.useRef([]),Oe=t.useRef(()=>{}),je=t.useRef(null),Fe=t.useRef(()=>{}),Pe=t.useMemo(()=>JSON.stringify(W||{}),[JSON.stringify(W)]),ke=t.useMemo(()=>W||{},[Pe]),Ne=t.useMemo(()=>F.hasGptCitationObjects(ke),[ke]),Me=t.useMemo(()=>k?.cognitive_decisioning||{},[k]),Le=t.useMemo(()=>({...l.SHARED_MARKDOWN_STYLES,...q}),[q]),qe=t.useRef(null),Ge=t.useRef(null),$e=t.useRef(null),Ve=t.useRef(null),He=t.useRef(null),ze=t.useRef(null),We=t.useRef(null),Ke=t.useRef(null),Ue=t.useRef(null),Ye=t.useRef(null),{cognitivePopup:Je,setCognitivePopup:Xe,moreFunctions:Qe,setMoreFunctions:Ze,position:et,setPosition:tt,activeBadgeId:nt,summaryPopup:it,setSummaryPopup:ot,closeSummaryPopup:rt,setActiveBadgeId:st,popupRef:lt,handleOpenCognitiveCompare:at,openCognitivePopupFromState:ct,closeCognitivePopup:ut,closeMoreFunctionsPopup:dt}=g.useComparePopups(qe),ft=t.useMemo(()=>({fields:N?.fields??l.DEFAULT_FIELD_CONFIG,thresholds:{high:N?.thresholds?.high??l.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:N?.thresholds?.medium??l.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:N?.thresholds?.exact??l.DEFAULT_COMPARISON_CONFIG.thresholds.exact}}),[N]),[pt,gt]=t.useState(null),ht=k?.documents?.[k?.input_index_map?.[0]]?.title,mt=k?.documents?.[k?.input_index_map?.[1]]?.title,St=s.safeStringify(M||ht||"Uploaded Contract"),xt=k?.documents?.[k?.input_index_map?.[0]]?.metadata?.file_name,Rt=s.safeStringify(xt),vt=k?.documents?.[k?.input_index_map?.[1]]?.metadata?.file_name,yt=s.safeStringify(vt),bt=s.safeStringify(L||mt||"Reference Template"),{isGuidelineMode:Ct,activeProposed:Et,existingRule:At,proposedSections:It,existingSections:_t,visibleFields:Tt,parentDeviationRecord:Bt,deviationNumberRegistry:wt,deviationParentRegistry:Dt,parseError:Ot}=p.useCognitiveTreeData(k,ie,ke,ft,fe,Z,ee);t.useEffect(()=>{Ot&&de(`Failed to load comparison: ${Ot}`)},[Ot]);const jt=It.length>0||_t.length>0,Ft=t.useMemo(()=>{if(!X)return"off";let e=0,t=0;const n=i=>{Array.isArray(i)&&i.forEach(i=>{const o=i?.content||"";s.hasMeaningfulRedlineTags(o)&&(e+=1,t+=String(o).length),i?.subsections?.length&&n(i.subsections)})};return n(It),n(_t),`${e}:${t}`},[X,It,_t]);t.useEffect(()=>{if(It.length||_t.length)if(se){const e={},t={},n=(n,i)=>{n.forEach((n,o)=>{const r=ie?`${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(It,"left"),n(_t,"right"),xn(e),vn(t)}else if(re>0){const e={},t={},n=(n,i,o)=>{n.forEach((n,r)=>{if(o>=1){const t=ie?`${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(It,"left",re),n(_t,"right",re),xn(e),vn(t)}},[se,re,It,_t,ie]);const{leftRefs:Pt,rightRefs:kt,sectionLeftRefs:Nt,sectionRightRefs:Mt,lhsBadgeRefs:Lt,rhsBadgeRefs:qt,sectionRightRowRefs:Gt,subSectionLeftRefs:$t,subSectionRightRefs:Vt,sectionRowRefs:Ht,getSectionRowRef:zt,getSubSectionRef:Wt,getBadgeRef:Kt}=h.useSectionRefs(Tt.map(({key:e})=>e),Math.max(It.length,_t.length)),{isSideBySide:Ut,isArrowVisible:Yt,setIsSideBySide:Jt,setIsArrowVisible:Xt,isResizing:Qt,setIsResizing:Zt,isSideBySideLoading:en,setIsSideBySideLoading:tn,activeSideBySideSection:nn,setActiveSideBySideSection:on,scrollLock:rn,sideBySideCacheRef:sn,isSideBySideRef:ln,activeSideBySideRightSectionRef:an,activeSideBySideSectionRef:cn,sideBySideLineRef:un,highlightedClauseRefs:dn,clearClauseHighlight:fn,applyAlignmentPadding:pn,resetSideBySide:gn,activateSideBySide:hn}=T.useSideBySide({isGuidelineMode:Ct,maintainRelativeOrder:ie,proposedSections:It,existingSections:_t,leftContainerRef:Ke,rightContainerRef:$e,scrollContainerRef:qe,sectionLeftRefs:Nt,sectionRightRefs:Mt,subSectionLeftRefs:$t,subSectionRightRefs:Vt,lhsBadgeRefs:Lt,rhsBadgeRefs:qt,sectionRowRefs:Ht,sectionRightRowRefs:Gt,rhsTopSpacerRef:Ve,rhsBottomSpacerRef:He,lhsTopSpacerRef:ze,lhsBottomSpacerRef:We,calculateLinesRef:Oe,setConnectedSections:ge,setConnectedLines:me,cachedConnectedPositions:De,closeMoreFunctionsPopup:dt,setErrorToast:de,moreFunctions:Qe,closeSummaryPopup:rt}),mn=t.useRef(hn);t.useEffect(()=>{mn.current=hn},[hn]);const{expandedSections:Sn,setExpandedSections:xn,expandedSubSections:Rn,setExpandedSubSections:vn,handleSubSectionToggle:yn,toggleSection:bn,forceExpandCrossWiredSections:Cn}=m.useAccordionState({maintainRelativeOrder:!!ie,proposedSections:It,existingSections:_t,activeSideBySideSection:nn,connectedSections:pe,resetSideBySide:gn,setConnectedSections:ge,setConnectedLines:me,cachedConnectedPositions:De,svgContainerRef:Ce,isAnimatingRef:Te,animationTimerRef:Be,calculateLinesRef:Oe,sectionLeftRefs:Nt,sectionRightRefs:Mt,subSectionLeftRefs:$t,subSectionRightRefs:Vt}),En=()=>{if(null==nn)return;const e=Nt.current[nn]?.current,t=Mt.current[nn]?.current,n=$e.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"})},An=t.useCallback(e=>{e?.stopPropagation(),xe(e=>{const t=!e;return t&&requestAnimationFrame(()=>{En()}),t})},[En]);t.useEffect(()=>{X&&"off"!==Ft&&"0:0"!==Ft&&(sn.current=null,De.current=[],requestAnimationFrame(()=>{Oe.current?.()}))},[X,Ft]);const In=t.useMemo(()=>{const e=new Map,t=new Map;let n=1;if(ie)It.forEach(t=>{!t.title&&!t.content||t.id&&e.set(t.id,n++)}),_t.forEach(i=>{if(!i.id)return;if(!i.title&&!i.content)return;const o=It.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(It.length,_t.length);for(let o=0;o<i;o++){const i=It[o],r=_t[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}},[It,_t,ie]),_n=At.analysis,Tn=s.safeStringify(_n?.rule_difference_comparison?.summary?.overall_summary),Bn=!!Tn.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),wn=k?.base_root_id??"-1",Dn=fe?(W&&W?.[wn]?.evaluation_result)??k?.nodes?.[wn]?.evaluation_result??null:(W&&W?.[wn]?.evaluation_result?.[0])??k?.nodes?.[wn]?.evaluation_result?.[0]??null,On=s.extractDeviationScore(Dn),jn=be&&null==Dn,Fn=jn?null:On??("complete"===ye&&null==Dn?"Same":null);let Pn=s.generateColorPalette(Dn?.evaluation_outputs?.metadata?.label_color??a.DEFAULT_DEVIAION_COLOR);if(Q){const e=Q(On);e&&(Pn={...Pn,badgeBg:e.bg,badgeText:e.text,badgeBorder:e.border})}const kn=t.useRef(gn);t.useEffect(()=>{kn.current=gn},[gn]);const Nn=t.useRef(ut);t.useEffect(()=>{Nn.current=ut},[ut]);const Mn=t.useCallback((e,t,n,i,o,r)=>Ui.current(e,t,n,i,o,r),[]),Ln=t.useCallback((e,t,n,i,o)=>Ji.current(e,t,n,i,o),[]),qn=t.useCallback(()=>Xi.current(),[]),Gn=t.useCallback((e,t)=>Qi.current(e,t),[]),$n=t.useCallback(e=>Zi.current(e),[]),Vn=t.useCallback(e=>eo.current(e),[]),Hn=t.useCallback(()=>to.current(),[]),zn=t.useCallback(()=>{fn(),kn.current?.(),xe(!1),ge(new Set),me([]),De.current=[],di([]),pi(null),ot(a.EMPTY_SUMMARY_POPUP_STATE),Nn.current?.(),requestAnimationFrame(()=>{Oe.current?.()})},[]),Wn=t.useRef(zn);t.useEffect(()=>{Wn.current=zn},[zn]),t.useEffect(()=>{G&&Wn.current()},[G]);const Kn=t.useMemo(()=>({documents:k?.documents,input_index_map:k?.input_index_map}),[JSON.stringify(k?.documents),JSON.stringify(k?.input_index_map)]),[Un,Yn]=t.useState(""),Jn=s.safeStringify(mt),Xn=t.useRef(k);t.useEffect(()=>{Xn.current=k;const e=k?.input_index_map?.[0],t=k?.documents?.[e]?.title;Yn(t)},[k]);const Qn=t.useRef(Me);t.useEffect(()=>{Qn.current=Me},[Me]);const Zn=t.useCallback((e,t,n,i,o,r,l)=>{const a=s.safeStringify(t?.id)||s.safeStringify(n?.id)||"",c="string"==typeof i?i.split(s.DEVIATION_BADGE_SEPARATOR):[],u=c[0]||s.safeStringify(t?.nodeId)||s.safeStringify(n?.nodeId)||s.safeStringify(t?.id).split(s.DEVIATION_BADGE_SEPARATOR)[0]||s.safeStringify(n?.id).split(s.DEVIATION_BADGE_SEPARATOR)[0]||void 0,d=c.length>1&&void 0!==c[1]?c[1]:void 0,f=(a?Qn.current?.[a]:null)||t?.cognitiveData||n?.cognitiveData||{section_id:a,decisioning:[],gap:[],relevance_score:0},p=Ht.current[i]?.current??null,g=(()=>{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(s.DEVIATION_BADGE_SEPARATOR)))return o(e);const r=i.split(s.DEVIATION_BADGE_SEPARATOR)[1];if(!r)return e;const l=t?.evaluationResult||n?.evaluationResult||{},a=l?.deviation_entries?.[r]||l?.deviations?.[r]||null;return a?{...l,...a,deviation_summary:a?.deviation_summary||l?.deviation_summary,deviation_title:a?.deviation_title||l?.deviation_title,deviation_impact:a?.deviation_impact||l?.deviation_impact,deviation_explanation:a?.deviation_explanation||l?.deviation_explanation,evaluation_outputs:a?.evaluation_outputs||l?.evaluation_outputs,cognitive_decisioning:a?.cognitive_decisioning||l?.cognitive_decisioning}:o(e)})(),h=(g?.cognitive_decisioning?.decisioning_factors?.length??0)>0||(g?.cognitive_decisioning?.gaps_in_decision?.length??0)>0,m=be;let S=!0;if(Ct){const e=g?.deviation_highlights;if(e&&"object"==typeof e){S=Object.values(e).some(e=>Array.isArray(e)&&e.length>0)}else S=!1}return{isLoading:m&&!h,open:!0,sectionTitle:t?.title?t?.title:"No Counterpart",refSectionTitle:n?.title?n?.title:"No Counterpart",cognitiveData:f,anchorEl:e,sectionAnchorEl:p,badgeStyle:r||null,sectionIdx:i,docData:Kn,deviationData:g,isOrphan:!!o,hasGuidelineMatches:S,sourceNodeId:u,deviationKey:d,baseContentId:t?.contentId,compareContentIds:[...n?.contentId?[n.contentId]:[],...t?.refContentIds||[],...n?.refContentIds||[]].filter(Boolean)}},[Kn,be,Ct]),ei=t.useCallback((e,t,n,i,o,r)=>{if(e.stopPropagation(),Qe.open&&Qe.sectionIdx===o)return void dt();const l=e.currentTarget;let a="left";$e.current?.contains(l)&&(a="right");fn(),ln.current&&gn(),ge(new Set),me([]),De.current=[],ut(),it.open?wi():rt(),requestAnimationFrame(()=>{const e=(()=>{if("string"==typeof o&&o.includes(s.DEVIATION_BADGE_SEPARATOR)){const e=o.split(s.DEVIATION_BADGE_SEPARATOR),t=`${e[0]}${s.DEVIATION_BADGE_SEPARATOR}${e[1]}`;return"right"===a?qt.current[t]?.current:Lt.current[t]?.current}return"right"===a?qt.current[o]?.current:Lt.current[o]?.current})()||l;Ze(Zn(e,t,i,o,n,r))})},[Qe.open,Qe.sectionIdx,dt,rt,Zn]),ti=t.useCallback(()=>{const e=Qe.sectionIdx;Qe.isOrphan,dt(),rt(),null!==e&&(Cn(e),fn(),ln.current&&gn(),me([]),De.current=[],Ct&&null!==e&&ve(Ai(e)),ge(t=>t.has(e)?new Set:new Set([e])),setTimeout(()=>{Oe.current&&Oe.current()},50))},[Qe.sectionIdx,Qe.isOrphan,dt,rt,gn]),ni=t.useCallback(()=>{const e=_e.current;if(!e)return;_e.current=null;const t=It.findIndex(t=>t.id===e),n=_t.findIndex(t=>t.id===e),i=-1===t?s.findKeyPathByNodeId(It,e):null,o=-1===n?s.findKeyPathByNodeId(_t,e):null,r=-1!==t?t:i?Number(i.split("-")[0]):-1,l=-1!==n?n:o?Number(o.split("-")[0]):-1,a=(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?(dn.current.add(r),s.scrollAndHighlightClause(r,t)):i++<n&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(ie)-1!==r&&Ke.current&&c(()=>a(t,i,Nt,$t),Ke.current),-1!==l&&$e.current&&c(()=>a(n,o,Mt,Vt),$e.current);else{const e=qe.current;if(!e)return;c(()=>-1!==r?a(t,i,Nt,$t):a(n,o,Mt,Vt),e)}},[It,_t,ie,Nt,Mt,$t,Vt,Ke,$e,qe]),ii=t.useCallback(e=>{if(!e)return;fn(),gn(),ge(new Set),me([]),De.current=[],rt(),ut();const t=It.findIndex(t=>t.id===e),n=_t.findIndex(t=>t.id===e),i=-1===t?s.findKeyPathByNodeId(It,e):null,o=-1===n?s.findKeyPathByNodeId(_t,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,l=-1!==n?n:o?Number(o.split("-")[0]):-1;_e.current=e,xn(e=>{const t={...e};let n=!1;if(-1!==r){const e=ie?`left-${r}`:String(r);t[e]||(t[e]=!0,n=!0)}if(-1!==l){const e=ie?`right-${l}`:String(l);t[e]||(t[e]=!0,n=!0)}return n?t:e}),vn(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(()=>{_e.current===e&&oi.current()})},50)},[It,_t,ie,xn,vn,gn,rt,ut]),oi=t.useRef(ni);t.useEffect(()=>{oi.current=ni},[ni]);const ri=t.useRef(null);t.useEffect(()=>{if(pt){const e=ft.fields.find(e=>e.analysisKey===pt||e.key===pt);if(e){const t=Pt.current[e.key]||kt.current[e.key];t?.current&&setTimeout(()=>t.current.scrollIntoView({behavior:"smooth",block:"center"}),150)}}},[pt,ft.fields]);const si=t.useCallback(e=>{const t=_n?.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}},[_n]),{getSectionCompareStyle:li,getSubSectionCompareStyle:ai,getDeviationStyleByKey:ci}=A.useStyleHelpers({proposedSections:It,existingSections:_t,maintainRelativeOrder:ie,cognitiveMap:Me,deviationData:ke,treeData:k,resolvedComparisonConfig:ft,badgeStyleOverride:Q}),{lines:ui,setLines:di,overallConnector:fi,setOverallConnector:pi,svgDimensions:gi,calculateLines:hi,calculateLinesDebounced:mi,handleColumnScroll:Si}=_.useLinesCalculator({containerRef:Ee,leftContainerRef:Ke,rightContainerRef:$e,svgContainerRef:Ce,pathRefs:we,leftHeaderRef:Ae,rightHeaderRef:Ie,proposedSections:It,existingSections:_t,visibleFields:Tt,leftRefs:Pt,rightRefs:kt,sectionLeftRefs:Nt,sectionRightRefs:Mt,subSectionLeftRefs:$t,subSectionRightRefs:Vt,lhsBadgeRefs:Lt,rhsBadgeRefs:qt,sectionRowRefs:Ht,expandedSections:Sn,expandedSubSections:Rn,connectedSections:pe,isSideBySide:Ut,activeSideBySideSection:nn,maintainRelativeOrder:ie,isGuidelineMode:Ct,cognitiveMap:Me,getSectionCompareStyle:li,getSubSectionCompareStyle:ai,getDeviationStyleByKey:ci,isArrowVisible:Yt,isAnimatingRef:Te,isSideBySideRef:ln,sideBySideCacheRef:sn,sideBySideLineRef:un,activeSideBySideSectionRef:cn,activeSideBySideRightSectionRef:an,connectedLines:he,setConnectedLines:me,cachedConnectedPositions:De,calculateLinesRef:Oe,resizeTimerRef:je,scrollLock:rn,scrollSyncLocked:Se,handleResizeRef:Fe,activeProposed:Et,existingRule:At,analysisData:_n,pendingScrollTargetRef:Ue,pendingScrollCallbackRef:Ye,resolvedComparisonConfig:ft,getFieldData:si});t.useEffect(()=>{it.anchorEl&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{Oe.current?.()})})},[it.anchorEl,Se]);const xi=t.useCallback(()=>{fn(),xe(!1),xn({}),vn({}),gn(),ge(new Set),me([]),De.current=[],rt(),ut(),dt(),requestAnimationFrame(()=>{Oe.current&&Oe.current()})},[xn,vn,gn,rt,ut,dt]);t.useEffect(()=>{Ut||0!==pe.size||xe(!1)},[Ut,pe]);const Ri=t.useMemo(()=>Object.values(Sn).some(Boolean)||Object.values(Rn).some(Boolean),[Sn,Rn]),vi=t.useRef(null),yi=t.useRef(0),bi=t.useRef(0),Ci=t.useRef(0),{handleResize:Ei}=I.useResizeHandler({timerRef:vi,ruleComponentRef:Ge,scrollContainerRef:qe,containerRef:Ee,maintainRelativeOrder:ie,proposedSections:It,existingSections:_t,isSideBySideRef:ln,activeSideBySideSectionRef:cn,activeSideBySideRightSectionRef:an,sectionRowRefs:Ht,sectionRightRowRefs:Gt,sectionLeftRefs:Nt,sectionRightRefs:Mt,subSectionLeftRefs:$t,subSectionRightRefs:Vt,lhsBadgeRefs:Lt,rhsBadgeRefs:qt,leftContainerRef:Ke,rightContainerRef:$e,calculateLinesRef:Oe,handleResizeRef:Fe,setIsResizing:Zt,setIsArrowVisible:Xt,sideBySideCacheRef:sn,cachedConnectedPositions:De});t.useEffect(()=>{Fe.current=Ei},[Ei,Fe]),t.useEffect(()=>{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 Ge.current&&o.push(e(Ge.current,yi,t,()=>Fe.current(),()=>{})),qe.current&&o.push(e(qe.current,bi,n,()=>Fe.current(),()=>Oe.current())),Ee.current&&o.push(e(Ee.current,Ci,i,()=>Fe.current(),()=>Oe.current())),()=>{o.forEach(e=>e.disconnect()),r.forEach(e=>{null!==e.current&&(cancelAnimationFrame(e.current),e.current=null)})}},[]),t.useEffect(()=>{ln.current=Ut},[Ut]),t.useEffect(()=>{cn.current=nn},[nn]);const Ai=t.useCallback(e=>{let t="",n="0";if("number"==typeof e)t=It[e]?.nodeId||It[e]?.id||"";else{const i=String(e).split(s.DEVIATION_BADGE_SEPARATOR);t=i[0],n=i[1]||"0"}const i=ke?.[t]?.evaluation_result,o=Array.isArray(i)?i[parseInt(n,10)]:i?.[n];return!1===o?.evaluation_outputs?.guideline_flag?.rulebook_used&&F.hasGptCitationObjects(o)?1:0},[It,ke]),Ii=t.useCallback(()=>{gn(),ge(new Set),me([]),De.current=[]},[gn]),_i=t.useCallback((e,t)=>{t!==Re&&(Ii(),ve(t))},[Re,Ii]);t.useEffect(()=>{Ne||0===Re||(Ii(),ve(0))},[Re,Ne,Ii]);const Ti=t.useCallback(e=>{const t=Ke.current,n=$e.current,i=j.getVisibleGuidelineTargets(n);if(!n)return;const o="string"==typeof e&&e.includes(s.DEVIATION_BADGE_SEPARATOR);let r=e;if(o){const t=e.split(s.DEVIATION_BADGE_SEPARATOR);t.length>=2&&(r=`${t[0]}${s.DEVIATION_BADGE_SEPARATOR}${t[1]}`)}const l=Lt.current[r]?.current||Lt.current[e]?.current;if(i.length>0&&l&&t&&n){const e=i[0];ze.current&&(ze.current.style.height="0px"),Ve.current&&(Ve.current.style.height="0px"),We.current&&(We.current.style.height="0px"),He.current&&(He.current.style.height="0px"),requestAnimationFrame(()=>{const i=l.getBoundingClientRect(),o=e.getBoundingClientRect(),r=t.getBoundingClientRect(),s=n.getBoundingClientRect(),a=t.scrollTop+(i.top-r.top)+i.height/2,c=n.scrollTop+(o.top-s.top)+o.height/2,u=a-r.height/2,d=Math.max(0,u),f=t.scrollHeight-t.clientHeight,p=d>f?d-f:0,g=r.top+a-d;let h=s.top+c-g,m=0;h<0&&(m=Math.abs(h),h=0);const S=n.scrollHeight-n.clientHeight+m,x=h>S?h-S:0;We.current&&(We.current.style.height=`${p}px`),Ve.current&&(Ve.current.style.height=`${m}px`),He.current&&(He.current.style.height=`${x}px`),requestAnimationFrame(()=>{t.scrollTo({top:d,behavior:"smooth"}),n.scrollTo({top:h,behavior:"smooth"}),Oe.current&&setTimeout(()=>Oe.current(),50)})})}},[s.DEVIATION_BADGE_SEPARATOR]),Bi=t.useCallback(()=>{const e=Qe.sectionIdx,t=Qe.isOrphan;if(rt(),null==e)return;let n="left";Qe.anchorEl&&$e.current?.contains(Qe.anchorEl)&&(n="right"),Cn(e),Ct&&(ve(Ai(e)),ge(new Set([e]))),hn(e,t,{sourceSide:n,onReady:()=>{Ct&&setTimeout(()=>Ti(String(e)),150)}})},[hn,Qe.isOrphan,Qe.sectionIdx,Qe.anchorEl,rt,Cn,Ct,Ti,Ai]),wi=t.useCallback(()=>{rt(),gn(),ge(new Set),me([]),De.current=[]},[rt,gn]),Di=null!==Qe.sectionIdx&&pe.has(Qe.sectionIdx),{showDeviationNavigation:Oi,showOpenNodeRef:ji,adjustScrollForPopup:Fi}=S.useDeviationNavigation({proposedSections:It,existingSections:_t,parentDeviationRecord:Bt,expandedSections:Sn,maintainRelativeOrder:!!ie,scrollContainerRef:qe,leftContainerRef:Ke,rightContainerRef:$e,lhsBadgeRefs:Lt,rhsBadgeRefs:qt}),Pi=t.useCallback((e,t,n,i,o)=>{const r="string"==typeof i?s.safeStringify(i).trim():s.safeStringify(i?.deviation_summary).trim(),l=e.currentTarget;ut();let a="left";$e.current?.contains(l)&&(a="right");const c=()=>{if("string"==typeof t&&t.includes(s.DEVIATION_BADGE_SEPARATOR)){const e=t.split(s.DEVIATION_BADGE_SEPARATOR),n=`${e[0]}${s.DEVIATION_BADGE_SEPARATOR}${e[1]}`;return"right"===a?qt.current[n]?.current:Lt.current[n]?.current}return"right"===a?qt.current[t]?.current:Lt.current[t]?.current};if(n&&!Ct)return gn(),ge(new Set),me([]),De.current=[],void(r&&(Cn(t),requestAnimationFrame(()=>{const e=c()||l;if(e){e.getBoundingClientRect().top>.8*window.innerHeight&&e.scrollIntoView({behavior:"smooth",block:"center"})}ot({open:!0,anchorEl:e,summary:i,displayImpact:o})})));Cn(t),Ct&&(ve(Ai(t)),ge(new Set([t]))),r?setTimeout(()=>{hn(t,n,{toggleIfSame:!1,sourceSide:a,onReady:()=>{const e=c()||l;if(Ct)setTimeout(()=>Ti(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;ie?(Ke.current?.scrollBy({top:e,behavior:"smooth"}),$e.current?.scrollBy({top:e,behavior:"smooth"})):qe.current?.scrollBy({top:e,behavior:"smooth"})}}ot({open:!0,anchorEl:e,summary:i,displayImpact:o})}})},350):setTimeout(()=>{hn(t,n,{toggleIfSame:!1,sourceSide:a}),Ct&&setTimeout(()=>Ti(t),150)},350)},[hn,ut,ot,gn,Cn,Ct,ie,Ti,ke]),ki=t.useMemo(()=>{if(!K)return null;const e=K?.id?.split(":")[0];for(const t in Bt){if((Bt[t]||[]).some(t=>t.id===e))return t}return null},[K,Bt]),Ni=t.useRef({id:null,triggerMs:null}),Mi=t.useRef(null);t.useEffect(()=>{if(!K?.id)return;const e=Number(K.trigger),t=Ni.current;if(t?.id===K.id&&t?.triggerMs===e)return;if(!(K.id.includes(":")&&/:\d+$/.test(K.id))){Ni.current={id:K.id,triggerMs:e},ii(K.id);const t=It.findIndex(e=>e.id===K.id),n=_t.findIndex(e=>e.id===K.id);return void(-1===t&&-1===n||setTimeout(()=>{const e=-1!==t?t:n,i=-1===t;Ct&&ve(Ai(e)),ge(new Set([e])),mn.current(e,i,{sourceSide:i?"right":"left",onReady:()=>{Ct&&setTimeout(()=>Ti(String(e)),150)}})},400))}const[n,i]=K.id.split(":"),o=i??"0",r=`${K.id}:${e}`;Mi.current!==r&&(rt(),ut(),gn(),ge(new Set),me([]),De.current=[],Mi.current=r);let l=!1,a=0;let c=null,u=null,d=!1;const f=(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(l)return;const t=()=>{Ni.current={id:K.id,triggerMs:e}};let i=null,r=null;for(const e in Bt){const t=Bt[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 a++,void(a<30&&(c=setTimeout(p,100)));const g=Array.from(new Set([n,r.id,r.nodeId,r.contentId,r.evaluationResult?.nodeId].filter(Boolean))),h=It.findIndex(e=>e.id===i),m=_t.findIndex(e=>e.id===i),S=-1===h&&-1!==m,x=f(It,g);let R=f(_t,g);if(x&&!R&&!S){const e=x.split("-");let t=Number(e[0]);if(ie){const e=It[t]?.refIndexes?.[0],n=_t.findIndex(t=>t.selfIndex===e);-1!==n&&(t=n)}R=[t,...e.slice(1)].join("-")}if(!x&&!R)return a++,void(a<30&&(c=setTimeout(p,100)));const v=x?Number(x.split("-")[0]):h,y=R?Number(R.split("-")[0]):m,b=y>=0?y:R?Number(R.split("-")[0]):-1,C=It[v],E=_t[b],A=C&&!C.title&&!C.content,I=E&&!E.title&&!E.content,_=S||(!x&&!!R||A&&!I);if(_){if(!(ie?!!Yi.current[`right-${y}`]:!!Yi.current[String(y)])&&y>=0)return bn(y,"right"),void(c=setTimeout(p,200))}else{if(!(ie?!!Yi.current[`left-${v}`]:!!Yi.current[String(v)])&&v>=0)return bn(v,"left"),void(c=setTimeout(p,200))}const T=x||"",B=R||"",w=g.map(e=>`${e}${s.DEVIATION_BADGE_SEPARATOR}${o}`),D=w[0],O=()=>{for(const e of w){const t=Lt.current[e]?.current||null,n=qt.current[e]?.current||null;if(t||n)return{refId:e,left:t,right:n}}return{refId:D,left:null,right:null}},j=e=>`${e}${s.DEVIATION_BADGE_SEPARATOR}${T}${s.DEVIATION_BADGE_SEPARATOR}${B}`;if(!d){Cn(j(D)),d=!0,a=0;const e=()=>{const{left:e,right:t}=O();return _||!e&&!!t?t:e};return u?.(),void(c=setTimeout(()=>{l||(u=((e,t)=>{let n,i=0,o=null,r=null;const s=performance.now(),a=()=>{if(l)return;if(performance.now()-s>3e3)return void t();const c=e();if(!c||0===c.getBoundingClientRect().height)return void(n=requestAnimationFrame(a));const u=c.getBoundingClientRect(),d=u.top,f=u.height,p=null!==o&&Math.abs(d-o)<.5,g=null!==r&&Math.abs(f-r)<.5;if(p&&g){if(i++,i>=5)return void t()}else i=0;o=d,r=f,n=requestAnimationFrame(a)};return n=requestAnimationFrame(a),()=>cancelAnimationFrame(n)})(e,()=>{l||(u=null,p())}))},300))}const{refId:F,left:P,right:k}=O(),N=j(F);if(!P&&!k)return a++,void(a<30&&(c=setTimeout(p,100)));const M=_||!P&&!!k,L=M?k:P,q=ie?M?$e.current:Ke.current:qe.current;if(!L||!q)return a++,void(a<30&&(c=setTimeout(p,100)));const G=L.getBoundingClientRect();if(0===G.height)return a++,void(a<30&&(c=setTimeout(p,100)));const $=q.getBoundingClientRect(),V=G.top-$.top+q.scrollTop-$.height/2+G.height/2,H=x?.includes("-")||R?.includes("-"),z=async()=>{if(l)return;t();const e=L instanceof Element?window.getComputedStyle(L).color:"";[P,k].forEach(t=>{t&&(t.style.transition="box-shadow 300ms ease-in-out",t.style.boxShadow=`0 0 10px ${e}`)}),setTimeout(()=>{[P,k].forEach(e=>{e&&(e.style.boxShadow="")})},2e3);const n=r.evaluationResult?.deviations?.[o]||r,i=r.evaluationResult?.evaluation_outputs||r.evaluation_outputs;if(!(!!P&&!!k)&&!Ct){const e=M?qt.current[H?F:y]?.current||k:Lt.current[H?F:v]?.current||P;return Fi(e,()=>{ot({open:!0,anchorEl:e,displayImpact:K.displayImpact,summary:{...n,evaluation_outputs:i}})},{skipScroll:!0}),void U?.()}const a=(e,t)=>Promise.race([e,new Promise(e=>setTimeout(e,t))]);ie&&await Promise.all([Ke.current?a(s.waitForScrollIdle(Ke.current),600):Promise.resolve(),$e.current?a(s.waitForScrollIdle($e.current),600):Promise.resolve()]),Ct&&(ve(Ai(N)),ge(new Set([N]))),mn.current(N,!1,{toggleIfSame:!1,sourceSide:S?"right":"left",onReady:()=>{t();const e=M?qt.current[F]?.current||k:Lt.current[F]?.current||P;if(Ct)setTimeout(()=>Ti(N),150);else{const e=Lt.current[F]?.current||P,t=qt.current[F]?.current||k;e&&(e.style.scrollMarginTop="150px",e.scrollIntoView({behavior:"smooth",block:"start"})),t&&(t.style.scrollMarginTop="150px",t.scrollIntoView({behavior:"smooth",block:"start"}))}ot({open:!0,anchorEl:e,displayImpact:K.displayImpact,summary:{...n}}),U?.()}})};Math.abs(q.scrollTop-V)<=2?z():s.scrollAndWait(q,V,z)};return c=setTimeout(p,100),()=>{l=!0,c&&clearTimeout(c),u?.()}},[K?.id,K?.trigger,K?.displayImpact,Bt,It,_t,ie,ot,ii,Ct,Ai,Ti]),t.useEffect(()=>{if(!it.open)return;const e=it.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(Lt.current)||t(qt.current);if(!n)return;const i=qt.current[n]?.current||Lt.current[n]?.current;i&&i.isConnected&&ot(e=>({...e,anchorEl:i}))},[it.open,it.anchorEl,Se,pe,Sn]);const{open:Li,sectionIdx:qi,isOrphan:Gi,badgeStyle:$i,anchorEl:Vi,sectionAnchorEl:Hi}=Je;t.useEffect(()=>{if(!$.isStreamingEnabled)return;if(!Li||null==qi)return;if(qi===wn)return;const e="string"==typeof qi?qi.split(s.DEVIATION_BADGE_SEPARATOR)[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(It,e):null,i=e&&"string"==typeof e?t(_t,e):null,o="number"==typeof qi?It[qi]||null:n||e&&(k?.nodes?.[e]||k?.[e])||null,r="number"==typeof qi?_t[qi]||null:i,l=Zn(Vi,o,r,qi,Gi,$i);Xe(e=>{if(!e.open)return e;return s.safeStringify(e.cognitiveData)===s.safeStringify(l.cognitiveData)&&s.safeStringify(e.deviationData)===s.safeStringify(l.deviationData)&&e.sectionTitle===l.sectionTitle&&e.refSectionTitle===l.refSectionTitle?e:{...e,...l,open:!0,anchorEl:e.anchorEl,sectionAnchorEl:e.sectionAnchorEl}})},[Li,qi,Gi,$i,Vi,Hi,It,_t,Zn]);const zi=t.useCallback(({section:t,keyPath:n,depth:i=0,columnKey:o="left",parentNodeId:r="",sectionOffset:s,rhsOrphanVisualIndexes:l})=>e.jsx(v.default,{section:t,keyPath:n,depth:i,columnKey:o,parentNodeId:r,sectionOffset:s,rhsOrphanVisualIndexes:l}),[]),Wi=t.useMemo(()=>It.map((t,n)=>{const i=!t?.title&&!t?.content,o=!t?.refIndexes||0===t.refIndexes.length;return i&&o&&ie?null:e.jsx(y.default,{section:t,idx:n},t?.layoutKey??t?.id??`left-row-${n}`)}),[It,ie]),Ki=t.useMemo(()=>_t.map((t,n)=>{const i=!t?.title&&!t?.content,o=!t?.refIndexes||0===t.refIndexes.length;return i&&o&&ie?null:e.jsx(b.default,{section:t,idx:n},t?.layoutKey??t?.id??`right-row-${n}`)}),[_t,ie]),Ui=t.useRef(ei);t.useEffect(()=>{Ui.current=ei},[ei]);const Yi=t.useRef(Sn);t.useEffect(()=>{Yi.current=Sn},[Sn]);const Ji=t.useRef(Pi);t.useEffect(()=>{Ji.current=Pi},[Pi]);const Xi=t.useRef(wi);t.useEffect(()=>{Xi.current=wi},[wi]);const Qi=t.useRef(bn);t.useEffect(()=>{Qi.current=bn},[bn]);const Zi=t.useRef(yn);t.useEffect(()=>{Zi.current=yn},[yn]);const eo=t.useRef(zi);t.useEffect(()=>{eo.current=zi},[zi]);const to=t.useRef(gn);t.useEffect(()=>{to.current=gn},[gn]);const{cacheVersion:no,getCacheKey:io,getCacheEntry:oo,fetchCitationContext:ro,prefetchCitationContexts:so,abortCitationContexts:lo}=x.useOnDemandCitationCache(ne),ao=t.useMemo(()=>({isGuidelineMode:Ct,maintainRelativeOrder:!!ie,showDeviationBadges:le,isProposingFix:Y,proposingFixNodeId:J,isRedlineFlow:X,isSideBySide:Ut,activeSideBySideSection:nn,scrollSyncLocked:Se,toggleScrollSyncLocked:An,summaryPopupAnchorEl:it.anchorEl,connectedSections:pe,proposedSections:It,existingSections:_t,deviationNumberRegistry:wt,deviationParentRegistry:Dt,treeData:k,displayConfig:$,deviationAnalysisStatus:ye,resolvedMarkdownStyles:Le,unifiedNumbering:In,expandedSections:Sn,expandedSubSections:Rn,setExpandedSubSections:vn,getSectionCompareStyle:li,getSubSectionCompareStyle:ai,getBadgeRef:Kt,getSectionRowRef:zt,getSubSectionRef:Wt,sectionLeftRefs:Nt,sectionRightRefs:Mt,sectionRowRefs:Ht,sectionRightRowRefs:Gt,subSectionLeftRefs:$t,subSectionRightRefs:Vt,lhsBadgeRefs:Lt,rhsBadgeRefs:qt,openMoreFunctionsPopup:Mn,handleOpenSummaryPopup:Ln,openSummaryPopup:Ln,handleCloseSummaryPopup:qn,toggleSection:Gn,handleSubSectionToggle:$n,renderSubSectionAccordion:Vn,resetSideBySide:Hn,setConnectedSections:ge,setConnectedLines:me,cachedConnectedPositions:De,showDeviationNavigation:Oi,showOpenNodeRef:ji,deviationNodeIdToView:K?.id,deviationTargetParentId:ki,guidelinesData:Z,gptWebCitationConfig:te,onDemandCitationConfig:ne,onDemandCitationCacheVersion:no,getOnDemandCitationCacheKey:io,getOnDemandCitationCacheEntry:oo,fetchOnDemandCitationContext:ro,prefetchOnDemandCitationContexts:so,abortOnDemandCitationContexts:lo}),[Ct,ie,le,Y,J,X,Ut,nn,Se,An,it.anchorEl,pe,It,_t,wt,$,ye,Le,In,Sn,Rn,vn,li,ai,Kt,zt,Wt,Oi,ji,K,ki,Z,te,ne,no,io,oo,ro,so,lo]),co=s.safeStringify(Je.sectionTitle||Rt||St),uo=s.safeStringify(Ct?yt||bt||Je.refSectionTitle:Je.refSectionTitle||yt||bt);return e.jsx(E.CompareContextProvider,{value:ao,children:e.jsxs(n.Box,{ref:Ge,sx:{display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif',overflow:"visible",position:"relative"},children:[ae&&e.jsx(n.Box,{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.jsx(d.default,{})}),it.open&&e.jsx(C.default,{open:it.open,anchorEl:it.anchorEl,containerEl:ri.current,clipTopEl:Ae.current,scrollContainerEl:qe.current,onClose:wi,summary:it.summary,displayImpact:it.displayImpact,isScrollLocked:Se}),e.jsx(u.default,{open:Qe.open,anchorEl:Qe.anchorEl,maintainRelativeOrder:!!ie,sectionTitle:Qe.sectionTitle,referenceSectionTitle:Qe.refSectionTitle,onClose:dt,onOpenCognitiveCompare:at,onOpenSideBySide:Bi,onConnect:ti,isConnected:Di,isOrphan:!Ct&&!!Qe.isOrphan,isGuidelineMode:Ct,hasGuidelineMatches:Qe.hasGuidelineMatches}),Je.open&&e.jsx(c.default,{open:Je.open,popupRef:lt,position:et,popupConfig:z,onClose:()=>{tt(null),Xe(e=>({...e,open:!1})),st(null)},markdownStyles:q,sectionTitle:co,referenceSectionTitle:uo,cognitiveData:Je.cognitiveData,anchorEl:Je.anchorEl,sectionAnchorEl:Je.sectionAnchorEl,scrollContainerEl:qe.current,badgeStyle:Je.badgeStyle,docData:Je.docData,deviationData:Je.deviationData,isLoading:Je.isLoading,sourceNodeId:Je.sourceNodeId,deviationKey:Je.deviationKey,baseContentId:Je.baseContentId,compareContentIds:Je.compareContentIds}),e.jsx(n.Snackbar,{open:!!ue,autoHideDuration:8e3,onClose:()=>de(null),anchorOrigin:{vertical:"top",horizontal:"center"},children:e.jsx(n.Alert,{onClose:()=>de(null),severity:"error",sx:{width:"100%",whiteSpace:"pre-line"},children:ue})}),e.jsx(R.default,{componentHeaderText:P,displayConfig:$,maintainRelativeOrder:ie,onCollapseAll:xi,showCollapseAll:Ri,onToggleView:e=>{ce(!0),setTimeout(()=>{oe(!e),H?.(!e),xe(!1),gn(),rt(),ge(new Set),me([]),De.current=[],requestAnimationFrame(()=>{requestAnimationFrame(()=>{setTimeout(()=>{ce(!1)},600)})})},50)}}),e.jsx(n.Box,{ref:qe,onScroll:Si,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:ie?"stretch":"flex-start",bgcolor:"#FFFFFF",overflowY:ie?"visible":"auto",borderTop:Tn&&Bn?"none":"1.5px solid #EEF0F4"},children:e.jsx(n.Box,{sx:{display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px",minHeight:0,...ie?{flex:1}:{}},children:e.jsxs(n.Box,{ref:Ee,sx:{display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"100px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0,...ie?{flex:1,overflow:"visible"}:{}},children:[e.jsx(B.default,{svgContainerRef:Ce,svgDimensions:gi,isResizing:Qt,overallConnector:fi,rootDeviationStyle:Pn,lines:ui,isSideBySide:Ut,activeSideBySideSection:nn,isArrowVisible:Yt,maintainRelativeOrder:ie,proposedSections:It,existingSections:_t,cognitivePopup:Je,activeBadgeId:nt,closeCognitivePopup:ut,setActiveBadgeId:st,openCognitivePopupFromState:ct,buildSectionPopupState:Zn,connectedLines:he,isGuidelineMode:Ct,deviationAnalysisStatus:ye,pathRefs:we}),e.jsxs(n.Box,{sx:{border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)",...ie?{flex:1,overflow:"visible",minHeight:0}:{}},children:[e.jsx(n.Box,{ref:Ae,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.jsx(n.Tooltip,{title:St,placement:"top",children:e.jsx(n.Typography,{sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"},children:St})})}),e.jsxs(n.Box,{ref:Ke,onScroll:Si,sx:{p:"12px",display:"flex",flexDirection:"column",...ie?{flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-180px",pr:"192px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{}},children:[e.jsx("div",{ref:ze,style:{width:"100%",height:"0px",flexShrink:0}}),jt&&Wi,e.jsx("div",{ref:We,style:{width:"100%",height:"0px",flexShrink:0}})]})]}),e.jsx(n.Box,{ref:ri,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"},children:e.jsx(n.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0},children:e.jsxs(n.Box,{onClick:e=>{e.stopPropagation(),Je.open&&nt===wn?ut():(st(wn),ct(Zn(e.currentTarget,{title:Un,content:"",evaluationResult:Dn,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},{title:Jn,content:""},wn,!0,{...Pn,label:""})))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:Pn.badgeBg,color:Pn.badgeText,border:`1px solid ${Pn.badgeBorder}`,fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"},children:[jn?e.jsx(n.Tooltip,{title:"Deviation data generation in progress",placement:"top",arrow:!0,children:e.jsx(n.Box,{component:"span",sx:{display:"inline-flex",alignItems:"center"},children:e.jsx(f.default,{color:Pn.badgeText})})}):Fn??e.jsx(f.default,{color:Pn.badgeText}),e.jsx(n.Box,{component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}},children:e.jsx(o.ButtonCognitiveIcon,{})}),e.jsx(i.ChevronDown,{size:11,style:{transform:Je.open&&nt===wn?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]})})}),e.jsxs(n.Box,{sx:{border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0,...ie?{flex:1,overflow:"visible",minHeight:0}:{}},children:[en&&e.jsx(r.default,{sections:11}),e.jsx(n.Box,{ref:Ie,sx:{p:"8px",bgcolor:Ct?"#F1F3F5":"#F7F8FA",borderBottom:"1px solid #D7DCE2",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center",flexShrink:0},children:Ct?e.jsxs(n.Tabs,{value:Re,onChange:_i,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.jsx(n.Tab,{label:e.jsx(n.Tooltip,{title:bt,placement:"top",children:e.jsx(n.Box,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block",width:"100%"},children:"Redline Guidelines"})})}),Ne&&e.jsx(n.Tab,{label:e.jsx(n.Tooltip,{title:"Web & GPT Sources",placement:"top",children:e.jsx(n.Box,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block",width:"100%"},children:"Web & GPT Sources"})})})]}):e.jsx(n.Tooltip,{title:bt,placement:"top",children:e.jsx(n.Typography,{sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"},children:bt})})}),e.jsxs(n.Box,{ref:$e,onScroll:Si,sx:{p:Ct?"0px":"12px",display:"flex",flexDirection:"column",...ie?{flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-150px",pl:"165px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{}},children:[e.jsx("div",{ref:Ve,style:{width:"100%",height:"0px",flexShrink:0}}),Ct?Z?0!==Re&&Ne?e.jsx(D.default,{deviationData:W,connectedSections:pe,proposedSections:It}):e.jsx(w.default,{guidelinesData:Z,deviationData:W,connectedSections:pe,proposedSections:It}):e.jsx(O.GuidelineSkeleton,{}):jt&&Ki,e.jsx("div",{ref:He,style:{width:"100%",height:"0px",flexShrink:0}})]})]})]})})})]})})};
2
2
  //# sourceMappingURL=CognitiveCompare.js.map