@viswa-test/test-citation 0.0.323 → 0.0.325

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 (154) hide show
  1. package/README.md +9 -3
  2. package/dist/cjs/features/ChatCitation/InternalChatCitationRenderer.js +1 -1
  3. package/dist/cjs/features/CodeCitation/CodeCitation.js +1 -1
  4. package/dist/cjs/features/CodeCitation/_components/CodeCitationPopup.js +1 -1
  5. package/dist/cjs/features/CodeCitation/_components/RepoAndBranchTag.js +2 -0
  6. package/dist/cjs/features/CodeCitation/_components/RepoAndBranchTag.js.map +1 -0
  7. package/dist/cjs/features/CognitiveCompare/CitationAnchor.js +1 -1
  8. package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js +1 -1
  9. package/dist/cjs/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
  10. package/dist/cjs/features/CognitiveCompare/CognitivePopup.js +1 -1
  11. package/dist/cjs/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js +1 -1
  12. package/dist/cjs/features/CognitiveCompare/Guidelines/components/WebGptPanel.js +1 -1
  13. package/dist/cjs/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js +1 -1
  14. package/dist/cjs/features/CognitiveCompare/components/SectionAccordion.js +1 -1
  15. package/dist/cjs/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
  16. package/dist/cjs/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
  17. package/dist/cjs/features/CognitiveCompare/hooks/useCompareData.js +1 -1
  18. package/dist/cjs/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
  19. package/dist/cjs/features/CognitiveCompare/hooks/useSideBySide.js +1 -1
  20. package/dist/cjs/features/CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.js +1 -1
  21. package/dist/cjs/features/GptWebCitation/GptWebCitation.js +1 -1
  22. package/dist/cjs/features/GptWebCitation/GptWebCitationImageCitation.js +1 -1
  23. package/dist/cjs/features/GptWebCitation/utils/fixedHeight.utils.js +1 -1
  24. package/dist/cjs/features/PdfViewer/PdfContainer.js +1 -1
  25. package/dist/cjs/features/PdfViewer/PdfStyle.js +1 -1
  26. package/dist/cjs/features/PdfViewer/PdfToolbar.js +1 -1
  27. package/dist/cjs/features/PdfViewer/PdfViewer.js +1 -1
  28. package/dist/cjs/features/PromptemonBlockViewer/PromptemonBlockViewer.js +1 -1
  29. package/dist/cjs/features/PromptemonViewer/PromptemonViewer.js +1 -1
  30. package/dist/cjs/features/SPBAnalysisPanel/Cognitivereasoningpanel.js +1 -1
  31. package/dist/cjs/features/SPBAnalysisPanel/DependencyGraph.js +1 -1
  32. package/dist/cjs/features/SPBAnalysisPanel/Markdownrenderer.js +1 -1
  33. package/dist/cjs/features/SPBAnalysisPanel/Spbanalysispanel.js +1 -1
  34. package/dist/cjs/features/SegmentReviewComponents/BoundaryCard.js +1 -1
  35. package/dist/cjs/features/SegmentReviewComponents/SegmentReviewPdfWrapper.js +1 -1
  36. package/dist/cjs/features/SegmentReviewComponents/helper.js +1 -1
  37. package/dist/cjs/hooks/useOnDemandCitationFetch.js +1 -1
  38. package/dist/cjs/index.js +1 -1
  39. package/dist/cjs/service/onDemandApi.js +1 -1
  40. package/dist/features/ChatCitation/InternalChatCitationRenderer.js +1 -1
  41. package/dist/features/CodeCitation/CodeCitation.js +1 -1
  42. package/dist/features/CodeCitation/_components/CodeCitationPopup.js +1 -1
  43. package/dist/features/CodeCitation/_components/RepoAndBranchTag.js +2 -0
  44. package/dist/features/CodeCitation/_components/RepoAndBranchTag.js.map +1 -0
  45. package/dist/features/CognitiveCompare/CitationAnchor.js +1 -1
  46. package/dist/features/CognitiveCompare/CognitiveCompare.js +1 -1
  47. package/dist/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
  48. package/dist/features/CognitiveCompare/CognitivePopup.js +1 -1
  49. package/dist/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js +1 -1
  50. package/dist/features/CognitiveCompare/Guidelines/components/WebGptPanel.js +1 -1
  51. package/dist/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js +1 -1
  52. package/dist/features/CognitiveCompare/components/SectionAccordion.js +1 -1
  53. package/dist/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
  54. package/dist/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
  55. package/dist/features/CognitiveCompare/hooks/useCompareData.js +1 -1
  56. package/dist/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
  57. package/dist/features/CognitiveCompare/hooks/useSideBySide.js +1 -1
  58. package/dist/features/CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.js +1 -1
  59. package/dist/features/GptWebCitation/GptWebCitation.js +1 -1
  60. package/dist/features/GptWebCitation/GptWebCitationImageCitation.js +1 -1
  61. package/dist/features/GptWebCitation/utils/fixedHeight.utils.js +1 -1
  62. package/dist/features/PdfViewer/PdfContainer.js +1 -1
  63. package/dist/features/PdfViewer/PdfStyle.js +1 -1
  64. package/dist/features/PdfViewer/PdfToolbar.js +1 -1
  65. package/dist/features/PdfViewer/PdfViewer.js +1 -1
  66. package/dist/features/PromptemonBlockViewer/PromptemonBlockViewer.js +1 -1
  67. package/dist/features/PromptemonViewer/PromptemonViewer.js +1 -1
  68. package/dist/features/SPBAnalysisPanel/Cognitivereasoningpanel.js +1 -1
  69. package/dist/features/SPBAnalysisPanel/DependencyGraph.js +1 -1
  70. package/dist/features/SPBAnalysisPanel/Markdownrenderer.js +1 -1
  71. package/dist/features/SPBAnalysisPanel/Spbanalysispanel.js +1 -1
  72. package/dist/features/SegmentReviewComponents/BoundaryCard.js +1 -1
  73. package/dist/features/SegmentReviewComponents/SegmentReviewPdfWrapper.js +1 -1
  74. package/dist/features/SegmentReviewComponents/helper.js +1 -1
  75. package/dist/hooks/useOnDemandCitationFetch.js +1 -1
  76. package/dist/index.js +1 -1
  77. package/dist/service/onDemandApi.js +1 -1
  78. package/dist/types/src/CodeCitationTest.d.ts.map +1 -1
  79. package/dist/types/src/PdfViewerTest.d.ts.map +1 -1
  80. package/dist/types/src/Spbanalysispaneltest.d.ts.map +1 -1
  81. package/dist/types/src/features/ChatCitation/InternalChatCitationRenderer.d.ts.map +1 -1
  82. package/dist/types/src/features/CodeCitation/CodeCitation.d.ts +2 -0
  83. package/dist/types/src/features/CodeCitation/CodeCitation.d.ts.map +1 -1
  84. package/dist/types/src/features/CodeCitation/_components/CodeCitationPopup.d.ts +3 -0
  85. package/dist/types/src/features/CodeCitation/_components/CodeCitationPopup.d.ts.map +1 -1
  86. package/dist/types/src/features/CodeCitation/_components/RepoAndBranchTag.d.ts +8 -0
  87. package/dist/types/src/features/CodeCitation/_components/RepoAndBranchTag.d.ts.map +1 -0
  88. package/dist/types/src/features/CognitiveCompare/CitationAnchor.d.ts.map +1 -1
  89. package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts +1 -1
  90. package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts.map +1 -1
  91. package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts +1 -1
  92. package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts.map +1 -1
  93. package/dist/types/src/features/CognitiveCompare/CognitiveComparehelpers.d.ts +0 -12
  94. package/dist/types/src/features/CognitiveCompare/CognitiveComparehelpers.d.ts.map +1 -1
  95. package/dist/types/src/features/CognitiveCompare/Guidelines/components/GuidelinePanel.d.ts.map +1 -1
  96. package/dist/types/src/features/CognitiveCompare/Guidelines/components/WebGptPanel.d.ts.map +1 -1
  97. package/dist/types/src/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.d.ts +1 -14
  98. package/dist/types/src/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.d.ts.map +1 -1
  99. package/dist/types/src/features/CognitiveCompare/components/SectionAccordion.d.ts.map +1 -1
  100. package/dist/types/src/features/CognitiveCompare/components/SubSectionAccordion.d.ts.map +1 -1
  101. package/dist/types/src/features/CognitiveCompare/hooks/memoizedMarkdown.d.ts.map +1 -1
  102. package/dist/types/src/features/CognitiveCompare/hooks/useCompareData.d.ts +1 -1
  103. package/dist/types/src/features/CognitiveCompare/hooks/useCompareData.d.ts.map +1 -1
  104. package/dist/types/src/features/CognitiveCompare/hooks/useCompareLayout.d.ts +1 -0
  105. package/dist/types/src/features/CognitiveCompare/hooks/useCompareLayout.d.ts.map +1 -1
  106. package/dist/types/src/features/CognitiveCompare/hooks/useLinesCalculator.d.ts.map +1 -1
  107. package/dist/types/src/features/CognitiveCompare/hooks/useSideBySide.d.ts.map +1 -1
  108. package/dist/types/src/features/CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.d.ts +0 -1
  109. package/dist/types/src/features/CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.d.ts.map +1 -1
  110. package/dist/types/src/features/GptWebCitation/GptWebCitation.d.ts.map +1 -1
  111. package/dist/types/src/features/GptWebCitation/GptWebCitationImageCitation.d.ts +1 -2
  112. package/dist/types/src/features/GptWebCitation/GptWebCitationImageCitation.d.ts.map +1 -1
  113. package/dist/types/src/features/GptWebCitation/types.d.ts +0 -11
  114. package/dist/types/src/features/GptWebCitation/types.d.ts.map +1 -1
  115. package/dist/types/src/features/GptWebCitation/utils/fixedHeight.utils.d.ts +0 -2
  116. package/dist/types/src/features/GptWebCitation/utils/fixedHeight.utils.d.ts.map +1 -1
  117. package/dist/types/src/features/PdfViewer/PdfContainer.d.ts +5 -3
  118. package/dist/types/src/features/PdfViewer/PdfContainer.d.ts.map +1 -1
  119. package/dist/types/src/features/PdfViewer/PdfStyle.d.ts.map +1 -1
  120. package/dist/types/src/features/PdfViewer/PdfToolbar.d.ts +7 -2
  121. package/dist/types/src/features/PdfViewer/PdfToolbar.d.ts.map +1 -1
  122. package/dist/types/src/features/PdfViewer/PdfViewer.d.ts +26 -2
  123. package/dist/types/src/features/PdfViewer/PdfViewer.d.ts.map +1 -1
  124. package/dist/types/src/features/PromptemonBlockViewer/PromptemonBlockViewer.d.ts +15 -2
  125. package/dist/types/src/features/PromptemonBlockViewer/PromptemonBlockViewer.d.ts.map +1 -1
  126. package/dist/types/src/features/SPBAnalysisPanel/Cognitivereasoningpanel.d.ts +31 -1
  127. package/dist/types/src/features/SPBAnalysisPanel/Cognitivereasoningpanel.d.ts.map +1 -1
  128. package/dist/types/src/features/SPBAnalysisPanel/DependencyGraph.d.ts +36 -2
  129. package/dist/types/src/features/SPBAnalysisPanel/DependencyGraph.d.ts.map +1 -1
  130. package/dist/types/src/features/SPBAnalysisPanel/Markdownrenderer.d.ts +7 -1
  131. package/dist/types/src/features/SPBAnalysisPanel/Markdownrenderer.d.ts.map +1 -1
  132. package/dist/types/src/features/SPBAnalysisPanel/Spbanalysispanel.d.ts +86 -1
  133. package/dist/types/src/features/SPBAnalysisPanel/Spbanalysispanel.d.ts.map +1 -1
  134. package/dist/types/src/features/SPBAnalysisPanel/index.d.ts +1 -1
  135. package/dist/types/src/features/SPBAnalysisPanel/index.d.ts.map +1 -1
  136. package/dist/types/src/features/SegmentReviewComponents/BoundaryCard.d.ts +4 -2
  137. package/dist/types/src/features/SegmentReviewComponents/BoundaryCard.d.ts.map +1 -1
  138. package/dist/types/src/features/SegmentReviewComponents/SegmentReviewPdfWrapper.d.ts.map +1 -1
  139. package/dist/types/src/features/SegmentReviewComponents/helper.d.ts +5 -5
  140. package/dist/types/src/features/SegmentReviewComponents/helper.d.ts.map +1 -1
  141. package/dist/types/src/features/SegmentReviewComponents/helper.test.d.ts +2 -0
  142. package/dist/types/src/features/SegmentReviewComponents/helper.test.d.ts.map +1 -0
  143. package/dist/types/src/features/SegmentReviewComponents/index.d.ts +4 -7
  144. package/dist/types/src/features/SegmentReviewComponents/index.d.ts.map +1 -1
  145. package/dist/types/src/features/SegmentReviewComponents/reviewStepAdapters.d.ts +1 -0
  146. package/dist/types/src/features/SegmentReviewComponents/reviewStepAdapters.d.ts.map +1 -1
  147. package/dist/types/src/hooks/useOnDemandCitationFetch.d.ts.map +1 -1
  148. package/dist/types/src/index.d.ts +6 -0
  149. package/dist/types/src/index.d.ts.map +1 -1
  150. package/dist/types/src/service/onDemandApi.d.ts +2 -2
  151. package/dist/types/src/service/onDemandApi.d.ts.map +1 -1
  152. package/dist/types/src/types/onDemandApi.types.d.ts +5 -0
  153. package/dist/types/src/types/onDemandApi.types.d.ts.map +1 -1
  154. package/package.json +9 -4
@@ -1,2 +1,2 @@
1
- import{__spreadArray as n,__assign as e}from"tslib";import{jsxs as i,jsx as o}from"react/jsx-runtime";import t,{useEffect as l}from"react";import{Box as r,Accordion as d,AccordionSummary as a,Tooltip as u,Typography as c,AccordionDetails as s}from"@mui/material";import{ChevronUp as v,ChevronDown as f}from"lucide-react";import{MemoizedMarkdown as p}from"../hooks/memoizedMarkdown.js";import{useCompareContext as h}from"../CompareContext.js";import{hasValue as g,hasMeaningfulRedlineTags as m,safeStringify as x,stripRedlineTags as I,hasSingleMappedLhsSection as y,generateColorPalette as b,getLhsDeviationDisplayIndexes as w,DEVIATION_BADGE_SEPARATOR as S,isMissingStr as R,getRhsMappedSectionNumber as M,findTextMatchRange as _}from"../CognitiveComparehelpers.js";import{DEFAULT_DEVIAION_COLOR as F}from"../CognitiveCompareConstants.js";import{normalizeRedlineMarkdown as k}from"../utils/normalizeRedlineMarkdown.js";var N=function(N){var B,C,E,A,O,j,W,T,D,P,z,K,G,L,X,H=N.section,V=N.idx,Y=N.columnKey,q=N.colRef,J=N.mb,Q=void 0===J?1:J,U=N.isExpanded,Z=N.onToggle,$=N.navigation,nn=N.parentNodeId,en=void 0===nn?"":nn,on=h(),tn=on.showOpenNodeRef,ln=on.resolvedMarkdownStyles,rn=on.maintainRelativeOrder,dn=on.showDeviationBadges,an=void 0!==dn&&dn,un=on.renderSubSectionAccordion,cn=on.treeData,sn=on.proposedSections,vn=on.existingSections,fn=on.deviationNumberRegistry,pn=on.deviationParentRegistry,hn=on.getBadgeRef,gn=on.openSummaryPopup,mn=on.getSectionCompareStyle,xn=on.connectedSections,In=on.openMoreFunctionsPopup,yn=on.isProposingFix,bn=on.proposingFixNodeId,wn=on.isRedlineFlow,Sn=on.isSideBySide,Rn=on.activeSideBySideSection,Mn=on.scrollSyncLocked,_n=on.unifiedNumbering,Fn=on.toggleScrollSyncLocked,kn=on.summaryPopupAnchorEl,Nn="".concat(Sn?"1":"0","-").concat(String(null!=Rn?Rn:"")),Bn=(null===(B=H.displayTitle)||void 0===B||B)&&g(H.title),Cn=!(!yn||!bn||"left"!==Y||H.id!==bn&&H.nodeId!==bn),En=m(H.content),An="boolean"==typeof wn?wn:En,On=En,jn=An&&En,Wn=t.useMemo(function(){return jn?k(x(H.content)):x(H.content)},[H.content,jn]),Tn=jn?I(Wn):H.content,Dn=jn?Wn:void 0,Pn=(null===(C=H.displayContent)||void 0===C||C||En)&&g(H.content),zn=!Bn&&!Pn,Kn=H.title;Bn||(Kn=Pn?"No Title Found":"No Matching Section Found");var Gn="left"===Y&&(H.isMultipleMapping||(null!==(A=null===(E=H.refContentIds)||void 0===E?void 0:E.length)&&void 0!==A?A:1)>1),Ln="left"===Y&&Kn.length>29?"".concat(Kn.slice(0,29).trimEnd(),"..."):Kn,Xn=H.evaluationResult;if(!Xn&&"right"===Y)if(rn){var Hn=null===(O=H.refIndexes)||void 0===O?void 0:O[0],Vn=sn.find(function(n){return n.selfIndex===Hn});Xn=null==Vn?void 0:Vn.evaluationResult}else Xn=null===(j=sn[V])||void 0===j?void 0:j.evaluationResult;var Yn=null===(W=null==cn?void 0:cn.input_index_map)||void 0===W?void 0:W[0],qn=null===(T=null==cn?void 0:cn.input_index_map)||void 0===T?void 0:T[1],Jn="left"===Y?qn:Yn,Qn=function(n,e){var i;if(!e||!n)return null;for(var o=0,t=n;o<t.length;o++){var l=t[o];if(l.id===e||l.nodeId===e||l.contentId===e)return l;if(null===(i=l.subsections)||void 0===i?void 0:i.length){var r=Qn(l.subsections,e);if(r)return r}}return null},Un="left"===Y?H:Qn(sn,H.id),Zn="right"===Y?H:Qn(vn,H.id),$n=t.useMemo(function(){if(!rn)return 0;var n=1/0,e=function(n){var e=x(n||"").replace(/\\n/g,"\n");return m(e)?I(k(e)):e},i=function(o,t,l,r){if(o){var d=o.nodeId||o.id;if(r&&"right"===Y){var a=sn.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(o.selfIndex)});a.length>0&&(d=a[0].nodeId||a[0].id)}var u=o.nodeId||o.id||(null==t?void 0:t.nodeId)||(null==t?void 0:t.id)||(null==l?void 0:l.nodeId)||(null==l?void 0:l.id),c=o.evaluationResult||(null==t?void 0:t.evaluationResult)||(null==l?void 0:l.evaluationResult),s=(null==c?void 0:c.deviations)||{};Object.keys(s).forEach(function(i){var r,a=null===(r=s[i])||void 0===r?void 0:r[en];if(function(n,i){if("string"!=typeof i||R(i))return!1;var o=e(null==n?void 0:n.content),t=e(i);return!!t&&!!_(o,t)}("left"===Y?t||o:l||o,a)){var c="".concat(d).concat(S).concat(i),v=null==fn?void 0:fn[c];null!=v&&v<n&&(n=v);var f="".concat(u).concat(S).concat(i),p=null==fn?void 0:fn[f];null!=p&&p<n&&(n=p)}});for(var v=o.subsections||[],f=(null==t?void 0:t.subsections)||[],p=(null==l?void 0:l.subsections)||[],h=Math.max(v.length,f.length,p.length),g=0;g<h;g++)i(v[g],f[g],p[g],!1)}},o="right"===Y?sn.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(H.selfIndex)}):[];if(1===o.length){var t=o[0];(t.refIndexes||[]).map(function(n){return vn.find(function(e){return e.selfIndex===n})}).filter(Boolean).forEach(function(n){i(n,t,n,!0)})}else i(H,Un,Zn,!0);return n!==1/0?n-1:0},[H,Un,Zn,Y,en,fn,rn,sn,vn]);if(rn)if("left"===Y){var ne=null===(D=H.refIndexes)||void 0===D?void 0:D[0],ee=vn.findIndex(function(n){return n.selfIndex===ne});Zn=-1!==ee?vn[ee]:Qn(vn,H.id)}else{var ie=null===(P=H.refIndexes)||void 0===P?void 0:P[0],oe=sn.findIndex(function(n){return n.selfIndex===ie});Un=-1!==oe?sn[oe]:Qn(sn,H.id)}var te="left"===Y?!Zn:!Un,le=rn&&"right"===Y&&y(H,sn),re=Xn||(null==Un?void 0:Un.evaluationResult)||(null==Zn?void 0:Zn.evaluationResult),de=null!==(G=null===(K=null===(z=null==re?void 0:re.evaluation_outputs)||void 0===z?void 0:z.metadata)||void 0===K?void 0:K.label_color)&&void 0!==G?G:F,ae=b(de).highlightBg,ue=(null==re?void 0:re.deviations)||{},ce=t.useMemo(function(){return rn&&"right"===Y?w(sn,Yn,fn):new Map},[rn,Y,sn,Yn,fn]),se=H.nodeId||H.id;if(rn&&"left"!==Y){var ve=sn.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(H.selfIndex)});ve.length>0?se=ve[0].nodeId||ve[0].id:(null==Un?void 0:Un.id)&&(se=Un.nodeId||Un.id)}var fe=t.useMemo(function(){var n,e=new Map;if(!rn||"right"!==Y)return e;var i=1,o=sn.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(H.selfIndex)}),t=1===o.length&&1===(null===(n=o[0].refIndexes)||void 0===n?void 0:n.length),l=function(n){return x(n||"").replace(/\\n/g,"\n")},r=function(n,e){var i=e?o[0]:Qn(sn,n.nodeId||n.id||n.contentId);return{lhsNode:i,evalResult:n.evaluationResult||(null==i?void 0:i.evaluationResult),registryNodeId:i?i.nodeId||i.id:n.nodeId||n.id}};if(t){var d=function(n,e){if(void 0===e&&(e=!1),n){var o=r(n,e),t=o.lhsNode,a=o.evalResult,u=o.registryNodeId,c=l(n.content);Object.entries((null==a?void 0:a.deviations)||{}).forEach(function(n){var e=n[0],o=n[1],r=o[en],d=l(r);if(!!t&&!R(o[Jn])&&d&&_(c,d)){var a="".concat(u).concat(S).concat(e),s=fn[a];null!=s&&(i=Math.max(i,Math.max(1,s-($n||0))+1))}}),(n.subsections||[]).forEach(function(n){return d(n)})}};d(H,!0)}var a=function(n,o){if(void 0===o&&(o=!1),n){var t=r(n,o),d=t.lhsNode,u=t.evalResult,c=t.registryNodeId,s=(null==u?void 0:u.deviations)||{},v=l(n.content);Object.entries(s).map(function(n){var e,i,o,t=n[0],r=n[1],a=r[en],u=!d||R(r[Jn]),s=l(a),f=s&&null!==(i=null===(e=_(v,s))||void 0===e?void 0:e.start)&&void 0!==i?i:-1,p="".concat(c).concat(S).concat(t);return{refId:p,isRenderable:u&&!!s&&!R(a),position:f,registryIndex:null!==(o=fn[p])&&void 0!==o?o:Number.MAX_SAFE_INTEGER}}).filter(function(n){return n.isRenderable}).sort(function(n,e){return(-1===n.position?Number.MAX_SAFE_INTEGER:n.position)-(-1===e.position?Number.MAX_SAFE_INTEGER:e.position)||n.registryIndex-e.registryIndex}).forEach(function(n){e.set(n.refId,i++)}),(n.subsections||[]).forEach(function(n){return a(n)})}};return a(H,!0),e},[rn,Y,H,sn,en,Jn,fn,$n]),pe=Object.keys(ue)[0],he=pe?"".concat(se).concat(S).concat(pe):null,ge=he?null==pn?void 0:pn[he]:null,me=V+1;if(rn&&_n){var xe="left"===Y?_n.leftNums.get(null==H?void 0:H.id):_n.rightNums.get(null==H?void 0:H.id);te&&void 0!==xe?me=xe:null!=ge&&ge>=0?me=ge:void 0!==xe&&(me=xe)}else null!=ge&&ge>=0&&(me=ge);var Ie=Math.max.apply(Math,n([0],Object.keys(ue).map(function(n){return fn["".concat(se).concat(S).concat(n)]}).filter(function(n){return"number"==typeof n&&Number.isFinite(n)}),!1))+1,ye=Object.entries(ue).map(function(n){var e,i=n[0],o=n[1],t="".concat(se).concat(S).concat(i);return{deviationKey:i,deviationMap:o,refId:t,currentIndex:null!==(e=fn[t])&&void 0!==e?e:Ie++}});ye.sort(function(n,e){return n.currentIndex-e.currentIndex});var be,we,Se=ye.map(function(n){var i,o,t,l,r,d,a=n.deviationKey,u=n.deviationMap,c=n.refId,s=n.currentIndex,v=u[en],f=R(v);if(f)v="";else if(!v)return null;var p=V,h=V;if(rn)if("left"===Y){var g=null===(i=H.refIndexes)||void 0===i?void 0:i[0],m=vn.findIndex(function(n){return n.selfIndex===g});if(-1!==m)h=m;else{var x=vn.findIndex(function(n){return n.id===H.id||n.nodeId===H.nodeId||n.contentId===H.contentId});h=-1!==x?x:V}}else{var I=null===(o=H.refIndexes)||void 0===o?void 0:o[0],y=sn.findIndex(function(n){return n.selfIndex===I});if(-1!==y)p=y;else p=-1!==(A=sn.findIndex(function(n){return n.id===H.id||n.nodeId===H.nodeId||n.contentId===H.contentId}))?A:V}var w="".concat(se).concat(S).concat(a).concat(S).concat(p).concat(S).concat(h),_=u[Jn],F=te||R(_),k=fe.get(c),N=ce.get(c);rn&&"right"===Y&&F&&void 0!==k?s=k:rn&&"right"===Y&&!F&&void 0!==N?s=N:rn&&void 0!==$n&&("right"!==Y||F||le)&&(s-=$n),s=Math.max(1,s);var B=rn&&"right"===Y&&F&&_n?M({section:H,proposedSections:sn,leftNums:_n.leftNums,fallbackNumber:String(me),firstOnly:!0}):me,C="".concat(B,".").concat(s),E=V;if("right"===Y&&rn){var A,O=null===(t=H.refIndexes)||void 0===t?void 0:t[0],j=sn.findIndex(function(n){return n.selfIndex===O});if(-1!==j)E=j;else-1!==(A=sn.findIndex(function(n){return n.id===H.id||n.nodeId===H.nodeId||n.contentId===H.contentId}))&&(E=A)}var W=mn?mn(E):null,T=(null==u?void 0:u.evaluation_outputs)||(null==re?void 0:re.evaluation_outputs),D=null!==(l=null==T?void 0:T.output_value)&&void 0!==l?l:null,P=null!==(d=null===(r=null==T?void 0:T.metadata)||void 0===r?void 0:r.label_color)&&void 0!==d?d:de,z=b(P),K=W?e(e({},W),{badgeBg:z.badgeBg,badgeBorder:z.badgeBorder,badgeText:z.badgeText}):e({},z),G=(null==u?void 0:u.deviation_summary)?{deviation_summary:u.deviation_summary,deviation_title:(null==u?void 0:u.deviation_title)||(null==re?void 0:re.deviation_title),deviation_impact:(null==u?void 0:u.deviation_impact)||(null==re?void 0:re.deviation_impact),deviation_explanation:(null==u?void 0:u.deviation_explanation)||(null==re?void 0:re.deviation_explanation),evaluation_outputs:T,cognitive_decisioning:(null==u?void 0:u.cognitive_decisioning)||(null==re?void 0:re.cognitive_decisioning)}:null,L=0,X=Tn||"";if(v&&X){var q=X.split(/\n{2,}/),J=q.findIndex(function(n){return n.includes(v)});if(-1!==J){var Q=Object.entries(ue).filter(function(n){n[0];var e=n[1][en];return e&&q[J].includes(e)}).sort(function(n,e){return q[J].indexOf(n[1][en])-q[J].indexOf(e[1][en])}),U=Q.filter(function(n){n[0];var e=n[1][en];return e&&(e.includes(v)||v.includes(e))});U.length>1&&(L=Math.max(0,U.findIndex(function(n){return n[0]===a})))}}var Z=hn(Y,c);return{id:c,actionId:w,label:C,highlight:v,side:Y,style:K,stackIndex:L,score:D,isConnected:null==xn?void 0:xn.has(w),showScrollLockToggle:(null==xn?void 0:xn.has(w))||Sn&&Rn===w||!!kn&&kn===Z.current,scrollSyncLocked:Mn,toggleScrollSyncLocked:Fn,isOrphan:F,isMissingClause:f,badgeRef:Z,onClick:function(n){n.stopPropagation(),In&&In(n,Un||{id:"orphan-left",title:"",content:""},F,Zn||{id:"orphan-right",title:"",content:""},w,K)},onSummaryClick:function(n){n.stopPropagation(),gn(n,w,F,G)}}}).filter(Boolean),Re=an||!An&&Cn?Se:[],Me=Se.map(function(n){return n.highlight}).filter(Boolean),_e=H.id&&Y===(null==$?void 0:$.columnKey)?$:null,Fe=t.useRef(!1);return l(function(){U||(Fe.current=!1)},[U]),i(r,e({ref:q,sx:{mb:Q,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:[U&&(null==_e?void 0:_e.showAbove)&&o("div",e({style:{position:"sticky",top:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==_e?void 0:_e.showAboveRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:o("div",e({style:e({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===Y?"+":"-"," 130px))"),position:"absolute",paddingTop:"20px"},"left"===Y?{right:"-20px"}:{left:"-20px"})},{children:o(v,{color:(null===(L=null==_e?void 0:_e.showAboveRef)||void 0===L?void 0:L.current)?window.getComputedStyle(_e.showAboveRef.current).color:void 0})}))})),i(d,e({disableGutters:!0,expanded:!zn&&U,onChange:function(){zn||(Z(),tn.current=H.id)},sx:{boxShadow:"none",border:zn?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:zn?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flexGrow:1,width:"100%",display:"flex",flexDirection:"column",minWidth:0,"&:before":{display:"none"},"& .MuiAccordion-heading":{position:"sticky",top:-12,zIndex:10,background:"#fff"}}},{children:[o(a,e({expandIcon:zn?null:o(f,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:zn?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:Bn&&o(u,e({title:Kn,placement:"top"},{children:o(c,e({component:"div",sx:{fontSize:"12px",color:zn?"#94A3B8":"#19213D",fontWeight:zn?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(be=Ln,we=Gn,void 0===we&&(we=!1),be?x(be).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(n,t){return n.startsWith("**")&&n.endsWith("**")?o("strong",{children:n.slice(2,-2)},t):i("div",e({style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px",width:"100%"}},{children:[o("span",e({style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:n})),we&&o("span",e({style:{display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"0px 6px",borderRadius:"9999px",background:"#F3F4F6",border:"1px solid #D1D5DB",color:"#6B7280",fontSize:"9px",fontWeight:500,whiteSpace:"nowrap",flexShrink:0,lineHeight:1.4,marginRight:"4px"}},{children:"Multiple"}))]}),t)}):null)}))}))})),!zn&&i(s,e({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[Pn&&o(p,{content:Tn,overlayContent:Dn,sxStyles:ln,highlights:Me,maintainRelativeOrder:rn,highlightBg:ae,suppressHighlightBg:On,deviationBadges:Re,collisionKey:Nn}),(H.subsections||[]).map(function(n,e){return un({section:n,keyPath:"".concat(V,"-").concat(e),depth:0,columnKey:Y,parentNodeId:en,sectionOffset:$n,rhsOrphanVisualIndexes:fe})})]}))]})),U&&(null==_e?void 0:_e.showBelow)&&o("div",e({style:{position:"sticky",bottom:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==_e?void 0:_e.showBelowRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:o("div",e({style:e({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===Y?"+":"-"," 130px))"),position:"absolute",paddingBottom:"20px"},"left"===Y?{right:"-20px"}:{left:"-20px"})},{children:o(f,{color:(null===(X=null==_e?void 0:_e.showBelowRef)||void 0===X?void 0:X.current)?window.getComputedStyle(_e.showBelowRef.current).color:void 0})}))}))]}),"".concat(Y,"-sec-").concat(V))};export{N as default};
1
+ import{__assign as n}from"tslib";import{jsxs as e,jsx as i}from"react/jsx-runtime";import o,{useEffect as t}from"react";import{Box as l,Accordion as d,AccordionSummary as r,Tooltip as a,Typography as u,AccordionDetails as c}from"@mui/material";import{ChevronUp as s,ChevronDown as v}from"lucide-react";import{MemoizedMarkdown as f}from"../hooks/memoizedMarkdown.js";import{useCompareContext as p}from"../CompareContext.js";import{hasValue as h,hasMeaningfulRedlineTags as g,stripRedlineTags as x,hasSingleMappedLhsSection as m,generateColorPalette as I,getLhsDeviationDisplayIndexes as y,isMissingStr as b,getRhsMappedSectionNumber as w,safeStringify as S,DEVIATION_BADGE_SEPARATOR as R}from"../CognitiveComparehelpers.js";import{DEFAULT_DEVIAION_COLOR as _}from"../CognitiveCompareConstants.js";var F=function(F){var M,k,N,B,C,E,A,O,j,W,T,D,P,K,z,G=F.section,L=F.idx,X=F.columnKey,H=F.colRef,V=F.mb,Y=void 0===V?1:V,q=F.isExpanded,J=F.onToggle,Q=F.navigation,U=F.parentNodeId,Z=void 0===U?"":U,$=p(),nn=$.showOpenNodeRef,en=$.resolvedMarkdownStyles,on=$.maintainRelativeOrder,tn=$.showDeviationBadges,ln=void 0!==tn&&tn,dn=$.renderSubSectionAccordion,rn=$.treeData,an=$.proposedSections,un=$.existingSections,cn=$.deviationNumberRegistry,sn=$.deviationParentRegistry,vn=$.getBadgeRef,fn=$.openSummaryPopup,pn=$.getSectionCompareStyle,hn=$.connectedSections,gn=$.openMoreFunctionsPopup,xn=$.isProposingFix,mn=$.proposingFixNodeId,In=$.isRedlineFlow,yn=$.isSideBySide,bn=$.activeSideBySideSection,wn=$.scrollSyncLocked,Sn=$.unifiedNumbering,Rn=$.toggleScrollSyncLocked,_n=$.summaryPopupAnchorEl,Fn="".concat(yn?"1":"0","-").concat(String(null!=bn?bn:"")),Mn=(null===(M=G.displayTitle)||void 0===M||M)&&h(G.title),kn=!(!xn||!mn||"left"!==X||G.id!==mn&&G.nodeId!==mn),Nn=g(G.content),Bn="boolean"==typeof In?In:Nn,Cn=Nn,En=Bn&&Nn,An=En?x(G.content):G.content,On=En?G.content:void 0,jn=(null===(k=G.displayContent)||void 0===k||k||Nn)&&h(G.content),Wn=!Mn&&!jn,Tn=G.title;Mn||(Tn=jn?"No Title Found":"No Matching Section Found");var Dn="left"===X&&(G.isMultipleMapping||(null!==(B=null===(N=G.refContentIds)||void 0===N?void 0:N.length)&&void 0!==B?B:1)>1),Pn="left"===X&&Tn.length>29?"".concat(Tn.slice(0,29).trimEnd(),"..."):Tn,Kn=G.evaluationResult;if(!Kn&&"right"===X)if(on){var zn=null===(C=G.refIndexes)||void 0===C?void 0:C[0],Gn=an.find(function(n){return n.selfIndex===zn});Kn=null==Gn?void 0:Gn.evaluationResult}else Kn=null===(E=an[L])||void 0===E?void 0:E.evaluationResult;var Ln=null===(A=null==rn?void 0:rn.input_index_map)||void 0===A?void 0:A[0],Xn=null===(O=null==rn?void 0:rn.input_index_map)||void 0===O?void 0:O[1],Hn="left"===X?Xn:Ln,Vn=function(n,e){var i;if(!e||!n)return null;for(var o=0,t=n;o<t.length;o++){var l=t[o];if(l.id===e||l.nodeId===e||l.contentId===e)return l;if(null===(i=l.subsections)||void 0===i?void 0:i.length){var d=Vn(l.subsections,e);if(d)return d}}return null},Yn="left"===X?G:Vn(an,G.id),qn="right"===X?G:Vn(un,G.id),Jn=o.useMemo(function(){if(!on)return 0;var n=1/0,e=function(n){var e=g(n)?x(n):n;return S(e||"").replace(/\\n/g,"\n")},i=function(o,t,l,d){if(o){var r=o.nodeId||o.id;if(d&&"right"===X){var a=an.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(o.selfIndex)});a.length>0&&(r=a[0].nodeId||a[0].id)}var u=o.nodeId||o.id||(null==t?void 0:t.nodeId)||(null==t?void 0:t.id)||(null==l?void 0:l.nodeId)||(null==l?void 0:l.id),c=o.evaluationResult||(null==t?void 0:t.evaluationResult)||(null==l?void 0:l.evaluationResult),s=(null==c?void 0:c.deviations)||{};Object.keys(s).forEach(function(i){var d,a=null===(d=s[i])||void 0===d?void 0:d[Z];if(function(n,i){if("string"!=typeof i||b(i))return!1;var o=e(null==n?void 0:n.content),t=e(i);return!!t&&o.includes(t)}("left"===X?t||o:l||o,a)){var c="".concat(r).concat(R).concat(i),v=null==cn?void 0:cn[c];null!=v&&v<n&&(n=v);var f="".concat(u).concat(R).concat(i),p=null==cn?void 0:cn[f];null!=p&&p<n&&(n=p)}});for(var v=o.subsections||[],f=(null==t?void 0:t.subsections)||[],p=(null==l?void 0:l.subsections)||[],h=Math.max(v.length,f.length,p.length),g=0;g<h;g++)i(v[g],f[g],p[g],!1)}},o="right"===X?an.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(G.selfIndex)}):[];if(1===o.length){var t=o[0];(t.refIndexes||[]).map(function(n){return un.find(function(e){return e.selfIndex===n})}).filter(Boolean).forEach(function(n){i(n,t,n,!0)})}else i(G,Yn,qn,!0);return n!==1/0?n-1:0},[G,Yn,qn,X,Z,cn,on,an,un]);if(on)if("left"===X){var Qn=null===(j=G.refIndexes)||void 0===j?void 0:j[0],Un=un.findIndex(function(n){return n.selfIndex===Qn});qn=-1!==Un?un[Un]:Vn(un,G.id)}else{var Zn=null===(W=G.refIndexes)||void 0===W?void 0:W[0],$n=an.findIndex(function(n){return n.selfIndex===Zn});Yn=-1!==$n?an[$n]:Vn(an,G.id)}var ne="left"===X?!qn:!Yn,ee=on&&"right"===X&&m(G,an),ie=Kn||(null==Yn?void 0:Yn.evaluationResult)||(null==qn?void 0:qn.evaluationResult),oe=null!==(P=null===(D=null===(T=null==ie?void 0:ie.evaluation_outputs)||void 0===T?void 0:T.metadata)||void 0===D?void 0:D.label_color)&&void 0!==P?P:_,te=I(oe).highlightBg,le=(null==ie?void 0:ie.deviations)||{},de=o.useMemo(function(){return on&&"right"===X?y(an,Ln,cn):new Map},[on,X,an,Ln,cn]),re=G.nodeId||G.id;if(on&&"left"!==X){var ae=an.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(G.selfIndex)});ae.length>0?re=ae[0].nodeId||ae[0].id:(null==Yn?void 0:Yn.id)&&(re=Yn.nodeId||Yn.id)}var ue=o.useMemo(function(){var n,e=new Map;if(!on||"right"!==X)return e;var i=1,o=an.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(G.selfIndex)}),t=1===o.length&&1===(null===(n=o[0].refIndexes)||void 0===n?void 0:n.length),l=function(n){return S(n||"").replace(/\\n/g,"\n")},d=function(n,e){var i=e?o[0]:Vn(an,n.nodeId||n.id||n.contentId);return{lhsNode:i,evalResult:n.evaluationResult||(null==i?void 0:i.evaluationResult),registryNodeId:i?i.nodeId||i.id:n.nodeId||n.id}};if(t){var r=function(n,e){if(void 0===e&&(e=!1),n){var o=d(n,e),t=o.lhsNode,a=o.evalResult,u=o.registryNodeId,c=l(n.content);Object.entries((null==a?void 0:a.deviations)||{}).forEach(function(n){var e=n[0],o=n[1],d=o[Z],r=l(d);if(!!t&&!b(o[Hn])&&r&&c.includes(r)){var a="".concat(u).concat(R).concat(e),s=cn[a];null!=s&&(i=Math.max(i,Math.max(1,s-(Jn||0))+1))}}),(n.subsections||[]).forEach(function(n){return r(n)})}};r(G,!0)}var a=function(n,o){if(void 0===o&&(o=!1),n){var t=d(n,o),r=t.lhsNode,u=t.evalResult,c=t.registryNodeId,s=(null==u?void 0:u.deviations)||{},v=l(n.content);Object.entries(s).map(function(n){var e,i=n[0],o=n[1],t=o[Z],d=!r||b(o[Hn]),a=l(t),u=a?v.indexOf(a):-1,s="".concat(c).concat(R).concat(i);return{refId:s,isRenderable:d&&!!a&&!b(t),position:u,registryIndex:null!==(e=cn[s])&&void 0!==e?e:Number.MAX_SAFE_INTEGER}}).filter(function(n){return n.isRenderable}).sort(function(n,e){return(-1===n.position?Number.MAX_SAFE_INTEGER:n.position)-(-1===e.position?Number.MAX_SAFE_INTEGER:e.position)||n.registryIndex-e.registryIndex}).forEach(function(n){e.set(n.refId,i++)}),(n.subsections||[]).forEach(function(n){return a(n)})}};return a(G,!0),e},[on,X,G,an,Z,Hn,cn,Jn]),ce=Object.keys(le)[0],se=ce?"".concat(re).concat(R).concat(ce):null,ve=se?null==sn?void 0:sn[se]:null,fe=L+1;if(on&&Sn){var pe="left"===X?Sn.leftNums.get(null==G?void 0:G.id):Sn.rightNums.get(null==G?void 0:G.id);ne&&void 0!==pe?fe=pe:null!=ve&&ve>=0?fe=ve:void 0!==pe&&(fe=pe)}else null!=ve&&ve>=0&&(fe=ve);var he=Object.entries(le).map(function(n){var e=n[0],i=n[1],o="".concat(re).concat(R).concat(e);return{deviationKey:e,deviationMap:i,refId:o,currentIndex:cn[o]}}).filter(function(n){return void 0!==n.currentIndex&&null!==n.currentIndex});he.sort(function(n,e){return n.currentIndex-e.currentIndex});var ge,xe,me=he.map(function(e){var i,o,t,l,d,r,a=e.deviationKey,u=e.deviationMap,c=e.refId,s=e.currentIndex,v=u[Z],f=b(v);if(f)v="";else if(!v)return null;var p=L,h=L;if(on)if("left"===X){var g=null===(i=G.refIndexes)||void 0===i?void 0:i[0],x=un.findIndex(function(n){return n.selfIndex===g});if(-1!==x)h=x;else{var m=un.findIndex(function(n){return n.id===G.id||n.nodeId===G.nodeId||n.contentId===G.contentId});h=-1!==m?m:L}}else{var y=null===(o=G.refIndexes)||void 0===o?void 0:o[0],S=an.findIndex(function(n){return n.selfIndex===y});if(-1!==S)p=S;else p=-1!==(A=an.findIndex(function(n){return n.id===G.id||n.nodeId===G.nodeId||n.contentId===G.contentId}))?A:L}var _="".concat(re).concat(R).concat(a).concat(R).concat(p).concat(R).concat(h),F=u[Hn],M=ne||b(F),k=ue.get(c),N=de.get(c);on&&"right"===X&&M&&void 0!==k?s=k:on&&"right"===X&&!M&&void 0!==N?s=N:on&&void 0!==Jn&&("right"!==X||M||ee)&&(s-=Jn),s=Math.max(1,s);var B=on&&"right"===X&&M&&Sn?w({section:G,proposedSections:an,leftNums:Sn.leftNums,fallbackNumber:String(fe),firstOnly:!0}):fe,C="".concat(B,".").concat(s),E=L;if("right"===X&&on){var A,O=null===(t=G.refIndexes)||void 0===t?void 0:t[0],j=an.findIndex(function(n){return n.selfIndex===O});if(-1!==j)E=j;else-1!==(A=an.findIndex(function(n){return n.id===G.id||n.nodeId===G.nodeId||n.contentId===G.contentId}))&&(E=A)}var W=pn?pn(E):null,T=(null==u?void 0:u.evaluation_outputs)||(null==ie?void 0:ie.evaluation_outputs),D=null!==(l=null==T?void 0:T.output_value)&&void 0!==l?l:null,P=null!==(r=null===(d=null==T?void 0:T.metadata)||void 0===d?void 0:d.label_color)&&void 0!==r?r:oe,K=I(P),z=W?n(n({},W),{badgeBg:K.badgeBg,badgeBorder:K.badgeBorder,badgeText:K.badgeText}):n({},K),H=(null==u?void 0:u.deviation_summary)?{deviation_summary:u.deviation_summary,deviation_title:(null==u?void 0:u.deviation_title)||(null==ie?void 0:ie.deviation_title),deviation_impact:(null==u?void 0:u.deviation_impact)||(null==ie?void 0:ie.deviation_impact),deviation_explanation:(null==u?void 0:u.deviation_explanation)||(null==ie?void 0:ie.deviation_explanation),evaluation_outputs:T,cognitive_decisioning:(null==u?void 0:u.cognitive_decisioning)||(null==ie?void 0:ie.cognitive_decisioning)}:null,V=0,Y=An||"";if(v&&Y){var q=Y.split(/\n{2,}/),J=q.findIndex(function(n){return n.includes(v)});if(-1!==J){var Q=Object.entries(le).filter(function(n){n[0];var e=n[1][Z];return e&&q[J].includes(e)}).sort(function(n,e){return q[J].indexOf(n[1][Z])-q[J].indexOf(e[1][Z])}),U=Q.filter(function(n){n[0];var e=n[1][Z];return e&&(e.includes(v)||v.includes(e))});U.length>1&&(V=Math.max(0,U.findIndex(function(n){return n[0]===a})))}}var $=vn(X,c);return{id:c,actionId:_,label:C,highlight:v,side:X,style:z,stackIndex:V,score:D,isConnected:null==hn?void 0:hn.has(_),showScrollLockToggle:(null==hn?void 0:hn.has(_))||yn&&bn===_||!!_n&&_n===$.current,scrollSyncLocked:wn,toggleScrollSyncLocked:Rn,isOrphan:M,isMissingClause:f,badgeRef:$,onClick:function(n){n.stopPropagation(),gn&&gn(n,Yn||{id:"orphan-left",title:"",content:""},M,qn||{id:"orphan-right",title:"",content:""},_,z)},onSummaryClick:function(n){n.stopPropagation(),fn(n,_,M,H)}}}).filter(Boolean),Ie=ln||!Bn&&kn?me:[],ye=me.map(function(n){return n.highlight}).filter(Boolean),be=G.id&&X===(null==Q?void 0:Q.columnKey)?Q:null,we=o.useRef(!1);return t(function(){q||(we.current=!1)},[q]),e(l,n({ref:H,sx:{mb:Y,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:[q&&(null==be?void 0:be.showAbove)&&i("div",n({style:{position:"sticky",top:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==be?void 0:be.showAboveRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:i("div",n({style:n({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===X?"+":"-"," 130px))"),position:"absolute",paddingTop:"20px"},"left"===X?{right:"-20px"}:{left:"-20px"})},{children:i(s,{color:(null===(K=null==be?void 0:be.showAboveRef)||void 0===K?void 0:K.current)?window.getComputedStyle(be.showAboveRef.current).color:void 0})}))})),e(d,n({disableGutters:!0,expanded:!Wn&&q,onChange:function(){Wn||(J(),nn.current=G.id)},sx:{boxShadow:"none",border:Wn?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:Wn?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flexGrow:1,width:"100%",display:"flex",flexDirection:"column",minWidth:0,"&:before":{display:"none"},"& .MuiAccordion-heading":{position:"sticky",top:-12,zIndex:10,background:"#fff"}}},{children:[i(r,n({expandIcon:Wn?null:i(v,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:Wn?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:Mn&&i(a,n({title:Tn,placement:"top"},{children:i(u,n({component:"div",sx:{fontSize:"12px",color:Wn?"#94A3B8":"#19213D",fontWeight:Wn?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(ge=Pn,xe=Dn,void 0===xe&&(xe=!1),ge?S(ge).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(o,t){return o.startsWith("**")&&o.endsWith("**")?i("strong",{children:o.slice(2,-2)},t):e("div",n({style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px",width:"100%"}},{children:[i("span",n({style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:o})),xe&&i("span",n({style:{display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"0px 6px",borderRadius:"9999px",background:"#F3F4F6",border:"1px solid #D1D5DB",color:"#6B7280",fontSize:"9px",fontWeight:500,whiteSpace:"nowrap",flexShrink:0,lineHeight:1.4,marginRight:"4px"}},{children:"Multiple"}))]}),t)}):null)}))}))})),!Wn&&e(c,n({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[jn&&i(f,{content:An,overlayContent:On,sxStyles:en,highlights:ye,maintainRelativeOrder:on,highlightBg:te,suppressHighlightBg:Cn,deviationBadges:Ie,collisionKey:Fn}),(G.subsections||[]).map(function(n,e){return dn({section:n,keyPath:"".concat(L,"-").concat(e),depth:0,columnKey:X,parentNodeId:Z,sectionOffset:Jn,rhsOrphanVisualIndexes:ue})})]}))]})),q&&(null==be?void 0:be.showBelow)&&i("div",n({style:{position:"sticky",bottom:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==be?void 0:be.showBelowRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:i("div",n({style:n({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===X?"+":"-"," 130px))"),position:"absolute",paddingBottom:"20px"},"left"===X?{right:"-20px"}:{left:"-20px"})},{children:i(v,{color:(null===(z=null==be?void 0:be.showBelowRef)||void 0===z?void 0:z.current)?window.getComputedStyle(be.showBelowRef.current).color:void 0})}))}))]}),"".concat(X,"-sec-").concat(L))};export{F as default};
2
2
  //# sourceMappingURL=SectionAccordion.js.map
@@ -1,2 +1,2 @@
1
- import{__spreadArray as n,__assign as i}from"tslib";import{jsx as e,jsxs as t}from"react/jsx-runtime";import o,{useMemo as l}from"react";import{Box as d,Accordion as r,AccordionSummary as a,Typography as u,AccordionDetails as c}from"@mui/material";import{ChevronDown as s}from"lucide-react";import{MemoizedMarkdown as v}from"../hooks/memoizedMarkdown.js";import{useCompareContext as f}from"../CompareContext.js";import{hasValue as p,hasMeaningfulRedlineTags as h,safeStringify as m,stripRedlineTags as g,hasSingleMappedLhsSection as x,getLhsDeviationDisplayIndexes as y,generateColorPalette as S,DEVIATION_BADGE_SEPARATOR as I,isMissingStr as b,findTextMatchRange as _,getRhsMappedSectionNumber as k}from"../CognitiveComparehelpers.js";import{DEFAULT_DEVIAION_COLOR as w}from"../CognitiveCompareConstants.js";import{normalizeRedlineMarkdown as N}from"../utils/normalizeRedlineMarkdown.js";var F=o.memo(function(o){var C,M,O,P,B,R,E,j,A,K,W=o.section,L=o.keyPath,T=o.depth,z=void 0===T?0:T,D=o.columnKey,G=void 0===D?"left":D,H=o.parentNodeId,V=void 0===H?"":H,X=o.sectionOffset,U=o.rhsOrphanVisualIndexes,q=f(),J=q.expandedSubSections,Q=q.setExpandedSubSections,Y=q.maintainRelativeOrder,Z=q.showDeviationBadges,$=void 0!==Z&&Z,nn=q.proposedSections,en=q.existingSections,tn=q.treeData,on=q.deviationNumberRegistry,ln=q.deviationParentRegistry,dn=q.connectedSections,rn=q.activeSideBySideSection,an=q.isSideBySide,un=q.scrollSyncLocked,cn=q.toggleScrollSyncLocked,sn=q.summaryPopupAnchorEl,vn=q.resolvedMarkdownStyles,fn=q.getSubSectionRef,pn=q.getSubSectionCompareStyle,hn=q.getBadgeRef,mn=q.openMoreFunctionsPopup,gn=q.openSummaryPopup,xn=q.resetSideBySide,yn=q.setConnectedSections,Sn=q.setConnectedLines,In=q.cachedConnectedPositions,bn=q.isProposingFix,_n=q.proposingFixNodeId,kn=q.isRedlineFlow,wn=q.unifiedNumbering,Nn=null!=rn?rn:"",Fn=(null===(C=W.displayTitle)||void 0===C||C)&&p(W.title),Cn=!(!bn||!_n||"left"!==G||W.id!==_n&&W.nodeId!==_n),Mn=h(W.content),On="boolean"==typeof kn?kn:Mn,Pn=Mn,Bn=On&&Mn,Rn=l(function(){return Bn?N(m(W.content)):m(W.content)},[W.content,Bn]),En=Bn?g(Rn):W.content,jn=Bn?Rn:void 0,An=(null===(M=W.displayContent)||void 0===M||M||Mn)&&p(W.content),Kn=!Fn&&!An,Wn=Fn?W.title:An?"No Title Found":"No Matching Section Found",Ln=!!J[L],Tn=fn(G,L),zn=L.split("-").map(Number)[0],Dn=nn[zn],Gn=en[zn],Hn=zn,Vn=zn,Xn=!1,Un=function(n,i,e){if(!n||!i)return null;if(n.id===i||n.nodeId===i||n.contentId===i)return{section:n,keyPath:e};for(var t=(n.subsections||[]).map(function(n,i){return{section:n,keyPath:"".concat(e,"-").concat(i)}}),o=function(){var n=t.shift();return(null==n?void 0:n.section)?n.section.id===i||n.section.nodeId===i||n.section.contentId===i?{value:n}:void(n.section.subsections||[]).forEach(function(i,e){t.push({section:i,keyPath:"".concat(n.keyPath,"-").concat(e)})}):"continue"};t.length>0;){var l=o();if("object"==typeof l)return l.value}return null};if(Y)if("left"===G){var qn=null===(O=null==Dn?void 0:Dn.refIndexes)||void 0===O?void 0:O[0],Jn=en.findIndex(function(n){return n.selfIndex===qn});-1!==Jn?(Gn=en[Jn],Vn=Jn):Xn=!0}else{var Qn=null===(P=null==Gn?void 0:Gn.refIndexes)||void 0===P?void 0:P[0],Yn=nn.findIndex(function(n){return n.selfIndex===Qn});-1!==Yn?(Dn=nn[Yn],Hn=Yn):Xn=!0}var Zn=function(n,i){if(!i||!n)return null;for(var e=0;e<n.length;e++){var t=Un(n[e],i,String(e));if(t)return t}return null},$n=null,ni=null,ii="",ei="";if(Y)"left"===G?($n=W,ii=L,(ti=Un(Gn,W.nodeId||W.id,String(Vn)))||(ti=Zn(en,W.nodeId||W.id)),ni=(null==ti?void 0:ti.section)||null,ei=(null==ti?void 0:ti.keyPath)||""):(ni=W,ei=L,(oi=Un(Dn,W.nodeId||W.id,String(Hn)))||(oi=Zn(nn,W.nodeId||W.id)),$n=(null==oi?void 0:oi.section)||null,ii=(null==oi?void 0:oi.keyPath)||"");else if("left"===G){$n=W,ii=L;var ti=Zn(en,W.nodeId||W.id);ni=(null==ti?void 0:ti.section)||null,ei=(null==ti?void 0:ti.keyPath)||""}else{ni=W,ei=L;var oi=Zn(nn,W.nodeId||W.id);$n=(null==oi?void 0:oi.section)||null,ii=(null==oi?void 0:oi.keyPath)||""}var li=(ii?pn(ii):null)||pn(L),di=null===(B=null==tn?void 0:tn.input_index_map)||void 0===B?void 0:B[0],ri=null===(R=null==tn?void 0:tn.input_index_map)||void 0===R?void 0:R[1],ai="left"===G?ri:di,ui="left"===G?!ni:!$n,ci=Y&&"right"===G&&x(Gn,nn),si=W.evaluationResult||(null==$n?void 0:$n.evaluationResult)||(null==ni?void 0:ni.evaluationResult),vi=(null==si?void 0:si.deviations)||{},fi=l(function(){return Y&&"right"===G?y(nn,di,on):new Map},[Y,G,nn,di,on]),pi=W.nodeId||W.id||(null==$n?void 0:$n.nodeId)||(null==$n?void 0:$n.id)||(null==ni?void 0:ni.nodeId)||(null==ni?void 0:ni.id);Y&&"left"!==G&&(null==$n?void 0:$n.id)&&(pi=$n.nodeId||$n.id);var hi=Object.keys(vi)[0],mi=hi?"".concat(pi).concat(I).concat(hi):null,gi=mi?null==ln?void 0:ln[mi]:null,xi=zn+1;if(Y&&wn){var yi="left"===G?wn.leftNums.get(null==Dn?void 0:Dn.id):wn.rightNums.get(null==Gn?void 0:Gn.id);Xn&&void 0!==yi?xi=yi:null!=gi&&gi>=0?xi=gi:void 0!==yi&&(xi=yi)}else null!=gi&&gi>=0&&(xi=gi);var Si=null!==(A=null===(j=null===(E=null==si?void 0:si.evaluation_outputs)||void 0===E?void 0:E.metadata)||void 0===j?void 0:j.label_color)&&void 0!==A?A:w,Ii=S(Si).highlightBg,bi=Math.max.apply(Math,n([0],Object.keys(vi).map(function(n){return on["".concat(pi).concat(I).concat(n)]}).filter(function(n){return"number"==typeof n&&Number.isFinite(n)}),!1))+1,_i=Object.entries(vi).map(function(n){var i,e=n[0],t=n[1],o="".concat(pi).concat(I).concat(e);return{deviationKey:e,deviationMap:t,refId:o,currentIndex:null!==(i=on[o])&&void 0!==i?i:bi++}});_i.sort(function(n,i){return n.currentIndex-i.currentIndex});var ki=new Map;if(!U&&Y&&"right"===G){var wi=m(En||"").replace(/\\n/g,"\n");_i.filter(function(n){var i=n.deviationMap,e=i[V];return(ui||b(i[ai]))&&!!e&&!b(e)}).map(function(n){var e,t,o=m(n.deviationMap[V]||"").replace(/\\n/g,"\n"),l=o&&null!==(t=null===(e=_(wi,o))||void 0===e?void 0:e.start)&&void 0!==t?t:-1;return i(i({},n),{position:l})}).sort(function(n,i){return(-1===n.position?Number.MAX_SAFE_INTEGER:n.position)-(-1===i.position?Number.MAX_SAFE_INTEGER:i.position)||n.currentIndex-i.currentIndex}).forEach(function(n,i){ki.set(n.refId,i+1)})}var Ni=_i.map(function(n){var e,t,o,l,d=n.deviationKey,r=n.deviationMap,a=n.refId,u=n.currentIndex,c=r[V],s=b(c);if(s)c="";else if(!c)return null;var v=r[ai],f=ui||b(v),p=null!==(e=null==U?void 0:U.get(a))&&void 0!==e?e:ki.get(a),h=fi.get(a);Y&&"right"===G&&f&&void 0!==p?u=p:Y&&"right"===G&&!f&&void 0!==h?u=h:Y&&void 0!==X&&("right"!==G||f||ci)&&(u-=X),u=Math.max(1,u);var m=Y&&"right"===G&&f&&wn?k({section:Gn,proposedSections:nn,leftNums:wn.leftNums,fallbackNumber:String(xi),firstOnly:!0}):xi,g="".concat(m,".").concat(u),x="".concat(pi).concat(I).concat(d).concat(I).concat(ii).concat(I).concat(ei),y=(null==r?void 0:r.evaluation_outputs)||(null==si?void 0:si.evaluation_outputs),_=null!==(t=null==y?void 0:y.output_value)&&void 0!==t?t:null,w=null!==(l=null===(o=null==y?void 0:y.metadata)||void 0===o?void 0:o.label_color)&&void 0!==l?l:Si,N=S(w),F=i({},N),C=(null==r?void 0:r.deviation_summary)?{deviation_summary:r.deviation_summary||(null==si?void 0:si.deviation_summary),deviation_title:(null==r?void 0:r.deviation_title)||(null==si?void 0:si.deviation_title),deviation_impact:(null==r?void 0:r.deviation_impact)||(null==si?void 0:si.deviation_impact),deviation_explanation:(null==r?void 0:r.deviation_explanation)||(null==si?void 0:si.deviation_explanation),evaluation_outputs:y,cognitive_decisioning:(null==r?void 0:r.cognitive_decisioning)||(null==si?void 0:si.cognitive_decisioning)}:null,M=0,O=En||"";if(c&&O){var P=O.split(/\n{2,}/),B=P.findIndex(function(n){return n.includes(c)});if(-1!==B){var R=Object.entries(vi).filter(function(n){n[0];var i=n[1][V];return i&&P[B].includes(i)}).sort(function(n,i){return P[B].indexOf(n[1][V])-P[B].indexOf(i[1][V])}),E=R.filter(function(n){n[0];var i=n[1][V];return i&&(i.includes(c)||c.includes(i))});E.length>1&&(M=Math.max(0,E.findIndex(function(n){return n[0]===d})))}}var j=hn(G,a);return{id:a,actionId:x,label:g,highlight:c,side:G,style:F,stackIndex:M,score:_,isConnected:dn.has(x),showScrollLockToggle:dn.has(x)||an&&rn===x||!!sn&&sn===j.current,scrollSyncLocked:un,toggleScrollSyncLocked:cn,isOrphan:f,isMissingClause:s,badgeRef:j,onClick:function(n){n.stopPropagation();var e=ii&&nn[Number(ii.split("-")[0])]||Dn,t=ei&&en[Number(ei.split("-")[0])]||Gn,o=$n?i(i({},$n),{title:(null==e?void 0:e.title)||(null==$n?void 0:$n.title)||""}):{id:"orphan-left",title:"",content:""},l=ni?i(i({},ni),{title:(null==t?void 0:t.title)||(null==ni?void 0:ni.title)||""}):{id:"orphan-right",title:"",content:""};mn(n,o,f,l,x,F)},onSummaryClick:function(n){n.stopPropagation(),gn(n,x,f,C)}}}).filter(Boolean).sort(function(n,i){return parseFloat(n.label)-parseFloat(i.label)}),Fi=l(function(){var n=new Set;return Ni.filter(function(i){return!n.has(i.id)&&(n.add(i.id),!0)})},[Ni]),Ci=$||!On&&Cn?Fi:[],Mi=Fi.map(function(n){return n.highlight}).filter(Boolean),Oi=Ni.find(function(n){return dn.has(n.actionId)}),Pi=!!Oi;if(!(Fn||An||W.subsections&&0!==W.subsections.length))return null;var Bi=(null===(K=null==Oi?void 0:Oi.style)||void 0===K?void 0:K.badgeBorder)||(null==li?void 0:li.badgeBorder),Ri=Pi&&Bi?{borderRadius:"4px",outline:"2px solid ".concat(Bi),outlineOffset:"1px"}:{};return e(d,Fn?i({ref:Tn,sx:{mt:1,width:"100%",minWidth:0,position:"relative"}},{children:e(d,i({sx:i({width:"100%"},Ri)},{children:t(r,i({disableGutters:!0,expanded:!Kn&&Ln,onChange:function(){if(!Kn){if(Ln){var n=String(rn||""),e=n.includes(ii)||n.includes(ei);e||dn.forEach(function(n){(String(n).includes(ii)||String(n).includes(ei))&&(e=!0)}),e&&(xn(),yn(new Set),Sn([]),In.current=[])}Q(function(n){var e;return i(i({},n),((e={})[L]=!n[L],e))})}},sx:{mt:0,boxShadow:"none",border:Kn?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF",minWidth:0,"&:before":{display:"none"}}},{children:[e(a,i({expandIcon:Kn?null:e(s,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"}}},{children:e(u,i({component:"div",sx:{fontSize:"11px",fontWeight:600,color:Kn?"#94A3B8":"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:Wn||"Untitled Subsection"}))})),!Kn&&t(c,i({sx:{pt:0,pb:1,minWidth:0}},{children:[An&&e(v,{content:En,overlayContent:jn,sxStyles:vn,deviationBadges:Ci,maintainRelativeOrder:Y,highlightBg:Ii,suppressHighlightBg:Pn,highlights:Mi,collisionKey:Nn}),(W.subsections||[]).map(function(n,i){return e(F,{section:n,keyPath:"".concat(L,"-").concat(i),depth:z+1,columnKey:G,parentNodeId:V,sectionOffset:X,rhsOrphanVisualIndexes:U},"".concat(L,"-").concat(i))})]}))]}))}))}):i({ref:Tn,sx:{mt:0===z?1:.75,width:"100%",minWidth:0,position:"relative"}},{children:!Kn&&t(d,i({sx:i({width:"100%"},Ri)},{children:[An&&e(v,{content:En,overlayContent:jn,sxStyles:vn,deviationBadges:Ci,maintainRelativeOrder:Y,highlightBg:Ii,suppressHighlightBg:Pn,highlights:Mi,collisionKey:Nn}),(W.subsections||[]).map(function(n,i){return e(F,{section:n,keyPath:"".concat(L,"-").concat(i),depth:z+1,columnKey:G,parentNodeId:V,sectionOffset:X,rhsOrphanVisualIndexes:U},"".concat(L,"-").concat(i))})]}))}))});export{F as default};
1
+ import{__assign as n}from"tslib";import{jsx as i,jsxs as e}from"react/jsx-runtime";import t,{useMemo as o}from"react";import{Box as l,Accordion as d,AccordionSummary as r,Typography as a,AccordionDetails as u}from"@mui/material";import{ChevronDown as c}from"lucide-react";import{MemoizedMarkdown as s}from"../hooks/memoizedMarkdown.js";import{useCompareContext as v}from"../CompareContext.js";import{hasValue as f,hasMeaningfulRedlineTags as p,stripRedlineTags as h,hasSingleMappedLhsSection as m,getLhsDeviationDisplayIndexes as g,generateColorPalette as x,safeStringify as y,isMissingStr as S,getRhsMappedSectionNumber as I,DEVIATION_BADGE_SEPARATOR as b}from"../CognitiveComparehelpers.js";import{DEFAULT_DEVIAION_COLOR as _}from"../CognitiveCompareConstants.js";var k=t.memo(function(t){var w,C,F,O,P,N,B,M,R,E,j=t.section,A=t.keyPath,K=t.depth,W=void 0===K?0:K,L=t.columnKey,T=void 0===L?"left":L,z=t.parentNodeId,D=void 0===z?"":z,G=t.sectionOffset,H=t.rhsOrphanVisualIndexes,V=v(),X=V.expandedSubSections,U=V.setExpandedSubSections,q=V.maintainRelativeOrder,J=V.showDeviationBadges,Q=void 0!==J&&J,Y=V.proposedSections,Z=V.existingSections,$=V.treeData,nn=V.deviationNumberRegistry,en=V.deviationParentRegistry,tn=V.connectedSections,on=V.activeSideBySideSection,ln=V.isSideBySide,dn=V.scrollSyncLocked,rn=V.toggleScrollSyncLocked,an=V.summaryPopupAnchorEl,un=V.resolvedMarkdownStyles,cn=V.getSubSectionRef,sn=V.getSubSectionCompareStyle,vn=V.getBadgeRef,fn=V.openMoreFunctionsPopup,pn=V.openSummaryPopup,hn=V.resetSideBySide,mn=V.setConnectedSections,gn=V.setConnectedLines,xn=V.cachedConnectedPositions,yn=V.isProposingFix,Sn=V.proposingFixNodeId,In=V.isRedlineFlow,bn=V.unifiedNumbering,_n=null!=on?on:"",kn=(null===(w=j.displayTitle)||void 0===w||w)&&f(j.title),wn=!(!yn||!Sn||"left"!==T||j.id!==Sn&&j.nodeId!==Sn),Cn=p(j.content),Fn="boolean"==typeof In?In:Cn,On=Cn,Pn=Fn&&Cn,Nn=Pn?h(j.content):j.content,Bn=Pn?j.content:void 0,Mn=(null===(C=j.displayContent)||void 0===C||C||Cn)&&f(j.content),Rn=!kn&&!Mn,En=kn?j.title:Mn?"No Title Found":"No Matching Section Found",jn=!!X[A],An=cn(T,A),Kn=A.split("-").map(Number)[0],Wn=Y[Kn],Ln=Z[Kn],Tn=Kn,zn=Kn,Dn=!1,Gn=function(n,i,e){if(!n||!i)return null;if(n.id===i||n.nodeId===i||n.contentId===i)return{section:n,keyPath:e};for(var t=(n.subsections||[]).map(function(n,i){return{section:n,keyPath:"".concat(e,"-").concat(i)}}),o=function(){var n=t.shift();return(null==n?void 0:n.section)?n.section.id===i||n.section.nodeId===i||n.section.contentId===i?{value:n}:void(n.section.subsections||[]).forEach(function(i,e){t.push({section:i,keyPath:"".concat(n.keyPath,"-").concat(e)})}):"continue"};t.length>0;){var l=o();if("object"==typeof l)return l.value}return null};if(q)if("left"===T){var Hn=null===(F=null==Wn?void 0:Wn.refIndexes)||void 0===F?void 0:F[0],Vn=Z.findIndex(function(n){return n.selfIndex===Hn});-1!==Vn?(Ln=Z[Vn],zn=Vn):Dn=!0}else{var Xn=null===(O=null==Ln?void 0:Ln.refIndexes)||void 0===O?void 0:O[0],Un=Y.findIndex(function(n){return n.selfIndex===Xn});-1!==Un?(Wn=Y[Un],Tn=Un):Dn=!0}var qn=function(n,i){if(!i||!n)return null;for(var e=0;e<n.length;e++){var t=Gn(n[e],i,String(e));if(t)return t}return null},Jn=null,Qn=null,Yn="",Zn="";if(q)"left"===T?(Jn=j,Yn=A,($n=Gn(Ln,j.nodeId||j.id,String(zn)))||($n=qn(Z,j.nodeId||j.id)),Qn=(null==$n?void 0:$n.section)||null,Zn=(null==$n?void 0:$n.keyPath)||""):(Qn=j,Zn=A,(ni=Gn(Wn,j.nodeId||j.id,String(Tn)))||(ni=qn(Y,j.nodeId||j.id)),Jn=(null==ni?void 0:ni.section)||null,Yn=(null==ni?void 0:ni.keyPath)||"");else if("left"===T){Jn=j,Yn=A;var $n=qn(Z,j.nodeId||j.id);Qn=(null==$n?void 0:$n.section)||null,Zn=(null==$n?void 0:$n.keyPath)||""}else{Qn=j,Zn=A;var ni=qn(Y,j.nodeId||j.id);Jn=(null==ni?void 0:ni.section)||null,Yn=(null==ni?void 0:ni.keyPath)||""}var ii=(Yn?sn(Yn):null)||sn(A),ei=null===(P=null==$?void 0:$.input_index_map)||void 0===P?void 0:P[0],ti=null===(N=null==$?void 0:$.input_index_map)||void 0===N?void 0:N[1],oi="left"===T?ti:ei,li="left"===T?!Qn:!Jn,di=q&&"right"===T&&m(Ln,Y),ri=j.evaluationResult||(null==Jn?void 0:Jn.evaluationResult)||(null==Qn?void 0:Qn.evaluationResult),ai=(null==ri?void 0:ri.deviations)||{},ui=o(function(){return q&&"right"===T?g(Y,ei,nn):new Map},[q,T,Y,ei,nn]),ci=j.nodeId||j.id||(null==Jn?void 0:Jn.nodeId)||(null==Jn?void 0:Jn.id)||(null==Qn?void 0:Qn.nodeId)||(null==Qn?void 0:Qn.id);q&&"left"!==T&&(null==Jn?void 0:Jn.id)&&(ci=Jn.nodeId||Jn.id);var si=Object.keys(ai)[0],vi=si?"".concat(ci).concat(b).concat(si):null,fi=vi?null==en?void 0:en[vi]:null,pi=Kn+1;if(q&&bn){var hi="left"===T?bn.leftNums.get(null==Wn?void 0:Wn.id):bn.rightNums.get(null==Ln?void 0:Ln.id);Dn&&void 0!==hi?pi=hi:null!=fi&&fi>=0?pi=fi:void 0!==hi&&(pi=hi)}else null!=fi&&fi>=0&&(pi=fi);var mi=null!==(R=null===(M=null===(B=null==ri?void 0:ri.evaluation_outputs)||void 0===B?void 0:B.metadata)||void 0===M?void 0:M.label_color)&&void 0!==R?R:_,gi=x(mi).highlightBg,xi=Object.entries(ai).map(function(n){var i=n[0],e=n[1],t="".concat(ci).concat(b).concat(i);return{deviationKey:i,deviationMap:e,refId:t,currentIndex:nn[t]}}).filter(function(n){return void 0!==n.currentIndex&&null!==n.currentIndex});xi.sort(function(n,i){return n.currentIndex-i.currentIndex});var yi=new Map;if(!H&&q&&"right"===T){var Si=y(Nn||"").replace(/\\n/g,"\n");xi.filter(function(n){var i=n.deviationMap,e=i[D];return(li||S(i[oi]))&&!!e&&!S(e)}).map(function(i){var e=y(i.deviationMap[D]||"").replace(/\\n/g,"\n"),t=e?Si.indexOf(e):-1;return n(n({},i),{position:t})}).sort(function(n,i){return(-1===n.position?Number.MAX_SAFE_INTEGER:n.position)-(-1===i.position?Number.MAX_SAFE_INTEGER:i.position)||n.currentIndex-i.currentIndex}).forEach(function(n,i){yi.set(n.refId,i+1)})}var Ii=xi.map(function(i){var e,t,o,l,d=i.deviationKey,r=i.deviationMap,a=i.refId,u=i.currentIndex,c=r[D],s=S(c);if(s)c="";else if(!c)return null;var v=r[oi],f=li||S(v),p=null!==(e=null==H?void 0:H.get(a))&&void 0!==e?e:yi.get(a),h=ui.get(a);q&&"right"===T&&f&&void 0!==p?u=p:q&&"right"===T&&!f&&void 0!==h?u=h:q&&void 0!==G&&("right"!==T||f||di)&&(u-=G),u=Math.max(1,u);var m=q&&"right"===T&&f&&bn?I({section:Ln,proposedSections:Y,leftNums:bn.leftNums,fallbackNumber:String(pi),firstOnly:!0}):pi,g="".concat(m,".").concat(u),y="".concat(ci).concat(b).concat(d).concat(b).concat(Yn).concat(b).concat(Zn),_=(null==r?void 0:r.evaluation_outputs)||(null==ri?void 0:ri.evaluation_outputs),k=null!==(t=null==_?void 0:_.output_value)&&void 0!==t?t:null,w=null!==(l=null===(o=null==_?void 0:_.metadata)||void 0===o?void 0:o.label_color)&&void 0!==l?l:mi,C=x(w),F=n({},C),O=(null==r?void 0:r.deviation_summary)?{deviation_summary:r.deviation_summary||(null==ri?void 0:ri.deviation_summary),deviation_title:(null==r?void 0:r.deviation_title)||(null==ri?void 0:ri.deviation_title),deviation_impact:(null==r?void 0:r.deviation_impact)||(null==ri?void 0:ri.deviation_impact),deviation_explanation:(null==r?void 0:r.deviation_explanation)||(null==ri?void 0:ri.deviation_explanation),evaluation_outputs:_,cognitive_decisioning:(null==r?void 0:r.cognitive_decisioning)||(null==ri?void 0:ri.cognitive_decisioning)}:null,P=0,N=Nn||"";if(c&&N){var B=N.split(/\n{2,}/),M=B.findIndex(function(n){return n.includes(c)});if(-1!==M){var R=Object.entries(ai).filter(function(n){n[0];var i=n[1][D];return i&&B[M].includes(i)}).sort(function(n,i){return B[M].indexOf(n[1][D])-B[M].indexOf(i[1][D])}),E=R.filter(function(n){n[0];var i=n[1][D];return i&&(i.includes(c)||c.includes(i))});E.length>1&&(P=Math.max(0,E.findIndex(function(n){return n[0]===d})))}}var j=vn(T,a);return{id:a,actionId:y,label:g,highlight:c,side:T,style:F,stackIndex:P,score:k,isConnected:tn.has(y),showScrollLockToggle:tn.has(y)||ln&&on===y||!!an&&an===j.current,scrollSyncLocked:dn,toggleScrollSyncLocked:rn,isOrphan:f,isMissingClause:s,badgeRef:j,onClick:function(i){i.stopPropagation();var e=Jn?n(n({},Jn),{title:(null==Wn?void 0:Wn.title)||(null==Jn?void 0:Jn.title)||""}):{id:"orphan-left",title:"",content:""},t=Qn?n(n({},Qn),{title:(null==Ln?void 0:Ln.title)||(null==Qn?void 0:Qn.title)||""}):{id:"orphan-right",title:"",content:""};fn(i,e,f,t,y,F)},onSummaryClick:function(n){n.stopPropagation(),pn(n,y,f,O)}}}).filter(Boolean).sort(function(n,i){return parseFloat(n.label)-parseFloat(i.label)}),bi=o(function(){var n=new Set;return Ii.filter(function(i){return!n.has(i.id)&&(n.add(i.id),!0)})},[Ii]),_i=Q||!Fn&&wn?bi:[],ki=bi.map(function(n){return n.highlight}).filter(Boolean),wi=Ii.find(function(n){return tn.has(n.actionId)}),Ci=!!wi;if(!(kn||Mn||j.subsections&&0!==j.subsections.length))return null;var Fi=(null===(E=null==wi?void 0:wi.style)||void 0===E?void 0:E.badgeBorder)||(null==ii?void 0:ii.badgeBorder),Oi=Ci&&Fi?{borderRadius:"4px",outline:"2px solid ".concat(Fi),outlineOffset:"1px"}:{};return i(l,kn?n({ref:An,sx:{mt:1,width:"100%",minWidth:0,position:"relative"}},{children:i(l,n({sx:n({width:"100%"},Oi)},{children:e(d,n({disableGutters:!0,expanded:!Rn&&jn,onChange:function(){if(!Rn){if(jn){var i=String(on||""),e=i.includes(Yn)||i.includes(Zn);e||tn.forEach(function(n){(String(n).includes(Yn)||String(n).includes(Zn))&&(e=!0)}),e&&(hn(),mn(new Set),gn([]),xn.current=[])}U(function(i){var e;return n(n({},i),((e={})[A]=!i[A],e))})}},sx:{mt:0,boxShadow:"none",border:Rn?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF",minWidth:0,"&:before":{display:"none"}}},{children:[i(r,n({expandIcon:Rn?null:i(c,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"}}},{children:i(a,n({component:"div",sx:{fontSize:"11px",fontWeight:600,color:Rn?"#94A3B8":"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:En||"Untitled Subsection"}))})),!Rn&&e(u,n({sx:{pt:0,pb:1,minWidth:0}},{children:[Mn&&i(s,{content:Nn,overlayContent:Bn,sxStyles:un,deviationBadges:_i,maintainRelativeOrder:q,highlightBg:gi,suppressHighlightBg:On,highlights:ki,collisionKey:_n}),(j.subsections||[]).map(function(n,e){return i(k,{section:n,keyPath:"".concat(A,"-").concat(e),depth:W+1,columnKey:T,parentNodeId:D,sectionOffset:G,rhsOrphanVisualIndexes:H},"".concat(A,"-").concat(e))})]}))]}))}))}):n({ref:An,sx:{mt:0===W?1:.75,width:"100%",minWidth:0,position:"relative"}},{children:!Rn&&e(l,n({sx:n({width:"100%"},Oi)},{children:[Mn&&i(s,{content:Nn,overlayContent:Bn,sxStyles:un,deviationBadges:_i,maintainRelativeOrder:q,highlightBg:gi,suppressHighlightBg:On,highlights:ki,collisionKey:_n}),(j.subsections||[]).map(function(n,e){return i(k,{section:n,keyPath:"".concat(A,"-").concat(e),depth:W+1,columnKey:T,parentNodeId:D,sectionOffset:G,rhsOrphanVisualIndexes:H},"".concat(A,"-").concat(e))})]}))}))});export{k as default};
2
2
  //# sourceMappingURL=SubSectionAccordion.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as n,__rest as e}from"tslib";import{jsx as t,jsxs as r,Fragment as i}from"react/jsx-runtime";import{Box as o,Typography as a}from"@mui/material";import l,{useRef as c,useMemo as d,useLayoutEffect as s}from"react";import{DEFAULT_DEVIAION_COLOR as u}from"../CognitiveCompareConstants.js";import{EllipsisVertical as h}from"lucide-react";import p from"react-markdown";import{findRedlineTextAnchorRange as g,findTextMatchRange as f,mixHexColors as v,areMarkdownPropsEqual as m}from"../CognitiveComparehelpers.js";import b from"rehype-raw";import x from"remark-gfm";import{normalizeRedlineMarkdown as y}from"../utils/normalizeRedlineMarkdown.js";var w=function(n){return"function"==typeof n?n:(null==n?void 0:n.default)||n},E=[w(x)],S=[w(b)],k=l.memo(function(m){var b=m.content,x=m.overlayContent,w=m.sxStyles,k=m.deviationBadges,C=void 0===k?[]:k,B=m.highlights,F=void 0===B?[]:B;m.maintainRelativeOrder;var z=m.highlightBg,A=m.suppressHighlightBg,T=void 0!==A&&A,W=m.collisionKey,I=c(null),M=!!x,j=d(function(){return C.reduce(function(e,t){var r;return n(n({},e),((r={})[t.id]=t,r))},{})},[C]),$=c({badgeMap:j,highlightBg:z,hideHighlightBg:M,suppressHighlightBg:T});$.current={badgeMap:j,highlightBg:z,hideHighlightBg:M,suppressHighlightBg:T};var O=function(e,t){return l.Children.map(e,function(e){var r;if(!l.isValidElement(e))return e;var i=(null===(r=e.props)||void 0===r?void 0:r.children)?O(e.props.children,t):e.props.children,o=l.cloneElement(e,n(n({},e.props),{children:i}));return t(o)})},P=d(function(){return{mark:function(r){var i,o,a,l,c=r.children,d=e(r,["children"]),s=$.current,u=s.badgeMap,h=s.highlightBg,p=s.hideHighlightBg,g=s.suppressHighlightBg,f=d["data-badge-id"],v=f?u[f]:null,m=d["data-highlight-color"],b=null!==(l=null!==(o=null!=m?m:null===(i=null==v?void 0:v.style)||void 0===i?void 0:i.highlightBg)&&void 0!==o?o:null===(a=null==v?void 0:v.style)||void 0===a?void 0:a.badgeBg)&&void 0!==l?l:h,x="true"===d["data-is-suggested-deviation-fix"]||g;return t("span",n({style:n(n(n({},x?{}:{backgroundColor:b}),{borderRadius:"2px",display:"inline",boxDecorationBreak:"clone",WebkitBoxDecorationBreak:"clone",backgroundClip:"padding-box",padding:"0 1px"}),p?{color:"transparent"}:{})},{children:c}))},span:function(i){var a,l,c,d,s,p,g=i.children,f=e(i,["children"]),v=$.current.badgeMap,m=f["data-badge-id"];if(!m)return t("span",n({},f,{children:g}));var b=v[m];if(!b)return t("span",n({},f,{children:g}));var x="number"==typeof b.stackIndex?b.stackIndex:0,y="translateY(calc(-20% + ".concat(12*x,"px + var(--badge-nudge, 0px)))");return r(o,n({component:"span",sx:{position:"static",display:"inline"}},{children:[r(o,n({ref:b.badgeRef,className:"deviation-badge","data-side":b.side||"right",sx:n(n({fontStyle:"normal",position:"absolute",zIndex:30+x,display:"inline-flex",alignItems:"stretch",fontSize:"10px",bgcolor:(null===(a=b.style)||void 0===a?void 0:a.badgeBg)||"#EEF2FF",color:(null===(l=b.style)||void 0===l?void 0:l.badgeText)||u,border:"1px solid ".concat((null===(c=b.style)||void 0===c?void 0:c.badgeBorder)||"#C7D2FE"),borderRadius:"12px",fontWeight:600,whiteSpace:"nowrap",boxShadow:"0 1px 3px rgba(0,0,0,0.07)",overflow:"hidden",transition:"none"},"left"===b.side?{right:"-16px",transform:"".concat(y," translateX(calc(100% + 8px))")}:{left:"-16px",transform:"".concat(y," translateX(calc(-100% - 8px))")}),b.isConnected&&b.style&&{outline:"2px solid ".concat(b.style.badgeBorder),outlineOffset:"1px"})},{children:[r(o,n({onClick:function(n){n.stopPropagation(),b.onSummaryClick&&b.onSummaryClick(n)},sx:{display:"flex",alignItems:"center",px:1,py:.3,cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.04)"}}},{children:[t(o,n({component:"span",sx:{fontSize:"10px",fontWeight:700}},{children:b.label})),("left"===b.side||b.isOrphan)&&t(o,n({component:"span",sx:{fontSize:"10px",pl:.5,ml:.5,borderLeft:"1px solid ".concat((null===(d=b.style)||void 0===d?void 0:d.badgeBorder)||"#C7D2FE")}},{children:null!=b.score&&"N/A"!==b.score&&"NA"!==b.score&&0!==b.score?"".concat(b.score):"N/A"===b.score||"NA"===b.score?"N/A":"Same"}))]})),("left"===b.side||b.isOrphan)&&t(o,n({onClick:function(n){n.stopPropagation(),b.onClick&&b.onClick(n)},sx:{display:"flex",alignItems:"center",px:.5,borderLeft:"1px solid ".concat((null===(s=b.style)||void 0===s?void 0:s.badgeBorder)||"#C7D2FE"),cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.06)"}}},{children:t(h,{size:12,color:(null===(p=b.style)||void 0===p?void 0:p.badgeText)||"#3730A3"})}))]})),g]}))},table:function(e){var r=e.children;return t(o,n({sx:{display:"block",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",contain:"inline-size",overflowX:"auto",overflowY:"hidden",overscrollBehaviorX:"contain",WebkitOverflowScrolling:"touch",my:1}},{children:t(o,n({component:"table",sx:{width:"600px",minWidth:"600px",tableLayout:"fixed",borderCollapse:"collapse",fontSize:"inherit"}},{children:r}))}))},thead:function(e){var r=e.children;return t(o,n({component:"thead"},{children:r}))},tbody:function(e){var r=e.children;return t(o,n({component:"tbody"},{children:r}))},tr:function(e){var r=e.children;return t(o,n({component:"tr",sx:{borderBottom:"1px solid #E5E7EB"}},{children:r}))},th:function(e){var r=e.children;return t(o,n({component:"th",sx:{border:"1px solid #E5E7EB",padding:"8px",textAlign:"left",verticalAlign:"top",fontWeight:600,backgroundColor:"#F9FAFB",whiteSpace:"normal",wordBreak:"break-word",overflowWrap:"anywhere"}},{children:r}))},td:function(e){var r=e.children;return t(o,n({component:"td",sx:{border:"1px solid #E5E7EB",padding:"8px",verticalAlign:"top",whiteSpace:"normal",wordBreak:"break-word",overflowWrap:"anywhere"}},{children:r}))},code:function(e){var r=e.children;return t("span",n({style:{fontFamily:"inherit",fontSize:"inherit"}},{children:r}))},pre:function(e){var r=e.children;return t("span",n({style:{fontFamily:"inherit",fontSize:"inherit",display:"block",whiteSpace:"pre-wrap"}},{children:r}))},updated:function(n){var e=n.children;return t(i,{children:e})},deleted:function(e){var r=e.children,i=O(r,function(n){return l.cloneElement(n,{"data-is-suggested-deviation-fix":"true"})});return t("span",n({style:{boxShadow:"inset 0 1px 0 #EF4444, inset 0 -1px 0 #EF4444",backgroundColor:"#FCCCCC",textDecoration:"line-through"}},{children:i}))},changed:function(e){var r=e.children,i=O(r,function(n){return l.cloneElement(n,{"data-is-suggested-deviation-fix":"true"})});return t("span",n({style:{boxShadow:"inset 0 1px 0 #2F59FF, inset 0 -1px 0 #2F59FF",backgroundColor:"#D5E8FF"}},{children:i}))},ul:function(r){var i=r.children,a=e(r,["children"]);return t(o,n({component:"ul",sx:{mt:1,mb:1,pl:3,listStyleType:"disc"}},a,{children:i}))},ol:function(r){var i=r.children,a=e(r,["children"]);return t(o,n({component:"ol",sx:{mt:1,mb:1,pl:3,listStyleType:"decimal"}},a,{children:i}))},li:function(r){var i=r.children,a=e(r,["children"]);return t(o,n({component:"li",sx:{mb:.5,display:"list-item"}},a,{children:i}))}}},[]),R=function(n){if(!n||"string"!=typeof n)return"";var e=n,t=(e=(e=(e=(e=(e=(e=(e=(e=e.replace(/((?:<\/?[a-z]+[^>]*>\s*)+)([*+\-] |\d+\. )/gi,"$2$1")).replace(/\\(['"])/g,"$1").replace(/\\n/g,"\n").replace(/\\\./g,".").replace(/\r\n/g,"\n")).replace(/^([ \t]*)(\d+\.)(\s{2,})/gm,function(n,e,t,r){return"".concat(e).concat(t.slice(0,-1),"\\.").concat(r)})).replace(/^(\d+\.)\s*\n+(\s+)(\S)/gm,function(n,e,t,r){return"".concat(e," ").concat(r)})).replace(/([^\n])\n(#{1,6} )/g,"$1\n\n$2")).replace(/([^\n])\n([ \t]*(?:[#*+\-] |\d+\. ))/g,"$1\n\n$2")).replace(/\n{3,}/g,"\n\n")).replace(/^[ \t]+(?![ \t]*([\*\-\+] |\d+\. ))/gm,function(n){return n.replace(/ /g," ").replace(/\t/g,"    ")})).split(/(\n{2,})/);return(e=t.map(function(n){return/^\n+$/.test(n)||/\|.*\|/.test(n)&&/\|[\s:|-]+\|/.test(n)||/^#{1,6} /.test(n.trimStart())?n:n.replace(/\n(?=[^\n])/g,function(e,t){var r=n.slice(t+1);return/^[ \t]*([#>|\-*+]|\d+\.)/.test(r)?"\n":" "})}).join("")).trim()},D=d(function(){return C.map(function(n){return{id:n.id,connected:n.isConnected,stackIndex:n.stackIndex,size:n.size}})},[C]),H=function(n){return R(y(n||""))},N=d(function(){var e=R(y(b||"")),t=(C||[]).map(function(n){var e,t;return{id:null==n?void 0:n.id,highlight:H((null==n?void 0:n.highlight)||""),highlightColor:(null===(e=null==n?void 0:n.style)||void 0===e?void 0:e.highlightBg)||(null===(t=null==n?void 0:n.style)||void 0===t?void 0:t.badgeBg)||z}}).filter(function(n){return n.id&&n.highlight}),r={};t.forEach(function(n){r[n.highlight]||(r[n.highlight]=[]),r[n.highlight].push(n)});var i=function(n,e,t,r){void 0===e&&(e=""),void 0===r&&(r=[]);var i=!1,o=function(n){var o=function(n,e,t){var r,i,o;void 0===e&&(e="");var a=n.match(/^(\s*)([\s\S]*?)(\s*)$/);if(!a)return n;var l=null!==(r=a[1])&&void 0!==r?r:"",c=null!==(i=a[2])&&void 0!==i?i:"",d=null!==(o=a[3])&&void 0!==o?o:"";return c?l+function(n,e){void 0===n&&(n="");var t=e?' data-highlight-color="'.concat(e,'"'):"",r=n?' data-badge-id="'.concat(n,'"'):"";return"<mark".concat(r).concat(t,">")}(e,t)+c+"</mark>"+d:n}(n,e,t),a=o;if(!i&&r.length>0){i=!0;var l="",c="";r.forEach(function(n){l+=function(n){return'<span data-badge-id="'.concat(n,'">')}(n.id),c="</span>"+c}),a=l+o+c}return"​"+a};return n.split(/(\n+)/).map(function(n){return/^\n+$/.test(n)?n:n.trim()?""===n.replace(/[|:\-\s]/g,"")&&n.includes("-")?n:n.includes("|")?n.split(/(\|)/).map(function(n){return"|"!==n&&n.trim()?o(n):n}).join(""):o(n):n}).join("")},o=[];Object.entries(r).forEach(function(n){var t=n[0],r=n[1],i=T?g(e,t):f(e,t,!1);if(i){for(var a=e.slice(i.start,i.end)!==t,l=r[0].highlightColor,c=1;c<r.length;c++)l=v(l,r[c].highlightColor||"");o.push({highlight:t,start:i.start,end:i.end,badges:r,color:l,usedLooseMatch:a})}});var a=new Set(Object.keys(r));(F||[]).forEach(function(n){if(n){var t=H(n);if(t&&!a.has(t)){var r=T?g(e,t):f(e,t,!1);if(r){var i=e.slice(r.start,r.end)!==t,l=e.slice(0,r.start);(l.match(/</g)||[]).length===(l.match(/>/g)||[]).length&&o.push({highlight:t,start:r.start,end:r.end,badges:[],color:z||"",usedLooseMatch:i})}}}}),o.sort(function(n,e){return n.start-e.start||e.end-n.end});var l=[],c={};o.forEach(function(n,e){for(var t=n.start,r=n.end,i=0,o=l;i<o.length;i++){var a=o[i],d=a.start,s=a.end,u=t<s&&r>s&&t>=d,h=t<d&&r>d&&r<=s;if(t>=d&&r<=s){n.orphaned=!0,c[e]=a.matchIdx;break}u&&(t=s),h&&(r=d)}n.trimmedStart=t,n.trimmedEnd=r,!n.orphaned&&t<r&&l.push({start:t,end:r,matchIdx:e})});var d={};Object.entries(c).forEach(function(n){var e=n[0],t=n[1],r=Number(e);d[t]||(d[t]=[]),d[t].push(r)});var s=o.map(function(e,t){return n(n({},e),{idx:t})}).filter(function(n){return!n.orphaned}).sort(function(n,e){var t,r;return(null!==(t=e.trimmedStart)&&void 0!==t?t:e.start)-(null!==(r=n.trimmedStart)&&void 0!==r?r:n.start)});return s.forEach(function(n){var t,r,a,l,c=null!==(t=n.trimmedStart)&&void 0!==t?t:n.start,s=null!==(r=n.trimmedEnd)&&void 0!==r?r:n.end;if(!(c>=s)){var u=e.slice(c,s),h=function(n,e,t,r){if(!t.length)return n;var a=t.map(function(n){return o[n]}).sort(function(n,e){return n.start-e.start}),l="",c=0;return a.forEach(function(t){var o,a,d=Math.max(c,t.start-e),s=Math.max(d,t.end-e);if(!(d>=s)){var u=v(r,t.color||"");l+=n.slice(c,d),l+=i(n.slice(d,s),(null===(a=null===(o=t.badges)||void 0===o?void 0:o[0])||void 0===a?void 0:a.id)||"",u,t.badges||[]),c=s}}),l+=n.slice(c)}(n.usedLooseMatch||c!==n.start||s!==n.end?u:n.highlight,n.start,d[n.idx]||[],n.color),p=i(h,(null===(l=null===(a=n.badges)||void 0===a?void 0:a[0])||void 0===l?void 0:l.id)||"",n.color,n.badges||[]);e=e.slice(0,c)+p+e.slice(s)}}),e},[b,C,F,z,T]),L=d(function(){return x?R(y(x||"")):""},[x]),q=!!x,X={"& *":{fontFamily:"inherit"},"& code, & pre, & kbd, & samp":{fontFamily:"inherit !important",fontSize:"inherit",background:"none",padding:0,border:"none",whiteSpace:"pre-wrap"},"& p, & li, & ul, & ol":{position:"static",overflow:"visible",whiteSpace:"pre-wrap"}},Y=n(n(n(n({},w),X),{position:"relative",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",overflow:"visible",whiteSpace:"normal",gridArea:"1 / 1",zIndex:2}),q?{color:"transparent",userSelect:"none",pointerEvents:"none","& .deviation-badge":{pointerEvents:"auto",visibility:"visible"},"& table":{visibility:"hidden",margin:"0 !important"},"& p:empty":{display:"none"}}:{}),K=n(n(n({},w),X),{position:"relative",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",overflow:"visible",whiteSpace:"normal",gridArea:"1 / 1",zIndex:1,pointerEvents:"auto"});return s(function(){if(I.current){var n=function(){var n=Array.from(I.current.querySelectorAll(".deviation-badge"));if(0!==n.length){n.forEach(function(n){n.style.setProperty("--badge-nudge","0px")});var e=n.filter(function(n){return"left"===n.dataset.side}),t=n.filter(function(n){return"left"!==n.dataset.side}),r=I.current.getBoundingClientRect(),i=r.bottom-4,o=r.top+4,a=function(n){if(0!==n.length){var e=n.map(function(n){var e=n.getBoundingClientRect();return{el:n,naturalTop:e.top,height:e.height,currentTop:e.top}});e.sort(function(n,e){return n.naturalTop-e.naturalTop});var t=[],r=[];e.forEach(function(n){if(0===r.length)r.push(n);else{var e=r[r.length-1],i=e.currentTop+e.height;n.naturalTop<i+8?(n.currentTop=i+8,r.push(n)):(t.push(r),r=[n])}}),r.length>0&&t.push(r),t.forEach(function(n){var e=n[n.length-1],t=e.currentTop+e.height;if(t>i){var r=t-i,a=n[0].currentTop-o,l=Math.max(0,Math.min(r,a));n.forEach(function(n){n.currentTop-=l})}}),t.flat().forEach(function(n){var e=n.currentTop-n.naturalTop;n.el.style.setProperty("--badge-nudge","".concat(e,"px"))})}};a(e),a(t)}},e=requestAnimationFrame(function(){requestAnimationFrame(function(){n()})}),t=new ResizeObserver(function(){requestAnimationFrame(n)});return t.observe(I.current),function(){t.disconnect(),cancelAnimationFrame(e)}}},[N,W,D]),r(o,n({ref:I,sx:{position:"relative",display:"grid",gridTemplateColumns:"minmax(0, 1fr)",width:"100%",maxWidth:"100%",minWidth:0}},{children:[t(a,n({component:"div",sx:n(n({},Y),{padding:"3px"})},{children:t(p,n({components:P,remarkPlugins:E,rehypePlugins:S},{children:N.replace(/#{3}/g,"")}))})),q&&t(a,n({component:"div",sx:K},{children:t(p,n({components:P,remarkPlugins:E,rehypePlugins:S},{children:L}))}))]}))},m);export{k as MemoizedMarkdown};
1
+ import{__assign as n,__rest as e}from"tslib";import{jsx as t,jsxs as r,Fragment as i}from"react/jsx-runtime";import{Box as o,Typography as a}from"@mui/material";import l,{useRef as d,useMemo as c,useLayoutEffect as s}from"react";import{DEFAULT_DEVIAION_COLOR as u}from"../CognitiveCompareConstants.js";import{EllipsisVertical as h}from"lucide-react";import p from"react-markdown";import{mixHexColors as g,areMarkdownPropsEqual as f}from"../CognitiveComparehelpers.js";import v from"rehype-raw";import m from"remark-gfm";var b=function(n){return"function"==typeof n?n:(null==n?void 0:n.default)||n},x=[b(m)],y=[b(v)],w=l.memo(function(f){var v=f.content,m=f.overlayContent,b=f.sxStyles,w=f.deviationBadges,E=void 0===w?[]:w,S=f.highlights,k=void 0===S?[]:S;f.maintainRelativeOrder;var C=f.highlightBg,B=f.suppressHighlightBg,F=void 0!==B&&B,z=f.collisionKey,A=d(null),T=!!m,W=c(function(){return E.reduce(function(e,t){var r;return n(n({},e),((r={})[t.id]=t,r))},{})},[E]),O=d({badgeMap:W,highlightBg:C,hideHighlightBg:T,suppressHighlightBg:F});O.current={badgeMap:W,highlightBg:C,hideHighlightBg:T,suppressHighlightBg:F};var I=function(e,t){return l.Children.map(e,function(e){var r;if(!l.isValidElement(e))return e;var i=(null===(r=e.props)||void 0===r?void 0:r.children)?I(e.props.children,t):e.props.children,o=l.cloneElement(e,n(n({},e.props),{children:i}));return t(o)})},M=c(function(){return{mark:function(r){var i,o,a,l,d=r.children,c=e(r,["children"]),s=O.current,u=s.badgeMap,h=s.highlightBg,p=s.hideHighlightBg,g=s.suppressHighlightBg,f=c["data-badge-id"],v=f?u[f]:null,m=c["data-highlight-color"],b=null!==(l=null!==(o=null!=m?m:null===(i=null==v?void 0:v.style)||void 0===i?void 0:i.highlightBg)&&void 0!==o?o:null===(a=null==v?void 0:v.style)||void 0===a?void 0:a.badgeBg)&&void 0!==l?l:h,x="true"===c["data-is-suggested-deviation-fix"]||g;return t("span",n({style:n(n(n({},x?{}:{backgroundColor:b}),{borderRadius:"2px",display:"inline",boxDecorationBreak:"clone",WebkitBoxDecorationBreak:"clone",backgroundClip:"padding-box",padding:"0 1px"}),p?{color:"transparent"}:{})},{children:d}))},span:function(i){var a,l,d,c,s,p,g=i.children,f=e(i,["children"]),v=O.current.badgeMap,m=f["data-badge-id"];if(!m)return t("span",n({},f,{children:g}));var b=v[m];if(!b)return t("span",n({},f,{children:g}));var x="number"==typeof b.stackIndex?b.stackIndex:0,y="translateY(calc(-20% + ".concat(12*x,"px + var(--badge-nudge, 0px)))");return r(o,n({component:"span",sx:{position:"static",display:"inline"}},{children:[r(o,n({ref:b.badgeRef,className:"deviation-badge","data-side":b.side||"right",sx:n(n({fontStyle:"normal",position:"absolute",zIndex:30+x,display:"inline-flex",alignItems:"stretch",fontSize:"10px",bgcolor:(null===(a=b.style)||void 0===a?void 0:a.badgeBg)||"#EEF2FF",color:(null===(l=b.style)||void 0===l?void 0:l.badgeText)||u,border:"1px solid ".concat((null===(d=b.style)||void 0===d?void 0:d.badgeBorder)||"#C7D2FE"),borderRadius:"12px",fontWeight:600,whiteSpace:"nowrap",boxShadow:"0 1px 3px rgba(0,0,0,0.07)",overflow:"hidden",transition:"none"},"left"===b.side?{right:"-16px",transform:"".concat(y," translateX(calc(100% + 8px))")}:{left:"-16px",transform:"".concat(y," translateX(calc(-100% - 8px))")}),b.isConnected&&b.style&&{outline:"2px solid ".concat(b.style.badgeBorder),outlineOffset:"1px"})},{children:[r(o,n({onClick:function(n){n.stopPropagation(),b.onSummaryClick&&b.onSummaryClick(n)},sx:{display:"flex",alignItems:"center",px:1,py:.3,cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.04)"}}},{children:[t(o,n({component:"span",sx:{fontSize:"10px",fontWeight:700}},{children:b.label})),("left"===b.side||b.isOrphan)&&t(o,n({component:"span",sx:{fontSize:"10px",pl:.5,ml:.5,borderLeft:"1px solid ".concat((null===(c=b.style)||void 0===c?void 0:c.badgeBorder)||"#C7D2FE")}},{children:null!=b.score&&"N/A"!==b.score&&"NA"!==b.score&&0!==b.score?"".concat(b.score):"N/A"===b.score||"NA"===b.score?"N/A":"Same"}))]})),("left"===b.side||b.isOrphan)&&t(o,n({onClick:function(n){n.stopPropagation(),b.onClick&&b.onClick(n)},sx:{display:"flex",alignItems:"center",px:.5,borderLeft:"1px solid ".concat((null===(s=b.style)||void 0===s?void 0:s.badgeBorder)||"#C7D2FE"),cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.06)"}}},{children:t(h,{size:12,color:(null===(p=b.style)||void 0===p?void 0:p.badgeText)||"#3730A3"})}))]})),g]}))},table:function(e){var r=e.children;return t(o,n({sx:{display:"block",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",contain:"inline-size",overflowX:"auto",overflowY:"hidden",overscrollBehaviorX:"contain",WebkitOverflowScrolling:"touch",my:1}},{children:t(o,n({component:"table",sx:{width:"600px",minWidth:"600px",tableLayout:"fixed",borderCollapse:"collapse",fontSize:"inherit"}},{children:r}))}))},thead:function(e){var r=e.children;return t(o,n({component:"thead"},{children:r}))},tbody:function(e){var r=e.children;return t(o,n({component:"tbody"},{children:r}))},tr:function(e){var r=e.children;return t(o,n({component:"tr",sx:{borderBottom:"1px solid #E5E7EB"}},{children:r}))},th:function(e){var r=e.children;return t(o,n({component:"th",sx:{border:"1px solid #E5E7EB",padding:"8px",textAlign:"left",verticalAlign:"top",fontWeight:600,backgroundColor:"#F9FAFB",whiteSpace:"normal",wordBreak:"break-word",overflowWrap:"anywhere"}},{children:r}))},td:function(e){var r=e.children;return t(o,n({component:"td",sx:{border:"1px solid #E5E7EB",padding:"8px",verticalAlign:"top",whiteSpace:"normal",wordBreak:"break-word",overflowWrap:"anywhere"}},{children:r}))},code:function(e){var r=e.children;return t("span",n({style:{fontFamily:"inherit",fontSize:"inherit"}},{children:r}))},pre:function(e){var r=e.children;return t("span",n({style:{fontFamily:"inherit",fontSize:"inherit",display:"block",whiteSpace:"pre-wrap"}},{children:r}))},updated:function(n){var e=n.children;return t(i,{children:e})},deleted:function(e){var r=e.children,i=I(r,function(n){return l.cloneElement(n,{"data-is-suggested-deviation-fix":"true"})});return t("span",n({style:{boxShadow:"inset 0 1px 0 #EF4444, inset 0 -1px 0 #EF4444",backgroundColor:"#FCCCCC",textDecoration:"line-through"}},{children:i}))},changed:function(e){var r=e.children,i=I(r,function(n){return l.cloneElement(n,{"data-is-suggested-deviation-fix":"true"})});return t("span",n({style:{boxShadow:"inset 0 1px 0 #2F59FF, inset 0 -1px 0 #2F59FF",backgroundColor:"#D5E8FF"}},{children:i}))},ul:function(r){var i=r.children,a=e(r,["children"]);return t(o,n({component:"ul",sx:{mt:1,mb:1,pl:3,listStyleType:"disc"}},a,{children:i}))},ol:function(r){var i=r.children,a=e(r,["children"]);return t(o,n({component:"ol",sx:{mt:1,mb:1,pl:3,listStyleType:"decimal"}},a,{children:i}))},li:function(r){var i=r.children,a=e(r,["children"]);return t(o,n({component:"li",sx:{mb:.5,display:"list-item"}},a,{children:i}))}}},[]),$=function(n){if(!n||"string"!=typeof n)return"";var e=n,t=(e=(e=(e=(e=(e=(e=(e=(e=e.replace(/((?:<\/?[a-z]+[^>]*>\s*)+)([*+\-] |\d+\. )/gi,"$2$1")).replace(/\\(['"])/g,"$1").replace(/\\n/g,"\n").replace(/\\\./g,".").replace(/\r\n/g,"\n")).replace(/^(\d+\.)(\s{2,})/gm,function(n,e,t){return"".concat(e.slice(0,-1),"\\.").concat(t)})).replace(/^(\d+\.)\s*\n+(\s+)(\S)/gm,function(n,e,t,r){return"".concat(e," ").concat(r)})).replace(/([^\n])\n(#{1,6} )/g,"$1\n\n$2")).replace(/([^\n])\n([ \t]*(?:[#*+\-] |\d+\. ))/g,"$1\n\n$2")).replace(/\n{3,}/g,"\n\n")).replace(/^[ \t]+(?![ \t]*([\*\-\+] |\d+\. ))/gm,function(n){return n.replace(/ /g," ").replace(/\t/g,"    ")})).split(/(\n{2,})/);return(e=t.map(function(n){return/^\n+$/.test(n)||/\|.*\|/.test(n)&&/\|[\s:|-]+\|/.test(n)||/^#{1,6} /.test(n.trimStart())?n:n.replace(/\n(?=[^\n])/g,function(e,t){var r=n.slice(t+1);return/^[ \t]*([#>|\-*+]|\d+\.)/.test(r)?"\n":" "})}).join("")).trim()},j=function(n){return n.replace(/[\.,;:]/g," ")},P=c(function(){return E.map(function(n){return{id:n.id,connected:n.isConnected,stackIndex:n.stackIndex,size:n.size}})},[E]),D=c(function(){var e=$(v||""),t=F?j(e):e,r=(E||[]).map(function(n){var e,t;return{id:null==n?void 0:n.id,highlight:$((null==n?void 0:n.highlight)||""),highlightColor:(null===(e=null==n?void 0:n.style)||void 0===e?void 0:e.highlightBg)||(null===(t=null==n?void 0:n.style)||void 0===t?void 0:t.badgeBg)||C}}).filter(function(n){return n.id&&n.highlight}),i={};r.forEach(function(n){i[n.highlight]||(i[n.highlight]=[]),i[n.highlight].push(n)});var o=function(n,e,t,r){void 0===e&&(e=""),void 0===r&&(r=[]);var i=!1,o=function(n){var o=function(n,e,t){var r,i,o;void 0===e&&(e="");var a=n.match(/^(\s*)([\s\S]*?)(\s*)$/);if(!a)return n;var l=null!==(r=a[1])&&void 0!==r?r:"",d=null!==(i=a[2])&&void 0!==i?i:"",c=null!==(o=a[3])&&void 0!==o?o:"";return d?l+function(n,e){void 0===n&&(n="");var t=e?' data-highlight-color="'.concat(e,'"'):"",r=n?' data-badge-id="'.concat(n,'"'):"";return"<mark".concat(r).concat(t,">")}(e,t)+d+"</mark>"+c:n}(n,e,t),a=o;if(!i&&r.length>0){i=!0;var l="",d="";r.forEach(function(n){l+=function(n){return'<span data-badge-id="'.concat(n,'">')}(n.id),d="</span>"+d}),a=l+o+d}return"​"+a};return n.split(/(\n+)/).map(function(n){return/^\n+$/.test(n)?n:n.trim()?""===n.replace(/[|:\-\s]/g,"")&&n.includes("-")?n:n.includes("|")?n.split(/(\|)/).map(function(n){return"|"!==n&&n.trim()?o(n):n}).join(""):o(n):n}).join("")},a=[];Object.entries(i).forEach(function(n){var r=n[0],i=n[1],o=e.indexOf(r),l=!1;if(-1===o&&F){var d=j(r);-1!==(o=t.indexOf(d))&&(l=!0)}if(-1!==o){for(var c=i[0].highlightColor,s=1;s<i.length;s++)c=g(c,i[s].highlightColor||"");a.push({highlight:r,start:o,end:o+r.length,badges:i,color:c,usedLooseMatch:l})}});var l=new Set(Object.keys(i));(k||[]).forEach(function(n){if(n){var r=$(n);if(r&&!l.has(r)){var i=e.indexOf(r),o=!1;if(-1===i&&F){var d=j(r);-1!==(i=t.indexOf(d))&&(o=!0)}if(-1!==i){var c=e.slice(0,i);(c.match(/</g)||[]).length===(c.match(/>/g)||[]).length&&a.push({highlight:r,start:i,end:i+r.length,badges:[],color:C||"",usedLooseMatch:o})}}}}),a.sort(function(n,e){return n.start-e.start||e.end-n.end});var d=[],c={};a.forEach(function(n,e){for(var t=n.start,r=n.end,i=0,o=d;i<o.length;i++){var a=o[i],l=a.start,s=a.end,u=t<s&&r>s&&t>=l,h=t<l&&r>l&&r<=s;if(t>=l&&r<=s){n.orphaned=!0,c[e]=a.matchIdx;break}u&&(t=s),h&&(r=l)}n.trimmedStart=t,n.trimmedEnd=r,!n.orphaned&&t<r&&d.push({start:t,end:r,matchIdx:e})});var s={};Object.entries(c).forEach(function(n){var e=n[0],t=n[1],r=Number(e);s[t]||(s[t]=[]),s[t].push(r)});var u=a.map(function(e,t){return n(n({},e),{idx:t})}).filter(function(n){return!n.orphaned}).sort(function(n,e){var t,r;return(null!==(t=e.trimmedStart)&&void 0!==t?t:e.start)-(null!==(r=n.trimmedStart)&&void 0!==r?r:n.start)});return u.forEach(function(n){var t,r,i,l,d=null!==(t=n.trimmedStart)&&void 0!==t?t:n.start,c=null!==(r=n.trimmedEnd)&&void 0!==r?r:n.end;if(!(d>=c)){var u=e.slice(d,c),h=function(n,e,t,r){if(!t.length)return n;var i=t.map(function(n){return a[n]}).sort(function(n,e){return n.start-e.start}),l="",d=0;return i.forEach(function(t){var i,a,c=Math.max(d,t.start-e),s=Math.max(c,t.end-e);if(!(c>=s)){var u=g(r,t.color||"");l+=n.slice(d,c),l+=o(n.slice(c,s),(null===(a=null===(i=t.badges)||void 0===i?void 0:i[0])||void 0===a?void 0:a.id)||"",u,t.badges||[]),d=s}}),l+=n.slice(d)}(n.usedLooseMatch||d!==n.start||c!==n.end?u:n.highlight,n.start,s[n.idx]||[],n.color),p=o(h,(null===(l=null===(i=n.badges)||void 0===i?void 0:i[0])||void 0===l?void 0:l.id)||"",n.color,n.badges||[]);e=e.slice(0,d)+p+e.slice(c)}}),e},[v,E,k,C,F]),H=c(function(){return m?$(m||""):""},[m]),N=!!m,R={"& *":{fontFamily:"inherit"},"& code, & pre, & kbd, & samp":{fontFamily:"inherit !important",fontSize:"inherit",background:"none",padding:0,border:"none",whiteSpace:"pre-wrap"},"& p, & li, & ul, & ol":{position:"static",overflow:"visible",whiteSpace:"pre-wrap"}},L=n(n(n(n({},b),R),{position:"relative",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",overflow:"visible",whiteSpace:"normal",gridArea:"1 / 1",zIndex:2}),N?{color:"transparent",userSelect:"none",pointerEvents:"none","& .deviation-badge":{pointerEvents:"auto"},"& table":{visibility:"hidden",margin:"0 !important"},"& th, & td":{padding:"0 !important",border:"none !important",backgroundColor:"transparent !important"},"& tr":{border:"none !important"},"& p:empty":{display:"none"}}:{}),q=n(n(n({},b),R),{position:"relative",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",overflow:"visible",whiteSpace:"normal",gridArea:"1 / 1",zIndex:1,pointerEvents:"auto"});return s(function(){if(A.current){var n=function(){var n=Array.from(A.current.querySelectorAll(".deviation-badge"));if(0!==n.length){n.forEach(function(n){n.style.setProperty("--badge-nudge","0px")});var e=n.filter(function(n){return"left"===n.dataset.side}),t=n.filter(function(n){return"left"!==n.dataset.side}),r=A.current.getBoundingClientRect(),i=r.bottom-4,o=r.top+4,a=function(n){if(0!==n.length){var e=n.map(function(n){var e=n.getBoundingClientRect();return{el:n,naturalTop:e.top,height:e.height,currentTop:e.top}});e.sort(function(n,e){return n.naturalTop-e.naturalTop});var t=[],r=[];e.forEach(function(n){if(0===r.length)r.push(n);else{var e=r[r.length-1],i=e.currentTop+e.height;n.naturalTop<i+8?(n.currentTop=i+8,r.push(n)):(t.push(r),r=[n])}}),r.length>0&&t.push(r),t.forEach(function(n){var e=n[n.length-1],t=e.currentTop+e.height;if(t>i){var r=t-i,a=n[0].currentTop-o,l=Math.max(0,Math.min(r,a));n.forEach(function(n){n.currentTop-=l})}}),t.flat().forEach(function(n){var e=n.currentTop-n.naturalTop;n.el.style.setProperty("--badge-nudge","".concat(e,"px"))})}};a(e),a(t)}},e=requestAnimationFrame(function(){requestAnimationFrame(function(){n()})}),t=new ResizeObserver(function(){requestAnimationFrame(n)});return t.observe(A.current),function(){t.disconnect(),cancelAnimationFrame(e)}}},[D,z,P]),r(o,n({ref:A,sx:{position:"relative",display:"grid",gridTemplateColumns:"minmax(0, 1fr)",width:"100%",maxWidth:"100%",minWidth:0}},{children:[t(a,n({component:"div",sx:n(n({},L),{padding:"3px"})},{children:t(p,n({components:M,remarkPlugins:x,rehypePlugins:y},{children:D.replace(/#{3}/g,"")}))})),N&&t(a,n({component:"div",sx:q},{children:t(p,n({components:M,remarkPlugins:x,rehypePlugins:y},{children:H}))}))]}))},f);export{w as MemoizedMarkdown};
2
2
  //# sourceMappingURL=memoizedMarkdown.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as n,__spreadArray as e}from"tslib";import{useMemo as t}from"react";import{safeStringify as i,isMissingStr as o,getRationale as r,resolveComparisonInputItems as a,getSideData as l,hasValue as d,DEVIATION_BADGE_SEPARATOR as s}from"../CognitiveComparehelpers.js";import{buildComparisonRows as u}from"../utils/buildComparisonRows.js";var v={id:"",title:"",similarity:0,sections:[]},c=function(c,f,p,_,I,g,h){var m,x;void 0===I&&(I=!0);var b="string"==typeof p?p:JSON.stringify(p||{}),y=null!=h?h:Boolean("string"==typeof g?g.trim():g&&(g.learnings_data||(null===(x=null===(m=g.data)||void 0===m?void 0:m.artifactData)||void 0===x?void 0:x.userStorySnapshot))),R=t(function(){if(!c||0===Object.keys(c).length)return{activeProposed:{},activeVariants:[],comparisonRows:[],parseError:"Tree data is required"};var t=JSON.parse(b);try{var d=c.nodes||c,s=[],v=[],p=[],_=c.base_root_id,h=c.input_index_map||{0:"left",1:"right"},m=c[_]||d[_];if(!m||!1===m.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[],comparisonRows:[],parseError:null};var x=c.content_mapping||{},R=function(n){return c[n]||d[n]},C=function(e,t,r){if(!e||"object"!=typeof e)return e||null;if(e.deviations)return e;if(I)return e;var a=Object.keys(e).filter(function(n){return/^\d+$/.test(n)});if(!a.length)return e;var l=a.sort(function(n,e){return Number(n)-Number(e)}),d={},s={},u=null;return l.forEach(function(n){var a,l,v,c,f,p,_,I=e[n];if(I&&"object"==typeof I){u||(u=I);var g="same"===i(null===(l=null==I?void 0:I.evaluation_outputs)||void 0===l?void 0:l.output_value).trim().toLowerCase(),m=!((null==I?void 0:I.status)&&"pending"!==I.status||g),x=(null==I?void 0:I.deviation_highlight)||(null===(v=null==I?void 0:I.web_search_answer)||void 0===v?void 0:v.deviation_highlight),b=function(n){var e,t=(null===(e=null==I?void 0:I.cognitive_decisioning)||void 0===e?void 0:e.citations)||(null==I?void 0:I.citations)||{};return Object.values(t).map(function(e){var t;return null===(t=null==e?void 0:e[n])||void 0===t?void 0:t.highlighted_text}).filter(function(n){return"string"==typeof n&&n.trim().length>0})},y=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];for(var t=0,i=n;t<i.length;t++){var r=i[t];if(Array.isArray(r)&&r.some(function(n){return!o(n)}))return r}return[]},R=m?y((null===(c=null==I?void 0:I.deviation_highlights)||void 0===c?void 0:c[t])||(null===(f=null==I?void 0:I.deviation_highlights)||void 0===f?void 0:f[h[0]]),"string"==typeof x?[x]:[],b(t),b(h[0])):[],C=m?y((null===(p=null==I?void 0:I.deviation_highlights)||void 0===p?void 0:p[r])||(null===(_=null==I?void 0:I.deviation_highlights)||void 0===_?void 0:_[h[1]]),b(r),b(h[1])):[];d[n]=((a={})[h[0]]=R[0]||"",a[h[1]]=C[0]||"",a.deviation_summary=(null==I?void 0:I.deviation_summary)||"",a.deviation_title=null==I?void 0:I.deviation_title,a.deviation_impact=null==I?void 0:I.deviation_impact,a.deviation_explanation=null==I?void 0:I.deviation_explanation,a.evaluation_outputs=null==I?void 0:I.evaluation_outputs,a.cognitive_decisioning=null==I?void 0:I.cognitive_decisioning,a.deviation_highlights=null==I?void 0:I.deviation_highlights,a),s[n]=I}}),n(n({},e),{deviation_title:(null==u?void 0:u.deviation_title)||(null==e?void 0:e.deviation_title),deviation_impact:(null==u?void 0:u.deviation_impact)||(null==e?void 0:e.deviation_impact),deviation_summary:(null==u?void 0:u.deviation_summary)||(null==e?void 0:e.deviation_summary),deviation_explanation:(null==u?void 0:u.deviation_explanation)||(null==e?void 0:e.deviation_explanation),evaluation_outputs:(null==u?void 0:u.evaluation_outputs)||(null==e?void 0:e.evaluation_outputs),cognitive_decisioning:(null==u?void 0:u.cognitive_decisioning)||(null==e?void 0:e.cognitive_decisioning),deviations:d,deviation_entries:s})},E=function(n){var e=new Map,t=function(n){n.forEach(function(n){var i;n.id&&e.set(n.id,n),(null===(i=n.subsections)||void 0===i?void 0:i.length)&&t(n.subsections)})};t(n);var i=function(n,t){for(var o,r=[],a=function(n){var a=n.ref_parent_section_node_id;if(a&&e.has(a)&&a!==(null==t?void 0:t.id)){var l=e.get(a);l.subsections||(l.subsections=[]),l.subsections.some(function(e){return e.id===n.id})||l.subsections.push(n)}else(null===(o=n.subsections)||void 0===o?void 0:o.length)&&(n.subsections=i(n.subsections,n)),r.push(n)},l=0,d=n;l<d.length;l++){a(d[l])}return r},o=i(n),r=function(n){n.forEach(function(n){n.subsections&&n.subsections.length>0&&(n.subsections.sort(function(n,e){return n.selfIndex<0&&e.selfIndex>=0?1:n.selfIndex>=0&&e.selfIndex<0?-1:(n.selfIndex||0)-(e.selfIndex||0)}),r(n.subsections))})};return r(o),o},O=function(n){var e=n.comparison_inputs?Object.keys(n.comparison_inputs):[],t=h[0],i=h[1];return e.length>0&&(t=e.includes(h[0])?h[0]:e[0],i=e.includes(h[1])?h[1]:e.length>1?e[1]:e[0]),{nodeLeftId:t,nodeRightId:i}},j=function(e,t,o,r){var a=t.attributes||{},l=t.data||{},d=!1!==a.display_title,s=!1!==a.display_content,u=d?i(l.title||""):"",v=s?i(l.content||""):"",c=s?i(l.change_history||""):"",f=void 0!==a.display_index&&null!==a.display_index?Number(a.display_index):-1,p=function(n){return(null==n?void 0:n.entity_id)||(null==n?void 0:n.ref_parent_section_node_id)||(null==n?void 0:n.parent_entity_id)||null}(a),_=!(!u.trim()&&!v.trim());return n(n({id:"".concat(e,"::").concat(t.contentId),nodeId:e,contentId:t.contentId,parentContentId:p,title:u,content:v,change_history:c,displayTitle:d,displayContent:s,subsections:[]},_?r:{score:void 0,relation:"not_defined"}),{evaluationResult:o,evaluationResults:o?[o]:[],selfIndex:f,refIndexes:[],refContentIds:[],ref_parent_section_node_id:p})},N=function(n,t){n.refIndexes=Array.from(new Set(e(e([],n.refIndexes||[],!0),t.refIndexes||[],!0))),n.refContentIds=Array.from(new Set(e(e([],n.refContentIds||[],!0),t.refContentIds||[],!0)));var i=new Set((n.subsections||[]).map(function(n){return n.id||n.contentId||n.nodeId}));(t.subsections||[]).forEach(function(t){var o=t.id||t.contentId||t.nodeId;i.has(o)||(n.subsections=e(e([],n.subsections||[],!0),[t],!1),i.add(o))});var o=e(e([],n.evaluationResults||(n.evaluationResult?[n.evaluationResult]:[]),!0),t.evaluationResults||(t.evaluationResult?[t.evaluationResult]:[]),!0).filter(Boolean),r=new Set;return n.evaluationResults=o.filter(function(n){var e=(null==n?void 0:n.nodeId)||JSON.stringify(Object.keys((null==n?void 0:n.deviations)||n||{}));return!r.has(e)&&(r.add(e),!0)}),!n.evaluationResult&&t.evaluationResult&&(n.evaluationResult=t.evaluationResult),!n.cognitiveData&&t.cognitiveData&&(n.cognitiveData=t.cognitiveData),n},S=function(n,e){return n.selfIndex<0&&e.selfIndex>=0?1:n.selfIndex>=0&&e.selfIndex<0?-1:n.selfIndex-e.selfIndex},w=function(e,i){var o,l=R(e);if(!l||!1===l.display_node)return[];if(y&&"1"===i)return[];var d=O(l),s=d.nodeLeftId,u=d.nodeRightId,v=r(l),c=(null===(o=null==t?void 0:t[e])||void 0===o?void 0:o.evaluation_result)||l.evaluation_result||null,f=C(c,s,u),p=f&&"object"==typeof f?n(n({},f),{nodeId:e}):f,_=a(l,i,h,x).map(function(n){return j(e,n,p,v)});if(l.next){var I=Object.values(l.next).flatMap(function(n){return w(n,i)});_.forEach(function(n){var e=I.filter(function(e){return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId});n.subsections=e.length?e:I})}return _};if(f){var k=function(e,i){var o;void 0===i&&(i=0);var l=[],d=[];if(!e)return{refSections:l,baseSections:d};var s={},u={},v=-1,c=-1,f=function(l){var d=e[l],f=R(d);if(!f||!1===f.display_node)return"continue";var p=O(f),_=p.nodeLeftId,I=p.nodeRightId,g=r(f),m=(null===(o=null==t?void 0:t[d])||void 0===o?void 0:o.evaluation_result)||f.evaluation_result||null,b=C(m,_,I),E=b&&"object"==typeof b?n(n({},b),{nodeId:d}):b,S=k(f.next,i+1),w=S.refSections,D=S.baseSections,P=a(f,"0",h,x).map(function(n){var e=j(d,n,E,g);return-1===e.selfIndex&&(e.selfIndex=c--),e}),K=[];if(!y){var V=a(f,"1",h,x);K=V.map(function(n){var e=j(d,n,E,g);return-1===e.selfIndex&&(e.selfIndex=v--),e})}P.forEach(function(n){K.forEach(function(e){var t,i,o,r,a,l,d,s;Number(e.selfIndex)>=0&&Number(n.selfIndex)>=0&&((null===(t=e.refIndexes)||void 0===t?void 0:t.includes(Number(n.selfIndex)))||null===(i=e.refIndexes)||void 0===i||i.push(Number(n.selfIndex)),(null===(o=n.refIndexes)||void 0===o?void 0:o.includes(Number(e.selfIndex)))||null===(r=n.refIndexes)||void 0===r||r.push(Number(e.selfIndex))),n.contentId&&!(null===(a=e.refContentIds)||void 0===a?void 0:a.includes(n.contentId))&&(null===(l=e.refContentIds)||void 0===l||l.push(n.contentId)),e.contentId&&!(null===(d=n.refContentIds)||void 0===d?void 0:d.includes(e.contentId))&&(null===(s=n.refContentIds)||void 0===s||s.push(e.contentId))})}),K.forEach(function(n){var e=w.filter(function(e){var t;return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId||(null===(t=n.refContentIds)||void 0===t?void 0:t.includes(e.parentContentId))});e.length>0&&(n.subsections=e);var t=0===i?String(n.selfIndex):"".concat(n.selfIndex,"_").concat(n.contentId||d);s[t]=s[t]?N(s[t],n):n}),P.forEach(function(n){var e=D.filter(function(e){var t;return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId||(null===(t=n.refContentIds)||void 0===t?void 0:t.includes(e.parentContentId))});e.length>0&&(n.subsections=e);var t=0===i?String(n.selfIndex):"".concat(n.selfIndex,"_").concat(n.contentId||d);u[t]=u[t]?N(u[t],n):n})};for(var p in e)f(p);return l=Object.values(s),d=Object.values(u),l.sort(S),d.sort(S),{refSections:l,baseSections:d}},D=k(m.next),P=D.refSections,K=D.baseSections;y||(v=E(P)),s=K}else m.next&&Object.values(m.next).forEach(function(n){var e=R(n);if(e&&!1!==e.display_node){var t=w(n,"0");if(y)s.push.apply(s,t);else{var i=E(w(n,"1"));p.push.apply(p,u(n,t,i))}}}),y||(s=p.map(function(n){return n.left}),v=p.map(function(n){return n.right}));var V=l(m,"0",h,x),T=l(m,"1",h,x),A={title:V.title||"Uploaded Contract",description:m.decision_scope_description||"",sections:s},L={id:"tree-variant-1",title:y?function(){var n,e;if("string"!=typeof g&&(null==g?void 0:g.learnings_data)&&Object.keys(g.learnings_data).length>0){var t=Object.keys(g.learnings_data)[0];return(null===(n=g.learnings_data[t])||void 0===n?void 0:n.title)||"Rulebook Guidelines"}return"string"!=typeof g&&(null===(e=null==g?void 0:g.data)||void 0===e?void 0:e.artifactTitle)||"Rulebook Guidelines"}():T.title||"Reference Template",similarity:0,sections:v,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:m.decision_scope_description||""},fields:{}}}};return{activeProposed:A,activeVariants:[L],comparisonRows:p,parseError:null}}catch(n){return console.error("Data Transformation Error: ",n),{activeProposed:{},activeVariants:[],comparisonRows:[],parseError:n instanceof Error?n.message:"Unknown Parsing Error"}}},[c,f,b,I,g,y]),C=R.activeProposed,E=R.activeVariants,O=R.comparisonRows,j=R.parseError,N=(null==E?void 0:E[0])||v,S=t(function(){return(null==C?void 0:C.sections)||[]},[null==C?void 0:C.sections]),w=t(function(){return N.sections||[]},[N.sections]),k=S.length>0||w.length>0,D=t(function(){return _.fields.filter(function(n){var e=n.key;return(!k||"description"!==e)&&(d(null==C?void 0:C[e])||d(N[e]))})},[C,N,k,_.fields]),P=t(function(){var n,e,t={},i={},r={},a=0,l=null===(n=null==c?void 0:c.input_index_map)||void 0===n?void 0:n[0],d=null===(e=null==c?void 0:c.input_index_map)||void 0===e?void 0:e[1],u=function(n,e){if(!f){var t="left"===e?S.indexOf(n):w.indexOf(n);return{rootKey:"".concat(e,":").concat(t),parentNum:t+1}}if("left"===e){var i=n.selfIndex,o=void 0!==i&&i>=0?i+1:S.indexOf(n)+1;return{rootKey:"left-root:".concat(n.id),parentNum:o}}var r=n.selfIndex,a=S.find(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(r)});if(a){var l=a.selfIndex,d=void 0!==l&&l>=0?l+1:S.indexOf(a)+1;return{rootKey:"left-root:".concat(a.id),parentNum:d}}var s=void 0!==r&&r>=0?r+1:w.indexOf(n)+1;return{rootKey:"right-orphan-root:".concat(n.id),parentNum:s}},v=function(n,e){if(n&&e)return n.find(function(n){return n.id===e.id||n.nodeId&&n.nodeId===e.nodeId||n.contentId&&n.contentId===e.contentId})||void 0},p=function(n,e,u,c,f,_,I){if(e&&function(n,e,t){var a;((null===(a=null==n?void 0:n.evaluationResults)||void 0===a?void 0:a.length)?n.evaluationResults:(null==n?void 0:n.evaluationResult)?[n.evaluationResult]:[]).forEach(function(a){var u=(null==a?void 0:a.deviations)||{};Object.keys(u).sort().forEach(function(v){var c=u[v];if(c){var f=!o(c[l]),p=!o(c[d]);if(f||p){var _=(null==a?void 0:a.nodeId)||n.nodeId||n.id,I="".concat(_).concat(s).concat(v);void 0===i[I]&&(void 0===r[e]&&(r[e]=1),i[I]={index:r[e]++,rootKey:e,parentNum:t})}}})})}(e,c,f),e&&!_){var g=(null==I?void 0:I.id)||"fallback_parent_".concat(a++);t[g]||(t[g]=[]),t[g].push(e)}((null==e?void 0:e.subsections)||(null==n?void 0:n.subsections)||(null==u?void 0:u.subsections)||[]).forEach(function(t){var i=v(null==n?void 0:n.subsections,t),o=v(null==u?void 0:u.subsections,t);p(t,i,o,c,f,!1,e||I)})};S.forEach(function(n){var e,t=u(n,"left"),i=t.rootKey,o=t.parentNum,r=null;if(f){var a=null===(e=n.refIndexes)||void 0===e?void 0:e[0];r=w.find(function(n){return n.selfIndex===a})}else r=w[S.indexOf(n)];p(n,n,r,i,o,!0,n)}),y||w.forEach(function(n){var e=u(n,"right"),t=e.rootKey,i=e.parentNum;t.startsWith("right-orphan-root:")&&p(n,null,n,t,i,!0,n)});var _=Object.fromEntries(Object.entries(i).map(function(n){return[n[0],n[1].index]})),I=Object.fromEntries(Object.entries(i).map(function(n){return[n[0],n[1].parentNum]}));return{parentDeviationRecord:t,registry:_,deviationParentRegistry:I}},[S,w,f,c,y]),K=P.parentDeviationRecord,V=P.registry,T=P.deviationParentRegistry;return{isGuidelineMode:y,activeProposed:C,activeVariants:E,comparisonRows:O,existingRule:N,proposedSections:S,existingSections:w,visibleFields:D,parentDeviationRecord:K,deviationNumberRegistry:V,deviationParentRegistry:T,parseError:j}};export{c as useCognitiveTreeData};
1
+ import{__assign as n,__spreadArray as e}from"tslib";import{useMemo as t}from"react";import{isMissingStr as i,safeStringify as o,getRationale as r,resolveComparisonInputItems as a,getSideData as l,hasValue as d,DEVIATION_BADGE_SEPARATOR as s}from"../CognitiveComparehelpers.js";import{buildComparisonRows as u}from"../utils/buildComparisonRows.js";var v={id:"",title:"",similarity:0,sections:[]},c=function(c,f,p,I,_,h){var g,m;void 0===_&&(_=!0);var x="string"==typeof p?p:JSON.stringify(p||{}),b=Boolean(h&&(h.learnings_data||(null===(m=null===(g=h.data)||void 0===g?void 0:g.artifactData)||void 0===m?void 0:m.userStorySnapshot))),y=t(function(){if(!c||0===Object.keys(c).length)return{activeProposed:{},activeVariants:[],comparisonRows:[],parseError:"Tree data is required"};var t=JSON.parse(x);try{var d=c.nodes||c,s=[],v=[],p=[],I=c.base_root_id,g=c.input_index_map||{0:"left",1:"right"},m=c[I]||d[I];if(!m||!1===m.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[],comparisonRows:[],parseError:null};var y=c.content_mapping||{},R=function(n){return c[n]||d[n]},C=function(e,t,o){if(!e||"object"!=typeof e)return e||null;if(e.deviations)return e;if(_)return e;var r=Object.keys(e).filter(function(n){return/^\d+$/.test(n)});if(!r.length)return e;var a=r.sort(function(n,e){return Number(n)-Number(e)}),l={},d={},s=null;return a.forEach(function(n){var r,a,u,v,c,f,p=e[n];if(p&&"object"==typeof p){s||(s=p);var I=!(null==p?void 0:p.status)||"pending"===p.status,_=(null==p?void 0:p.deviation_highlight)||(null===(a=null==p?void 0:p.web_search_answer)||void 0===a?void 0:a.deviation_highlight),h=function(n){var e,t=(null===(e=null==p?void 0:p.cognitive_decisioning)||void 0===e?void 0:e.citations)||(null==p?void 0:p.citations)||{};return Object.values(t).map(function(e){var t;return null===(t=null==e?void 0:e[n])||void 0===t?void 0:t.highlighted_text}).filter(function(n){return"string"==typeof n&&n.trim().length>0})},m=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];for(var t=0,o=n;t<o.length;t++){var r=o[t];if(Array.isArray(r)&&r.some(function(n){return!i(n)}))return r}return[]},x=I?m((null===(u=null==p?void 0:p.deviation_highlights)||void 0===u?void 0:u[t])||(null===(v=null==p?void 0:p.deviation_highlights)||void 0===v?void 0:v[g[0]]),"string"==typeof _?[_]:[],h(t),h(g[0])):[],b=I?m((null===(c=null==p?void 0:p.deviation_highlights)||void 0===c?void 0:c[o])||(null===(f=null==p?void 0:p.deviation_highlights)||void 0===f?void 0:f[g[1]]),h(o),h(g[1])):[];l[n]=((r={})[g[0]]=x[0]||"",r[g[1]]=b[0]||"",r.deviation_summary=(null==p?void 0:p.deviation_summary)||"",r.deviation_title=null==p?void 0:p.deviation_title,r.deviation_impact=null==p?void 0:p.deviation_impact,r.deviation_explanation=null==p?void 0:p.deviation_explanation,r.evaluation_outputs=null==p?void 0:p.evaluation_outputs,r.cognitive_decisioning=null==p?void 0:p.cognitive_decisioning,r.deviation_highlights=null==p?void 0:p.deviation_highlights,r),d[n]=p}}),n(n({},e),{deviation_title:(null==s?void 0:s.deviation_title)||(null==e?void 0:e.deviation_title),deviation_impact:(null==s?void 0:s.deviation_impact)||(null==e?void 0:e.deviation_impact),deviation_summary:(null==s?void 0:s.deviation_summary)||(null==e?void 0:e.deviation_summary),deviation_explanation:(null==s?void 0:s.deviation_explanation)||(null==e?void 0:e.deviation_explanation),evaluation_outputs:(null==s?void 0:s.evaluation_outputs)||(null==e?void 0:e.evaluation_outputs),cognitive_decisioning:(null==s?void 0:s.cognitive_decisioning)||(null==e?void 0:e.cognitive_decisioning),deviations:l,deviation_entries:d})},E=function(n){var e=new Map,t=function(n){n.forEach(function(n){var i;n.id&&e.set(n.id,n),(null===(i=n.subsections)||void 0===i?void 0:i.length)&&t(n.subsections)})};t(n);var i=function(n,t){for(var o,r=[],a=function(n){var a=n.ref_parent_section_node_id;if(a&&e.has(a)&&a!==(null==t?void 0:t.id)){var l=e.get(a);l.subsections||(l.subsections=[]),l.subsections.some(function(e){return e.id===n.id})||l.subsections.push(n)}else(null===(o=n.subsections)||void 0===o?void 0:o.length)&&(n.subsections=i(n.subsections,n)),r.push(n)},l=0,d=n;l<d.length;l++){a(d[l])}return r},o=i(n),r=function(n){n.forEach(function(n){n.subsections&&n.subsections.length>0&&(n.subsections.sort(function(n,e){return n.selfIndex<0&&e.selfIndex>=0?1:n.selfIndex>=0&&e.selfIndex<0?-1:(n.selfIndex||0)-(e.selfIndex||0)}),r(n.subsections))})};return r(o),o},O=function(n){var e=n.comparison_inputs?Object.keys(n.comparison_inputs):[],t=g[0],i=g[1];return e.length>0&&(t=e.includes(g[0])?g[0]:e[0],i=e.includes(g[1])?g[1]:e.length>1?e[1]:e[0]),{nodeLeftId:t,nodeRightId:i}},j=function(e,t,i,r){var a=t.attributes||{},l=t.data||{},d=!1!==a.display_title,s=!1!==a.display_content,u=d?o(l.title||""):"",v=s?o(l.content||""):"",c=s?o(l.change_history||""):"",f=void 0!==a.display_index&&null!==a.display_index?Number(a.display_index):-1,p=function(n){return(null==n?void 0:n.entity_id)||(null==n?void 0:n.ref_parent_section_node_id)||(null==n?void 0:n.parent_entity_id)||null}(a),I=!(!u.trim()&&!v.trim());return n(n({id:"".concat(e,"::").concat(t.contentId),nodeId:e,contentId:t.contentId,parentContentId:p,title:u,content:v,change_history:c,displayTitle:d,displayContent:s,subsections:[]},I?r:{score:void 0,relation:"not_defined"}),{evaluationResult:i,evaluationResults:i?[i]:[],selfIndex:f,refIndexes:[],refContentIds:[],ref_parent_section_node_id:p})},N=function(n,t){n.refIndexes=Array.from(new Set(e(e([],n.refIndexes||[],!0),t.refIndexes||[],!0))),n.refContentIds=Array.from(new Set(e(e([],n.refContentIds||[],!0),t.refContentIds||[],!0)));var i=new Set((n.subsections||[]).map(function(n){return n.id||n.contentId||n.nodeId}));(t.subsections||[]).forEach(function(t){var o=t.id||t.contentId||t.nodeId;i.has(o)||(n.subsections=e(e([],n.subsections||[],!0),[t],!1),i.add(o))});var o=e(e([],n.evaluationResults||(n.evaluationResult?[n.evaluationResult]:[]),!0),t.evaluationResults||(t.evaluationResult?[t.evaluationResult]:[]),!0).filter(Boolean),r=new Set;return n.evaluationResults=o.filter(function(n){var e=(null==n?void 0:n.nodeId)||JSON.stringify(Object.keys((null==n?void 0:n.deviations)||n||{}));return!r.has(e)&&(r.add(e),!0)}),!n.evaluationResult&&t.evaluationResult&&(n.evaluationResult=t.evaluationResult),!n.cognitiveData&&t.cognitiveData&&(n.cognitiveData=t.cognitiveData),n},S=function(n,e){return n.selfIndex<0&&e.selfIndex>=0?1:n.selfIndex>=0&&e.selfIndex<0?-1:n.selfIndex-e.selfIndex},w=function(e,i){var o,l=R(e);if(!l||!1===l.display_node)return[];if(b&&"1"===i)return[];var d=O(l),s=d.nodeLeftId,u=d.nodeRightId,v=r(l),c=(null===(o=null==t?void 0:t[e])||void 0===o?void 0:o.evaluation_result)||l.evaluation_result||null,f=C(c,s,u),p=f&&"object"==typeof f?n(n({},f),{nodeId:e}):f,I=a(l,i,g,y).map(function(n){return j(e,n,p,v)});if(l.next){var _=Object.values(l.next).flatMap(function(n){return w(n,i)});I.forEach(function(n){var e=_.filter(function(e){return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId});n.subsections=e.length?e:_})}return I};if(f){var k=function(e,i){var o;void 0===i&&(i=0);var l=[],d=[];if(!e)return{refSections:l,baseSections:d};var s={},u={},v=-1,c=-1,f=function(l){var d=e[l],f=R(d);if(!f||!1===f.display_node)return"continue";var p=O(f),I=p.nodeLeftId,_=p.nodeRightId,h=r(f),m=(null===(o=null==t?void 0:t[d])||void 0===o?void 0:o.evaluation_result)||f.evaluation_result||null,x=C(m,I,_),E=x&&"object"==typeof x?n(n({},x),{nodeId:d}):x,S=k(f.next,i+1),w=S.refSections,D=S.baseSections,P=a(f,"0",g,y).map(function(n){var e=j(d,n,E,h);return-1===e.selfIndex&&(e.selfIndex=c--),e}),K=[];if(!b){var V=a(f,"1",g,y);K=V.map(function(n){var e=j(d,n,E,h);return-1===e.selfIndex&&(e.selfIndex=v--),e})}P.forEach(function(n){K.forEach(function(e){var t,i,o,r,a,l,d,s;Number(e.selfIndex)>=0&&Number(n.selfIndex)>=0&&((null===(t=e.refIndexes)||void 0===t?void 0:t.includes(Number(n.selfIndex)))||null===(i=e.refIndexes)||void 0===i||i.push(Number(n.selfIndex)),(null===(o=n.refIndexes)||void 0===o?void 0:o.includes(Number(e.selfIndex)))||null===(r=n.refIndexes)||void 0===r||r.push(Number(e.selfIndex))),n.contentId&&!(null===(a=e.refContentIds)||void 0===a?void 0:a.includes(n.contentId))&&(null===(l=e.refContentIds)||void 0===l||l.push(n.contentId)),e.contentId&&!(null===(d=n.refContentIds)||void 0===d?void 0:d.includes(e.contentId))&&(null===(s=n.refContentIds)||void 0===s||s.push(e.contentId))})}),K.forEach(function(n){var e=w.filter(function(e){var t;return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId||(null===(t=n.refContentIds)||void 0===t?void 0:t.includes(e.parentContentId))});e.length>0&&(n.subsections=e);var t=0===i?String(n.selfIndex):"".concat(n.selfIndex,"_").concat(n.contentId||d);s[t]=s[t]?N(s[t],n):n}),P.forEach(function(n){var e=D.filter(function(e){var t;return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId||(null===(t=n.refContentIds)||void 0===t?void 0:t.includes(e.parentContentId))});e.length>0&&(n.subsections=e);var t=0===i?String(n.selfIndex):"".concat(n.selfIndex,"_").concat(n.contentId||d);u[t]=u[t]?N(u[t],n):n})};for(var p in e)f(p);return l=Object.values(s),d=Object.values(u),l.sort(S),d.sort(S),{refSections:l,baseSections:d}},D=k(m.next),P=D.refSections,K=D.baseSections;b||(v=E(P)),s=K}else m.next&&Object.values(m.next).forEach(function(n){var e=R(n);if(e&&!1!==e.display_node){var t=w(n,"0");if(b)s.push.apply(s,t);else{var i=E(w(n,"1"));p.push.apply(p,u(n,t,i))}}}),b||(s=p.map(function(n){return n.left}),v=p.map(function(n){return n.right}));var V=l(m,"0",g,y),T=l(m,"1",g,y),A={title:V.title||"Uploaded Contract",description:m.decision_scope_description||"",sections:s},G={id:"tree-variant-1",title:b?function(){var n,e;if((null==h?void 0:h.learnings_data)&&Object.keys(h.learnings_data).length>0){var t=Object.keys(h.learnings_data)[0];return(null===(n=h.learnings_data[t])||void 0===n?void 0:n.title)||"Rulebook Guidelines"}return(null===(e=null==h?void 0:h.data)||void 0===e?void 0:e.artifactTitle)||"Rulebook Guidelines"}():T.title||"Reference Template",similarity:0,sections:v,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:m.decision_scope_description||""},fields:{}}}};return{activeProposed:A,activeVariants:[G],comparisonRows:p,parseError:null}}catch(n){return console.error("Data Transformation Error: ",n),{activeProposed:{},activeVariants:[],comparisonRows:[],parseError:n instanceof Error?n.message:"Unknown Parsing Error"}}},[c,f,x,_,h]),R=y.activeProposed,C=y.activeVariants,E=y.comparisonRows,O=y.parseError,j=(null==C?void 0:C[0])||v,N=t(function(){return(null==R?void 0:R.sections)||[]},[null==R?void 0:R.sections]),S=t(function(){return j.sections||[]},[j.sections]),w=N.length>0||S.length>0,k=t(function(){return I.fields.filter(function(n){var e=n.key;return(!w||"description"!==e)&&(d(null==R?void 0:R[e])||d(j[e]))})},[R,j,w,I.fields]),D=t(function(){var n,e,t={},o={},r={},a=0,l=null===(n=null==c?void 0:c.input_index_map)||void 0===n?void 0:n[0],d=null===(e=null==c?void 0:c.input_index_map)||void 0===e?void 0:e[1],u=function(n,e){if(!f){var t="left"===e?N.indexOf(n):S.indexOf(n);return{rootKey:"".concat(e,":").concat(t),parentNum:t+1}}if("left"===e){var i=n.selfIndex,o=void 0!==i&&i>=0?i+1:N.indexOf(n)+1;return{rootKey:"left-root:".concat(n.id),parentNum:o}}var r=n.selfIndex,a=N.find(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(r)});if(a){var l=a.selfIndex,d=void 0!==l&&l>=0?l+1:N.indexOf(a)+1;return{rootKey:"left-root:".concat(a.id),parentNum:d}}var s=void 0!==r&&r>=0?r+1:S.indexOf(n)+1;return{rootKey:"right-orphan-root:".concat(n.id),parentNum:s}},v=function(n,e){if(n&&e)return n.find(function(n){return n.id===e.id||n.nodeId&&n.nodeId===e.nodeId||n.contentId&&n.contentId===e.contentId})||void 0},p=function(n,e,u,c,f,I,_){if(e&&function(n,e,t){var a;((null===(a=null==n?void 0:n.evaluationResults)||void 0===a?void 0:a.length)?n.evaluationResults:(null==n?void 0:n.evaluationResult)?[n.evaluationResult]:[]).forEach(function(a){var u=(null==a?void 0:a.deviations)||{};Object.keys(u).sort().forEach(function(v){var c=u[v];if(c){var f=!i(c[l]),p=!i(c[d]);if(f||p){var I=(null==a?void 0:a.nodeId)||n.nodeId||n.id,_="".concat(I).concat(s).concat(v);void 0===o[_]&&(void 0===r[e]&&(r[e]=1),o[_]={index:r[e]++,rootKey:e,parentNum:t})}}})})}(e,c,f),e&&!I){var h=(null==_?void 0:_.id)||"fallback_parent_".concat(a++);t[h]||(t[h]=[]),t[h].push(e)}((null==e?void 0:e.subsections)||(null==n?void 0:n.subsections)||(null==u?void 0:u.subsections)||[]).forEach(function(t){var i=v(null==n?void 0:n.subsections,t),o=v(null==u?void 0:u.subsections,t);p(t,i,o,c,f,!1,e||_)})};N.forEach(function(n){var e,t=u(n,"left"),i=t.rootKey,o=t.parentNum,r=null;if(f){var a=null===(e=n.refIndexes)||void 0===e?void 0:e[0];r=S.find(function(n){return n.selfIndex===a})}else r=S[N.indexOf(n)];p(n,n,r,i,o,!0,n)}),b||S.forEach(function(n){var e=u(n,"right"),t=e.rootKey,i=e.parentNum;t.startsWith("right-orphan-root:")&&p(n,null,n,t,i,!0,n)});var I=Object.fromEntries(Object.entries(o).map(function(n){return[n[0],n[1].index]})),_=Object.fromEntries(Object.entries(o).map(function(n){return[n[0],n[1].parentNum]}));return{parentDeviationRecord:t,registry:I,deviationParentRegistry:_}},[N,S,f,c,b]),P=D.parentDeviationRecord,K=D.registry,V=D.deviationParentRegistry;return{isGuidelineMode:b,activeProposed:R,activeVariants:C,comparisonRows:E,existingRule:j,proposedSections:N,existingSections:S,visibleFields:k,parentDeviationRecord:P,deviationNumberRegistry:K,deviationParentRegistry:V,parseError:O}};export{c as useCognitiveTreeData};
2
2
  //# sourceMappingURL=useCompareData.js.map
@@ -1,2 +1,2 @@
1
- import{useState as t,useRef as e,useCallback as n,useEffect as i}from"react";import{DEVIATION_BADGE_SEPARATOR as r}from"../CognitiveComparehelpers.js";import{getVisibleGuidelineTargets as c}from"../Guidelines/utils/guidelineTargets.js";var o=function(o){var l=o.containerRef,u=o.leftContainerRef,a=o.rightContainerRef;o.svgContainerRef;var d=o.pathRefs,s=o.leftHeaderRef,v=o.rightHeaderRef,h=o.proposedSections,g=o.existingSections,f=o.visibleFields,p=o.leftRefs,b=o.rightRefs,y=o.sectionLeftRefs,x=o.sectionRightRefs,m=o.subSectionLeftRefs,R=o.subSectionRightRefs,C=o.lhsBadgeRefs,B=o.rhsBadgeRefs,A=o.sectionRowRefs,S=o.expandedSections,M=o.expandedSubSections,T=o.connectedSections,I=o.isSideBySide,L=o.activeSideBySideSection,F=o.maintainRelativeOrder,H=o.isGuidelineMode,w=o.cognitiveMap,k=o.getSectionCompareStyle,E=o.getSubSectionCompareStyle,N=o.getDeviationStyleByKey,Y=o.isArrowVisible,D=o.isAnimatingRef,j=o.isSideBySideRef,O=o.sideBySideCacheRef,z=o.sideBySideLineRef,P=o.activeSideBySideSectionRef,Q=o.activeSideBySideRightSectionRef,X=o.connectedLines,G=o.setConnectedLines,q=o.cachedConnectedPositions,K=o.calculateLinesRef,V=o.resizeTimerRef,J=o.scrollLock,U=o.scrollSyncLocked,W=o.handleResizeRef,Z=o.activeProposed,$=o.existingRule,_=o.analysisData,tt=o.pendingScrollTargetRef,et=o.pendingScrollCallbackRef,nt=o.resolvedComparisonConfig,it=o.getFieldData,rt=t([]),ct=rt[0],ot=rt[1],lt=t(null),ut=lt[0],at=lt[1],dt=t([]),st=dt[0],vt=dt[1],ht=null!=X?X:st,gt=null!=G?G:vt,ft=t({width:0,height:0}),pt=ft[0],bt=ft[1],yt=e(!1),xt=e(!1),mt=e(!1),Rt=e(null),Ct=e([]),Bt=null!=q?q:Ct,At=function(t,e,n,i,r,c,o){if(Math.abs(i-e)<=1)return c&&o?"M ".concat(t,",").concat(e," L ").concat(n,",").concat(i):c&&!o?"M ".concat(t,",").concat(e," L ").concat(r,",").concat(e):!c&&o?"M ".concat(r,",").concat(e," L ").concat(n,",").concat(i):"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i);var l=Math.min(15,Math.abs(r-t),Math.abs(i-e)/2),u=Math.min(15,Math.abs(n-r),Math.abs(i-e)/2),a=i>e?l:-l,d=i>e?u:-u,s=n>r?u:-u;return c&&o?"M ".concat(t,",").concat(e," L ").concat(r-l,",").concat(e," Q ").concat(r,",").concat(e," ").concat(r,",").concat(e+a," L ").concat(r,",").concat(i-d," Q ").concat(r,",").concat(i," ").concat(r+s,",").concat(i," L ").concat(n,",").concat(i):c&&!o?"M ".concat(t,",").concat(e," L ").concat(r-l,",").concat(e," Q ").concat(r,",").concat(e," ").concat(r,",").concat(e+a," L ").concat(r,",").concat(i):!c&&o?"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i-d," Q ").concat(r,",").concat(i," ").concat(r+s,",").concat(i," L ").concat(n,",").concat(i):"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i)},St=n(function(){var t,e,n,i,o,d,A,Y,j,O,z,P,Q,X,G,q,K,V;if(!yt.current&&!D.current){yt.current=!0;try{if(!l.current)return;var J=function(t){var e=t.split("-"),n=e[0];if(!S[n]&&!1===F)return!1;if(F&&!S["left-".concat(n)]&&!S["right-".concat(n)]&&!S[n])return!1;for(var i=n,r=1;r<e.length-1;r++)if(i+="-".concat(e[r]),!M[i])return!1;return!0},U=l.current.getBoundingClientRect();bt({width:U.width,height:U.height});var W=[];if(f.forEach(function(t){var e,n,i=t.key,r=null===(e=p.current[i])||void 0===e?void 0:e.current,c=null===(n=b.current[i])||void 0===n?void 0:n.current;r&&c&&(r.style.height="auto",c.style.height="auto",r.style.minHeight="0px",c.style.minHeight="0px")}),!D.current){for(var Z=0;Z<Math.max(h.length,g.length);Z++){var $=null===(t=y.current[Z])||void 0===t?void 0:t.current,_=null===(e=x.current[Z])||void 0===e?void 0:e.current;$&&($.style.height="auto",$.style.minHeight="0px"),_&&(_.style.height="auto",_.style.minHeight="0px")}F||Object.keys(m.current).forEach(function(t){var e,n;if(J(t)){var i=null===(e=m.current[t])||void 0===e?void 0:e.current,r=null===(n=R.current[t])||void 0===n?void 0:n.current;i&&r&&(i.style.height="auto",r.style.height="auto",i.style.minHeight="0px",r.style.minHeight="0px")}})}var tt={};f.forEach(function(t){var e,n,i=t.key,r=null===(e=p.current[i])||void 0===e?void 0:e.current,c=null===(n=b.current[i])||void 0===n?void 0:n.current;if(r&&c){var o=r.getBoundingClientRect(),l=c.getBoundingClientRect();tt[i]=Math.max(o.height,l.height)}});var et={left:{},right:{}},nt={};if(!D.current)if(F){if(I&&null!==L)if("number"==typeof L){var it=L,rt=h[it],ct=null===(o=y.current[it])||void 0===o?void 0:o.current;ct&&rt&&(rt.refIndexes||[]).forEach(function(t){var e,n=g.findIndex(function(e){return e.selfIndex===t}),i=null===(e=x.current[n])||void 0===e?void 0:e.current;if(i&&(S["left-".concat(it)]||S["right-".concat(n)])){var r=Math.max(ct.getBoundingClientRect().height,i.getBoundingClientRect().height);et.left[it]=Math.max(et.left[it]||0,r),et.right[n]=Math.max(et.right[n]||0,r)}})}else{var lt=L.split(r)[2];if(lt){$=null===(d=m.current[lt])||void 0===d?void 0:d.current,_=null===(A=R.current[lt])||void 0===A?void 0:A.current;if($&&_){ut=Math.max($.getBoundingClientRect().height,_.getBoundingClientRect().height);nt[lt]=Math.max(nt[lt]||0,ut)}}}}else{Object.keys(m.current).forEach(function(t){var e,n;if(J(t)){var i=null===(e=m.current[t])||void 0===e?void 0:e.current,r=null===(n=R.current[t])||void 0===n?void 0:n.current;if(i&&r&&null!==i.offsetParent&&null!==r.offsetParent){var c=i.getBoundingClientRect(),o=r.getBoundingClientRect(),l=Math.max(c.height,o.height);nt[t]=l,i.style.minHeight="".concat(l,"px"),r.style.minHeight="".concat(l,"px")}}});for(Z=0;Z<Math.min(h.length,g.length);Z++){var $=null===(n=y.current[Z])||void 0===n?void 0:n.current,_=null===(i=x.current[Z])||void 0===i?void 0:i.current;if($&&_){var ut=Math.max($.getBoundingClientRect().height,_.getBoundingClientRect().height);et.left[Z]=ut,et.right[Z]=ut}}}if(f.forEach(function(t){var e,n,i=t.key,r=null===(e=p.current[i])||void 0===e?void 0:e.current,c=null===(n=b.current[i])||void 0===n?void 0:n.current;if(r&&c){var o=tt[i];r.style.minHeight="".concat(o,"px"),c.style.minHeight="".concat(o,"px")}}),D.current||(Object.entries(et.left).forEach(function(t){var e,n=t[0],i=t[1],r=null===(e=y.current[Number(n)])||void 0===e?void 0:e.current;r&&(r.style.minHeight="".concat(i,"px"))}),Object.entries(et.right).forEach(function(t){var e,n=t[0],i=t[1],r=null===(e=x.current[Number(n)])||void 0===e?void 0:e.current;r&&(r.style.minHeight="".concat(i,"px"))}),F||Object.keys(nt).forEach(function(t){var e,n,i=null===(e=m.current[t])||void 0===e?void 0:e.current,r=null===(n=R.current[t])||void 0===n?void 0:n.current;if(i&&r&&nt[t]){var c=nt[t];i.style.minHeight="".concat(c,"px"),r.style.minHeight="".concat(c,"px")}})),!H){h.forEach(function(t,e){var n,i=t.continuationSourceRowId?h.findIndex(function(e){return e.comparisonRowId===t.continuationSourceRowId}):-1,r=i>=0?i:e,c=null===(n=y.current[r])||void 0===n?void 0:n.current;if(c){var o=function(t,e){if(!F)return g[e]?[e]:[];var n=(t.refIndexes||[]).map(function(t){return g.findIndex(function(e){return e.selfIndex===t})}).filter(function(t){return-1!==t});return!n.length&&g[e]?[e]:Array.from(new Set(n))}(t,e);o.forEach(function(t){var n,o,l,d,s,v,f,p,b,y,m,R,C=null===(n=x.current[t])||void 0===n?void 0:n.current;if(C){var B=c.getBoundingClientRect(),A=C.getBoundingClientRect(),S=B.right-U.left,M=A.left-U.left,T=B.top+18-U.top,H=A.top+18-U.top;if(F&&I&&L===e){var E=null!==(l=null===(o=u.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==l?l:0,N=null!==(s=null===(d=a.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==s?s:0,Y=E+(null!==(f=null===(v=u.current)||void 0===v?void 0:v.clientHeight)&&void 0!==f?f:1/0),D=N+(null!==(b=null===(p=a.current)||void 0===p?void 0:p.clientHeight)&&void 0!==b?b:1/0),j=function(t,e,n){return Math.max(e,Math.min(n,t))};T=j(B.top+18,E,Y)-U.top,H=j(A.top+18,N,D)-U.top}var O=k(r);O&&W.push({id:"line-".concat(r,"-").concat(t),x1:S,y1:T,x2:M,y2:H,style:O,sectionIdx:r,targetRightIdx:t,isSubSection:!1,isMappingContinuation:i>=0,hasCognitive:!!((null===(y=h[r])||void 0===y?void 0:y.cognitiveData)||(null===(m=g[t])||void 0===m?void 0:m.cognitiveData)||(null===(R=h[r])||void 0===R?void 0:R.nodeId)&&w[h[r].nodeId])})}})}})}if(!H&&I&&"string"==typeof L&&L.includes(r)){var dt=L.split(r),st=dt[0],vt=dt[1],ht=dt[2],ft=(dt[3],"".concat(st).concat(r).concat(vt)),pt=null===(Y=C.current[ft])||void 0===Y?void 0:Y.current,xt=null===(j=B.current[ft])||void 0===j?void 0:j.current;if(pt&&xt){var mt=pt.getBoundingClientRect(),Rt=xt.getBoundingClientRect(),Ct=mt.right-U.left,St=Rt.left-U.left,Tt=mt.top+mt.height/2-U.top,It=Rt.top+Rt.height/2-U.top;if(F){var Lt=null!==(z=null===(O=u.current)||void 0===O?void 0:O.getBoundingClientRect().top)&&void 0!==z?z:0,Ft=null!==(Q=null===(P=a.current)||void 0===P?void 0:P.getBoundingClientRect().top)&&void 0!==Q?Q:0,Ht=Lt+(null!==(G=null===(X=u.current)||void 0===X?void 0:X.clientHeight)&&void 0!==G?G:1/0),wt=Ft+(null!==(K=null===(q=a.current)||void 0===q?void 0:q.clientHeight)&&void 0!==K?K:1/0),kt=function(t,e,n){return Math.max(e,Math.min(n,t))};Tt=kt(mt.top+mt.height/2,Lt,Ht)-U.top,It=kt(Rt.top+Rt.height/2,Ft,wt)-U.top}var Et=null!==(V=N(st,vt))&&void 0!==V?V:E(ht);Et&&W.push({id:"line-subsec-".concat(ft),x1:Ct,y1:Tt,x2:St,y2:It,style:Et,sectionIdx:Number(ht.split("-")[0]),isSubSection:!0,subSectionKeyPath:L})}}if(ot(W),s.current&&v.current){var Nt=s.current.getBoundingClientRect(),Yt=v.current.getBoundingClientRect(),Dt=(Nt.top+Nt.height/2-U.top+Yt.top+Yt.height/2-U.top)/2;at({x1:Nt.right-U.left,x2:Yt.left-U.left,y:Dt})}else at(null);if(T.size>0){var jt=[],Ot=u.current,zt=a.current;if(Ot&&zt){var Pt=[],Qt=Ot.getBoundingClientRect().top,Xt=zt.getBoundingClientRect().top,Gt=Qt+Ot.clientHeight,qt=Xt+zt.clientHeight,Kt=Ot.scrollTop,Vt=zt.scrollTop,Jt=U.top,Ut=function(t,e,n){return Math.max(e,Math.min(n,t))};T.forEach(function(t){var e,n,i,o,l,u,a,d,s;if(H){var v=null,f=null,p=null;if("string"==typeof t&&t.includes(r)){var b=t.split(r),y=b[0],x=b[1],m=b[2],R="".concat(y).concat(r).concat(x);v=null===(e=C.current[R])||void 0===e?void 0:e.current,p=null!==(n=N(y,x))&&void 0!==n?n:E(m),f=Number((null==m?void 0:m.split("-")[0])||0)}else f=Number(t),v=null===(i=C.current[f])||void 0===i?void 0:i.current,p=k(f);if(!v)return;var A=c(zt);A.forEach(function(e,n){var i=v.getBoundingClientRect(),c=e.getBoundingClientRect(),o=i.right-U.left,l=c.left-U.left-0,u=o+75,a=i.top+i.height/2,d=c.top+c.height/2,s=a-Qt+Kt,h=d-Xt+Vt,g="conn-guide-".concat(t,"-").concat(n),f="";"string"==typeof t&&t.includes(r)?f=(t.split(r)[2]||"").split("-").map(function(t){return Number(t)+1}).join("."):f=String(Number(t)+1);var b=String.fromCharCode(97+n),y=1===A.length?null:"".concat(f,"(").concat(b,")");Pt.push({lhsScrollY:s,rhsScrollY:h,x1:o,x2:l,containerTop:Jt,leftIdx:t,rhsArrayIdx:n,styleColor:(null==p?void 0:p.badgeBorder)||"#6366F1",styleBg:(null==p?void 0:p.badgeBg)||"#FFFFFF",styleText:(null==p?void 0:p.badgeText)||"#A16207",styleId:g,centerX:u});var x=Ut(a,Qt,Gt),m=Ut(d,Xt,qt),R=x-Jt,C=m-Jt,B=At(o,R,l,C,u,a>=Qt-4&&a<=Gt+4,d>=Xt-4&&d<=qt+4);jt.push({id:g,pathD:B,style:p,leftIdx:t,rhsArrayIdx:n,x1:o,x2:l,y1:R,y2:C,centerX:u,matchLabel:y,isGuideline:!0})})}else if("string"==typeof t&&t.includes(r)){var S=t.split(r),M=(y=S[0],x=S[1],m=S[2],S[3],R="".concat(y).concat(r).concat(x),null===(o=C.current[R])||void 0===o?void 0:o.current),T=null===(l=B.current[R])||void 0===l?void 0:l.current;if(!M||!T)return;var I=M.getBoundingClientRect(),L=T.getBoundingClientRect(),w=null!==(u=N(y,x))&&void 0!==u?u:E(m),Y=I.right-U.left,D=L.left-U.left-0,j=Y+75,O=I.top+I.height/2,z=L.top+L.height/2,P=O-Qt+Kt,Q=z-Xt+Vt,X="conn-subsec-".concat(R),G=((m||"").split("-").map(function(t){return Number(t)+1}).join("."),null);Pt.push({lhsScrollY:P,rhsScrollY:Q,x1:Y,x2:D,containerTop:Jt,leftIdx:t,rhsArrayIdx:t,styleColor:(null==w?void 0:w.badgeBorder)||"#6366F1",styleBg:(null==w?void 0:w.badgeBg)||"#FFFFFF",styleText:(null==w?void 0:w.badgeText)||"#A16207",styleId:X,centerX:j});var q=Ut(O,Qt,Gt),K=Ut(z,Xt,qt),V=At(Y,_=q-Jt,D,tt=K-Jt,j,O>=Qt-4&&O<=Gt+4,z>=Xt-4&&z<=qt+4);jt.push({id:X,pathD:V,style:w,leftIdx:t,rhsArrayIdx:t,x1:Y,x2:D,y1:_,y2:tt,matchLabel:G})}else if(F){var J=t,W=h[J];if(!(null===(s=null==W?void 0:W.refIndexes)||void 0===s?void 0:s.length))return;W.refIndexes.forEach(function(e,n){var i,r,c=g.findIndex(function(t){return t.selfIndex===e});if(-1!==c){var o=null===(i=C.current[J])||void 0===i?void 0:i.current,l=null===(r=B.current[c])||void 0===r?void 0:r.current;if(o&&l){var u=o.getBoundingClientRect(),a=l.getBoundingClientRect(),d=k(J),s=u.right-U.left,v=a.left-U.left-0,h=s+75,f=u.top+u.height/2,p=a.top+a.height/2,b=f-Qt+Kt,y=p-Xt+Vt,x="conn-".concat(J,"-").concat(c),m=String(Number(t)+1),R=String.fromCharCode(97+n),A=1===W.refIndexes.length?null:"".concat(m,"(").concat(R,")");Pt.push({lhsScrollY:b,rhsScrollY:y,x1:s,x2:v,containerTop:Jt,leftIdx:J,rhsArrayIdx:c,styleColor:(null==d?void 0:d.badgeBorder)||"#6366F1",styleBg:(null==d?void 0:d.badgeBg)||"#FFFFFF",styleText:(null==d?void 0:d.badgeText)||"#A16207",styleId:x,centerX:h});var S=Ut(f,Qt,Gt),M=Ut(p,Xt,qt),T=S-Jt,I=M-Jt,L=At(s,T,v,I,h,f>=Qt-4&&f<=Gt+4,p>=Xt-4&&p<=qt+4);jt.push({id:x,pathD:L,style:d,leftIdx:J,rhsArrayIdx:c,x1:s,x2:v,y1:T,y2:I,matchLabel:A})}}})}else{var Z=t,$=Z;M=null===(a=C.current[Z])||void 0===a?void 0:a.current,T=null===(d=B.current[$])||void 0===d?void 0:d.current;if(!M||!T)return;I=M.getBoundingClientRect(),L=T.getBoundingClientRect(),w=k(Z),Y=I.right-U.left,D=L.left-U.left-0,j=Y+75,O=I.top+I.height/2,z=L.top+L.height/2,P=O-Qt+Kt,Q=z-Xt+Vt,X="conn-".concat(Z,"-").concat($),String(Number(t)+1),G=null;Pt.push({lhsScrollY:P,rhsScrollY:Q,x1:Y,x2:D,containerTop:Jt,leftIdx:Z,rhsArrayIdx:$,styleColor:(null==w?void 0:w.badgeBorder)||"#6366F1",styleBg:(null==w?void 0:w.badgeBg)||"#FFFFFF",styleText:(null==w?void 0:w.badgeText)||"#A16207",styleId:X,centerX:j});var _,tt;q=Ut(O,Qt,Gt),K=Ut(z,Xt,qt),V=At(Y,_=q-Jt,D,tt=K-Jt,j,O>=Qt-4&&O<=Gt+4,z>=Xt-4&&z<=qt+4);jt.push({id:X,pathD:V,style:w,leftIdx:Z,rhsArrayIdx:$,x1:Y,x2:D,y1:_,y2:tt,matchLabel:G})}}),Bt.current=Pt}gt(jt),setTimeout(function(){return Mt()},10)}else gt([]),Bt.current=[],setTimeout(function(){return Mt()},10)}catch(t){console.error("Line render safe fail: ",t)}finally{yt.current=!1}}},[f,h,g,w,nt,it,k,N,F,I,L,T,S,M,H]),Mt=n(function(){var t,e,n,i,r,c,o,s,v,h,g,f,p,b,y,x,m,R,C,B=Bt.current;if(!B.length)return null===(t=d.current["guideline-up-stroke"])||void 0===t||t.setAttribute("visibility","hidden"),null===(e=d.current["guideline-up-badge"])||void 0===e||e.setAttribute("visibility","hidden"),null===(n=d.current["guideline-down-stroke"])||void 0===n||n.setAttribute("visibility","hidden"),void(null===(i=d.current["guideline-down-badge"])||void 0===i||i.setAttribute("visibility","hidden"));if(!D.current){var A=null!==(c=null===(r=u.current)||void 0===r?void 0:r.scrollTop)&&void 0!==c?c:0,S=null!==(s=null===(o=a.current)||void 0===o?void 0:o.scrollTop)&&void 0!==s?s:0,M=null!==(h=null===(v=u.current)||void 0===v?void 0:v.clientHeight)&&void 0!==h?h:1/0,T=null!==(f=null===(g=a.current)||void 0===g?void 0:g.clientHeight)&&void 0!==f?f:1/0,I=null!==(b=null===(p=u.current)||void 0===p?void 0:p.getBoundingClientRect().top)&&void 0!==b?b:0,L=null!==(x=null===(y=a.current)||void 0===y?void 0:y.getBoundingClientRect().top)&&void 0!==x?x:0,F=I+M,H=L+T,w=null===(m=l.current)||void 0===m?void 0:m.getBoundingClientRect(),k=null!==(R=null==w?void 0:w.top)&&void 0!==R?R:0,E=null!==(C=null==w?void 0:w.height)&&void 0!==C?C:1/0,N=function(t,e,n){return Math.max(e,Math.min(n,t))},Y=0,j=0,O=0,z=0,P="#6366F1",Q="#A16207",X=!1,G=0;if(B.forEach(function(t){var e=t.lhsScrollY-A+I,n=t.rhsScrollY-S+L,i=d.current[t.styleId+"-stroke"],r=d.current[t.styleId+"-bg"],c=d.current[t.styleId+"-btn"],o=d.current[t.styleId+"-number"];if(i||r){var l=N(e,I,F),u=N(n,L,H),a=l-k,s=u-k,v=e>=I-4&&e<=F+4,h=n>=L-4&&n<=H+4,g=!0;X=!0;var f=t.centerX||t.x1+75;0===O&&(O=t.x1,z=a,G=f,P=t.styleColor,t.styleBg,Q=t.styleText||"#A16207"),n<L-4?(Y++,g=!1):n>H+4&&(j++,g=!1);var p=At(t.x1,a,t.x2,s,G,v,h);i&&(g&&p?(i.setAttribute("visibility","visible"),i.setAttribute("d",p)):i.setAttribute("visibility","hidden")),r&&(g&&p?(r.setAttribute("visibility","visible"),r.setAttribute("d",p)):r.setAttribute("visibility","hidden")),c&&(v&&g?(c.setAttribute("visibility","visible"),c.setAttribute("y",String(a-12))):c.setAttribute("visibility","hidden")),o&&(v&&g?(o.setAttribute("visibility","visible"),o.setAttribute("transform","translate(".concat(t.x2-42,", ").concat(s,")"))):o.setAttribute("visibility","hidden"))}}),X&&G>0){var q=d.current["guideline-up-stroke"],K=d.current["guideline-up-badge"],V=d.current["guideline-up-arrow"],J=d.current["guideline-up-text"],U=d.current["guideline-up-badge-rect"];if(Y>0){var W=Math.max(15,L-k+15),Z=Math.min(15,Math.abs(G-O),Math.max(0,z-W)),$="M ".concat(O,",").concat(z," L ").concat(G-Z,",").concat(z," Q ").concat(G,",").concat(z," ").concat(G,",").concat(z-Z," L ").concat(G,",").concat(W);null==q||q.setAttribute("visibility","visible"),null==q||q.setAttribute("d",$),null==q||q.setAttribute("stroke",P),null==K||K.setAttribute("visibility","visible"),null==K||K.setAttribute("transform","translate(".concat(G,", ").concat(W,")")),V&&V.setAttribute("fill",P),J&&(J.textContent="+".concat(Y),J.setAttribute("fill",Q)),U&&U.setAttribute("stroke",P)}else null==q||q.setAttribute("visibility","hidden"),null==K||K.setAttribute("visibility","hidden");var _=d.current["guideline-down-stroke"],tt=d.current["guideline-down-badge"],et=d.current["guideline-down-arrow"],nt=d.current["guideline-down-text"],it=d.current["guideline-down-badge-rect"];if(j>0){var rt=Math.min(E-15,H-k-15);Z=Math.min(15,Math.abs(G-O),Math.max(0,rt-z)),$="M ".concat(O,",").concat(z," L ").concat(G-Z,",").concat(z," Q ").concat(G,",").concat(z," ").concat(G,",").concat(z+Z," L ").concat(G,",").concat(rt);null==_||_.setAttribute("visibility","visible"),null==_||_.setAttribute("d",$),null==_||_.setAttribute("stroke",P),null==tt||tt.setAttribute("visibility","visible"),null==tt||tt.setAttribute("transform","translate(".concat(G,", ").concat(rt,")")),et&&et.setAttribute("fill",P),nt&&(nt.textContent="+".concat(j),nt.setAttribute("fill",Q)),it&&it.setAttribute("stroke",P)}else null==_||_.setAttribute("visibility","hidden"),null==tt||tt.setAttribute("visibility","hidden")}}},[]),Tt=n(function(){Bt.current.length>0&&!D.current||(null!==Rt.current&&clearTimeout(Rt.current),Rt.current=setTimeout(function(){K.current(),Rt.current=null},50))},[]),It=n(function(t){if(null!==tt.current&&et.current&&Math.abs(t.currentTarget.scrollTop-tt.current)<=2){var e=et.current;tt.current=null,et.current=null,e()}if(!mt.current&&!J.current){if(F&&U&&(j.current||T.size>0)){var n=t.currentTarget,i=u.current,c=a.current,o=n===i?c:n===c?i:null;if(n&&o){var d=function(){var t,e,n,i,c,o,l,u,a,d,s,v=P.current,h=Q.current;if(null===v)return{leftAnchor:null,rightAnchor:null};if("string"==typeof v&&v.includes(r)){var g=v.split(r),f="".concat(g[0]).concat(r).concat(g[1]);return{leftAnchor:(null===(t=C.current[f])||void 0===t?void 0:t.current)||(null===(e=m.current[g[2]])||void 0===e?void 0:e.current)||(null===(n=y.current[Number(g[2])])||void 0===n?void 0:n.current)||null,rightAnchor:(null===(i=B.current[f])||void 0===i?void 0:i.current)||(null===(c=R.current[g[3]])||void 0===c?void 0:c.current)||(null===(o=x.current[Number(g[3])])||void 0===o?void 0:o.current)||null}}var p=Number(v),b=null!==h?Number(h):p;return{leftAnchor:(null===(l=C.current[p])||void 0===l?void 0:l.current)||(null===(u=A.current[p])||void 0===u?void 0:u.current)||(null===(a=y.current[p])||void 0===a?void 0:a.current)||null,rightAnchor:(null===(d=B.current[b])||void 0===d?void 0:d.current)||(null===(s=x.current[b])||void 0===s?void 0:s.current)||null}}(),s=d.leftAnchor,v=d.rightAnchor,h=n===i?s:v,g=n===i?v:s,f=null;if(h&&g){var p=h.getBoundingClientRect(),b=g.getBoundingClientRect(),S=o.getBoundingClientRect(),M=p.top+p.height/2;f=b.top-S.top+o.scrollTop+b.height/2-(M-S.top)}else{var I=Math.max(0,n.scrollHeight-n.clientHeight),L=Math.max(0,o.scrollHeight-o.clientHeight);f=I>0?n.scrollTop/I*L:n.scrollTop}var H=Math.max(0,o.scrollHeight-o.clientHeight);f=Math.max(0,Math.min(f,H)),Math.abs(o.scrollTop-f)>1&&(mt.current=!0,o.scrollTop=f,requestAnimationFrame(function(){mt.current=!1}))}}F||Tt(),xt.current||(xt.current=!0,requestAnimationFrame(function(){var t,e,n,i,c,o,d;if(j.current){var s=u.current,v=a.current;if(s&&v&&z.current){if(!O.current){var h=P.current,g=void 0;if("string"==typeof h&&h.includes(r)){var f=h.split(r),p="".concat(f[0]).concat(r).concat(f[1]);g=null===(t=C.current[p])||void 0===t?void 0:t.current}else g=null===(e=C.current[h])||void 0===e?void 0:e.current;if(g){var b=g.getBoundingClientRect();O.current={badgeScreenY:b.top+b.height/2,initialScrollTop:s.scrollTop,leftTop:s.getBoundingClientRect().top,leftBottom:s.getBoundingClientRect().top+s.clientHeight,cTop:null!==(i=null===(n=l.current)||void 0===n?void 0:n.getBoundingClientRect().top)&&void 0!==i?i:0}}}if(O.current){var y=O.current,x=s.scrollTop-y.initialScrollTop,m=y.badgeScreenY-x,R=((c=m,o=y.leftTop,d=y.leftBottom,Math.max(o,Math.min(d,c)))-y.cTop).toString(),B=m>=y.leftTop-4&&m<=y.leftBottom+4;z.current.setAttribute("y1",R),z.current.setAttribute("y2",R),z.current.setAttribute("visibility",B?"visible":"hidden")}}}Mt(),xt.current=!1}))}},[Mt,F,U,T,Tt]);return i(function(){K.current=St},[St]),i(function(){var t=setTimeout(Tt,250),e=function(){return W.current()};return window.addEventListener("resize",e),function(){clearTimeout(t),null!==Rt.current&&clearTimeout(Rt.current),null!==V.current&&clearTimeout(V.current),window.removeEventListener("resize",e)}},[Z,$,_,f,S,M,h,g,nt,Tt,I,L,Y,T]),{lines:ct,setLines:ot,overallConnector:ut,setOverallConnector:at,connectedLines:ht,setConnectedLines:gt,svgDimensions:pt,cachedConnectedPositions:Bt,calculateLines:St,calculateLinesRef:K,calculateLinesDebounced:Tt,handleColumnScroll:It}};export{o as useLinesCalculator};
1
+ import{useState as t,useRef as e,useCallback as n,useEffect as i}from"react";import{DEVIATION_BADGE_SEPARATOR as r}from"../CognitiveComparehelpers.js";var c=function(c){var o=c.containerRef,l=c.leftContainerRef,u=c.rightContainerRef;c.svgContainerRef;var a=c.pathRefs,d=c.leftHeaderRef,s=c.rightHeaderRef,v=c.proposedSections,h=c.existingSections,g=c.visibleFields,f=c.leftRefs,p=c.rightRefs,b=c.sectionLeftRefs,y=c.sectionRightRefs,x=c.subSectionLeftRefs,m=c.subSectionRightRefs,R=c.lhsBadgeRefs,C=c.rhsBadgeRefs,A=c.sectionRowRefs,B=c.expandedSections,S=c.expandedSubSections,M=c.connectedSections,I=c.isSideBySide,T=c.activeSideBySideSection,L=c.maintainRelativeOrder,F=c.isGuidelineMode,H=c.cognitiveMap,w=c.getSectionCompareStyle,k=c.getSubSectionCompareStyle,E=c.getDeviationStyleByKey,N=c.isArrowVisible,Y=c.isAnimatingRef,D=c.isSideBySideRef,j=c.sideBySideCacheRef,O=c.sideBySideLineRef,z=c.activeSideBySideSectionRef,P=c.activeSideBySideRightSectionRef,Q=c.connectedLines,X=c.setConnectedLines,q=c.cachedConnectedPositions,G=c.calculateLinesRef,K=c.resizeTimerRef,V=c.scrollLock,J=c.scrollSyncLocked,U=c.handleResizeRef,W=c.activeProposed,Z=c.existingRule,$=c.analysisData,_=c.pendingScrollTargetRef,tt=c.pendingScrollCallbackRef,et=c.resolvedComparisonConfig,nt=c.getFieldData,it=t([]),rt=it[0],ct=it[1],ot=t(null),lt=ot[0],ut=ot[1],at=t([]),dt=at[0],st=at[1],vt=null!=Q?Q:dt,ht=null!=X?X:st,gt=t({width:0,height:0}),ft=gt[0],pt=gt[1],bt=e(!1),yt=e(!1),xt=e(!1),mt=e(null),Rt=e([]),Ct=null!=q?q:Rt,At=function(t,e,n,i,r,c,o){if(Math.abs(i-e)<=1)return c&&o?"M ".concat(t,",").concat(e," L ").concat(n,",").concat(i):c&&!o?"M ".concat(t,",").concat(e," L ").concat(r,",").concat(e):!c&&o?"M ".concat(r,",").concat(e," L ").concat(n,",").concat(i):"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i);var l=Math.min(15,Math.abs(r-t),Math.abs(i-e)/2),u=Math.min(15,Math.abs(n-r),Math.abs(i-e)/2),a=i>e?l:-l,d=i>e?u:-u,s=n>r?u:-u;return c&&o?"M ".concat(t,",").concat(e," L ").concat(r-l,",").concat(e," Q ").concat(r,",").concat(e," ").concat(r,",").concat(e+a," L ").concat(r,",").concat(i-d," Q ").concat(r,",").concat(i," ").concat(r+s,",").concat(i," L ").concat(n,",").concat(i):c&&!o?"M ".concat(t,",").concat(e," L ").concat(r-l,",").concat(e," Q ").concat(r,",").concat(e," ").concat(r,",").concat(e+a," L ").concat(r,",").concat(i):!c&&o?"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i-d," Q ").concat(r,",").concat(i," ").concat(r+s,",").concat(i," L ").concat(n,",").concat(i):"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i)},Bt=n(function(){var t,e,n,i,c,a,A,N,D,j,O,z,P,Q,X,q,G,K;if(!bt.current&&!Y.current){bt.current=!0;try{if(!o.current)return;var V=function(t){var e=t.split("-"),n=e[0];if(!B[n]&&!1===L)return!1;if(L&&!B["left-".concat(n)]&&!B["right-".concat(n)]&&!B[n])return!1;for(var i=n,r=1;r<e.length-1;r++)if(i+="-".concat(e[r]),!S[i])return!1;return!0},J=o.current.getBoundingClientRect();pt({width:J.width,height:J.height});var U=[];if(g.forEach(function(t){var e,n,i=t.key,r=null===(e=f.current[i])||void 0===e?void 0:e.current,c=null===(n=p.current[i])||void 0===n?void 0:n.current;r&&c&&(r.style.height="auto",c.style.height="auto",r.style.minHeight="0px",c.style.minHeight="0px")}),!Y.current){for(var W=0;W<Math.max(v.length,h.length);W++){var Z=null===(t=b.current[W])||void 0===t?void 0:t.current,$=null===(e=y.current[W])||void 0===e?void 0:e.current;Z&&(Z.style.height="auto",Z.style.minHeight="0px"),$&&($.style.height="auto",$.style.minHeight="0px")}L||Object.keys(x.current).forEach(function(t){var e,n;if(V(t)){var i=null===(e=x.current[t])||void 0===e?void 0:e.current,r=null===(n=m.current[t])||void 0===n?void 0:n.current;i&&r&&(i.style.height="auto",r.style.height="auto",i.style.minHeight="0px",r.style.minHeight="0px")}})}var _={};g.forEach(function(t){var e,n,i=t.key,r=null===(e=f.current[i])||void 0===e?void 0:e.current,c=null===(n=p.current[i])||void 0===n?void 0:n.current;if(r&&c){var o=r.getBoundingClientRect(),l=c.getBoundingClientRect();_[i]=Math.max(o.height,l.height)}});var tt={left:{},right:{}},et={};if(!Y.current)if(L){if(I&&null!==T)if("number"==typeof T){var nt=T,it=v[nt],rt=null===(c=b.current[nt])||void 0===c?void 0:c.current;rt&&it&&(it.refIndexes||[]).forEach(function(t){var e,n=h.findIndex(function(e){return e.selfIndex===t}),i=null===(e=y.current[n])||void 0===e?void 0:e.current;if(i&&(B["left-".concat(nt)]||B["right-".concat(n)])){var r=Math.max(rt.getBoundingClientRect().height,i.getBoundingClientRect().height);tt.left[nt]=Math.max(tt.left[nt]||0,r),tt.right[n]=Math.max(tt.right[n]||0,r)}})}else{var ot=T.split(r)[2];if(ot){Z=null===(a=x.current[ot])||void 0===a?void 0:a.current,$=null===(A=m.current[ot])||void 0===A?void 0:A.current;if(Z&&$){lt=Math.max(Z.getBoundingClientRect().height,$.getBoundingClientRect().height);et[ot]=Math.max(et[ot]||0,lt)}}}}else{Object.keys(x.current).forEach(function(t){var e,n;if(V(t)){var i=null===(e=x.current[t])||void 0===e?void 0:e.current,r=null===(n=m.current[t])||void 0===n?void 0:n.current;if(i&&r&&null!==i.offsetParent&&null!==r.offsetParent){var c=i.getBoundingClientRect(),o=r.getBoundingClientRect(),l=Math.max(c.height,o.height);et[t]=l,i.style.minHeight="".concat(l,"px"),r.style.minHeight="".concat(l,"px")}}});for(W=0;W<Math.min(v.length,h.length);W++){var Z=null===(n=b.current[W])||void 0===n?void 0:n.current,$=null===(i=y.current[W])||void 0===i?void 0:i.current;if(Z&&$){var lt=Math.max(Z.getBoundingClientRect().height,$.getBoundingClientRect().height);tt.left[W]=lt,tt.right[W]=lt}}}if(g.forEach(function(t){var e,n,i=t.key,r=null===(e=f.current[i])||void 0===e?void 0:e.current,c=null===(n=p.current[i])||void 0===n?void 0:n.current;if(r&&c){var o=_[i];r.style.minHeight="".concat(o,"px"),c.style.minHeight="".concat(o,"px")}}),Y.current||(Object.entries(tt.left).forEach(function(t){var e,n=t[0],i=t[1],r=null===(e=b.current[Number(n)])||void 0===e?void 0:e.current;r&&(r.style.minHeight="".concat(i,"px"))}),Object.entries(tt.right).forEach(function(t){var e,n=t[0],i=t[1],r=null===(e=y.current[Number(n)])||void 0===e?void 0:e.current;r&&(r.style.minHeight="".concat(i,"px"))}),L||Object.keys(et).forEach(function(t){var e,n,i=null===(e=x.current[t])||void 0===e?void 0:e.current,r=null===(n=m.current[t])||void 0===n?void 0:n.current;if(i&&r&&et[t]){var c=et[t];i.style.minHeight="".concat(c,"px"),r.style.minHeight="".concat(c,"px")}})),!F){v.forEach(function(t,e){var n,i=t.continuationSourceRowId?v.findIndex(function(e){return e.comparisonRowId===t.continuationSourceRowId}):-1,r=i>=0?i:e,c=null===(n=b.current[r])||void 0===n?void 0:n.current;if(c){var o=function(t,e){if(!L)return h[e]?[e]:[];var n=(t.refIndexes||[]).map(function(t){return h.findIndex(function(e){return e.selfIndex===t})}).filter(function(t){return-1!==t});return!n.length&&h[e]?[e]:Array.from(new Set(n))}(t,e);o.forEach(function(t){var n,o,a,d,s,g,f,p,b,x,m,R,C=null===(n=y.current[t])||void 0===n?void 0:n.current;if(C){var A=c.getBoundingClientRect(),B=C.getBoundingClientRect(),S=A.right-J.left,M=B.left-J.left,F=A.top+18-J.top,k=B.top+18-J.top;if(L&&I&&T===e){var E=null!==(a=null===(o=l.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==a?a:0,N=null!==(s=null===(d=u.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==s?s:0,Y=E+(null!==(f=null===(g=l.current)||void 0===g?void 0:g.clientHeight)&&void 0!==f?f:1/0),D=N+(null!==(b=null===(p=u.current)||void 0===p?void 0:p.clientHeight)&&void 0!==b?b:1/0),j=function(t,e,n){return Math.max(e,Math.min(n,t))};F=j(A.top+18,E,Y)-J.top,k=j(B.top+18,N,D)-J.top}var O=w(r);O&&U.push({id:"line-".concat(r,"-").concat(t),x1:S,y1:F,x2:M,y2:k,style:O,sectionIdx:r,targetRightIdx:t,isSubSection:!1,isMappingContinuation:i>=0,hasCognitive:!!((null===(x=v[r])||void 0===x?void 0:x.cognitiveData)||(null===(m=h[t])||void 0===m?void 0:m.cognitiveData)||(null===(R=v[r])||void 0===R?void 0:R.nodeId)&&H[v[r].nodeId])})}})}})}if(!F&&I&&"string"==typeof T&&T.includes(r)){var at=T.split(r),dt=at[0],st=at[1],vt=at[2],gt=(at[3],"".concat(dt).concat(r).concat(st)),ft=null===(N=R.current[gt])||void 0===N?void 0:N.current,yt=null===(D=C.current[gt])||void 0===D?void 0:D.current;if(ft&&yt){var xt=ft.getBoundingClientRect(),mt=yt.getBoundingClientRect(),Rt=xt.right-J.left,Bt=mt.left-J.left,Mt=xt.top+xt.height/2-J.top,It=mt.top+mt.height/2-J.top;if(L){var Tt=null!==(O=null===(j=l.current)||void 0===j?void 0:j.getBoundingClientRect().top)&&void 0!==O?O:0,Lt=null!==(P=null===(z=u.current)||void 0===z?void 0:z.getBoundingClientRect().top)&&void 0!==P?P:0,Ft=Tt+(null!==(X=null===(Q=l.current)||void 0===Q?void 0:Q.clientHeight)&&void 0!==X?X:1/0),Ht=Lt+(null!==(G=null===(q=u.current)||void 0===q?void 0:q.clientHeight)&&void 0!==G?G:1/0),wt=function(t,e,n){return Math.max(e,Math.min(n,t))};Mt=wt(xt.top+xt.height/2,Tt,Ft)-J.top,It=wt(mt.top+mt.height/2,Lt,Ht)-J.top}var kt=null!==(K=E(dt,st))&&void 0!==K?K:k(vt);kt&&U.push({id:"line-subsec-".concat(gt),x1:Rt,y1:Mt,x2:Bt,y2:It,style:kt,sectionIdx:Number(vt.split("-")[0]),isSubSection:!0,subSectionKeyPath:T})}}if(ct(U),d.current&&s.current){var Et=d.current.getBoundingClientRect(),Nt=s.current.getBoundingClientRect(),Yt=(Et.top+Et.height/2-J.top+Nt.top+Nt.height/2-J.top)/2;ut({x1:Et.right-J.left,x2:Nt.left-J.left,y:Yt})}else ut(null);if(M.size>0){var Dt=[],jt=l.current,Ot=u.current;if(jt&&Ot){var zt=[],Pt=jt.getBoundingClientRect().top,Qt=Ot.getBoundingClientRect().top,Xt=Pt+jt.clientHeight,qt=Qt+Ot.clientHeight,Gt=jt.scrollTop,Kt=Ot.scrollTop,Vt=J.top,Jt=function(t,e,n){return Math.max(e,Math.min(n,t))};M.forEach(function(t){var e,n,i,c,o,l,u,a,d;if(F){var s=null,g=null,f=null;if("string"==typeof t&&t.includes(r)){var p=t.split(r),b=p[0],y=p[1],x=p[2],m="".concat(b).concat(r).concat(y);s=null===(e=R.current[m])||void 0===e?void 0:e.current,f=null!==(n=E(b,y))&&void 0!==n?n:k(x),g=Number((null==x?void 0:x.split("-")[0])||0)}else g=Number(t),s=null===(i=R.current[g])||void 0===i?void 0:i.current,f=w(g);if(!s)return;var A=document.querySelectorAll('[id^="guideline-target-"]');A.forEach(function(e,n){var i=s.getBoundingClientRect(),c=e.getBoundingClientRect(),o=i.right-J.left,l=c.left-J.left-0,u=o+75,a=i.top+i.height/2,d=c.top+c.height/2,v=a-Pt+Gt,h=d-Qt+Kt,g="conn-guide-".concat(t,"-").concat(n),p="";"string"==typeof t&&t.includes(r)?p=(t.split(r)[2]||"").split("-").map(function(t){return Number(t)+1}).join("."):p=String(Number(t)+1);var b=String.fromCharCode(97+n),y=1===A.length?null:"".concat(p,"(").concat(b,")");zt.push({lhsScrollY:v,rhsScrollY:h,x1:o,x2:l,containerTop:Vt,leftIdx:t,rhsArrayIdx:n,styleColor:(null==f?void 0:f.badgeBorder)||"#6366F1",styleBg:(null==f?void 0:f.badgeBg)||"#FFFFFF",styleText:(null==f?void 0:f.badgeText)||"#A16207",styleId:g,centerX:u});var x=Jt(a,Pt,Xt),m=Jt(d,Qt,qt),R=x-Vt,C=m-Vt,B=At(o,R,l,C,u,a>=Pt-4&&a<=Xt+4,d>=Qt-4&&d<=qt+4);Dt.push({id:g,pathD:B,style:f,leftIdx:t,rhsArrayIdx:n,x1:o,x2:l,y1:R,y2:C,centerX:u,matchLabel:y,isGuideline:!0})})}else if("string"==typeof t&&t.includes(r)){var B=t.split(r),S=(b=B[0],y=B[1],x=B[2],B[3],m="".concat(b).concat(r).concat(y),null===(c=R.current[m])||void 0===c?void 0:c.current),M=null===(o=C.current[m])||void 0===o?void 0:o.current;if(!S||!M)return;var I=S.getBoundingClientRect(),T=M.getBoundingClientRect(),H=null!==(l=E(b,y))&&void 0!==l?l:k(x),N=I.right-J.left,Y=T.left-J.left-0,D=N+75,j=I.top+I.height/2,O=T.top+T.height/2,z=j-Pt+Gt,P=O-Qt+Kt,Q="conn-subsec-".concat(m),X=((x||"").split("-").map(function(t){return Number(t)+1}).join("."),null);zt.push({lhsScrollY:z,rhsScrollY:P,x1:N,x2:Y,containerTop:Vt,leftIdx:t,rhsArrayIdx:t,styleColor:(null==H?void 0:H.badgeBorder)||"#6366F1",styleBg:(null==H?void 0:H.badgeBg)||"#FFFFFF",styleText:(null==H?void 0:H.badgeText)||"#A16207",styleId:Q,centerX:D});var q=Jt(j,Pt,Xt),G=Jt(O,Qt,qt),K=At(N,$=q-Vt,Y,_=G-Vt,D,j>=Pt-4&&j<=Xt+4,O>=Qt-4&&O<=qt+4);Dt.push({id:Q,pathD:K,style:H,leftIdx:t,rhsArrayIdx:t,x1:N,x2:Y,y1:$,y2:_,matchLabel:X})}else if(L){var V=t,U=v[V];if(!(null===(d=null==U?void 0:U.refIndexes)||void 0===d?void 0:d.length))return;U.refIndexes.forEach(function(e,n){var i,r,c=h.findIndex(function(t){return t.selfIndex===e});if(-1!==c){var o=null===(i=R.current[V])||void 0===i?void 0:i.current,l=null===(r=C.current[c])||void 0===r?void 0:r.current;if(o&&l){var u=o.getBoundingClientRect(),a=l.getBoundingClientRect(),d=w(V),s=u.right-J.left,v=a.left-J.left-0,g=s+75,f=u.top+u.height/2,p=a.top+a.height/2,b=f-Pt+Gt,y=p-Qt+Kt,x="conn-".concat(V,"-").concat(c),m=String(Number(t)+1),A=String.fromCharCode(97+n),B=1===U.refIndexes.length?null:"".concat(m,"(").concat(A,")");zt.push({lhsScrollY:b,rhsScrollY:y,x1:s,x2:v,containerTop:Vt,leftIdx:V,rhsArrayIdx:c,styleColor:(null==d?void 0:d.badgeBorder)||"#6366F1",styleBg:(null==d?void 0:d.badgeBg)||"#FFFFFF",styleText:(null==d?void 0:d.badgeText)||"#A16207",styleId:x,centerX:g});var S=Jt(f,Pt,Xt),M=Jt(p,Qt,qt),I=S-Vt,T=M-Vt,L=At(s,I,v,T,g,f>=Pt-4&&f<=Xt+4,p>=Qt-4&&p<=qt+4);Dt.push({id:x,pathD:L,style:d,leftIdx:V,rhsArrayIdx:c,x1:s,x2:v,y1:I,y2:T,matchLabel:B})}}})}else{var W=t,Z=W;S=null===(u=R.current[W])||void 0===u?void 0:u.current,M=null===(a=C.current[Z])||void 0===a?void 0:a.current;if(!S||!M)return;I=S.getBoundingClientRect(),T=M.getBoundingClientRect(),H=w(W),N=I.right-J.left,Y=T.left-J.left-0,D=N+75,j=I.top+I.height/2,O=T.top+T.height/2,z=j-Pt+Gt,P=O-Qt+Kt,Q="conn-".concat(W,"-").concat(Z),String(Number(t)+1),X=null;zt.push({lhsScrollY:z,rhsScrollY:P,x1:N,x2:Y,containerTop:Vt,leftIdx:W,rhsArrayIdx:Z,styleColor:(null==H?void 0:H.badgeBorder)||"#6366F1",styleBg:(null==H?void 0:H.badgeBg)||"#FFFFFF",styleText:(null==H?void 0:H.badgeText)||"#A16207",styleId:Q,centerX:D});var $,_;q=Jt(j,Pt,Xt),G=Jt(O,Qt,qt),K=At(N,$=q-Vt,Y,_=G-Vt,D,j>=Pt-4&&j<=Xt+4,O>=Qt-4&&O<=qt+4);Dt.push({id:Q,pathD:K,style:H,leftIdx:W,rhsArrayIdx:Z,x1:N,x2:Y,y1:$,y2:_,matchLabel:X})}}),Ct.current=zt}ht(Dt),setTimeout(function(){return St()},10)}else ht([]),Ct.current=[],setTimeout(function(){return St()},10)}catch(t){console.error("Line render safe fail: ",t)}finally{bt.current=!1}}},[g,v,h,H,et,nt,w,E,L,I,T,M,B,S,F]),St=n(function(){var t,e,n,i,r,c,d,s,v,h,g,f,p,b,y,x,m,R,C,A=Ct.current;if(!A.length)return null===(t=a.current["guideline-up-stroke"])||void 0===t||t.setAttribute("visibility","hidden"),null===(e=a.current["guideline-up-badge"])||void 0===e||e.setAttribute("visibility","hidden"),null===(n=a.current["guideline-down-stroke"])||void 0===n||n.setAttribute("visibility","hidden"),void(null===(i=a.current["guideline-down-badge"])||void 0===i||i.setAttribute("visibility","hidden"));if(!Y.current){var B=null!==(c=null===(r=l.current)||void 0===r?void 0:r.scrollTop)&&void 0!==c?c:0,S=null!==(s=null===(d=u.current)||void 0===d?void 0:d.scrollTop)&&void 0!==s?s:0,M=null!==(h=null===(v=l.current)||void 0===v?void 0:v.clientHeight)&&void 0!==h?h:1/0,I=null!==(f=null===(g=u.current)||void 0===g?void 0:g.clientHeight)&&void 0!==f?f:1/0,T=null!==(b=null===(p=l.current)||void 0===p?void 0:p.getBoundingClientRect().top)&&void 0!==b?b:0,L=null!==(x=null===(y=u.current)||void 0===y?void 0:y.getBoundingClientRect().top)&&void 0!==x?x:0,F=T+M,H=L+I,w=null===(m=o.current)||void 0===m?void 0:m.getBoundingClientRect(),k=null!==(R=null==w?void 0:w.top)&&void 0!==R?R:0,E=null!==(C=null==w?void 0:w.height)&&void 0!==C?C:1/0,N=function(t,e,n){return Math.max(e,Math.min(n,t))},D=0,j=0,O=0,z=0,P="#6366F1",Q="#A16207",X=!1,q=0;if(A.forEach(function(t){var e=t.lhsScrollY-B+T,n=t.rhsScrollY-S+L,i=a.current[t.styleId+"-stroke"],r=a.current[t.styleId+"-bg"],c=a.current[t.styleId+"-btn"],o=a.current[t.styleId+"-number"];if(i||r){var l=N(e,T,F),u=N(n,L,H),d=l-k,s=u-k,v=e>=T-4&&e<=F+4,h=n>=L-4&&n<=H+4,g=!0;X=!0;var f=t.centerX||t.x1+75;0===O&&(O=t.x1,z=d,q=f,P=t.styleColor,t.styleBg,Q=t.styleText||"#A16207"),n<L-4?(D++,g=!1):n>H+4&&(j++,g=!1);var p=At(t.x1,d,t.x2,s,q,v,h);i&&(g&&p?(i.setAttribute("visibility","visible"),i.setAttribute("d",p)):i.setAttribute("visibility","hidden")),r&&(g&&p?(r.setAttribute("visibility","visible"),r.setAttribute("d",p)):r.setAttribute("visibility","hidden")),c&&(v&&g?(c.setAttribute("visibility","visible"),c.setAttribute("y",String(d-12))):c.setAttribute("visibility","hidden")),o&&(v&&g?(o.setAttribute("visibility","visible"),o.setAttribute("transform","translate(".concat(t.x2-42,", ").concat(s,")"))):o.setAttribute("visibility","hidden"))}}),X&&q>0){var G=a.current["guideline-up-stroke"],K=a.current["guideline-up-badge"],V=a.current["guideline-up-arrow"],J=a.current["guideline-up-text"],U=a.current["guideline-up-badge-rect"];if(D>0){var W=Math.max(15,L-k+15),Z=Math.min(15,Math.abs(q-O),Math.max(0,z-W)),$="M ".concat(O,",").concat(z," L ").concat(q-Z,",").concat(z," Q ").concat(q,",").concat(z," ").concat(q,",").concat(z-Z," L ").concat(q,",").concat(W);null==G||G.setAttribute("visibility","visible"),null==G||G.setAttribute("d",$),null==G||G.setAttribute("stroke",P),null==K||K.setAttribute("visibility","visible"),null==K||K.setAttribute("transform","translate(".concat(q,", ").concat(W,")")),V&&V.setAttribute("fill",P),J&&(J.textContent="+".concat(D),J.setAttribute("fill",Q)),U&&U.setAttribute("stroke",P)}else null==G||G.setAttribute("visibility","hidden"),null==K||K.setAttribute("visibility","hidden");var _=a.current["guideline-down-stroke"],tt=a.current["guideline-down-badge"],et=a.current["guideline-down-arrow"],nt=a.current["guideline-down-text"],it=a.current["guideline-down-badge-rect"];if(j>0){var rt=Math.min(E-15,H-k-15);Z=Math.min(15,Math.abs(q-O),Math.max(0,rt-z)),$="M ".concat(O,",").concat(z," L ").concat(q-Z,",").concat(z," Q ").concat(q,",").concat(z," ").concat(q,",").concat(z+Z," L ").concat(q,",").concat(rt);null==_||_.setAttribute("visibility","visible"),null==_||_.setAttribute("d",$),null==_||_.setAttribute("stroke",P),null==tt||tt.setAttribute("visibility","visible"),null==tt||tt.setAttribute("transform","translate(".concat(q,", ").concat(rt,")")),et&&et.setAttribute("fill",P),nt&&(nt.textContent="+".concat(j),nt.setAttribute("fill",Q)),it&&it.setAttribute("stroke",P)}else null==_||_.setAttribute("visibility","hidden"),null==tt||tt.setAttribute("visibility","hidden")}}},[]),Mt=n(function(){Ct.current.length>0&&!Y.current||(null!==mt.current&&clearTimeout(mt.current),mt.current=setTimeout(function(){G.current(),mt.current=null},50))},[]),It=n(function(t){if(null!==_.current&&tt.current&&Math.abs(t.currentTarget.scrollTop-_.current)<=2){var e=tt.current;_.current=null,tt.current=null,e()}if(!xt.current&&!V.current){if(L&&J&&(D.current||M.size>0)){var n=t.currentTarget,i=l.current,c=u.current,a=n===i?c:n===c?i:null;if(n&&a){var d=function(){var t,e,n,i,c,o,l,u,a,d,s,v=z.current,h=P.current;if(null===v)return{leftAnchor:null,rightAnchor:null};if("string"==typeof v&&v.includes(r)){var g=v.split(r),f="".concat(g[0]).concat(r).concat(g[1]);return{leftAnchor:(null===(t=R.current[f])||void 0===t?void 0:t.current)||(null===(e=x.current[g[2]])||void 0===e?void 0:e.current)||(null===(n=b.current[Number(g[2])])||void 0===n?void 0:n.current)||null,rightAnchor:(null===(i=C.current[f])||void 0===i?void 0:i.current)||(null===(c=m.current[g[3]])||void 0===c?void 0:c.current)||(null===(o=y.current[Number(g[3])])||void 0===o?void 0:o.current)||null}}var p=Number(v),B=null!==h?Number(h):p;return{leftAnchor:(null===(l=R.current[p])||void 0===l?void 0:l.current)||(null===(u=A.current[p])||void 0===u?void 0:u.current)||(null===(a=b.current[p])||void 0===a?void 0:a.current)||null,rightAnchor:(null===(d=C.current[B])||void 0===d?void 0:d.current)||(null===(s=y.current[B])||void 0===s?void 0:s.current)||null}}(),s=d.leftAnchor,v=d.rightAnchor,h=n===i?s:v,g=n===i?v:s,f=null;if(h&&g){var p=h.getBoundingClientRect(),B=g.getBoundingClientRect(),S=a.getBoundingClientRect(),I=p.top+p.height/2;f=B.top-S.top+a.scrollTop+B.height/2-(I-S.top)}else{var T=Math.max(0,n.scrollHeight-n.clientHeight),F=Math.max(0,a.scrollHeight-a.clientHeight);f=T>0?n.scrollTop/T*F:n.scrollTop}var H=Math.max(0,a.scrollHeight-a.clientHeight);f=Math.max(0,Math.min(f,H)),Math.abs(a.scrollTop-f)>1&&(xt.current=!0,a.scrollTop=f,requestAnimationFrame(function(){xt.current=!1}))}}L||Mt(),yt.current||(yt.current=!0,requestAnimationFrame(function(){var t,e,n,i,c,a,d;if(D.current){var s=l.current,v=u.current;if(s&&v&&O.current){if(!j.current){var h=z.current,g=void 0;if("string"==typeof h&&h.includes(r)){var f=h.split(r),p="".concat(f[0]).concat(r).concat(f[1]);g=null===(t=R.current[p])||void 0===t?void 0:t.current}else g=null===(e=R.current[h])||void 0===e?void 0:e.current;if(g){var b=g.getBoundingClientRect();j.current={badgeScreenY:b.top+b.height/2,initialScrollTop:s.scrollTop,leftTop:s.getBoundingClientRect().top,leftBottom:s.getBoundingClientRect().top+s.clientHeight,cTop:null!==(i=null===(n=o.current)||void 0===n?void 0:n.getBoundingClientRect().top)&&void 0!==i?i:0}}}if(j.current){var y=j.current,x=s.scrollTop-y.initialScrollTop,m=y.badgeScreenY-x,C=((c=m,a=y.leftTop,d=y.leftBottom,Math.max(a,Math.min(d,c)))-y.cTop).toString(),A=m>=y.leftTop-4&&m<=y.leftBottom+4;O.current.setAttribute("y1",C),O.current.setAttribute("y2",C),O.current.setAttribute("visibility",A?"visible":"hidden")}}}St(),yt.current=!1}))}},[St,L,J,M,Mt]);return i(function(){G.current=Bt},[Bt]),i(function(){var t=setTimeout(Mt,250),e=function(){return U.current()};return window.addEventListener("resize",e),function(){clearTimeout(t),null!==mt.current&&clearTimeout(mt.current),null!==K.current&&clearTimeout(K.current),window.removeEventListener("resize",e)}},[W,Z,$,g,B,S,v,h,et,Mt,I,T,N,M]),{lines:rt,setLines:ct,overallConnector:lt,setOverallConnector:ut,connectedLines:vt,setConnectedLines:ht,svgDimensions:ft,cachedConnectedPositions:Ct,calculateLines:Bt,calculateLinesRef:G,calculateLinesDebounced:Mt,handleColumnScroll:It}};export{c as useLinesCalculator};
2
2
  //# sourceMappingURL=useLinesCalculator.js.map
@@ -1,2 +1,2 @@
1
- import{useState as e,useRef as n,useCallback as t,useEffect as r}from"react";import{DEVIATION_BADGE_SEPARATOR as i,resetClauseHighlight as l,smoothScrollTo as u}from"../CognitiveComparehelpers.js";import{getVisibleGuidelineTargets as o}from"../Guidelines/utils/guidelineTargets.js";var c=function(c){var d=c.isGuidelineMode,s=c.maintainRelativeOrder,v=c.proposedSections,a=c.existingSections,p=c.leftContainerRef,g=c.rightContainerRef,f=c.scrollContainerRef,h=c.sectionLeftRefs,R=c.sectionRightRefs,S=c.subSectionLeftRefs,y=c.subSectionRightRefs,m=c.lhsBadgeRefs,B=c.rhsBadgeRefs,x=c.sectionRowRefs,C=c.sectionRightRowRefs,T=c.rhsTopSpacerRef,b=c.rhsBottomSpacerRef,A=c.lhsTopSpacerRef,w=c.lhsBottomSpacerRef,I=c.calculateLinesRef,L=c.setConnectedSections,F=c.setConnectedLines,N=c.cachedConnectedPositions,E=c.closeMoreFunctionsPopup,q=c.setErrorToast;c.moreFunctions,c.closeSummaryPopup;var H=e(!1),M=H[0],P=H[1],j=e(!1),z=j[0],G=j[1],V=e(!1),k=V[0],O=V[1],D=e(!1),J=D[0],K=D[1],Q=e(null),U=Q[0],W=Q[1],X=n(!1),Y=n(null),Z=n(!1),$=n(null),_=n(null),ee=n(null),ne=n(new Set),te=function(){ne.current.forEach(function(e){l(e)}),ne.current.clear()},re=function(e,n,t){var r,l,u,o,c,d,s,v,a,f,T,b,A=null,w=null,I=null,L=null,F=null,N=null,E=function(e,n){if(!e||!n)return!0;var t=e.getBoundingClientRect(),r=n.getBoundingClientRect();return t.bottom>=r.top&&t.top<=r.bottom};if(e){var q=n.split(i),H="".concat(q[0]).concat(i).concat(q[1]);A=(null===(r=S.current[q[2]])||void 0===r?void 0:r.current)||(null===(l=h.current[Number(q[2])])||void 0===l?void 0:l.current)||null,w=(null===(u=y.current[q[3]])||void 0===u?void 0:u.current)||(null===(o=R.current[Number(q[3])])||void 0===o?void 0:o.current)||null,I=(null===(c=m.current[H])||void 0===c?void 0:c.current)||A,L=(null===(d=B.current[H])||void 0===d?void 0:d.current)||w}else{var M=Number(n),P=null!==t?Number(t):M;A=(null===(s=h.current[M])||void 0===s?void 0:s.current)||null,w=(null===(v=R.current[P])||void 0===v?void 0:v.current)||null,F=(null===(a=m.current[M])||void 0===a?void 0:a.current)||null,N=(null===(f=B.current[P])||void 0===f?void 0:f.current)||null,I=F||(null===(T=x.current[M])||void 0===T?void 0:T.current)||A,L=N||(null===(b=C.current[P])||void 0===b?void 0:b.current)||w}if(A&&(A.style.paddingTop="0px"),w&&(w.style.paddingTop="0px"),e||(F&&(F.style.marginTop="0px"),N&&(N.style.marginTop="0px")),!e&&F&&N){var j=p.current,z=g.current;if(!E(F,j)||!E(N,z))return;var G=F.getBoundingClientRect(),V=N.getBoundingClientRect(),k=G.top-V.top;if(Math.abs(k)>32)return;k>0&&(N.style.marginTop="".concat(k,"px"))}else if(I&&L&&A&&w){G=I.getBoundingClientRect(),V=L.getBoundingClientRect();(k=G.top-V.top)>0&&(w.style.paddingTop="".concat(k,"px"))}},ie=t(function(){var e,n,t,r,l,u,o,c,d=$.current,s=_.current;if(null!==d)if("string"==typeof d&&d.includes(i)){var v=d.split(i),a=(null===(e=S.current[v[2]])||void 0===e?void 0:e.current)||(null===(n=h.current[Number(v[2])])||void 0===n?void 0:n.current)||null,p=(null===(t=y.current[v[3]])||void 0===t?void 0:t.current)||(null===(r=R.current[Number(v[3])])||void 0===r?void 0:r.current)||null;a&&(a.style.paddingTop="0px"),p&&(p.style.paddingTop="0px")}else{a=(null===(l=h.current[d])||void 0===l?void 0:l.current)||null,p=(null===(u=R.current[null!=s?s:d])||void 0===u?void 0:u.current)||null;a&&(a.style.paddingTop="0px"),p&&(p.style.paddingTop="0px");var g=(null===(o=m.current[d])||void 0===o?void 0:o.current)||null,f=(null===(c=B.current[null!=s?s:d])||void 0===c?void 0:c.current)||null;g&&(g.style.marginTop="0px"),f&&(f.style.marginTop="0px")}T.current&&(T.current.style.height="0px"),b.current&&(b.current.style.height="0px"),A.current&&(A.current.style.height="0px"),w.current&&(w.current.style.height="0px")},[]);r(function(){Z.current=M},[M]),r(function(){$.current=U},[U]);var le=t(function(){te(),P(!1),Z.current=!1,Y.current=null,ie(),W(null),$.current=null,_.current=null,G(!1),K(!1)},[ie]),ue=t(function(e,n,t){var r,l,c=null===(r=null==t?void 0:t.toggleIfSame)||void 0===r||r,S=null==t?void 0:t.onReady,y=null!==(l=null==t?void 0:t.sourceSide)&&void 0!==l?l:"left";if(E(),null!=e)if(!n||d){te();var H=M&&U===e;M&&null!==U&&ie(),H&&c?le():(L(new Set([e])),F([]),N.current=[],K(!0),X.current=!0,W(e),$.current=e,P(!0),Z.current=!0,G(!1),T.current&&(T.current.style.height="0px"),b.current&&(b.current.style.height="0px"),A.current&&(A.current.style.height="0px"),w.current&&(w.current.style.height="0px"),requestAnimationFrame(function(){var n=function(){var n,t,r,l,c,A,w,L,F,N,E,q="string"==typeof e&&e.includes(i),H=null,M=null,P=null;if(d){if(q){var j=e.split(i),z="".concat(j[0]).concat(i).concat(j[1]);H=(null===(n=m.current[z])||void 0===n?void 0:n.current)||null}else H=(null===(t=h.current[e])||void 0===t?void 0:t.current)||(null===(r=x.current[e])||void 0===r?void 0:r.current)||null;M=o(g.current)[0]||null,P=M?e:null}else if(q){j=e.split(i),z="".concat(j[0]).concat(i).concat(j[1]);H=(null===(l=m.current[z])||void 0===l?void 0:l.current)||null,M=(null===(c=B.current[z])||void 0===c?void 0:c.current)||null,P=M?e:null}else if(H=(null===(A=h.current[e])||void 0===A?void 0:A.current)||(null===(w=x.current[e])||void 0===w?void 0:w.current)||null,s){var V=v[e],k=(null==V?void 0:V.refIndexes)||[];if(k.length>0){var O=k[0],D=a.findIndex(function(e){return e.selfIndex===O});-1!==D&&(M=(null===(N=R.current[D])||void 0===N?void 0:N.current)||(null===(E=C.current[D])||void 0===E?void 0:E.current)||null,P=D)}}else M=(null===(L=R.current[e])||void 0===L?void 0:L.current)||(null===(F=C.current[e])||void 0===F?void 0:F.current)||null,P=M?e:null;_.current=P;var J=p.current,Q=g.current,U=function(){re(q,e,P),G(!0),I.current&&I.current(),X.current=!1,"right"===y&&Q?Q.dispatchEvent(new Event("scroll")):J&&J.dispatchEvent(new Event("scroll")),K(!1),null==S||S()};if(!H||!J)return X.current=!1,K(!1),void(null==S||S());if(M&&Q){if(!s){var W=0;W="right"===y?M?M.getBoundingClientRect().top:0:H?H.getBoundingClientRect().top:0;var Y=f.current,Z=(null==Y?void 0:Y.getBoundingClientRect().top)||0,$=Y?Y.scrollTop+W-Z-150:0;return Y?void u(Y,$,200,U):void U()}var ee=H.getBoundingClientRect().top-J.getBoundingClientRect().top+J.scrollTop,ne=M.getBoundingClientRect().top-Q.getBoundingClientRect().top+Q.scrollTop,te=200;if("left"===y){var ie=ne-(ee-J.scrollTop);ie<0&&T.current&&!d&&(T.current.style.height="".concat(Math.abs(ie),"px")),requestAnimationFrame(function(){var e,n=Q.scrollHeight-Q.clientHeight;if(ie<0)e=0;else{if(ie>n){var t=ie-n;return b.current&&!d&&(b.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){u(Q,ie,te,U)})}e=ie}u(Q,e,te,U)})}else{var le=ee-(ne-Q.scrollTop);requestAnimationFrame(function(){var e,n=J.scrollHeight-J.clientHeight;if(le<0)e=0;else{if(le>n)return void requestAnimationFrame(function(){return u(J,n,te,U)});e=le}u(J,e,te,U)})}}else U()};d?setTimeout(n,100):n()}))}else q("No counterpart exists for this section.")},[U,E,a,M,s,v,ie,le,d]);return{isSideBySide:M,setIsSideBySide:P,isArrowVisible:z,setIsArrowVisible:G,isResizing:k,setIsResizing:O,isSideBySideLoading:J,setIsSideBySideLoading:K,activeSideBySideSection:U,setActiveSideBySideSection:W,scrollLock:X,sideBySideCacheRef:Y,isSideBySideRef:Z,activeSideBySideSectionRef:$,activeSideBySideRightSectionRef:_,sideBySideLineRef:ee,highlightedClauseRefs:ne,clearClauseHighlight:te,applyAlignmentPadding:re,resetSideBySide:le,activateSideBySide:ue}};export{c as useSideBySide};
1
+ import{useState as e,useRef as n,useCallback as t,useEffect as r}from"react";import{DEVIATION_BADGE_SEPARATOR as i,resetClauseHighlight as l,smoothScrollTo as u}from"../CognitiveComparehelpers.js";var o=function(o){var c=o.isGuidelineMode,d=o.maintainRelativeOrder,s=o.proposedSections,v=o.existingSections,a=o.leftContainerRef,p=o.rightContainerRef,g=o.scrollContainerRef,f=o.sectionLeftRefs,h=o.sectionRightRefs,R=o.subSectionLeftRefs,S=o.subSectionRightRefs,y=o.lhsBadgeRefs,m=o.rhsBadgeRefs,B=o.sectionRowRefs,x=o.sectionRightRowRefs,C=o.rhsTopSpacerRef,T=o.rhsBottomSpacerRef,b=o.lhsTopSpacerRef,A=o.lhsBottomSpacerRef,I=o.calculateLinesRef,w=o.setConnectedSections,L=o.setConnectedLines,E=o.cachedConnectedPositions,F=o.closeMoreFunctionsPopup,N=o.setErrorToast;o.moreFunctions,o.closeSummaryPopup;var q=e(!1),H=q[0],M=q[1],P=e(!1),z=P[0],V=P[1],j=e(!1),k=j[0],G=j[1],O=e(!1),D=O[0],J=O[1],K=e(null),Q=K[0],U=K[1],W=n(!1),X=n(null),Y=n(!1),Z=n(null),$=n(null),_=n(null),ee=n(new Set),ne=function(){ee.current.forEach(function(e){l(e)}),ee.current.clear()},te=function(e,n,t){var r,l,u,o,c,d,s,v,g,C,T,b,A=null,I=null,w=null,L=null,E=null,F=null,N=function(e,n){if(!e||!n)return!0;var t=e.getBoundingClientRect(),r=n.getBoundingClientRect();return t.bottom>=r.top&&t.top<=r.bottom};if(e){var q=n.split(i),H="".concat(q[0]).concat(i).concat(q[1]);A=(null===(r=R.current[q[2]])||void 0===r?void 0:r.current)||(null===(l=f.current[Number(q[2])])||void 0===l?void 0:l.current)||null,I=(null===(u=S.current[q[3]])||void 0===u?void 0:u.current)||(null===(o=h.current[Number(q[3])])||void 0===o?void 0:o.current)||null,w=(null===(c=y.current[H])||void 0===c?void 0:c.current)||A,L=(null===(d=m.current[H])||void 0===d?void 0:d.current)||I}else{var M=Number(n),P=null!==t?Number(t):M;A=(null===(s=f.current[M])||void 0===s?void 0:s.current)||null,I=(null===(v=h.current[P])||void 0===v?void 0:v.current)||null,E=(null===(g=y.current[M])||void 0===g?void 0:g.current)||null,F=(null===(C=m.current[P])||void 0===C?void 0:C.current)||null,w=E||(null===(T=B.current[M])||void 0===T?void 0:T.current)||A,L=F||(null===(b=x.current[P])||void 0===b?void 0:b.current)||I}if(A&&(A.style.paddingTop="0px"),I&&(I.style.paddingTop="0px"),e||(E&&(E.style.marginTop="0px"),F&&(F.style.marginTop="0px")),!e&&E&&F){var z=a.current,V=p.current;if(!N(E,z)||!N(F,V))return;var j=E.getBoundingClientRect(),k=F.getBoundingClientRect(),G=j.top-k.top;if(Math.abs(G)>32)return;G>0&&(F.style.marginTop="".concat(G,"px"))}else if(w&&L&&A&&I){j=w.getBoundingClientRect(),k=L.getBoundingClientRect();(G=j.top-k.top)>0&&(I.style.paddingTop="".concat(G,"px"))}},re=t(function(){var e,n,t,r,l,u,o,c,d=Z.current,s=$.current;if(null!==d)if("string"==typeof d&&d.includes(i)){var v=d.split(i),a=(null===(e=R.current[v[2]])||void 0===e?void 0:e.current)||(null===(n=f.current[Number(v[2])])||void 0===n?void 0:n.current)||null,p=(null===(t=S.current[v[3]])||void 0===t?void 0:t.current)||(null===(r=h.current[Number(v[3])])||void 0===r?void 0:r.current)||null;a&&(a.style.paddingTop="0px"),p&&(p.style.paddingTop="0px")}else{a=(null===(l=f.current[d])||void 0===l?void 0:l.current)||null,p=(null===(u=h.current[null!=s?s:d])||void 0===u?void 0:u.current)||null;a&&(a.style.paddingTop="0px"),p&&(p.style.paddingTop="0px");var g=(null===(o=y.current[d])||void 0===o?void 0:o.current)||null,B=(null===(c=m.current[null!=s?s:d])||void 0===c?void 0:c.current)||null;g&&(g.style.marginTop="0px"),B&&(B.style.marginTop="0px")}C.current&&(C.current.style.height="0px"),T.current&&(T.current.style.height="0px"),b.current&&(b.current.style.height="0px"),A.current&&(A.current.style.height="0px")},[]);r(function(){Y.current=H},[H]),r(function(){Z.current=Q},[Q]);var ie=t(function(){ne(),M(!1),Y.current=!1,X.current=null,re(),U(null),Z.current=null,$.current=null,V(!1),J(!1)},[re]),le=t(function(e,n,t){var r,l,o=null===(r=null==t?void 0:t.toggleIfSame)||void 0===r||r,R=null==t?void 0:t.onReady,S=null!==(l=null==t?void 0:t.sourceSide)&&void 0!==l?l:"left";if(F(),null!=e)if(!n||c){ne();var q=H&&Q===e;H&&null!==Q&&re(),q&&o?ie():(w(new Set([e])),L([]),E.current=[],J(!0),W.current=!0,U(e),Z.current=e,M(!0),Y.current=!0,V(!1),C.current&&(C.current.style.height="0px"),T.current&&(T.current.style.height="0px"),b.current&&(b.current.style.height="0px"),A.current&&(A.current.style.height="0px"),requestAnimationFrame(function(){var n=function(){var n,t,r,l,o,b,A,w,L,E,F,N="string"==typeof e&&e.includes(i),q=null,H=null,M=null;if(c){if(N){var P=e.split(i),z="".concat(P[0]).concat(i).concat(P[1]);q=(null===(n=y.current[z])||void 0===n?void 0:n.current)||null}else q=(null===(t=f.current[e])||void 0===t?void 0:t.current)||(null===(r=B.current[e])||void 0===r?void 0:r.current)||null;H=document.getElementById("guideline-target-0"),M=H?e:null}else if(N){P=e.split(i),z="".concat(P[0]).concat(i).concat(P[1]);q=(null===(l=y.current[z])||void 0===l?void 0:l.current)||null,H=(null===(o=m.current[z])||void 0===o?void 0:o.current)||null,M=H?e:null}else if(q=(null===(b=f.current[e])||void 0===b?void 0:b.current)||(null===(A=B.current[e])||void 0===A?void 0:A.current)||null,d){var j=s[e],k=(null==j?void 0:j.refIndexes)||[];if(k.length>0){var G=k[0],O=v.findIndex(function(e){return e.selfIndex===G});-1!==O&&(H=(null===(E=h.current[O])||void 0===E?void 0:E.current)||(null===(F=x.current[O])||void 0===F?void 0:F.current)||null,M=O)}}else H=(null===(w=h.current[e])||void 0===w?void 0:w.current)||(null===(L=x.current[e])||void 0===L?void 0:L.current)||null,M=H?e:null;$.current=M;var D=a.current,K=p.current,Q=function(){te(N,e,M),V(!0),I.current&&I.current(),W.current=!1,"right"===S&&K?K.dispatchEvent(new Event("scroll")):D&&D.dispatchEvent(new Event("scroll")),J(!1),null==R||R()};if(!q||!D)return W.current=!1,J(!1),void(null==R||R());if(H&&K){if(!d){var U=0;U="right"===S?H?H.getBoundingClientRect().top:0:q?q.getBoundingClientRect().top:0;var X=g.current,Y=(null==X?void 0:X.getBoundingClientRect().top)||0,Z=X?X.scrollTop+U-Y-150:0;return X?void u(X,Z,200,Q):void Q()}var _=q.getBoundingClientRect().top-D.getBoundingClientRect().top+D.scrollTop,ee=H.getBoundingClientRect().top-K.getBoundingClientRect().top+K.scrollTop,ne=200;if("left"===S){var re=ee-(_-D.scrollTop);re<0&&C.current&&!c&&(C.current.style.height="".concat(Math.abs(re),"px")),requestAnimationFrame(function(){var e,n=K.scrollHeight-K.clientHeight;if(re<0)e=0;else{if(re>n){var t=re-n;return T.current&&!c&&(T.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){u(K,re,ne,Q)})}e=re}u(K,e,ne,Q)})}else{var ie=_-(ee-K.scrollTop);requestAnimationFrame(function(){var e,n=D.scrollHeight-D.clientHeight;if(ie<0)e=0;else{if(ie>n)return void requestAnimationFrame(function(){return u(D,n,ne,Q)});e=ie}u(D,e,ne,Q)})}}else Q()};c?setTimeout(n,100):n()}))}else N("No counterpart exists for this section.")},[Q,F,v,H,d,s,re,ie,c]);return{isSideBySide:H,setIsSideBySide:M,isArrowVisible:z,setIsArrowVisible:V,isResizing:k,setIsResizing:G,isSideBySideLoading:D,setIsSideBySideLoading:J,activeSideBySideSection:Q,setActiveSideBySideSection:U,scrollLock:W,sideBySideCacheRef:X,isSideBySideRef:Y,activeSideBySideSectionRef:Z,activeSideBySideRightSectionRef:$,sideBySideLineRef:_,highlightedClauseRefs:ee,clearClauseHighlight:ne,applyAlignmentPadding:te,resetSideBySide:ie,activateSideBySide:le}};export{o as useSideBySide};
2
2
  //# sourceMappingURL=useSideBySide.js.map
@@ -1,2 +1,2 @@
1
- import{__spreadArray as n,__assign as e}from"tslib";import{jsxs as l,jsx as i,Fragment as o}from"react/jsx-runtime";import{useMemo as t,useState as r,useRef as d,useEffect as a}from"react";import{ExternalLink as c,ChevronUp as s,ChevronDown as u}from"lucide-react";import v from"./CognitiveNonWebSearchReasoning.module.css.js";var h=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return n.filter(Boolean).join(" ")},m=function(n){return n.split(/(\*\*.*?\*\*|__.*?__)/g).map(function(n,l){return n.startsWith("**")&&n.endsWith("**")||n.startsWith("__")&&n.endsWith("__")?i("strong",e({className:v.boldText},{children:n.slice(2,-2)}),l):n})},g=function(g){var p=g.item,f=g.headerTitle;g.index;var x=g.iconsConfig,y=g.DocumentTitle,b=g.previewCallback,C=g.bodyHeight,N=g.disableMaximize,I=void 0!==N&&N,k=g.onFullscreenChange,T=g.splitterCustomStyle,H=void 0!==T&&T,L=g.themeTokens,B=g.classNames,w=g.styles,z=p.dataSource,S=p.confidence_score,A=p.trainingDataTitle,F=null==x?void 0:x.ChevronDownIcon,_=null==x?void 0:x.ChevronUpIcon,D=null==x?void 0:x.MaximizeIcon,R=null==x?void 0:x.CloseIcon,W=t(function(){var e=(z?z.replace(/\\n/g,"\n").replace(/\n+/g,"\n"):"").split(/(<highlight>[\s\S]*?<\/highlight>)/g),l=0,i=e.map(function(n){var e=n.startsWith("<highlight>"),i={text:e?n.replace(/<\/?highlight>/g,""):n,isHighlight:e,highlightIndex:e?l:-1};return e&&l++,i}),o=i.filter(function(n){return n.isHighlight}).length,t=[],r=[];return i.forEach(function(e){var l=e.text,i=e.isHighlight,o=e.highlightIndex;l.split("\n").forEach(function(e,l){l>0&&((r.length>0||t.length>0)&&t.push(n([],r,!0)),r=[]),e&&r.push({text:e,isHighlight:i,highlightIndex:o})})}),r.length>0&&t.push(n([],r,!0)),{processedLines:t.map(function(n){var e=n.map(function(n){return n.text}).join(""),l=e.match(/^(\s*)(-|\*|\d+\.)\s+(.*)$/);return{segments:n,isListItem:!!l,isHeader:!!e.match(/^(Title|Description|Training-basis):\s*(.*)$/i),indent:(null==l?void 0:l[1])||"",content:(null==l?void 0:l[3])||e}}),totalHighlights:o}},[z]),j=W.processedLines,M=W.totalHighlights,V=r(0),E=V[0],$=V[1],U=d(null),Y=d(null),q=d(null),G=d([]),J=d([]);a(function(){G.current=G.current.slice(0,M),J.current=J.current.slice(0,M)},[M]),a(function(){if(M>0){$(0);var n=setTimeout(function(){var n;null===(n=G.current[0])||void 0===n||n.scrollIntoView({behavior:"smooth",block:"center"})},50);return function(){return clearTimeout(n)}}},[M]),a(function(){return function(){var n;(null===(n=q.current)||void 0===n?void 0:n.open)&&(null==k||k(!1))}},[k]);var K=function(n,e){setTimeout(function(){var l=e?J.current[n]:G.current[n];null==l||l.scrollIntoView({behavior:"smooth",block:"center"})},50)},O=function(n){if(void 0===n&&(n=!1),M){var e=E>0?E-1:M-1;$(e),K(e,n)}},P=function(n){if(void 0===n&&(n=!1),M){var e=E<M-1?E+1:0;$(e),K(e,n)}},Q=function(n){var o=n?J:G,t=0;return j.map(function(n,r){n.isHeader&&(t=0),n.isListItem&&(t+=1);var d=function(){return n.segments.map(function(l,t){var r=l.isHighlight&&l.highlightIndex===E,d=l.text;return n.isListItem&&0===t&&(d=l.text.replace(/^(\s*)(-|\*|\d+\.)\s+/,"")),l.isHighlight?i("span",e({ref:function(n){n&&(o.current[l.highlightIndex]=n)},className:h(v.highlight,r?v.highlightActive:void 0,null==B?void 0:B.highlight,r?null==B?void 0:B.highlightActive:void 0),style:r?e(e({},null==w?void 0:w.highlight),null==w?void 0:w.highlightActive):null==w?void 0:w.highlight},{children:m(d)}),t):i("span",{children:m(d)},t)})};return n.isHeader?i("span",e({className:h(v.headerLine,null==B?void 0:B.headerLine),style:null==w?void 0:w.headerLine},{children:d()}),r):n.isListItem?l("span",e({className:h(v.listItemLine,null==B?void 0:B.listItemLine),style:e({paddingLeft:n.indent?"1rem":"0"},null==w?void 0:w.listItemLine)},{children:[l("span",e({className:h(v.listCounter,null==B?void 0:B.listCounter),style:null==w?void 0:w.listCounter},{children:[t,"."]})),i("span",{children:d()})]}),r):i("span",e({className:h(v.blockLine,null==B?void 0:B.blockLine),style:null==w?void 0:w.blockLine},{children:d()}),r)})},X=function(n){return M>1?l("div",e({className:h(n?v.modalNavContainer:v.navigationContainer,n?null==B?void 0:B.modalNavContainer:null==B?void 0:B.navigationContainer),style:n?null==w?void 0:w.modalNavContainer:null==w?void 0:w.navigationContainer},{children:[_&&i("button",e({onClick:function(){return O(n)},className:h(n?v.modalNavButton:v.navButton,null==B?void 0:B.navButton),style:null==w?void 0:w.navButton},{children:i(_,{className:h(v.navIcon,null==B?void 0:B.navIcon),style:null==w?void 0:w.navIcon})})),l("span",e({className:h(v.navCounter,null==B?void 0:B.navCounter),style:null==w?void 0:w.navCounter},{children:[E+1,"/",M]})),F&&i("button",e({onClick:function(){return P(n)},className:h(n?v.modalNavButton:v.navButton,null==B?void 0:B.navButton),style:null==w?void 0:w.navButton},{children:i(F,{className:h(v.navIcon,null==B?void 0:B.navIcon),style:null==w?void 0:w.navIcon})}))]})):null},Z=null!=S?l("span",e({className:h(v.confidenceBadge,null==B?void 0:B.confidenceBadge),style:null==w?void 0:w.confidenceBadge},{children:[i("span",e({className:v.confidenceStar},{children:"✦"})),l("span",e({className:v.confidenceScore},{children:[S,"%"]}))]})):null,nn=H?{backgroundColor:"white",padding:"1rem 1.5rem"}:void 0,en=l(o,{children:[A&&i("div",e({className:h(v.footer,null==B?void 0:B.footer),style:e(e({},nn),null==w?void 0:w.footer)},{children:i("span",e({className:h(v.trainingTitle,null==B?void 0:B.trainingTitle),style:null==w?void 0:w.trainingTitle},{children:A}))})),y&&i("div",e({className:h(v.modalFooterSource,null==B?void 0:B.modalFooterSource),style:e(e({},nn),null==w?void 0:w.modalFooterSource)},{children:l("button",e({type:"button",onClick:function(){return null==b?void 0:b()},className:h(v.trainingTitleLink,null==B?void 0:B.trainingTitleLink),style:null==w?void 0:w.trainingTitleLink},{children:[y,i(c,{size:16,color:"#2563eb"})]}))}))]});return l(o,{children:[l("div",e({className:h(v.expandedContainer,null==B?void 0:B.expandedContainer),style:e(e(e(e({},L),C?{height:"".concat(C),display:"flex",flexDirection:"column"}:void 0),H?{border:"none",borderRadius:0,marginLeft:"0px",marginTop:"0px"}:void 0),null==w?void 0:w.expandedContainer)},{children:[l("div",e({className:h(v.expandedHeader,null==B?void 0:B.expandedHeader),style:e(e({},H?{backgroundColor:"white",padding:"0.5rem 1.5rem"}:void 0),null==w?void 0:w.expandedHeader)},{children:[i("span",e({className:h(v.headerTitle,null==B?void 0:B.headerTitle),style:null==w?void 0:w.headerTitle},{children:f})),l("div",e({className:h(v.headerActions,null==B?void 0:B.headerActions),style:null==w?void 0:w.headerActions},{children:[H?M>1&&l(o,{children:[l("span",e({style:{fontSize:"12px",color:"#888"}},{children:[E+1," / ",M]})),i("button",e({onClick:function(){return O(!0)},disabled:E<=0,style:{padding:"2px 4px",cursor:E<=0?"not-allowed":"pointer",opacity:E<=0?.4:1,border:"1px solid #ddd",borderRadius:"3px",background:"white",display:"flex",alignItems:"center"}},{children:i(s,{size:14,color:"#64748b"})})),i("button",e({onClick:function(){return P(!0)},disabled:E>=M-1,style:{padding:"2px 4px",cursor:E>=M-1?"not-allowed":"pointer",opacity:E>=M-1?.4:1,border:"1px solid #ddd",borderRadius:"3px",background:"white",display:"flex",alignItems:"center"}},{children:i(u,{size:14,color:"#64748b"})}))]}):X(!1),Z,!I&&D&&i("button",e({onClick:function(){var n;null==k||k(!0),null===(n=q.current)||void 0===n||n.showModal()},className:h(v.maximizeButton,null==B?void 0:B.maximizeButton),style:null==w?void 0:w.maximizeButton,title:"View fullscreen"},{children:i(D,{className:v.maximizeIcon})}))]}))]})),i("div",e({ref:U,className:h(v.contentArea,null==B?void 0:B.contentArea),style:e(e(e({},C?{flex:1,maxHeight:"300px",overflowY:"scroll",minHeight:0}:void 0),H?{padding:"1rem 1.5rem"}:void 0),null==w?void 0:w.contentArea)},{children:i("div",e({className:h(v.contentInner,null==B?void 0:B.contentInner),style:null==w?void 0:w.contentInner},{children:Q(!1)}))})),en]})),!I&&i("dialog",e({ref:q,className:v.modalDialog,onClose:function(){return null==k?void 0:k(!1)},onClick:function(n){var e;n.target===q.current&&(null===(e=q.current)||void 0===e||e.close())}},{children:l("div",e({className:h(v.modalContainer,null==B?void 0:B.modalContainer),style:null==w?void 0:w.modalContainer},{children:[l("div",e({className:h(v.modalHeader,null==B?void 0:B.modalHeader),style:null==w?void 0:w.modalHeader},{children:[i("span",e({className:h(v.modalHeaderTitle,null==B?void 0:B.modalHeaderTitle),style:null==w?void 0:w.modalHeaderTitle},{children:f})),l("div",e({className:h(v.modalHeaderActions,null==B?void 0:B.modalHeaderActions),style:null==w?void 0:w.modalHeaderActions},{children:[H?M>1&&l(o,{children:[l("span",e({style:{fontSize:"12px",color:"#888"}},{children:[E+1," / ",M]})),i("button",e({onClick:function(){return O(!0)},disabled:E<=0,style:{padding:"2px 4px",cursor:E<=0?"not-allowed":"pointer",opacity:E<=0?.4:1,border:"1px solid #ddd",borderRadius:"3px",background:"white",display:"flex",alignItems:"center"}},{children:i(s,{size:14,color:"#64748b"})})),i("button",e({onClick:function(){return P(!0)},disabled:E>=M-1,style:{padding:"2px 4px",cursor:E>=M-1?"not-allowed":"pointer",opacity:E>=M-1?.4:1,border:"1px solid #ddd",borderRadius:"3px",background:"white",display:"flex",alignItems:"center"}},{children:i(u,{size:14,color:"#64748b"})}))]}):X(!0),Z,R&&i("button",e({onClick:function(){var n;return null===(n=q.current)||void 0===n?void 0:n.close()},className:h(v.closeButton,null==B?void 0:B.closeButton),style:null==w?void 0:w.closeButton,title:"Close"},{children:i(R,{className:h(v.closeIcon,null==B?void 0:B.closeIcon),style:null==w?void 0:w.closeIcon})}))]}))]})),i("div",e({ref:Y,className:h(v.modalContent,null==B?void 0:B.modalContent),style:null==w?void 0:w.modalContent},{children:i("div",e({className:h(v.modalContentInner,null==B?void 0:B.modalContentInner),style:null==w?void 0:w.modalContentInner},{children:Q(!0)}))})),A&&i("div",e({className:h(v.modalFooter,null==B?void 0:B.modalFooter),style:null==w?void 0:w.modalFooter},{children:i("span",e({className:h(v.trainingTitle,null==B?void 0:B.trainingTitle),style:null==w?void 0:w.trainingTitle},{children:A}))})),y&&i("div",e({className:h(v.modalFooterSource,null==B?void 0:B.modalFooterSource),style:null==w?void 0:w.modalFooterSource},{children:l("button",e({type:"button",onClick:function(){var n;null==b||b(),null===(n=q.current)||void 0===n||n.close()},className:h(v.trainingTitleLink,null==B?void 0:B.trainingTitleLink),style:null==w?void 0:w.trainingTitleLink},{children:[y,i(c,{size:16,color:"#2563eb"})]}))}))]}))}))]})};export{g as default};
1
+ import{__spreadArray as n,__assign as e}from"tslib";import{jsxs as l,jsx as i,Fragment as o}from"react/jsx-runtime";import{useMemo as t,useState as r,useRef as d,useEffect as a}from"react";import{ExternalLink as s,ChevronUp as c,ChevronDown as u}from"lucide-react";import v from"./CognitiveNonWebSearchReasoning.module.css.js";var h=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return n.filter(Boolean).join(" ")},m=function(n){return n.split(/(\*\*.*?\*\*|__.*?__)/g).map(function(n,l){return n.startsWith("**")&&n.endsWith("**")||n.startsWith("__")&&n.endsWith("__")?i("strong",e({className:v.boldText},{children:n.slice(2,-2)}),l):n})},g=function(g){var p=g.item,f=g.headerTitle;g.index;var x=g.iconsConfig,y=g.DocumentTitle,b=g.previewCallback,N=g.bodyHeight,C=g.disableMaximize,I=void 0!==C&&C,k=g.splitterCustomStyle,T=void 0!==k&&k,H=g.themeTokens,L=g.classNames,B=g.styles,w=p.dataSource,z=p.confidence_score,S=p.trainingDataTitle,A=null==x?void 0:x.ChevronDownIcon,F=null==x?void 0:x.ChevronUpIcon,_=null==x?void 0:x.MaximizeIcon,D=null==x?void 0:x.CloseIcon,R=t(function(){var e=(w?w.replace(/\\n/g,"\n").replace(/\n+/g,"\n"):"").split(/(<highlight>[\s\S]*?<\/highlight>)/g),l=0,i=e.map(function(n){var e=n.startsWith("<highlight>"),i={text:e?n.replace(/<\/?highlight>/g,""):n,isHighlight:e,highlightIndex:e?l:-1};return e&&l++,i}),o=i.filter(function(n){return n.isHighlight}).length,t=[],r=[];return i.forEach(function(e){var l=e.text,i=e.isHighlight,o=e.highlightIndex;l.split("\n").forEach(function(e,l){l>0&&((r.length>0||t.length>0)&&t.push(n([],r,!0)),r=[]),e&&r.push({text:e,isHighlight:i,highlightIndex:o})})}),r.length>0&&t.push(n([],r,!0)),{processedLines:t.map(function(n){var e=n.map(function(n){return n.text}).join(""),l=e.match(/^(\s*)(-|\*|\d+\.)\s+(.*)$/);return{segments:n,isListItem:!!l,isHeader:!!e.match(/^(Title|Description|Training-basis):\s*(.*)$/i),indent:(null==l?void 0:l[1])||"",content:(null==l?void 0:l[3])||e}}),totalHighlights:o}},[w]),W=R.processedLines,j=R.totalHighlights,M=r(0),V=M[0],E=M[1],$=d(null),U=d(null),Y=d(null),q=d([]),G=d([]);a(function(){q.current=q.current.slice(0,j),G.current=G.current.slice(0,j)},[j]),a(function(){if(j>0){E(0);var n=setTimeout(function(){var n;null===(n=q.current[0])||void 0===n||n.scrollIntoView({behavior:"smooth",block:"center"})},50);return function(){return clearTimeout(n)}}},[j]);var J=function(n,e){setTimeout(function(){var l=e?G.current[n]:q.current[n];null==l||l.scrollIntoView({behavior:"smooth",block:"center"})},50)},K=function(n){if(void 0===n&&(n=!1),j){var e=V>0?V-1:j-1;E(e),J(e,n)}},O=function(n){if(void 0===n&&(n=!1),j){var e=V<j-1?V+1:0;E(e),J(e,n)}},P=function(n){var o=n?G:q,t=0;return W.map(function(n,r){n.isHeader&&(t=0),n.isListItem&&(t+=1);var d=function(){return n.segments.map(function(l,t){var r=l.isHighlight&&l.highlightIndex===V,d=l.text;return n.isListItem&&0===t&&(d=l.text.replace(/^(\s*)(-|\*|\d+\.)\s+/,"")),l.isHighlight?i("span",e({ref:function(n){n&&(o.current[l.highlightIndex]=n)},className:h(v.highlight,r?v.highlightActive:void 0,null==L?void 0:L.highlight,r?null==L?void 0:L.highlightActive:void 0),style:r?e(e({},null==B?void 0:B.highlight),null==B?void 0:B.highlightActive):null==B?void 0:B.highlight},{children:m(d)}),t):i("span",{children:m(d)},t)})};return n.isHeader?i("span",e({className:h(v.headerLine,null==L?void 0:L.headerLine),style:null==B?void 0:B.headerLine},{children:d()}),r):n.isListItem?l("span",e({className:h(v.listItemLine,null==L?void 0:L.listItemLine),style:e({paddingLeft:n.indent?"1rem":"0"},null==B?void 0:B.listItemLine)},{children:[l("span",e({className:h(v.listCounter,null==L?void 0:L.listCounter),style:null==B?void 0:B.listCounter},{children:[t,"."]})),i("span",{children:d()})]}),r):i("span",e({className:h(v.blockLine,null==L?void 0:L.blockLine),style:null==B?void 0:B.blockLine},{children:d()}),r)})},Q=function(n){return j>1?l("div",e({className:h(n?v.modalNavContainer:v.navigationContainer,n?null==L?void 0:L.modalNavContainer:null==L?void 0:L.navigationContainer),style:n?null==B?void 0:B.modalNavContainer:null==B?void 0:B.navigationContainer},{children:[F&&i("button",e({onClick:function(){return K(n)},className:h(n?v.modalNavButton:v.navButton,null==L?void 0:L.navButton),style:null==B?void 0:B.navButton},{children:i(F,{className:h(v.navIcon,null==L?void 0:L.navIcon),style:null==B?void 0:B.navIcon})})),l("span",e({className:h(v.navCounter,null==L?void 0:L.navCounter),style:null==B?void 0:B.navCounter},{children:[V+1,"/",j]})),A&&i("button",e({onClick:function(){return O(n)},className:h(n?v.modalNavButton:v.navButton,null==L?void 0:L.navButton),style:null==B?void 0:B.navButton},{children:i(A,{className:h(v.navIcon,null==L?void 0:L.navIcon),style:null==B?void 0:B.navIcon})}))]})):null},X=null!=z?l("span",e({className:h(v.confidenceBadge,null==L?void 0:L.confidenceBadge),style:null==B?void 0:B.confidenceBadge},{children:[i("span",e({className:v.confidenceStar},{children:"✦"})),l("span",e({className:v.confidenceScore},{children:[z,"%"]}))]})):null,Z=T?{backgroundColor:"white",padding:"1rem 1.5rem"}:void 0,nn=l(o,{children:[S&&i("div",e({className:h(v.footer,null==L?void 0:L.footer),style:e(e({},Z),null==B?void 0:B.footer)},{children:i("span",e({className:h(v.trainingTitle,null==L?void 0:L.trainingTitle),style:null==B?void 0:B.trainingTitle},{children:S}))})),y&&i("div",e({className:h(v.modalFooterSource,null==L?void 0:L.modalFooterSource),style:e(e({},Z),null==B?void 0:B.modalFooterSource)},{children:l("button",e({type:"button",onClick:function(){return null==b?void 0:b()},className:h(v.trainingTitleLink,null==L?void 0:L.trainingTitleLink),style:null==B?void 0:B.trainingTitleLink},{children:[y,i(s,{size:16,color:"#2563eb"})]}))}))]});return l(o,{children:[l("div",e({className:h(v.expandedContainer,null==L?void 0:L.expandedContainer),style:e(e(e(e({},H),N?{height:"".concat(N),display:"flex",flexDirection:"column"}:void 0),T?{border:"none",borderRadius:0,marginLeft:"0px",marginTop:"0px"}:void 0),null==B?void 0:B.expandedContainer)},{children:[l("div",e({className:h(v.expandedHeader,null==L?void 0:L.expandedHeader),style:e(e({},T?{backgroundColor:"white",padding:"0.5rem 1.5rem"}:void 0),null==B?void 0:B.expandedHeader)},{children:[i("span",e({className:h(v.headerTitle,null==L?void 0:L.headerTitle),style:null==B?void 0:B.headerTitle},{children:f})),l("div",e({className:h(v.headerActions,null==L?void 0:L.headerActions),style:null==B?void 0:B.headerActions},{children:[T?j>1&&l(o,{children:[l("span",e({style:{fontSize:"12px",color:"#888"}},{children:[V+1," / ",j]})),i("button",e({onClick:function(){return K(!0)},disabled:V<=0,style:{padding:"2px 4px",cursor:V<=0?"not-allowed":"pointer",opacity:V<=0?.4:1,border:"1px solid #ddd",borderRadius:"3px",background:"white",display:"flex",alignItems:"center"}},{children:i(c,{size:14,color:"#64748b"})})),i("button",e({onClick:function(){return O(!0)},disabled:V>=j-1,style:{padding:"2px 4px",cursor:V>=j-1?"not-allowed":"pointer",opacity:V>=j-1?.4:1,border:"1px solid #ddd",borderRadius:"3px",background:"white",display:"flex",alignItems:"center"}},{children:i(u,{size:14,color:"#64748b"})}))]}):Q(!1),X,!I&&_&&i("button",e({onClick:function(){var n;return null===(n=Y.current)||void 0===n?void 0:n.showModal()},className:h(v.maximizeButton,null==L?void 0:L.maximizeButton),style:null==B?void 0:B.maximizeButton,title:"View fullscreen"},{children:i(_,{className:v.maximizeIcon})}))]}))]})),i("div",e({ref:$,className:h(v.contentArea,null==L?void 0:L.contentArea),style:e(e(e({},N?{flex:1,maxHeight:"300px",overflowY:"scroll",minHeight:0}:void 0),T?{padding:"1rem 1.5rem"}:void 0),null==B?void 0:B.contentArea)},{children:i("div",e({className:h(v.contentInner,null==L?void 0:L.contentInner),style:null==B?void 0:B.contentInner},{children:P(!1)}))})),nn]})),!I&&i("dialog",e({ref:Y,className:v.modalDialog,onClick:function(n){var e;n.target===Y.current&&(null===(e=Y.current)||void 0===e||e.close())}},{children:l("div",e({className:h(v.modalContainer,null==L?void 0:L.modalContainer),style:null==B?void 0:B.modalContainer},{children:[l("div",e({className:h(v.modalHeader,null==L?void 0:L.modalHeader),style:null==B?void 0:B.modalHeader},{children:[i("span",e({className:h(v.modalHeaderTitle,null==L?void 0:L.modalHeaderTitle),style:null==B?void 0:B.modalHeaderTitle},{children:f})),l("div",e({className:h(v.modalHeaderActions,null==L?void 0:L.modalHeaderActions),style:null==B?void 0:B.modalHeaderActions},{children:[T?j>1&&l(o,{children:[l("span",e({style:{fontSize:"12px",color:"#888"}},{children:[V+1," / ",j]})),i("button",e({onClick:function(){return K(!0)},disabled:V<=0,style:{padding:"2px 4px",cursor:V<=0?"not-allowed":"pointer",opacity:V<=0?.4:1,border:"1px solid #ddd",borderRadius:"3px",background:"white",display:"flex",alignItems:"center"}},{children:i(c,{size:14,color:"#64748b"})})),i("button",e({onClick:function(){return O(!0)},disabled:V>=j-1,style:{padding:"2px 4px",cursor:V>=j-1?"not-allowed":"pointer",opacity:V>=j-1?.4:1,border:"1px solid #ddd",borderRadius:"3px",background:"white",display:"flex",alignItems:"center"}},{children:i(u,{size:14,color:"#64748b"})}))]}):Q(!0),X,D&&i("button",e({onClick:function(){var n;return null===(n=Y.current)||void 0===n?void 0:n.close()},className:h(v.closeButton,null==L?void 0:L.closeButton),style:null==B?void 0:B.closeButton,title:"Close"},{children:i(D,{className:h(v.closeIcon,null==L?void 0:L.closeIcon),style:null==B?void 0:B.closeIcon})}))]}))]})),i("div",e({ref:U,className:h(v.modalContent,null==L?void 0:L.modalContent),style:null==B?void 0:B.modalContent},{children:i("div",e({className:h(v.modalContentInner,null==L?void 0:L.modalContentInner),style:null==B?void 0:B.modalContentInner},{children:P(!0)}))})),S&&i("div",e({className:h(v.modalFooter,null==L?void 0:L.modalFooter),style:null==B?void 0:B.modalFooter},{children:i("span",e({className:h(v.trainingTitle,null==L?void 0:L.trainingTitle),style:null==B?void 0:B.trainingTitle},{children:S}))})),y&&i("div",e({className:h(v.modalFooterSource,null==L?void 0:L.modalFooterSource),style:null==B?void 0:B.modalFooterSource},{children:l("button",e({type:"button",onClick:function(){var n;null==b||b(),null===(n=Y.current)||void 0===n||n.close()},className:h(v.trainingTitleLink,null==L?void 0:L.trainingTitleLink),style:null==B?void 0:B.trainingTitleLink},{children:[y,i(s,{size:16,color:"#2563eb"})]}))}))]}))}))]})};export{g as default};
2
2
  //# sourceMappingURL=CognitiveInternalgptCoreComponent.js.map