@viswa-test/test-citation 0.0.131 → 0.0.132

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.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),t=require("react"),i=require("@mui/material"),o=require("lucide-react"),r=require("../../assests/svg/ButtonCognitiveIcon.js"),l=require("./OverlayComponent.js"),u=require("./CognitiveComparehelpers.js"),c=require("./CognitiveCompareConfig.js"),a=require("./CognitiveCompareConstants.js"),s=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"),x=require("./hooks/useAccordionState.js"),m=require("./hooks/useDeviationNavigation.js"),_=require("./components/CompareHeader.js"),R=require("./components/SectionAccordion.js"),y=require("./components/SubSectionAccordion.js"),b=require("./components/CognitiveSummaryPopup.js"),S=require("./components/connectedLines.js");exports.SHARED_MARKDOWN_STYLES=c.SHARED_MARKDOWN_STYLES,exports.default=function(A){var I,E,T,B,C,D,O,w,N,j,P,F,M,k,L,V,H,q,G,z,W,K,Y,U,X,$,J=A.componentHeaderText,Q=void 0===J?a.DEFAULT_COMPONENT_HEADER_TEXT:J,Z=A.treeData,ee=A.comparisonConfig,ne=A.leftColumnTitleText,te=A.rightColumnTitleText,ie=A.markdownStyles,oe=A.resetTrigger,re=A.displayConfig,le=void 0===re?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1}:re,ue=A.popupConfig,ce=A.deviationData,ae=void 0===ce?{}:ce,se=A.deviationNodeIdToView,de=A.resetDeviationNodeId,ve=A.isProposingFix,fe=void 0!==ve&&ve,ge=A.proposingFixNodeId,pe=A.isRedlineFlow,he=t.useState(le.maintainRelativeOrder),xe=he[0],me=he[1],_e=!!xe||!!(null==le?void 0:le.showDeviationBadges),Re=t.useState(!1),ye=Re[0],be=Re[1],Se=t.useState(!1),Ae=Se[0],Ie=Se[1],Ee=t.useState(null),Te=Ee[0],Be=Ee[1],Ce=t.useState(!1),De=Ce[0],Oe=Ce[1],we=t.useState(null===(E=null!==(I=null==Z?void 0:Z.newEvaluationResult)&&void 0!==I?I:null==le?void 0:le.enableDeviationSchemaBackwardCompatibility)||void 0===E||E)[0],Ne=t.useState(!1),je=Ne[0],Pe=Ne[1],Fe=t.useState(!1),Me=Fe[0],ke=Fe[1],Le=t.useState(null),Ve=Le[0],He=Le[1],qe=t.useRef(!1),Ge=t.useState(new Set),ze=Ge[0],We=Ge[1],Ke=t.useState([]),Ye=Ke[0],Ue=Ke[1],Xe=t.useRef(null),$e=t.useRef(null),Je=t.useRef(null),Qe=t.useRef(new Set),Ze=t.useRef(!1),en=t.useRef(null),nn=t.useRef({}),tn=t.useRef([]),on=t.useRef(!1),rn=t.useRef(!1),ln=t.useRef(null),un=t.useRef(function(){}),cn=t.useMemo(function(){return(null==Z?void 0:Z.cognitive_decisioning)||{}},[Z]),an=t.useState({width:0,height:0}),sn=an[0],dn=an[1],vn=t.useMemo(function(){return e.__assign(e.__assign({},c.SHARED_MARKDOWN_STYLES),ie)},[ie]),fn=t.useRef(null),gn=t.useRef(null),pn=t.useRef(null),hn=t.useRef(null),xn=t.useRef(null),mn=t.useRef(null),_n=t.useRef(null),Rn=t.useRef(null),yn=t.useRef(!1),bn=t.useRef(null),Sn=t.useRef(null),An=p.useComparePopups(fn),In=An.cognitivePopup,En=An.setCognitivePopup,Tn=An.moreFunctions,Bn=An.setMoreFunctions,Cn=An.position,Dn=An.setPosition,On=An.activeBadgeId,wn=An.summaryPopup,Nn=An.setSummaryPopup,jn=An.closeSummaryPopup,Pn=An.setActiveBadgeId,Fn=An.popupRef,Mn=An.closeCognitivePopup,kn=An.closeMoreFunctionsPopup,Ln=t.useMemo(function(){var e,n,t,i,o,r,l;return{fields:null!==(e=null==ee?void 0:ee.fields)&&void 0!==e?e:c.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(t=null===(n=null==ee?void 0:ee.thresholds)||void 0===n?void 0:n.high)&&void 0!==t?t:c.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(o=null===(i=null==ee?void 0:ee.thresholds)||void 0===i?void 0:i.medium)&&void 0!==o?o:c.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(l=null===(r=null==ee?void 0:ee.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:c.DEFAULT_COMPARISON_CONFIG.thresholds.exact}}},[ee]),Vn=t.useState(null),Hn=Vn[0];Vn[1];var qn=null===(C=null===(T=null==Z?void 0:Z.documents)||void 0===T?void 0:T[null===(B=null==Z?void 0:Z.input_index_map)||void 0===B?void 0:B[0]])||void 0===C?void 0:C.title,Gn=null===(w=null===(D=null==Z?void 0:Z.documents)||void 0===D?void 0:D[null===(O=null==Z?void 0:Z.input_index_map)||void 0===O?void 0:O[1]])||void 0===w?void 0:w.title,zn=u.safeStringify(ne||qn||"Uploaded Contract"),Wn=u.safeStringify(te||Gn||"Reference Template"),Kn=g.useCognitiveTreeData(Z,xe,ae,Ln,we),Yn=Kn.activeProposed,Un=Kn.existingRule,Xn=Kn.proposedSections,$n=Kn.existingSections,Jn=Kn.visibleFields,Qn=Kn.parentDeviationRecord,Zn=Kn.deviationNumberRegistry,et=Kn.parseError;t.useEffect(function(){et&&Be("Failed to load comparison: ".concat(et))},[et]);var nt=Xn.length>0||$n.length>0,tt=t.useMemo(function(){if(!pe)return"off";var e=0,n=0,t=function(i){Array.isArray(i)&&i.forEach(function(i){var o,r=(null==i?void 0:i.content)||"";u.hasMeaningfulRedlineTags(r)&&(e+=1,n+=String(r).length),(null===(o=null==i?void 0:i.subsections)||void 0===o?void 0:o.length)&&t(i.subsections)})};return t(Xn),t($n),"".concat(e,":").concat(n)},[pe,Xn,$n]);t.useEffect(function(){pe&&"off"!==tt&&"0:0"!==tt&&($e.current=null,tn.current=[],requestAnimationFrame(function(){var e;null===(e=un.current)||void 0===e||e.call(un)}))},[pe,tt]);var it=t.useMemo(function(){var e=new Map,n=new Map,t=1;if(xe)Xn.forEach(function(n){!n.title&&!n.content||n.id&&e.set(n.id,t++)}),$n.forEach(function(i){if(i.id){var o=Xn.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(i.selfIndex)});if(o.length>0){var r=o.map(function(n){return e.get(n.id)}).filter(Boolean);n.set(i.id,r.join(", "))}else n.set(i.id,String(t++))}});else for(var i=Math.max(Xn.length,$n.length),o=0;o<i;o++){var r=Xn[o],l=$n[o];r?(e.set(r.id,t),l&&n.set(l.id,String(t)),t++):l&&n.set(l.id,String(t++))}return{leftNums:e,rightNums:n}},[Xn,$n,xe]),ot=h.useSectionRefs(Jn.map(function(e){return e.key}),Math.max(Xn.length,$n.length)),rt=ot.leftRefs,lt=ot.rightRefs,ut=ot.sectionLeftRefs,ct=ot.sectionRightRefs,at=ot.lhsBadgeRefs,st=ot.rhsBadgeRefs,dt=ot.sectionRightRowRefs,vt=ot.subSectionLeftRefs,ft=ot.subSectionRightRefs,gt=ot.sectionRowRefs,pt=ot.getSectionRowRef,ht=ot.getSubSectionRef,xt=ot.getBadgeRef,mt=Un.analysis,_t=u.safeStringify(null===(j=null===(N=null==mt?void 0:mt.rule_difference_comparison)||void 0===N?void 0:N.summary)||void 0===j?void 0:j.overall_summary),Rt=!!_t.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),yt=null!==(P=null==Z?void 0:Z.base_root_id)&&void 0!==P?P:"-1";null==Z||Z[yt];var bt=we?null!==(Y=null!==(z=ae&&(null===(G=null==ae?void 0:ae[yt])||void 0===G?void 0:G.evaluation_result))&&void 0!==z?z:null===(K=null===(W=null==Z?void 0:Z.nodes)||void 0===W?void 0:W[yt])||void 0===K?void 0:K.evaluation_result)&&void 0!==Y?Y:null:null!==(q=null!==(k=ae&&(null===(M=null===(F=null==ae?void 0:ae[yt])||void 0===F?void 0:F.evaluation_result)||void 0===M?void 0:M[0]))&&void 0!==k?k:null===(H=null===(V=null===(L=null==Z?void 0:Z.nodes)||void 0===L?void 0:L[yt])||void 0===V?void 0:V.evaluation_result)||void 0===H?void 0:H[0])&&void 0!==q?q:null,St=u.extractDeviationScore(bt),At=u.generateColorPalette(null!==($=null===(X=null===(U=null==bt?void 0:bt.evaluation_outputs)||void 0===U?void 0:U.metadata)||void 0===X?void 0:X.label_color)&&void 0!==$?$:""),It=function(){Qe.current.forEach(function(e){u.resetClauseHighlight(e)}),Qe.current.clear()},Et=t.useCallback(function(){var e,n,t,i,o,r;It(),Oe(!1),rn.current=!1,$e.current=null;var l=ln.current,c=Wt.current;if(null!==l)if("string"==typeof l&&l.includes(u.DEVIATION_BADGE_SEPARATOR)){var a=l.split(u.DEVIATION_BADGE_SEPARATOR);(s=(null===(e=vt.current[a[2]])||void 0===e?void 0:e.current)||(null===(n=ut.current[Number(a[2])])||void 0===n?void 0:n.current))&&(s.style.paddingTop="0px")}else{var s;(s=null===(t=ut.current[l])||void 0===t?void 0:t.current)&&(s.style.paddingTop="0px")}if(null!==c)if("string"==typeof c&&c.includes(u.DEVIATION_BADGE_SEPARATOR)){a=c.split(u.DEVIATION_BADGE_SEPARATOR);(d=(null===(i=ft.current[a[3]])||void 0===i?void 0:i.current)||(null===(o=ct.current[Number(a[3])])||void 0===o?void 0:o.current))&&(d.style.paddingTop="0px")}else{var d;(d=null===(r=ct.current[c])||void 0===r?void 0:r.current)&&(d.style.paddingTop="0px")}He(null),ln.current=null,Wt.current=null,Pe(!1),Ie(!1),hn.current&&(hn.current.style.height="0px"),xn.current&&(xn.current.style.height="0px"),mn.current&&(mn.current.style.height="0px"),_n.current&&(_n.current.style.height="0px")},[]),Tt=t.useCallback(function(){It(),Et(),We(new Set),Ue([]),tn.current=[],Jt([]),ei(null),Nn(a.EMPTY_SUMMARY_POPUP_STATE),Mn(),requestAnimationFrame(function(){var e;null===(e=un.current)||void 0===e||e.call(un)})},[]),Bt=t.useRef(Tt);t.useEffect(function(){Bt.current=Tt},[Tt]),t.useEffect(function(){oe&&Bt.current()},[oe]);var Ct=x.useAccordionState({maintainRelativeOrder:!!xe,proposedSections:Xn,existingSections:$n,activeSideBySideSection:Ve,connectedSections:ze,resetSideBySide:Et,setConnectedSections:We,setConnectedLines:Ue,cachedConnectedPositions:tn,svgContainerRef:Xe,isAnimatingRef:Ze,animationTimerRef:en,calculateLinesRef:un,sectionLeftRefs:ut,sectionRightRefs:ct,subSectionLeftRefs:vt,subSectionRightRefs:ft}),Dt=Ct.expandedSections,Ot=Ct.setExpandedSections,wt=Ct.expandedSubSections,Nt=Ct.setExpandedSubSections,jt=Ct.toggleSection,Pt=t.useCallback(function(n,t,i,o,r,l,c){var a,s,d,v=u.safeStringify(null==t?void 0:t.id)||u.safeStringify(null==i?void 0:i.id)||"",f=(v?cn[v]:null)||(null==t?void 0:t.cognitiveData)||(null==i?void 0:i.cognitiveData)||{section_id:v,decisioning:[],gap:[],relevance_score:0},g=null!==(s=null===(a=gt.current[o])||void 0===a?void 0:a.current)&&void 0!==s?s:null;return{isLoading:null!==(d=null==le?void 0:le.isLoading)&&void 0!==d&&d,open:!0,sectionTitle:(null==t?void 0:t.title)?null==t?void 0:t.title:"No Counterpart",refSectionTitle:(null==i?void 0:i.title)?null==i?void 0:i.title:"No Counterpart",cognitiveData:f,anchorEl:n,sectionAnchorEl:g,badgeStyle:l||null,sectionIdx:o,docData:{documents:null==Z?void 0:Z.documents,input_index_map:null==Z?void 0:Z.input_index_map},deviationData:function(){var n,r,l=(null==t?void 0:t.evaluationResult)||(null==i?void 0:i.evaluationResult)||null,c=function(n){var t=function(e){if(!e||"object"!=typeof e)return null;var n=null==e?void 0:e.deviation_entries;if(n&&"object"==typeof n){var t=Object.keys(n).sort(function(e,n){return Number(e)-Number(n)})[0];if(t&&n[t])return n[t]}var i=Object.keys(e).filter(function(e){return/^\d+$/.test(e)}).sort(function(e,n){return Number(e)-Number(n)});if(i.length&&e[i[0]])return e[i[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 t?e.__assign(e.__assign({},n),{deviation_summary:(null==n?void 0:n.deviation_summary)||(null==t?void 0:t.deviation_summary),deviation_title:(null==n?void 0:n.deviation_title)||(null==t?void 0:t.deviation_title),deviation_impact:(null==n?void 0:n.deviation_impact)||(null==t?void 0:t.deviation_impact),deviation_explanation:(null==n?void 0:n.deviation_explanation)||(null==t?void 0:t.deviation_explanation),evaluation_outputs:(null==n?void 0:n.evaluation_outputs)||(null==t?void 0:t.evaluation_outputs),cognitive_decisioning:(null==n?void 0:n.cognitive_decisioning)||(null==t?void 0:t.cognitive_decisioning)}):n};if(!("string"==typeof o&&o.includes(u.DEVIATION_BADGE_SEPARATOR)))return c(l);var a=o.split(u.DEVIATION_BADGE_SEPARATOR)[1];if(!a)return l;var s=(null==t?void 0:t.evaluationResult)||(null==i?void 0:i.evaluationResult)||{},d=(null===(n=null==s?void 0:s.deviation_entries)||void 0===n?void 0:n[a])||(null===(r=null==s?void 0:s.deviations)||void 0===r?void 0:r[a])||null;return d?e.__assign(e.__assign(e.__assign({},s),d),{deviation_summary:(null==d?void 0:d.deviation_summary)||(null==s?void 0:s.deviation_summary),deviation_title:(null==d?void 0:d.deviation_title)||(null==s?void 0:s.deviation_title),deviation_impact:(null==d?void 0:d.deviation_impact)||(null==s?void 0:s.deviation_impact),deviation_explanation:(null==d?void 0:d.deviation_explanation)||(null==s?void 0:s.deviation_explanation),evaluation_outputs:(null==d?void 0:d.evaluation_outputs)||(null==s?void 0:s.evaluation_outputs),cognitive_decisioning:(null==d?void 0:d.cognitive_decisioning)||(null==s?void 0:s.cognitive_decisioning)}):c(l)}(),isOrphan:!!r}},[cn,Z]),Ft=t.useCallback(function(e){kn(),Dn(null),En(e)},[kn]),Mt=function(e,n,t,i,o,r){var l;if(e.stopPropagation(),Tn.open&&Tn.sectionIdx===o)kn();else{var c=e.currentTarget,a="left";(null===(l=pn.current)||void 0===l?void 0:l.contains(c))&&(a="right");It(),rn.current&&Et(),We(new Set),Ue([]),tn.current=[],Mn(),wn.open?Ri():jn(),requestAnimationFrame(function(){var e=function(){var e,n,t,i;if("string"==typeof o&&o.includes(u.DEVIATION_BADGE_SEPARATOR)){var r=o.split(u.DEVIATION_BADGE_SEPARATOR),l="".concat(r[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(r[1]);return"right"===a?null===(e=st.current[l])||void 0===e?void 0:e.current:null===(n=at.current[l])||void 0===n?void 0:n.current}return"right"===a?null===(t=st.current[o])||void 0===t?void 0:t.current:null===(i=at.current[o])||void 0===i?void 0:i.current}()||c;Bn(Pt(e,n,i,o,t,r))})}},kt=t.useCallback(function(){null!==Tn.sectionIdx&&Tn.anchorEl?Ft(e.__assign(e.__assign({},Tn),{open:!0})):kn()},[Tn,kn,Ft]),Lt=t.useCallback(function(){var e=Tn.sectionIdx,n=Tn.isOrphan;kn(),jn(),null!==e&&(n?Be("No counterpart exists to connect to."):(It(),rn.current&&Et(),Ue([]),tn.current=[],We(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){un.current&&un.current()},50)))},[Tn.sectionIdx,Tn.isOrphan,kn,jn,Et]),Vt=t.useCallback(function(){var e=Je.current;if(e){Je.current=null;var n=Xn.findIndex(function(n){return n.id===e}),t=$n.findIndex(function(n){return n.id===e}),i=-1===n?u.findKeyPathByNodeId(Xn,e):null,o=-1===t?u.findKeyPathByNodeId($n,e):null,r=-1!==n?n:i?Number(i.split("-")[0]):-1,l=-1!==t?t:o?Number(o.split("-")[0]):-1,c=function(e,n,t,i){var o,r,l,u;return-1!==e?null!==(r=null===(o=t.current[e])||void 0===o?void 0:o.current)&&void 0!==r?r:null:n&&null!==(u=null===(l=i.current[n])||void 0===l?void 0:l.current)&&void 0!==u?u:null},a=function(e,n,t){void 0===t&&(t=30);var i=0,o=function(){var r=e();r&&0!==r.getBoundingClientRect().height?(Qe.current.add(r),u.scrollAndHighlightClause(r,n)):i++<t&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(xe)-1!==r&&Rn.current&&a(function(){return c(n,i,ut,vt)},Rn.current),-1!==l&&pn.current&&a(function(){return c(t,o,ct,ft)},pn.current);else{var s=fn.current;if(!s)return;a(function(){return-1!==r?c(n,i,ut,vt):c(t,o,ct,ft)},s)}}},[Xn,$n,xe,ut,ct,vt,ft,Rn,pn,fn]),Ht=t.useCallback(function(n){if(n){It(),Et(),We(new Set),Ue([]),tn.current=[],jn(),Mn();var t=Xn.findIndex(function(e){return e.id===n}),i=$n.findIndex(function(e){return e.id===n}),o=-1===t?u.findKeyPathByNodeId(Xn,n):null,r=-1===i?u.findKeyPathByNodeId($n,n):null;if(-1!==t||o||-1!==i||r){var l=-1!==t?t:o?Number(o.split("-")[0]):-1,c=-1!==i?i:r?Number(r.split("-")[0]):-1;Je.current=n,Ot(function(n){var t,i=e.__assign({},n),o=!1;-1!==l&&(i[t=xe?"left-".concat(l):String(l)]||(i[t]=!0,o=!0));-1!==c&&(i[t=xe?"right-".concat(c):String(c)]||(i[t]=!0,o=!0));return o?i:n}),Nt(function(n){var t=e.__assign({},n),i=!1,l=function(e){for(var n=e.split("-"),o=n[0],r=1;r<n.length;r++)o+="-".concat(n[r]),t[o]||(t[o]=!0,i=!0)};return o&&l(o),r&&l(r),i?t:n}),setTimeout(function(){requestAnimationFrame(function(){Je.current===n&&qt.current()})},50)}else console.warn('scrollToAndHighlightClause: nodeId "'.concat(n,'" not found'))}},[Xn,$n,xe,Ot,Nt,Et,jn,Mn]),qt=t.useRef(Vt);t.useEffect(function(){qt.current=Vt},[Vt]);var Gt=t.useRef(null),zt=t.useRef(null),Wt=t.useRef(null),Kt=t.useRef(null),Yt=t.useRef(null),Ut=t.useRef(null),Xt=t.useState([]),$t=Xt[0],Jt=Xt[1];t.useRef(null);var Qt=t.useState(null),Zt=Qt[0],ei=Qt[1];t.useEffect(function(){if(Hn){var e=Ln.fields.find(function(e){return e.analysisKey===Hn||e.key===Hn});if(e){var n=rt.current[e.key]||lt.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[Hn,Ln.fields]);var ni=t.useCallback(function(e){var n,t,i,o,r,l,u,c,a,s=null===(n=null==mt?void 0:mt.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!s||!s[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var d=s[e],v=(null==d?void 0:d.relation)||(null===(i=null===(t=null==d?void 0:d.highlights)||void 0===t?void 0:t.ruleA_spans)||void 0===i?void 0:i.length)||(null===(r=null===(o=null==d?void 0:d.highlights)||void 0===o?void 0:o.ruleB_spans)||void 0===r?void 0:r.length)||(null==d?void 0:d.mappings)&&d.mappings.length>0;if(d.mappings){var f=d.mappings[0]||{};return{score:d.score,relation:f.relation||"",highlightsA:(null===(l=f.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(u=f.highlights)||void 0===u?void 0:u.ruleB_spans)||[],hasContent:!!v}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(c=d.highlights)||void 0===c?void 0:c.ruleA_spans)||[],highlightsB:(null===(a=d.highlights)||void 0===a?void 0:a.ruleB_spans)||[],hasContent:!!v}},[mt]),ti=t.useCallback(function(n,t){var i,o,r;void 0===t&&(t="left");var l=null,c=null;if("left"===t)if(l=Xn[n],xe&&l){var s=$n.filter(function(e){var n;return null===(n=l.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)});c=s.find(function(e){return e.evaluationResult})||s[0]}else c=$n[n];else if(c=$n[n],xe&&c){var d=Xn.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(c.selfIndex)});l=d.find(function(e){return e.evaluationResult})||d[0]}else l=Xn[n];var v=(null==l?void 0:l.relation)&&"not_defined"!==l.relation,f=(null==c?void 0:c.relation)&&"not_defined"!==c.relation,g=!(!(null==l?void 0:l.cognitiveData)&&!(null==c?void 0:c.cognitiveData));if(!v&&!f&&!g)return e.__assign(e.__assign({},u.generateColorPalette(a.DEFAULT_DEVIAION_COLOR)),{label:"Not Defined"});var p=null!==(o=null!==(i=null==l?void 0:l.evaluationResult)&&void 0!==i?i:null==c?void 0:c.evaluationResult)&&void 0!==o?o:null,h=u.getFirstDeviationOutputValue(p),x=u.getFirstDeviationColor(p);return null!=p?e.__assign(e.__assign({},u.generateColorPalette(x)),{label:null!==(r=h)&&void 0!==r?r:""}):e.__assign(e.__assign({},u.generateColorPalette(x)),{label:null})},[Xn,$n,cn,Ln,xe]),ii=t.useCallback(function(n){for(var t,i,o,r,l,c=n.split("-").map(Number),s=Xn[c[0]],d=$n[c[0]],v=1;v<c.length;v++)(null==s?void 0:s.subsections)&&(s=s.subsections[c[v]]),(null==d?void 0:d.subsections)&&(d=d.subsections[c[v]]);if(!s&&!d)return null;var f=(null==s?void 0:s.relation)&&"not_defined"!==s.relation,g=(null==d?void 0:d.relation)&&"not_defined"!==d.relation,p=u.safeStringify(null==s?void 0:s.id)||u.safeStringify(null==d?void 0:d.id)||"",h=!(!(null==s?void 0:s.cognitiveData)&&!(null==d?void 0:d.cognitiveData));if(!f&&!g&&!h)return e.__assign(e.__assign({},u.generateColorPalette(a.DEFAULT_DEVIAION_COLOR)),{label:"Not Defined"});null!==(i=null!==(t=null==s?void 0:s.cognitiveRelevanceScore)&&void 0!==t?t:null==d?void 0:d.cognitiveRelevanceScore)&&void 0!==i||p&&(null===(o=cn[p])||void 0===o||o.relevance_score);var x=null!==(l=null!==(r=null==s?void 0:s.evaluationResult)&&void 0!==r?r:null==d?void 0:d.evaluationResult)&&void 0!==l?l:null,m=u.getFirstDeviationOutputValue(x),_=u.getFirstDeviationColor(x);return null!=x?e.__assign(e.__assign({},u.generateColorPalette(_)),{label:null!=m?m:""}):e.__assign(e.__assign({},u.generateColorPalette(_)),{label:null})},[Xn,$n,cn,Ln]),oi=t.useCallback(function(n,t){var i,o,r,l,c,s,d,v,f,g,p,h,x,m,_,R,y;if(!n||null==t)return null;var b=null!==(d=null!==(c=null!==(o=null===(i=null==ae?void 0:ae[n])||void 0===i?void 0:i.evaluation_result)&&void 0!==o?o:null===(l=null===(r=null==Z?void 0:Z.nodes)||void 0===r?void 0:r[n])||void 0===l?void 0:l.evaluation_result)&&void 0!==c?c:null===(s=null==Z?void 0:Z[n])||void 0===s?void 0:s.evaluation_result)&&void 0!==d?d:null;if(!b||"object"!=typeof b)return null;var S=null!==(p=null!==(f=null===(v=null==b?void 0:b.deviations)||void 0===v?void 0:v[t])&&void 0!==f?f:null===(g=null==b?void 0:b.deviation_entries)||void 0===g?void 0:g[t])&&void 0!==p?p:null==b?void 0:b[t],A=null!==(y=null!==(m=null===(x=null===(h=null==S?void 0:S.evaluation_outputs)||void 0===h?void 0:h.metadata)||void 0===x?void 0:x.label_color)&&void 0!==m?m:null===(R=null===(_=null==b?void 0:b.evaluation_outputs)||void 0===_?void 0:_.metadata)||void 0===R?void 0:R.label_color)&&void 0!==y?y:a.DEFAULT_DEVIAION_COLOR;return e.__assign(e.__assign({},u.generateColorPalette(A)),{label:null})},[ae,Z]),ri=t.useCallback(function(){It(),Ot({}),Nt({}),Et(),We(new Set),Ue([]),tn.current=[],jn(),Mn(),kn(),requestAnimationFrame(function(){un.current&&un.current()})},[Ot,Nt,Et,jn,Mn,kn]),li=t.useMemo(function(){return Object.values(Dt).some(Boolean)||Object.values(wt).some(Boolean)},[Dt,wt]),ui=t.useCallback(function(){var e,n,t,i,o,r,l,c,a,s,d,v,f,g,p,h,x,m,_,R,y,b,S;if(!yn.current&&!Ze.current){yn.current=!0;try{if(!Gt.current)return;var A=function(e){var n=e.split("-"),t=n[0];if(!Dt[t]&&!1===xe)return!1;if(xe&&!Dt["left-".concat(t)]&&!Dt["right-".concat(t)]&&!Dt[t])return!1;for(var i=t,o=1;o<n.length-1;o++)if(i+="-".concat(n[o]),!wt[i])return!1;return!0},I=Gt.current.getBoundingClientRect();dn({width:I.width,height:I.height});var E=[];if(Jn.forEach(function(e){var n,t,i=e.key,o=null===(n=rt.current[i])||void 0===n?void 0:n.current,r=null===(t=lt.current[i])||void 0===t?void 0:t.current;o&&r&&(o.style.height="auto",r.style.height="auto",o.style.minHeight="0px",r.style.minHeight="0px")}),!Ze.current){for(var T=0;T<Math.max(Xn.length,$n.length);T++){var B=null===(e=ut.current[T])||void 0===e?void 0:e.current,C=null===(n=ct.current[T])||void 0===n?void 0:n.current;B&&(B.style.height="auto",B.style.minHeight="0px"),C&&(C.style.height="auto",C.style.minHeight="0px")}xe||Object.keys(vt.current).forEach(function(e){var n,t;if(A(e)){var i=null===(n=vt.current[e])||void 0===n?void 0:n.current,o=null===(t=ft.current[e])||void 0===t?void 0:t.current;i&&o&&(i.style.height="auto",o.style.height="auto",i.style.minHeight="0px",o.style.minHeight="0px")}})}var D={};Jn.forEach(function(e){var n,t,i=e.key,o=null===(n=rt.current[i])||void 0===n?void 0:n.current,r=null===(t=lt.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),u=r.getBoundingClientRect();D[i]=Math.max(l.height,u.height)}});var O={left:{},right:{}},w={};if(!Ze.current)if(xe){if(De&&null!==Ve)if("number"==typeof Ve){var N=Ve,j=Xn[N],P=null===(o=ut.current[N])||void 0===o?void 0:o.current;P&&j&&(j.refIndexes||[]).forEach(function(e){var n,t=$n.findIndex(function(n){return n.selfIndex===e}),i=null===(n=ct.current[t])||void 0===n?void 0:n.current;if(i&&(Dt["left-".concat(N)]||Dt["right-".concat(t)])){var o=Math.max(P.getBoundingClientRect().height,i.getBoundingClientRect().height);O.left[N]=Math.max(O.left[N]||0,o),O.right[t]=Math.max(O.right[t]||0,o)}})}else{var F=Ve.split(u.DEVIATION_BADGE_SEPARATOR)[2];if(F){B=null===(r=vt.current[F])||void 0===r?void 0:r.current,C=null===(l=ft.current[F])||void 0===l?void 0:l.current;if(B&&C){M=Math.max(B.getBoundingClientRect().height,C.getBoundingClientRect().height);w[F]=Math.max(w[F]||0,M)}}}}else{Object.keys(vt.current).forEach(function(e){var n,t;if(A(e)){var i=null===(n=vt.current[e])||void 0===n?void 0:n.current,o=null===(t=ft.current[e])||void 0===t?void 0:t.current;if(i&&o&&null!==i.offsetParent&&null!==o.offsetParent){var r=i.getBoundingClientRect(),l=o.getBoundingClientRect(),u=Math.max(r.height,l.height);w[e]=u,i.style.minHeight="".concat(u,"px"),o.style.minHeight="".concat(u,"px")}}});for(T=0;T<Math.min(Xn.length,$n.length);T++){var B=null===(t=ut.current[T])||void 0===t?void 0:t.current,C=null===(i=ct.current[T])||void 0===i?void 0:i.current;if(B&&C){var M=Math.max(B.getBoundingClientRect().height,C.getBoundingClientRect().height);O.left[T]=M,O.right[T]=M}}}if(Jn.forEach(function(e){var n,t,i=e.key,o=null===(n=rt.current[i])||void 0===n?void 0:n.current,r=null===(t=lt.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=D[i];o.style.minHeight="".concat(l,"px"),r.style.minHeight="".concat(l,"px")}}),Ze.current||(Object.entries(O.left).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=ut.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),Object.entries(O.right).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=ct.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),xe||Object.keys(w).forEach(function(e){var n,t,i=null===(n=vt.current[e])||void 0===n?void 0:n.current,o=null===(t=ft.current[e])||void 0===t?void 0:t.current;if(i&&o&&w[e]){var r=w[e];i.style.minHeight="".concat(r,"px"),o.style.minHeight="".concat(r,"px")}})),xe)Xn.forEach(function(e,n){var t;(null===(t=ut.current[n])||void 0===t?void 0:t.current)&&(e.refIndexes||[]).forEach(function(e){var t,i,o,r,l,u,c,a,s,d,v=$n.findIndex(function(n){return n.selfIndex===e});if(-1!==v){var f=null===(t=at.current[n])||void 0===t?void 0:t.current,g=null===(i=st.current[v])||void 0===i?void 0:i.current;if(f&&g){var p=f.getBoundingClientRect(),h=g.getBoundingClientRect(),x=p.right-I.left,m=h.left-I.left,_=p.top+p.height/2-I.top,R=h.top+h.height/2-I.top;if(De&&Ve===n){var y=null!==(r=null===(o=Rn.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==r?r:0,b=null!==(u=null===(l=pn.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==u?u:0,S=y+(null!==(a=null===(c=Rn.current)||void 0===c?void 0:c.clientHeight)&&void 0!==a?a:1/0),A=b+(null!==(d=null===(s=pn.current)||void 0===s?void 0:s.clientHeight)&&void 0!==d?d:1/0),T=p.top+p.height/2,B=h.top+h.height/2,C=function(e,n,t){return Math.max(n,Math.min(t,e))};_=C(T,y,S)-I.top,R=C(B,b,A)-I.top}var D=ti(n);D&&E.push({id:"line-".concat(n,"-").concat(v),x1:x,y1:_,x2:m,y2:R,style:D,sectionIdx:n,targetRightIdx:v})}}})});else{for(T=0;T<Math.min(Xn.length,$n.length);T++){var k=null===(c=ut.current[T])||void 0===c?void 0:c.current,L=null===(a=ct.current[T])||void 0===a?void 0:a.current;if(k&&L){var V=k.getBoundingClientRect(),H=L.getBoundingClientRect(),q=Math.max(V.top,H.top)+18-I.top,G=(null===(s=$n[T])||void 0===s?void 0:s.id)||"sec-".concat(T);(J=ti(T))&&E.push({id:G,x1:V.right-I.left,y1:q,x2:H.left-I.left,y2:q,style:J,sectionIdx:T,hasCognitive:!!((null===(d=Xn[T])||void 0===d?void 0:d.cognitiveData)||(null===(v=$n[T])||void 0===v?void 0:v.cognitiveData)||G&&cn[G]),isSubSection:!1})}}Object.keys(vt.current).forEach(function(e){var n,t,i,o,r,l;if(A(e)){var c=null===(n=vt.current[e])||void 0===n?void 0:n.current,a=null===(t=ft.current[e])||void 0===t?void 0:t.current;if(c&&a){for(var s=e.split("-").map(Number),d=Xn[s[0]],v=$n[s[0]],f=1;f<s.length;f++)(null==d?void 0:d.subsections)&&(d=d.subsections[s[f]]),(null==v?void 0:v.subsections)&&(v=v.subsections[s[f]]);var g=!!d&&((null===(i=d.displayTitle)||void 0===i||i)&&u.hasValue(d.title)),p=!!d&&((null===(o=d.displayContent)||void 0===o||o)&&u.hasValue(d.content)),h=!!v&&((null===(r=v.displayTitle)||void 0===r||r)&&u.hasValue(v.title)),x=!!v&&((null===(l=v.displayContent)||void 0===l||l)&&u.hasValue(v.content));if(g&&p||h&&x){var m=c.getBoundingClientRect(),_=a.getBoundingClientRect(),R=Math.max(m.top,_.top)+16-I.top,y=ii(e);y&&"Not Defined"!==y.label&&E.push({id:"subsec-".concat(e),x1:m.right-I.left,y1:R,x2:_.left-I.left,y2:R,style:y,sectionIdx:s[0],isSubSection:!0,subSectionKeyPath:e,hasCognitive:!(!(null==d?void 0:d.cognitiveData)&&!(null==v?void 0:v.cognitiveData))})}}}})}if(De&&"string"==typeof Ve&&Ve.includes(u.DEVIATION_BADGE_SEPARATOR)){var z=Ve.split(u.DEVIATION_BADGE_SEPARATOR),W=z[0],K=z[1],Y=z[2],U=(z[3],"".concat(W).concat(u.DEVIATION_BADGE_SEPARATOR).concat(K)),X=null===(f=at.current[U])||void 0===f?void 0:f.current,$=null===(g=st.current[U])||void 0===g?void 0:g.current;if(X&&$){var J,Q=X.getBoundingClientRect(),Z=$.getBoundingClientRect(),ee=Q.right-I.left,ne=Z.left-I.left,te=Q.top+Q.height/2-I.top,ie=Z.top+Z.height/2-I.top;if(xe){var oe=null!==(h=null===(p=Rn.current)||void 0===p?void 0:p.getBoundingClientRect().top)&&void 0!==h?h:0,re=null!==(m=null===(x=pn.current)||void 0===x?void 0:x.getBoundingClientRect().top)&&void 0!==m?m:0,le=oe+(null!==(R=null===(_=Rn.current)||void 0===_?void 0:_.clientHeight)&&void 0!==R?R:1/0),ue=re+(null!==(b=null===(y=pn.current)||void 0===y?void 0:y.clientHeight)&&void 0!==b?b:1/0),ce=function(e,n,t){return Math.max(n,Math.min(t,e))};te=ce(Q.top+Q.height/2,oe,le)-I.top,ie=ce(Z.top+Z.height/2,re,ue)-I.top}(J=null!==(S=oi(W,K))&&void 0!==S?S:ii(Y))&&E.push({id:"line-subsec-".concat(U),x1:ee,y1:te,x2:ne,y2:ie,style:J,sectionIdx:Number(Y.split("-")[0]),isSubSection:!0,subSectionKeyPath:Ve})}}if(Jt(E),Yt.current&&Ut.current){var ae=Yt.current.getBoundingClientRect(),se=Ut.current.getBoundingClientRect(),de=(ae.top+ae.height/2-I.top+se.top+se.height/2-I.top)/2;ei({x1:ae.right-I.left,x2:se.left-I.left,y:de})}else ei(null);if(ze.size>0){var ve=[],fe=Rn.current,ge=pn.current;if(fe&&ge){var pe=[],he=fe.getBoundingClientRect().top,me=ge.getBoundingClientRect().top,_e=he+fe.clientHeight,Re=me+ge.clientHeight,ye=fe.scrollTop,be=ge.scrollTop,Se=I.top,Ae=function(e,n,t){return Math.max(n,Math.min(t,e))};ze.forEach(function(e){var n,t,i,o,r,l;if("string"==typeof e&&e.includes(u.DEVIATION_BADGE_SEPARATOR)){var c=e.split(u.DEVIATION_BADGE_SEPARATOR),a=c[0],s=c[1],d=c[2],v=(c[3],"".concat(a).concat(u.DEVIATION_BADGE_SEPARATOR).concat(s)),f=null===(n=at.current[v])||void 0===n?void 0:n.current,g=null===(t=st.current[v])||void 0===t?void 0:t.current;if(!f||!g)return;var p=f.getBoundingClientRect(),h=g.getBoundingClientRect(),x=null!==(i=oi(a,s))&&void 0!==i?i:ii(d),m=(P=p.right-I.left)+.5*((F=h.left-I.left-0)-P),_=p.top+p.height/2,R=h.top+h.height/2,y=_-he+ye,b=R-me+be,S="conn-subsec-".concat(v);pe.push({lhsScrollY:y,rhsScrollY:b,x1:P,x2:F,containerTop:Se,leftIdx:e,rhsArrayIdx:e,styleColor:(null==x?void 0:x.badgeBorder)||"#6366F1",styleId:S});var A=Ae(_,he,_e),E=Ae(R,me,Re),T=A-Se,B=E-Se,C=R>=me-4&&R<=Re+4,D="";D=(M=_>=he-4&&_<=_e+4)&&C?u.getBentArrowPath(P,T,F,B):M&&!C?"M ".concat(P,",").concat(T," L ").concat(m,",").concat(T," L ").concat(m,",").concat(B):!M&&C?"M ".concat(m,",").concat(T," L ").concat(m,",").concat(B," L ").concat(F,",").concat(B):"M ".concat(m,",").concat(T," L ").concat(m,",").concat(B),ve.push({id:S,pathD:D,style:x,leftIdx:e,rhsArrayIdx:e})}else if(xe){var O=e,w=Xn[O];if(!(null===(l=null==w?void 0:w.refIndexes)||void 0===l?void 0:l.length))return;w.refIndexes.forEach(function(e){var n,t,i=$n.findIndex(function(n){return n.selfIndex===e});if(-1!==i){var o=null===(n=at.current[O])||void 0===n?void 0:n.current,r=null===(t=st.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),c=r.getBoundingClientRect(),a=ti(O),s=l.right-I.left,d=c.left-I.left-0,v=s+.5*(d-s),f=l.top+l.height/2,g=c.top+c.height/2,p=f-he+ye,h=g-me+be,x="conn-".concat(O,"-").concat(i);pe.push({lhsScrollY:p,rhsScrollY:h,x1:s,x2:d,containerTop:Se,leftIdx:O,rhsArrayIdx:i,styleColor:(null==a?void 0:a.badgeBorder)||"#6366F1",styleId:x});var m=Ae(f,he,_e),_=Ae(g,me,Re),R=m-Se,y=_-Se,b=f>=he-4&&f<=_e+4,S=g>=me-4&&g<=Re+4,A="";A=b&&S?u.getBentArrowPath(s,R,d,y):b&&!S?"M ".concat(s,",").concat(R," L ").concat(v,",").concat(R," L ").concat(v,",").concat(y):!b&&S?"M ".concat(v,",").concat(R," L ").concat(v,",").concat(y," L ").concat(d,",").concat(y):"M ".concat(v,",").concat(R," L ").concat(v,",").concat(y),ve.push({id:x,pathD:A,style:a,leftIdx:O,rhsArrayIdx:i})}}})}else{var N=e,j=N;f=null===(o=at.current[N])||void 0===o?void 0:o.current,g=null===(r=st.current[j])||void 0===r?void 0:r.current;if(!f||!g)return;var P,F;p=f.getBoundingClientRect(),h=g.getBoundingClientRect(),x=ti(N),m=(P=p.right-I.left)+.5*((F=h.left-I.left-0)-P),_=p.top+p.height/2,R=h.top+h.height/2,y=_-he+ye,b=R-me+be,S="conn-".concat(N,"-").concat(j);pe.push({lhsScrollY:y,rhsScrollY:b,x1:P,x2:F,containerTop:Se,leftIdx:N,rhsArrayIdx:j,styleColor:(null==x?void 0:x.badgeBorder)||"#6366F1",styleId:S});var M;A=Ae(_,he,_e),E=Ae(R,me,Re),T=A-Se,B=E-Se,C=R>=me-4&&R<=Re+4,D="";D=(M=_>=he-4&&_<=_e+4)&&C?u.getBentArrowPath(P,T,F,B):M&&!C?"M ".concat(P,",").concat(T," L ").concat(m,",").concat(T," L ").concat(m,",").concat(B):!M&&C?"M ".concat(m,",").concat(T," L ").concat(m,",").concat(B," L ").concat(F,",").concat(B):"M ".concat(m,",").concat(T," L ").concat(m,",").concat(B),ve.push({id:S,pathD:D,style:x,leftIdx:N,rhsArrayIdx:j})}}),tn.current=pe}Ue(ve)}else Ue([]),tn.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{yn.current=!1}}},[Jn,Xn,$n,cn,Ln,ni,ti,oi,xe,De,Ve,ze,Dt,wt]),ci=t.useCallback(function(){var e,n,t,i,o,r,l,c,a,s,d,v,f,g,p=tn.current;if(p.length&&!Ze.current){var h=null!==(n=null===(e=Rn.current)||void 0===e?void 0:e.scrollTop)&&void 0!==n?n:0,x=null!==(i=null===(t=pn.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,m=null!==(r=null===(o=Rn.current)||void 0===o?void 0:o.clientHeight)&&void 0!==r?r:1/0,_=null!==(c=null===(l=pn.current)||void 0===l?void 0:l.clientHeight)&&void 0!==c?c:1/0,R=null!==(s=null===(a=Rn.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==s?s:0,y=null!==(v=null===(d=pn.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==v?v:0,b=R+m,S=y+_,A=null!==(g=null===(f=Gt.current)||void 0===f?void 0:f.getBoundingClientRect().top)&&void 0!==g?g:0,I=function(e,n,t){return Math.max(n,Math.min(t,e))};p.forEach(function(e){var n=e.lhsScrollY-h+R,t=e.rhsScrollY-x+y,i=nn.current[e.styleId+"-stroke"],o=nn.current[e.styleId+"-bg"];if(i||o){var r,l=I(n,R,b),c=I(t,y,S),a=l-A,s=c-A,d=n>=R-4&&n<=b+4,v=t>=y-4&&t<=S+4,f=e.x1+.5*(e.x2-e.x1);r=d&&v?u.getBentArrowPath(e.x1,a,e.x2,s):d&&!v?"M ".concat(e.x1,",").concat(a," L ").concat(f,",").concat(a," L ").concat(f,",").concat(s):!d&&v?"M ".concat(f,",").concat(a," L ").concat(f,",").concat(s," L ").concat(e.x2,",").concat(s):"M ".concat(f,",").concat(a," L ").concat(f,",").concat(s),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",r)),o&&(o.setAttribute("visibility","visible"),o.setAttribute("d",r))}})}},[]);t.useEffect(function(){un.current=ui},[ui]);var ai=t.useRef(null),si=t.useRef(null),di=t.useCallback(function(){tn.current.length>0&&!Ze.current||(null!==ai.current&&clearTimeout(ai.current),ai.current=setTimeout(function(){un.current(),ai.current=null},50))},[]),vi=t.useCallback(function(){ke(!0),Pe(!1),$e.current=null,null!==si.current&&clearTimeout(si.current),null!==ai.current&&(clearTimeout(ai.current),ai.current=null),si.current=setTimeout(function(){var e,n,t,i,o,r,l,c,a,s,d;try{if(tn.current=[],rn.current&&null!==ln.current&&null!==Wt.current){var v=ln.current,f=Wt.current,g="string"==typeof v&&v.includes(u.DEVIATION_BADGE_SEPARATOR),p=null,h=null,x=null,m=null;if(g){var _=v.split(u.DEVIATION_BADGE_SEPARATOR),R="".concat(_[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(_[1]);p=(null===(e=at.current[R])||void 0===e?void 0:e.current)||null,h=(null===(n=st.current[R])||void 0===n?void 0:n.current)||null,x=(null===(t=vt.current[_[2]])||void 0===t?void 0:t.current)||(null===(i=ut.current[Number(_[2])])||void 0===i?void 0:i.current)||null,m=(null===(o=ft.current[_[3]])||void 0===o?void 0:o.current)||(null===(r=ct.current[Number(_[3])])||void 0===r?void 0:r.current)||null}else p=(null===(l=gt.current[v])||void 0===l?void 0:l.current)||null,x=(null===(c=ut.current[v])||void 0===c?void 0:c.current)||null,h=(null===(a=dt.current[f])||void 0===a?void 0:a.current)||null,m=(null===(s=ct.current[f])||void 0===s?void 0:s.current)||null;if(p&&h&&x&&m){if(x.style.paddingTop="0px",m.style.paddingTop="0px",!xe){var y=p.getBoundingClientRect(),b=h.getBoundingClientRect(),S=y.top-b.top;S>0?m.style.paddingTop="".concat(S,"px"):S<0&&(x.style.paddingTop="".concat(Math.abs(S),"px"))}var A=Rn.current,I=pn.current;if(A&&I){var E=p.getBoundingClientRect().top-A.getBoundingClientRect().top+A.scrollTop,T=h.getBoundingClientRect().top-I.getBoundingClientRect().top+I.scrollTop-(E-A.scrollTop);Math.abs(I.scrollTop-T)>1&&(I.scrollTop=T)}}}null===(d=un.current)||void 0===d||d.call(un),rn.current&&Pe(!0)}catch(e){console.error("Safely caught error during resize calculation:",e)}finally{ke(!1),si.current=null}},150)},[xe,Xn,$n]),fi=t.useCallback(function(e){if(null!==bn.current&&Sn.current&&Math.abs(e.currentTarget.scrollTop-bn.current)<=2){var n=Sn.current;bn.current=null,Sn.current=null,n()}qe.current||(xe||di(),on.current||(on.current=!0,requestAnimationFrame(function(){var e,n,t,i,o,r,l;if(rn.current){var c=Rn.current,a=pn.current;if(c&&a&&Kt.current){if(!$e.current){var s=ln.current,d=void 0;if("string"==typeof s&&s.includes(u.DEVIATION_BADGE_SEPARATOR)){var v=s.split(u.DEVIATION_BADGE_SEPARATOR),f="".concat(v[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(v[1]);d=null===(e=at.current[f])||void 0===e?void 0:e.current}else d=null===(n=at.current[s])||void 0===n?void 0:n.current;if(d){var g=d.getBoundingClientRect();$e.current={badgeScreenY:g.top+g.height/2,initialScrollTop:c.scrollTop,leftTop:c.getBoundingClientRect().top,leftBottom:c.getBoundingClientRect().top+c.clientHeight,cTop:null!==(i=null===(t=Gt.current)||void 0===t?void 0:t.getBoundingClientRect().top)&&void 0!==i?i:0}}}if($e.current){var p=$e.current,h=c.scrollTop-p.initialScrollTop,x=p.badgeScreenY-h,m=((o=x,r=p.leftTop,l=p.leftBottom,Math.max(r,Math.min(l,o)))-p.cTop).toString(),_=x>=p.leftTop-4&&x<=p.leftBottom+4;Kt.current.setAttribute("y1",m),Kt.current.setAttribute("y2",m),Kt.current.setAttribute("visibility",_?"visible":"hidden")}}}tn.current.length>0&&ci(),on.current=!1})))},[ci,xe,di]),gi=t.useRef(0),pi=t.useRef(0),hi=t.useRef(0),xi=t.useRef(function(){});t.useRef(null),t.useEffect(function(){xi.current=vi},[vi]),t.useEffect(function(){var e=setTimeout(di,250),n=function(){return xi.current()};return window.addEventListener("resize",n),function(){clearTimeout(e),null!==ai.current&&clearTimeout(ai.current),null!==si.current&&clearTimeout(si.current),window.removeEventListener("resize",n)}},[Yn,Un,mt,Jn,Dt,wt,Xn,$n,Ln,di,De,Ve,je,ze]),t.useEffect(function(){var e=function(e,n,t,i,o){n.current=e.getBoundingClientRect().width;var r=new ResizeObserver(function(e){null!==t.current&&cancelAnimationFrame(t.current),t.current=requestAnimationFrame(function(){var r,l,u;t.current=null;var c=e[e.length-1];if(c){var a=null!==(u=null===(l=null===(r=c.borderBoxSize)||void 0===r?void 0:r[0])||void 0===l?void 0:l.inlineSize)&&void 0!==u?u:c.contentRect.width;Math.abs(a-n.current)<1?o():(n.current=a,i())}})});return r.observe(e),r},n={current:null},t={current:null},i={current:null},o=[],r=[n,t,i];return gn.current&&o.push(e(gn.current,gi,n,function(){return xi.current()},function(){})),fn.current&&o.push(e(fn.current,pi,t,function(){return xi.current()},function(){return un.current()})),Gt.current&&o.push(e(Gt.current,hi,i,function(){return xi.current()},function(){return un.current()})),function(){o.forEach(function(e){return e.disconnect()}),r.forEach(function(e){null!==e.current&&(cancelAnimationFrame(e.current),e.current=null)})}},[]),t.useEffect(function(){rn.current=De},[De]),t.useEffect(function(){ln.current=Ve},[Ve]);var mi=t.useCallback(function(e,n,t){var i,o,r=null===(i=null==t?void 0:t.toggleIfSame)||void 0===i||i,l=null==t?void 0:t.onReady,c=null!==(o=null==t?void 0:t.sourceSide)&&void 0!==o?o:"left";kn(),null!=e&&(n?Be("No counterpart exists for this section."):(It(),De&&Ve===e?r?Et():null==l||l():(We(new Set([e])),Ue([]),tn.current=[],Ie(!0),qe.current=!0,He(e),ln.current=e,Oe(!0),rn.current=!0,Pe(!1),hn.current&&(hn.current.style.height="0px"),xn.current&&(xn.current.style.height="0px"),mn.current&&(mn.current.style.height="0px"),_n.current&&(_n.current.style.height="0px"),requestAnimationFrame(function(){var n,t,i,o,r,a="string"==typeof e&&e.includes(u.DEVIATION_BADGE_SEPARATOR),s=null,d=null,v=null;if(a){var f=e.split(u.DEVIATION_BADGE_SEPARATOR),g="".concat(f[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(f[1]);s=(null===(n=at.current[g])||void 0===n?void 0:n.current)||null,d=(null===(t=st.current[g])||void 0===t?void 0:t.current)||null,v=d?e:null}else if(s=(null===(i=gt.current[e])||void 0===i?void 0:i.current)||null,xe){var p=Xn[e],h=(null==p?void 0:p.refIndexes)||[];if(h.length>0){var x=h[0],m=$n.findIndex(function(e){return e.selfIndex===x});-1!==m&&(d=(null===(r=dt.current[m])||void 0===r?void 0:r.current)||null,v=m)}}else d=(null===(o=dt.current[e])||void 0===o?void 0:o.current)||null,v=d?e:null;Wt.current=v;var _=Rn.current,R=pn.current,y=function(){!function(){var n,t,i,o,r,l,c,s,d,f,g,p,h=null,x=null,m=null,_=null;if(a){var R=e.split(u.DEVIATION_BADGE_SEPARATOR),y="".concat(R[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(R[1]);h=(null===(n=vt.current[R[2]])||void 0===n?void 0:n.current)||(null===(t=ut.current[Number(R[2])])||void 0===t?void 0:t.current)||null,x=(null===(i=ft.current[R[3]])||void 0===i?void 0:i.current)||(null===(o=ct.current[Number(R[3])])||void 0===o?void 0:o.current)||null,m=(null===(r=at.current[y])||void 0===r?void 0:r.current)||h,_=(null===(l=st.current[y])||void 0===l?void 0:l.current)||x}else{var b=Number(e),S=null!==v?Number(v):b;h=(null===(c=ut.current[b])||void 0===c?void 0:c.current)||null,x=(null===(s=ct.current[S])||void 0===s?void 0:s.current)||null,m=(null===(d=at.current[b])||void 0===d?void 0:d.current)||(null===(f=gt.current[b])||void 0===f?void 0:f.current)||h,_=(null===(g=st.current[S])||void 0===g?void 0:g.current)||(null===(p=dt.current[S])||void 0===p?void 0:p.current)||x}if(m&&_&&h&&x){h.style.paddingTop="0px",x.style.paddingTop="0px";var A=m.getBoundingClientRect(),I=_.getBoundingClientRect(),E=A.top-I.top;E>0?x.style.paddingTop="".concat(E,"px"):E<0&&(h.style.paddingTop="".concat(Math.abs(E),"px"))}}(),Pe(!0),un.current&&un.current(),qe.current=!1,"right"===c&&R?R.dispatchEvent(new Event("scroll")):_&&_.dispatchEvent(new Event("scroll")),Ie(!1),null==l||l()};if(!s||!_)return qe.current=!1,Ie(!1),void(null==l||l());if(d&&R){if(!xe){var b=0;b="right"===c?d?d.getBoundingClientRect().top:0:s?s.getBoundingClientRect().top:0;var S=fn.current,A=(null==S?void 0:S.getBoundingClientRect().top)||0,I=S?S.scrollTop+b-A-150:0;return S?void u.smoothScrollTo(S,I,200,y):void y()}var E=s.getBoundingClientRect().top-_.getBoundingClientRect().top+_.scrollTop,T=d.getBoundingClientRect().top-R.getBoundingClientRect().top+R.scrollTop,B=200;if("left"===c){var C=T-(E-_.scrollTop);C<0&&hn.current&&(hn.current.style.height="".concat(Math.abs(C),"px")),requestAnimationFrame(function(){var e,n=R.scrollHeight-R.clientHeight;if(C<0)e=0;else{if(C>n){var t=C-n;return xn.current&&(xn.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){u.smoothScrollTo(R,C,B,y)})}e=C}u.smoothScrollTo(R,e,B,y)})}else{var D=E-(T-R.scrollTop);D<0&&mn.current&&(mn.current.style.height="".concat(Math.abs(D),"px")),requestAnimationFrame(function(){var e,n=_.scrollHeight-_.clientHeight;if(D<0)e=0;else{if(D>n){var t=D-n;return _n.current&&(_n.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){u.smoothScrollTo(_,D,B,y)})}e=D}u.smoothScrollTo(_,e,B,y)})}}else y()}))))},[Ve,kn,$n,De,xe,Xn,Et]),_i=t.useCallback(function(){var e,n=Tn.sectionIdx,t=Tn.isOrphan;if(jn(),null!=n){var i="left";Tn.anchorEl&&(null===(e=pn.current)||void 0===e?void 0:e.contains(Tn.anchorEl))&&(i="right"),mi(n,t,{sourceSide:i})}},[mi,Tn.isOrphan,Tn.sectionIdx,Tn.anchorEl,jn]),Ri=t.useCallback(function(){jn(),Et(),We(new Set),Ue([]),tn.current=[]},[jn,Et]),yi=null!==Tn.sectionIdx&&ze.has(Tn.sectionIdx),bi=m.useDeviationNavigation({proposedSections:Xn,existingSections:$n,parentDeviationRecord:Qn,expandedSections:Dt,maintainRelativeOrder:!!xe,scrollContainerRef:fn,leftContainerRef:Rn,rightContainerRef:pn,lhsBadgeRefs:at,rhsBadgeRefs:st}),Si=bi.showDeviationNavigation,Ai=bi.showOpenNodeRef,Ii=bi.adjustScrollForPopup,Ei=t.useCallback(function(e,n,t,i,o){var r,l="string"==typeof i?u.safeStringify(i).trim():u.safeStringify(null==i?void 0:i.deviation_summary).trim(),c=e.currentTarget;Mn();var a="left";(null===(r=pn.current)||void 0===r?void 0:r.contains(c))&&(a="right");var s=function(){var e,t,i,o;if("string"==typeof n&&n.includes(u.DEVIATION_BADGE_SEPARATOR)){var r=n.split(u.DEVIATION_BADGE_SEPARATOR),l="".concat(r[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(r[1]);return"right"===a?null===(e=st.current[l])||void 0===e?void 0:e.current:null===(t=at.current[l])||void 0===t?void 0:t.current}return"right"===a?null===(i=st.current[n])||void 0===i?void 0:i.current:null===(o=at.current[n])||void 0===o?void 0:o.current},d=function(e,n){var t=!!xe,i=t?"right"===a?pn.current:Rn.current:fn.current,o=t?"right"===a?Rn.current:pn.current:null;if(i&&e){var r=e.getBoundingClientRect(),l=i.getBoundingClientRect(),c=l.bottom-.35*l.height,s=l.top+.35*l.height;if(r.top>c||r.top<s){var d=l.top+l.height/2,v=r.top+r.height/2-d+200;t&&o&&u.smoothScrollTo(o,o.scrollTop+v,250,function(){}),u.smoothScrollTo(i,i.scrollTop+v,250,n)}else n()}else n()};if(t)return Et(),We(new Set),Ue([]),tn.current=[],void(l&&requestAnimationFrame(function(){var e=s()||c;d(e,function(){Nn({open:!0,anchorEl:e,summary:i,displayImpact:o})})}));mi(n,t,l?{toggleIfSame:!1,sourceSide:a,onReady:function(){var e=s()||c;d(e,function(){Nn({open:!0,anchorEl:e,summary:i,displayImpact:o})})}}:{toggleIfSame:!1,sourceSide:a})},[mi,Mn,Nn,Et,xe]),Ti=t.useMemo(function(){var e;if(!se)return null;var n=null===(e=null==se?void 0:se.id)||void 0===e?void 0:e.split(":")[0];for(var t in Qn){if((Qn[t]||[]).some(function(e){return e.id===n}))return t}return null},[se,Qn]),Bi=t.useRef({id:null,triggerMs:null}),Ci=t.useRef(null);t.useEffect(function(){var n;if(null==se?void 0:se.id){var t=Number(se.trigger),i=Bi.current;if((null==i?void 0:i.triggerMs)!==t){if(!(se.id.includes(":")&&/:\d+$/.test(se.id)))return Bi.current={id:se.id,triggerMs:t},void Ht(se.id);var o=null===(n=null==se?void 0:se.id)||void 0===n?void 0:n.split(":"),r=o[0],l=o[1],c=null!=l?l:"0";Ci.current!==se.id&&(jn(),Mn(),Et(),We(new Set),Ue([]),tn.current=[],Ci.current=se.id);var a=!1,s=0,d=null,v=150,f=function(e,n){for(var t=function(e,i){if(!e)return null;if(e.id===n)return i;if(!Array.isArray(e.subsections))return null;for(var o=0;o<e.subsections.length;o++){var r=t(e.subsections[o],"".concat(i,"-").concat(o));if(r)return r}return null},i=0;i<e.length;i++){var o=t(e[i],String(i));if(o)return o}return null},g=function(){var n,i,o,l;if(!a){var p=function(){Bi.current={id:se.id,triggerMs:t}},h=null,x=null;for(var m in Qn){var _=Qn[m].find(function(e){return e.id===r});if(_){h=m,x=_;break}}if(x&&h){var R=Xn.findIndex(function(e){return e.id===h}),y=$n.findIndex(function(e){return e.id===h}),b=-1===R&&-1!==y,S=f(Xn,x.id),A=f($n,x.id);if(S&&!A&&!b){var I=S.split("-"),E=Number(I[0]);if(xe){var T=null===(i=null===(n=Xn[E])||void 0===n?void 0:n.refIndexes)||void 0===i?void 0:i[0],B=$n.findIndex(function(e){return e.selfIndex===T});-1!==B&&(E=B)}A=e.__spreadArray([E],I.slice(1),!0).join("-")}if(S||A){var C=b||!S&&!!A,D=S?Number(S.split("-")[0]):R,O=A?Number(A.split("-")[0]):y;if(C){if(!(xe?!!Dt["right-".concat(O)]:!!Dt[String(O)])&&O>=0)return jt(O,"right"),s+=1,void(d=setTimeout(g,450))}else if(!(xe?!!Dt["left-".concat(D)]:!!Dt[String(D)])&&D>=0)return jt(D,"left"),s+=1,void(d=setTimeout(g,450));var w,N=S||"",j=A||"",P="".concat(x.id).concat(u.DEVIATION_BADGE_SEPARATOR).concat(c).concat(u.DEVIATION_BADGE_SEPARATOR).concat(N).concat(u.DEVIATION_BADGE_SEPARATOR).concat(j),F="".concat(x.id).concat(u.DEVIATION_BADGE_SEPARATOR).concat(c),M=null===(o=at.current[F])||void 0===o?void 0:o.current,k=null===(l=st.current[F])||void 0===l?void 0:l.current,L=C||!M&&!!k,V=L?k:M;if(w=xe?L?pn.current:Rn.current:fn.current,V&&w){var H=V.getBoundingClientRect();if(0===H.height)return void((s+=1)<2?d=setTimeout(g,v):p());var q=w.getBoundingClientRect(),G=H.top-q.top+w.scrollTop-q.height/2+H.height/2+150,z=function(){var n,t,i,o,r;if(!a){p();var l=V instanceof Element?window.getComputedStyle(V).color:"";M&&(M.style.transition="box-shadow 300ms ease-in-out",M.style.boxShadow="0 0 10px ".concat(l)),k&&(k.style.transition="box-shadow 300ms ease-in-out",k.style.boxShadow="0 0 10px ".concat(l)),setTimeout(function(){M&&(M.style.boxShadow=""),k&&(k.style.boxShadow="")},2e3);var u=(null===(t=null===(n=x.evaluationResult)||void 0===n?void 0:n.deviations)||void 0===t?void 0:t[c])||x,s=(null===(i=x.evaluationResult)||void 0===i?void 0:i.evaluation_outputs)||x.evaluation_outputs;if(!(!!M&&!!k)){var d=L?(null===(o=st.current[F])||void 0===o?void 0:o.current)||k:(null===(r=at.current[F])||void 0===r?void 0:r.current)||M;return Ii(d,function(){Nn({open:!0,anchorEl:d,displayImpact:se.displayImpact,summary:e.__assign(e.__assign({},u),{evaluation_outputs:s})})}),void(null==de||de())}mi(P,!1,{toggleIfSame:!1,sourceSide:"left",onReady:function(){var n,t,i=L?(null===(n=st.current[F])||void 0===n?void 0:n.current)||k:(null===(t=at.current[F])||void 0===t?void 0:t.current)||M;Ii(i,function(){Nn({open:!0,anchorEl:i,displayImpact:null==se?void 0:se.displayImpact,summary:e.__assign({},u)})})}})}};Math.abs(w.scrollTop-G)<=2?z():(bn.current=G,Sn.current=z,w.scrollTo({top:G,behavior:"smooth"}),d&&clearTimeout(d),d=setTimeout(function(){if(Sn.current){bn.current=null;var e=Sn.current;Sn.current=null,e()}},800))}else(s+=1)<2?d=setTimeout(g,v):p()}else(s+=1)<2?d=setTimeout(g,v):p()}else(s+=1)<2?d=setTimeout(g,v):p()}};return d=setTimeout(g,v),function(){a=!0,d&&clearTimeout(d)}}}},[se,Qn,Xn,$n,xe,Dt,jt,mi,Nn,Ht]);var Di=function(e){var t=e.section,i=e.keyPath,o=e.depth,r=void 0===o?0:o,l=e.columnKey,u=void 0===l?"left":l,c=e.parentNodeId,a=void 0===c?"":c,s=e.sectionOffset;return n.jsx(y.default,{section:t,keyPath:i,depth:r,columnKey:u,parentNodeId:a,expandedSubSections:wt,setExpandedSubSections:Nt,maintainRelativeOrder:xe||!1,proposedSections:Xn,existingSections:$n,treeData:Z,deviationNumberRegistry:Zn,connectedSections:ze,activeSideBySideSection:Ve,resolvedMarkdownStyles:vn,getSubSectionRef:ht,getSubSectionCompareStyle:ii,getBadgeRef:xt,openMoreFunctionsPopup:Mt,openSummaryPopup:Ei,showDeviationBadges:_e,resetSideBySide:Et,setConnectedSections:We,setConnectedLines:Ue,cachedConnectedPositions:tn,isProposingFix:fe,proposingFixNodeId:ge,isRedlineFlow:pe,sectionOffset:s})};return n.jsxs(i.Box,e.__assign({ref:gn,sx:e.__assign(e.__assign({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},xe?{}:{overflow:"visible"}),{position:"relative"})},{children:[ye&&n.jsx(i.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,{})})),wn.open&&n.jsx(b.default,{open:wn.open,anchorEl:wn.anchorEl,containerEl:zt.current,clipTopEl:Yt.current,scrollContainerEl:fn.current,onClose:Ri,summary:wn.summary,displayImpact:wn.displayImpact}),n.jsx(d.default,{open:Tn.open,anchorEl:Tn.anchorEl,sectionTitle:Tn.sectionTitle,referenceSectionTitle:Tn.refSectionTitle,onClose:kn,onOpenCognitiveCompare:kt,onOpenSideBySide:_i,onConnect:Lt,isConnected:yi,isOrphan:Tn.isOrphan}),In.open&&n.jsx(s.default,{open:In.open,popupRef:Fn,position:Cn,popupConfig:ue,onClose:function(){Dn(null),En(function(n){return e.__assign(e.__assign({},n),{open:!1})}),Pn(null)},markdownStyles:ie,sectionTitle:In.sectionTitle,referenceSectionTitle:In.refSectionTitle,cognitiveData:In.cognitiveData,anchorEl:In.anchorEl,sectionAnchorEl:In.sectionAnchorEl,scrollContainerEl:fn.current,badgeStyle:In.badgeStyle,docData:In.docData,deviationData:In.deviationData,isLoading:In.isLoading}),n.jsx(i.Snackbar,e.__assign({open:!!Te,autoHideDuration:8e3,onClose:function(){return Be(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(i.Alert,e.__assign({onClose:function(){return Be(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:Te}))})),n.jsx(_.default,{componentHeaderText:Q,displayConfig:le,maintainRelativeOrder:xe,onCollapseAll:ri,showCollapseAll:li,onToggleView:function(e){be(!0),setTimeout(function(){me(!e),Et(),jn(),We(new Set),Ue([]),tn.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){be(!1)},600)})})},50)}}),n.jsx(i.Box,e.__assign({ref:fn,onScroll:fi,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:xe?"hidden":"auto",borderTop:_t&&Rt?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(i.Box,e.__assign({sx:e.__assign({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},xe?{flex:1,minHeight:0}:{})},{children:n.jsxs(i.Box,e.__assign({ref:Gt,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},xe?{flex:1,overflow:"visible"}:{})},{children:[n.jsxs("svg",e.__assign({ref:Xe,style:{position:"absolute",top:0,left:0,width:sn.width||"100%",height:sn.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",opacity:Me?0:1,transition:"opacity 0.15s ease-in-out"}},{children:[Zt&&n.jsx("g",{children:n.jsx("line",{x1:Zt.x1,y1:Zt.y,x2:Zt.x2,y2:Zt.y,stroke:At.badgeBorder,strokeWidth:"1.5"})}),$t.map(function(t){var l,c,s,d,v,g,p,h=t.x1+.5*(t.x2-t.x1),x=(t.y1+t.y2)/2;if("Not Defined"===t.style.label&&!t.hasCognitive)return null;if(t.isSubSection?De&&Ve===t.subSectionKeyPath&&je:De&&Ve===t.sectionIdx&&je)return null;if(!xe){var m=t.isSubSection?u.getBentArrowPath(t.x1,t.y1,t.x2,t.y2):"M ".concat(t.x1," ").concat(t.y1," L ").concat(t.x2," ").concat(t.y2),_=Xn[t.sectionIdx]||{title:"",content:""},R=$n[null!==(l=t.targetRightIdx)&&void 0!==l?l:t.sectionIdx]||{title:"",content:""};if(console.log("Base and Ref Sections for Badge:",_,R),t.isSubSection&&t.subSectionKeyPath){var y=t.subSectionKeyPath.includes(u.DEVIATION_BADGE_SEPARATOR)?t.subSectionKeyPath.split(u.DEVIATION_BADGE_SEPARATOR):[],b=y[2]||t.subSectionKeyPath,S=y[3]||b,A=b.split("-").map(Number),I=S.split("-").map(Number),E=null,T=null;A.length>0&&(E=Xn[A[0]]),I.length>0&&(T=$n[I[0]]);var B=(null==E?void 0:E.title)||"",C=(null==T?void 0:T.title)||"";console.log("Root Parent Titles:",B,C);for(var D=1;D<A.length;D++)(null==E?void 0:E.subsections)&&(E=E.subsections[A[D]]);for(D=1;D<I.length;D++)(null==T?void 0:T.subsections)&&(T=T.subsections[I[D]]);E&&(_=e.__assign(e.__assign({},E),{title:B||E.title})),console.log("Base Section for Subsection Badge:",_),T&&(R=e.__assign(e.__assign({},T),{title:C||T.title})),console.log("Ref Section for Subsection Badge:",R)}var O=!(null===(c=_.cognitiveData)||void 0===c?void 0:c.isMissingRationale)||Boolean(null===(d=null===(s=_.cognitiveData)||void 0===s?void 0:s.decisioning)||void 0===d?void 0:d.length),w=(null===(p=null===(g=null===(v=_.evaluationResult)||void 0===v?void 0:v.cognitive_decisioning)||void 0===g?void 0:g.decisioning_factors)||void 0===p?void 0:p.length)||!1,N=O||w;return n.jsxs("g",{children:[n.jsx("path",{d:m,fill:"none",stroke:t.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),n.jsx("foreignObject",e.__assign({x:h-100,y:x-14,width:"200",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:n.jsx(i.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:n.jsxs(i.Box,e.__assign({onClick:function(e){e.stopPropagation(),N&&(In.open&&On===t.id?Mn():(Pn(t.id),Ft(Pt(e.currentTarget,_,R,t.sectionIdx,t.style))))},sx:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:t.style.badgeBg,color:t.style.badgeText,border:"1px solid ".concat(t.style.badgeBorder),borderRadius:"12px",px:1.5,py:.5,fontWeight:600,textAlign:"center",whiteSpace:"nowrap",cursor:N?"pointer":"default"}},{children:[t.style.badgeText===a.DEFAULT_DEVIAION_COLOR&&null==t.style.label?n.jsx(f.default,{color:t.style.badgeText}):0===t.style.label?"Same":t.style.label,n.jsx(i.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&&n.jsx(o.ChevronDown,{size:11,style:{transform:In.open&&On===t.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},t.id)}return null}),n.jsx(S.default,{connectedLines:Ye,pathRefs:nn})]})),n.jsxs(i.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)"},xe?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(i.Box,e.__assign({ref:Yt,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(i.Tooltip,e.__assign({title:zn,placement:"top"},{children:n.jsx(i.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:zn}))}))})),n.jsxs(i.Box,e.__assign({ref:Rn,onScroll:fi,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},xe?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-160px",pr:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:mn,style:{width:"100%",height:"0px",flexShrink:0}}),nt&&Xn.map(function(t,r){var l,c,a=!t.title&&!t.content;if(xe&&a)return null;var s=t,d=ti(r,"left"),v=xe?!(null===(l=s.refIndexes)||void 0===l?void 0:l.length)||s.selfIndex<0:!$n[r],g=ze.has(r),p=u.extractDeviationScore(s.evaluationResult,null==d?void 0:d.deviationLabel),h=it.leftNums.get(s.id);return n.jsx(i.Box,e.__assign({ref:pt(r),sx:{mb:1,width:"100%"}},{children:n.jsxs(i.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[n.jsx(i.Box,e.__assign({ref:ut.current[r],sx:e.__assign({width:"100%",display:"flex",flexDirection:"column",minWidth:0},g&&{borderRadius:"6px",outline:"2px solid ".concat((null==d?void 0:d.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:n.jsx(R.default,{section:t,idx:r,columnKey:"left",colRef:pt("left-accordion-".concat(r)),mb:0,treeData:Z,proposedSections:Xn,existingSections:$n,deviationNumberRegistry:Zn,getSectionCompareStyle:ti,getBadgeRef:xt,connectedSections:ze,openMoreFunctionsPopup:Mt,openSummaryPopup:Ei,deviationNodeIdToView:null==se?void 0:se.id,deviationTargetParentId:Ti,parentNodeId:(null===(c=null==Z?void 0:Z.input_index_map)||void 0===c?void 0:c[0])||"",isExpanded:xe?!!Dt["left-".concat(r)]:!!Dt[String(r)],onToggle:function(){Ri(),jt(r,"left")},navigation:t.id?Si[t.id]:null,showOpenNodeRef:Ai,resolvedMarkdownStyles:vn,maintainRelativeOrder:xe,showDeviationBadges:_e,renderSubSections:Di,isProposingFix:fe,proposingFixNodeId:ge,isRedlineFlow:pe,collisionKey:"".concat(De?"1":"0","-").concat(String(null!=Ve?Ve:""))})})),xe&&d&&n.jsxs(i.Box,e.__assign({ref:at.current[r],onClick:function(e){var n,t,i,o=le.enableDeviationSchemaBackwardCompatibility?null!==(n=s.evaluationResult)&&void 0!==n?n:null:null!==(i=null===(t=s.evaluationResult)||void 0===t?void 0:t[0])&&void 0!==i?i:null;Ei(e,String(r),v,o)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:d.badgeBg,color:d.badgeText,border:"1px solid ".concat(d.badgeBorder),borderRadius:"12px",px:1.2,py:.3,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[n.jsxs(i.Box,e.__assign({component:"span",onClick:function(e){var n,t,i;e.stopPropagation();var o=le.enableDeviationSchemaBackwardCompatibility?null!==(n=s.evaluationResult)&&void 0!==n?n:null:null!==(i=null===(t=s.evaluationResult)||void 0===t?void 0:t[0])&&void 0!==i?i:null;Ei(e,String(r),v,o)},sx:{display:"inline-flex",alignItems:"center",gap:"4px",px:.2,cursor:v?"default":"pointer",borderRight:"1px solid ".concat(d.badgeBorder),"&:hover":v?{}:{bgColor:"".concat(d.badgeBorder,"22")}}},{children:[null!=h&&n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(d.badgeBorder)}},{children:h})),n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",px:.25}},{children:!le.isLoading||null!=s.evaluationResult&&null!=s.evaluationResult?"N/A"===p||"NA"===p?"N/A":0==p||null==p?"Same":"".concat(p):n.jsx(f.default,{color:d.badgeText})}))]})),n.jsx(i.Box,e.__assign({component:"span",onClick:function(e){e.stopPropagation();var n=xe?$n.find(function(e){var n;return null===(n=s.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""}:$n[r]||{title:"",content:""};Mt(e,t,v,n,r,d)},sx:{display:"inline-flex",alignItems:"center",px:.2,cursor:"pointer","&:hover":{bgcolor:"".concat(d.badgeBorder,"22")}}},{children:n.jsx(o.EllipsisVertical,{size:11,color:d.badgeText})}))]}))]}))}),"left-row-".concat(r))}),n.jsx("div",{ref:_n,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),n.jsx(i.Box,e.__assign({ref:zt,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:n.jsx(i.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:n.jsxs(i.Box,e.__assign({onClick:function(n){n.stopPropagation(),In.open&&On===yt?Mn():(Pn(yt),Ft(Pt(n.currentTarget,{title:"",content:"",evaluationResult:bt,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,yt,!0,e.__assign(e.__assign({},At),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:At.badgeBg,color:At.badgeText,border:"1px solid ".concat(At.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=St?St:n.jsx(f.default,{}),n.jsx(i.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:In.open&&On===yt?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),n.jsxs(i.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},xe?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[Ae&&n.jsx(l.default,{sections:11}),n.jsx(i.Box,e.__assign({ref:Ut,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"40px",display:"flex",alignItems:"center",overflowX:"hidden"}},{children:n.jsx(i.Tooltip,e.__assign({title:Wn,placement:"top"},{children:n.jsx(i.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:Wn}))}))})),n.jsxs(i.Box,e.__assign({ref:pn,onScroll:fi,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},xe?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-150px",pl:"165px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:hn,style:{width:"100%",height:"0px",flexShrink:0}}),nt&&$n.map(function(t,r){var l,u,c=t,a=!1,s=null,d=-1;if(xe){d=Xn.findIndex(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(c.selfIndex))&&e.selfIndex>=0});var v=Xn.findIndex(function(e,n){var t;return ze.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(c.selfIndex))});(a=-1!==v)&&(s=ti(v,"left"))}else(a=ze.has(r))&&(s=ti(r,"right"));var g=xe&&-1!==d?ti(d,"left"):ti(r,"right"),p=xe?-1!==d||!(null===(l=c.refIndexes)||void 0===l?void 0:l.length)&&Xn.some(function(e){return e.id&&e.id===c.id}):Boolean(Xn[r]),h=xe?c.selfIndex<0||!p:!Xn[r],x=it.rightNums.get(c.id);return n.jsx(i.Box,e.__assign({ref:dt.current[r],sx:{mb:1,width:"100%"}},{children:n.jsxs(i.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[n.jsx(i.Box,e.__assign({ref:ct.current[r],sx:e.__assign({width:"100%",display:"flex"},a&&s&&{borderRadius:"6px",outline:"2px solid ".concat(s.badgeBorder),outlineOffset:"1px"})},{children:n.jsx(R.default,{section:t,idx:r,columnKey:"right",colRef:pt("right-accordion-".concat(r)),mb:0,parentNodeId:(null===(u=null==Z?void 0:Z.input_index_map)||void 0===u?void 0:u[1])||"",isExpanded:xe?!!Dt["right-".concat(r)]:!!Dt[String(r)],treeData:Z,proposedSections:Xn,existingSections:$n,deviationNumberRegistry:Zn,getBadgeRef:xt,getSectionCompareStyle:ti,connectedSections:ze,openMoreFunctionsPopup:Mt,openSummaryPopup:Ei,deviationNodeIdToView:null==se?void 0:se.id,deviationTargetParentId:Ti,onToggle:function(){Ri(),jt(r,"right")},navigation:t.id?Si[t.id]:null,showOpenNodeRef:Ai,resolvedMarkdownStyles:vn,maintainRelativeOrder:xe,showDeviationBadges:_e,renderSubSections:Di,isProposingFix:fe,proposingFixNodeId:ge,isRedlineFlow:pe,collisionKey:"".concat(De?"1":"0","-").concat(String(null!=Ve?Ve:""))})})),xe&&g&&n.jsx(i.Box,e.__assign({ref:st.current[r],"data-section-id":c.id,onClick:function(e){var n,t,i;if(h){var o=le.enableDeviationSchemaBackwardCompatibility?null!==(n=c.evaluationResult)&&void 0!==n?n:null:null!==(i=null===(t=c.evaluationResult)||void 0===t?void 0:t[0])&&void 0!==i?i:null;Ei(e,String(r),h,o)}},sx:{position:"absolute",top:"18px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:h?"4px":"0px",fontSize:"11px",bgcolor:g.badgeBg,color:g.badgeText,border:"1px solid ".concat(g.badgeBorder),borderRadius:h?"12px":"10px",px:h?1.2:1,py:.3,fontWeight:h?600:700,cursor:h?"pointer":"default",whiteSpace:"nowrap",zIndex:20,boxShadow:h?"0 1px 3px rgba(0,0,0,0.07)":"none"}},{children:h?n.jsxs(n.Fragment,{children:[n.jsxs(i.Box,e.__assign({component:"span",onClick:function(e){var n,t,i;e.stopPropagation();var o=le.enableDeviationSchemaBackwardCompatibility?null!==(n=c.evaluationResult)&&void 0!==n?n:null:null!==(i=null===(t=c.evaluationResult)||void 0===t?void 0:t[0])&&void 0!==i?i:null;Ei(e,String(r),h,o)},sx:{display:"inline-flex",alignItems:"center",gap:"4px",px:.2,cursor:"pointer",borderRight:"1px solid ".concat(g.badgeBorder),"&:hover":{bgcolor:"".concat(g.badgeBorder,"22")}}},{children:[null!=x&&n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(g.badgeBorder)}},{children:x})),n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",px:.25}},{children:!le.isLoading||null!=c.evaluationResult&&void 0!==c.evaluationResult?g.label?"".concat(g.label):"100% Deviation":n.jsx(f.default,{color:g.badgeText})}))]})),n.jsx(i.Box,e.__assign({component:"span",onClick:function(e){e.stopPropagation();var n=xe?Xn.find(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(c.selfIndex)})||{title:"",content:""}:Xn[r]||{title:"",content:""};Mt(e,n,h,c,r,g)},sx:{display:"inline-flex",alignItems:"center",px:.2,cursor:"pointer","&:hover":{bgcolor:"".concat(g.badgeBorder,"22")}}},{children:n.jsx(o.EllipsisVertical,{size:11,color:g.badgeText})}))]}):null!=x?x:""}))]}))}),"right-row-".concat(r))}),n.jsx("div",{ref:xn,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"),t=require("react"),i=require("@mui/material"),o=require("lucide-react"),l=require("../../assests/svg/ButtonCognitiveIcon.js"),r=require("./OverlayComponent.js"),u=require("./CognitiveComparehelpers.js"),c=require("./CognitiveCompareConfig.js"),a=require("./CognitiveCompareConstants.js"),s=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"),x=require("./hooks/useAccordionState.js"),m=require("./hooks/useDeviationNavigation.js"),_=require("./components/CompareHeader.js"),R=require("./components/SectionAccordion.js"),y=require("./components/SubSectionAccordion.js"),b=require("./components/CognitiveSummaryPopup.js"),S=require("./components/connectedLines.js");exports.SHARED_MARKDOWN_STYLES=c.SHARED_MARKDOWN_STYLES,exports.default=function(A){var I,E,T,B,C,D,O,w,N,j,P,F,M,k,L,V,H,q,G,z,W,K,Y,U,X,$,J=A.componentHeaderText,Q=void 0===J?a.DEFAULT_COMPONENT_HEADER_TEXT:J,Z=A.treeData,ee=A.comparisonConfig,ne=A.leftColumnTitleText,te=A.rightColumnTitleText,ie=A.markdownStyles,oe=A.resetTrigger,le=A.displayConfig,re=void 0===le?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1}:le,ue=A.popupConfig,ce=A.deviationData,ae=void 0===ce?{}:ce,se=A.deviationNodeIdToView,de=A.resetDeviationNodeId,ve=A.isProposingFix,fe=void 0!==ve&&ve,ge=A.proposingFixNodeId,pe=A.isRedlineFlow,he=t.useState(re.maintainRelativeOrder),xe=he[0],me=he[1],_e=!!xe||!!(null==re?void 0:re.showDeviationBadges),Re=t.useState(!1),ye=Re[0],be=Re[1],Se=t.useState(!1),Ae=Se[0],Ie=Se[1],Ee=t.useState(null),Te=Ee[0],Be=Ee[1],Ce=t.useState(!1),De=Ce[0],Oe=Ce[1],we=t.useState(null===(E=null!==(I=null==Z?void 0:Z.newEvaluationResult)&&void 0!==I?I:null==re?void 0:re.enableDeviationSchemaBackwardCompatibility)||void 0===E||E)[0],Ne=t.useState(!1),je=Ne[0],Pe=Ne[1],Fe=t.useState(!1),Me=Fe[0],ke=Fe[1],Le=t.useState(null),Ve=Le[0],He=Le[1],qe=t.useRef(!1),Ge=t.useState(new Set),ze=Ge[0],We=Ge[1],Ke=t.useState([]),Ye=Ke[0],Ue=Ke[1],Xe=t.useRef(null),$e=t.useRef(null),Je=t.useRef(null),Qe=t.useRef(new Set),Ze=t.useRef(!1),en=t.useRef(null),nn=t.useRef({}),tn=t.useRef([]),on=t.useRef(!1),ln=t.useRef(!1),rn=t.useRef(null),un=t.useRef(function(){}),cn=t.useMemo(function(){return(null==Z?void 0:Z.cognitive_decisioning)||{}},[Z]),an=t.useState({width:0,height:0}),sn=an[0],dn=an[1],vn=t.useMemo(function(){return e.__assign(e.__assign({},c.SHARED_MARKDOWN_STYLES),ie)},[ie]),fn=t.useRef(null),gn=t.useRef(null),pn=t.useRef(null),hn=t.useRef(null),xn=t.useRef(null),mn=t.useRef(null),_n=t.useRef(null),Rn=t.useRef(null),yn=t.useRef(!1),bn=t.useRef(null),Sn=t.useRef(null),An=p.useComparePopups(fn),In=An.cognitivePopup,En=An.setCognitivePopup,Tn=An.moreFunctions,Bn=An.setMoreFunctions,Cn=An.position,Dn=An.setPosition,On=An.activeBadgeId,wn=An.summaryPopup,Nn=An.setSummaryPopup,jn=An.closeSummaryPopup,Pn=An.setActiveBadgeId,Fn=An.popupRef,Mn=An.closeCognitivePopup,kn=An.closeMoreFunctionsPopup,Ln=t.useMemo(function(){var e,n,t,i,o,l,r;return{fields:null!==(e=null==ee?void 0:ee.fields)&&void 0!==e?e:c.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(t=null===(n=null==ee?void 0:ee.thresholds)||void 0===n?void 0:n.high)&&void 0!==t?t:c.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(o=null===(i=null==ee?void 0:ee.thresholds)||void 0===i?void 0:i.medium)&&void 0!==o?o:c.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(r=null===(l=null==ee?void 0:ee.thresholds)||void 0===l?void 0:l.exact)&&void 0!==r?r:c.DEFAULT_COMPARISON_CONFIG.thresholds.exact}}},[ee]),Vn=t.useState(null),Hn=Vn[0];Vn[1];var qn=null===(C=null===(T=null==Z?void 0:Z.documents)||void 0===T?void 0:T[null===(B=null==Z?void 0:Z.input_index_map)||void 0===B?void 0:B[0]])||void 0===C?void 0:C.title,Gn=null===(w=null===(D=null==Z?void 0:Z.documents)||void 0===D?void 0:D[null===(O=null==Z?void 0:Z.input_index_map)||void 0===O?void 0:O[1]])||void 0===w?void 0:w.title,zn=u.safeStringify(ne||qn||"Uploaded Contract"),Wn=u.safeStringify(te||Gn||"Reference Template"),Kn=g.useCognitiveTreeData(Z,xe,ae,Ln,we),Yn=Kn.activeProposed,Un=Kn.existingRule,Xn=Kn.proposedSections,$n=Kn.existingSections,Jn=Kn.visibleFields,Qn=Kn.parentDeviationRecord,Zn=Kn.deviationNumberRegistry,et=Kn.parseError;t.useEffect(function(){et&&Be("Failed to load comparison: ".concat(et))},[et]);var nt=Xn.length>0||$n.length>0,tt=t.useMemo(function(){if(!pe)return"off";var e=0,n=0,t=function(i){Array.isArray(i)&&i.forEach(function(i){var o,l=(null==i?void 0:i.content)||"";u.hasMeaningfulRedlineTags(l)&&(e+=1,n+=String(l).length),(null===(o=null==i?void 0:i.subsections)||void 0===o?void 0:o.length)&&t(i.subsections)})};return t(Xn),t($n),"".concat(e,":").concat(n)},[pe,Xn,$n]);t.useEffect(function(){pe&&"off"!==tt&&"0:0"!==tt&&($e.current=null,tn.current=[],requestAnimationFrame(function(){var e;null===(e=un.current)||void 0===e||e.call(un)}))},[pe,tt]);var it=t.useMemo(function(){var e=new Map,n=new Map,t=1;if(xe)Xn.forEach(function(n){!n.title&&!n.content||n.id&&e.set(n.id,t++)}),$n.forEach(function(i){if(i.id){var o=Xn.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(i.selfIndex)});if(o.length>0){var l=o.map(function(n){return e.get(n.id)}).filter(Boolean);n.set(i.id,l.join(", "))}else n.set(i.id,String(t++))}});else for(var i=Math.max(Xn.length,$n.length),o=0;o<i;o++){var l=Xn[o],r=$n[o];l?(e.set(l.id,t),r&&n.set(r.id,String(t)),t++):r&&n.set(r.id,String(t++))}return{leftNums:e,rightNums:n}},[Xn,$n,xe]),ot=h.useSectionRefs(Jn.map(function(e){return e.key}),Math.max(Xn.length,$n.length)),lt=ot.leftRefs,rt=ot.rightRefs,ut=ot.sectionLeftRefs,ct=ot.sectionRightRefs,at=ot.lhsBadgeRefs,st=ot.rhsBadgeRefs,dt=ot.sectionRightRowRefs,vt=ot.subSectionLeftRefs,ft=ot.subSectionRightRefs,gt=ot.sectionRowRefs,pt=ot.getSectionRowRef,ht=ot.getSubSectionRef,xt=ot.getBadgeRef,mt=Un.analysis,_t=u.safeStringify(null===(j=null===(N=null==mt?void 0:mt.rule_difference_comparison)||void 0===N?void 0:N.summary)||void 0===j?void 0:j.overall_summary),Rt=!!_t.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),yt=null!==(P=null==Z?void 0:Z.base_root_id)&&void 0!==P?P:"-1";null==Z||Z[yt];var bt=we?null!==(Y=null!==(z=ae&&(null===(G=null==ae?void 0:ae[yt])||void 0===G?void 0:G.evaluation_result))&&void 0!==z?z:null===(K=null===(W=null==Z?void 0:Z.nodes)||void 0===W?void 0:W[yt])||void 0===K?void 0:K.evaluation_result)&&void 0!==Y?Y:null:null!==(q=null!==(k=ae&&(null===(M=null===(F=null==ae?void 0:ae[yt])||void 0===F?void 0:F.evaluation_result)||void 0===M?void 0:M[0]))&&void 0!==k?k:null===(H=null===(V=null===(L=null==Z?void 0:Z.nodes)||void 0===L?void 0:L[yt])||void 0===V?void 0:V.evaluation_result)||void 0===H?void 0:H[0])&&void 0!==q?q:null,St=u.extractDeviationScore(bt),At=u.generateColorPalette(null!==($=null===(X=null===(U=null==bt?void 0:bt.evaluation_outputs)||void 0===U?void 0:U.metadata)||void 0===X?void 0:X.label_color)&&void 0!==$?$:""),It=function(){Qe.current.forEach(function(e){u.resetClauseHighlight(e)}),Qe.current.clear()},Et=t.useCallback(function(){var e,n,t,i,o,l;It(),Oe(!1),ln.current=!1,$e.current=null;var r=rn.current,c=Wt.current;if(null!==r)if("string"==typeof r&&r.includes(u.DEVIATION_BADGE_SEPARATOR)){var a=r.split(u.DEVIATION_BADGE_SEPARATOR);(s=(null===(e=vt.current[a[2]])||void 0===e?void 0:e.current)||(null===(n=ut.current[Number(a[2])])||void 0===n?void 0:n.current))&&(s.style.paddingTop="0px")}else{var s;(s=null===(t=ut.current[r])||void 0===t?void 0:t.current)&&(s.style.paddingTop="0px")}if(null!==c)if("string"==typeof c&&c.includes(u.DEVIATION_BADGE_SEPARATOR)){a=c.split(u.DEVIATION_BADGE_SEPARATOR);(d=(null===(i=ft.current[a[3]])||void 0===i?void 0:i.current)||(null===(o=ct.current[Number(a[3])])||void 0===o?void 0:o.current))&&(d.style.paddingTop="0px")}else{var d;(d=null===(l=ct.current[c])||void 0===l?void 0:l.current)&&(d.style.paddingTop="0px")}He(null),rn.current=null,Wt.current=null,Pe(!1),Ie(!1),hn.current&&(hn.current.style.height="0px"),xn.current&&(xn.current.style.height="0px"),mn.current&&(mn.current.style.height="0px"),_n.current&&(_n.current.style.height="0px")},[]),Tt=t.useCallback(function(){It(),Et(),We(new Set),Ue([]),tn.current=[],Jt([]),ei(null),Nn(a.EMPTY_SUMMARY_POPUP_STATE),Mn(),requestAnimationFrame(function(){var e;null===(e=un.current)||void 0===e||e.call(un)})},[]),Bt=t.useRef(Tt);t.useEffect(function(){Bt.current=Tt},[Tt]),t.useEffect(function(){oe&&Bt.current()},[oe]);var Ct=x.useAccordionState({maintainRelativeOrder:!!xe,proposedSections:Xn,existingSections:$n,activeSideBySideSection:Ve,connectedSections:ze,resetSideBySide:Et,setConnectedSections:We,setConnectedLines:Ue,cachedConnectedPositions:tn,svgContainerRef:Xe,isAnimatingRef:Ze,animationTimerRef:en,calculateLinesRef:un,sectionLeftRefs:ut,sectionRightRefs:ct,subSectionLeftRefs:vt,subSectionRightRefs:ft}),Dt=Ct.expandedSections,Ot=Ct.setExpandedSections,wt=Ct.expandedSubSections,Nt=Ct.setExpandedSubSections,jt=Ct.toggleSection,Pt=t.useCallback(function(n,t,i,o,l,r,c){var a,s,d,v=u.safeStringify(null==t?void 0:t.id)||u.safeStringify(null==i?void 0:i.id)||"",f=(v?cn[v]:null)||(null==t?void 0:t.cognitiveData)||(null==i?void 0:i.cognitiveData)||{section_id:v,decisioning:[],gap:[],relevance_score:0},g=null!==(s=null===(a=gt.current[o])||void 0===a?void 0:a.current)&&void 0!==s?s:null;return{isLoading:null!==(d=null==re?void 0:re.isLoading)&&void 0!==d&&d,open:!0,sectionTitle:(null==t?void 0:t.title)?null==t?void 0:t.title:"No Counterpart",refSectionTitle:(null==i?void 0:i.title)?null==i?void 0:i.title:"No Counterpart",cognitiveData:f,anchorEl:n,sectionAnchorEl:g,badgeStyle:r||null,sectionIdx:o,docData:{documents:null==Z?void 0:Z.documents,input_index_map:null==Z?void 0:Z.input_index_map},deviationData:function(){var n,l,r=(null==t?void 0:t.evaluationResult)||(null==i?void 0:i.evaluationResult)||null,c=function(n){var t=function(e){if(!e||"object"!=typeof e)return null;var n=null==e?void 0:e.deviation_entries;if(n&&"object"==typeof n){var t=Object.keys(n).sort(function(e,n){return Number(e)-Number(n)})[0];if(t&&n[t])return n[t]}var i=Object.keys(e).filter(function(e){return/^\d+$/.test(e)}).sort(function(e,n){return Number(e)-Number(n)});if(i.length&&e[i[0]])return e[i[0]];var o=null==e?void 0:e.deviations;if(o&&"object"==typeof o){var l=Object.keys(o).sort(function(e,n){return Number(e)-Number(n)})[0];if(l&&o[l])return o[l]}return null}(n);return t?e.__assign(e.__assign({},n),{deviation_summary:(null==n?void 0:n.deviation_summary)||(null==t?void 0:t.deviation_summary),deviation_title:(null==n?void 0:n.deviation_title)||(null==t?void 0:t.deviation_title),deviation_impact:(null==n?void 0:n.deviation_impact)||(null==t?void 0:t.deviation_impact),deviation_explanation:(null==n?void 0:n.deviation_explanation)||(null==t?void 0:t.deviation_explanation),evaluation_outputs:(null==n?void 0:n.evaluation_outputs)||(null==t?void 0:t.evaluation_outputs),cognitive_decisioning:(null==n?void 0:n.cognitive_decisioning)||(null==t?void 0:t.cognitive_decisioning)}):n};if(!("string"==typeof o&&o.includes(u.DEVIATION_BADGE_SEPARATOR)))return c(r);var a=o.split(u.DEVIATION_BADGE_SEPARATOR)[1];if(!a)return r;var s=(null==t?void 0:t.evaluationResult)||(null==i?void 0:i.evaluationResult)||{},d=(null===(n=null==s?void 0:s.deviation_entries)||void 0===n?void 0:n[a])||(null===(l=null==s?void 0:s.deviations)||void 0===l?void 0:l[a])||null;return d?e.__assign(e.__assign(e.__assign({},s),d),{deviation_summary:(null==d?void 0:d.deviation_summary)||(null==s?void 0:s.deviation_summary),deviation_title:(null==d?void 0:d.deviation_title)||(null==s?void 0:s.deviation_title),deviation_impact:(null==d?void 0:d.deviation_impact)||(null==s?void 0:s.deviation_impact),deviation_explanation:(null==d?void 0:d.deviation_explanation)||(null==s?void 0:s.deviation_explanation),evaluation_outputs:(null==d?void 0:d.evaluation_outputs)||(null==s?void 0:s.evaluation_outputs),cognitive_decisioning:(null==d?void 0:d.cognitive_decisioning)||(null==s?void 0:s.cognitive_decisioning)}):c(r)}(),isOrphan:!!l}},[cn,Z]),Ft=t.useCallback(function(e){kn(),Dn(null),En(e)},[kn]),Mt=function(e,n,t,i,o,l){var r;if(e.stopPropagation(),Tn.open&&Tn.sectionIdx===o)kn();else{var c=e.currentTarget,a="left";(null===(r=pn.current)||void 0===r?void 0:r.contains(c))&&(a="right");It(),ln.current&&Et(),We(new Set),Ue([]),tn.current=[],Mn(),wn.open?Ri():jn(),requestAnimationFrame(function(){var e=function(){var e,n,t,i;if("string"==typeof o&&o.includes(u.DEVIATION_BADGE_SEPARATOR)){var l=o.split(u.DEVIATION_BADGE_SEPARATOR),r="".concat(l[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(l[1]);return"right"===a?null===(e=st.current[r])||void 0===e?void 0:e.current:null===(n=at.current[r])||void 0===n?void 0:n.current}return"right"===a?null===(t=st.current[o])||void 0===t?void 0:t.current:null===(i=at.current[o])||void 0===i?void 0:i.current}()||c;Bn(Pt(e,n,i,o,t,l))})}},kt=t.useCallback(function(){null!==Tn.sectionIdx&&Tn.anchorEl?Ft(e.__assign(e.__assign({},Tn),{open:!0})):kn()},[Tn,kn,Ft]),Lt=t.useCallback(function(){var e=Tn.sectionIdx,n=Tn.isOrphan;kn(),jn(),null!==e&&(n?Be("No counterpart exists to connect to."):(It(),ln.current&&Et(),Ue([]),tn.current=[],We(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){un.current&&un.current()},50)))},[Tn.sectionIdx,Tn.isOrphan,kn,jn,Et]),Vt=t.useCallback(function(){var e=Je.current;if(e){Je.current=null;var n=Xn.findIndex(function(n){return n.id===e}),t=$n.findIndex(function(n){return n.id===e}),i=-1===n?u.findKeyPathByNodeId(Xn,e):null,o=-1===t?u.findKeyPathByNodeId($n,e):null,l=-1!==n?n:i?Number(i.split("-")[0]):-1,r=-1!==t?t:o?Number(o.split("-")[0]):-1,c=function(e,n,t,i){var o,l,r,u;return-1!==e?null!==(l=null===(o=t.current[e])||void 0===o?void 0:o.current)&&void 0!==l?l:null:n&&null!==(u=null===(r=i.current[n])||void 0===r?void 0:r.current)&&void 0!==u?u:null},a=function(e,n,t){void 0===t&&(t=30);var i=0,o=function(){var l=e();l&&0!==l.getBoundingClientRect().height?(Qe.current.add(l),u.scrollAndHighlightClause(l,n)):i++<t&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(xe)-1!==l&&Rn.current&&a(function(){return c(n,i,ut,vt)},Rn.current),-1!==r&&pn.current&&a(function(){return c(t,o,ct,ft)},pn.current);else{var s=fn.current;if(!s)return;a(function(){return-1!==l?c(n,i,ut,vt):c(t,o,ct,ft)},s)}}},[Xn,$n,xe,ut,ct,vt,ft,Rn,pn,fn]),Ht=t.useCallback(function(n){if(n){It(),Et(),We(new Set),Ue([]),tn.current=[],jn(),Mn();var t=Xn.findIndex(function(e){return e.id===n}),i=$n.findIndex(function(e){return e.id===n}),o=-1===t?u.findKeyPathByNodeId(Xn,n):null,l=-1===i?u.findKeyPathByNodeId($n,n):null;if(-1!==t||o||-1!==i||l){var r=-1!==t?t:o?Number(o.split("-")[0]):-1,c=-1!==i?i:l?Number(l.split("-")[0]):-1;Je.current=n,Ot(function(n){var t,i=e.__assign({},n),o=!1;-1!==r&&(i[t=xe?"left-".concat(r):String(r)]||(i[t]=!0,o=!0));-1!==c&&(i[t=xe?"right-".concat(c):String(c)]||(i[t]=!0,o=!0));return o?i:n}),Nt(function(n){var t=e.__assign({},n),i=!1,r=function(e){for(var n=e.split("-"),o=n[0],l=1;l<n.length;l++)o+="-".concat(n[l]),t[o]||(t[o]=!0,i=!0)};return o&&r(o),l&&r(l),i?t:n}),setTimeout(function(){requestAnimationFrame(function(){Je.current===n&&qt.current()})},50)}else console.warn('scrollToAndHighlightClause: nodeId "'.concat(n,'" not found'))}},[Xn,$n,xe,Ot,Nt,Et,jn,Mn]),qt=t.useRef(Vt);t.useEffect(function(){qt.current=Vt},[Vt]);var Gt=t.useRef(null),zt=t.useRef(null),Wt=t.useRef(null),Kt=t.useRef(null),Yt=t.useRef(null),Ut=t.useRef(null),Xt=t.useState([]),$t=Xt[0],Jt=Xt[1];t.useRef(null);var Qt=t.useState(null),Zt=Qt[0],ei=Qt[1];t.useEffect(function(){if(Hn){var e=Ln.fields.find(function(e){return e.analysisKey===Hn||e.key===Hn});if(e){var n=lt.current[e.key]||rt.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[Hn,Ln.fields]);var ni=t.useCallback(function(e){var n,t,i,o,l,r,u,c,a,s=null===(n=null==mt?void 0:mt.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!s||!s[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var d=s[e],v=(null==d?void 0:d.relation)||(null===(i=null===(t=null==d?void 0:d.highlights)||void 0===t?void 0:t.ruleA_spans)||void 0===i?void 0:i.length)||(null===(l=null===(o=null==d?void 0:d.highlights)||void 0===o?void 0:o.ruleB_spans)||void 0===l?void 0:l.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===(r=f.highlights)||void 0===r?void 0:r.ruleA_spans)||[],highlightsB:(null===(u=f.highlights)||void 0===u?void 0:u.ruleB_spans)||[],hasContent:!!v}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(c=d.highlights)||void 0===c?void 0:c.ruleA_spans)||[],highlightsB:(null===(a=d.highlights)||void 0===a?void 0:a.ruleB_spans)||[],hasContent:!!v}},[mt]),ti=t.useCallback(function(n,t){var i,o,l;void 0===t&&(t="left");var r=null,c=null;if("left"===t)if(r=Xn[n],xe&&r){var s=$n.filter(function(e){var n;return null===(n=r.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)});c=s.find(function(e){return e.evaluationResult})||s[0]}else c=$n[n];else if(c=$n[n],xe&&c){var d=Xn.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(c.selfIndex)});r=d.find(function(e){return e.evaluationResult})||d[0]}else r=Xn[n];var v=(null==r?void 0:r.relation)&&"not_defined"!==r.relation,f=(null==c?void 0:c.relation)&&"not_defined"!==c.relation,g=!(!(null==r?void 0:r.cognitiveData)&&!(null==c?void 0:c.cognitiveData));if(!v&&!f&&!g)return e.__assign(e.__assign({},u.generateColorPalette(a.DEFAULT_DEVIAION_COLOR)),{label:"Not Defined"});var p=null!==(o=null!==(i=null==r?void 0:r.evaluationResult)&&void 0!==i?i:null==c?void 0:c.evaluationResult)&&void 0!==o?o:null,h=u.getFirstDeviationOutputValue(p),x=u.getFirstDeviationColor(p);return null!=p?e.__assign(e.__assign({},u.generateColorPalette(x)),{label:null!==(l=h)&&void 0!==l?l:""}):e.__assign(e.__assign({},u.generateColorPalette(x)),{label:null})},[Xn,$n,cn,Ln,xe]),ii=t.useCallback(function(n){for(var t,i,o,l,r,c=n.split("-").map(Number),s=Xn[c[0]],d=$n[c[0]],v=1;v<c.length;v++)(null==s?void 0:s.subsections)&&(s=s.subsections[c[v]]),(null==d?void 0:d.subsections)&&(d=d.subsections[c[v]]);if(!s&&!d)return null;var f=(null==s?void 0:s.relation)&&"not_defined"!==s.relation,g=(null==d?void 0:d.relation)&&"not_defined"!==d.relation,p=u.safeStringify(null==s?void 0:s.id)||u.safeStringify(null==d?void 0:d.id)||"",h=!(!(null==s?void 0:s.cognitiveData)&&!(null==d?void 0:d.cognitiveData));if(!f&&!g&&!h)return e.__assign(e.__assign({},u.generateColorPalette(a.DEFAULT_DEVIAION_COLOR)),{label:"Not Defined"});null!==(i=null!==(t=null==s?void 0:s.cognitiveRelevanceScore)&&void 0!==t?t:null==d?void 0:d.cognitiveRelevanceScore)&&void 0!==i||p&&(null===(o=cn[p])||void 0===o||o.relevance_score);var x=null!==(r=null!==(l=null==s?void 0:s.evaluationResult)&&void 0!==l?l:null==d?void 0:d.evaluationResult)&&void 0!==r?r:null,m=u.getFirstDeviationOutputValue(x),_=u.getFirstDeviationColor(x);return null!=x?e.__assign(e.__assign({},u.generateColorPalette(_)),{label:null!=m?m:""}):e.__assign(e.__assign({},u.generateColorPalette(_)),{label:null})},[Xn,$n,cn,Ln]),oi=t.useCallback(function(n,t){var i,o,l,r,c,s,d,v,f,g,p,h,x,m,_,R,y;if(!n||null==t)return null;var b=null!==(d=null!==(c=null!==(o=null===(i=null==ae?void 0:ae[n])||void 0===i?void 0:i.evaluation_result)&&void 0!==o?o:null===(r=null===(l=null==Z?void 0:Z.nodes)||void 0===l?void 0:l[n])||void 0===r?void 0:r.evaluation_result)&&void 0!==c?c:null===(s=null==Z?void 0:Z[n])||void 0===s?void 0:s.evaluation_result)&&void 0!==d?d:null;if(!b||"object"!=typeof b)return null;var S=null!==(p=null!==(f=null===(v=null==b?void 0:b.deviations)||void 0===v?void 0:v[t])&&void 0!==f?f:null===(g=null==b?void 0:b.deviation_entries)||void 0===g?void 0:g[t])&&void 0!==p?p:null==b?void 0:b[t],A=null!==(y=null!==(m=null===(x=null===(h=null==S?void 0:S.evaluation_outputs)||void 0===h?void 0:h.metadata)||void 0===x?void 0:x.label_color)&&void 0!==m?m:null===(R=null===(_=null==b?void 0:b.evaluation_outputs)||void 0===_?void 0:_.metadata)||void 0===R?void 0:R.label_color)&&void 0!==y?y:a.DEFAULT_DEVIAION_COLOR;return e.__assign(e.__assign({},u.generateColorPalette(A)),{label:null})},[ae,Z]),li=t.useCallback(function(){It(),Ot({}),Nt({}),Et(),We(new Set),Ue([]),tn.current=[],jn(),Mn(),kn(),requestAnimationFrame(function(){un.current&&un.current()})},[Ot,Nt,Et,jn,Mn,kn]),ri=t.useMemo(function(){return Object.values(Dt).some(Boolean)||Object.values(wt).some(Boolean)},[Dt,wt]),ui=t.useCallback(function(){var e,n,t,i,o,l,r,c,a,s,d,v,f,g,p,h,x,m,_,R,y,b,S;if(!yn.current&&!Ze.current){yn.current=!0;try{if(!Gt.current)return;var A=function(e){var n=e.split("-"),t=n[0];if(!Dt[t]&&!1===xe)return!1;if(xe&&!Dt["left-".concat(t)]&&!Dt["right-".concat(t)]&&!Dt[t])return!1;for(var i=t,o=1;o<n.length-1;o++)if(i+="-".concat(n[o]),!wt[i])return!1;return!0},I=Gt.current.getBoundingClientRect();dn({width:I.width,height:I.height});var E=[];if(Jn.forEach(function(e){var n,t,i=e.key,o=null===(n=lt.current[i])||void 0===n?void 0:n.current,l=null===(t=rt.current[i])||void 0===t?void 0:t.current;o&&l&&(o.style.height="auto",l.style.height="auto",o.style.minHeight="0px",l.style.minHeight="0px")}),!Ze.current){for(var T=0;T<Math.max(Xn.length,$n.length);T++){var B=null===(e=ut.current[T])||void 0===e?void 0:e.current,C=null===(n=ct.current[T])||void 0===n?void 0:n.current;B&&(B.style.height="auto",B.style.minHeight="0px"),C&&(C.style.height="auto",C.style.minHeight="0px")}xe||Object.keys(vt.current).forEach(function(e){var n,t;if(A(e)){var i=null===(n=vt.current[e])||void 0===n?void 0:n.current,o=null===(t=ft.current[e])||void 0===t?void 0:t.current;i&&o&&(i.style.height="auto",o.style.height="auto",i.style.minHeight="0px",o.style.minHeight="0px")}})}var D={};Jn.forEach(function(e){var n,t,i=e.key,o=null===(n=lt.current[i])||void 0===n?void 0:n.current,l=null===(t=rt.current[i])||void 0===t?void 0:t.current;if(o&&l){var r=o.getBoundingClientRect(),u=l.getBoundingClientRect();D[i]=Math.max(r.height,u.height)}});var O={left:{},right:{}},w={};if(!Ze.current)if(xe){if(De&&null!==Ve)if("number"==typeof Ve){var N=Ve,j=Xn[N],P=null===(o=ut.current[N])||void 0===o?void 0:o.current;P&&j&&(j.refIndexes||[]).forEach(function(e){var n,t=$n.findIndex(function(n){return n.selfIndex===e}),i=null===(n=ct.current[t])||void 0===n?void 0:n.current;if(i&&(Dt["left-".concat(N)]||Dt["right-".concat(t)])){var o=Math.max(P.getBoundingClientRect().height,i.getBoundingClientRect().height);O.left[N]=Math.max(O.left[N]||0,o),O.right[t]=Math.max(O.right[t]||0,o)}})}else{var F=Ve.split(u.DEVIATION_BADGE_SEPARATOR)[2];if(F){B=null===(l=vt.current[F])||void 0===l?void 0:l.current,C=null===(r=ft.current[F])||void 0===r?void 0:r.current;if(B&&C){M=Math.max(B.getBoundingClientRect().height,C.getBoundingClientRect().height);w[F]=Math.max(w[F]||0,M)}}}}else{Object.keys(vt.current).forEach(function(e){var n,t;if(A(e)){var i=null===(n=vt.current[e])||void 0===n?void 0:n.current,o=null===(t=ft.current[e])||void 0===t?void 0:t.current;if(i&&o&&null!==i.offsetParent&&null!==o.offsetParent){var l=i.getBoundingClientRect(),r=o.getBoundingClientRect(),u=Math.max(l.height,r.height);w[e]=u,i.style.minHeight="".concat(u,"px"),o.style.minHeight="".concat(u,"px")}}});for(T=0;T<Math.min(Xn.length,$n.length);T++){var B=null===(t=ut.current[T])||void 0===t?void 0:t.current,C=null===(i=ct.current[T])||void 0===i?void 0:i.current;if(B&&C){var M=Math.max(B.getBoundingClientRect().height,C.getBoundingClientRect().height);O.left[T]=M,O.right[T]=M}}}if(Jn.forEach(function(e){var n,t,i=e.key,o=null===(n=lt.current[i])||void 0===n?void 0:n.current,l=null===(t=rt.current[i])||void 0===t?void 0:t.current;if(o&&l){var r=D[i];o.style.minHeight="".concat(r,"px"),l.style.minHeight="".concat(r,"px")}}),Ze.current||(Object.entries(O.left).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=ut.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),Object.entries(O.right).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=ct.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),xe||Object.keys(w).forEach(function(e){var n,t,i=null===(n=vt.current[e])||void 0===n?void 0:n.current,o=null===(t=ft.current[e])||void 0===t?void 0:t.current;if(i&&o&&w[e]){var l=w[e];i.style.minHeight="".concat(l,"px"),o.style.minHeight="".concat(l,"px")}})),xe)Xn.forEach(function(e,n){var t;(null===(t=ut.current[n])||void 0===t?void 0:t.current)&&(e.refIndexes||[]).forEach(function(e){var t,i,o,l,r,u,c,a,s,d,v=$n.findIndex(function(n){return n.selfIndex===e});if(-1!==v){var f=null===(t=at.current[n])||void 0===t?void 0:t.current,g=null===(i=st.current[v])||void 0===i?void 0:i.current;if(f&&g){var p=f.getBoundingClientRect(),h=g.getBoundingClientRect(),x=p.right-I.left,m=h.left-I.left,_=p.top+p.height/2-I.top,R=h.top+h.height/2-I.top;if(De&&Ve===n){var y=null!==(l=null===(o=Rn.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==l?l:0,b=null!==(u=null===(r=pn.current)||void 0===r?void 0:r.getBoundingClientRect().top)&&void 0!==u?u:0,S=y+(null!==(a=null===(c=Rn.current)||void 0===c?void 0:c.clientHeight)&&void 0!==a?a:1/0),A=b+(null!==(d=null===(s=pn.current)||void 0===s?void 0:s.clientHeight)&&void 0!==d?d:1/0),T=p.top+p.height/2,B=h.top+h.height/2,C=function(e,n,t){return Math.max(n,Math.min(t,e))};_=C(T,y,S)-I.top,R=C(B,b,A)-I.top}var D=ti(n);D&&E.push({id:"line-".concat(n,"-").concat(v),x1:x,y1:_,x2:m,y2:R,style:D,sectionIdx:n,targetRightIdx:v})}}})});else{for(T=0;T<Math.min(Xn.length,$n.length);T++){var k=null===(c=ut.current[T])||void 0===c?void 0:c.current,L=null===(a=ct.current[T])||void 0===a?void 0:a.current;if(k&&L){var V=k.getBoundingClientRect(),H=L.getBoundingClientRect(),q=Math.max(V.top,H.top)+18-I.top,G=(null===(s=$n[T])||void 0===s?void 0:s.id)||"sec-".concat(T);(J=ti(T))&&E.push({id:G,x1:V.right-I.left,y1:q,x2:H.left-I.left,y2:q,style:J,sectionIdx:T,hasCognitive:!!((null===(d=Xn[T])||void 0===d?void 0:d.cognitiveData)||(null===(v=$n[T])||void 0===v?void 0:v.cognitiveData)||G&&cn[G]),isSubSection:!1})}}Object.keys(vt.current).forEach(function(e){var n,t,i,o,l,r;if(A(e)){var c=null===(n=vt.current[e])||void 0===n?void 0:n.current,a=null===(t=ft.current[e])||void 0===t?void 0:t.current;if(c&&a){for(var s=e.split("-").map(Number),d=Xn[s[0]],v=$n[s[0]],f=1;f<s.length;f++)(null==d?void 0:d.subsections)&&(d=d.subsections[s[f]]),(null==v?void 0:v.subsections)&&(v=v.subsections[s[f]]);var g=!!d&&((null===(i=d.displayTitle)||void 0===i||i)&&u.hasValue(d.title)),p=!!d&&((null===(o=d.displayContent)||void 0===o||o)&&u.hasValue(d.content)),h=!!v&&((null===(l=v.displayTitle)||void 0===l||l)&&u.hasValue(v.title)),x=!!v&&((null===(r=v.displayContent)||void 0===r||r)&&u.hasValue(v.content));if(g&&p||h&&x){var m=c.getBoundingClientRect(),_=a.getBoundingClientRect(),R=Math.max(m.top,_.top)+16-I.top,y=ii(e);y&&"Not Defined"!==y.label&&E.push({id:"subsec-".concat(e),x1:m.right-I.left,y1:R,x2:_.left-I.left,y2:R,style:y,sectionIdx:s[0],isSubSection:!0,subSectionKeyPath:e,hasCognitive:!(!(null==d?void 0:d.cognitiveData)&&!(null==v?void 0:v.cognitiveData))})}}}})}if(De&&"string"==typeof Ve&&Ve.includes(u.DEVIATION_BADGE_SEPARATOR)){var z=Ve.split(u.DEVIATION_BADGE_SEPARATOR),W=z[0],K=z[1],Y=z[2],U=(z[3],"".concat(W).concat(u.DEVIATION_BADGE_SEPARATOR).concat(K)),X=null===(f=at.current[U])||void 0===f?void 0:f.current,$=null===(g=st.current[U])||void 0===g?void 0:g.current;if(X&&$){var J,Q=X.getBoundingClientRect(),Z=$.getBoundingClientRect(),ee=Q.right-I.left,ne=Z.left-I.left,te=Q.top+Q.height/2-I.top,ie=Z.top+Z.height/2-I.top;if(xe){var oe=null!==(h=null===(p=Rn.current)||void 0===p?void 0:p.getBoundingClientRect().top)&&void 0!==h?h:0,le=null!==(m=null===(x=pn.current)||void 0===x?void 0:x.getBoundingClientRect().top)&&void 0!==m?m:0,re=oe+(null!==(R=null===(_=Rn.current)||void 0===_?void 0:_.clientHeight)&&void 0!==R?R:1/0),ue=le+(null!==(b=null===(y=pn.current)||void 0===y?void 0:y.clientHeight)&&void 0!==b?b:1/0),ce=function(e,n,t){return Math.max(n,Math.min(t,e))};te=ce(Q.top+Q.height/2,oe,re)-I.top,ie=ce(Z.top+Z.height/2,le,ue)-I.top}(J=null!==(S=oi(W,K))&&void 0!==S?S:ii(Y))&&E.push({id:"line-subsec-".concat(U),x1:ee,y1:te,x2:ne,y2:ie,style:J,sectionIdx:Number(Y.split("-")[0]),isSubSection:!0,subSectionKeyPath:Ve})}}if(Jt(E),Yt.current&&Ut.current){var ae=Yt.current.getBoundingClientRect(),se=Ut.current.getBoundingClientRect(),de=(ae.top+ae.height/2-I.top+se.top+se.height/2-I.top)/2;ei({x1:ae.right-I.left,x2:se.left-I.left,y:de})}else ei(null);if(ze.size>0){var ve=[],fe=Rn.current,ge=pn.current;if(fe&&ge){var pe=[],he=fe.getBoundingClientRect().top,me=ge.getBoundingClientRect().top,_e=he+fe.clientHeight,Re=me+ge.clientHeight,ye=fe.scrollTop,be=ge.scrollTop,Se=I.top,Ae=function(e,n,t){return Math.max(n,Math.min(t,e))};ze.forEach(function(e){var n,t,i,o,l,r;if("string"==typeof e&&e.includes(u.DEVIATION_BADGE_SEPARATOR)){var c=e.split(u.DEVIATION_BADGE_SEPARATOR),a=c[0],s=c[1],d=c[2],v=(c[3],"".concat(a).concat(u.DEVIATION_BADGE_SEPARATOR).concat(s)),f=null===(n=at.current[v])||void 0===n?void 0:n.current,g=null===(t=st.current[v])||void 0===t?void 0:t.current;if(!f||!g)return;var p=f.getBoundingClientRect(),h=g.getBoundingClientRect(),x=null!==(i=oi(a,s))&&void 0!==i?i:ii(d),m=(P=p.right-I.left)+.5*((F=h.left-I.left-0)-P),_=p.top+p.height/2,R=h.top+h.height/2,y=_-he+ye,b=R-me+be,S="conn-subsec-".concat(v);pe.push({lhsScrollY:y,rhsScrollY:b,x1:P,x2:F,containerTop:Se,leftIdx:e,rhsArrayIdx:e,styleColor:(null==x?void 0:x.badgeBorder)||"#6366F1",styleId:S});var A=Ae(_,he,_e),E=Ae(R,me,Re),T=A-Se,B=E-Se,C=R>=me-4&&R<=Re+4,D="";D=(M=_>=he-4&&_<=_e+4)&&C?u.getBentArrowPath(P,T,F,B):M&&!C?"M ".concat(P,",").concat(T," L ").concat(m,",").concat(T," L ").concat(m,",").concat(B):!M&&C?"M ".concat(m,",").concat(T," L ").concat(m,",").concat(B," L ").concat(F,",").concat(B):"M ".concat(m,",").concat(T," L ").concat(m,",").concat(B),ve.push({id:S,pathD:D,style:x,leftIdx:e,rhsArrayIdx:e})}else if(xe){var O=e,w=Xn[O];if(!(null===(r=null==w?void 0:w.refIndexes)||void 0===r?void 0:r.length))return;w.refIndexes.forEach(function(e){var n,t,i=$n.findIndex(function(n){return n.selfIndex===e});if(-1!==i){var o=null===(n=at.current[O])||void 0===n?void 0:n.current,l=null===(t=st.current[i])||void 0===t?void 0:t.current;if(o&&l){var r=o.getBoundingClientRect(),c=l.getBoundingClientRect(),a=ti(O),s=r.right-I.left,d=c.left-I.left-0,v=s+.5*(d-s),f=r.top+r.height/2,g=c.top+c.height/2,p=f-he+ye,h=g-me+be,x="conn-".concat(O,"-").concat(i);pe.push({lhsScrollY:p,rhsScrollY:h,x1:s,x2:d,containerTop:Se,leftIdx:O,rhsArrayIdx:i,styleColor:(null==a?void 0:a.badgeBorder)||"#6366F1",styleId:x});var m=Ae(f,he,_e),_=Ae(g,me,Re),R=m-Se,y=_-Se,b=f>=he-4&&f<=_e+4,S=g>=me-4&&g<=Re+4,A="";A=b&&S?u.getBentArrowPath(s,R,d,y):b&&!S?"M ".concat(s,",").concat(R," L ").concat(v,",").concat(R," L ").concat(v,",").concat(y):!b&&S?"M ".concat(v,",").concat(R," L ").concat(v,",").concat(y," L ").concat(d,",").concat(y):"M ".concat(v,",").concat(R," L ").concat(v,",").concat(y),ve.push({id:x,pathD:A,style:a,leftIdx:O,rhsArrayIdx:i})}}})}else{var N=e,j=N;f=null===(o=at.current[N])||void 0===o?void 0:o.current,g=null===(l=st.current[j])||void 0===l?void 0:l.current;if(!f||!g)return;var P,F;p=f.getBoundingClientRect(),h=g.getBoundingClientRect(),x=ti(N),m=(P=p.right-I.left)+.5*((F=h.left-I.left-0)-P),_=p.top+p.height/2,R=h.top+h.height/2,y=_-he+ye,b=R-me+be,S="conn-".concat(N,"-").concat(j);pe.push({lhsScrollY:y,rhsScrollY:b,x1:P,x2:F,containerTop:Se,leftIdx:N,rhsArrayIdx:j,styleColor:(null==x?void 0:x.badgeBorder)||"#6366F1",styleId:S});var M;A=Ae(_,he,_e),E=Ae(R,me,Re),T=A-Se,B=E-Se,C=R>=me-4&&R<=Re+4,D="";D=(M=_>=he-4&&_<=_e+4)&&C?u.getBentArrowPath(P,T,F,B):M&&!C?"M ".concat(P,",").concat(T," L ").concat(m,",").concat(T," L ").concat(m,",").concat(B):!M&&C?"M ".concat(m,",").concat(T," L ").concat(m,",").concat(B," L ").concat(F,",").concat(B):"M ".concat(m,",").concat(T," L ").concat(m,",").concat(B),ve.push({id:S,pathD:D,style:x,leftIdx:N,rhsArrayIdx:j})}}),tn.current=pe}Ue(ve)}else Ue([]),tn.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{yn.current=!1}}},[Jn,Xn,$n,cn,Ln,ni,ti,oi,xe,De,Ve,ze,Dt,wt]),ci=t.useCallback(function(){var e,n,t,i,o,l,r,c,a,s,d,v,f,g,p=tn.current;if(p.length&&!Ze.current){var h=null!==(n=null===(e=Rn.current)||void 0===e?void 0:e.scrollTop)&&void 0!==n?n:0,x=null!==(i=null===(t=pn.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,m=null!==(l=null===(o=Rn.current)||void 0===o?void 0:o.clientHeight)&&void 0!==l?l:1/0,_=null!==(c=null===(r=pn.current)||void 0===r?void 0:r.clientHeight)&&void 0!==c?c:1/0,R=null!==(s=null===(a=Rn.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==s?s:0,y=null!==(v=null===(d=pn.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==v?v:0,b=R+m,S=y+_,A=null!==(g=null===(f=Gt.current)||void 0===f?void 0:f.getBoundingClientRect().top)&&void 0!==g?g:0,I=function(e,n,t){return Math.max(n,Math.min(t,e))};p.forEach(function(e){var n=e.lhsScrollY-h+R,t=e.rhsScrollY-x+y,i=nn.current[e.styleId+"-stroke"],o=nn.current[e.styleId+"-bg"];if(i||o){var l,r=I(n,R,b),c=I(t,y,S),a=r-A,s=c-A,d=n>=R-4&&n<=b+4,v=t>=y-4&&t<=S+4,f=e.x1+.5*(e.x2-e.x1);l=d&&v?u.getBentArrowPath(e.x1,a,e.x2,s):d&&!v?"M ".concat(e.x1,",").concat(a," L ").concat(f,",").concat(a," L ").concat(f,",").concat(s):!d&&v?"M ".concat(f,",").concat(a," L ").concat(f,",").concat(s," L ").concat(e.x2,",").concat(s):"M ".concat(f,",").concat(a," L ").concat(f,",").concat(s),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",l)),o&&(o.setAttribute("visibility","visible"),o.setAttribute("d",l))}})}},[]);t.useEffect(function(){un.current=ui},[ui]);var ai=t.useRef(null),si=t.useRef(null),di=t.useCallback(function(){tn.current.length>0&&!Ze.current||(null!==ai.current&&clearTimeout(ai.current),ai.current=setTimeout(function(){un.current(),ai.current=null},50))},[]),vi=t.useCallback(function(){ke(!0),Pe(!1),$e.current=null,null!==si.current&&clearTimeout(si.current),null!==ai.current&&(clearTimeout(ai.current),ai.current=null),si.current=setTimeout(function(){var e,n,t,i,o,l,r,c,a,s,d;try{if(tn.current=[],ln.current&&null!==rn.current&&null!==Wt.current){var v=rn.current,f=Wt.current,g="string"==typeof v&&v.includes(u.DEVIATION_BADGE_SEPARATOR),p=null,h=null,x=null,m=null;if(g){var _=v.split(u.DEVIATION_BADGE_SEPARATOR),R="".concat(_[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(_[1]);p=(null===(e=at.current[R])||void 0===e?void 0:e.current)||null,h=(null===(n=st.current[R])||void 0===n?void 0:n.current)||null,x=(null===(t=vt.current[_[2]])||void 0===t?void 0:t.current)||(null===(i=ut.current[Number(_[2])])||void 0===i?void 0:i.current)||null,m=(null===(o=ft.current[_[3]])||void 0===o?void 0:o.current)||(null===(l=ct.current[Number(_[3])])||void 0===l?void 0:l.current)||null}else p=(null===(r=gt.current[v])||void 0===r?void 0:r.current)||null,x=(null===(c=ut.current[v])||void 0===c?void 0:c.current)||null,h=(null===(a=dt.current[f])||void 0===a?void 0:a.current)||null,m=(null===(s=ct.current[f])||void 0===s?void 0:s.current)||null;if(p&&h&&x&&m){if(x.style.paddingTop="0px",m.style.paddingTop="0px",!xe){var y=p.getBoundingClientRect(),b=h.getBoundingClientRect(),S=y.top-b.top;S>0?m.style.paddingTop="".concat(S,"px"):S<0&&(x.style.paddingTop="".concat(Math.abs(S),"px"))}var A=Rn.current,I=pn.current;if(A&&I){var E=p.getBoundingClientRect().top-A.getBoundingClientRect().top+A.scrollTop,T=h.getBoundingClientRect().top-I.getBoundingClientRect().top+I.scrollTop-(E-A.scrollTop);Math.abs(I.scrollTop-T)>1&&(I.scrollTop=T)}}}null===(d=un.current)||void 0===d||d.call(un),ln.current&&Pe(!0)}catch(e){console.error("Safely caught error during resize calculation:",e)}finally{ke(!1),si.current=null}},150)},[xe,Xn,$n]),fi=t.useCallback(function(e){if(null!==bn.current&&Sn.current&&Math.abs(e.currentTarget.scrollTop-bn.current)<=2){var n=Sn.current;bn.current=null,Sn.current=null,n()}qe.current||(xe||di(),on.current||(on.current=!0,requestAnimationFrame(function(){var e,n,t,i,o,l,r;if(ln.current){var c=Rn.current,a=pn.current;if(c&&a&&Kt.current){if(!$e.current){var s=rn.current,d=void 0;if("string"==typeof s&&s.includes(u.DEVIATION_BADGE_SEPARATOR)){var v=s.split(u.DEVIATION_BADGE_SEPARATOR),f="".concat(v[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(v[1]);d=null===(e=at.current[f])||void 0===e?void 0:e.current}else d=null===(n=at.current[s])||void 0===n?void 0:n.current;if(d){var g=d.getBoundingClientRect();$e.current={badgeScreenY:g.top+g.height/2,initialScrollTop:c.scrollTop,leftTop:c.getBoundingClientRect().top,leftBottom:c.getBoundingClientRect().top+c.clientHeight,cTop:null!==(i=null===(t=Gt.current)||void 0===t?void 0:t.getBoundingClientRect().top)&&void 0!==i?i:0}}}if($e.current){var p=$e.current,h=c.scrollTop-p.initialScrollTop,x=p.badgeScreenY-h,m=((o=x,l=p.leftTop,r=p.leftBottom,Math.max(l,Math.min(r,o)))-p.cTop).toString(),_=x>=p.leftTop-4&&x<=p.leftBottom+4;Kt.current.setAttribute("y1",m),Kt.current.setAttribute("y2",m),Kt.current.setAttribute("visibility",_?"visible":"hidden")}}}tn.current.length>0&&ci(),on.current=!1})))},[ci,xe,di]),gi=t.useRef(0),pi=t.useRef(0),hi=t.useRef(0),xi=t.useRef(function(){});t.useRef(null),t.useEffect(function(){xi.current=vi},[vi]),t.useEffect(function(){var e=setTimeout(di,250),n=function(){return xi.current()};return window.addEventListener("resize",n),function(){clearTimeout(e),null!==ai.current&&clearTimeout(ai.current),null!==si.current&&clearTimeout(si.current),window.removeEventListener("resize",n)}},[Yn,Un,mt,Jn,Dt,wt,Xn,$n,Ln,di,De,Ve,je,ze]),t.useEffect(function(){var e=function(e,n,t,i,o){n.current=e.getBoundingClientRect().width;var l=new ResizeObserver(function(e){null!==t.current&&cancelAnimationFrame(t.current),t.current=requestAnimationFrame(function(){var l,r,u;t.current=null;var c=e[e.length-1];if(c){var a=null!==(u=null===(r=null===(l=c.borderBoxSize)||void 0===l?void 0:l[0])||void 0===r?void 0:r.inlineSize)&&void 0!==u?u:c.contentRect.width;Math.abs(a-n.current)<1?o():(n.current=a,i())}})});return l.observe(e),l},n={current:null},t={current:null},i={current:null},o=[],l=[n,t,i];return gn.current&&o.push(e(gn.current,gi,n,function(){return xi.current()},function(){})),fn.current&&o.push(e(fn.current,pi,t,function(){return xi.current()},function(){return un.current()})),Gt.current&&o.push(e(Gt.current,hi,i,function(){return xi.current()},function(){return un.current()})),function(){o.forEach(function(e){return e.disconnect()}),l.forEach(function(e){null!==e.current&&(cancelAnimationFrame(e.current),e.current=null)})}},[]),t.useEffect(function(){ln.current=De},[De]),t.useEffect(function(){rn.current=Ve},[Ve]);var mi=t.useCallback(function(e,n,t){var i,o,l=null===(i=null==t?void 0:t.toggleIfSame)||void 0===i||i,r=null==t?void 0:t.onReady,c=null!==(o=null==t?void 0:t.sourceSide)&&void 0!==o?o:"left";kn(),null!=e&&(n?Be("No counterpart exists for this section."):(It(),De&&Ve===e?l?Et():null==r||r():(We(new Set([e])),Ue([]),tn.current=[],Ie(!0),qe.current=!0,He(e),rn.current=e,Oe(!0),ln.current=!0,Pe(!1),hn.current&&(hn.current.style.height="0px"),xn.current&&(xn.current.style.height="0px"),mn.current&&(mn.current.style.height="0px"),_n.current&&(_n.current.style.height="0px"),requestAnimationFrame(function(){var n,t,i,o,l,a="string"==typeof e&&e.includes(u.DEVIATION_BADGE_SEPARATOR),s=null,d=null,v=null;if(a){var f=e.split(u.DEVIATION_BADGE_SEPARATOR),g="".concat(f[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(f[1]);s=(null===(n=at.current[g])||void 0===n?void 0:n.current)||null,d=(null===(t=st.current[g])||void 0===t?void 0:t.current)||null,v=d?e:null}else if(s=(null===(i=gt.current[e])||void 0===i?void 0:i.current)||null,xe){var p=Xn[e],h=(null==p?void 0:p.refIndexes)||[];if(h.length>0){var x=h[0],m=$n.findIndex(function(e){return e.selfIndex===x});-1!==m&&(d=(null===(l=dt.current[m])||void 0===l?void 0:l.current)||null,v=m)}}else d=(null===(o=dt.current[e])||void 0===o?void 0:o.current)||null,v=d?e:null;Wt.current=v;var _=Rn.current,R=pn.current,y=function(){!function(){var n,t,i,o,l,r,c,s,d,f,g,p,h=null,x=null,m=null,_=null;if(a){var R=e.split(u.DEVIATION_BADGE_SEPARATOR),y="".concat(R[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(R[1]);h=(null===(n=vt.current[R[2]])||void 0===n?void 0:n.current)||(null===(t=ut.current[Number(R[2])])||void 0===t?void 0:t.current)||null,x=(null===(i=ft.current[R[3]])||void 0===i?void 0:i.current)||(null===(o=ct.current[Number(R[3])])||void 0===o?void 0:o.current)||null,m=(null===(l=at.current[y])||void 0===l?void 0:l.current)||h,_=(null===(r=st.current[y])||void 0===r?void 0:r.current)||x}else{var b=Number(e),S=null!==v?Number(v):b;h=(null===(c=ut.current[b])||void 0===c?void 0:c.current)||null,x=(null===(s=ct.current[S])||void 0===s?void 0:s.current)||null,m=(null===(d=at.current[b])||void 0===d?void 0:d.current)||(null===(f=gt.current[b])||void 0===f?void 0:f.current)||h,_=(null===(g=st.current[S])||void 0===g?void 0:g.current)||(null===(p=dt.current[S])||void 0===p?void 0:p.current)||x}if(m&&_&&h&&x){h.style.paddingTop="0px",x.style.paddingTop="0px";var A=m.getBoundingClientRect(),I=_.getBoundingClientRect(),E=A.top-I.top;E>0?x.style.paddingTop="".concat(E,"px"):E<0&&(h.style.paddingTop="".concat(Math.abs(E),"px"))}}(),Pe(!0),un.current&&un.current(),qe.current=!1,"right"===c&&R?R.dispatchEvent(new Event("scroll")):_&&_.dispatchEvent(new Event("scroll")),Ie(!1),null==r||r()};if(!s||!_)return qe.current=!1,Ie(!1),void(null==r||r());if(d&&R){if(!xe){var b=0;b="right"===c?d?d.getBoundingClientRect().top:0:s?s.getBoundingClientRect().top:0;var S=fn.current,A=(null==S?void 0:S.getBoundingClientRect().top)||0,I=S?S.scrollTop+b-A-150:0;return S?void u.smoothScrollTo(S,I,200,y):void y()}var E=s.getBoundingClientRect().top-_.getBoundingClientRect().top+_.scrollTop,T=d.getBoundingClientRect().top-R.getBoundingClientRect().top+R.scrollTop,B=200;if("left"===c){var C=T-(E-_.scrollTop);C<0&&hn.current&&(hn.current.style.height="".concat(Math.abs(C),"px")),requestAnimationFrame(function(){var e,n=R.scrollHeight-R.clientHeight;if(C<0)e=0;else{if(C>n){var t=C-n;return xn.current&&(xn.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){u.smoothScrollTo(R,C,B,y)})}e=C}u.smoothScrollTo(R,e,B,y)})}else{var D=E-(T-R.scrollTop);D<0&&mn.current&&(mn.current.style.height="".concat(Math.abs(D),"px")),requestAnimationFrame(function(){var e,n=_.scrollHeight-_.clientHeight;if(D<0)e=0;else{if(D>n){var t=D-n;return _n.current&&(_n.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){u.smoothScrollTo(_,D,B,y)})}e=D}u.smoothScrollTo(_,e,B,y)})}}else y()}))))},[Ve,kn,$n,De,xe,Xn,Et]),_i=t.useCallback(function(){var e,n=Tn.sectionIdx,t=Tn.isOrphan;if(jn(),null!=n){var i="left";Tn.anchorEl&&(null===(e=pn.current)||void 0===e?void 0:e.contains(Tn.anchorEl))&&(i="right"),mi(n,t,{sourceSide:i})}},[mi,Tn.isOrphan,Tn.sectionIdx,Tn.anchorEl,jn]),Ri=t.useCallback(function(){jn(),Et(),We(new Set),Ue([]),tn.current=[]},[jn,Et]),yi=null!==Tn.sectionIdx&&ze.has(Tn.sectionIdx),bi=m.useDeviationNavigation({proposedSections:Xn,existingSections:$n,parentDeviationRecord:Qn,expandedSections:Dt,maintainRelativeOrder:!!xe,scrollContainerRef:fn,leftContainerRef:Rn,rightContainerRef:pn,lhsBadgeRefs:at,rhsBadgeRefs:st}),Si=bi.showDeviationNavigation,Ai=bi.showOpenNodeRef,Ii=bi.adjustScrollForPopup,Ei=t.useCallback(function(e,n,t,i,o){var l,r="string"==typeof i?u.safeStringify(i).trim():u.safeStringify(null==i?void 0:i.deviation_summary).trim(),c=e.currentTarget;Mn();var a="left";(null===(l=pn.current)||void 0===l?void 0:l.contains(c))&&(a="right");var s=function(){var e,t,i,o;if("string"==typeof n&&n.includes(u.DEVIATION_BADGE_SEPARATOR)){var l=n.split(u.DEVIATION_BADGE_SEPARATOR),r="".concat(l[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(l[1]);return"right"===a?null===(e=st.current[r])||void 0===e?void 0:e.current:null===(t=at.current[r])||void 0===t?void 0:t.current}return"right"===a?null===(i=st.current[n])||void 0===i?void 0:i.current:null===(o=at.current[n])||void 0===o?void 0:o.current},d=function(e,n){var t=!!xe,i=t?"right"===a?pn.current:Rn.current:fn.current,o=t?"right"===a?Rn.current:pn.current:null;if(i&&e){var l=e.getBoundingClientRect(),r=i.getBoundingClientRect(),c=r.bottom-.35*r.height,s=r.top+.35*r.height;if(l.top>c||l.top<s){var d=r.top+r.height/2,v=l.top+l.height/2-d;if(t&&o){var f=i.scrollHeight-i.clientHeight,g=o.scrollHeight-o.clientHeight;if(v>0){var p=f-i.scrollTop,h=g-o.scrollTop;v=Math.max(0,Math.min(v,p,h))}else v=Math.min(0,Math.max(v,-i.scrollTop,-o.scrollTop));u.smoothScrollTo(o,o.scrollTop+v,250,function(){})}u.smoothScrollTo(i,i.scrollTop+v,250,n)}else n()}else n()};if(t)return Et(),We(new Set),Ue([]),tn.current=[],void(r&&requestAnimationFrame(function(){var e=s()||c;d(e,function(){Nn({open:!0,anchorEl:e,summary:i,displayImpact:o})})}));mi(n,t,r?{toggleIfSame:!1,sourceSide:a,onReady:function(){var e=s()||c;d(e,function(){Nn({open:!0,anchorEl:e,summary:i,displayImpact:o})})}}:{toggleIfSame:!1,sourceSide:a})},[mi,Mn,Nn,Et,xe]),Ti=t.useMemo(function(){var e;if(!se)return null;var n=null===(e=null==se?void 0:se.id)||void 0===e?void 0:e.split(":")[0];for(var t in Qn){if((Qn[t]||[]).some(function(e){return e.id===n}))return t}return null},[se,Qn]),Bi=t.useRef({id:null,triggerMs:null}),Ci=t.useRef(null);t.useEffect(function(){var n;if(null==se?void 0:se.id){var t=Number(se.trigger),i=Bi.current;if((null==i?void 0:i.triggerMs)!==t){if(!(se.id.includes(":")&&/:\d+$/.test(se.id)))return Bi.current={id:se.id,triggerMs:t},void Ht(se.id);var o=null===(n=null==se?void 0:se.id)||void 0===n?void 0:n.split(":"),l=o[0],r=o[1],c=null!=r?r:"0";Ci.current!==se.id&&(jn(),Mn(),Et(),We(new Set),Ue([]),tn.current=[],Ci.current=se.id);var a=!1,s=0,d=null,v=150,f=function(e,n){for(var t=function(e,i){if(!e)return null;if(e.id===n)return i;if(!Array.isArray(e.subsections))return null;for(var o=0;o<e.subsections.length;o++){var l=t(e.subsections[o],"".concat(i,"-").concat(o));if(l)return l}return null},i=0;i<e.length;i++){var o=t(e[i],String(i));if(o)return o}return null},g=function(){var n,i,o,r;if(!a){var p=function(){Bi.current={id:se.id,triggerMs:t}},h=null,x=null;for(var m in Qn){var _=Qn[m].find(function(e){return e.id===l});if(_){h=m,x=_;break}}if(x&&h){var R=Xn.findIndex(function(e){return e.id===h}),y=$n.findIndex(function(e){return e.id===h}),b=-1===R&&-1!==y,S=f(Xn,x.id),A=f($n,x.id);if(S&&!A&&!b){var I=S.split("-"),E=Number(I[0]);if(xe){var T=null===(i=null===(n=Xn[E])||void 0===n?void 0:n.refIndexes)||void 0===i?void 0:i[0],B=$n.findIndex(function(e){return e.selfIndex===T});-1!==B&&(E=B)}A=e.__spreadArray([E],I.slice(1),!0).join("-")}if(S||A){var C=b||!S&&!!A,D=S?Number(S.split("-")[0]):R,O=A?Number(A.split("-")[0]):y;if(C){if(!(xe?!!Dt["right-".concat(O)]:!!Dt[String(O)])&&O>=0)return jt(O,"right"),s+=1,void(d=setTimeout(g,450))}else if(!(xe?!!Dt["left-".concat(D)]:!!Dt[String(D)])&&D>=0)return jt(D,"left"),s+=1,void(d=setTimeout(g,450));var w,N=S||"",j=A||"",P="".concat(x.id).concat(u.DEVIATION_BADGE_SEPARATOR).concat(c).concat(u.DEVIATION_BADGE_SEPARATOR).concat(N).concat(u.DEVIATION_BADGE_SEPARATOR).concat(j),F="".concat(x.id).concat(u.DEVIATION_BADGE_SEPARATOR).concat(c),M=null===(o=at.current[F])||void 0===o?void 0:o.current,k=null===(r=st.current[F])||void 0===r?void 0:r.current,L=C||!M&&!!k,V=L?k:M;if(w=xe?L?pn.current:Rn.current:fn.current,V&&w){var H=V.getBoundingClientRect();if(0===H.height)return void((s+=1)<2?d=setTimeout(g,v):p());var q=w.getBoundingClientRect(),G=H.top-q.top+w.scrollTop-q.height/2+H.height/2+150,z=function(){var n,t,i,o,l;if(!a){p();var r=V instanceof Element?window.getComputedStyle(V).color:"";M&&(M.style.transition="box-shadow 300ms ease-in-out",M.style.boxShadow="0 0 10px ".concat(r)),k&&(k.style.transition="box-shadow 300ms ease-in-out",k.style.boxShadow="0 0 10px ".concat(r)),setTimeout(function(){M&&(M.style.boxShadow=""),k&&(k.style.boxShadow="")},2e3);var u=(null===(t=null===(n=x.evaluationResult)||void 0===n?void 0:n.deviations)||void 0===t?void 0:t[c])||x,s=(null===(i=x.evaluationResult)||void 0===i?void 0:i.evaluation_outputs)||x.evaluation_outputs;if(!(!!M&&!!k)){var d=L?(null===(o=st.current[F])||void 0===o?void 0:o.current)||k:(null===(l=at.current[F])||void 0===l?void 0:l.current)||M;return Ii(d,function(){Nn({open:!0,anchorEl:d,displayImpact:se.displayImpact,summary:e.__assign(e.__assign({},u),{evaluation_outputs:s})})}),void(null==de||de())}mi(P,!1,{toggleIfSame:!1,sourceSide:"left",onReady:function(){var n,t,i=L?(null===(n=st.current[F])||void 0===n?void 0:n.current)||k:(null===(t=at.current[F])||void 0===t?void 0:t.current)||M;Ii(i,function(){Nn({open:!0,anchorEl:i,displayImpact:null==se?void 0:se.displayImpact,summary:e.__assign({},u)})})}})}};Math.abs(w.scrollTop-G)<=2?z():(bn.current=G,Sn.current=z,w.scrollTo({top:G,behavior:"smooth"}),d&&clearTimeout(d),d=setTimeout(function(){if(Sn.current){bn.current=null;var e=Sn.current;Sn.current=null,e()}},800))}else(s+=1)<2?d=setTimeout(g,v):p()}else(s+=1)<2?d=setTimeout(g,v):p()}else(s+=1)<2?d=setTimeout(g,v):p()}};return d=setTimeout(g,v),function(){a=!0,d&&clearTimeout(d)}}}},[se,Qn,Xn,$n,xe,Dt,jt,mi,Nn,Ht]);var Di=function(e){var t=e.section,i=e.keyPath,o=e.depth,l=void 0===o?0:o,r=e.columnKey,u=void 0===r?"left":r,c=e.parentNodeId,a=void 0===c?"":c,s=e.sectionOffset;return n.jsx(y.default,{section:t,keyPath:i,depth:l,columnKey:u,parentNodeId:a,expandedSubSections:wt,setExpandedSubSections:Nt,maintainRelativeOrder:xe||!1,proposedSections:Xn,existingSections:$n,treeData:Z,deviationNumberRegistry:Zn,connectedSections:ze,activeSideBySideSection:Ve,resolvedMarkdownStyles:vn,getSubSectionRef:ht,getSubSectionCompareStyle:ii,getBadgeRef:xt,openMoreFunctionsPopup:Mt,openSummaryPopup:Ei,showDeviationBadges:_e,resetSideBySide:Et,setConnectedSections:We,setConnectedLines:Ue,cachedConnectedPositions:tn,isProposingFix:fe,proposingFixNodeId:ge,isRedlineFlow:pe,sectionOffset:s})};return n.jsxs(i.Box,e.__assign({ref:gn,sx:e.__assign(e.__assign({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},xe?{}:{overflow:"visible"}),{position:"relative"})},{children:[ye&&n.jsx(i.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,{})})),wn.open&&n.jsx(b.default,{open:wn.open,anchorEl:wn.anchorEl,containerEl:zt.current,clipTopEl:Yt.current,scrollContainerEl:fn.current,onClose:Ri,summary:wn.summary,displayImpact:wn.displayImpact}),n.jsx(d.default,{open:Tn.open,anchorEl:Tn.anchorEl,sectionTitle:Tn.sectionTitle,referenceSectionTitle:Tn.refSectionTitle,onClose:kn,onOpenCognitiveCompare:kt,onOpenSideBySide:_i,onConnect:Lt,isConnected:yi,isOrphan:Tn.isOrphan}),In.open&&n.jsx(s.default,{open:In.open,popupRef:Fn,position:Cn,popupConfig:ue,onClose:function(){Dn(null),En(function(n){return e.__assign(e.__assign({},n),{open:!1})}),Pn(null)},markdownStyles:ie,sectionTitle:In.sectionTitle,referenceSectionTitle:In.refSectionTitle,cognitiveData:In.cognitiveData,anchorEl:In.anchorEl,sectionAnchorEl:In.sectionAnchorEl,scrollContainerEl:fn.current,badgeStyle:In.badgeStyle,docData:In.docData,deviationData:In.deviationData,isLoading:In.isLoading}),n.jsx(i.Snackbar,e.__assign({open:!!Te,autoHideDuration:8e3,onClose:function(){return Be(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(i.Alert,e.__assign({onClose:function(){return Be(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:Te}))})),n.jsx(_.default,{componentHeaderText:Q,displayConfig:re,maintainRelativeOrder:xe,onCollapseAll:li,showCollapseAll:ri,onToggleView:function(e){be(!0),setTimeout(function(){me(!e),Et(),jn(),We(new Set),Ue([]),tn.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){be(!1)},600)})})},50)}}),n.jsx(i.Box,e.__assign({ref:fn,onScroll:fi,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:xe?"hidden":"auto",borderTop:_t&&Rt?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(i.Box,e.__assign({sx:e.__assign({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},xe?{flex:1,minHeight:0}:{})},{children:n.jsxs(i.Box,e.__assign({ref:Gt,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},xe?{flex:1,overflow:"visible"}:{})},{children:[n.jsxs("svg",e.__assign({ref:Xe,style:{position:"absolute",top:0,left:0,width:sn.width||"100%",height:sn.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",opacity:Me?0:1,transition:"opacity 0.15s ease-in-out"}},{children:[Zt&&n.jsx("g",{children:n.jsx("line",{x1:Zt.x1,y1:Zt.y,x2:Zt.x2,y2:Zt.y,stroke:At.badgeBorder,strokeWidth:"1.5"})}),$t.map(function(t){var r,c,s,d,v,g,p,h=t.x1+.5*(t.x2-t.x1),x=(t.y1+t.y2)/2;if("Not Defined"===t.style.label&&!t.hasCognitive)return null;if(t.isSubSection?De&&Ve===t.subSectionKeyPath&&je:De&&Ve===t.sectionIdx&&je)return null;if(!xe){var m=t.isSubSection?u.getBentArrowPath(t.x1,t.y1,t.x2,t.y2):"M ".concat(t.x1," ").concat(t.y1," L ").concat(t.x2," ").concat(t.y2),_=Xn[t.sectionIdx]||{title:"",content:""},R=$n[null!==(r=t.targetRightIdx)&&void 0!==r?r:t.sectionIdx]||{title:"",content:""};if(console.log("Base and Ref Sections for Badge:",_,R),t.isSubSection&&t.subSectionKeyPath){var y=t.subSectionKeyPath.includes(u.DEVIATION_BADGE_SEPARATOR)?t.subSectionKeyPath.split(u.DEVIATION_BADGE_SEPARATOR):[],b=y[2]||t.subSectionKeyPath,S=y[3]||b,A=b.split("-").map(Number),I=S.split("-").map(Number),E=null,T=null;A.length>0&&(E=Xn[A[0]]),I.length>0&&(T=$n[I[0]]);var B=(null==E?void 0:E.title)||"",C=(null==T?void 0:T.title)||"";console.log("Root Parent Titles:",B,C);for(var D=1;D<A.length;D++)(null==E?void 0:E.subsections)&&(E=E.subsections[A[D]]);for(D=1;D<I.length;D++)(null==T?void 0:T.subsections)&&(T=T.subsections[I[D]]);E&&(_=e.__assign(e.__assign({},E),{title:B||E.title})),console.log("Base Section for Subsection Badge:",_),T&&(R=e.__assign(e.__assign({},T),{title:C||T.title})),console.log("Ref Section for Subsection Badge:",R)}var O=!(null===(c=_.cognitiveData)||void 0===c?void 0:c.isMissingRationale)||Boolean(null===(d=null===(s=_.cognitiveData)||void 0===s?void 0:s.decisioning)||void 0===d?void 0:d.length),w=(null===(p=null===(g=null===(v=_.evaluationResult)||void 0===v?void 0:v.cognitive_decisioning)||void 0===g?void 0:g.decisioning_factors)||void 0===p?void 0:p.length)||!1,N=O||w;return n.jsxs("g",{children:[n.jsx("path",{d:m,fill:"none",stroke:t.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),n.jsx("foreignObject",e.__assign({x:h-100,y:x-14,width:"200",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:n.jsx(i.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:n.jsxs(i.Box,e.__assign({onClick:function(e){e.stopPropagation(),N&&(In.open&&On===t.id?Mn():(Pn(t.id),Ft(Pt(e.currentTarget,_,R,t.sectionIdx,t.style))))},sx:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:t.style.badgeBg,color:t.style.badgeText,border:"1px solid ".concat(t.style.badgeBorder),borderRadius:"12px",px:1.5,py:.5,fontWeight:600,textAlign:"center",whiteSpace:"nowrap",cursor:N?"pointer":"default"}},{children:[t.style.badgeText===a.DEFAULT_DEVIAION_COLOR&&null==t.style.label?n.jsx(f.default,{color:t.style.badgeText}):0===t.style.label?"Same":t.style.label,n.jsx(i.Box,e.__assign({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n.jsx(l.ButtonCognitiveIcon,{})})),N&&n.jsx(o.ChevronDown,{size:11,style:{transform:In.open&&On===t.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},t.id)}return null}),n.jsx(S.default,{connectedLines:Ye,pathRefs:nn})]})),n.jsxs(i.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)"},xe?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(i.Box,e.__assign({ref:Yt,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(i.Tooltip,e.__assign({title:zn,placement:"top"},{children:n.jsx(i.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:zn}))}))})),n.jsxs(i.Box,e.__assign({ref:Rn,onScroll:fi,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},xe?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-160px",pr:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:mn,style:{width:"100%",height:"0px",flexShrink:0}}),nt&&Xn.map(function(t,l){var r,c,a=!t.title&&!t.content;if(xe&&a)return null;var s=t,d=ti(l,"left"),v=xe?!(null===(r=s.refIndexes)||void 0===r?void 0:r.length)||s.selfIndex<0:!$n[l],g=ze.has(l),p=u.extractDeviationScore(s.evaluationResult,null==d?void 0:d.deviationLabel),h=it.leftNums.get(s.id);return n.jsx(i.Box,e.__assign({ref:pt(l),sx:{mb:1,width:"100%"}},{children:n.jsxs(i.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[n.jsx(i.Box,e.__assign({ref:ut.current[l],sx:e.__assign({width:"100%",display:"flex",flexDirection:"column",minWidth:0},g&&{borderRadius:"6px",outline:"2px solid ".concat((null==d?void 0:d.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:n.jsx(R.default,{section:t,idx:l,columnKey:"left",colRef:pt("left-accordion-".concat(l)),mb:0,treeData:Z,proposedSections:Xn,existingSections:$n,deviationNumberRegistry:Zn,getSectionCompareStyle:ti,getBadgeRef:xt,connectedSections:ze,openMoreFunctionsPopup:Mt,openSummaryPopup:Ei,deviationNodeIdToView:null==se?void 0:se.id,deviationTargetParentId:Ti,parentNodeId:(null===(c=null==Z?void 0:Z.input_index_map)||void 0===c?void 0:c[0])||"",isExpanded:xe?!!Dt["left-".concat(l)]:!!Dt[String(l)],onToggle:function(){Ri(),jt(l,"left")},navigation:t.id?Si[t.id]:null,showOpenNodeRef:Ai,resolvedMarkdownStyles:vn,maintainRelativeOrder:xe,showDeviationBadges:_e,renderSubSections:Di,isProposingFix:fe,proposingFixNodeId:ge,isRedlineFlow:pe,collisionKey:"".concat(De?"1":"0","-").concat(String(null!=Ve?Ve:""))})})),xe&&d&&n.jsxs(i.Box,e.__assign({ref:at.current[l],onClick:function(e){var n,t,i,o=re.enableDeviationSchemaBackwardCompatibility?null!==(n=s.evaluationResult)&&void 0!==n?n:null:null!==(i=null===(t=s.evaluationResult)||void 0===t?void 0:t[0])&&void 0!==i?i:null;Ei(e,String(l),v,o)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:d.badgeBg,color:d.badgeText,border:"1px solid ".concat(d.badgeBorder),borderRadius:"12px",px:1.2,py:.3,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[n.jsxs(i.Box,e.__assign({component:"span",onClick:function(e){var n,t,i;e.stopPropagation();var o=re.enableDeviationSchemaBackwardCompatibility?null!==(n=s.evaluationResult)&&void 0!==n?n:null:null!==(i=null===(t=s.evaluationResult)||void 0===t?void 0:t[0])&&void 0!==i?i:null;Ei(e,String(l),v,o)},sx:{display:"inline-flex",alignItems:"center",gap:"4px",px:.2,cursor:v?"default":"pointer",borderRight:"1px solid ".concat(d.badgeBorder),"&:hover":v?{}:{bgColor:"".concat(d.badgeBorder,"22")}}},{children:[null!=h&&n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(d.badgeBorder)}},{children:h})),n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",px:.25}},{children:!re.isLoading||null!=s.evaluationResult&&null!=s.evaluationResult?"N/A"===p||"NA"===p?"N/A":0==p||null==p?"Same":"".concat(p):n.jsx(f.default,{color:d.badgeText})}))]})),n.jsx(i.Box,e.__assign({component:"span",onClick:function(e){e.stopPropagation();var n=xe?$n.find(function(e){var n;return null===(n=s.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""}:$n[l]||{title:"",content:""};Mt(e,t,v,n,l,d)},sx:{display:"inline-flex",alignItems:"center",px:.2,cursor:"pointer","&:hover":{bgcolor:"".concat(d.badgeBorder,"22")}}},{children:n.jsx(o.EllipsisVertical,{size:11,color:d.badgeText})}))]}))]}))}),"left-row-".concat(l))}),n.jsx("div",{ref:_n,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),n.jsx(i.Box,e.__assign({ref:zt,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:n.jsx(i.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:n.jsxs(i.Box,e.__assign({onClick:function(n){n.stopPropagation(),In.open&&On===yt?Mn():(Pn(yt),Ft(Pt(n.currentTarget,{title:"",content:"",evaluationResult:bt,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,yt,!0,e.__assign(e.__assign({},At),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:At.badgeBg,color:At.badgeText,border:"1px solid ".concat(At.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=St?St:n.jsx(f.default,{}),n.jsx(i.Box,e.__assign({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n.jsx(l.ButtonCognitiveIcon,{})})),n.jsx(o.ChevronDown,{size:11,style:{transform:In.open&&On===yt?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),n.jsxs(i.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},xe?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[Ae&&n.jsx(r.default,{sections:11}),n.jsx(i.Box,e.__assign({ref:Ut,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"40px",display:"flex",alignItems:"center",overflowX:"hidden"}},{children:n.jsx(i.Tooltip,e.__assign({title:Wn,placement:"top"},{children:n.jsx(i.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:Wn}))}))})),n.jsxs(i.Box,e.__assign({ref:pn,onScroll:fi,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},xe?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-150px",pl:"165px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:hn,style:{width:"100%",height:"0px",flexShrink:0}}),nt&&$n.map(function(t,l){var r,u,c=t,a=!1,s=null,d=-1;if(xe){d=Xn.findIndex(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(c.selfIndex))&&e.selfIndex>=0});var v=Xn.findIndex(function(e,n){var t;return ze.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(c.selfIndex))});(a=-1!==v)&&(s=ti(v,"left"))}else(a=ze.has(l))&&(s=ti(l,"right"));var g=xe&&-1!==d?ti(d,"left"):ti(l,"right"),p=xe?-1!==d||!(null===(r=c.refIndexes)||void 0===r?void 0:r.length)&&Xn.some(function(e){return e.id&&e.id===c.id}):Boolean(Xn[l]),h=xe?c.selfIndex<0||!p:!Xn[l],x=it.rightNums.get(c.id);return n.jsx(i.Box,e.__assign({ref:dt.current[l],sx:{mb:1,width:"100%"}},{children:n.jsxs(i.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[n.jsx(i.Box,e.__assign({ref:ct.current[l],sx:e.__assign({width:"100%",display:"flex"},a&&s&&{borderRadius:"6px",outline:"2px solid ".concat(s.badgeBorder),outlineOffset:"1px"})},{children:n.jsx(R.default,{section:t,idx:l,columnKey:"right",colRef:pt("right-accordion-".concat(l)),mb:0,parentNodeId:(null===(u=null==Z?void 0:Z.input_index_map)||void 0===u?void 0:u[1])||"",isExpanded:xe?!!Dt["right-".concat(l)]:!!Dt[String(l)],treeData:Z,proposedSections:Xn,existingSections:$n,deviationNumberRegistry:Zn,getBadgeRef:xt,getSectionCompareStyle:ti,connectedSections:ze,openMoreFunctionsPopup:Mt,openSummaryPopup:Ei,deviationNodeIdToView:null==se?void 0:se.id,deviationTargetParentId:Ti,onToggle:function(){Ri(),jt(l,"right")},navigation:t.id?Si[t.id]:null,showOpenNodeRef:Ai,resolvedMarkdownStyles:vn,maintainRelativeOrder:xe,showDeviationBadges:_e,renderSubSections:Di,isProposingFix:fe,proposingFixNodeId:ge,isRedlineFlow:pe,collisionKey:"".concat(De?"1":"0","-").concat(String(null!=Ve?Ve:""))})})),xe&&g&&n.jsx(i.Box,e.__assign({ref:st.current[l],"data-section-id":c.id,onClick:function(e){var n,t,i;if(h){var o=re.enableDeviationSchemaBackwardCompatibility?null!==(n=c.evaluationResult)&&void 0!==n?n:null:null!==(i=null===(t=c.evaluationResult)||void 0===t?void 0:t[0])&&void 0!==i?i:null;Ei(e,String(l),h,o)}},sx:{position:"absolute",top:"18px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:h?"4px":"0px",fontSize:"11px",bgcolor:g.badgeBg,color:g.badgeText,border:"1px solid ".concat(g.badgeBorder),borderRadius:h?"12px":"10px",px:h?1.2:1,py:.3,fontWeight:h?600:700,cursor:h?"pointer":"default",whiteSpace:"nowrap",zIndex:20,boxShadow:h?"0 1px 3px rgba(0,0,0,0.07)":"none"}},{children:h?n.jsxs(n.Fragment,{children:[n.jsxs(i.Box,e.__assign({component:"span",onClick:function(e){var n,t,i;e.stopPropagation();var o=re.enableDeviationSchemaBackwardCompatibility?null!==(n=c.evaluationResult)&&void 0!==n?n:null:null!==(i=null===(t=c.evaluationResult)||void 0===t?void 0:t[0])&&void 0!==i?i:null;Ei(e,String(l),h,o)},sx:{display:"inline-flex",alignItems:"center",gap:"4px",px:.2,cursor:"pointer",borderRight:"1px solid ".concat(g.badgeBorder),"&:hover":{bgcolor:"".concat(g.badgeBorder,"22")}}},{children:[null!=x&&n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(g.badgeBorder)}},{children:x})),n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",px:.25}},{children:!re.isLoading||null!=c.evaluationResult&&void 0!==c.evaluationResult?g.label?"".concat(g.label):"100% Deviation":n.jsx(f.default,{color:g.badgeText})}))]})),n.jsx(i.Box,e.__assign({component:"span",onClick:function(e){e.stopPropagation();var n=xe?Xn.find(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(c.selfIndex)})||{title:"",content:""}:Xn[l]||{title:"",content:""};Mt(e,n,h,c,l,g)},sx:{display:"inline-flex",alignItems:"center",px:.2,cursor:"pointer","&:hover":{bgcolor:"".concat(g.badgeBorder,"22")}}},{children:n.jsx(o.EllipsisVertical,{size:11,color:g.badgeText})}))]}):null!=x?x:""}))]}))}),"right-row-".concat(l))}),n.jsx("div",{ref:xn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))};
2
2
  //# sourceMappingURL=CognitiveCompare.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as n,__spreadArray as e}from"tslib";import{jsxs as t,jsx as i,Fragment as o}from"react/jsx-runtime";import{useState as r,useRef as l,useMemo as u,useEffect as c,useCallback as a}from"react";import{Box as d,Snackbar as s,Alert as v,Tooltip as p,Typography as f}from"@mui/material";import{ChevronDown as g,EllipsisVertical as h}from"lucide-react";import{ButtonCognitiveIcon as m}from"../../assests/svg/ButtonCognitiveIcon.js";import x from"./OverlayComponent.js";import{safeStringify as y,extractDeviationScore as b,generateColorPalette as S,DEVIATION_BADGE_SEPARATOR as R,findKeyPathByNodeId as C,getFirstDeviationOutputValue as I,getFirstDeviationColor as B,hasValue as w,getBentArrowPath as T,smoothScrollTo as _,hasMeaningfulRedlineTags as F,resetClauseHighlight as E,scrollAndHighlightClause as D}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as N,DEFAULT_FIELD_CONFIG as A,DEFAULT_COMPARISON_CONFIG as M}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import{EMPTY_SUMMARY_POPUP_STATE as k,DEFAULT_DEVIAION_COLOR as P,DEFAULT_COMPONENT_HEADER_TEXT as j}from"./CognitiveCompareConstants.js";import H from"./CognitivePopup.js";import L from"./MoreFunctionsPopup.js";import O from"./LoaderComponent.js";import z from"./components/ThreeDotsLoader.js";import{useCognitiveTreeData as W}from"./hooks/useCompareData.js";import{useComparePopups as q}from"./hooks/useComparePopups.js";import{useSectionRefs as Y}from"./hooks/useSectionRefs.js";import{useAccordionState as K}from"./hooks/useAccordionState.js";import{useDeviationNavigation as V}from"./hooks/useDeviationNavigation.js";import X from"./components/CompareHeader.js";import $ from"./components/SectionAccordion.js";import J from"./components/SubSectionAccordion.js";import U from"./components/CognitiveSummaryPopup.js";import G from"./components/connectedLines.js";var Q=function(Q){var Z,nn,en,tn,on,rn,ln,un,cn,an,dn,sn,vn,pn,fn,gn,hn,mn,xn,yn,bn,Sn,Rn,Cn,In,Bn,wn=Q.componentHeaderText,Tn=void 0===wn?j:wn,_n=Q.treeData,Fn=Q.comparisonConfig,En=Q.leftColumnTitleText,Dn=Q.rightColumnTitleText,Nn=Q.markdownStyles,An=Q.resetTrigger,Mn=Q.displayConfig,kn=void 0===Mn?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1}:Mn,Pn=Q.popupConfig,jn=Q.deviationData,Hn=void 0===jn?{}:jn,Ln=Q.deviationNodeIdToView,On=Q.resetDeviationNodeId,zn=Q.isProposingFix,Wn=void 0!==zn&&zn,qn=Q.proposingFixNodeId,Yn=Q.isRedlineFlow,Kn=r(kn.maintainRelativeOrder),Vn=Kn[0],Xn=Kn[1],$n=!!Vn||!!(null==kn?void 0:kn.showDeviationBadges),Jn=r(!1),Un=Jn[0],Gn=Jn[1],Qn=r(!1),Zn=Qn[0],ne=Qn[1],ee=r(null),te=ee[0],ie=ee[1],oe=r(!1),re=oe[0],le=oe[1],ue=r(null===(nn=null!==(Z=null==_n?void 0:_n.newEvaluationResult)&&void 0!==Z?Z:null==kn?void 0:kn.enableDeviationSchemaBackwardCompatibility)||void 0===nn||nn)[0],ce=r(!1),ae=ce[0],de=ce[1],se=r(!1),ve=se[0],pe=se[1],fe=r(null),ge=fe[0],he=fe[1],me=l(!1),xe=r(new Set),ye=xe[0],be=xe[1],Se=r([]),Re=Se[0],Ce=Se[1],Ie=l(null),Be=l(null),we=l(null),Te=l(new Set),_e=l(!1),Fe=l(null),Ee=l({}),De=l([]),Ne=l(!1),Ae=l(!1),Me=l(null),ke=l(function(){}),Pe=u(function(){return(null==_n?void 0:_n.cognitive_decisioning)||{}},[_n]),je=r({width:0,height:0}),He=je[0],Le=je[1],Oe=u(function(){return n(n({},N),Nn)},[Nn]),ze=l(null),We=l(null),qe=l(null),Ye=l(null),Ke=l(null),Ve=l(null),Xe=l(null),$e=l(null),Je=l(!1),Ue=l(null),Ge=l(null),Qe=q(ze),Ze=Qe.cognitivePopup,nt=Qe.setCognitivePopup,et=Qe.moreFunctions,tt=Qe.setMoreFunctions,it=Qe.position,ot=Qe.setPosition,rt=Qe.activeBadgeId,lt=Qe.summaryPopup,ut=Qe.setSummaryPopup,ct=Qe.closeSummaryPopup,at=Qe.setActiveBadgeId,dt=Qe.popupRef,st=Qe.closeCognitivePopup,vt=Qe.closeMoreFunctionsPopup,pt=u(function(){var n,e,t,i,o,r,l;return{fields:null!==(n=null==Fn?void 0:Fn.fields)&&void 0!==n?n:A,thresholds:{high:null!==(t=null===(e=null==Fn?void 0:Fn.thresholds)||void 0===e?void 0:e.high)&&void 0!==t?t:M.thresholds.high,medium:null!==(o=null===(i=null==Fn?void 0:Fn.thresholds)||void 0===i?void 0:i.medium)&&void 0!==o?o:M.thresholds.medium,exact:null!==(l=null===(r=null==Fn?void 0:Fn.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:M.thresholds.exact}}},[Fn]),ft=r(null),gt=ft[0];ft[1];var ht=null===(on=null===(en=null==_n?void 0:_n.documents)||void 0===en?void 0:en[null===(tn=null==_n?void 0:_n.input_index_map)||void 0===tn?void 0:tn[0]])||void 0===on?void 0:on.title,mt=null===(un=null===(rn=null==_n?void 0:_n.documents)||void 0===rn?void 0:rn[null===(ln=null==_n?void 0:_n.input_index_map)||void 0===ln?void 0:ln[1]])||void 0===un?void 0:un.title,xt=y(En||ht||"Uploaded Contract"),yt=y(Dn||mt||"Reference Template"),bt=W(_n,Vn,Hn,pt,ue),St=bt.activeProposed,Rt=bt.existingRule,Ct=bt.proposedSections,It=bt.existingSections,Bt=bt.visibleFields,wt=bt.parentDeviationRecord,Tt=bt.deviationNumberRegistry,_t=bt.parseError;c(function(){_t&&ie("Failed to load comparison: ".concat(_t))},[_t]);var Ft=Ct.length>0||It.length>0,Et=u(function(){if(!Yn)return"off";var n=0,e=0,t=function(i){Array.isArray(i)&&i.forEach(function(i){var o,r=(null==i?void 0:i.content)||"";F(r)&&(n+=1,e+=String(r).length),(null===(o=null==i?void 0:i.subsections)||void 0===o?void 0:o.length)&&t(i.subsections)})};return t(Ct),t(It),"".concat(n,":").concat(e)},[Yn,Ct,It]);c(function(){Yn&&"off"!==Et&&"0:0"!==Et&&(Be.current=null,De.current=[],requestAnimationFrame(function(){var n;null===(n=ke.current)||void 0===n||n.call(ke)}))},[Yn,Et]);var Dt=u(function(){var n=new Map,e=new Map,t=1;if(Vn)Ct.forEach(function(e){!e.title&&!e.content||e.id&&n.set(e.id,t++)}),It.forEach(function(i){if(i.id){var o=Ct.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(i.selfIndex)});if(o.length>0){var r=o.map(function(e){return n.get(e.id)}).filter(Boolean);e.set(i.id,r.join(", "))}else e.set(i.id,String(t++))}});else for(var i=Math.max(Ct.length,It.length),o=0;o<i;o++){var r=Ct[o],l=It[o];r?(n.set(r.id,t),l&&e.set(l.id,String(t)),t++):l&&e.set(l.id,String(t++))}return{leftNums:n,rightNums:e}},[Ct,It,Vn]),Nt=Y(Bt.map(function(n){return n.key}),Math.max(Ct.length,It.length)),At=Nt.leftRefs,Mt=Nt.rightRefs,kt=Nt.sectionLeftRefs,Pt=Nt.sectionRightRefs,jt=Nt.lhsBadgeRefs,Ht=Nt.rhsBadgeRefs,Lt=Nt.sectionRightRowRefs,Ot=Nt.subSectionLeftRefs,zt=Nt.subSectionRightRefs,Wt=Nt.sectionRowRefs,qt=Nt.getSectionRowRef,Yt=Nt.getSubSectionRef,Kt=Nt.getBadgeRef,Vt=Rt.analysis,Xt=y(null===(an=null===(cn=null==Vt?void 0:Vt.rule_difference_comparison)||void 0===cn?void 0:cn.summary)||void 0===an?void 0:an.overall_summary),$t=!!Xt.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),Jt=null!==(dn=null==_n?void 0:_n.base_root_id)&&void 0!==dn?dn:"-1";null==_n||_n[Jt];var Ut=ue?null!==(Rn=null!==(yn=Hn&&(null===(xn=null==Hn?void 0:Hn[Jt])||void 0===xn?void 0:xn.evaluation_result))&&void 0!==yn?yn:null===(Sn=null===(bn=null==_n?void 0:_n.nodes)||void 0===bn?void 0:bn[Jt])||void 0===Sn?void 0:Sn.evaluation_result)&&void 0!==Rn?Rn:null:null!==(mn=null!==(pn=Hn&&(null===(vn=null===(sn=null==Hn?void 0:Hn[Jt])||void 0===sn?void 0:sn.evaluation_result)||void 0===vn?void 0:vn[0]))&&void 0!==pn?pn:null===(hn=null===(gn=null===(fn=null==_n?void 0:_n.nodes)||void 0===fn?void 0:fn[Jt])||void 0===gn?void 0:gn.evaluation_result)||void 0===hn?void 0:hn[0])&&void 0!==mn?mn:null,Gt=b(Ut),Qt=S(null!==(Bn=null===(In=null===(Cn=null==Ut?void 0:Ut.evaluation_outputs)||void 0===Cn?void 0:Cn.metadata)||void 0===In?void 0:In.label_color)&&void 0!==Bn?Bn:""),Zt=function(){Te.current.forEach(function(n){E(n)}),Te.current.clear()},ni=a(function(){var n,e,t,i,o,r;Zt(),le(!1),Ae.current=!1,Be.current=null;var l=Me.current,u=yi.current;if(null!==l)if("string"==typeof l&&l.includes(R)){var c=l.split(R);(a=(null===(n=Ot.current[c[2]])||void 0===n?void 0:n.current)||(null===(e=kt.current[Number(c[2])])||void 0===e?void 0:e.current))&&(a.style.paddingTop="0px")}else{var a;(a=null===(t=kt.current[l])||void 0===t?void 0:t.current)&&(a.style.paddingTop="0px")}if(null!==u)if("string"==typeof u&&u.includes(R)){c=u.split(R);(d=(null===(i=zt.current[c[3]])||void 0===i?void 0:i.current)||(null===(o=Pt.current[Number(c[3])])||void 0===o?void 0:o.current))&&(d.style.paddingTop="0px")}else{var d;(d=null===(r=Pt.current[u])||void 0===r?void 0:r.current)&&(d.style.paddingTop="0px")}he(null),Me.current=null,yi.current=null,de(!1),ne(!1),Ye.current&&(Ye.current.style.height="0px"),Ke.current&&(Ke.current.style.height="0px"),Ve.current&&(Ve.current.style.height="0px"),Xe.current&&(Xe.current.style.height="0px")},[]),ei=a(function(){Zt(),ni(),be(new Set),Ce([]),De.current=[],Bi([]),_i(null),ut(k),st(),requestAnimationFrame(function(){var n;null===(n=ke.current)||void 0===n||n.call(ke)})},[]),ti=l(ei);c(function(){ti.current=ei},[ei]),c(function(){An&&ti.current()},[An]);var ii=K({maintainRelativeOrder:!!Vn,proposedSections:Ct,existingSections:It,activeSideBySideSection:ge,connectedSections:ye,resetSideBySide:ni,setConnectedSections:be,setConnectedLines:Ce,cachedConnectedPositions:De,svgContainerRef:Ie,isAnimatingRef:_e,animationTimerRef:Fe,calculateLinesRef:ke,sectionLeftRefs:kt,sectionRightRefs:Pt,subSectionLeftRefs:Ot,subSectionRightRefs:zt}),oi=ii.expandedSections,ri=ii.setExpandedSections,li=ii.expandedSubSections,ui=ii.setExpandedSubSections,ci=ii.toggleSection,ai=a(function(e,t,i,o,r,l,u){var c,a,d,s=y(null==t?void 0:t.id)||y(null==i?void 0:i.id)||"",v=(s?Pe[s]:null)||(null==t?void 0:t.cognitiveData)||(null==i?void 0:i.cognitiveData)||{section_id:s,decisioning:[],gap:[],relevance_score:0},p=null!==(a=null===(c=Wt.current[o])||void 0===c?void 0:c.current)&&void 0!==a?a:null;return{isLoading:null!==(d=null==kn?void 0:kn.isLoading)&&void 0!==d&&d,open:!0,sectionTitle:(null==t?void 0:t.title)?null==t?void 0:t.title:"No Counterpart",refSectionTitle:(null==i?void 0:i.title)?null==i?void 0:i.title:"No Counterpart",cognitiveData:v,anchorEl:e,sectionAnchorEl:p,badgeStyle:l||null,sectionIdx:o,docData:{documents:null==_n?void 0:_n.documents,input_index_map:null==_n?void 0:_n.input_index_map},deviationData:function(){var e,r,l=(null==t?void 0:t.evaluationResult)||(null==i?void 0:i.evaluationResult)||null,u=function(e){var t=function(n){if(!n||"object"!=typeof n)return null;var e=null==n?void 0:n.deviation_entries;if(e&&"object"==typeof e){var t=Object.keys(e).sort(function(n,e){return Number(n)-Number(e)})[0];if(t&&e[t])return e[t]}var i=Object.keys(n).filter(function(n){return/^\d+$/.test(n)}).sort(function(n,e){return Number(n)-Number(e)});if(i.length&&n[i[0]])return n[i[0]];var o=null==n?void 0:n.deviations;if(o&&"object"==typeof o){var r=Object.keys(o).sort(function(n,e){return Number(n)-Number(e)})[0];if(r&&o[r])return o[r]}return null}(e);return t?n(n({},e),{deviation_summary:(null==e?void 0:e.deviation_summary)||(null==t?void 0:t.deviation_summary),deviation_title:(null==e?void 0:e.deviation_title)||(null==t?void 0:t.deviation_title),deviation_impact:(null==e?void 0:e.deviation_impact)||(null==t?void 0:t.deviation_impact),deviation_explanation:(null==e?void 0:e.deviation_explanation)||(null==t?void 0:t.deviation_explanation),evaluation_outputs:(null==e?void 0:e.evaluation_outputs)||(null==t?void 0:t.evaluation_outputs),cognitive_decisioning:(null==e?void 0:e.cognitive_decisioning)||(null==t?void 0:t.cognitive_decisioning)}):e};if(!("string"==typeof o&&o.includes(R)))return u(l);var c=o.split(R)[1];if(!c)return l;var a=(null==t?void 0:t.evaluationResult)||(null==i?void 0:i.evaluationResult)||{},d=(null===(e=null==a?void 0:a.deviation_entries)||void 0===e?void 0:e[c])||(null===(r=null==a?void 0:a.deviations)||void 0===r?void 0:r[c])||null;return d?n(n(n({},a),d),{deviation_summary:(null==d?void 0:d.deviation_summary)||(null==a?void 0:a.deviation_summary),deviation_title:(null==d?void 0:d.deviation_title)||(null==a?void 0:a.deviation_title),deviation_impact:(null==d?void 0:d.deviation_impact)||(null==a?void 0:a.deviation_impact),deviation_explanation:(null==d?void 0:d.deviation_explanation)||(null==a?void 0:a.deviation_explanation),evaluation_outputs:(null==d?void 0:d.evaluation_outputs)||(null==a?void 0:a.evaluation_outputs),cognitive_decisioning:(null==d?void 0:d.cognitive_decisioning)||(null==a?void 0:a.cognitive_decisioning)}):u(l)}(),isOrphan:!!r}},[Pe,_n]),di=a(function(n){vt(),ot(null),nt(n)},[vt]),si=function(n,e,t,i,o,r){var l;if(n.stopPropagation(),et.open&&et.sectionIdx===o)vt();else{var u=n.currentTarget,c="left";(null===(l=qe.current)||void 0===l?void 0:l.contains(u))&&(c="right");Zt(),Ae.current&&ni(),be(new Set),Ce([]),De.current=[],st(),lt.open?$i():ct(),requestAnimationFrame(function(){var n=function(){var n,e,t,i;if("string"==typeof o&&o.includes(R)){var r=o.split(R),l="".concat(r[0]).concat(R).concat(r[1]);return"right"===c?null===(n=Ht.current[l])||void 0===n?void 0:n.current:null===(e=jt.current[l])||void 0===e?void 0:e.current}return"right"===c?null===(t=Ht.current[o])||void 0===t?void 0:t.current:null===(i=jt.current[o])||void 0===i?void 0:i.current}()||u;tt(ai(n,e,i,o,t,r))})}},vi=a(function(){null!==et.sectionIdx&&et.anchorEl?di(n(n({},et),{open:!0})):vt()},[et,vt,di]),pi=a(function(){var n=et.sectionIdx,e=et.isOrphan;vt(),ct(),null!==n&&(e?ie("No counterpart exists to connect to."):(Zt(),Ae.current&&ni(),Ce([]),De.current=[],be(function(e){return e.has(n)?new Set:new Set([n])}),setTimeout(function(){ke.current&&ke.current()},50)))},[et.sectionIdx,et.isOrphan,vt,ct,ni]),fi=a(function(){var n=we.current;if(n){we.current=null;var e=Ct.findIndex(function(e){return e.id===n}),t=It.findIndex(function(e){return e.id===n}),i=-1===e?C(Ct,n):null,o=-1===t?C(It,n):null,r=-1!==e?e:i?Number(i.split("-")[0]):-1,l=-1!==t?t:o?Number(o.split("-")[0]):-1,u=function(n,e,t,i){var o,r,l,u;return-1!==n?null!==(r=null===(o=t.current[n])||void 0===o?void 0:o.current)&&void 0!==r?r:null:e&&null!==(u=null===(l=i.current[e])||void 0===l?void 0:l.current)&&void 0!==u?u:null},c=function(n,e,t){void 0===t&&(t=30);var i=0,o=function(){var r=n();r&&0!==r.getBoundingClientRect().height?(Te.current.add(r),D(r,e)):i++<t&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(Vn)-1!==r&&$e.current&&c(function(){return u(e,i,kt,Ot)},$e.current),-1!==l&&qe.current&&c(function(){return u(t,o,Pt,zt)},qe.current);else{var a=ze.current;if(!a)return;c(function(){return-1!==r?u(e,i,kt,Ot):u(t,o,Pt,zt)},a)}}},[Ct,It,Vn,kt,Pt,Ot,zt,$e,qe,ze]),gi=a(function(e){if(e){Zt(),ni(),be(new Set),Ce([]),De.current=[],ct(),st();var t=Ct.findIndex(function(n){return n.id===e}),i=It.findIndex(function(n){return n.id===e}),o=-1===t?C(Ct,e):null,r=-1===i?C(It,e):null;if(-1!==t||o||-1!==i||r){var l=-1!==t?t:o?Number(o.split("-")[0]):-1,u=-1!==i?i:r?Number(r.split("-")[0]):-1;we.current=e,ri(function(e){var t,i=n({},e),o=!1;-1!==l&&(i[t=Vn?"left-".concat(l):String(l)]||(i[t]=!0,o=!0));-1!==u&&(i[t=Vn?"right-".concat(u):String(u)]||(i[t]=!0,o=!0));return o?i:e}),ui(function(e){var t=n({},e),i=!1,l=function(n){for(var e=n.split("-"),o=e[0],r=1;r<e.length;r++)o+="-".concat(e[r]),t[o]||(t[o]=!0,i=!0)};return o&&l(o),r&&l(r),i?t:e}),setTimeout(function(){requestAnimationFrame(function(){we.current===e&&hi.current()})},50)}else console.warn('scrollToAndHighlightClause: nodeId "'.concat(e,'" not found'))}},[Ct,It,Vn,ri,ui,ni,ct,st]),hi=l(fi);c(function(){hi.current=fi},[fi]);var mi=l(null),xi=l(null),yi=l(null),bi=l(null),Si=l(null),Ri=l(null),Ci=r([]),Ii=Ci[0],Bi=Ci[1];l(null);var wi=r(null),Ti=wi[0],_i=wi[1];c(function(){if(gt){var n=pt.fields.find(function(n){return n.analysisKey===gt||n.key===gt});if(n){var e=At.current[n.key]||Mt.current[n.key];(null==e?void 0:e.current)&&setTimeout(function(){return e.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[gt,pt.fields]);var Fi=a(function(n){var e,t,i,o,r,l,u,c,a,d=null===(e=null==Vt?void 0:Vt.rule_difference_comparison)||void 0===e?void 0:e.fields;if(!d||!d[n])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var s=d[n],v=(null==s?void 0:s.relation)||(null===(i=null===(t=null==s?void 0:s.highlights)||void 0===t?void 0:t.ruleA_spans)||void 0===i?void 0:i.length)||(null===(r=null===(o=null==s?void 0:s.highlights)||void 0===o?void 0:o.ruleB_spans)||void 0===r?void 0:r.length)||(null==s?void 0:s.mappings)&&s.mappings.length>0;if(s.mappings){var p=s.mappings[0]||{};return{score:s.score,relation:p.relation||"",highlightsA:(null===(l=p.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(u=p.highlights)||void 0===u?void 0:u.ruleB_spans)||[],hasContent:!!v}}return{score:s.score,relation:s.relation||"",highlightsA:(null===(c=s.highlights)||void 0===c?void 0:c.ruleA_spans)||[],highlightsB:(null===(a=s.highlights)||void 0===a?void 0:a.ruleB_spans)||[],hasContent:!!v}},[Vt]),Ei=a(function(e,t){var i,o,r;void 0===t&&(t="left");var l=null,u=null;if("left"===t)if(l=Ct[e],Vn&&l){var c=It.filter(function(n){var e;return null===(e=l.refIndexes)||void 0===e?void 0:e.includes(n.selfIndex)});u=c.find(function(n){return n.evaluationResult})||c[0]}else u=It[e];else if(u=It[e],Vn&&u){var a=Ct.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(u.selfIndex)});l=a.find(function(n){return n.evaluationResult})||a[0]}else l=Ct[e];var d=(null==l?void 0:l.relation)&&"not_defined"!==l.relation,s=(null==u?void 0:u.relation)&&"not_defined"!==u.relation,v=!(!(null==l?void 0:l.cognitiveData)&&!(null==u?void 0:u.cognitiveData));if(!d&&!s&&!v)return n(n({},S(P)),{label:"Not Defined"});var p=null!==(o=null!==(i=null==l?void 0:l.evaluationResult)&&void 0!==i?i:null==u?void 0:u.evaluationResult)&&void 0!==o?o:null,f=I(p),g=B(p);return n(n({},S(g)),null!=p?{label:null!==(r=f)&&void 0!==r?r:""}:{label:null})},[Ct,It,Pe,pt,Vn]),Di=a(function(e){for(var t,i,o,r,l,u=e.split("-").map(Number),c=Ct[u[0]],a=It[u[0]],d=1;d<u.length;d++)(null==c?void 0:c.subsections)&&(c=c.subsections[u[d]]),(null==a?void 0:a.subsections)&&(a=a.subsections[u[d]]);if(!c&&!a)return null;var s=(null==c?void 0:c.relation)&&"not_defined"!==c.relation,v=(null==a?void 0:a.relation)&&"not_defined"!==a.relation,p=y(null==c?void 0:c.id)||y(null==a?void 0:a.id)||"",f=!(!(null==c?void 0:c.cognitiveData)&&!(null==a?void 0:a.cognitiveData));if(!s&&!v&&!f)return n(n({},S(P)),{label:"Not Defined"});null!==(i=null!==(t=null==c?void 0:c.cognitiveRelevanceScore)&&void 0!==t?t:null==a?void 0:a.cognitiveRelevanceScore)&&void 0!==i||p&&(null===(o=Pe[p])||void 0===o||o.relevance_score);var g=null!==(l=null!==(r=null==c?void 0:c.evaluationResult)&&void 0!==r?r:null==a?void 0:a.evaluationResult)&&void 0!==l?l:null,h=I(g),m=B(g);return n(n({},S(m)),null!=g?{label:null!=h?h:""}:{label:null})},[Ct,It,Pe,pt]),Ni=a(function(e,t){var i,o,r,l,u,c,a,d,s,v,p,f,g,h,m,x,y;if(!e||null==t)return null;var b=null!==(a=null!==(u=null!==(o=null===(i=null==Hn?void 0:Hn[e])||void 0===i?void 0:i.evaluation_result)&&void 0!==o?o:null===(l=null===(r=null==_n?void 0:_n.nodes)||void 0===r?void 0:r[e])||void 0===l?void 0:l.evaluation_result)&&void 0!==u?u:null===(c=null==_n?void 0:_n[e])||void 0===c?void 0:c.evaluation_result)&&void 0!==a?a:null;if(!b||"object"!=typeof b)return null;var R=null!==(p=null!==(s=null===(d=null==b?void 0:b.deviations)||void 0===d?void 0:d[t])&&void 0!==s?s:null===(v=null==b?void 0:b.deviation_entries)||void 0===v?void 0:v[t])&&void 0!==p?p:null==b?void 0:b[t],C=null!==(y=null!==(h=null===(g=null===(f=null==R?void 0:R.evaluation_outputs)||void 0===f?void 0:f.metadata)||void 0===g?void 0:g.label_color)&&void 0!==h?h:null===(x=null===(m=null==b?void 0:b.evaluation_outputs)||void 0===m?void 0:m.metadata)||void 0===x?void 0:x.label_color)&&void 0!==y?y:P;return n(n({},S(C)),{label:null})},[Hn,_n]),Ai=a(function(){Zt(),ri({}),ui({}),ni(),be(new Set),Ce([]),De.current=[],ct(),st(),vt(),requestAnimationFrame(function(){ke.current&&ke.current()})},[ri,ui,ni,ct,st,vt]),Mi=u(function(){return Object.values(oi).some(Boolean)||Object.values(li).some(Boolean)},[oi,li]),ki=a(function(){var n,e,t,i,o,r,l,u,c,a,d,s,v,p,f,g,h,m,x,y,b,S,C;if(!Je.current&&!_e.current){Je.current=!0;try{if(!mi.current)return;var I=function(n){var e=n.split("-"),t=e[0];if(!oi[t]&&!1===Vn)return!1;if(Vn&&!oi["left-".concat(t)]&&!oi["right-".concat(t)]&&!oi[t])return!1;for(var i=t,o=1;o<e.length-1;o++)if(i+="-".concat(e[o]),!li[i])return!1;return!0},B=mi.current.getBoundingClientRect();Le({width:B.width,height:B.height});var _=[];if(Bt.forEach(function(n){var e,t,i=n.key,o=null===(e=At.current[i])||void 0===e?void 0:e.current,r=null===(t=Mt.current[i])||void 0===t?void 0:t.current;o&&r&&(o.style.height="auto",r.style.height="auto",o.style.minHeight="0px",r.style.minHeight="0px")}),!_e.current){for(var F=0;F<Math.max(Ct.length,It.length);F++){var E=null===(n=kt.current[F])||void 0===n?void 0:n.current,D=null===(e=Pt.current[F])||void 0===e?void 0:e.current;E&&(E.style.height="auto",E.style.minHeight="0px"),D&&(D.style.height="auto",D.style.minHeight="0px")}Vn||Object.keys(Ot.current).forEach(function(n){var e,t;if(I(n)){var i=null===(e=Ot.current[n])||void 0===e?void 0:e.current,o=null===(t=zt.current[n])||void 0===t?void 0:t.current;i&&o&&(i.style.height="auto",o.style.height="auto",i.style.minHeight="0px",o.style.minHeight="0px")}})}var N={};Bt.forEach(function(n){var e,t,i=n.key,o=null===(e=At.current[i])||void 0===e?void 0:e.current,r=null===(t=Mt.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),u=r.getBoundingClientRect();N[i]=Math.max(l.height,u.height)}});var A={left:{},right:{}},M={};if(!_e.current)if(Vn){if(re&&null!==ge)if("number"==typeof ge){var k=ge,P=Ct[k],j=null===(o=kt.current[k])||void 0===o?void 0:o.current;j&&P&&(P.refIndexes||[]).forEach(function(n){var e,t=It.findIndex(function(e){return e.selfIndex===n}),i=null===(e=Pt.current[t])||void 0===e?void 0:e.current;if(i&&(oi["left-".concat(k)]||oi["right-".concat(t)])){var o=Math.max(j.getBoundingClientRect().height,i.getBoundingClientRect().height);A.left[k]=Math.max(A.left[k]||0,o),A.right[t]=Math.max(A.right[t]||0,o)}})}else{var H=ge.split(R)[2];if(H){E=null===(r=Ot.current[H])||void 0===r?void 0:r.current,D=null===(l=zt.current[H])||void 0===l?void 0:l.current;if(E&&D){L=Math.max(E.getBoundingClientRect().height,D.getBoundingClientRect().height);M[H]=Math.max(M[H]||0,L)}}}}else{Object.keys(Ot.current).forEach(function(n){var e,t;if(I(n)){var i=null===(e=Ot.current[n])||void 0===e?void 0:e.current,o=null===(t=zt.current[n])||void 0===t?void 0:t.current;if(i&&o&&null!==i.offsetParent&&null!==o.offsetParent){var r=i.getBoundingClientRect(),l=o.getBoundingClientRect(),u=Math.max(r.height,l.height);M[n]=u,i.style.minHeight="".concat(u,"px"),o.style.minHeight="".concat(u,"px")}}});for(F=0;F<Math.min(Ct.length,It.length);F++){var E=null===(t=kt.current[F])||void 0===t?void 0:t.current,D=null===(i=Pt.current[F])||void 0===i?void 0:i.current;if(E&&D){var L=Math.max(E.getBoundingClientRect().height,D.getBoundingClientRect().height);A.left[F]=L,A.right[F]=L}}}if(Bt.forEach(function(n){var e,t,i=n.key,o=null===(e=At.current[i])||void 0===e?void 0:e.current,r=null===(t=Mt.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=N[i];o.style.minHeight="".concat(l,"px"),r.style.minHeight="".concat(l,"px")}}),_e.current||(Object.entries(A.left).forEach(function(n){var e,t=n[0],i=n[1],o=null===(e=kt.current[Number(t)])||void 0===e?void 0:e.current;o&&(o.style.minHeight="".concat(i,"px"))}),Object.entries(A.right).forEach(function(n){var e,t=n[0],i=n[1],o=null===(e=Pt.current[Number(t)])||void 0===e?void 0:e.current;o&&(o.style.minHeight="".concat(i,"px"))}),Vn||Object.keys(M).forEach(function(n){var e,t,i=null===(e=Ot.current[n])||void 0===e?void 0:e.current,o=null===(t=zt.current[n])||void 0===t?void 0:t.current;if(i&&o&&M[n]){var r=M[n];i.style.minHeight="".concat(r,"px"),o.style.minHeight="".concat(r,"px")}})),Vn)Ct.forEach(function(n,e){var t;(null===(t=kt.current[e])||void 0===t?void 0:t.current)&&(n.refIndexes||[]).forEach(function(n){var t,i,o,r,l,u,c,a,d,s,v=It.findIndex(function(e){return e.selfIndex===n});if(-1!==v){var p=null===(t=jt.current[e])||void 0===t?void 0:t.current,f=null===(i=Ht.current[v])||void 0===i?void 0:i.current;if(p&&f){var g=p.getBoundingClientRect(),h=f.getBoundingClientRect(),m=g.right-B.left,x=h.left-B.left,y=g.top+g.height/2-B.top,b=h.top+h.height/2-B.top;if(re&&ge===e){var S=null!==(r=null===(o=$e.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==r?r:0,R=null!==(u=null===(l=qe.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==u?u:0,C=S+(null!==(a=null===(c=$e.current)||void 0===c?void 0:c.clientHeight)&&void 0!==a?a:1/0),I=R+(null!==(s=null===(d=qe.current)||void 0===d?void 0:d.clientHeight)&&void 0!==s?s:1/0),w=g.top+g.height/2,T=h.top+h.height/2,F=function(n,e,t){return Math.max(e,Math.min(t,n))};y=F(w,S,C)-B.top,b=F(T,R,I)-B.top}var E=Ei(e);E&&_.push({id:"line-".concat(e,"-").concat(v),x1:m,y1:y,x2:x,y2:b,style:E,sectionIdx:e,targetRightIdx:v})}}})});else{for(F=0;F<Math.min(Ct.length,It.length);F++){var O=null===(u=kt.current[F])||void 0===u?void 0:u.current,z=null===(c=Pt.current[F])||void 0===c?void 0:c.current;if(O&&z){var W=O.getBoundingClientRect(),q=z.getBoundingClientRect(),Y=Math.max(W.top,q.top)+18-B.top,K=(null===(a=It[F])||void 0===a?void 0:a.id)||"sec-".concat(F);(Z=Ei(F))&&_.push({id:K,x1:W.right-B.left,y1:Y,x2:q.left-B.left,y2:Y,style:Z,sectionIdx:F,hasCognitive:!!((null===(d=Ct[F])||void 0===d?void 0:d.cognitiveData)||(null===(s=It[F])||void 0===s?void 0:s.cognitiveData)||K&&Pe[K]),isSubSection:!1})}}Object.keys(Ot.current).forEach(function(n){var e,t,i,o,r,l;if(I(n)){var u=null===(e=Ot.current[n])||void 0===e?void 0:e.current,c=null===(t=zt.current[n])||void 0===t?void 0:t.current;if(u&&c){for(var a=n.split("-").map(Number),d=Ct[a[0]],s=It[a[0]],v=1;v<a.length;v++)(null==d?void 0:d.subsections)&&(d=d.subsections[a[v]]),(null==s?void 0:s.subsections)&&(s=s.subsections[a[v]]);var p=!!d&&((null===(i=d.displayTitle)||void 0===i||i)&&w(d.title)),f=!!d&&((null===(o=d.displayContent)||void 0===o||o)&&w(d.content)),g=!!s&&((null===(r=s.displayTitle)||void 0===r||r)&&w(s.title)),h=!!s&&((null===(l=s.displayContent)||void 0===l||l)&&w(s.content));if(p&&f||g&&h){var m=u.getBoundingClientRect(),x=c.getBoundingClientRect(),y=Math.max(m.top,x.top)+16-B.top,b=Di(n);b&&"Not Defined"!==b.label&&_.push({id:"subsec-".concat(n),x1:m.right-B.left,y1:y,x2:x.left-B.left,y2:y,style:b,sectionIdx:a[0],isSubSection:!0,subSectionKeyPath:n,hasCognitive:!(!(null==d?void 0:d.cognitiveData)&&!(null==s?void 0:s.cognitiveData))})}}}})}if(re&&"string"==typeof ge&&ge.includes(R)){var V=ge.split(R),X=V[0],$=V[1],J=V[2],U=(V[3],"".concat(X).concat(R).concat($)),G=null===(v=jt.current[U])||void 0===v?void 0:v.current,Q=null===(p=Ht.current[U])||void 0===p?void 0:p.current;if(G&&Q){var Z,nn=G.getBoundingClientRect(),en=Q.getBoundingClientRect(),tn=nn.right-B.left,on=en.left-B.left,rn=nn.top+nn.height/2-B.top,ln=en.top+en.height/2-B.top;if(Vn){var un=null!==(g=null===(f=$e.current)||void 0===f?void 0:f.getBoundingClientRect().top)&&void 0!==g?g:0,cn=null!==(m=null===(h=qe.current)||void 0===h?void 0:h.getBoundingClientRect().top)&&void 0!==m?m:0,an=un+(null!==(y=null===(x=$e.current)||void 0===x?void 0:x.clientHeight)&&void 0!==y?y:1/0),dn=cn+(null!==(S=null===(b=qe.current)||void 0===b?void 0:b.clientHeight)&&void 0!==S?S:1/0),sn=function(n,e,t){return Math.max(e,Math.min(t,n))};rn=sn(nn.top+nn.height/2,un,an)-B.top,ln=sn(en.top+en.height/2,cn,dn)-B.top}(Z=null!==(C=Ni(X,$))&&void 0!==C?C:Di(J))&&_.push({id:"line-subsec-".concat(U),x1:tn,y1:rn,x2:on,y2:ln,style:Z,sectionIdx:Number(J.split("-")[0]),isSubSection:!0,subSectionKeyPath:ge})}}if(Bi(_),Si.current&&Ri.current){var vn=Si.current.getBoundingClientRect(),pn=Ri.current.getBoundingClientRect(),fn=(vn.top+vn.height/2-B.top+pn.top+pn.height/2-B.top)/2;_i({x1:vn.right-B.left,x2:pn.left-B.left,y:fn})}else _i(null);if(ye.size>0){var gn=[],hn=$e.current,mn=qe.current;if(hn&&mn){var xn=[],yn=hn.getBoundingClientRect().top,bn=mn.getBoundingClientRect().top,Sn=yn+hn.clientHeight,Rn=bn+mn.clientHeight,Cn=hn.scrollTop,In=mn.scrollTop,Bn=B.top,wn=function(n,e,t){return Math.max(e,Math.min(t,n))};ye.forEach(function(n){var e,t,i,o,r,l;if("string"==typeof n&&n.includes(R)){var u=n.split(R),c=u[0],a=u[1],d=u[2],s=(u[3],"".concat(c).concat(R).concat(a)),v=null===(e=jt.current[s])||void 0===e?void 0:e.current,p=null===(t=Ht.current[s])||void 0===t?void 0:t.current;if(!v||!p)return;var f=v.getBoundingClientRect(),g=p.getBoundingClientRect(),h=null!==(i=Ni(c,a))&&void 0!==i?i:Di(d),m=(P=f.right-B.left)+.5*((j=g.left-B.left-0)-P),x=f.top+f.height/2,y=g.top+g.height/2,b=x-yn+Cn,S=y-bn+In,C="conn-subsec-".concat(s);xn.push({lhsScrollY:b,rhsScrollY:S,x1:P,x2:j,containerTop:Bn,leftIdx:n,rhsArrayIdx:n,styleColor:(null==h?void 0:h.badgeBorder)||"#6366F1",styleId:C});var I=wn(x,yn,Sn),w=wn(y,bn,Rn),_=I-Bn,F=w-Bn,E=y>=bn-4&&y<=Rn+4,D="";D=(H=x>=yn-4&&x<=Sn+4)&&E?T(P,_,j,F):H&&!E?"M ".concat(P,",").concat(_," L ").concat(m,",").concat(_," L ").concat(m,",").concat(F):!H&&E?"M ".concat(m,",").concat(_," L ").concat(m,",").concat(F," L ").concat(j,",").concat(F):"M ".concat(m,",").concat(_," L ").concat(m,",").concat(F),gn.push({id:C,pathD:D,style:h,leftIdx:n,rhsArrayIdx:n})}else if(Vn){var N=n,A=Ct[N];if(!(null===(l=null==A?void 0:A.refIndexes)||void 0===l?void 0:l.length))return;A.refIndexes.forEach(function(n){var e,t,i=It.findIndex(function(e){return e.selfIndex===n});if(-1!==i){var o=null===(e=jt.current[N])||void 0===e?void 0:e.current,r=null===(t=Ht.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),u=r.getBoundingClientRect(),c=Ei(N),a=l.right-B.left,d=u.left-B.left-0,s=a+.5*(d-a),v=l.top+l.height/2,p=u.top+u.height/2,f=v-yn+Cn,g=p-bn+In,h="conn-".concat(N,"-").concat(i);xn.push({lhsScrollY:f,rhsScrollY:g,x1:a,x2:d,containerTop:Bn,leftIdx:N,rhsArrayIdx:i,styleColor:(null==c?void 0:c.badgeBorder)||"#6366F1",styleId:h});var m=wn(v,yn,Sn),x=wn(p,bn,Rn),y=m-Bn,b=x-Bn,S=v>=yn-4&&v<=Sn+4,R=p>=bn-4&&p<=Rn+4,C="";C=S&&R?T(a,y,d,b):S&&!R?"M ".concat(a,",").concat(y," L ").concat(s,",").concat(y," L ").concat(s,",").concat(b):!S&&R?"M ".concat(s,",").concat(y," L ").concat(s,",").concat(b," L ").concat(d,",").concat(b):"M ".concat(s,",").concat(y," L ").concat(s,",").concat(b),gn.push({id:h,pathD:C,style:c,leftIdx:N,rhsArrayIdx:i})}}})}else{var M=n,k=M;v=null===(o=jt.current[M])||void 0===o?void 0:o.current,p=null===(r=Ht.current[k])||void 0===r?void 0:r.current;if(!v||!p)return;var P,j;f=v.getBoundingClientRect(),g=p.getBoundingClientRect(),h=Ei(M),m=(P=f.right-B.left)+.5*((j=g.left-B.left-0)-P),x=f.top+f.height/2,y=g.top+g.height/2,b=x-yn+Cn,S=y-bn+In,C="conn-".concat(M,"-").concat(k);xn.push({lhsScrollY:b,rhsScrollY:S,x1:P,x2:j,containerTop:Bn,leftIdx:M,rhsArrayIdx:k,styleColor:(null==h?void 0:h.badgeBorder)||"#6366F1",styleId:C});var H;I=wn(x,yn,Sn),w=wn(y,bn,Rn),_=I-Bn,F=w-Bn,E=y>=bn-4&&y<=Rn+4,D="";D=(H=x>=yn-4&&x<=Sn+4)&&E?T(P,_,j,F):H&&!E?"M ".concat(P,",").concat(_," L ").concat(m,",").concat(_," L ").concat(m,",").concat(F):!H&&E?"M ".concat(m,",").concat(_," L ").concat(m,",").concat(F," L ").concat(j,",").concat(F):"M ".concat(m,",").concat(_," L ").concat(m,",").concat(F),gn.push({id:C,pathD:D,style:h,leftIdx:M,rhsArrayIdx:k})}}),De.current=xn}Ce(gn)}else Ce([]),De.current=[]}catch(n){console.error("Line render safe fail: ",n)}finally{Je.current=!1}}},[Bt,Ct,It,Pe,pt,Fi,Ei,Ni,Vn,re,ge,ye,oi,li]),Pi=a(function(){var n,e,t,i,o,r,l,u,c,a,d,s,v,p,f=De.current;if(f.length&&!_e.current){var g=null!==(e=null===(n=$e.current)||void 0===n?void 0:n.scrollTop)&&void 0!==e?e:0,h=null!==(i=null===(t=qe.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,m=null!==(r=null===(o=$e.current)||void 0===o?void 0:o.clientHeight)&&void 0!==r?r:1/0,x=null!==(u=null===(l=qe.current)||void 0===l?void 0:l.clientHeight)&&void 0!==u?u:1/0,y=null!==(a=null===(c=$e.current)||void 0===c?void 0:c.getBoundingClientRect().top)&&void 0!==a?a:0,b=null!==(s=null===(d=qe.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==s?s:0,S=y+m,R=b+x,C=null!==(p=null===(v=mi.current)||void 0===v?void 0:v.getBoundingClientRect().top)&&void 0!==p?p:0,I=function(n,e,t){return Math.max(e,Math.min(t,n))};f.forEach(function(n){var e=n.lhsScrollY-g+y,t=n.rhsScrollY-h+b,i=Ee.current[n.styleId+"-stroke"],o=Ee.current[n.styleId+"-bg"];if(i||o){var r,l=I(e,y,S),u=I(t,b,R),c=l-C,a=u-C,d=e>=y-4&&e<=S+4,s=t>=b-4&&t<=R+4,v=n.x1+.5*(n.x2-n.x1);r=d&&s?T(n.x1,c,n.x2,a):d&&!s?"M ".concat(n.x1,",").concat(c," L ").concat(v,",").concat(c," L ").concat(v,",").concat(a):!d&&s?"M ".concat(v,",").concat(c," L ").concat(v,",").concat(a," L ").concat(n.x2,",").concat(a):"M ".concat(v,",").concat(c," L ").concat(v,",").concat(a),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",r)),o&&(o.setAttribute("visibility","visible"),o.setAttribute("d",r))}})}},[]);c(function(){ke.current=ki},[ki]);var ji=l(null),Hi=l(null),Li=a(function(){De.current.length>0&&!_e.current||(null!==ji.current&&clearTimeout(ji.current),ji.current=setTimeout(function(){ke.current(),ji.current=null},50))},[]),Oi=a(function(){pe(!0),de(!1),Be.current=null,null!==Hi.current&&clearTimeout(Hi.current),null!==ji.current&&(clearTimeout(ji.current),ji.current=null),Hi.current=setTimeout(function(){var n,e,t,i,o,r,l,u,c,a,d;try{if(De.current=[],Ae.current&&null!==Me.current&&null!==yi.current){var s=Me.current,v=yi.current,p="string"==typeof s&&s.includes(R),f=null,g=null,h=null,m=null;if(p){var x=s.split(R),y="".concat(x[0]).concat(R).concat(x[1]);f=(null===(n=jt.current[y])||void 0===n?void 0:n.current)||null,g=(null===(e=Ht.current[y])||void 0===e?void 0:e.current)||null,h=(null===(t=Ot.current[x[2]])||void 0===t?void 0:t.current)||(null===(i=kt.current[Number(x[2])])||void 0===i?void 0:i.current)||null,m=(null===(o=zt.current[x[3]])||void 0===o?void 0:o.current)||(null===(r=Pt.current[Number(x[3])])||void 0===r?void 0:r.current)||null}else f=(null===(l=Wt.current[s])||void 0===l?void 0:l.current)||null,h=(null===(u=kt.current[s])||void 0===u?void 0:u.current)||null,g=(null===(c=Lt.current[v])||void 0===c?void 0:c.current)||null,m=(null===(a=Pt.current[v])||void 0===a?void 0:a.current)||null;if(f&&g&&h&&m){if(h.style.paddingTop="0px",m.style.paddingTop="0px",!Vn){var b=f.getBoundingClientRect(),S=g.getBoundingClientRect(),C=b.top-S.top;C>0?m.style.paddingTop="".concat(C,"px"):C<0&&(h.style.paddingTop="".concat(Math.abs(C),"px"))}var I=$e.current,B=qe.current;if(I&&B){var w=f.getBoundingClientRect().top-I.getBoundingClientRect().top+I.scrollTop,T=g.getBoundingClientRect().top-B.getBoundingClientRect().top+B.scrollTop-(w-I.scrollTop);Math.abs(B.scrollTop-T)>1&&(B.scrollTop=T)}}}null===(d=ke.current)||void 0===d||d.call(ke),Ae.current&&de(!0)}catch(n){console.error("Safely caught error during resize calculation:",n)}finally{pe(!1),Hi.current=null}},150)},[Vn,Ct,It]),zi=a(function(n){if(null!==Ue.current&&Ge.current&&Math.abs(n.currentTarget.scrollTop-Ue.current)<=2){var e=Ge.current;Ue.current=null,Ge.current=null,e()}me.current||(Vn||Li(),Ne.current||(Ne.current=!0,requestAnimationFrame(function(){var n,e,t,i,o,r,l;if(Ae.current){var u=$e.current,c=qe.current;if(u&&c&&bi.current){if(!Be.current){var a=Me.current,d=void 0;if("string"==typeof a&&a.includes(R)){var s=a.split(R),v="".concat(s[0]).concat(R).concat(s[1]);d=null===(n=jt.current[v])||void 0===n?void 0:n.current}else d=null===(e=jt.current[a])||void 0===e?void 0:e.current;if(d){var p=d.getBoundingClientRect();Be.current={badgeScreenY:p.top+p.height/2,initialScrollTop:u.scrollTop,leftTop:u.getBoundingClientRect().top,leftBottom:u.getBoundingClientRect().top+u.clientHeight,cTop:null!==(i=null===(t=mi.current)||void 0===t?void 0:t.getBoundingClientRect().top)&&void 0!==i?i:0}}}if(Be.current){var f=Be.current,g=u.scrollTop-f.initialScrollTop,h=f.badgeScreenY-g,m=((o=h,r=f.leftTop,l=f.leftBottom,Math.max(r,Math.min(l,o)))-f.cTop).toString(),x=h>=f.leftTop-4&&h<=f.leftBottom+4;bi.current.setAttribute("y1",m),bi.current.setAttribute("y2",m),bi.current.setAttribute("visibility",x?"visible":"hidden")}}}De.current.length>0&&Pi(),Ne.current=!1})))},[Pi,Vn,Li]),Wi=l(0),qi=l(0),Yi=l(0),Ki=l(function(){});l(null),c(function(){Ki.current=Oi},[Oi]),c(function(){var n=setTimeout(Li,250),e=function(){return Ki.current()};return window.addEventListener("resize",e),function(){clearTimeout(n),null!==ji.current&&clearTimeout(ji.current),null!==Hi.current&&clearTimeout(Hi.current),window.removeEventListener("resize",e)}},[St,Rt,Vt,Bt,oi,li,Ct,It,pt,Li,re,ge,ae,ye]),c(function(){var n=function(n,e,t,i,o){e.current=n.getBoundingClientRect().width;var r=new ResizeObserver(function(n){null!==t.current&&cancelAnimationFrame(t.current),t.current=requestAnimationFrame(function(){var r,l,u;t.current=null;var c=n[n.length-1];if(c){var a=null!==(u=null===(l=null===(r=c.borderBoxSize)||void 0===r?void 0:r[0])||void 0===l?void 0:l.inlineSize)&&void 0!==u?u:c.contentRect.width;Math.abs(a-e.current)<1?o():(e.current=a,i())}})});return r.observe(n),r},e={current:null},t={current:null},i={current:null},o=[],r=[e,t,i];return We.current&&o.push(n(We.current,Wi,e,function(){return Ki.current()},function(){})),ze.current&&o.push(n(ze.current,qi,t,function(){return Ki.current()},function(){return ke.current()})),mi.current&&o.push(n(mi.current,Yi,i,function(){return Ki.current()},function(){return ke.current()})),function(){o.forEach(function(n){return n.disconnect()}),r.forEach(function(n){null!==n.current&&(cancelAnimationFrame(n.current),n.current=null)})}},[]),c(function(){Ae.current=re},[re]),c(function(){Me.current=ge},[ge]);var Vi=a(function(n,e,t){var i,o,r=null===(i=null==t?void 0:t.toggleIfSame)||void 0===i||i,l=null==t?void 0:t.onReady,u=null!==(o=null==t?void 0:t.sourceSide)&&void 0!==o?o:"left";vt(),null!=n&&(e?ie("No counterpart exists for this section."):(Zt(),re&&ge===n?r?ni():null==l||l():(be(new Set([n])),Ce([]),De.current=[],ne(!0),me.current=!0,he(n),Me.current=n,le(!0),Ae.current=!0,de(!1),Ye.current&&(Ye.current.style.height="0px"),Ke.current&&(Ke.current.style.height="0px"),Ve.current&&(Ve.current.style.height="0px"),Xe.current&&(Xe.current.style.height="0px"),requestAnimationFrame(function(){var e,t,i,o,r,c="string"==typeof n&&n.includes(R),a=null,d=null,s=null;if(c){var v=n.split(R),p="".concat(v[0]).concat(R).concat(v[1]);a=(null===(e=jt.current[p])||void 0===e?void 0:e.current)||null,d=(null===(t=Ht.current[p])||void 0===t?void 0:t.current)||null,s=d?n:null}else if(a=(null===(i=Wt.current[n])||void 0===i?void 0:i.current)||null,Vn){var f=Ct[n],g=(null==f?void 0:f.refIndexes)||[];if(g.length>0){var h=g[0],m=It.findIndex(function(n){return n.selfIndex===h});-1!==m&&(d=(null===(r=Lt.current[m])||void 0===r?void 0:r.current)||null,s=m)}}else d=(null===(o=Lt.current[n])||void 0===o?void 0:o.current)||null,s=d?n:null;yi.current=s;var x=$e.current,y=qe.current,b=function(){!function(){var e,t,i,o,r,l,u,a,d,v,p,f,g=null,h=null,m=null,x=null;if(c){var y=n.split(R),b="".concat(y[0]).concat(R).concat(y[1]);g=(null===(e=Ot.current[y[2]])||void 0===e?void 0:e.current)||(null===(t=kt.current[Number(y[2])])||void 0===t?void 0:t.current)||null,h=(null===(i=zt.current[y[3]])||void 0===i?void 0:i.current)||(null===(o=Pt.current[Number(y[3])])||void 0===o?void 0:o.current)||null,m=(null===(r=jt.current[b])||void 0===r?void 0:r.current)||g,x=(null===(l=Ht.current[b])||void 0===l?void 0:l.current)||h}else{var S=Number(n),C=null!==s?Number(s):S;g=(null===(u=kt.current[S])||void 0===u?void 0:u.current)||null,h=(null===(a=Pt.current[C])||void 0===a?void 0:a.current)||null,m=(null===(d=jt.current[S])||void 0===d?void 0:d.current)||(null===(v=Wt.current[S])||void 0===v?void 0:v.current)||g,x=(null===(p=Ht.current[C])||void 0===p?void 0:p.current)||(null===(f=Lt.current[C])||void 0===f?void 0:f.current)||h}if(m&&x&&g&&h){g.style.paddingTop="0px",h.style.paddingTop="0px";var I=m.getBoundingClientRect(),B=x.getBoundingClientRect(),w=I.top-B.top;w>0?h.style.paddingTop="".concat(w,"px"):w<0&&(g.style.paddingTop="".concat(Math.abs(w),"px"))}}(),de(!0),ke.current&&ke.current(),me.current=!1,"right"===u&&y?y.dispatchEvent(new Event("scroll")):x&&x.dispatchEvent(new Event("scroll")),ne(!1),null==l||l()};if(!a||!x)return me.current=!1,ne(!1),void(null==l||l());if(d&&y){if(!Vn){var S=0;S="right"===u?d?d.getBoundingClientRect().top:0:a?a.getBoundingClientRect().top:0;var C=ze.current,I=(null==C?void 0:C.getBoundingClientRect().top)||0,B=C?C.scrollTop+S-I-150:0;return C?void _(C,B,200,b):void b()}var w=a.getBoundingClientRect().top-x.getBoundingClientRect().top+x.scrollTop,T=d.getBoundingClientRect().top-y.getBoundingClientRect().top+y.scrollTop,F=200;if("left"===u){var E=T-(w-x.scrollTop);E<0&&Ye.current&&(Ye.current.style.height="".concat(Math.abs(E),"px")),requestAnimationFrame(function(){var n,e=y.scrollHeight-y.clientHeight;if(E<0)n=0;else{if(E>e){var t=E-e;return Ke.current&&(Ke.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){_(y,E,F,b)})}n=E}_(y,n,F,b)})}else{var D=w-(T-y.scrollTop);D<0&&Ve.current&&(Ve.current.style.height="".concat(Math.abs(D),"px")),requestAnimationFrame(function(){var n,e=x.scrollHeight-x.clientHeight;if(D<0)n=0;else{if(D>e){var t=D-e;return Xe.current&&(Xe.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){_(x,D,F,b)})}n=D}_(x,n,F,b)})}}else b()}))))},[ge,vt,It,re,Vn,Ct,ni]),Xi=a(function(){var n,e=et.sectionIdx,t=et.isOrphan;if(ct(),null!=e){var i="left";et.anchorEl&&(null===(n=qe.current)||void 0===n?void 0:n.contains(et.anchorEl))&&(i="right"),Vi(e,t,{sourceSide:i})}},[Vi,et.isOrphan,et.sectionIdx,et.anchorEl,ct]),$i=a(function(){ct(),ni(),be(new Set),Ce([]),De.current=[]},[ct,ni]),Ji=null!==et.sectionIdx&&ye.has(et.sectionIdx),Ui=V({proposedSections:Ct,existingSections:It,parentDeviationRecord:wt,expandedSections:oi,maintainRelativeOrder:!!Vn,scrollContainerRef:ze,leftContainerRef:$e,rightContainerRef:qe,lhsBadgeRefs:jt,rhsBadgeRefs:Ht}),Gi=Ui.showDeviationNavigation,Qi=Ui.showOpenNodeRef,Zi=Ui.adjustScrollForPopup,no=a(function(n,e,t,i,o){var r,l="string"==typeof i?y(i).trim():y(null==i?void 0:i.deviation_summary).trim(),u=n.currentTarget;st();var c="left";(null===(r=qe.current)||void 0===r?void 0:r.contains(u))&&(c="right");var a=function(){var n,t,i,o;if("string"==typeof e&&e.includes(R)){var r=e.split(R),l="".concat(r[0]).concat(R).concat(r[1]);return"right"===c?null===(n=Ht.current[l])||void 0===n?void 0:n.current:null===(t=jt.current[l])||void 0===t?void 0:t.current}return"right"===c?null===(i=Ht.current[e])||void 0===i?void 0:i.current:null===(o=jt.current[e])||void 0===o?void 0:o.current},d=function(n,e){var t=!!Vn,i=t?"right"===c?qe.current:$e.current:ze.current,o=t?"right"===c?$e.current:qe.current:null;if(i&&n){var r=n.getBoundingClientRect(),l=i.getBoundingClientRect(),u=l.bottom-.35*l.height,a=l.top+.35*l.height;if(r.top>u||r.top<a){var d=l.top+l.height/2,s=r.top+r.height/2-d+200;t&&o&&_(o,o.scrollTop+s,250,function(){}),_(i,i.scrollTop+s,250,e)}else e()}else e()};if(t)return ni(),be(new Set),Ce([]),De.current=[],void(l&&requestAnimationFrame(function(){var n=a()||u;d(n,function(){ut({open:!0,anchorEl:n,summary:i,displayImpact:o})})}));Vi(e,t,l?{toggleIfSame:!1,sourceSide:c,onReady:function(){var n=a()||u;d(n,function(){ut({open:!0,anchorEl:n,summary:i,displayImpact:o})})}}:{toggleIfSame:!1,sourceSide:c})},[Vi,st,ut,ni,Vn]),eo=u(function(){var n;if(!Ln)return null;var e=null===(n=null==Ln?void 0:Ln.id)||void 0===n?void 0:n.split(":")[0];for(var t in wt){if((wt[t]||[]).some(function(n){return n.id===e}))return t}return null},[Ln,wt]),to=l({id:null,triggerMs:null}),io=l(null);c(function(){var t;if(null==Ln?void 0:Ln.id){var i=Number(Ln.trigger),o=to.current;if((null==o?void 0:o.triggerMs)!==i){if(!(Ln.id.includes(":")&&/:\d+$/.test(Ln.id)))return to.current={id:Ln.id,triggerMs:i},void gi(Ln.id);var r=null===(t=null==Ln?void 0:Ln.id)||void 0===t?void 0:t.split(":"),l=r[0],u=r[1],c=null!=u?u:"0";io.current!==Ln.id&&(ct(),st(),ni(),be(new Set),Ce([]),De.current=[],io.current=Ln.id);var a=!1,d=0,s=null,v=150,p=function(n,e){for(var t=function(n,i){if(!n)return null;if(n.id===e)return i;if(!Array.isArray(n.subsections))return null;for(var o=0;o<n.subsections.length;o++){var r=t(n.subsections[o],"".concat(i,"-").concat(o));if(r)return r}return null},i=0;i<n.length;i++){var o=t(n[i],String(i));if(o)return o}return null},f=function(){var t,o,r,u;if(!a){var g=function(){to.current={id:Ln.id,triggerMs:i}},h=null,m=null;for(var x in wt){var y=wt[x].find(function(n){return n.id===l});if(y){h=x,m=y;break}}if(m&&h){var b=Ct.findIndex(function(n){return n.id===h}),S=It.findIndex(function(n){return n.id===h}),C=-1===b&&-1!==S,I=p(Ct,m.id),B=p(It,m.id);if(I&&!B&&!C){var w=I.split("-"),T=Number(w[0]);if(Vn){var _=null===(o=null===(t=Ct[T])||void 0===t?void 0:t.refIndexes)||void 0===o?void 0:o[0],F=It.findIndex(function(n){return n.selfIndex===_});-1!==F&&(T=F)}B=e([T],w.slice(1),!0).join("-")}if(I||B){var E=C||!I&&!!B,D=I?Number(I.split("-")[0]):b,N=B?Number(B.split("-")[0]):S;if(E){if(!(Vn?!!oi["right-".concat(N)]:!!oi[String(N)])&&N>=0)return ci(N,"right"),d+=1,void(s=setTimeout(f,450))}else if(!(Vn?!!oi["left-".concat(D)]:!!oi[String(D)])&&D>=0)return ci(D,"left"),d+=1,void(s=setTimeout(f,450));var A,M=I||"",k=B||"",P="".concat(m.id).concat(R).concat(c).concat(R).concat(M).concat(R).concat(k),j="".concat(m.id).concat(R).concat(c),H=null===(r=jt.current[j])||void 0===r?void 0:r.current,L=null===(u=Ht.current[j])||void 0===u?void 0:u.current,O=E||!H&&!!L,z=O?L:H;if(A=Vn?O?qe.current:$e.current:ze.current,z&&A){var W=z.getBoundingClientRect();if(0===W.height)return void((d+=1)<2?s=setTimeout(f,v):g());var q=A.getBoundingClientRect(),Y=W.top-q.top+A.scrollTop-q.height/2+W.height/2+150,K=function(){var e,t,i,o,r;if(!a){g();var l=z instanceof Element?window.getComputedStyle(z).color:"";H&&(H.style.transition="box-shadow 300ms ease-in-out",H.style.boxShadow="0 0 10px ".concat(l)),L&&(L.style.transition="box-shadow 300ms ease-in-out",L.style.boxShadow="0 0 10px ".concat(l)),setTimeout(function(){H&&(H.style.boxShadow=""),L&&(L.style.boxShadow="")},2e3);var u=(null===(t=null===(e=m.evaluationResult)||void 0===e?void 0:e.deviations)||void 0===t?void 0:t[c])||m,d=(null===(i=m.evaluationResult)||void 0===i?void 0:i.evaluation_outputs)||m.evaluation_outputs;if(!(!!H&&!!L)){var s=O?(null===(o=Ht.current[j])||void 0===o?void 0:o.current)||L:(null===(r=jt.current[j])||void 0===r?void 0:r.current)||H;return Zi(s,function(){ut({open:!0,anchorEl:s,displayImpact:Ln.displayImpact,summary:n(n({},u),{evaluation_outputs:d})})}),void(null==On||On())}Vi(P,!1,{toggleIfSame:!1,sourceSide:"left",onReady:function(){var e,t,i=O?(null===(e=Ht.current[j])||void 0===e?void 0:e.current)||L:(null===(t=jt.current[j])||void 0===t?void 0:t.current)||H;Zi(i,function(){ut({open:!0,anchorEl:i,displayImpact:null==Ln?void 0:Ln.displayImpact,summary:n({},u)})})}})}};Math.abs(A.scrollTop-Y)<=2?K():(Ue.current=Y,Ge.current=K,A.scrollTo({top:Y,behavior:"smooth"}),s&&clearTimeout(s),s=setTimeout(function(){if(Ge.current){Ue.current=null;var n=Ge.current;Ge.current=null,n()}},800))}else(d+=1)<2?s=setTimeout(f,v):g()}else(d+=1)<2?s=setTimeout(f,v):g()}else(d+=1)<2?s=setTimeout(f,v):g()}};return s=setTimeout(f,v),function(){a=!0,s&&clearTimeout(s)}}}},[Ln,wt,Ct,It,Vn,oi,ci,Vi,ut,gi]);var oo=function(n){var e=n.section,t=n.keyPath,o=n.depth,r=void 0===o?0:o,l=n.columnKey,u=void 0===l?"left":l,c=n.parentNodeId,a=void 0===c?"":c,d=n.sectionOffset;return i(J,{section:e,keyPath:t,depth:r,columnKey:u,parentNodeId:a,expandedSubSections:li,setExpandedSubSections:ui,maintainRelativeOrder:Vn||!1,proposedSections:Ct,existingSections:It,treeData:_n,deviationNumberRegistry:Tt,connectedSections:ye,activeSideBySideSection:ge,resolvedMarkdownStyles:Oe,getSubSectionRef:Yt,getSubSectionCompareStyle:Di,getBadgeRef:Kt,openMoreFunctionsPopup:si,openSummaryPopup:no,showDeviationBadges:$n,resetSideBySide:ni,setConnectedSections:be,setConnectedLines:Ce,cachedConnectedPositions:De,isProposingFix:Wn,proposingFixNodeId:qn,isRedlineFlow:Yn,sectionOffset:d})};return t(d,n({ref:We,sx:n(n({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},Vn?{}:{overflow:"visible"}),{position:"relative"})},{children:[Un&&i(d,n({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:i(O,{})})),lt.open&&i(U,{open:lt.open,anchorEl:lt.anchorEl,containerEl:xi.current,clipTopEl:Si.current,scrollContainerEl:ze.current,onClose:$i,summary:lt.summary,displayImpact:lt.displayImpact}),i(L,{open:et.open,anchorEl:et.anchorEl,sectionTitle:et.sectionTitle,referenceSectionTitle:et.refSectionTitle,onClose:vt,onOpenCognitiveCompare:vi,onOpenSideBySide:Xi,onConnect:pi,isConnected:Ji,isOrphan:et.isOrphan}),Ze.open&&i(H,{open:Ze.open,popupRef:dt,position:it,popupConfig:Pn,onClose:function(){ot(null),nt(function(e){return n(n({},e),{open:!1})}),at(null)},markdownStyles:Nn,sectionTitle:Ze.sectionTitle,referenceSectionTitle:Ze.refSectionTitle,cognitiveData:Ze.cognitiveData,anchorEl:Ze.anchorEl,sectionAnchorEl:Ze.sectionAnchorEl,scrollContainerEl:ze.current,badgeStyle:Ze.badgeStyle,docData:Ze.docData,deviationData:Ze.deviationData,isLoading:Ze.isLoading}),i(s,n({open:!!te,autoHideDuration:8e3,onClose:function(){return ie(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:i(v,n({onClose:function(){return ie(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:te}))})),i(X,{componentHeaderText:Tn,displayConfig:kn,maintainRelativeOrder:Vn,onCollapseAll:Ai,showCollapseAll:Mi,onToggleView:function(n){Gn(!0),setTimeout(function(){Xn(!n),ni(),ct(),be(new Set),Ce([]),De.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){Gn(!1)},600)})})},50)}}),i(d,n({ref:ze,onScroll:zi,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:Vn?"hidden":"auto",borderTop:Xt&&$t?"none":"1.5px solid #EEF0F4"}},{children:i(d,n({sx:n({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},Vn?{flex:1,minHeight:0}:{})},{children:t(d,n({ref:mi,sx:n({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},Vn?{flex:1,overflow:"visible"}:{})},{children:[t("svg",n({ref:Ie,style:{position:"absolute",top:0,left:0,width:He.width||"100%",height:He.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",opacity:ve?0:1,transition:"opacity 0.15s ease-in-out"}},{children:[Ti&&i("g",{children:i("line",{x1:Ti.x1,y1:Ti.y,x2:Ti.x2,y2:Ti.y,stroke:Qt.badgeBorder,strokeWidth:"1.5"})}),Ii.map(function(e){var o,r,l,u,c,a,s,v=e.x1+.5*(e.x2-e.x1),p=(e.y1+e.y2)/2;if("Not Defined"===e.style.label&&!e.hasCognitive)return null;if(e.isSubSection?re&&ge===e.subSectionKeyPath&&ae:re&&ge===e.sectionIdx&&ae)return null;if(!Vn){var f=e.isSubSection?T(e.x1,e.y1,e.x2,e.y2):"M ".concat(e.x1," ").concat(e.y1," L ").concat(e.x2," ").concat(e.y2),h=Ct[e.sectionIdx]||{title:"",content:""},x=It[null!==(o=e.targetRightIdx)&&void 0!==o?o:e.sectionIdx]||{title:"",content:""};if(console.log("Base and Ref Sections for Badge:",h,x),e.isSubSection&&e.subSectionKeyPath){var y=e.subSectionKeyPath.includes(R)?e.subSectionKeyPath.split(R):[],b=y[2]||e.subSectionKeyPath,S=y[3]||b,C=b.split("-").map(Number),I=S.split("-").map(Number),B=null,w=null;C.length>0&&(B=Ct[C[0]]),I.length>0&&(w=It[I[0]]);var _=(null==B?void 0:B.title)||"",F=(null==w?void 0:w.title)||"";console.log("Root Parent Titles:",_,F);for(var E=1;E<C.length;E++)(null==B?void 0:B.subsections)&&(B=B.subsections[C[E]]);for(E=1;E<I.length;E++)(null==w?void 0:w.subsections)&&(w=w.subsections[I[E]]);B&&(h=n(n({},B),{title:_||B.title})),console.log("Base Section for Subsection Badge:",h),w&&(x=n(n({},w),{title:F||w.title})),console.log("Ref Section for Subsection Badge:",x)}var D=!(null===(r=h.cognitiveData)||void 0===r?void 0:r.isMissingRationale)||Boolean(null===(u=null===(l=h.cognitiveData)||void 0===l?void 0:l.decisioning)||void 0===u?void 0:u.length),N=(null===(s=null===(a=null===(c=h.evaluationResult)||void 0===c?void 0:c.cognitive_decisioning)||void 0===a?void 0:a.decisioning_factors)||void 0===s?void 0:s.length)||!1,A=D||N;return t("g",{children:[i("path",{d:f,fill:"none",stroke:e.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),i("foreignObject",n({x:v-100,y:p-14,width:"200",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:i(d,n({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:t(d,n({onClick:function(n){n.stopPropagation(),A&&(Ze.open&&rt===e.id?st():(at(e.id),di(ai(n.currentTarget,h,x,e.sectionIdx,e.style))))},sx:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:e.style.badgeBg,color:e.style.badgeText,border:"1px solid ".concat(e.style.badgeBorder),borderRadius:"12px",px:1.5,py:.5,fontWeight:600,textAlign:"center",whiteSpace:"nowrap",cursor:A?"pointer":"default"}},{children:[e.style.badgeText===P&&null==e.style.label?i(z,{color:e.style.badgeText}):0===e.style.label?"Same":e.style.label,i(d,n({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:i(m,{})})),A&&i(g,{size:11,style:{transform:Ze.open&&rt===e.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},e.id)}return null}),i(G,{connectedLines:Re,pathRefs:Ee})]})),t(d,n({sx:n({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},Vn?{flex:1,overflow:"visible"}:{})},{children:[i(d,n({ref:Si,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:i(p,n({title:xt,placement:"top"},{children:i(f,n({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:xt}))}))})),t(d,n({ref:$e,onScroll:zi,sx:n({p:"12px",display:"flex",flexDirection:"column"},Vn?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-160px",pr:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[i("div",{ref:Ve,style:{width:"100%",height:"0px",flexShrink:0}}),Ft&&Ct.map(function(e,o){var r,l,u=!e.title&&!e.content;if(Vn&&u)return null;var c=e,a=Ei(o,"left"),s=Vn?!(null===(r=c.refIndexes)||void 0===r?void 0:r.length)||c.selfIndex<0:!It[o],v=ye.has(o),p=b(c.evaluationResult,null==a?void 0:a.deviationLabel),f=Dt.leftNums.get(c.id);return i(d,n({ref:qt(o),sx:{mb:1,width:"100%"}},{children:t(d,n({sx:{position:"relative",width:"100%"}},{children:[i(d,n({ref:kt.current[o],sx:n({width:"100%",display:"flex",flexDirection:"column",minWidth:0},v&&{borderRadius:"6px",outline:"2px solid ".concat((null==a?void 0:a.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:i($,{section:e,idx:o,columnKey:"left",colRef:qt("left-accordion-".concat(o)),mb:0,treeData:_n,proposedSections:Ct,existingSections:It,deviationNumberRegistry:Tt,getSectionCompareStyle:Ei,getBadgeRef:Kt,connectedSections:ye,openMoreFunctionsPopup:si,openSummaryPopup:no,deviationNodeIdToView:null==Ln?void 0:Ln.id,deviationTargetParentId:eo,parentNodeId:(null===(l=null==_n?void 0:_n.input_index_map)||void 0===l?void 0:l[0])||"",isExpanded:Vn?!!oi["left-".concat(o)]:!!oi[String(o)],onToggle:function(){$i(),ci(o,"left")},navigation:e.id?Gi[e.id]:null,showOpenNodeRef:Qi,resolvedMarkdownStyles:Oe,maintainRelativeOrder:Vn,showDeviationBadges:$n,renderSubSections:oo,isProposingFix:Wn,proposingFixNodeId:qn,isRedlineFlow:Yn,collisionKey:"".concat(re?"1":"0","-").concat(String(null!=ge?ge:""))})})),Vn&&a&&t(d,n({ref:jt.current[o],onClick:function(n){var e,t,i,r=kn.enableDeviationSchemaBackwardCompatibility?null!==(e=c.evaluationResult)&&void 0!==e?e:null:null!==(i=null===(t=c.evaluationResult)||void 0===t?void 0:t[0])&&void 0!==i?i:null;no(n,String(o),s,r)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:a.badgeBg,color:a.badgeText,border:"1px solid ".concat(a.badgeBorder),borderRadius:"12px",px:1.2,py:.3,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[t(d,n({component:"span",onClick:function(n){var e,t,i;n.stopPropagation();var r=kn.enableDeviationSchemaBackwardCompatibility?null!==(e=c.evaluationResult)&&void 0!==e?e:null:null!==(i=null===(t=c.evaluationResult)||void 0===t?void 0:t[0])&&void 0!==i?i:null;no(n,String(o),s,r)},sx:{display:"inline-flex",alignItems:"center",gap:"4px",px:.2,cursor:s?"default":"pointer",borderRight:"1px solid ".concat(a.badgeBorder),"&:hover":s?{}:{bgColor:"".concat(a.badgeBorder,"22")}}},{children:[null!=f&&i(d,n({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(a.badgeBorder)}},{children:f})),i(d,n({component:"span",sx:{fontSize:"11px",px:.25}},{children:!kn.isLoading||null!=c.evaluationResult&&null!=c.evaluationResult?"N/A"===p||"NA"===p?"N/A":0==p||null==p?"Same":"".concat(p):i(z,{color:a.badgeText})}))]})),i(d,n({component:"span",onClick:function(n){n.stopPropagation();var t=Vn?It.find(function(n){var e;return null===(e=c.refIndexes)||void 0===e?void 0:e.includes(n.selfIndex)})||{title:"",content:""}:It[o]||{title:"",content:""};si(n,e,s,t,o,a)},sx:{display:"inline-flex",alignItems:"center",px:.2,cursor:"pointer","&:hover":{bgcolor:"".concat(a.badgeBorder,"22")}}},{children:i(h,{size:11,color:a.badgeText})}))]}))]}))}),"left-row-".concat(o))}),i("div",{ref:Xe,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),i(d,n({ref:xi,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:i(d,n({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:t(d,n({onClick:function(e){e.stopPropagation(),Ze.open&&rt===Jt?st():(at(Jt),di(ai(e.currentTarget,{title:"",content:"",evaluationResult:Ut,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,Jt,!0,n(n({},Qt),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:Qt.badgeBg,color:Qt.badgeText,border:"1px solid ".concat(Qt.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=Gt?Gt:i(z,{}),i(d,n({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:i(m,{})})),i(g,{size:11,style:{transform:Ze.open&&rt===Jt?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),t(d,n({sx:n({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},Vn?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[Zn&&i(x,{sections:11}),i(d,n({ref:Ri,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"40px",display:"flex",alignItems:"center",overflowX:"hidden"}},{children:i(p,n({title:yt,placement:"top"},{children:i(f,n({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:yt}))}))})),t(d,n({ref:qe,onScroll:zi,sx:n({p:"12px",display:"flex",flexDirection:"column"},Vn?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-150px",pl:"165px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[i("div",{ref:Ye,style:{width:"100%",height:"0px",flexShrink:0}}),Ft&&It.map(function(e,r){var l,u,c=e,a=!1,s=null,v=-1;if(Vn){v=Ct.findIndex(function(n){var e;return(null===(e=n.refIndexes)||void 0===e?void 0:e.includes(c.selfIndex))&&n.selfIndex>=0});var p=Ct.findIndex(function(n,e){var t;return ye.has(e)&&(null===(t=n.refIndexes)||void 0===t?void 0:t.includes(c.selfIndex))});(a=-1!==p)&&(s=Ei(p,"left"))}else(a=ye.has(r))&&(s=Ei(r,"right"));var f=Vn&&-1!==v?Ei(v,"left"):Ei(r,"right"),g=Vn?-1!==v||!(null===(l=c.refIndexes)||void 0===l?void 0:l.length)&&Ct.some(function(n){return n.id&&n.id===c.id}):Boolean(Ct[r]),m=Vn?c.selfIndex<0||!g:!Ct[r],x=Dt.rightNums.get(c.id);return i(d,n({ref:Lt.current[r],sx:{mb:1,width:"100%"}},{children:t(d,n({sx:{position:"relative",width:"100%"}},{children:[i(d,n({ref:Pt.current[r],sx:n({width:"100%",display:"flex"},a&&s&&{borderRadius:"6px",outline:"2px solid ".concat(s.badgeBorder),outlineOffset:"1px"})},{children:i($,{section:e,idx:r,columnKey:"right",colRef:qt("right-accordion-".concat(r)),mb:0,parentNodeId:(null===(u=null==_n?void 0:_n.input_index_map)||void 0===u?void 0:u[1])||"",isExpanded:Vn?!!oi["right-".concat(r)]:!!oi[String(r)],treeData:_n,proposedSections:Ct,existingSections:It,deviationNumberRegistry:Tt,getBadgeRef:Kt,getSectionCompareStyle:Ei,connectedSections:ye,openMoreFunctionsPopup:si,openSummaryPopup:no,deviationNodeIdToView:null==Ln?void 0:Ln.id,deviationTargetParentId:eo,onToggle:function(){$i(),ci(r,"right")},navigation:e.id?Gi[e.id]:null,showOpenNodeRef:Qi,resolvedMarkdownStyles:Oe,maintainRelativeOrder:Vn,showDeviationBadges:$n,renderSubSections:oo,isProposingFix:Wn,proposingFixNodeId:qn,isRedlineFlow:Yn,collisionKey:"".concat(re?"1":"0","-").concat(String(null!=ge?ge:""))})})),Vn&&f&&i(d,n({ref:Ht.current[r],"data-section-id":c.id,onClick:function(n){var e,t,i;if(m){var o=kn.enableDeviationSchemaBackwardCompatibility?null!==(e=c.evaluationResult)&&void 0!==e?e:null:null!==(i=null===(t=c.evaluationResult)||void 0===t?void 0:t[0])&&void 0!==i?i:null;no(n,String(r),m,o)}},sx:{position:"absolute",top:"18px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:m?"4px":"0px",fontSize:"11px",bgcolor:f.badgeBg,color:f.badgeText,border:"1px solid ".concat(f.badgeBorder),borderRadius:m?"12px":"10px",px:m?1.2:1,py:.3,fontWeight:m?600:700,cursor:m?"pointer":"default",whiteSpace:"nowrap",zIndex:20,boxShadow:m?"0 1px 3px rgba(0,0,0,0.07)":"none"}},{children:m?t(o,{children:[t(d,n({component:"span",onClick:function(n){var e,t,i;n.stopPropagation();var o=kn.enableDeviationSchemaBackwardCompatibility?null!==(e=c.evaluationResult)&&void 0!==e?e:null:null!==(i=null===(t=c.evaluationResult)||void 0===t?void 0:t[0])&&void 0!==i?i:null;no(n,String(r),m,o)},sx:{display:"inline-flex",alignItems:"center",gap:"4px",px:.2,cursor:"pointer",borderRight:"1px solid ".concat(f.badgeBorder),"&:hover":{bgcolor:"".concat(f.badgeBorder,"22")}}},{children:[null!=x&&i(d,n({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(f.badgeBorder)}},{children:x})),i(d,n({component:"span",sx:{fontSize:"11px",px:.25}},{children:!kn.isLoading||null!=c.evaluationResult&&void 0!==c.evaluationResult?f.label?"".concat(f.label):"100% Deviation":i(z,{color:f.badgeText})}))]})),i(d,n({component:"span",onClick:function(n){n.stopPropagation();var e=Vn?Ct.find(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(c.selfIndex)})||{title:"",content:""}:Ct[r]||{title:"",content:""};si(n,e,m,c,r,f)},sx:{display:"inline-flex",alignItems:"center",px:.2,cursor:"pointer","&:hover":{bgcolor:"".concat(f.badgeBorder,"22")}}},{children:i(h,{size:11,color:f.badgeText})}))]}):null!=x?x:""}))]}))}),"right-row-".concat(r))}),i("div",{ref:Ke,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))};export{Q as default};
1
+ import{__assign as n,__spreadArray as e}from"tslib";import{jsxs as t,jsx as i,Fragment as o}from"react/jsx-runtime";import{useState as r,useRef as l,useMemo as u,useEffect as c,useCallback as a}from"react";import{Box as d,Snackbar as s,Alert as v,Tooltip as p,Typography as f}from"@mui/material";import{ChevronDown as g,EllipsisVertical as h}from"lucide-react";import{ButtonCognitiveIcon as m}from"../../assests/svg/ButtonCognitiveIcon.js";import x from"./OverlayComponent.js";import{safeStringify as y,extractDeviationScore as b,generateColorPalette as S,DEVIATION_BADGE_SEPARATOR as R,findKeyPathByNodeId as C,getFirstDeviationOutputValue as I,getFirstDeviationColor as B,hasValue as w,getBentArrowPath as T,smoothScrollTo as _,hasMeaningfulRedlineTags as F,resetClauseHighlight as E,scrollAndHighlightClause as M}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as D,DEFAULT_FIELD_CONFIG as N,DEFAULT_COMPARISON_CONFIG as A}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import{EMPTY_SUMMARY_POPUP_STATE as k,DEFAULT_DEVIAION_COLOR as H,DEFAULT_COMPONENT_HEADER_TEXT as P}from"./CognitiveCompareConstants.js";import j from"./CognitivePopup.js";import L from"./MoreFunctionsPopup.js";import O from"./LoaderComponent.js";import z from"./components/ThreeDotsLoader.js";import{useCognitiveTreeData as W}from"./hooks/useCompareData.js";import{useComparePopups as q}from"./hooks/useComparePopups.js";import{useSectionRefs as Y}from"./hooks/useSectionRefs.js";import{useAccordionState as K}from"./hooks/useAccordionState.js";import{useDeviationNavigation as V}from"./hooks/useDeviationNavigation.js";import X from"./components/CompareHeader.js";import $ from"./components/SectionAccordion.js";import J from"./components/SubSectionAccordion.js";import U from"./components/CognitiveSummaryPopup.js";import G from"./components/connectedLines.js";var Q=function(Q){var Z,nn,en,tn,on,rn,ln,un,cn,an,dn,sn,vn,pn,fn,gn,hn,mn,xn,yn,bn,Sn,Rn,Cn,In,Bn,wn=Q.componentHeaderText,Tn=void 0===wn?P:wn,_n=Q.treeData,Fn=Q.comparisonConfig,En=Q.leftColumnTitleText,Mn=Q.rightColumnTitleText,Dn=Q.markdownStyles,Nn=Q.resetTrigger,An=Q.displayConfig,kn=void 0===An?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1}:An,Hn=Q.popupConfig,Pn=Q.deviationData,jn=void 0===Pn?{}:Pn,Ln=Q.deviationNodeIdToView,On=Q.resetDeviationNodeId,zn=Q.isProposingFix,Wn=void 0!==zn&&zn,qn=Q.proposingFixNodeId,Yn=Q.isRedlineFlow,Kn=r(kn.maintainRelativeOrder),Vn=Kn[0],Xn=Kn[1],$n=!!Vn||!!(null==kn?void 0:kn.showDeviationBadges),Jn=r(!1),Un=Jn[0],Gn=Jn[1],Qn=r(!1),Zn=Qn[0],ne=Qn[1],ee=r(null),te=ee[0],ie=ee[1],oe=r(!1),re=oe[0],le=oe[1],ue=r(null===(nn=null!==(Z=null==_n?void 0:_n.newEvaluationResult)&&void 0!==Z?Z:null==kn?void 0:kn.enableDeviationSchemaBackwardCompatibility)||void 0===nn||nn)[0],ce=r(!1),ae=ce[0],de=ce[1],se=r(!1),ve=se[0],pe=se[1],fe=r(null),ge=fe[0],he=fe[1],me=l(!1),xe=r(new Set),ye=xe[0],be=xe[1],Se=r([]),Re=Se[0],Ce=Se[1],Ie=l(null),Be=l(null),we=l(null),Te=l(new Set),_e=l(!1),Fe=l(null),Ee=l({}),Me=l([]),De=l(!1),Ne=l(!1),Ae=l(null),ke=l(function(){}),He=u(function(){return(null==_n?void 0:_n.cognitive_decisioning)||{}},[_n]),Pe=r({width:0,height:0}),je=Pe[0],Le=Pe[1],Oe=u(function(){return n(n({},D),Dn)},[Dn]),ze=l(null),We=l(null),qe=l(null),Ye=l(null),Ke=l(null),Ve=l(null),Xe=l(null),$e=l(null),Je=l(!1),Ue=l(null),Ge=l(null),Qe=q(ze),Ze=Qe.cognitivePopup,nt=Qe.setCognitivePopup,et=Qe.moreFunctions,tt=Qe.setMoreFunctions,it=Qe.position,ot=Qe.setPosition,rt=Qe.activeBadgeId,lt=Qe.summaryPopup,ut=Qe.setSummaryPopup,ct=Qe.closeSummaryPopup,at=Qe.setActiveBadgeId,dt=Qe.popupRef,st=Qe.closeCognitivePopup,vt=Qe.closeMoreFunctionsPopup,pt=u(function(){var n,e,t,i,o,r,l;return{fields:null!==(n=null==Fn?void 0:Fn.fields)&&void 0!==n?n:N,thresholds:{high:null!==(t=null===(e=null==Fn?void 0:Fn.thresholds)||void 0===e?void 0:e.high)&&void 0!==t?t:A.thresholds.high,medium:null!==(o=null===(i=null==Fn?void 0:Fn.thresholds)||void 0===i?void 0:i.medium)&&void 0!==o?o:A.thresholds.medium,exact:null!==(l=null===(r=null==Fn?void 0:Fn.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:A.thresholds.exact}}},[Fn]),ft=r(null),gt=ft[0];ft[1];var ht=null===(on=null===(en=null==_n?void 0:_n.documents)||void 0===en?void 0:en[null===(tn=null==_n?void 0:_n.input_index_map)||void 0===tn?void 0:tn[0]])||void 0===on?void 0:on.title,mt=null===(un=null===(rn=null==_n?void 0:_n.documents)||void 0===rn?void 0:rn[null===(ln=null==_n?void 0:_n.input_index_map)||void 0===ln?void 0:ln[1]])||void 0===un?void 0:un.title,xt=y(En||ht||"Uploaded Contract"),yt=y(Mn||mt||"Reference Template"),bt=W(_n,Vn,jn,pt,ue),St=bt.activeProposed,Rt=bt.existingRule,Ct=bt.proposedSections,It=bt.existingSections,Bt=bt.visibleFields,wt=bt.parentDeviationRecord,Tt=bt.deviationNumberRegistry,_t=bt.parseError;c(function(){_t&&ie("Failed to load comparison: ".concat(_t))},[_t]);var Ft=Ct.length>0||It.length>0,Et=u(function(){if(!Yn)return"off";var n=0,e=0,t=function(i){Array.isArray(i)&&i.forEach(function(i){var o,r=(null==i?void 0:i.content)||"";F(r)&&(n+=1,e+=String(r).length),(null===(o=null==i?void 0:i.subsections)||void 0===o?void 0:o.length)&&t(i.subsections)})};return t(Ct),t(It),"".concat(n,":").concat(e)},[Yn,Ct,It]);c(function(){Yn&&"off"!==Et&&"0:0"!==Et&&(Be.current=null,Me.current=[],requestAnimationFrame(function(){var n;null===(n=ke.current)||void 0===n||n.call(ke)}))},[Yn,Et]);var Mt=u(function(){var n=new Map,e=new Map,t=1;if(Vn)Ct.forEach(function(e){!e.title&&!e.content||e.id&&n.set(e.id,t++)}),It.forEach(function(i){if(i.id){var o=Ct.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(i.selfIndex)});if(o.length>0){var r=o.map(function(e){return n.get(e.id)}).filter(Boolean);e.set(i.id,r.join(", "))}else e.set(i.id,String(t++))}});else for(var i=Math.max(Ct.length,It.length),o=0;o<i;o++){var r=Ct[o],l=It[o];r?(n.set(r.id,t),l&&e.set(l.id,String(t)),t++):l&&e.set(l.id,String(t++))}return{leftNums:n,rightNums:e}},[Ct,It,Vn]),Dt=Y(Bt.map(function(n){return n.key}),Math.max(Ct.length,It.length)),Nt=Dt.leftRefs,At=Dt.rightRefs,kt=Dt.sectionLeftRefs,Ht=Dt.sectionRightRefs,Pt=Dt.lhsBadgeRefs,jt=Dt.rhsBadgeRefs,Lt=Dt.sectionRightRowRefs,Ot=Dt.subSectionLeftRefs,zt=Dt.subSectionRightRefs,Wt=Dt.sectionRowRefs,qt=Dt.getSectionRowRef,Yt=Dt.getSubSectionRef,Kt=Dt.getBadgeRef,Vt=Rt.analysis,Xt=y(null===(an=null===(cn=null==Vt?void 0:Vt.rule_difference_comparison)||void 0===cn?void 0:cn.summary)||void 0===an?void 0:an.overall_summary),$t=!!Xt.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),Jt=null!==(dn=null==_n?void 0:_n.base_root_id)&&void 0!==dn?dn:"-1";null==_n||_n[Jt];var Ut=ue?null!==(Rn=null!==(yn=jn&&(null===(xn=null==jn?void 0:jn[Jt])||void 0===xn?void 0:xn.evaluation_result))&&void 0!==yn?yn:null===(Sn=null===(bn=null==_n?void 0:_n.nodes)||void 0===bn?void 0:bn[Jt])||void 0===Sn?void 0:Sn.evaluation_result)&&void 0!==Rn?Rn:null:null!==(mn=null!==(pn=jn&&(null===(vn=null===(sn=null==jn?void 0:jn[Jt])||void 0===sn?void 0:sn.evaluation_result)||void 0===vn?void 0:vn[0]))&&void 0!==pn?pn:null===(hn=null===(gn=null===(fn=null==_n?void 0:_n.nodes)||void 0===fn?void 0:fn[Jt])||void 0===gn?void 0:gn.evaluation_result)||void 0===hn?void 0:hn[0])&&void 0!==mn?mn:null,Gt=b(Ut),Qt=S(null!==(Bn=null===(In=null===(Cn=null==Ut?void 0:Ut.evaluation_outputs)||void 0===Cn?void 0:Cn.metadata)||void 0===In?void 0:In.label_color)&&void 0!==Bn?Bn:""),Zt=function(){Te.current.forEach(function(n){E(n)}),Te.current.clear()},ni=a(function(){var n,e,t,i,o,r;Zt(),le(!1),Ne.current=!1,Be.current=null;var l=Ae.current,u=yi.current;if(null!==l)if("string"==typeof l&&l.includes(R)){var c=l.split(R);(a=(null===(n=Ot.current[c[2]])||void 0===n?void 0:n.current)||(null===(e=kt.current[Number(c[2])])||void 0===e?void 0:e.current))&&(a.style.paddingTop="0px")}else{var a;(a=null===(t=kt.current[l])||void 0===t?void 0:t.current)&&(a.style.paddingTop="0px")}if(null!==u)if("string"==typeof u&&u.includes(R)){c=u.split(R);(d=(null===(i=zt.current[c[3]])||void 0===i?void 0:i.current)||(null===(o=Ht.current[Number(c[3])])||void 0===o?void 0:o.current))&&(d.style.paddingTop="0px")}else{var d;(d=null===(r=Ht.current[u])||void 0===r?void 0:r.current)&&(d.style.paddingTop="0px")}he(null),Ae.current=null,yi.current=null,de(!1),ne(!1),Ye.current&&(Ye.current.style.height="0px"),Ke.current&&(Ke.current.style.height="0px"),Ve.current&&(Ve.current.style.height="0px"),Xe.current&&(Xe.current.style.height="0px")},[]),ei=a(function(){Zt(),ni(),be(new Set),Ce([]),Me.current=[],Bi([]),_i(null),ut(k),st(),requestAnimationFrame(function(){var n;null===(n=ke.current)||void 0===n||n.call(ke)})},[]),ti=l(ei);c(function(){ti.current=ei},[ei]),c(function(){Nn&&ti.current()},[Nn]);var ii=K({maintainRelativeOrder:!!Vn,proposedSections:Ct,existingSections:It,activeSideBySideSection:ge,connectedSections:ye,resetSideBySide:ni,setConnectedSections:be,setConnectedLines:Ce,cachedConnectedPositions:Me,svgContainerRef:Ie,isAnimatingRef:_e,animationTimerRef:Fe,calculateLinesRef:ke,sectionLeftRefs:kt,sectionRightRefs:Ht,subSectionLeftRefs:Ot,subSectionRightRefs:zt}),oi=ii.expandedSections,ri=ii.setExpandedSections,li=ii.expandedSubSections,ui=ii.setExpandedSubSections,ci=ii.toggleSection,ai=a(function(e,t,i,o,r,l,u){var c,a,d,s=y(null==t?void 0:t.id)||y(null==i?void 0:i.id)||"",v=(s?He[s]:null)||(null==t?void 0:t.cognitiveData)||(null==i?void 0:i.cognitiveData)||{section_id:s,decisioning:[],gap:[],relevance_score:0},p=null!==(a=null===(c=Wt.current[o])||void 0===c?void 0:c.current)&&void 0!==a?a:null;return{isLoading:null!==(d=null==kn?void 0:kn.isLoading)&&void 0!==d&&d,open:!0,sectionTitle:(null==t?void 0:t.title)?null==t?void 0:t.title:"No Counterpart",refSectionTitle:(null==i?void 0:i.title)?null==i?void 0:i.title:"No Counterpart",cognitiveData:v,anchorEl:e,sectionAnchorEl:p,badgeStyle:l||null,sectionIdx:o,docData:{documents:null==_n?void 0:_n.documents,input_index_map:null==_n?void 0:_n.input_index_map},deviationData:function(){var e,r,l=(null==t?void 0:t.evaluationResult)||(null==i?void 0:i.evaluationResult)||null,u=function(e){var t=function(n){if(!n||"object"!=typeof n)return null;var e=null==n?void 0:n.deviation_entries;if(e&&"object"==typeof e){var t=Object.keys(e).sort(function(n,e){return Number(n)-Number(e)})[0];if(t&&e[t])return e[t]}var i=Object.keys(n).filter(function(n){return/^\d+$/.test(n)}).sort(function(n,e){return Number(n)-Number(e)});if(i.length&&n[i[0]])return n[i[0]];var o=null==n?void 0:n.deviations;if(o&&"object"==typeof o){var r=Object.keys(o).sort(function(n,e){return Number(n)-Number(e)})[0];if(r&&o[r])return o[r]}return null}(e);return t?n(n({},e),{deviation_summary:(null==e?void 0:e.deviation_summary)||(null==t?void 0:t.deviation_summary),deviation_title:(null==e?void 0:e.deviation_title)||(null==t?void 0:t.deviation_title),deviation_impact:(null==e?void 0:e.deviation_impact)||(null==t?void 0:t.deviation_impact),deviation_explanation:(null==e?void 0:e.deviation_explanation)||(null==t?void 0:t.deviation_explanation),evaluation_outputs:(null==e?void 0:e.evaluation_outputs)||(null==t?void 0:t.evaluation_outputs),cognitive_decisioning:(null==e?void 0:e.cognitive_decisioning)||(null==t?void 0:t.cognitive_decisioning)}):e};if(!("string"==typeof o&&o.includes(R)))return u(l);var c=o.split(R)[1];if(!c)return l;var a=(null==t?void 0:t.evaluationResult)||(null==i?void 0:i.evaluationResult)||{},d=(null===(e=null==a?void 0:a.deviation_entries)||void 0===e?void 0:e[c])||(null===(r=null==a?void 0:a.deviations)||void 0===r?void 0:r[c])||null;return d?n(n(n({},a),d),{deviation_summary:(null==d?void 0:d.deviation_summary)||(null==a?void 0:a.deviation_summary),deviation_title:(null==d?void 0:d.deviation_title)||(null==a?void 0:a.deviation_title),deviation_impact:(null==d?void 0:d.deviation_impact)||(null==a?void 0:a.deviation_impact),deviation_explanation:(null==d?void 0:d.deviation_explanation)||(null==a?void 0:a.deviation_explanation),evaluation_outputs:(null==d?void 0:d.evaluation_outputs)||(null==a?void 0:a.evaluation_outputs),cognitive_decisioning:(null==d?void 0:d.cognitive_decisioning)||(null==a?void 0:a.cognitive_decisioning)}):u(l)}(),isOrphan:!!r}},[He,_n]),di=a(function(n){vt(),ot(null),nt(n)},[vt]),si=function(n,e,t,i,o,r){var l;if(n.stopPropagation(),et.open&&et.sectionIdx===o)vt();else{var u=n.currentTarget,c="left";(null===(l=qe.current)||void 0===l?void 0:l.contains(u))&&(c="right");Zt(),Ne.current&&ni(),be(new Set),Ce([]),Me.current=[],st(),lt.open?$i():ct(),requestAnimationFrame(function(){var n=function(){var n,e,t,i;if("string"==typeof o&&o.includes(R)){var r=o.split(R),l="".concat(r[0]).concat(R).concat(r[1]);return"right"===c?null===(n=jt.current[l])||void 0===n?void 0:n.current:null===(e=Pt.current[l])||void 0===e?void 0:e.current}return"right"===c?null===(t=jt.current[o])||void 0===t?void 0:t.current:null===(i=Pt.current[o])||void 0===i?void 0:i.current}()||u;tt(ai(n,e,i,o,t,r))})}},vi=a(function(){null!==et.sectionIdx&&et.anchorEl?di(n(n({},et),{open:!0})):vt()},[et,vt,di]),pi=a(function(){var n=et.sectionIdx,e=et.isOrphan;vt(),ct(),null!==n&&(e?ie("No counterpart exists to connect to."):(Zt(),Ne.current&&ni(),Ce([]),Me.current=[],be(function(e){return e.has(n)?new Set:new Set([n])}),setTimeout(function(){ke.current&&ke.current()},50)))},[et.sectionIdx,et.isOrphan,vt,ct,ni]),fi=a(function(){var n=we.current;if(n){we.current=null;var e=Ct.findIndex(function(e){return e.id===n}),t=It.findIndex(function(e){return e.id===n}),i=-1===e?C(Ct,n):null,o=-1===t?C(It,n):null,r=-1!==e?e:i?Number(i.split("-")[0]):-1,l=-1!==t?t:o?Number(o.split("-")[0]):-1,u=function(n,e,t,i){var o,r,l,u;return-1!==n?null!==(r=null===(o=t.current[n])||void 0===o?void 0:o.current)&&void 0!==r?r:null:e&&null!==(u=null===(l=i.current[e])||void 0===l?void 0:l.current)&&void 0!==u?u:null},c=function(n,e,t){void 0===t&&(t=30);var i=0,o=function(){var r=n();r&&0!==r.getBoundingClientRect().height?(Te.current.add(r),M(r,e)):i++<t&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(Vn)-1!==r&&$e.current&&c(function(){return u(e,i,kt,Ot)},$e.current),-1!==l&&qe.current&&c(function(){return u(t,o,Ht,zt)},qe.current);else{var a=ze.current;if(!a)return;c(function(){return-1!==r?u(e,i,kt,Ot):u(t,o,Ht,zt)},a)}}},[Ct,It,Vn,kt,Ht,Ot,zt,$e,qe,ze]),gi=a(function(e){if(e){Zt(),ni(),be(new Set),Ce([]),Me.current=[],ct(),st();var t=Ct.findIndex(function(n){return n.id===e}),i=It.findIndex(function(n){return n.id===e}),o=-1===t?C(Ct,e):null,r=-1===i?C(It,e):null;if(-1!==t||o||-1!==i||r){var l=-1!==t?t:o?Number(o.split("-")[0]):-1,u=-1!==i?i:r?Number(r.split("-")[0]):-1;we.current=e,ri(function(e){var t,i=n({},e),o=!1;-1!==l&&(i[t=Vn?"left-".concat(l):String(l)]||(i[t]=!0,o=!0));-1!==u&&(i[t=Vn?"right-".concat(u):String(u)]||(i[t]=!0,o=!0));return o?i:e}),ui(function(e){var t=n({},e),i=!1,l=function(n){for(var e=n.split("-"),o=e[0],r=1;r<e.length;r++)o+="-".concat(e[r]),t[o]||(t[o]=!0,i=!0)};return o&&l(o),r&&l(r),i?t:e}),setTimeout(function(){requestAnimationFrame(function(){we.current===e&&hi.current()})},50)}else console.warn('scrollToAndHighlightClause: nodeId "'.concat(e,'" not found'))}},[Ct,It,Vn,ri,ui,ni,ct,st]),hi=l(fi);c(function(){hi.current=fi},[fi]);var mi=l(null),xi=l(null),yi=l(null),bi=l(null),Si=l(null),Ri=l(null),Ci=r([]),Ii=Ci[0],Bi=Ci[1];l(null);var wi=r(null),Ti=wi[0],_i=wi[1];c(function(){if(gt){var n=pt.fields.find(function(n){return n.analysisKey===gt||n.key===gt});if(n){var e=Nt.current[n.key]||At.current[n.key];(null==e?void 0:e.current)&&setTimeout(function(){return e.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[gt,pt.fields]);var Fi=a(function(n){var e,t,i,o,r,l,u,c,a,d=null===(e=null==Vt?void 0:Vt.rule_difference_comparison)||void 0===e?void 0:e.fields;if(!d||!d[n])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var s=d[n],v=(null==s?void 0:s.relation)||(null===(i=null===(t=null==s?void 0:s.highlights)||void 0===t?void 0:t.ruleA_spans)||void 0===i?void 0:i.length)||(null===(r=null===(o=null==s?void 0:s.highlights)||void 0===o?void 0:o.ruleB_spans)||void 0===r?void 0:r.length)||(null==s?void 0:s.mappings)&&s.mappings.length>0;if(s.mappings){var p=s.mappings[0]||{};return{score:s.score,relation:p.relation||"",highlightsA:(null===(l=p.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(u=p.highlights)||void 0===u?void 0:u.ruleB_spans)||[],hasContent:!!v}}return{score:s.score,relation:s.relation||"",highlightsA:(null===(c=s.highlights)||void 0===c?void 0:c.ruleA_spans)||[],highlightsB:(null===(a=s.highlights)||void 0===a?void 0:a.ruleB_spans)||[],hasContent:!!v}},[Vt]),Ei=a(function(e,t){var i,o,r;void 0===t&&(t="left");var l=null,u=null;if("left"===t)if(l=Ct[e],Vn&&l){var c=It.filter(function(n){var e;return null===(e=l.refIndexes)||void 0===e?void 0:e.includes(n.selfIndex)});u=c.find(function(n){return n.evaluationResult})||c[0]}else u=It[e];else if(u=It[e],Vn&&u){var a=Ct.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(u.selfIndex)});l=a.find(function(n){return n.evaluationResult})||a[0]}else l=Ct[e];var d=(null==l?void 0:l.relation)&&"not_defined"!==l.relation,s=(null==u?void 0:u.relation)&&"not_defined"!==u.relation,v=!(!(null==l?void 0:l.cognitiveData)&&!(null==u?void 0:u.cognitiveData));if(!d&&!s&&!v)return n(n({},S(H)),{label:"Not Defined"});var p=null!==(o=null!==(i=null==l?void 0:l.evaluationResult)&&void 0!==i?i:null==u?void 0:u.evaluationResult)&&void 0!==o?o:null,f=I(p),g=B(p);return n(n({},S(g)),null!=p?{label:null!==(r=f)&&void 0!==r?r:""}:{label:null})},[Ct,It,He,pt,Vn]),Mi=a(function(e){for(var t,i,o,r,l,u=e.split("-").map(Number),c=Ct[u[0]],a=It[u[0]],d=1;d<u.length;d++)(null==c?void 0:c.subsections)&&(c=c.subsections[u[d]]),(null==a?void 0:a.subsections)&&(a=a.subsections[u[d]]);if(!c&&!a)return null;var s=(null==c?void 0:c.relation)&&"not_defined"!==c.relation,v=(null==a?void 0:a.relation)&&"not_defined"!==a.relation,p=y(null==c?void 0:c.id)||y(null==a?void 0:a.id)||"",f=!(!(null==c?void 0:c.cognitiveData)&&!(null==a?void 0:a.cognitiveData));if(!s&&!v&&!f)return n(n({},S(H)),{label:"Not Defined"});null!==(i=null!==(t=null==c?void 0:c.cognitiveRelevanceScore)&&void 0!==t?t:null==a?void 0:a.cognitiveRelevanceScore)&&void 0!==i||p&&(null===(o=He[p])||void 0===o||o.relevance_score);var g=null!==(l=null!==(r=null==c?void 0:c.evaluationResult)&&void 0!==r?r:null==a?void 0:a.evaluationResult)&&void 0!==l?l:null,h=I(g),m=B(g);return n(n({},S(m)),null!=g?{label:null!=h?h:""}:{label:null})},[Ct,It,He,pt]),Di=a(function(e,t){var i,o,r,l,u,c,a,d,s,v,p,f,g,h,m,x,y;if(!e||null==t)return null;var b=null!==(a=null!==(u=null!==(o=null===(i=null==jn?void 0:jn[e])||void 0===i?void 0:i.evaluation_result)&&void 0!==o?o:null===(l=null===(r=null==_n?void 0:_n.nodes)||void 0===r?void 0:r[e])||void 0===l?void 0:l.evaluation_result)&&void 0!==u?u:null===(c=null==_n?void 0:_n[e])||void 0===c?void 0:c.evaluation_result)&&void 0!==a?a:null;if(!b||"object"!=typeof b)return null;var R=null!==(p=null!==(s=null===(d=null==b?void 0:b.deviations)||void 0===d?void 0:d[t])&&void 0!==s?s:null===(v=null==b?void 0:b.deviation_entries)||void 0===v?void 0:v[t])&&void 0!==p?p:null==b?void 0:b[t],C=null!==(y=null!==(h=null===(g=null===(f=null==R?void 0:R.evaluation_outputs)||void 0===f?void 0:f.metadata)||void 0===g?void 0:g.label_color)&&void 0!==h?h:null===(x=null===(m=null==b?void 0:b.evaluation_outputs)||void 0===m?void 0:m.metadata)||void 0===x?void 0:x.label_color)&&void 0!==y?y:H;return n(n({},S(C)),{label:null})},[jn,_n]),Ni=a(function(){Zt(),ri({}),ui({}),ni(),be(new Set),Ce([]),Me.current=[],ct(),st(),vt(),requestAnimationFrame(function(){ke.current&&ke.current()})},[ri,ui,ni,ct,st,vt]),Ai=u(function(){return Object.values(oi).some(Boolean)||Object.values(li).some(Boolean)},[oi,li]),ki=a(function(){var n,e,t,i,o,r,l,u,c,a,d,s,v,p,f,g,h,m,x,y,b,S,C;if(!Je.current&&!_e.current){Je.current=!0;try{if(!mi.current)return;var I=function(n){var e=n.split("-"),t=e[0];if(!oi[t]&&!1===Vn)return!1;if(Vn&&!oi["left-".concat(t)]&&!oi["right-".concat(t)]&&!oi[t])return!1;for(var i=t,o=1;o<e.length-1;o++)if(i+="-".concat(e[o]),!li[i])return!1;return!0},B=mi.current.getBoundingClientRect();Le({width:B.width,height:B.height});var _=[];if(Bt.forEach(function(n){var e,t,i=n.key,o=null===(e=Nt.current[i])||void 0===e?void 0:e.current,r=null===(t=At.current[i])||void 0===t?void 0:t.current;o&&r&&(o.style.height="auto",r.style.height="auto",o.style.minHeight="0px",r.style.minHeight="0px")}),!_e.current){for(var F=0;F<Math.max(Ct.length,It.length);F++){var E=null===(n=kt.current[F])||void 0===n?void 0:n.current,M=null===(e=Ht.current[F])||void 0===e?void 0:e.current;E&&(E.style.height="auto",E.style.minHeight="0px"),M&&(M.style.height="auto",M.style.minHeight="0px")}Vn||Object.keys(Ot.current).forEach(function(n){var e,t;if(I(n)){var i=null===(e=Ot.current[n])||void 0===e?void 0:e.current,o=null===(t=zt.current[n])||void 0===t?void 0:t.current;i&&o&&(i.style.height="auto",o.style.height="auto",i.style.minHeight="0px",o.style.minHeight="0px")}})}var D={};Bt.forEach(function(n){var e,t,i=n.key,o=null===(e=Nt.current[i])||void 0===e?void 0:e.current,r=null===(t=At.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),u=r.getBoundingClientRect();D[i]=Math.max(l.height,u.height)}});var N={left:{},right:{}},A={};if(!_e.current)if(Vn){if(re&&null!==ge)if("number"==typeof ge){var k=ge,H=Ct[k],P=null===(o=kt.current[k])||void 0===o?void 0:o.current;P&&H&&(H.refIndexes||[]).forEach(function(n){var e,t=It.findIndex(function(e){return e.selfIndex===n}),i=null===(e=Ht.current[t])||void 0===e?void 0:e.current;if(i&&(oi["left-".concat(k)]||oi["right-".concat(t)])){var o=Math.max(P.getBoundingClientRect().height,i.getBoundingClientRect().height);N.left[k]=Math.max(N.left[k]||0,o),N.right[t]=Math.max(N.right[t]||0,o)}})}else{var j=ge.split(R)[2];if(j){E=null===(r=Ot.current[j])||void 0===r?void 0:r.current,M=null===(l=zt.current[j])||void 0===l?void 0:l.current;if(E&&M){L=Math.max(E.getBoundingClientRect().height,M.getBoundingClientRect().height);A[j]=Math.max(A[j]||0,L)}}}}else{Object.keys(Ot.current).forEach(function(n){var e,t;if(I(n)){var i=null===(e=Ot.current[n])||void 0===e?void 0:e.current,o=null===(t=zt.current[n])||void 0===t?void 0:t.current;if(i&&o&&null!==i.offsetParent&&null!==o.offsetParent){var r=i.getBoundingClientRect(),l=o.getBoundingClientRect(),u=Math.max(r.height,l.height);A[n]=u,i.style.minHeight="".concat(u,"px"),o.style.minHeight="".concat(u,"px")}}});for(F=0;F<Math.min(Ct.length,It.length);F++){var E=null===(t=kt.current[F])||void 0===t?void 0:t.current,M=null===(i=Ht.current[F])||void 0===i?void 0:i.current;if(E&&M){var L=Math.max(E.getBoundingClientRect().height,M.getBoundingClientRect().height);N.left[F]=L,N.right[F]=L}}}if(Bt.forEach(function(n){var e,t,i=n.key,o=null===(e=Nt.current[i])||void 0===e?void 0:e.current,r=null===(t=At.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=D[i];o.style.minHeight="".concat(l,"px"),r.style.minHeight="".concat(l,"px")}}),_e.current||(Object.entries(N.left).forEach(function(n){var e,t=n[0],i=n[1],o=null===(e=kt.current[Number(t)])||void 0===e?void 0:e.current;o&&(o.style.minHeight="".concat(i,"px"))}),Object.entries(N.right).forEach(function(n){var e,t=n[0],i=n[1],o=null===(e=Ht.current[Number(t)])||void 0===e?void 0:e.current;o&&(o.style.minHeight="".concat(i,"px"))}),Vn||Object.keys(A).forEach(function(n){var e,t,i=null===(e=Ot.current[n])||void 0===e?void 0:e.current,o=null===(t=zt.current[n])||void 0===t?void 0:t.current;if(i&&o&&A[n]){var r=A[n];i.style.minHeight="".concat(r,"px"),o.style.minHeight="".concat(r,"px")}})),Vn)Ct.forEach(function(n,e){var t;(null===(t=kt.current[e])||void 0===t?void 0:t.current)&&(n.refIndexes||[]).forEach(function(n){var t,i,o,r,l,u,c,a,d,s,v=It.findIndex(function(e){return e.selfIndex===n});if(-1!==v){var p=null===(t=Pt.current[e])||void 0===t?void 0:t.current,f=null===(i=jt.current[v])||void 0===i?void 0:i.current;if(p&&f){var g=p.getBoundingClientRect(),h=f.getBoundingClientRect(),m=g.right-B.left,x=h.left-B.left,y=g.top+g.height/2-B.top,b=h.top+h.height/2-B.top;if(re&&ge===e){var S=null!==(r=null===(o=$e.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==r?r:0,R=null!==(u=null===(l=qe.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==u?u:0,C=S+(null!==(a=null===(c=$e.current)||void 0===c?void 0:c.clientHeight)&&void 0!==a?a:1/0),I=R+(null!==(s=null===(d=qe.current)||void 0===d?void 0:d.clientHeight)&&void 0!==s?s:1/0),w=g.top+g.height/2,T=h.top+h.height/2,F=function(n,e,t){return Math.max(e,Math.min(t,n))};y=F(w,S,C)-B.top,b=F(T,R,I)-B.top}var E=Ei(e);E&&_.push({id:"line-".concat(e,"-").concat(v),x1:m,y1:y,x2:x,y2:b,style:E,sectionIdx:e,targetRightIdx:v})}}})});else{for(F=0;F<Math.min(Ct.length,It.length);F++){var O=null===(u=kt.current[F])||void 0===u?void 0:u.current,z=null===(c=Ht.current[F])||void 0===c?void 0:c.current;if(O&&z){var W=O.getBoundingClientRect(),q=z.getBoundingClientRect(),Y=Math.max(W.top,q.top)+18-B.top,K=(null===(a=It[F])||void 0===a?void 0:a.id)||"sec-".concat(F);(Z=Ei(F))&&_.push({id:K,x1:W.right-B.left,y1:Y,x2:q.left-B.left,y2:Y,style:Z,sectionIdx:F,hasCognitive:!!((null===(d=Ct[F])||void 0===d?void 0:d.cognitiveData)||(null===(s=It[F])||void 0===s?void 0:s.cognitiveData)||K&&He[K]),isSubSection:!1})}}Object.keys(Ot.current).forEach(function(n){var e,t,i,o,r,l;if(I(n)){var u=null===(e=Ot.current[n])||void 0===e?void 0:e.current,c=null===(t=zt.current[n])||void 0===t?void 0:t.current;if(u&&c){for(var a=n.split("-").map(Number),d=Ct[a[0]],s=It[a[0]],v=1;v<a.length;v++)(null==d?void 0:d.subsections)&&(d=d.subsections[a[v]]),(null==s?void 0:s.subsections)&&(s=s.subsections[a[v]]);var p=!!d&&((null===(i=d.displayTitle)||void 0===i||i)&&w(d.title)),f=!!d&&((null===(o=d.displayContent)||void 0===o||o)&&w(d.content)),g=!!s&&((null===(r=s.displayTitle)||void 0===r||r)&&w(s.title)),h=!!s&&((null===(l=s.displayContent)||void 0===l||l)&&w(s.content));if(p&&f||g&&h){var m=u.getBoundingClientRect(),x=c.getBoundingClientRect(),y=Math.max(m.top,x.top)+16-B.top,b=Mi(n);b&&"Not Defined"!==b.label&&_.push({id:"subsec-".concat(n),x1:m.right-B.left,y1:y,x2:x.left-B.left,y2:y,style:b,sectionIdx:a[0],isSubSection:!0,subSectionKeyPath:n,hasCognitive:!(!(null==d?void 0:d.cognitiveData)&&!(null==s?void 0:s.cognitiveData))})}}}})}if(re&&"string"==typeof ge&&ge.includes(R)){var V=ge.split(R),X=V[0],$=V[1],J=V[2],U=(V[3],"".concat(X).concat(R).concat($)),G=null===(v=Pt.current[U])||void 0===v?void 0:v.current,Q=null===(p=jt.current[U])||void 0===p?void 0:p.current;if(G&&Q){var Z,nn=G.getBoundingClientRect(),en=Q.getBoundingClientRect(),tn=nn.right-B.left,on=en.left-B.left,rn=nn.top+nn.height/2-B.top,ln=en.top+en.height/2-B.top;if(Vn){var un=null!==(g=null===(f=$e.current)||void 0===f?void 0:f.getBoundingClientRect().top)&&void 0!==g?g:0,cn=null!==(m=null===(h=qe.current)||void 0===h?void 0:h.getBoundingClientRect().top)&&void 0!==m?m:0,an=un+(null!==(y=null===(x=$e.current)||void 0===x?void 0:x.clientHeight)&&void 0!==y?y:1/0),dn=cn+(null!==(S=null===(b=qe.current)||void 0===b?void 0:b.clientHeight)&&void 0!==S?S:1/0),sn=function(n,e,t){return Math.max(e,Math.min(t,n))};rn=sn(nn.top+nn.height/2,un,an)-B.top,ln=sn(en.top+en.height/2,cn,dn)-B.top}(Z=null!==(C=Di(X,$))&&void 0!==C?C:Mi(J))&&_.push({id:"line-subsec-".concat(U),x1:tn,y1:rn,x2:on,y2:ln,style:Z,sectionIdx:Number(J.split("-")[0]),isSubSection:!0,subSectionKeyPath:ge})}}if(Bi(_),Si.current&&Ri.current){var vn=Si.current.getBoundingClientRect(),pn=Ri.current.getBoundingClientRect(),fn=(vn.top+vn.height/2-B.top+pn.top+pn.height/2-B.top)/2;_i({x1:vn.right-B.left,x2:pn.left-B.left,y:fn})}else _i(null);if(ye.size>0){var gn=[],hn=$e.current,mn=qe.current;if(hn&&mn){var xn=[],yn=hn.getBoundingClientRect().top,bn=mn.getBoundingClientRect().top,Sn=yn+hn.clientHeight,Rn=bn+mn.clientHeight,Cn=hn.scrollTop,In=mn.scrollTop,Bn=B.top,wn=function(n,e,t){return Math.max(e,Math.min(t,n))};ye.forEach(function(n){var e,t,i,o,r,l;if("string"==typeof n&&n.includes(R)){var u=n.split(R),c=u[0],a=u[1],d=u[2],s=(u[3],"".concat(c).concat(R).concat(a)),v=null===(e=Pt.current[s])||void 0===e?void 0:e.current,p=null===(t=jt.current[s])||void 0===t?void 0:t.current;if(!v||!p)return;var f=v.getBoundingClientRect(),g=p.getBoundingClientRect(),h=null!==(i=Di(c,a))&&void 0!==i?i:Mi(d),m=(H=f.right-B.left)+.5*((P=g.left-B.left-0)-H),x=f.top+f.height/2,y=g.top+g.height/2,b=x-yn+Cn,S=y-bn+In,C="conn-subsec-".concat(s);xn.push({lhsScrollY:b,rhsScrollY:S,x1:H,x2:P,containerTop:Bn,leftIdx:n,rhsArrayIdx:n,styleColor:(null==h?void 0:h.badgeBorder)||"#6366F1",styleId:C});var I=wn(x,yn,Sn),w=wn(y,bn,Rn),_=I-Bn,F=w-Bn,E=y>=bn-4&&y<=Rn+4,M="";M=(j=x>=yn-4&&x<=Sn+4)&&E?T(H,_,P,F):j&&!E?"M ".concat(H,",").concat(_," L ").concat(m,",").concat(_," L ").concat(m,",").concat(F):!j&&E?"M ".concat(m,",").concat(_," L ").concat(m,",").concat(F," L ").concat(P,",").concat(F):"M ".concat(m,",").concat(_," L ").concat(m,",").concat(F),gn.push({id:C,pathD:M,style:h,leftIdx:n,rhsArrayIdx:n})}else if(Vn){var D=n,N=Ct[D];if(!(null===(l=null==N?void 0:N.refIndexes)||void 0===l?void 0:l.length))return;N.refIndexes.forEach(function(n){var e,t,i=It.findIndex(function(e){return e.selfIndex===n});if(-1!==i){var o=null===(e=Pt.current[D])||void 0===e?void 0:e.current,r=null===(t=jt.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),u=r.getBoundingClientRect(),c=Ei(D),a=l.right-B.left,d=u.left-B.left-0,s=a+.5*(d-a),v=l.top+l.height/2,p=u.top+u.height/2,f=v-yn+Cn,g=p-bn+In,h="conn-".concat(D,"-").concat(i);xn.push({lhsScrollY:f,rhsScrollY:g,x1:a,x2:d,containerTop:Bn,leftIdx:D,rhsArrayIdx:i,styleColor:(null==c?void 0:c.badgeBorder)||"#6366F1",styleId:h});var m=wn(v,yn,Sn),x=wn(p,bn,Rn),y=m-Bn,b=x-Bn,S=v>=yn-4&&v<=Sn+4,R=p>=bn-4&&p<=Rn+4,C="";C=S&&R?T(a,y,d,b):S&&!R?"M ".concat(a,",").concat(y," L ").concat(s,",").concat(y," L ").concat(s,",").concat(b):!S&&R?"M ".concat(s,",").concat(y," L ").concat(s,",").concat(b," L ").concat(d,",").concat(b):"M ".concat(s,",").concat(y," L ").concat(s,",").concat(b),gn.push({id:h,pathD:C,style:c,leftIdx:D,rhsArrayIdx:i})}}})}else{var A=n,k=A;v=null===(o=Pt.current[A])||void 0===o?void 0:o.current,p=null===(r=jt.current[k])||void 0===r?void 0:r.current;if(!v||!p)return;var H,P;f=v.getBoundingClientRect(),g=p.getBoundingClientRect(),h=Ei(A),m=(H=f.right-B.left)+.5*((P=g.left-B.left-0)-H),x=f.top+f.height/2,y=g.top+g.height/2,b=x-yn+Cn,S=y-bn+In,C="conn-".concat(A,"-").concat(k);xn.push({lhsScrollY:b,rhsScrollY:S,x1:H,x2:P,containerTop:Bn,leftIdx:A,rhsArrayIdx:k,styleColor:(null==h?void 0:h.badgeBorder)||"#6366F1",styleId:C});var j;I=wn(x,yn,Sn),w=wn(y,bn,Rn),_=I-Bn,F=w-Bn,E=y>=bn-4&&y<=Rn+4,M="";M=(j=x>=yn-4&&x<=Sn+4)&&E?T(H,_,P,F):j&&!E?"M ".concat(H,",").concat(_," L ").concat(m,",").concat(_," L ").concat(m,",").concat(F):!j&&E?"M ".concat(m,",").concat(_," L ").concat(m,",").concat(F," L ").concat(P,",").concat(F):"M ".concat(m,",").concat(_," L ").concat(m,",").concat(F),gn.push({id:C,pathD:M,style:h,leftIdx:A,rhsArrayIdx:k})}}),Me.current=xn}Ce(gn)}else Ce([]),Me.current=[]}catch(n){console.error("Line render safe fail: ",n)}finally{Je.current=!1}}},[Bt,Ct,It,He,pt,Fi,Ei,Di,Vn,re,ge,ye,oi,li]),Hi=a(function(){var n,e,t,i,o,r,l,u,c,a,d,s,v,p,f=Me.current;if(f.length&&!_e.current){var g=null!==(e=null===(n=$e.current)||void 0===n?void 0:n.scrollTop)&&void 0!==e?e:0,h=null!==(i=null===(t=qe.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,m=null!==(r=null===(o=$e.current)||void 0===o?void 0:o.clientHeight)&&void 0!==r?r:1/0,x=null!==(u=null===(l=qe.current)||void 0===l?void 0:l.clientHeight)&&void 0!==u?u:1/0,y=null!==(a=null===(c=$e.current)||void 0===c?void 0:c.getBoundingClientRect().top)&&void 0!==a?a:0,b=null!==(s=null===(d=qe.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==s?s:0,S=y+m,R=b+x,C=null!==(p=null===(v=mi.current)||void 0===v?void 0:v.getBoundingClientRect().top)&&void 0!==p?p:0,I=function(n,e,t){return Math.max(e,Math.min(t,n))};f.forEach(function(n){var e=n.lhsScrollY-g+y,t=n.rhsScrollY-h+b,i=Ee.current[n.styleId+"-stroke"],o=Ee.current[n.styleId+"-bg"];if(i||o){var r,l=I(e,y,S),u=I(t,b,R),c=l-C,a=u-C,d=e>=y-4&&e<=S+4,s=t>=b-4&&t<=R+4,v=n.x1+.5*(n.x2-n.x1);r=d&&s?T(n.x1,c,n.x2,a):d&&!s?"M ".concat(n.x1,",").concat(c," L ").concat(v,",").concat(c," L ").concat(v,",").concat(a):!d&&s?"M ".concat(v,",").concat(c," L ").concat(v,",").concat(a," L ").concat(n.x2,",").concat(a):"M ".concat(v,",").concat(c," L ").concat(v,",").concat(a),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",r)),o&&(o.setAttribute("visibility","visible"),o.setAttribute("d",r))}})}},[]);c(function(){ke.current=ki},[ki]);var Pi=l(null),ji=l(null),Li=a(function(){Me.current.length>0&&!_e.current||(null!==Pi.current&&clearTimeout(Pi.current),Pi.current=setTimeout(function(){ke.current(),Pi.current=null},50))},[]),Oi=a(function(){pe(!0),de(!1),Be.current=null,null!==ji.current&&clearTimeout(ji.current),null!==Pi.current&&(clearTimeout(Pi.current),Pi.current=null),ji.current=setTimeout(function(){var n,e,t,i,o,r,l,u,c,a,d;try{if(Me.current=[],Ne.current&&null!==Ae.current&&null!==yi.current){var s=Ae.current,v=yi.current,p="string"==typeof s&&s.includes(R),f=null,g=null,h=null,m=null;if(p){var x=s.split(R),y="".concat(x[0]).concat(R).concat(x[1]);f=(null===(n=Pt.current[y])||void 0===n?void 0:n.current)||null,g=(null===(e=jt.current[y])||void 0===e?void 0:e.current)||null,h=(null===(t=Ot.current[x[2]])||void 0===t?void 0:t.current)||(null===(i=kt.current[Number(x[2])])||void 0===i?void 0:i.current)||null,m=(null===(o=zt.current[x[3]])||void 0===o?void 0:o.current)||(null===(r=Ht.current[Number(x[3])])||void 0===r?void 0:r.current)||null}else f=(null===(l=Wt.current[s])||void 0===l?void 0:l.current)||null,h=(null===(u=kt.current[s])||void 0===u?void 0:u.current)||null,g=(null===(c=Lt.current[v])||void 0===c?void 0:c.current)||null,m=(null===(a=Ht.current[v])||void 0===a?void 0:a.current)||null;if(f&&g&&h&&m){if(h.style.paddingTop="0px",m.style.paddingTop="0px",!Vn){var b=f.getBoundingClientRect(),S=g.getBoundingClientRect(),C=b.top-S.top;C>0?m.style.paddingTop="".concat(C,"px"):C<0&&(h.style.paddingTop="".concat(Math.abs(C),"px"))}var I=$e.current,B=qe.current;if(I&&B){var w=f.getBoundingClientRect().top-I.getBoundingClientRect().top+I.scrollTop,T=g.getBoundingClientRect().top-B.getBoundingClientRect().top+B.scrollTop-(w-I.scrollTop);Math.abs(B.scrollTop-T)>1&&(B.scrollTop=T)}}}null===(d=ke.current)||void 0===d||d.call(ke),Ne.current&&de(!0)}catch(n){console.error("Safely caught error during resize calculation:",n)}finally{pe(!1),ji.current=null}},150)},[Vn,Ct,It]),zi=a(function(n){if(null!==Ue.current&&Ge.current&&Math.abs(n.currentTarget.scrollTop-Ue.current)<=2){var e=Ge.current;Ue.current=null,Ge.current=null,e()}me.current||(Vn||Li(),De.current||(De.current=!0,requestAnimationFrame(function(){var n,e,t,i,o,r,l;if(Ne.current){var u=$e.current,c=qe.current;if(u&&c&&bi.current){if(!Be.current){var a=Ae.current,d=void 0;if("string"==typeof a&&a.includes(R)){var s=a.split(R),v="".concat(s[0]).concat(R).concat(s[1]);d=null===(n=Pt.current[v])||void 0===n?void 0:n.current}else d=null===(e=Pt.current[a])||void 0===e?void 0:e.current;if(d){var p=d.getBoundingClientRect();Be.current={badgeScreenY:p.top+p.height/2,initialScrollTop:u.scrollTop,leftTop:u.getBoundingClientRect().top,leftBottom:u.getBoundingClientRect().top+u.clientHeight,cTop:null!==(i=null===(t=mi.current)||void 0===t?void 0:t.getBoundingClientRect().top)&&void 0!==i?i:0}}}if(Be.current){var f=Be.current,g=u.scrollTop-f.initialScrollTop,h=f.badgeScreenY-g,m=((o=h,r=f.leftTop,l=f.leftBottom,Math.max(r,Math.min(l,o)))-f.cTop).toString(),x=h>=f.leftTop-4&&h<=f.leftBottom+4;bi.current.setAttribute("y1",m),bi.current.setAttribute("y2",m),bi.current.setAttribute("visibility",x?"visible":"hidden")}}}Me.current.length>0&&Hi(),De.current=!1})))},[Hi,Vn,Li]),Wi=l(0),qi=l(0),Yi=l(0),Ki=l(function(){});l(null),c(function(){Ki.current=Oi},[Oi]),c(function(){var n=setTimeout(Li,250),e=function(){return Ki.current()};return window.addEventListener("resize",e),function(){clearTimeout(n),null!==Pi.current&&clearTimeout(Pi.current),null!==ji.current&&clearTimeout(ji.current),window.removeEventListener("resize",e)}},[St,Rt,Vt,Bt,oi,li,Ct,It,pt,Li,re,ge,ae,ye]),c(function(){var n=function(n,e,t,i,o){e.current=n.getBoundingClientRect().width;var r=new ResizeObserver(function(n){null!==t.current&&cancelAnimationFrame(t.current),t.current=requestAnimationFrame(function(){var r,l,u;t.current=null;var c=n[n.length-1];if(c){var a=null!==(u=null===(l=null===(r=c.borderBoxSize)||void 0===r?void 0:r[0])||void 0===l?void 0:l.inlineSize)&&void 0!==u?u:c.contentRect.width;Math.abs(a-e.current)<1?o():(e.current=a,i())}})});return r.observe(n),r},e={current:null},t={current:null},i={current:null},o=[],r=[e,t,i];return We.current&&o.push(n(We.current,Wi,e,function(){return Ki.current()},function(){})),ze.current&&o.push(n(ze.current,qi,t,function(){return Ki.current()},function(){return ke.current()})),mi.current&&o.push(n(mi.current,Yi,i,function(){return Ki.current()},function(){return ke.current()})),function(){o.forEach(function(n){return n.disconnect()}),r.forEach(function(n){null!==n.current&&(cancelAnimationFrame(n.current),n.current=null)})}},[]),c(function(){Ne.current=re},[re]),c(function(){Ae.current=ge},[ge]);var Vi=a(function(n,e,t){var i,o,r=null===(i=null==t?void 0:t.toggleIfSame)||void 0===i||i,l=null==t?void 0:t.onReady,u=null!==(o=null==t?void 0:t.sourceSide)&&void 0!==o?o:"left";vt(),null!=n&&(e?ie("No counterpart exists for this section."):(Zt(),re&&ge===n?r?ni():null==l||l():(be(new Set([n])),Ce([]),Me.current=[],ne(!0),me.current=!0,he(n),Ae.current=n,le(!0),Ne.current=!0,de(!1),Ye.current&&(Ye.current.style.height="0px"),Ke.current&&(Ke.current.style.height="0px"),Ve.current&&(Ve.current.style.height="0px"),Xe.current&&(Xe.current.style.height="0px"),requestAnimationFrame(function(){var e,t,i,o,r,c="string"==typeof n&&n.includes(R),a=null,d=null,s=null;if(c){var v=n.split(R),p="".concat(v[0]).concat(R).concat(v[1]);a=(null===(e=Pt.current[p])||void 0===e?void 0:e.current)||null,d=(null===(t=jt.current[p])||void 0===t?void 0:t.current)||null,s=d?n:null}else if(a=(null===(i=Wt.current[n])||void 0===i?void 0:i.current)||null,Vn){var f=Ct[n],g=(null==f?void 0:f.refIndexes)||[];if(g.length>0){var h=g[0],m=It.findIndex(function(n){return n.selfIndex===h});-1!==m&&(d=(null===(r=Lt.current[m])||void 0===r?void 0:r.current)||null,s=m)}}else d=(null===(o=Lt.current[n])||void 0===o?void 0:o.current)||null,s=d?n:null;yi.current=s;var x=$e.current,y=qe.current,b=function(){!function(){var e,t,i,o,r,l,u,a,d,v,p,f,g=null,h=null,m=null,x=null;if(c){var y=n.split(R),b="".concat(y[0]).concat(R).concat(y[1]);g=(null===(e=Ot.current[y[2]])||void 0===e?void 0:e.current)||(null===(t=kt.current[Number(y[2])])||void 0===t?void 0:t.current)||null,h=(null===(i=zt.current[y[3]])||void 0===i?void 0:i.current)||(null===(o=Ht.current[Number(y[3])])||void 0===o?void 0:o.current)||null,m=(null===(r=Pt.current[b])||void 0===r?void 0:r.current)||g,x=(null===(l=jt.current[b])||void 0===l?void 0:l.current)||h}else{var S=Number(n),C=null!==s?Number(s):S;g=(null===(u=kt.current[S])||void 0===u?void 0:u.current)||null,h=(null===(a=Ht.current[C])||void 0===a?void 0:a.current)||null,m=(null===(d=Pt.current[S])||void 0===d?void 0:d.current)||(null===(v=Wt.current[S])||void 0===v?void 0:v.current)||g,x=(null===(p=jt.current[C])||void 0===p?void 0:p.current)||(null===(f=Lt.current[C])||void 0===f?void 0:f.current)||h}if(m&&x&&g&&h){g.style.paddingTop="0px",h.style.paddingTop="0px";var I=m.getBoundingClientRect(),B=x.getBoundingClientRect(),w=I.top-B.top;w>0?h.style.paddingTop="".concat(w,"px"):w<0&&(g.style.paddingTop="".concat(Math.abs(w),"px"))}}(),de(!0),ke.current&&ke.current(),me.current=!1,"right"===u&&y?y.dispatchEvent(new Event("scroll")):x&&x.dispatchEvent(new Event("scroll")),ne(!1),null==l||l()};if(!a||!x)return me.current=!1,ne(!1),void(null==l||l());if(d&&y){if(!Vn){var S=0;S="right"===u?d?d.getBoundingClientRect().top:0:a?a.getBoundingClientRect().top:0;var C=ze.current,I=(null==C?void 0:C.getBoundingClientRect().top)||0,B=C?C.scrollTop+S-I-150:0;return C?void _(C,B,200,b):void b()}var w=a.getBoundingClientRect().top-x.getBoundingClientRect().top+x.scrollTop,T=d.getBoundingClientRect().top-y.getBoundingClientRect().top+y.scrollTop,F=200;if("left"===u){var E=T-(w-x.scrollTop);E<0&&Ye.current&&(Ye.current.style.height="".concat(Math.abs(E),"px")),requestAnimationFrame(function(){var n,e=y.scrollHeight-y.clientHeight;if(E<0)n=0;else{if(E>e){var t=E-e;return Ke.current&&(Ke.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){_(y,E,F,b)})}n=E}_(y,n,F,b)})}else{var M=w-(T-y.scrollTop);M<0&&Ve.current&&(Ve.current.style.height="".concat(Math.abs(M),"px")),requestAnimationFrame(function(){var n,e=x.scrollHeight-x.clientHeight;if(M<0)n=0;else{if(M>e){var t=M-e;return Xe.current&&(Xe.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){_(x,M,F,b)})}n=M}_(x,n,F,b)})}}else b()}))))},[ge,vt,It,re,Vn,Ct,ni]),Xi=a(function(){var n,e=et.sectionIdx,t=et.isOrphan;if(ct(),null!=e){var i="left";et.anchorEl&&(null===(n=qe.current)||void 0===n?void 0:n.contains(et.anchorEl))&&(i="right"),Vi(e,t,{sourceSide:i})}},[Vi,et.isOrphan,et.sectionIdx,et.anchorEl,ct]),$i=a(function(){ct(),ni(),be(new Set),Ce([]),Me.current=[]},[ct,ni]),Ji=null!==et.sectionIdx&&ye.has(et.sectionIdx),Ui=V({proposedSections:Ct,existingSections:It,parentDeviationRecord:wt,expandedSections:oi,maintainRelativeOrder:!!Vn,scrollContainerRef:ze,leftContainerRef:$e,rightContainerRef:qe,lhsBadgeRefs:Pt,rhsBadgeRefs:jt}),Gi=Ui.showDeviationNavigation,Qi=Ui.showOpenNodeRef,Zi=Ui.adjustScrollForPopup,no=a(function(n,e,t,i,o){var r,l="string"==typeof i?y(i).trim():y(null==i?void 0:i.deviation_summary).trim(),u=n.currentTarget;st();var c="left";(null===(r=qe.current)||void 0===r?void 0:r.contains(u))&&(c="right");var a=function(){var n,t,i,o;if("string"==typeof e&&e.includes(R)){var r=e.split(R),l="".concat(r[0]).concat(R).concat(r[1]);return"right"===c?null===(n=jt.current[l])||void 0===n?void 0:n.current:null===(t=Pt.current[l])||void 0===t?void 0:t.current}return"right"===c?null===(i=jt.current[e])||void 0===i?void 0:i.current:null===(o=Pt.current[e])||void 0===o?void 0:o.current},d=function(n,e){var t=!!Vn,i=t?"right"===c?qe.current:$e.current:ze.current,o=t?"right"===c?$e.current:qe.current:null;if(i&&n){var r=n.getBoundingClientRect(),l=i.getBoundingClientRect(),u=l.bottom-.35*l.height,a=l.top+.35*l.height;if(r.top>u||r.top<a){var d=l.top+l.height/2,s=r.top+r.height/2-d;if(t&&o){var v=i.scrollHeight-i.clientHeight,p=o.scrollHeight-o.clientHeight;if(s>0){var f=v-i.scrollTop,g=p-o.scrollTop;s=Math.max(0,Math.min(s,f,g))}else s=Math.min(0,Math.max(s,-i.scrollTop,-o.scrollTop));_(o,o.scrollTop+s,250,function(){})}_(i,i.scrollTop+s,250,e)}else e()}else e()};if(t)return ni(),be(new Set),Ce([]),Me.current=[],void(l&&requestAnimationFrame(function(){var n=a()||u;d(n,function(){ut({open:!0,anchorEl:n,summary:i,displayImpact:o})})}));Vi(e,t,l?{toggleIfSame:!1,sourceSide:c,onReady:function(){var n=a()||u;d(n,function(){ut({open:!0,anchorEl:n,summary:i,displayImpact:o})})}}:{toggleIfSame:!1,sourceSide:c})},[Vi,st,ut,ni,Vn]),eo=u(function(){var n;if(!Ln)return null;var e=null===(n=null==Ln?void 0:Ln.id)||void 0===n?void 0:n.split(":")[0];for(var t in wt){if((wt[t]||[]).some(function(n){return n.id===e}))return t}return null},[Ln,wt]),to=l({id:null,triggerMs:null}),io=l(null);c(function(){var t;if(null==Ln?void 0:Ln.id){var i=Number(Ln.trigger),o=to.current;if((null==o?void 0:o.triggerMs)!==i){if(!(Ln.id.includes(":")&&/:\d+$/.test(Ln.id)))return to.current={id:Ln.id,triggerMs:i},void gi(Ln.id);var r=null===(t=null==Ln?void 0:Ln.id)||void 0===t?void 0:t.split(":"),l=r[0],u=r[1],c=null!=u?u:"0";io.current!==Ln.id&&(ct(),st(),ni(),be(new Set),Ce([]),Me.current=[],io.current=Ln.id);var a=!1,d=0,s=null,v=150,p=function(n,e){for(var t=function(n,i){if(!n)return null;if(n.id===e)return i;if(!Array.isArray(n.subsections))return null;for(var o=0;o<n.subsections.length;o++){var r=t(n.subsections[o],"".concat(i,"-").concat(o));if(r)return r}return null},i=0;i<n.length;i++){var o=t(n[i],String(i));if(o)return o}return null},f=function(){var t,o,r,u;if(!a){var g=function(){to.current={id:Ln.id,triggerMs:i}},h=null,m=null;for(var x in wt){var y=wt[x].find(function(n){return n.id===l});if(y){h=x,m=y;break}}if(m&&h){var b=Ct.findIndex(function(n){return n.id===h}),S=It.findIndex(function(n){return n.id===h}),C=-1===b&&-1!==S,I=p(Ct,m.id),B=p(It,m.id);if(I&&!B&&!C){var w=I.split("-"),T=Number(w[0]);if(Vn){var _=null===(o=null===(t=Ct[T])||void 0===t?void 0:t.refIndexes)||void 0===o?void 0:o[0],F=It.findIndex(function(n){return n.selfIndex===_});-1!==F&&(T=F)}B=e([T],w.slice(1),!0).join("-")}if(I||B){var E=C||!I&&!!B,M=I?Number(I.split("-")[0]):b,D=B?Number(B.split("-")[0]):S;if(E){if(!(Vn?!!oi["right-".concat(D)]:!!oi[String(D)])&&D>=0)return ci(D,"right"),d+=1,void(s=setTimeout(f,450))}else if(!(Vn?!!oi["left-".concat(M)]:!!oi[String(M)])&&M>=0)return ci(M,"left"),d+=1,void(s=setTimeout(f,450));var N,A=I||"",k=B||"",H="".concat(m.id).concat(R).concat(c).concat(R).concat(A).concat(R).concat(k),P="".concat(m.id).concat(R).concat(c),j=null===(r=Pt.current[P])||void 0===r?void 0:r.current,L=null===(u=jt.current[P])||void 0===u?void 0:u.current,O=E||!j&&!!L,z=O?L:j;if(N=Vn?O?qe.current:$e.current:ze.current,z&&N){var W=z.getBoundingClientRect();if(0===W.height)return void((d+=1)<2?s=setTimeout(f,v):g());var q=N.getBoundingClientRect(),Y=W.top-q.top+N.scrollTop-q.height/2+W.height/2+150,K=function(){var e,t,i,o,r;if(!a){g();var l=z instanceof Element?window.getComputedStyle(z).color:"";j&&(j.style.transition="box-shadow 300ms ease-in-out",j.style.boxShadow="0 0 10px ".concat(l)),L&&(L.style.transition="box-shadow 300ms ease-in-out",L.style.boxShadow="0 0 10px ".concat(l)),setTimeout(function(){j&&(j.style.boxShadow=""),L&&(L.style.boxShadow="")},2e3);var u=(null===(t=null===(e=m.evaluationResult)||void 0===e?void 0:e.deviations)||void 0===t?void 0:t[c])||m,d=(null===(i=m.evaluationResult)||void 0===i?void 0:i.evaluation_outputs)||m.evaluation_outputs;if(!(!!j&&!!L)){var s=O?(null===(o=jt.current[P])||void 0===o?void 0:o.current)||L:(null===(r=Pt.current[P])||void 0===r?void 0:r.current)||j;return Zi(s,function(){ut({open:!0,anchorEl:s,displayImpact:Ln.displayImpact,summary:n(n({},u),{evaluation_outputs:d})})}),void(null==On||On())}Vi(H,!1,{toggleIfSame:!1,sourceSide:"left",onReady:function(){var e,t,i=O?(null===(e=jt.current[P])||void 0===e?void 0:e.current)||L:(null===(t=Pt.current[P])||void 0===t?void 0:t.current)||j;Zi(i,function(){ut({open:!0,anchorEl:i,displayImpact:null==Ln?void 0:Ln.displayImpact,summary:n({},u)})})}})}};Math.abs(N.scrollTop-Y)<=2?K():(Ue.current=Y,Ge.current=K,N.scrollTo({top:Y,behavior:"smooth"}),s&&clearTimeout(s),s=setTimeout(function(){if(Ge.current){Ue.current=null;var n=Ge.current;Ge.current=null,n()}},800))}else(d+=1)<2?s=setTimeout(f,v):g()}else(d+=1)<2?s=setTimeout(f,v):g()}else(d+=1)<2?s=setTimeout(f,v):g()}};return s=setTimeout(f,v),function(){a=!0,s&&clearTimeout(s)}}}},[Ln,wt,Ct,It,Vn,oi,ci,Vi,ut,gi]);var oo=function(n){var e=n.section,t=n.keyPath,o=n.depth,r=void 0===o?0:o,l=n.columnKey,u=void 0===l?"left":l,c=n.parentNodeId,a=void 0===c?"":c,d=n.sectionOffset;return i(J,{section:e,keyPath:t,depth:r,columnKey:u,parentNodeId:a,expandedSubSections:li,setExpandedSubSections:ui,maintainRelativeOrder:Vn||!1,proposedSections:Ct,existingSections:It,treeData:_n,deviationNumberRegistry:Tt,connectedSections:ye,activeSideBySideSection:ge,resolvedMarkdownStyles:Oe,getSubSectionRef:Yt,getSubSectionCompareStyle:Mi,getBadgeRef:Kt,openMoreFunctionsPopup:si,openSummaryPopup:no,showDeviationBadges:$n,resetSideBySide:ni,setConnectedSections:be,setConnectedLines:Ce,cachedConnectedPositions:Me,isProposingFix:Wn,proposingFixNodeId:qn,isRedlineFlow:Yn,sectionOffset:d})};return t(d,n({ref:We,sx:n(n({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},Vn?{}:{overflow:"visible"}),{position:"relative"})},{children:[Un&&i(d,n({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:i(O,{})})),lt.open&&i(U,{open:lt.open,anchorEl:lt.anchorEl,containerEl:xi.current,clipTopEl:Si.current,scrollContainerEl:ze.current,onClose:$i,summary:lt.summary,displayImpact:lt.displayImpact}),i(L,{open:et.open,anchorEl:et.anchorEl,sectionTitle:et.sectionTitle,referenceSectionTitle:et.refSectionTitle,onClose:vt,onOpenCognitiveCompare:vi,onOpenSideBySide:Xi,onConnect:pi,isConnected:Ji,isOrphan:et.isOrphan}),Ze.open&&i(j,{open:Ze.open,popupRef:dt,position:it,popupConfig:Hn,onClose:function(){ot(null),nt(function(e){return n(n({},e),{open:!1})}),at(null)},markdownStyles:Dn,sectionTitle:Ze.sectionTitle,referenceSectionTitle:Ze.refSectionTitle,cognitiveData:Ze.cognitiveData,anchorEl:Ze.anchorEl,sectionAnchorEl:Ze.sectionAnchorEl,scrollContainerEl:ze.current,badgeStyle:Ze.badgeStyle,docData:Ze.docData,deviationData:Ze.deviationData,isLoading:Ze.isLoading}),i(s,n({open:!!te,autoHideDuration:8e3,onClose:function(){return ie(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:i(v,n({onClose:function(){return ie(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:te}))})),i(X,{componentHeaderText:Tn,displayConfig:kn,maintainRelativeOrder:Vn,onCollapseAll:Ni,showCollapseAll:Ai,onToggleView:function(n){Gn(!0),setTimeout(function(){Xn(!n),ni(),ct(),be(new Set),Ce([]),Me.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){Gn(!1)},600)})})},50)}}),i(d,n({ref:ze,onScroll:zi,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:Vn?"hidden":"auto",borderTop:Xt&&$t?"none":"1.5px solid #EEF0F4"}},{children:i(d,n({sx:n({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},Vn?{flex:1,minHeight:0}:{})},{children:t(d,n({ref:mi,sx:n({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},Vn?{flex:1,overflow:"visible"}:{})},{children:[t("svg",n({ref:Ie,style:{position:"absolute",top:0,left:0,width:je.width||"100%",height:je.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",opacity:ve?0:1,transition:"opacity 0.15s ease-in-out"}},{children:[Ti&&i("g",{children:i("line",{x1:Ti.x1,y1:Ti.y,x2:Ti.x2,y2:Ti.y,stroke:Qt.badgeBorder,strokeWidth:"1.5"})}),Ii.map(function(e){var o,r,l,u,c,a,s,v=e.x1+.5*(e.x2-e.x1),p=(e.y1+e.y2)/2;if("Not Defined"===e.style.label&&!e.hasCognitive)return null;if(e.isSubSection?re&&ge===e.subSectionKeyPath&&ae:re&&ge===e.sectionIdx&&ae)return null;if(!Vn){var f=e.isSubSection?T(e.x1,e.y1,e.x2,e.y2):"M ".concat(e.x1," ").concat(e.y1," L ").concat(e.x2," ").concat(e.y2),h=Ct[e.sectionIdx]||{title:"",content:""},x=It[null!==(o=e.targetRightIdx)&&void 0!==o?o:e.sectionIdx]||{title:"",content:""};if(console.log("Base and Ref Sections for Badge:",h,x),e.isSubSection&&e.subSectionKeyPath){var y=e.subSectionKeyPath.includes(R)?e.subSectionKeyPath.split(R):[],b=y[2]||e.subSectionKeyPath,S=y[3]||b,C=b.split("-").map(Number),I=S.split("-").map(Number),B=null,w=null;C.length>0&&(B=Ct[C[0]]),I.length>0&&(w=It[I[0]]);var _=(null==B?void 0:B.title)||"",F=(null==w?void 0:w.title)||"";console.log("Root Parent Titles:",_,F);for(var E=1;E<C.length;E++)(null==B?void 0:B.subsections)&&(B=B.subsections[C[E]]);for(E=1;E<I.length;E++)(null==w?void 0:w.subsections)&&(w=w.subsections[I[E]]);B&&(h=n(n({},B),{title:_||B.title})),console.log("Base Section for Subsection Badge:",h),w&&(x=n(n({},w),{title:F||w.title})),console.log("Ref Section for Subsection Badge:",x)}var M=!(null===(r=h.cognitiveData)||void 0===r?void 0:r.isMissingRationale)||Boolean(null===(u=null===(l=h.cognitiveData)||void 0===l?void 0:l.decisioning)||void 0===u?void 0:u.length),D=(null===(s=null===(a=null===(c=h.evaluationResult)||void 0===c?void 0:c.cognitive_decisioning)||void 0===a?void 0:a.decisioning_factors)||void 0===s?void 0:s.length)||!1,N=M||D;return t("g",{children:[i("path",{d:f,fill:"none",stroke:e.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),i("foreignObject",n({x:v-100,y:p-14,width:"200",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:i(d,n({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:t(d,n({onClick:function(n){n.stopPropagation(),N&&(Ze.open&&rt===e.id?st():(at(e.id),di(ai(n.currentTarget,h,x,e.sectionIdx,e.style))))},sx:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:e.style.badgeBg,color:e.style.badgeText,border:"1px solid ".concat(e.style.badgeBorder),borderRadius:"12px",px:1.5,py:.5,fontWeight:600,textAlign:"center",whiteSpace:"nowrap",cursor:N?"pointer":"default"}},{children:[e.style.badgeText===H&&null==e.style.label?i(z,{color:e.style.badgeText}):0===e.style.label?"Same":e.style.label,i(d,n({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:i(m,{})})),N&&i(g,{size:11,style:{transform:Ze.open&&rt===e.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},e.id)}return null}),i(G,{connectedLines:Re,pathRefs:Ee})]})),t(d,n({sx:n({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},Vn?{flex:1,overflow:"visible"}:{})},{children:[i(d,n({ref:Si,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:i(p,n({title:xt,placement:"top"},{children:i(f,n({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:xt}))}))})),t(d,n({ref:$e,onScroll:zi,sx:n({p:"12px",display:"flex",flexDirection:"column"},Vn?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-160px",pr:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[i("div",{ref:Ve,style:{width:"100%",height:"0px",flexShrink:0}}),Ft&&Ct.map(function(e,o){var r,l,u=!e.title&&!e.content;if(Vn&&u)return null;var c=e,a=Ei(o,"left"),s=Vn?!(null===(r=c.refIndexes)||void 0===r?void 0:r.length)||c.selfIndex<0:!It[o],v=ye.has(o),p=b(c.evaluationResult,null==a?void 0:a.deviationLabel),f=Mt.leftNums.get(c.id);return i(d,n({ref:qt(o),sx:{mb:1,width:"100%"}},{children:t(d,n({sx:{position:"relative",width:"100%"}},{children:[i(d,n({ref:kt.current[o],sx:n({width:"100%",display:"flex",flexDirection:"column",minWidth:0},v&&{borderRadius:"6px",outline:"2px solid ".concat((null==a?void 0:a.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:i($,{section:e,idx:o,columnKey:"left",colRef:qt("left-accordion-".concat(o)),mb:0,treeData:_n,proposedSections:Ct,existingSections:It,deviationNumberRegistry:Tt,getSectionCompareStyle:Ei,getBadgeRef:Kt,connectedSections:ye,openMoreFunctionsPopup:si,openSummaryPopup:no,deviationNodeIdToView:null==Ln?void 0:Ln.id,deviationTargetParentId:eo,parentNodeId:(null===(l=null==_n?void 0:_n.input_index_map)||void 0===l?void 0:l[0])||"",isExpanded:Vn?!!oi["left-".concat(o)]:!!oi[String(o)],onToggle:function(){$i(),ci(o,"left")},navigation:e.id?Gi[e.id]:null,showOpenNodeRef:Qi,resolvedMarkdownStyles:Oe,maintainRelativeOrder:Vn,showDeviationBadges:$n,renderSubSections:oo,isProposingFix:Wn,proposingFixNodeId:qn,isRedlineFlow:Yn,collisionKey:"".concat(re?"1":"0","-").concat(String(null!=ge?ge:""))})})),Vn&&a&&t(d,n({ref:Pt.current[o],onClick:function(n){var e,t,i,r=kn.enableDeviationSchemaBackwardCompatibility?null!==(e=c.evaluationResult)&&void 0!==e?e:null:null!==(i=null===(t=c.evaluationResult)||void 0===t?void 0:t[0])&&void 0!==i?i:null;no(n,String(o),s,r)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:a.badgeBg,color:a.badgeText,border:"1px solid ".concat(a.badgeBorder),borderRadius:"12px",px:1.2,py:.3,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[t(d,n({component:"span",onClick:function(n){var e,t,i;n.stopPropagation();var r=kn.enableDeviationSchemaBackwardCompatibility?null!==(e=c.evaluationResult)&&void 0!==e?e:null:null!==(i=null===(t=c.evaluationResult)||void 0===t?void 0:t[0])&&void 0!==i?i:null;no(n,String(o),s,r)},sx:{display:"inline-flex",alignItems:"center",gap:"4px",px:.2,cursor:s?"default":"pointer",borderRight:"1px solid ".concat(a.badgeBorder),"&:hover":s?{}:{bgColor:"".concat(a.badgeBorder,"22")}}},{children:[null!=f&&i(d,n({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(a.badgeBorder)}},{children:f})),i(d,n({component:"span",sx:{fontSize:"11px",px:.25}},{children:!kn.isLoading||null!=c.evaluationResult&&null!=c.evaluationResult?"N/A"===p||"NA"===p?"N/A":0==p||null==p?"Same":"".concat(p):i(z,{color:a.badgeText})}))]})),i(d,n({component:"span",onClick:function(n){n.stopPropagation();var t=Vn?It.find(function(n){var e;return null===(e=c.refIndexes)||void 0===e?void 0:e.includes(n.selfIndex)})||{title:"",content:""}:It[o]||{title:"",content:""};si(n,e,s,t,o,a)},sx:{display:"inline-flex",alignItems:"center",px:.2,cursor:"pointer","&:hover":{bgcolor:"".concat(a.badgeBorder,"22")}}},{children:i(h,{size:11,color:a.badgeText})}))]}))]}))}),"left-row-".concat(o))}),i("div",{ref:Xe,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),i(d,n({ref:xi,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:i(d,n({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:t(d,n({onClick:function(e){e.stopPropagation(),Ze.open&&rt===Jt?st():(at(Jt),di(ai(e.currentTarget,{title:"",content:"",evaluationResult:Ut,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,Jt,!0,n(n({},Qt),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:Qt.badgeBg,color:Qt.badgeText,border:"1px solid ".concat(Qt.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=Gt?Gt:i(z,{}),i(d,n({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:i(m,{})})),i(g,{size:11,style:{transform:Ze.open&&rt===Jt?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),t(d,n({sx:n({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},Vn?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[Zn&&i(x,{sections:11}),i(d,n({ref:Ri,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"40px",display:"flex",alignItems:"center",overflowX:"hidden"}},{children:i(p,n({title:yt,placement:"top"},{children:i(f,n({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:yt}))}))})),t(d,n({ref:qe,onScroll:zi,sx:n({p:"12px",display:"flex",flexDirection:"column"},Vn?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-150px",pl:"165px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[i("div",{ref:Ye,style:{width:"100%",height:"0px",flexShrink:0}}),Ft&&It.map(function(e,r){var l,u,c=e,a=!1,s=null,v=-1;if(Vn){v=Ct.findIndex(function(n){var e;return(null===(e=n.refIndexes)||void 0===e?void 0:e.includes(c.selfIndex))&&n.selfIndex>=0});var p=Ct.findIndex(function(n,e){var t;return ye.has(e)&&(null===(t=n.refIndexes)||void 0===t?void 0:t.includes(c.selfIndex))});(a=-1!==p)&&(s=Ei(p,"left"))}else(a=ye.has(r))&&(s=Ei(r,"right"));var f=Vn&&-1!==v?Ei(v,"left"):Ei(r,"right"),g=Vn?-1!==v||!(null===(l=c.refIndexes)||void 0===l?void 0:l.length)&&Ct.some(function(n){return n.id&&n.id===c.id}):Boolean(Ct[r]),m=Vn?c.selfIndex<0||!g:!Ct[r],x=Mt.rightNums.get(c.id);return i(d,n({ref:Lt.current[r],sx:{mb:1,width:"100%"}},{children:t(d,n({sx:{position:"relative",width:"100%"}},{children:[i(d,n({ref:Ht.current[r],sx:n({width:"100%",display:"flex"},a&&s&&{borderRadius:"6px",outline:"2px solid ".concat(s.badgeBorder),outlineOffset:"1px"})},{children:i($,{section:e,idx:r,columnKey:"right",colRef:qt("right-accordion-".concat(r)),mb:0,parentNodeId:(null===(u=null==_n?void 0:_n.input_index_map)||void 0===u?void 0:u[1])||"",isExpanded:Vn?!!oi["right-".concat(r)]:!!oi[String(r)],treeData:_n,proposedSections:Ct,existingSections:It,deviationNumberRegistry:Tt,getBadgeRef:Kt,getSectionCompareStyle:Ei,connectedSections:ye,openMoreFunctionsPopup:si,openSummaryPopup:no,deviationNodeIdToView:null==Ln?void 0:Ln.id,deviationTargetParentId:eo,onToggle:function(){$i(),ci(r,"right")},navigation:e.id?Gi[e.id]:null,showOpenNodeRef:Qi,resolvedMarkdownStyles:Oe,maintainRelativeOrder:Vn,showDeviationBadges:$n,renderSubSections:oo,isProposingFix:Wn,proposingFixNodeId:qn,isRedlineFlow:Yn,collisionKey:"".concat(re?"1":"0","-").concat(String(null!=ge?ge:""))})})),Vn&&f&&i(d,n({ref:jt.current[r],"data-section-id":c.id,onClick:function(n){var e,t,i;if(m){var o=kn.enableDeviationSchemaBackwardCompatibility?null!==(e=c.evaluationResult)&&void 0!==e?e:null:null!==(i=null===(t=c.evaluationResult)||void 0===t?void 0:t[0])&&void 0!==i?i:null;no(n,String(r),m,o)}},sx:{position:"absolute",top:"18px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:m?"4px":"0px",fontSize:"11px",bgcolor:f.badgeBg,color:f.badgeText,border:"1px solid ".concat(f.badgeBorder),borderRadius:m?"12px":"10px",px:m?1.2:1,py:.3,fontWeight:m?600:700,cursor:m?"pointer":"default",whiteSpace:"nowrap",zIndex:20,boxShadow:m?"0 1px 3px rgba(0,0,0,0.07)":"none"}},{children:m?t(o,{children:[t(d,n({component:"span",onClick:function(n){var e,t,i;n.stopPropagation();var o=kn.enableDeviationSchemaBackwardCompatibility?null!==(e=c.evaluationResult)&&void 0!==e?e:null:null!==(i=null===(t=c.evaluationResult)||void 0===t?void 0:t[0])&&void 0!==i?i:null;no(n,String(r),m,o)},sx:{display:"inline-flex",alignItems:"center",gap:"4px",px:.2,cursor:"pointer",borderRight:"1px solid ".concat(f.badgeBorder),"&:hover":{bgcolor:"".concat(f.badgeBorder,"22")}}},{children:[null!=x&&i(d,n({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(f.badgeBorder)}},{children:x})),i(d,n({component:"span",sx:{fontSize:"11px",px:.25}},{children:!kn.isLoading||null!=c.evaluationResult&&void 0!==c.evaluationResult?f.label?"".concat(f.label):"100% Deviation":i(z,{color:f.badgeText})}))]})),i(d,n({component:"span",onClick:function(n){n.stopPropagation();var e=Vn?Ct.find(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(c.selfIndex)})||{title:"",content:""}:Ct[r]||{title:"",content:""};si(n,e,m,c,r,f)},sx:{display:"inline-flex",alignItems:"center",px:.2,cursor:"pointer","&:hover":{bgcolor:"".concat(f.badgeBorder,"22")}}},{children:i(h,{size:11,color:f.badgeText})}))]}):null!=x?x:""}))]}))}),"right-row-".concat(r))}),i("div",{ref:Ke,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))};export{Q as default};
2
2
  //# sourceMappingURL=CognitiveCompare.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CommonConstants.d.ts","sourceRoot":"","sources":["../../../../src/CommonConstants/CommonConstants.tsx"],"names":[],"mappings":"AACA,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,OAAO,CAAC;AAC5C,eAAO,MAAM,OAAO,EAAE,aAAqB,CAAC;AAC5C,eAAO,MAAM,SAAS,EAAE,aAAuB,CAAC;AAChD,eAAO,MAAM,6BAA6B,yCAAyC,CAAA;AAEnF,eAAO,MAAM,iBAAiB,EAAE,GAotd/B,CAAA"}
1
+ {"version":3,"file":"CommonConstants.d.ts","sourceRoot":"","sources":["../../../../src/CommonConstants/CommonConstants.tsx"],"names":[],"mappings":"AACA,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,OAAO,CAAC;AAC5C,eAAO,MAAM,OAAO,EAAE,aAAqB,CAAC;AAC5C,eAAO,MAAM,SAAS,EAAE,aAAuB,CAAC;AAChD,eAAO,MAAM,6BAA6B,yCAAyC,CAAA;AAEnF,eAAO,MAAM,iBAAiB,EAAE,GAupV/B,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"CognitiveCompare.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitiveCompare.tsx"],"names":[],"mappings":"AAwCA,OAAO,EAEL,qBAAqB,EAMtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAGL,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AAkBlC,QAAA,MAAM,gBAAgB,6QAuBnB,qBAAqB,4CA2yHvB,CAAC;AAEF,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAClC,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"CognitiveCompare.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitiveCompare.tsx"],"names":[],"mappings":"AAwCA,OAAO,EAEL,qBAAqB,EAMtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAGL,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AAkBlC,QAAA,MAAM,gBAAgB,6QAuBnB,qBAAqB,4CA0zHvB,CAAC;AAEF,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAClC,eAAe,gBAAgB,CAAC"}
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export declare const useCompareLayout: (initialMaintainOrder: boolean, scrollContainerRef: React.RefObject<HTMLDivElement>, lhsBadgeRefs: any, rhsBadgeRefs: any, proposedSections: any[], existingSections: any[]) => {
2
3
  maintainRelativeOrder: boolean;
3
4
  setMaintainRelativeOrder: import("react").Dispatch<import("react").SetStateAction<boolean>>;
@@ -1 +1 @@
1
- {"version":3,"file":"useCompareLayout.d.ts","sourceRoot":"","sources":["../../../../../../src/features/CognitiveCompare/hooks/useCompareLayout.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,gBAAgB,yBACL,OAAO,sBACT,MAAM,SAAS,CAAC,cAAc,CAAC,gBACrC,GAAG,gBACH,GAAG,oBACC,GAAG,EAAE,oBACL,GAAG,EAAE;;;;;;;;;;;;;;;;;;;;;;CAkFxB,CAAC"}
1
+ {"version":3,"file":"useCompareLayout.d.ts","sourceRoot":"","sources":["../../../../../../src/features/CognitiveCompare/hooks/useCompareLayout.tsx"],"names":[],"mappings":";AAGA,eAAO,MAAM,gBAAgB,yBACL,OAAO,sBACT,MAAM,SAAS,CAAC,cAAc,CAAC,gBACrC,GAAG,gBACH,GAAG,oBACC,GAAG,EAAE,oBACL,GAAG,EAAE;;;;;;;;;;;;;;;;;;;;;;CAkFxB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viswa-test/test-citation",
3
- "version": "0.0.131",
3
+ "version": "0.0.132",
4
4
  "author": "Viswa Koduru",
5
5
  "description": "",
6
6
  "license": "MIT",
@@ -144,7 +144,7 @@
144
144
  "dist"
145
145
  ],
146
146
  "scripts": {
147
- "start": "craco start",
147
+ "start": "PORT=3005 craco start",
148
148
  "build": "rollup -c",
149
149
  "tsupBuild": "tsup src/index.ts",
150
150
  "test": "craco test",