@viswa-test/test-citation 0.0.322 → 0.0.324

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 (94) hide show
  1. package/README.md +4 -0
  2. package/dist/cjs/features/ChatCitation/InternalChatCitationRenderer.js +1 -1
  3. package/dist/cjs/features/CitationRenderer/MarkdownRenderer.module.css.js +1 -1
  4. package/dist/cjs/features/CodeCitation/CodeCitation.js +1 -1
  5. package/dist/cjs/features/CodeCitation/_components/CodeCitationPopup.js +1 -1
  6. package/dist/cjs/features/CodeCitation/_components/RepoAndBranchTag.js +2 -0
  7. package/dist/cjs/features/CodeCitation/_components/RepoAndBranchTag.js.map +1 -0
  8. package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js +1 -1
  9. package/dist/cjs/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js +1 -1
  10. package/dist/cjs/features/CognitiveCompare/Guidelines/components/WebGptPanel.js +1 -1
  11. package/dist/cjs/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js +1 -1
  12. package/dist/cjs/features/CognitiveCompare/Guidelines/utils/resolveGuidelineSelection.js +1 -1
  13. package/dist/cjs/features/CognitiveCompare/hooks/useCompareData.js +1 -1
  14. package/dist/cjs/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
  15. package/dist/cjs/features/CognitiveCompare/hooks/useSideBySide.js +1 -1
  16. package/dist/cjs/features/PdfViewer/PdfViewer.js +1 -1
  17. package/dist/cjs/features/SPBAnalysisPanel/Cognitivereasoningpanel.js +1 -1
  18. package/dist/cjs/features/SPBAnalysisPanel/DependencyGraph.js +1 -1
  19. package/dist/cjs/features/SPBAnalysisPanel/Markdownrenderer.js +1 -1
  20. package/dist/cjs/features/SPBAnalysisPanel/Spbanalysispanel.js +1 -1
  21. package/dist/cjs/features/SegmentReviewComponents/BoundaryCard.js +1 -1
  22. package/dist/cjs/features/SegmentReviewComponents/SegmentReviewPdfWrapper.js +1 -1
  23. package/dist/cjs/features/SegmentReviewComponents/helper.js +1 -1
  24. package/dist/cjs/index.js +1 -1
  25. package/dist/features/ChatCitation/InternalChatCitationRenderer.js +1 -1
  26. package/dist/features/CitationRenderer/MarkdownRenderer.module.css.js +1 -1
  27. package/dist/features/CodeCitation/CodeCitation.js +1 -1
  28. package/dist/features/CodeCitation/_components/CodeCitationPopup.js +1 -1
  29. package/dist/features/CodeCitation/_components/RepoAndBranchTag.js +2 -0
  30. package/dist/features/CodeCitation/_components/RepoAndBranchTag.js.map +1 -0
  31. package/dist/features/CognitiveCompare/CognitiveCompare.js +1 -1
  32. package/dist/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js +1 -1
  33. package/dist/features/CognitiveCompare/Guidelines/components/WebGptPanel.js +1 -1
  34. package/dist/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js +1 -1
  35. package/dist/features/CognitiveCompare/Guidelines/utils/resolveGuidelineSelection.js +1 -1
  36. package/dist/features/CognitiveCompare/hooks/useCompareData.js +1 -1
  37. package/dist/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
  38. package/dist/features/CognitiveCompare/hooks/useSideBySide.js +1 -1
  39. package/dist/features/PdfViewer/PdfViewer.js +1 -1
  40. package/dist/features/SPBAnalysisPanel/Cognitivereasoningpanel.js +1 -1
  41. package/dist/features/SPBAnalysisPanel/DependencyGraph.js +1 -1
  42. package/dist/features/SPBAnalysisPanel/Markdownrenderer.js +1 -1
  43. package/dist/features/SPBAnalysisPanel/Spbanalysispanel.js +1 -1
  44. package/dist/features/SegmentReviewComponents/BoundaryCard.js +1 -1
  45. package/dist/features/SegmentReviewComponents/SegmentReviewPdfWrapper.js +1 -1
  46. package/dist/features/SegmentReviewComponents/helper.js +1 -1
  47. package/dist/index.js +1 -1
  48. package/dist/types/src/CodeCitationTest.d.ts.map +1 -1
  49. package/dist/types/src/features/ChatCitation/InternalChatCitationRenderer.d.ts.map +1 -1
  50. package/dist/types/src/features/CodeCitation/CodeCitation.d.ts +2 -0
  51. package/dist/types/src/features/CodeCitation/CodeCitation.d.ts.map +1 -1
  52. package/dist/types/src/features/CodeCitation/_components/CodeCitationPopup.d.ts +3 -0
  53. package/dist/types/src/features/CodeCitation/_components/CodeCitationPopup.d.ts.map +1 -1
  54. package/dist/types/src/features/CodeCitation/_components/RepoAndBranchTag.d.ts +8 -0
  55. package/dist/types/src/features/CodeCitation/_components/RepoAndBranchTag.d.ts.map +1 -0
  56. package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts +1 -1
  57. package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts.map +1 -1
  58. package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts +1 -1
  59. package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts.map +1 -1
  60. package/dist/types/src/features/CognitiveCompare/Guidelines/components/GuidelinePanel.d.ts.map +1 -1
  61. package/dist/types/src/features/CognitiveCompare/Guidelines/components/WebGptPanel.d.ts.map +1 -1
  62. package/dist/types/src/features/CognitiveCompare/Guidelines/constants/guidelines.mockData.d.ts +802 -14744
  63. package/dist/types/src/features/CognitiveCompare/Guidelines/constants/guidelines.mockData.d.ts.map +1 -1
  64. package/dist/types/src/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.d.ts +1 -14
  65. package/dist/types/src/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.d.ts.map +1 -1
  66. package/dist/types/src/features/CognitiveCompare/Guidelines/utils/resolveGuidelineSelection.d.ts.map +1 -1
  67. package/dist/types/src/features/CognitiveCompare/hooks/useCompareData.d.ts +1 -1
  68. package/dist/types/src/features/CognitiveCompare/hooks/useCompareData.d.ts.map +1 -1
  69. package/dist/types/src/features/CognitiveCompare/hooks/useLinesCalculator.d.ts.map +1 -1
  70. package/dist/types/src/features/CognitiveCompare/hooks/useSideBySide.d.ts.map +1 -1
  71. package/dist/types/src/features/PdfViewer/PdfViewer.d.ts.map +1 -1
  72. package/dist/types/src/features/SPBAnalysisPanel/Cognitivereasoningpanel.d.ts +31 -1
  73. package/dist/types/src/features/SPBAnalysisPanel/Cognitivereasoningpanel.d.ts.map +1 -1
  74. package/dist/types/src/features/SPBAnalysisPanel/DependencyGraph.d.ts +25 -0
  75. package/dist/types/src/features/SPBAnalysisPanel/DependencyGraph.d.ts.map +1 -1
  76. package/dist/types/src/features/SPBAnalysisPanel/Markdownrenderer.d.ts +3 -1
  77. package/dist/types/src/features/SPBAnalysisPanel/Markdownrenderer.d.ts.map +1 -1
  78. package/dist/types/src/features/SPBAnalysisPanel/Spbanalysispanel.d.ts +7 -1
  79. package/dist/types/src/features/SPBAnalysisPanel/Spbanalysispanel.d.ts.map +1 -1
  80. package/dist/types/src/features/SegmentReviewComponents/BoundaryCard.d.ts +4 -2
  81. package/dist/types/src/features/SegmentReviewComponents/BoundaryCard.d.ts.map +1 -1
  82. package/dist/types/src/features/SegmentReviewComponents/SegmentReviewPdfWrapper.d.ts.map +1 -1
  83. package/dist/types/src/features/SegmentReviewComponents/SegmentReviewRedirectionTest.d.ts.map +1 -1
  84. package/dist/types/src/features/SegmentReviewComponents/helper.d.ts +25 -0
  85. package/dist/types/src/features/SegmentReviewComponents/helper.d.ts.map +1 -1
  86. package/dist/types/src/features/SegmentReviewComponents/index.d.ts +4 -7
  87. package/dist/types/src/features/SegmentReviewComponents/index.d.ts.map +1 -1
  88. package/dist/types/src/features/SegmentReviewComponents/reviewStepAdapters.d.ts +1 -0
  89. package/dist/types/src/features/SegmentReviewComponents/reviewStepAdapters.d.ts.map +1 -1
  90. package/dist/types/src/features/SegmentReviewComponents/segmentReviewEdgeCases.test.d.ts +2 -0
  91. package/dist/types/src/features/SegmentReviewComponents/segmentReviewEdgeCases.test.d.ts.map +1 -0
  92. package/dist/types/src/index.d.ts +2 -2
  93. package/dist/types/src/index.d.ts.map +1 -1
  94. package/package.json +2 -2
@@ -1,2 +1,2 @@
1
- import{__assign as i}from"tslib";import{jsxs as e,jsx as t}from"react/jsx-runtime";import{Close as l}from"@mui/icons-material";import o from"./CodeCitationsStats.js";import{returnCitationTitle as a,returnCodeTitle as r}from"../../../utils/codeCitations.utils.js";import n from"@mui/material/Dialog";import s from"@mui/material/IconButton";import d from"@mui/material/DialogContent";import f from"@mui/material/DialogTitle";var h=function(h){var g=h.open,c=h.onClose,p=h.title,u=h.customStyles,y=h.editorChildren,x=h.fileDetails,b=h.setHighlightIndexes,S=h.highlightCodeStatsLine,v=h.setHighlightCodeStatsLine,C=h.highlightCodeStatsVariable,k=h.setHighlightCodeStatsVariable,D=h.filepath,w=h.datasource,H=void 0===w?"codebase":w;return e(n,i({open:g,onClose:c,maxWidth:"xl",fullWidth:!0,PaperProps:{style:i({},null==u?void 0:u.popupContainer)}},{children:[e(f,i({style:(null==u?void 0:u.popupTitleContainer)||{fontFamily:"Plus Jakarta Sans, sans-serif",position:"relative",textAlign:"left",fontWeight:"bold"}},{children:[e("div",i({style:{display:"flex",flexDirection:"column"}},{children:[t("span",i({style:{fontWeight:"bold",fontFamily:"Plus Jakarta Sans, sans-serif"}},{children:p})),e("div",i({style:{display:"flex",flexDirection:"row",gap:"5px",fontSize:"0.875rem",color:"#666",marginTop:"0.25rem"}},{children:[t("span",i({style:{fontFamily:"Plus Jakarta Sans, sans-serif"}},{children:"File path: "})),e("span",i({style:{fontFamily:"Plus Jakarta Sans, sans-serif"}},{children:[" ",a(D,H)]}))]}))]})),t(s,i({edge:"end",onClick:c,"aria-label":"close",style:{position:"absolute",top:5,right:16},size:"large"},{children:t(l,{})}))]})),e(d,i({style:i(i({},m.body),null==u?void 0:u.body)},{children:[t("div",i({style:(null==u?void 0:u.leftSection)||m.leftSection},{children:t(o,{datasource:H,fileDetails:x,setHighlightIndexes:b,highlightCodeStatsLine:S,setHighlightCodeStatsLine:v,highlightCodeStatsVariable:C,setHighlightCodeStatsVariable:k})})),e("div",i({style:m.rightSection},{children:[t("div",i({style:{minHeight:"4vh",fontWeight:"700",fontFamily:"Plus Jakarta Sans, sans-serif"}},{children:r(H)})),t("div",i({style:{width:"100%",height:"100%"}},{children:y}))]}))]}))]}))},m={body:{backgroundColor:"#fff",display:"flex",gap:"1rem",flexDirection:"row",paddingTop:"1rem",paddingRight:"1rem",paddingLeft:"1rem",minHeight:"60vh",maxWidth:"100%",overflow:"hidden"},leftSection:{display:"flex",flexDirection:"column",width:"50%",background:"#f6f6f6",borderRadius:"0.375rem",fontFamily:"Plus Jakarta Sans, sans-serif",overflowY:"scroll"},topLeft:{height:"50%",background:"#f9f9f9",display:"flex",flexDirection:"column",overflowY:"auto",borderRadius:"0.375rem"},bottomLeft:{height:"50%",background:"#f9f9f9",display:"flex",flexDirection:"column",overflowY:"auto",borderRadius:"0.375rem"},rightSection:{width:"50%",minHeight:"70vh",paddingLeft:"10px",backgroundColor:"#fff",zIndex:30}};export{h as default};
1
+ import{__assign as i}from"tslib";import{jsxs as e,jsx as t}from"react/jsx-runtime";import{Close as o}from"@mui/icons-material";import l from"./CodeCitationsStats.js";import{returnCitationTitle as a,returnCodeTitle as r}from"../../../utils/codeCitations.utils.js";import n from"@mui/material/Dialog";import s from"@mui/material/IconButton";import d from"@mui/material/DialogContent";import f from"@mui/material/DialogTitle";import{RepoAndBranchTag as h}from"./RepoAndBranchTag.js";var m=function(m){var p=m.open,c=m.onClose,u=m.title,y=m.customStyles,b=m.editorChildren,x=m.fileDetails,S=m.setHighlightIndexes,v=m.highlightCodeStatsLine,C=m.setHighlightCodeStatsLine,k=m.highlightCodeStatsVariable,D=m.setHighlightCodeStatsVariable,w=m.filepath,H=m.datasource,L=void 0===H?"codebase":H,P=m.repoName,F=m.branchName,J=m.repoUrl;return e(n,i({open:p,onClose:c,maxWidth:"xl",fullWidth:!0,PaperProps:{style:i({},null==y?void 0:y.popupContainer)}},{children:[e(f,i({style:(null==y?void 0:y.popupTitleContainer)||{fontFamily:"Plus Jakarta Sans, sans-serif",position:"relative",textAlign:"left",fontWeight:"bold"}},{children:[e("div",i({style:{display:"flex",flexDirection:"column"}},{children:[t("span",i({style:{fontWeight:"bold",fontFamily:"Plus Jakarta Sans, sans-serif"}},{children:u})),P&&F&&J&&t(h,{repoName:P,branchName:F,repoUrl:J}),e("div",i({style:{display:"flex",flexDirection:"row",gap:"5px",fontSize:"0.875rem",color:"#666",marginTop:"0.25rem"}},{children:[t("span",i({style:{fontFamily:"Plus Jakarta Sans, sans-serif"}},{children:"File path: "})),e("span",i({style:{fontFamily:"Plus Jakarta Sans, sans-serif"}},{children:[" ",a(w,L)]}))]}))]})),t(s,i({edge:"end",onClick:c,"aria-label":"close",style:{position:"absolute",top:5,right:16},size:"large"},{children:t(o,{})}))]})),e(d,i({style:i(i({},g.body),null==y?void 0:y.body)},{children:[t("div",i({style:(null==y?void 0:y.leftSection)||g.leftSection},{children:t(l,{datasource:L,fileDetails:x,setHighlightIndexes:S,highlightCodeStatsLine:v,setHighlightCodeStatsLine:C,highlightCodeStatsVariable:k,setHighlightCodeStatsVariable:D})})),e("div",i({style:g.rightSection},{children:[t("div",i({style:{minHeight:"4vh",fontWeight:"700",fontFamily:"Plus Jakarta Sans, sans-serif"}},{children:r(L)})),t("div",i({style:{width:"100%",height:"100%"}},{children:b}))]}))]}))]}))},g={body:{backgroundColor:"#fff",display:"flex",gap:"1rem",flexDirection:"row",paddingTop:"1rem",paddingRight:"1rem",paddingLeft:"1rem",minHeight:"60vh",maxWidth:"100%",overflow:"hidden"},leftSection:{display:"flex",flexDirection:"column",width:"50%",background:"#f6f6f6",borderRadius:"0.375rem",fontFamily:"Plus Jakarta Sans, sans-serif",overflowY:"scroll"},topLeft:{height:"50%",background:"#f9f9f9",display:"flex",flexDirection:"column",overflowY:"auto",borderRadius:"0.375rem"},bottomLeft:{height:"50%",background:"#f9f9f9",display:"flex",flexDirection:"column",overflowY:"auto",borderRadius:"0.375rem"},rightSection:{width:"50%",minHeight:"70vh",paddingLeft:"10px",backgroundColor:"#fff",zIndex:30}};export{m as default};
2
2
  //# sourceMappingURL=CodeCitationPopup.js.map
@@ -0,0 +1,2 @@
1
+ import{__assign as e}from"tslib";import{jsxs as r,jsx as o}from"react/jsx-runtime";import{useState as t,useRef as n}from"react";import{ExternalLink as i,GitBranch as a}from"lucide-react";import l from"@mui/icons-material/GitHub";var p={display:"inline-flex",flexDirection:"column",gap:4,padding:"6px 12px",paddingLeft:0,borderRadius:8,fontSize:13},c={display:"flex",alignItems:"center",gap:6},d={position:"absolute",top:22,left:0,zIndex:10,background:"#fff",border:"0.5px solid #D3D1C7",borderRadius:8,padding:"8px 10px",boxShadow:"0 8px 24px rgba(0,0,0,0.12), 0 2px 6px rgba(0,0,0,0.08)",whiteSpace:"nowrap"};function s(s){var f=s.repoName,u=s.branchName,x=s.repoUrl,m=t(!1),b=m[0],g=m[1],h=n(),v=function(){clearTimeout(h.current),g(!0)},y=function(){h.current=setTimeout(function(){return g(!1)},150)};return r("div",e({style:p},{children:[r("div",e({style:e(e({},c),{position:"relative",color:"#5F5E5A"}),onMouseEnter:v,onMouseLeave:y},{children:[o(l,{sx:{fontSize:14}}),o("span",e({style:{cursor:"pointer",textDecoration:"underline dotted",textUnderlineOffset:2,color:"black"}},{children:f})),b&&o("div",e({style:d,onMouseEnter:v,onMouseLeave:y},{children:r("a",e({href:x,target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:6,fontSize:12,color:"#185FA5",textDecoration:"none"}},{children:[o(i,{size:13}),x.replace("https://","")]}))}))]})),r("div",e({style:e(e({},c),{color:"#888780"})},{children:[o(a,{size:14}),u]}))]}))}export{s as RepoAndBranchTag};
2
+ //# sourceMappingURL=RepoAndBranchTag.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RepoAndBranchTag.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,2 +1,2 @@
1
- import{__assign as e,__spreadArray as n,__awaiter as i,__generator as t}from"tslib";import{jsx as o,jsxs as r}from"react/jsx-runtime";import{useState as l,useRef as u,useMemo as c,useEffect as a,useCallback as s}from"react";import{Box as d,Snackbar as v,Alert as f,Tooltip as p,Typography as g,Tabs as h,Tab as m}from"@mui/material";import{ChevronDown as S}from"lucide-react";import{ButtonCognitiveIcon as x}from"../../assests/svg/ButtonCognitiveIcon.js";import R from"./OverlayComponent.js";import{safeStringify as b,extractDeviationScore as y,generateColorPalette as C,findKeyPathByNodeId as w,DEVIATION_BADGE_SEPARATOR as B,hasMeaningfulRedlineTags as _,scrollAndHighlightClause as I,scrollAndWait as F,waitForScrollIdle as T}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as E,DEFAULT_FIELD_CONFIG as A,DEFAULT_COMPARISON_CONFIG as D}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import{DEFAULT_DEVIAION_COLOR as k,EMPTY_SUMMARY_POPUP_STATE as O,DEFAULT_COMPONENT_HEADER_TEXT as P}from"./CognitiveCompareConstants.js";import j from"./CognitivePopup.js";import L from"./MoreFunctionsPopup.js";import N from"./LoaderComponent.js";import M from"./components/ThreeDotsLoader.js";import{useCognitiveTreeData as H}from"./hooks/useCompareData.js";import{useComparePopups as z}from"./hooks/useComparePopups.js";import{useSectionRefs as W}from"./hooks/useSectionRefs.js";import{useAccordionState as q}from"./hooks/useAccordionState.js";import{useDeviationNavigation as G}from"./hooks/useDeviationNavigation.js";import V from"./components/CompareHeader.js";import K from"./components/SubSectionAccordion.js";import J from"./components/LHSSectionRow.js";import Y from"./components/RHSSectionRow.js";import X from"./components/CognitiveSummaryPopup.js";import{CompareContextProvider as $}from"./CompareContext.js";import{useStyleHelpers as U}from"./hooks/useStyles.js";import{useResizeHandler as Q}from"./hooks/useResizeHandler.js";import{useLinesCalculator as Z}from"./hooks/useLinesCalculator.js";import{useSideBySide as ee}from"./hooks/useSideBySide.js";import ne from"./components/SvgConnectors.js";import ie from"./Guidelines/components/GuidelinePanel.js";import te from"./Guidelines/components/WebGptPanel.js";import{getVisibleGuidelineTargets as oe}from"./Guidelines/utils/guidelineTargets.js";var re=function(re){var le,ue,ce,ae,se,de,ve,fe,pe,ge,he,me,Se,xe,Re,be,ye,Ce,we,Be,_e,Ie,Fe,Te,Ee,Ae,De,ke,Oe,Pe,je,Le,Ne,Me,He,ze=re.componentHeaderText,We=void 0===ze?P:ze,qe=re.treeData,Ge=re.comparisonConfig,Ve=re.leftColumnTitleText,Ke=re.rightColumnTitleText,Je=re.markdownStyles,Ye=re.resetTrigger,Xe=re.displayConfig,$e=void 0===Xe?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1,displayEmailNotifier:!0,isStreamingEnabled:!1}:Xe,Ue=re.onMaintainRelativeOrderChange,Qe=re.popupConfig,Ze=re.deviationData,en=void 0===Ze?{}:Ze,nn=re.deviationNodeIdToView,tn=re.resetDeviationNodeId,on=re.isProposingFix,rn=void 0!==on&&on,ln=re.proposingFixNodeId,un=re.isRedlineFlow,cn=re.badgeStyleOverride,an=re.guidelinesData,sn=re.isGuidelineMode,dn=re.gptWebCitationConfig,vn=l($e.maintainRelativeOrder),fn=vn[0],pn=vn[1],gn=null!==(le=null==$e?void 0:$e.expandLevels)&&void 0!==le?le:0,hn=!!(null==$e?void 0:$e.expandAllSections),mn=!!fn||!!(null==$e?void 0:$e.showDeviationBadges),Sn=l(!1),xn=Sn[0],Rn=Sn[1],bn=l(null),yn=bn[0],Cn=bn[1],wn=l(null===(ce=null!==(ue=null==qe?void 0:qe.newEvaluationResult)&&void 0!==ue?ue:null==$e?void 0:$e.enableDeviationSchemaBackwardCompatibility)||void 0===ce||ce)[0],Bn=l(new Set),_n=Bn[0],In=Bn[1],Fn=l([]),Tn=Fn[0],En=Fn[1],An=l(!1),Dn=An[0],kn=An[1],On=l(0),Pn=On[0],jn=On[1],Ln=u(null),Nn=u(null),Mn=u(null),Hn=u(null),zn=u(null),Wn=u(!1),qn=u(null),Gn=u({}),Vn=u([]),Kn=u(function(){}),Jn=u(null),Yn=u(function(){}),Xn=c(function(){return JSON.stringify(en||{})},[JSON.stringify(en)]),$n=c(function(){return en||{}},[Xn]),Un=c(function(){return(null==qe?void 0:qe.cognitive_decisioning)||{}},[qe]),Qn=c(function(){return e(e({},E),Je)},[Je]),Zn=u(null),ei=u(null),ni=u(null),ii=u(null),ti=u(null),oi=u(null),ri=u(null),li=u(null),ui=u(null),ci=u(null),ai=z(Zn),si=ai.cognitivePopup,di=ai.setCognitivePopup,vi=ai.moreFunctions,fi=ai.setMoreFunctions,pi=ai.position,gi=ai.setPosition,hi=ai.activeBadgeId,mi=ai.summaryPopup,Si=ai.setSummaryPopup,xi=ai.closeSummaryPopup,Ri=ai.setActiveBadgeId,bi=ai.popupRef,yi=ai.handleOpenCognitiveCompare,Ci=ai.openCognitivePopupFromState,wi=ai.closeCognitivePopup,Bi=ai.closeMoreFunctionsPopup,_i=c(function(){var e,n,i,t,o,r,l;return{fields:null!==(e=null==Ge?void 0:Ge.fields)&&void 0!==e?e:A,thresholds:{high:null!==(i=null===(n=null==Ge?void 0:Ge.thresholds)||void 0===n?void 0:n.high)&&void 0!==i?i:D.thresholds.high,medium:null!==(o=null===(t=null==Ge?void 0:Ge.thresholds)||void 0===t?void 0:t.medium)&&void 0!==o?o:D.thresholds.medium,exact:null!==(l=null===(r=null==Ge?void 0:Ge.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:D.thresholds.exact}}},[Ge]),Ii=l(null),Fi=Ii[0];Ii[1];var Ti=null===(de=null===(ae=null==qe?void 0:qe.documents)||void 0===ae?void 0:ae[null===(se=null==qe?void 0:qe.input_index_map)||void 0===se?void 0:se[0]])||void 0===de?void 0:de.title,Ei=null===(pe=null===(ve=null==qe?void 0:qe.documents)||void 0===ve?void 0:ve[null===(fe=null==qe?void 0:qe.input_index_map)||void 0===fe?void 0:fe[1]])||void 0===pe?void 0:pe.title,Ai=b(Ve||Ti||"Uploaded Contract"),Di=null===(Se=null===(me=null===(ge=null==qe?void 0:qe.documents)||void 0===ge?void 0:ge[null===(he=null==qe?void 0:qe.input_index_map)||void 0===he?void 0:he[0]])||void 0===me?void 0:me.metadata)||void 0===Se?void 0:Se.file_name,ki=b(Di),Oi=null===(ye=null===(be=null===(xe=null==qe?void 0:qe.documents)||void 0===xe?void 0:xe[null===(Re=null==qe?void 0:qe.input_index_map)||void 0===Re?void 0:Re[1]])||void 0===be?void 0:be.metadata)||void 0===ye?void 0:ye.file_name,Pi=b(Oi),ji=b(Ke||Ei||"Reference Template"),Li=H(qe,fn,$n,_i,wn,an,sn),Ni=Li.isGuidelineMode,Mi=Li.activeProposed,Hi=Li.existingRule,zi=Li.proposedSections,Wi=Li.existingSections,qi=Li.visibleFields,Gi=Li.parentDeviationRecord,Vi=Li.deviationNumberRegistry,Ki=Li.deviationParentRegistry,Ji=Li.parseError;a(function(){Ji&&Cn("Failed to load comparison: ".concat(Ji))},[Ji]);var Yi=zi.length>0||Wi.length>0,Xi=c(function(){if(!un)return"off";var e=0,n=0,i=function(t){Array.isArray(t)&&t.forEach(function(t){var o,r=(null==t?void 0:t.content)||"";_(r)&&(e+=1,n+=String(r).length),(null===(o=null==t?void 0:t.subsections)||void 0===o?void 0:o.length)&&i(t.subsections)})};return i(zi),i(Wi),"".concat(e,":").concat(n)},[un,zi,Wi]);a(function(){if(zi.length||Wi.length)if(hn){var e={},n={},i=function(i,t){i.forEach(function(i,o){var r,l=fn?"".concat(t,"-").concat(o):String(o);e[l]=!0;var u=function(e,i){null==e||e.forEach(function(e,t){var o,r="".concat(i,"-").concat(t);n[r]=!0,(null===(o=e.subsections)||void 0===o?void 0:o.length)&&u(e.subsections,r)})};(null===(r=i.subsections)||void 0===r?void 0:r.length)&&u(i.subsections,String(o))})};i(zi,"left"),i(Wi,"right"),At(e),kt(n)}else if(gn>0){var t={},o={},r=function(e,n,i){e.forEach(function(e,r){var l;if(i>=1){var u=fn?"".concat(n,"-").concat(r):String(r);t[u]=!0}var c=function(e,n,t){t>i||null==e||e.forEach(function(e,i){var r,l="".concat(n,"-").concat(i);o[l]=!0,(null===(r=e.subsections)||void 0===r?void 0:r.length)&&c(e.subsections,l,t+1)})};(null===(l=e.subsections)||void 0===l?void 0:l.length)&&i>=2&&c(e.subsections,String(r),2)})};r(zi,"left",gn),r(Wi,"right",gn),At(t),kt(o)}},[hn,gn,zi,Wi,fn]);var $i=W(qi.map(function(e){return e.key}),Math.max(zi.length,Wi.length)),Ui=$i.leftRefs,Qi=$i.rightRefs,Zi=$i.sectionLeftRefs,et=$i.sectionRightRefs,nt=$i.lhsBadgeRefs,it=$i.rhsBadgeRefs,tt=$i.sectionRightRowRefs,ot=$i.subSectionLeftRefs,rt=$i.subSectionRightRefs,lt=$i.sectionRowRefs,ut=$i.getSectionRowRef,ct=$i.getSubSectionRef,at=$i.getBadgeRef,st=ee({isGuidelineMode:Ni,maintainRelativeOrder:fn,proposedSections:zi,existingSections:Wi,leftContainerRef:li,rightContainerRef:ni,scrollContainerRef:Zn,sectionLeftRefs:Zi,sectionRightRefs:et,subSectionLeftRefs:ot,subSectionRightRefs:rt,lhsBadgeRefs:nt,rhsBadgeRefs:it,sectionRowRefs:lt,sectionRightRowRefs:tt,rhsTopSpacerRef:ii,rhsBottomSpacerRef:ti,lhsTopSpacerRef:oi,lhsBottomSpacerRef:ri,calculateLinesRef:Kn,setConnectedSections:In,setConnectedLines:En,cachedConnectedPositions:Vn,closeMoreFunctionsPopup:Bi,setErrorToast:Cn,moreFunctions:vi,closeSummaryPopup:xi}),dt=st.isSideBySide,vt=st.isArrowVisible,ft=st.setIsArrowVisible,pt=st.isResizing,gt=st.setIsResizing,ht=st.isSideBySideLoading,mt=st.activeSideBySideSection,St=st.scrollLock,xt=st.sideBySideCacheRef,Rt=st.isSideBySideRef,bt=st.activeSideBySideRightSectionRef,yt=st.activeSideBySideSectionRef,Ct=st.sideBySideLineRef,wt=st.highlightedClauseRefs,Bt=st.clearClauseHighlight,_t=st.resetSideBySide,It=st.activateSideBySide,Ft=u(It);a(function(){Ft.current=It},[It]);var Tt=q({maintainRelativeOrder:!!fn,proposedSections:zi,existingSections:Wi,activeSideBySideSection:mt,connectedSections:_n,resetSideBySide:_t,setConnectedSections:In,setConnectedLines:En,cachedConnectedPositions:Vn,svgContainerRef:Ln,isAnimatingRef:Wn,animationTimerRef:qn,calculateLinesRef:Kn,sectionLeftRefs:Zi,sectionRightRefs:et,subSectionLeftRefs:ot,subSectionRightRefs:rt}),Et=Tt.expandedSections,At=Tt.setExpandedSections,Dt=Tt.expandedSubSections,kt=Tt.setExpandedSubSections,Ot=Tt.handleSubSectionToggle,Pt=Tt.toggleSection,jt=Tt.forceExpandCrossWiredSections,Lt=function(){var e,n;if(null!=mt){var i=null===(e=Zi.current[mt])||void 0===e?void 0:e.current,t=null===(n=et.current[mt])||void 0===n?void 0:n.current,o=ni.current;if(i&&t&&o){var r=i.getBoundingClientRect(),l=t.getBoundingClientRect(),u=o.getBoundingClientRect(),c=r.top-u.top,a=l.top-u.top-c;o.scrollBy({top:a,behavior:"smooth"})}}},Nt=s(function(e){null==e||e.stopPropagation(),kn(function(e){var n=!e;return n&&requestAnimationFrame(function(){Lt()}),n})},[Lt]);a(function(){un&&"off"!==Xi&&"0:0"!==Xi&&(xt.current=null,Vn.current=[],requestAnimationFrame(function(){var e;null===(e=Kn.current)||void 0===e||e.call(Kn)}))},[un,Xi]);var Mt=c(function(){var e=new Map,n=new Map,i=1;if(fn)zi.forEach(function(n){!n.title&&!n.content||n.id&&e.set(n.id,i++)}),Wi.forEach(function(t){if(t.id&&!(!t.title&&!t.content)){var o=zi.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(t.selfIndex)});if(o.length>0){var r=o.map(function(n){return e.get(n.id)}).filter(Boolean);n.set(t.id,r.join(", "))}else n.set(t.id,String(i++))}});else for(var t=Math.max(zi.length,Wi.length),o=0;o<t;o++){var r=zi[o],l=Wi[o];r?(e.set(r.id,i),l&&n.set(l.id,String(i)),i++):l&&n.set(l.id,String(i++))}return{leftNums:e,rightNums:n}},[zi,Wi,fn]),Ht=Hi.analysis,zt=b(null===(we=null===(Ce=null==Ht?void 0:Ht.rule_difference_comparison)||void 0===Ce?void 0:Ce.summary)||void 0===we?void 0:we.overall_summary),Wt=!!zt.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),qt=null!==(Be=null==qe?void 0:qe.base_root_id)&&void 0!==Be?Be:"-1";null==qe||qe[qt];var Gt=wn?null!==(Le=null!==(Oe=en&&(null===(ke=null==en?void 0:en[qt])||void 0===ke?void 0:ke.evaluation_result))&&void 0!==Oe?Oe:null===(je=null===(Pe=null==qe?void 0:qe.nodes)||void 0===Pe?void 0:Pe[qt])||void 0===je?void 0:je.evaluation_result)&&void 0!==Le?Le:null:null!==(De=null!==(Fe=en&&(null===(Ie=null===(_e=null==en?void 0:en[qt])||void 0===_e?void 0:_e.evaluation_result)||void 0===Ie?void 0:Ie[0]))&&void 0!==Fe?Fe:null===(Ae=null===(Ee=null===(Te=null==qe?void 0:qe.nodes)||void 0===Te?void 0:Te[qt])||void 0===Ee?void 0:Ee.evaluation_result)||void 0===Ae?void 0:Ae[0])&&void 0!==De?De:null,Vt=y(Gt),Kt=C(null!==(He=null===(Me=null===(Ne=null==Gt?void 0:Gt.evaluation_outputs)||void 0===Ne?void 0:Ne.metadata)||void 0===Me?void 0:Me.label_color)&&void 0!==He?He:k);if(cn){var Jt=cn(Vt);Jt&&(Kt=e(e({},Kt),{badgeBg:Jt.bg,badgeText:Jt.text,badgeBorder:Jt.border}))}var Yt=u(_t);a(function(){Yt.current=_t},[_t]);var Xt=u(wi);a(function(){Xt.current=wi},[wi]);var $t=s(function(e,n,i,t,o,r){return lr.current(e,n,i,t,o,r)},[]),Ut=s(function(e,n,i,t,o){return cr.current(e,n,i,t,o)},[]),Qt=s(function(){return ar.current()},[]),Zt=s(function(e,n){return sr.current(e,n)},[]),eo=s(function(e){return dr.current(e)},[]),no=s(function(e){return vr.current(e)},[]),io=s(function(){return fr.current()},[]),to=s(function(){var e,n;Bt(),null===(e=Yt.current)||void 0===e||e.call(Yt),kn(!1),In(new Set),En([]),Vn.current=[],_o([]),Fo(null),Si(O),null===(n=Xt.current)||void 0===n||n.call(Xt),requestAnimationFrame(function(){var e;null===(e=Kn.current)||void 0===e||e.call(Kn)})},[]),oo=u(to);a(function(){oo.current=to},[to]),a(function(){Ye&&oo.current()},[Ye]);var ro=c(function(){return{documents:null==qe?void 0:qe.documents,input_index_map:null==qe?void 0:qe.input_index_map}},[JSON.stringify(null==qe?void 0:qe.documents),JSON.stringify(null==qe?void 0:qe.input_index_map)]),lo=l(""),uo=lo[0],co=lo[1],ao=u(qe);a(function(){var e,n,i;ao.current=qe;var t=null===(e=null==qe?void 0:qe.input_index_map)||void 0===e?void 0:e[0],o=null===(i=null===(n=null==qe?void 0:qe.documents)||void 0===n?void 0:n[t])||void 0===i?void 0:i.title;co(o)},[qe]);var so=u(Un);a(function(){so.current=Un},[Un]);var vo=s(function(n,i,t,o,r,l,u){var c,a,s,d,v,f,p,g,h,m,S=b(null==i?void 0:i.id)||b(null==t?void 0:t.id)||"",x=(S?null===(c=so.current)||void 0===c?void 0:c[S]:null)||(null==i?void 0:i.cognitiveData)||(null==t?void 0:t.cognitiveData)||{section_id:S,decisioning:[],gap:[],relevance_score:0},R=null!==(s=null===(a=lt.current[o])||void 0===a?void 0:a.current)&&void 0!==s?s:null,y=function(){var n,r,l=(null==i?void 0:i.evaluationResult)||(null==t?void 0:t.evaluationResult)||null,u=function(n){var i=function(e){if(!e||"object"!=typeof e)return null;var n=null==e?void 0:e.deviation_entries;if(n&&"object"==typeof n){var i=Object.keys(n).sort(function(e,n){return Number(e)-Number(n)})[0];if(i&&n[i])return n[i]}var t=Object.keys(e).filter(function(e){return/^\d+$/.test(e)}).sort(function(e,n){return Number(e)-Number(n)});if(t.length&&e[t[0]])return e[t[0]];var o=null==e?void 0:e.deviations;if(o&&"object"==typeof o){var r=Object.keys(o).sort(function(e,n){return Number(e)-Number(n)})[0];if(r&&o[r])return o[r]}return null}(n);return i?e(e({},n),{deviation_summary:(null==n?void 0:n.deviation_summary)||(null==i?void 0:i.deviation_summary),deviation_title:(null==n?void 0:n.deviation_title)||(null==i?void 0:i.deviation_title),deviation_impact:(null==n?void 0:n.deviation_impact)||(null==i?void 0:i.deviation_impact),deviation_explanation:(null==n?void 0:n.deviation_explanation)||(null==i?void 0:i.deviation_explanation),evaluation_outputs:(null==n?void 0:n.evaluation_outputs)||(null==i?void 0:i.evaluation_outputs),cognitive_decisioning:(null==n?void 0:n.cognitive_decisioning)||(null==i?void 0:i.cognitive_decisioning)}):n};if(!("string"==typeof o&&o.includes(B)))return u(l);var c=o.split(B)[1];if(!c)return l;var a=(null==i?void 0:i.evaluationResult)||(null==t?void 0:t.evaluationResult)||{},s=(null===(n=null==a?void 0:a.deviation_entries)||void 0===n?void 0:n[c])||(null===(r=null==a?void 0:a.deviations)||void 0===r?void 0:r[c])||null;return s?e(e(e({},a),s),{deviation_summary:(null==s?void 0:s.deviation_summary)||(null==a?void 0:a.deviation_summary),deviation_title:(null==s?void 0:s.deviation_title)||(null==a?void 0:a.deviation_title),deviation_impact:(null==s?void 0:s.deviation_impact)||(null==a?void 0:a.deviation_impact),deviation_explanation:(null==s?void 0:s.deviation_explanation)||(null==a?void 0:a.deviation_explanation),evaluation_outputs:(null==s?void 0:s.evaluation_outputs)||(null==a?void 0:a.evaluation_outputs),cognitive_decisioning:(null==s?void 0:s.cognitive_decisioning)||(null==a?void 0:a.cognitive_decisioning)}):u(l)}(),C=(null!==(f=null===(v=null===(d=null==y?void 0:y.cognitive_decisioning)||void 0===d?void 0:d.decisioning_factors)||void 0===v?void 0:v.length)&&void 0!==f?f:0)>0||(null!==(h=null===(g=null===(p=null==y?void 0:y.cognitive_decisioning)||void 0===p?void 0:p.gaps_in_decision)||void 0===g?void 0:g.length)&&void 0!==h?h:0)>0,w=null!==(m=null==$e?void 0:$e.isLoading)&&void 0!==m&&m,_=!0;if(Ni){var I=null==y?void 0:y.deviation_highlights;if(I&&"object"==typeof I)_=Object.values(I).some(function(e){return Array.isArray(e)&&e.length>0});else _=!1}return{isLoading:w&&!C,open:!0,sectionTitle:(null==i?void 0:i.title)?null==i?void 0:i.title:"No Counterpart",refSectionTitle:(null==t?void 0:t.title)?null==t?void 0:t.title:"No Counterpart",cognitiveData:x,anchorEl:n,sectionAnchorEl:R,badgeStyle:l||null,sectionIdx:o,docData:ro,deviationData:y,isOrphan:!!r,hasGuidelineMatches:_}},[ro,null==$e?void 0:$e.isLoading,Ni]),fo=s(function(e,n,i,t,o,r){var l;if(e.stopPropagation(),vi.open&&vi.sectionIdx===o)Bi();else{var u=e.currentTarget,c="left";(null===(l=ni.current)||void 0===l?void 0:l.contains(u))&&(c="right");Bt(),Rt.current&&_t(),In(new Set),En([]),Vn.current=[],wi(),mi.open?zo():xi(),requestAnimationFrame(function(){var e=function(){var e,n,i,t;if("string"==typeof o&&o.includes(B)){var r=o.split(B),l="".concat(r[0]).concat(B).concat(r[1]);return"right"===c?null===(e=it.current[l])||void 0===e?void 0:e.current:null===(n=nt.current[l])||void 0===n?void 0:n.current}return"right"===c?null===(i=it.current[o])||void 0===i?void 0:i.current:null===(t=nt.current[o])||void 0===t?void 0:t.current}()||u;fi(vo(e,n,t,o,i,r))})}},[vi.open,vi.sectionIdx,Bi,xi,vo]),po=s(function(){var e=vi.sectionIdx;vi.isOrphan,Bi(),xi(),null!==e&&(jt(e),Bt(),Rt.current&&_t(),En([]),Vn.current=[],Ni&&null!==e&&jn(No(e)),In(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){Kn.current&&Kn.current()},50))},[vi.sectionIdx,vi.isOrphan,Bi,xi,_t]),go=s(function(){var e=zn.current;if(e){zn.current=null;var n=zi.findIndex(function(n){return n.id===e}),i=Wi.findIndex(function(n){return n.id===e}),t=-1===n?w(zi,e):null,o=-1===i?w(Wi,e):null,r=-1!==n?n:t?Number(t.split("-")[0]):-1,l=-1!==i?i:o?Number(o.split("-")[0]):-1,u=function(e,n,i,t){var o,r,l,u;return-1!==e?null!==(r=null===(o=i.current[e])||void 0===o?void 0:o.current)&&void 0!==r?r:null:n&&null!==(u=null===(l=t.current[n])||void 0===l?void 0:l.current)&&void 0!==u?u:null},c=function(e,n,i){void 0===i&&(i=30);var t=0,o=function(){var r=e();r&&0!==r.getBoundingClientRect().height?(wt.current.add(r),I(r,n)):t++<i&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(fn)-1!==r&&li.current&&c(function(){return u(n,t,Zi,ot)},li.current),-1!==l&&ni.current&&c(function(){return u(i,o,et,rt)},ni.current);else{var a=Zn.current;if(!a)return;c(function(){return-1!==r?u(n,t,Zi,ot):u(i,o,et,rt)},a)}}},[zi,Wi,fn,Zi,et,ot,rt,li,ni,Zn]),ho=s(function(n){if(n){Bt(),_t(),In(new Set),En([]),Vn.current=[],xi(),wi();var i=zi.findIndex(function(e){return e.id===n}),t=Wi.findIndex(function(e){return e.id===n}),o=-1===i?w(zi,n):null,r=-1===t?w(Wi,n):null;if(-1!==i||o||-1!==t||r){var l=-1!==i?i:o?Number(o.split("-")[0]):-1,u=-1!==t?t:r?Number(r.split("-")[0]):-1;zn.current=n,At(function(n){var i,t=e({},n),o=!1;-1!==l&&(t[i=fn?"left-".concat(l):String(l)]||(t[i]=!0,o=!0));-1!==u&&(t[i=fn?"right-".concat(u):String(u)]||(t[i]=!0,o=!0));return o?t:n}),kt(function(n){var i=e({},n),t=!1,l=function(e){for(var n=e.split("-"),o=n[0],r=1;r<n.length;r++)o+="-".concat(n[r]),i[o]||(i[o]=!0,t=!0)};return o&&l(o),r&&l(r),t?i:n}),setTimeout(function(){requestAnimationFrame(function(){zn.current===n&&mo.current()})},50)}else console.warn('scrollToAndHighlightClause: nodeId "'.concat(n,'" not found'))}},[zi,Wi,fn,At,kt,_t,xi,wi]),mo=u(go);a(function(){mo.current=go},[go]);var So=u(null);a(function(){if(Fi){var e=_i.fields.find(function(e){return e.analysisKey===Fi||e.key===Fi});if(e){var n=Ui.current[e.key]||Qi.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[Fi,_i.fields]);var xo=s(function(e){var n,i,t,o,r,l,u,c,a,s=null===(n=null==Ht?void 0:Ht.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!s||!s[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var d=s[e],v=(null==d?void 0:d.relation)||(null===(t=null===(i=null==d?void 0:d.highlights)||void 0===i?void 0:i.ruleA_spans)||void 0===t?void 0:t.length)||(null===(r=null===(o=null==d?void 0:d.highlights)||void 0===o?void 0:o.ruleB_spans)||void 0===r?void 0:r.length)||(null==d?void 0:d.mappings)&&d.mappings.length>0;if(d.mappings){var f=d.mappings[0]||{};return{score:d.score,relation:f.relation||"",highlightsA:(null===(l=f.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(u=f.highlights)||void 0===u?void 0:u.ruleB_spans)||[],hasContent:!!v}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(c=d.highlights)||void 0===c?void 0:c.ruleA_spans)||[],highlightsB:(null===(a=d.highlights)||void 0===a?void 0:a.ruleB_spans)||[],hasContent:!!v}},[Ht]),Ro=U({proposedSections:zi,existingSections:Wi,maintainRelativeOrder:fn,cognitiveMap:Un,deviationData:$n,treeData:qe,resolvedComparisonConfig:_i,badgeStyleOverride:cn}),bo=Ro.getSectionCompareStyle,yo=Ro.getSubSectionCompareStyle,Co=Ro.getDeviationStyleByKey,wo=Z({containerRef:Nn,leftContainerRef:li,rightContainerRef:ni,svgContainerRef:Ln,pathRefs:Gn,leftHeaderRef:Mn,rightHeaderRef:Hn,proposedSections:zi,existingSections:Wi,visibleFields:qi,leftRefs:Ui,rightRefs:Qi,sectionLeftRefs:Zi,sectionRightRefs:et,subSectionLeftRefs:ot,subSectionRightRefs:rt,lhsBadgeRefs:nt,rhsBadgeRefs:it,sectionRowRefs:lt,expandedSections:Et,expandedSubSections:Dt,connectedSections:_n,isSideBySide:dt,activeSideBySideSection:mt,maintainRelativeOrder:fn,isGuidelineMode:Ni,cognitiveMap:Un,getSectionCompareStyle:bo,getSubSectionCompareStyle:yo,getDeviationStyleByKey:Co,isArrowVisible:vt,isAnimatingRef:Wn,isSideBySideRef:Rt,sideBySideCacheRef:xt,sideBySideLineRef:Ct,activeSideBySideSectionRef:yt,activeSideBySideRightSectionRef:bt,connectedLines:Tn,setConnectedLines:En,cachedConnectedPositions:Vn,calculateLinesRef:Kn,resizeTimerRef:Jn,scrollLock:St,scrollSyncLocked:Dn,handleResizeRef:Yn,activeProposed:Mi,existingRule:Hi,analysisData:Ht,pendingScrollTargetRef:ui,pendingScrollCallbackRef:ci,resolvedComparisonConfig:_i,getFieldData:xo}),Bo=wo.lines,_o=wo.setLines,Io=wo.overallConnector,Fo=wo.setOverallConnector,To=wo.svgDimensions,Eo=wo.handleColumnScroll;a(function(){mi.anchorEl&&requestAnimationFrame(function(){requestAnimationFrame(function(){var e;null===(e=Kn.current)||void 0===e||e.call(Kn)})})},[mi.anchorEl,Dn]);var Ao=s(function(){Bt(),kn(!1),At({}),kt({}),_t(),In(new Set),En([]),Vn.current=[],xi(),wi(),Bi(),requestAnimationFrame(function(){Kn.current&&Kn.current()})},[At,kt,_t,xi,wi,Bi]);a(function(){dt||0!==_n.size||kn(!1)},[dt,_n]);var Do=c(function(){return Object.values(Et).some(Boolean)||Object.values(Dt).some(Boolean)},[Et,Dt]),ko=u(null),Oo=u(0),Po=u(0),jo=u(0),Lo=Q({timerRef:ko,ruleComponentRef:ei,scrollContainerRef:Zn,containerRef:Nn,maintainRelativeOrder:fn,proposedSections:zi,existingSections:Wi,isSideBySideRef:Rt,activeSideBySideSectionRef:yt,activeSideBySideRightSectionRef:bt,sectionRowRefs:lt,sectionRightRowRefs:tt,sectionLeftRefs:Zi,sectionRightRefs:et,subSectionLeftRefs:ot,subSectionRightRefs:rt,lhsBadgeRefs:nt,rhsBadgeRefs:it,leftContainerRef:li,rightContainerRef:ni,calculateLinesRef:Kn,handleResizeRef:Yn,setIsResizing:gt,setIsArrowVisible:ft,sideBySideCacheRef:xt,cachedConnectedPositions:Vn}).handleResize;a(function(){Yn.current=Lo},[Lo,Yn]),a(function(){var e=function(e,n,i,t,o){n.current=e.getBoundingClientRect().width;var r=new ResizeObserver(function(e){null!==i.current&&cancelAnimationFrame(i.current),i.current=requestAnimationFrame(function(){var r,l,u;i.current=null;var c=e[e.length-1];if(c){var a=null!==(u=null===(l=null===(r=c.borderBoxSize)||void 0===r?void 0:r[0])||void 0===l?void 0:l.inlineSize)&&void 0!==u?u:c.contentRect.width;Math.abs(a-n.current)<1?o():(n.current=a,t())}})});return r.observe(e),r},n={current:null},i={current:null},t={current:null},o=[],r=[n,i,t];return ei.current&&o.push(e(ei.current,Oo,n,function(){return Yn.current()},function(){})),Zn.current&&o.push(e(Zn.current,Po,i,function(){return Yn.current()},function(){return Kn.current()})),Nn.current&&o.push(e(Nn.current,jo,t,function(){return Yn.current()},function(){return Kn.current()})),function(){o.forEach(function(e){return e.disconnect()}),r.forEach(function(e){null!==e.current&&(cancelAnimationFrame(e.current),e.current=null)})}},[]),a(function(){Rt.current=dt},[dt]),a(function(){yt.current=mt},[mt]);var No=s(function(e){var n,i,t,o,r,l="",u="0";if("number"==typeof e)l=(null===(n=zi[e])||void 0===n?void 0:n.nodeId)||(null===(i=zi[e])||void 0===i?void 0:i.id)||"";else{var c=String(e).split(B);l=c[0],u=c[1]||"0"}var a=null===(t=null==$n?void 0:$n[l])||void 0===t?void 0:t.evaluation_result,s=Array.isArray(a)?a[parseInt(u,10)]:null==a?void 0:a[u];return!1===(null===(r=null===(o=null==s?void 0:s.evaluation_outputs)||void 0===o?void 0:o.guideline_flag)||void 0===r?void 0:r.rulebook_used)?1:0},[zi,$n]),Mo=s(function(e){var n,i,t=li.current,o=ni.current,r=oe(o),l="string"==typeof e&&e.includes(B),u=e;if(l){var c=e.split(B);c.length>=2&&(u="".concat(c[0]).concat(B).concat(c[1]))}var a=(null===(n=nt.current[u])||void 0===n?void 0:n.current)||(null===(i=nt.current[e])||void 0===i?void 0:i.current);if(r.length>0&&a&&t&&o){var s=r[0];oi.current&&(oi.current.style.height="0px"),ii.current&&(ii.current.style.height="0px"),ri.current&&(ri.current.style.height="0px"),ti.current&&(ti.current.style.height="0px"),requestAnimationFrame(function(){var e=a.getBoundingClientRect(),n=s.getBoundingClientRect(),i=t.getBoundingClientRect(),r=o.getBoundingClientRect(),l=t.scrollTop+(e.top-i.top)+e.height/2,u=o.scrollTop+(n.top-r.top)+n.height/2,c=l-i.height/2,d=Math.max(0,c),v=t.scrollHeight-t.clientHeight,f=d>v?d-v:0,p=i.top+l-d,g=r.top+u-p,h=0;g<0&&(h=Math.abs(g),g=0);var m=o.scrollHeight-o.clientHeight+h,S=g>m?g-m:0;ri.current&&(ri.current.style.height="".concat(f,"px")),ii.current&&(ii.current.style.height="".concat(h,"px")),ti.current&&(ti.current.style.height="".concat(S,"px")),requestAnimationFrame(function(){t.scrollTo({top:d,behavior:"smooth"}),o.scrollTo({top:g,behavior:"smooth"}),Kn.current&&setTimeout(function(){return Kn.current()},50)})})}},[B]),Ho=s(function(){var e,n=vi.sectionIdx,i=vi.isOrphan;if(xi(),null!=n){var t="left";vi.anchorEl&&(null===(e=ni.current)||void 0===e?void 0:e.contains(vi.anchorEl))&&(t="right"),jt(n),Ni&&(jn(No(n)),In(new Set([n]))),It(n,i,{sourceSide:t,onReady:function(){Ni&&setTimeout(function(){return Mo(String(n))},150)}})}},[It,vi.isOrphan,vi.sectionIdx,vi.anchorEl,xi,jt,Ni,Mo,No]),zo=s(function(){xi(),_t(),In(new Set),En([]),Vn.current=[]},[xi,_t]),Wo=null!==vi.sectionIdx&&_n.has(vi.sectionIdx),qo=G({proposedSections:zi,existingSections:Wi,parentDeviationRecord:Gi,expandedSections:Et,maintainRelativeOrder:!!fn,scrollContainerRef:Zn,leftContainerRef:li,rightContainerRef:ni,lhsBadgeRefs:nt,rhsBadgeRefs:it}),Go=qo.showDeviationNavigation,Vo=qo.showOpenNodeRef,Ko=qo.adjustScrollForPopup,Jo=s(function(e,n,i,t,o){var r,l="string"==typeof t?b(t).trim():b(null==t?void 0:t.deviation_summary).trim(),u=e.currentTarget;wi();var c="left";(null===(r=ni.current)||void 0===r?void 0:r.contains(u))&&(c="right");var a=function(){var e,i,t,o;if("string"==typeof n&&n.includes(B)){var r=n.split(B),l="".concat(r[0]).concat(B).concat(r[1]);return"right"===c?null===(e=it.current[l])||void 0===e?void 0:e.current:null===(i=nt.current[l])||void 0===i?void 0:i.current}return"right"===c?null===(t=it.current[n])||void 0===t?void 0:t.current:null===(o=nt.current[n])||void 0===o?void 0:o.current};if(i&&!Ni)return _t(),In(new Set),En([]),Vn.current=[],void(l&&(jt(n),requestAnimationFrame(function(){var e=a()||u;e&&(e.getBoundingClientRect().top>.8*window.innerHeight&&e.scrollIntoView({behavior:"smooth",block:"center"}));Si({open:!0,anchorEl:e,summary:t,displayImpact:o})})));jt(n),Ni&&(jn(No(n)),In(new Set([n]))),l?setTimeout(function(){It(n,i,{toggleIfSame:!1,sourceSide:c,onReady:function(){var e,i,r,l=a()||u;if(Ni)setTimeout(function(){return Mo(n)},150);else if(l){var c=l.getBoundingClientRect();if(c.top>.8*window.innerHeight||c.top<100){var s=c.top-window.innerHeight/2;fn?(null===(e=li.current)||void 0===e||e.scrollBy({top:s,behavior:"smooth"}),null===(i=ni.current)||void 0===i||i.scrollBy({top:s,behavior:"smooth"})):null===(r=Zn.current)||void 0===r||r.scrollBy({top:s,behavior:"smooth"})}}Si({open:!0,anchorEl:l,summary:t,displayImpact:o})}})},350):setTimeout(function(){It(n,i,{toggleIfSame:!1,sourceSide:c}),Ni&&setTimeout(function(){return Mo(n)},150)},350)},[It,wi,Si,_t,jt,Ni,fn,Mo,$n]),Yo=c(function(){var e;if(!nn)return null;var n=null===(e=null==nn?void 0:nn.id)||void 0===e?void 0:e.split(":")[0];for(var i in Gi){if((Gi[i]||[]).some(function(e){return e.id===n}))return i}return null},[nn,Gi]),Xo=u({id:null,triggerMs:null}),$o=u(null);a(function(){if(null==nn?void 0:nn.id){var o=Number(nn.trigger),r=Xo.current;if((null==r?void 0:r.id)!==nn.id||(null==r?void 0:r.triggerMs)!==o){if(nn.id.includes(":")&&/:\d+$/.test(nn.id)){var l=nn.id.split(":"),u=l[0],c=l[1],a=null!=c?c:"0",s="".concat(nn.id,":").concat(o);$o.current!==s&&(xi(),wi(),_t(),In(new Set),En([]),Vn.current=[],$o.current=s);var d=!1,v=0,f=null,p=null,g=!1,h=function(e,n){for(var i=function(e,t){if(!e)return null;if(n.includes(e.id)||n.includes(e.nodeId)||n.includes(e.contentId))return t;if(!Array.isArray(e.subsections))return null;for(var o=0;o<e.subsections.length;o++){var r=i(e.subsections[o],"".concat(t,"-").concat(o));if(r)return r}return null},t=0;t<e.length;t++){var o=i(e[t],String(t));if(o)return o}return null},m=function(){var r,l,c;if(!d){var s=function(){Xo.current={id:nn.id,triggerMs:o}},S=null,x=null;for(var R in Gi){var b=Gi[R].find(function(e){var n;return e.id===u||e.nodeId===u||e.contentId===u||(null===(n=e.evaluationResult)||void 0===n?void 0:n.nodeId)===u});if(b){S=R,x=b;break}}if(x&&S){var y=Array.from(new Set([u,x.id,x.nodeId,x.contentId,null===(r=x.evaluationResult)||void 0===r?void 0:r.nodeId].filter(Boolean))),C=zi.findIndex(function(e){return e.id===S}),w=Wi.findIndex(function(e){return e.id===S}),_=-1===C&&-1!==w,I=h(zi,y),E=h(Wi,y);if(I&&!E&&!_){var A=I.split("-"),D=Number(A[0]);if(fn){var k=null===(c=null===(l=zi[D])||void 0===l?void 0:l.refIndexes)||void 0===c?void 0:c[0],O=Wi.findIndex(function(e){return e.selfIndex===k});-1!==O&&(D=O)}E=n([D],A.slice(1),!0).join("-")}if(I||E){var P=I?Number(I.split("-")[0]):C,j=E?Number(E.split("-")[0]):w,L=j>=0?j:E?Number(E.split("-")[0]):-1,N=zi[P],M=Wi[L],H=N&&!N.title&&!N.content,z=M&&!M.title&&!M.content,W=_||(!I&&!!E||H&&!z);if(W){if(!(fn?!!ur.current["right-".concat(j)]:!!ur.current[String(j)])&&j>=0)return Pt(j,"right"),void(f=setTimeout(m,200))}else if(!(fn?!!ur.current["left-".concat(P)]:!!ur.current[String(P)])&&P>=0)return Pt(P,"left"),void(f=setTimeout(m,200));var q=I||"",G=E||"",V=y.map(function(e){return"".concat(e).concat(B).concat(a)}),K=V[0],J=function(){for(var e,n,i=0,t=V;i<t.length;i++){var o=t[i],r=(null===(e=nt.current[o])||void 0===e?void 0:e.current)||null,l=(null===(n=it.current[o])||void 0===n?void 0:n.current)||null;if(r||l)return{refId:o,left:r,right:l}}return{refId:K,left:null,right:null}},Y=function(e){return"".concat(e).concat(B).concat(q).concat(B).concat(G)};if(!g){jt(Y(K)),g=!0,v=0;var X=function(){var e=J(),n=e.left,i=e.right;return W||!n&&!!i?i:n};return null==p||p(),void(f=setTimeout(function(){var e,n,i,t,o,r,l,u;d||(e=X,n=function(){d||(p=null,m())},t=0,o=null,r=null,l=performance.now(),u=function(){if(!d)if(performance.now()-l>3e3)n();else{var c=e();if(c&&0!==c.getBoundingClientRect().height){var a=c.getBoundingClientRect(),s=a.top,v=a.height,f=null!==o&&Math.abs(s-o)<.5,p=null!==r&&Math.abs(v-r)<.5;if(f&&p){if(++t>=5)return void n()}else t=0;o=s,r=v,i=requestAnimationFrame(u)}else i=requestAnimationFrame(u)}},i=requestAnimationFrame(u),p=function(){return cancelAnimationFrame(i)})},300))}var $=J(),U=$.refId,Q=$.left,Z=$.right,ee=Y(U);if(Q||Z){var ne=W||!Q&&!!Z,ie=ne?Z:Q,te=fn?ne?ni.current:li.current:Zn.current;if(ie&&te){var oe=ie.getBoundingClientRect();if(0!==oe.height){var re=te.getBoundingClientRect(),le=oe.top-re.top+te.scrollTop-re.height/2+oe.height/2,ue=(null==I?void 0:I.includes("-"))||(null==E?void 0:E.includes("-")),ce=function(){return i(void 0,void 0,void 0,function(){var n,i,o,r,l,u,c,v,f,p;return t(this,function(t){switch(t.label){case 0:return d?[2]:(s(),n=ie instanceof Element?window.getComputedStyle(ie).color:"",[Q,Z].forEach(function(e){e&&(e.style.transition="box-shadow 300ms ease-in-out",e.style.boxShadow="0 0 10px ".concat(n))}),setTimeout(function(){[Q,Z].forEach(function(e){e&&(e.style.boxShadow="")})},2e3),i=(null===(c=null===(u=x.evaluationResult)||void 0===u?void 0:u.deviations)||void 0===c?void 0:c[a])||x,o=(null===(v=x.evaluationResult)||void 0===v?void 0:v.evaluation_outputs)||x.evaluation_outputs,!!Q&&!!Z||Ni?(l=function(e,n){return Promise.race([e,new Promise(function(e){return setTimeout(e,n)})])},fn?[4,Promise.all([li.current?l(T(li.current),600):Promise.resolve(),ni.current?l(T(ni.current),600):Promise.resolve()])]:[3,2]):(r=ne?(null===(f=it.current[ue?U:j])||void 0===f?void 0:f.current)||Z:(null===(p=nt.current[ue?U:P])||void 0===p?void 0:p.current)||Q,Ko(r,function(){Si({open:!0,anchorEl:r,displayImpact:nn.displayImpact,summary:e(e({},i),{evaluation_outputs:o})})},{skipScroll:!0}),null==tn||tn(),[2]));case 1:t.sent(),t.label=2;case 2:return Ni&&(jn(No(ee)),In(new Set([ee]))),Ft.current(ee,!1,{toggleIfSame:!1,sourceSide:_?"right":"left",onReady:function(){var n,t,o,r;s();var l=ne?(null===(n=it.current[U])||void 0===n?void 0:n.current)||Z:(null===(t=nt.current[U])||void 0===t?void 0:t.current)||Q;if(Ni)setTimeout(function(){return Mo(ee)},150);else{var u=(null===(o=nt.current[U])||void 0===o?void 0:o.current)||Q,c=(null===(r=it.current[U])||void 0===r?void 0:r.current)||Z;u&&(u.style.scrollMarginTop="150px",u.scrollIntoView({behavior:"smooth",block:"start"})),c&&(c.style.scrollMarginTop="150px",c.scrollIntoView({behavior:"smooth",block:"start"}))}Si({open:!0,anchorEl:l,displayImpact:nn.displayImpact,summary:e({},i)}),null==tn||tn()}}),[2]}})})};Math.abs(te.scrollTop-le)<=2?ce():F(te,le,ce)}else++v<30&&(f=setTimeout(m,100))}else++v<30&&(f=setTimeout(m,100))}else++v<30&&(f=setTimeout(m,100))}else++v<30&&(f=setTimeout(m,100))}else++v<30&&(f=setTimeout(m,100))}};return f=setTimeout(m,100),function(){d=!0,f&&clearTimeout(f),null==p||p()}}Xo.current={id:nn.id,triggerMs:o},ho(nn.id);var S=zi.findIndex(function(e){return e.id===nn.id}),x=Wi.findIndex(function(e){return e.id===nn.id});-1===S&&-1===x||setTimeout(function(){var e=-1!==S?S:x,n=-1===S;Ni&&jn(No(e)),In(new Set([e])),Ft.current(e,n,{sourceSide:n?"right":"left",onReady:function(){Ni&&setTimeout(function(){return Mo(String(e))},150)}})},400)}}},[null==nn?void 0:nn.id,null==nn?void 0:nn.trigger,null==nn?void 0:nn.displayImpact,Gi,zi,Wi,fn,Si,ho,Ni,No,Mo]),a(function(){var n,i,t;if(mi.open){var o=mi.anchorEl;if(o&&!o.isConnected){var r=function(e){for(var n,i=0,t=Object.entries(e);i<t.length;i++){var r=t[i],l=r[0];if((null===(n=r[1].current)||void 0===n?void 0:n.textContent)===o.textContent)return l}return null},l=(null===(n=o.dataset)||void 0===n?void 0:n.deviationRefId)||r(nt.current)||r(it.current);if(l){var u=(null===(i=it.current[l])||void 0===i?void 0:i.current)||(null===(t=nt.current[l])||void 0===t?void 0:t.current);u&&u.isConnected&&Si(function(n){return e(e({},n),{anchorEl:u})})}}}},[mi.open,mi.anchorEl,Dn,_n,Et]);var Uo=si.open,Qo=si.sectionIdx,Zo=si.isOrphan,er=si.badgeStyle,nr=si.anchorEl,ir=si.sectionAnchorEl;a(function(){var n;if($e.isStreamingEnabled&&Uo&&null!=Qo&&Qo!==qt){var i="string"==typeof Qo?Qo.split(B)[0]:null,t=function(e,n){var i;if(!e||!Array.isArray(e))return null;for(var o=0,r=e;o<r.length;o++){var l=r[o];if(l.id===n)return l;if(null===(i=l.subsections)||void 0===i?void 0:i.length){var u=t(l.subsections,n);if(u)return u}}return null},o=i&&"string"==typeof i?t(zi,i):null,r=i&&"string"==typeof i?t(Wi,i):null,l="number"==typeof Qo?zi[Qo]||null:o||i&&((null===(n=null==qe?void 0:qe.nodes)||void 0===n?void 0:n[i])||(null==qe?void 0:qe[i]))||null,u="number"==typeof Qo?Wi[Qo]||null:r,c=vo(nr,l,u,Qo,Zo,er);di(function(n){return n.open?b(n.cognitiveData)===b(c.cognitiveData)&&b(n.deviationData)===b(c.deviationData)&&n.sectionTitle===c.sectionTitle&&n.refSectionTitle===c.refSectionTitle?n:e(e(e({},n),c),{open:!0,anchorEl:n.anchorEl,sectionAnchorEl:n.sectionAnchorEl}):n})}},[Uo,Qo,Zo,er,nr,ir,zi,Wi,vo]);var tr=s(function(e){var n=e.section,i=e.keyPath,t=e.depth,r=void 0===t?0:t,l=e.columnKey,u=void 0===l?"left":l,c=e.parentNodeId,a=void 0===c?"":c,s=e.sectionOffset,d=e.rhsOrphanVisualIndexes;return o(K,{section:n,keyPath:i,depth:r,columnKey:u,parentNodeId:a,sectionOffset:s,rhsOrphanVisualIndexes:d})},[]),or=c(function(){return zi.map(function(e,n){var i,t,r=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),l=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return r&&l&&fn?null:o(J,{section:e,idx:n},null!==(t=null!==(i=null==e?void 0:e.layoutKey)&&void 0!==i?i:null==e?void 0:e.id)&&void 0!==t?t:"left-row-".concat(n))})},[zi,fn]),rr=c(function(){return Wi.map(function(e,n){var i,t,r=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),l=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return r&&l&&fn?null:o(Y,{section:e,idx:n},null!==(t=null!==(i=null==e?void 0:e.layoutKey)&&void 0!==i?i:null==e?void 0:e.id)&&void 0!==t?t:"right-row-".concat(n))})},[Wi,fn]),lr=u(fo);a(function(){lr.current=fo},[fo]);var ur=u(Et);a(function(){ur.current=Et},[Et]);var cr=u(Jo);a(function(){cr.current=Jo},[Jo]);var ar=u(zo);a(function(){ar.current=zo},[zo]);var sr=u(Pt);a(function(){sr.current=Pt},[Pt]);var dr=u(Ot);a(function(){dr.current=Ot},[Ot]);var vr=u(tr);a(function(){vr.current=tr},[tr]);var fr=u(_t);a(function(){fr.current=_t},[_t]);var pr=c(function(){return{isGuidelineMode:Ni,maintainRelativeOrder:!!fn,showDeviationBadges:mn,isProposingFix:rn,proposingFixNodeId:ln,isRedlineFlow:un,isSideBySide:dt,activeSideBySideSection:mt,scrollSyncLocked:Dn,toggleScrollSyncLocked:Nt,summaryPopupAnchorEl:mi.anchorEl,connectedSections:_n,proposedSections:zi,existingSections:Wi,deviationNumberRegistry:Vi,deviationParentRegistry:Ki,treeData:qe,displayConfig:$e,resolvedMarkdownStyles:Qn,unifiedNumbering:Mt,expandedSections:Et,expandedSubSections:Dt,setExpandedSubSections:kt,getSectionCompareStyle:bo,getSubSectionCompareStyle:yo,getBadgeRef:at,getSectionRowRef:ut,getSubSectionRef:ct,sectionLeftRefs:Zi,sectionRightRefs:et,sectionRowRefs:lt,sectionRightRowRefs:tt,subSectionLeftRefs:ot,subSectionRightRefs:rt,lhsBadgeRefs:nt,rhsBadgeRefs:it,openMoreFunctionsPopup:$t,handleOpenSummaryPopup:Ut,openSummaryPopup:Ut,handleCloseSummaryPopup:Qt,toggleSection:Zt,handleSubSectionToggle:eo,renderSubSectionAccordion:no,resetSideBySide:io,setConnectedSections:In,setConnectedLines:En,cachedConnectedPositions:Vn,showDeviationNavigation:Go,showOpenNodeRef:Vo,deviationNodeIdToView:null==nn?void 0:nn.id,deviationTargetParentId:Yo,guidelinesData:an,gptWebCitationConfig:dn}},[Ni,fn,mn,rn,ln,un,dt,mt,Dn,Nt,mi.anchorEl,_n,zi,Wi,Vi,$e,Qn,Mt,Et,Dt,kt,bo,yo,at,ut,ct,Go,Vo,nn,Yo,an,dn]),gr=b(si.sectionTitle||ki||Ai),hr=b(Ni?Pi||ji||si.refSectionTitle:si.refSectionTitle||Pi||ji);return o($,e({value:pr},{children:r(d,e({ref:ei,sx:{display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif',overflow:"visible",position:"relative"}},{children:[xn&&o(d,e({sx:{position:"absolute",inset:0,bgcolor:"rgba(255, 255, 255, 0.6)",backdropFilter:"blur(10px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"8px"}},{children:o(N,{})})),mi.open&&o(X,{open:mi.open,anchorEl:mi.anchorEl,containerEl:So.current,clipTopEl:Mn.current,scrollContainerEl:Zn.current,onClose:zo,summary:mi.summary,displayImpact:mi.displayImpact,isScrollLocked:Dn}),o(L,{open:vi.open,anchorEl:vi.anchorEl,maintainRelativeOrder:!!fn,sectionTitle:vi.sectionTitle,referenceSectionTitle:vi.refSectionTitle,onClose:Bi,onOpenCognitiveCompare:yi,onOpenSideBySide:Ho,onConnect:po,isConnected:Wo,isOrphan:!Ni&&!!vi.isOrphan,isGuidelineMode:Ni,hasGuidelineMatches:vi.hasGuidelineMatches}),si.open&&o(j,{open:si.open,popupRef:bi,position:pi,popupConfig:Qe,onClose:function(){gi(null),di(function(n){return e(e({},n),{open:!1})}),Ri(null)},markdownStyles:Je,sectionTitle:gr,referenceSectionTitle:hr,cognitiveData:si.cognitiveData,anchorEl:si.anchorEl,sectionAnchorEl:si.sectionAnchorEl,scrollContainerEl:Zn.current,badgeStyle:si.badgeStyle,docData:si.docData,deviationData:si.deviationData,isLoading:si.isLoading}),o(v,e({open:!!yn,autoHideDuration:8e3,onClose:function(){return Cn(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:o(f,e({onClose:function(){return Cn(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:yn}))})),o(V,{componentHeaderText:We,displayConfig:$e,maintainRelativeOrder:fn,onCollapseAll:Ao,showCollapseAll:Do,onToggleView:function(e){Rn(!0),setTimeout(function(){pn(!e),null==Ue||Ue(!e),kn(!1),_t(),xi(),In(new Set),En([]),Vn.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){Rn(!1)},600)})})},50)}}),o(d,e({ref:Zn,onScroll:Eo,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:fn?"visible":"auto",borderTop:zt&&Wt?"none":"1.5px solid #EEF0F4"}},{children:o(d,e({sx:e({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},fn?{flex:1}:{})},{children:r(d,e({ref:Nn,sx:e({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"100px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},fn?{flex:1,overflow:"visible"}:{})},{children:[o(ne,{svgContainerRef:Ln,svgDimensions:To,isResizing:pt,overallConnector:Io,rootDeviationStyle:Kt,lines:Bo,isSideBySide:dt,activeSideBySideSection:mt,isArrowVisible:vt,maintainRelativeOrder:fn,proposedSections:zi,existingSections:Wi,cognitivePopup:si,activeBadgeId:hi,closeCognitivePopup:wi,setActiveBadgeId:Ri,openCognitivePopupFromState:Ci,buildSectionPopupState:vo,connectedLines:Tn,isGuidelineMode:Ni,pathRefs:Gn}),r(d,e({sx:e({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},fn?{flex:1,overflow:"visible"}:{})},{children:[o(d,e({ref:Mn,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center",minHeight:"40px",overflow:"hidden",minWidth:0}},{children:o(p,e({title:Ai,placement:"top"},{children:o(g,e({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:Ai}))}))})),r(d,e({ref:li,onScroll:Eo,sx:e({p:"12px",display:"flex",flexDirection:"column"},fn?{maxHeight:"calc(100vh - 250px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-180px",pr:"192px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[o("div",{ref:oi,style:{width:"100%",height:"0px",flexShrink:0}}),Yi&&or,o("div",{ref:ri,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),o(d,e({ref:So,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:o(d,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:r(d,e({onClick:function(n){n.stopPropagation(),si.open&&hi===qt?wi():(Ri(qt),Ci(vo(n.currentTarget,{title:uo,content:"",evaluationResult:Gt,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,qt,!0,e(e({},Kt),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:Kt.badgeBg,color:Kt.badgeText,border:"1px solid ".concat(Kt.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=Vt?Vt:o(M,{}),o(d,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:o(x,{})})),o(S,{size:11,style:{transform:si.open&&hi===qt?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),r(d,e({sx:e({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},fn?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[ht&&o(R,{sections:11}),o(d,e({ref:Hn,sx:e({p:"8px",bgcolor:Ni?"#F1F3F5":"#F7F8FA",borderBottom:"1px solid #D7DCE2",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center"},fn?e({maxHeight:"calc(100vh - 250px)",overflowY:"auto",overflowX:"hidden",minHeight:0},Ni?{"&::-webkit-scrollbar":{width:"6px",display:"block"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{background:"#CBD5E1",borderRadius:"10px"},"&::-webkit-scrollbar-thumb:hover":{background:"#94A3B8"},scrollbarWidth:"thin",scrollbarColor:"#CBD5E1 transparent"}:{"&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}):{})},{children:Ni?r(h,e({value:Pn,onChange:function(e,n){return jn(n)},variant:"fullWidth",TabIndicatorProps:{sx:{display:"none"}},sx:{width:"100%",minHeight:"36px","& .MuiTab-root":{minHeight:"36px",px:1,py:0,borderRadius:"8px",fontSize:"14px",lineHeight:1,fontWeight:500,textTransform:"none",color:"#374151",minWidth:0,transition:"background-color 160ms ease, box-shadow 160ms ease"},"& .Mui-selected":{color:"#374151",bgcolor:"#FFFFFF"}}},{children:[o(m,{label:o(p,e({title:ji,placement:"top"},{children:o(d,e({component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block",width:"100%"}},{children:"Redline Guidelines"}))}))}),o(m,{label:o(p,e({title:"Web & GPT Sources",placement:"top"},{children:o(d,e({component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block",width:"100%"}},{children:"Web & GPT Sources"}))}))})]})):o(p,e({title:ji,placement:"top"},{children:o(g,e({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:ji}))}))})),r(d,e({ref:ni,onScroll:Eo,sx:e({p:Ni?"0px":"12px",display:"flex",flexDirection:"column"},fn?e(e({maxHeight:"calc(100vh - 250px)"},!Ni&&{flex:1}),{overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-150px",pl:"165px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}):{})},{children:[o("div",{ref:ii,style:{width:"100%",height:"0px",flexShrink:0}}),Ni?0===Pn?o(ie,{guidelinesData:an,deviationData:en,connectedSections:_n,proposedSections:zi}):o(te,{deviationData:en,connectedSections:_n,proposedSections:zi}):Yi&&rr,o("div",{ref:ti,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))}))};export{re as default};
1
+ import{__assign as e,__spreadArray as n,__awaiter as i,__generator as t}from"tslib";import{jsx as o,jsxs as r}from"react/jsx-runtime";import{useState as l,useRef as u,useMemo as c,useEffect as a,useCallback as s}from"react";import{Box as d,Snackbar as v,Alert as f,Tooltip as p,Typography as g,Tabs as h,Tab as m}from"@mui/material";import{ChevronDown as S}from"lucide-react";import{ButtonCognitiveIcon as x}from"../../assests/svg/ButtonCognitiveIcon.js";import R from"./OverlayComponent.js";import{safeStringify as b,extractDeviationScore as y,generateColorPalette as C,findKeyPathByNodeId as w,DEVIATION_BADGE_SEPARATOR as B,hasMeaningfulRedlineTags as _,scrollAndHighlightClause as I,scrollAndWait as F,waitForScrollIdle as T}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as E,DEFAULT_FIELD_CONFIG as A,DEFAULT_COMPARISON_CONFIG as D}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import{DEFAULT_DEVIAION_COLOR as k,EMPTY_SUMMARY_POPUP_STATE as O,DEFAULT_COMPONENT_HEADER_TEXT as P}from"./CognitiveCompareConstants.js";import j from"./CognitivePopup.js";import L from"./MoreFunctionsPopup.js";import N from"./LoaderComponent.js";import M from"./components/ThreeDotsLoader.js";import{useCognitiveTreeData as H}from"./hooks/useCompareData.js";import{useComparePopups as z}from"./hooks/useComparePopups.js";import{useSectionRefs as W}from"./hooks/useSectionRefs.js";import{useAccordionState as q}from"./hooks/useAccordionState.js";import{useDeviationNavigation as G}from"./hooks/useDeviationNavigation.js";import V from"./components/CompareHeader.js";import K from"./components/SubSectionAccordion.js";import J from"./components/LHSSectionRow.js";import Y from"./components/RHSSectionRow.js";import X from"./components/CognitiveSummaryPopup.js";import{CompareContextProvider as $}from"./CompareContext.js";import{useStyleHelpers as U}from"./hooks/useStyles.js";import{useResizeHandler as Q}from"./hooks/useResizeHandler.js";import{useLinesCalculator as Z}from"./hooks/useLinesCalculator.js";import{useSideBySide as ee}from"./hooks/useSideBySide.js";import ne from"./components/SvgConnectors.js";import ie from"./Guidelines/components/GuidelinePanel.js";import te from"./Guidelines/components/WebGptPanel.js";var oe=function(oe){var re,le,ue,ce,ae,se,de,ve,fe,pe,ge,he,me,Se,xe,Re,be,ye,Ce,we,Be,_e,Ie,Fe,Te,Ee,Ae,De,ke,Oe,Pe,je,Le,Ne,Me,He=oe.componentHeaderText,ze=void 0===He?P:He,We=oe.treeData,qe=oe.comparisonConfig,Ge=oe.leftColumnTitleText,Ve=oe.rightColumnTitleText,Ke=oe.markdownStyles,Je=oe.resetTrigger,Ye=oe.displayConfig,Xe=void 0===Ye?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1,displayEmailNotifier:!0,isStreamingEnabled:!1}:Ye,$e=oe.onMaintainRelativeOrderChange,Ue=oe.popupConfig,Qe=oe.deviationData,Ze=void 0===Qe?{}:Qe,en=oe.deviationNodeIdToView,nn=oe.resetDeviationNodeId,tn=oe.isProposingFix,on=void 0!==tn&&tn,rn=oe.proposingFixNodeId,ln=oe.isRedlineFlow,un=oe.badgeStyleOverride,cn=oe.guidelinesData,an=oe.gptWebCitationConfig,sn=l(Xe.maintainRelativeOrder),dn=sn[0],vn=sn[1],fn=null!==(re=null==Xe?void 0:Xe.expandLevels)&&void 0!==re?re:0,pn=!!(null==Xe?void 0:Xe.expandAllSections),gn=!!dn||!!(null==Xe?void 0:Xe.showDeviationBadges),hn=l(!1),mn=hn[0],Sn=hn[1],xn=l(null),Rn=xn[0],bn=xn[1],yn=l(null===(ue=null!==(le=null==We?void 0:We.newEvaluationResult)&&void 0!==le?le:null==Xe?void 0:Xe.enableDeviationSchemaBackwardCompatibility)||void 0===ue||ue)[0],Cn=l(new Set),wn=Cn[0],Bn=Cn[1],_n=l([]),In=_n[0],Fn=_n[1],Tn=l(!1),En=Tn[0],An=Tn[1],Dn=l(0),kn=Dn[0],On=Dn[1],Pn=u(null),jn=u(null),Ln=u(null),Nn=u(null),Mn=u(null),Hn=u(!1),zn=u(null),Wn=u({}),qn=u([]),Gn=u(function(){}),Vn=u(null),Kn=u(function(){}),Jn=c(function(){return JSON.stringify(Ze||{})},[JSON.stringify(Ze)]),Yn=c(function(){return Ze||{}},[Jn]),Xn=c(function(){return(null==We?void 0:We.cognitive_decisioning)||{}},[We]),$n=c(function(){return e(e({},E),Ke)},[Ke]),Un=u(null),Qn=u(null),Zn=u(null),ei=u(null),ni=u(null),ii=u(null),ti=u(null),oi=u(null),ri=u(null),li=u(null),ui=z(Un),ci=ui.cognitivePopup,ai=ui.setCognitivePopup,si=ui.moreFunctions,di=ui.setMoreFunctions,vi=ui.position,fi=ui.setPosition,pi=ui.activeBadgeId,gi=ui.summaryPopup,hi=ui.setSummaryPopup,mi=ui.closeSummaryPopup,Si=ui.setActiveBadgeId,xi=ui.popupRef,Ri=ui.handleOpenCognitiveCompare,bi=ui.openCognitivePopupFromState,yi=ui.closeCognitivePopup,Ci=ui.closeMoreFunctionsPopup,wi=c(function(){var e,n,i,t,o,r,l;return{fields:null!==(e=null==qe?void 0:qe.fields)&&void 0!==e?e:A,thresholds:{high:null!==(i=null===(n=null==qe?void 0:qe.thresholds)||void 0===n?void 0:n.high)&&void 0!==i?i:D.thresholds.high,medium:null!==(o=null===(t=null==qe?void 0:qe.thresholds)||void 0===t?void 0:t.medium)&&void 0!==o?o:D.thresholds.medium,exact:null!==(l=null===(r=null==qe?void 0:qe.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:D.thresholds.exact}}},[qe]),Bi=l(null),_i=Bi[0];Bi[1];var Ii=null===(se=null===(ce=null==We?void 0:We.documents)||void 0===ce?void 0:ce[null===(ae=null==We?void 0:We.input_index_map)||void 0===ae?void 0:ae[0]])||void 0===se?void 0:se.title,Fi=null===(fe=null===(de=null==We?void 0:We.documents)||void 0===de?void 0:de[null===(ve=null==We?void 0:We.input_index_map)||void 0===ve?void 0:ve[1]])||void 0===fe?void 0:fe.title,Ti=b(Ge||Ii||"Uploaded Contract"),Ei=null===(me=null===(he=null===(pe=null==We?void 0:We.documents)||void 0===pe?void 0:pe[null===(ge=null==We?void 0:We.input_index_map)||void 0===ge?void 0:ge[0]])||void 0===he?void 0:he.metadata)||void 0===me?void 0:me.file_name,Ai=b(Ei),Di=null===(be=null===(Re=null===(Se=null==We?void 0:We.documents)||void 0===Se?void 0:Se[null===(xe=null==We?void 0:We.input_index_map)||void 0===xe?void 0:xe[1]])||void 0===Re?void 0:Re.metadata)||void 0===be?void 0:be.file_name,ki=b(Di),Oi=b(Ve||Fi||"Reference Template"),Pi=H(We,dn,Yn,wi,yn,cn),ji=Pi.isGuidelineMode,Li=Pi.activeProposed,Ni=Pi.existingRule,Mi=Pi.proposedSections,Hi=Pi.existingSections,zi=Pi.visibleFields,Wi=Pi.parentDeviationRecord,qi=Pi.deviationNumberRegistry,Gi=Pi.deviationParentRegistry,Vi=Pi.parseError;a(function(){Vi&&bn("Failed to load comparison: ".concat(Vi))},[Vi]);var Ki=Mi.length>0||Hi.length>0,Ji=c(function(){if(!ln)return"off";var e=0,n=0,i=function(t){Array.isArray(t)&&t.forEach(function(t){var o,r=(null==t?void 0:t.content)||"";_(r)&&(e+=1,n+=String(r).length),(null===(o=null==t?void 0:t.subsections)||void 0===o?void 0:o.length)&&i(t.subsections)})};return i(Mi),i(Hi),"".concat(e,":").concat(n)},[ln,Mi,Hi]);a(function(){if(Mi.length||Hi.length)if(pn){var e={},n={},i=function(i,t){i.forEach(function(i,o){var r,l=dn?"".concat(t,"-").concat(o):String(o);e[l]=!0;var u=function(e,i){null==e||e.forEach(function(e,t){var o,r="".concat(i,"-").concat(t);n[r]=!0,(null===(o=e.subsections)||void 0===o?void 0:o.length)&&u(e.subsections,r)})};(null===(r=i.subsections)||void 0===r?void 0:r.length)&&u(i.subsections,String(o))})};i(Mi,"left"),i(Hi,"right"),Tt(e),At(n)}else if(fn>0){var t={},o={},r=function(e,n,i){e.forEach(function(e,r){var l;if(i>=1){var u=dn?"".concat(n,"-").concat(r):String(r);t[u]=!0}var c=function(e,n,t){t>i||null==e||e.forEach(function(e,i){var r,l="".concat(n,"-").concat(i);o[l]=!0,(null===(r=e.subsections)||void 0===r?void 0:r.length)&&c(e.subsections,l,t+1)})};(null===(l=e.subsections)||void 0===l?void 0:l.length)&&i>=2&&c(e.subsections,String(r),2)})};r(Mi,"left",fn),r(Hi,"right",fn),Tt(t),At(o)}},[pn,fn,Mi,Hi,dn]);var Yi=W(zi.map(function(e){return e.key}),Math.max(Mi.length,Hi.length)),Xi=Yi.leftRefs,$i=Yi.rightRefs,Ui=Yi.sectionLeftRefs,Qi=Yi.sectionRightRefs,Zi=Yi.lhsBadgeRefs,et=Yi.rhsBadgeRefs,nt=Yi.sectionRightRowRefs,it=Yi.subSectionLeftRefs,tt=Yi.subSectionRightRefs,ot=Yi.sectionRowRefs,rt=Yi.getSectionRowRef,lt=Yi.getSubSectionRef,ut=Yi.getBadgeRef,ct=ee({isGuidelineMode:ji,maintainRelativeOrder:dn,proposedSections:Mi,existingSections:Hi,leftContainerRef:oi,rightContainerRef:Zn,scrollContainerRef:Un,sectionLeftRefs:Ui,sectionRightRefs:Qi,subSectionLeftRefs:it,subSectionRightRefs:tt,lhsBadgeRefs:Zi,rhsBadgeRefs:et,sectionRowRefs:ot,sectionRightRowRefs:nt,rhsTopSpacerRef:ei,rhsBottomSpacerRef:ni,lhsTopSpacerRef:ii,lhsBottomSpacerRef:ti,calculateLinesRef:Gn,setConnectedSections:Bn,setConnectedLines:Fn,cachedConnectedPositions:qn,closeMoreFunctionsPopup:Ci,setErrorToast:bn,moreFunctions:si,closeSummaryPopup:mi}),at=ct.isSideBySide,st=ct.isArrowVisible,dt=ct.setIsArrowVisible,vt=ct.isResizing,ft=ct.setIsResizing,pt=ct.isSideBySideLoading,gt=ct.activeSideBySideSection,ht=ct.scrollLock,mt=ct.sideBySideCacheRef,St=ct.isSideBySideRef,xt=ct.activeSideBySideRightSectionRef,Rt=ct.activeSideBySideSectionRef,bt=ct.sideBySideLineRef,yt=ct.highlightedClauseRefs,Ct=ct.clearClauseHighlight,wt=ct.resetSideBySide,Bt=ct.activateSideBySide,_t=u(Bt);a(function(){_t.current=Bt},[Bt]);var It=q({maintainRelativeOrder:!!dn,proposedSections:Mi,existingSections:Hi,activeSideBySideSection:gt,connectedSections:wn,resetSideBySide:wt,setConnectedSections:Bn,setConnectedLines:Fn,cachedConnectedPositions:qn,svgContainerRef:Pn,isAnimatingRef:Hn,animationTimerRef:zn,calculateLinesRef:Gn,sectionLeftRefs:Ui,sectionRightRefs:Qi,subSectionLeftRefs:it,subSectionRightRefs:tt}),Ft=It.expandedSections,Tt=It.setExpandedSections,Et=It.expandedSubSections,At=It.setExpandedSubSections,Dt=It.handleSubSectionToggle,kt=It.toggleSection,Ot=It.forceExpandCrossWiredSections,Pt=function(){var e,n;if(null!=gt){var i=null===(e=Ui.current[gt])||void 0===e?void 0:e.current,t=null===(n=Qi.current[gt])||void 0===n?void 0:n.current,o=Zn.current;if(i&&t&&o){var r=i.getBoundingClientRect(),l=t.getBoundingClientRect(),u=o.getBoundingClientRect(),c=r.top-u.top,a=l.top-u.top-c;o.scrollBy({top:a,behavior:"smooth"})}}},jt=s(function(e){null==e||e.stopPropagation(),An(function(e){var n=!e;return n&&requestAnimationFrame(function(){Pt()}),n})},[Pt]);a(function(){ln&&"off"!==Ji&&"0:0"!==Ji&&(mt.current=null,qn.current=[],requestAnimationFrame(function(){var e;null===(e=Gn.current)||void 0===e||e.call(Gn)}))},[ln,Ji]);var Lt=c(function(){var e=new Map,n=new Map,i=1;if(dn)Mi.forEach(function(n){!n.title&&!n.content||n.id&&e.set(n.id,i++)}),Hi.forEach(function(t){if(t.id&&!(!t.title&&!t.content)){var o=Mi.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(t.selfIndex)});if(o.length>0){var r=o.map(function(n){return e.get(n.id)}).filter(Boolean);n.set(t.id,r.join(", "))}else n.set(t.id,String(i++))}});else for(var t=Math.max(Mi.length,Hi.length),o=0;o<t;o++){var r=Mi[o],l=Hi[o];r?(e.set(r.id,i),l&&n.set(l.id,String(i)),i++):l&&n.set(l.id,String(i++))}return{leftNums:e,rightNums:n}},[Mi,Hi,dn]),Nt=Ni.analysis,Mt=b(null===(Ce=null===(ye=null==Nt?void 0:Nt.rule_difference_comparison)||void 0===ye?void 0:ye.summary)||void 0===Ce?void 0:Ce.overall_summary),Ht=!!Mt.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),zt=null!==(we=null==We?void 0:We.base_root_id)&&void 0!==we?we:"-1";null==We||We[zt];var Wt=yn?null!==(je=null!==(ke=Ze&&(null===(De=null==Ze?void 0:Ze[zt])||void 0===De?void 0:De.evaluation_result))&&void 0!==ke?ke:null===(Pe=null===(Oe=null==We?void 0:We.nodes)||void 0===Oe?void 0:Oe[zt])||void 0===Pe?void 0:Pe.evaluation_result)&&void 0!==je?je:null:null!==(Ae=null!==(Ie=Ze&&(null===(_e=null===(Be=null==Ze?void 0:Ze[zt])||void 0===Be?void 0:Be.evaluation_result)||void 0===_e?void 0:_e[0]))&&void 0!==Ie?Ie:null===(Ee=null===(Te=null===(Fe=null==We?void 0:We.nodes)||void 0===Fe?void 0:Fe[zt])||void 0===Te?void 0:Te.evaluation_result)||void 0===Ee?void 0:Ee[0])&&void 0!==Ae?Ae:null,qt=y(Wt),Gt=C(null!==(Me=null===(Ne=null===(Le=null==Wt?void 0:Wt.evaluation_outputs)||void 0===Le?void 0:Le.metadata)||void 0===Ne?void 0:Ne.label_color)&&void 0!==Me?Me:k);if(un){var Vt=un(qt);Vt&&(Gt=e(e({},Gt),{badgeBg:Vt.bg,badgeText:Vt.text,badgeBorder:Vt.border}))}var Kt=u(wt);a(function(){Kt.current=wt},[wt]);var Jt=u(yi);a(function(){Jt.current=yi},[yi]);var Yt=s(function(e,n,i,t,o,r){return or.current(e,n,i,t,o,r)},[]),Xt=s(function(e,n,i,t,o){return lr.current(e,n,i,t,o)},[]),$t=s(function(){return ur.current()},[]),Ut=s(function(e,n){return cr.current(e,n)},[]),Qt=s(function(e){return ar.current(e)},[]),Zt=s(function(e){return sr.current(e)},[]),eo=s(function(){return dr.current()},[]),no=s(function(){var e,n;Ct(),null===(e=Kt.current)||void 0===e||e.call(Kt),An(!1),Bn(new Set),Fn([]),qn.current=[],wo([]),_o(null),hi(O),null===(n=Jt.current)||void 0===n||n.call(Jt),requestAnimationFrame(function(){var e;null===(e=Gn.current)||void 0===e||e.call(Gn)})},[]),io=u(no);a(function(){io.current=no},[no]),a(function(){Je&&io.current()},[Je]);var to=c(function(){return{documents:null==We?void 0:We.documents,input_index_map:null==We?void 0:We.input_index_map}},[JSON.stringify(null==We?void 0:We.documents),JSON.stringify(null==We?void 0:We.input_index_map)]),oo=l(""),ro=oo[0],lo=oo[1],uo=u(We);a(function(){var e,n,i;uo.current=We;var t=null===(e=null==We?void 0:We.input_index_map)||void 0===e?void 0:e[0],o=null===(i=null===(n=null==We?void 0:We.documents)||void 0===n?void 0:n[t])||void 0===i?void 0:i.title;lo(o)},[We]);var co=u(Xn);a(function(){co.current=Xn},[Xn]);var ao=s(function(n,i,t,o,r,l,u){var c,a,s,d,v,f,p,g,h,m,S=b(null==i?void 0:i.id)||b(null==t?void 0:t.id)||"",x=(S?null===(c=co.current)||void 0===c?void 0:c[S]:null)||(null==i?void 0:i.cognitiveData)||(null==t?void 0:t.cognitiveData)||{section_id:S,decisioning:[],gap:[],relevance_score:0},R=null!==(s=null===(a=ot.current[o])||void 0===a?void 0:a.current)&&void 0!==s?s:null,y=function(){var n,r,l=(null==i?void 0:i.evaluationResult)||(null==t?void 0:t.evaluationResult)||null,u=function(n){var i=function(e){if(!e||"object"!=typeof e)return null;var n=null==e?void 0:e.deviation_entries;if(n&&"object"==typeof n){var i=Object.keys(n).sort(function(e,n){return Number(e)-Number(n)})[0];if(i&&n[i])return n[i]}var t=Object.keys(e).filter(function(e){return/^\d+$/.test(e)}).sort(function(e,n){return Number(e)-Number(n)});if(t.length&&e[t[0]])return e[t[0]];var o=null==e?void 0:e.deviations;if(o&&"object"==typeof o){var r=Object.keys(o).sort(function(e,n){return Number(e)-Number(n)})[0];if(r&&o[r])return o[r]}return null}(n);return i?e(e({},n),{deviation_summary:(null==n?void 0:n.deviation_summary)||(null==i?void 0:i.deviation_summary),deviation_title:(null==n?void 0:n.deviation_title)||(null==i?void 0:i.deviation_title),deviation_impact:(null==n?void 0:n.deviation_impact)||(null==i?void 0:i.deviation_impact),deviation_explanation:(null==n?void 0:n.deviation_explanation)||(null==i?void 0:i.deviation_explanation),evaluation_outputs:(null==n?void 0:n.evaluation_outputs)||(null==i?void 0:i.evaluation_outputs),cognitive_decisioning:(null==n?void 0:n.cognitive_decisioning)||(null==i?void 0:i.cognitive_decisioning)}):n};if(!("string"==typeof o&&o.includes(B)))return u(l);var c=o.split(B)[1];if(!c)return l;var a=(null==i?void 0:i.evaluationResult)||(null==t?void 0:t.evaluationResult)||{},s=(null===(n=null==a?void 0:a.deviation_entries)||void 0===n?void 0:n[c])||(null===(r=null==a?void 0:a.deviations)||void 0===r?void 0:r[c])||null;return s?e(e(e({},a),s),{deviation_summary:(null==s?void 0:s.deviation_summary)||(null==a?void 0:a.deviation_summary),deviation_title:(null==s?void 0:s.deviation_title)||(null==a?void 0:a.deviation_title),deviation_impact:(null==s?void 0:s.deviation_impact)||(null==a?void 0:a.deviation_impact),deviation_explanation:(null==s?void 0:s.deviation_explanation)||(null==a?void 0:a.deviation_explanation),evaluation_outputs:(null==s?void 0:s.evaluation_outputs)||(null==a?void 0:a.evaluation_outputs),cognitive_decisioning:(null==s?void 0:s.cognitive_decisioning)||(null==a?void 0:a.cognitive_decisioning)}):u(l)}(),C=(null!==(f=null===(v=null===(d=null==y?void 0:y.cognitive_decisioning)||void 0===d?void 0:d.decisioning_factors)||void 0===v?void 0:v.length)&&void 0!==f?f:0)>0||(null!==(h=null===(g=null===(p=null==y?void 0:y.cognitive_decisioning)||void 0===p?void 0:p.gaps_in_decision)||void 0===g?void 0:g.length)&&void 0!==h?h:0)>0,w=null!==(m=null==Xe?void 0:Xe.isLoading)&&void 0!==m&&m,_=!0;if(ji){var I=null==y?void 0:y.deviation_highlights;if(I&&"object"==typeof I)_=Object.values(I).some(function(e){return Array.isArray(e)&&e.length>0});else _=!1}return{isLoading:w&&!C,open:!0,sectionTitle:(null==i?void 0:i.title)?null==i?void 0:i.title:"No Counterpart",refSectionTitle:(null==t?void 0:t.title)?null==t?void 0:t.title:"No Counterpart",cognitiveData:x,anchorEl:n,sectionAnchorEl:R,badgeStyle:l||null,sectionIdx:o,docData:to,deviationData:y,isOrphan:!!r,hasGuidelineMatches:_}},[to,null==Xe?void 0:Xe.isLoading,ji]),so=s(function(e,n,i,t,o,r){var l;if(e.stopPropagation(),si.open&&si.sectionIdx===o)Ci();else{var u=e.currentTarget,c="left";(null===(l=Zn.current)||void 0===l?void 0:l.contains(u))&&(c="right");Ct(),St.current&&wt(),Bn(new Set),Fn([]),qn.current=[],yi(),gi.open?Mo():mi(),requestAnimationFrame(function(){var e=function(){var e,n,i,t;if("string"==typeof o&&o.includes(B)){var r=o.split(B),l="".concat(r[0]).concat(B).concat(r[1]);return"right"===c?null===(e=et.current[l])||void 0===e?void 0:e.current:null===(n=Zi.current[l])||void 0===n?void 0:n.current}return"right"===c?null===(i=et.current[o])||void 0===i?void 0:i.current:null===(t=Zi.current[o])||void 0===t?void 0:t.current}()||u;di(ao(e,n,t,o,i,r))})}},[si.open,si.sectionIdx,Ci,mi,ao]),vo=s(function(){var e=si.sectionIdx;si.isOrphan,Ci(),mi(),null!==e&&(Ot(e),Ct(),St.current&&wt(),Fn([]),qn.current=[],ji&&null!==e&&On(jo(e)),Bn(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){Gn.current&&Gn.current()},50))},[si.sectionIdx,si.isOrphan,Ci,mi,wt]),fo=s(function(){var e=Mn.current;if(e){Mn.current=null;var n=Mi.findIndex(function(n){return n.id===e}),i=Hi.findIndex(function(n){return n.id===e}),t=-1===n?w(Mi,e):null,o=-1===i?w(Hi,e):null,r=-1!==n?n:t?Number(t.split("-")[0]):-1,l=-1!==i?i:o?Number(o.split("-")[0]):-1,u=function(e,n,i,t){var o,r,l,u;return-1!==e?null!==(r=null===(o=i.current[e])||void 0===o?void 0:o.current)&&void 0!==r?r:null:n&&null!==(u=null===(l=t.current[n])||void 0===l?void 0:l.current)&&void 0!==u?u:null},c=function(e,n,i){void 0===i&&(i=30);var t=0,o=function(){var r=e();r&&0!==r.getBoundingClientRect().height?(yt.current.add(r),I(r,n)):t++<i&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(dn)-1!==r&&oi.current&&c(function(){return u(n,t,Ui,it)},oi.current),-1!==l&&Zn.current&&c(function(){return u(i,o,Qi,tt)},Zn.current);else{var a=Un.current;if(!a)return;c(function(){return-1!==r?u(n,t,Ui,it):u(i,o,Qi,tt)},a)}}},[Mi,Hi,dn,Ui,Qi,it,tt,oi,Zn,Un]),po=s(function(n){if(n){Ct(),wt(),Bn(new Set),Fn([]),qn.current=[],mi(),yi();var i=Mi.findIndex(function(e){return e.id===n}),t=Hi.findIndex(function(e){return e.id===n}),o=-1===i?w(Mi,n):null,r=-1===t?w(Hi,n):null;if(-1!==i||o||-1!==t||r){var l=-1!==i?i:o?Number(o.split("-")[0]):-1,u=-1!==t?t:r?Number(r.split("-")[0]):-1;Mn.current=n,Tt(function(n){var i,t=e({},n),o=!1;-1!==l&&(t[i=dn?"left-".concat(l):String(l)]||(t[i]=!0,o=!0));-1!==u&&(t[i=dn?"right-".concat(u):String(u)]||(t[i]=!0,o=!0));return o?t:n}),At(function(n){var i=e({},n),t=!1,l=function(e){for(var n=e.split("-"),o=n[0],r=1;r<n.length;r++)o+="-".concat(n[r]),i[o]||(i[o]=!0,t=!0)};return o&&l(o),r&&l(r),t?i:n}),setTimeout(function(){requestAnimationFrame(function(){Mn.current===n&&go.current()})},50)}else console.warn('scrollToAndHighlightClause: nodeId "'.concat(n,'" not found'))}},[Mi,Hi,dn,Tt,At,wt,mi,yi]),go=u(fo);a(function(){go.current=fo},[fo]);var ho=u(null);a(function(){if(_i){var e=wi.fields.find(function(e){return e.analysisKey===_i||e.key===_i});if(e){var n=Xi.current[e.key]||$i.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[_i,wi.fields]);var mo=s(function(e){var n,i,t,o,r,l,u,c,a,s=null===(n=null==Nt?void 0:Nt.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!s||!s[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var d=s[e],v=(null==d?void 0:d.relation)||(null===(t=null===(i=null==d?void 0:d.highlights)||void 0===i?void 0:i.ruleA_spans)||void 0===t?void 0:t.length)||(null===(r=null===(o=null==d?void 0:d.highlights)||void 0===o?void 0:o.ruleB_spans)||void 0===r?void 0:r.length)||(null==d?void 0:d.mappings)&&d.mappings.length>0;if(d.mappings){var f=d.mappings[0]||{};return{score:d.score,relation:f.relation||"",highlightsA:(null===(l=f.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(u=f.highlights)||void 0===u?void 0:u.ruleB_spans)||[],hasContent:!!v}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(c=d.highlights)||void 0===c?void 0:c.ruleA_spans)||[],highlightsB:(null===(a=d.highlights)||void 0===a?void 0:a.ruleB_spans)||[],hasContent:!!v}},[Nt]),So=U({proposedSections:Mi,existingSections:Hi,maintainRelativeOrder:dn,cognitiveMap:Xn,deviationData:Yn,treeData:We,resolvedComparisonConfig:wi,badgeStyleOverride:un}),xo=So.getSectionCompareStyle,Ro=So.getSubSectionCompareStyle,bo=So.getDeviationStyleByKey,yo=Z({containerRef:jn,leftContainerRef:oi,rightContainerRef:Zn,svgContainerRef:Pn,pathRefs:Wn,leftHeaderRef:Ln,rightHeaderRef:Nn,proposedSections:Mi,existingSections:Hi,visibleFields:zi,leftRefs:Xi,rightRefs:$i,sectionLeftRefs:Ui,sectionRightRefs:Qi,subSectionLeftRefs:it,subSectionRightRefs:tt,lhsBadgeRefs:Zi,rhsBadgeRefs:et,sectionRowRefs:ot,expandedSections:Ft,expandedSubSections:Et,connectedSections:wn,isSideBySide:at,activeSideBySideSection:gt,maintainRelativeOrder:dn,isGuidelineMode:ji,cognitiveMap:Xn,getSectionCompareStyle:xo,getSubSectionCompareStyle:Ro,getDeviationStyleByKey:bo,isArrowVisible:st,isAnimatingRef:Hn,isSideBySideRef:St,sideBySideCacheRef:mt,sideBySideLineRef:bt,activeSideBySideSectionRef:Rt,activeSideBySideRightSectionRef:xt,connectedLines:In,setConnectedLines:Fn,cachedConnectedPositions:qn,calculateLinesRef:Gn,resizeTimerRef:Vn,scrollLock:ht,scrollSyncLocked:En,handleResizeRef:Kn,activeProposed:Li,existingRule:Ni,analysisData:Nt,pendingScrollTargetRef:ri,pendingScrollCallbackRef:li,resolvedComparisonConfig:wi,getFieldData:mo}),Co=yo.lines,wo=yo.setLines,Bo=yo.overallConnector,_o=yo.setOverallConnector,Io=yo.svgDimensions,Fo=yo.handleColumnScroll;a(function(){gi.anchorEl&&requestAnimationFrame(function(){requestAnimationFrame(function(){var e;null===(e=Gn.current)||void 0===e||e.call(Gn)})})},[gi.anchorEl,En]);var To=s(function(){Ct(),An(!1),Tt({}),At({}),wt(),Bn(new Set),Fn([]),qn.current=[],mi(),yi(),Ci(),requestAnimationFrame(function(){Gn.current&&Gn.current()})},[Tt,At,wt,mi,yi,Ci]);a(function(){at||0!==wn.size||An(!1)},[at,wn]);var Eo=c(function(){return Object.values(Ft).some(Boolean)||Object.values(Et).some(Boolean)},[Ft,Et]),Ao=u(null),Do=u(0),ko=u(0),Oo=u(0),Po=Q({timerRef:Ao,ruleComponentRef:Qn,scrollContainerRef:Un,containerRef:jn,maintainRelativeOrder:dn,proposedSections:Mi,existingSections:Hi,isSideBySideRef:St,activeSideBySideSectionRef:Rt,activeSideBySideRightSectionRef:xt,sectionRowRefs:ot,sectionRightRowRefs:nt,sectionLeftRefs:Ui,sectionRightRefs:Qi,subSectionLeftRefs:it,subSectionRightRefs:tt,lhsBadgeRefs:Zi,rhsBadgeRefs:et,leftContainerRef:oi,rightContainerRef:Zn,calculateLinesRef:Gn,handleResizeRef:Kn,setIsResizing:ft,setIsArrowVisible:dt,sideBySideCacheRef:mt,cachedConnectedPositions:qn}).handleResize;a(function(){Kn.current=Po},[Po,Kn]),a(function(){var e=function(e,n,i,t,o){n.current=e.getBoundingClientRect().width;var r=new ResizeObserver(function(e){null!==i.current&&cancelAnimationFrame(i.current),i.current=requestAnimationFrame(function(){var r,l,u;i.current=null;var c=e[e.length-1];if(c){var a=null!==(u=null===(l=null===(r=c.borderBoxSize)||void 0===r?void 0:r[0])||void 0===l?void 0:l.inlineSize)&&void 0!==u?u:c.contentRect.width;Math.abs(a-n.current)<1?o():(n.current=a,t())}})});return r.observe(e),r},n={current:null},i={current:null},t={current:null},o=[],r=[n,i,t];return Qn.current&&o.push(e(Qn.current,Do,n,function(){return Kn.current()},function(){})),Un.current&&o.push(e(Un.current,ko,i,function(){return Kn.current()},function(){return Gn.current()})),jn.current&&o.push(e(jn.current,Oo,t,function(){return Kn.current()},function(){return Gn.current()})),function(){o.forEach(function(e){return e.disconnect()}),r.forEach(function(e){null!==e.current&&(cancelAnimationFrame(e.current),e.current=null)})}},[]),a(function(){St.current=at},[at]),a(function(){Rt.current=gt},[gt]);var jo=s(function(e){var n,i,t,o,r,l="",u="0";if("number"==typeof e)l=(null===(n=Mi[e])||void 0===n?void 0:n.nodeId)||(null===(i=Mi[e])||void 0===i?void 0:i.id)||"";else{var c=String(e).split(B);l=c[0],u=c[1]||"0"}var a=null===(t=null==Yn?void 0:Yn[l])||void 0===t?void 0:t.evaluation_result,s=Array.isArray(a)?a[parseInt(u,10)]:null==a?void 0:a[u];return!1===(null===(r=null===(o=null==s?void 0:s.evaluation_outputs)||void 0===o?void 0:o.guideline_flag)||void 0===r?void 0:r.rulebook_used)?1:0},[Mi,Yn]),Lo=s(function(e){var n,i,t=document.querySelectorAll('[id^="guideline-target-"], [data-web-gpt-active="true"]'),o=oi.current,r=Zn.current,l="string"==typeof e&&e.includes(B),u=e;if(l){var c=e.split(B);c.length>=2&&(u="".concat(c[0]).concat(B).concat(c[1]))}var a=(null===(n=Zi.current[u])||void 0===n?void 0:n.current)||(null===(i=Zi.current[e])||void 0===i?void 0:i.current);if(t.length>0&&a&&o&&r){var s=t[0];ii.current&&(ii.current.style.height="0px"),ei.current&&(ei.current.style.height="0px"),ti.current&&(ti.current.style.height="0px"),ni.current&&(ni.current.style.height="0px"),requestAnimationFrame(function(){var e=a.getBoundingClientRect(),n=s.getBoundingClientRect(),i=o.getBoundingClientRect(),t=r.getBoundingClientRect(),l=o.scrollTop+(e.top-i.top)+e.height/2,u=r.scrollTop+(n.top-t.top)+n.height/2,c=l-i.height/2,d=Math.max(0,c),v=o.scrollHeight-o.clientHeight,f=d>v?d-v:0,p=i.top+l-d,g=t.top+u-p,h=0;g<0&&(h=Math.abs(g),g=0);var m=r.scrollHeight-r.clientHeight+h,S=g>m?g-m:0;ti.current&&(ti.current.style.height="".concat(f,"px")),ei.current&&(ei.current.style.height="".concat(h,"px")),ni.current&&(ni.current.style.height="".concat(S,"px")),requestAnimationFrame(function(){o.scrollTo({top:d,behavior:"smooth"}),r.scrollTo({top:g,behavior:"smooth"}),Gn.current&&setTimeout(function(){return Gn.current()},50)})})}},[B]),No=s(function(){var e,n=si.sectionIdx,i=si.isOrphan;if(mi(),null!=n){var t="left";si.anchorEl&&(null===(e=Zn.current)||void 0===e?void 0:e.contains(si.anchorEl))&&(t="right"),Ot(n),ji&&(On(jo(n)),Bn(new Set([n]))),Bt(n,i,{sourceSide:t,onReady:function(){ji&&setTimeout(function(){return Lo(String(n))},150)}})}},[Bt,si.isOrphan,si.sectionIdx,si.anchorEl,mi,Ot,ji,Lo,jo]),Mo=s(function(){mi(),wt(),Bn(new Set),Fn([]),qn.current=[]},[mi,wt]),Ho=null!==si.sectionIdx&&wn.has(si.sectionIdx),zo=G({proposedSections:Mi,existingSections:Hi,parentDeviationRecord:Wi,expandedSections:Ft,maintainRelativeOrder:!!dn,scrollContainerRef:Un,leftContainerRef:oi,rightContainerRef:Zn,lhsBadgeRefs:Zi,rhsBadgeRefs:et}),Wo=zo.showDeviationNavigation,qo=zo.showOpenNodeRef,Go=zo.adjustScrollForPopup,Vo=s(function(e,n,i,t,o){var r,l="string"==typeof t?b(t).trim():b(null==t?void 0:t.deviation_summary).trim(),u=e.currentTarget;yi();var c="left";(null===(r=Zn.current)||void 0===r?void 0:r.contains(u))&&(c="right");var a=function(){var e,i,t,o;if("string"==typeof n&&n.includes(B)){var r=n.split(B),l="".concat(r[0]).concat(B).concat(r[1]);return"right"===c?null===(e=et.current[l])||void 0===e?void 0:e.current:null===(i=Zi.current[l])||void 0===i?void 0:i.current}return"right"===c?null===(t=et.current[n])||void 0===t?void 0:t.current:null===(o=Zi.current[n])||void 0===o?void 0:o.current};if(i&&!ji)return wt(),Bn(new Set),Fn([]),qn.current=[],void(l&&(Ot(n),requestAnimationFrame(function(){var e=a()||u;e&&(e.getBoundingClientRect().top>.8*window.innerHeight&&e.scrollIntoView({behavior:"smooth",block:"center"}));hi({open:!0,anchorEl:e,summary:t,displayImpact:o})})));Ot(n),ji&&(On(jo(n)),Bn(new Set([n]))),l?setTimeout(function(){Bt(n,i,{toggleIfSame:!1,sourceSide:c,onReady:function(){var e,i,r,l=a()||u;if(ji)setTimeout(function(){return Lo(n)},150);else if(l){var c=l.getBoundingClientRect();if(c.top>.8*window.innerHeight||c.top<100){var s=c.top-window.innerHeight/2;dn?(null===(e=oi.current)||void 0===e||e.scrollBy({top:s,behavior:"smooth"}),null===(i=Zn.current)||void 0===i||i.scrollBy({top:s,behavior:"smooth"})):null===(r=Un.current)||void 0===r||r.scrollBy({top:s,behavior:"smooth"})}}hi({open:!0,anchorEl:l,summary:t,displayImpact:o})}})},350):setTimeout(function(){Bt(n,i,{toggleIfSame:!1,sourceSide:c}),ji&&setTimeout(function(){return Lo(n)},150)},350)},[Bt,yi,hi,wt,Ot,ji,dn,Lo,Yn]),Ko=c(function(){var e;if(!en)return null;var n=null===(e=null==en?void 0:en.id)||void 0===e?void 0:e.split(":")[0];for(var i in Wi){if((Wi[i]||[]).some(function(e){return e.id===n}))return i}return null},[en,Wi]),Jo=u({id:null,triggerMs:null}),Yo=u(null);a(function(){if(null==en?void 0:en.id){var o=Number(en.trigger),r=Jo.current;if((null==r?void 0:r.id)!==en.id||(null==r?void 0:r.triggerMs)!==o){if(en.id.includes(":")&&/:\d+$/.test(en.id)){var l=en.id.split(":"),u=l[0],c=l[1],a=null!=c?c:"0",s="".concat(en.id,":").concat(o);Yo.current!==s&&(mi(),yi(),wt(),Bn(new Set),Fn([]),qn.current=[],Yo.current=s);var d=!1,v=0,f=null,p=null,g=!1,h=function(e,n){for(var i=function(e,t){if(!e)return null;if(n.includes(e.id)||n.includes(e.nodeId)||n.includes(e.contentId))return t;if(!Array.isArray(e.subsections))return null;for(var o=0;o<e.subsections.length;o++){var r=i(e.subsections[o],"".concat(t,"-").concat(o));if(r)return r}return null},t=0;t<e.length;t++){var o=i(e[t],String(t));if(o)return o}return null},m=function(){var r,l,c;if(!d){var s=function(){Jo.current={id:en.id,triggerMs:o}},S=null,x=null;for(var R in Wi){var b=Wi[R].find(function(e){var n;return e.id===u||e.nodeId===u||e.contentId===u||(null===(n=e.evaluationResult)||void 0===n?void 0:n.nodeId)===u});if(b){S=R,x=b;break}}if(x&&S){var y=Array.from(new Set([u,x.id,x.nodeId,x.contentId,null===(r=x.evaluationResult)||void 0===r?void 0:r.nodeId].filter(Boolean))),C=Mi.findIndex(function(e){return e.id===S}),w=Hi.findIndex(function(e){return e.id===S}),_=-1===C&&-1!==w,I=h(Mi,y),E=h(Hi,y);if(I&&!E&&!_){var A=I.split("-"),D=Number(A[0]);if(dn){var k=null===(c=null===(l=Mi[D])||void 0===l?void 0:l.refIndexes)||void 0===c?void 0:c[0],O=Hi.findIndex(function(e){return e.selfIndex===k});-1!==O&&(D=O)}E=n([D],A.slice(1),!0).join("-")}if(I||E){var P=I?Number(I.split("-")[0]):C,j=E?Number(E.split("-")[0]):w,L=j>=0?j:E?Number(E.split("-")[0]):-1,N=Mi[P],M=Hi[L],H=N&&!N.title&&!N.content,z=M&&!M.title&&!M.content,W=_||(!I&&!!E||H&&!z);if(W){if(!(dn?!!rr.current["right-".concat(j)]:!!rr.current[String(j)])&&j>=0)return kt(j,"right"),void(f=setTimeout(m,200))}else if(!(dn?!!rr.current["left-".concat(P)]:!!rr.current[String(P)])&&P>=0)return kt(P,"left"),void(f=setTimeout(m,200));var q=I||"",G=E||"",V=y.map(function(e){return"".concat(e).concat(B).concat(a)}),K=V[0],J=function(){for(var e,n,i=0,t=V;i<t.length;i++){var o=t[i],r=(null===(e=Zi.current[o])||void 0===e?void 0:e.current)||null,l=(null===(n=et.current[o])||void 0===n?void 0:n.current)||null;if(r||l)return{refId:o,left:r,right:l}}return{refId:K,left:null,right:null}},Y=function(e){return"".concat(e).concat(B).concat(q).concat(B).concat(G)};if(!g){Ot(Y(K)),g=!0,v=0;var X=function(){var e=J(),n=e.left,i=e.right;return W||!n&&!!i?i:n};return null==p||p(),void(f=setTimeout(function(){var e,n,i,t,o,r,l,u;d||(e=X,n=function(){d||(p=null,m())},t=0,o=null,r=null,l=performance.now(),u=function(){if(!d)if(performance.now()-l>3e3)n();else{var c=e();if(c&&0!==c.getBoundingClientRect().height){var a=c.getBoundingClientRect(),s=a.top,v=a.height,f=null!==o&&Math.abs(s-o)<.5,p=null!==r&&Math.abs(v-r)<.5;if(f&&p){if(++t>=5)return void n()}else t=0;o=s,r=v,i=requestAnimationFrame(u)}else i=requestAnimationFrame(u)}},i=requestAnimationFrame(u),p=function(){return cancelAnimationFrame(i)})},300))}var $=J(),U=$.refId,Q=$.left,Z=$.right,ee=Y(U);if(Q||Z){var ne=W||!Q&&!!Z,ie=ne?Z:Q,te=dn?ne?Zn.current:oi.current:Un.current;if(ie&&te){var oe=ie.getBoundingClientRect();if(0!==oe.height){var re=te.getBoundingClientRect(),le=oe.top-re.top+te.scrollTop-re.height/2+oe.height/2,ue=(null==I?void 0:I.includes("-"))||(null==E?void 0:E.includes("-")),ce=function(){return i(void 0,void 0,void 0,function(){var n,i,o,r,l,u,c,v,f,p;return t(this,function(t){switch(t.label){case 0:return d?[2]:(s(),n=ie instanceof Element?window.getComputedStyle(ie).color:"",[Q,Z].forEach(function(e){e&&(e.style.transition="box-shadow 300ms ease-in-out",e.style.boxShadow="0 0 10px ".concat(n))}),setTimeout(function(){[Q,Z].forEach(function(e){e&&(e.style.boxShadow="")})},2e3),i=(null===(c=null===(u=x.evaluationResult)||void 0===u?void 0:u.deviations)||void 0===c?void 0:c[a])||x,o=(null===(v=x.evaluationResult)||void 0===v?void 0:v.evaluation_outputs)||x.evaluation_outputs,!!Q&&!!Z||ji?(l=function(e,n){return Promise.race([e,new Promise(function(e){return setTimeout(e,n)})])},dn?[4,Promise.all([oi.current?l(T(oi.current),600):Promise.resolve(),Zn.current?l(T(Zn.current),600):Promise.resolve()])]:[3,2]):(r=ne?(null===(f=et.current[ue?U:j])||void 0===f?void 0:f.current)||Z:(null===(p=Zi.current[ue?U:P])||void 0===p?void 0:p.current)||Q,Go(r,function(){hi({open:!0,anchorEl:r,displayImpact:en.displayImpact,summary:e(e({},i),{evaluation_outputs:o})})},{skipScroll:!0}),null==nn||nn(),[2]));case 1:t.sent(),t.label=2;case 2:return ji&&(On(jo(ee)),Bn(new Set([ee]))),_t.current(ee,!1,{toggleIfSame:!1,sourceSide:_?"right":"left",onReady:function(){var n,t,o,r;s();var l=ne?(null===(n=et.current[U])||void 0===n?void 0:n.current)||Z:(null===(t=Zi.current[U])||void 0===t?void 0:t.current)||Q;if(ji)setTimeout(function(){return Lo(ee)},150);else{var u=(null===(o=Zi.current[U])||void 0===o?void 0:o.current)||Q,c=(null===(r=et.current[U])||void 0===r?void 0:r.current)||Z;u&&(u.style.scrollMarginTop="150px",u.scrollIntoView({behavior:"smooth",block:"start"})),c&&(c.style.scrollMarginTop="150px",c.scrollIntoView({behavior:"smooth",block:"start"}))}hi({open:!0,anchorEl:l,displayImpact:en.displayImpact,summary:e({},i)}),null==nn||nn()}}),[2]}})})};Math.abs(te.scrollTop-le)<=2?ce():F(te,le,ce)}else++v<30&&(f=setTimeout(m,100))}else++v<30&&(f=setTimeout(m,100))}else++v<30&&(f=setTimeout(m,100))}else++v<30&&(f=setTimeout(m,100))}else++v<30&&(f=setTimeout(m,100))}};return f=setTimeout(m,100),function(){d=!0,f&&clearTimeout(f),null==p||p()}}Jo.current={id:en.id,triggerMs:o},po(en.id);var S=Mi.findIndex(function(e){return e.id===en.id}),x=Hi.findIndex(function(e){return e.id===en.id});-1===S&&-1===x||setTimeout(function(){var e=-1!==S?S:x,n=-1===S;ji&&On(jo(e)),Bn(new Set([e])),_t.current(e,n,{sourceSide:n?"right":"left",onReady:function(){ji&&setTimeout(function(){return Lo(String(e))},150)}})},400)}}},[null==en?void 0:en.id,null==en?void 0:en.trigger,null==en?void 0:en.displayImpact,Wi,Mi,Hi,dn,hi,po,ji,jo,Lo]),a(function(){var n,i,t;if(gi.open){var o=gi.anchorEl;if(o&&!o.isConnected){var r=function(e){for(var n,i=0,t=Object.entries(e);i<t.length;i++){var r=t[i],l=r[0];if((null===(n=r[1].current)||void 0===n?void 0:n.textContent)===o.textContent)return l}return null},l=(null===(n=o.dataset)||void 0===n?void 0:n.deviationRefId)||r(Zi.current)||r(et.current);if(l){var u=(null===(i=et.current[l])||void 0===i?void 0:i.current)||(null===(t=Zi.current[l])||void 0===t?void 0:t.current);u&&u.isConnected&&hi(function(n){return e(e({},n),{anchorEl:u})})}}}},[gi.open,gi.anchorEl,En,wn,Ft]);var Xo=ci.open,$o=ci.sectionIdx,Uo=ci.isOrphan,Qo=ci.badgeStyle,Zo=ci.anchorEl,er=ci.sectionAnchorEl;a(function(){var n;if(Xe.isStreamingEnabled&&Xo&&null!=$o&&$o!==zt){var i="string"==typeof $o?$o.split(B)[0]:null,t=function(e,n){var i;if(!e||!Array.isArray(e))return null;for(var o=0,r=e;o<r.length;o++){var l=r[o];if(l.id===n)return l;if(null===(i=l.subsections)||void 0===i?void 0:i.length){var u=t(l.subsections,n);if(u)return u}}return null},o=i&&"string"==typeof i?t(Mi,i):null,r=i&&"string"==typeof i?t(Hi,i):null,l="number"==typeof $o?Mi[$o]||null:o||i&&((null===(n=null==We?void 0:We.nodes)||void 0===n?void 0:n[i])||(null==We?void 0:We[i]))||null,u="number"==typeof $o?Hi[$o]||null:r,c=ao(Zo,l,u,$o,Uo,Qo);ai(function(n){return n.open?b(n.cognitiveData)===b(c.cognitiveData)&&b(n.deviationData)===b(c.deviationData)&&n.sectionTitle===c.sectionTitle&&n.refSectionTitle===c.refSectionTitle?n:e(e(e({},n),c),{open:!0,anchorEl:n.anchorEl,sectionAnchorEl:n.sectionAnchorEl}):n})}},[Xo,$o,Uo,Qo,Zo,er,Mi,Hi,ao]);var nr=s(function(e){var n=e.section,i=e.keyPath,t=e.depth,r=void 0===t?0:t,l=e.columnKey,u=void 0===l?"left":l,c=e.parentNodeId,a=void 0===c?"":c,s=e.sectionOffset,d=e.rhsOrphanVisualIndexes;return o(K,{section:n,keyPath:i,depth:r,columnKey:u,parentNodeId:a,sectionOffset:s,rhsOrphanVisualIndexes:d})},[]),ir=c(function(){return Mi.map(function(e,n){var i,t,r=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),l=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return r&&l&&dn?null:o(J,{section:e,idx:n},null!==(t=null!==(i=null==e?void 0:e.layoutKey)&&void 0!==i?i:null==e?void 0:e.id)&&void 0!==t?t:"left-row-".concat(n))})},[Mi,dn]),tr=c(function(){return Hi.map(function(e,n){var i,t,r=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),l=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return r&&l&&dn?null:o(Y,{section:e,idx:n},null!==(t=null!==(i=null==e?void 0:e.layoutKey)&&void 0!==i?i:null==e?void 0:e.id)&&void 0!==t?t:"right-row-".concat(n))})},[Hi,dn]),or=u(so);a(function(){or.current=so},[so]);var rr=u(Ft);a(function(){rr.current=Ft},[Ft]);var lr=u(Vo);a(function(){lr.current=Vo},[Vo]);var ur=u(Mo);a(function(){ur.current=Mo},[Mo]);var cr=u(kt);a(function(){cr.current=kt},[kt]);var ar=u(Dt);a(function(){ar.current=Dt},[Dt]);var sr=u(nr);a(function(){sr.current=nr},[nr]);var dr=u(wt);a(function(){dr.current=wt},[wt]);var vr=c(function(){return{isGuidelineMode:ji,maintainRelativeOrder:!!dn,showDeviationBadges:gn,isProposingFix:on,proposingFixNodeId:rn,isRedlineFlow:ln,isSideBySide:at,activeSideBySideSection:gt,scrollSyncLocked:En,toggleScrollSyncLocked:jt,summaryPopupAnchorEl:gi.anchorEl,connectedSections:wn,proposedSections:Mi,existingSections:Hi,deviationNumberRegistry:qi,deviationParentRegistry:Gi,treeData:We,displayConfig:Xe,resolvedMarkdownStyles:$n,unifiedNumbering:Lt,expandedSections:Ft,expandedSubSections:Et,setExpandedSubSections:At,getSectionCompareStyle:xo,getSubSectionCompareStyle:Ro,getBadgeRef:ut,getSectionRowRef:rt,getSubSectionRef:lt,sectionLeftRefs:Ui,sectionRightRefs:Qi,sectionRowRefs:ot,sectionRightRowRefs:nt,subSectionLeftRefs:it,subSectionRightRefs:tt,lhsBadgeRefs:Zi,rhsBadgeRefs:et,openMoreFunctionsPopup:Yt,handleOpenSummaryPopup:Xt,openSummaryPopup:Xt,handleCloseSummaryPopup:$t,toggleSection:Ut,handleSubSectionToggle:Qt,renderSubSectionAccordion:Zt,resetSideBySide:eo,setConnectedSections:Bn,setConnectedLines:Fn,cachedConnectedPositions:qn,showDeviationNavigation:Wo,showOpenNodeRef:qo,deviationNodeIdToView:null==en?void 0:en.id,deviationTargetParentId:Ko,guidelinesData:cn,gptWebCitationConfig:an}},[ji,dn,gn,on,rn,ln,at,gt,En,jt,gi.anchorEl,wn,Mi,Hi,qi,Xe,$n,Lt,Ft,Et,At,xo,Ro,ut,rt,lt,Wo,qo,en,Ko,cn,an]),fr=b(ci.sectionTitle||Ai||Ti),pr=b(ji?ki||Oi||ci.refSectionTitle:ci.refSectionTitle||ki||Oi);return o($,e({value:vr},{children:r(d,e({ref:Qn,sx:{display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif',overflow:"visible",position:"relative"}},{children:[mn&&o(d,e({sx:{position:"absolute",inset:0,bgcolor:"rgba(255, 255, 255, 0.6)",backdropFilter:"blur(10px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"8px"}},{children:o(N,{})})),gi.open&&o(X,{open:gi.open,anchorEl:gi.anchorEl,containerEl:ho.current,clipTopEl:Ln.current,scrollContainerEl:Un.current,onClose:Mo,summary:gi.summary,displayImpact:gi.displayImpact,isScrollLocked:En}),o(L,{open:si.open,anchorEl:si.anchorEl,maintainRelativeOrder:!!dn,sectionTitle:si.sectionTitle,referenceSectionTitle:si.refSectionTitle,onClose:Ci,onOpenCognitiveCompare:Ri,onOpenSideBySide:No,onConnect:vo,isConnected:Ho,isOrphan:!ji&&!!si.isOrphan,isGuidelineMode:ji,hasGuidelineMatches:si.hasGuidelineMatches}),ci.open&&o(j,{open:ci.open,popupRef:xi,position:vi,popupConfig:Ue,onClose:function(){fi(null),ai(function(n){return e(e({},n),{open:!1})}),Si(null)},markdownStyles:Ke,sectionTitle:fr,referenceSectionTitle:pr,cognitiveData:ci.cognitiveData,anchorEl:ci.anchorEl,sectionAnchorEl:ci.sectionAnchorEl,scrollContainerEl:Un.current,badgeStyle:ci.badgeStyle,docData:ci.docData,deviationData:ci.deviationData,isLoading:ci.isLoading}),o(v,e({open:!!Rn,autoHideDuration:8e3,onClose:function(){return bn(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:o(f,e({onClose:function(){return bn(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:Rn}))})),o(V,{componentHeaderText:ze,displayConfig:Xe,maintainRelativeOrder:dn,onCollapseAll:To,showCollapseAll:Eo,onToggleView:function(e){Sn(!0),setTimeout(function(){vn(!e),null==$e||$e(!e),An(!1),wt(),mi(),Bn(new Set),Fn([]),qn.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){Sn(!1)},600)})})},50)}}),o(d,e({ref:Un,onScroll:Fo,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:dn?"visible":"auto",borderTop:Mt&&Ht?"none":"1.5px solid #EEF0F4"}},{children:o(d,e({sx:e({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},dn?{flex:1}:{})},{children:r(d,e({ref:jn,sx:e({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"100px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},dn?{flex:1,overflow:"visible"}:{})},{children:[o(ne,{svgContainerRef:Pn,svgDimensions:Io,isResizing:vt,overallConnector:Bo,rootDeviationStyle:Gt,lines:Co,isSideBySide:at,activeSideBySideSection:gt,isArrowVisible:st,maintainRelativeOrder:dn,proposedSections:Mi,existingSections:Hi,cognitivePopup:ci,activeBadgeId:pi,closeCognitivePopup:yi,setActiveBadgeId:Si,openCognitivePopupFromState:bi,buildSectionPopupState:ao,connectedLines:In,isGuidelineMode:ji,pathRefs:Wn}),r(d,e({sx:e({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},dn?{flex:1,overflow:"visible"}:{})},{children:[o(d,e({ref:Ln,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center",minHeight:"40px",overflow:"hidden",minWidth:0}},{children:o(p,e({title:Ti,placement:"top"},{children:o(g,e({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:Ti}))}))})),r(d,e({ref:oi,onScroll:Fo,sx:e({p:"12px",display:"flex",flexDirection:"column"},dn?{maxHeight:"calc(100vh - 250px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-180px",pr:"192px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[o("div",{ref:ii,style:{width:"100%",height:"0px",flexShrink:0}}),Ki&&ir,o("div",{ref:ti,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),o(d,e({ref:ho,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:o(d,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:r(d,e({onClick:function(n){n.stopPropagation(),ci.open&&pi===zt?yi():(Si(zt),bi(ao(n.currentTarget,{title:ro,content:"",evaluationResult:Wt,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,zt,!0,e(e({},Gt),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:Gt.badgeBg,color:Gt.badgeText,border:"1px solid ".concat(Gt.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=qt?qt:o(M,{}),o(d,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:o(x,{})})),o(S,{size:11,style:{transform:ci.open&&pi===zt?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),r(d,e({sx:e({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},dn?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[pt&&o(R,{sections:11}),o(d,e({ref:Nn,sx:e({p:"8px",bgcolor:ji?"#F1F3F5":"#F7F8FA",borderBottom:"1px solid #D7DCE2",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center"},dn?e({maxHeight:"calc(100vh - 250px)",overflowY:"auto",overflowX:"hidden",minHeight:0},ji?{"&::-webkit-scrollbar":{width:"6px",display:"block"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{background:"#CBD5E1",borderRadius:"10px"},"&::-webkit-scrollbar-thumb:hover":{background:"#94A3B8"},scrollbarWidth:"thin",scrollbarColor:"#CBD5E1 transparent"}:{"&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}):{})},{children:ji?r(h,e({value:kn,onChange:function(e,n){return On(n)},variant:"fullWidth",TabIndicatorProps:{sx:{display:"none"}},sx:{width:"100%",minHeight:"36px","& .MuiTab-root":{minHeight:"36px",px:1,py:0,borderRadius:"8px",fontSize:"14px",lineHeight:1,fontWeight:500,textTransform:"none",color:"#374151",minWidth:0,transition:"background-color 160ms ease, box-shadow 160ms ease"},"& .Mui-selected":{color:"#374151",bgcolor:"#FFFFFF"}}},{children:[o(m,{label:o(p,e({title:Oi,placement:"top"},{children:o(d,e({component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block",width:"100%"}},{children:"Redline Guidelines"}))}))}),o(m,{label:o(p,e({title:"Web & GPT Sources",placement:"top"},{children:o(d,e({component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block",width:"100%"}},{children:"Web & GPT Sources"}))}))})]})):o(p,e({title:Oi,placement:"top"},{children:o(g,e({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:Oi}))}))})),r(d,e({ref:Zn,onScroll:Fo,sx:e({p:ji?"0px":"12px",display:"flex",flexDirection:"column"},dn?e(e({maxHeight:"calc(100vh - 250px)"},!ji&&{flex:1}),{overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-150px",pl:"165px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}):{})},{children:[o("div",{ref:ei,style:{width:"100%",height:"0px",flexShrink:0}}),ji?0===kn?o(ie,{guidelinesData:cn,deviationData:Ze,connectedSections:wn,proposedSections:Mi}):o(te,{deviationData:Ze,connectedSections:wn,proposedSections:Mi}):Ki&&tr,o("div",{ref:ni,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))}))};export{oe as default};
2
2
  //# sourceMappingURL=CognitiveCompare.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as r}from"tslib";import{jsx as o}from"react/jsx-runtime";import{useMemo as e}from"react";import{Box as i}from"@mui/material";import t from"react-markdown";import l from"rehype-raw";import{SHARED_MARKDOWN_STYLES as a}from"../../CognitiveCompareConfig.js";import{generateColorPalette as n}from"../../CognitiveComparehelpers.js";import{processGuidelinesMarkdown as s}from"../utils/processGuidelinesMarkdown.js";import{resolveGuidelineSelection as m}from"../utils/resolveGuidelineSelection.js";var p=function(p){var g=p.guidelinesData,u=p.deviationData,d=p.connectedSections,f=p.proposedSections,c=Array.from(d)[0],h=e(function(){if(null==c||!u)return{targetHighlights:[],labelColor:""};var r=m({activeIdentifier:c,deviationData:u,proposedSections:f}),o=r.labelColor?n(r.labelColor):null;return{targetHighlights:r.targetHighlights,labelColor:(null==o?void 0:o.bg)||""}},[c,u,f]),v=h.targetHighlights,C=h.labelColor,b=e(function(){return s({guidelinesData:g,targetHighlights:v,labelColor:C||"#FEF08A"})},[g,v,C]);return o(i,r({sx:r(r({padding:"0px 12px",backgroundColor:"#FFFFFF",borderRadius:"8px"},a),{overflow:"visible"})},{children:o(t,r({rehypePlugins:[l]},{children:b}))}))};export{p as default};
1
+ import{__spreadArray as o,__assign as i}from"tslib";import{jsx as r}from"react/jsx-runtime";import{useMemo as e}from"react";import{Box as t}from"@mui/material";import l from"react-markdown";import a from"rehype-raw";import{SHARED_MARKDOWN_STYLES as n}from"../../CognitiveCompareConfig.js";import{DEVIATION_BADGE_SEPARATOR as u,generateColorPalette as d}from"../../CognitiveComparehelpers.js";import{processGuidelinesMarkdown as s}from"../utils/processGuidelinesMarkdown.js";var g=function(g){var v=g.guidelinesData,p=g.deviationData,m=g.connectedSections,f=g.proposedSections,h=Array.from(m)[0],c=e(function(){var i;if(null==h||!p)return{targetHighlights:[],labelColor:""};var r="";"number"==typeof h?r=(null===(i=f[h])||void 0===i?void 0:i.nodeId)||"":"string"==typeof h&&(r=h.includes(u)?h.split(u)[0]:h.split("::")[0].split(":")[0]);var e=p[r];if(!e)return{targetHighlights:[],labelColor:""};var t=[],l=e.evaluation_result||{},a="";return Object.values(l).forEach(function(i){var r,e,l,n,u;(null===(r=null==i?void 0:i.deviation_highlights)||void 0===r?void 0:r.rulebook_guidelines)&&(t=o(o([],t,!0),i.deviation_highlights.rulebook_guidelines,!0),a=(null===(l=null===(e=i.evaluation_outputs)||void 0===e?void 0:e.metadata)||void 0===l?void 0:l.label_color)?d(null===(u=null===(n=i.evaluation_outputs)||void 0===n?void 0:n.metadata)||void 0===u?void 0:u.label_color).bg:"")}),{targetHighlights:t.filter(Boolean),labelColor:a}},[h,p,f]),b=c.targetHighlights,C=c.labelColor,_=e(function(){return s({guidelinesData:v,targetHighlights:b,labelColor:C||"#FEF08A"})},[v,b,C]);return r(t,i({sx:i(i({padding:"0px 12px",backgroundColor:"#FFFFFF",borderRadius:"8px"},n),{overflow:"visible"})},{children:r(l,i({rehypePlugins:[a]},{children:_}))}))};export{g as default};
2
2
  //# sourceMappingURL=GuidelinePanel.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e,__rest as r}from"tslib";import{jsx as n}from"react/jsx-runtime";import{useMemo as o}from"react";import{Box as t,Typography as a}from"@mui/material";import i from"react-markdown";import d from"rehype-raw";import{SHARED_MARKDOWN_STYLES as u}from"../../CognitiveCompareConfig.js";import{generateColorPalette as l}from"../../CognitiveComparehelpers.js";import c from"../../CitationAnchor.js";import{resolveGuidelineSelection as v}from"../utils/resolveGuidelineSelection.js";var s=function(e){var r,n,o=e.evalNode;return!1===(null===(n=null===(r=null==o?void 0:o.evaluation_outputs)||void 0===r?void 0:r.guideline_flag)||void 0===n?void 0:n.rulebook_used)},p=function(e,r,n){return"".concat(e,"::").concat(r,"::").concat(n)},f=function(e,r){return"".concat(e,"::").concat(r)},w={relativeWrapper:{verticalAlign:"baseline"},arrow:{color:"#6D28D9"}},y=function(y){var b=y.deviationData,m=y.connectedSections,h=y.proposedSections,g=Array.from(m||[])[0],K=o(function(){return v({activeIdentifier:g,deviationData:b,proposedSections:h||[]})},[g,b,h]),x=o(function(){if(!b||"object"!=typeof b)return[];return Object.entries(b).flatMap(function(e){var r=e[0];return function(e){var r=e&&"object"==typeof e?e.evaluation_result:null;return!r||"object"!=typeof r&&!Array.isArray(r)?[]:Array.isArray(r)?r.map(function(e,r){return{evalNode:e,evaluationKey:String(r)}}):"object"==typeof r?Object.entries(r).map(function(e){var r=e[0];return{evalNode:e[1],evaluationKey:r}}):[]}(e[1]).filter(s).map(function(e){var n,o,t,a=e.evalNode,i=e.evaluationKey;return{nodeId:r,evaluationKey:i,answerKey:f(r,i),evaluation:a,webSearchAnswer:a.web_search_answer,colorPalette:null!==(t=l((null===(o=null===(n=null==a?void 0:a.evaluation_outputs)||void 0===n?void 0:n.metadata)||void 0===o?void 0:o.label_color)||""))&&void 0!==t?t:{border:w.arrow.color}}}).filter(function(e){var r=e.webSearchAnswer;return!!(null==r?void 0:r.enhanced_content)})}).map(function(r,n){return e(e({},r),{answerOrder:n})})},[b]),S=o(function(){var e;return null===(e=(null==K.evaluationKey?void 0:x.find(function(e){return e.nodeId===K.baseNodeId&&e.evaluationKey===K.evaluationKey}))||x.find(function(e){return e.nodeId===K.baseNodeId}))||void 0===e?void 0:e.answerKey},[K.baseNodeId,K.evaluationKey,x]),A=o(function(){return x.reduce(function(e,r){var n,o=(null===(n=r.webSearchAnswer)||void 0===n?void 0:n.extraMetaData)||{};return Object.entries(o).forEach(function(n){var o=n[0],t=n[1],a=p(r.nodeId,r.evaluationKey,o);e[a]={nodeId:r.nodeId,evaluationKey:r.evaluationKey,answerKey:r.answerKey,answerOrder:r.answerOrder,reasoningId:o,evaluation:r.evaluation,webSearchAnswer:r.webSearchAnswer,extraMetaData:t}}),e},{})},[x]),I=o(function(){return x.reduce(function(e,o){return e[o.answerKey]={a:function(e){var t=e.href,a=void 0===t?"":t,i=e.children,d=e.type,u=e.reason,l=r(e,["href","children","type","reason"]),v=null==l?void 0:l["data-cognitive-reasoning"],s=v?p(o.nodeId,o.evaluationKey,String(v)):"",f=s?A[s]:null;return n(c,{href:a,children:i,citationType:d,citationReason:u,metaData:{webGpt:f,webGptMetaKey:s},customStyle:w})}},e},{})},[x,A]);return n(t,e({sx:e(e({padding:"12px 12px 12px 0px",backgroundColor:"#FFFFFF",borderRadius:"8px"},u),{overflow:"visible"})},{children:x.length>0?x.map(function(r){var o=r.answerKey===S;return n(t,e({id:o?"guideline-target-0":void 0,"data-web-gpt-node-id":r.nodeId,"data-web-gpt-evaluation-key":r.evaluationKey,"data-web-gpt-answer-order":r.answerOrder,"data-web-gpt-active":o?"true":"false",sx:{mb:1.5,border:o?"2px solid ".concat(r.colorPalette.border):"1px solid #d3d3d3",borderRadius:"6px",padding:"8px",backgroundColor:"#FFFFFF"}},{children:n(i,e({rehypePlugins:[d],components:I[r.answerKey]},{children:r.webSearchAnswer.enhanced_content}))}),r.answerKey)}):n(a,e({sx:{color:"#64748B",fontSize:"14px",py:1}},{children:"No web GPT data available."}))}))};export{y as default};
1
+ import{__assign as e,__rest as r}from"tslib";import{jsx as n}from"react/jsx-runtime";import{useMemo as o}from"react";import{Box as t,Typography as a}from"@mui/material";import i from"react-markdown";import d from"rehype-raw";import{SHARED_MARKDOWN_STYLES as l}from"../../CognitiveCompareConfig.js";import{DEVIATION_BADGE_SEPARATOR as u,generateColorPalette as c}from"../../CognitiveComparehelpers.js";import s from"../../CitationAnchor.js";var v=function(e){var r,n,o=e.evalNode;return!1===(null===(n=null===(r=null==o?void 0:o.evaluation_outputs)||void 0===r?void 0:r.guideline_flag)||void 0===n?void 0:n.rulebook_used)},p=function(e,r,n){return"".concat(e,"::").concat(r,"::").concat(n)},f=function(e,r){return"".concat(e,"::").concat(r)},m={relativeWrapper:{verticalAlign:"baseline"},arrow:{color:"#6D28D9"}},w=function(w){var b=w.deviationData,y=w.connectedSections,h=w.proposedSections,g=Array.from(y||[])[0],x=o(function(){return function(e,r){var n;return"number"==typeof e?(null===(n=r[e])||void 0===n?void 0:n.nodeId)||"":e&&"string"==typeof e&&e.trim()?e.includes(u)?e.split(u)[0]:e.split("::")[0].split(":")[0]:""}(g,h||[])},[g,h]),K=o(function(){if(!b||"object"!=typeof b)return[];return Object.entries(b).flatMap(function(e){var r=e[0];return function(e){var r=e&&"object"==typeof e?e.evaluation_result:null;return!r||"object"!=typeof r&&!Array.isArray(r)?[]:Array.isArray(r)?r.map(function(e,r){return{evalNode:e,evaluationKey:String(r)}}):"object"==typeof r?Object.entries(r).map(function(e){var r=e[0];return{evalNode:e[1],evaluationKey:r}}):[]}(e[1]).filter(v).map(function(e){var n,o,t,a=e.evalNode,i=e.evaluationKey;return{nodeId:r,evaluationKey:i,answerKey:f(r,i),evaluation:a,webSearchAnswer:a.web_search_answer,colorPalette:null!==(t=c((null===(o=null===(n=null==a?void 0:a.evaluation_outputs)||void 0===n?void 0:n.metadata)||void 0===o?void 0:o.label_color)||""))&&void 0!==t?t:{border:m.arrow.color}}}).filter(function(e){var r=e.webSearchAnswer;return!!(null==r?void 0:r.enhanced_content)})}).map(function(r,n){return e(e({},r),{answerOrder:n})})},[b]),A=o(function(){return K.reduce(function(e,r){var n,o=(null===(n=r.webSearchAnswer)||void 0===n?void 0:n.extraMetaData)||{};return Object.entries(o).forEach(function(n){var o=n[0],t=n[1],a=p(r.nodeId,r.evaluationKey,o);e[a]={nodeId:r.nodeId,evaluationKey:r.evaluationKey,answerKey:r.answerKey,answerOrder:r.answerOrder,reasoningId:o,evaluation:r.evaluation,webSearchAnswer:r.webSearchAnswer,extraMetaData:t}}),e},{})},[K]),F=o(function(){return K.reduce(function(e,o){return e[o.answerKey]={a:function(e){var t=e.href,a=void 0===t?"":t,i=e.children,d=e.type,l=e.reason,u=r(e,["href","children","type","reason"]),c=null==u?void 0:u["data-cognitive-reasoning"],v=c?p(o.nodeId,o.evaluationKey,String(c)):"",f=v?A[v]:null;return n(s,{href:a,children:i,citationType:d,citationReason:l,metaData:{webGpt:f,webGptMetaKey:v},customStyle:m})}},e},{})},[K,A]);return n(t,e({sx:e(e({padding:"12px 12px 12px 0px",backgroundColor:"#FFFFFF",borderRadius:"8px"},l),{overflow:"visible"})},{children:K.length>0?K.map(function(r,o){return n(t,e({id:r.nodeId===x?"guideline-target-0":void 0,"data-web-gpt-node-id":r.nodeId,"data-web-gpt-evaluation-key":r.evaluationKey,"data-web-gpt-answer-order":r.answerOrder,"data-web-gpt-active":r.nodeId===x?"true":"false",sx:{mb:1.5,border:r.nodeId===x?"2px solid ".concat(r.colorPalette.border):"1px solid #d3d3d3",borderRadius:"6px",padding:"8px",backgroundColor:"#FFFFFF"}},{children:n(i,e({rehypePlugins:[d],components:F[r.answerKey]},{children:r.webSearchAnswer.enhanced_content}))}),r.answerKey)}):n(a,e({sx:{color:"#64748B",fontSize:"14px",py:1}},{children:"No web GPT data available."}))}))};export{w as default};
2
2
  //# sourceMappingURL=WebGptPanel.js.map
@@ -1,2 +1,2 @@
1
- var n=function(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")},t=function(n){return n.trim().replace(/\s+/g," ")},a=function(a){var r,i,o=a.guidelinesData,e=a.targetHighlights,c=void 0===e?[]:e,l=a.labelColor,u=void 0===l?"#FEF08A":l,d="";return"string"==typeof o?d=o:(null==o?void 0:o.learnings_data)&&"object"==typeof o.learnings_data?(r=o.learnings_data,i=new Set,d=Object.values(r).map(function(n){var a="string"==typeof(null==n?void 0:n.title)?n.title.trim():"",r="string"==typeof(null==n?void 0:n.instruction_prompt)?n.instruction_prompt.trim():"";if(!r)return"";var o="".concat(t(a),"\n").concat(t(r));return i.has(o)?"":(i.add(o),a?"# ".concat(a,"\n\n").concat(r):r)}).filter(Boolean).join("\n\n")):d=function(n){var t,a,r=null===(a=null===(t=null==n?void 0:n.data)||void 0===t?void 0:t.artifactData)||void 0===a?void 0:a.userStorySnapshot;if(!Array.isArray(r))return"";var i="";return r.forEach(function(n){(null==n?void 0:n.title)&&(i+="### ".concat(n.title,"\n\n")),(null==n?void 0:n.value)&&(i+="".concat(n.value,"\n\n")),Array.isArray(null==n?void 0:n.sub_features)&&n.sub_features.forEach(function(n){(null==n?void 0:n.title)&&(i+="#### ".concat(n.title,"\n\n")),(null==n?void 0:n.value)&&(i+="".concat(n.value,"\n\n"))})}),i.trim()}(o),function(a,r,i){var o=a,e=new Set,c=0;return r.forEach(function(a){if("string"==typeof a){var r=a.trim(),l=t(r).toLocaleLowerCase();if(l&&!e.has(l)){e.add(l);var u=r.split(/\s+/).map(n).join("\\s+"),d=new RegExp(u,"i").exec(o);if(d){var s='<mark id="guideline-target-'.concat(c,'" style="background-color: ').concat(i,'; border-radius: 3px; padding: 2px;">').concat(d[0],"</mark>");o="".concat(o.slice(0,d.index)).concat(s).concat(o.slice(d.index+d[0].length)),c+=1}}}}),o}(d,Array.isArray(c)?c:[],u||"#FEF08A")};export{a as processGuidelinesMarkdown};
1
+ var a=function(a){var n,t,e=a.guidelinesData,i=a.targetHighlights,o=void 0===i?[]:i,l=a.labelColor,r=void 0===l?"#FEF08A":l,c="";if((null==e?void 0:e.learnings_data)&&Object.keys(e.learnings_data).length>0){var u=Object.keys(e.learnings_data)[0],d=e.learnings_data[u];(null==d?void 0:d.instruction_prompt)&&(c=d.instruction_prompt)}else{((null===(t=null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.artifactData)||void 0===t?void 0:t.userStorySnapshot)||[]).forEach(function(a){var n;a.title&&(c+="### ".concat(a.title,"\n\n")),a.value&&(c+="".concat(a.value,"\n\n")),null===(n=a.sub_features)||void 0===n||n.forEach(function(a){a.title&&(c+="#### ".concat(a.title,"\n\n")),a.value&&(c+="".concat(a.value,"\n\n"))})})}return o.forEach(function(a,n){var t=a.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),e=new RegExp("(".concat(t,")"),"g");c=c.replace(e,'<mark id="guideline-target-'.concat(n,'" style="background-color: ').concat(r,'; border-radius: 3px; padding: 2px;">$1</mark>'))}),c};export{a as processGuidelinesMarkdown};
2
2
  //# sourceMappingURL=processGuidelinesMarkdown.js.map
@@ -1,2 +1,2 @@
1
- import{DEVIATION_BADGE_SEPARATOR as e}from"../../CognitiveComparehelpers.js";var i=function(i){var o,l=i.activeIdentifier,r=i.deviationData,t=i.proposedSections,a="",n=null;if("number"==typeof l){var u=t[l],v=(null==u?void 0:u.nodeId)||(null==u?void 0:u.id);a="string"==typeof v?v:""}else if("string"==typeof l){var d=l.split(e);a=d[0]||"",n=d.length>1&&""!==d[1]?d[1]:null}var s=null===(o=null==r?void 0:r[a])||void 0===o?void 0:o.evaluation_result;if(!s||"object"!=typeof s)return{baseNodeId:a,evaluationKey:n,evaluationNodes:[],targetHighlights:[],labelColor:""};var f=null==n?void 0:function(e,i){if(Array.isArray(e)){var o=Number(i);return Number.isInteger(o)?e[o]:void 0}return null==e?void 0:e[i]}(s,n),g=null==n?Object.values(s):f?[f]:[],p=new Set,c=[],h="";return g.forEach(function(e){var i,o,l,r=null===(i=null==e?void 0:e.deviation_highlights)||void 0===i?void 0:i.rulebook_guidelines;if(Array.isArray(r)&&r.forEach(function(e){if("string"==typeof e&&e.trim()){var i=e.trim().replace(/\s+/g," ").toLocaleLowerCase();p.has(i)||(p.add(i),c.push(e))}}),!h){var t=null===(l=null===(o=null==e?void 0:e.evaluation_outputs)||void 0===o?void 0:o.metadata)||void 0===l?void 0:l.label_color;"string"==typeof t&&(h=t)}}),{baseNodeId:a,evaluationKey:n,evaluationNodes:g,targetHighlights:c,labelColor:h}};export{i as resolveGuidelineSelection};
1
+ import{DEVIATION_BADGE_SEPARATOR as e}from"../../CognitiveComparehelpers.js";var i=function(i){var o,l=i.activeIdentifier,t=i.deviationData,r=i.proposedSections,a="",n=null;if("number"==typeof l){var u=r[l],v=(null==u?void 0:u.nodeId)||(null==u?void 0:u.id);a="string"==typeof v?v:""}else if("string"==typeof l){var d=l.split(e);a=d[0]||"",n=d.length>1&&""!==d[1]?d[1]:null}var s=null===(o=null==t?void 0:t[a])||void 0===o?void 0:o.evaluation_result;if(!s||"object"!=typeof s)return{baseNodeId:a,evaluationKey:n,evaluationNodes:[],targetHighlights:[],labelColor:""};var g=null==n?void 0:function(e,i){if(Array.isArray(e)){var o=Number(i);return Number.isInteger(o)?e[o]:void 0}return null==e?void 0:e[i]}(s,n),f=null==n?Object.values(s):g?[g]:[],h=new Set,p=[],c="";return f.forEach(function(e){var i,o,l,t=null===(i=null==e?void 0:e.deviation_highlights)||void 0===i?void 0:i.rulebook_guidelines;if(Array.isArray(t)&&(t.forEach(function(e){if("string"==typeof e&&e.trim()){var i=e.trim().replace(/\s+/g," ").toLocaleLowerCase();h.has(i)||(h.add(i),p.push(e))}}),console.log("LOG: Printing highlights",t,p,h)),!c){var r=null===(l=null===(o=null==e?void 0:e.evaluation_outputs)||void 0===o?void 0:o.metadata)||void 0===l?void 0:l.label_color;"string"==typeof r&&(c=r)}}),{baseNodeId:a,evaluationKey:n,evaluationNodes:f,targetHighlights:p,labelColor:c}};export{i as resolveGuidelineSelection};
2
2
  //# sourceMappingURL=resolveGuidelineSelection.js.map
@@ -1,2 +1,2 @@
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,_,g,h){var m,x;void 0===_&&(_=!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=[],I=c.base_root_id,h=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 x=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),g=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[h[0]]),"string"==typeof _?[_]:[],g(t),g(h[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[h[1]]),g(o),g(h[1])):[];l[n]=((r={})[h[0]]=x[0]||"",r[h[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=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,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(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,I=a(l,i,h,x).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,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},G={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:[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,b,_,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 I.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,I.fields]),P=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?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=!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 g=(null==_?void 0:_.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||_)})};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 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:_}},[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