@viswa-test/test-citation 0.0.232 → 0.0.234

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 (54) hide show
  1. package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js +1 -1
  2. package/dist/cjs/features/CognitiveCompare/MoreFunctionsPopup.js +1 -1
  3. package/dist/cjs/features/CognitiveCompare/components/SectionAccordion.js +1 -1
  4. package/dist/cjs/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
  5. package/dist/cjs/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
  6. package/dist/cjs/features/RequirementAI/components/RichTextEditor/Editor/Editor.js +1 -1
  7. package/dist/cjs/features/RequirementAI/components/RichTextEditor/Editor/plugins/ManualNode.js +1 -1
  8. package/dist/cjs/features/RequirementAI/components/RichTextEditor/Editor/plugins/UpdateNode.js +1 -1
  9. package/dist/cjs/features/RequirementAI/components/RichTextEditor/Editor/theme/theme.css.js +1 -1
  10. package/dist/cjs/features/RequirementAI/components/UserStoryCard/CognitiveComponents/CognitiveComponent.js +1 -1
  11. package/dist/cjs/features/RequirementAI/components/UserStoryCard/Popups/DeviationSummary.js +1 -1
  12. package/dist/cjs/features/RequirementAI/components/UserStoryCard/UserStoryCard.js +1 -1
  13. package/dist/cjs/features/RequirementAI/components/userstory-with-citation/components/InlineUpdatedComponent.js +1 -1
  14. package/dist/cjs/features/RequirementAI/utils/helpers.js +1 -1
  15. package/dist/features/CognitiveCompare/CognitiveCompare.js +1 -1
  16. package/dist/features/CognitiveCompare/MoreFunctionsPopup.js +1 -1
  17. package/dist/features/CognitiveCompare/components/SectionAccordion.js +1 -1
  18. package/dist/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
  19. package/dist/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
  20. package/dist/features/RequirementAI/components/RichTextEditor/Editor/Editor.js +1 -1
  21. package/dist/features/RequirementAI/components/RichTextEditor/Editor/plugins/ManualNode.js +1 -1
  22. package/dist/features/RequirementAI/components/RichTextEditor/Editor/plugins/UpdateNode.js +1 -1
  23. package/dist/features/RequirementAI/components/RichTextEditor/Editor/theme/theme.css.js +1 -1
  24. package/dist/features/RequirementAI/components/UserStoryCard/CognitiveComponents/CognitiveComponent.js +1 -1
  25. package/dist/features/RequirementAI/components/UserStoryCard/Popups/DeviationSummary.js +1 -1
  26. package/dist/features/RequirementAI/components/UserStoryCard/UserStoryCard.js +1 -1
  27. package/dist/features/RequirementAI/components/userstory-with-citation/components/InlineUpdatedComponent.js +1 -1
  28. package/dist/features/RequirementAI/utils/helpers.js +1 -1
  29. package/dist/types/src/RedlineEditorTest.d.ts.map +1 -1
  30. package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts.map +1 -1
  31. package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts +1 -0
  32. package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts.map +1 -1
  33. package/dist/types/src/features/CognitiveCompare/MoreFunctionsPopup.d.ts +2 -0
  34. package/dist/types/src/features/CognitiveCompare/MoreFunctionsPopup.d.ts.map +1 -1
  35. package/dist/types/src/features/CognitiveCompare/components/SectionAccordion.d.ts.map +1 -1
  36. package/dist/types/src/features/CognitiveCompare/components/SubSectionAccordion.d.ts.map +1 -1
  37. package/dist/types/src/features/CognitiveCompare/hooks/useLinesCalculator.d.ts.map +1 -1
  38. package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/Editor.d.ts.map +1 -1
  39. package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/plugins/ManualNode.d.ts +6 -2
  40. package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/plugins/ManualNode.d.ts.map +1 -1
  41. package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/plugins/UpdateNode.d.ts +6 -2
  42. package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/plugins/UpdateNode.d.ts.map +1 -1
  43. package/dist/types/src/features/RequirementAI/components/UserStoryCard/CognitiveComponents/CognitiveComponent.d.ts +2 -2
  44. package/dist/types/src/features/RequirementAI/components/UserStoryCard/CognitiveComponents/CognitiveComponent.d.ts.map +1 -1
  45. package/dist/types/src/features/RequirementAI/components/UserStoryCard/Popups/DeviationSummary.d.ts +16 -10
  46. package/dist/types/src/features/RequirementAI/components/UserStoryCard/Popups/DeviationSummary.d.ts.map +1 -1
  47. package/dist/types/src/features/RequirementAI/components/UserStoryCard/UserStoryCard.d.ts +1 -2
  48. package/dist/types/src/features/RequirementAI/components/UserStoryCard/UserStoryCard.d.ts.map +1 -1
  49. package/dist/types/src/features/RequirementAI/components/userstory-with-citation/UserStoryWithCitation.d.ts +4 -0
  50. package/dist/types/src/features/RequirementAI/components/userstory-with-citation/UserStoryWithCitation.d.ts.map +1 -1
  51. package/dist/types/src/features/RequirementAI/components/userstory-with-citation/components/InlineUpdatedComponent.d.ts.map +1 -1
  52. package/dist/types/src/features/RequirementAI/types/aiReasoning.type.d.ts +1 -0
  53. package/dist/types/src/features/RequirementAI/types/aiReasoning.type.d.ts.map +1 -1
  54. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),i=require("react"),t=require("@mui/material"),o=require("lucide-react"),r=require("../../assests/svg/ButtonCognitiveIcon.js"),l=require("./OverlayComponent.js"),s=require("./CognitiveComparehelpers.js"),u=require("./CognitiveCompareConfig.js"),a=require("./CognitiveCompareConstants.js"),c=require("./CognitivePopup.js"),d=require("./MoreFunctionsPopup.js"),f=require("./LoaderComponent.js"),v=require("./components/ThreeDotsLoader.js"),g=require("./hooks/useCompareData.js"),p=require("./hooks/useComparePopups.js"),h=require("./hooks/useSectionRefs.js"),m=require("./hooks/useAccordionState.js"),S=require("./hooks/useDeviationNavigation.js"),R=require("./components/CompareHeader.js"),x=require("./components/SubSectionAccordion.js"),_=require("./components/LHSSectionRow.js"),b=require("./components/RHSSectionRow.js"),y=require("./components/CognitiveSummaryPopup.js"),C=require("./CompareContext.js"),E=require("./hooks/useStyles.js"),A=require("./hooks/useResizeHandler.js"),B=require("./hooks/useLinesCalculator.js"),w=require("./hooks/useSideBySide.js"),I=require("./components/SvgConnectors.js"),T=require("./Guidelines/components/GuidelinePanel.js");exports.SHARED_MARKDOWN_STYLES=u.SHARED_MARKDOWN_STYLES,exports.default=function(D){var O,F,j,k,P,N,L,M,q,H,V,z,G,W,K,U,Y,J,X,$,Q,Z,ee,ne,ie,te,oe,re,le,se,ue,ae,ce,de,fe,ve=D.componentHeaderText,ge=void 0===ve?a.DEFAULT_COMPONENT_HEADER_TEXT:ve,pe=D.treeData,he=D.comparisonConfig,me=D.leftColumnTitleText,Se=D.rightColumnTitleText,Re=D.markdownStyles,xe=D.resetTrigger,_e=D.displayConfig,be=void 0===_e?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1,displayEmailNotifier:!0,isStreamingEnabled:!1}:_e,ye=D.onMaintainRelativeOrderChange,Ce=D.popupConfig,Ee=D.deviationData,Ae=void 0===Ee?{}:Ee,Be=D.deviationNodeIdToView,we=D.resetDeviationNodeId,Ie=D.isProposingFix,Te=void 0!==Ie&&Ie,De=D.proposingFixNodeId,Oe=D.isRedlineFlow,Fe=D.badgeStyleOverride,je=D.guidelinesData,ke=i.useState(be.maintainRelativeOrder),Pe=ke[0],Ne=ke[1],Le=null!==(O=null==be?void 0:be.expandLevels)&&void 0!==O?O:0,Me=!!(null==be?void 0:be.expandAllSections),qe=!!Pe||!!(null==be?void 0:be.showDeviationBadges),He=i.useState(!1),Ve=He[0],ze=He[1],Ge=i.useState(null),We=Ge[0],Ke=Ge[1],Ue=i.useState(null===(j=null!==(F=null==pe?void 0:pe.newEvaluationResult)&&void 0!==F?F:null==be?void 0:be.enableDeviationSchemaBackwardCompatibility)||void 0===j||j)[0],Ye=i.useState(new Set),Je=Ye[0],Xe=Ye[1],$e=i.useState([]),Qe=$e[0],Ze=$e[1],en=i.useState(!1),nn=en[0],tn=en[1],on=i.useRef(null),rn=i.useRef(null),ln=i.useRef(null),sn=i.useRef(null),un=i.useRef(null),an=i.useRef(!1),cn=i.useRef(null),dn=i.useRef({}),fn=i.useRef([]),vn=i.useRef(function(){}),gn=i.useRef(null),pn=i.useRef(function(){}),hn=i.useMemo(function(){return JSON.stringify(Ae||{})},[JSON.stringify(Ae)]),mn=i.useMemo(function(){return Ae||{}},[hn]),Sn=i.useMemo(function(){return(null==pe?void 0:pe.cognitive_decisioning)||{}},[pe]),Rn=i.useMemo(function(){return e.__assign(e.__assign({},u.SHARED_MARKDOWN_STYLES),Re)},[Re]),xn=i.useRef(null),_n=i.useRef(null),bn=i.useRef(null),yn=i.useRef(null),Cn=i.useRef(null),En=i.useRef(null),An=i.useRef(null),Bn=i.useRef(null),wn=i.useRef(null),In=i.useRef(null),Tn=p.useComparePopups(xn),Dn=Tn.cognitivePopup,On=Tn.setCognitivePopup,Fn=Tn.moreFunctions,jn=Tn.setMoreFunctions,kn=Tn.position,Pn=Tn.setPosition,Nn=Tn.activeBadgeId,Ln=Tn.summaryPopup,Mn=Tn.setSummaryPopup,qn=Tn.closeSummaryPopup,Hn=Tn.setActiveBadgeId,Vn=Tn.popupRef,zn=Tn.handleOpenCognitiveCompare,Gn=Tn.openCognitivePopupFromState,Wn=Tn.closeCognitivePopup,Kn=Tn.closeMoreFunctionsPopup,Un=i.useMemo(function(){var e,n,i,t,o,r,l;return{fields:null!==(e=null==he?void 0:he.fields)&&void 0!==e?e:u.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(i=null===(n=null==he?void 0:he.thresholds)||void 0===n?void 0:n.high)&&void 0!==i?i:u.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(o=null===(t=null==he?void 0:he.thresholds)||void 0===t?void 0:t.medium)&&void 0!==o?o:u.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(l=null===(r=null==he?void 0:he.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:u.DEFAULT_COMPARISON_CONFIG.thresholds.exact}}},[he]),Yn=i.useState(null),Jn=Yn[0];Yn[1];var Xn=null===(N=null===(k=null==pe?void 0:pe.documents)||void 0===k?void 0:k[null===(P=null==pe?void 0:pe.input_index_map)||void 0===P?void 0:P[0]])||void 0===N?void 0:N.title,$n=null===(q=null===(L=null==pe?void 0:pe.documents)||void 0===L?void 0:L[null===(M=null==pe?void 0:pe.input_index_map)||void 0===M?void 0:M[1]])||void 0===q?void 0:q.title,Qn=s.safeStringify(me||Xn||"Uploaded Contract"),Zn=null===(G=null===(z=null===(H=null==pe?void 0:pe.documents)||void 0===H?void 0:H[null===(V=null==pe?void 0:pe.input_index_map)||void 0===V?void 0:V[0]])||void 0===z?void 0:z.metadata)||void 0===G?void 0:G.file_name,ei=s.safeStringify(Zn),ni=null===(Y=null===(U=null===(W=null==pe?void 0:pe.documents)||void 0===W?void 0:W[null===(K=null==pe?void 0:pe.input_index_map)||void 0===K?void 0:K[1]])||void 0===U?void 0:U.metadata)||void 0===Y?void 0:Y.file_name,ii=s.safeStringify(ni),ti=s.safeStringify(Se||$n||"Reference Template"),oi=g.useCognitiveTreeData(pe,Pe,mn,Un,Ue,je),ri=oi.isGuidelineMode,li=oi.activeProposed,si=oi.existingRule,ui=oi.proposedSections,ai=oi.existingSections,ci=oi.visibleFields,di=oi.parentDeviationRecord,fi=oi.deviationNumberRegistry,vi=oi.deviationParentRegistry,gi=oi.parseError;i.useEffect(function(){gi&&Ke("Failed to load comparison: ".concat(gi))},[gi]);var pi=ui.length>0||ai.length>0,hi=i.useMemo(function(){if(!Oe)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)||"";s.hasMeaningfulRedlineTags(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(ui),i(ai),"".concat(e,":").concat(n)},[Oe,ui,ai]);i.useEffect(function(){if(ui.length||ai.length)if(Me){var e={},n={},i=function(i,t){i.forEach(function(i,o){var r,l=Pe?"".concat(t,"-").concat(o):String(o);e[l]=!0;var s=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)&&s(e.subsections,r)})};(null===(r=i.subsections)||void 0===r?void 0:r.length)&&s(i.subsections,String(o))})};i(ui,"left"),i(ai,"right"),$i(e),Zi(n)}else if(Le>0){var t={},o={},r=function(e,n,i){e.forEach(function(e,r){var l;if(i>=1){var s=Pe?"".concat(n,"-").concat(r):String(r);t[s]=!0}var u=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)&&u(e.subsections,l,t+1)})};(null===(l=e.subsections)||void 0===l?void 0:l.length)&&i>=2&&u(e.subsections,String(r),2)})};r(ui,"left",Le),r(ai,"right",Le),$i(t),Zi(o)}},[Me,Le,ui,ai,Pe]);var mi=h.useSectionRefs(ci.map(function(e){return e.key}),Math.max(ui.length,ai.length)),Si=mi.leftRefs,Ri=mi.rightRefs,xi=mi.sectionLeftRefs,_i=mi.sectionRightRefs,bi=mi.lhsBadgeRefs,yi=mi.rhsBadgeRefs,Ci=mi.sectionRightRowRefs,Ei=mi.subSectionLeftRefs,Ai=mi.subSectionRightRefs,Bi=mi.sectionRowRefs,wi=mi.getSectionRowRef,Ii=mi.getSubSectionRef,Ti=mi.getBadgeRef,Di=w.useSideBySide({isGuidelineMode:ri,maintainRelativeOrder:Pe,proposedSections:ui,existingSections:ai,leftContainerRef:Bn,rightContainerRef:bn,scrollContainerRef:xn,sectionLeftRefs:xi,sectionRightRefs:_i,subSectionLeftRefs:Ei,subSectionRightRefs:Ai,lhsBadgeRefs:bi,rhsBadgeRefs:yi,sectionRowRefs:Bi,sectionRightRowRefs:Ci,rhsTopSpacerRef:yn,rhsBottomSpacerRef:Cn,lhsTopSpacerRef:En,lhsBottomSpacerRef:An,calculateLinesRef:vn,setConnectedSections:Xe,setConnectedLines:Ze,cachedConnectedPositions:fn,closeMoreFunctionsPopup:Kn,setErrorToast:Ke,moreFunctions:Fn,closeSummaryPopup:qn}),Oi=Di.isSideBySide,Fi=Di.isArrowVisible,ji=Di.setIsArrowVisible,ki=Di.isResizing,Pi=Di.setIsResizing,Ni=Di.isSideBySideLoading,Li=Di.activeSideBySideSection,Mi=Di.scrollLock,qi=Di.sideBySideCacheRef,Hi=Di.isSideBySideRef,Vi=Di.activeSideBySideRightSectionRef,zi=Di.activeSideBySideSectionRef,Gi=Di.sideBySideLineRef,Wi=Di.highlightedClauseRefs,Ki=Di.clearClauseHighlight,Ui=Di.resetSideBySide,Yi=Di.activateSideBySide,Ji=m.useAccordionState({maintainRelativeOrder:!!Pe,proposedSections:ui,existingSections:ai,activeSideBySideSection:Li,connectedSections:Je,resetSideBySide:Ui,setConnectedSections:Xe,setConnectedLines:Ze,cachedConnectedPositions:fn,svgContainerRef:on,isAnimatingRef:an,animationTimerRef:cn,calculateLinesRef:vn,sectionLeftRefs:xi,sectionRightRefs:_i,subSectionLeftRefs:Ei,subSectionRightRefs:Ai}),Xi=Ji.expandedSections,$i=Ji.setExpandedSections,Qi=Ji.expandedSubSections,Zi=Ji.setExpandedSubSections,et=Ji.handleSubSectionToggle,nt=Ji.toggleSection,it=Ji.forceExpandCrossWiredSections,tt=function(){var e,n;if(null!=Li){var i=null===(e=xi.current[Li])||void 0===e?void 0:e.current,t=null===(n=_i.current[Li])||void 0===n?void 0:n.current,o=bn.current;if(i&&t&&o){var r=i.getBoundingClientRect(),l=t.getBoundingClientRect(),s=o.getBoundingClientRect(),u=r.top-s.top,a=l.top-s.top-u;o.scrollBy({top:a,behavior:"smooth"})}}},ot=i.useCallback(function(e){null==e||e.stopPropagation(),tn(function(e){var n=!e;return n&&requestAnimationFrame(function(){tt()}),n})},[tt]);i.useEffect(function(){Oe&&"off"!==hi&&"0:0"!==hi&&(qi.current=null,fn.current=[],requestAnimationFrame(function(){var e;null===(e=vn.current)||void 0===e||e.call(vn)}))},[Oe,hi]);var rt=i.useMemo(function(){var e=new Map,n=new Map,i=1;if(Pe)ui.forEach(function(n){!n.title&&!n.content||n.id&&e.set(n.id,i++)}),ai.forEach(function(t){if(t.id&&!(!t.title&&!t.content)){var o=ui.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(ui.length,ai.length),o=0;o<t;o++){var r=ui[o],l=ai[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}},[ui,ai,Pe]),lt=si.analysis,st=s.safeStringify(null===(X=null===(J=null==lt?void 0:lt.rule_difference_comparison)||void 0===J?void 0:J.summary)||void 0===X?void 0:X.overall_summary),ut=!!st.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),at=null!==($=null==pe?void 0:pe.base_root_id)&&void 0!==$?$:"-1";null==pe||pe[at];var ct=Ue?null!==(ae=null!==(le=Ae&&(null===(re=null==Ae?void 0:Ae[at])||void 0===re?void 0:re.evaluation_result))&&void 0!==le?le:null===(ue=null===(se=null==pe?void 0:pe.nodes)||void 0===se?void 0:se[at])||void 0===ue?void 0:ue.evaluation_result)&&void 0!==ae?ae:null:null!==(oe=null!==(ee=Ae&&(null===(Z=null===(Q=null==Ae?void 0:Ae[at])||void 0===Q?void 0:Q.evaluation_result)||void 0===Z?void 0:Z[0]))&&void 0!==ee?ee:null===(te=null===(ie=null===(ne=null==pe?void 0:pe.nodes)||void 0===ne?void 0:ne[at])||void 0===ie?void 0:ie.evaluation_result)||void 0===te?void 0:te[0])&&void 0!==oe?oe:null,dt=s.extractDeviationScore(ct),ft=s.generateColorPalette(null!==(fe=null===(de=null===(ce=null==ct?void 0:ct.evaluation_outputs)||void 0===ce?void 0:ce.metadata)||void 0===de?void 0:de.label_color)&&void 0!==fe?fe:a.DEFAULT_DEVIAION_COLOR);if(Fe){var vt=Fe(dt);vt&&(ft=e.__assign(e.__assign({},ft),{badgeBg:vt.bg,badgeText:vt.text,badgeBorder:vt.border}))}var gt=i.useRef(Ui);i.useEffect(function(){gt.current=Ui},[Ui]);var pt=i.useRef(Wn);i.useEffect(function(){pt.current=Wn},[Wn]);var ht=i.useCallback(function(e,n,i,t,o,r){return _o.current(e,n,i,t,o,r)},[]),mt=i.useCallback(function(e,n,i,t,o){return yo.current(e,n,i,t,o)},[]),St=i.useCallback(function(){return Co.current()},[]),Rt=i.useCallback(function(e,n){return Eo.current(e,n)},[]),xt=i.useCallback(function(e){return Ao.current(e)},[]),_t=i.useCallback(function(e){return Bo.current(e)},[]),bt=i.useCallback(function(){return wo.current()},[]),yt=i.useCallback(function(){var e,n;Ki(),null===(e=gt.current)||void 0===e||e.call(gt),tn(!1),Xe(new Set),Ze([]),fn.current=[],Vt([]),Gt(null),Mn(a.EMPTY_SUMMARY_POPUP_STATE),null===(n=pt.current)||void 0===n||n.call(pt),requestAnimationFrame(function(){var e;null===(e=vn.current)||void 0===e||e.call(vn)})},[]),Ct=i.useRef(yt);i.useEffect(function(){Ct.current=yt},[yt]),i.useEffect(function(){xe&&Ct.current()},[xe]);var Et=i.useMemo(function(){return{documents:null==pe?void 0:pe.documents,input_index_map:null==pe?void 0:pe.input_index_map}},[JSON.stringify(null==pe?void 0:pe.documents),JSON.stringify(null==pe?void 0:pe.input_index_map)]),At=i.useRef(pe);i.useEffect(function(){At.current=pe},[pe]);var Bt=i.useRef(Sn);i.useEffect(function(){Bt.current=Sn},[Sn]);var wt=i.useCallback(function(n,i,t,o,r,l,u){var a,c,d,f,v,g,p,h,m,S,R=s.safeStringify(null==i?void 0:i.id)||s.safeStringify(null==t?void 0:t.id)||"",x=(R?null===(a=Bt.current)||void 0===a?void 0:a[R]:null)||(null==i?void 0:i.cognitiveData)||(null==t?void 0:t.cognitiveData)||{section_id:R,decisioning:[],gap:[],relevance_score:0},_=null!==(d=null===(c=Bi.current[o])||void 0===c?void 0:c.current)&&void 0!==d?d:null,b=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.__assign(e.__assign({},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(s.DEVIATION_BADGE_SEPARATOR)))return u(l);var a=o.split(s.DEVIATION_BADGE_SEPARATOR)[1];if(!a)return l;var c=(null==i?void 0:i.evaluationResult)||(null==t?void 0:t.evaluationResult)||{},d=(null===(n=null==c?void 0:c.deviation_entries)||void 0===n?void 0:n[a])||(null===(r=null==c?void 0:c.deviations)||void 0===r?void 0:r[a])||null;return d?e.__assign(e.__assign(e.__assign({},c),d),{deviation_summary:(null==d?void 0:d.deviation_summary)||(null==c?void 0:c.deviation_summary),deviation_title:(null==d?void 0:d.deviation_title)||(null==c?void 0:c.deviation_title),deviation_impact:(null==d?void 0:d.deviation_impact)||(null==c?void 0:c.deviation_impact),deviation_explanation:(null==d?void 0:d.deviation_explanation)||(null==c?void 0:c.deviation_explanation),evaluation_outputs:(null==d?void 0:d.evaluation_outputs)||(null==c?void 0:c.evaluation_outputs),cognitive_decisioning:(null==d?void 0:d.cognitive_decisioning)||(null==c?void 0:c.cognitive_decisioning)}):u(l)}(),y=(null!==(g=null===(v=null===(f=null==b?void 0:b.cognitive_decisioning)||void 0===f?void 0:f.decisioning_factors)||void 0===v?void 0:v.length)&&void 0!==g?g:0)>0||(null!==(m=null===(h=null===(p=null==b?void 0:b.cognitive_decisioning)||void 0===p?void 0:p.gaps_in_decision)||void 0===h?void 0:h.length)&&void 0!==m?m:0)>0;return{isLoading:null!==(S=null==be?void 0:be.isLoading)&&void 0!==S&&S&&!y,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:_,badgeStyle:l||null,sectionIdx:o,docData:Et,deviationData:b,isOrphan:!!r}},[Et,null==be?void 0:be.isLoading]),It=i.useCallback(function(e,n,i,t,o,r){var l;if(e.stopPropagation(),Fn.open&&Fn.sectionIdx===o)Kn();else{var u=e.currentTarget,a="left";(null===(l=bn.current)||void 0===l?void 0:l.contains(u))&&(a="right");Ki(),Hi.current&&Ui(),Xe(new Set),Ze([]),fn.current=[],Wn(),Ln.open?no():qn(),requestAnimationFrame(function(){var e=function(){var e,n,i,t;if("string"==typeof o&&o.includes(s.DEVIATION_BADGE_SEPARATOR)){var r=o.split(s.DEVIATION_BADGE_SEPARATOR),l="".concat(r[0]).concat(s.DEVIATION_BADGE_SEPARATOR).concat(r[1]);return"right"===a?null===(e=yi.current[l])||void 0===e?void 0:e.current:null===(n=bi.current[l])||void 0===n?void 0:n.current}return"right"===a?null===(i=yi.current[o])||void 0===i?void 0:i.current:null===(t=bi.current[o])||void 0===t?void 0:t.current}()||u;jn(wt(e,n,t,o,i,r))})}},[Fn.open,Fn.sectionIdx,Kn,qn,wt]),Tt=i.useCallback(function(){var e=Fn.sectionIdx;Fn.isOrphan,Kn(),qn(),null!==e&&(it(e),Ki(),Hi.current&&Ui(),Ze([]),fn.current=[],Xe(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){vn.current&&vn.current()},50))},[Fn.sectionIdx,Fn.isOrphan,Kn,qn,Ui]),Dt=i.useCallback(function(){var e=un.current;if(e){un.current=null;var n=ui.findIndex(function(n){return n.id===e}),i=ai.findIndex(function(n){return n.id===e}),t=-1===n?s.findKeyPathByNodeId(ui,e):null,o=-1===i?s.findKeyPathByNodeId(ai,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,s;return-1!==e?null!==(r=null===(o=i.current[e])||void 0===o?void 0:o.current)&&void 0!==r?r:null:n&&null!==(s=null===(l=t.current[n])||void 0===l?void 0:l.current)&&void 0!==s?s:null},a=function(e,n,i){void 0===i&&(i=30);var t=0,o=function(){var r=e();r&&0!==r.getBoundingClientRect().height?(Wi.current.add(r),s.scrollAndHighlightClause(r,n)):t++<i&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(Pe)-1!==r&&Bn.current&&a(function(){return u(n,t,xi,Ei)},Bn.current),-1!==l&&bn.current&&a(function(){return u(i,o,_i,Ai)},bn.current);else{var c=xn.current;if(!c)return;a(function(){return-1!==r?u(n,t,xi,Ei):u(i,o,_i,Ai)},c)}}},[ui,ai,Pe,xi,_i,Ei,Ai,Bn,bn,xn]),Ot=i.useCallback(function(n){if(n){Ki(),Ui(),Xe(new Set),Ze([]),fn.current=[],qn(),Wn();var i=ui.findIndex(function(e){return e.id===n}),t=ai.findIndex(function(e){return e.id===n}),o=-1===i?s.findKeyPathByNodeId(ui,n):null,r=-1===t?s.findKeyPathByNodeId(ai,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;un.current=n,$i(function(n){var i,t=e.__assign({},n),o=!1;-1!==l&&(t[i=Pe?"left-".concat(l):String(l)]||(t[i]=!0,o=!0));-1!==u&&(t[i=Pe?"right-".concat(u):String(u)]||(t[i]=!0,o=!0));return o?t:n}),Zi(function(n){var i=e.__assign({},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(){un.current===n&&Ft.current()})},50)}else console.warn('scrollToAndHighlightClause: nodeId "'.concat(n,'" not found'))}},[ui,ai,Pe,$i,Zi,Ui,qn,Wn]),Ft=i.useRef(Dt);i.useEffect(function(){Ft.current=Dt},[Dt]);var jt=i.useRef(null);i.useEffect(function(){if(Jn){var e=Un.fields.find(function(e){return e.analysisKey===Jn||e.key===Jn});if(e){var n=Si.current[e.key]||Ri.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[Jn,Un.fields]);var kt=i.useCallback(function(e){var n,i,t,o,r,l,s,u,a,c=null===(n=null==lt?void 0:lt.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!c||!c[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var d=c[e],f=(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 v=d.mappings[0]||{};return{score:d.score,relation:v.relation||"",highlightsA:(null===(l=v.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(s=v.highlights)||void 0===s?void 0:s.ruleB_spans)||[],hasContent:!!f}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(u=d.highlights)||void 0===u?void 0:u.ruleA_spans)||[],highlightsB:(null===(a=d.highlights)||void 0===a?void 0:a.ruleB_spans)||[],hasContent:!!f}},[lt]),Pt=E.useStyleHelpers({proposedSections:ui,existingSections:ai,maintainRelativeOrder:Pe,cognitiveMap:Sn,deviationData:mn,treeData:pe,resolvedComparisonConfig:Un,badgeStyleOverride:Fe}),Nt=Pt.getSectionCompareStyle,Lt=Pt.getSubSectionCompareStyle,Mt=Pt.getDeviationStyleByKey,qt=B.useLinesCalculator({containerRef:rn,leftContainerRef:Bn,rightContainerRef:bn,svgContainerRef:on,pathRefs:dn,leftHeaderRef:ln,rightHeaderRef:sn,proposedSections:ui,existingSections:ai,visibleFields:ci,leftRefs:Si,rightRefs:Ri,sectionLeftRefs:xi,sectionRightRefs:_i,subSectionLeftRefs:Ei,subSectionRightRefs:Ai,lhsBadgeRefs:bi,rhsBadgeRefs:yi,sectionRowRefs:Bi,expandedSections:Xi,expandedSubSections:Qi,connectedSections:Je,isSideBySide:Oi,activeSideBySideSection:Li,maintainRelativeOrder:Pe,isGuidelineMode:ri,cognitiveMap:Sn,getSectionCompareStyle:Nt,getSubSectionCompareStyle:Lt,getDeviationStyleByKey:Mt,isArrowVisible:Fi,isAnimatingRef:an,isSideBySideRef:Hi,sideBySideCacheRef:qi,sideBySideLineRef:Gi,activeSideBySideSectionRef:zi,activeSideBySideRightSectionRef:Vi,connectedLines:Qe,setConnectedLines:Ze,cachedConnectedPositions:fn,calculateLinesRef:vn,resizeTimerRef:gn,scrollLock:Mi,scrollSyncLocked:nn,handleResizeRef:pn,activeProposed:li,existingRule:si,analysisData:lt,pendingScrollTargetRef:wn,pendingScrollCallbackRef:In,resolvedComparisonConfig:Un,getFieldData:kt}),Ht=qt.lines,Vt=qt.setLines,zt=qt.overallConnector,Gt=qt.setOverallConnector,Wt=qt.svgDimensions,Kt=qt.handleColumnScroll;i.useEffect(function(){Ln.anchorEl&&requestAnimationFrame(function(){requestAnimationFrame(function(){var e;null===(e=vn.current)||void 0===e||e.call(vn)})})},[Ln.anchorEl,nn]);var Ut=i.useCallback(function(){Ki(),tn(!1),$i({}),Zi({}),Ui(),Xe(new Set),Ze([]),fn.current=[],qn(),Wn(),Kn(),requestAnimationFrame(function(){vn.current&&vn.current()})},[$i,Zi,Ui,qn,Wn,Kn]);i.useEffect(function(){Oi||0!==Je.size||tn(!1)},[Oi,Je]);var Yt=i.useMemo(function(){return Object.values(Xi).some(Boolean)||Object.values(Qi).some(Boolean)},[Xi,Qi]),Jt=i.useRef(null),Xt=i.useRef(0),$t=i.useRef(0),Qt=i.useRef(0),Zt=A.useResizeHandler({timerRef:Jt,ruleComponentRef:_n,scrollContainerRef:xn,containerRef:rn,maintainRelativeOrder:Pe,proposedSections:ui,existingSections:ai,isSideBySideRef:Hi,activeSideBySideSectionRef:zi,activeSideBySideRightSectionRef:Vi,sectionRowRefs:Bi,sectionRightRowRefs:Ci,sectionLeftRefs:xi,sectionRightRefs:_i,subSectionLeftRefs:Ei,subSectionRightRefs:Ai,lhsBadgeRefs:bi,rhsBadgeRefs:yi,leftContainerRef:Bn,rightContainerRef:bn,calculateLinesRef:vn,handleResizeRef:pn,setIsResizing:Pi,setIsArrowVisible:ji,sideBySideCacheRef:qi,cachedConnectedPositions:fn}).handleResize;i.useEffect(function(){pn.current=Zt},[Zt,pn]),i.useEffect(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,s;i.current=null;var u=e[e.length-1];if(u){var a=null!==(s=null===(l=null===(r=u.borderBoxSize)||void 0===r?void 0:r[0])||void 0===l?void 0:l.inlineSize)&&void 0!==s?s:u.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 _n.current&&o.push(e(_n.current,Xt,n,function(){return pn.current()},function(){})),xn.current&&o.push(e(xn.current,$t,i,function(){return pn.current()},function(){return vn.current()})),rn.current&&o.push(e(rn.current,Qt,t,function(){return pn.current()},function(){return vn.current()})),function(){o.forEach(function(e){return e.disconnect()}),r.forEach(function(e){null!==e.current&&(cancelAnimationFrame(e.current),e.current=null)})}},[]),i.useEffect(function(){Hi.current=Oi},[Oi]),i.useEffect(function(){zi.current=Li},[Li]);var eo=i.useCallback(function(){var e,n=Fn.sectionIdx,i=Fn.isOrphan;if(qn(),null!=n){var t="left";Fn.anchorEl&&(null===(e=bn.current)||void 0===e?void 0:e.contains(Fn.anchorEl))&&(t="right"),it(n),Yi(n,i,{sourceSide:t})}},[Yi,Fn.isOrphan,Fn.sectionIdx,Fn.anchorEl,qn]),no=i.useCallback(function(){qn(),Ui(),Xe(new Set),Ze([]),fn.current=[]},[qn,Ui]),io=null!==Fn.sectionIdx&&Je.has(Fn.sectionIdx),to=S.useDeviationNavigation({proposedSections:ui,existingSections:ai,parentDeviationRecord:di,expandedSections:Xi,maintainRelativeOrder:!!Pe,scrollContainerRef:xn,leftContainerRef:Bn,rightContainerRef:bn,lhsBadgeRefs:bi,rhsBadgeRefs:yi}),oo=to.showDeviationNavigation,ro=to.showOpenNodeRef,lo=to.adjustScrollForPopup,so=i.useCallback(function(e,n,i,t,o){var r,l="string"==typeof t?s.safeStringify(t).trim():s.safeStringify(null==t?void 0:t.deviation_summary).trim(),u=e.currentTarget;Wn();var a="left";(null===(r=bn.current)||void 0===r?void 0:r.contains(u))&&(a="right");var c=function(){var e,i,t,o;if("string"==typeof n&&n.includes(s.DEVIATION_BADGE_SEPARATOR)){var r=n.split(s.DEVIATION_BADGE_SEPARATOR),l="".concat(r[0]).concat(s.DEVIATION_BADGE_SEPARATOR).concat(r[1]);return"right"===a?null===(e=yi.current[l])||void 0===e?void 0:e.current:null===(i=bi.current[l])||void 0===i?void 0:i.current}return"right"===a?null===(t=yi.current[n])||void 0===t?void 0:t.current:null===(o=bi.current[n])||void 0===o?void 0:o.current};if(i)return Ui(),Xe(new Set),Ze([]),fn.current=[],void(l&&(it(n),requestAnimationFrame(function(){var e=c()||u;e&&(e.getBoundingClientRect().top>.8*window.innerHeight&&e.scrollIntoView({behavior:"smooth",block:"center"}));Mn({open:!0,anchorEl:e,summary:t,displayImpact:o})})));it(n),l?setTimeout(function(){Yi(n,i,{toggleIfSame:!1,sourceSide:a,onReady:function(){var e,n,i,r=c()||u;if(r){var l=r.getBoundingClientRect();if(l.top>.8*window.innerHeight||l.top<100){var s=l.top-window.innerHeight/2;Pe?(null===(e=Bn.current)||void 0===e||e.scrollBy({top:s,behavior:"smooth"}),null===(n=bn.current)||void 0===n||n.scrollBy({top:s,behavior:"smooth"})):null===(i=xn.current)||void 0===i||i.scrollBy({top:s,behavior:"smooth"})}}Mn({open:!0,anchorEl:r,summary:t,displayImpact:o})}})},350):setTimeout(function(){Yi(n,i,{toggleIfSame:!1,sourceSide:a})},350)},[Yi,Wn,Mn,Ui,it]),uo=i.useMemo(function(){var e;if(!Be)return null;var n=null===(e=null==Be?void 0:Be.id)||void 0===e?void 0:e.split(":")[0];for(var i in di){if((di[i]||[]).some(function(e){return e.id===n}))return i}return null},[Be,di]),ao=i.useRef({id:null,triggerMs:null}),co=i.useRef(null);i.useEffect(function(){if(null==Be?void 0:Be.id){var n=Number(Be.trigger),i=ao.current;if((null==i?void 0:i.triggerMs)!==n){if(!(Be.id.includes(":")&&/:\d+$/.test(Be.id)))return ao.current={id:Be.id,triggerMs:n},void Ot(Be.id);var t=Be.id.split(":"),o=t[0],r=t[1],l=null!=r?r:"0";co.current!==Be.id&&(qn(),Wn(),Ui(),Xe(new Set),Ze([]),fn.current=[],co.current=Be.id);var u=!1,a=0,c=null,d=null,f=!1,v=function(e,n){for(var i=function(e,t){if(!e)return null;if(e.id===n)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},g=function(){var i,t,r,p;if(!u){var h=function(){ao.current={id:Be.id,triggerMs:n}},m=null,S=null;for(var R in di){var x=di[R].find(function(e){return e.id===o});if(x){m=R,S=x;break}}if(S&&m){var _=ui.findIndex(function(e){return e.id===m}),b=ai.findIndex(function(e){return e.id===m}),y=-1===_&&-1!==b,C=v(ui,S.id),E=v(ai,S.id);if(C&&!E&&!y){var A=C.split("-"),B=Number(A[0]);if(Pe){var w=null===(t=null===(i=ui[B])||void 0===i?void 0:i.refIndexes)||void 0===t?void 0:t[0],I=ai.findIndex(function(e){return e.selfIndex===w});-1!==I&&(B=I)}E=e.__spreadArray([B],A.slice(1),!0).join("-")}if(C||E){var T=C?Number(C.split("-")[0]):_,D=E?Number(E.split("-")[0]):b,O=D>=0?D:E?Number(E.split("-")[0]):-1,F=ui[T],j=ai[O],k=F&&!F.title&&!F.content,P=j&&!j.title&&!j.content,N=y||(!C&&!!E||k&&!P);if(N){if(!(Pe?!!bo.current["right-".concat(D)]:!!bo.current[String(D)])&&D>=0)return nt(D,"right"),void(c=setTimeout(g,200))}else if(!(Pe?!!bo.current["left-".concat(T)]:!!bo.current[String(T)])&&T>=0)return nt(T,"left"),void(c=setTimeout(g,200));var L=C||"",M=E||"",q="".concat(S.id).concat(s.DEVIATION_BADGE_SEPARATOR).concat(l).concat(s.DEVIATION_BADGE_SEPARATOR).concat(L).concat(s.DEVIATION_BADGE_SEPARATOR).concat(M),H="".concat(S.id).concat(s.DEVIATION_BADGE_SEPARATOR).concat(l);if(!f){it(q),f=!0,a=0;var V=function(){var e,n,i=null===(e=bi.current[H])||void 0===e?void 0:e.current,t=null===(n=yi.current[H])||void 0===n?void 0:n.current;return N||!i&&!!t?t:i};return null==d||d(),void(c=setTimeout(function(){var e,n,i,t,o,r,l;u||(e=V,n=function(){u||(d=null,g())},t=0,o=null,r=null,l=function(){if(!u){var s=e();if(s&&0!==s.getBoundingClientRect().height){var a=s.getBoundingClientRect(),c=a.top,d=a.height,f=null!==o&&Math.abs(c-o)<.5,v=null!==r&&Math.abs(d-r)<.5;if(f&&v){if(++t>=5)return void n()}else t=0;o=c,r=d,i=requestAnimationFrame(l)}else i=requestAnimationFrame(l)}},i=requestAnimationFrame(l),d=function(){return cancelAnimationFrame(i)})},300))}var z=null===(r=bi.current[H])||void 0===r?void 0:r.current,G=null===(p=yi.current[H])||void 0===p?void 0:p.current;if(z||G){var W=N||!z&&!!G,K=W?G:z,U=Pe?W?bn.current:Bn.current:xn.current;if(K&&U){var Y=K.getBoundingClientRect();if(0!==Y.height){var J=U.getBoundingClientRect(),X=Y.top-J.top+U.scrollTop-J.height/2+Y.height/2,$=(null==C?void 0:C.includes("-"))||(null==E?void 0:E.includes("-")),Q=function(){return e.__awaiter(void 0,void 0,void 0,function(){var n,i,t,o,r,a,c,d,f,v;return e.__generator(this,function(g){switch(g.label){case 0:return u?[2]:(h(),n=K instanceof Element?window.getComputedStyle(K).color:"",[z,G].forEach(function(e){e&&(e.style.transition="box-shadow 300ms ease-in-out",e.style.boxShadow="0 0 10px ".concat(n))}),setTimeout(function(){[z,G].forEach(function(e){e&&(e.style.boxShadow="")})},2e3),i=(null===(c=null===(a=S.evaluationResult)||void 0===a?void 0:a.deviations)||void 0===c?void 0:c[l])||S,t=(null===(d=S.evaluationResult)||void 0===d?void 0:d.evaluation_outputs)||S.evaluation_outputs,!!z&&!!G?(r=function(e,n){return Promise.race([e,new Promise(function(e){return setTimeout(e,n)})])},Pe?[4,Promise.all([Bn.current?r(s.waitForScrollIdle(Bn.current),600):Promise.resolve(),bn.current?r(s.waitForScrollIdle(bn.current),600):Promise.resolve()])]:[3,2]):(o=W?(null===(f=yi.current[$?H:D])||void 0===f?void 0:f.current)||G:(null===(v=bi.current[$?H:T])||void 0===v?void 0:v.current)||z,lo(o,function(){Mn({open:!0,anchorEl:o,displayImpact:Be.displayImpact,summary:e.__assign(e.__assign({},i),{evaluation_outputs:t})})},{skipScroll:!0}),null==we||we(),[2]));case 1:g.sent(),g.label=2;case 2:return Yi(q,!1,{toggleIfSame:!1,sourceSide:y?"right":"left",onReady:function(){var n,t,o,r;h();var l=W?(null===(n=yi.current[H])||void 0===n?void 0:n.current)||G:(null===(t=bi.current[H])||void 0===t?void 0:t.current)||z,s=(null===(o=bi.current[H])||void 0===o?void 0:o.current)||z,u=(null===(r=yi.current[H])||void 0===r?void 0:r.current)||G;s&&(s.style.scrollMarginTop="150px",s.scrollIntoView({behavior:"smooth",block:"start"})),u&&(u.style.scrollMarginTop="150px",u.scrollIntoView({behavior:"smooth",block:"start"})),Mn({open:!0,anchorEl:l,displayImpact:Be.displayImpact,summary:e.__assign({},i)}),null==we||we()}}),[2]}})})};Math.abs(U.scrollTop-X)<=2?Q():s.scrollAndWait(U,X,Q)}else++a<2?c=setTimeout(g,100):h()}else++a<2?c=setTimeout(g,100):h()}else++a<2?c=setTimeout(g,100):h()}else++a<2?c=setTimeout(g,100):h()}else++a<2?c=setTimeout(g,100):h()}};return c=setTimeout(g,100),function(){u=!0,c&&clearTimeout(c),null==d||d()}}}},[Be,di,ui,ai,Pe,Xi,Yi,Mn,Ot]),i.useEffect(function(){var n,i,t;if(Ln.open){var o=Ln.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(bi.current)||r(yi.current);if(l){var s=(null===(i=yi.current[l])||void 0===i?void 0:i.current)||(null===(t=bi.current[l])||void 0===t?void 0:t.current);s&&s.isConnected&&Mn(function(n){return e.__assign(e.__assign({},n),{anchorEl:s})})}}}},[Ln.open,Ln.anchorEl,nn,Je,Xi]);var fo=Dn.open,vo=Dn.sectionIdx,go=Dn.isOrphan,po=Dn.badgeStyle,ho=Dn.anchorEl,mo=Dn.sectionAnchorEl;i.useEffect(function(){var n;if(be.isStreamingEnabled&&fo&&null!=vo&&vo!==at){var i="string"==typeof vo?vo.split(s.DEVIATION_BADGE_SEPARATOR)[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 s=t(l.subsections,n);if(s)return s}}return null},o=i&&"string"==typeof i?t(ui,i):null,r=i&&"string"==typeof i?t(ai,i):null,l="number"==typeof vo?ui[vo]||null:o||i&&((null===(n=null==pe?void 0:pe.nodes)||void 0===n?void 0:n[i])||(null==pe?void 0:pe[i]))||null,u="number"==typeof vo?ai[vo]||null:r,a=wt(ho,l,u,vo,go,po);On(function(n){return n.open?s.safeStringify(n.cognitiveData)===s.safeStringify(a.cognitiveData)&&s.safeStringify(n.deviationData)===s.safeStringify(a.deviationData)&&n.sectionTitle===a.sectionTitle&&n.refSectionTitle===a.refSectionTitle?n:e.__assign(e.__assign(e.__assign({},n),a),{open:!0,anchorEl:n.anchorEl,sectionAnchorEl:n.sectionAnchorEl}):n})}},[fo,vo,go,po,ho,mo,ui,ai,wt]);var So=i.useCallback(function(e){var i=e.section,t=e.keyPath,o=e.depth,r=void 0===o?0:o,l=e.columnKey,s=void 0===l?"left":l,u=e.parentNodeId,a=void 0===u?"":u,c=e.sectionOffset;return n.jsx(x.default,{section:i,keyPath:t,depth:r,columnKey:s,parentNodeId:a,sectionOffset:c})},[]),Ro=i.useMemo(function(){return ui.map(function(e,i){var t,o=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),r=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return o&&r&&Pe?null:n.jsx(_.default,{section:e,idx:i},null!==(t=null==e?void 0:e.id)&&void 0!==t?t:"left-row-".concat(i))})},[ui]),xo=i.useMemo(function(){return ai.map(function(e,i){var t,o=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),r=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return o&&r&&Pe?null:n.jsx(b.default,{section:e,idx:i},null!==(t=null==e?void 0:e.id)&&void 0!==t?t:"right-row-".concat(i))})},[ai]),_o=i.useRef(It);i.useEffect(function(){_o.current=It},[It]);var bo=i.useRef(Xi);i.useEffect(function(){bo.current=Xi},[Xi]);var yo=i.useRef(so);i.useEffect(function(){yo.current=so},[so]);var Co=i.useRef(no);i.useEffect(function(){Co.current=no},[no]);var Eo=i.useRef(nt);i.useEffect(function(){Eo.current=nt},[nt]);var Ao=i.useRef(et);i.useEffect(function(){Ao.current=et},[et]);var Bo=i.useRef(So);i.useEffect(function(){Bo.current=So},[So]);var wo=i.useRef(Ui);i.useEffect(function(){wo.current=Ui},[Ui]);var Io=i.useMemo(function(){return{isGuidelineMode:ri,maintainRelativeOrder:!!Pe,showDeviationBadges:qe,isProposingFix:Te,proposingFixNodeId:De,isRedlineFlow:Oe,isSideBySide:Oi,activeSideBySideSection:Li,scrollSyncLocked:nn,toggleScrollSyncLocked:ot,summaryPopupAnchorEl:Ln.anchorEl,connectedSections:Je,proposedSections:ui,existingSections:ai,deviationNumberRegistry:fi,deviationParentRegistry:vi,treeData:pe,displayConfig:be,resolvedMarkdownStyles:Rn,unifiedNumbering:rt,expandedSections:Xi,expandedSubSections:Qi,setExpandedSubSections:Zi,getSectionCompareStyle:Nt,getSubSectionCompareStyle:Lt,getBadgeRef:Ti,getSectionRowRef:wi,getSubSectionRef:Ii,sectionLeftRefs:xi,sectionRightRefs:_i,sectionRowRefs:Bi,sectionRightRowRefs:Ci,subSectionLeftRefs:Ei,subSectionRightRefs:Ai,lhsBadgeRefs:bi,rhsBadgeRefs:yi,openMoreFunctionsPopup:ht,handleOpenSummaryPopup:mt,openSummaryPopup:mt,handleCloseSummaryPopup:St,toggleSection:Rt,handleSubSectionToggle:xt,renderSubSectionAccordion:_t,resetSideBySide:bt,setConnectedSections:Xe,setConnectedLines:Ze,cachedConnectedPositions:fn,showDeviationNavigation:oo,showOpenNodeRef:ro,deviationNodeIdToView:null==Be?void 0:Be.id,deviationTargetParentId:uo}},[ri,Pe,qe,Te,De,Oe,Oi,Li,nn,ot,Ln.anchorEl,Je,ui,ai,fi,be,Rn,rt,Xi,Qi,Zi,Nt,Lt,Ti,wi,Ii,oo,ro,Be,uo]);return n.jsx(C.CompareContextProvider,e.__assign({value:Io},{children:n.jsxs(t.Box,e.__assign({ref:_n,sx:{display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif',overflow:"visible",position:"relative"}},{children:[Ve&&n.jsx(t.Box,e.__assign({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:n.jsx(f.default,{})})),Ln.open&&n.jsx(y.default,{open:Ln.open,anchorEl:Ln.anchorEl,containerEl:jt.current,clipTopEl:ln.current,scrollContainerEl:xn.current,onClose:no,summary:Ln.summary,displayImpact:Ln.displayImpact,isScrollLocked:nn}),n.jsx(d.default,{open:Fn.open,anchorEl:Fn.anchorEl,maintainRelativeOrder:!!Pe,sectionTitle:Fn.sectionTitle,referenceSectionTitle:Fn.refSectionTitle,onClose:Kn,onOpenCognitiveCompare:zn,onOpenSideBySide:eo,onConnect:Tt,isConnected:io,isOrphan:!ri&&Fn.isOrphan}),Dn.open&&n.jsx(c.default,{open:Dn.open,popupRef:Vn,position:kn,popupConfig:Ce,onClose:function(){Pn(null),On(function(n){return e.__assign(e.__assign({},n),{open:!1})}),Hn(null)},markdownStyles:Re,sectionTitle:ei,referenceSectionTitle:ii,cognitiveData:Dn.cognitiveData,anchorEl:Dn.anchorEl,sectionAnchorEl:Dn.sectionAnchorEl,scrollContainerEl:xn.current,badgeStyle:Dn.badgeStyle,docData:Dn.docData,deviationData:Dn.deviationData,isLoading:Dn.isLoading}),n.jsx(t.Snackbar,e.__assign({open:!!We,autoHideDuration:8e3,onClose:function(){return Ke(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(t.Alert,e.__assign({onClose:function(){return Ke(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:We}))})),n.jsx(R.default,{componentHeaderText:ge,displayConfig:be,maintainRelativeOrder:Pe,onCollapseAll:Ut,showCollapseAll:Yt,onToggleView:function(e){ze(!0),setTimeout(function(){Ne(!e),null==ye||ye(!e),tn(!1),Ui(),qn(),Xe(new Set),Ze([]),fn.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){ze(!1)},600)})})},50)}}),n.jsx(t.Box,e.__assign({ref:xn,onScroll:Kt,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:Pe?"visible":"auto",borderTop:st&&ut?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(t.Box,e.__assign({sx:e.__assign({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},Pe?{flex:1}:{})},{children:n.jsxs(t.Box,e.__assign({ref:rn,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},Pe?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(I.default,{svgContainerRef:on,svgDimensions:Wt,isResizing:ki,overallConnector:zt,rootDeviationStyle:ft,lines:Ht,isSideBySide:Oi,activeSideBySideSection:Li,isArrowVisible:Fi,maintainRelativeOrder:Pe,proposedSections:ui,existingSections:ai,cognitivePopup:Dn,activeBadgeId:Nn,closeCognitivePopup:Wn,setActiveBadgeId:Hn,openCognitivePopupFromState:Gn,buildSectionPopupState:wt,connectedLines:Qe,pathRefs:dn}),n.jsxs(t.Box,e.__assign({sx:e.__assign({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},Pe?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(t.Box,e.__assign({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:n.jsx(t.Tooltip,e.__assign({title:Qn,placement:"top"},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:Qn}))}))})),n.jsxs(t.Box,e.__assign({ref:Bn,onScroll:Kt,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},Pe?{maxHeight:"calc(100vh - 250px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-180px",pr:"192px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:En,style:{width:"100%",height:"0px",flexShrink:0}}),pi&&Ro,n.jsx("div",{ref:An,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),n.jsx(t.Box,e.__assign({ref:jt,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:n.jsx(t.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:n.jsxs(t.Box,e.__assign({onClick:function(n){n.stopPropagation(),Dn.open&&Nn===at?Wn():(Hn(at),Gn(wt(n.currentTarget,{title:"",content:"",evaluationResult:ct,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,at,!0,e.__assign(e.__assign({},ft),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:ft.badgeBg,color:ft.badgeText,border:"1px solid ".concat(ft.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=dt?dt:n.jsx(v.default,{}),n.jsx(t.Box,e.__assign({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n.jsx(r.ButtonCognitiveIcon,{})})),n.jsx(o.ChevronDown,{size:11,style:{transform:Dn.open&&Nn===at?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),n.jsxs(t.Box,e.__assign({sx:e.__assign({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},Pe?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[Ni&&n.jsx(l.default,{sections:11}),n.jsx(t.Box,e.__assign({ref:sn,sx:e.__assign({p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center"},Pe?e.__assign({maxHeight:"calc(100vh - 250px)",overflowY:"auto",overflowX:"hidden",minHeight:0},ri?{"&::-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:n.jsx(t.Tooltip,e.__assign({title:ti,placement:"top"},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:ti}))}))})),n.jsxs(t.Box,e.__assign({ref:bn,onScroll:Kt,sx:e.__assign({p:ri?"0px":"12px",display:"flex",flexDirection:"column"},Pe?e.__assign(e.__assign({maxHeight:"calc(100vh - 250px)"},!ri&&{flex:1}),{overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-150px",pl:"165px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}):{})},{children:[n.jsx("div",{ref:yn,style:{width:"100%",height:"0px",flexShrink:0}}),ri?n.jsx(T.default,{guidelinesData:je,deviationData:Ae,connectedSections:Je,proposedSections:ui}):pi&&xo,n.jsx("div",{ref:Cn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),i=require("react"),t=require("@mui/material"),o=require("lucide-react"),r=require("../../assests/svg/ButtonCognitiveIcon.js"),l=require("./OverlayComponent.js"),s=require("./CognitiveComparehelpers.js"),u=require("./CognitiveCompareConfig.js"),a=require("./CognitiveCompareConstants.js"),c=require("./CognitivePopup.js"),d=require("./MoreFunctionsPopup.js"),v=require("./LoaderComponent.js"),f=require("./components/ThreeDotsLoader.js"),g=require("./hooks/useCompareData.js"),p=require("./hooks/useComparePopups.js"),h=require("./hooks/useSectionRefs.js"),m=require("./hooks/useAccordionState.js"),S=require("./hooks/useDeviationNavigation.js"),R=require("./components/CompareHeader.js"),x=require("./components/SubSectionAccordion.js"),_=require("./components/LHSSectionRow.js"),y=require("./components/RHSSectionRow.js"),b=require("./components/CognitiveSummaryPopup.js"),C=require("./CompareContext.js"),E=require("./hooks/useStyles.js"),A=require("./hooks/useResizeHandler.js"),B=require("./hooks/useLinesCalculator.js"),w=require("./hooks/useSideBySide.js"),I=require("./components/SvgConnectors.js"),T=require("./Guidelines/components/GuidelinePanel.js");exports.SHARED_MARKDOWN_STYLES=u.SHARED_MARKDOWN_STYLES,exports.default=function(D){var O,F,j,k,P,N,M,L,q,H,V,G,z,W,K,Y,U,J,X,$,Q,Z,ee,ne,ie,te,oe,re,le,se,ue,ae,ce,de,ve,fe=D.componentHeaderText,ge=void 0===fe?a.DEFAULT_COMPONENT_HEADER_TEXT:fe,pe=D.treeData,he=D.comparisonConfig,me=D.leftColumnTitleText,Se=D.rightColumnTitleText,Re=D.markdownStyles,xe=D.resetTrigger,_e=D.displayConfig,ye=void 0===_e?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1,displayEmailNotifier:!0,isStreamingEnabled:!1}:_e,be=D.onMaintainRelativeOrderChange,Ce=D.popupConfig,Ee=D.deviationData,Ae=void 0===Ee?{}:Ee,Be=D.deviationNodeIdToView,we=D.resetDeviationNodeId,Ie=D.isProposingFix,Te=void 0!==Ie&&Ie,De=D.proposingFixNodeId,Oe=D.isRedlineFlow,Fe=D.badgeStyleOverride,je=D.guidelinesData,ke=i.useState(ye.maintainRelativeOrder),Pe=ke[0],Ne=ke[1],Me=null!==(O=null==ye?void 0:ye.expandLevels)&&void 0!==O?O:0,Le=!!(null==ye?void 0:ye.expandAllSections),qe=!!Pe||!!(null==ye?void 0:ye.showDeviationBadges),He=i.useState(!1),Ve=He[0],Ge=He[1],ze=i.useState(null),We=ze[0],Ke=ze[1],Ye=i.useState(null===(j=null!==(F=null==pe?void 0:pe.newEvaluationResult)&&void 0!==F?F:null==ye?void 0:ye.enableDeviationSchemaBackwardCompatibility)||void 0===j||j)[0],Ue=i.useState(new Set),Je=Ue[0],Xe=Ue[1],$e=i.useState([]),Qe=$e[0],Ze=$e[1],en=i.useState(!1),nn=en[0],tn=en[1],on=i.useRef(null),rn=i.useRef(null),ln=i.useRef(null),sn=i.useRef(null),un=i.useRef(null),an=i.useRef(!1),cn=i.useRef(null),dn=i.useRef({}),vn=i.useRef([]),fn=i.useRef(function(){}),gn=i.useRef(null),pn=i.useRef(function(){}),hn=i.useMemo(function(){return JSON.stringify(Ae||{})},[JSON.stringify(Ae)]),mn=i.useMemo(function(){return Ae||{}},[hn]),Sn=i.useMemo(function(){return(null==pe?void 0:pe.cognitive_decisioning)||{}},[pe]),Rn=i.useMemo(function(){return e.__assign(e.__assign({},u.SHARED_MARKDOWN_STYLES),Re)},[Re]),xn=i.useRef(null),_n=i.useRef(null),yn=i.useRef(null),bn=i.useRef(null),Cn=i.useRef(null),En=i.useRef(null),An=i.useRef(null),Bn=i.useRef(null),wn=i.useRef(null),In=i.useRef(null),Tn=p.useComparePopups(xn),Dn=Tn.cognitivePopup,On=Tn.setCognitivePopup,Fn=Tn.moreFunctions,jn=Tn.setMoreFunctions,kn=Tn.position,Pn=Tn.setPosition,Nn=Tn.activeBadgeId,Mn=Tn.summaryPopup,Ln=Tn.setSummaryPopup,qn=Tn.closeSummaryPopup,Hn=Tn.setActiveBadgeId,Vn=Tn.popupRef,Gn=Tn.handleOpenCognitiveCompare,zn=Tn.openCognitivePopupFromState,Wn=Tn.closeCognitivePopup,Kn=Tn.closeMoreFunctionsPopup,Yn=i.useMemo(function(){var e,n,i,t,o,r,l;return{fields:null!==(e=null==he?void 0:he.fields)&&void 0!==e?e:u.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(i=null===(n=null==he?void 0:he.thresholds)||void 0===n?void 0:n.high)&&void 0!==i?i:u.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(o=null===(t=null==he?void 0:he.thresholds)||void 0===t?void 0:t.medium)&&void 0!==o?o:u.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(l=null===(r=null==he?void 0:he.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:u.DEFAULT_COMPARISON_CONFIG.thresholds.exact}}},[he]),Un=i.useState(null),Jn=Un[0];Un[1];var Xn=null===(N=null===(k=null==pe?void 0:pe.documents)||void 0===k?void 0:k[null===(P=null==pe?void 0:pe.input_index_map)||void 0===P?void 0:P[0]])||void 0===N?void 0:N.title,$n=null===(q=null===(M=null==pe?void 0:pe.documents)||void 0===M?void 0:M[null===(L=null==pe?void 0:pe.input_index_map)||void 0===L?void 0:L[1]])||void 0===q?void 0:q.title,Qn=s.safeStringify(me||Xn||"Uploaded Contract"),Zn=null===(z=null===(G=null===(H=null==pe?void 0:pe.documents)||void 0===H?void 0:H[null===(V=null==pe?void 0:pe.input_index_map)||void 0===V?void 0:V[0]])||void 0===G?void 0:G.metadata)||void 0===z?void 0:z.file_name,ei=s.safeStringify(Zn),ni=null===(U=null===(Y=null===(W=null==pe?void 0:pe.documents)||void 0===W?void 0:W[null===(K=null==pe?void 0:pe.input_index_map)||void 0===K?void 0:K[1]])||void 0===Y?void 0:Y.metadata)||void 0===U?void 0:U.file_name,ii=s.safeStringify(ni),ti=s.safeStringify(Se||$n||"Reference Template"),oi=g.useCognitiveTreeData(pe,Pe,mn,Yn,Ye,je),ri=oi.isGuidelineMode,li=oi.activeProposed,si=oi.existingRule,ui=oi.proposedSections,ai=oi.existingSections,ci=oi.visibleFields,di=oi.parentDeviationRecord,vi=oi.deviationNumberRegistry,fi=oi.deviationParentRegistry,gi=oi.parseError;i.useEffect(function(){gi&&Ke("Failed to load comparison: ".concat(gi))},[gi]);var pi=ui.length>0||ai.length>0,hi=i.useMemo(function(){if(!Oe)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)||"";s.hasMeaningfulRedlineTags(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(ui),i(ai),"".concat(e,":").concat(n)},[Oe,ui,ai]);i.useEffect(function(){if(ui.length||ai.length)if(Le){var e={},n={},i=function(i,t){i.forEach(function(i,o){var r,l=Pe?"".concat(t,"-").concat(o):String(o);e[l]=!0;var s=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)&&s(e.subsections,r)})};(null===(r=i.subsections)||void 0===r?void 0:r.length)&&s(i.subsections,String(o))})};i(ui,"left"),i(ai,"right"),$i(e),Zi(n)}else if(Me>0){var t={},o={},r=function(e,n,i){e.forEach(function(e,r){var l;if(i>=1){var s=Pe?"".concat(n,"-").concat(r):String(r);t[s]=!0}var u=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)&&u(e.subsections,l,t+1)})};(null===(l=e.subsections)||void 0===l?void 0:l.length)&&i>=2&&u(e.subsections,String(r),2)})};r(ui,"left",Me),r(ai,"right",Me),$i(t),Zi(o)}},[Le,Me,ui,ai,Pe]);var mi=h.useSectionRefs(ci.map(function(e){return e.key}),Math.max(ui.length,ai.length)),Si=mi.leftRefs,Ri=mi.rightRefs,xi=mi.sectionLeftRefs,_i=mi.sectionRightRefs,yi=mi.lhsBadgeRefs,bi=mi.rhsBadgeRefs,Ci=mi.sectionRightRowRefs,Ei=mi.subSectionLeftRefs,Ai=mi.subSectionRightRefs,Bi=mi.sectionRowRefs,wi=mi.getSectionRowRef,Ii=mi.getSubSectionRef,Ti=mi.getBadgeRef,Di=w.useSideBySide({isGuidelineMode:ri,maintainRelativeOrder:Pe,proposedSections:ui,existingSections:ai,leftContainerRef:Bn,rightContainerRef:yn,scrollContainerRef:xn,sectionLeftRefs:xi,sectionRightRefs:_i,subSectionLeftRefs:Ei,subSectionRightRefs:Ai,lhsBadgeRefs:yi,rhsBadgeRefs:bi,sectionRowRefs:Bi,sectionRightRowRefs:Ci,rhsTopSpacerRef:bn,rhsBottomSpacerRef:Cn,lhsTopSpacerRef:En,lhsBottomSpacerRef:An,calculateLinesRef:fn,setConnectedSections:Xe,setConnectedLines:Ze,cachedConnectedPositions:vn,closeMoreFunctionsPopup:Kn,setErrorToast:Ke,moreFunctions:Fn,closeSummaryPopup:qn}),Oi=Di.isSideBySide,Fi=Di.isArrowVisible,ji=Di.setIsArrowVisible,ki=Di.isResizing,Pi=Di.setIsResizing,Ni=Di.isSideBySideLoading,Mi=Di.activeSideBySideSection,Li=Di.scrollLock,qi=Di.sideBySideCacheRef,Hi=Di.isSideBySideRef,Vi=Di.activeSideBySideRightSectionRef,Gi=Di.activeSideBySideSectionRef,zi=Di.sideBySideLineRef,Wi=Di.highlightedClauseRefs,Ki=Di.clearClauseHighlight,Yi=Di.resetSideBySide,Ui=Di.activateSideBySide,Ji=m.useAccordionState({maintainRelativeOrder:!!Pe,proposedSections:ui,existingSections:ai,activeSideBySideSection:Mi,connectedSections:Je,resetSideBySide:Yi,setConnectedSections:Xe,setConnectedLines:Ze,cachedConnectedPositions:vn,svgContainerRef:on,isAnimatingRef:an,animationTimerRef:cn,calculateLinesRef:fn,sectionLeftRefs:xi,sectionRightRefs:_i,subSectionLeftRefs:Ei,subSectionRightRefs:Ai}),Xi=Ji.expandedSections,$i=Ji.setExpandedSections,Qi=Ji.expandedSubSections,Zi=Ji.setExpandedSubSections,et=Ji.handleSubSectionToggle,nt=Ji.toggleSection,it=Ji.forceExpandCrossWiredSections,tt=function(){var e,n;if(null!=Mi){var i=null===(e=xi.current[Mi])||void 0===e?void 0:e.current,t=null===(n=_i.current[Mi])||void 0===n?void 0:n.current,o=yn.current;if(i&&t&&o){var r=i.getBoundingClientRect(),l=t.getBoundingClientRect(),s=o.getBoundingClientRect(),u=r.top-s.top,a=l.top-s.top-u;o.scrollBy({top:a,behavior:"smooth"})}}},ot=i.useCallback(function(e){null==e||e.stopPropagation(),tn(function(e){var n=!e;return n&&requestAnimationFrame(function(){tt()}),n})},[tt]);i.useEffect(function(){Oe&&"off"!==hi&&"0:0"!==hi&&(qi.current=null,vn.current=[],requestAnimationFrame(function(){var e;null===(e=fn.current)||void 0===e||e.call(fn)}))},[Oe,hi]);var rt=i.useMemo(function(){var e=new Map,n=new Map,i=1;if(Pe)ui.forEach(function(n){!n.title&&!n.content||n.id&&e.set(n.id,i++)}),ai.forEach(function(t){if(t.id&&!(!t.title&&!t.content)){var o=ui.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(ui.length,ai.length),o=0;o<t;o++){var r=ui[o],l=ai[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}},[ui,ai,Pe]),lt=si.analysis,st=s.safeStringify(null===(X=null===(J=null==lt?void 0:lt.rule_difference_comparison)||void 0===J?void 0:J.summary)||void 0===X?void 0:X.overall_summary),ut=!!st.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),at=null!==($=null==pe?void 0:pe.base_root_id)&&void 0!==$?$:"-1";null==pe||pe[at];var ct=Ye?null!==(ae=null!==(le=Ae&&(null===(re=null==Ae?void 0:Ae[at])||void 0===re?void 0:re.evaluation_result))&&void 0!==le?le:null===(ue=null===(se=null==pe?void 0:pe.nodes)||void 0===se?void 0:se[at])||void 0===ue?void 0:ue.evaluation_result)&&void 0!==ae?ae:null:null!==(oe=null!==(ee=Ae&&(null===(Z=null===(Q=null==Ae?void 0:Ae[at])||void 0===Q?void 0:Q.evaluation_result)||void 0===Z?void 0:Z[0]))&&void 0!==ee?ee:null===(te=null===(ie=null===(ne=null==pe?void 0:pe.nodes)||void 0===ne?void 0:ne[at])||void 0===ie?void 0:ie.evaluation_result)||void 0===te?void 0:te[0])&&void 0!==oe?oe:null,dt=s.extractDeviationScore(ct),vt=s.generateColorPalette(null!==(ve=null===(de=null===(ce=null==ct?void 0:ct.evaluation_outputs)||void 0===ce?void 0:ce.metadata)||void 0===de?void 0:de.label_color)&&void 0!==ve?ve:a.DEFAULT_DEVIAION_COLOR);if(Fe){var ft=Fe(dt);ft&&(vt=e.__assign(e.__assign({},vt),{badgeBg:ft.bg,badgeText:ft.text,badgeBorder:ft.border}))}var gt=i.useRef(Yi);i.useEffect(function(){gt.current=Yi},[Yi]);var pt=i.useRef(Wn);i.useEffect(function(){pt.current=Wn},[Wn]);var ht=i.useCallback(function(e,n,i,t,o,r){return _o.current(e,n,i,t,o,r)},[]),mt=i.useCallback(function(e,n,i,t,o){return bo.current(e,n,i,t,o)},[]),St=i.useCallback(function(){return Co.current()},[]),Rt=i.useCallback(function(e,n){return Eo.current(e,n)},[]),xt=i.useCallback(function(e){return Ao.current(e)},[]),_t=i.useCallback(function(e){return Bo.current(e)},[]),yt=i.useCallback(function(){return wo.current()},[]),bt=i.useCallback(function(){var e,n;Ki(),null===(e=gt.current)||void 0===e||e.call(gt),tn(!1),Xe(new Set),Ze([]),vn.current=[],Vt([]),zt(null),Ln(a.EMPTY_SUMMARY_POPUP_STATE),null===(n=pt.current)||void 0===n||n.call(pt),requestAnimationFrame(function(){var e;null===(e=fn.current)||void 0===e||e.call(fn)})},[]),Ct=i.useRef(bt);i.useEffect(function(){Ct.current=bt},[bt]),i.useEffect(function(){xe&&Ct.current()},[xe]);var Et=i.useMemo(function(){return{documents:null==pe?void 0:pe.documents,input_index_map:null==pe?void 0:pe.input_index_map}},[JSON.stringify(null==pe?void 0:pe.documents),JSON.stringify(null==pe?void 0:pe.input_index_map)]),At=i.useRef(pe);i.useEffect(function(){At.current=pe},[pe]);var Bt=i.useRef(Sn);i.useEffect(function(){Bt.current=Sn},[Sn]);var wt=i.useCallback(function(n,i,t,o,r,l,u){var a,c,d,v,f,g,p,h,m,S,R,x,_=s.safeStringify(null==i?void 0:i.id)||s.safeStringify(null==t?void 0:t.id)||"",y=(_?null===(a=Bt.current)||void 0===a?void 0:a[_]:null)||(null==i?void 0:i.cognitiveData)||(null==t?void 0:t.cognitiveData)||{section_id:_,decisioning:[],gap:[],relevance_score:0},b=null!==(d=null===(c=Bi.current[o])||void 0===c?void 0:c.current)&&void 0!==d?d:null,C=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.__assign(e.__assign({},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(s.DEVIATION_BADGE_SEPARATOR)))return u(l);var a=o.split(s.DEVIATION_BADGE_SEPARATOR)[1];if(!a)return l;var c=(null==i?void 0:i.evaluationResult)||(null==t?void 0:t.evaluationResult)||{},d=(null===(n=null==c?void 0:c.deviation_entries)||void 0===n?void 0:n[a])||(null===(r=null==c?void 0:c.deviations)||void 0===r?void 0:r[a])||null;return d?e.__assign(e.__assign(e.__assign({},c),d),{deviation_summary:(null==d?void 0:d.deviation_summary)||(null==c?void 0:c.deviation_summary),deviation_title:(null==d?void 0:d.deviation_title)||(null==c?void 0:c.deviation_title),deviation_impact:(null==d?void 0:d.deviation_impact)||(null==c?void 0:c.deviation_impact),deviation_explanation:(null==d?void 0:d.deviation_explanation)||(null==c?void 0:c.deviation_explanation),evaluation_outputs:(null==d?void 0:d.evaluation_outputs)||(null==c?void 0:c.evaluation_outputs),cognitive_decisioning:(null==d?void 0:d.cognitive_decisioning)||(null==c?void 0:c.cognitive_decisioning)}):u(l)}(),E=(null!==(g=null===(f=null===(v=null==C?void 0:C.cognitive_decisioning)||void 0===v?void 0:v.decisioning_factors)||void 0===f?void 0:f.length)&&void 0!==g?g:0)>0||(null!==(m=null===(h=null===(p=null==C?void 0:C.cognitive_decisioning)||void 0===p?void 0:p.gaps_in_decision)||void 0===h?void 0:h.length)&&void 0!==m?m:0)>0,A=null!==(S=null==ye?void 0:ye.isLoading)&&void 0!==S&&S,B=!0;if(ri)if(C&&Object.keys(C).length>0){var w=Array.isArray(C)?C[0]:C,I=null===(x=null===(R=null==w?void 0:w.evaluation_outputs)||void 0===R?void 0:R.metadata)||void 0===x?void 0:x.is_orphan;!0!==I&&"true"!==I&&"Yes"!==I&&"yes"!==I||(B=!1)}else B=!1;return{isLoading:A&&!E,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:y,anchorEl:n,sectionAnchorEl:b,badgeStyle:l||null,sectionIdx:o,docData:Et,deviationData:C,isOrphan:!!r,hasGuidelineMatches:B}},[Et,null==ye?void 0:ye.isLoading,ri]),It=i.useCallback(function(e,n,i,t,o,r){var l;if(e.stopPropagation(),Fn.open&&Fn.sectionIdx===o)Kn();else{var u=e.currentTarget,a="left";(null===(l=yn.current)||void 0===l?void 0:l.contains(u))&&(a="right");Ki(),Hi.current&&Yi(),Xe(new Set),Ze([]),vn.current=[],Wn(),Mn.open?no():qn(),requestAnimationFrame(function(){var e=function(){var e,n,i,t;if("string"==typeof o&&o.includes(s.DEVIATION_BADGE_SEPARATOR)){var r=o.split(s.DEVIATION_BADGE_SEPARATOR),l="".concat(r[0]).concat(s.DEVIATION_BADGE_SEPARATOR).concat(r[1]);return"right"===a?null===(e=bi.current[l])||void 0===e?void 0:e.current:null===(n=yi.current[l])||void 0===n?void 0:n.current}return"right"===a?null===(i=bi.current[o])||void 0===i?void 0:i.current:null===(t=yi.current[o])||void 0===t?void 0:t.current}()||u;jn(wt(e,n,t,o,i,r))})}},[Fn.open,Fn.sectionIdx,Kn,qn,wt]),Tt=i.useCallback(function(){var e=Fn.sectionIdx;Fn.isOrphan,Kn(),qn(),null!==e&&(it(e),Ki(),Hi.current&&Yi(),Ze([]),vn.current=[],Xe(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){fn.current&&fn.current()},50))},[Fn.sectionIdx,Fn.isOrphan,Kn,qn,Yi]),Dt=i.useCallback(function(){var e=un.current;if(e){un.current=null;var n=ui.findIndex(function(n){return n.id===e}),i=ai.findIndex(function(n){return n.id===e}),t=-1===n?s.findKeyPathByNodeId(ui,e):null,o=-1===i?s.findKeyPathByNodeId(ai,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,s;return-1!==e?null!==(r=null===(o=i.current[e])||void 0===o?void 0:o.current)&&void 0!==r?r:null:n&&null!==(s=null===(l=t.current[n])||void 0===l?void 0:l.current)&&void 0!==s?s:null},a=function(e,n,i){void 0===i&&(i=30);var t=0,o=function(){var r=e();r&&0!==r.getBoundingClientRect().height?(Wi.current.add(r),s.scrollAndHighlightClause(r,n)):t++<i&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(Pe)-1!==r&&Bn.current&&a(function(){return u(n,t,xi,Ei)},Bn.current),-1!==l&&yn.current&&a(function(){return u(i,o,_i,Ai)},yn.current);else{var c=xn.current;if(!c)return;a(function(){return-1!==r?u(n,t,xi,Ei):u(i,o,_i,Ai)},c)}}},[ui,ai,Pe,xi,_i,Ei,Ai,Bn,yn,xn]),Ot=i.useCallback(function(n){if(n){Ki(),Yi(),Xe(new Set),Ze([]),vn.current=[],qn(),Wn();var i=ui.findIndex(function(e){return e.id===n}),t=ai.findIndex(function(e){return e.id===n}),o=-1===i?s.findKeyPathByNodeId(ui,n):null,r=-1===t?s.findKeyPathByNodeId(ai,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;un.current=n,$i(function(n){var i,t=e.__assign({},n),o=!1;-1!==l&&(t[i=Pe?"left-".concat(l):String(l)]||(t[i]=!0,o=!0));-1!==u&&(t[i=Pe?"right-".concat(u):String(u)]||(t[i]=!0,o=!0));return o?t:n}),Zi(function(n){var i=e.__assign({},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(){un.current===n&&Ft.current()})},50)}else console.warn('scrollToAndHighlightClause: nodeId "'.concat(n,'" not found'))}},[ui,ai,Pe,$i,Zi,Yi,qn,Wn]),Ft=i.useRef(Dt);i.useEffect(function(){Ft.current=Dt},[Dt]);var jt=i.useRef(null);i.useEffect(function(){if(Jn){var e=Yn.fields.find(function(e){return e.analysisKey===Jn||e.key===Jn});if(e){var n=Si.current[e.key]||Ri.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[Jn,Yn.fields]);var kt=i.useCallback(function(e){var n,i,t,o,r,l,s,u,a,c=null===(n=null==lt?void 0:lt.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!c||!c[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var d=c[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===(s=f.highlights)||void 0===s?void 0:s.ruleB_spans)||[],hasContent:!!v}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(u=d.highlights)||void 0===u?void 0:u.ruleA_spans)||[],highlightsB:(null===(a=d.highlights)||void 0===a?void 0:a.ruleB_spans)||[],hasContent:!!v}},[lt]),Pt=E.useStyleHelpers({proposedSections:ui,existingSections:ai,maintainRelativeOrder:Pe,cognitiveMap:Sn,deviationData:mn,treeData:pe,resolvedComparisonConfig:Yn,badgeStyleOverride:Fe}),Nt=Pt.getSectionCompareStyle,Mt=Pt.getSubSectionCompareStyle,Lt=Pt.getDeviationStyleByKey,qt=B.useLinesCalculator({containerRef:rn,leftContainerRef:Bn,rightContainerRef:yn,svgContainerRef:on,pathRefs:dn,leftHeaderRef:ln,rightHeaderRef:sn,proposedSections:ui,existingSections:ai,visibleFields:ci,leftRefs:Si,rightRefs:Ri,sectionLeftRefs:xi,sectionRightRefs:_i,subSectionLeftRefs:Ei,subSectionRightRefs:Ai,lhsBadgeRefs:yi,rhsBadgeRefs:bi,sectionRowRefs:Bi,expandedSections:Xi,expandedSubSections:Qi,connectedSections:Je,isSideBySide:Oi,activeSideBySideSection:Mi,maintainRelativeOrder:Pe,isGuidelineMode:ri,cognitiveMap:Sn,getSectionCompareStyle:Nt,getSubSectionCompareStyle:Mt,getDeviationStyleByKey:Lt,isArrowVisible:Fi,isAnimatingRef:an,isSideBySideRef:Hi,sideBySideCacheRef:qi,sideBySideLineRef:zi,activeSideBySideSectionRef:Gi,activeSideBySideRightSectionRef:Vi,connectedLines:Qe,setConnectedLines:Ze,cachedConnectedPositions:vn,calculateLinesRef:fn,resizeTimerRef:gn,scrollLock:Li,scrollSyncLocked:nn,handleResizeRef:pn,activeProposed:li,existingRule:si,analysisData:lt,pendingScrollTargetRef:wn,pendingScrollCallbackRef:In,resolvedComparisonConfig:Yn,getFieldData:kt}),Ht=qt.lines,Vt=qt.setLines,Gt=qt.overallConnector,zt=qt.setOverallConnector,Wt=qt.svgDimensions,Kt=qt.handleColumnScroll;i.useEffect(function(){Mn.anchorEl&&requestAnimationFrame(function(){requestAnimationFrame(function(){var e;null===(e=fn.current)||void 0===e||e.call(fn)})})},[Mn.anchorEl,nn]);var Yt=i.useCallback(function(){Ki(),tn(!1),$i({}),Zi({}),Yi(),Xe(new Set),Ze([]),vn.current=[],qn(),Wn(),Kn(),requestAnimationFrame(function(){fn.current&&fn.current()})},[$i,Zi,Yi,qn,Wn,Kn]);i.useEffect(function(){Oi||0!==Je.size||tn(!1)},[Oi,Je]);var Ut=i.useMemo(function(){return Object.values(Xi).some(Boolean)||Object.values(Qi).some(Boolean)},[Xi,Qi]),Jt=i.useRef(null),Xt=i.useRef(0),$t=i.useRef(0),Qt=i.useRef(0),Zt=A.useResizeHandler({timerRef:Jt,ruleComponentRef:_n,scrollContainerRef:xn,containerRef:rn,maintainRelativeOrder:Pe,proposedSections:ui,existingSections:ai,isSideBySideRef:Hi,activeSideBySideSectionRef:Gi,activeSideBySideRightSectionRef:Vi,sectionRowRefs:Bi,sectionRightRowRefs:Ci,sectionLeftRefs:xi,sectionRightRefs:_i,subSectionLeftRefs:Ei,subSectionRightRefs:Ai,lhsBadgeRefs:yi,rhsBadgeRefs:bi,leftContainerRef:Bn,rightContainerRef:yn,calculateLinesRef:fn,handleResizeRef:pn,setIsResizing:Pi,setIsArrowVisible:ji,sideBySideCacheRef:qi,cachedConnectedPositions:vn}).handleResize;i.useEffect(function(){pn.current=Zt},[Zt,pn]),i.useEffect(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,s;i.current=null;var u=e[e.length-1];if(u){var a=null!==(s=null===(l=null===(r=u.borderBoxSize)||void 0===r?void 0:r[0])||void 0===l?void 0:l.inlineSize)&&void 0!==s?s:u.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 _n.current&&o.push(e(_n.current,Xt,n,function(){return pn.current()},function(){})),xn.current&&o.push(e(xn.current,$t,i,function(){return pn.current()},function(){return fn.current()})),rn.current&&o.push(e(rn.current,Qt,t,function(){return pn.current()},function(){return fn.current()})),function(){o.forEach(function(e){return e.disconnect()}),r.forEach(function(e){null!==e.current&&(cancelAnimationFrame(e.current),e.current=null)})}},[]),i.useEffect(function(){Hi.current=Oi},[Oi]),i.useEffect(function(){Gi.current=Mi},[Mi]);var eo=i.useCallback(function(){var e,n=Fn.sectionIdx,i=Fn.isOrphan;if(qn(),null!=n){var t="left";Fn.anchorEl&&(null===(e=yn.current)||void 0===e?void 0:e.contains(Fn.anchorEl))&&(t="right"),it(n),Ui(n,i,{sourceSide:t})}},[Ui,Fn.isOrphan,Fn.sectionIdx,Fn.anchorEl,qn]),no=i.useCallback(function(){qn(),Yi(),Xe(new Set),Ze([]),vn.current=[]},[qn,Yi]),io=null!==Fn.sectionIdx&&Je.has(Fn.sectionIdx),to=S.useDeviationNavigation({proposedSections:ui,existingSections:ai,parentDeviationRecord:di,expandedSections:Xi,maintainRelativeOrder:!!Pe,scrollContainerRef:xn,leftContainerRef:Bn,rightContainerRef:yn,lhsBadgeRefs:yi,rhsBadgeRefs:bi}),oo=to.showDeviationNavigation,ro=to.showOpenNodeRef,lo=to.adjustScrollForPopup,so=i.useCallback(function(e,n,i,t,o){var r,l="string"==typeof t?s.safeStringify(t).trim():s.safeStringify(null==t?void 0:t.deviation_summary).trim(),u=e.currentTarget;Wn();var a="left";(null===(r=yn.current)||void 0===r?void 0:r.contains(u))&&(a="right");var c=function(){var e,i,t,o;if("string"==typeof n&&n.includes(s.DEVIATION_BADGE_SEPARATOR)){var r=n.split(s.DEVIATION_BADGE_SEPARATOR),l="".concat(r[0]).concat(s.DEVIATION_BADGE_SEPARATOR).concat(r[1]);return"right"===a?null===(e=bi.current[l])||void 0===e?void 0:e.current:null===(i=yi.current[l])||void 0===i?void 0:i.current}return"right"===a?null===(t=bi.current[n])||void 0===t?void 0:t.current:null===(o=yi.current[n])||void 0===o?void 0:o.current};if(i)return Yi(),Xe(new Set),Ze([]),vn.current=[],void(l&&(it(n),requestAnimationFrame(function(){var e=c()||u;e&&(e.getBoundingClientRect().top>.8*window.innerHeight&&e.scrollIntoView({behavior:"smooth",block:"center"}));Ln({open:!0,anchorEl:e,summary:t,displayImpact:o})})));it(n),l?setTimeout(function(){Ui(n,i,{toggleIfSame:!1,sourceSide:a,onReady:function(){var e,n,i,r=c()||u;if(r){var l=r.getBoundingClientRect();if(l.top>.8*window.innerHeight||l.top<100){var s=l.top-window.innerHeight/2;Pe?(null===(e=Bn.current)||void 0===e||e.scrollBy({top:s,behavior:"smooth"}),null===(n=yn.current)||void 0===n||n.scrollBy({top:s,behavior:"smooth"})):null===(i=xn.current)||void 0===i||i.scrollBy({top:s,behavior:"smooth"})}}Ln({open:!0,anchorEl:r,summary:t,displayImpact:o})}})},350):setTimeout(function(){Ui(n,i,{toggleIfSame:!1,sourceSide:a})},350)},[Ui,Wn,Ln,Yi,it]),uo=i.useMemo(function(){var e;if(!Be)return null;var n=null===(e=null==Be?void 0:Be.id)||void 0===e?void 0:e.split(":")[0];for(var i in di){if((di[i]||[]).some(function(e){return e.id===n}))return i}return null},[Be,di]),ao=i.useRef({id:null,triggerMs:null}),co=i.useRef(null);i.useEffect(function(){if(null==Be?void 0:Be.id){var n=Number(Be.trigger),i=ao.current;if((null==i?void 0:i.triggerMs)!==n){if(!(Be.id.includes(":")&&/:\d+$/.test(Be.id)))return ao.current={id:Be.id,triggerMs:n},void Ot(Be.id);var t=Be.id.split(":"),o=t[0],r=t[1],l=null!=r?r:"0";co.current!==Be.id&&(qn(),Wn(),Yi(),Xe(new Set),Ze([]),vn.current=[],co.current=Be.id);var u=!1,a=0,c=null,d=null,v=!1,f=function(e,n){for(var i=function(e,t){if(!e)return null;if(e.id===n)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},g=function(){var i,t,r,p;if(!u){var h=function(){ao.current={id:Be.id,triggerMs:n}},m=null,S=null;for(var R in di){var x=di[R].find(function(e){return e.id===o});if(x){m=R,S=x;break}}if(S&&m){var _=ui.findIndex(function(e){return e.id===m}),y=ai.findIndex(function(e){return e.id===m}),b=-1===_&&-1!==y,C=f(ui,S.id),E=f(ai,S.id);if(C&&!E&&!b){var A=C.split("-"),B=Number(A[0]);if(Pe){var w=null===(t=null===(i=ui[B])||void 0===i?void 0:i.refIndexes)||void 0===t?void 0:t[0],I=ai.findIndex(function(e){return e.selfIndex===w});-1!==I&&(B=I)}E=e.__spreadArray([B],A.slice(1),!0).join("-")}if(C||E){var T=C?Number(C.split("-")[0]):_,D=E?Number(E.split("-")[0]):y,O=D>=0?D:E?Number(E.split("-")[0]):-1,F=ui[T],j=ai[O],k=F&&!F.title&&!F.content,P=j&&!j.title&&!j.content,N=b||(!C&&!!E||k&&!P);if(N){if(!(Pe?!!yo.current["right-".concat(D)]:!!yo.current[String(D)])&&D>=0)return nt(D,"right"),void(c=setTimeout(g,200))}else if(!(Pe?!!yo.current["left-".concat(T)]:!!yo.current[String(T)])&&T>=0)return nt(T,"left"),void(c=setTimeout(g,200));var M=C||"",L=E||"",q="".concat(S.id).concat(s.DEVIATION_BADGE_SEPARATOR).concat(l).concat(s.DEVIATION_BADGE_SEPARATOR).concat(M).concat(s.DEVIATION_BADGE_SEPARATOR).concat(L),H="".concat(S.id).concat(s.DEVIATION_BADGE_SEPARATOR).concat(l);if(!v){it(q),v=!0,a=0;var V=function(){var e,n,i=null===(e=yi.current[H])||void 0===e?void 0:e.current,t=null===(n=bi.current[H])||void 0===n?void 0:n.current;return N||!i&&!!t?t:i};return null==d||d(),void(c=setTimeout(function(){var e,n,i,t,o,r,l;u||(e=V,n=function(){u||(d=null,g())},t=0,o=null,r=null,l=function(){if(!u){var s=e();if(s&&0!==s.getBoundingClientRect().height){var a=s.getBoundingClientRect(),c=a.top,d=a.height,v=null!==o&&Math.abs(c-o)<.5,f=null!==r&&Math.abs(d-r)<.5;if(v&&f){if(++t>=5)return void n()}else t=0;o=c,r=d,i=requestAnimationFrame(l)}else i=requestAnimationFrame(l)}},i=requestAnimationFrame(l),d=function(){return cancelAnimationFrame(i)})},300))}var G=null===(r=yi.current[H])||void 0===r?void 0:r.current,z=null===(p=bi.current[H])||void 0===p?void 0:p.current;if(G||z){var W=N||!G&&!!z,K=W?z:G,Y=Pe?W?yn.current:Bn.current:xn.current;if(K&&Y){var U=K.getBoundingClientRect();if(0!==U.height){var J=Y.getBoundingClientRect(),X=U.top-J.top+Y.scrollTop-J.height/2+U.height/2,$=(null==C?void 0:C.includes("-"))||(null==E?void 0:E.includes("-")),Q=function(){return e.__awaiter(void 0,void 0,void 0,function(){var n,i,t,o,r,a,c,d,v,f;return e.__generator(this,function(g){switch(g.label){case 0:return u?[2]:(h(),n=K instanceof Element?window.getComputedStyle(K).color:"",[G,z].forEach(function(e){e&&(e.style.transition="box-shadow 300ms ease-in-out",e.style.boxShadow="0 0 10px ".concat(n))}),setTimeout(function(){[G,z].forEach(function(e){e&&(e.style.boxShadow="")})},2e3),i=(null===(c=null===(a=S.evaluationResult)||void 0===a?void 0:a.deviations)||void 0===c?void 0:c[l])||S,t=(null===(d=S.evaluationResult)||void 0===d?void 0:d.evaluation_outputs)||S.evaluation_outputs,!!G&&!!z?(r=function(e,n){return Promise.race([e,new Promise(function(e){return setTimeout(e,n)})])},Pe?[4,Promise.all([Bn.current?r(s.waitForScrollIdle(Bn.current),600):Promise.resolve(),yn.current?r(s.waitForScrollIdle(yn.current),600):Promise.resolve()])]:[3,2]):(o=W?(null===(v=bi.current[$?H:D])||void 0===v?void 0:v.current)||z:(null===(f=yi.current[$?H:T])||void 0===f?void 0:f.current)||G,lo(o,function(){Ln({open:!0,anchorEl:o,displayImpact:Be.displayImpact,summary:e.__assign(e.__assign({},i),{evaluation_outputs:t})})},{skipScroll:!0}),null==we||we(),[2]));case 1:g.sent(),g.label=2;case 2:return Ui(q,!1,{toggleIfSame:!1,sourceSide:b?"right":"left",onReady:function(){var n,t,o,r;h();var l=W?(null===(n=bi.current[H])||void 0===n?void 0:n.current)||z:(null===(t=yi.current[H])||void 0===t?void 0:t.current)||G,s=(null===(o=yi.current[H])||void 0===o?void 0:o.current)||G,u=(null===(r=bi.current[H])||void 0===r?void 0:r.current)||z;s&&(s.style.scrollMarginTop="150px",s.scrollIntoView({behavior:"smooth",block:"start"})),u&&(u.style.scrollMarginTop="150px",u.scrollIntoView({behavior:"smooth",block:"start"})),Ln({open:!0,anchorEl:l,displayImpact:Be.displayImpact,summary:e.__assign({},i)}),null==we||we()}}),[2]}})})};Math.abs(Y.scrollTop-X)<=2?Q():s.scrollAndWait(Y,X,Q)}else++a<2?c=setTimeout(g,100):h()}else++a<2?c=setTimeout(g,100):h()}else++a<2?c=setTimeout(g,100):h()}else++a<2?c=setTimeout(g,100):h()}else++a<2?c=setTimeout(g,100):h()}};return c=setTimeout(g,100),function(){u=!0,c&&clearTimeout(c),null==d||d()}}}},[Be,di,ui,ai,Pe,Xi,Ui,Ln,Ot]),i.useEffect(function(){var n,i,t;if(Mn.open){var o=Mn.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(yi.current)||r(bi.current);if(l){var s=(null===(i=bi.current[l])||void 0===i?void 0:i.current)||(null===(t=yi.current[l])||void 0===t?void 0:t.current);s&&s.isConnected&&Ln(function(n){return e.__assign(e.__assign({},n),{anchorEl:s})})}}}},[Mn.open,Mn.anchorEl,nn,Je,Xi]);var vo=Dn.open,fo=Dn.sectionIdx,go=Dn.isOrphan,po=Dn.badgeStyle,ho=Dn.anchorEl,mo=Dn.sectionAnchorEl;i.useEffect(function(){var n;if(ye.isStreamingEnabled&&vo&&null!=fo&&fo!==at){var i="string"==typeof fo?fo.split(s.DEVIATION_BADGE_SEPARATOR)[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 s=t(l.subsections,n);if(s)return s}}return null},o=i&&"string"==typeof i?t(ui,i):null,r=i&&"string"==typeof i?t(ai,i):null,l="number"==typeof fo?ui[fo]||null:o||i&&((null===(n=null==pe?void 0:pe.nodes)||void 0===n?void 0:n[i])||(null==pe?void 0:pe[i]))||null,u="number"==typeof fo?ai[fo]||null:r,a=wt(ho,l,u,fo,go,po);On(function(n){return n.open?s.safeStringify(n.cognitiveData)===s.safeStringify(a.cognitiveData)&&s.safeStringify(n.deviationData)===s.safeStringify(a.deviationData)&&n.sectionTitle===a.sectionTitle&&n.refSectionTitle===a.refSectionTitle?n:e.__assign(e.__assign(e.__assign({},n),a),{open:!0,anchorEl:n.anchorEl,sectionAnchorEl:n.sectionAnchorEl}):n})}},[vo,fo,go,po,ho,mo,ui,ai,wt]);var So=i.useCallback(function(e){var i=e.section,t=e.keyPath,o=e.depth,r=void 0===o?0:o,l=e.columnKey,s=void 0===l?"left":l,u=e.parentNodeId,a=void 0===u?"":u,c=e.sectionOffset;return n.jsx(x.default,{section:i,keyPath:t,depth:r,columnKey:s,parentNodeId:a,sectionOffset:c})},[]),Ro=i.useMemo(function(){return ui.map(function(e,i){var t,o=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),r=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return o&&r&&Pe?null:n.jsx(_.default,{section:e,idx:i},null!==(t=null==e?void 0:e.id)&&void 0!==t?t:"left-row-".concat(i))})},[ui]),xo=i.useMemo(function(){return ai.map(function(e,i){var t,o=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),r=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return o&&r&&Pe?null:n.jsx(y.default,{section:e,idx:i},null!==(t=null==e?void 0:e.id)&&void 0!==t?t:"right-row-".concat(i))})},[ai]),_o=i.useRef(It);i.useEffect(function(){_o.current=It},[It]);var yo=i.useRef(Xi);i.useEffect(function(){yo.current=Xi},[Xi]);var bo=i.useRef(so);i.useEffect(function(){bo.current=so},[so]);var Co=i.useRef(no);i.useEffect(function(){Co.current=no},[no]);var Eo=i.useRef(nt);i.useEffect(function(){Eo.current=nt},[nt]);var Ao=i.useRef(et);i.useEffect(function(){Ao.current=et},[et]);var Bo=i.useRef(So);i.useEffect(function(){Bo.current=So},[So]);var wo=i.useRef(Yi);i.useEffect(function(){wo.current=Yi},[Yi]);var Io=i.useMemo(function(){return{isGuidelineMode:ri,maintainRelativeOrder:!!Pe,showDeviationBadges:qe,isProposingFix:Te,proposingFixNodeId:De,isRedlineFlow:Oe,isSideBySide:Oi,activeSideBySideSection:Mi,scrollSyncLocked:nn,toggleScrollSyncLocked:ot,summaryPopupAnchorEl:Mn.anchorEl,connectedSections:Je,proposedSections:ui,existingSections:ai,deviationNumberRegistry:vi,deviationParentRegistry:fi,treeData:pe,displayConfig:ye,resolvedMarkdownStyles:Rn,unifiedNumbering:rt,expandedSections:Xi,expandedSubSections:Qi,setExpandedSubSections:Zi,getSectionCompareStyle:Nt,getSubSectionCompareStyle:Mt,getBadgeRef:Ti,getSectionRowRef:wi,getSubSectionRef:Ii,sectionLeftRefs:xi,sectionRightRefs:_i,sectionRowRefs:Bi,sectionRightRowRefs:Ci,subSectionLeftRefs:Ei,subSectionRightRefs:Ai,lhsBadgeRefs:yi,rhsBadgeRefs:bi,openMoreFunctionsPopup:ht,handleOpenSummaryPopup:mt,openSummaryPopup:mt,handleCloseSummaryPopup:St,toggleSection:Rt,handleSubSectionToggle:xt,renderSubSectionAccordion:_t,resetSideBySide:yt,setConnectedSections:Xe,setConnectedLines:Ze,cachedConnectedPositions:vn,showDeviationNavigation:oo,showOpenNodeRef:ro,deviationNodeIdToView:null==Be?void 0:Be.id,deviationTargetParentId:uo}},[ri,Pe,qe,Te,De,Oe,Oi,Mi,nn,ot,Mn.anchorEl,Je,ui,ai,vi,ye,Rn,rt,Xi,Qi,Zi,Nt,Mt,Ti,wi,Ii,oo,ro,Be,uo]);return n.jsx(C.CompareContextProvider,e.__assign({value:Io},{children:n.jsxs(t.Box,e.__assign({ref:_n,sx:{display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif',overflow:"visible",position:"relative"}},{children:[Ve&&n.jsx(t.Box,e.__assign({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:n.jsx(v.default,{})})),Mn.open&&n.jsx(b.default,{open:Mn.open,anchorEl:Mn.anchorEl,containerEl:jt.current,clipTopEl:ln.current,scrollContainerEl:xn.current,onClose:no,summary:Mn.summary,displayImpact:Mn.displayImpact,isScrollLocked:nn}),n.jsx(d.default,{open:Fn.open,anchorEl:Fn.anchorEl,maintainRelativeOrder:!!Pe,sectionTitle:Fn.sectionTitle,referenceSectionTitle:Fn.refSectionTitle,onClose:Kn,onOpenCognitiveCompare:Gn,onOpenSideBySide:eo,onConnect:Tt,isConnected:io,isOrphan:!ri&&!!Fn.isOrphan,isGuidelineMode:ri,hasGuidelineMatches:Fn.hasGuidelineMatches}),Dn.open&&n.jsx(c.default,{open:Dn.open,popupRef:Vn,position:kn,popupConfig:Ce,onClose:function(){Pn(null),On(function(n){return e.__assign(e.__assign({},n),{open:!1})}),Hn(null)},markdownStyles:Re,sectionTitle:ei,referenceSectionTitle:ii,cognitiveData:Dn.cognitiveData,anchorEl:Dn.anchorEl,sectionAnchorEl:Dn.sectionAnchorEl,scrollContainerEl:xn.current,badgeStyle:Dn.badgeStyle,docData:Dn.docData,deviationData:Dn.deviationData,isLoading:Dn.isLoading}),n.jsx(t.Snackbar,e.__assign({open:!!We,autoHideDuration:8e3,onClose:function(){return Ke(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(t.Alert,e.__assign({onClose:function(){return Ke(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:We}))})),n.jsx(R.default,{componentHeaderText:ge,displayConfig:ye,maintainRelativeOrder:Pe,onCollapseAll:Yt,showCollapseAll:Ut,onToggleView:function(e){Ge(!0),setTimeout(function(){Ne(!e),null==be||be(!e),tn(!1),Yi(),qn(),Xe(new Set),Ze([]),vn.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){Ge(!1)},600)})})},50)}}),n.jsx(t.Box,e.__assign({ref:xn,onScroll:Kt,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:Pe?"visible":"auto",borderTop:st&&ut?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(t.Box,e.__assign({sx:e.__assign({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},Pe?{flex:1}:{})},{children:n.jsxs(t.Box,e.__assign({ref:rn,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},Pe?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(I.default,{svgContainerRef:on,svgDimensions:Wt,isResizing:ki,overallConnector:Gt,rootDeviationStyle:vt,lines:Ht,isSideBySide:Oi,activeSideBySideSection:Mi,isArrowVisible:Fi,maintainRelativeOrder:Pe,proposedSections:ui,existingSections:ai,cognitivePopup:Dn,activeBadgeId:Nn,closeCognitivePopup:Wn,setActiveBadgeId:Hn,openCognitivePopupFromState:zn,buildSectionPopupState:wt,connectedLines:Qe,pathRefs:dn}),n.jsxs(t.Box,e.__assign({sx:e.__assign({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},Pe?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(t.Box,e.__assign({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:n.jsx(t.Tooltip,e.__assign({title:Qn,placement:"top"},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:Qn}))}))})),n.jsxs(t.Box,e.__assign({ref:Bn,onScroll:Kt,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},Pe?{maxHeight:"calc(100vh - 250px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-180px",pr:"192px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:En,style:{width:"100%",height:"0px",flexShrink:0}}),pi&&Ro,n.jsx("div",{ref:An,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),n.jsx(t.Box,e.__assign({ref:jt,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:n.jsx(t.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:n.jsxs(t.Box,e.__assign({onClick:function(n){n.stopPropagation(),Dn.open&&Nn===at?Wn():(Hn(at),zn(wt(n.currentTarget,{title:"",content:"",evaluationResult:ct,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,at,!0,e.__assign(e.__assign({},vt),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:vt.badgeBg,color:vt.badgeText,border:"1px solid ".concat(vt.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=dt?dt:n.jsx(f.default,{}),n.jsx(t.Box,e.__assign({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n.jsx(r.ButtonCognitiveIcon,{})})),n.jsx(o.ChevronDown,{size:11,style:{transform:Dn.open&&Nn===at?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),n.jsxs(t.Box,e.__assign({sx:e.__assign({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},Pe?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[Ni&&n.jsx(l.default,{sections:11}),n.jsx(t.Box,e.__assign({ref:sn,sx:e.__assign({p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center"},Pe?e.__assign({maxHeight:"calc(100vh - 250px)",overflowY:"auto",overflowX:"hidden",minHeight:0},ri?{"&::-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:n.jsx(t.Tooltip,e.__assign({title:ti,placement:"top"},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:ti}))}))})),n.jsxs(t.Box,e.__assign({ref:yn,onScroll:Kt,sx:e.__assign({p:ri?"0px":"12px",display:"flex",flexDirection:"column"},Pe?e.__assign(e.__assign({maxHeight:"calc(100vh - 250px)"},!ri&&{flex:1}),{overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-150px",pl:"165px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}):{})},{children:[n.jsx("div",{ref:bn,style:{width:"100%",height:"0px",flexShrink:0}}),ri?n.jsx(T.default,{guidelinesData:je,deviationData:Ae,connectedSections:Je,proposedSections:ui}):pi&&xo,n.jsx("div",{ref:Cn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))}))};
2
2
  //# sourceMappingURL=CognitiveCompare.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),i=require("react/jsx-runtime"),n=require("@mui/material"),t=require("../../assests/svg/ButtonCognitiveIcon.js"),s=function(){return i.jsx("svg",e.__assign({width:"13",height:"13",viewBox:"0 0 13 13",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:i.jsx("path",{d:"M2 6.5L5 9.5L11 3.5",stroke:"#15803D",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})}))},o=[{key:"connect",title:"Connect",icon:i.jsx("svg",e.__assign({width:"15",height:"18",viewBox:"0 0 15 18",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:i.jsx("path",{d:"M14.8237 3.89331C14.547 5.57188 13.0559 6.77501 11.3572 6.69242C9.65857 6.60983 8.2925 5.26384 8.18312 3.56742C4.75678 3.67456 3.54027 4.4759 3.73893 6.10536C3.81259 6.71474 4.18089 7.04063 4.85723 7.19911C5.26794 7.2951 5.7233 7.30849 6.13625 7.27054C6.17419 7.26608 6.21437 7.26385 6.25232 7.25938C6.50455 7.19911 6.76125 7.14777 7.01794 7.1076C7.77911 6.9826 8.55366 6.9201 9.29027 6.96027C11.3617 7.07188 12.7724 7.98483 12.8438 9.92233C12.913 11.7996 11.6229 13.1299 9.5425 14.0205C8.87509 14.3063 8.1675 14.5272 7.45991 14.6946C7.14071 14.7705 6.87286 14.8219 6.67419 14.8554C6.49786 16.5496 5.07821 17.842 3.37509 17.8554C1.67196 17.8688 0.229997 16.6031 0.0246403 14.9112C-0.180717 13.2192 0.917498 11.6455 2.57375 11.2527C4.23 10.8598 5.91973 11.7728 6.49562 13.3755C6.70544 13.3375 6.91303 13.2951 7.12062 13.246C7.75009 13.0987 8.37955 12.9022 8.95991 12.6522C10.538 11.9781 11.3996 11.0875 11.3595 9.9759C11.3237 8.98036 10.6095 8.52054 9.21214 8.44465C8.5983 8.41117 7.92643 8.46474 7.26348 8.57411C7.07821 8.60536 6.90857 8.63661 6.75902 8.6701C6.67196 8.68795 6.61169 8.70358 6.58491 8.71027L6.51571 8.72367C6.4666 8.73036 6.38402 8.74152 6.27687 8.75268C5.71884 8.80402 5.11393 8.78617 4.52464 8.65001C3.2925 8.36206 2.42866 7.59643 2.26794 6.2884C1.9175 3.47143 4.02241 2.16563 8.42866 2.07188C9.07821 0.500452 10.8037 -0.336602 12.4376 0.129916C14.0737 0.596434 15.1005 2.21474 14.8237 3.89331V3.89331ZM3.34161 12.6478C3.09741 12.6478 2.85562 12.6959 2.63002 12.7894C2.40442 12.8828 2.19944 13.0198 2.02678 13.1925C1.85412 13.3652 1.71717 13.5702 1.62373 13.7958C1.5303 14.0214 1.48222 14.2632 1.48223 14.5074C1.48224 14.7516 1.53036 14.9934 1.62382 15.219C1.71728 15.4446 1.85426 15.6495 2.02694 15.8222C2.19962 15.9949 2.40462 16.1318 2.63022 16.2252C2.85583 16.3187 3.09764 16.3668 3.34183 16.3667C3.83499 16.3667 4.30795 16.1708 4.65665 15.822C5.00535 15.4733 5.20123 15.0003 5.2012 14.5071C5.20117 14.014 5.00524 13.541 4.65649 13.1923C4.30775 12.8436 3.83477 12.6477 3.34161 12.6478ZM11.5224 1.49152C11.2782 1.49154 11.0364 1.53965 10.8108 1.63311C10.5852 1.72657 10.3802 1.86355 10.2076 2.03623C10.0349 2.20891 9.89797 2.41391 9.80454 2.63952C9.7111 2.86513 9.66302 3.10693 9.66303 3.35112C9.66305 3.59531 9.71116 3.83711 9.80462 4.06271C9.89808 4.28831 10.0351 4.49329 10.2077 4.66594C10.3804 4.8386 10.5854 4.97556 10.811 5.06899C11.0366 5.16243 11.2784 5.21051 11.5226 5.2105C12.0158 5.21047 12.4888 5.01453 12.8375 4.66579C13.1862 4.31704 13.382 3.84406 13.382 3.3509C13.382 2.85773 13.186 2.38478 12.8373 2.03608C12.4886 1.68738 12.0156 1.49149 11.5224 1.49152V1.49152Z",fill:"#1D2939",fillOpacity:"0.85"})}))},{key:"side-by-side",title:"Side by Side",icon:i.jsx("svg",e.__assign({width:"17",height:"17",viewBox:"0 0 17 17",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:i.jsx("path",{d:"M3.19922 8.19922H13.1992M3.19922 8.19922L4.86589 10.6992M3.19922 8.19922L4.86589 5.69922M13.1992 8.19922L11.5326 10.6992M13.1992 8.19922L11.5326 5.69922M15.6992 0.699219V15.6992M0.699219 0.699219V15.6992",stroke:"#3F4957",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})}))},{key:"cognitive-decisioning",title:"Cognitive Decisioning",icon:i.jsx(t.ButtonCognitiveIcon,{})}];exports.default=function(t){var r=t.open,l=t.anchorEl;t.sectionTitle,t.referenceSectionTitle;var a=t.onClose,c=t.onOpenCognitiveCompare,d=t.onOpenSideBySide,C=t.onConnect,x=t.isConnected,g=void 0!==x&&x,h=t.isOrphan,p=t.maintainRelativeOrder;return i.jsx(n.Menu,e.__assign({open:r,anchorEl:l,onClose:a,disableScrollLock:!0,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},PaperProps:{sx:{ml:.75,minWidth:190,maxWidth:220,borderRadius:"12px",border:"1px solid #E4E7EC",boxShadow:"0px 12px 28px rgba(16, 24, 40, 0.12)",overflow:"hidden"}},MenuListProps:{sx:{p:.5,bgcolor:"#FFFFFF"}}},{children:o.filter(function(e){return p||"side-by-side"!==e.key}).map(function(t){var o="connect"===t.key,r=o&&g,l=h&&("connect"===t.key||"side-by-side"===t.key),a=i.jsxs(i.Fragment,{children:[i.jsx(n.Box,e.__assign({sx:e.__assign(e.__assign({width:18,height:18,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,"& svg":{display:"block"}},l&&{opacity:.15}),r&&{"& svg path":{fill:"#15803D",fillOpacity:1}})},{children:t.icon})),i.jsxs(n.Box,e.__assign({sx:{minWidth:0,display:"flex",flexDirection:"column",flex:1}},{children:[i.jsx(n.Typography,e.__assign({sx:{fontSize:"12px",fontWeight:500,color:l?"#98A2B3":r?"#15803D":"#101828",lineHeight:1.2,whiteSpace:"nowrap"}},{children:o?g?"Disconnect":"Connect":t.title})),l&&i.jsx(n.Typography,e.__assign({sx:{mt:.35,fontSize:"10px",lineHeight:1.3,color:"#98A2B3",whiteSpace:"normal"}},{children:"No counterpart exists to connect to."}))]})),r&&!l&&i.jsx(n.Box,e.__assign({sx:{display:"flex",alignItems:"center",justifyContent:"center",ml:"auto"}},{children:i.jsx(s,{})}))]});return l?i.jsx(n.Box,e.__assign({"aria-disabled":"true",sx:{px:1.25,py:1,minHeight:22,borderRadius:"10px",display:"flex",alignItems:"flex-start",gap:1,cursor:"not-allowed",userSelect:"none"}},{children:a}),t.key):i.jsx(n.MenuItem,e.__assign({onClick:function(){return e=t.key,void(h&&("connect"===e||"side-by-side"===e)||("connect"!==e?"side-by-side"!==e?c():d():C()));var e},sx:{px:1.25,py:1,minHeight:40,borderRadius:"10px",display:"flex",alignItems:"center",gap:1,bgcolor:r?"#F0FDF4":"transparent","&:hover":{bgcolor:r?"#DCFCE7":"#F9FAFB"}}},{children:a}),t.key)})}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),i=require("react/jsx-runtime"),n=require("@mui/material"),t=require("../../assests/svg/ButtonCognitiveIcon.js"),s=function(){return i.jsx("svg",e.__assign({width:"13",height:"13",viewBox:"0 0 13 13",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:i.jsx("path",{d:"M2 6.5L5 9.5L11 3.5",stroke:"#15803D",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})}))},o=[{key:"connect",title:"Connect",icon:i.jsx("svg",e.__assign({width:"15",height:"18",viewBox:"0 0 15 18",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:i.jsx("path",{d:"M14.8237 3.89331C14.547 5.57188 13.0559 6.77501 11.3572 6.69242C9.65857 6.60983 8.2925 5.26384 8.18312 3.56742C4.75678 3.67456 3.54027 4.4759 3.73893 6.10536C3.81259 6.71474 4.18089 7.04063 4.85723 7.19911C5.26794 7.2951 5.7233 7.30849 6.13625 7.27054C6.17419 7.26608 6.21437 7.26385 6.25232 7.25938C6.50455 7.19911 6.76125 7.14777 7.01794 7.1076C7.77911 6.9826 8.55366 6.9201 9.29027 6.96027C11.3617 7.07188 12.7724 7.98483 12.8438 9.92233C12.913 11.7996 11.6229 13.1299 9.5425 14.0205C8.87509 14.3063 8.1675 14.5272 7.45991 14.6946C7.14071 14.7705 6.87286 14.8219 6.67419 14.8554C6.49786 16.5496 5.07821 17.842 3.37509 17.8554C1.67196 17.8688 0.229997 16.6031 0.0246403 14.9112C-0.180717 13.2192 0.917498 11.6455 2.57375 11.2527C4.23 10.8598 5.91973 11.7728 6.49562 13.3755C6.70544 13.3375 6.91303 13.2951 7.12062 13.246C7.75009 13.0987 8.37955 12.9022 8.95991 12.6522C10.538 11.9781 11.3996 11.0875 11.3595 9.9759C11.3237 8.98036 10.6095 8.52054 9.21214 8.44465C8.5983 8.41117 7.92643 8.46474 7.26348 8.57411C7.07821 8.60536 6.90857 8.63661 6.75902 8.6701C6.67196 8.68795 6.61169 8.70358 6.58491 8.71027L6.51571 8.72367C6.4666 8.73036 6.38402 8.74152 6.27687 8.75268C5.71884 8.80402 5.11393 8.78617 4.52464 8.65001C3.2925 8.36206 2.42866 7.59643 2.26794 6.2884C1.9175 3.47143 4.02241 2.16563 8.42866 2.07188C9.07821 0.500452 10.8037 -0.336602 12.4376 0.129916C14.0737 0.596434 15.1005 2.21474 14.8237 3.89331V3.89331ZM3.34161 12.6478C3.09741 12.6478 2.85562 12.6959 2.63002 12.7894C2.40442 12.8828 2.19944 13.0198 2.02678 13.1925C1.85412 13.3652 1.71717 13.5702 1.62373 13.7958C1.5303 14.0214 1.48222 14.2632 1.48223 14.5074C1.48224 14.7516 1.53036 14.9934 1.62382 15.219C1.71728 15.4446 1.85426 15.6495 2.02694 15.8222C2.19962 15.9949 2.40462 16.1318 2.63022 16.2252C2.85583 16.3187 3.09764 16.3668 3.34183 16.3667C3.83499 16.3667 4.30795 16.1708 4.65665 15.822C5.00535 15.4733 5.20123 15.0003 5.2012 14.5071C5.20117 14.014 5.00524 13.541 4.65649 13.1923C4.30775 12.8436 3.83477 12.6477 3.34161 12.6478ZM11.5224 1.49152C11.2782 1.49154 11.0364 1.53965 10.8108 1.63311C10.5852 1.72657 10.3802 1.86355 10.2076 2.03623C10.0349 2.20891 9.89797 2.41391 9.80454 2.63952C9.7111 2.86513 9.66302 3.10693 9.66303 3.35112C9.66305 3.59531 9.71116 3.83711 9.80462 4.06271C9.89808 4.28831 10.0351 4.49329 10.2077 4.66594C10.3804 4.8386 10.5854 4.97556 10.811 5.06899C11.0366 5.16243 11.2784 5.21051 11.5226 5.2105C12.0158 5.21047 12.4888 5.01453 12.8375 4.66579C13.1862 4.31704 13.382 3.84406 13.382 3.3509C13.382 2.85773 13.186 2.38478 12.8373 2.03608C12.4886 1.68738 12.0156 1.49149 11.5224 1.49152V1.49152Z",fill:"#1D2939",fillOpacity:"0.85"})}))},{key:"side-by-side",title:"Side by Side",icon:i.jsx("svg",e.__assign({width:"17",height:"17",viewBox:"0 0 17 17",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:i.jsx("path",{d:"M3.19922 8.19922H13.1992M3.19922 8.19922L4.86589 10.6992M3.19922 8.19922L4.86589 5.69922M13.1992 8.19922L11.5326 10.6992M13.1992 8.19922L11.5326 5.69922M15.6992 0.699219V15.6992M0.699219 0.699219V15.6992",stroke:"#3F4957",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})}))},{key:"cognitive-decisioning",title:"Cognitive Decisioning",icon:i.jsx(t.ButtonCognitiveIcon,{})}];exports.default=function(t){var r=t.open,l=t.anchorEl;t.sectionTitle,t.referenceSectionTitle;var a=t.onClose,c=t.onOpenCognitiveCompare,d=t.onOpenSideBySide,C=t.onConnect,x=t.isConnected,h=void 0!==x&&x,g=t.isOrphan,p=void 0!==g&&g,u=t.maintainRelativeOrder,y=t.isGuidelineMode,f=t.hasGuidelineMatches,v=y?!(void 0===f||f):p,_=y?"No highlights found in guidelines.":"No counterpart exists to connect to.";return i.jsx(n.Menu,e.__assign({open:r,anchorEl:l,onClose:a,disableScrollLock:!0,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},PaperProps:{sx:{ml:.75,minWidth:190,maxWidth:220,borderRadius:"12px",border:"1px solid #E4E7EC",boxShadow:"0px 12px 28px rgba(16, 24, 40, 0.12)",overflow:"hidden"}},MenuListProps:{sx:{p:.5,bgcolor:"#FFFFFF"}}},{children:o.filter(function(e){return u||"side-by-side"!==e.key}).map(function(t){var o="connect"===t.key,r=o&&h,l=("connect"===t.key||"side-by-side"===t.key)&&v,a=i.jsxs(i.Fragment,{children:[i.jsx(n.Box,e.__assign({sx:e.__assign(e.__assign({width:18,height:18,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,"& svg":{display:"block"}},l&&{opacity:.15}),r&&{"& svg path":{fill:"#15803D",fillOpacity:1}})},{children:t.icon})),i.jsxs(n.Box,e.__assign({sx:{minWidth:0,display:"flex",flexDirection:"column",flex:1}},{children:[i.jsx(n.Typography,e.__assign({sx:{fontSize:"12px",fontWeight:500,color:l?"#98A2B3":r?"#15803D":"#101828",lineHeight:1.2,whiteSpace:"nowrap"}},{children:o?h?"Disconnect":"Connect":t.title})),l&&i.jsx(n.Typography,e.__assign({sx:{mt:.35,fontSize:"10px",lineHeight:1.3,color:"#98A2B3",whiteSpace:"normal"}},{children:_}))]})),r&&!l&&i.jsx(n.Box,e.__assign({sx:{display:"flex",alignItems:"center",justifyContent:"center",ml:"auto"}},{children:i.jsx(s,{})}))]});return l?i.jsx(n.Box,e.__assign({"aria-disabled":"true",sx:{px:1.25,py:1,minHeight:22,borderRadius:"10px",display:"flex",alignItems:"flex-start",gap:1,cursor:"not-allowed",userSelect:"none"}},{children:a}),t.key):i.jsx(n.MenuItem,e.__assign({onClick:function(){var e;("connect"===(e=t.key)||"side-by-side"===e)&&v||("connect"!==e?"side-by-side"!==e?c():d():C())},sx:{px:1.25,py:1,minHeight:40,borderRadius:"10px",display:"flex",alignItems:"center",gap:1,bgcolor:r?"#F0FDF4":"transparent","&:hover":{bgcolor:r?"#DCFCE7":"#F9FAFB"}}},{children:a}),t.key)})}))};
2
2
  //# sourceMappingURL=MoreFunctionsPopup.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("tslib"),e=require("react/jsx-runtime"),i=require("react"),o=require("@mui/material"),t=require("lucide-react"),l=require("../hooks/memoizedMarkdown.js"),d=require("../CompareContext.js"),r=require("../CognitiveComparehelpers.js"),a=require("../CognitiveCompareConstants.js");function s(n){return n&&"object"==typeof n&&"default"in n?n:{default:n}}var u=s(i);exports.default=function(s){var c,v,f,p,g,x,h,I,m,_,y,b,A,S,R,w=s.section,j=s.idx,E=s.columnKey,B=s.colRef,C=s.mb,O=void 0===C?1:C,D=s.isExpanded,F=s.onToggle,T=s.navigation,k=s.parentNodeId,M=void 0===k?"":k,N=d.useCompareContext(),P=N.showOpenNodeRef,V=N.resolvedMarkdownStyles,W=N.maintainRelativeOrder,q=N.showDeviationBadges,G=void 0!==q&&q,L=N.renderSubSectionAccordion,z=N.treeData,K=N.proposedSections,H=N.existingSections,U=N.deviationNumberRegistry,X=N.deviationParentRegistry,Y=N.getBadgeRef,J=N.openSummaryPopup,Q=N.getSectionCompareStyle,Z=N.connectedSections,$=N.openMoreFunctionsPopup,nn=N.isProposingFix,en=N.proposingFixNodeId,on=N.isRedlineFlow,tn=N.isSideBySide,ln=N.activeSideBySideSection,dn=N.scrollSyncLocked,rn=N.unifiedNumbering,an=N.toggleScrollSyncLocked,sn=N.summaryPopupAnchorEl,un="".concat(tn?"1":"0","-").concat(String(null!=ln?ln:"")),cn=(null===(c=w.displayTitle)||void 0===c||c)&&r.hasValue(w.title),vn=!(!nn||!en||"left"!==E||w.id!==en&&w.nodeId!==en),fn=r.hasMeaningfulRedlineTags(w.content),pn="boolean"==typeof on?on:fn,gn=fn,xn=pn&&fn,hn=xn?r.stripRedlineTags(w.content):w.content,In=xn?w.content:void 0,mn=(null===(v=w.displayContent)||void 0===v||v||fn)&&r.hasValue(w.content),_n=!cn&&!mn,yn=w.title;cn||(yn=mn?"No Title Found":"No Matching Section Found");var bn=w.evaluationResult;if(!bn&&"right"===E)if(W){var An=null===(f=w.refIndexes)||void 0===f?void 0:f[0],Sn=K.find(function(n){return n.selfIndex===An});bn=null==Sn?void 0:Sn.evaluationResult}else bn=null===(p=K[j])||void 0===p?void 0:p.evaluationResult;var Rn=null===(g=null==z?void 0:z.input_index_map)||void 0===g?void 0:g[0],wn=null===(x=null==z?void 0:z.input_index_map)||void 0===x?void 0:x[1],jn="left"===E?wn:Rn,En=function(n,e){var i;if(!e||!n)return null;for(var o=0,t=n;o<t.length;o++){var l=t[o];if(l.id===e||l.nodeId===e||l.contentId===e)return l;if(null===(i=l.subsections)||void 0===i?void 0:i.length){var d=En(l.subsections,e);if(d)return d}}return null},Bn="left"===E?w:En(K,w.id),Cn="right"===E?w:En(H,w.id),On=u.default.useMemo(function(){if(!W)return 0;var n=1/0,e=function(i,o,t,l){var d;if(i){var a=i.nodeId||i.id;if(l&&"right"===E){var s=K.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(i.selfIndex)});s.length>0&&(a=s[0].nodeId||s[0].id)}var u=i.nodeId||i.id||(null==o?void 0:o.nodeId)||(null==o?void 0:o.id)||(null==t?void 0:t.nodeId)||(null==t?void 0:t.id),c=(null===(d=i.evaluationResult)||void 0===d?void 0:d.deviations)||{};Object.keys(c).forEach(function(e){var i="".concat(a).concat(r.DEVIATION_BADGE_SEPARATOR).concat(e),o=null==U?void 0:U[i];null!=o&&o<n&&(n=o);var t="".concat(u).concat(r.DEVIATION_BADGE_SEPARATOR).concat(e),l=null==U?void 0:U[t];null!=l&&l<n&&(n=l)});for(var v=i.subsections||[],f=(null==o?void 0:o.subsections)||[],p=(null==t?void 0:t.subsections)||[],g=Math.max(v.length,f.length,p.length),x=0;x<g;x++)e(v[x],f[x],p[x],!1)}};return e(w,Bn,Cn,!0),n!==1/0?n-1:0},[w,Bn,Cn,E,U,W,K]);if(W)if("left"===E){var Dn=null===(h=w.refIndexes)||void 0===h?void 0:h[0],Fn=H.findIndex(function(n){return n.selfIndex===Dn});Cn=-1!==Fn?H[Fn]:En(H,w.id)}else{var Tn=null===(I=w.refIndexes)||void 0===I?void 0:I[0],kn=K.findIndex(function(n){return n.selfIndex===Tn});Bn=-1!==kn?K[kn]:En(K,w.id)}var Mn="left"===E?!Cn:!Bn,Nn=bn||(null==Bn?void 0:Bn.evaluationResult)||(null==Cn?void 0:Cn.evaluationResult),Pn=null!==(y=null===(_=null===(m=null==Nn?void 0:Nn.evaluation_outputs)||void 0===m?void 0:m.metadata)||void 0===_?void 0:_.label_color)&&void 0!==y?y:a.DEFAULT_DEVIAION_COLOR,Vn=r.generateColorPalette(Pn).highlightBg,Wn=(null==Nn?void 0:Nn.deviations)||{},qn=w.nodeId||w.id;if(W&&"left"!==E){var Gn=K.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(w.selfIndex)});Gn.length>0?qn=Gn[0].nodeId||Gn[0].id:(null==Bn?void 0:Bn.id)&&(qn=Bn.nodeId||Bn.id)}var Ln=Object.keys(Wn)[0],zn=Ln?"".concat(qn).concat(r.DEVIATION_BADGE_SEPARATOR).concat(Ln):null,Kn=zn?null==X?void 0:X[zn]:null,Hn=j+1;if(W&&rn){var Un="left"===E?rn.leftNums.get(null==w?void 0:w.id):rn.rightNums.get(null==w?void 0:w.id);Mn&&void 0!==Un?Hn=Un:null!=Kn&&Kn>=0?Hn=Kn:void 0!==Un&&(Hn=Un)}else null!=Kn&&Kn>=0&&(Hn=Kn);var Xn=Object.entries(Wn).map(function(n){var e=n[0],i=n[1],o="".concat(qn).concat(r.DEVIATION_BADGE_SEPARATOR).concat(e);return{deviationKey:e,deviationMap:i,refId:o,currentIndex:U[o]}}).filter(function(n){return void 0!==n.currentIndex&&null!==n.currentIndex});Xn.sort(function(n,e){return n.currentIndex-e.currentIndex});var Yn,Jn,Qn=Xn.map(function(e){var i,o,t,l,d,a,s=e.deviationKey,u=e.deviationMap,c=e.refId,v=e.currentIndex;W&&void 0!==On&&(v-=On);var f=u[M],p=r.isMissingStr(f);if(p)f="";else if(!f)return null;var g=j,x=j;if(W)if("left"===E){var h=null===(i=w.refIndexes)||void 0===i?void 0:i[0],I=H.findIndex(function(n){return n.selfIndex===h});if(-1!==I)x=I;else{var m=H.findIndex(function(n){return n.id===w.id||n.nodeId===w.nodeId||n.contentId===w.contentId});x=-1!==m?m:j}}else{var _=null===(o=w.refIndexes)||void 0===o?void 0:o[0],y=K.findIndex(function(n){return n.selfIndex===_});if(-1!==y)g=y;else g=-1!==(C=K.findIndex(function(n){return n.id===w.id||n.nodeId===w.nodeId||n.contentId===w.contentId}))?C:j}var b="".concat(qn).concat(r.DEVIATION_BADGE_SEPARATOR).concat(s).concat(r.DEVIATION_BADGE_SEPARATOR).concat(g).concat(r.DEVIATION_BADGE_SEPARATOR).concat(x),A=u[jn],S=Mn||r.isMissingStr(A),R="".concat(Hn,".").concat(v),B=j;if("right"===E&&W){var C,O=null===(t=w.refIndexes)||void 0===t?void 0:t[0],D=K.findIndex(function(n){return n.selfIndex===O});if(-1!==D)B=D;else-1!==(C=K.findIndex(function(n){return n.id===w.id||n.nodeId===w.nodeId||n.contentId===w.contentId}))&&(B=C)}var F=Q?Q(B):null,T=(null==u?void 0:u.evaluation_outputs)||(null==Nn?void 0:Nn.evaluation_outputs),k=null!==(l=null==T?void 0:T.output_value)&&void 0!==l?l:null,N=null!==(a=null===(d=null==T?void 0:T.metadata)||void 0===d?void 0:d.label_color)&&void 0!==a?a:Pn,P=r.generateColorPalette(N),V=F?n.__assign(n.__assign({},F),{badgeBg:P.badgeBg,badgeBorder:P.badgeBorder,badgeText:P.badgeText}):n.__assign({},P),q=(null==u?void 0:u.deviation_summary)?{deviation_summary:u.deviation_summary,deviation_title:(null==u?void 0:u.deviation_title)||(null==Nn?void 0:Nn.deviation_title),deviation_impact:(null==u?void 0:u.deviation_impact)||(null==Nn?void 0:Nn.deviation_impact),deviation_explanation:(null==u?void 0:u.deviation_explanation)||(null==Nn?void 0:Nn.deviation_explanation),evaluation_outputs:T,cognitive_decisioning:(null==u?void 0:u.cognitive_decisioning)||(null==Nn?void 0:Nn.cognitive_decisioning)}:null,G=0,L=hn||"";if(f&&L){var z=L.split(/\n{2,}/),U=z.findIndex(function(n){return n.includes(f)});if(-1!==U){var X=Object.entries(Wn).filter(function(n){n[0];var e=n[1][M];return e&&z[U].includes(e)}).sort(function(n,e){return z[U].indexOf(n[1][M])-z[U].indexOf(e[1][M])}),nn=X.filter(function(n){n[0];var e=n[1][M];return e&&(e.includes(f)||f.includes(e))});nn.length>1&&(G=Math.max(0,nn.findIndex(function(n){return n[0]===s})))}}var en=Y(E,c);return{id:c,actionId:b,label:R,highlight:f,side:E,style:V,stackIndex:G,score:k,isConnected:null==Z?void 0:Z.has(b),showScrollLockToggle:(null==Z?void 0:Z.has(b))||tn&&ln===b||!!sn&&sn===en.current,scrollSyncLocked:dn,toggleScrollSyncLocked:an,isOrphan:S,isMissingClause:p,badgeRef:en,onClick:function(n){n.stopPropagation(),$&&$(n,Bn||{id:"orphan-left",title:"",content:""},S,Cn||{id:"orphan-right",title:"",content:""},b,V)},onSummaryClick:function(n){n.stopPropagation(),J(n,b,S,q)}}}).filter(Boolean),Zn=G||!pn&&vn?Qn:[],$n=Qn.map(function(n){return n.highlight}).filter(Boolean),ne=w.id&&E===(null==T?void 0:T.columnKey)?T:null,ee=u.default.useRef(!1);return i.useEffect(function(){D||(ee.current=!1)},[D]),e.jsxs(o.Box,n.__assign({ref:B,sx:{mb:O,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:[D&&(null==ne?void 0:ne.showAbove)&&e.jsx("div",n.__assign({style:{position:"sticky",top:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==ne?void 0:ne.showAboveRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:e.jsx("div",n.__assign({style:n.__assign({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===E?"+":"-"," 130px))"),position:"absolute",paddingTop:"20px"},"left"===E?{right:"-20px"}:{left:"-20px"})},{children:e.jsx(t.ChevronUp,{color:(null===(b=null==ne?void 0:ne.showAboveRef)||void 0===b?void 0:b.current)?window.getComputedStyle(ne.showAboveRef.current).color:void 0})}))})),e.jsxs(o.Accordion,n.__assign({disableGutters:!0,expanded:!_n&&D,onChange:function(){_n||(F(),P.current=w.id)},sx:{boxShadow:"none",border:_n?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:_n?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flexGrow:1,width:"100%",display:"flex",flexDirection:"column",minWidth:0,"&:before":{display:"none"},"& .MuiAccordion-heading":{position:"sticky",top:-12,zIndex:10,background:"#fff"}}},{children:[e.jsx(o.AccordionSummary,n.__assign({expandIcon:_n?null:e.jsx(t.ChevronDown,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:_n?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:cn&&e.jsx(o.Tooltip,n.__assign({title:yn,placement:"top"},{children:e.jsx(o.Typography,n.__assign({component:"div",sx:{fontSize:"12px",color:_n?"#94A3B8":"#19213D",fontWeight:_n?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(Yn=yn,Jn="left"===E&&(null!==(S=null===(A=null==w?void 0:w.refContentIds)||void 0===A?void 0:A.length)&&void 0!==S?S:1)>1,void 0===Jn&&(Jn=!1),Yn?r.safeStringify(Yn).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(i,o){return i.startsWith("**")&&i.endsWith("**")?e.jsx("strong",{children:i.slice(2,-2)},o):e.jsxs("div",n.__assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px",width:"100%"}},{children:[e.jsx("span",{children:i}),Jn&&e.jsx("span",n.__assign({style:{display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"0px 6px",borderRadius:"9999px",background:"#F3F4F6",border:"1px solid #D1D5DB",color:"#6B7280",fontSize:"9px",fontWeight:500,whiteSpace:"nowrap",lineHeight:1.4,marginRight:"4px"}},{children:"Multiple"}))]}),o)}):null)}))}))})),!_n&&e.jsxs(o.AccordionDetails,n.__assign({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[mn&&e.jsx(l.MemoizedMarkdown,{content:hn,overlayContent:In,sxStyles:V,highlights:$n,maintainRelativeOrder:W,highlightBg:Vn,suppressHighlightBg:gn,deviationBadges:Zn,collisionKey:un}),(w.subsections||[]).map(function(n,e){return L({section:n,keyPath:"".concat(j,"-").concat(e),depth:0,columnKey:E,parentNodeId:M,sectionOffset:On})})]}))]})),D&&(null==ne?void 0:ne.showBelow)&&e.jsx("div",n.__assign({style:{position:"sticky",bottom:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==ne?void 0:ne.showBelowRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:e.jsx("div",n.__assign({style:n.__assign({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===E?"+":"-"," 130px))"),position:"absolute",paddingBottom:"20px"},"left"===E?{right:"-20px"}:{left:"-20px"})},{children:e.jsx(t.ChevronDown,{color:(null===(R=null==ne?void 0:ne.showBelowRef)||void 0===R?void 0:R.current)?window.getComputedStyle(ne.showBelowRef.current).color:void 0})}))}))]}),"".concat(E,"-sec-").concat(j))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("tslib"),e=require("react/jsx-runtime"),i=require("react"),o=require("@mui/material"),t=require("lucide-react"),l=require("../hooks/memoizedMarkdown.js"),d=require("../CompareContext.js"),r=require("../CognitiveComparehelpers.js"),a=require("../CognitiveCompareConstants.js");function s(n){return n&&"object"==typeof n&&"default"in n?n:{default:n}}var u=s(i);exports.default=function(s){var c,v,f,p,g,x,h,I,m,_,y,b,S,A,R,w=s.section,j=s.idx,E=s.columnKey,B=s.colRef,C=s.mb,O=void 0===C?1:C,D=s.isExpanded,T=s.onToggle,F=s.navigation,k=s.parentNodeId,M=void 0===k?"":k,N=d.useCompareContext(),P=N.showOpenNodeRef,V=N.resolvedMarkdownStyles,W=N.maintainRelativeOrder,q=N.showDeviationBadges,G=void 0!==q&&q,L=N.renderSubSectionAccordion,z=N.treeData,K=N.proposedSections,H=N.existingSections,U=N.deviationNumberRegistry,X=N.deviationParentRegistry,Y=N.getBadgeRef,J=N.openSummaryPopup,Q=N.getSectionCompareStyle,Z=N.connectedSections,$=N.openMoreFunctionsPopup,nn=N.isProposingFix,en=N.proposingFixNodeId,on=N.isRedlineFlow,tn=N.isSideBySide,ln=N.activeSideBySideSection,dn=N.scrollSyncLocked,rn=N.unifiedNumbering,an=N.toggleScrollSyncLocked,sn=N.summaryPopupAnchorEl,un="".concat(tn?"1":"0","-").concat(String(null!=ln?ln:"")),cn=(null===(c=w.displayTitle)||void 0===c||c)&&r.hasValue(w.title),vn=!(!nn||!en||"left"!==E||w.id!==en&&w.nodeId!==en),fn=r.hasMeaningfulRedlineTags(w.content),pn="boolean"==typeof on?on:fn,gn=fn,xn=pn&&fn,hn=xn?r.stripRedlineTags(w.content):w.content,In=xn?w.content:void 0,mn=(null===(v=w.displayContent)||void 0===v||v||fn)&&r.hasValue(w.content),_n=!cn&&!mn,yn=w.title;cn||(yn=mn?"No Title Found":"No Matching Section Found");var bn=w.evaluationResult;if(!bn&&"right"===E)if(W){var Sn=null===(f=w.refIndexes)||void 0===f?void 0:f[0],An=K.find(function(n){return n.selfIndex===Sn});bn=null==An?void 0:An.evaluationResult}else bn=null===(p=K[j])||void 0===p?void 0:p.evaluationResult;var Rn=null===(g=null==z?void 0:z.input_index_map)||void 0===g?void 0:g[0],wn=null===(x=null==z?void 0:z.input_index_map)||void 0===x?void 0:x[1],jn="left"===E?wn:Rn,En=function(n,e){var i;if(!e||!n)return null;for(var o=0,t=n;o<t.length;o++){var l=t[o];if(l.id===e||l.nodeId===e||l.contentId===e)return l;if(null===(i=l.subsections)||void 0===i?void 0:i.length){var d=En(l.subsections,e);if(d)return d}}return null},Bn="left"===E?w:En(K,w.id),Cn="right"===E?w:En(H,w.id),On=u.default.useMemo(function(){if(!W)return 0;var n=1/0,e=function(n){var e=r.hasMeaningfulRedlineTags(n)?r.stripRedlineTags(n):n;return r.safeStringify(e||"").replace(/\\n/g,"\n")},i=function(o,t,l,d){if(o){var a=o.nodeId||o.id;if(d&&"right"===E){var s=K.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(o.selfIndex)});s.length>0&&(a=s[0].nodeId||s[0].id)}var u=o.nodeId||o.id||(null==t?void 0:t.nodeId)||(null==t?void 0:t.id)||(null==l?void 0:l.nodeId)||(null==l?void 0:l.id),c=o.evaluationResult||(null==t?void 0:t.evaluationResult)||(null==l?void 0:l.evaluationResult),v=(null==c?void 0:c.deviations)||{};Object.keys(v).forEach(function(i){var d,s=null===(d=v[i])||void 0===d?void 0:d[M];if(function(n,i){if("string"!=typeof i||r.isMissingStr(i))return!1;var o=e(null==n?void 0:n.content),t=e(i);return!!t&&o.includes(t)}("left"===E?t||o:l||o,s)){var c="".concat(a).concat(r.DEVIATION_BADGE_SEPARATOR).concat(i),f=null==U?void 0:U[c];null!=f&&f<n&&(n=f);var p="".concat(u).concat(r.DEVIATION_BADGE_SEPARATOR).concat(i),g=null==U?void 0:U[p];null!=g&&g<n&&(n=g)}});for(var f=o.subsections||[],p=(null==t?void 0:t.subsections)||[],g=(null==l?void 0:l.subsections)||[],x=Math.max(f.length,p.length,g.length),h=0;h<x;h++)i(f[h],p[h],g[h],!1)}};return i(w,Bn,Cn,!0),n!==1/0?n-1:0},[w,Bn,Cn,E,M,U,W,K]);if(W)if("left"===E){var Dn=null===(h=w.refIndexes)||void 0===h?void 0:h[0],Tn=H.findIndex(function(n){return n.selfIndex===Dn});Cn=-1!==Tn?H[Tn]:En(H,w.id)}else{var Fn=null===(I=w.refIndexes)||void 0===I?void 0:I[0],kn=K.findIndex(function(n){return n.selfIndex===Fn});Bn=-1!==kn?K[kn]:En(K,w.id)}var Mn="left"===E?!Cn:!Bn,Nn=bn||(null==Bn?void 0:Bn.evaluationResult)||(null==Cn?void 0:Cn.evaluationResult),Pn=null!==(y=null===(_=null===(m=null==Nn?void 0:Nn.evaluation_outputs)||void 0===m?void 0:m.metadata)||void 0===_?void 0:_.label_color)&&void 0!==y?y:a.DEFAULT_DEVIAION_COLOR,Vn=r.generateColorPalette(Pn).highlightBg,Wn=(null==Nn?void 0:Nn.deviations)||{},qn=w.nodeId||w.id;if(W&&"left"!==E){var Gn=K.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(w.selfIndex)});Gn.length>0?qn=Gn[0].nodeId||Gn[0].id:(null==Bn?void 0:Bn.id)&&(qn=Bn.nodeId||Bn.id)}var Ln=Object.keys(Wn)[0],zn=Ln?"".concat(qn).concat(r.DEVIATION_BADGE_SEPARATOR).concat(Ln):null,Kn=zn?null==X?void 0:X[zn]:null,Hn=j+1;if(W&&rn){var Un="left"===E?rn.leftNums.get(null==w?void 0:w.id):rn.rightNums.get(null==w?void 0:w.id);Mn&&void 0!==Un?Hn=Un:null!=Kn&&Kn>=0?Hn=Kn:void 0!==Un&&(Hn=Un)}else null!=Kn&&Kn>=0&&(Hn=Kn);var Xn=Object.entries(Wn).map(function(n){var e=n[0],i=n[1],o="".concat(qn).concat(r.DEVIATION_BADGE_SEPARATOR).concat(e);return{deviationKey:e,deviationMap:i,refId:o,currentIndex:U[o]}}).filter(function(n){return void 0!==n.currentIndex&&null!==n.currentIndex});Xn.sort(function(n,e){return n.currentIndex-e.currentIndex});var Yn,Jn,Qn=Xn.map(function(e){var i,o,t,l,d,a,s=e.deviationKey,u=e.deviationMap,c=e.refId,v=e.currentIndex;W&&void 0!==On&&(v-=On),v=Math.max(1,v);var f=u[M],p=r.isMissingStr(f);if(p)f="";else if(!f)return null;var g=j,x=j;if(W)if("left"===E){var h=null===(i=w.refIndexes)||void 0===i?void 0:i[0],I=H.findIndex(function(n){return n.selfIndex===h});if(-1!==I)x=I;else{var m=H.findIndex(function(n){return n.id===w.id||n.nodeId===w.nodeId||n.contentId===w.contentId});x=-1!==m?m:j}}else{var _=null===(o=w.refIndexes)||void 0===o?void 0:o[0],y=K.findIndex(function(n){return n.selfIndex===_});if(-1!==y)g=y;else g=-1!==(C=K.findIndex(function(n){return n.id===w.id||n.nodeId===w.nodeId||n.contentId===w.contentId}))?C:j}var b="".concat(qn).concat(r.DEVIATION_BADGE_SEPARATOR).concat(s).concat(r.DEVIATION_BADGE_SEPARATOR).concat(g).concat(r.DEVIATION_BADGE_SEPARATOR).concat(x),S=u[jn],A=Mn||r.isMissingStr(S),R="".concat(Hn,".").concat(v),B=j;if("right"===E&&W){var C,O=null===(t=w.refIndexes)||void 0===t?void 0:t[0],D=K.findIndex(function(n){return n.selfIndex===O});if(-1!==D)B=D;else-1!==(C=K.findIndex(function(n){return n.id===w.id||n.nodeId===w.nodeId||n.contentId===w.contentId}))&&(B=C)}var T=Q?Q(B):null,F=(null==u?void 0:u.evaluation_outputs)||(null==Nn?void 0:Nn.evaluation_outputs),k=null!==(l=null==F?void 0:F.output_value)&&void 0!==l?l:null,N=null!==(a=null===(d=null==F?void 0:F.metadata)||void 0===d?void 0:d.label_color)&&void 0!==a?a:Pn,P=r.generateColorPalette(N),V=T?n.__assign(n.__assign({},T),{badgeBg:P.badgeBg,badgeBorder:P.badgeBorder,badgeText:P.badgeText}):n.__assign({},P),q=(null==u?void 0:u.deviation_summary)?{deviation_summary:u.deviation_summary,deviation_title:(null==u?void 0:u.deviation_title)||(null==Nn?void 0:Nn.deviation_title),deviation_impact:(null==u?void 0:u.deviation_impact)||(null==Nn?void 0:Nn.deviation_impact),deviation_explanation:(null==u?void 0:u.deviation_explanation)||(null==Nn?void 0:Nn.deviation_explanation),evaluation_outputs:F,cognitive_decisioning:(null==u?void 0:u.cognitive_decisioning)||(null==Nn?void 0:Nn.cognitive_decisioning)}:null,G=0,L=hn||"";if(f&&L){var z=L.split(/\n{2,}/),U=z.findIndex(function(n){return n.includes(f)});if(-1!==U){var X=Object.entries(Wn).filter(function(n){n[0];var e=n[1][M];return e&&z[U].includes(e)}).sort(function(n,e){return z[U].indexOf(n[1][M])-z[U].indexOf(e[1][M])}),nn=X.filter(function(n){n[0];var e=n[1][M];return e&&(e.includes(f)||f.includes(e))});nn.length>1&&(G=Math.max(0,nn.findIndex(function(n){return n[0]===s})))}}var en=Y(E,c);return{id:c,actionId:b,label:R,highlight:f,side:E,style:V,stackIndex:G,score:k,isConnected:null==Z?void 0:Z.has(b),showScrollLockToggle:(null==Z?void 0:Z.has(b))||tn&&ln===b||!!sn&&sn===en.current,scrollSyncLocked:dn,toggleScrollSyncLocked:an,isOrphan:A,isMissingClause:p,badgeRef:en,onClick:function(n){n.stopPropagation(),$&&$(n,Bn||{id:"orphan-left",title:"",content:""},A,Cn||{id:"orphan-right",title:"",content:""},b,V)},onSummaryClick:function(n){n.stopPropagation(),J(n,b,A,q)}}}).filter(Boolean),Zn=G||!pn&&vn?Qn:[],$n=Qn.map(function(n){return n.highlight}).filter(Boolean),ne=w.id&&E===(null==F?void 0:F.columnKey)?F:null,ee=u.default.useRef(!1);return i.useEffect(function(){D||(ee.current=!1)},[D]),e.jsxs(o.Box,n.__assign({ref:B,sx:{mb:O,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:[D&&(null==ne?void 0:ne.showAbove)&&e.jsx("div",n.__assign({style:{position:"sticky",top:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==ne?void 0:ne.showAboveRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:e.jsx("div",n.__assign({style:n.__assign({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===E?"+":"-"," 130px))"),position:"absolute",paddingTop:"20px"},"left"===E?{right:"-20px"}:{left:"-20px"})},{children:e.jsx(t.ChevronUp,{color:(null===(b=null==ne?void 0:ne.showAboveRef)||void 0===b?void 0:b.current)?window.getComputedStyle(ne.showAboveRef.current).color:void 0})}))})),e.jsxs(o.Accordion,n.__assign({disableGutters:!0,expanded:!_n&&D,onChange:function(){_n||(T(),P.current=w.id)},sx:{boxShadow:"none",border:_n?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:_n?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flexGrow:1,width:"100%",display:"flex",flexDirection:"column",minWidth:0,"&:before":{display:"none"},"& .MuiAccordion-heading":{position:"sticky",top:-12,zIndex:10,background:"#fff"}}},{children:[e.jsx(o.AccordionSummary,n.__assign({expandIcon:_n?null:e.jsx(t.ChevronDown,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:_n?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:cn&&e.jsx(o.Tooltip,n.__assign({title:yn,placement:"top"},{children:e.jsx(o.Typography,n.__assign({component:"div",sx:{fontSize:"12px",color:_n?"#94A3B8":"#19213D",fontWeight:_n?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(Yn=yn,Jn="left"===E&&(null!==(A=null===(S=null==w?void 0:w.refContentIds)||void 0===S?void 0:S.length)&&void 0!==A?A:1)>1,void 0===Jn&&(Jn=!1),Yn?r.safeStringify(Yn).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(i,o){return i.startsWith("**")&&i.endsWith("**")?e.jsx("strong",{children:i.slice(2,-2)},o):e.jsxs("div",n.__assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px",width:"100%"}},{children:[e.jsx("span",{children:i}),Jn&&e.jsx("span",n.__assign({style:{display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"0px 6px",borderRadius:"9999px",background:"#F3F4F6",border:"1px solid #D1D5DB",color:"#6B7280",fontSize:"9px",fontWeight:500,whiteSpace:"nowrap",lineHeight:1.4,marginRight:"4px"}},{children:"Multiple"}))]}),o)}):null)}))}))})),!_n&&e.jsxs(o.AccordionDetails,n.__assign({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[mn&&e.jsx(l.MemoizedMarkdown,{content:hn,overlayContent:In,sxStyles:V,highlights:$n,maintainRelativeOrder:W,highlightBg:Vn,suppressHighlightBg:gn,deviationBadges:Zn,collisionKey:un}),(w.subsections||[]).map(function(n,e){return L({section:n,keyPath:"".concat(j,"-").concat(e),depth:0,columnKey:E,parentNodeId:M,sectionOffset:On})})]}))]})),D&&(null==ne?void 0:ne.showBelow)&&e.jsx("div",n.__assign({style:{position:"sticky",bottom:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==ne?void 0:ne.showBelowRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:e.jsx("div",n.__assign({style:n.__assign({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===E?"+":"-"," 130px))"),position:"absolute",paddingBottom:"20px"},"left"===E?{right:"-20px"}:{left:"-20px"})},{children:e.jsx(t.ChevronDown,{color:(null===(R=null==ne?void 0:ne.showBelowRef)||void 0===R?void 0:R.current)?window.getComputedStyle(ne.showBelowRef.current).color:void 0})}))}))]}),"".concat(E,"-sec-").concat(j))};
2
2
  //# sourceMappingURL=SectionAccordion.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("tslib"),e=require("react/jsx-runtime"),i=require("react"),t=require("@mui/material"),o=require("lucide-react"),l=require("../hooks/memoizedMarkdown.js"),d=require("../CompareContext.js"),a=require("../CognitiveComparehelpers.js"),r=require("../CognitiveCompareConstants.js");function s(n){return n&&"object"==typeof n&&"default"in n?n:{default:n}}var u=s(i).default.memo(function(s){var c,v,f,g,p,h,_,m,x,y,S=s.section,I=s.keyPath,b=s.depth,A=void 0===b?0:b,O=s.columnKey,P=void 0===O?"left":O,R=s.parentNodeId,B=void 0===R?"":R,k=s.sectionOffset,C=d.useCompareContext(),E=C.expandedSubSections,j=C.setExpandedSubSections,w=C.maintainRelativeOrder,F=C.showDeviationBadges,M=void 0!==F&&F,D=C.proposedSections,N=C.existingSections,T=C.treeData,q=C.deviationNumberRegistry,L=C.deviationParentRegistry,V=C.connectedSections,K=C.activeSideBySideSection,W=C.isSideBySide,G=C.scrollSyncLocked,z=C.toggleScrollSyncLocked,H=C.summaryPopupAnchorEl,U=C.resolvedMarkdownStyles,J=C.getSubSectionRef,Q=C.getSubSectionCompareStyle,X=C.getBadgeRef,Y=C.openMoreFunctionsPopup,Z=C.openSummaryPopup,$=C.resetSideBySide,nn=C.setConnectedSections,en=C.setConnectedLines,tn=C.cachedConnectedPositions,on=C.isProposingFix,ln=C.proposingFixNodeId,dn=C.isRedlineFlow,an=C.unifiedNumbering,rn=null!=K?K:"",sn=(null===(c=S.displayTitle)||void 0===c||c)&&a.hasValue(S.title),un=!(!on||!ln||"left"!==P||S.id!==ln&&S.nodeId!==ln),cn=a.hasMeaningfulRedlineTags(S.content),vn="boolean"==typeof dn?dn:cn,fn=cn,gn=vn&&cn,pn=gn?a.stripRedlineTags(S.content):S.content,hn=gn?S.content:void 0,_n=(null===(v=S.displayContent)||void 0===v||v||cn)&&a.hasValue(S.content),mn=!sn&&!_n,xn=sn?S.title:_n?"No Title Found":"No Matching Section Found",yn=!!E[I],Sn=J(P,I),In=I.split("-").map(Number)[0],bn=D[In],An=N[In],On=In,Pn=In,Rn=!1,Bn=function(n,e,i){if(!n||!e)return null;if(n.id===e||n.nodeId===e||n.contentId===e)return{section:n,keyPath:i};for(var t=(n.subsections||[]).map(function(n,e){return{section:n,keyPath:"".concat(i,"-").concat(e)}}),o=function(){var n=t.shift();return(null==n?void 0:n.section)?n.section.id===e||n.section.nodeId===e||n.section.contentId===e?{value:n}:void(n.section.subsections||[]).forEach(function(e,i){t.push({section:e,keyPath:"".concat(n.keyPath,"-").concat(i)})}):"continue"};t.length>0;){var l=o();if("object"==typeof l)return l.value}return null};if(w)if("left"===P){var kn=null===(f=null==bn?void 0:bn.refIndexes)||void 0===f?void 0:f[0],Cn=N.findIndex(function(n){return n.selfIndex===kn});-1!==Cn?(An=N[Cn],Pn=Cn):Rn=!0}else{var En=null===(g=null==An?void 0:An.refIndexes)||void 0===g?void 0:g[0],jn=D.findIndex(function(n){return n.selfIndex===En});-1!==jn?(bn=D[jn],On=jn):Rn=!0}var wn=function(n,e){if(!e||!n)return null;for(var i=0;i<n.length;i++){var t=Bn(n[i],e,String(i));if(t)return t}return null},Fn=null,Mn=null,Dn="",Nn="";if(w)"left"===P?(Fn=S,Dn=I,(Tn=Bn(An,S.nodeId||S.id,String(Pn)))||(Tn=wn(N,S.nodeId||S.id)),Mn=(null==Tn?void 0:Tn.section)||null,Nn=(null==Tn?void 0:Tn.keyPath)||""):(Mn=S,Nn=I,(qn=Bn(bn,S.nodeId||S.id,String(On)))||(qn=wn(D,S.nodeId||S.id)),Fn=(null==qn?void 0:qn.section)||null,Dn=(null==qn?void 0:qn.keyPath)||"");else if("left"===P){Fn=S,Dn=I;var Tn=wn(N,S.nodeId||S.id);Mn=(null==Tn?void 0:Tn.section)||null,Nn=(null==Tn?void 0:Tn.keyPath)||""}else{Mn=S,Nn=I;var qn=wn(D,S.nodeId||S.id);Fn=(null==qn?void 0:qn.section)||null,Dn=(null==qn?void 0:qn.keyPath)||""}var Ln=(Dn?Q(Dn):null)||Q(I),Vn=null===(p=null==T?void 0:T.input_index_map)||void 0===p?void 0:p[0],Kn=null===(h=null==T?void 0:T.input_index_map)||void 0===h?void 0:h[1],Wn="left"===P?Kn:Vn,Gn="left"===P?!Mn:!Fn,zn=S.evaluationResult||(null==Fn?void 0:Fn.evaluationResult)||(null==Mn?void 0:Mn.evaluationResult),Hn=(null==zn?void 0:zn.deviations)||{},Un=S.nodeId||S.id||(null==Fn?void 0:Fn.nodeId)||(null==Fn?void 0:Fn.id)||(null==Mn?void 0:Mn.nodeId)||(null==Mn?void 0:Mn.id);w&&"left"!==P&&(null==Fn?void 0:Fn.id)&&(Un=Fn.nodeId||Fn.id);var Jn=Object.keys(Hn)[0],Qn=Jn?"".concat(Un).concat(a.DEVIATION_BADGE_SEPARATOR).concat(Jn):null,Xn=Qn?null==L?void 0:L[Qn]:null,Yn=In+1;if(w&&an){var Zn="left"===P?an.leftNums.get(null==bn?void 0:bn.id):an.rightNums.get(null==An?void 0:An.id);Rn&&void 0!==Zn?Yn=Zn:null!=Xn&&Xn>=0?Yn=Xn:void 0!==Zn&&(Yn=Zn)}else null!=Xn&&Xn>=0&&(Yn=Xn);var $n=null!==(x=null===(m=null===(_=null==zn?void 0:zn.evaluation_outputs)||void 0===_?void 0:_.metadata)||void 0===m?void 0:m.label_color)&&void 0!==x?x:r.DEFAULT_DEVIAION_COLOR,ne=a.generateColorPalette($n).highlightBg,ee=Object.entries(Hn).map(function(n){var e=n[0],i=n[1],t="".concat(Un).concat(a.DEVIATION_BADGE_SEPARATOR).concat(e);return{deviationKey:e,deviationMap:i,refId:t,currentIndex:q[t]}}).filter(function(n){return void 0!==n.currentIndex&&null!==n.currentIndex});ee.sort(function(n,e){return n.currentIndex-e.currentIndex});var ie=ee.map(function(e){var i,t,o,l=e.deviationKey,d=e.deviationMap,r=e.refId,s=e.currentIndex;w&&void 0!==k&&(s-=k);var u=d[B],c=a.isMissingStr(u);if(c)u="";else if(!u)return null;var v=d[Wn],f=Gn||a.isMissingStr(v),g="".concat(Yn,".").concat(s),p="".concat(Un).concat(a.DEVIATION_BADGE_SEPARATOR).concat(l).concat(a.DEVIATION_BADGE_SEPARATOR).concat(Dn).concat(a.DEVIATION_BADGE_SEPARATOR).concat(Nn),h=(null==d?void 0:d.evaluation_outputs)||(null==zn?void 0:zn.evaluation_outputs),_=null!==(i=null==h?void 0:h.output_value)&&void 0!==i?i:null,m=null!==(o=null===(t=null==h?void 0:h.metadata)||void 0===t?void 0:t.label_color)&&void 0!==o?o:$n,x=a.generateColorPalette(m),y=n.__assign({},x),S=(null==d?void 0:d.deviation_summary)?{deviation_summary:d.deviation_summary||(null==zn?void 0:zn.deviation_summary),deviation_title:(null==d?void 0:d.deviation_title)||(null==zn?void 0:zn.deviation_title),deviation_impact:(null==d?void 0:d.deviation_impact)||(null==zn?void 0:zn.deviation_impact),deviation_explanation:(null==d?void 0:d.deviation_explanation)||(null==zn?void 0:zn.deviation_explanation),evaluation_outputs:h,cognitive_decisioning:(null==d?void 0:d.cognitive_decisioning)||(null==zn?void 0:zn.cognitive_decisioning)}:null,I=0,b=pn||"";if(u&&b){var A=b.split(/\n{2,}/),O=A.findIndex(function(n){return n.includes(u)});if(-1!==O){var R=Object.entries(Hn).filter(function(n){n[0];var e=n[1][B];return e&&A[O].includes(e)}).sort(function(n,e){return A[O].indexOf(n[1][B])-A[O].indexOf(e[1][B])}),C=R.filter(function(n){n[0];var e=n[1][B];return e&&(e.includes(u)||u.includes(e))});C.length>1&&(I=Math.max(0,C.findIndex(function(n){return n[0]===l})))}}var E=X(P,r);return{id:r,actionId:p,label:g,highlight:u,side:P,style:y,stackIndex:I,score:_,isConnected:V.has(p),showScrollLockToggle:V.has(p)||W&&K===p||!!H&&H===E.current,scrollSyncLocked:G,toggleScrollSyncLocked:z,isOrphan:f,isMissingClause:c,badgeRef:E,onClick:function(e){e.stopPropagation();var i=Fn?n.__assign(n.__assign({},Fn),{title:(null==bn?void 0:bn.title)||(null==Fn?void 0:Fn.title)||""}):{id:"orphan-left",title:"",content:""},t=Mn?n.__assign(n.__assign({},Mn),{title:(null==An?void 0:An.title)||(null==Mn?void 0:Mn.title)||""}):{id:"orphan-right",title:"",content:""};Y(e,i,f,t,p,y)},onSummaryClick:function(n){n.stopPropagation(),Z(n,p,f,S)}}}).filter(Boolean).sort(function(n,e){return parseFloat(n.label)-parseFloat(e.label)}),te=i.useMemo(function(){var n=new Set;return ie.filter(function(e){return!n.has(e.id)&&(n.add(e.id),!0)})},[ie]),oe=M||!vn&&un?te:[],le=te.map(function(n){return n.highlight}).filter(Boolean),de=ie.find(function(n){return V.has(n.actionId)}),ae=!!de;if(!(sn||_n||S.subsections&&0!==S.subsections.length))return null;var re=(null===(y=null==de?void 0:de.style)||void 0===y?void 0:y.badgeBorder)||(null==Ln?void 0:Ln.badgeBorder),se=ae&&re?{borderRadius:"4px",outline:"2px solid ".concat(re),outlineOffset:"1px"}:{};return sn?e.jsx(t.Box,n.__assign({ref:Sn,sx:{mt:1,width:"100%",minWidth:0,position:"relative"}},{children:e.jsx(t.Box,n.__assign({sx:n.__assign({width:"100%"},se)},{children:e.jsxs(t.Accordion,n.__assign({disableGutters:!0,expanded:!mn&&yn,onChange:function(){if(!mn){if(yn){var e=String(K||""),i=e.includes(Dn)||e.includes(Nn);i||V.forEach(function(n){(String(n).includes(Dn)||String(n).includes(Nn))&&(i=!0)}),i&&($(),nn(new Set),en([]),tn.current=[])}j(function(e){var i;return n.__assign(n.__assign({},e),((i={})[I]=!e[I],i))})}},sx:{mt:0,boxShadow:"none",border:mn?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF",minWidth:0,"&:before":{display:"none"}}},{children:[e.jsx(t.AccordionSummary,n.__assign({expandIcon:mn?null:e.jsx(o.ChevronDown,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"}}},{children:e.jsx(t.Typography,n.__assign({component:"div",sx:{fontSize:"11px",fontWeight:600,color:mn?"#94A3B8":"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:xn||"Untitled Subsection"}))})),!mn&&e.jsxs(t.AccordionDetails,n.__assign({sx:{pt:0,pb:1,minWidth:0}},{children:[_n&&e.jsx(l.MemoizedMarkdown,{content:pn,overlayContent:hn,sxStyles:U,deviationBadges:oe,maintainRelativeOrder:w,highlightBg:ne,suppressHighlightBg:fn,highlights:le,collisionKey:rn}),(S.subsections||[]).map(function(n,i){return e.jsx(u,{section:n,keyPath:"".concat(I,"-").concat(i),depth:A+1,columnKey:P,parentNodeId:B},"".concat(I,"-").concat(i))})]}))]}))}))})):e.jsx(t.Box,n.__assign({ref:Sn,sx:{mt:0===A?1:.75,width:"100%",minWidth:0,position:"relative"}},{children:!mn&&e.jsxs(t.Box,n.__assign({sx:n.__assign({width:"100%"},se)},{children:[_n&&e.jsx(l.MemoizedMarkdown,{content:pn,overlayContent:hn,sxStyles:U,deviationBadges:oe,maintainRelativeOrder:w,highlightBg:ne,suppressHighlightBg:fn,highlights:le,collisionKey:rn}),(S.subsections||[]).map(function(n,i){return e.jsx(u,{section:n,keyPath:"".concat(I,"-").concat(i),depth:A+1,columnKey:P,parentNodeId:B,sectionOffset:k},"".concat(I,"-").concat(i))})]}))}))});exports.default=u;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("tslib"),e=require("react/jsx-runtime"),i=require("react"),t=require("@mui/material"),o=require("lucide-react"),l=require("../hooks/memoizedMarkdown.js"),d=require("../CompareContext.js"),a=require("../CognitiveComparehelpers.js"),r=require("../CognitiveCompareConstants.js");function s(n){return n&&"object"==typeof n&&"default"in n?n:{default:n}}var u=s(i).default.memo(function(s){var c,v,f,g,p,h,_,m,x,y,S=s.section,I=s.keyPath,b=s.depth,A=void 0===b?0:b,O=s.columnKey,P=void 0===O?"left":O,R=s.parentNodeId,B=void 0===R?"":R,k=s.sectionOffset,C=d.useCompareContext(),E=C.expandedSubSections,j=C.setExpandedSubSections,w=C.maintainRelativeOrder,M=C.showDeviationBadges,F=void 0!==M&&M,D=C.proposedSections,N=C.existingSections,T=C.treeData,q=C.deviationNumberRegistry,L=C.deviationParentRegistry,V=C.connectedSections,K=C.activeSideBySideSection,W=C.isSideBySide,G=C.scrollSyncLocked,z=C.toggleScrollSyncLocked,H=C.summaryPopupAnchorEl,U=C.resolvedMarkdownStyles,J=C.getSubSectionRef,Q=C.getSubSectionCompareStyle,X=C.getBadgeRef,Y=C.openMoreFunctionsPopup,Z=C.openSummaryPopup,$=C.resetSideBySide,nn=C.setConnectedSections,en=C.setConnectedLines,tn=C.cachedConnectedPositions,on=C.isProposingFix,ln=C.proposingFixNodeId,dn=C.isRedlineFlow,an=C.unifiedNumbering,rn=null!=K?K:"",sn=(null===(c=S.displayTitle)||void 0===c||c)&&a.hasValue(S.title),un=!(!on||!ln||"left"!==P||S.id!==ln&&S.nodeId!==ln),cn=a.hasMeaningfulRedlineTags(S.content),vn="boolean"==typeof dn?dn:cn,fn=cn,gn=vn&&cn,pn=gn?a.stripRedlineTags(S.content):S.content,hn=gn?S.content:void 0,_n=(null===(v=S.displayContent)||void 0===v||v||cn)&&a.hasValue(S.content),mn=!sn&&!_n,xn=sn?S.title:_n?"No Title Found":"No Matching Section Found",yn=!!E[I],Sn=J(P,I),In=I.split("-").map(Number)[0],bn=D[In],An=N[In],On=In,Pn=In,Rn=!1,Bn=function(n,e,i){if(!n||!e)return null;if(n.id===e||n.nodeId===e||n.contentId===e)return{section:n,keyPath:i};for(var t=(n.subsections||[]).map(function(n,e){return{section:n,keyPath:"".concat(i,"-").concat(e)}}),o=function(){var n=t.shift();return(null==n?void 0:n.section)?n.section.id===e||n.section.nodeId===e||n.section.contentId===e?{value:n}:void(n.section.subsections||[]).forEach(function(e,i){t.push({section:e,keyPath:"".concat(n.keyPath,"-").concat(i)})}):"continue"};t.length>0;){var l=o();if("object"==typeof l)return l.value}return null};if(w)if("left"===P){var kn=null===(f=null==bn?void 0:bn.refIndexes)||void 0===f?void 0:f[0],Cn=N.findIndex(function(n){return n.selfIndex===kn});-1!==Cn?(An=N[Cn],Pn=Cn):Rn=!0}else{var En=null===(g=null==An?void 0:An.refIndexes)||void 0===g?void 0:g[0],jn=D.findIndex(function(n){return n.selfIndex===En});-1!==jn?(bn=D[jn],On=jn):Rn=!0}var wn=function(n,e){if(!e||!n)return null;for(var i=0;i<n.length;i++){var t=Bn(n[i],e,String(i));if(t)return t}return null},Mn=null,Fn=null,Dn="",Nn="";if(w)"left"===P?(Mn=S,Dn=I,(Tn=Bn(An,S.nodeId||S.id,String(Pn)))||(Tn=wn(N,S.nodeId||S.id)),Fn=(null==Tn?void 0:Tn.section)||null,Nn=(null==Tn?void 0:Tn.keyPath)||""):(Fn=S,Nn=I,(qn=Bn(bn,S.nodeId||S.id,String(On)))||(qn=wn(D,S.nodeId||S.id)),Mn=(null==qn?void 0:qn.section)||null,Dn=(null==qn?void 0:qn.keyPath)||"");else if("left"===P){Mn=S,Dn=I;var Tn=wn(N,S.nodeId||S.id);Fn=(null==Tn?void 0:Tn.section)||null,Nn=(null==Tn?void 0:Tn.keyPath)||""}else{Fn=S,Nn=I;var qn=wn(D,S.nodeId||S.id);Mn=(null==qn?void 0:qn.section)||null,Dn=(null==qn?void 0:qn.keyPath)||""}var Ln=(Dn?Q(Dn):null)||Q(I),Vn=null===(p=null==T?void 0:T.input_index_map)||void 0===p?void 0:p[0],Kn=null===(h=null==T?void 0:T.input_index_map)||void 0===h?void 0:h[1],Wn="left"===P?Kn:Vn,Gn="left"===P?!Fn:!Mn,zn=S.evaluationResult||(null==Mn?void 0:Mn.evaluationResult)||(null==Fn?void 0:Fn.evaluationResult),Hn=(null==zn?void 0:zn.deviations)||{},Un=S.nodeId||S.id||(null==Mn?void 0:Mn.nodeId)||(null==Mn?void 0:Mn.id)||(null==Fn?void 0:Fn.nodeId)||(null==Fn?void 0:Fn.id);w&&"left"!==P&&(null==Mn?void 0:Mn.id)&&(Un=Mn.nodeId||Mn.id);var Jn=Object.keys(Hn)[0],Qn=Jn?"".concat(Un).concat(a.DEVIATION_BADGE_SEPARATOR).concat(Jn):null,Xn=Qn?null==L?void 0:L[Qn]:null,Yn=In+1;if(w&&an){var Zn="left"===P?an.leftNums.get(null==bn?void 0:bn.id):an.rightNums.get(null==An?void 0:An.id);Rn&&void 0!==Zn?Yn=Zn:null!=Xn&&Xn>=0?Yn=Xn:void 0!==Zn&&(Yn=Zn)}else null!=Xn&&Xn>=0&&(Yn=Xn);var $n=null!==(x=null===(m=null===(_=null==zn?void 0:zn.evaluation_outputs)||void 0===_?void 0:_.metadata)||void 0===m?void 0:m.label_color)&&void 0!==x?x:r.DEFAULT_DEVIAION_COLOR,ne=a.generateColorPalette($n).highlightBg,ee=Object.entries(Hn).map(function(n){var e=n[0],i=n[1],t="".concat(Un).concat(a.DEVIATION_BADGE_SEPARATOR).concat(e);return{deviationKey:e,deviationMap:i,refId:t,currentIndex:q[t]}}).filter(function(n){return void 0!==n.currentIndex&&null!==n.currentIndex});ee.sort(function(n,e){return n.currentIndex-e.currentIndex});var ie=ee.map(function(e){var i,t,o,l=e.deviationKey,d=e.deviationMap,r=e.refId,s=e.currentIndex;w&&void 0!==k&&(s-=k),s=Math.max(1,s);var u=d[B],c=a.isMissingStr(u);if(c)u="";else if(!u)return null;var v=d[Wn],f=Gn||a.isMissingStr(v),g="".concat(Yn,".").concat(s),p="".concat(Un).concat(a.DEVIATION_BADGE_SEPARATOR).concat(l).concat(a.DEVIATION_BADGE_SEPARATOR).concat(Dn).concat(a.DEVIATION_BADGE_SEPARATOR).concat(Nn),h=(null==d?void 0:d.evaluation_outputs)||(null==zn?void 0:zn.evaluation_outputs),_=null!==(i=null==h?void 0:h.output_value)&&void 0!==i?i:null,m=null!==(o=null===(t=null==h?void 0:h.metadata)||void 0===t?void 0:t.label_color)&&void 0!==o?o:$n,x=a.generateColorPalette(m),y=n.__assign({},x),S=(null==d?void 0:d.deviation_summary)?{deviation_summary:d.deviation_summary||(null==zn?void 0:zn.deviation_summary),deviation_title:(null==d?void 0:d.deviation_title)||(null==zn?void 0:zn.deviation_title),deviation_impact:(null==d?void 0:d.deviation_impact)||(null==zn?void 0:zn.deviation_impact),deviation_explanation:(null==d?void 0:d.deviation_explanation)||(null==zn?void 0:zn.deviation_explanation),evaluation_outputs:h,cognitive_decisioning:(null==d?void 0:d.cognitive_decisioning)||(null==zn?void 0:zn.cognitive_decisioning)}:null,I=0,b=pn||"";if(u&&b){var A=b.split(/\n{2,}/),O=A.findIndex(function(n){return n.includes(u)});if(-1!==O){var R=Object.entries(Hn).filter(function(n){n[0];var e=n[1][B];return e&&A[O].includes(e)}).sort(function(n,e){return A[O].indexOf(n[1][B])-A[O].indexOf(e[1][B])}),C=R.filter(function(n){n[0];var e=n[1][B];return e&&(e.includes(u)||u.includes(e))});C.length>1&&(I=Math.max(0,C.findIndex(function(n){return n[0]===l})))}}var E=X(P,r);return{id:r,actionId:p,label:g,highlight:u,side:P,style:y,stackIndex:I,score:_,isConnected:V.has(p),showScrollLockToggle:V.has(p)||W&&K===p||!!H&&H===E.current,scrollSyncLocked:G,toggleScrollSyncLocked:z,isOrphan:f,isMissingClause:c,badgeRef:E,onClick:function(e){e.stopPropagation();var i=Mn?n.__assign(n.__assign({},Mn),{title:(null==bn?void 0:bn.title)||(null==Mn?void 0:Mn.title)||""}):{id:"orphan-left",title:"",content:""},t=Fn?n.__assign(n.__assign({},Fn),{title:(null==An?void 0:An.title)||(null==Fn?void 0:Fn.title)||""}):{id:"orphan-right",title:"",content:""};Y(e,i,f,t,p,y)},onSummaryClick:function(n){n.stopPropagation(),Z(n,p,f,S)}}}).filter(Boolean).sort(function(n,e){return parseFloat(n.label)-parseFloat(e.label)}),te=i.useMemo(function(){var n=new Set;return ie.filter(function(e){return!n.has(e.id)&&(n.add(e.id),!0)})},[ie]),oe=F||!vn&&un?te:[],le=te.map(function(n){return n.highlight}).filter(Boolean),de=ie.find(function(n){return V.has(n.actionId)}),ae=!!de;if(!(sn||_n||S.subsections&&0!==S.subsections.length))return null;var re=(null===(y=null==de?void 0:de.style)||void 0===y?void 0:y.badgeBorder)||(null==Ln?void 0:Ln.badgeBorder),se=ae&&re?{borderRadius:"4px",outline:"2px solid ".concat(re),outlineOffset:"1px"}:{};return sn?e.jsx(t.Box,n.__assign({ref:Sn,sx:{mt:1,width:"100%",minWidth:0,position:"relative"}},{children:e.jsx(t.Box,n.__assign({sx:n.__assign({width:"100%"},se)},{children:e.jsxs(t.Accordion,n.__assign({disableGutters:!0,expanded:!mn&&yn,onChange:function(){if(!mn){if(yn){var e=String(K||""),i=e.includes(Dn)||e.includes(Nn);i||V.forEach(function(n){(String(n).includes(Dn)||String(n).includes(Nn))&&(i=!0)}),i&&($(),nn(new Set),en([]),tn.current=[])}j(function(e){var i;return n.__assign(n.__assign({},e),((i={})[I]=!e[I],i))})}},sx:{mt:0,boxShadow:"none",border:mn?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF",minWidth:0,"&:before":{display:"none"}}},{children:[e.jsx(t.AccordionSummary,n.__assign({expandIcon:mn?null:e.jsx(o.ChevronDown,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"}}},{children:e.jsx(t.Typography,n.__assign({component:"div",sx:{fontSize:"11px",fontWeight:600,color:mn?"#94A3B8":"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:xn||"Untitled Subsection"}))})),!mn&&e.jsxs(t.AccordionDetails,n.__assign({sx:{pt:0,pb:1,minWidth:0}},{children:[_n&&e.jsx(l.MemoizedMarkdown,{content:pn,overlayContent:hn,sxStyles:U,deviationBadges:oe,maintainRelativeOrder:w,highlightBg:ne,suppressHighlightBg:fn,highlights:le,collisionKey:rn}),(S.subsections||[]).map(function(n,i){return e.jsx(u,{section:n,keyPath:"".concat(I,"-").concat(i),depth:A+1,columnKey:P,parentNodeId:B,sectionOffset:k},"".concat(I,"-").concat(i))})]}))]}))}))})):e.jsx(t.Box,n.__assign({ref:Sn,sx:{mt:0===A?1:.75,width:"100%",minWidth:0,position:"relative"}},{children:!mn&&e.jsxs(t.Box,n.__assign({sx:n.__assign({width:"100%"},se)},{children:[_n&&e.jsx(l.MemoizedMarkdown,{content:pn,overlayContent:hn,sxStyles:U,deviationBadges:oe,maintainRelativeOrder:w,highlightBg:ne,suppressHighlightBg:fn,highlights:le,collisionKey:rn}),(S.subsections||[]).map(function(n,i){return e.jsx(u,{section:n,keyPath:"".concat(I,"-").concat(i),depth:A+1,columnKey:P,parentNodeId:B,sectionOffset:k},"".concat(I,"-").concat(i))})]}))}))});exports.default=u;
2
2
  //# sourceMappingURL=SubSectionAccordion.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),e=require("../CognitiveComparehelpers.js");exports.useLinesCalculator=function(n){var i=n.containerRef,r=n.leftContainerRef,c=n.rightContainerRef;n.svgContainerRef;var l=n.pathRefs,o=n.leftHeaderRef,u=n.rightHeaderRef,a=n.proposedSections,d=n.existingSections,s=n.visibleFields,v=n.leftRefs,h=n.rightRefs,g=n.sectionLeftRefs,f=n.sectionRightRefs,b=n.subSectionLeftRefs,p=n.subSectionRightRefs,A=n.lhsBadgeRefs,y=n.rhsBadgeRefs,R=n.sectionRowRefs,x=n.expandedSections,m=n.expandedSubSections,B=n.connectedSections,S=n.isSideBySide,T=n.activeSideBySideSection,C=n.maintainRelativeOrder,I=n.isGuidelineMode,E=n.cognitiveMap,M=n.getSectionCompareStyle,D=n.getSubSectionCompareStyle,O=n.getDeviationStyleByKey,L=n.isArrowVisible,_=n.isAnimatingRef,F=n.isSideBySideRef,N=n.sideBySideCacheRef,H=n.sideBySideLineRef,P=n.activeSideBySideSectionRef,k=n.activeSideBySideRightSectionRef,G=n.connectedLines,w=n.setConnectedLines,V=n.cachedConnectedPositions,Y=n.calculateLinesRef,j=n.resizeTimerRef,z=n.scrollLock,Q=n.scrollSyncLocked,X=n.handleResizeRef,q=n.activeProposed,K=n.existingRule,J=n.analysisData,U=n.pendingScrollTargetRef,W=n.pendingScrollCallbackRef,Z=n.resolvedComparisonConfig,$=n.getFieldData,tt=t.useState([]),et=tt[0],nt=tt[1],it=t.useState(null),rt=it[0],ct=it[1],lt=t.useState([]),ot=lt[0],ut=lt[1],at=null!=G?G:ot,dt=null!=w?w:ut,st=t.useState({width:0,height:0}),vt=st[0],ht=st[1],gt=t.useRef(!1),ft=t.useRef(!1),bt=t.useRef(!1),pt=t.useRef(null),At=t.useRef([]),yt=null!=V?V:At,Rt=function(t,e,n,i,r,c,l){if(Math.abs(i-e)<=1)return c&&l?"M ".concat(t,",").concat(e," L ").concat(n,",").concat(i):c&&!l?"M ".concat(t,",").concat(e," L ").concat(r,",").concat(e):!c&&l?"M ".concat(r,",").concat(e," L ").concat(n,",").concat(i):"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i);var o=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?o:-o,d=i>e?u:-u,s=n>r?u:-u;return c&&l?"M ".concat(t,",").concat(e," L ").concat(r-o,",").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&&!l?"M ".concat(t,",").concat(e," L ").concat(r-o,",").concat(e," Q ").concat(r,",").concat(e," ").concat(r,",").concat(e+a," L ").concat(r,",").concat(i):!c&&l?"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)},xt=t.useCallback(function(){var t,n,l,R,L,F,N,H,P,k,G,w,V,Y,j,z,Q,X;if(!gt.current&&!_.current){gt.current=!0;try{if(!i.current)return;var q=function(t){var e=t.split("-"),n=e[0];if(!x[n]&&!1===C)return!1;if(C&&!x["left-".concat(n)]&&!x["right-".concat(n)]&&!x[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},K=i.current.getBoundingClientRect();ht({width:K.width,height:K.height});var J=[];if(s.forEach(function(t){var e,n,i=t.key,r=null===(e=v.current[i])||void 0===e?void 0:e.current,c=null===(n=h.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")}),!_.current){for(var U=0;U<Math.max(a.length,d.length);U++){var W=null===(t=g.current[U])||void 0===t?void 0:t.current,Z=null===(n=f.current[U])||void 0===n?void 0:n.current;W&&(W.style.height="auto",W.style.minHeight="0px"),Z&&(Z.style.height="auto",Z.style.minHeight="0px")}C||Object.keys(b.current).forEach(function(t){var e,n;if(q(t)){var i=null===(e=b.current[t])||void 0===e?void 0:e.current,r=null===(n=p.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 $={};s.forEach(function(t){var e,n,i=t.key,r=null===(e=v.current[i])||void 0===e?void 0:e.current,c=null===(n=h.current[i])||void 0===n?void 0:n.current;if(r&&c){var l=r.getBoundingClientRect(),o=c.getBoundingClientRect();$[i]=Math.max(l.height,o.height)}});var tt={left:{},right:{}},et={};if(!_.current)if(C){if(S&&null!==T)if("number"==typeof T){var it=T,rt=a[it],lt=null===(L=g.current[it])||void 0===L?void 0:L.current;lt&&rt&&(rt.refIndexes||[]).forEach(function(t){var e,n=d.findIndex(function(e){return e.selfIndex===t}),i=null===(e=f.current[n])||void 0===e?void 0:e.current;if(i&&(x["left-".concat(it)]||x["right-".concat(n)])){var r=Math.max(lt.getBoundingClientRect().height,i.getBoundingClientRect().height);tt.left[it]=Math.max(tt.left[it]||0,r),tt.right[n]=Math.max(tt.right[n]||0,r)}})}else{var ot=T.split(e.DEVIATION_BADGE_SEPARATOR)[2];if(ot){W=null===(F=b.current[ot])||void 0===F?void 0:F.current,Z=null===(N=p.current[ot])||void 0===N?void 0:N.current;if(W&&Z){ut=Math.max(W.getBoundingClientRect().height,Z.getBoundingClientRect().height);et[ot]=Math.max(et[ot]||0,ut)}}}}else{Object.keys(b.current).forEach(function(t){var e,n;if(q(t)){var i=null===(e=b.current[t])||void 0===e?void 0:e.current,r=null===(n=p.current[t])||void 0===n?void 0:n.current;if(i&&r&&null!==i.offsetParent&&null!==r.offsetParent){var c=i.getBoundingClientRect(),l=r.getBoundingClientRect(),o=Math.max(c.height,l.height);et[t]=o,i.style.minHeight="".concat(o,"px"),r.style.minHeight="".concat(o,"px")}}});for(U=0;U<Math.min(a.length,d.length);U++){var W=null===(l=g.current[U])||void 0===l?void 0:l.current,Z=null===(R=f.current[U])||void 0===R?void 0:R.current;if(W&&Z){var ut=Math.max(W.getBoundingClientRect().height,Z.getBoundingClientRect().height);tt.left[U]=ut,tt.right[U]=ut}}}if(s.forEach(function(t){var e,n,i=t.key,r=null===(e=v.current[i])||void 0===e?void 0:e.current,c=null===(n=h.current[i])||void 0===n?void 0:n.current;if(r&&c){var l=$[i];r.style.minHeight="".concat(l,"px"),c.style.minHeight="".concat(l,"px")}}),_.current||(Object.entries(tt.left).forEach(function(t){var e,n=t[0],i=t[1],r=null===(e=g.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=f.current[Number(n)])||void 0===e?void 0:e.current;r&&(r.style.minHeight="".concat(i,"px"))}),C||Object.keys(et).forEach(function(t){var e,n,i=null===(e=b.current[t])||void 0===e?void 0:e.current,r=null===(n=p.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")}})),!I){a.forEach(function(t,e){var n,i=null===(n=g.current[e])||void 0===n?void 0:n.current;if(i){var l=function(t,e){var n=(t.refIndexes||[]).map(function(t){return d.findIndex(function(e){return e.selfIndex===t})}).filter(function(t){return-1!==t});return!n.length&&d[e]?[e]:Array.from(new Set(n))}(t,e);l.forEach(function(n){var l,o,u,a,s,v,h,g,b,p,A=null===(l=f.current[n])||void 0===l?void 0:l.current;if(A){var y=i.getBoundingClientRect(),R=A.getBoundingClientRect(),x=y.right-K.left,m=R.left-K.left,B=y.top+18-K.top,I=R.top+18-K.top;if(C&&S&&T===e){var D=null!==(u=null===(o=r.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==u?u:0,O=null!==(s=null===(a=c.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==s?s:0,L=D+(null!==(h=null===(v=r.current)||void 0===v?void 0:v.clientHeight)&&void 0!==h?h:1/0),_=O+(null!==(b=null===(g=c.current)||void 0===g?void 0:g.clientHeight)&&void 0!==b?b:1/0),F=function(t,e,n){return Math.max(e,Math.min(n,t))};B=F(y.top+18,D,L)-K.top,I=F(R.top+18,O,_)-K.top}var N=M(e);N&&J.push({id:"line-".concat(e,"-").concat(n),x1:x,y1:B,x2:m,y2:I,style:N,sectionIdx:e,targetRightIdx:n,isSubSection:!1,hasCognitive:!!((null==t?void 0:t.cognitiveData)||(null===(p=d[n])||void 0===p?void 0:p.cognitiveData)||(null==t?void 0:t.nodeId)&&E[t.nodeId])})}})}})}if(!I&&S&&"string"==typeof T&&T.includes(e.DEVIATION_BADGE_SEPARATOR)){var at=T.split(e.DEVIATION_BADGE_SEPARATOR),st=at[0],vt=at[1],ft=at[2],bt=(at[3],"".concat(st).concat(e.DEVIATION_BADGE_SEPARATOR).concat(vt)),pt=null===(H=A.current[bt])||void 0===H?void 0:H.current,At=null===(P=y.current[bt])||void 0===P?void 0:P.current;if(pt&&At){var xt=pt.getBoundingClientRect(),Bt=At.getBoundingClientRect(),St=xt.right-K.left,Tt=Bt.left-K.left,Ct=xt.top+xt.height/2-K.top,It=Bt.top+Bt.height/2-K.top;if(C){var Et=null!==(G=null===(k=r.current)||void 0===k?void 0:k.getBoundingClientRect().top)&&void 0!==G?G:0,Mt=null!==(V=null===(w=c.current)||void 0===w?void 0:w.getBoundingClientRect().top)&&void 0!==V?V:0,Dt=Et+(null!==(j=null===(Y=r.current)||void 0===Y?void 0:Y.clientHeight)&&void 0!==j?j:1/0),Ot=Mt+(null!==(Q=null===(z=c.current)||void 0===z?void 0:z.clientHeight)&&void 0!==Q?Q:1/0),Lt=function(t,e,n){return Math.max(e,Math.min(n,t))};Ct=Lt(xt.top+xt.height/2,Et,Dt)-K.top,It=Lt(Bt.top+Bt.height/2,Mt,Ot)-K.top}var _t=null!==(X=O(st,vt))&&void 0!==X?X:D(ft);_t&&J.push({id:"line-subsec-".concat(bt),x1:St,y1:Ct,x2:Tt,y2:It,style:_t,sectionIdx:Number(ft.split("-")[0]),isSubSection:!0,subSectionKeyPath:T})}}if(nt(J),o.current&&u.current){var Ft=o.current.getBoundingClientRect(),Nt=u.current.getBoundingClientRect(),Ht=(Ft.top+Ft.height/2-K.top+Nt.top+Nt.height/2-K.top)/2;ct({x1:Ft.right-K.left,x2:Nt.left-K.left,y:Ht})}else ct(null);if(B.size>0){var Pt=[],kt=r.current,Gt=c.current;if(kt&&Gt){var wt=[],Vt=kt.getBoundingClientRect().top,Yt=Gt.getBoundingClientRect().top,jt=Vt+kt.clientHeight,zt=Yt+Gt.clientHeight,Qt=kt.scrollTop,Xt=Gt.scrollTop,qt=K.top,Kt=function(t,e,n){return Math.max(e,Math.min(n,t))};B.forEach(function(t){var n,i,r,c,l,o,u,s,v;if(I){var h=null,g=null,f=null;if("string"==typeof t&&t.includes(e.DEVIATION_BADGE_SEPARATOR)){var b=t.split(e.DEVIATION_BADGE_SEPARATOR),p=b[0],R=b[1],x=b[2],m="".concat(p).concat(e.DEVIATION_BADGE_SEPARATOR).concat(R);h=null===(n=A.current[m])||void 0===n?void 0:n.current,f=null!==(i=O(p,R))&&void 0!==i?i:D(x),g=Number((null==x?void 0:x.split("-")[0])||0)}else g=Number(t),h=null===(r=A.current[g])||void 0===r?void 0:r.current,f=M(g);if(!h)return;document.querySelectorAll('[id^="guideline-target-"]').forEach(function(n,i){var r=h.getBoundingClientRect(),c=n.getBoundingClientRect(),l=r.right-K.left,o=c.left-K.left-0,u=l+75,a=r.top+r.height/2,d=c.top+c.height/2,s=a-Vt+Qt,v=d-Yt+Xt,g="conn-guide-".concat(t,"-").concat(i),b="";"string"==typeof t&&t.includes(e.DEVIATION_BADGE_SEPARATOR)?b=(t.split(e.DEVIATION_BADGE_SEPARATOR)[2]||"").split("-").map(function(t){return Number(t)+1}).join("."):b=String(Number(t)+1);var p=String.fromCharCode(97+i),A="".concat(b,"(").concat(p,")");wt.push({lhsScrollY:s,rhsScrollY:v,x1:l,x2:o,containerTop:qt,leftIdx:t,rhsArrayIdx:i,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 y=Kt(a,Vt,jt),R=Kt(d,Yt,zt),x=y-qt,m=R-qt,B=Rt(l,x,o,m,u,a>=Vt-4&&a<=jt+4,d>=Yt-4&&d<=zt+4);Pt.push({id:g,pathD:B,style:f,leftIdx:t,rhsArrayIdx:i,x1:l,x2:o,y1:x,y2:m,centerX:u,matchLabel:A,isGuideline:!0})})}else if("string"==typeof t&&t.includes(e.DEVIATION_BADGE_SEPARATOR)){var B=t.split(e.DEVIATION_BADGE_SEPARATOR),S=(p=B[0],R=B[1],x=B[2],B[3],m="".concat(p).concat(e.DEVIATION_BADGE_SEPARATOR).concat(R),null===(c=A.current[m])||void 0===c?void 0:c.current),T=null===(l=y.current[m])||void 0===l?void 0:l.current;if(!S||!T)return;var E=S.getBoundingClientRect(),L=T.getBoundingClientRect(),_=null!==(o=O(p,R))&&void 0!==o?o:D(x),F=E.right-K.left,N=L.left-K.left-0,H=F+75,P=E.top+E.height/2,k=L.top+L.height/2,G=P-Vt+Qt,w=k-Yt+Xt,V="conn-subsec-".concat(m),Y=(x||"").split("-").map(function(t){return Number(t)+1}).join("."),j="".concat(Y,"(a)");wt.push({lhsScrollY:G,rhsScrollY:w,x1:F,x2:N,containerTop:qt,leftIdx:t,rhsArrayIdx:t,styleColor:(null==_?void 0:_.badgeBorder)||"#6366F1",styleBg:(null==_?void 0:_.badgeBg)||"#FFFFFF",styleText:(null==_?void 0:_.badgeText)||"#A16207",styleId:V,centerX:H});var z=Kt(P,Vt,jt),Q=Kt(k,Yt,zt),X=Rt(F,Z=z-qt,N,$=Q-qt,H,P>=Vt-4&&P<=jt+4,k>=Yt-4&&k<=zt+4);Pt.push({id:V,pathD:X,style:_,leftIdx:t,rhsArrayIdx:t,x1:F,x2:N,y1:Z,y2:$,matchLabel:j})}else if(C){var q=t,J=a[q];if(!(null===(v=null==J?void 0:J.refIndexes)||void 0===v?void 0:v.length))return;J.refIndexes.forEach(function(e,n){var i,r,c=d.findIndex(function(t){return t.selfIndex===e});if(-1!==c){var l=null===(i=A.current[q])||void 0===i?void 0:i.current,o=null===(r=y.current[c])||void 0===r?void 0:r.current;if(l&&o){var u=l.getBoundingClientRect(),a=o.getBoundingClientRect(),s=M(q),v=u.right-K.left,h=a.left-K.left-0,g=v+75,f=u.top+u.height/2,b=a.top+a.height/2,p=f-Vt+Qt,R=b-Yt+Xt,x="conn-".concat(q,"-").concat(c),m=String(Number(t)+1),B=String.fromCharCode(97+n),S="".concat(m,"(").concat(B,")");wt.push({lhsScrollY:p,rhsScrollY:R,x1:v,x2:h,containerTop:qt,leftIdx:q,rhsArrayIdx:c,styleColor:(null==s?void 0:s.badgeBorder)||"#6366F1",styleBg:(null==s?void 0:s.badgeBg)||"#FFFFFF",styleText:(null==s?void 0:s.badgeText)||"#A16207",styleId:x,centerX:g});var T=Kt(f,Vt,jt),C=Kt(b,Yt,zt),I=T-qt,E=C-qt,D=Rt(v,I,h,E,g,f>=Vt-4&&f<=jt+4,b>=Yt-4&&b<=zt+4);Pt.push({id:x,pathD:D,style:s,leftIdx:q,rhsArrayIdx:c,x1:v,x2:h,y1:I,y2:E,matchLabel:S})}}})}else{var U=t,W=U;S=null===(u=A.current[U])||void 0===u?void 0:u.current,T=null===(s=y.current[W])||void 0===s?void 0:s.current;if(!S||!T)return;E=S.getBoundingClientRect(),L=T.getBoundingClientRect(),_=M(U),F=E.right-K.left,N=L.left-K.left-0,H=F+75,P=E.top+E.height/2,k=L.top+L.height/2,G=P-Vt+Qt,w=k-Yt+Xt,V="conn-".concat(U,"-").concat(W),Y=String(Number(t)+1),j="".concat(Y,"(a)");wt.push({lhsScrollY:G,rhsScrollY:w,x1:F,x2:N,containerTop:qt,leftIdx:U,rhsArrayIdx:W,styleColor:(null==_?void 0:_.badgeBorder)||"#6366F1",styleBg:(null==_?void 0:_.badgeBg)||"#FFFFFF",styleText:(null==_?void 0:_.badgeText)||"#A16207",styleId:V,centerX:H});var Z,$;z=Kt(P,Vt,jt),Q=Kt(k,Yt,zt),X=Rt(F,Z=z-qt,N,$=Q-qt,H,P>=Vt-4&&P<=jt+4,k>=Yt-4&&k<=zt+4);Pt.push({id:V,pathD:X,style:_,leftIdx:U,rhsArrayIdx:W,x1:F,x2:N,y1:Z,y2:$,matchLabel:j})}}),yt.current=wt}dt(Pt),setTimeout(function(){return mt()},10)}else dt([]),yt.current=[],setTimeout(function(){return mt()},10)}catch(t){console.error("Line render safe fail: ",t)}finally{gt.current=!1}}},[s,a,d,E,Z,$,M,O,C,S,T,B,x,m,I]),mt=t.useCallback(function(){var t,e,n,o,u,a,d,s,v,h,g,f,b,p,A,y,R,x,m,B=yt.current;if(!B.length)return null===(t=l.current["guideline-up-stroke"])||void 0===t||t.setAttribute("visibility","hidden"),null===(e=l.current["guideline-up-badge"])||void 0===e||e.setAttribute("visibility","hidden"),null===(n=l.current["guideline-down-stroke"])||void 0===n||n.setAttribute("visibility","hidden"),void(null===(o=l.current["guideline-down-badge"])||void 0===o||o.setAttribute("visibility","hidden"));if(!_.current){var S=null!==(a=null===(u=r.current)||void 0===u?void 0:u.scrollTop)&&void 0!==a?a:0,T=null!==(s=null===(d=c.current)||void 0===d?void 0:d.scrollTop)&&void 0!==s?s:0,C=null!==(h=null===(v=r.current)||void 0===v?void 0:v.clientHeight)&&void 0!==h?h:1/0,I=null!==(f=null===(g=c.current)||void 0===g?void 0:g.clientHeight)&&void 0!==f?f:1/0,E=null!==(p=null===(b=r.current)||void 0===b?void 0:b.getBoundingClientRect().top)&&void 0!==p?p:0,M=null!==(y=null===(A=c.current)||void 0===A?void 0:A.getBoundingClientRect().top)&&void 0!==y?y:0,D=E+C,O=M+I,L=null===(R=i.current)||void 0===R?void 0:R.getBoundingClientRect(),F=null!==(x=null==L?void 0:L.top)&&void 0!==x?x:0,N=null!==(m=null==L?void 0:L.height)&&void 0!==m?m:1/0,H=function(t,e,n){return Math.max(e,Math.min(n,t))},P=0,k=0,G=0,w=0,V="#6366F1",Y="#A16207",j=!1;if(B.forEach(function(t){var e=t.lhsScrollY-S+E,n=t.rhsScrollY-T+M,i=l.current[t.styleId+"-stroke"],r=l.current[t.styleId+"-bg"],c=l.current[t.styleId+"-btn"],o=l.current[t.styleId+"-number"];if(i||r){var u=H(e,E,D),a=H(n,M,O),d=u-F,s=a-F,v=e>=E-4&&e<=D+4,h=n>=M-4&&n<=O+4,g=!0;j=!0;var f=t.centerX||t.x1+75;0===G&&(G=t.x1,w=d,V=t.styleColor,t.styleBg,Y=t.styleText||"#A16207"),n<M-4?(P++,g=!1):n>O+4&&(k++,g=!1);var b=Rt(t.x1,d,t.x2,s,f,v,h);i&&(g&&b?(i.setAttribute("visibility","visible"),i.setAttribute("d",b)):i.setAttribute("visibility","hidden")),r&&(g&&b?(r.setAttribute("visibility","visible"),r.setAttribute("d",b)):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"))}}),j){var z=l.current["guideline-up-stroke"],Q=l.current["guideline-up-badge"],X=l.current["guideline-up-arrow"],q=l.current["guideline-up-text"],K=l.current["guideline-up-badge-rect"],J=G+75;if(P>0){var U=Math.max(15,M-F+15),W=Math.min(15,Math.abs(J-G),Math.max(0,w-U)),Z="M ".concat(G,",").concat(w," L ").concat(J-W,",").concat(w," Q ").concat(J,",").concat(w," ").concat(J,",").concat(w-W," L ").concat(J,",").concat(U);null==z||z.setAttribute("visibility","visible"),null==z||z.setAttribute("d",Z),null==z||z.setAttribute("stroke",V),null==Q||Q.setAttribute("visibility","visible"),null==Q||Q.setAttribute("transform","translate(".concat(J,", ").concat(U,")")),X&&X.setAttribute("fill",V),q&&(q.textContent="+".concat(P),q.setAttribute("fill",Y)),K&&K.setAttribute("stroke",V)}else null==z||z.setAttribute("visibility","hidden"),null==Q||Q.setAttribute("visibility","hidden");var $=l.current["guideline-down-stroke"],tt=l.current["guideline-down-badge"],et=l.current["guideline-down-arrow"],nt=l.current["guideline-down-text"],it=l.current["guideline-down-badge-rect"];if(k>0){var rt=Math.min(N-15,O-F-15);W=Math.min(15,Math.abs(J-G),Math.max(0,rt-w)),Z="M ".concat(G,",").concat(w," L ").concat(J-W,",").concat(w," Q ").concat(J,",").concat(w," ").concat(J,",").concat(w+W," L ").concat(J,",").concat(rt);null==$||$.setAttribute("visibility","visible"),null==$||$.setAttribute("d",Z),null==$||$.setAttribute("stroke",V),null==tt||tt.setAttribute("visibility","visible"),null==tt||tt.setAttribute("transform","translate(".concat(J,", ").concat(rt,")")),et&&et.setAttribute("fill",V),nt&&(nt.textContent="+".concat(k),nt.setAttribute("fill",Y)),it&&it.setAttribute("stroke",V)}else null==$||$.setAttribute("visibility","hidden"),null==tt||tt.setAttribute("visibility","hidden")}}},[]),Bt=t.useCallback(function(){yt.current.length>0&&!_.current||(null!==pt.current&&clearTimeout(pt.current),pt.current=setTimeout(function(){Y.current(),pt.current=null},50))},[]),St=t.useCallback(function(t){if(null!==U.current&&W.current&&Math.abs(t.currentTarget.scrollTop-U.current)<=2){var n=W.current;U.current=null,W.current=null,n()}if(!bt.current&&!z.current){if(C&&Q&&(F.current||B.size>0)){var l=t.currentTarget,o=r.current,u=c.current,a=l===o?u:l===u?o:null;if(l&&a){var d=function(){var t,n,i,r,c,l,o,u,a,d,s,v=P.current,h=k.current;if(null===v)return{leftAnchor:null,rightAnchor:null};if("string"==typeof v&&v.includes(e.DEVIATION_BADGE_SEPARATOR)){var x=v.split(e.DEVIATION_BADGE_SEPARATOR),m="".concat(x[0]).concat(e.DEVIATION_BADGE_SEPARATOR).concat(x[1]);return{leftAnchor:(null===(t=A.current[m])||void 0===t?void 0:t.current)||(null===(n=b.current[x[2]])||void 0===n?void 0:n.current)||(null===(i=g.current[Number(x[2])])||void 0===i?void 0:i.current)||null,rightAnchor:(null===(r=y.current[m])||void 0===r?void 0:r.current)||(null===(c=p.current[x[3]])||void 0===c?void 0:c.current)||(null===(l=f.current[Number(x[3])])||void 0===l?void 0:l.current)||null}}var B=Number(v),S=null!==h?Number(h):B;return{leftAnchor:(null===(o=A.current[B])||void 0===o?void 0:o.current)||(null===(u=R.current[B])||void 0===u?void 0:u.current)||(null===(a=g.current[B])||void 0===a?void 0:a.current)||null,rightAnchor:(null===(d=y.current[S])||void 0===d?void 0:d.current)||(null===(s=f.current[S])||void 0===s?void 0:s.current)||null}}(),s=d.leftAnchor,v=d.rightAnchor,h=l===o?s:v,x=l===o?v:s,m=null;if(h&&x){var S=h.getBoundingClientRect(),T=x.getBoundingClientRect(),I=a.getBoundingClientRect(),E=S.top+S.height/2;m=T.top-I.top+a.scrollTop+T.height/2-(E-I.top)}else{var M=Math.max(0,l.scrollHeight-l.clientHeight),D=Math.max(0,a.scrollHeight-a.clientHeight);m=M>0?l.scrollTop/M*D:l.scrollTop}var O=Math.max(0,a.scrollHeight-a.clientHeight);m=Math.max(0,Math.min(m,O)),Math.abs(a.scrollTop-m)>1&&(bt.current=!0,a.scrollTop=m,requestAnimationFrame(function(){bt.current=!1}))}}C||Bt(),ft.current||(ft.current=!0,requestAnimationFrame(function(){var t,n,l,o,u,a,d;if(F.current){var s=r.current,v=c.current;if(s&&v&&H.current){if(!N.current){var h=P.current,g=void 0;if("string"==typeof h&&h.includes(e.DEVIATION_BADGE_SEPARATOR)){var f=h.split(e.DEVIATION_BADGE_SEPARATOR),b="".concat(f[0]).concat(e.DEVIATION_BADGE_SEPARATOR).concat(f[1]);g=null===(t=A.current[b])||void 0===t?void 0:t.current}else g=null===(n=A.current[h])||void 0===n?void 0:n.current;if(g){var p=g.getBoundingClientRect();N.current={badgeScreenY:p.top+p.height/2,initialScrollTop:s.scrollTop,leftTop:s.getBoundingClientRect().top,leftBottom:s.getBoundingClientRect().top+s.clientHeight,cTop:null!==(o=null===(l=i.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==o?o:0}}}if(N.current){var y=N.current,R=s.scrollTop-y.initialScrollTop,x=y.badgeScreenY-R,m=((u=x,a=y.leftTop,d=y.leftBottom,Math.max(a,Math.min(d,u)))-y.cTop).toString(),B=x>=y.leftTop-4&&x<=y.leftBottom+4;H.current.setAttribute("y1",m),H.current.setAttribute("y2",m),H.current.setAttribute("visibility",B?"visible":"hidden")}}}mt(),ft.current=!1}))}},[mt,C,Q,B,Bt]);return t.useEffect(function(){Y.current=xt},[xt]),t.useEffect(function(){var t=setTimeout(Bt,250),e=function(){return X.current()};return window.addEventListener("resize",e),function(){clearTimeout(t),null!==pt.current&&clearTimeout(pt.current),null!==j.current&&clearTimeout(j.current),window.removeEventListener("resize",e)}},[q,K,J,s,x,m,a,d,Z,Bt,S,T,L,B]),{lines:et,setLines:nt,overallConnector:rt,setOverallConnector:ct,connectedLines:at,setConnectedLines:dt,svgDimensions:vt,cachedConnectedPositions:yt,calculateLines:xt,calculateLinesRef:Y,calculateLinesDebounced:Bt,handleColumnScroll:St}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),e=require("../CognitiveComparehelpers.js");exports.useLinesCalculator=function(n){var i=n.containerRef,r=n.leftContainerRef,c=n.rightContainerRef;n.svgContainerRef;var l=n.pathRefs,o=n.leftHeaderRef,u=n.rightHeaderRef,a=n.proposedSections,d=n.existingSections,s=n.visibleFields,v=n.leftRefs,h=n.rightRefs,g=n.sectionLeftRefs,f=n.sectionRightRefs,b=n.subSectionLeftRefs,p=n.subSectionRightRefs,A=n.lhsBadgeRefs,y=n.rhsBadgeRefs,R=n.sectionRowRefs,x=n.expandedSections,m=n.expandedSubSections,B=n.connectedSections,S=n.isSideBySide,T=n.activeSideBySideSection,C=n.maintainRelativeOrder,I=n.isGuidelineMode,E=n.cognitiveMap,M=n.getSectionCompareStyle,D=n.getSubSectionCompareStyle,O=n.getDeviationStyleByKey,L=n.isArrowVisible,_=n.isAnimatingRef,F=n.isSideBySideRef,N=n.sideBySideCacheRef,H=n.sideBySideLineRef,P=n.activeSideBySideSectionRef,k=n.activeSideBySideRightSectionRef,G=n.connectedLines,w=n.setConnectedLines,V=n.cachedConnectedPositions,Y=n.calculateLinesRef,j=n.resizeTimerRef,z=n.scrollLock,Q=n.scrollSyncLocked,X=n.handleResizeRef,q=n.activeProposed,K=n.existingRule,J=n.analysisData,U=n.pendingScrollTargetRef,W=n.pendingScrollCallbackRef,Z=n.resolvedComparisonConfig,$=n.getFieldData,tt=t.useState([]),et=tt[0],nt=tt[1],it=t.useState(null),rt=it[0],ct=it[1],lt=t.useState([]),ot=lt[0],ut=lt[1],at=null!=G?G:ot,dt=null!=w?w:ut,st=t.useState({width:0,height:0}),vt=st[0],ht=st[1],gt=t.useRef(!1),ft=t.useRef(!1),bt=t.useRef(!1),pt=t.useRef(null),At=t.useRef([]),yt=null!=V?V:At,Rt=function(t,e,n,i,r,c,l){if(Math.abs(i-e)<=1)return c&&l?"M ".concat(t,",").concat(e," L ").concat(n,",").concat(i):c&&!l?"M ".concat(t,",").concat(e," L ").concat(r,",").concat(e):!c&&l?"M ".concat(r,",").concat(e," L ").concat(n,",").concat(i):"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i);var o=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?o:-o,d=i>e?u:-u,s=n>r?u:-u;return c&&l?"M ".concat(t,",").concat(e," L ").concat(r-o,",").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&&!l?"M ".concat(t,",").concat(e," L ").concat(r-o,",").concat(e," Q ").concat(r,",").concat(e," ").concat(r,",").concat(e+a," L ").concat(r,",").concat(i):!c&&l?"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)},xt=t.useCallback(function(){var t,n,l,R,L,F,N,H,P,k,G,w,V,Y,j,z,Q,X;if(!gt.current&&!_.current){gt.current=!0;try{if(!i.current)return;var q=function(t){var e=t.split("-"),n=e[0];if(!x[n]&&!1===C)return!1;if(C&&!x["left-".concat(n)]&&!x["right-".concat(n)]&&!x[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},K=i.current.getBoundingClientRect();ht({width:K.width,height:K.height});var J=[];if(s.forEach(function(t){var e,n,i=t.key,r=null===(e=v.current[i])||void 0===e?void 0:e.current,c=null===(n=h.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")}),!_.current){for(var U=0;U<Math.max(a.length,d.length);U++){var W=null===(t=g.current[U])||void 0===t?void 0:t.current,Z=null===(n=f.current[U])||void 0===n?void 0:n.current;W&&(W.style.height="auto",W.style.minHeight="0px"),Z&&(Z.style.height="auto",Z.style.minHeight="0px")}C||Object.keys(b.current).forEach(function(t){var e,n;if(q(t)){var i=null===(e=b.current[t])||void 0===e?void 0:e.current,r=null===(n=p.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 $={};s.forEach(function(t){var e,n,i=t.key,r=null===(e=v.current[i])||void 0===e?void 0:e.current,c=null===(n=h.current[i])||void 0===n?void 0:n.current;if(r&&c){var l=r.getBoundingClientRect(),o=c.getBoundingClientRect();$[i]=Math.max(l.height,o.height)}});var tt={left:{},right:{}},et={};if(!_.current)if(C){if(S&&null!==T)if("number"==typeof T){var it=T,rt=a[it],lt=null===(L=g.current[it])||void 0===L?void 0:L.current;lt&&rt&&(rt.refIndexes||[]).forEach(function(t){var e,n=d.findIndex(function(e){return e.selfIndex===t}),i=null===(e=f.current[n])||void 0===e?void 0:e.current;if(i&&(x["left-".concat(it)]||x["right-".concat(n)])){var r=Math.max(lt.getBoundingClientRect().height,i.getBoundingClientRect().height);tt.left[it]=Math.max(tt.left[it]||0,r),tt.right[n]=Math.max(tt.right[n]||0,r)}})}else{var ot=T.split(e.DEVIATION_BADGE_SEPARATOR)[2];if(ot){W=null===(F=b.current[ot])||void 0===F?void 0:F.current,Z=null===(N=p.current[ot])||void 0===N?void 0:N.current;if(W&&Z){ut=Math.max(W.getBoundingClientRect().height,Z.getBoundingClientRect().height);et[ot]=Math.max(et[ot]||0,ut)}}}}else{Object.keys(b.current).forEach(function(t){var e,n;if(q(t)){var i=null===(e=b.current[t])||void 0===e?void 0:e.current,r=null===(n=p.current[t])||void 0===n?void 0:n.current;if(i&&r&&null!==i.offsetParent&&null!==r.offsetParent){var c=i.getBoundingClientRect(),l=r.getBoundingClientRect(),o=Math.max(c.height,l.height);et[t]=o,i.style.minHeight="".concat(o,"px"),r.style.minHeight="".concat(o,"px")}}});for(U=0;U<Math.min(a.length,d.length);U++){var W=null===(l=g.current[U])||void 0===l?void 0:l.current,Z=null===(R=f.current[U])||void 0===R?void 0:R.current;if(W&&Z){var ut=Math.max(W.getBoundingClientRect().height,Z.getBoundingClientRect().height);tt.left[U]=ut,tt.right[U]=ut}}}if(s.forEach(function(t){var e,n,i=t.key,r=null===(e=v.current[i])||void 0===e?void 0:e.current,c=null===(n=h.current[i])||void 0===n?void 0:n.current;if(r&&c){var l=$[i];r.style.minHeight="".concat(l,"px"),c.style.minHeight="".concat(l,"px")}}),_.current||(Object.entries(tt.left).forEach(function(t){var e,n=t[0],i=t[1],r=null===(e=g.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=f.current[Number(n)])||void 0===e?void 0:e.current;r&&(r.style.minHeight="".concat(i,"px"))}),C||Object.keys(et).forEach(function(t){var e,n,i=null===(e=b.current[t])||void 0===e?void 0:e.current,r=null===(n=p.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")}})),!I){a.forEach(function(t,e){var n,i=null===(n=g.current[e])||void 0===n?void 0:n.current;if(i){var l=function(t,e){var n=(t.refIndexes||[]).map(function(t){return d.findIndex(function(e){return e.selfIndex===t})}).filter(function(t){return-1!==t});return!n.length&&d[e]?[e]:Array.from(new Set(n))}(t,e);l.forEach(function(n){var l,o,u,a,s,v,h,g,b,p,A=null===(l=f.current[n])||void 0===l?void 0:l.current;if(A){var y=i.getBoundingClientRect(),R=A.getBoundingClientRect(),x=y.right-K.left,m=R.left-K.left,B=y.top+18-K.top,I=R.top+18-K.top;if(C&&S&&T===e){var D=null!==(u=null===(o=r.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==u?u:0,O=null!==(s=null===(a=c.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==s?s:0,L=D+(null!==(h=null===(v=r.current)||void 0===v?void 0:v.clientHeight)&&void 0!==h?h:1/0),_=O+(null!==(b=null===(g=c.current)||void 0===g?void 0:g.clientHeight)&&void 0!==b?b:1/0),F=function(t,e,n){return Math.max(e,Math.min(n,t))};B=F(y.top+18,D,L)-K.top,I=F(R.top+18,O,_)-K.top}var N=M(e);N&&J.push({id:"line-".concat(e,"-").concat(n),x1:x,y1:B,x2:m,y2:I,style:N,sectionIdx:e,targetRightIdx:n,isSubSection:!1,hasCognitive:!!((null==t?void 0:t.cognitiveData)||(null===(p=d[n])||void 0===p?void 0:p.cognitiveData)||(null==t?void 0:t.nodeId)&&E[t.nodeId])})}})}})}if(!I&&S&&"string"==typeof T&&T.includes(e.DEVIATION_BADGE_SEPARATOR)){var at=T.split(e.DEVIATION_BADGE_SEPARATOR),st=at[0],vt=at[1],ft=at[2],bt=(at[3],"".concat(st).concat(e.DEVIATION_BADGE_SEPARATOR).concat(vt)),pt=null===(H=A.current[bt])||void 0===H?void 0:H.current,At=null===(P=y.current[bt])||void 0===P?void 0:P.current;if(pt&&At){var xt=pt.getBoundingClientRect(),Bt=At.getBoundingClientRect(),St=xt.right-K.left,Tt=Bt.left-K.left,Ct=xt.top+xt.height/2-K.top,It=Bt.top+Bt.height/2-K.top;if(C){var Et=null!==(G=null===(k=r.current)||void 0===k?void 0:k.getBoundingClientRect().top)&&void 0!==G?G:0,Mt=null!==(V=null===(w=c.current)||void 0===w?void 0:w.getBoundingClientRect().top)&&void 0!==V?V:0,Dt=Et+(null!==(j=null===(Y=r.current)||void 0===Y?void 0:Y.clientHeight)&&void 0!==j?j:1/0),Ot=Mt+(null!==(Q=null===(z=c.current)||void 0===z?void 0:z.clientHeight)&&void 0!==Q?Q:1/0),Lt=function(t,e,n){return Math.max(e,Math.min(n,t))};Ct=Lt(xt.top+xt.height/2,Et,Dt)-K.top,It=Lt(Bt.top+Bt.height/2,Mt,Ot)-K.top}var _t=null!==(X=O(st,vt))&&void 0!==X?X:D(ft);_t&&J.push({id:"line-subsec-".concat(bt),x1:St,y1:Ct,x2:Tt,y2:It,style:_t,sectionIdx:Number(ft.split("-")[0]),isSubSection:!0,subSectionKeyPath:T})}}if(nt(J),o.current&&u.current){var Ft=o.current.getBoundingClientRect(),Nt=u.current.getBoundingClientRect(),Ht=(Ft.top+Ft.height/2-K.top+Nt.top+Nt.height/2-K.top)/2;ct({x1:Ft.right-K.left,x2:Nt.left-K.left,y:Ht})}else ct(null);if(B.size>0){var Pt=[],kt=r.current,Gt=c.current;if(kt&&Gt){var wt=[],Vt=kt.getBoundingClientRect().top,Yt=Gt.getBoundingClientRect().top,jt=Vt+kt.clientHeight,zt=Yt+Gt.clientHeight,Qt=kt.scrollTop,Xt=Gt.scrollTop,qt=K.top,Kt=function(t,e,n){return Math.max(e,Math.min(n,t))};B.forEach(function(t){var n,i,r,c,l,o,u,s,v;if(I){var h=null,g=null,f=null;if("string"==typeof t&&t.includes(e.DEVIATION_BADGE_SEPARATOR)){var b=t.split(e.DEVIATION_BADGE_SEPARATOR),p=b[0],R=b[1],x=b[2],m="".concat(p).concat(e.DEVIATION_BADGE_SEPARATOR).concat(R);h=null===(n=A.current[m])||void 0===n?void 0:n.current,f=null!==(i=O(p,R))&&void 0!==i?i:D(x),g=Number((null==x?void 0:x.split("-")[0])||0)}else g=Number(t),h=null===(r=A.current[g])||void 0===r?void 0:r.current,f=M(g);if(!h)return;var B=document.querySelectorAll('[id^="guideline-target-"]');B.forEach(function(n,i){var r=h.getBoundingClientRect(),c=n.getBoundingClientRect(),l=r.right-K.left,o=c.left-K.left-0,u=l+75,a=r.top+r.height/2,d=c.top+c.height/2,s=a-Vt+Qt,v=d-Yt+Xt,g="conn-guide-".concat(t,"-").concat(i),b="";"string"==typeof t&&t.includes(e.DEVIATION_BADGE_SEPARATOR)?b=(t.split(e.DEVIATION_BADGE_SEPARATOR)[2]||"").split("-").map(function(t){return Number(t)+1}).join("."):b=String(Number(t)+1);var p=String.fromCharCode(97+i),A=1===B.length?null:"".concat(b,"(").concat(p,")");wt.push({lhsScrollY:s,rhsScrollY:v,x1:l,x2:o,containerTop:qt,leftIdx:t,rhsArrayIdx:i,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 y=Kt(a,Vt,jt),R=Kt(d,Yt,zt),x=y-qt,m=R-qt,S=Rt(l,x,o,m,u,a>=Vt-4&&a<=jt+4,d>=Yt-4&&d<=zt+4);Pt.push({id:g,pathD:S,style:f,leftIdx:t,rhsArrayIdx:i,x1:l,x2:o,y1:x,y2:m,centerX:u,matchLabel:A,isGuideline:!0})})}else if("string"==typeof t&&t.includes(e.DEVIATION_BADGE_SEPARATOR)){var S=t.split(e.DEVIATION_BADGE_SEPARATOR),T=(p=S[0],R=S[1],x=S[2],S[3],m="".concat(p).concat(e.DEVIATION_BADGE_SEPARATOR).concat(R),null===(c=A.current[m])||void 0===c?void 0:c.current),E=null===(l=y.current[m])||void 0===l?void 0:l.current;if(!T||!E)return;var L=T.getBoundingClientRect(),_=E.getBoundingClientRect(),F=null!==(o=O(p,R))&&void 0!==o?o:D(x),N=L.right-K.left,H=_.left-K.left-0,P=N+75,k=L.top+L.height/2,G=_.top+_.height/2,w=k-Vt+Qt,V=G-Yt+Xt,Y="conn-subsec-".concat(m),j=((x||"").split("-").map(function(t){return Number(t)+1}).join("."),null);wt.push({lhsScrollY:w,rhsScrollY:V,x1:N,x2:H,containerTop:qt,leftIdx:t,rhsArrayIdx:t,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:Y,centerX:P});var z=Kt(k,Vt,jt),Q=Kt(G,Yt,zt),X=Rt(N,Z=z-qt,H,$=Q-qt,P,k>=Vt-4&&k<=jt+4,G>=Yt-4&&G<=zt+4);Pt.push({id:Y,pathD:X,style:F,leftIdx:t,rhsArrayIdx:t,x1:N,x2:H,y1:Z,y2:$,matchLabel:j})}else if(C){var q=t,J=a[q];if(!(null===(v=null==J?void 0:J.refIndexes)||void 0===v?void 0:v.length))return;J.refIndexes.forEach(function(e,n){var i,r,c=d.findIndex(function(t){return t.selfIndex===e});if(-1!==c){var l=null===(i=A.current[q])||void 0===i?void 0:i.current,o=null===(r=y.current[c])||void 0===r?void 0:r.current;if(l&&o){var u=l.getBoundingClientRect(),a=o.getBoundingClientRect(),s=M(q),v=u.right-K.left,h=a.left-K.left-0,g=v+75,f=u.top+u.height/2,b=a.top+a.height/2,p=f-Vt+Qt,R=b-Yt+Xt,x="conn-".concat(q,"-").concat(c),m=String(Number(t)+1),B=String.fromCharCode(97+n),S=1===J.refIndexes.length?null:"".concat(m,"(").concat(B,")");wt.push({lhsScrollY:p,rhsScrollY:R,x1:v,x2:h,containerTop:qt,leftIdx:q,rhsArrayIdx:c,styleColor:(null==s?void 0:s.badgeBorder)||"#6366F1",styleBg:(null==s?void 0:s.badgeBg)||"#FFFFFF",styleText:(null==s?void 0:s.badgeText)||"#A16207",styleId:x,centerX:g});var T=Kt(f,Vt,jt),C=Kt(b,Yt,zt),I=T-qt,E=C-qt,D=Rt(v,I,h,E,g,f>=Vt-4&&f<=jt+4,b>=Yt-4&&b<=zt+4);Pt.push({id:x,pathD:D,style:s,leftIdx:q,rhsArrayIdx:c,x1:v,x2:h,y1:I,y2:E,matchLabel:S})}}})}else{var U=t,W=U;T=null===(u=A.current[U])||void 0===u?void 0:u.current,E=null===(s=y.current[W])||void 0===s?void 0:s.current;if(!T||!E)return;L=T.getBoundingClientRect(),_=E.getBoundingClientRect(),F=M(U),N=L.right-K.left,H=_.left-K.left-0,P=N+75,k=L.top+L.height/2,G=_.top+_.height/2,w=k-Vt+Qt,V=G-Yt+Xt,Y="conn-".concat(U,"-").concat(W),String(Number(t)+1),j=null;wt.push({lhsScrollY:w,rhsScrollY:V,x1:N,x2:H,containerTop:qt,leftIdx:U,rhsArrayIdx:W,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:Y,centerX:P});var Z,$;z=Kt(k,Vt,jt),Q=Kt(G,Yt,zt),X=Rt(N,Z=z-qt,H,$=Q-qt,P,k>=Vt-4&&k<=jt+4,G>=Yt-4&&G<=zt+4);Pt.push({id:Y,pathD:X,style:F,leftIdx:U,rhsArrayIdx:W,x1:N,x2:H,y1:Z,y2:$,matchLabel:j})}}),yt.current=wt}dt(Pt),setTimeout(function(){return mt()},10)}else dt([]),yt.current=[],setTimeout(function(){return mt()},10)}catch(t){console.error("Line render safe fail: ",t)}finally{gt.current=!1}}},[s,a,d,E,Z,$,M,O,C,S,T,B,x,m,I]),mt=t.useCallback(function(){var t,e,n,o,u,a,d,s,v,h,g,f,b,p,A,y,R,x,m,B=yt.current;if(!B.length)return null===(t=l.current["guideline-up-stroke"])||void 0===t||t.setAttribute("visibility","hidden"),null===(e=l.current["guideline-up-badge"])||void 0===e||e.setAttribute("visibility","hidden"),null===(n=l.current["guideline-down-stroke"])||void 0===n||n.setAttribute("visibility","hidden"),void(null===(o=l.current["guideline-down-badge"])||void 0===o||o.setAttribute("visibility","hidden"));if(!_.current){var S=null!==(a=null===(u=r.current)||void 0===u?void 0:u.scrollTop)&&void 0!==a?a:0,T=null!==(s=null===(d=c.current)||void 0===d?void 0:d.scrollTop)&&void 0!==s?s:0,C=null!==(h=null===(v=r.current)||void 0===v?void 0:v.clientHeight)&&void 0!==h?h:1/0,I=null!==(f=null===(g=c.current)||void 0===g?void 0:g.clientHeight)&&void 0!==f?f:1/0,E=null!==(p=null===(b=r.current)||void 0===b?void 0:b.getBoundingClientRect().top)&&void 0!==p?p:0,M=null!==(y=null===(A=c.current)||void 0===A?void 0:A.getBoundingClientRect().top)&&void 0!==y?y:0,D=E+C,O=M+I,L=null===(R=i.current)||void 0===R?void 0:R.getBoundingClientRect(),F=null!==(x=null==L?void 0:L.top)&&void 0!==x?x:0,N=null!==(m=null==L?void 0:L.height)&&void 0!==m?m:1/0,H=function(t,e,n){return Math.max(e,Math.min(n,t))},P=0,k=0,G=0,w=0,V="#6366F1",Y="#A16207",j=!1,z=0;if(B.forEach(function(t){var e=t.lhsScrollY-S+E,n=t.rhsScrollY-T+M,i=l.current[t.styleId+"-stroke"],r=l.current[t.styleId+"-bg"],c=l.current[t.styleId+"-btn"],o=l.current[t.styleId+"-number"];if(i||r){var u=H(e,E,D),a=H(n,M,O),d=u-F,s=a-F,v=e>=E-4&&e<=D+4,h=n>=M-4&&n<=O+4,g=!0;j=!0;var f=t.centerX||t.x1+75;0===G&&(G=t.x1,w=d,z=f,V=t.styleColor,t.styleBg,Y=t.styleText||"#A16207"),n<M-4?(P++,g=!1):n>O+4&&(k++,g=!1);var b=Rt(t.x1,d,t.x2,s,z,v,h);i&&(g&&b?(i.setAttribute("visibility","visible"),i.setAttribute("d",b)):i.setAttribute("visibility","hidden")),r&&(g&&b?(r.setAttribute("visibility","visible"),r.setAttribute("d",b)):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"))}}),j&&z>0){var Q=l.current["guideline-up-stroke"],X=l.current["guideline-up-badge"],q=l.current["guideline-up-arrow"],K=l.current["guideline-up-text"],J=l.current["guideline-up-badge-rect"];if(P>0){var U=Math.max(15,M-F+15),W=Math.min(15,Math.abs(z-G),Math.max(0,w-U)),Z="M ".concat(G,",").concat(w," L ").concat(z-W,",").concat(w," Q ").concat(z,",").concat(w," ").concat(z,",").concat(w-W," L ").concat(z,",").concat(U);null==Q||Q.setAttribute("visibility","visible"),null==Q||Q.setAttribute("d",Z),null==Q||Q.setAttribute("stroke",V),null==X||X.setAttribute("visibility","visible"),null==X||X.setAttribute("transform","translate(".concat(z,", ").concat(U,")")),q&&q.setAttribute("fill",V),K&&(K.textContent="+".concat(P),K.setAttribute("fill",Y)),J&&J.setAttribute("stroke",V)}else null==Q||Q.setAttribute("visibility","hidden"),null==X||X.setAttribute("visibility","hidden");var $=l.current["guideline-down-stroke"],tt=l.current["guideline-down-badge"],et=l.current["guideline-down-arrow"],nt=l.current["guideline-down-text"],it=l.current["guideline-down-badge-rect"];if(k>0){var rt=Math.min(N-15,O-F-15);W=Math.min(15,Math.abs(z-G),Math.max(0,rt-w)),Z="M ".concat(G,",").concat(w," L ").concat(z-W,",").concat(w," Q ").concat(z,",").concat(w," ").concat(z,",").concat(w+W," L ").concat(z,",").concat(rt);null==$||$.setAttribute("visibility","visible"),null==$||$.setAttribute("d",Z),null==$||$.setAttribute("stroke",V),null==tt||tt.setAttribute("visibility","visible"),null==tt||tt.setAttribute("transform","translate(".concat(z,", ").concat(rt,")")),et&&et.setAttribute("fill",V),nt&&(nt.textContent="+".concat(k),nt.setAttribute("fill",Y)),it&&it.setAttribute("stroke",V)}else null==$||$.setAttribute("visibility","hidden"),null==tt||tt.setAttribute("visibility","hidden")}}},[]),Bt=t.useCallback(function(){yt.current.length>0&&!_.current||(null!==pt.current&&clearTimeout(pt.current),pt.current=setTimeout(function(){Y.current(),pt.current=null},50))},[]),St=t.useCallback(function(t){if(null!==U.current&&W.current&&Math.abs(t.currentTarget.scrollTop-U.current)<=2){var n=W.current;U.current=null,W.current=null,n()}if(!bt.current&&!z.current){if(C&&Q&&(F.current||B.size>0)){var l=t.currentTarget,o=r.current,u=c.current,a=l===o?u:l===u?o:null;if(l&&a){var d=function(){var t,n,i,r,c,l,o,u,a,d,s,v=P.current,h=k.current;if(null===v)return{leftAnchor:null,rightAnchor:null};if("string"==typeof v&&v.includes(e.DEVIATION_BADGE_SEPARATOR)){var x=v.split(e.DEVIATION_BADGE_SEPARATOR),m="".concat(x[0]).concat(e.DEVIATION_BADGE_SEPARATOR).concat(x[1]);return{leftAnchor:(null===(t=A.current[m])||void 0===t?void 0:t.current)||(null===(n=b.current[x[2]])||void 0===n?void 0:n.current)||(null===(i=g.current[Number(x[2])])||void 0===i?void 0:i.current)||null,rightAnchor:(null===(r=y.current[m])||void 0===r?void 0:r.current)||(null===(c=p.current[x[3]])||void 0===c?void 0:c.current)||(null===(l=f.current[Number(x[3])])||void 0===l?void 0:l.current)||null}}var B=Number(v),S=null!==h?Number(h):B;return{leftAnchor:(null===(o=A.current[B])||void 0===o?void 0:o.current)||(null===(u=R.current[B])||void 0===u?void 0:u.current)||(null===(a=g.current[B])||void 0===a?void 0:a.current)||null,rightAnchor:(null===(d=y.current[S])||void 0===d?void 0:d.current)||(null===(s=f.current[S])||void 0===s?void 0:s.current)||null}}(),s=d.leftAnchor,v=d.rightAnchor,h=l===o?s:v,x=l===o?v:s,m=null;if(h&&x){var S=h.getBoundingClientRect(),T=x.getBoundingClientRect(),I=a.getBoundingClientRect(),E=S.top+S.height/2;m=T.top-I.top+a.scrollTop+T.height/2-(E-I.top)}else{var M=Math.max(0,l.scrollHeight-l.clientHeight),D=Math.max(0,a.scrollHeight-a.clientHeight);m=M>0?l.scrollTop/M*D:l.scrollTop}var O=Math.max(0,a.scrollHeight-a.clientHeight);m=Math.max(0,Math.min(m,O)),Math.abs(a.scrollTop-m)>1&&(bt.current=!0,a.scrollTop=m,requestAnimationFrame(function(){bt.current=!1}))}}C||Bt(),ft.current||(ft.current=!0,requestAnimationFrame(function(){var t,n,l,o,u,a,d;if(F.current){var s=r.current,v=c.current;if(s&&v&&H.current){if(!N.current){var h=P.current,g=void 0;if("string"==typeof h&&h.includes(e.DEVIATION_BADGE_SEPARATOR)){var f=h.split(e.DEVIATION_BADGE_SEPARATOR),b="".concat(f[0]).concat(e.DEVIATION_BADGE_SEPARATOR).concat(f[1]);g=null===(t=A.current[b])||void 0===t?void 0:t.current}else g=null===(n=A.current[h])||void 0===n?void 0:n.current;if(g){var p=g.getBoundingClientRect();N.current={badgeScreenY:p.top+p.height/2,initialScrollTop:s.scrollTop,leftTop:s.getBoundingClientRect().top,leftBottom:s.getBoundingClientRect().top+s.clientHeight,cTop:null!==(o=null===(l=i.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==o?o:0}}}if(N.current){var y=N.current,R=s.scrollTop-y.initialScrollTop,x=y.badgeScreenY-R,m=((u=x,a=y.leftTop,d=y.leftBottom,Math.max(a,Math.min(d,u)))-y.cTop).toString(),B=x>=y.leftTop-4&&x<=y.leftBottom+4;H.current.setAttribute("y1",m),H.current.setAttribute("y2",m),H.current.setAttribute("visibility",B?"visible":"hidden")}}}mt(),ft.current=!1}))}},[mt,C,Q,B,Bt]);return t.useEffect(function(){Y.current=xt},[xt]),t.useEffect(function(){var t=setTimeout(Bt,250),e=function(){return X.current()};return window.addEventListener("resize",e),function(){clearTimeout(t),null!==pt.current&&clearTimeout(pt.current),null!==j.current&&clearTimeout(j.current),window.removeEventListener("resize",e)}},[q,K,J,s,x,m,a,d,Z,Bt,S,T,L,B]),{lines:et,setLines:nt,overallConnector:rt,setOverallConnector:ct,connectedLines:at,setConnectedLines:dt,svgDimensions:vt,cachedConnectedPositions:yt,calculateLines:xt,calculateLinesRef:Y,calculateLinesDebounced:Bt,handleColumnScroll:St}};
2
2
  //# sourceMappingURL=useLinesCalculator.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),i=require("@lexical/react/LexicalComposer"),r=require("@lexical/react/LexicalHistoryPlugin"),l=require("@lexical/react/LexicalOnChangePlugin"),n=require("@lexical/react/LexicalTabIndentationPlugin"),o=require("@lexical/list"),a=require("@lexical/react/LexicalListPlugin"),u=require("@lexical/react/LexicalLinkPlugin"),s=require("@lexical/link"),d=require("@lexical/rich-text"),c=require("@lexical/react/LexicalTablePlugin"),g=require("@lexical/table"),p=require("lexical");require("./components/EditorToolbar/components/ToolbarButton/ToolbarButton.css.js");var x=require("../../RequirementAIWrapper/RequirementAIWrapper.js"),f=require("./components/EditorContainer/EditorContainer.js"),m=require("./components/EditorToolbar/EditorToolbar.js"),h=require("./plugins/LayoutPlugin.js"),C=require("./theme/theme.js");require("./theme/theme.css.js"),require("./Editor.css.js");var N=require("./components/Context/ContextMenu.js"),q=require("@lexical/mark"),v=require("./plugins/CommentPlugin/HTMLNode.js"),j=require("./constants/editorConfig.js"),b=require("./plugins/InitialHtml.js"),y=require("./plugins/InsertNode.js"),T=require("./plugins/DeleteNode.js"),L=require("./plugins/HighlightNode.js"),P=require("@lexical/react/LexicalComposerContext"),S=require("./plugins/UpdateNode.js"),E=require("./plugins/ManualNode.js"),I=require("./plugins/PreservedNode.js"),_=require("./plugins/InvisibleNode.js");function k(e){console.log(e)}function R({onEditBlocked:e}){const[i]=P.useLexicalComposerContext();return t.useEffect(()=>{const t=e=>{let t=e;for(;t;){if(["preserved","insert","delete"].includes(t.getType()))return t;t=t.getParent()}return!1};function r(e){let t=e.getParent();for(;t;){if(t instanceof S.UpdateNode||t instanceof E.ManualNode)return t.__id;t=t.getParent()}return null}return i.registerCommand(p.KEY_DOWN_COMMAND,i=>{var l;if("Backspace"!==i.key&&"Delete"!==i.key)return!1;const n=p.$getSelection();if(!p.$isRangeSelection(n))return!1;const o=n.getNodes().find(e=>!!t(e));if(o)return i.preventDefault(),null==e||e(r(o)||""),!0;if(n.isCollapsed()){const o=n.anchor.getNode(),a=n.focus.getNode(),u=t(o),s=t(a);if(u||s){const t=u?r(u):s?r(s):"";return null==e||e(t||""),i.preventDefault(),!0}if("Backspace"===i.key){const a=o.getPreviousSibling(),u=null===(l=null==a?void 0:a.getLastDescendant)||void 0===l?void 0:l.call(a),s=a&&["delete","insert","preserved"].includes(a.getType())?a:u&&t(u)?u:null;if(0===n.anchor.offset&&s)return null==e||e(r(s)||""),i.preventDefault(),!0}else if("Delete"===i.key){const l=o.getNextSibling(),a=null==l?void 0:l.getFirstDescendant(),u=l&&["delete","insert","preserved"].includes(l.getType())?l:a&&t(a)?a:null,s=o.getTextContent().length;if(n.anchor.offset===s&&u)return null==e||e(r(u)||""),i.preventDefault(),!0}}return!1},p.COMMAND_PRIORITY_CRITICAL)},[i]),null}exports.default=function({minHeight:P,height:B,placeholder:D,onFocus:M,onBlur:H,onChange:O,onToolbarButtonClick:A,toolbarConfig:w=j.DEFAULT_TOOLBAR_CONFIG,editorRef:$,editorState:F,initialString:U,customToolbar:W,plugins:Y,nodes:V,dynamicHeight:G,artifactContext:K,commentsPanelState:Q,mode:X,doNotShowBorderInViewMode:z,onEditBlocked:J}){var Z,ee,te;const ie=t.useRef(null),re={namespace:"MyEditor",theme:C.default,onError:k,nodes:[p.TextNode,o.ListNode,o.ListItemNode,s.LinkNode,d.QuoteNode,d.HeadingNode,g.TableNode,g.TableRowNode,g.TableCellNode,q.MarkNode,v.default,y.InsertNode,T.DeleteNode,S.UpdateNode,I.PreservedNode,E.ManualNode,_.InvisibleNode,L.HighlightSpanNode,L.HighlightButtonNode],editorState:F},[le,ne]=t.useState(null),[oe,ae]=t.useState(!1),{customStyles:ue}=x.useRequirementAI(),se=e=>{var t;null===(t=$.current)||void 0===t||t.update(()=>{const t=p.$getSelection();p.$isRangeSelection(t)&&t.getNodes().forEach(t=>{p.$isTextNode(t)&&t.setStyle(`color: ${e}`)})})};return document.getElementById("lexical_editor_wrapper"),e.jsxs(e.Fragment,{children:[(null===(Z=null==ue?void 0:ue.textEditorStyles)||void 0===Z?void 0:Z.themeStyles)&&e.jsx("style",{children:null===(ee=null==ue?void 0:ue.textEditorStyles)||void 0===ee?void 0:ee.themeStyles}),e.jsxs("div",{ref:ie,className:"w-full lexical_editor_wrapper "+(z&&"readOnly"===X?"":"lexical_editor_wrapper_box"),id:"lexical_editor_wrapper",onContextMenu:e=>{var t;e.preventDefault(),null===(t=$.current)||void 0===t||t.update(()=>{const t=p.$getSelection();p.$isRangeSelection(t)&&!t.isCollapsed()?(ae(!0),ne({x:e.clientX,y:e.clientY})):(ae(!1),ne(null))})},style:{minHeight:P,height:B,...null===(te=null==ue?void 0:ue.textEditorStyles)||void 0===te?void 0:te.textArea},children:[e.jsxs(i.LexicalComposer,{initialConfig:re,children:[" ","edit"===X&&e.jsx(R,{onEditBlocked:J}),"edit"===X&&e.jsx(m.default,{onToolbarButtonClick:A,editorWrapperRef:ie,toolbarConfig:w,customToolbar:W,editorRef:$}),e.jsx(f.default,{placeholder:D}),e.jsx(n.TabIndentationPlugin,{}),e.jsx(r.HistoryPlugin,{}),e.jsx(a.ListPlugin,{}),e.jsx(u.LinkPlugin,{}),e.jsx(c.TablePlugin,{}),e.jsx(h.LayoutPlugin,{onFocus:M,onBlur:H,editorRef:$}),e.jsx(l.OnChangePlugin,{ignoreSelectionChange:!0,ignoreHistoryMergeTagChange:!0,onChange:(e,t,i)=>{O&&O(e,t,i)}}),U&&e.jsx(b.InitialHtml,{initialValue:U.value,initialFormat:U.type,mode:X}),Y&&Y]}),le&&oe&&"edit"===X&&e.jsx(N.default,{position:le,options:[{label:"Change Color to Red",action:()=>se("red")},{label:"Change Color to Blue",action:()=>se("blue")}],onClose:()=>{ne(null)}})]})]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),i=require("@lexical/react/LexicalComposer"),n=require("@lexical/react/LexicalHistoryPlugin"),r=require("@lexical/react/LexicalOnChangePlugin"),l=require("@lexical/react/LexicalTabIndentationPlugin"),o=require("@lexical/list"),a=require("@lexical/react/LexicalListPlugin"),u=require("@lexical/react/LexicalLinkPlugin"),s=require("@lexical/link"),d=require("@lexical/rich-text"),c=require("@lexical/react/LexicalTablePlugin"),g=require("@lexical/table"),p=require("lexical");require("./components/EditorToolbar/components/ToolbarButton/ToolbarButton.css.js");var x=require("../../RequirementAIWrapper/RequirementAIWrapper.js"),f=require("./components/EditorContainer/EditorContainer.js"),m=require("./components/EditorToolbar/EditorToolbar.js"),h=require("./plugins/LayoutPlugin.js"),C=require("./theme/theme.js");require("./theme/theme.css.js"),require("./Editor.css.js");var N=require("./components/Context/ContextMenu.js"),q=require("@lexical/mark"),j=require("./plugins/CommentPlugin/HTMLNode.js"),v=require("./constants/editorConfig.js"),T=require("./plugins/InitialHtml.js"),S=require("./plugins/InsertNode.js"),y=require("./plugins/DeleteNode.js"),b=require("./plugins/HighlightNode.js"),P=require("@lexical/react/LexicalComposerContext"),L=require("./plugins/UpdateNode.js"),I=require("./plugins/ManualNode.js"),E=require("./plugins/PreservedNode.js"),R=require("./plugins/InvisibleNode.js");function _(e){console.log(e)}function B({onEditBlocked:e}){const[i]=P.useLexicalComposerContext();return t.useEffect(()=>{const t=e=>{let t=e;for(;t;){if(["preserved","insert","delete"].includes(t.getType()))return t;if(["update","manual"].includes(t.getType())&&t.getStatus()&&"pending"===t.getStatus())return t;t=t.getParent()}return!1};function n(e){let t=e.getParent();for(;t;){if(t instanceof L.UpdateNode||t instanceof I.ManualNode)return t.getId();t=t.getParent()}return null}return i.registerCommand(p.KEY_DOWN_COMMAND,i=>{const r=p.$getSelection();if(!p.$isRangeSelection(r))return!1;const l=r.getNodes().find(e=>!!t(e));if(l)return i.preventDefault(),null==e||e(n(l)||""),!0;if(r.isCollapsed()){const l=r.anchor.getNode(),o=t(l);if(o){const t=o?n(o):"";return null==e||e(t||""),i.preventDefault(),!0}if("Backspace"===i.key){const t=l.getPreviousSibling(),o=t&&(["delete","insert","preserved"].includes(t.getType())||["update","manual"].includes(t.getType())&&t.getStatus()&&"pending"===t.getStatus())?t:null;if(0===r.anchor.offset&&o)return null==e||e(n(o)||""),i.preventDefault(),!0}else if("Delete"===i.key){const t=l.getNextSibling(),o=t&&(["delete","insert","preserved"].includes(t.getType())||["update","manual"].includes(t.getType())&&t.getStatus()&&"pending"===t.getStatus())?t:null,a=l.getTextContent().length;if(r.anchor.offset===a&&o)return null==e||e(n(o)||""),i.preventDefault(),!0}}return!1},p.COMMAND_PRIORITY_CRITICAL)},[i]),null}exports.default=function({minHeight:P,height:M,placeholder:k,onFocus:H,onBlur:D,onChange:O,onToolbarButtonClick:A,toolbarConfig:w=v.DEFAULT_TOOLBAR_CONFIG,editorRef:$,editorState:F,initialString:U,customToolbar:W,plugins:Y,nodes:V,dynamicHeight:G,artifactContext:K,commentsPanelState:Q,mode:X,doNotShowBorderInViewMode:z,onEditBlocked:J}){var Z,ee,te;const ie=t.useRef(null),ne={namespace:"MyEditor",theme:C.default,onError:_,nodes:[p.TextNode,o.ListNode,o.ListItemNode,s.LinkNode,d.QuoteNode,d.HeadingNode,g.TableNode,g.TableRowNode,g.TableCellNode,q.MarkNode,j.default,S.InsertNode,y.DeleteNode,L.UpdateNode,E.PreservedNode,I.ManualNode,R.InvisibleNode,b.HighlightSpanNode,b.HighlightButtonNode],editorState:F},[re,le]=t.useState(null),[oe,ae]=t.useState(!1),{customStyles:ue}=x.useRequirementAI(),se=e=>{var t;null===(t=$.current)||void 0===t||t.update(()=>{const t=p.$getSelection();p.$isRangeSelection(t)&&t.getNodes().forEach(t=>{p.$isTextNode(t)&&t.setStyle(`color: ${e}`)})})};return document.getElementById("lexical_editor_wrapper"),e.jsxs(e.Fragment,{children:[(null===(Z=null==ue?void 0:ue.textEditorStyles)||void 0===Z?void 0:Z.themeStyles)&&e.jsx("style",{children:null===(ee=null==ue?void 0:ue.textEditorStyles)||void 0===ee?void 0:ee.themeStyles}),e.jsxs("div",{ref:ie,className:"w-full lexical_editor_wrapper "+(z&&"readOnly"===X?"":"lexical_editor_wrapper_box"),id:"lexical_editor_wrapper",onContextMenu:e=>{var t;e.preventDefault(),null===(t=$.current)||void 0===t||t.update(()=>{const t=p.$getSelection();p.$isRangeSelection(t)&&!t.isCollapsed()?(ae(!0),le({x:e.clientX,y:e.clientY})):(ae(!1),le(null))})},style:{minHeight:P,height:M,...null===(te=null==ue?void 0:ue.textEditorStyles)||void 0===te?void 0:te.textArea},children:[e.jsxs(i.LexicalComposer,{initialConfig:ne,children:[" ","edit"===X&&e.jsx(B,{onEditBlocked:J}),"edit"===X&&e.jsx(m.default,{onToolbarButtonClick:A,editorWrapperRef:ie,toolbarConfig:w,customToolbar:W,editorRef:$}),e.jsx(f.default,{placeholder:k}),e.jsx(l.TabIndentationPlugin,{}),e.jsx(n.HistoryPlugin,{}),e.jsx(a.ListPlugin,{}),e.jsx(u.LinkPlugin,{}),e.jsx(c.TablePlugin,{}),e.jsx(h.LayoutPlugin,{onFocus:H,onBlur:D,editorRef:$}),e.jsx(r.OnChangePlugin,{ignoreSelectionChange:!0,ignoreHistoryMergeTagChange:!0,onChange:(e,t,i)=>{O&&O(e,t,i)}}),U&&e.jsx(T.InitialHtml,{initialValue:U.value,initialFormat:U.type,mode:X}),Y&&Y]}),re&&oe&&"edit"===X&&e.jsx(N.default,{position:re,options:[{label:"Change Color to Red",action:()=>se("red")},{label:"Change Color to Blue",action:()=>se("blue")}],onClose:()=>{le(null)}})]})]})};
2
2
  //# sourceMappingURL=Editor.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("lexical");class t extends e.ElementNode{static getType(){return"manual"}static clone(e){return new t(e.__id,e.__key)}constructor(e=crypto.randomUUID(),t){super(t),this.__id=e}createDOM(){const e=document.createElement("manual");return e.id=this.__id,e.className="PlaygroundEditorTheme__manual-node",e}exportDOM(){const e=document.createElement("manual");return e.id=this.__id,{element:e}}updateDOM(e,t){return e.__id!==this.__id&&(t.id=this.__id),!1}static importDOM(){return{manual:()=>({conversion:r,priority:1})}}static importJSON(e){const r=new t(e.id);return r.setFormat(e.format),r.setIndent(e.indent),r.setDirection(e.direction),r}exportJSON(){return{...super.exportJSON(),type:"manual",version:1,id:this.__id}}isInline(){return!0}getId(){return this.__id}}function r(e){const r=e.id||crypto.randomUUID();return{node:new t(r)}}exports.ManualNode=t;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("lexical");class e extends t.ElementNode{static getType(){return"manual"}static clone(t){return new e(t.__id,t.__status,t.__key)}constructor(t=crypto.randomUUID(),e="",s){super(s),this.__id=t,this.__status=e}getId(){return this.getLatest().__id}getStatus(){return this.getLatest().__status}setStatus(t){this.getWritable().__status=t}createDOM(){const t=document.createElement("manual");return t.id=this.__id,t.className=`PlaygroundEditorTheme__manual-node-${this.__status}`,this.__status&&(t.dataset.status=this.__status),t.contentEditable="pending"===this.__status?"false":"true",t}exportDOM(){const t=document.createElement("manual");return t.id=this.__id,{element:t}}updateDOM(t,e){return t.__id!==this.__id&&(e.id=this.__id),t.__status!==this.__status&&(this.__status?e.dataset.status=this.__status:delete e.dataset.status,e.contentEditable="pending"===this.__status?"false":"true"),!1}static importDOM(){return{manual:()=>({conversion:s,priority:1})}}static importJSON(t){var s;return new e(t.id,null!==(s=t.status)&&void 0!==s?s:"")}exportJSON(){return{...super.exportJSON(),type:"manual",version:1,id:this.__id,status:this.__status}}isInline(){return!0}}function s(t){var s;return{node:new e(t.id||crypto.randomUUID(),null!==(s=t.dataset.status)&&void 0!==s?s:"")}}exports.ManualNode=e;
2
2
  //# sourceMappingURL=ManualNode.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("lexical");class t extends e.ElementNode{static getType(){return"update"}static clone(e){return new t(e.__id,e.__key)}constructor(e=crypto.randomUUID(),t){super(t),this.__id=e}createDOM(){const e=document.createElement("upt");return e.id=this.__id,e.className="PlaygroundEditorTheme__update-node",e}exportDOM(){const e=document.createElement("upt");return e.id=this.__id,{element:e}}updateDOM(e,t){return e.__id!==this.__id&&(t.id=this.__id),!1}static importDOM(){return{upt:()=>({conversion:r,priority:1})}}static importJSON(e){const r=new t(e.id);return r.setFormat(e.format),r.setIndent(e.indent),r.setDirection(e.direction),r}exportJSON(){return{...super.exportJSON(),type:"update",version:1,id:this.__id}}isInline(){return!0}getId(){return this.__id}}function r(e){const r=e.id||crypto.randomUUID();return{node:new t(r)}}exports.UpdateNode=t;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("lexical");class e extends t.ElementNode{static getType(){return"update"}static clone(t){return new e(t.__id,t.__status,t.__key)}constructor(t=crypto.randomUUID(),e="",s){super(s),this.__id=t,this.__status=e}getId(){return this.getLatest().__id}getStatus(){return this.getLatest().__status}setStatus(t){this.getWritable().__status=t}createDOM(){const t=document.createElement("upt");return t.id=this.__id,t.className=`PlaygroundEditorTheme__update-node-${this.__status}`,this.__status&&(t.dataset.status=this.__status),t.contentEditable="pending"===this.__status?"false":"true",t}exportDOM(){const t=document.createElement("upt");return t.id=this.__id,{element:t}}updateDOM(t,e){return t.__id!==this.__id&&(e.id=this.__id),t.__status!==this.__status&&(this.__status?e.dataset.status=this.__status:delete e.dataset.status,e.contentEditable="pending"===this.__status?"false":"true"),!1}static importDOM(){return{upt:()=>({conversion:s,priority:1})}}static importJSON(t){var s;return new e(t.id,null!==(s=t.status)&&void 0!==s?s:"")}exportJSON(){return{...super.exportJSON(),type:"update",version:1,id:this.__id,status:this.__status}}isInline(){return!0}}function s(t){var s;return{node:new e(t.id||crypto.randomUUID(),null!==(s=t.dataset.status)&&void 0!==s?s:"")}}exports.UpdateNode=e;
2
2
  //# sourceMappingURL=UpdateNode.js.map