@viswa-test/test-citation 0.0.94 → 0.0.96

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"),g=require("./components/ThreeDotsLoader.js"),f=require("./hooks/useCompareData.js"),p=require("./hooks/useComparePopups.js"),h=require("./hooks/useSectionRefs.js"),x=require("./hooks/useAccordionState.js"),_=require("./hooks/useDeviationNavigation.js"),m=require("./components/CompareHeader.js"),R=require("./components/SectionAccordion.js"),y=require("./components/SubSectionAccordion.js"),S=require("./components/CognitiveSummaryPopup.js");exports.SHARED_MARKDOWN_STYLES=c.SHARED_MARKDOWN_STYLES,exports.default=function(b){var A,E,I,T,B,D,C,O,w,N,j,P,F,k,M,V,L,G,H=b.componentHeaderText,q=void 0===H?a.DEFAULT_COMPONENT_HEADER_TEXT:H,z=b.treeData,W=b.comparisonConfig,Y=b.leftColumnTitleText,K=b.rightColumnTitleText,U=b.markdownStyles,X=b.displayConfig,J=void 0===X?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!0}:X,$=b.popupConfig,Q=b.deviationData,Z=void 0===Q?{}:Q,ee=b.deviationNodeIdToView,ne=b.resetDeviationNodeId,te=t.useState(J.maintainRelativeOrder),ie=te[0],oe=te[1],re=!!ie||!!(null==J?void 0:J.showDeviationBadges),le=t.useState(!1),ue=le[0],ce=le[1],ae=t.useState(!1),se=ae[0],de=ae[1],ve=t.useState(null),ge=ve[0],fe=ve[1],pe=t.useState(!1),he=pe[0],xe=pe[1],_e=t.useState((null==z?void 0:z.newEvaluationResult)?z.evaulationResult:!J.enableDeviationSchemaBackwardCompatibility||J.enableDeviationSchemaBackwardCompatibility),me=_e[0];_e[1];var Re=t.useState(!1),ye=Re[0],Se=Re[1],be=t.useState(!1),Ae=be[0],Ee=be[1],Ie=t.useState(null),Te=Ie[0],Be=Ie[1],De=t.useRef(!1),Ce=t.useState(new Set),Oe=Ce[0],we=Ce[1],Ne=t.useState([]),je=Ne[0],Pe=Ne[1],Fe=t.useRef(null),ke=t.useRef(!1),Me=t.useRef(null),Ve=t.useRef({}),Le=t.useRef([]),Ge=t.useRef(!1),He=t.useRef(!1),qe=t.useRef(null),ze=t.useRef(function(){}),We=t.useMemo(function(){return(null==z?void 0:z.cognitive_decisioning)||{}},[z]),Ye=t.useState({width:0,height:0}),Ke=Ye[0],Ue=Ye[1],Xe=t.useMemo(function(){return e.__assign(e.__assign({},c.SHARED_MARKDOWN_STYLES),U)},[U]),Je=t.useRef(null),$e=t.useRef(null),Qe=t.useRef(null),Ze=t.useRef(null),en=t.useRef(null),nn=t.useRef(null),tn=t.useRef(null),on=t.useRef(null),rn=t.useRef(!1),ln=t.useRef(null),un=t.useRef(null),cn=p.useComparePopups(Je),an=cn.cognitivePopup,sn=cn.setCognitivePopup,dn=cn.moreFunctions,vn=cn.setMoreFunctions,gn=cn.position,fn=cn.setPosition,pn=cn.activeBadgeId,hn=cn.summaryPopup,xn=cn.setSummaryPopup,_n=cn.closeSummaryPopup,mn=cn.setActiveBadgeId,Rn=cn.popupRef,yn=cn.closeCognitivePopup,Sn=cn.closeMoreFunctionsPopup,bn=t.useMemo(function(){var e,n,t,i,o,r,l;return{fields:null!==(e=null==W?void 0:W.fields)&&void 0!==e?e:c.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(t=null===(n=null==W?void 0:W.thresholds)||void 0===n?void 0:n.high)&&void 0!==t?t:c.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(o=null===(i=null==W?void 0:W.thresholds)||void 0===i?void 0:i.medium)&&void 0!==o?o:c.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(l=null===(r=null==W?void 0:W.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:c.DEFAULT_COMPARISON_CONFIG.thresholds.exact}}},[W]),An=t.useState(null),En=An[0];An[1];var In=null===(I=null===(A=null==z?void 0:z.documents)||void 0===A?void 0:A[null===(E=null==z?void 0:z.input_index_map)||void 0===E?void 0:E[0]])||void 0===I?void 0:I.title,Tn=null===(D=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[1]])||void 0===D?void 0:D.title,Bn=u.safeStringify(Y||In||"Uploaded Contract"),Dn=u.safeStringify(K||Tn||"Reference Template"),Cn=f.useCognitiveTreeData(z,ie,Z,bn,me),On=Cn.activeProposed,wn=Cn.existingRule,Nn=Cn.proposedSections,jn=Cn.existingSections,Pn=Cn.visibleFields,Fn=Cn.parentDeviationRecord,kn=Cn.deviationNumberRegistry,Mn=Cn.parseError;t.useEffect(function(){Mn&&fe("Failed to load comparison: ".concat(Mn))},[Mn]);var Vn=Nn.length>0||jn.length>0,Ln=h.useSectionRefs(Pn.map(function(e){return e.key}),Math.max(Nn.length,jn.length)),Gn=Ln.leftRefs,Hn=Ln.rightRefs,qn=Ln.sectionLeftRefs,zn=Ln.sectionRightRefs,Wn=Ln.lhsBadgeRefs,Yn=Ln.rhsBadgeRefs,Kn=Ln.sectionRightRowRefs,Un=Ln.subSectionLeftRefs,Xn=Ln.subSectionRightRefs,Jn=Ln.sectionRowRefs,$n=Ln.getSectionRowRef,Qn=Ln.getSubSectionRef,Zn=Ln.getBadgeRef,et=wn.analysis,nt=u.safeStringify(null===(O=null===(C=null==et?void 0:et.rule_difference_comparison)||void 0===C?void 0:C.summary)||void 0===O?void 0:O.overall_summary),tt=!!nt.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),it=null!==(w=null==z?void 0:z.base_root_id)&&void 0!==w?w:"-1";null==z||z[it];var ot=me?(null===(F=null==Z?void 0:Z[it])||void 0===F?void 0:F.evaluation_result)||(null===(M=null===(k=null==z?void 0:z.nodes)||void 0===k?void 0:k[it])||void 0===M?void 0:M.evaluation_result)||null:(null===(N=null==Z?void 0:Z[it])||void 0===N?void 0:N.evaluation_result[0])||(null===(P=null===(j=null==z?void 0:z.nodes)||void 0===j?void 0:j[it])||void 0===P?void 0:P.evaluation_result[0])||null,rt=u.extractDeviationScore(ot),lt=u.generateColorPalette(null!==(G=null===(L=null===(V=null==ot?void 0:ot.evaluation_outputs)||void 0===V?void 0:V.metadata)||void 0===L?void 0:L.label_color)&&void 0!==G?G:""),ut=t.useCallback(function(){var e,n,t,i,o,r;xe(!1),He.current=!1;var l=qe.current,c=Rt.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=Un.current[a[2]])||void 0===e?void 0:e.current)||(null===(n=qn.current[Number(a[2])])||void 0===n?void 0:n.current))&&(s.style.paddingTop="0px")}else{var s;(s=null===(t=qn.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=Xn.current[a[3]])||void 0===i?void 0:i.current)||(null===(o=zn.current[Number(a[3])])||void 0===o?void 0:o.current))&&(d.style.paddingTop="0px")}else{var d;(d=null===(r=zn.current[c])||void 0===r?void 0:r.current)&&(d.style.paddingTop="0px")}Be(null),qe.current=null,Rt.current=null,Se(!1),de(!1),Ze.current&&(Ze.current.style.height="0px"),en.current&&(en.current.style.height="0px"),nn.current&&(nn.current.style.height="0px"),tn.current&&(tn.current.style.height="0px")},[]),ct=x.useAccordionState({maintainRelativeOrder:!!ie,proposedSections:Nn,existingSections:jn,activeSideBySideSection:Te,connectedSections:Oe,resetSideBySide:ut,setConnectedSections:we,setConnectedLines:Pe,cachedConnectedPositions:Le,svgContainerRef:Fe,isAnimatingRef:ke,animationTimerRef:Me,calculateLinesRef:ze,sectionLeftRefs:qn,sectionRightRefs:zn,subSectionLeftRefs:Un,subSectionRightRefs:Xn}),at=ct.expandedSections,st=ct.expandedSubSections,dt=ct.setExpandedSubSections,vt=ct.toggleSection,gt=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)||"",g=(v?We[v]:null)||(null==t?void 0:t.cognitiveData)||(null==i?void 0:i.cognitiveData)||{section_id:v,decisioning:[],gap:[],relevance_score:0},f=null!==(s=null===(a=Jn.current[o])||void 0===a?void 0:a.current)&&void 0!==s?s:null;return{isLoading:null!==(d=null==J?void 0:J.isLoading)&&void 0!==d&&d,open:!0,sectionTitle:(null==t?void 0:t.displayTitle)?null==t?void 0:t.title:"no title",refSectionTitle:(null==i?void 0:i.displayTitle)?null==i?void 0:i.title:"no title",cognitiveData:g,anchorEl:n,sectionAnchorEl:f,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}},[We,z]),ft=t.useCallback(function(e){Sn(),fn(null),sn(e)},[Sn]),pt=function(e,n,t,i,o,r){var l;if(e.stopPropagation(),dn.open&&dn.sectionIdx===o)Sn();else{var c=e.currentTarget,a="left";(null===(l=Qe.current)||void 0===l?void 0:l.contains(c))&&(a="right");He.current&&ut(),we(new Set),Pe([]),Le.current=[],yn(),hn.open?qt():_n(),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=Yn.current[l])||void 0===e?void 0:e.current:null===(n=Wn.current[l])||void 0===n?void 0:n.current}return"right"===a?null===(t=Yn.current[o])||void 0===t?void 0:t.current:null===(i=Wn.current[o])||void 0===i?void 0:i.current}()||c;vn(gt(e,n,i,o,t,r))})}},ht=t.useCallback(function(){null!==dn.sectionIdx&&dn.anchorEl?ft(e.__assign(e.__assign({},dn),{open:!0})):Sn()},[dn,Sn,ft]),xt=t.useCallback(function(){var e=dn.sectionIdx,n=dn.isOrphan;Sn(),_n(),null!==e&&(n?fe("No counterpart exists to connect to."):(He.current&&ut(),Pe([]),Le.current=[],we(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){ze.current&&ze.current()},50)))},[dn.sectionIdx,dn.isOrphan,Sn,_n,ut]),_t=t.useRef(null),mt=t.useRef(null),Rt=t.useRef(null),yt=t.useRef(null),St=t.useRef(null),bt=t.useRef(null),At=t.useState([]),Et=At[0],It=At[1];t.useRef(null);var Tt=t.useState(null),Bt=Tt[0],Dt=Tt[1];t.useEffect(function(){if(En){var e=bn.fields.find(function(e){return e.analysisKey===En||e.key===En});if(e){var n=Gn.current[e.key]||Hn.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[En,bn.fields]);var Ct=t.useCallback(function(e){var n,t,i,o,r,l,u,c,a,s=null===(n=null==et?void 0:et.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 g=d.mappings[0]||{};return{score:d.score,relation:g.relation||"",highlightsA:(null===(l=g.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(u=g.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}},[et]),Ot=t.useCallback(function(n,t){var i,o,r,l,c,s,d;void 0===t&&(t="left");var v=null,g=null;if("left"===t)if(v=Nn[n],ie&&v){var f=jn.filter(function(e){var n;return null===(n=v.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)});g=f.find(function(e){return e.evaluationResult})||f[0]}else g=jn[n];else if(g=jn[n],ie&&g){var p=Nn.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(g.selfIndex)});v=p.find(function(e){return e.evaluationResult})||p[0]}else v=Nn[n];var h=(null==v?void 0:v.relation)&&"not_defined"!==v.relation,x=(null==g?void 0:g.relation)&&"not_defined"!==g.relation,_=!(!(null==v?void 0:v.cognitiveData)&&!(null==g?void 0:g.cognitiveData));if(!h&&!x&&!_)return e.__assign(e.__assign({},u.generateColorPalette(a.DEFAULT_DEVIAION_COLOR)),{label:"Not Defined"});var m=null!==(o=null!==(i=null==v?void 0:v.evaluationResult)&&void 0!==i?i:null==g?void 0:g.evaluationResult)&&void 0!==o?o:null,R=null===(r=null==m?void 0:m.evaluation_outputs)||void 0===r?void 0:r.output_value,y=null!==(s=null===(c=null===(l=null==m?void 0:m.evaluation_outputs)||void 0===l?void 0:l.metadata)||void 0===c?void 0:c.label_color)&&void 0!==s?s:a.DEFAULT_DEVIAION_COLOR;return null!=m?e.__assign(e.__assign({},u.generateColorPalette(y)),{label:null!==(d=R)&&void 0!==d?d:""}):e.__assign(e.__assign({},u.generateColorPalette(y)),{label:null})},[Nn,jn,We,bn,ie]),wt=t.useCallback(function(n){for(var t,i,o,r,l,c,s,d,v,g=n.split("-").map(Number),f=Nn[g[0]],p=jn[g[0]],h=1;h<g.length;h++)(null==f?void 0:f.subsections)&&(f=f.subsections[g[h]]),(null==p?void 0:p.subsections)&&(p=p.subsections[g[h]]);if(!f&&!p)return null;var x=(null==f?void 0:f.relation)&&"not_defined"!==f.relation,_=(null==p?void 0:p.relation)&&"not_defined"!==p.relation,m=u.safeStringify(null==f?void 0:f.id)||u.safeStringify(null==p?void 0:p.id)||"",R=!(!(null==f?void 0:f.cognitiveData)&&!(null==p?void 0:p.cognitiveData));if(!x&&!_&&!R)return e.__assign(e.__assign({},u.generateColorPalette(a.DEFAULT_DEVIAION_COLOR)),{label:"Not Defined"});null!==(i=null!==(t=null==f?void 0:f.cognitiveRelevanceScore)&&void 0!==t?t:null==p?void 0:p.cognitiveRelevanceScore)&&void 0!==i||m&&(null===(o=We[m])||void 0===o||o.relevance_score);var y=null!==(l=null!==(r=null==f?void 0:f.evaluationResult)&&void 0!==r?r:null==p?void 0:p.evaluationResult)&&void 0!==l?l:null,S=null===(c=null==y?void 0:y.evaluation_outputs)||void 0===c?void 0:c.output_value,b=null!==(v=null===(d=null===(s=null==y?void 0:y.evaluation_outputs)||void 0===s?void 0:s.metadata)||void 0===d?void 0:d.label_color)&&void 0!==v?v:a.DEFAULT_DEVIAION_COLOR;return null!=y?e.__assign(e.__assign({},u.generateColorPalette(b)),{label:null!=S?S:""}):e.__assign(e.__assign({},u.generateColorPalette(b)),{label:null})},[Nn,jn,We,bn]),Nt=t.useCallback(function(){var e,n,t,i,o,r,l,c,a,s,d,v,g,f,p,h,x,_,m,R,y,S;if(!rn.current&&!ke.current){rn.current=!0;try{if(!_t.current)return;var b=function(e){var n=e.split("-"),t=n[0];if(!at[t]&&!1===ie)return!1;if(ie&&!at["left-".concat(t)]&&!at["right-".concat(t)]&&!at[t])return!1;for(var i=t,o=1;o<n.length-1;o++)if(i+="-".concat(n[o]),!st[i])return!1;return!0},A=_t.current.getBoundingClientRect();Ue({width:A.width,height:A.height});var E=[];if(Pn.forEach(function(e){var n,t,i=e.key,o=null===(n=Gn.current[i])||void 0===n?void 0:n.current,r=null===(t=Hn.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")}),!ke.current){for(var I=0;I<Math.max(Nn.length,jn.length);I++){var T=null===(e=qn.current[I])||void 0===e?void 0:e.current,B=null===(n=zn.current[I])||void 0===n?void 0:n.current;T&&(T.style.height="auto",T.style.minHeight="0px"),B&&(B.style.height="auto",B.style.minHeight="0px")}ie||Object.keys(Un.current).forEach(function(e){var n,t;if(b(e)){var i=null===(n=Un.current[e])||void 0===n?void 0:n.current,o=null===(t=Xn.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={};Pn.forEach(function(e){var n,t,i=e.key,o=null===(n=Gn.current[i])||void 0===n?void 0:n.current,r=null===(t=Hn.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 C={left:{},right:{}},O={};if(!ke.current)if(ie){if(he&&null!==Te)if("number"==typeof Te){var w=Te,N=Nn[w],j=null===(o=qn.current[w])||void 0===o?void 0:o.current;j&&N&&(N.refIndexes||[]).forEach(function(e){var n,t=jn.findIndex(function(n){return n.selfIndex===e}),i=null===(n=zn.current[t])||void 0===n?void 0:n.current;if(i&&(at["left-".concat(w)]||at["right-".concat(t)])){var o=Math.max(j.getBoundingClientRect().height,i.getBoundingClientRect().height);C.left[w]=Math.max(C.left[w]||0,o),C.right[t]=Math.max(C.right[t]||0,o)}})}else{var P=Te.split(u.DEVIATION_BADGE_SEPARATOR)[2];if(P){T=null===(r=Un.current[P])||void 0===r?void 0:r.current,B=null===(l=Xn.current[P])||void 0===l?void 0:l.current;if(T&&B){F=Math.max(T.getBoundingClientRect().height,B.getBoundingClientRect().height);O[P]=Math.max(O[P]||0,F)}}}}else{Object.keys(Un.current).forEach(function(e){var n,t;if(b(e)){var i=null===(n=Un.current[e])||void 0===n?void 0:n.current,o=null===(t=Xn.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);O[e]=u,i.style.minHeight="".concat(u,"px"),o.style.minHeight="".concat(u,"px")}}});for(I=0;I<Math.min(Nn.length,jn.length);I++){var T=null===(t=qn.current[I])||void 0===t?void 0:t.current,B=null===(i=zn.current[I])||void 0===i?void 0:i.current;if(T&&B){var F=Math.max(T.getBoundingClientRect().height,B.getBoundingClientRect().height);C.left[I]=F,C.right[I]=F}}}if(Pn.forEach(function(e){var n,t,i=e.key,o=null===(n=Gn.current[i])||void 0===n?void 0:n.current,r=null===(t=Hn.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")}}),ke.current||(Object.entries(C.left).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=qn.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),Object.entries(C.right).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=zn.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),ie||Object.keys(O).forEach(function(e){var n,t,i=null===(n=Un.current[e])||void 0===n?void 0:n.current,o=null===(t=Xn.current[e])||void 0===t?void 0:t.current;if(i&&o&&O[e]){var r=O[e];i.style.minHeight="".concat(r,"px"),o.style.minHeight="".concat(r,"px")}})),ie)Nn.forEach(function(e,n){var t;(null===(t=qn.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=jn.findIndex(function(n){return n.selfIndex===e});if(-1!==v){var g=null===(t=Wn.current[n])||void 0===t?void 0:t.current,f=null===(i=Yn.current[v])||void 0===i?void 0:i.current;if(g&&f){var p=g.getBoundingClientRect(),h=f.getBoundingClientRect(),x=p.right-A.left,_=h.left-A.left,m=p.top+p.height/2-A.top,R=h.top+h.height/2-A.top;if(he&&Te===n){var y=null!==(r=null===(o=on.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==r?r:0,S=null!==(u=null===(l=Qe.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==u?u:0,b=y+(null!==(a=null===(c=on.current)||void 0===c?void 0:c.clientHeight)&&void 0!==a?a:1/0),I=S+(null!==(d=null===(s=Qe.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,D=function(e,n,t){return Math.max(n,Math.min(t,e))};m=D(T,y,b)-A.top,R=D(B,S,I)-A.top}var C=Ot(n);C&&E.push({id:"line-".concat(n,"-").concat(v),x1:x,y1:m,x2:_,y2:R,style:C,sectionIdx:n,targetRightIdx:v})}}})});else{for(I=0;I<Math.min(Nn.length,jn.length);I++){var k=null===(c=qn.current[I])||void 0===c?void 0:c.current,M=null===(a=zn.current[I])||void 0===a?void 0:a.current;if(k&&M){var V=k.getBoundingClientRect(),L=M.getBoundingClientRect(),G=Math.max(V.top,L.top)+18-A.top,H=(null===(s=jn[I])||void 0===s?void 0:s.id)||"sec-".concat(I);(J=Ot(I))&&E.push({id:H,x1:V.right-A.left,y1:G,x2:L.left-A.left,y2:G,style:J,sectionIdx:I,hasCognitive:!!((null===(d=Nn[I])||void 0===d?void 0:d.cognitiveData)||(null===(v=jn[I])||void 0===v?void 0:v.cognitiveData)||H&&We[H]),isSubSection:!1})}}Object.keys(Un.current).forEach(function(e){var n,t,i,o,r,l;if(b(e)){var c=null===(n=Un.current[e])||void 0===n?void 0:n.current,a=null===(t=Xn.current[e])||void 0===t?void 0:t.current;if(c&&a){for(var s=e.split("-").map(Number),d=Nn[s[0]],v=jn[s[0]],g=1;g<s.length;g++)(null==d?void 0:d.subsections)&&(d=d.subsections[s[g]]),(null==v?void 0:v.subsections)&&(v=v.subsections[s[g]]);var f=!!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(f&&p||h&&x){var _=c.getBoundingClientRect(),m=a.getBoundingClientRect(),R=Math.max(_.top,m.top)+16-A.top,y=wt(e);y&&"Not Defined"!==y.label&&E.push({id:"subsec-".concat(e),x1:_.right-A.left,y1:R,x2:m.left-A.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(he&&"string"==typeof Te&&Te.includes(u.DEVIATION_BADGE_SEPARATOR)){var q=Te.split(u.DEVIATION_BADGE_SEPARATOR),z=q[0],W=q[1],Y=q[2],K=(q[3],"".concat(z).concat(u.DEVIATION_BADGE_SEPARATOR).concat(W)),U=null===(g=Wn.current[K])||void 0===g?void 0:g.current,X=null===(f=Yn.current[K])||void 0===f?void 0:f.current;if(U&&X){var J,$=U.getBoundingClientRect(),Q=X.getBoundingClientRect(),Z=$.right-A.left,ee=Q.left-A.left,ne=$.top+$.height/2-A.top,te=Q.top+Q.height/2-A.top;if(ie){var oe=null!==(h=null===(p=on.current)||void 0===p?void 0:p.getBoundingClientRect().top)&&void 0!==h?h:0,re=null!==(_=null===(x=Qe.current)||void 0===x?void 0:x.getBoundingClientRect().top)&&void 0!==_?_:0,le=oe+(null!==(R=null===(m=on.current)||void 0===m?void 0:m.clientHeight)&&void 0!==R?R:1/0),ue=re+(null!==(S=null===(y=Qe.current)||void 0===y?void 0:y.clientHeight)&&void 0!==S?S:1/0),ce=function(e,n,t){return Math.max(n,Math.min(t,e))};ne=ce($.top+$.height/2,oe,le)-A.top,te=ce(Q.top+Q.height/2,re,ue)-A.top}(J=wt(Y))&&E.push({id:"line-subsec-".concat(K),x1:Z,y1:ne,x2:ee,y2:te,style:J,sectionIdx:Number(Y.split("-")[0]),isSubSection:!0,subSectionKeyPath:Te})}}if(It(E),St.current&&bt.current){var ae=St.current.getBoundingClientRect(),se=bt.current.getBoundingClientRect(),de=(ae.top+ae.height/2-A.top+se.top+se.height/2-A.top)/2;Dt({x1:ae.right-A.left,x2:se.left-A.left,y:de})}else Dt(null);if(Oe.size>0){var ve=[],ge=on.current,fe=Qe.current;if(ge&&fe){var pe=[],xe=ge.getBoundingClientRect().top,_e=fe.getBoundingClientRect().top,me=xe+ge.clientHeight,Re=_e+fe.clientHeight,ye=ge.scrollTop,Se=fe.scrollTop,be=A.top,Ae=function(e,n,t){return Math.max(n,Math.min(t,e))};Oe.forEach(function(e){var n,t,i,o,r;if("string"==typeof e&&e.includes(u.DEVIATION_BADGE_SEPARATOR)){var l=e.split(u.DEVIATION_BADGE_SEPARATOR),c=l[0],a=l[1],s=l[2],d=(l[3],"".concat(c).concat(u.DEVIATION_BADGE_SEPARATOR).concat(a)),v=null===(n=Wn.current[d])||void 0===n?void 0:n.current,g=null===(t=Yn.current[d])||void 0===t?void 0:t.current;if(!v||!g)return;var f=v.getBoundingClientRect(),p=g.getBoundingClientRect(),h=wt(s),x=(j=f.right-A.left)+.5*((P=p.left-A.left-0)-j),_=f.top+f.height/2,m=p.top+p.height/2,R=_-xe+ye,y=m-_e+Se,S="conn-subsec-".concat(d);pe.push({lhsScrollY:R,rhsScrollY:y,x1:j,x2:P,containerTop:be,leftIdx:e,rhsArrayIdx:e,styleColor:(null==h?void 0:h.badgeBorder)||"#6366F1",styleId:S});var b=Ae(_,xe,me),E=Ae(m,_e,Re),I=b-be,T=E-be,B=m>=_e-4&&m<=Re+4,D="";D=(F=_>=xe-4&&_<=me+4)&&B?u.getBentArrowPath(j,I,P,T):F&&!B?"M ".concat(j,",").concat(I," L ").concat(x,",").concat(I," L ").concat(x,",").concat(T):!F&&B?"M ".concat(x,",").concat(I," L ").concat(x,",").concat(T," L ").concat(P,",").concat(T):"M ".concat(x,",").concat(I," L ").concat(x,",").concat(T),ve.push({id:S,pathD:D,style:h,leftIdx:e,rhsArrayIdx:e})}else if(ie){var C=e,O=Nn[C];if(!(null===(r=null==O?void 0:O.refIndexes)||void 0===r?void 0:r.length))return;O.refIndexes.forEach(function(e){var n,t,i=jn.findIndex(function(n){return n.selfIndex===e});if(-1!==i){var o=null===(n=Wn.current[C])||void 0===n?void 0:n.current,r=null===(t=Yn.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),c=r.getBoundingClientRect(),a=Ot(C),s=l.right-A.left,d=c.left-A.left-0,v=s+.5*(d-s),g=l.top+l.height/2,f=c.top+c.height/2,p=g-xe+ye,h=f-_e+Se,x="conn-".concat(C,"-").concat(i);pe.push({lhsScrollY:p,rhsScrollY:h,x1:s,x2:d,containerTop:be,leftIdx:C,rhsArrayIdx:i,styleColor:(null==a?void 0:a.badgeBorder)||"#6366F1",styleId:x});var _=Ae(g,xe,me),m=Ae(f,_e,Re),R=_-be,y=m-be,S=g>=xe-4&&g<=me+4,b=f>=_e-4&&f<=Re+4,E="";E=S&&b?u.getBentArrowPath(s,R,d,y):S&&!b?"M ".concat(s,",").concat(R," L ").concat(v,",").concat(R," L ").concat(v,",").concat(y):!S&&b?"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:E,style:a,leftIdx:C,rhsArrayIdx:i})}}})}else{var w=e,N=w;v=null===(i=Wn.current[w])||void 0===i?void 0:i.current,g=null===(o=Yn.current[N])||void 0===o?void 0:o.current;if(!v||!g)return;var j,P;f=v.getBoundingClientRect(),p=g.getBoundingClientRect(),h=Ot(w),x=(j=f.right-A.left)+.5*((P=p.left-A.left-0)-j),_=f.top+f.height/2,m=p.top+p.height/2,R=_-xe+ye,y=m-_e+Se,S="conn-".concat(w,"-").concat(N);pe.push({lhsScrollY:R,rhsScrollY:y,x1:j,x2:P,containerTop:be,leftIdx:w,rhsArrayIdx:N,styleColor:(null==h?void 0:h.badgeBorder)||"#6366F1",styleId:S});var F;b=Ae(_,xe,me),E=Ae(m,_e,Re),I=b-be,T=E-be,B=m>=_e-4&&m<=Re+4,D="";D=(F=_>=xe-4&&_<=me+4)&&B?u.getBentArrowPath(j,I,P,T):F&&!B?"M ".concat(j,",").concat(I," L ").concat(x,",").concat(I," L ").concat(x,",").concat(T):!F&&B?"M ".concat(x,",").concat(I," L ").concat(x,",").concat(T," L ").concat(P,",").concat(T):"M ".concat(x,",").concat(I," L ").concat(x,",").concat(T),ve.push({id:S,pathD:D,style:h,leftIdx:w,rhsArrayIdx:N})}}),Le.current=pe}Pe(ve)}else Pe([]),Le.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{rn.current=!1}}},[Pn,Nn,jn,We,bn,Ct,Ot,ie,he,Te,Oe,at,st]),jt=t.useCallback(function(){var e,n,t,i,o,r,l,c,a,s,d,v,g,f,p=Le.current;if(p.length&&!ke.current){var h=null!==(n=null===(e=on.current)||void 0===e?void 0:e.scrollTop)&&void 0!==n?n:0,x=null!==(i=null===(t=Qe.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,_=null!==(r=null===(o=on.current)||void 0===o?void 0:o.clientHeight)&&void 0!==r?r:1/0,m=null!==(c=null===(l=Qe.current)||void 0===l?void 0:l.clientHeight)&&void 0!==c?c:1/0,R=null!==(s=null===(a=on.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==s?s:0,y=null!==(v=null===(d=Qe.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==v?v:0,S=R+_,b=y+m,A=null!==(f=null===(g=_t.current)||void 0===g?void 0:g.getBoundingClientRect().top)&&void 0!==f?f:0,E=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=Ve.current[e.styleId+"-stroke"],o=Ve.current[e.styleId+"-bg"];if(i||o){var r,l=E(n,R,S),c=E(t,y,b),a=l-A,s=c-A,d=n>=R-4&&n<=S+4,v=t>=y-4&&t<=b+4,g=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(g,",").concat(a," L ").concat(g,",").concat(s):!d&&v?"M ".concat(g,",").concat(a," L ").concat(g,",").concat(s," L ").concat(e.x2,",").concat(s):"M ".concat(g,",").concat(a," L ").concat(g,",").concat(s),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",r)),o&&(o.setAttribute("visibility","visible"),o.setAttribute("d",r))}})}},[]);t.useEffect(function(){ze.current=Nt},[Nt]);var Pt=t.useRef(null),Ft=t.useRef(null),kt=t.useCallback(function(){Le.current.length>0&&!ke.current||(null!==Pt.current&&clearTimeout(Pt.current),Pt.current=setTimeout(function(){ze.current(),Pt.current=null},50))},[]),Mt=t.useCallback(function(){Ee(!0),Se(!1),null!==Ft.current&&clearTimeout(Ft.current),null!==Pt.current&&(clearTimeout(Pt.current),Pt.current=null),Ft.current=setTimeout(function(){var e,n,t,i,o,r,l,c,a,s;if(Le.current=[],He.current&&null!==qe.current&&null!==Rt.current){var d=qe.current,v=Rt.current,g=null,f=null,p=null,h=null;if("string"==typeof d&&d.includes(u.DEVIATION_BADGE_SEPARATOR)){var x=d.split(u.DEVIATION_BADGE_SEPARATOR),_="".concat(x[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(x[1]);g=(null===(e=Wn.current[_])||void 0===e?void 0:e.current)||null,f=(null===(n=Yn.current[_])||void 0===n?void 0:n.current)||null,p=(null===(t=Un.current[x[2]])||void 0===t?void 0:t.current)||(null===(i=qn.current[Number(x[2])])||void 0===i?void 0:i.current)||null,h=(null===(o=Xn.current[x[3]])||void 0===o?void 0:o.current)||(null===(r=zn.current[Number(x[3])])||void 0===r?void 0:r.current)||null}else g=(null===(l=Jn.current[d])||void 0===l?void 0:l.current)||null,p=(null===(c=qn.current[d])||void 0===c?void 0:c.current)||null,f=(null===(a=Kn.current[v])||void 0===a?void 0:a.current)||null,h=(null===(s=zn.current[v])||void 0===s?void 0:s.current)||null;if(g&&f&&p&&h){if(p.style.paddingTop="0px",h.style.paddingTop="0px",!ie){var m=g.getBoundingClientRect(),R=f.getBoundingClientRect(),y=m.top-R.top;y>0?h.style.paddingTop="".concat(y,"px"):y<0&&(p.style.paddingTop="".concat(Math.abs(y),"px"))}var S=on.current,b=Qe.current;if(S&&b){var A=g.getBoundingClientRect().top-S.getBoundingClientRect().top+S.scrollTop,E=f.getBoundingClientRect().top-b.getBoundingClientRect().top+b.scrollTop-(A-S.scrollTop);Math.abs(b.scrollTop-E)>1&&(b.scrollTop=E)}}}ze.current(),He.current&&Se(!0),Ee(!1),Ft.current=null},150)},[ie,Nn,jn]),Vt=t.useCallback(function(e){var n,t,i,o,r,l,c,a,s,d;if(null!==ln.current&&un.current&&Math.abs(e.currentTarget.scrollTop-ln.current)<=2){var v=un.current;ln.current=null,un.current=null,v()}if(!De.current){if(ie||kt(),He.current){var g=qe.current,f=Rt.current,p=on.current,h=Qe.current;if(null!==g&&null!==f&&p&&h){var x="string"==typeof g&&g.includes(u.DEVIATION_BADGE_SEPARATOR)?null===(n=Wn.current["".concat(g.split(u.DEVIATION_BADGE_SEPARATOR)[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(g.split(u.DEVIATION_BADGE_SEPARATOR)[1])])||void 0===n?void 0:n.current:null===(t=Jn.current[g])||void 0===t?void 0:t.current,_="string"==typeof f&&f.includes(u.DEVIATION_BADGE_SEPARATOR)?null===(i=Yn.current["".concat(f.split(u.DEVIATION_BADGE_SEPARATOR)[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(f.split(u.DEVIATION_BADGE_SEPARATOR)[1])])||void 0===i?void 0:i.current:null===(o=Kn.current[f])||void 0===o?void 0:o.current;if(x&&_&&yt.current){var m=void 0,R=void 0;if("string"==typeof g&&g.includes(u.DEVIATION_BADGE_SEPARATOR)){var y=g.split(u.DEVIATION_BADGE_SEPARATOR),S="".concat(y[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(y[1]);m=null===(r=Wn.current[S])||void 0===r?void 0:r.current,R=null===(l=Yn.current[S])||void 0===l?void 0:l.current}else m=null===(c=Wn.current[g])||void 0===c?void 0:c.current,R=null===(a=Yn.current[f])||void 0===a?void 0:a.current;var b=null!==(d=null===(s=_t.current)||void 0===s?void 0:s.getBoundingClientRect().top)&&void 0!==d?d:0,A=p.getBoundingClientRect().top,E=A+p.clientHeight;h.getBoundingClientRect().top;h.clientHeight;if(m&&R){var I=m.getBoundingClientRect(),T=R.getBoundingClientRect(),B=I.top+I.height/2;T.top,T.height;var D=((O=B,w=A,N=E,Math.max(w,Math.min(N,O)))-b).toString();yt.current.setAttribute("y1",D),yt.current.setAttribute("y2",D);var C=B>=A-4&&B<=E+4;yt.current.setAttribute("visibility",C?"visible":"hidden")}}}}var O,w,N;Le.current.length>0&&!Ge.current&&(Ge.current=!0,requestAnimationFrame(function(){jt(),Ge.current=!1}))}},[jt,ie,kt]);t.useEffect(function(){var e=setTimeout(kt,250);window.addEventListener("resize",Mt);var n=null,t=null;return Je.current&&(n=new ResizeObserver(kt)).observe(Je.current),_t.current&&(t=new ResizeObserver(kt)).observe(_t.current),function(){clearTimeout(e),null!==Pt.current&&clearTimeout(Pt.current),null!==Ft.current&&clearTimeout(Ft.current),window.removeEventListener("resize",Mt),null==n||n.disconnect(),null==t||t.disconnect()}},[On,wn,et,Pn,at,st,Nn,jn,bn,kt,Mt,he,Te,ye,Oe]),t.useEffect(function(){He.current=he},[he]),t.useEffect(function(){qe.current=Te},[Te]);var Lt=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";Sn(),null!=e&&(n?fe("No counterpart exists for this section."):he&&Te===e?r?ut():null==l||l():(we(new Set([e])),Pe([]),Le.current=[],de(!0),De.current=!0,Be(e),qe.current=e,xe(!0),He.current=!0,Se(!1),Ze.current&&(Ze.current.style.height="0px"),en.current&&(en.current.style.height="0px"),nn.current&&(nn.current.style.height="0px"),tn.current&&(tn.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 g=e.split(u.DEVIATION_BADGE_SEPARATOR),f="".concat(g[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(g[1]);s=(null===(n=Wn.current[f])||void 0===n?void 0:n.current)||null,d=(null===(t=Yn.current[f])||void 0===t?void 0:t.current)||null,v=d?e:null}else if(s=(null===(i=Jn.current[e])||void 0===i?void 0:i.current)||null,ie){var p=Nn[e],h=(null==p?void 0:p.refIndexes)||[];if(h.length>0){var x=h[0],_=jn.findIndex(function(e){return e.selfIndex===x});-1!==_&&(d=(null===(r=Kn.current[_])||void 0===r?void 0:r.current)||null,v=_)}}else d=(null===(o=Kn.current[e])||void 0===o?void 0:o.current)||null,v=d?e:null;Rt.current=v;var m=on.current,R=Qe.current,y=function(){!function(){var n,t,i,o,r,l,c,s,d,g,f,p,h=null,x=null,_=null,m=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=Un.current[R[2]])||void 0===n?void 0:n.current)||(null===(t=qn.current[Number(R[2])])||void 0===t?void 0:t.current)||null,x=(null===(i=Xn.current[R[3]])||void 0===i?void 0:i.current)||(null===(o=zn.current[Number(R[3])])||void 0===o?void 0:o.current)||null,_=(null===(r=Wn.current[y])||void 0===r?void 0:r.current)||h,m=(null===(l=Yn.current[y])||void 0===l?void 0:l.current)||x}else{var S=Number(e),b=null!==v?Number(v):S;h=(null===(c=qn.current[S])||void 0===c?void 0:c.current)||null,x=(null===(s=zn.current[b])||void 0===s?void 0:s.current)||null,_=(null===(d=Wn.current[S])||void 0===d?void 0:d.current)||(null===(g=Jn.current[S])||void 0===g?void 0:g.current)||h,m=(null===(f=Yn.current[b])||void 0===f?void 0:f.current)||(null===(p=Kn.current[b])||void 0===p?void 0:p.current)||x}if(_&&m&&h&&x){h.style.paddingTop="0px",x.style.paddingTop="0px";var A=_.getBoundingClientRect(),E=m.getBoundingClientRect(),I=A.top-E.top;I>0?x.style.paddingTop="".concat(I,"px"):I<0&&(h.style.paddingTop="".concat(Math.abs(I),"px"))}}(),Se(!0),ze.current&&ze.current(),De.current=!1,"right"===c&&R?R.dispatchEvent(new Event("scroll")):m&&m.dispatchEvent(new Event("scroll")),de(!1),null==l||l()};if(!s||!m)return De.current=!1,de(!1),void(null==l||l());if(d&&R){if(!ie){var S=0;S="right"===c?d?d.getBoundingClientRect().top:0:s?s.getBoundingClientRect().top:0;var b=Je.current,A=(null==b?void 0:b.getBoundingClientRect().top)||0,E=b?b.scrollTop+S-A-150:0;return b?void u.smoothScrollTo(b,E,200,y):void y()}var I=s.getBoundingClientRect().top-m.getBoundingClientRect().top+m.scrollTop,T=d.getBoundingClientRect().top-R.getBoundingClientRect().top+R.scrollTop,B=200;if("left"===c){var D=T-(I-m.scrollTop);D<0&&Ze.current&&(Ze.current.style.height="".concat(Math.abs(D),"px")),requestAnimationFrame(function(){var e,n=R.scrollHeight-R.clientHeight;if(D<0)e=0;else{if(D>n){var t=D-n;return en.current&&(en.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){u.smoothScrollTo(R,D,B,y)})}e=D}u.smoothScrollTo(R,e,B,y)})}else{var C=I-(T-R.scrollTop);C<0&&nn.current&&(nn.current.style.height="".concat(Math.abs(C),"px")),requestAnimationFrame(function(){var e,n=m.scrollHeight-m.clientHeight;if(C<0)e=0;else{if(C>n){var t=C-n;return tn.current&&(tn.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){u.smoothScrollTo(m,C,B,y)})}e=C}u.smoothScrollTo(m,e,B,y)})}}else y()})))},[Te,Sn,jn,he,ie,Nn,ut]),Gt=t.useCallback(function(e,n,t,i){var o,r="string"==typeof i?u.safeStringify(i).trim():u.safeStringify(null==i?void 0:i.deviation_summary).trim(),l=e.currentTarget;yn();var c="left";(null===(o=Qe.current)||void 0===o?void 0:o.contains(l))&&(c="right");var a=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"===c?null===(e=Yn.current[l])||void 0===e?void 0:e.current:null===(t=Wn.current[l])||void 0===t?void 0:t.current}return"right"===c?null===(i=Yn.current[n])||void 0===i?void 0:i.current:null===(o=Wn.current[n])||void 0===o?void 0:o.current};if(t)return ut(),we(new Set),Pe([]),Le.current=[],void(r&&requestAnimationFrame(function(){var e=a()||l;xn({open:!0,anchorEl:e,summary:i})}));Lt(n,t,r?{toggleIfSame:!1,sourceSide:c,onReady:function(){var e=a()||l;xn({open:!0,anchorEl:e,summary:i})}}:{toggleIfSame:!1,sourceSide:c})},[Lt,yn,xn,ut]),Ht=t.useCallback(function(){var e,n=dn.sectionIdx,t=dn.isOrphan;if(_n(),null!=n){var i="left";dn.anchorEl&&(null===(e=Qe.current)||void 0===e?void 0:e.contains(dn.anchorEl))&&(i="right"),Lt(n,t,{sourceSide:i})}},[Lt,dn.isOrphan,dn.sectionIdx,dn.anchorEl,_n]),qt=t.useCallback(function(){_n(),ut(),we(new Set),Pe([]),Le.current=[]},[_n,ut]),zt=null!==dn.sectionIdx&&Oe.has(dn.sectionIdx),Wt=_.useDeviationNavigation({proposedSections:Nn,existingSections:jn,parentDeviationRecord:Fn,expandedSections:at,maintainRelativeOrder:!!ie,scrollContainerRef:Je,leftContainerRef:on,lhsBadgeRefs:Wn,rhsBadgeRefs:Yn}),Yt=Wt.showDeviationNavigation,Kt=Wt.showOpenNodeRef,Ut=t.useMemo(function(){if(!ee)return null;for(var e in Fn){if((Fn[e]||[]).some(function(e){return e.id===ee}))return e}return null},[ee,Fn]),Xt=t.useRef(null),Jt=t.useRef(null);t.useEffect(function(){if(ee&&Xt.current!==ee){Jt.current!==ee&&(_n(),yn(),ut(),we(new Set),Pe([]),Le.current=[],Jt.current=ee);var n=!1,t=0,i=null,o=150,r=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},l=function(){var c,a,s,d;if(!n){var v=null,g=null;for(var f in Fn){var p=Fn[f].find(function(e){return e.id===ee});if(p){v=f,g=p;break}}if(g&&v){var h=Nn.findIndex(function(e){return e.id===v}),x=jn.findIndex(function(e){return e.id===v}),_=-1===h&&-1!==x,m=r(Nn,g.id),R=r(jn,g.id);if(m&&!R&&!_){var y=m.split("-"),S=Number(y[0]);if(ie){var b=null===(a=null===(c=Nn[S])||void 0===c?void 0:c.refIndexes)||void 0===a?void 0:a[0],A=jn.findIndex(function(e){return e.selfIndex===b});-1!==A&&(S=A)}R=e.__spreadArray([S],y.slice(1),!0).join("-")}if(m||R){var E=_||!m&&!!R,I=m?Number(m.split("-")[0]):h,T=R?Number(R.split("-")[0]):x;if(E){if(!(ie?!!at["right-".concat(T)]:!!at[String(T)])&&T>=0)return vt(T,"right"),t+=1,void(i=setTimeout(l,450))}else if(!(ie?!!at["left-".concat(I)]:!!at[String(I)])&&I>=0)return vt(I,"left"),t+=1,void(i=setTimeout(l,450));var B,D=m||"",C=R||"",O="".concat(g.id).concat(u.DEVIATION_BADGE_SEPARATOR,"0").concat(u.DEVIATION_BADGE_SEPARATOR).concat(D).concat(u.DEVIATION_BADGE_SEPARATOR).concat(C),w="".concat(g.id).concat(u.DEVIATION_BADGE_SEPARATOR,"0"),N=null===(s=Wn.current[w])||void 0===s?void 0:s.current,j=null===(d=Yn.current[w])||void 0===d?void 0:d.current,P=E||!N&&!!j,F=P?j:N;if(B=ie?P?Qe.current:on.current:Je.current,F&&B){var k=F.getBoundingClientRect();if(0===k.height)return void((t+=1)<20&&(i=setTimeout(l,o)));var M=B.getBoundingClientRect(),V=k.top-M.top+B.scrollTop-M.height/2+k.height/2,L=function(){var e,t,i,o,r;if(!n){Xt.current=ee;var l=window.getComputedStyle(F).color;N&&(N.style.transition="box-shadow 300ms ease-in-out",N.style.boxShadow="0 0 10px ".concat(l)),j&&(j.style.transition="box-shadow 300ms ease-in-out",j.style.boxShadow="0 0 10px ".concat(l)),setTimeout(function(){N&&(N.style.boxShadow=""),j&&(j.style.boxShadow="")},2e3);var u=(null===(t=null===(e=g.evaluationResult)||void 0===e?void 0:e.deviations)||void 0===t?void 0:t[0])||g,c=(null===(i=g.evaluationResult)||void 0===i?void 0:i.evaluation_outputs)||g.evaluation_outputs;if(!(!!N&&!!j)){var a=P?(null===(o=Yn.current[w])||void 0===o?void 0:o.current)||j:(null===(r=Wn.current[w])||void 0===r?void 0:r.current)||N;return xn({open:!0,anchorEl:a,summary:{deviation_summary:u.deviation_summary||u,evaluation_outputs:c}}),void(null==ne||ne())}Lt(O,!1,{toggleIfSame:!1,sourceSide:"left",onReady:function(){var e,n=(null===(e=Wn.current[w])||void 0===e?void 0:e.current)||N;xn({open:!0,anchorEl:n,summary:{deviation_summary:u.deviation_summary||u,evaluation_outputs:c}})}})}};Math.abs(B.scrollTop-V)<=2?L():(ln.current=V,un.current=L,B.scrollTo({top:V,behavior:"smooth"}),i&&clearTimeout(i),i=setTimeout(function(){if(un.current){ln.current=null;var e=un.current;un.current=null,e()}},800))}else(t+=1)<20&&(i=setTimeout(l,o))}else(t+=1)<20&&(i=setTimeout(l,o))}else(t+=1)<20&&(i=setTimeout(l,o))}};return i=setTimeout(l,o),function(){n=!0,i&&clearTimeout(i)}}},[ee,Fn,Nn,jn,ie,at,vt,Lt,xn]);var $t=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;return n.jsx(y.default,{section:t,keyPath:i,depth:r,columnKey:u,parentNodeId:a,expandedSubSections:st,setExpandedSubSections:dt,maintainRelativeOrder:ie||!1,proposedSections:Nn,existingSections:jn,treeData:z,deviationNumberRegistry:kn,connectedSections:Oe,activeSideBySideSection:Te,resolvedMarkdownStyles:Xe,getSubSectionRef:Qn,getSubSectionCompareStyle:wt,getBadgeRef:Zn,openMoreFunctionsPopup:pt,openSummaryPopup:Gt,showDeviationBadges:re,resetSideBySide:ut,setConnectedSections:we,setConnectedLines:Pe,cachedConnectedPositions:Le})};return n.jsxs(i.Box,e.__assign({ref:$e,sx:e.__assign(e.__assign({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},ie?{}:{overflow:"visible"}),{position:"relative"})},{children:[ue&&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,{})})),hn.open&&n.jsx(S.default,{open:hn.open,anchorEl:hn.anchorEl,containerEl:mt.current,clipTopEl:St.current,scrollContainerEl:Je.current,onClose:qt,summary:hn.summary}),n.jsx(d.default,{open:dn.open,anchorEl:dn.anchorEl,sectionTitle:dn.sectionTitle,referenceSectionTitle:dn.refSectionTitle,onClose:Sn,onOpenCognitiveCompare:ht,onOpenSideBySide:Ht,onConnect:xt,isConnected:zt,isOrphan:dn.isOrphan}),an.open&&n.jsx(s.default,{open:an.open,popupRef:Rn,position:gn,popupConfig:$,onClose:function(){fn(null),sn(function(n){return e.__assign(e.__assign({},n),{open:!1})}),mn(null)},markdownStyles:U,sectionTitle:an.sectionTitle,referenceSectionTitle:an.refSectionTitle,cognitiveData:an.cognitiveData,anchorEl:an.anchorEl,sectionAnchorEl:an.sectionAnchorEl,scrollContainerEl:Je.current,badgeStyle:an.badgeStyle,docData:an.docData,deviationData:an.deviationData,isLoading:an.isLoading}),n.jsx(i.Snackbar,e.__assign({open:!!ge,autoHideDuration:8e3,onClose:function(){return fe(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(i.Alert,e.__assign({onClose:function(){return fe(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:ge}))})),n.jsx(m.default,{componentHeaderText:q,displayConfig:J,maintainRelativeOrder:ie,onToggleView:function(e){ce(!0),setTimeout(function(){oe(!e),ut(),_n(),we(new Set),Pe([]),Le.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){ce(!1)},600)})})},50)}}),n.jsx(i.Box,e.__assign({ref:Je,onScroll:Vt,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:ie?"hidden":"auto",borderTop:nt&&tt?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(i.Box,e.__assign({sx:e.__assign({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},ie?{flex:1,minHeight:0}:{})},{children:n.jsxs(i.Box,e.__assign({ref:_t,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"40px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},ie?{flex:1,overflow:"visible"}:{})},{children:[n.jsxs("svg",e.__assign({ref:Fe,style:{position:"absolute",top:0,left:0,width:Ke.width||"100%",height:Ke.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",opacity:Ae?0:1,transition:"opacity 0.15s ease-in-out"}},{children:[Bt&&n.jsx("g",{children:n.jsx("line",{x1:Bt.x1,y1:Bt.y,x2:Bt.x2,y2:Bt.y,stroke:lt.badgeBorder,strokeWidth:"1.5"})}),Et.map(function(t){var l,c,s,d,v,f,p=t.x1+.5*(t.x2-t.x1),h=(t.y1+t.y2)/2;if("Not Defined"===t.style.label&&!t.hasCognitive)return null;if(t.isSubSection?he&&Te===t.subSectionKeyPath&&ye:he&&Te===t.sectionIdx&&ye)return null;if(!ie){var x=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),_=Nn[t.sectionIdx]||{title:"",content:""},m=jn[t.sectionIdx]||{title:"",content:""};if(console.log("Base and Ref Sections for Badge:",_,m),t.isSubSection&&t.subSectionKeyPath){var R=t.subSectionKeyPath.includes(u.DEVIATION_BADGE_SEPARATOR)?t.subSectionKeyPath.split(u.DEVIATION_BADGE_SEPARATOR):[],y=R[2]||t.subSectionKeyPath,S=R[3]||y,b=y.split("-").map(Number),A=S.split("-").map(Number),E=null,I=null;b.length>0&&(E=Nn[b[0]]),A.length>0&&(I=jn[A[0]]);var T=(null==E?void 0:E.title)||"",B=(null==I?void 0:I.title)||"";console.log("Root Parent Titles:",T,B);for(var D=1;D<b.length;D++)(null==E?void 0:E.subsections)&&(E=E.subsections[b[D]]);for(D=1;D<A.length;D++)(null==I?void 0:I.subsections)&&(I=I.subsections[A[D]]);E&&(_=e.__assign(e.__assign({},E),{title:T||E.title})),console.log("Base Section for Subsection Badge:",_),I&&(m=e.__assign(e.__assign({},I),{title:B||I.title})),console.log("Ref Section for Subsection Badge:",m)}var C=!(null===(l=_.cognitiveData)||void 0===l?void 0:l.isMissingRationale)||Boolean(null===(s=null===(c=_.cognitiveData)||void 0===c?void 0:c.decisioning)||void 0===s?void 0:s.length),O=(null===(f=null===(v=null===(d=_.evaluationResult)||void 0===d?void 0:d.cognitive_decisioning)||void 0===v?void 0:v.decisioning_factors)||void 0===f?void 0:f.length)||!1,w=C||O;return n.jsxs("g",{children:[n.jsx("path",{d:x,fill:"none",stroke:t.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),n.jsx("foreignObject",e.__assign({x:p-100,y:h-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(),w&&(an.open&&pn===t.id?yn():(mn(t.id),ft(gt(e.currentTarget,_,m,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:w?"pointer":"default"}},{children:[t.style.badgeText===a.DEFAULT_DEVIAION_COLOR&&null==t.style.label?n.jsx(g.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,{})})),w&&n.jsx(o.ChevronDown,{size:11,style:{transform:an.open&&pn===t.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},t.id)}return null}),je.map(function(t){var i,o=t.pathD,r=(null===(i=t.style)||void 0===i?void 0:i.badgeBorder)||"#6366F1",l="conn-marker-".concat(t.id),u="".concat(t.id,"-bg"),c="".concat(t.id,"-stroke");return n.jsxs("g",{children:[n.jsx("defs",{children:n.jsx("clipPath",e.__assign({id:"connections-clip"},{children:n.jsx("marker",e.__assign({id:l,markerWidth:"8",markerHeight:"6",refX:"7",refY:"3",orient:"auto"},{children:n.jsx("polygon",{points:"0 0, 8 3, 0 6",fill:r})}))}))}),n.jsx("path",{ref:function(e){Ve.current[u]=e},d:o,fill:"none",stroke:"#FFFFFF",strokeWidth:"4",strokeOpacity:"0.7"}),n.jsx("path",{ref:function(e){Ve.current[c]=e},d:o,fill:"none",stroke:r,strokeWidth:"1.75",markerEnd:"url(#".concat(l,")")})]},t.id)})]})),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)"},ie?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(i.Box,e.__assign({ref:St,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:Bn,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:Bn}))}))})),n.jsxs(i.Box,e.__assign({ref:on,onScroll:Vt,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},ie?{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:nn,style:{width:"100%",height:"0px",flexShrink:0}}),Vn&&Nn.map(function(t,r){var l,c,a=!t.title&&!t.content;if(ie&&a)return null;var s=t,d=Ot(r,"left"),v=ie?!(null===(l=s.refIndexes)||void 0===l?void 0:l.length)||s.selfIndex<0:!jn[r],f=ie?"number"==typeof s.selfIndex&&s.selfIndex>=0?s.selfIndex+1:null:r+1,p=Oe.has(r),h=u.extractDeviationScore(s.evaluationResult,null==d?void 0:d.deviationLabel);return n.jsx(i.Box,e.__assign({ref:$n(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:qn.current[r],sx:e.__assign({width:"100%",display:"flex"},p&&{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:$n("left-accordion-".concat(r)),mb:0,treeData:z,proposedSections:Nn,existingSections:jn,deviationNumberRegistry:kn,getSectionCompareStyle:Ot,getBadgeRef:Zn,connectedSections:Oe,openMoreFunctionsPopup:pt,openSummaryPopup:Gt,deviationNodeIdToView:ee,deviationTargetParentId:Ut,parentNodeId:(null===(c=null==z?void 0:z.input_index_map)||void 0===c?void 0:c[0])||"",isExpanded:ie?!!at["left-".concat(r)]:!!at[String(r)],onToggle:function(){qt(),vt(r,"left")},navigation:t.id?Yt[t.id]:null,showOpenNodeRef:Kt,resolvedMarkdownStyles:Xe,maintainRelativeOrder:ie,showDeviationBadges:re,renderSubSections:$t})})),ie&&d&&n.jsxs(i.Box,e.__assign({ref:Wn.current[r],onClick:function(e){var n=ie?jn.find(function(e){var n;return null===(n=s.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""}:jn[r]||{title:"",content:""};pt(e,t,v,n,r,d)},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:.4,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[null!==f&&n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(d.badgeBorder)}},{children:f})),n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",px:.25}},{children:!J.isLoading||null!=s.evaluationResult&&null!=s.evaluationResult?v?"No Deviation Found":"N/A"===h||"NA"===h?"N/A":0==h||null==h?"Same":"".concat(h):n.jsx(g.default,{color:d.badgeText})})),n.jsx(o.EllipsisVertical,{size:11,color:d.badgeText})]}))]}))}),"left-row-".concat(r))}),n.jsx("div",{ref:tn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),n.jsx(i.Box,e.__assign({ref:mt,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(),an.open&&pn===it?yn():(mn(it),ft(gt(n.currentTarget,{title:"",content:"",evaluationResult:ot,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,it,!0,e.__assign(e.__assign({},lt),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-5px",borderRadius:"20px",bgcolor:lt.badgeBg,color:lt.badgeText,border:"1px solid ".concat(lt.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=rt?rt:n.jsx(g.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:an.open&&pn===it?"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},ie?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[se&&n.jsx(l.default,{sections:11}),n.jsx(i.Box,e.__assign({ref:bt,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:Dn,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:Dn}))}))})),n.jsxs(i.Box,e.__assign({ref:Qe,onScroll:Vt,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},ie?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-120px",pl:"140px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:Ze,style:{width:"100%",height:"0px",flexShrink:0}}),Vn&&jn.map(function(t,o){var r,l=t,u=[],c=!1,a=null,s=-1;if(ie){u=Nn.filter(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(l.selfIndex))&&e.selfIndex>=0}).map(function(e){return e.selfIndex+1}),s=Nn.findIndex(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(l.selfIndex))&&e.selfIndex>=0});var d=Nn.findIndex(function(e,n){var t;return Oe.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(l.selfIndex))});(c=-1!==d)&&(a=Ot(d))}else u=[o+1],(c=Oe.has(o))&&(a=Ot(o));var v=Ot(ie&&-1!==s?s:o);return n.jsx(i.Box,e.__assign({ref:Kn.current[o],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:zn.current[o],sx:e.__assign({width:"100%",display:"flex"},c&&a&&{borderRadius:"6px",outline:"2px solid ".concat(a.badgeBorder),outlineOffset:"1px"})},{children:n.jsx(R.default,{section:t,idx:o,columnKey:"right",colRef:$n("right-accordion-".concat(o)),mb:0,parentNodeId:(null===(r=null==z?void 0:z.input_index_map)||void 0===r?void 0:r[1])||"",isExpanded:ie?!!at["right-".concat(o)]:!!at[String(o)],treeData:z,proposedSections:Nn,existingSections:jn,deviationNumberRegistry:kn,getBadgeRef:Zn,getSectionCompareStyle:Ot,connectedSections:Oe,openMoreFunctionsPopup:pt,openSummaryPopup:Gt,deviationNodeIdToView:ee,deviationTargetParentId:Ut,onToggle:function(){qt(),vt(o,"right")},navigation:t.id?Yt[t.id]:null,showOpenNodeRef:Kt,resolvedMarkdownStyles:Xe,maintainRelativeOrder:ie,showDeviationBadges:re,renderSubSections:$t})})),ie&&v&&n.jsx(i.Box,e.__assign({ref:Yn.current[o],"data-section-id":l.id,sx:{position:"absolute",top:"18px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"11px",bgcolor:v.badgeBg,color:v.badgeText,border:"1px solid ".concat(v.badgeBorder),borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:u.length>0?u.join(", "):"-"}))]}))}),"right-row-".concat(o))}),n.jsx("div",{ref:en,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"),g=require("./components/ThreeDotsLoader.js"),f=require("./hooks/useCompareData.js"),p=require("./hooks/useComparePopups.js"),h=require("./hooks/useSectionRefs.js"),x=require("./hooks/useAccordionState.js"),_=require("./hooks/useDeviationNavigation.js"),m=require("./components/CompareHeader.js"),R=require("./components/SectionAccordion.js"),y=require("./components/SubSectionAccordion.js"),S=require("./components/CognitiveSummaryPopup.js");exports.SHARED_MARKDOWN_STYLES=c.SHARED_MARKDOWN_STYLES,exports.default=function(b){var A,E,I,T,B,D,C,O,w,N,j,P,F,k,M,V,L,G,H,q,z,W,Y,K,U,X,J=b.componentHeaderText,$=void 0===J?a.DEFAULT_COMPONENT_HEADER_TEXT:J,Q=b.treeData,Z=b.comparisonConfig,ee=b.leftColumnTitleText,ne=b.rightColumnTitleText,te=b.markdownStyles,ie=b.displayConfig,oe=void 0===ie?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!0}:ie,le=b.popupConfig,re=b.deviationData,ue=void 0===re?{}:re,ce=b.deviationNodeIdToView,ae=b.resetDeviationNodeId,se=t.useState(oe.maintainRelativeOrder),de=se[0],ve=se[1],ge=!!de||!!(null==oe?void 0:oe.showDeviationBadges),fe=t.useState(!1),pe=fe[0],he=fe[1],xe=t.useState(!1),_e=xe[0],me=xe[1],Re=t.useState(null),ye=Re[0],Se=Re[1],be=t.useState(!1),Ae=be[0],Ee=be[1],Ie=t.useState(null===(E=null!==(A=null==Q?void 0:Q.newEvaluationResult)&&void 0!==A?A:null==oe?void 0:oe.enableDeviationSchemaBackwardCompatibility)||void 0===E||E)[0],Te=t.useState(!1),Be=Te[0],De=Te[1],Ce=t.useState(!1),Oe=Ce[0],we=Ce[1],Ne=t.useState(null),je=Ne[0],Pe=Ne[1],Fe=t.useRef(!1),ke=t.useState(new Set),Me=ke[0],Ve=ke[1],Le=t.useState([]),Ge=Le[0],He=Le[1],qe=t.useRef(null),ze=t.useRef(!1),We=t.useRef(null),Ye=t.useRef({}),Ke=t.useRef([]),Ue=t.useRef(!1),Xe=t.useRef(!1),Je=t.useRef(null),$e=t.useRef(function(){}),Qe=t.useMemo(function(){return(null==Q?void 0:Q.cognitive_decisioning)||{}},[Q]),Ze=t.useState({width:0,height:0}),en=Ze[0],nn=Ze[1],tn=t.useMemo(function(){return e.__assign(e.__assign({},c.SHARED_MARKDOWN_STYLES),te)},[te]),on=t.useRef(null),ln=t.useRef(null),rn=t.useRef(null),un=t.useRef(null),cn=t.useRef(null),an=t.useRef(null),sn=t.useRef(null),dn=t.useRef(null),vn=t.useRef(!1),gn=t.useRef(null),fn=t.useRef(null),pn=p.useComparePopups(on),hn=pn.cognitivePopup,xn=pn.setCognitivePopup,_n=pn.moreFunctions,mn=pn.setMoreFunctions,Rn=pn.position,yn=pn.setPosition,Sn=pn.activeBadgeId,bn=pn.summaryPopup,An=pn.setSummaryPopup,En=pn.closeSummaryPopup,In=pn.setActiveBadgeId,Tn=pn.popupRef,Bn=pn.closeCognitivePopup,Dn=pn.closeMoreFunctionsPopup,Cn=t.useMemo(function(){var e,n,t,i,o,l,r;return{fields:null!==(e=null==Z?void 0:Z.fields)&&void 0!==e?e:c.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(t=null===(n=null==Z?void 0:Z.thresholds)||void 0===n?void 0:n.high)&&void 0!==t?t:c.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(o=null===(i=null==Z?void 0:Z.thresholds)||void 0===i?void 0:i.medium)&&void 0!==o?o:c.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(r=null===(l=null==Z?void 0:Z.thresholds)||void 0===l?void 0:l.exact)&&void 0!==r?r:c.DEFAULT_COMPARISON_CONFIG.thresholds.exact}}},[Z]),On=t.useState(null),wn=On[0];On[1];var Nn=null===(B=null===(I=null==Q?void 0:Q.documents)||void 0===I?void 0:I[null===(T=null==Q?void 0:Q.input_index_map)||void 0===T?void 0:T[0]])||void 0===B?void 0:B.title,jn=null===(O=null===(D=null==Q?void 0:Q.documents)||void 0===D?void 0:D[null===(C=null==Q?void 0:Q.input_index_map)||void 0===C?void 0:C[1]])||void 0===O?void 0:O.title,Pn=u.safeStringify(ee||Nn||"Uploaded Contract"),Fn=u.safeStringify(ne||jn||"Reference Template"),kn=f.useCognitiveTreeData(Q,de,ue,Cn,Ie),Mn=kn.activeProposed,Vn=kn.existingRule,Ln=kn.proposedSections,Gn=kn.existingSections,Hn=kn.visibleFields,qn=kn.parentDeviationRecord,zn=kn.deviationNumberRegistry,Wn=kn.parseError;t.useEffect(function(){Wn&&Se("Failed to load comparison: ".concat(Wn))},[Wn]);var Yn=Ln.length>0||Gn.length>0,Kn=h.useSectionRefs(Hn.map(function(e){return e.key}),Math.max(Ln.length,Gn.length)),Un=Kn.leftRefs,Xn=Kn.rightRefs,Jn=Kn.sectionLeftRefs,$n=Kn.sectionRightRefs,Qn=Kn.lhsBadgeRefs,Zn=Kn.rhsBadgeRefs,et=Kn.sectionRightRowRefs,nt=Kn.subSectionLeftRefs,tt=Kn.subSectionRightRefs,it=Kn.sectionRowRefs,ot=Kn.getSectionRowRef,lt=Kn.getSubSectionRef,rt=Kn.getBadgeRef,ut=Vn.analysis,ct=u.safeStringify(null===(N=null===(w=null==ut?void 0:ut.rule_difference_comparison)||void 0===w?void 0:w.summary)||void 0===N?void 0:N.overall_summary),at=!!ct.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),st=null!==(j=null==Q?void 0:Q.base_root_id)&&void 0!==j?j:"-1";null==Q||Q[st];var dt=Ie?null!==(Y=null!==(q=ue&&(null===(H=null==ue?void 0:ue[st])||void 0===H?void 0:H.evaluation_result))&&void 0!==q?q:null===(W=null===(z=null==Q?void 0:Q.nodes)||void 0===z?void 0:z[st])||void 0===W?void 0:W.evaluation_result)&&void 0!==Y?Y:null:null!==(G=null!==(k=ue&&(null===(F=null===(P=null==ue?void 0:ue[st])||void 0===P?void 0:P.evaluation_result)||void 0===F?void 0:F[0]))&&void 0!==k?k:null===(L=null===(V=null===(M=null==Q?void 0:Q.nodes)||void 0===M?void 0:M[st])||void 0===V?void 0:V.evaluation_result)||void 0===L?void 0:L[0])&&void 0!==G?G:null,vt=u.extractDeviationScore(dt),gt=u.generateColorPalette(null!==(X=null===(U=null===(K=null==dt?void 0:dt.evaluation_outputs)||void 0===K?void 0:K.metadata)||void 0===U?void 0:U.label_color)&&void 0!==X?X:""),ft=t.useCallback(function(){var e,n,t,i,o,l;Ee(!1),Xe.current=!1;var r=Je.current,c=Tt.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=nt.current[a[2]])||void 0===e?void 0:e.current)||(null===(n=Jn.current[Number(a[2])])||void 0===n?void 0:n.current))&&(s.style.paddingTop="0px")}else{var s;(s=null===(t=Jn.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=tt.current[a[3]])||void 0===i?void 0:i.current)||(null===(o=$n.current[Number(a[3])])||void 0===o?void 0:o.current))&&(d.style.paddingTop="0px")}else{var d;(d=null===(l=$n.current[c])||void 0===l?void 0:l.current)&&(d.style.paddingTop="0px")}Pe(null),Je.current=null,Tt.current=null,De(!1),me(!1),un.current&&(un.current.style.height="0px"),cn.current&&(cn.current.style.height="0px"),an.current&&(an.current.style.height="0px"),sn.current&&(sn.current.style.height="0px")},[]),pt=x.useAccordionState({maintainRelativeOrder:!!de,proposedSections:Ln,existingSections:Gn,activeSideBySideSection:je,connectedSections:Me,resetSideBySide:ft,setConnectedSections:Ve,setConnectedLines:He,cachedConnectedPositions:Ke,svgContainerRef:qe,isAnimatingRef:ze,animationTimerRef:We,calculateLinesRef:$e,sectionLeftRefs:Jn,sectionRightRefs:$n,subSectionLeftRefs:nt,subSectionRightRefs:tt}),ht=pt.expandedSections,xt=pt.expandedSubSections,_t=pt.setExpandedSubSections,mt=pt.toggleSection,Rt=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)||"",g=(v?Qe[v]:null)||(null==t?void 0:t.cognitiveData)||(null==i?void 0:i.cognitiveData)||{section_id:v,decisioning:[],gap:[],relevance_score:0},f=null!==(s=null===(a=it.current[o])||void 0===a?void 0:a.current)&&void 0!==s?s:null;return{isLoading:null!==(d=null==oe?void 0:oe.isLoading)&&void 0!==d&&d,open:!0,sectionTitle:(null==t?void 0:t.displayTitle)?null==t?void 0:t.title:"no title",refSectionTitle:(null==i?void 0:i.displayTitle)?null==i?void 0:i.title:"no title",cognitiveData:g,anchorEl:n,sectionAnchorEl:f,badgeStyle:r||null,sectionIdx:o,docData:{documents:null==Q?void 0:Q.documents,input_index_map:null==Q?void 0:Q.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}},[Qe,Q]),yt=t.useCallback(function(e){Dn(),yn(null),xn(e)},[Dn]),St=function(e,n,t,i,o,l){var r;if(e.stopPropagation(),_n.open&&_n.sectionIdx===o)Dn();else{var c=e.currentTarget,a="left";(null===(r=rn.current)||void 0===r?void 0:r.contains(c))&&(a="right");Xe.current&&ft(),Ve(new Set),He([]),Ke.current=[],Bn(),bn.open?Jt():En(),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=Zn.current[r])||void 0===e?void 0:e.current:null===(n=Qn.current[r])||void 0===n?void 0:n.current}return"right"===a?null===(t=Zn.current[o])||void 0===t?void 0:t.current:null===(i=Qn.current[o])||void 0===i?void 0:i.current}()||c;mn(Rt(e,n,i,o,t,l))})}},bt=t.useCallback(function(){null!==_n.sectionIdx&&_n.anchorEl?yt(e.__assign(e.__assign({},_n),{open:!0})):Dn()},[_n,Dn,yt]),At=t.useCallback(function(){var e=_n.sectionIdx,n=_n.isOrphan;Dn(),En(),null!==e&&(n?Se("No counterpart exists to connect to."):(Xe.current&&ft(),He([]),Ke.current=[],Ve(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){$e.current&&$e.current()},50)))},[_n.sectionIdx,_n.isOrphan,Dn,En,ft]),Et=t.useRef(null),It=t.useRef(null),Tt=t.useRef(null),Bt=t.useRef(null),Dt=t.useRef(null),Ct=t.useRef(null),Ot=t.useState([]),wt=Ot[0],Nt=Ot[1];t.useRef(null);var jt=t.useState(null),Pt=jt[0],Ft=jt[1];t.useEffect(function(){if(wn){var e=Cn.fields.find(function(e){return e.analysisKey===wn||e.key===wn});if(e){var n=Un.current[e.key]||Xn.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[wn,Cn.fields]);var kt=t.useCallback(function(e){var n,t,i,o,l,r,u,c,a,s=null===(n=null==ut?void 0:ut.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 g=d.mappings[0]||{};return{score:d.score,relation:g.relation||"",highlightsA:(null===(r=g.highlights)||void 0===r?void 0:r.ruleA_spans)||[],highlightsB:(null===(u=g.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}},[ut]),Mt=t.useCallback(function(n,t){var i,o,l,r,c,s,d;void 0===t&&(t="left");var v=null,g=null;if("left"===t)if(v=Ln[n],de&&v){var f=Gn.filter(function(e){var n;return null===(n=v.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)});g=f.find(function(e){return e.evaluationResult})||f[0]}else g=Gn[n];else if(g=Gn[n],de&&g){var p=Ln.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(g.selfIndex)});v=p.find(function(e){return e.evaluationResult})||p[0]}else v=Ln[n];var h=(null==v?void 0:v.relation)&&"not_defined"!==v.relation,x=(null==g?void 0:g.relation)&&"not_defined"!==g.relation,_=!(!(null==v?void 0:v.cognitiveData)&&!(null==g?void 0:g.cognitiveData));if(!h&&!x&&!_)return e.__assign(e.__assign({},u.generateColorPalette(a.DEFAULT_DEVIAION_COLOR)),{label:"Not Defined"});var m=null!==(o=null!==(i=null==v?void 0:v.evaluationResult)&&void 0!==i?i:null==g?void 0:g.evaluationResult)&&void 0!==o?o:null,R=null===(l=null==m?void 0:m.evaluation_outputs)||void 0===l?void 0:l.output_value,y=null!==(s=null===(c=null===(r=null==m?void 0:m.evaluation_outputs)||void 0===r?void 0:r.metadata)||void 0===c?void 0:c.label_color)&&void 0!==s?s:a.DEFAULT_DEVIAION_COLOR;return null!=m?e.__assign(e.__assign({},u.generateColorPalette(y)),{label:null!==(d=R)&&void 0!==d?d:""}):e.__assign(e.__assign({},u.generateColorPalette(y)),{label:null})},[Ln,Gn,Qe,Cn,de]),Vt=t.useCallback(function(n){for(var t,i,o,l,r,c,s,d,v,g=n.split("-").map(Number),f=Ln[g[0]],p=Gn[g[0]],h=1;h<g.length;h++)(null==f?void 0:f.subsections)&&(f=f.subsections[g[h]]),(null==p?void 0:p.subsections)&&(p=p.subsections[g[h]]);if(!f&&!p)return null;var x=(null==f?void 0:f.relation)&&"not_defined"!==f.relation,_=(null==p?void 0:p.relation)&&"not_defined"!==p.relation,m=u.safeStringify(null==f?void 0:f.id)||u.safeStringify(null==p?void 0:p.id)||"",R=!(!(null==f?void 0:f.cognitiveData)&&!(null==p?void 0:p.cognitiveData));if(!x&&!_&&!R)return e.__assign(e.__assign({},u.generateColorPalette(a.DEFAULT_DEVIAION_COLOR)),{label:"Not Defined"});null!==(i=null!==(t=null==f?void 0:f.cognitiveRelevanceScore)&&void 0!==t?t:null==p?void 0:p.cognitiveRelevanceScore)&&void 0!==i||m&&(null===(o=Qe[m])||void 0===o||o.relevance_score);var y=null!==(r=null!==(l=null==f?void 0:f.evaluationResult)&&void 0!==l?l:null==p?void 0:p.evaluationResult)&&void 0!==r?r:null,S=null===(c=null==y?void 0:y.evaluation_outputs)||void 0===c?void 0:c.output_value,b=null!==(v=null===(d=null===(s=null==y?void 0:y.evaluation_outputs)||void 0===s?void 0:s.metadata)||void 0===d?void 0:d.label_color)&&void 0!==v?v:a.DEFAULT_DEVIAION_COLOR;return null!=y?e.__assign(e.__assign({},u.generateColorPalette(b)),{label:null!=S?S:""}):e.__assign(e.__assign({},u.generateColorPalette(b)),{label:null})},[Ln,Gn,Qe,Cn]),Lt=t.useCallback(function(){var e,n,t,i,o,l,r,c,a,s,d,v,g,f,p,h,x,_,m,R,y,S;if(!vn.current&&!ze.current){vn.current=!0;try{if(!Et.current)return;var b=function(e){var n=e.split("-"),t=n[0];if(!ht[t]&&!1===de)return!1;if(de&&!ht["left-".concat(t)]&&!ht["right-".concat(t)]&&!ht[t])return!1;for(var i=t,o=1;o<n.length-1;o++)if(i+="-".concat(n[o]),!xt[i])return!1;return!0},A=Et.current.getBoundingClientRect();nn({width:A.width,height:A.height});var E=[];if(Hn.forEach(function(e){var n,t,i=e.key,o=null===(n=Un.current[i])||void 0===n?void 0:n.current,l=null===(t=Xn.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 I=0;I<Math.max(Ln.length,Gn.length);I++){var T=null===(e=Jn.current[I])||void 0===e?void 0:e.current,B=null===(n=$n.current[I])||void 0===n?void 0:n.current;T&&(T.style.height="auto",T.style.minHeight="0px"),B&&(B.style.height="auto",B.style.minHeight="0px")}de||Object.keys(nt.current).forEach(function(e){var n,t;if(b(e)){var i=null===(n=nt.current[e])||void 0===n?void 0:n.current,o=null===(t=tt.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={};Hn.forEach(function(e){var n,t,i=e.key,o=null===(n=Un.current[i])||void 0===n?void 0:n.current,l=null===(t=Xn.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 C={left:{},right:{}},O={};if(!ze.current)if(de){if(Ae&&null!==je)if("number"==typeof je){var w=je,N=Ln[w],j=null===(o=Jn.current[w])||void 0===o?void 0:o.current;j&&N&&(N.refIndexes||[]).forEach(function(e){var n,t=Gn.findIndex(function(n){return n.selfIndex===e}),i=null===(n=$n.current[t])||void 0===n?void 0:n.current;if(i&&(ht["left-".concat(w)]||ht["right-".concat(t)])){var o=Math.max(j.getBoundingClientRect().height,i.getBoundingClientRect().height);C.left[w]=Math.max(C.left[w]||0,o),C.right[t]=Math.max(C.right[t]||0,o)}})}else{var P=je.split(u.DEVIATION_BADGE_SEPARATOR)[2];if(P){T=null===(l=nt.current[P])||void 0===l?void 0:l.current,B=null===(r=tt.current[P])||void 0===r?void 0:r.current;if(T&&B){F=Math.max(T.getBoundingClientRect().height,B.getBoundingClientRect().height);O[P]=Math.max(O[P]||0,F)}}}}else{Object.keys(nt.current).forEach(function(e){var n,t;if(b(e)){var i=null===(n=nt.current[e])||void 0===n?void 0:n.current,o=null===(t=tt.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);O[e]=u,i.style.minHeight="".concat(u,"px"),o.style.minHeight="".concat(u,"px")}}});for(I=0;I<Math.min(Ln.length,Gn.length);I++){var T=null===(t=Jn.current[I])||void 0===t?void 0:t.current,B=null===(i=$n.current[I])||void 0===i?void 0:i.current;if(T&&B){var F=Math.max(T.getBoundingClientRect().height,B.getBoundingClientRect().height);C.left[I]=F,C.right[I]=F}}}if(Hn.forEach(function(e){var n,t,i=e.key,o=null===(n=Un.current[i])||void 0===n?void 0:n.current,l=null===(t=Xn.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(C.left).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=Jn.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),Object.entries(C.right).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=$n.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),de||Object.keys(O).forEach(function(e){var n,t,i=null===(n=nt.current[e])||void 0===n?void 0:n.current,o=null===(t=tt.current[e])||void 0===t?void 0:t.current;if(i&&o&&O[e]){var l=O[e];i.style.minHeight="".concat(l,"px"),o.style.minHeight="".concat(l,"px")}})),de)Ln.forEach(function(e,n){var t;(null===(t=Jn.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=Gn.findIndex(function(n){return n.selfIndex===e});if(-1!==v){var g=null===(t=Qn.current[n])||void 0===t?void 0:t.current,f=null===(i=Zn.current[v])||void 0===i?void 0:i.current;if(g&&f){var p=g.getBoundingClientRect(),h=f.getBoundingClientRect(),x=p.right-A.left,_=h.left-A.left,m=p.top+p.height/2-A.top,R=h.top+h.height/2-A.top;if(Ae&&je===n){var y=null!==(l=null===(o=dn.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==l?l:0,S=null!==(u=null===(r=rn.current)||void 0===r?void 0:r.getBoundingClientRect().top)&&void 0!==u?u:0,b=y+(null!==(a=null===(c=dn.current)||void 0===c?void 0:c.clientHeight)&&void 0!==a?a:1/0),I=S+(null!==(d=null===(s=rn.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,D=function(e,n,t){return Math.max(n,Math.min(t,e))};m=D(T,y,b)-A.top,R=D(B,S,I)-A.top}var C=Mt(n);C&&E.push({id:"line-".concat(n,"-").concat(v),x1:x,y1:m,x2:_,y2:R,style:C,sectionIdx:n,targetRightIdx:v})}}})});else{for(I=0;I<Math.min(Ln.length,Gn.length);I++){var k=null===(c=Jn.current[I])||void 0===c?void 0:c.current,M=null===(a=$n.current[I])||void 0===a?void 0:a.current;if(k&&M){var V=k.getBoundingClientRect(),L=M.getBoundingClientRect(),G=Math.max(V.top,L.top)+18-A.top,H=(null===(s=Gn[I])||void 0===s?void 0:s.id)||"sec-".concat(I);(J=Mt(I))&&E.push({id:H,x1:V.right-A.left,y1:G,x2:L.left-A.left,y2:G,style:J,sectionIdx:I,hasCognitive:!!((null===(d=Ln[I])||void 0===d?void 0:d.cognitiveData)||(null===(v=Gn[I])||void 0===v?void 0:v.cognitiveData)||H&&Qe[H]),isSubSection:!1})}}Object.keys(nt.current).forEach(function(e){var n,t,i,o,l,r;if(b(e)){var c=null===(n=nt.current[e])||void 0===n?void 0:n.current,a=null===(t=tt.current[e])||void 0===t?void 0:t.current;if(c&&a){for(var s=e.split("-").map(Number),d=Ln[s[0]],v=Gn[s[0]],g=1;g<s.length;g++)(null==d?void 0:d.subsections)&&(d=d.subsections[s[g]]),(null==v?void 0:v.subsections)&&(v=v.subsections[s[g]]);var f=!!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(f&&p||h&&x){var _=c.getBoundingClientRect(),m=a.getBoundingClientRect(),R=Math.max(_.top,m.top)+16-A.top,y=Vt(e);y&&"Not Defined"!==y.label&&E.push({id:"subsec-".concat(e),x1:_.right-A.left,y1:R,x2:m.left-A.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(Ae&&"string"==typeof je&&je.includes(u.DEVIATION_BADGE_SEPARATOR)){var q=je.split(u.DEVIATION_BADGE_SEPARATOR),z=q[0],W=q[1],Y=q[2],K=(q[3],"".concat(z).concat(u.DEVIATION_BADGE_SEPARATOR).concat(W)),U=null===(g=Qn.current[K])||void 0===g?void 0:g.current,X=null===(f=Zn.current[K])||void 0===f?void 0:f.current;if(U&&X){var J,$=U.getBoundingClientRect(),Q=X.getBoundingClientRect(),Z=$.right-A.left,ee=Q.left-A.left,ne=$.top+$.height/2-A.top,te=Q.top+Q.height/2-A.top;if(de){var ie=null!==(h=null===(p=dn.current)||void 0===p?void 0:p.getBoundingClientRect().top)&&void 0!==h?h:0,oe=null!==(_=null===(x=rn.current)||void 0===x?void 0:x.getBoundingClientRect().top)&&void 0!==_?_:0,le=ie+(null!==(R=null===(m=dn.current)||void 0===m?void 0:m.clientHeight)&&void 0!==R?R:1/0),re=oe+(null!==(S=null===(y=rn.current)||void 0===y?void 0:y.clientHeight)&&void 0!==S?S:1/0),ue=function(e,n,t){return Math.max(n,Math.min(t,e))};ne=ue($.top+$.height/2,ie,le)-A.top,te=ue(Q.top+Q.height/2,oe,re)-A.top}(J=Vt(Y))&&E.push({id:"line-subsec-".concat(K),x1:Z,y1:ne,x2:ee,y2:te,style:J,sectionIdx:Number(Y.split("-")[0]),isSubSection:!0,subSectionKeyPath:je})}}if(Nt(E),Dt.current&&Ct.current){var ce=Dt.current.getBoundingClientRect(),ae=Ct.current.getBoundingClientRect(),se=(ce.top+ce.height/2-A.top+ae.top+ae.height/2-A.top)/2;Ft({x1:ce.right-A.left,x2:ae.left-A.left,y:se})}else Ft(null);if(Me.size>0){var ve=[],ge=dn.current,fe=rn.current;if(ge&&fe){var pe=[],he=ge.getBoundingClientRect().top,xe=fe.getBoundingClientRect().top,_e=he+ge.clientHeight,me=xe+fe.clientHeight,Re=ge.scrollTop,ye=fe.scrollTop,Se=A.top,be=function(e,n,t){return Math.max(n,Math.min(t,e))};Me.forEach(function(e){var n,t,i,o,l;if("string"==typeof e&&e.includes(u.DEVIATION_BADGE_SEPARATOR)){var r=e.split(u.DEVIATION_BADGE_SEPARATOR),c=r[0],a=r[1],s=r[2],d=(r[3],"".concat(c).concat(u.DEVIATION_BADGE_SEPARATOR).concat(a)),v=null===(n=Qn.current[d])||void 0===n?void 0:n.current,g=null===(t=Zn.current[d])||void 0===t?void 0:t.current;if(!v||!g)return;var f=v.getBoundingClientRect(),p=g.getBoundingClientRect(),h=Vt(s),x=(j=f.right-A.left)+.5*((P=p.left-A.left-0)-j),_=f.top+f.height/2,m=p.top+p.height/2,R=_-he+Re,y=m-xe+ye,S="conn-subsec-".concat(d);pe.push({lhsScrollY:R,rhsScrollY:y,x1:j,x2:P,containerTop:Se,leftIdx:e,rhsArrayIdx:e,styleColor:(null==h?void 0:h.badgeBorder)||"#6366F1",styleId:S});var b=be(_,he,_e),E=be(m,xe,me),I=b-Se,T=E-Se,B=m>=xe-4&&m<=me+4,D="";D=(F=_>=he-4&&_<=_e+4)&&B?u.getBentArrowPath(j,I,P,T):F&&!B?"M ".concat(j,",").concat(I," L ").concat(x,",").concat(I," L ").concat(x,",").concat(T):!F&&B?"M ".concat(x,",").concat(I," L ").concat(x,",").concat(T," L ").concat(P,",").concat(T):"M ".concat(x,",").concat(I," L ").concat(x,",").concat(T),ve.push({id:S,pathD:D,style:h,leftIdx:e,rhsArrayIdx:e})}else if(de){var C=e,O=Ln[C];if(!(null===(l=null==O?void 0:O.refIndexes)||void 0===l?void 0:l.length))return;O.refIndexes.forEach(function(e){var n,t,i=Gn.findIndex(function(n){return n.selfIndex===e});if(-1!==i){var o=null===(n=Qn.current[C])||void 0===n?void 0:n.current,l=null===(t=Zn.current[i])||void 0===t?void 0:t.current;if(o&&l){var r=o.getBoundingClientRect(),c=l.getBoundingClientRect(),a=Mt(C),s=r.right-A.left,d=c.left-A.left-0,v=s+.5*(d-s),g=r.top+r.height/2,f=c.top+c.height/2,p=g-he+Re,h=f-xe+ye,x="conn-".concat(C,"-").concat(i);pe.push({lhsScrollY:p,rhsScrollY:h,x1:s,x2:d,containerTop:Se,leftIdx:C,rhsArrayIdx:i,styleColor:(null==a?void 0:a.badgeBorder)||"#6366F1",styleId:x});var _=be(g,he,_e),m=be(f,xe,me),R=_-Se,y=m-Se,S=g>=he-4&&g<=_e+4,b=f>=xe-4&&f<=me+4,E="";E=S&&b?u.getBentArrowPath(s,R,d,y):S&&!b?"M ".concat(s,",").concat(R," L ").concat(v,",").concat(R," L ").concat(v,",").concat(y):!S&&b?"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:E,style:a,leftIdx:C,rhsArrayIdx:i})}}})}else{var w=e,N=w;v=null===(i=Qn.current[w])||void 0===i?void 0:i.current,g=null===(o=Zn.current[N])||void 0===o?void 0:o.current;if(!v||!g)return;var j,P;f=v.getBoundingClientRect(),p=g.getBoundingClientRect(),h=Mt(w),x=(j=f.right-A.left)+.5*((P=p.left-A.left-0)-j),_=f.top+f.height/2,m=p.top+p.height/2,R=_-he+Re,y=m-xe+ye,S="conn-".concat(w,"-").concat(N);pe.push({lhsScrollY:R,rhsScrollY:y,x1:j,x2:P,containerTop:Se,leftIdx:w,rhsArrayIdx:N,styleColor:(null==h?void 0:h.badgeBorder)||"#6366F1",styleId:S});var F;b=be(_,he,_e),E=be(m,xe,me),I=b-Se,T=E-Se,B=m>=xe-4&&m<=me+4,D="";D=(F=_>=he-4&&_<=_e+4)&&B?u.getBentArrowPath(j,I,P,T):F&&!B?"M ".concat(j,",").concat(I," L ").concat(x,",").concat(I," L ").concat(x,",").concat(T):!F&&B?"M ".concat(x,",").concat(I," L ").concat(x,",").concat(T," L ").concat(P,",").concat(T):"M ".concat(x,",").concat(I," L ").concat(x,",").concat(T),ve.push({id:S,pathD:D,style:h,leftIdx:w,rhsArrayIdx:N})}}),Ke.current=pe}He(ve)}else He([]),Ke.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{vn.current=!1}}},[Hn,Ln,Gn,Qe,Cn,kt,Mt,de,Ae,je,Me,ht,xt]),Gt=t.useCallback(function(){var e,n,t,i,o,l,r,c,a,s,d,v,g,f,p=Ke.current;if(p.length&&!ze.current){var h=null!==(n=null===(e=dn.current)||void 0===e?void 0:e.scrollTop)&&void 0!==n?n:0,x=null!==(i=null===(t=rn.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,_=null!==(l=null===(o=dn.current)||void 0===o?void 0:o.clientHeight)&&void 0!==l?l:1/0,m=null!==(c=null===(r=rn.current)||void 0===r?void 0:r.clientHeight)&&void 0!==c?c:1/0,R=null!==(s=null===(a=dn.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==s?s:0,y=null!==(v=null===(d=rn.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==v?v:0,S=R+_,b=y+m,A=null!==(f=null===(g=Et.current)||void 0===g?void 0:g.getBoundingClientRect().top)&&void 0!==f?f:0,E=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=Ye.current[e.styleId+"-stroke"],o=Ye.current[e.styleId+"-bg"];if(i||o){var l,r=E(n,R,S),c=E(t,y,b),a=r-A,s=c-A,d=n>=R-4&&n<=S+4,v=t>=y-4&&t<=b+4,g=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(g,",").concat(a," L ").concat(g,",").concat(s):!d&&v?"M ".concat(g,",").concat(a," L ").concat(g,",").concat(s," L ").concat(e.x2,",").concat(s):"M ".concat(g,",").concat(a," L ").concat(g,",").concat(s),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",l)),o&&(o.setAttribute("visibility","visible"),o.setAttribute("d",l))}})}},[]);t.useEffect(function(){$e.current=Lt},[Lt]);var Ht=t.useRef(null),qt=t.useRef(null),zt=t.useCallback(function(){Ke.current.length>0&&!ze.current||(null!==Ht.current&&clearTimeout(Ht.current),Ht.current=setTimeout(function(){$e.current(),Ht.current=null},50))},[]),Wt=t.useCallback(function(){we(!0),De(!1),null!==qt.current&&clearTimeout(qt.current),null!==Ht.current&&(clearTimeout(Ht.current),Ht.current=null),qt.current=setTimeout(function(){var e,n,t,i,o,l,r,c,a,s;if(Ke.current=[],Xe.current&&null!==Je.current&&null!==Tt.current){var d=Je.current,v=Tt.current,g=null,f=null,p=null,h=null;if("string"==typeof d&&d.includes(u.DEVIATION_BADGE_SEPARATOR)){var x=d.split(u.DEVIATION_BADGE_SEPARATOR),_="".concat(x[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(x[1]);g=(null===(e=Qn.current[_])||void 0===e?void 0:e.current)||null,f=(null===(n=Zn.current[_])||void 0===n?void 0:n.current)||null,p=(null===(t=nt.current[x[2]])||void 0===t?void 0:t.current)||(null===(i=Jn.current[Number(x[2])])||void 0===i?void 0:i.current)||null,h=(null===(o=tt.current[x[3]])||void 0===o?void 0:o.current)||(null===(l=$n.current[Number(x[3])])||void 0===l?void 0:l.current)||null}else g=(null===(r=it.current[d])||void 0===r?void 0:r.current)||null,p=(null===(c=Jn.current[d])||void 0===c?void 0:c.current)||null,f=(null===(a=et.current[v])||void 0===a?void 0:a.current)||null,h=(null===(s=$n.current[v])||void 0===s?void 0:s.current)||null;if(g&&f&&p&&h){if(p.style.paddingTop="0px",h.style.paddingTop="0px",!de){var m=g.getBoundingClientRect(),R=f.getBoundingClientRect(),y=m.top-R.top;y>0?h.style.paddingTop="".concat(y,"px"):y<0&&(p.style.paddingTop="".concat(Math.abs(y),"px"))}var S=dn.current,b=rn.current;if(S&&b){var A=g.getBoundingClientRect().top-S.getBoundingClientRect().top+S.scrollTop,E=f.getBoundingClientRect().top-b.getBoundingClientRect().top+b.scrollTop-(A-S.scrollTop);Math.abs(b.scrollTop-E)>1&&(b.scrollTop=E)}}}$e.current(),Xe.current&&De(!0),we(!1),qt.current=null},150)},[de,Ln,Gn]),Yt=t.useCallback(function(e){var n,t,i,o,l,r,c,a,s,d;if(null!==gn.current&&fn.current&&Math.abs(e.currentTarget.scrollTop-gn.current)<=2){var v=fn.current;gn.current=null,fn.current=null,v()}if(!Fe.current){if(de||zt(),Xe.current){var g=Je.current,f=Tt.current,p=dn.current,h=rn.current;if(null!==g&&null!==f&&p&&h){var x="string"==typeof g&&g.includes(u.DEVIATION_BADGE_SEPARATOR)?null===(n=Qn.current["".concat(g.split(u.DEVIATION_BADGE_SEPARATOR)[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(g.split(u.DEVIATION_BADGE_SEPARATOR)[1])])||void 0===n?void 0:n.current:null===(t=it.current[g])||void 0===t?void 0:t.current,_="string"==typeof f&&f.includes(u.DEVIATION_BADGE_SEPARATOR)?null===(i=Zn.current["".concat(f.split(u.DEVIATION_BADGE_SEPARATOR)[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(f.split(u.DEVIATION_BADGE_SEPARATOR)[1])])||void 0===i?void 0:i.current:null===(o=et.current[f])||void 0===o?void 0:o.current;if(x&&_&&Bt.current){var m=void 0,R=void 0;if("string"==typeof g&&g.includes(u.DEVIATION_BADGE_SEPARATOR)){var y=g.split(u.DEVIATION_BADGE_SEPARATOR),S="".concat(y[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(y[1]);m=null===(l=Qn.current[S])||void 0===l?void 0:l.current,R=null===(r=Zn.current[S])||void 0===r?void 0:r.current}else m=null===(c=Qn.current[g])||void 0===c?void 0:c.current,R=null===(a=Zn.current[f])||void 0===a?void 0:a.current;var b=null!==(d=null===(s=Et.current)||void 0===s?void 0:s.getBoundingClientRect().top)&&void 0!==d?d:0,A=p.getBoundingClientRect().top,E=A+p.clientHeight;h.getBoundingClientRect().top;h.clientHeight;if(m&&R){var I=m.getBoundingClientRect(),T=R.getBoundingClientRect(),B=I.top+I.height/2;T.top,T.height;var D=((O=B,w=A,N=E,Math.max(w,Math.min(N,O)))-b).toString();Bt.current.setAttribute("y1",D),Bt.current.setAttribute("y2",D);var C=B>=A-4&&B<=E+4;Bt.current.setAttribute("visibility",C?"visible":"hidden")}}}}var O,w,N;Ke.current.length>0&&!Ue.current&&(Ue.current=!0,requestAnimationFrame(function(){Gt(),Ue.current=!1}))}},[Gt,de,zt]);t.useEffect(function(){var e=setTimeout(zt,250);window.addEventListener("resize",Wt);var n=null,t=null;return on.current&&(n=new ResizeObserver(zt)).observe(on.current),Et.current&&(t=new ResizeObserver(zt)).observe(Et.current),function(){clearTimeout(e),null!==Ht.current&&clearTimeout(Ht.current),null!==qt.current&&clearTimeout(qt.current),window.removeEventListener("resize",Wt),null==n||n.disconnect(),null==t||t.disconnect()}},[Mn,Vn,ut,Hn,ht,xt,Ln,Gn,Cn,zt,Wt,Ae,je,Be,Me]),t.useEffect(function(){Xe.current=Ae},[Ae]),t.useEffect(function(){Je.current=je},[je]);var Kt=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";Dn(),null!=e&&(n?Se("No counterpart exists for this section."):Ae&&je===e?l?ft():null==r||r():(Ve(new Set([e])),He([]),Ke.current=[],me(!0),Fe.current=!0,Pe(e),Je.current=e,Ee(!0),Xe.current=!0,De(!1),un.current&&(un.current.style.height="0px"),cn.current&&(cn.current.style.height="0px"),an.current&&(an.current.style.height="0px"),sn.current&&(sn.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 g=e.split(u.DEVIATION_BADGE_SEPARATOR),f="".concat(g[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(g[1]);s=(null===(n=Qn.current[f])||void 0===n?void 0:n.current)||null,d=(null===(t=Zn.current[f])||void 0===t?void 0:t.current)||null,v=d?e:null}else if(s=(null===(i=it.current[e])||void 0===i?void 0:i.current)||null,de){var p=Ln[e],h=(null==p?void 0:p.refIndexes)||[];if(h.length>0){var x=h[0],_=Gn.findIndex(function(e){return e.selfIndex===x});-1!==_&&(d=(null===(l=et.current[_])||void 0===l?void 0:l.current)||null,v=_)}}else d=(null===(o=et.current[e])||void 0===o?void 0:o.current)||null,v=d?e:null;Tt.current=v;var m=dn.current,R=rn.current,y=function(){!function(){var n,t,i,o,l,r,c,s,d,g,f,p,h=null,x=null,_=null,m=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=nt.current[R[2]])||void 0===n?void 0:n.current)||(null===(t=Jn.current[Number(R[2])])||void 0===t?void 0:t.current)||null,x=(null===(i=tt.current[R[3]])||void 0===i?void 0:i.current)||(null===(o=$n.current[Number(R[3])])||void 0===o?void 0:o.current)||null,_=(null===(l=Qn.current[y])||void 0===l?void 0:l.current)||h,m=(null===(r=Zn.current[y])||void 0===r?void 0:r.current)||x}else{var S=Number(e),b=null!==v?Number(v):S;h=(null===(c=Jn.current[S])||void 0===c?void 0:c.current)||null,x=(null===(s=$n.current[b])||void 0===s?void 0:s.current)||null,_=(null===(d=Qn.current[S])||void 0===d?void 0:d.current)||(null===(g=it.current[S])||void 0===g?void 0:g.current)||h,m=(null===(f=Zn.current[b])||void 0===f?void 0:f.current)||(null===(p=et.current[b])||void 0===p?void 0:p.current)||x}if(_&&m&&h&&x){h.style.paddingTop="0px",x.style.paddingTop="0px";var A=_.getBoundingClientRect(),E=m.getBoundingClientRect(),I=A.top-E.top;I>0?x.style.paddingTop="".concat(I,"px"):I<0&&(h.style.paddingTop="".concat(Math.abs(I),"px"))}}(),De(!0),$e.current&&$e.current(),Fe.current=!1,"right"===c&&R?R.dispatchEvent(new Event("scroll")):m&&m.dispatchEvent(new Event("scroll")),me(!1),null==r||r()};if(!s||!m)return Fe.current=!1,me(!1),void(null==r||r());if(d&&R){if(!de){var S=0;S="right"===c?d?d.getBoundingClientRect().top:0:s?s.getBoundingClientRect().top:0;var b=on.current,A=(null==b?void 0:b.getBoundingClientRect().top)||0,E=b?b.scrollTop+S-A-150:0;return b?void u.smoothScrollTo(b,E,200,y):void y()}var I=s.getBoundingClientRect().top-m.getBoundingClientRect().top+m.scrollTop,T=d.getBoundingClientRect().top-R.getBoundingClientRect().top+R.scrollTop,B=200;if("left"===c){var D=T-(I-m.scrollTop);D<0&&un.current&&(un.current.style.height="".concat(Math.abs(D),"px")),requestAnimationFrame(function(){var e,n=R.scrollHeight-R.clientHeight;if(D<0)e=0;else{if(D>n){var t=D-n;return cn.current&&(cn.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){u.smoothScrollTo(R,D,B,y)})}e=D}u.smoothScrollTo(R,e,B,y)})}else{var C=I-(T-R.scrollTop);C<0&&an.current&&(an.current.style.height="".concat(Math.abs(C),"px")),requestAnimationFrame(function(){var e,n=m.scrollHeight-m.clientHeight;if(C<0)e=0;else{if(C>n){var t=C-n;return sn.current&&(sn.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){u.smoothScrollTo(m,C,B,y)})}e=C}u.smoothScrollTo(m,e,B,y)})}}else y()})))},[je,Dn,Gn,Ae,de,Ln,ft]),Ut=t.useCallback(function(e,n,t,i){var o,l="string"==typeof i?u.safeStringify(i).trim():u.safeStringify(null==i?void 0:i.deviation_summary).trim(),r=e.currentTarget;Bn();var c="left";(null===(o=rn.current)||void 0===o?void 0:o.contains(r))&&(c="right");var a=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"===c?null===(e=Zn.current[r])||void 0===e?void 0:e.current:null===(t=Qn.current[r])||void 0===t?void 0:t.current}return"right"===c?null===(i=Zn.current[n])||void 0===i?void 0:i.current:null===(o=Qn.current[n])||void 0===o?void 0:o.current};if(t)return ft(),Ve(new Set),He([]),Ke.current=[],void(l&&requestAnimationFrame(function(){var e=a()||r;An({open:!0,anchorEl:e,summary:i})}));Kt(n,t,l?{toggleIfSame:!1,sourceSide:c,onReady:function(){var e=a()||r;An({open:!0,anchorEl:e,summary:i})}}:{toggleIfSame:!1,sourceSide:c})},[Kt,Bn,An,ft]),Xt=t.useCallback(function(){var e,n=_n.sectionIdx,t=_n.isOrphan;if(En(),null!=n){var i="left";_n.anchorEl&&(null===(e=rn.current)||void 0===e?void 0:e.contains(_n.anchorEl))&&(i="right"),Kt(n,t,{sourceSide:i})}},[Kt,_n.isOrphan,_n.sectionIdx,_n.anchorEl,En]),Jt=t.useCallback(function(){En(),ft(),Ve(new Set),He([]),Ke.current=[]},[En,ft]),$t=null!==_n.sectionIdx&&Me.has(_n.sectionIdx),Qt=_.useDeviationNavigation({proposedSections:Ln,existingSections:Gn,parentDeviationRecord:qn,expandedSections:ht,maintainRelativeOrder:!!de,scrollContainerRef:on,leftContainerRef:dn,lhsBadgeRefs:Qn,rhsBadgeRefs:Zn}),Zt=Qt.showDeviationNavigation,ei=Qt.showOpenNodeRef,ni=t.useMemo(function(){if(!ce)return null;var e=ce.split(":")[0];for(var n in qn){if((qn[n]||[]).some(function(n){return n.id===e}))return n}return null},[ce,qn]),ti=t.useRef(null),ii=t.useRef(null);t.useEffect(function(){if(ce&&ti.current!==ce){var n=ce.split(":"),t=n[0],i=n[1],o=null!=i?i:"0";ii.current!==ce&&(En(),Bn(),ft(),Ve(new Set),He([]),Ke.current=[],ii.current=ce);var l=!1,r=0,c=null,a=150,s=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},d=function(){var n,i,v,g;if(!l){var f=null,p=null;for(var h in qn){var x=qn[h].find(function(e){return e.id===t});if(x){f=h,p=x;break}}if(p&&f){var _=Ln.findIndex(function(e){return e.id===f}),m=Gn.findIndex(function(e){return e.id===f}),R=-1===_&&-1!==m,y=s(Ln,p.id),S=s(Gn,p.id);if(y&&!S&&!R){var b=y.split("-"),A=Number(b[0]);if(de){var E=null===(i=null===(n=Ln[A])||void 0===n?void 0:n.refIndexes)||void 0===i?void 0:i[0],I=Gn.findIndex(function(e){return e.selfIndex===E});-1!==I&&(A=I)}S=e.__spreadArray([A],b.slice(1),!0).join("-")}if(y||S){var T=R||!y&&!!S,B=y?Number(y.split("-")[0]):_,D=S?Number(S.split("-")[0]):m;if(T){if(!(de?!!ht["right-".concat(D)]:!!ht[String(D)])&&D>=0)return mt(D,"right"),r+=1,void(c=setTimeout(d,450))}else if(!(de?!!ht["left-".concat(B)]:!!ht[String(B)])&&B>=0)return mt(B,"left"),r+=1,void(c=setTimeout(d,450));var C,O=y||"",w=S||"",N="".concat(p.id).concat(u.DEVIATION_BADGE_SEPARATOR).concat(o).concat(u.DEVIATION_BADGE_SEPARATOR).concat(O).concat(u.DEVIATION_BADGE_SEPARATOR).concat(w),j="".concat(p.id).concat(u.DEVIATION_BADGE_SEPARATOR).concat(o),P=null===(v=Qn.current[j])||void 0===v?void 0:v.current,F=null===(g=Zn.current[j])||void 0===g?void 0:g.current,k=T||!P&&!!F,M=k?F:P;if(C=de?k?rn.current:dn.current:on.current,M&&C){var V=M.getBoundingClientRect();if(0===V.height)return void((r+=1)<20&&(c=setTimeout(d,a)));var L=C.getBoundingClientRect(),G=V.top-L.top+C.scrollTop-L.height/2+V.height/2,H=function(){var n,t,i,r,u;if(!l){ti.current=ce;var c=window.getComputedStyle(M).color;P&&(P.style.transition="box-shadow 300ms ease-in-out",P.style.boxShadow="0 0 10px ".concat(c)),F&&(F.style.transition="box-shadow 300ms ease-in-out",F.style.boxShadow="0 0 10px ".concat(c)),setTimeout(function(){P&&(P.style.boxShadow=""),F&&(F.style.boxShadow="")},2e3);var a=(null===(t=null===(n=p.evaluationResult)||void 0===n?void 0:n.deviations)||void 0===t?void 0:t[o])||p,s=(null===(i=p.evaluationResult)||void 0===i?void 0:i.evaluation_outputs)||p.evaluation_outputs;if(!(!!P&&!!F)){var d=k?(null===(r=Zn.current[j])||void 0===r?void 0:r.current)||F:(null===(u=Qn.current[j])||void 0===u?void 0:u.current)||P;return An({open:!0,anchorEl:d,summary:e.__assign(e.__assign({},a),{evaluation_outputs:s})}),void(null==ae||ae())}Kt(N,!1,{toggleIfSame:!1,sourceSide:"left",onReady:function(){var n,t=(null===(n=Qn.current[j])||void 0===n?void 0:n.current)||P;An({open:!0,anchorEl:t,summary:e.__assign(e.__assign({},a),{evaluation_outputs:s})})}})}};Math.abs(C.scrollTop-G)<=2?H():(gn.current=G,fn.current=H,C.scrollTo({top:G,behavior:"smooth"}),c&&clearTimeout(c),c=setTimeout(function(){if(fn.current){gn.current=null;var e=fn.current;fn.current=null,e()}},800))}else(r+=1)<20&&(c=setTimeout(d,a))}else(r+=1)<20&&(c=setTimeout(d,a))}else(r+=1)<20&&(c=setTimeout(d,a))}};return c=setTimeout(d,a),function(){l=!0,c&&clearTimeout(c)}}},[ce,qn,Ln,Gn,de,ht,mt,Kt,An]);var oi=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;return n.jsx(y.default,{section:t,keyPath:i,depth:l,columnKey:u,parentNodeId:a,expandedSubSections:xt,setExpandedSubSections:_t,maintainRelativeOrder:de||!1,proposedSections:Ln,existingSections:Gn,treeData:Q,deviationNumberRegistry:zn,connectedSections:Me,activeSideBySideSection:je,resolvedMarkdownStyles:tn,getSubSectionRef:lt,getSubSectionCompareStyle:Vt,getBadgeRef:rt,openMoreFunctionsPopup:St,openSummaryPopup:Ut,showDeviationBadges:ge,resetSideBySide:ft,setConnectedSections:Ve,setConnectedLines:He,cachedConnectedPositions:Ke})};return n.jsxs(i.Box,e.__assign({ref:ln,sx:e.__assign(e.__assign({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},de?{}:{overflow:"visible"}),{position:"relative"})},{children:[pe&&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,{})})),bn.open&&n.jsx(S.default,{open:bn.open,anchorEl:bn.anchorEl,containerEl:It.current,clipTopEl:Dt.current,scrollContainerEl:on.current,onClose:Jt,summary:bn.summary}),n.jsx(d.default,{open:_n.open,anchorEl:_n.anchorEl,sectionTitle:_n.sectionTitle,referenceSectionTitle:_n.refSectionTitle,onClose:Dn,onOpenCognitiveCompare:bt,onOpenSideBySide:Xt,onConnect:At,isConnected:$t,isOrphan:_n.isOrphan}),hn.open&&n.jsx(s.default,{open:hn.open,popupRef:Tn,position:Rn,popupConfig:le,onClose:function(){yn(null),xn(function(n){return e.__assign(e.__assign({},n),{open:!1})}),In(null)},markdownStyles:te,sectionTitle:hn.sectionTitle,referenceSectionTitle:hn.refSectionTitle,cognitiveData:hn.cognitiveData,anchorEl:hn.anchorEl,sectionAnchorEl:hn.sectionAnchorEl,scrollContainerEl:on.current,badgeStyle:hn.badgeStyle,docData:hn.docData,deviationData:hn.deviationData,isLoading:hn.isLoading}),n.jsx(i.Snackbar,e.__assign({open:!!ye,autoHideDuration:8e3,onClose:function(){return Se(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(i.Alert,e.__assign({onClose:function(){return Se(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:ye}))})),n.jsx(m.default,{componentHeaderText:$,displayConfig:oe,maintainRelativeOrder:de,onToggleView:function(e){he(!0),setTimeout(function(){ve(!e),ft(),En(),Ve(new Set),He([]),Ke.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){he(!1)},600)})})},50)}}),n.jsx(i.Box,e.__assign({ref:on,onScroll:Yt,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:de?"hidden":"auto",borderTop:ct&&at?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(i.Box,e.__assign({sx:e.__assign({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},de?{flex:1,minHeight:0}:{})},{children:n.jsxs(i.Box,e.__assign({ref:Et,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"40px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},de?{flex:1,overflow:"visible"}:{})},{children:[n.jsxs("svg",e.__assign({ref:qe,style:{position:"absolute",top:0,left:0,width:en.width||"100%",height:en.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",opacity:Oe?0:1,transition:"opacity 0.15s ease-in-out"}},{children:[Pt&&n.jsx("g",{children:n.jsx("line",{x1:Pt.x1,y1:Pt.y,x2:Pt.x2,y2:Pt.y,stroke:gt.badgeBorder,strokeWidth:"1.5"})}),wt.map(function(t){var r,c,s,d,v,f,p=t.x1+.5*(t.x2-t.x1),h=(t.y1+t.y2)/2;if("Not Defined"===t.style.label&&!t.hasCognitive)return null;if(t.isSubSection?Ae&&je===t.subSectionKeyPath&&Be:Ae&&je===t.sectionIdx&&Be)return null;if(!de){var x=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),_=Ln[t.sectionIdx]||{title:"",content:""},m=Gn[t.sectionIdx]||{title:"",content:""};if(console.log("Base and Ref Sections for Badge:",_,m),t.isSubSection&&t.subSectionKeyPath){var R=t.subSectionKeyPath.includes(u.DEVIATION_BADGE_SEPARATOR)?t.subSectionKeyPath.split(u.DEVIATION_BADGE_SEPARATOR):[],y=R[2]||t.subSectionKeyPath,S=R[3]||y,b=y.split("-").map(Number),A=S.split("-").map(Number),E=null,I=null;b.length>0&&(E=Ln[b[0]]),A.length>0&&(I=Gn[A[0]]);var T=(null==E?void 0:E.title)||"",B=(null==I?void 0:I.title)||"";console.log("Root Parent Titles:",T,B);for(var D=1;D<b.length;D++)(null==E?void 0:E.subsections)&&(E=E.subsections[b[D]]);for(D=1;D<A.length;D++)(null==I?void 0:I.subsections)&&(I=I.subsections[A[D]]);E&&(_=e.__assign(e.__assign({},E),{title:T||E.title})),console.log("Base Section for Subsection Badge:",_),I&&(m=e.__assign(e.__assign({},I),{title:B||I.title})),console.log("Ref Section for Subsection Badge:",m)}var C=!(null===(r=_.cognitiveData)||void 0===r?void 0:r.isMissingRationale)||Boolean(null===(s=null===(c=_.cognitiveData)||void 0===c?void 0:c.decisioning)||void 0===s?void 0:s.length),O=(null===(f=null===(v=null===(d=_.evaluationResult)||void 0===d?void 0:d.cognitive_decisioning)||void 0===v?void 0:v.decisioning_factors)||void 0===f?void 0:f.length)||!1,w=C||O;return n.jsxs("g",{children:[n.jsx("path",{d:x,fill:"none",stroke:t.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),n.jsx("foreignObject",e.__assign({x:p-100,y:h-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(),w&&(hn.open&&Sn===t.id?Bn():(In(t.id),yt(Rt(e.currentTarget,_,m,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:w?"pointer":"default"}},{children:[t.style.badgeText===a.DEFAULT_DEVIAION_COLOR&&null==t.style.label?n.jsx(g.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,{})})),w&&n.jsx(o.ChevronDown,{size:11,style:{transform:hn.open&&Sn===t.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},t.id)}return null}),Ge.map(function(t){var i,o=t.pathD,l=(null===(i=t.style)||void 0===i?void 0:i.badgeBorder)||"#6366F1",r="conn-marker-".concat(t.id),u="".concat(t.id,"-bg"),c="".concat(t.id,"-stroke");return n.jsxs("g",{children:[n.jsx("defs",{children:n.jsx("clipPath",e.__assign({id:"connections-clip"},{children:n.jsx("marker",e.__assign({id:r,markerWidth:"8",markerHeight:"6",refX:"7",refY:"3",orient:"auto"},{children:n.jsx("polygon",{points:"0 0, 8 3, 0 6",fill:l})}))}))}),n.jsx("path",{ref:function(e){Ye.current[u]=e},d:o,fill:"none",stroke:"#FFFFFF",strokeWidth:"4",strokeOpacity:"0.7"}),n.jsx("path",{ref:function(e){Ye.current[c]=e},d:o,fill:"none",stroke:l,strokeWidth:"1.75",markerEnd:"url(#".concat(r,")")})]},t.id)})]})),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)"},de?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(i.Box,e.__assign({ref:Dt,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:Pn,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:Pn}))}))})),n.jsxs(i.Box,e.__assign({ref:dn,onScroll:Yt,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},de?{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:an,style:{width:"100%",height:"0px",flexShrink:0}}),Yn&&Ln.map(function(t,l){var r,c,a=!t.title&&!t.content;if(de&&a)return null;var s=t,d=Mt(l,"left"),v=de?!(null===(r=s.refIndexes)||void 0===r?void 0:r.length)||s.selfIndex<0:!Gn[l],f=de?"number"==typeof s.selfIndex&&s.selfIndex>=0?s.selfIndex+1:null:l+1,p=Me.has(l),h=u.extractDeviationScore(s.evaluationResult,null==d?void 0:d.deviationLabel);return n.jsx(i.Box,e.__assign({ref:ot(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:Jn.current[l],sx:e.__assign({width:"100%",display:"flex"},p&&{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:ot("left-accordion-".concat(l)),mb:0,treeData:Q,proposedSections:Ln,existingSections:Gn,deviationNumberRegistry:zn,getSectionCompareStyle:Mt,getBadgeRef:rt,connectedSections:Me,openMoreFunctionsPopup:St,openSummaryPopup:Ut,deviationNodeIdToView:ce,deviationTargetParentId:ni,parentNodeId:(null===(c=null==Q?void 0:Q.input_index_map)||void 0===c?void 0:c[0])||"",isExpanded:de?!!ht["left-".concat(l)]:!!ht[String(l)],onToggle:function(){Jt(),mt(l,"left")},navigation:t.id?Zt[t.id]:null,showOpenNodeRef:ei,resolvedMarkdownStyles:tn,maintainRelativeOrder:de,showDeviationBadges:ge,renderSubSections:oi})})),de&&d&&n.jsxs(i.Box,e.__assign({ref:Qn.current[l],onClick:function(e){var n=de?Gn.find(function(e){var n;return null===(n=s.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""}:Gn[l]||{title:"",content:""};St(e,t,v,n,l,d)},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:.4,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[null!==f&&n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(d.badgeBorder)}},{children:f})),n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",px:.25}},{children:!oe.isLoading||null!=s.evaluationResult&&null!=s.evaluationResult?v?"No Deviation Found":"N/A"===h||"NA"===h?"N/A":0==h||null==h?"Same":"".concat(h):n.jsx(g.default,{color:d.badgeText})})),n.jsx(o.EllipsisVertical,{size:11,color:d.badgeText})]}))]}))}),"left-row-".concat(l))}),n.jsx("div",{ref:sn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),n.jsx(i.Box,e.__assign({ref:It,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(),hn.open&&Sn===st?Bn():(In(st),yt(Rt(n.currentTarget,{title:"",content:"",evaluationResult:dt,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,st,!0,e.__assign(e.__assign({},gt),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-5px",borderRadius:"20px",bgcolor:gt.badgeBg,color:gt.badgeText,border:"1px solid ".concat(gt.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=vt?vt:n.jsx(g.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:hn.open&&Sn===st?"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},de?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[_e&&n.jsx(r.default,{sections:11}),n.jsx(i.Box,e.__assign({ref:Ct,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:Fn,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:Fn}))}))})),n.jsxs(i.Box,e.__assign({ref:rn,onScroll:Yt,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},de?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-120px",pl:"140px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:un,style:{width:"100%",height:"0px",flexShrink:0}}),Yn&&Gn.map(function(t,o){var l,r=t,u=[],c=!1,a=null,s=-1;if(de){u=Ln.filter(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(r.selfIndex))&&e.selfIndex>=0}).map(function(e){return e.selfIndex+1}),s=Ln.findIndex(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(r.selfIndex))&&e.selfIndex>=0});var d=Ln.findIndex(function(e,n){var t;return Me.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(r.selfIndex))});(c=-1!==d)&&(a=Mt(d))}else u=[o+1],(c=Me.has(o))&&(a=Mt(o));var v=Mt(de&&-1!==s?s:o);return n.jsx(i.Box,e.__assign({ref:et.current[o],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:$n.current[o],sx:e.__assign({width:"100%",display:"flex"},c&&a&&{borderRadius:"6px",outline:"2px solid ".concat(a.badgeBorder),outlineOffset:"1px"})},{children:n.jsx(R.default,{section:t,idx:o,columnKey:"right",colRef:ot("right-accordion-".concat(o)),mb:0,parentNodeId:(null===(l=null==Q?void 0:Q.input_index_map)||void 0===l?void 0:l[1])||"",isExpanded:de?!!ht["right-".concat(o)]:!!ht[String(o)],treeData:Q,proposedSections:Ln,existingSections:Gn,deviationNumberRegistry:zn,getBadgeRef:rt,getSectionCompareStyle:Mt,connectedSections:Me,openMoreFunctionsPopup:St,openSummaryPopup:Ut,deviationNodeIdToView:ce,deviationTargetParentId:ni,onToggle:function(){Jt(),mt(o,"right")},navigation:t.id?Zt[t.id]:null,showOpenNodeRef:ei,resolvedMarkdownStyles:tn,maintainRelativeOrder:de,showDeviationBadges:ge,renderSubSections:oi})})),de&&v&&n.jsx(i.Box,e.__assign({ref:Zn.current[o],"data-section-id":r.id,sx:{position:"absolute",top:"18px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"11px",bgcolor:v.badgeBg,color:v.badgeText,border:"1px solid ".concat(v.badgeBorder),borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:u.length>0?u.join(", "):"-"}))]}))}),"right-row-".concat(o))}),n.jsx("div",{ref:cn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))};
2
2
  //# sourceMappingURL=CognitiveCompare.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),n=require("@mui/material"),o=require("lucide-react"),i=require("react");exports.default=function(r){var l,a,s,c=r.open,d=r.anchorEl,u=r.containerEl,p=r.clipTopEl,x=r.scrollContainerEl,g=r.onClose,m=r.summary;r.markdownStyles,r.isLoading;var f=i.useRef(null),h=i.useRef(null),v=i.useState(null),_=v[0],b=v[1],y=i.useState(null),w=y[0],j=y[1],C=i.useState(null),S=C[0],B=C[1],R=i.useState(0),z=R[0],E=R[1],A="string"==typeof m?{deviation_summary:m}:null!=m?m:{};A.deviation_title;var I=A.deviation_summary,T=A.deviation_impact,W=A.evaluation_outputs,M=!!String(T||"").trim(),q=(null===(l=null==W?void 0:W.metadata)||void 0===l?void 0:l.label_color)||"#6366F1",H=null!==(a=null==u?void 0:u.getBoundingClientRect().width)&&void 0!==a?a:180,k=Math.max(148,H+70),L=d&&u?{top:d.getBoundingClientRect().top,bottom:d.getBoundingClientRect().bottom,left:u.getBoundingClientRect().left+u.getBoundingClientRect().width/2}:null;i.useEffect(function(){if(!c||!d||!u)return b(null),j(null),void B(null);var e=function(){null!==f.current&&cancelAnimationFrame(f.current),f.current=requestAnimationFrame(function(){var e,t,n=d.getBoundingClientRect(),o=u.getBoundingClientRect(),i=null==p?void 0:p.getBoundingClientRect(),r=null==x?void 0:x.getBoundingClientRect();b({top:n.top,bottom:n.bottom,left:o.left+o.width/2}),j(null!==(e=null==i?void 0:i.bottom)&&void 0!==e?e:null),B(null!==(t=null==r?void 0:r.bottom)&&void 0!==t?t:null),h.current&&E(h.current.offsetHeight)})};e();var t=!0;return window.addEventListener("scroll",e,{passive:!0,capture:t}),window.addEventListener("resize",e),function(){null!==f.current&&cancelAnimationFrame(f.current),window.removeEventListener("scroll",e,t),window.removeEventListener("resize",e)}},[c,d,u,p,x]);var P=null!==(s=null!=_?_:L)&&void 0!==s?s:{top:0,bottom:0,left:0},F=P.bottom+20,D=F+z,O=null!=w?Math.max(0,w-F):0,N=null!=S?Math.max(0,D-S):0,G=O>0||N>0;return m?t.jsx(n.Popper,e.__assign({open:c,disablePortal:!0,popperOptions:{strategy:"fixed"},anchorEl:{getBoundingClientRect:function(){return{width:0,height:P.bottom-P.top,top:P.top,bottom:P.bottom,left:P.left,right:P.left,x:P.left,y:P.top,toJSON:function(){}}}},placement:"bottom",modifiers:[{name:"offset",options:{offset:[0,20]}}],sx:{zIndex:20}},{children:t.jsxs(n.Paper,e.__assign({ref:h,sx:e.__assign(e.__assign({p:1.5,borderRadius:"12px",width:k,maxWidth:k},G&&{clipPath:"inset(".concat(O,"px 0 ").concat(N-150,"px 0 round 12px)")}),{transition:"transform 80ms linear",willChange:"transform",backfaceVisibility:"hidden",transform:"translateZ(0)",boxShadow:"0px 10px 24px rgba(15, 23, 42, 0.18)",border:"1px solid ".concat(q,"26"),borderTop:"3px solid ".concat(q),overflow:"hidden",bgcolor:"#fff"})},{children:[t.jsxs(n.Box,e.__assign({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.75}},{children:[t.jsxs(n.Box,e.__assign({sx:{display:"flex",alignItems:"center",gap:.75,minWidth:0}},{children:[t.jsx(o.Info,{size:14,color:q}),t.jsx(n.Typography,e.__assign({sx:{fontSize:"11px",fontWeight:700,color:q,textTransform:"uppercase",letterSpacing:"0.4px",lineHeight:1.2}},{children:"Summary"}))]})),t.jsx(n.IconButton,e.__assign({size:"small",onClick:g,sx:{p:.25,ml:.5,color:"#64748B"}},{children:t.jsx(o.X,{size:14})}))]})),t.jsxs(n.Box,e.__assign({sx:{display:"flex",flexDirection:"column",gap:1.5}},{children:[t.jsx(n.Typography,e.__assign({sx:{fontSize:"13px",color:"#334155",lineHeight:1.6,fontWeight:400,overflowWrap:"anywhere"}},{children:I||"No summary available."})),M&&t.jsxs(n.Accordion,e.__assign({disableGutters:!0,elevation:0,sx:{backgroundColor:"".concat(q,"0A"),border:"1px solid ".concat(q,"33"),borderRadius:"8px",overflow:"hidden","&:before":{display:"none"},"&.Mui-expanded":{margin:0}}},{children:[t.jsx(n.AccordionSummary,e.__assign({expandIcon:t.jsx(o.ChevronDown,{size:16,color:q}),sx:{minHeight:"10px",px:1.5,"& .MuiAccordionSummary-content":{py:"5px",my:0},"&.Mui-expanded":{minHeight:"10px",borderBottom:"1px solid ".concat(q,"1A")}}},{children:t.jsx(n.Typography,e.__assign({sx:{fontSize:"11px",fontWeight:700,color:q,textTransform:"uppercase",letterSpacing:"0.5px"}},{children:"Impact"}))})),t.jsx(n.AccordionDetails,e.__assign({sx:{p:1.5,backgroundColor:"#fff"}},{children:t.jsx(n.Typography,e.__assign({sx:{fontSize:"12px",color:"#475569",lineHeight:1.6,fontWeight:400,overflowWrap:"anywhere"}},{children:String(T).replace("Impact -","")}))}))]}))]}))]}))})):null};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),n=require("@mui/material"),o=require("lucide-react"),i=require("react");exports.default=function(r){var l,a,s,c=r.open,d=r.anchorEl,u=r.containerEl,p=r.clipTopEl,x=r.scrollContainerEl,g=r.onClose,f=r.summary;r.markdownStyles,r.isLoading;var m=i.useRef(null),h=i.useRef(null),v=i.useState(null),_=v[0],b=v[1],y=i.useState(null),w=y[0],S=y[1],j=i.useState(null),C=j[0],B=j[1],R=i.useState(0),z=R[0],E=R[1],W="string"==typeof f?{deviation_summary:f}:null!=f?f:{},A=W.deviation_title,T=W.deviation_summary,H=W.deviation_impact,I=W.evaluation_outputs,M=!!String(H||"").trim(),k=(null===(l=null==I?void 0:I.metadata)||void 0===l?void 0:l.label_color)||"#6366F1",q=null!==(a=null==u?void 0:u.getBoundingClientRect().width)&&void 0!==a?a:180,L=Math.max(148,q+70),P=d&&u?{top:d.getBoundingClientRect().top,bottom:d.getBoundingClientRect().bottom,left:u.getBoundingClientRect().left+u.getBoundingClientRect().width/2}:null;i.useEffect(function(){if(!c||!d||!u)return b(null),S(null),void B(null);var e=function(){null!==m.current&&cancelAnimationFrame(m.current),m.current=requestAnimationFrame(function(){var e,t,n=d.getBoundingClientRect(),o=u.getBoundingClientRect(),i=null==p?void 0:p.getBoundingClientRect(),r=null==x?void 0:x.getBoundingClientRect();b({top:n.top,bottom:n.bottom,left:o.left+o.width/2}),S(null!==(e=null==i?void 0:i.bottom)&&void 0!==e?e:null),B(null!==(t=null==r?void 0:r.bottom)&&void 0!==t?t:null),h.current&&E(h.current.offsetHeight)})};e();var t=!0;return window.addEventListener("scroll",e,{passive:!0,capture:t}),window.addEventListener("resize",e),function(){null!==m.current&&cancelAnimationFrame(m.current),window.removeEventListener("scroll",e,t),window.removeEventListener("resize",e)}},[c,d,u,p,x]);var F=null!==(s=null!=_?_:P)&&void 0!==s?s:{top:0,bottom:0,left:0},D=F.bottom+20,O=D+z,N=null!=w?Math.max(0,w-D):0,G=null!=C?Math.max(0,O-C):0,J=N>0||G>0;return f?t.jsx(n.Popper,e.__assign({open:c,disablePortal:!0,popperOptions:{strategy:"fixed"},anchorEl:{getBoundingClientRect:function(){return{width:0,height:F.bottom-F.top,top:F.top,bottom:F.bottom,left:F.left,right:F.left,x:F.left,y:F.top,toJSON:function(){}}}},placement:"bottom",modifiers:[{name:"offset",options:{offset:[0,20]}}],sx:{zIndex:20}},{children:t.jsxs(n.Paper,e.__assign({ref:h,sx:e.__assign(e.__assign({p:1.5,borderRadius:"12px",width:L,maxWidth:L},J&&{clipPath:"inset(".concat(N,"px 0 ").concat(G-150,"px 0 round 12px)")}),{transition:"transform 80ms linear",willChange:"transform",backfaceVisibility:"hidden",transform:"translateZ(0)",boxShadow:"0px 10px 24px rgba(15, 23, 42, 0.18)",border:"1px solid ".concat(k,"26"),borderTop:"3px solid ".concat(k),overflow:"hidden",bgcolor:"#fff"})},{children:[t.jsxs(n.Box,e.__assign({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.75}},{children:[t.jsxs(n.Box,e.__assign({sx:{display:"flex",alignItems:"center",gap:.75,minWidth:0}},{children:[t.jsx(o.Info,{size:14,color:k}),t.jsx(n.Typography,e.__assign({sx:{fontSize:"11px",fontWeight:700,color:k,textTransform:"uppercase",letterSpacing:"0.4px",lineHeight:1.2}},{children:"Summary"}))]})),t.jsx(n.IconButton,e.__assign({size:"small",onClick:g,sx:{p:.25,ml:.5,color:"#64748B"}},{children:t.jsx(o.X,{size:14})}))]})),t.jsxs(n.Box,e.__assign({sx:{display:"flex",flexDirection:"column",gap:1.5,maxHeight:"300px",overflowY:"auto",pr:.5}},{children:[t.jsxs(n.Box,{children:[A&&t.jsx(n.Typography,e.__assign({sx:{fontSize:"13px",color:k,lineHeight:1.6,fontWeight:500,overflowWrap:"anywhere"}},{children:A})),t.jsx(n.Typography,e.__assign({sx:{fontSize:"13px",color:"#334155",lineHeight:1.6,fontWeight:400,overflowWrap:"anywhere",whiteSpace:"pre-wrap"}},{children:T||"No summary available."}))]}),M&&t.jsxs(n.Accordion,e.__assign({disableGutters:!0,elevation:0,sx:{backgroundColor:"".concat(k,"0A"),border:"1px solid ".concat(k,"33"),borderRadius:"4px",overflow:"hidden",flexShrink:0,"&:before":{display:"none"},"&.Mui-expanded":{margin:0}}},{children:[t.jsx(n.AccordionSummary,e.__assign({expandIcon:t.jsx(o.ChevronDown,{size:16,color:k}),sx:{minHeight:"10px",px:1.5,"& .MuiAccordionSummary-content":{py:"5px",my:0},"&.Mui-expanded":{minHeight:"10px",borderBottom:"1px solid ".concat(k,"1A")}}},{children:t.jsx(n.Typography,e.__assign({sx:{fontSize:"11px",fontWeight:700,color:k,textTransform:"uppercase",letterSpacing:"0.5px"}},{children:"Impact"}))})),t.jsx(n.AccordionDetails,e.__assign({sx:{p:1.5,backgroundColor:"#fff"}},{children:t.jsx(n.Typography,e.__assign({sx:{fontSize:"12px",color:"#475569",lineHeight:1.6,fontWeight:400,overflowWrap:"anywhere",whiteSpace:"pre-wrap"}},{children:String(H).replace("Impact -","")}))}))]}))]}))]}))})):null};
2
2
  //# sourceMappingURL=CognitiveSummaryPopup.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var i=require("tslib"),e=require("react"),t=require("../CognitiveComparehelpers.js"),n={id:"",title:"",similarity:0,sections:[]};exports.useCognitiveTreeData=function(o,l,s,a,d){void 0===d&&(d=!0);var r=JSON.stringify(s||{}),u=e.useMemo(function(){var e,n,s,a;if(!o||0===Object.keys(o).length)return{activeProposed:{},activeVariants:[],parseError:"Tree data is required"};var u=JSON.parse(r);try{var v=o.nodes||o,c=[],_=[],f=o.base_root_id,p=o.input_index_map||{0:"left",1:"right"},b=o[f]||v[f];if(!b||!1===b.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[],parseError:null};var g=function(e){if(!e||"object"!=typeof e)return e||null;if(e.deviations)return e;if(!d)return e;var t=Object.keys(e).filter(function(i){return/^\d+$/.test(i)});if(!t.length)return e;var n=t.sort(function(i,e){return Number(i)-Number(e)}),o=null==p?void 0:p[0],l=null==p?void 0:p[1],s={},a={},r=null;return n.forEach(function(i){var t,n,d,u=e[i];if(u&&"object"==typeof u){r||(r=u);var v=(null===(n=null==u?void 0:u.deviation_highlights)||void 0===n?void 0:n[o])||[],c=(null===(d=null==u?void 0:u.deviation_highlights)||void 0===d?void 0:d[l])||[],_=v[0]||"",f=c[0]||"";s[i]=((t={})[o]=_,t[l]=f,t.deviation_summary=(null==u?void 0:u.deviation_summary)||"",t.deviation_title=null==u?void 0:u.deviation_title,t.deviation_impact=null==u?void 0:u.deviation_impact,t.deviation_explanation=null==u?void 0:u.deviation_explanation,t.evaluation_outputs=null==u?void 0:u.evaluation_outputs,t.cognitive_decisioning=null==u?void 0:u.cognitive_decisioning,t.deviation_highlights=null==u?void 0:u.deviation_highlights,t),a[i]=u}}),i.__assign(i.__assign({},e),{deviation_title:(null==r?void 0:r.deviation_title)||(null==e?void 0:e.deviation_title),deviation_impact:(null==r?void 0:r.deviation_impact)||(null==e?void 0:e.deviation_impact),deviation_summary:(null==r?void 0:r.deviation_summary)||(null==e?void 0:e.deviation_summary),deviation_explanation:(null==r?void 0:r.deviation_explanation)||(null==e?void 0:e.deviation_explanation),evaluation_outputs:(null==r?void 0:r.evaluation_outputs)||(null==e?void 0:e.evaluation_outputs),cognitive_decisioning:(null==r?void 0:r.cognitive_decisioning)||(null==e?void 0:e.cognitive_decisioning),deviations:s,deviation_entries:a})},m=function(e,n){var l,s,a,d=o[e]||v[e];if(!d||!1===d.display_node)return null;var r=t.getSideData(d,n,p),c=!1!==(null===(l=r.attributes)||void 0===l?void 0:l.display_title),_=!1!==(null===(s=r.attributes)||void 0===s?void 0:s.display_content),f=!!r.title.trim(),b=!!r.content.trim(),y=t.getRationale(d),x=(null===(a=null==u?void 0:u[e])||void 0===a?void 0:a.evaluation_result)||d.evaluation_result||null,h=g(x),I=[];d.next&&Object.values(d.next).forEach(function(i){var e=v[i];if(e&&!1!==e.display_node){var t=m(i,n);t&&I.push(t)}});var E=!(!f&&!b);return i.__assign(i.__assign({id:e,title:f?r.title:"",content:b?r.content:"",displayTitle:c,displayContent:_,subsections:I},E?y:{score:void 0,relation:"not_defined"}),{evaluationResult:h})};if(l){var y=function(e,n){var l,s,a,d,r,c,_,f,b,m,x,h,I,E,S,N,R,O,j,D,M;void 0===n&&(n=0);var P=[],T=[];if(!e)return{refSections:P,baseSections:T};var V={},A={},C=-1,k=-1;for(var q in e){var J=e[q],U=o[J]||v[J];if(U&&!1!==U.display_node){var w=t.getRationale(U),B=(null===(l=null==u?void 0:u[J])||void 0===l?void 0:l.evaluation_result)||U.evaluation_result||null,F=g(B),G=t.getSideData(U,"1",p),$=t.getSideData(U,"0",p),z=!1!==(null===(s=G.attributes)||void 0===s?void 0:s.display_title)&&G.title.trim()||!1!==(null===(a=G.attributes)||void 0===a?void 0:a.display_content)&&G.content.trim(),H=!1!==(null===(d=$.attributes)||void 0===d?void 0:d.display_title)&&$.title.trim()||!1!==(null===(r=$.attributes)||void 0===r?void 0:r.display_content)&&$.content.trim(),K=Number(null!==(_=null===(c=G.attributes)||void 0===c?void 0:c.display_index)&&void 0!==_?_:C--),L=Number(null!==(b=null===(f=$.attributes)||void 0===f?void 0:f.display_index)&&void 0!==b?b:k--),Q=V[K]||i.__assign(i.__assign({id:J,title:!1!==(null===(m=G.attributes)||void 0===m?void 0:m.display_title)?G.title:"",content:!1!==(null===(x=G.attributes)||void 0===x?void 0:x.display_content)?G.content:"",subsections:[]},z?w:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:K,evaluationResult:F,displayContent:null===(h=G.attributes)||void 0===h?void 0:h.display_content,displayTitle:null===(I=G.attributes)||void 0===I?void 0:I.display_title}),W=A[L]||i.__assign(i.__assign({id:J,title:!1!==(null===(E=$.attributes)||void 0===E?void 0:E.display_title)?$.title:"",content:!1!==(null===(S=$.attributes)||void 0===S?void 0:S.display_content)?$.content:"",subsections:[]},H?w:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:L,evaluationResult:F,displayContent:null===(N=$.attributes)||void 0===N?void 0:N.display_content,displayTitle:null===(R=$.attributes)||void 0===R?void 0:R.display_title});Number(K)>=0&&Number(L)>=0&&((null===(O=Q.refIndexes)||void 0===O?void 0:O.includes(Number(L)))||null===(j=Q.refIndexes)||void 0===j||j.push(Number(L)),(null===(D=W.refIndexes)||void 0===D?void 0:D.includes(Number(K)))||null===(M=W.refIndexes)||void 0===M||M.push(Number(K))),V[K]=Q,A[L]=W;var X=y(U.next,n+1),Y=X.refSections,Z=X.baseSections;Y.length>0&&(Q.subsections=i.__spreadArray(i.__spreadArray([],Q.subsections||[],!0),Y,!0)),Z.length>0&&(W.subsections=i.__spreadArray(i.__spreadArray([],W.subsections||[],!0),Z,!0))}}P=Object.values(V),T=Object.values(A);var ii=function(i,e){return i.selfIndex<0&&e.selfIndex>=0?1:i.selfIndex>=0&&e.selfIndex<0?-1:i.selfIndex-e.selfIndex};return P.sort(ii),T.sort(ii),{refSections:P,baseSections:T}},x=y(b.next),h=x.refSections,I=x.baseSections;_=h,c=I}else b.next&&Object.values(b.next).forEach(function(i){var e=o[i]||v[i];e&&!1!==e.display_node&&(c.push(m(i,"0")||{id:i,title:"",content:"",subsections:[]}),_.push(m(i,"1")||{id:i,title:"",content:"",subsections:[]}))});return{activeProposed:{title:(null===(n=null===(e=b.comparison_inputs)||void 0===e?void 0:e[p[0]])||void 0===n?void 0:n.title)||"Uploaded Contract",description:b.decision_scope_description||"",sections:c},activeVariants:[{id:"tree-variant-1",title:(null===(a=null===(s=b.comparison_inputs)||void 0===s?void 0:s[p[1]])||void 0===a?void 0:a.title)||"Reference Template",similarity:0,sections:_,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:b.decision_scope_description||""},fields:{}}}}],parseError:null}}catch(i){return console.error("Data Transformation Error: ",i),{activeProposed:{},activeVariants:[],parseError:i instanceof Error?i.message:"Unknown Parsing Error"}}},[o,l,r,d]),v=u.activeProposed,c=u.activeVariants,_=u.parseError,f=(null==c?void 0:c[0])||n,p=e.useMemo(function(){return(null==v?void 0:v.sections)||[]},[null==v?void 0:v.sections]),b=e.useMemo(function(){return f.sections||[]},[f.sections]),g=p.length>0||b.length>0,m=e.useMemo(function(){return a.fields.filter(function(i){var e=i.key;return(!g||"description"!==e)&&(t.hasValue(null==v?void 0:v[e])||t.hasValue(f[e]))})},[v,f,g,a.fields]),y=e.useMemo(function(){var i,e,n={},s={},a={},d=0,r=null===(i=null==o?void 0:o.input_index_map)||void 0===i?void 0:i[0],u=null===(e=null==o?void 0:o.input_index_map)||void 0===e?void 0:e[1],v=function(i,e,o,l,c,_){var f,p,b,g,m,y,x,h;if(i&&function(i,e){var n,o=(null===(n=null==i?void 0:i.evaluationResult)||void 0===n?void 0:n.deviations)||{};Object.keys(o).sort().forEach(function(n){var l=o[n];if(l){var d=!t.isMissingStr(l[r]),v=!t.isMissingStr(l[u]);if(d||v){var c="".concat(i.id).concat(t.DEVIATION_BADGE_SEPARATOR).concat(n);void 0===s[c]&&(void 0===a[e]&&(a[e]=1),s[c]=a[e]++)}}})}(i,l),i&&!c){var I=(null==_?void 0:_.id)||"fallback_parent_".concat(d++);n[I]||(n[I]=[]),n[I].push(i)}for(var E=Math.max((null===(f=null==e?void 0:e.subsections)||void 0===f?void 0:f.length)||0,(null===(p=null==o?void 0:o.subsections)||void 0===p?void 0:p.length)||0,(null===(b=null==i?void 0:i.subsections)||void 0===b?void 0:b.length)||0),S=0;S<E;S++)v((null===(g=null==i?void 0:i.subsections)||void 0===g?void 0:g[S])||(null===(m=null==e?void 0:e.subsections)||void 0===m?void 0:m[S])||(null===(y=null==o?void 0:o.subsections)||void 0===y?void 0:y[S]),null===(x=null==e?void 0:e.subsections)||void 0===x?void 0:x[S],null===(h=null==o?void 0:o.subsections)||void 0===h?void 0:h[S],l,!1,_)};return p.forEach(function(i,e){var t,n=e+1;l&&void 0!==i.selfIndex&&i.selfIndex>=0&&(n=i.selfIndex+1);var o=null;if(l){var s=null===(t=i.refIndexes)||void 0===t?void 0:t[0];o=b.find(function(i){return i.selfIndex===s})}else o=b[e];v(i,i,o,n,!0,i)}),b.forEach(function(i,e){var t,n=e+1,o=!1;if(l){var s=null===(t=i.refIndexes)||void 0===t?void 0:t[0],a=p.find(function(i){return i.selfIndex===s});a&&void 0!==a.selfIndex&&a.selfIndex>=0?n=a.selfIndex+1:(o=!0,void 0!==i.selfIndex&&i.selfIndex>=0&&(n=i.selfIndex+1))}else e>=p.length&&(o=!0);o&&v(i,null,i,n,!0,i)}),{parentDeviationRecord:n,registry:s}},[p,b,l,o]),x=y.parentDeviationRecord,h=y.registry;return{activeProposed:v,activeVariants:c,existingRule:f,proposedSections:p,existingSections:b,visibleFields:m,parentDeviationRecord:x,deviationNumberRegistry:h,parseError:_}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var i=require("tslib"),e=require("react"),t=require("../CognitiveComparehelpers.js"),n={id:"",title:"",similarity:0,sections:[]};exports.useCognitiveTreeData=function(o,l,s,a,d){void 0===d&&(d=!0);var r=JSON.stringify(s||{}),u=e.useMemo(function(){var e,n,s,a;if(!o||0===Object.keys(o).length)return{activeProposed:{},activeVariants:[],parseError:"Tree data is required"};var u=JSON.parse(r);try{var v=o.nodes||o,c=[],_=[],f=o.base_root_id,p=o.input_index_map||{0:"left",1:"right"},b=o[f]||v[f];if(!b||!1===b.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[],parseError:null};var g=function(e){if(!e||"object"!=typeof e)return e||null;if(e.deviations)return e;if(d)return e;var t=Object.keys(e).filter(function(i){return/^\d+$/.test(i)});if(!t.length)return e;var n=t.sort(function(i,e){return Number(i)-Number(e)}),o=null==p?void 0:p[0],l=null==p?void 0:p[1],s={},a={},r=null;return n.forEach(function(i){var t,n,d,u=e[i];if(u&&"object"==typeof u){r||(r=u);var v=(null===(n=null==u?void 0:u.deviation_highlights)||void 0===n?void 0:n[o])||[],c=(null===(d=null==u?void 0:u.deviation_highlights)||void 0===d?void 0:d[l])||[],_=v[0]||"",f=c[0]||"";s[i]=((t={})[o]=_,t[l]=f,t.deviation_summary=(null==u?void 0:u.deviation_summary)||"",t.deviation_title=null==u?void 0:u.deviation_title,t.deviation_impact=null==u?void 0:u.deviation_impact,t.deviation_explanation=null==u?void 0:u.deviation_explanation,t.evaluation_outputs=null==u?void 0:u.evaluation_outputs,t.cognitive_decisioning=null==u?void 0:u.cognitive_decisioning,t.deviation_highlights=null==u?void 0:u.deviation_highlights,t),a[i]=u}}),i.__assign(i.__assign({},e),{deviation_title:(null==r?void 0:r.deviation_title)||(null==e?void 0:e.deviation_title),deviation_impact:(null==r?void 0:r.deviation_impact)||(null==e?void 0:e.deviation_impact),deviation_summary:(null==r?void 0:r.deviation_summary)||(null==e?void 0:e.deviation_summary),deviation_explanation:(null==r?void 0:r.deviation_explanation)||(null==e?void 0:e.deviation_explanation),evaluation_outputs:(null==r?void 0:r.evaluation_outputs)||(null==e?void 0:e.evaluation_outputs),cognitive_decisioning:(null==r?void 0:r.cognitive_decisioning)||(null==e?void 0:e.cognitive_decisioning),deviations:s,deviation_entries:a})},m=function(e,n){var l,s,a,d=o[e]||v[e];if(!d||!1===d.display_node)return null;var r=t.getSideData(d,n,p),c=!1!==(null===(l=r.attributes)||void 0===l?void 0:l.display_title),_=!1!==(null===(s=r.attributes)||void 0===s?void 0:s.display_content),f=!!r.title.trim(),b=!!r.content.trim(),y=t.getRationale(d),x=(null===(a=null==u?void 0:u[e])||void 0===a?void 0:a.evaluation_result)||d.evaluation_result||null,h=g(x),I=[];d.next&&Object.values(d.next).forEach(function(i){var e=v[i];if(e&&!1!==e.display_node){var t=m(i,n);t&&I.push(t)}});var E=!(!f&&!b);return i.__assign(i.__assign({id:e,title:f?r.title:"",content:b?r.content:"",displayTitle:c,displayContent:_,subsections:I},E?y:{score:void 0,relation:"not_defined"}),{evaluationResult:h})};if(l){var y=function(e,n){var l,s,a,d,r,c,_,f,b,m,x,h,I,E,S,N,R,O,j,D,M;void 0===n&&(n=0);var P=[],T=[];if(!e)return{refSections:P,baseSections:T};var V={},A={},C=-1,k=-1;for(var q in e){var J=e[q],U=o[J]||v[J];if(U&&!1!==U.display_node){var w=t.getRationale(U),B=(null===(l=null==u?void 0:u[J])||void 0===l?void 0:l.evaluation_result)||U.evaluation_result||null,F=g(B),G=t.getSideData(U,"1",p),$=t.getSideData(U,"0",p),z=!1!==(null===(s=G.attributes)||void 0===s?void 0:s.display_title)&&G.title.trim()||!1!==(null===(a=G.attributes)||void 0===a?void 0:a.display_content)&&G.content.trim(),H=!1!==(null===(d=$.attributes)||void 0===d?void 0:d.display_title)&&$.title.trim()||!1!==(null===(r=$.attributes)||void 0===r?void 0:r.display_content)&&$.content.trim(),K=Number(null!==(_=null===(c=G.attributes)||void 0===c?void 0:c.display_index)&&void 0!==_?_:C--),L=Number(null!==(b=null===(f=$.attributes)||void 0===f?void 0:f.display_index)&&void 0!==b?b:k--),Q=V[K]||i.__assign(i.__assign({id:J,title:!1!==(null===(m=G.attributes)||void 0===m?void 0:m.display_title)?G.title:"",content:!1!==(null===(x=G.attributes)||void 0===x?void 0:x.display_content)?G.content:"",subsections:[]},z?w:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:K,evaluationResult:F,displayContent:null===(h=G.attributes)||void 0===h?void 0:h.display_content,displayTitle:null===(I=G.attributes)||void 0===I?void 0:I.display_title}),W=A[L]||i.__assign(i.__assign({id:J,title:!1!==(null===(E=$.attributes)||void 0===E?void 0:E.display_title)?$.title:"",content:!1!==(null===(S=$.attributes)||void 0===S?void 0:S.display_content)?$.content:"",subsections:[]},H?w:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:L,evaluationResult:F,displayContent:null===(N=$.attributes)||void 0===N?void 0:N.display_content,displayTitle:null===(R=$.attributes)||void 0===R?void 0:R.display_title});Number(K)>=0&&Number(L)>=0&&((null===(O=Q.refIndexes)||void 0===O?void 0:O.includes(Number(L)))||null===(j=Q.refIndexes)||void 0===j||j.push(Number(L)),(null===(D=W.refIndexes)||void 0===D?void 0:D.includes(Number(K)))||null===(M=W.refIndexes)||void 0===M||M.push(Number(K))),V[K]=Q,A[L]=W;var X=y(U.next,n+1),Y=X.refSections,Z=X.baseSections;Y.length>0&&(Q.subsections=i.__spreadArray(i.__spreadArray([],Q.subsections||[],!0),Y,!0)),Z.length>0&&(W.subsections=i.__spreadArray(i.__spreadArray([],W.subsections||[],!0),Z,!0))}}P=Object.values(V),T=Object.values(A);var ii=function(i,e){return i.selfIndex<0&&e.selfIndex>=0?1:i.selfIndex>=0&&e.selfIndex<0?-1:i.selfIndex-e.selfIndex};return P.sort(ii),T.sort(ii),{refSections:P,baseSections:T}},x=y(b.next),h=x.refSections,I=x.baseSections;_=h,c=I}else b.next&&Object.values(b.next).forEach(function(i){var e=o[i]||v[i];e&&!1!==e.display_node&&(c.push(m(i,"0")||{id:i,title:"",content:"",subsections:[]}),_.push(m(i,"1")||{id:i,title:"",content:"",subsections:[]}))});return{activeProposed:{title:(null===(n=null===(e=b.comparison_inputs)||void 0===e?void 0:e[p[0]])||void 0===n?void 0:n.title)||"Uploaded Contract",description:b.decision_scope_description||"",sections:c},activeVariants:[{id:"tree-variant-1",title:(null===(a=null===(s=b.comparison_inputs)||void 0===s?void 0:s[p[1]])||void 0===a?void 0:a.title)||"Reference Template",similarity:0,sections:_,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:b.decision_scope_description||""},fields:{}}}}],parseError:null}}catch(i){return console.error("Data Transformation Error: ",i),{activeProposed:{},activeVariants:[],parseError:i instanceof Error?i.message:"Unknown Parsing Error"}}},[o,l,r,d]),v=u.activeProposed,c=u.activeVariants,_=u.parseError,f=(null==c?void 0:c[0])||n,p=e.useMemo(function(){return(null==v?void 0:v.sections)||[]},[null==v?void 0:v.sections]),b=e.useMemo(function(){return f.sections||[]},[f.sections]),g=p.length>0||b.length>0,m=e.useMemo(function(){return a.fields.filter(function(i){var e=i.key;return(!g||"description"!==e)&&(t.hasValue(null==v?void 0:v[e])||t.hasValue(f[e]))})},[v,f,g,a.fields]),y=e.useMemo(function(){var i,e,n={},s={},a={},d=0,r=null===(i=null==o?void 0:o.input_index_map)||void 0===i?void 0:i[0],u=null===(e=null==o?void 0:o.input_index_map)||void 0===e?void 0:e[1],v=function(i,e,o,l,c,_){var f,p,b,g,m,y,x,h;if(i&&function(i,e){var n,o=(null===(n=null==i?void 0:i.evaluationResult)||void 0===n?void 0:n.deviations)||{};Object.keys(o).sort().forEach(function(n){var l=o[n];if(l){var d=!t.isMissingStr(l[r]),v=!t.isMissingStr(l[u]);if(d||v){var c="".concat(i.id).concat(t.DEVIATION_BADGE_SEPARATOR).concat(n);void 0===s[c]&&(void 0===a[e]&&(a[e]=1),s[c]=a[e]++)}}})}(i,l),i&&!c){var I=(null==_?void 0:_.id)||"fallback_parent_".concat(d++);n[I]||(n[I]=[]),n[I].push(i)}for(var E=Math.max((null===(f=null==e?void 0:e.subsections)||void 0===f?void 0:f.length)||0,(null===(p=null==o?void 0:o.subsections)||void 0===p?void 0:p.length)||0,(null===(b=null==i?void 0:i.subsections)||void 0===b?void 0:b.length)||0),S=0;S<E;S++)v((null===(g=null==i?void 0:i.subsections)||void 0===g?void 0:g[S])||(null===(m=null==e?void 0:e.subsections)||void 0===m?void 0:m[S])||(null===(y=null==o?void 0:o.subsections)||void 0===y?void 0:y[S]),null===(x=null==e?void 0:e.subsections)||void 0===x?void 0:x[S],null===(h=null==o?void 0:o.subsections)||void 0===h?void 0:h[S],l,!1,_)};return p.forEach(function(i,e){var t,n=e+1;l&&void 0!==i.selfIndex&&i.selfIndex>=0&&(n=i.selfIndex+1);var o=null;if(l){var s=null===(t=i.refIndexes)||void 0===t?void 0:t[0];o=b.find(function(i){return i.selfIndex===s})}else o=b[e];v(i,i,o,n,!0,i)}),b.forEach(function(i,e){var t,n=e+1,o=!1;if(l){var s=null===(t=i.refIndexes)||void 0===t?void 0:t[0],a=p.find(function(i){return i.selfIndex===s});a&&void 0!==a.selfIndex&&a.selfIndex>=0?n=a.selfIndex+1:(o=!0,void 0!==i.selfIndex&&i.selfIndex>=0&&(n=i.selfIndex+1))}else e>=p.length&&(o=!0);o&&v(i,null,i,n,!0,i)}),{parentDeviationRecord:n,registry:s}},[p,b,l,o]),x=y.parentDeviationRecord,h=y.registry;return{activeProposed:v,activeVariants:c,existingRule:f,proposedSections:p,existingSections:b,visibleFields:m,parentDeviationRecord:x,deviationNumberRegistry:h,parseError:_}};
2
2
  //# sourceMappingURL=useCompareData.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e,__spreadArray as n}from"tslib";import{jsxs as t,jsx as i}from"react/jsx-runtime";import{useState as o,useRef as r,useMemo as l,useEffect as u,useCallback as c}from"react";import{Box as a,Snackbar as d,Alert as s,Tooltip as v,Typography as p}from"@mui/material";import{ChevronDown as f,EllipsisVertical as g}from"lucide-react";import{ButtonCognitiveIcon as h}from"../../assests/svg/ButtonCognitiveIcon.js";import x from"./OverlayComponent.js";import{safeStringify as m,extractDeviationScore as y,generateColorPalette as b,DEVIATION_BADGE_SEPARATOR as S,hasValue as R,getBentArrowPath as C,smoothScrollTo as w}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as B,DEFAULT_FIELD_CONFIG as I,DEFAULT_COMPARISON_CONFIG as T}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import{DEFAULT_DEVIAION_COLOR as _,DEFAULT_COMPONENT_HEADER_TEXT as E}from"./CognitiveCompareConstants.js";import F from"./CognitivePopup.js";import D from"./MoreFunctionsPopup.js";import k from"./LoaderComponent.js";import M from"./components/ThreeDotsLoader.js";import{useCognitiveTreeData as N}from"./hooks/useCompareData.js";import{useComparePopups as A}from"./hooks/useComparePopups.js";import{useSectionRefs as H}from"./hooks/useSectionRefs.js";import{useAccordionState as L}from"./hooks/useAccordionState.js";import{useDeviationNavigation as j}from"./hooks/useDeviationNavigation.js";import O from"./components/CompareHeader.js";import P from"./components/SectionAccordion.js";import z from"./components/SubSectionAccordion.js";import W from"./components/CognitiveSummaryPopup.js";var Y=function(Y){var K,q,V,X,J,U,$,G,Q,Z,ee,ne,te,ie,oe,re,le,ue,ce=Y.componentHeaderText,ae=void 0===ce?E:ce,de=Y.treeData,se=Y.comparisonConfig,ve=Y.leftColumnTitleText,pe=Y.rightColumnTitleText,fe=Y.markdownStyles,ge=Y.displayConfig,he=void 0===ge?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!0}:ge,xe=Y.popupConfig,me=Y.deviationData,ye=void 0===me?{}:me,be=Y.deviationNodeIdToView,Se=Y.resetDeviationNodeId,Re=o(he.maintainRelativeOrder),Ce=Re[0],we=Re[1],Be=!!Ce||!!(null==he?void 0:he.showDeviationBadges),Ie=o(!1),Te=Ie[0],_e=Ie[1],Ee=o(!1),Fe=Ee[0],De=Ee[1],ke=o(null),Me=ke[0],Ne=ke[1],Ae=o(!1),He=Ae[0],Le=Ae[1],je=o((null==de?void 0:de.newEvaluationResult)?de.evaulationResult:!he.enableDeviationSchemaBackwardCompatibility||he.enableDeviationSchemaBackwardCompatibility),Oe=je[0];je[1];var Pe=o(!1),ze=Pe[0],We=Pe[1],Ye=o(!1),Ke=Ye[0],qe=Ye[1],Ve=o(null),Xe=Ve[0],Je=Ve[1],Ue=r(!1),$e=o(new Set),Ge=$e[0],Qe=$e[1],Ze=o([]),en=Ze[0],nn=Ze[1],tn=r(null),on=r(!1),rn=r(null),ln=r({}),un=r([]),cn=r(!1),an=r(!1),dn=r(null),sn=r(function(){}),vn=l(function(){return(null==de?void 0:de.cognitive_decisioning)||{}},[de]),pn=o({width:0,height:0}),fn=pn[0],gn=pn[1],hn=l(function(){return e(e({},B),fe)},[fe]),xn=r(null),mn=r(null),yn=r(null),bn=r(null),Sn=r(null),Rn=r(null),Cn=r(null),wn=r(null),Bn=r(!1),In=r(null),Tn=r(null),_n=A(xn),En=_n.cognitivePopup,Fn=_n.setCognitivePopup,Dn=_n.moreFunctions,kn=_n.setMoreFunctions,Mn=_n.position,Nn=_n.setPosition,An=_n.activeBadgeId,Hn=_n.summaryPopup,Ln=_n.setSummaryPopup,jn=_n.closeSummaryPopup,On=_n.setActiveBadgeId,Pn=_n.popupRef,zn=_n.closeCognitivePopup,Wn=_n.closeMoreFunctionsPopup,Yn=l(function(){var e,n,t,i,o,r,l;return{fields:null!==(e=null==se?void 0:se.fields)&&void 0!==e?e:I,thresholds:{high:null!==(t=null===(n=null==se?void 0:se.thresholds)||void 0===n?void 0:n.high)&&void 0!==t?t:T.thresholds.high,medium:null!==(o=null===(i=null==se?void 0:se.thresholds)||void 0===i?void 0:i.medium)&&void 0!==o?o:T.thresholds.medium,exact:null!==(l=null===(r=null==se?void 0:se.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:T.thresholds.exact}}},[se]),Kn=o(null),qn=Kn[0];Kn[1];var Vn=null===(V=null===(K=null==de?void 0:de.documents)||void 0===K?void 0:K[null===(q=null==de?void 0:de.input_index_map)||void 0===q?void 0:q[0]])||void 0===V?void 0:V.title,Xn=null===(U=null===(X=null==de?void 0:de.documents)||void 0===X?void 0:X[null===(J=null==de?void 0:de.input_index_map)||void 0===J?void 0:J[1]])||void 0===U?void 0:U.title,Jn=m(ve||Vn||"Uploaded Contract"),Un=m(pe||Xn||"Reference Template"),$n=N(de,Ce,ye,Yn,Oe),Gn=$n.activeProposed,Qn=$n.existingRule,Zn=$n.proposedSections,et=$n.existingSections,nt=$n.visibleFields,tt=$n.parentDeviationRecord,it=$n.deviationNumberRegistry,ot=$n.parseError;u(function(){ot&&Ne("Failed to load comparison: ".concat(ot))},[ot]);var rt=Zn.length>0||et.length>0,lt=H(nt.map(function(e){return e.key}),Math.max(Zn.length,et.length)),ut=lt.leftRefs,ct=lt.rightRefs,at=lt.sectionLeftRefs,dt=lt.sectionRightRefs,st=lt.lhsBadgeRefs,vt=lt.rhsBadgeRefs,pt=lt.sectionRightRowRefs,ft=lt.subSectionLeftRefs,gt=lt.subSectionRightRefs,ht=lt.sectionRowRefs,xt=lt.getSectionRowRef,mt=lt.getSubSectionRef,yt=lt.getBadgeRef,bt=Qn.analysis,St=m(null===(G=null===($=null==bt?void 0:bt.rule_difference_comparison)||void 0===$?void 0:$.summary)||void 0===G?void 0:G.overall_summary),Rt=!!St.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),Ct=null!==(Q=null==de?void 0:de.base_root_id)&&void 0!==Q?Q:"-1";null==de||de[Ct];var wt=Oe?(null===(te=null==ye?void 0:ye[Ct])||void 0===te?void 0:te.evaluation_result)||(null===(oe=null===(ie=null==de?void 0:de.nodes)||void 0===ie?void 0:ie[Ct])||void 0===oe?void 0:oe.evaluation_result)||null:(null===(Z=null==ye?void 0:ye[Ct])||void 0===Z?void 0:Z.evaluation_result[0])||(null===(ne=null===(ee=null==de?void 0:de.nodes)||void 0===ee?void 0:ee[Ct])||void 0===ne?void 0:ne.evaluation_result[0])||null,Bt=y(wt),It=b(null!==(ue=null===(le=null===(re=null==wt?void 0:wt.evaluation_outputs)||void 0===re?void 0:re.metadata)||void 0===le?void 0:le.label_color)&&void 0!==ue?ue:""),Tt=c(function(){var e,n,t,i,o,r;Le(!1),an.current=!1;var l=dn.current,u=Pt.current;if(null!==l)if("string"==typeof l&&l.includes(S)){var c=l.split(S);(a=(null===(e=ft.current[c[2]])||void 0===e?void 0:e.current)||(null===(n=at.current[Number(c[2])])||void 0===n?void 0:n.current))&&(a.style.paddingTop="0px")}else{var a;(a=null===(t=at.current[l])||void 0===t?void 0:t.current)&&(a.style.paddingTop="0px")}if(null!==u)if("string"==typeof u&&u.includes(S)){c=u.split(S);(d=(null===(i=gt.current[c[3]])||void 0===i?void 0:i.current)||(null===(o=dt.current[Number(c[3])])||void 0===o?void 0:o.current))&&(d.style.paddingTop="0px")}else{var d;(d=null===(r=dt.current[u])||void 0===r?void 0:r.current)&&(d.style.paddingTop="0px")}Je(null),dn.current=null,Pt.current=null,We(!1),De(!1),bn.current&&(bn.current.style.height="0px"),Sn.current&&(Sn.current.style.height="0px"),Rn.current&&(Rn.current.style.height="0px"),Cn.current&&(Cn.current.style.height="0px")},[]),_t=L({maintainRelativeOrder:!!Ce,proposedSections:Zn,existingSections:et,activeSideBySideSection:Xe,connectedSections:Ge,resetSideBySide:Tt,setConnectedSections:Qe,setConnectedLines:nn,cachedConnectedPositions:un,svgContainerRef:tn,isAnimatingRef:on,animationTimerRef:rn,calculateLinesRef:sn,sectionLeftRefs:at,sectionRightRefs:dt,subSectionLeftRefs:ft,subSectionRightRefs:gt}),Et=_t.expandedSections,Ft=_t.expandedSubSections,Dt=_t.setExpandedSubSections,kt=_t.toggleSection,Mt=c(function(n,t,i,o,r,l,u){var c,a,d,s=m(null==t?void 0:t.id)||m(null==i?void 0:i.id)||"",v=(s?vn[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=ht.current[o])||void 0===c?void 0:c.current)&&void 0!==a?a:null;return{isLoading:null!==(d=null==he?void 0:he.isLoading)&&void 0!==d&&d,open:!0,sectionTitle:(null==t?void 0:t.displayTitle)?null==t?void 0:t.title:"no title",refSectionTitle:(null==i?void 0:i.displayTitle)?null==i?void 0:i.title:"no title",cognitiveData:v,anchorEl:n,sectionAnchorEl:p,badgeStyle:l||null,sectionIdx:o,docData:{documents:null==de?void 0:de.documents,input_index_map:null==de?void 0:de.input_index_map},deviationData:function(){var n,r,l=(null==t?void 0:t.evaluationResult)||(null==i?void 0:i.evaluationResult)||null,u=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(e({},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(S)))return u(l);var c=o.split(S)[1];if(!c)return l;var a=(null==t?void 0:t.evaluationResult)||(null==i?void 0:i.evaluationResult)||{},d=(null===(n=null==a?void 0:a.deviation_entries)||void 0===n?void 0:n[c])||(null===(r=null==a?void 0:a.deviations)||void 0===r?void 0:r[c])||null;return d?e(e(e({},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}},[vn,de]),Nt=c(function(e){Wn(),Nn(null),Fn(e)},[Wn]),At=function(e,n,t,i,o,r){var l;if(e.stopPropagation(),Dn.open&&Dn.sectionIdx===o)Wn();else{var u=e.currentTarget,c="left";(null===(l=yn.current)||void 0===l?void 0:l.contains(u))&&(c="right");an.current&&Tt(),Qe(new Set),nn([]),un.current=[],zn(),Hn.open?ai():jn(),requestAnimationFrame(function(){var e=function(){var e,n,t,i;if("string"==typeof o&&o.includes(S)){var r=o.split(S),l="".concat(r[0]).concat(S).concat(r[1]);return"right"===c?null===(e=vt.current[l])||void 0===e?void 0:e.current:null===(n=st.current[l])||void 0===n?void 0:n.current}return"right"===c?null===(t=vt.current[o])||void 0===t?void 0:t.current:null===(i=st.current[o])||void 0===i?void 0:i.current}()||u;kn(Mt(e,n,i,o,t,r))})}},Ht=c(function(){null!==Dn.sectionIdx&&Dn.anchorEl?Nt(e(e({},Dn),{open:!0})):Wn()},[Dn,Wn,Nt]),Lt=c(function(){var e=Dn.sectionIdx,n=Dn.isOrphan;Wn(),jn(),null!==e&&(n?Ne("No counterpart exists to connect to."):(an.current&&Tt(),nn([]),un.current=[],Qe(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){sn.current&&sn.current()},50)))},[Dn.sectionIdx,Dn.isOrphan,Wn,jn,Tt]),jt=r(null),Ot=r(null),Pt=r(null),zt=r(null),Wt=r(null),Yt=r(null),Kt=o([]),qt=Kt[0],Vt=Kt[1];r(null);var Xt=o(null),Jt=Xt[0],Ut=Xt[1];u(function(){if(qn){var e=Yn.fields.find(function(e){return e.analysisKey===qn||e.key===qn});if(e){var n=ut.current[e.key]||ct.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[qn,Yn.fields]);var $t=c(function(e){var n,t,i,o,r,l,u,c,a,d=null===(n=null==bt?void 0:bt.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!d||!d[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var s=d[e],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}},[bt]),Gt=c(function(n,t){var i,o,r,l,u,c,a;void 0===t&&(t="left");var d=null,s=null;if("left"===t)if(d=Zn[n],Ce&&d){var v=et.filter(function(e){var n;return null===(n=d.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)});s=v.find(function(e){return e.evaluationResult})||v[0]}else s=et[n];else if(s=et[n],Ce&&s){var p=Zn.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(s.selfIndex)});d=p.find(function(e){return e.evaluationResult})||p[0]}else d=Zn[n];var f=(null==d?void 0:d.relation)&&"not_defined"!==d.relation,g=(null==s?void 0:s.relation)&&"not_defined"!==s.relation,h=!(!(null==d?void 0:d.cognitiveData)&&!(null==s?void 0:s.cognitiveData));if(!f&&!g&&!h)return e(e({},b(_)),{label:"Not Defined"});var x=null!==(o=null!==(i=null==d?void 0:d.evaluationResult)&&void 0!==i?i:null==s?void 0:s.evaluationResult)&&void 0!==o?o:null,m=null===(r=null==x?void 0:x.evaluation_outputs)||void 0===r?void 0:r.output_value,y=null!==(c=null===(u=null===(l=null==x?void 0:x.evaluation_outputs)||void 0===l?void 0:l.metadata)||void 0===u?void 0:u.label_color)&&void 0!==c?c:_;return e(e({},b(y)),null!=x?{label:null!==(a=m)&&void 0!==a?a:""}:{label:null})},[Zn,et,vn,Yn,Ce]),Qt=c(function(n){for(var t,i,o,r,l,u,c,a,d,s=n.split("-").map(Number),v=Zn[s[0]],p=et[s[0]],f=1;f<s.length;f++)(null==v?void 0:v.subsections)&&(v=v.subsections[s[f]]),(null==p?void 0:p.subsections)&&(p=p.subsections[s[f]]);if(!v&&!p)return null;var g=(null==v?void 0:v.relation)&&"not_defined"!==v.relation,h=(null==p?void 0:p.relation)&&"not_defined"!==p.relation,x=m(null==v?void 0:v.id)||m(null==p?void 0:p.id)||"",y=!(!(null==v?void 0:v.cognitiveData)&&!(null==p?void 0:p.cognitiveData));if(!g&&!h&&!y)return e(e({},b(_)),{label:"Not Defined"});null!==(i=null!==(t=null==v?void 0:v.cognitiveRelevanceScore)&&void 0!==t?t:null==p?void 0:p.cognitiveRelevanceScore)&&void 0!==i||x&&(null===(o=vn[x])||void 0===o||o.relevance_score);var S=null!==(l=null!==(r=null==v?void 0:v.evaluationResult)&&void 0!==r?r:null==p?void 0:p.evaluationResult)&&void 0!==l?l:null,R=null===(u=null==S?void 0:S.evaluation_outputs)||void 0===u?void 0:u.output_value,C=null!==(d=null===(a=null===(c=null==S?void 0:S.evaluation_outputs)||void 0===c?void 0:c.metadata)||void 0===a?void 0:a.label_color)&&void 0!==d?d:_;return e(e({},b(C)),null!=S?{label:null!=R?R:""}:{label:null})},[Zn,et,vn,Yn]),Zt=c(function(){var e,n,t,i,o,r,l,u,c,a,d,s,v,p,f,g,h,x,m,y,b,w;if(!Bn.current&&!on.current){Bn.current=!0;try{if(!jt.current)return;var B=function(e){var n=e.split("-"),t=n[0];if(!Et[t]&&!1===Ce)return!1;if(Ce&&!Et["left-".concat(t)]&&!Et["right-".concat(t)]&&!Et[t])return!1;for(var i=t,o=1;o<n.length-1;o++)if(i+="-".concat(n[o]),!Ft[i])return!1;return!0},I=jt.current.getBoundingClientRect();gn({width:I.width,height:I.height});var T=[];if(nt.forEach(function(e){var n,t,i=e.key,o=null===(n=ut.current[i])||void 0===n?void 0:n.current,r=null===(t=ct.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")}),!on.current){for(var _=0;_<Math.max(Zn.length,et.length);_++){var E=null===(e=at.current[_])||void 0===e?void 0:e.current,F=null===(n=dt.current[_])||void 0===n?void 0:n.current;E&&(E.style.height="auto",E.style.minHeight="0px"),F&&(F.style.height="auto",F.style.minHeight="0px")}Ce||Object.keys(ft.current).forEach(function(e){var n,t;if(B(e)){var i=null===(n=ft.current[e])||void 0===n?void 0:n.current,o=null===(t=gt.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={};nt.forEach(function(e){var n,t,i=e.key,o=null===(n=ut.current[i])||void 0===n?void 0:n.current,r=null===(t=ct.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 k={left:{},right:{}},M={};if(!on.current)if(Ce){if(He&&null!==Xe)if("number"==typeof Xe){var N=Xe,A=Zn[N],H=null===(o=at.current[N])||void 0===o?void 0:o.current;H&&A&&(A.refIndexes||[]).forEach(function(e){var n,t=et.findIndex(function(n){return n.selfIndex===e}),i=null===(n=dt.current[t])||void 0===n?void 0:n.current;if(i&&(Et["left-".concat(N)]||Et["right-".concat(t)])){var o=Math.max(H.getBoundingClientRect().height,i.getBoundingClientRect().height);k.left[N]=Math.max(k.left[N]||0,o),k.right[t]=Math.max(k.right[t]||0,o)}})}else{var L=Xe.split(S)[2];if(L){E=null===(r=ft.current[L])||void 0===r?void 0:r.current,F=null===(l=gt.current[L])||void 0===l?void 0:l.current;if(E&&F){j=Math.max(E.getBoundingClientRect().height,F.getBoundingClientRect().height);M[L]=Math.max(M[L]||0,j)}}}}else{Object.keys(ft.current).forEach(function(e){var n,t;if(B(e)){var i=null===(n=ft.current[e])||void 0===n?void 0:n.current,o=null===(t=gt.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);M[e]=u,i.style.minHeight="".concat(u,"px"),o.style.minHeight="".concat(u,"px")}}});for(_=0;_<Math.min(Zn.length,et.length);_++){var E=null===(t=at.current[_])||void 0===t?void 0:t.current,F=null===(i=dt.current[_])||void 0===i?void 0:i.current;if(E&&F){var j=Math.max(E.getBoundingClientRect().height,F.getBoundingClientRect().height);k.left[_]=j,k.right[_]=j}}}if(nt.forEach(function(e){var n,t,i=e.key,o=null===(n=ut.current[i])||void 0===n?void 0:n.current,r=null===(t=ct.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")}}),on.current||(Object.entries(k.left).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=at.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),Object.entries(k.right).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=dt.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),Ce||Object.keys(M).forEach(function(e){var n,t,i=null===(n=ft.current[e])||void 0===n?void 0:n.current,o=null===(t=gt.current[e])||void 0===t?void 0:t.current;if(i&&o&&M[e]){var r=M[e];i.style.minHeight="".concat(r,"px"),o.style.minHeight="".concat(r,"px")}})),Ce)Zn.forEach(function(e,n){var t;(null===(t=at.current[n])||void 0===t?void 0:t.current)&&(e.refIndexes||[]).forEach(function(e){var t,i,o,r,l,u,c,a,d,s,v=et.findIndex(function(n){return n.selfIndex===e});if(-1!==v){var p=null===(t=st.current[n])||void 0===t?void 0:t.current,f=null===(i=vt.current[v])||void 0===i?void 0:i.current;if(p&&f){var g=p.getBoundingClientRect(),h=f.getBoundingClientRect(),x=g.right-I.left,m=h.left-I.left,y=g.top+g.height/2-I.top,b=h.top+h.height/2-I.top;if(He&&Xe===n){var S=null!==(r=null===(o=wn.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==r?r:0,R=null!==(u=null===(l=yn.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==u?u:0,C=S+(null!==(a=null===(c=wn.current)||void 0===c?void 0:c.clientHeight)&&void 0!==a?a:1/0),w=R+(null!==(s=null===(d=yn.current)||void 0===d?void 0:d.clientHeight)&&void 0!==s?s:1/0),B=g.top+g.height/2,_=h.top+h.height/2,E=function(e,n,t){return Math.max(n,Math.min(t,e))};y=E(B,S,C)-I.top,b=E(_,R,w)-I.top}var F=Gt(n);F&&T.push({id:"line-".concat(n,"-").concat(v),x1:x,y1:y,x2:m,y2:b,style:F,sectionIdx:n,targetRightIdx:v})}}})});else{for(_=0;_<Math.min(Zn.length,et.length);_++){var O=null===(u=at.current[_])||void 0===u?void 0:u.current,P=null===(c=dt.current[_])||void 0===c?void 0:c.current;if(O&&P){var z=O.getBoundingClientRect(),W=P.getBoundingClientRect(),Y=Math.max(z.top,W.top)+18-I.top,K=(null===(a=et[_])||void 0===a?void 0:a.id)||"sec-".concat(_);(Q=Gt(_))&&T.push({id:K,x1:z.right-I.left,y1:Y,x2:W.left-I.left,y2:Y,style:Q,sectionIdx:_,hasCognitive:!!((null===(d=Zn[_])||void 0===d?void 0:d.cognitiveData)||(null===(s=et[_])||void 0===s?void 0:s.cognitiveData)||K&&vn[K]),isSubSection:!1})}}Object.keys(ft.current).forEach(function(e){var n,t,i,o,r,l;if(B(e)){var u=null===(n=ft.current[e])||void 0===n?void 0:n.current,c=null===(t=gt.current[e])||void 0===t?void 0:t.current;if(u&&c){for(var a=e.split("-").map(Number),d=Zn[a[0]],s=et[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)&&R(d.title)),f=!!d&&((null===(o=d.displayContent)||void 0===o||o)&&R(d.content)),g=!!s&&((null===(r=s.displayTitle)||void 0===r||r)&&R(s.title)),h=!!s&&((null===(l=s.displayContent)||void 0===l||l)&&R(s.content));if(p&&f||g&&h){var x=u.getBoundingClientRect(),m=c.getBoundingClientRect(),y=Math.max(x.top,m.top)+16-I.top,b=Qt(e);b&&"Not Defined"!==b.label&&T.push({id:"subsec-".concat(e),x1:x.right-I.left,y1:y,x2:m.left-I.left,y2:y,style:b,sectionIdx:a[0],isSubSection:!0,subSectionKeyPath:e,hasCognitive:!(!(null==d?void 0:d.cognitiveData)&&!(null==s?void 0:s.cognitiveData))})}}}})}if(He&&"string"==typeof Xe&&Xe.includes(S)){var q=Xe.split(S),V=q[0],X=q[1],J=q[2],U=(q[3],"".concat(V).concat(S).concat(X)),$=null===(v=st.current[U])||void 0===v?void 0:v.current,G=null===(p=vt.current[U])||void 0===p?void 0:p.current;if($&&G){var Q,Z=$.getBoundingClientRect(),ee=G.getBoundingClientRect(),ne=Z.right-I.left,te=ee.left-I.left,ie=Z.top+Z.height/2-I.top,oe=ee.top+ee.height/2-I.top;if(Ce){var re=null!==(g=null===(f=wn.current)||void 0===f?void 0:f.getBoundingClientRect().top)&&void 0!==g?g:0,le=null!==(x=null===(h=yn.current)||void 0===h?void 0:h.getBoundingClientRect().top)&&void 0!==x?x:0,ue=re+(null!==(y=null===(m=wn.current)||void 0===m?void 0:m.clientHeight)&&void 0!==y?y:1/0),ce=le+(null!==(w=null===(b=yn.current)||void 0===b?void 0:b.clientHeight)&&void 0!==w?w:1/0),ae=function(e,n,t){return Math.max(n,Math.min(t,e))};ie=ae(Z.top+Z.height/2,re,ue)-I.top,oe=ae(ee.top+ee.height/2,le,ce)-I.top}(Q=Qt(J))&&T.push({id:"line-subsec-".concat(U),x1:ne,y1:ie,x2:te,y2:oe,style:Q,sectionIdx:Number(J.split("-")[0]),isSubSection:!0,subSectionKeyPath:Xe})}}if(Vt(T),Wt.current&&Yt.current){var de=Wt.current.getBoundingClientRect(),se=Yt.current.getBoundingClientRect(),ve=(de.top+de.height/2-I.top+se.top+se.height/2-I.top)/2;Ut({x1:de.right-I.left,x2:se.left-I.left,y:ve})}else Ut(null);if(Ge.size>0){var pe=[],fe=wn.current,ge=yn.current;if(fe&&ge){var he=[],xe=fe.getBoundingClientRect().top,me=ge.getBoundingClientRect().top,ye=xe+fe.clientHeight,be=me+ge.clientHeight,Se=fe.scrollTop,Re=ge.scrollTop,we=I.top,Be=function(e,n,t){return Math.max(n,Math.min(t,e))};Ge.forEach(function(e){var n,t,i,o,r;if("string"==typeof e&&e.includes(S)){var l=e.split(S),u=l[0],c=l[1],a=l[2],d=(l[3],"".concat(u).concat(S).concat(c)),s=null===(n=st.current[d])||void 0===n?void 0:n.current,v=null===(t=vt.current[d])||void 0===t?void 0:t.current;if(!s||!v)return;var p=s.getBoundingClientRect(),f=v.getBoundingClientRect(),g=Qt(a),h=(A=p.right-I.left)+.5*((H=f.left-I.left-0)-A),x=p.top+p.height/2,m=f.top+f.height/2,y=x-xe+Se,b=m-me+Re,R="conn-subsec-".concat(d);he.push({lhsScrollY:y,rhsScrollY:b,x1:A,x2:H,containerTop:we,leftIdx:e,rhsArrayIdx:e,styleColor:(null==g?void 0:g.badgeBorder)||"#6366F1",styleId:R});var w=Be(x,xe,ye),B=Be(m,me,be),T=w-we,_=B-we,E=m>=me-4&&m<=be+4,F="";F=(L=x>=xe-4&&x<=ye+4)&&E?C(A,T,H,_):L&&!E?"M ".concat(A,",").concat(T," L ").concat(h,",").concat(T," L ").concat(h,",").concat(_):!L&&E?"M ".concat(h,",").concat(T," L ").concat(h,",").concat(_," L ").concat(H,",").concat(_):"M ".concat(h,",").concat(T," L ").concat(h,",").concat(_),pe.push({id:R,pathD:F,style:g,leftIdx:e,rhsArrayIdx:e})}else if(Ce){var D=e,k=Zn[D];if(!(null===(r=null==k?void 0:k.refIndexes)||void 0===r?void 0:r.length))return;k.refIndexes.forEach(function(e){var n,t,i=et.findIndex(function(n){return n.selfIndex===e});if(-1!==i){var o=null===(n=st.current[D])||void 0===n?void 0:n.current,r=null===(t=vt.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),u=r.getBoundingClientRect(),c=Gt(D),a=l.right-I.left,d=u.left-I.left-0,s=a+.5*(d-a),v=l.top+l.height/2,p=u.top+u.height/2,f=v-xe+Se,g=p-me+Re,h="conn-".concat(D,"-").concat(i);he.push({lhsScrollY:f,rhsScrollY:g,x1:a,x2:d,containerTop:we,leftIdx:D,rhsArrayIdx:i,styleColor:(null==c?void 0:c.badgeBorder)||"#6366F1",styleId:h});var x=Be(v,xe,ye),m=Be(p,me,be),y=x-we,b=m-we,S=v>=xe-4&&v<=ye+4,R=p>=me-4&&p<=be+4,w="";w=S&&R?C(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),pe.push({id:h,pathD:w,style:c,leftIdx:D,rhsArrayIdx:i})}}})}else{var M=e,N=M;s=null===(i=st.current[M])||void 0===i?void 0:i.current,v=null===(o=vt.current[N])||void 0===o?void 0:o.current;if(!s||!v)return;var A,H;p=s.getBoundingClientRect(),f=v.getBoundingClientRect(),g=Gt(M),h=(A=p.right-I.left)+.5*((H=f.left-I.left-0)-A),x=p.top+p.height/2,m=f.top+f.height/2,y=x-xe+Se,b=m-me+Re,R="conn-".concat(M,"-").concat(N);he.push({lhsScrollY:y,rhsScrollY:b,x1:A,x2:H,containerTop:we,leftIdx:M,rhsArrayIdx:N,styleColor:(null==g?void 0:g.badgeBorder)||"#6366F1",styleId:R});var L;w=Be(x,xe,ye),B=Be(m,me,be),T=w-we,_=B-we,E=m>=me-4&&m<=be+4,F="";F=(L=x>=xe-4&&x<=ye+4)&&E?C(A,T,H,_):L&&!E?"M ".concat(A,",").concat(T," L ").concat(h,",").concat(T," L ").concat(h,",").concat(_):!L&&E?"M ".concat(h,",").concat(T," L ").concat(h,",").concat(_," L ").concat(H,",").concat(_):"M ".concat(h,",").concat(T," L ").concat(h,",").concat(_),pe.push({id:R,pathD:F,style:g,leftIdx:M,rhsArrayIdx:N})}}),un.current=he}nn(pe)}else nn([]),un.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{Bn.current=!1}}},[nt,Zn,et,vn,Yn,$t,Gt,Ce,He,Xe,Ge,Et,Ft]),ei=c(function(){var e,n,t,i,o,r,l,u,c,a,d,s,v,p,f=un.current;if(f.length&&!on.current){var g=null!==(n=null===(e=wn.current)||void 0===e?void 0:e.scrollTop)&&void 0!==n?n:0,h=null!==(i=null===(t=yn.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,x=null!==(r=null===(o=wn.current)||void 0===o?void 0:o.clientHeight)&&void 0!==r?r:1/0,m=null!==(u=null===(l=yn.current)||void 0===l?void 0:l.clientHeight)&&void 0!==u?u:1/0,y=null!==(a=null===(c=wn.current)||void 0===c?void 0:c.getBoundingClientRect().top)&&void 0!==a?a:0,b=null!==(s=null===(d=yn.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==s?s:0,S=y+x,R=b+m,w=null!==(p=null===(v=jt.current)||void 0===v?void 0:v.getBoundingClientRect().top)&&void 0!==p?p:0,B=function(e,n,t){return Math.max(n,Math.min(t,e))};f.forEach(function(e){var n=e.lhsScrollY-g+y,t=e.rhsScrollY-h+b,i=ln.current[e.styleId+"-stroke"],o=ln.current[e.styleId+"-bg"];if(i||o){var r,l=B(n,y,S),u=B(t,b,R),c=l-w,a=u-w,d=n>=y-4&&n<=S+4,s=t>=b-4&&t<=R+4,v=e.x1+.5*(e.x2-e.x1);r=d&&s?C(e.x1,c,e.x2,a):d&&!s?"M ".concat(e.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(e.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))}})}},[]);u(function(){sn.current=Zt},[Zt]);var ni=r(null),ti=r(null),ii=c(function(){un.current.length>0&&!on.current||(null!==ni.current&&clearTimeout(ni.current),ni.current=setTimeout(function(){sn.current(),ni.current=null},50))},[]),oi=c(function(){qe(!0),We(!1),null!==ti.current&&clearTimeout(ti.current),null!==ni.current&&(clearTimeout(ni.current),ni.current=null),ti.current=setTimeout(function(){var e,n,t,i,o,r,l,u,c,a;if(un.current=[],an.current&&null!==dn.current&&null!==Pt.current){var d=dn.current,s=Pt.current,v=null,p=null,f=null,g=null;if("string"==typeof d&&d.includes(S)){var h=d.split(S),x="".concat(h[0]).concat(S).concat(h[1]);v=(null===(e=st.current[x])||void 0===e?void 0:e.current)||null,p=(null===(n=vt.current[x])||void 0===n?void 0:n.current)||null,f=(null===(t=ft.current[h[2]])||void 0===t?void 0:t.current)||(null===(i=at.current[Number(h[2])])||void 0===i?void 0:i.current)||null,g=(null===(o=gt.current[h[3]])||void 0===o?void 0:o.current)||(null===(r=dt.current[Number(h[3])])||void 0===r?void 0:r.current)||null}else v=(null===(l=ht.current[d])||void 0===l?void 0:l.current)||null,f=(null===(u=at.current[d])||void 0===u?void 0:u.current)||null,p=(null===(c=pt.current[s])||void 0===c?void 0:c.current)||null,g=(null===(a=dt.current[s])||void 0===a?void 0:a.current)||null;if(v&&p&&f&&g){if(f.style.paddingTop="0px",g.style.paddingTop="0px",!Ce){var m=v.getBoundingClientRect(),y=p.getBoundingClientRect(),b=m.top-y.top;b>0?g.style.paddingTop="".concat(b,"px"):b<0&&(f.style.paddingTop="".concat(Math.abs(b),"px"))}var R=wn.current,C=yn.current;if(R&&C){var w=v.getBoundingClientRect().top-R.getBoundingClientRect().top+R.scrollTop,B=p.getBoundingClientRect().top-C.getBoundingClientRect().top+C.scrollTop-(w-R.scrollTop);Math.abs(C.scrollTop-B)>1&&(C.scrollTop=B)}}}sn.current(),an.current&&We(!0),qe(!1),ti.current=null},150)},[Ce,Zn,et]),ri=c(function(e){var n,t,i,o,r,l,u,c,a,d;if(null!==In.current&&Tn.current&&Math.abs(e.currentTarget.scrollTop-In.current)<=2){var s=Tn.current;In.current=null,Tn.current=null,s()}if(!Ue.current){if(Ce||ii(),an.current){var v=dn.current,p=Pt.current,f=wn.current,g=yn.current;if(null!==v&&null!==p&&f&&g){var h="string"==typeof v&&v.includes(S)?null===(n=st.current["".concat(v.split(S)[0]).concat(S).concat(v.split(S)[1])])||void 0===n?void 0:n.current:null===(t=ht.current[v])||void 0===t?void 0:t.current,x="string"==typeof p&&p.includes(S)?null===(i=vt.current["".concat(p.split(S)[0]).concat(S).concat(p.split(S)[1])])||void 0===i?void 0:i.current:null===(o=pt.current[p])||void 0===o?void 0:o.current;if(h&&x&&zt.current){var m=void 0,y=void 0;if("string"==typeof v&&v.includes(S)){var b=v.split(S),R="".concat(b[0]).concat(S).concat(b[1]);m=null===(r=st.current[R])||void 0===r?void 0:r.current,y=null===(l=vt.current[R])||void 0===l?void 0:l.current}else m=null===(u=st.current[v])||void 0===u?void 0:u.current,y=null===(c=vt.current[p])||void 0===c?void 0:c.current;var C=null!==(d=null===(a=jt.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==d?d:0,w=f.getBoundingClientRect().top,B=w+f.clientHeight;g.getBoundingClientRect().top;g.clientHeight;if(m&&y){var I=m.getBoundingClientRect(),T=y.getBoundingClientRect(),_=I.top+I.height/2;T.top,T.height;var E=((D=_,k=w,M=B,Math.max(k,Math.min(M,D)))-C).toString();zt.current.setAttribute("y1",E),zt.current.setAttribute("y2",E);var F=_>=w-4&&_<=B+4;zt.current.setAttribute("visibility",F?"visible":"hidden")}}}}var D,k,M;un.current.length>0&&!cn.current&&(cn.current=!0,requestAnimationFrame(function(){ei(),cn.current=!1}))}},[ei,Ce,ii]);u(function(){var e=setTimeout(ii,250);window.addEventListener("resize",oi);var n=null,t=null;return xn.current&&(n=new ResizeObserver(ii)).observe(xn.current),jt.current&&(t=new ResizeObserver(ii)).observe(jt.current),function(){clearTimeout(e),null!==ni.current&&clearTimeout(ni.current),null!==ti.current&&clearTimeout(ti.current),window.removeEventListener("resize",oi),null==n||n.disconnect(),null==t||t.disconnect()}},[Gn,Qn,bt,nt,Et,Ft,Zn,et,Yn,ii,oi,He,Xe,ze,Ge]),u(function(){an.current=He},[He]),u(function(){dn.current=Xe},[Xe]);var li=c(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,u=null!==(o=null==t?void 0:t.sourceSide)&&void 0!==o?o:"left";Wn(),null!=e&&(n?Ne("No counterpart exists for this section."):He&&Xe===e?r?Tt():null==l||l():(Qe(new Set([e])),nn([]),un.current=[],De(!0),Ue.current=!0,Je(e),dn.current=e,Le(!0),an.current=!0,We(!1),bn.current&&(bn.current.style.height="0px"),Sn.current&&(Sn.current.style.height="0px"),Rn.current&&(Rn.current.style.height="0px"),Cn.current&&(Cn.current.style.height="0px"),requestAnimationFrame(function(){var n,t,i,o,r,c="string"==typeof e&&e.includes(S),a=null,d=null,s=null;if(c){var v=e.split(S),p="".concat(v[0]).concat(S).concat(v[1]);a=(null===(n=st.current[p])||void 0===n?void 0:n.current)||null,d=(null===(t=vt.current[p])||void 0===t?void 0:t.current)||null,s=d?e:null}else if(a=(null===(i=ht.current[e])||void 0===i?void 0:i.current)||null,Ce){var f=Zn[e],g=(null==f?void 0:f.refIndexes)||[];if(g.length>0){var h=g[0],x=et.findIndex(function(e){return e.selfIndex===h});-1!==x&&(d=(null===(r=pt.current[x])||void 0===r?void 0:r.current)||null,s=x)}}else d=(null===(o=pt.current[e])||void 0===o?void 0:o.current)||null,s=d?e:null;Pt.current=s;var m=wn.current,y=yn.current,b=function(){!function(){var n,t,i,o,r,l,u,a,d,v,p,f,g=null,h=null,x=null,m=null;if(c){var y=e.split(S),b="".concat(y[0]).concat(S).concat(y[1]);g=(null===(n=ft.current[y[2]])||void 0===n?void 0:n.current)||(null===(t=at.current[Number(y[2])])||void 0===t?void 0:t.current)||null,h=(null===(i=gt.current[y[3]])||void 0===i?void 0:i.current)||(null===(o=dt.current[Number(y[3])])||void 0===o?void 0:o.current)||null,x=(null===(r=st.current[b])||void 0===r?void 0:r.current)||g,m=(null===(l=vt.current[b])||void 0===l?void 0:l.current)||h}else{var R=Number(e),C=null!==s?Number(s):R;g=(null===(u=at.current[R])||void 0===u?void 0:u.current)||null,h=(null===(a=dt.current[C])||void 0===a?void 0:a.current)||null,x=(null===(d=st.current[R])||void 0===d?void 0:d.current)||(null===(v=ht.current[R])||void 0===v?void 0:v.current)||g,m=(null===(p=vt.current[C])||void 0===p?void 0:p.current)||(null===(f=pt.current[C])||void 0===f?void 0:f.current)||h}if(x&&m&&g&&h){g.style.paddingTop="0px",h.style.paddingTop="0px";var w=x.getBoundingClientRect(),B=m.getBoundingClientRect(),I=w.top-B.top;I>0?h.style.paddingTop="".concat(I,"px"):I<0&&(g.style.paddingTop="".concat(Math.abs(I),"px"))}}(),We(!0),sn.current&&sn.current(),Ue.current=!1,"right"===u&&y?y.dispatchEvent(new Event("scroll")):m&&m.dispatchEvent(new Event("scroll")),De(!1),null==l||l()};if(!a||!m)return Ue.current=!1,De(!1),void(null==l||l());if(d&&y){if(!Ce){var R=0;R="right"===u?d?d.getBoundingClientRect().top:0:a?a.getBoundingClientRect().top:0;var C=xn.current,B=(null==C?void 0:C.getBoundingClientRect().top)||0,I=C?C.scrollTop+R-B-150:0;return C?void w(C,I,200,b):void b()}var T=a.getBoundingClientRect().top-m.getBoundingClientRect().top+m.scrollTop,_=d.getBoundingClientRect().top-y.getBoundingClientRect().top+y.scrollTop,E=200;if("left"===u){var F=_-(T-m.scrollTop);F<0&&bn.current&&(bn.current.style.height="".concat(Math.abs(F),"px")),requestAnimationFrame(function(){var e,n=y.scrollHeight-y.clientHeight;if(F<0)e=0;else{if(F>n){var t=F-n;return Sn.current&&(Sn.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){w(y,F,E,b)})}e=F}w(y,e,E,b)})}else{var D=T-(_-y.scrollTop);D<0&&Rn.current&&(Rn.current.style.height="".concat(Math.abs(D),"px")),requestAnimationFrame(function(){var e,n=m.scrollHeight-m.clientHeight;if(D<0)e=0;else{if(D>n){var t=D-n;return Cn.current&&(Cn.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){w(m,D,E,b)})}e=D}w(m,e,E,b)})}}else b()})))},[Xe,Wn,et,He,Ce,Zn,Tt]),ui=c(function(e,n,t,i){var o,r="string"==typeof i?m(i).trim():m(null==i?void 0:i.deviation_summary).trim(),l=e.currentTarget;zn();var u="left";(null===(o=yn.current)||void 0===o?void 0:o.contains(l))&&(u="right");var c=function(){var e,t,i,o;if("string"==typeof n&&n.includes(S)){var r=n.split(S),l="".concat(r[0]).concat(S).concat(r[1]);return"right"===u?null===(e=vt.current[l])||void 0===e?void 0:e.current:null===(t=st.current[l])||void 0===t?void 0:t.current}return"right"===u?null===(i=vt.current[n])||void 0===i?void 0:i.current:null===(o=st.current[n])||void 0===o?void 0:o.current};if(t)return Tt(),Qe(new Set),nn([]),un.current=[],void(r&&requestAnimationFrame(function(){var e=c()||l;Ln({open:!0,anchorEl:e,summary:i})}));li(n,t,r?{toggleIfSame:!1,sourceSide:u,onReady:function(){var e=c()||l;Ln({open:!0,anchorEl:e,summary:i})}}:{toggleIfSame:!1,sourceSide:u})},[li,zn,Ln,Tt]),ci=c(function(){var e,n=Dn.sectionIdx,t=Dn.isOrphan;if(jn(),null!=n){var i="left";Dn.anchorEl&&(null===(e=yn.current)||void 0===e?void 0:e.contains(Dn.anchorEl))&&(i="right"),li(n,t,{sourceSide:i})}},[li,Dn.isOrphan,Dn.sectionIdx,Dn.anchorEl,jn]),ai=c(function(){jn(),Tt(),Qe(new Set),nn([]),un.current=[]},[jn,Tt]),di=null!==Dn.sectionIdx&&Ge.has(Dn.sectionIdx),si=j({proposedSections:Zn,existingSections:et,parentDeviationRecord:tt,expandedSections:Et,maintainRelativeOrder:!!Ce,scrollContainerRef:xn,leftContainerRef:wn,lhsBadgeRefs:st,rhsBadgeRefs:vt}),vi=si.showDeviationNavigation,pi=si.showOpenNodeRef,fi=l(function(){if(!be)return null;for(var e in tt){if((tt[e]||[]).some(function(e){return e.id===be}))return e}return null},[be,tt]),gi=r(null),hi=r(null);u(function(){if(be&&gi.current!==be){hi.current!==be&&(jn(),zn(),Tt(),Qe(new Set),nn([]),un.current=[],hi.current=be);var e=!1,t=0,i=null,o=150,r=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},l=function(){var u,c,a,d;if(!e){var s=null,v=null;for(var p in tt){var f=tt[p].find(function(e){return e.id===be});if(f){s=p,v=f;break}}if(v&&s){var g=Zn.findIndex(function(e){return e.id===s}),h=et.findIndex(function(e){return e.id===s}),x=-1===g&&-1!==h,m=r(Zn,v.id),y=r(et,v.id);if(m&&!y&&!x){var b=m.split("-"),R=Number(b[0]);if(Ce){var C=null===(c=null===(u=Zn[R])||void 0===u?void 0:u.refIndexes)||void 0===c?void 0:c[0],w=et.findIndex(function(e){return e.selfIndex===C});-1!==w&&(R=w)}y=n([R],b.slice(1),!0).join("-")}if(m||y){var B=x||!m&&!!y,I=m?Number(m.split("-")[0]):g,T=y?Number(y.split("-")[0]):h;if(B){if(!(Ce?!!Et["right-".concat(T)]:!!Et[String(T)])&&T>=0)return kt(T,"right"),t+=1,void(i=setTimeout(l,450))}else if(!(Ce?!!Et["left-".concat(I)]:!!Et[String(I)])&&I>=0)return kt(I,"left"),t+=1,void(i=setTimeout(l,450));var _,E=m||"",F=y||"",D="".concat(v.id).concat(S,"0").concat(S).concat(E).concat(S).concat(F),k="".concat(v.id).concat(S,"0"),M=null===(a=st.current[k])||void 0===a?void 0:a.current,N=null===(d=vt.current[k])||void 0===d?void 0:d.current,A=B||!M&&!!N,H=A?N:M;if(_=Ce?A?yn.current:wn.current:xn.current,H&&_){var L=H.getBoundingClientRect();if(0===L.height)return void((t+=1)<20&&(i=setTimeout(l,o)));var j=_.getBoundingClientRect(),O=L.top-j.top+_.scrollTop-j.height/2+L.height/2,P=function(){var n,t,i,o,r;if(!e){gi.current=be;var l=window.getComputedStyle(H).color;M&&(M.style.transition="box-shadow 300ms ease-in-out",M.style.boxShadow="0 0 10px ".concat(l)),N&&(N.style.transition="box-shadow 300ms ease-in-out",N.style.boxShadow="0 0 10px ".concat(l)),setTimeout(function(){M&&(M.style.boxShadow=""),N&&(N.style.boxShadow="")},2e3);var u=(null===(t=null===(n=v.evaluationResult)||void 0===n?void 0:n.deviations)||void 0===t?void 0:t[0])||v,c=(null===(i=v.evaluationResult)||void 0===i?void 0:i.evaluation_outputs)||v.evaluation_outputs;if(!(!!M&&!!N)){var a=A?(null===(o=vt.current[k])||void 0===o?void 0:o.current)||N:(null===(r=st.current[k])||void 0===r?void 0:r.current)||M;return Ln({open:!0,anchorEl:a,summary:{deviation_summary:u.deviation_summary||u,evaluation_outputs:c}}),void(null==Se||Se())}li(D,!1,{toggleIfSame:!1,sourceSide:"left",onReady:function(){var e,n=(null===(e=st.current[k])||void 0===e?void 0:e.current)||M;Ln({open:!0,anchorEl:n,summary:{deviation_summary:u.deviation_summary||u,evaluation_outputs:c}})}})}};Math.abs(_.scrollTop-O)<=2?P():(In.current=O,Tn.current=P,_.scrollTo({top:O,behavior:"smooth"}),i&&clearTimeout(i),i=setTimeout(function(){if(Tn.current){In.current=null;var e=Tn.current;Tn.current=null,e()}},800))}else(t+=1)<20&&(i=setTimeout(l,o))}else(t+=1)<20&&(i=setTimeout(l,o))}else(t+=1)<20&&(i=setTimeout(l,o))}};return i=setTimeout(l,o),function(){e=!0,i&&clearTimeout(i)}}},[be,tt,Zn,et,Ce,Et,kt,li,Ln]);var xi=function(e){var n=e.section,t=e.keyPath,o=e.depth,r=void 0===o?0:o,l=e.columnKey,u=void 0===l?"left":l,c=e.parentNodeId;return i(z,{section:n,keyPath:t,depth:r,columnKey:u,parentNodeId:void 0===c?"":c,expandedSubSections:Ft,setExpandedSubSections:Dt,maintainRelativeOrder:Ce||!1,proposedSections:Zn,existingSections:et,treeData:de,deviationNumberRegistry:it,connectedSections:Ge,activeSideBySideSection:Xe,resolvedMarkdownStyles:hn,getSubSectionRef:mt,getSubSectionCompareStyle:Qt,getBadgeRef:yt,openMoreFunctionsPopup:At,openSummaryPopup:ui,showDeviationBadges:Be,resetSideBySide:Tt,setConnectedSections:Qe,setConnectedLines:nn,cachedConnectedPositions:un})};return t(a,e({ref:mn,sx:e(e({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},Ce?{}:{overflow:"visible"}),{position:"relative"})},{children:[Te&&i(a,e({sx:{position:"absolute",inset:0,bgcolor:"rgba(255, 255, 255, 0.6)",backdropFilter:"blur(10px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"8px"}},{children:i(k,{})})),Hn.open&&i(W,{open:Hn.open,anchorEl:Hn.anchorEl,containerEl:Ot.current,clipTopEl:Wt.current,scrollContainerEl:xn.current,onClose:ai,summary:Hn.summary}),i(D,{open:Dn.open,anchorEl:Dn.anchorEl,sectionTitle:Dn.sectionTitle,referenceSectionTitle:Dn.refSectionTitle,onClose:Wn,onOpenCognitiveCompare:Ht,onOpenSideBySide:ci,onConnect:Lt,isConnected:di,isOrphan:Dn.isOrphan}),En.open&&i(F,{open:En.open,popupRef:Pn,position:Mn,popupConfig:xe,onClose:function(){Nn(null),Fn(function(n){return e(e({},n),{open:!1})}),On(null)},markdownStyles:fe,sectionTitle:En.sectionTitle,referenceSectionTitle:En.refSectionTitle,cognitiveData:En.cognitiveData,anchorEl:En.anchorEl,sectionAnchorEl:En.sectionAnchorEl,scrollContainerEl:xn.current,badgeStyle:En.badgeStyle,docData:En.docData,deviationData:En.deviationData,isLoading:En.isLoading}),i(d,e({open:!!Me,autoHideDuration:8e3,onClose:function(){return Ne(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:i(s,e({onClose:function(){return Ne(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:Me}))})),i(O,{componentHeaderText:ae,displayConfig:he,maintainRelativeOrder:Ce,onToggleView:function(e){_e(!0),setTimeout(function(){we(!e),Tt(),jn(),Qe(new Set),nn([]),un.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){_e(!1)},600)})})},50)}}),i(a,e({ref:xn,onScroll:ri,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:Ce?"hidden":"auto",borderTop:St&&Rt?"none":"1.5px solid #EEF0F4"}},{children:i(a,e({sx:e({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},Ce?{flex:1,minHeight:0}:{})},{children:t(a,e({ref:jt,sx:e({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"40px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},Ce?{flex:1,overflow:"visible"}:{})},{children:[t("svg",e({ref:tn,style:{position:"absolute",top:0,left:0,width:fn.width||"100%",height:fn.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",opacity:Ke?0:1,transition:"opacity 0.15s ease-in-out"}},{children:[Jt&&i("g",{children:i("line",{x1:Jt.x1,y1:Jt.y,x2:Jt.x2,y2:Jt.y,stroke:It.badgeBorder,strokeWidth:"1.5"})}),qt.map(function(n){var o,r,l,u,c,d,s=n.x1+.5*(n.x2-n.x1),v=(n.y1+n.y2)/2;if("Not Defined"===n.style.label&&!n.hasCognitive)return null;if(n.isSubSection?He&&Xe===n.subSectionKeyPath&&ze:He&&Xe===n.sectionIdx&&ze)return null;if(!Ce){var p=n.isSubSection?C(n.x1,n.y1,n.x2,n.y2):"M ".concat(n.x1," ").concat(n.y1," L ").concat(n.x2," ").concat(n.y2),g=Zn[n.sectionIdx]||{title:"",content:""},x=et[n.sectionIdx]||{title:"",content:""};if(console.log("Base and Ref Sections for Badge:",g,x),n.isSubSection&&n.subSectionKeyPath){var m=n.subSectionKeyPath.includes(S)?n.subSectionKeyPath.split(S):[],y=m[2]||n.subSectionKeyPath,b=m[3]||y,R=y.split("-").map(Number),w=b.split("-").map(Number),B=null,I=null;R.length>0&&(B=Zn[R[0]]),w.length>0&&(I=et[w[0]]);var T=(null==B?void 0:B.title)||"",E=(null==I?void 0:I.title)||"";console.log("Root Parent Titles:",T,E);for(var F=1;F<R.length;F++)(null==B?void 0:B.subsections)&&(B=B.subsections[R[F]]);for(F=1;F<w.length;F++)(null==I?void 0:I.subsections)&&(I=I.subsections[w[F]]);B&&(g=e(e({},B),{title:T||B.title})),console.log("Base Section for Subsection Badge:",g),I&&(x=e(e({},I),{title:E||I.title})),console.log("Ref Section for Subsection Badge:",x)}var D=!(null===(o=g.cognitiveData)||void 0===o?void 0:o.isMissingRationale)||Boolean(null===(l=null===(r=g.cognitiveData)||void 0===r?void 0:r.decisioning)||void 0===l?void 0:l.length),k=(null===(d=null===(c=null===(u=g.evaluationResult)||void 0===u?void 0:u.cognitive_decisioning)||void 0===c?void 0:c.decisioning_factors)||void 0===d?void 0:d.length)||!1,N=D||k;return t("g",{children:[i("path",{d:p,fill:"none",stroke:n.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),i("foreignObject",e({x:s-100,y:v-14,width:"200",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:i(a,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:t(a,e({onClick:function(e){e.stopPropagation(),N&&(En.open&&An===n.id?zn():(On(n.id),Nt(Mt(e.currentTarget,g,x,n.sectionIdx,n.style))))},sx:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:n.style.badgeBg,color:n.style.badgeText,border:"1px solid ".concat(n.style.badgeBorder),borderRadius:"12px",px:1.5,py:.5,fontWeight:600,textAlign:"center",whiteSpace:"nowrap",cursor:N?"pointer":"default"}},{children:[n.style.badgeText===_&&null==n.style.label?i(M,{color:n.style.badgeText}):0===n.style.label?"Same":n.style.label,i(a,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:i(h,{})})),N&&i(f,{size:11,style:{transform:En.open&&An===n.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},n.id)}return null}),en.map(function(n){var o,r=n.pathD,l=(null===(o=n.style)||void 0===o?void 0:o.badgeBorder)||"#6366F1",u="conn-marker-".concat(n.id),c="".concat(n.id,"-bg"),a="".concat(n.id,"-stroke");return t("g",{children:[i("defs",{children:i("clipPath",e({id:"connections-clip"},{children:i("marker",e({id:u,markerWidth:"8",markerHeight:"6",refX:"7",refY:"3",orient:"auto"},{children:i("polygon",{points:"0 0, 8 3, 0 6",fill:l})}))}))}),i("path",{ref:function(e){ln.current[c]=e},d:r,fill:"none",stroke:"#FFFFFF",strokeWidth:"4",strokeOpacity:"0.7"}),i("path",{ref:function(e){ln.current[a]=e},d:r,fill:"none",stroke:l,strokeWidth:"1.75",markerEnd:"url(#".concat(u,")")})]},n.id)})]})),t(a,e({sx:e({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},Ce?{flex:1,overflow:"visible"}:{})},{children:[i(a,e({ref:Wt,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(v,e({title:Jn,placement:"top"},{children:i(p,e({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:Jn}))}))})),t(a,e({ref:wn,onScroll:ri,sx:e({p:"12px",display:"flex",flexDirection:"column"},Ce?{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:Rn,style:{width:"100%",height:"0px",flexShrink:0}}),rt&&Zn.map(function(n,o){var r,l,u=!n.title&&!n.content;if(Ce&&u)return null;var c=n,d=Gt(o,"left"),s=Ce?!(null===(r=c.refIndexes)||void 0===r?void 0:r.length)||c.selfIndex<0:!et[o],v=Ce?"number"==typeof c.selfIndex&&c.selfIndex>=0?c.selfIndex+1:null:o+1,p=Ge.has(o),f=y(c.evaluationResult,null==d?void 0:d.deviationLabel);return i(a,e({ref:xt(o),sx:{mb:1,width:"100%"}},{children:t(a,e({sx:{position:"relative",width:"100%"}},{children:[i(a,e({ref:at.current[o],sx:e({width:"100%",display:"flex"},p&&{borderRadius:"6px",outline:"2px solid ".concat((null==d?void 0:d.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:i(P,{section:n,idx:o,columnKey:"left",colRef:xt("left-accordion-".concat(o)),mb:0,treeData:de,proposedSections:Zn,existingSections:et,deviationNumberRegistry:it,getSectionCompareStyle:Gt,getBadgeRef:yt,connectedSections:Ge,openMoreFunctionsPopup:At,openSummaryPopup:ui,deviationNodeIdToView:be,deviationTargetParentId:fi,parentNodeId:(null===(l=null==de?void 0:de.input_index_map)||void 0===l?void 0:l[0])||"",isExpanded:Ce?!!Et["left-".concat(o)]:!!Et[String(o)],onToggle:function(){ai(),kt(o,"left")},navigation:n.id?vi[n.id]:null,showOpenNodeRef:pi,resolvedMarkdownStyles:hn,maintainRelativeOrder:Ce,showDeviationBadges:Be,renderSubSections:xi})})),Ce&&d&&t(a,e({ref:st.current[o],onClick:function(e){var t=Ce?et.find(function(e){var n;return null===(n=c.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""}:et[o]||{title:"",content:""};At(e,n,s,t,o,d)},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:.4,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[null!==v&&i(a,e({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(d.badgeBorder)}},{children:v})),i(a,e({component:"span",sx:{fontSize:"11px",px:.25}},{children:!he.isLoading||null!=c.evaluationResult&&null!=c.evaluationResult?s?"No Deviation Found":"N/A"===f||"NA"===f?"N/A":0==f||null==f?"Same":"".concat(f):i(M,{color:d.badgeText})})),i(g,{size:11,color:d.badgeText})]}))]}))}),"left-row-".concat(o))}),i("div",{ref:Cn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),i(a,e({ref:Ot,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:i(a,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:t(a,e({onClick:function(n){n.stopPropagation(),En.open&&An===Ct?zn():(On(Ct),Nt(Mt(n.currentTarget,{title:"",content:"",evaluationResult:wt,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,Ct,!0,e(e({},It),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-5px",borderRadius:"20px",bgcolor:It.badgeBg,color:It.badgeText,border:"1px solid ".concat(It.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=Bt?Bt:i(M,{}),i(a,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:i(h,{})})),i(f,{size:11,style:{transform:En.open&&An===Ct?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),t(a,e({sx:e({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},Ce?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[Fe&&i(x,{sections:11}),i(a,e({ref:Yt,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"40px",display:"flex",alignItems:"center",overflowX:"hidden"}},{children:i(v,e({title:Un,placement:"top"},{children:i(p,e({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:Un}))}))})),t(a,e({ref:yn,onScroll:ri,sx:e({p:"12px",display:"flex",flexDirection:"column"},Ce?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-120px",pl:"140px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[i("div",{ref:bn,style:{width:"100%",height:"0px",flexShrink:0}}),rt&&et.map(function(n,o){var r,l=n,u=[],c=!1,d=null,s=-1;if(Ce){u=Zn.filter(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(l.selfIndex))&&e.selfIndex>=0}).map(function(e){return e.selfIndex+1}),s=Zn.findIndex(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(l.selfIndex))&&e.selfIndex>=0});var v=Zn.findIndex(function(e,n){var t;return Ge.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(l.selfIndex))});(c=-1!==v)&&(d=Gt(v))}else u=[o+1],(c=Ge.has(o))&&(d=Gt(o));var p=Gt(Ce&&-1!==s?s:o);return i(a,e({ref:pt.current[o],sx:{mb:1,width:"100%"}},{children:t(a,e({sx:{position:"relative",width:"100%"}},{children:[i(a,e({ref:dt.current[o],sx:e({width:"100%",display:"flex"},c&&d&&{borderRadius:"6px",outline:"2px solid ".concat(d.badgeBorder),outlineOffset:"1px"})},{children:i(P,{section:n,idx:o,columnKey:"right",colRef:xt("right-accordion-".concat(o)),mb:0,parentNodeId:(null===(r=null==de?void 0:de.input_index_map)||void 0===r?void 0:r[1])||"",isExpanded:Ce?!!Et["right-".concat(o)]:!!Et[String(o)],treeData:de,proposedSections:Zn,existingSections:et,deviationNumberRegistry:it,getBadgeRef:yt,getSectionCompareStyle:Gt,connectedSections:Ge,openMoreFunctionsPopup:At,openSummaryPopup:ui,deviationNodeIdToView:be,deviationTargetParentId:fi,onToggle:function(){ai(),kt(o,"right")},navigation:n.id?vi[n.id]:null,showOpenNodeRef:pi,resolvedMarkdownStyles:hn,maintainRelativeOrder:Ce,showDeviationBadges:Be,renderSubSections:xi})})),Ce&&p&&i(a,e({ref:vt.current[o],"data-section-id":l.id,sx:{position:"absolute",top:"18px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"11px",bgcolor:p.badgeBg,color:p.badgeText,border:"1px solid ".concat(p.badgeBorder),borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:u.length>0?u.join(", "):"-"}))]}))}),"right-row-".concat(o))}),i("div",{ref:Sn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))};export{Y as default};
1
+ import{__assign as e,__spreadArray as n}from"tslib";import{jsxs as t,jsx as i}from"react/jsx-runtime";import{useState as o,useRef as r,useMemo as l,useEffect as u,useCallback as c}from"react";import{Box as d,Snackbar as a,Alert as s,Tooltip as v,Typography as p}from"@mui/material";import{ChevronDown as f,EllipsisVertical as g}from"lucide-react";import{ButtonCognitiveIcon as h}from"../../assests/svg/ButtonCognitiveIcon.js";import x from"./OverlayComponent.js";import{safeStringify as m,extractDeviationScore as y,generateColorPalette as b,DEVIATION_BADGE_SEPARATOR as S,hasValue as R,getBentArrowPath as C,smoothScrollTo as I}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as w,DEFAULT_FIELD_CONFIG as B,DEFAULT_COMPARISON_CONFIG as T}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import{DEFAULT_DEVIAION_COLOR as _,DEFAULT_COMPONENT_HEADER_TEXT as E}from"./CognitiveCompareConstants.js";import F from"./CognitivePopup.js";import D from"./MoreFunctionsPopup.js";import k from"./LoaderComponent.js";import M from"./components/ThreeDotsLoader.js";import{useCognitiveTreeData as N}from"./hooks/useCompareData.js";import{useComparePopups as A}from"./hooks/useComparePopups.js";import{useSectionRefs as H}from"./hooks/useSectionRefs.js";import{useAccordionState as L}from"./hooks/useAccordionState.js";import{useDeviationNavigation as j}from"./hooks/useDeviationNavigation.js";import O from"./components/CompareHeader.js";import P from"./components/SectionAccordion.js";import z from"./components/SubSectionAccordion.js";import W from"./components/CognitiveSummaryPopup.js";var Y=function(Y){var K,q,V,X,J,U,$,G,Q,Z,ee,ne,te,ie,oe,re,le,ue,ce,de,ae,se,ve,pe,fe,ge,he=Y.componentHeaderText,xe=void 0===he?E:he,me=Y.treeData,ye=Y.comparisonConfig,be=Y.leftColumnTitleText,Se=Y.rightColumnTitleText,Re=Y.markdownStyles,Ce=Y.displayConfig,Ie=void 0===Ce?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!0}:Ce,we=Y.popupConfig,Be=Y.deviationData,Te=void 0===Be?{}:Be,_e=Y.deviationNodeIdToView,Ee=Y.resetDeviationNodeId,Fe=o(Ie.maintainRelativeOrder),De=Fe[0],ke=Fe[1],Me=!!De||!!(null==Ie?void 0:Ie.showDeviationBadges),Ne=o(!1),Ae=Ne[0],He=Ne[1],Le=o(!1),je=Le[0],Oe=Le[1],Pe=o(null),ze=Pe[0],We=Pe[1],Ye=o(!1),Ke=Ye[0],qe=Ye[1],Ve=o(null===(q=null!==(K=null==me?void 0:me.newEvaluationResult)&&void 0!==K?K:null==Ie?void 0:Ie.enableDeviationSchemaBackwardCompatibility)||void 0===q||q)[0],Xe=o(!1),Je=Xe[0],Ue=Xe[1],$e=o(!1),Ge=$e[0],Qe=$e[1],Ze=o(null),en=Ze[0],nn=Ze[1],tn=r(!1),on=o(new Set),rn=on[0],ln=on[1],un=o([]),cn=un[0],dn=un[1],an=r(null),sn=r(!1),vn=r(null),pn=r({}),fn=r([]),gn=r(!1),hn=r(!1),xn=r(null),mn=r(function(){}),yn=l(function(){return(null==me?void 0:me.cognitive_decisioning)||{}},[me]),bn=o({width:0,height:0}),Sn=bn[0],Rn=bn[1],Cn=l(function(){return e(e({},w),Re)},[Re]),In=r(null),wn=r(null),Bn=r(null),Tn=r(null),_n=r(null),En=r(null),Fn=r(null),Dn=r(null),kn=r(!1),Mn=r(null),Nn=r(null),An=A(In),Hn=An.cognitivePopup,Ln=An.setCognitivePopup,jn=An.moreFunctions,On=An.setMoreFunctions,Pn=An.position,zn=An.setPosition,Wn=An.activeBadgeId,Yn=An.summaryPopup,Kn=An.setSummaryPopup,qn=An.closeSummaryPopup,Vn=An.setActiveBadgeId,Xn=An.popupRef,Jn=An.closeCognitivePopup,Un=An.closeMoreFunctionsPopup,$n=l(function(){var e,n,t,i,o,r,l;return{fields:null!==(e=null==ye?void 0:ye.fields)&&void 0!==e?e:B,thresholds:{high:null!==(t=null===(n=null==ye?void 0:ye.thresholds)||void 0===n?void 0:n.high)&&void 0!==t?t:T.thresholds.high,medium:null!==(o=null===(i=null==ye?void 0:ye.thresholds)||void 0===i?void 0:i.medium)&&void 0!==o?o:T.thresholds.medium,exact:null!==(l=null===(r=null==ye?void 0:ye.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:T.thresholds.exact}}},[ye]),Gn=o(null),Qn=Gn[0];Gn[1];var Zn=null===(J=null===(V=null==me?void 0:me.documents)||void 0===V?void 0:V[null===(X=null==me?void 0:me.input_index_map)||void 0===X?void 0:X[0]])||void 0===J?void 0:J.title,et=null===(G=null===(U=null==me?void 0:me.documents)||void 0===U?void 0:U[null===($=null==me?void 0:me.input_index_map)||void 0===$?void 0:$[1]])||void 0===G?void 0:G.title,nt=m(be||Zn||"Uploaded Contract"),tt=m(Se||et||"Reference Template"),it=N(me,De,Te,$n,Ve),ot=it.activeProposed,rt=it.existingRule,lt=it.proposedSections,ut=it.existingSections,ct=it.visibleFields,dt=it.parentDeviationRecord,at=it.deviationNumberRegistry,st=it.parseError;u(function(){st&&We("Failed to load comparison: ".concat(st))},[st]);var vt=lt.length>0||ut.length>0,pt=H(ct.map(function(e){return e.key}),Math.max(lt.length,ut.length)),ft=pt.leftRefs,gt=pt.rightRefs,ht=pt.sectionLeftRefs,xt=pt.sectionRightRefs,mt=pt.lhsBadgeRefs,yt=pt.rhsBadgeRefs,bt=pt.sectionRightRowRefs,St=pt.subSectionLeftRefs,Rt=pt.subSectionRightRefs,Ct=pt.sectionRowRefs,It=pt.getSectionRowRef,wt=pt.getSubSectionRef,Bt=pt.getBadgeRef,Tt=rt.analysis,_t=m(null===(Z=null===(Q=null==Tt?void 0:Tt.rule_difference_comparison)||void 0===Q?void 0:Q.summary)||void 0===Z?void 0:Z.overall_summary),Et=!!_t.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),Ft=null!==(ee=null==me?void 0:me.base_root_id)&&void 0!==ee?ee:"-1";null==me||me[Ft];var Dt=Ve?null!==(ve=null!==(de=Te&&(null===(ce=null==Te?void 0:Te[Ft])||void 0===ce?void 0:ce.evaluation_result))&&void 0!==de?de:null===(se=null===(ae=null==me?void 0:me.nodes)||void 0===ae?void 0:ae[Ft])||void 0===se?void 0:se.evaluation_result)&&void 0!==ve?ve:null:null!==(ue=null!==(ie=Te&&(null===(te=null===(ne=null==Te?void 0:Te[Ft])||void 0===ne?void 0:ne.evaluation_result)||void 0===te?void 0:te[0]))&&void 0!==ie?ie:null===(le=null===(re=null===(oe=null==me?void 0:me.nodes)||void 0===oe?void 0:oe[Ft])||void 0===re?void 0:re.evaluation_result)||void 0===le?void 0:le[0])&&void 0!==ue?ue:null,kt=y(Dt),Mt=b(null!==(ge=null===(fe=null===(pe=null==Dt?void 0:Dt.evaluation_outputs)||void 0===pe?void 0:pe.metadata)||void 0===fe?void 0:fe.label_color)&&void 0!==ge?ge:""),Nt=c(function(){var e,n,t,i,o,r;qe(!1),hn.current=!1;var l=xn.current,u=Xt.current;if(null!==l)if("string"==typeof l&&l.includes(S)){var c=l.split(S);(d=(null===(e=St.current[c[2]])||void 0===e?void 0:e.current)||(null===(n=ht.current[Number(c[2])])||void 0===n?void 0:n.current))&&(d.style.paddingTop="0px")}else{var d;(d=null===(t=ht.current[l])||void 0===t?void 0:t.current)&&(d.style.paddingTop="0px")}if(null!==u)if("string"==typeof u&&u.includes(S)){c=u.split(S);(a=(null===(i=Rt.current[c[3]])||void 0===i?void 0:i.current)||(null===(o=xt.current[Number(c[3])])||void 0===o?void 0:o.current))&&(a.style.paddingTop="0px")}else{var a;(a=null===(r=xt.current[u])||void 0===r?void 0:r.current)&&(a.style.paddingTop="0px")}nn(null),xn.current=null,Xt.current=null,Ue(!1),Oe(!1),Tn.current&&(Tn.current.style.height="0px"),_n.current&&(_n.current.style.height="0px"),En.current&&(En.current.style.height="0px"),Fn.current&&(Fn.current.style.height="0px")},[]),At=L({maintainRelativeOrder:!!De,proposedSections:lt,existingSections:ut,activeSideBySideSection:en,connectedSections:rn,resetSideBySide:Nt,setConnectedSections:ln,setConnectedLines:dn,cachedConnectedPositions:fn,svgContainerRef:an,isAnimatingRef:sn,animationTimerRef:vn,calculateLinesRef:mn,sectionLeftRefs:ht,sectionRightRefs:xt,subSectionLeftRefs:St,subSectionRightRefs:Rt}),Ht=At.expandedSections,Lt=At.expandedSubSections,jt=At.setExpandedSubSections,Ot=At.toggleSection,Pt=c(function(n,t,i,o,r,l,u){var c,d,a,s=m(null==t?void 0:t.id)||m(null==i?void 0:i.id)||"",v=(s?yn[s]:null)||(null==t?void 0:t.cognitiveData)||(null==i?void 0:i.cognitiveData)||{section_id:s,decisioning:[],gap:[],relevance_score:0},p=null!==(d=null===(c=Ct.current[o])||void 0===c?void 0:c.current)&&void 0!==d?d:null;return{isLoading:null!==(a=null==Ie?void 0:Ie.isLoading)&&void 0!==a&&a,open:!0,sectionTitle:(null==t?void 0:t.displayTitle)?null==t?void 0:t.title:"no title",refSectionTitle:(null==i?void 0:i.displayTitle)?null==i?void 0:i.title:"no title",cognitiveData:v,anchorEl:n,sectionAnchorEl:p,badgeStyle:l||null,sectionIdx:o,docData:{documents:null==me?void 0:me.documents,input_index_map:null==me?void 0:me.input_index_map},deviationData:function(){var n,r,l=(null==t?void 0:t.evaluationResult)||(null==i?void 0:i.evaluationResult)||null,u=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(e({},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(S)))return u(l);var c=o.split(S)[1];if(!c)return l;var d=(null==t?void 0:t.evaluationResult)||(null==i?void 0:i.evaluationResult)||{},a=(null===(n=null==d?void 0:d.deviation_entries)||void 0===n?void 0:n[c])||(null===(r=null==d?void 0:d.deviations)||void 0===r?void 0:r[c])||null;return a?e(e(e({},d),a),{deviation_summary:(null==a?void 0:a.deviation_summary)||(null==d?void 0:d.deviation_summary),deviation_title:(null==a?void 0:a.deviation_title)||(null==d?void 0:d.deviation_title),deviation_impact:(null==a?void 0:a.deviation_impact)||(null==d?void 0:d.deviation_impact),deviation_explanation:(null==a?void 0:a.deviation_explanation)||(null==d?void 0:d.deviation_explanation),evaluation_outputs:(null==a?void 0:a.evaluation_outputs)||(null==d?void 0:d.evaluation_outputs),cognitive_decisioning:(null==a?void 0:a.cognitive_decisioning)||(null==d?void 0:d.cognitive_decisioning)}):u(l)}(),isOrphan:!!r}},[yn,me]),zt=c(function(e){Un(),zn(null),Ln(e)},[Un]),Wt=function(e,n,t,i,o,r){var l;if(e.stopPropagation(),jn.open&&jn.sectionIdx===o)Un();else{var u=e.currentTarget,c="left";(null===(l=Bn.current)||void 0===l?void 0:l.contains(u))&&(c="right");hn.current&&Nt(),ln(new Set),dn([]),fn.current=[],Jn(),Yn.open?hi():qn(),requestAnimationFrame(function(){var e=function(){var e,n,t,i;if("string"==typeof o&&o.includes(S)){var r=o.split(S),l="".concat(r[0]).concat(S).concat(r[1]);return"right"===c?null===(e=yt.current[l])||void 0===e?void 0:e.current:null===(n=mt.current[l])||void 0===n?void 0:n.current}return"right"===c?null===(t=yt.current[o])||void 0===t?void 0:t.current:null===(i=mt.current[o])||void 0===i?void 0:i.current}()||u;On(Pt(e,n,i,o,t,r))})}},Yt=c(function(){null!==jn.sectionIdx&&jn.anchorEl?zt(e(e({},jn),{open:!0})):Un()},[jn,Un,zt]),Kt=c(function(){var e=jn.sectionIdx,n=jn.isOrphan;Un(),qn(),null!==e&&(n?We("No counterpart exists to connect to."):(hn.current&&Nt(),dn([]),fn.current=[],ln(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){mn.current&&mn.current()},50)))},[jn.sectionIdx,jn.isOrphan,Un,qn,Nt]),qt=r(null),Vt=r(null),Xt=r(null),Jt=r(null),Ut=r(null),$t=r(null),Gt=o([]),Qt=Gt[0],Zt=Gt[1];r(null);var ei=o(null),ni=ei[0],ti=ei[1];u(function(){if(Qn){var e=$n.fields.find(function(e){return e.analysisKey===Qn||e.key===Qn});if(e){var n=ft.current[e.key]||gt.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[Qn,$n.fields]);var ii=c(function(e){var n,t,i,o,r,l,u,c,d,a=null===(n=null==Tt?void 0:Tt.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!a||!a[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var s=a[e],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===(d=s.highlights)||void 0===d?void 0:d.ruleB_spans)||[],hasContent:!!v}},[Tt]),oi=c(function(n,t){var i,o,r,l,u,c,d;void 0===t&&(t="left");var a=null,s=null;if("left"===t)if(a=lt[n],De&&a){var v=ut.filter(function(e){var n;return null===(n=a.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)});s=v.find(function(e){return e.evaluationResult})||v[0]}else s=ut[n];else if(s=ut[n],De&&s){var p=lt.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(s.selfIndex)});a=p.find(function(e){return e.evaluationResult})||p[0]}else a=lt[n];var f=(null==a?void 0:a.relation)&&"not_defined"!==a.relation,g=(null==s?void 0:s.relation)&&"not_defined"!==s.relation,h=!(!(null==a?void 0:a.cognitiveData)&&!(null==s?void 0:s.cognitiveData));if(!f&&!g&&!h)return e(e({},b(_)),{label:"Not Defined"});var x=null!==(o=null!==(i=null==a?void 0:a.evaluationResult)&&void 0!==i?i:null==s?void 0:s.evaluationResult)&&void 0!==o?o:null,m=null===(r=null==x?void 0:x.evaluation_outputs)||void 0===r?void 0:r.output_value,y=null!==(c=null===(u=null===(l=null==x?void 0:x.evaluation_outputs)||void 0===l?void 0:l.metadata)||void 0===u?void 0:u.label_color)&&void 0!==c?c:_;return e(e({},b(y)),null!=x?{label:null!==(d=m)&&void 0!==d?d:""}:{label:null})},[lt,ut,yn,$n,De]),ri=c(function(n){for(var t,i,o,r,l,u,c,d,a,s=n.split("-").map(Number),v=lt[s[0]],p=ut[s[0]],f=1;f<s.length;f++)(null==v?void 0:v.subsections)&&(v=v.subsections[s[f]]),(null==p?void 0:p.subsections)&&(p=p.subsections[s[f]]);if(!v&&!p)return null;var g=(null==v?void 0:v.relation)&&"not_defined"!==v.relation,h=(null==p?void 0:p.relation)&&"not_defined"!==p.relation,x=m(null==v?void 0:v.id)||m(null==p?void 0:p.id)||"",y=!(!(null==v?void 0:v.cognitiveData)&&!(null==p?void 0:p.cognitiveData));if(!g&&!h&&!y)return e(e({},b(_)),{label:"Not Defined"});null!==(i=null!==(t=null==v?void 0:v.cognitiveRelevanceScore)&&void 0!==t?t:null==p?void 0:p.cognitiveRelevanceScore)&&void 0!==i||x&&(null===(o=yn[x])||void 0===o||o.relevance_score);var S=null!==(l=null!==(r=null==v?void 0:v.evaluationResult)&&void 0!==r?r:null==p?void 0:p.evaluationResult)&&void 0!==l?l:null,R=null===(u=null==S?void 0:S.evaluation_outputs)||void 0===u?void 0:u.output_value,C=null!==(a=null===(d=null===(c=null==S?void 0:S.evaluation_outputs)||void 0===c?void 0:c.metadata)||void 0===d?void 0:d.label_color)&&void 0!==a?a:_;return e(e({},b(C)),null!=S?{label:null!=R?R:""}:{label:null})},[lt,ut,yn,$n]),li=c(function(){var e,n,t,i,o,r,l,u,c,d,a,s,v,p,f,g,h,x,m,y,b,I;if(!kn.current&&!sn.current){kn.current=!0;try{if(!qt.current)return;var w=function(e){var n=e.split("-"),t=n[0];if(!Ht[t]&&!1===De)return!1;if(De&&!Ht["left-".concat(t)]&&!Ht["right-".concat(t)]&&!Ht[t])return!1;for(var i=t,o=1;o<n.length-1;o++)if(i+="-".concat(n[o]),!Lt[i])return!1;return!0},B=qt.current.getBoundingClientRect();Rn({width:B.width,height:B.height});var T=[];if(ct.forEach(function(e){var n,t,i=e.key,o=null===(n=ft.current[i])||void 0===n?void 0:n.current,r=null===(t=gt.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")}),!sn.current){for(var _=0;_<Math.max(lt.length,ut.length);_++){var E=null===(e=ht.current[_])||void 0===e?void 0:e.current,F=null===(n=xt.current[_])||void 0===n?void 0:n.current;E&&(E.style.height="auto",E.style.minHeight="0px"),F&&(F.style.height="auto",F.style.minHeight="0px")}De||Object.keys(St.current).forEach(function(e){var n,t;if(w(e)){var i=null===(n=St.current[e])||void 0===n?void 0:n.current,o=null===(t=Rt.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={};ct.forEach(function(e){var n,t,i=e.key,o=null===(n=ft.current[i])||void 0===n?void 0:n.current,r=null===(t=gt.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 k={left:{},right:{}},M={};if(!sn.current)if(De){if(Ke&&null!==en)if("number"==typeof en){var N=en,A=lt[N],H=null===(o=ht.current[N])||void 0===o?void 0:o.current;H&&A&&(A.refIndexes||[]).forEach(function(e){var n,t=ut.findIndex(function(n){return n.selfIndex===e}),i=null===(n=xt.current[t])||void 0===n?void 0:n.current;if(i&&(Ht["left-".concat(N)]||Ht["right-".concat(t)])){var o=Math.max(H.getBoundingClientRect().height,i.getBoundingClientRect().height);k.left[N]=Math.max(k.left[N]||0,o),k.right[t]=Math.max(k.right[t]||0,o)}})}else{var L=en.split(S)[2];if(L){E=null===(r=St.current[L])||void 0===r?void 0:r.current,F=null===(l=Rt.current[L])||void 0===l?void 0:l.current;if(E&&F){j=Math.max(E.getBoundingClientRect().height,F.getBoundingClientRect().height);M[L]=Math.max(M[L]||0,j)}}}}else{Object.keys(St.current).forEach(function(e){var n,t;if(w(e)){var i=null===(n=St.current[e])||void 0===n?void 0:n.current,o=null===(t=Rt.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);M[e]=u,i.style.minHeight="".concat(u,"px"),o.style.minHeight="".concat(u,"px")}}});for(_=0;_<Math.min(lt.length,ut.length);_++){var E=null===(t=ht.current[_])||void 0===t?void 0:t.current,F=null===(i=xt.current[_])||void 0===i?void 0:i.current;if(E&&F){var j=Math.max(E.getBoundingClientRect().height,F.getBoundingClientRect().height);k.left[_]=j,k.right[_]=j}}}if(ct.forEach(function(e){var n,t,i=e.key,o=null===(n=ft.current[i])||void 0===n?void 0:n.current,r=null===(t=gt.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")}}),sn.current||(Object.entries(k.left).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=ht.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),Object.entries(k.right).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=xt.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),De||Object.keys(M).forEach(function(e){var n,t,i=null===(n=St.current[e])||void 0===n?void 0:n.current,o=null===(t=Rt.current[e])||void 0===t?void 0:t.current;if(i&&o&&M[e]){var r=M[e];i.style.minHeight="".concat(r,"px"),o.style.minHeight="".concat(r,"px")}})),De)lt.forEach(function(e,n){var t;(null===(t=ht.current[n])||void 0===t?void 0:t.current)&&(e.refIndexes||[]).forEach(function(e){var t,i,o,r,l,u,c,d,a,s,v=ut.findIndex(function(n){return n.selfIndex===e});if(-1!==v){var p=null===(t=mt.current[n])||void 0===t?void 0:t.current,f=null===(i=yt.current[v])||void 0===i?void 0:i.current;if(p&&f){var g=p.getBoundingClientRect(),h=f.getBoundingClientRect(),x=g.right-B.left,m=h.left-B.left,y=g.top+g.height/2-B.top,b=h.top+h.height/2-B.top;if(Ke&&en===n){var S=null!==(r=null===(o=Dn.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==r?r:0,R=null!==(u=null===(l=Bn.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==u?u:0,C=S+(null!==(d=null===(c=Dn.current)||void 0===c?void 0:c.clientHeight)&&void 0!==d?d:1/0),I=R+(null!==(s=null===(a=Bn.current)||void 0===a?void 0:a.clientHeight)&&void 0!==s?s:1/0),w=g.top+g.height/2,_=h.top+h.height/2,E=function(e,n,t){return Math.max(n,Math.min(t,e))};y=E(w,S,C)-B.top,b=E(_,R,I)-B.top}var F=oi(n);F&&T.push({id:"line-".concat(n,"-").concat(v),x1:x,y1:y,x2:m,y2:b,style:F,sectionIdx:n,targetRightIdx:v})}}})});else{for(_=0;_<Math.min(lt.length,ut.length);_++){var O=null===(u=ht.current[_])||void 0===u?void 0:u.current,P=null===(c=xt.current[_])||void 0===c?void 0:c.current;if(O&&P){var z=O.getBoundingClientRect(),W=P.getBoundingClientRect(),Y=Math.max(z.top,W.top)+18-B.top,K=(null===(d=ut[_])||void 0===d?void 0:d.id)||"sec-".concat(_);(Q=oi(_))&&T.push({id:K,x1:z.right-B.left,y1:Y,x2:W.left-B.left,y2:Y,style:Q,sectionIdx:_,hasCognitive:!!((null===(a=lt[_])||void 0===a?void 0:a.cognitiveData)||(null===(s=ut[_])||void 0===s?void 0:s.cognitiveData)||K&&yn[K]),isSubSection:!1})}}Object.keys(St.current).forEach(function(e){var n,t,i,o,r,l;if(w(e)){var u=null===(n=St.current[e])||void 0===n?void 0:n.current,c=null===(t=Rt.current[e])||void 0===t?void 0:t.current;if(u&&c){for(var d=e.split("-").map(Number),a=lt[d[0]],s=ut[d[0]],v=1;v<d.length;v++)(null==a?void 0:a.subsections)&&(a=a.subsections[d[v]]),(null==s?void 0:s.subsections)&&(s=s.subsections[d[v]]);var p=!!a&&((null===(i=a.displayTitle)||void 0===i||i)&&R(a.title)),f=!!a&&((null===(o=a.displayContent)||void 0===o||o)&&R(a.content)),g=!!s&&((null===(r=s.displayTitle)||void 0===r||r)&&R(s.title)),h=!!s&&((null===(l=s.displayContent)||void 0===l||l)&&R(s.content));if(p&&f||g&&h){var x=u.getBoundingClientRect(),m=c.getBoundingClientRect(),y=Math.max(x.top,m.top)+16-B.top,b=ri(e);b&&"Not Defined"!==b.label&&T.push({id:"subsec-".concat(e),x1:x.right-B.left,y1:y,x2:m.left-B.left,y2:y,style:b,sectionIdx:d[0],isSubSection:!0,subSectionKeyPath:e,hasCognitive:!(!(null==a?void 0:a.cognitiveData)&&!(null==s?void 0:s.cognitiveData))})}}}})}if(Ke&&"string"==typeof en&&en.includes(S)){var q=en.split(S),V=q[0],X=q[1],J=q[2],U=(q[3],"".concat(V).concat(S).concat(X)),$=null===(v=mt.current[U])||void 0===v?void 0:v.current,G=null===(p=yt.current[U])||void 0===p?void 0:p.current;if($&&G){var Q,Z=$.getBoundingClientRect(),ee=G.getBoundingClientRect(),ne=Z.right-B.left,te=ee.left-B.left,ie=Z.top+Z.height/2-B.top,oe=ee.top+ee.height/2-B.top;if(De){var re=null!==(g=null===(f=Dn.current)||void 0===f?void 0:f.getBoundingClientRect().top)&&void 0!==g?g:0,le=null!==(x=null===(h=Bn.current)||void 0===h?void 0:h.getBoundingClientRect().top)&&void 0!==x?x:0,ue=re+(null!==(y=null===(m=Dn.current)||void 0===m?void 0:m.clientHeight)&&void 0!==y?y:1/0),ce=le+(null!==(I=null===(b=Bn.current)||void 0===b?void 0:b.clientHeight)&&void 0!==I?I:1/0),de=function(e,n,t){return Math.max(n,Math.min(t,e))};ie=de(Z.top+Z.height/2,re,ue)-B.top,oe=de(ee.top+ee.height/2,le,ce)-B.top}(Q=ri(J))&&T.push({id:"line-subsec-".concat(U),x1:ne,y1:ie,x2:te,y2:oe,style:Q,sectionIdx:Number(J.split("-")[0]),isSubSection:!0,subSectionKeyPath:en})}}if(Zt(T),Ut.current&&$t.current){var ae=Ut.current.getBoundingClientRect(),se=$t.current.getBoundingClientRect(),ve=(ae.top+ae.height/2-B.top+se.top+se.height/2-B.top)/2;ti({x1:ae.right-B.left,x2:se.left-B.left,y:ve})}else ti(null);if(rn.size>0){var pe=[],fe=Dn.current,ge=Bn.current;if(fe&&ge){var he=[],xe=fe.getBoundingClientRect().top,me=ge.getBoundingClientRect().top,ye=xe+fe.clientHeight,be=me+ge.clientHeight,Se=fe.scrollTop,Re=ge.scrollTop,Ce=B.top,Ie=function(e,n,t){return Math.max(n,Math.min(t,e))};rn.forEach(function(e){var n,t,i,o,r;if("string"==typeof e&&e.includes(S)){var l=e.split(S),u=l[0],c=l[1],d=l[2],a=(l[3],"".concat(u).concat(S).concat(c)),s=null===(n=mt.current[a])||void 0===n?void 0:n.current,v=null===(t=yt.current[a])||void 0===t?void 0:t.current;if(!s||!v)return;var p=s.getBoundingClientRect(),f=v.getBoundingClientRect(),g=ri(d),h=(A=p.right-B.left)+.5*((H=f.left-B.left-0)-A),x=p.top+p.height/2,m=f.top+f.height/2,y=x-xe+Se,b=m-me+Re,R="conn-subsec-".concat(a);he.push({lhsScrollY:y,rhsScrollY:b,x1:A,x2:H,containerTop:Ce,leftIdx:e,rhsArrayIdx:e,styleColor:(null==g?void 0:g.badgeBorder)||"#6366F1",styleId:R});var I=Ie(x,xe,ye),w=Ie(m,me,be),T=I-Ce,_=w-Ce,E=m>=me-4&&m<=be+4,F="";F=(L=x>=xe-4&&x<=ye+4)&&E?C(A,T,H,_):L&&!E?"M ".concat(A,",").concat(T," L ").concat(h,",").concat(T," L ").concat(h,",").concat(_):!L&&E?"M ".concat(h,",").concat(T," L ").concat(h,",").concat(_," L ").concat(H,",").concat(_):"M ".concat(h,",").concat(T," L ").concat(h,",").concat(_),pe.push({id:R,pathD:F,style:g,leftIdx:e,rhsArrayIdx:e})}else if(De){var D=e,k=lt[D];if(!(null===(r=null==k?void 0:k.refIndexes)||void 0===r?void 0:r.length))return;k.refIndexes.forEach(function(e){var n,t,i=ut.findIndex(function(n){return n.selfIndex===e});if(-1!==i){var o=null===(n=mt.current[D])||void 0===n?void 0:n.current,r=null===(t=yt.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),u=r.getBoundingClientRect(),c=oi(D),d=l.right-B.left,a=u.left-B.left-0,s=d+.5*(a-d),v=l.top+l.height/2,p=u.top+u.height/2,f=v-xe+Se,g=p-me+Re,h="conn-".concat(D,"-").concat(i);he.push({lhsScrollY:f,rhsScrollY:g,x1:d,x2:a,containerTop:Ce,leftIdx:D,rhsArrayIdx:i,styleColor:(null==c?void 0:c.badgeBorder)||"#6366F1",styleId:h});var x=Ie(v,xe,ye),m=Ie(p,me,be),y=x-Ce,b=m-Ce,S=v>=xe-4&&v<=ye+4,R=p>=me-4&&p<=be+4,I="";I=S&&R?C(d,y,a,b):S&&!R?"M ".concat(d,",").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(a,",").concat(b):"M ".concat(s,",").concat(y," L ").concat(s,",").concat(b),pe.push({id:h,pathD:I,style:c,leftIdx:D,rhsArrayIdx:i})}}})}else{var M=e,N=M;s=null===(i=mt.current[M])||void 0===i?void 0:i.current,v=null===(o=yt.current[N])||void 0===o?void 0:o.current;if(!s||!v)return;var A,H;p=s.getBoundingClientRect(),f=v.getBoundingClientRect(),g=oi(M),h=(A=p.right-B.left)+.5*((H=f.left-B.left-0)-A),x=p.top+p.height/2,m=f.top+f.height/2,y=x-xe+Se,b=m-me+Re,R="conn-".concat(M,"-").concat(N);he.push({lhsScrollY:y,rhsScrollY:b,x1:A,x2:H,containerTop:Ce,leftIdx:M,rhsArrayIdx:N,styleColor:(null==g?void 0:g.badgeBorder)||"#6366F1",styleId:R});var L;I=Ie(x,xe,ye),w=Ie(m,me,be),T=I-Ce,_=w-Ce,E=m>=me-4&&m<=be+4,F="";F=(L=x>=xe-4&&x<=ye+4)&&E?C(A,T,H,_):L&&!E?"M ".concat(A,",").concat(T," L ").concat(h,",").concat(T," L ").concat(h,",").concat(_):!L&&E?"M ".concat(h,",").concat(T," L ").concat(h,",").concat(_," L ").concat(H,",").concat(_):"M ".concat(h,",").concat(T," L ").concat(h,",").concat(_),pe.push({id:R,pathD:F,style:g,leftIdx:M,rhsArrayIdx:N})}}),fn.current=he}dn(pe)}else dn([]),fn.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{kn.current=!1}}},[ct,lt,ut,yn,$n,ii,oi,De,Ke,en,rn,Ht,Lt]),ui=c(function(){var e,n,t,i,o,r,l,u,c,d,a,s,v,p,f=fn.current;if(f.length&&!sn.current){var g=null!==(n=null===(e=Dn.current)||void 0===e?void 0:e.scrollTop)&&void 0!==n?n:0,h=null!==(i=null===(t=Bn.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,x=null!==(r=null===(o=Dn.current)||void 0===o?void 0:o.clientHeight)&&void 0!==r?r:1/0,m=null!==(u=null===(l=Bn.current)||void 0===l?void 0:l.clientHeight)&&void 0!==u?u:1/0,y=null!==(d=null===(c=Dn.current)||void 0===c?void 0:c.getBoundingClientRect().top)&&void 0!==d?d:0,b=null!==(s=null===(a=Bn.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==s?s:0,S=y+x,R=b+m,I=null!==(p=null===(v=qt.current)||void 0===v?void 0:v.getBoundingClientRect().top)&&void 0!==p?p:0,w=function(e,n,t){return Math.max(n,Math.min(t,e))};f.forEach(function(e){var n=e.lhsScrollY-g+y,t=e.rhsScrollY-h+b,i=pn.current[e.styleId+"-stroke"],o=pn.current[e.styleId+"-bg"];if(i||o){var r,l=w(n,y,S),u=w(t,b,R),c=l-I,d=u-I,a=n>=y-4&&n<=S+4,s=t>=b-4&&t<=R+4,v=e.x1+.5*(e.x2-e.x1);r=a&&s?C(e.x1,c,e.x2,d):a&&!s?"M ".concat(e.x1,",").concat(c," L ").concat(v,",").concat(c," L ").concat(v,",").concat(d):!a&&s?"M ".concat(v,",").concat(c," L ").concat(v,",").concat(d," L ").concat(e.x2,",").concat(d):"M ".concat(v,",").concat(c," L ").concat(v,",").concat(d),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",r)),o&&(o.setAttribute("visibility","visible"),o.setAttribute("d",r))}})}},[]);u(function(){mn.current=li},[li]);var ci=r(null),di=r(null),ai=c(function(){fn.current.length>0&&!sn.current||(null!==ci.current&&clearTimeout(ci.current),ci.current=setTimeout(function(){mn.current(),ci.current=null},50))},[]),si=c(function(){Qe(!0),Ue(!1),null!==di.current&&clearTimeout(di.current),null!==ci.current&&(clearTimeout(ci.current),ci.current=null),di.current=setTimeout(function(){var e,n,t,i,o,r,l,u,c,d;if(fn.current=[],hn.current&&null!==xn.current&&null!==Xt.current){var a=xn.current,s=Xt.current,v=null,p=null,f=null,g=null;if("string"==typeof a&&a.includes(S)){var h=a.split(S),x="".concat(h[0]).concat(S).concat(h[1]);v=(null===(e=mt.current[x])||void 0===e?void 0:e.current)||null,p=(null===(n=yt.current[x])||void 0===n?void 0:n.current)||null,f=(null===(t=St.current[h[2]])||void 0===t?void 0:t.current)||(null===(i=ht.current[Number(h[2])])||void 0===i?void 0:i.current)||null,g=(null===(o=Rt.current[h[3]])||void 0===o?void 0:o.current)||(null===(r=xt.current[Number(h[3])])||void 0===r?void 0:r.current)||null}else v=(null===(l=Ct.current[a])||void 0===l?void 0:l.current)||null,f=(null===(u=ht.current[a])||void 0===u?void 0:u.current)||null,p=(null===(c=bt.current[s])||void 0===c?void 0:c.current)||null,g=(null===(d=xt.current[s])||void 0===d?void 0:d.current)||null;if(v&&p&&f&&g){if(f.style.paddingTop="0px",g.style.paddingTop="0px",!De){var m=v.getBoundingClientRect(),y=p.getBoundingClientRect(),b=m.top-y.top;b>0?g.style.paddingTop="".concat(b,"px"):b<0&&(f.style.paddingTop="".concat(Math.abs(b),"px"))}var R=Dn.current,C=Bn.current;if(R&&C){var I=v.getBoundingClientRect().top-R.getBoundingClientRect().top+R.scrollTop,w=p.getBoundingClientRect().top-C.getBoundingClientRect().top+C.scrollTop-(I-R.scrollTop);Math.abs(C.scrollTop-w)>1&&(C.scrollTop=w)}}}mn.current(),hn.current&&Ue(!0),Qe(!1),di.current=null},150)},[De,lt,ut]),vi=c(function(e){var n,t,i,o,r,l,u,c,d,a;if(null!==Mn.current&&Nn.current&&Math.abs(e.currentTarget.scrollTop-Mn.current)<=2){var s=Nn.current;Mn.current=null,Nn.current=null,s()}if(!tn.current){if(De||ai(),hn.current){var v=xn.current,p=Xt.current,f=Dn.current,g=Bn.current;if(null!==v&&null!==p&&f&&g){var h="string"==typeof v&&v.includes(S)?null===(n=mt.current["".concat(v.split(S)[0]).concat(S).concat(v.split(S)[1])])||void 0===n?void 0:n.current:null===(t=Ct.current[v])||void 0===t?void 0:t.current,x="string"==typeof p&&p.includes(S)?null===(i=yt.current["".concat(p.split(S)[0]).concat(S).concat(p.split(S)[1])])||void 0===i?void 0:i.current:null===(o=bt.current[p])||void 0===o?void 0:o.current;if(h&&x&&Jt.current){var m=void 0,y=void 0;if("string"==typeof v&&v.includes(S)){var b=v.split(S),R="".concat(b[0]).concat(S).concat(b[1]);m=null===(r=mt.current[R])||void 0===r?void 0:r.current,y=null===(l=yt.current[R])||void 0===l?void 0:l.current}else m=null===(u=mt.current[v])||void 0===u?void 0:u.current,y=null===(c=yt.current[p])||void 0===c?void 0:c.current;var C=null!==(a=null===(d=qt.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==a?a:0,I=f.getBoundingClientRect().top,w=I+f.clientHeight;g.getBoundingClientRect().top;g.clientHeight;if(m&&y){var B=m.getBoundingClientRect(),T=y.getBoundingClientRect(),_=B.top+B.height/2;T.top,T.height;var E=((D=_,k=I,M=w,Math.max(k,Math.min(M,D)))-C).toString();Jt.current.setAttribute("y1",E),Jt.current.setAttribute("y2",E);var F=_>=I-4&&_<=w+4;Jt.current.setAttribute("visibility",F?"visible":"hidden")}}}}var D,k,M;fn.current.length>0&&!gn.current&&(gn.current=!0,requestAnimationFrame(function(){ui(),gn.current=!1}))}},[ui,De,ai]);u(function(){var e=setTimeout(ai,250);window.addEventListener("resize",si);var n=null,t=null;return In.current&&(n=new ResizeObserver(ai)).observe(In.current),qt.current&&(t=new ResizeObserver(ai)).observe(qt.current),function(){clearTimeout(e),null!==ci.current&&clearTimeout(ci.current),null!==di.current&&clearTimeout(di.current),window.removeEventListener("resize",si),null==n||n.disconnect(),null==t||t.disconnect()}},[ot,rt,Tt,ct,Ht,Lt,lt,ut,$n,ai,si,Ke,en,Je,rn]),u(function(){hn.current=Ke},[Ke]),u(function(){xn.current=en},[en]);var pi=c(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,u=null!==(o=null==t?void 0:t.sourceSide)&&void 0!==o?o:"left";Un(),null!=e&&(n?We("No counterpart exists for this section."):Ke&&en===e?r?Nt():null==l||l():(ln(new Set([e])),dn([]),fn.current=[],Oe(!0),tn.current=!0,nn(e),xn.current=e,qe(!0),hn.current=!0,Ue(!1),Tn.current&&(Tn.current.style.height="0px"),_n.current&&(_n.current.style.height="0px"),En.current&&(En.current.style.height="0px"),Fn.current&&(Fn.current.style.height="0px"),requestAnimationFrame(function(){var n,t,i,o,r,c="string"==typeof e&&e.includes(S),d=null,a=null,s=null;if(c){var v=e.split(S),p="".concat(v[0]).concat(S).concat(v[1]);d=(null===(n=mt.current[p])||void 0===n?void 0:n.current)||null,a=(null===(t=yt.current[p])||void 0===t?void 0:t.current)||null,s=a?e:null}else if(d=(null===(i=Ct.current[e])||void 0===i?void 0:i.current)||null,De){var f=lt[e],g=(null==f?void 0:f.refIndexes)||[];if(g.length>0){var h=g[0],x=ut.findIndex(function(e){return e.selfIndex===h});-1!==x&&(a=(null===(r=bt.current[x])||void 0===r?void 0:r.current)||null,s=x)}}else a=(null===(o=bt.current[e])||void 0===o?void 0:o.current)||null,s=a?e:null;Xt.current=s;var m=Dn.current,y=Bn.current,b=function(){!function(){var n,t,i,o,r,l,u,d,a,v,p,f,g=null,h=null,x=null,m=null;if(c){var y=e.split(S),b="".concat(y[0]).concat(S).concat(y[1]);g=(null===(n=St.current[y[2]])||void 0===n?void 0:n.current)||(null===(t=ht.current[Number(y[2])])||void 0===t?void 0:t.current)||null,h=(null===(i=Rt.current[y[3]])||void 0===i?void 0:i.current)||(null===(o=xt.current[Number(y[3])])||void 0===o?void 0:o.current)||null,x=(null===(r=mt.current[b])||void 0===r?void 0:r.current)||g,m=(null===(l=yt.current[b])||void 0===l?void 0:l.current)||h}else{var R=Number(e),C=null!==s?Number(s):R;g=(null===(u=ht.current[R])||void 0===u?void 0:u.current)||null,h=(null===(d=xt.current[C])||void 0===d?void 0:d.current)||null,x=(null===(a=mt.current[R])||void 0===a?void 0:a.current)||(null===(v=Ct.current[R])||void 0===v?void 0:v.current)||g,m=(null===(p=yt.current[C])||void 0===p?void 0:p.current)||(null===(f=bt.current[C])||void 0===f?void 0:f.current)||h}if(x&&m&&g&&h){g.style.paddingTop="0px",h.style.paddingTop="0px";var I=x.getBoundingClientRect(),w=m.getBoundingClientRect(),B=I.top-w.top;B>0?h.style.paddingTop="".concat(B,"px"):B<0&&(g.style.paddingTop="".concat(Math.abs(B),"px"))}}(),Ue(!0),mn.current&&mn.current(),tn.current=!1,"right"===u&&y?y.dispatchEvent(new Event("scroll")):m&&m.dispatchEvent(new Event("scroll")),Oe(!1),null==l||l()};if(!d||!m)return tn.current=!1,Oe(!1),void(null==l||l());if(a&&y){if(!De){var R=0;R="right"===u?a?a.getBoundingClientRect().top:0:d?d.getBoundingClientRect().top:0;var C=In.current,w=(null==C?void 0:C.getBoundingClientRect().top)||0,B=C?C.scrollTop+R-w-150:0;return C?void I(C,B,200,b):void b()}var T=d.getBoundingClientRect().top-m.getBoundingClientRect().top+m.scrollTop,_=a.getBoundingClientRect().top-y.getBoundingClientRect().top+y.scrollTop,E=200;if("left"===u){var F=_-(T-m.scrollTop);F<0&&Tn.current&&(Tn.current.style.height="".concat(Math.abs(F),"px")),requestAnimationFrame(function(){var e,n=y.scrollHeight-y.clientHeight;if(F<0)e=0;else{if(F>n){var t=F-n;return _n.current&&(_n.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){I(y,F,E,b)})}e=F}I(y,e,E,b)})}else{var D=T-(_-y.scrollTop);D<0&&En.current&&(En.current.style.height="".concat(Math.abs(D),"px")),requestAnimationFrame(function(){var e,n=m.scrollHeight-m.clientHeight;if(D<0)e=0;else{if(D>n){var t=D-n;return Fn.current&&(Fn.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){I(m,D,E,b)})}e=D}I(m,e,E,b)})}}else b()})))},[en,Un,ut,Ke,De,lt,Nt]),fi=c(function(e,n,t,i){var o,r="string"==typeof i?m(i).trim():m(null==i?void 0:i.deviation_summary).trim(),l=e.currentTarget;Jn();var u="left";(null===(o=Bn.current)||void 0===o?void 0:o.contains(l))&&(u="right");var c=function(){var e,t,i,o;if("string"==typeof n&&n.includes(S)){var r=n.split(S),l="".concat(r[0]).concat(S).concat(r[1]);return"right"===u?null===(e=yt.current[l])||void 0===e?void 0:e.current:null===(t=mt.current[l])||void 0===t?void 0:t.current}return"right"===u?null===(i=yt.current[n])||void 0===i?void 0:i.current:null===(o=mt.current[n])||void 0===o?void 0:o.current};if(t)return Nt(),ln(new Set),dn([]),fn.current=[],void(r&&requestAnimationFrame(function(){var e=c()||l;Kn({open:!0,anchorEl:e,summary:i})}));pi(n,t,r?{toggleIfSame:!1,sourceSide:u,onReady:function(){var e=c()||l;Kn({open:!0,anchorEl:e,summary:i})}}:{toggleIfSame:!1,sourceSide:u})},[pi,Jn,Kn,Nt]),gi=c(function(){var e,n=jn.sectionIdx,t=jn.isOrphan;if(qn(),null!=n){var i="left";jn.anchorEl&&(null===(e=Bn.current)||void 0===e?void 0:e.contains(jn.anchorEl))&&(i="right"),pi(n,t,{sourceSide:i})}},[pi,jn.isOrphan,jn.sectionIdx,jn.anchorEl,qn]),hi=c(function(){qn(),Nt(),ln(new Set),dn([]),fn.current=[]},[qn,Nt]),xi=null!==jn.sectionIdx&&rn.has(jn.sectionIdx),mi=j({proposedSections:lt,existingSections:ut,parentDeviationRecord:dt,expandedSections:Ht,maintainRelativeOrder:!!De,scrollContainerRef:In,leftContainerRef:Dn,lhsBadgeRefs:mt,rhsBadgeRefs:yt}),yi=mi.showDeviationNavigation,bi=mi.showOpenNodeRef,Si=l(function(){if(!_e)return null;var e=_e.split(":")[0];for(var n in dt){if((dt[n]||[]).some(function(n){return n.id===e}))return n}return null},[_e,dt]),Ri=r(null),Ci=r(null);u(function(){if(_e&&Ri.current!==_e){var t=_e.split(":"),i=t[0],o=t[1],r=null!=o?o:"0";Ci.current!==_e&&(qn(),Jn(),Nt(),ln(new Set),dn([]),fn.current=[],Ci.current=_e);var l=!1,u=0,c=null,d=150,a=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},s=function(){var t,o,v,p;if(!l){var f=null,g=null;for(var h in dt){var x=dt[h].find(function(e){return e.id===i});if(x){f=h,g=x;break}}if(g&&f){var m=lt.findIndex(function(e){return e.id===f}),y=ut.findIndex(function(e){return e.id===f}),b=-1===m&&-1!==y,R=a(lt,g.id),C=a(ut,g.id);if(R&&!C&&!b){var I=R.split("-"),w=Number(I[0]);if(De){var B=null===(o=null===(t=lt[w])||void 0===t?void 0:t.refIndexes)||void 0===o?void 0:o[0],T=ut.findIndex(function(e){return e.selfIndex===B});-1!==T&&(w=T)}C=n([w],I.slice(1),!0).join("-")}if(R||C){var _=b||!R&&!!C,E=R?Number(R.split("-")[0]):m,F=C?Number(C.split("-")[0]):y;if(_){if(!(De?!!Ht["right-".concat(F)]:!!Ht[String(F)])&&F>=0)return Ot(F,"right"),u+=1,void(c=setTimeout(s,450))}else if(!(De?!!Ht["left-".concat(E)]:!!Ht[String(E)])&&E>=0)return Ot(E,"left"),u+=1,void(c=setTimeout(s,450));var D,k=R||"",M=C||"",N="".concat(g.id).concat(S).concat(r).concat(S).concat(k).concat(S).concat(M),A="".concat(g.id).concat(S).concat(r),H=null===(v=mt.current[A])||void 0===v?void 0:v.current,L=null===(p=yt.current[A])||void 0===p?void 0:p.current,j=_||!H&&!!L,O=j?L:H;if(D=De?j?Bn.current:Dn.current:In.current,O&&D){var P=O.getBoundingClientRect();if(0===P.height)return void((u+=1)<20&&(c=setTimeout(s,d)));var z=D.getBoundingClientRect(),W=P.top-z.top+D.scrollTop-z.height/2+P.height/2,Y=function(){var n,t,i,o,u;if(!l){Ri.current=_e;var c=window.getComputedStyle(O).color;H&&(H.style.transition="box-shadow 300ms ease-in-out",H.style.boxShadow="0 0 10px ".concat(c)),L&&(L.style.transition="box-shadow 300ms ease-in-out",L.style.boxShadow="0 0 10px ".concat(c)),setTimeout(function(){H&&(H.style.boxShadow=""),L&&(L.style.boxShadow="")},2e3);var d=(null===(t=null===(n=g.evaluationResult)||void 0===n?void 0:n.deviations)||void 0===t?void 0:t[r])||g,a=(null===(i=g.evaluationResult)||void 0===i?void 0:i.evaluation_outputs)||g.evaluation_outputs;if(!(!!H&&!!L)){var s=j?(null===(o=yt.current[A])||void 0===o?void 0:o.current)||L:(null===(u=mt.current[A])||void 0===u?void 0:u.current)||H;return Kn({open:!0,anchorEl:s,summary:e(e({},d),{evaluation_outputs:a})}),void(null==Ee||Ee())}pi(N,!1,{toggleIfSame:!1,sourceSide:"left",onReady:function(){var n,t=(null===(n=mt.current[A])||void 0===n?void 0:n.current)||H;Kn({open:!0,anchorEl:t,summary:e(e({},d),{evaluation_outputs:a})})}})}};Math.abs(D.scrollTop-W)<=2?Y():(Mn.current=W,Nn.current=Y,D.scrollTo({top:W,behavior:"smooth"}),c&&clearTimeout(c),c=setTimeout(function(){if(Nn.current){Mn.current=null;var e=Nn.current;Nn.current=null,e()}},800))}else(u+=1)<20&&(c=setTimeout(s,d))}else(u+=1)<20&&(c=setTimeout(s,d))}else(u+=1)<20&&(c=setTimeout(s,d))}};return c=setTimeout(s,d),function(){l=!0,c&&clearTimeout(c)}}},[_e,dt,lt,ut,De,Ht,Ot,pi,Kn]);var Ii=function(e){var n=e.section,t=e.keyPath,o=e.depth,r=void 0===o?0:o,l=e.columnKey,u=void 0===l?"left":l,c=e.parentNodeId;return i(z,{section:n,keyPath:t,depth:r,columnKey:u,parentNodeId:void 0===c?"":c,expandedSubSections:Lt,setExpandedSubSections:jt,maintainRelativeOrder:De||!1,proposedSections:lt,existingSections:ut,treeData:me,deviationNumberRegistry:at,connectedSections:rn,activeSideBySideSection:en,resolvedMarkdownStyles:Cn,getSubSectionRef:wt,getSubSectionCompareStyle:ri,getBadgeRef:Bt,openMoreFunctionsPopup:Wt,openSummaryPopup:fi,showDeviationBadges:Me,resetSideBySide:Nt,setConnectedSections:ln,setConnectedLines:dn,cachedConnectedPositions:fn})};return t(d,e({ref:wn,sx:e(e({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},De?{}:{overflow:"visible"}),{position:"relative"})},{children:[Ae&&i(d,e({sx:{position:"absolute",inset:0,bgcolor:"rgba(255, 255, 255, 0.6)",backdropFilter:"blur(10px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"8px"}},{children:i(k,{})})),Yn.open&&i(W,{open:Yn.open,anchorEl:Yn.anchorEl,containerEl:Vt.current,clipTopEl:Ut.current,scrollContainerEl:In.current,onClose:hi,summary:Yn.summary}),i(D,{open:jn.open,anchorEl:jn.anchorEl,sectionTitle:jn.sectionTitle,referenceSectionTitle:jn.refSectionTitle,onClose:Un,onOpenCognitiveCompare:Yt,onOpenSideBySide:gi,onConnect:Kt,isConnected:xi,isOrphan:jn.isOrphan}),Hn.open&&i(F,{open:Hn.open,popupRef:Xn,position:Pn,popupConfig:we,onClose:function(){zn(null),Ln(function(n){return e(e({},n),{open:!1})}),Vn(null)},markdownStyles:Re,sectionTitle:Hn.sectionTitle,referenceSectionTitle:Hn.refSectionTitle,cognitiveData:Hn.cognitiveData,anchorEl:Hn.anchorEl,sectionAnchorEl:Hn.sectionAnchorEl,scrollContainerEl:In.current,badgeStyle:Hn.badgeStyle,docData:Hn.docData,deviationData:Hn.deviationData,isLoading:Hn.isLoading}),i(a,e({open:!!ze,autoHideDuration:8e3,onClose:function(){return We(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:i(s,e({onClose:function(){return We(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:ze}))})),i(O,{componentHeaderText:xe,displayConfig:Ie,maintainRelativeOrder:De,onToggleView:function(e){He(!0),setTimeout(function(){ke(!e),Nt(),qn(),ln(new Set),dn([]),fn.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){He(!1)},600)})})},50)}}),i(d,e({ref:In,onScroll:vi,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:De?"hidden":"auto",borderTop:_t&&Et?"none":"1.5px solid #EEF0F4"}},{children:i(d,e({sx:e({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},De?{flex:1,minHeight:0}:{})},{children:t(d,e({ref:qt,sx:e({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"40px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},De?{flex:1,overflow:"visible"}:{})},{children:[t("svg",e({ref:an,style:{position:"absolute",top:0,left:0,width:Sn.width||"100%",height:Sn.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",opacity:Ge?0:1,transition:"opacity 0.15s ease-in-out"}},{children:[ni&&i("g",{children:i("line",{x1:ni.x1,y1:ni.y,x2:ni.x2,y2:ni.y,stroke:Mt.badgeBorder,strokeWidth:"1.5"})}),Qt.map(function(n){var o,r,l,u,c,a,s=n.x1+.5*(n.x2-n.x1),v=(n.y1+n.y2)/2;if("Not Defined"===n.style.label&&!n.hasCognitive)return null;if(n.isSubSection?Ke&&en===n.subSectionKeyPath&&Je:Ke&&en===n.sectionIdx&&Je)return null;if(!De){var p=n.isSubSection?C(n.x1,n.y1,n.x2,n.y2):"M ".concat(n.x1," ").concat(n.y1," L ").concat(n.x2," ").concat(n.y2),g=lt[n.sectionIdx]||{title:"",content:""},x=ut[n.sectionIdx]||{title:"",content:""};if(console.log("Base and Ref Sections for Badge:",g,x),n.isSubSection&&n.subSectionKeyPath){var m=n.subSectionKeyPath.includes(S)?n.subSectionKeyPath.split(S):[],y=m[2]||n.subSectionKeyPath,b=m[3]||y,R=y.split("-").map(Number),I=b.split("-").map(Number),w=null,B=null;R.length>0&&(w=lt[R[0]]),I.length>0&&(B=ut[I[0]]);var T=(null==w?void 0:w.title)||"",E=(null==B?void 0:B.title)||"";console.log("Root Parent Titles:",T,E);for(var F=1;F<R.length;F++)(null==w?void 0:w.subsections)&&(w=w.subsections[R[F]]);for(F=1;F<I.length;F++)(null==B?void 0:B.subsections)&&(B=B.subsections[I[F]]);w&&(g=e(e({},w),{title:T||w.title})),console.log("Base Section for Subsection Badge:",g),B&&(x=e(e({},B),{title:E||B.title})),console.log("Ref Section for Subsection Badge:",x)}var D=!(null===(o=g.cognitiveData)||void 0===o?void 0:o.isMissingRationale)||Boolean(null===(l=null===(r=g.cognitiveData)||void 0===r?void 0:r.decisioning)||void 0===l?void 0:l.length),k=(null===(a=null===(c=null===(u=g.evaluationResult)||void 0===u?void 0:u.cognitive_decisioning)||void 0===c?void 0:c.decisioning_factors)||void 0===a?void 0:a.length)||!1,N=D||k;return t("g",{children:[i("path",{d:p,fill:"none",stroke:n.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),i("foreignObject",e({x:s-100,y:v-14,width:"200",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:i(d,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:t(d,e({onClick:function(e){e.stopPropagation(),N&&(Hn.open&&Wn===n.id?Jn():(Vn(n.id),zt(Pt(e.currentTarget,g,x,n.sectionIdx,n.style))))},sx:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:n.style.badgeBg,color:n.style.badgeText,border:"1px solid ".concat(n.style.badgeBorder),borderRadius:"12px",px:1.5,py:.5,fontWeight:600,textAlign:"center",whiteSpace:"nowrap",cursor:N?"pointer":"default"}},{children:[n.style.badgeText===_&&null==n.style.label?i(M,{color:n.style.badgeText}):0===n.style.label?"Same":n.style.label,i(d,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:i(h,{})})),N&&i(f,{size:11,style:{transform:Hn.open&&Wn===n.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},n.id)}return null}),cn.map(function(n){var o,r=n.pathD,l=(null===(o=n.style)||void 0===o?void 0:o.badgeBorder)||"#6366F1",u="conn-marker-".concat(n.id),c="".concat(n.id,"-bg"),d="".concat(n.id,"-stroke");return t("g",{children:[i("defs",{children:i("clipPath",e({id:"connections-clip"},{children:i("marker",e({id:u,markerWidth:"8",markerHeight:"6",refX:"7",refY:"3",orient:"auto"},{children:i("polygon",{points:"0 0, 8 3, 0 6",fill:l})}))}))}),i("path",{ref:function(e){pn.current[c]=e},d:r,fill:"none",stroke:"#FFFFFF",strokeWidth:"4",strokeOpacity:"0.7"}),i("path",{ref:function(e){pn.current[d]=e},d:r,fill:"none",stroke:l,strokeWidth:"1.75",markerEnd:"url(#".concat(u,")")})]},n.id)})]})),t(d,e({sx:e({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},De?{flex:1,overflow:"visible"}:{})},{children:[i(d,e({ref:Ut,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(v,e({title:nt,placement:"top"},{children:i(p,e({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:nt}))}))})),t(d,e({ref:Dn,onScroll:vi,sx:e({p:"12px",display:"flex",flexDirection:"column"},De?{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:En,style:{width:"100%",height:"0px",flexShrink:0}}),vt&&lt.map(function(n,o){var r,l,u=!n.title&&!n.content;if(De&&u)return null;var c=n,a=oi(o,"left"),s=De?!(null===(r=c.refIndexes)||void 0===r?void 0:r.length)||c.selfIndex<0:!ut[o],v=De?"number"==typeof c.selfIndex&&c.selfIndex>=0?c.selfIndex+1:null:o+1,p=rn.has(o),f=y(c.evaluationResult,null==a?void 0:a.deviationLabel);return i(d,e({ref:It(o),sx:{mb:1,width:"100%"}},{children:t(d,e({sx:{position:"relative",width:"100%"}},{children:[i(d,e({ref:ht.current[o],sx:e({width:"100%",display:"flex"},p&&{borderRadius:"6px",outline:"2px solid ".concat((null==a?void 0:a.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:i(P,{section:n,idx:o,columnKey:"left",colRef:It("left-accordion-".concat(o)),mb:0,treeData:me,proposedSections:lt,existingSections:ut,deviationNumberRegistry:at,getSectionCompareStyle:oi,getBadgeRef:Bt,connectedSections:rn,openMoreFunctionsPopup:Wt,openSummaryPopup:fi,deviationNodeIdToView:_e,deviationTargetParentId:Si,parentNodeId:(null===(l=null==me?void 0:me.input_index_map)||void 0===l?void 0:l[0])||"",isExpanded:De?!!Ht["left-".concat(o)]:!!Ht[String(o)],onToggle:function(){hi(),Ot(o,"left")},navigation:n.id?yi[n.id]:null,showOpenNodeRef:bi,resolvedMarkdownStyles:Cn,maintainRelativeOrder:De,showDeviationBadges:Me,renderSubSections:Ii})})),De&&a&&t(d,e({ref:mt.current[o],onClick:function(e){var t=De?ut.find(function(e){var n;return null===(n=c.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""}:ut[o]||{title:"",content:""};Wt(e,n,s,t,o,a)},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:.4,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[null!==v&&i(d,e({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(a.badgeBorder)}},{children:v})),i(d,e({component:"span",sx:{fontSize:"11px",px:.25}},{children:!Ie.isLoading||null!=c.evaluationResult&&null!=c.evaluationResult?s?"No Deviation Found":"N/A"===f||"NA"===f?"N/A":0==f||null==f?"Same":"".concat(f):i(M,{color:a.badgeText})})),i(g,{size:11,color:a.badgeText})]}))]}))}),"left-row-".concat(o))}),i("div",{ref:Fn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),i(d,e({ref:Vt,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:i(d,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:t(d,e({onClick:function(n){n.stopPropagation(),Hn.open&&Wn===Ft?Jn():(Vn(Ft),zt(Pt(n.currentTarget,{title:"",content:"",evaluationResult:Dt,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,Ft,!0,e(e({},Mt),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-5px",borderRadius:"20px",bgcolor:Mt.badgeBg,color:Mt.badgeText,border:"1px solid ".concat(Mt.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=kt?kt:i(M,{}),i(d,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:i(h,{})})),i(f,{size:11,style:{transform:Hn.open&&Wn===Ft?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),t(d,e({sx:e({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},De?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[je&&i(x,{sections:11}),i(d,e({ref:$t,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"40px",display:"flex",alignItems:"center",overflowX:"hidden"}},{children:i(v,e({title:tt,placement:"top"},{children:i(p,e({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:tt}))}))})),t(d,e({ref:Bn,onScroll:vi,sx:e({p:"12px",display:"flex",flexDirection:"column"},De?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-120px",pl:"140px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[i("div",{ref:Tn,style:{width:"100%",height:"0px",flexShrink:0}}),vt&&ut.map(function(n,o){var r,l=n,u=[],c=!1,a=null,s=-1;if(De){u=lt.filter(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(l.selfIndex))&&e.selfIndex>=0}).map(function(e){return e.selfIndex+1}),s=lt.findIndex(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(l.selfIndex))&&e.selfIndex>=0});var v=lt.findIndex(function(e,n){var t;return rn.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(l.selfIndex))});(c=-1!==v)&&(a=oi(v))}else u=[o+1],(c=rn.has(o))&&(a=oi(o));var p=oi(De&&-1!==s?s:o);return i(d,e({ref:bt.current[o],sx:{mb:1,width:"100%"}},{children:t(d,e({sx:{position:"relative",width:"100%"}},{children:[i(d,e({ref:xt.current[o],sx:e({width:"100%",display:"flex"},c&&a&&{borderRadius:"6px",outline:"2px solid ".concat(a.badgeBorder),outlineOffset:"1px"})},{children:i(P,{section:n,idx:o,columnKey:"right",colRef:It("right-accordion-".concat(o)),mb:0,parentNodeId:(null===(r=null==me?void 0:me.input_index_map)||void 0===r?void 0:r[1])||"",isExpanded:De?!!Ht["right-".concat(o)]:!!Ht[String(o)],treeData:me,proposedSections:lt,existingSections:ut,deviationNumberRegistry:at,getBadgeRef:Bt,getSectionCompareStyle:oi,connectedSections:rn,openMoreFunctionsPopup:Wt,openSummaryPopup:fi,deviationNodeIdToView:_e,deviationTargetParentId:Si,onToggle:function(){hi(),Ot(o,"right")},navigation:n.id?yi[n.id]:null,showOpenNodeRef:bi,resolvedMarkdownStyles:Cn,maintainRelativeOrder:De,showDeviationBadges:Me,renderSubSections:Ii})})),De&&p&&i(d,e({ref:yt.current[o],"data-section-id":l.id,sx:{position:"absolute",top:"18px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"11px",bgcolor:p.badgeBg,color:p.badgeText,border:"1px solid ".concat(p.badgeBorder),borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:u.length>0?u.join(", "):"-"}))]}))}),"right-row-".concat(o))}),i("div",{ref:_n,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))};export{Y as default};
2
2
  //# sourceMappingURL=CognitiveCompare.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as t}from"tslib";import{jsx as e,jsxs as n}from"react/jsx-runtime";import{Popper as o,Paper as i,Box as l,Typography as r,IconButton as a,Accordion as c,AccordionSummary as d,AccordionDetails as u}from"@mui/material";import{Info as p,X as s,ChevronDown as m}from"lucide-react";import{useRef as f,useState as x,useEffect as g}from"react";function h(h){var v,b,w,y=h.open,C=h.anchorEl,S=h.containerEl,B=h.clipTopEl,R=h.scrollContainerEl,z=h.onClose,E=h.summary;h.markdownStyles,h.isLoading;var W=f(null),A=f(null),H=x(null),I=H[0],M=H[1],_=x(null),k=_[0],L=_[1],F=x(null),T=F[0],j=F[1],N=x(0),O=N[0],P=N[1],q="string"==typeof E?{deviation_summary:E}:null!=E?E:{};q.deviation_title;var D=q.deviation_summary,G=q.deviation_impact,J=q.evaluation_outputs,V=!!String(G||"").trim(),Z=(null===(v=null==J?void 0:J.metadata)||void 0===v?void 0:v.label_color)||"#6366F1",K=null!==(b=null==S?void 0:S.getBoundingClientRect().width)&&void 0!==b?b:180,Q=Math.max(148,K+70),U=C&&S?{top:C.getBoundingClientRect().top,bottom:C.getBoundingClientRect().bottom,left:S.getBoundingClientRect().left+S.getBoundingClientRect().width/2}:null;g(function(){if(!y||!C||!S)return M(null),L(null),void j(null);var t=function(){null!==W.current&&cancelAnimationFrame(W.current),W.current=requestAnimationFrame(function(){var t,e,n=C.getBoundingClientRect(),o=S.getBoundingClientRect(),i=null==B?void 0:B.getBoundingClientRect(),l=null==R?void 0:R.getBoundingClientRect();M({top:n.top,bottom:n.bottom,left:o.left+o.width/2}),L(null!==(t=null==i?void 0:i.bottom)&&void 0!==t?t:null),j(null!==(e=null==l?void 0:l.bottom)&&void 0!==e?e:null),A.current&&P(A.current.offsetHeight)})};t();var e=!0;return window.addEventListener("scroll",t,{passive:!0,capture:e}),window.addEventListener("resize",t),function(){null!==W.current&&cancelAnimationFrame(W.current),window.removeEventListener("scroll",t,e),window.removeEventListener("resize",t)}},[y,C,S,B,R]);var X=null!==(w=null!=I?I:U)&&void 0!==w?w:{top:0,bottom:0,left:0},Y=X.bottom+20,$=Y+O,tt=null!=k?Math.max(0,k-Y):0,et=null!=T?Math.max(0,$-T):0;return E?e(o,t({open:y,disablePortal:!0,popperOptions:{strategy:"fixed"},anchorEl:{getBoundingClientRect:function(){return{width:0,height:X.bottom-X.top,top:X.top,bottom:X.bottom,left:X.left,right:X.left,x:X.left,y:X.top,toJSON:function(){}}}},placement:"bottom",modifiers:[{name:"offset",options:{offset:[0,20]}}],sx:{zIndex:20}},{children:n(i,t({ref:A,sx:t(t({p:1.5,borderRadius:"12px",width:Q,maxWidth:Q},(tt>0||et>0)&&{clipPath:"inset(".concat(tt,"px 0 ").concat(et-150,"px 0 round 12px)")}),{transition:"transform 80ms linear",willChange:"transform",backfaceVisibility:"hidden",transform:"translateZ(0)",boxShadow:"0px 10px 24px rgba(15, 23, 42, 0.18)",border:"1px solid ".concat(Z,"26"),borderTop:"3px solid ".concat(Z),overflow:"hidden",bgcolor:"#fff"})},{children:[n(l,t({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.75}},{children:[n(l,t({sx:{display:"flex",alignItems:"center",gap:.75,minWidth:0}},{children:[e(p,{size:14,color:Z}),e(r,t({sx:{fontSize:"11px",fontWeight:700,color:Z,textTransform:"uppercase",letterSpacing:"0.4px",lineHeight:1.2}},{children:"Summary"}))]})),e(a,t({size:"small",onClick:z,sx:{p:.25,ml:.5,color:"#64748B"}},{children:e(s,{size:14})}))]})),n(l,t({sx:{display:"flex",flexDirection:"column",gap:1.5}},{children:[e(r,t({sx:{fontSize:"13px",color:"#334155",lineHeight:1.6,fontWeight:400,overflowWrap:"anywhere"}},{children:D||"No summary available."})),V&&n(c,t({disableGutters:!0,elevation:0,sx:{backgroundColor:"".concat(Z,"0A"),border:"1px solid ".concat(Z,"33"),borderRadius:"8px",overflow:"hidden","&:before":{display:"none"},"&.Mui-expanded":{margin:0}}},{children:[e(d,t({expandIcon:e(m,{size:16,color:Z}),sx:{minHeight:"10px",px:1.5,"& .MuiAccordionSummary-content":{py:"5px",my:0},"&.Mui-expanded":{minHeight:"10px",borderBottom:"1px solid ".concat(Z,"1A")}}},{children:e(r,t({sx:{fontSize:"11px",fontWeight:700,color:Z,textTransform:"uppercase",letterSpacing:"0.5px"}},{children:"Impact"}))})),e(u,t({sx:{p:1.5,backgroundColor:"#fff"}},{children:e(r,t({sx:{fontSize:"12px",color:"#475569",lineHeight:1.6,fontWeight:400,overflowWrap:"anywhere"}},{children:String(G).replace("Impact -","")}))}))]}))]}))]}))})):null}export{h as default};
1
+ import{__assign as e}from"tslib";import{jsx as t,jsxs as n}from"react/jsx-runtime";import{Popper as o,Paper as i,Box as l,Typography as r,IconButton as a,Accordion as c,AccordionSummary as d,AccordionDetails as p}from"@mui/material";import{Info as u,X as s,ChevronDown as m}from"lucide-react";import{useRef as f,useState as x,useEffect as h}from"react";function g(g){var v,b,w,y=g.open,C=g.anchorEl,S=g.containerEl,z=g.clipTopEl,B=g.scrollContainerEl,R=g.onClose,W=g.summary;g.markdownStyles,g.isLoading;var E=f(null),H=f(null),k=x(null),A=k[0],I=k[1],M=x(null),_=M[0],L=M[1],F=x(null),T=F[0],j=F[1],N=x(0),O=N[0],P=N[1],q="string"==typeof W?{deviation_summary:W}:null!=W?W:{},D=q.deviation_title,G=q.deviation_summary,J=q.deviation_impact,V=q.evaluation_outputs,Y=!!String(J||"").trim(),Z=(null===(v=null==V?void 0:V.metadata)||void 0===v?void 0:v.label_color)||"#6366F1",K=null!==(b=null==S?void 0:S.getBoundingClientRect().width)&&void 0!==b?b:180,Q=Math.max(148,K+70),U=C&&S?{top:C.getBoundingClientRect().top,bottom:C.getBoundingClientRect().bottom,left:S.getBoundingClientRect().left+S.getBoundingClientRect().width/2}:null;h(function(){if(!y||!C||!S)return I(null),L(null),void j(null);var e=function(){null!==E.current&&cancelAnimationFrame(E.current),E.current=requestAnimationFrame(function(){var e,t,n=C.getBoundingClientRect(),o=S.getBoundingClientRect(),i=null==z?void 0:z.getBoundingClientRect(),l=null==B?void 0:B.getBoundingClientRect();I({top:n.top,bottom:n.bottom,left:o.left+o.width/2}),L(null!==(e=null==i?void 0:i.bottom)&&void 0!==e?e:null),j(null!==(t=null==l?void 0:l.bottom)&&void 0!==t?t:null),H.current&&P(H.current.offsetHeight)})};e();var t=!0;return window.addEventListener("scroll",e,{passive:!0,capture:t}),window.addEventListener("resize",e),function(){null!==E.current&&cancelAnimationFrame(E.current),window.removeEventListener("scroll",e,t),window.removeEventListener("resize",e)}},[y,C,S,z,B]);var X=null!==(w=null!=A?A:U)&&void 0!==w?w:{top:0,bottom:0,left:0},$=X.bottom+20,ee=$+O,te=null!=_?Math.max(0,_-$):0,ne=null!=T?Math.max(0,ee-T):0;return W?t(o,e({open:y,disablePortal:!0,popperOptions:{strategy:"fixed"},anchorEl:{getBoundingClientRect:function(){return{width:0,height:X.bottom-X.top,top:X.top,bottom:X.bottom,left:X.left,right:X.left,x:X.left,y:X.top,toJSON:function(){}}}},placement:"bottom",modifiers:[{name:"offset",options:{offset:[0,20]}}],sx:{zIndex:20}},{children:n(i,e({ref:H,sx:e(e({p:1.5,borderRadius:"12px",width:Q,maxWidth:Q},(te>0||ne>0)&&{clipPath:"inset(".concat(te,"px 0 ").concat(ne-150,"px 0 round 12px)")}),{transition:"transform 80ms linear",willChange:"transform",backfaceVisibility:"hidden",transform:"translateZ(0)",boxShadow:"0px 10px 24px rgba(15, 23, 42, 0.18)",border:"1px solid ".concat(Z,"26"),borderTop:"3px solid ".concat(Z),overflow:"hidden",bgcolor:"#fff"})},{children:[n(l,e({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.75}},{children:[n(l,e({sx:{display:"flex",alignItems:"center",gap:.75,minWidth:0}},{children:[t(u,{size:14,color:Z}),t(r,e({sx:{fontSize:"11px",fontWeight:700,color:Z,textTransform:"uppercase",letterSpacing:"0.4px",lineHeight:1.2}},{children:"Summary"}))]})),t(a,e({size:"small",onClick:R,sx:{p:.25,ml:.5,color:"#64748B"}},{children:t(s,{size:14})}))]})),n(l,e({sx:{display:"flex",flexDirection:"column",gap:1.5,maxHeight:"300px",overflowY:"auto",pr:.5}},{children:[n(l,{children:[D&&t(r,e({sx:{fontSize:"13px",color:Z,lineHeight:1.6,fontWeight:500,overflowWrap:"anywhere"}},{children:D})),t(r,e({sx:{fontSize:"13px",color:"#334155",lineHeight:1.6,fontWeight:400,overflowWrap:"anywhere",whiteSpace:"pre-wrap"}},{children:G||"No summary available."}))]}),Y&&n(c,e({disableGutters:!0,elevation:0,sx:{backgroundColor:"".concat(Z,"0A"),border:"1px solid ".concat(Z,"33"),borderRadius:"4px",overflow:"hidden",flexShrink:0,"&:before":{display:"none"},"&.Mui-expanded":{margin:0}}},{children:[t(d,e({expandIcon:t(m,{size:16,color:Z}),sx:{minHeight:"10px",px:1.5,"& .MuiAccordionSummary-content":{py:"5px",my:0},"&.Mui-expanded":{minHeight:"10px",borderBottom:"1px solid ".concat(Z,"1A")}}},{children:t(r,e({sx:{fontSize:"11px",fontWeight:700,color:Z,textTransform:"uppercase",letterSpacing:"0.5px"}},{children:"Impact"}))})),t(p,e({sx:{p:1.5,backgroundColor:"#fff"}},{children:t(r,e({sx:{fontSize:"12px",color:"#475569",lineHeight:1.6,fontWeight:400,overflowWrap:"anywhere",whiteSpace:"pre-wrap"}},{children:String(J).replace("Impact -","")}))}))]}))]}))]}))})):null}export{g as default};
2
2
  //# sourceMappingURL=CognitiveSummaryPopup.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as i,__spreadArray as e}from"tslib";import{useMemo as t}from"react";import{getSideData as n,getRationale as o,hasValue as l,isMissingStr as d,DEVIATION_BADGE_SEPARATOR as s}from"../CognitiveComparehelpers.js";var r={id:"",title:"",similarity:0,sections:[]},a=function(a,v,u,c,f){void 0===f&&(f=!0);var p=JSON.stringify(u||{}),_=t(function(){var t,l,d,s;if(!a||0===Object.keys(a).length)return{activeProposed:{},activeVariants:[],parseError:"Tree data is required"};var r=JSON.parse(p);try{var u=a.nodes||a,c=[],_=[],b=a.base_root_id,m=a.input_index_map||{0:"left",1:"right"},y=a[b]||u[b];if(!y||!1===y.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[],parseError:null};var x=function(e){if(!e||"object"!=typeof e)return e||null;if(e.deviations)return e;if(!f)return e;var t=Object.keys(e).filter(function(i){return/^\d+$/.test(i)});if(!t.length)return e;var n=t.sort(function(i,e){return Number(i)-Number(e)}),o=null==m?void 0:m[0],l=null==m?void 0:m[1],d={},s={},r=null;return n.forEach(function(i){var t,n,a,v=e[i];if(v&&"object"==typeof v){r||(r=v);var u=(null===(n=null==v?void 0:v.deviation_highlights)||void 0===n?void 0:n[o])||[],c=(null===(a=null==v?void 0:v.deviation_highlights)||void 0===a?void 0:a[l])||[],f=u[0]||"",p=c[0]||"";d[i]=((t={})[o]=f,t[l]=p,t.deviation_summary=(null==v?void 0:v.deviation_summary)||"",t.deviation_title=null==v?void 0:v.deviation_title,t.deviation_impact=null==v?void 0:v.deviation_impact,t.deviation_explanation=null==v?void 0:v.deviation_explanation,t.evaluation_outputs=null==v?void 0:v.evaluation_outputs,t.cognitive_decisioning=null==v?void 0:v.cognitive_decisioning,t.deviation_highlights=null==v?void 0:v.deviation_highlights,t),s[i]=v}}),i(i({},e),{deviation_title:(null==r?void 0:r.deviation_title)||(null==e?void 0:e.deviation_title),deviation_impact:(null==r?void 0:r.deviation_impact)||(null==e?void 0:e.deviation_impact),deviation_summary:(null==r?void 0:r.deviation_summary)||(null==e?void 0:e.deviation_summary),deviation_explanation:(null==r?void 0:r.deviation_explanation)||(null==e?void 0:e.deviation_explanation),evaluation_outputs:(null==r?void 0:r.evaluation_outputs)||(null==e?void 0:e.evaluation_outputs),cognitive_decisioning:(null==r?void 0:r.cognitive_decisioning)||(null==e?void 0:e.cognitive_decisioning),deviations:d,deviation_entries:s})},g=function(e,t){var l,d,s,v=a[e]||u[e];if(!v||!1===v.display_node)return null;var c=n(v,t,m),f=!1!==(null===(l=c.attributes)||void 0===l?void 0:l.display_title),p=!1!==(null===(d=c.attributes)||void 0===d?void 0:d.display_content),_=!!c.title.trim(),b=!!c.content.trim(),y=o(v),h=(null===(s=null==r?void 0:r[e])||void 0===s?void 0:s.evaluation_result)||v.evaluation_result||null,I=x(h),E=[];v.next&&Object.values(v.next).forEach(function(i){var e=u[i];if(e&&!1!==e.display_node){var n=g(i,t);n&&E.push(n)}});var N=!(!_&&!b);return i(i({id:e,title:_?c.title:"",content:b?c.content:"",displayTitle:f,displayContent:p,subsections:E},N?y:{score:void 0,relation:"not_defined"}),{evaluationResult:I})};if(v){var h=function(t,l){var d,s,v,c,f,p,_,b,y,g,I,E,N,S,j,R,O,P,k,C,T;void 0===l&&(l=0);var V=[],D=[];if(!t)return{refSections:V,baseSections:D};var J={},U={},q=-1,w=-1;for(var F in t){var M=t[F],$=a[M]||u[M];if($&&!1!==$.display_node){var z=o($),A=(null===(d=null==r?void 0:r[M])||void 0===d?void 0:d.evaluation_result)||$.evaluation_result||null,B=x(A),G=n($,"1",m),H=n($,"0",m),K=!1!==(null===(s=G.attributes)||void 0===s?void 0:s.display_title)&&G.title.trim()||!1!==(null===(v=G.attributes)||void 0===v?void 0:v.display_content)&&G.content.trim(),L=!1!==(null===(c=H.attributes)||void 0===c?void 0:c.display_title)&&H.title.trim()||!1!==(null===(f=H.attributes)||void 0===f?void 0:f.display_content)&&H.content.trim(),Q=Number(null!==(_=null===(p=G.attributes)||void 0===p?void 0:p.display_index)&&void 0!==_?_:q--),W=Number(null!==(y=null===(b=H.attributes)||void 0===b?void 0:b.display_index)&&void 0!==y?y:w--),X=J[Q]||i(i({id:M,title:!1!==(null===(g=G.attributes)||void 0===g?void 0:g.display_title)?G.title:"",content:!1!==(null===(I=G.attributes)||void 0===I?void 0:I.display_content)?G.content:"",subsections:[]},K?z:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:Q,evaluationResult:B,displayContent:null===(E=G.attributes)||void 0===E?void 0:E.display_content,displayTitle:null===(N=G.attributes)||void 0===N?void 0:N.display_title}),Y=U[W]||i(i({id:M,title:!1!==(null===(S=H.attributes)||void 0===S?void 0:S.display_title)?H.title:"",content:!1!==(null===(j=H.attributes)||void 0===j?void 0:j.display_content)?H.content:"",subsections:[]},L?z:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:W,evaluationResult:B,displayContent:null===(R=H.attributes)||void 0===R?void 0:R.display_content,displayTitle:null===(O=H.attributes)||void 0===O?void 0:O.display_title});Number(Q)>=0&&Number(W)>=0&&((null===(P=X.refIndexes)||void 0===P?void 0:P.includes(Number(W)))||null===(k=X.refIndexes)||void 0===k||k.push(Number(W)),(null===(C=Y.refIndexes)||void 0===C?void 0:C.includes(Number(Q)))||null===(T=Y.refIndexes)||void 0===T||T.push(Number(Q))),J[Q]=X,U[W]=Y;var Z=h($.next,l+1),ii=Z.refSections,ei=Z.baseSections;ii.length>0&&(X.subsections=e(e([],X.subsections||[],!0),ii,!0)),ei.length>0&&(Y.subsections=e(e([],Y.subsections||[],!0),ei,!0))}}V=Object.values(J),D=Object.values(U);var ti=function(i,e){return i.selfIndex<0&&e.selfIndex>=0?1:i.selfIndex>=0&&e.selfIndex<0?-1:i.selfIndex-e.selfIndex};return V.sort(ti),D.sort(ti),{refSections:V,baseSections:D}},I=h(y.next),E=I.refSections,N=I.baseSections;_=E,c=N}else y.next&&Object.values(y.next).forEach(function(i){var e=a[i]||u[i];e&&!1!==e.display_node&&(c.push(g(i,"0")||{id:i,title:"",content:"",subsections:[]}),_.push(g(i,"1")||{id:i,title:"",content:"",subsections:[]}))});return{activeProposed:{title:(null===(l=null===(t=y.comparison_inputs)||void 0===t?void 0:t[m[0]])||void 0===l?void 0:l.title)||"Uploaded Contract",description:y.decision_scope_description||"",sections:c},activeVariants:[{id:"tree-variant-1",title:(null===(s=null===(d=y.comparison_inputs)||void 0===d?void 0:d[m[1]])||void 0===s?void 0:s.title)||"Reference Template",similarity:0,sections:_,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:y.decision_scope_description||""},fields:{}}}}],parseError:null}}catch(i){return console.error("Data Transformation Error: ",i),{activeProposed:{},activeVariants:[],parseError:i instanceof Error?i.message:"Unknown Parsing Error"}}},[a,v,p,f]),b=_.activeProposed,m=_.activeVariants,y=_.parseError,x=(null==m?void 0:m[0])||r,g=t(function(){return(null==b?void 0:b.sections)||[]},[null==b?void 0:b.sections]),h=t(function(){return x.sections||[]},[x.sections]),I=g.length>0||h.length>0,E=t(function(){return c.fields.filter(function(i){var e=i.key;return(!I||"description"!==e)&&(l(null==b?void 0:b[e])||l(x[e]))})},[b,x,I,c.fields]),N=t(function(){var i,e,t={},n={},o={},l=0,r=null===(i=null==a?void 0:a.input_index_map)||void 0===i?void 0:i[0],u=null===(e=null==a?void 0:a.input_index_map)||void 0===e?void 0:e[1],c=function(i,e,a,v,f,p){var _,b,m,y,x,g,h,I;if(i&&function(i,e){var t,l=(null===(t=null==i?void 0:i.evaluationResult)||void 0===t?void 0:t.deviations)||{};Object.keys(l).sort().forEach(function(t){var a=l[t];if(a){var v=!d(a[r]),c=!d(a[u]);if(v||c){var f="".concat(i.id).concat(s).concat(t);void 0===n[f]&&(void 0===o[e]&&(o[e]=1),n[f]=o[e]++)}}})}(i,v),i&&!f){var E=(null==p?void 0:p.id)||"fallback_parent_".concat(l++);t[E]||(t[E]=[]),t[E].push(i)}for(var N=Math.max((null===(_=null==e?void 0:e.subsections)||void 0===_?void 0:_.length)||0,(null===(b=null==a?void 0:a.subsections)||void 0===b?void 0:b.length)||0,(null===(m=null==i?void 0:i.subsections)||void 0===m?void 0:m.length)||0),S=0;S<N;S++)c((null===(y=null==i?void 0:i.subsections)||void 0===y?void 0:y[S])||(null===(x=null==e?void 0:e.subsections)||void 0===x?void 0:x[S])||(null===(g=null==a?void 0:a.subsections)||void 0===g?void 0:g[S]),null===(h=null==e?void 0:e.subsections)||void 0===h?void 0:h[S],null===(I=null==a?void 0:a.subsections)||void 0===I?void 0:I[S],v,!1,p)};return g.forEach(function(i,e){var t,n=e+1;v&&void 0!==i.selfIndex&&i.selfIndex>=0&&(n=i.selfIndex+1);var o=null;if(v){var l=null===(t=i.refIndexes)||void 0===t?void 0:t[0];o=h.find(function(i){return i.selfIndex===l})}else o=h[e];c(i,i,o,n,!0,i)}),h.forEach(function(i,e){var t,n=e+1,o=!1;if(v){var l=null===(t=i.refIndexes)||void 0===t?void 0:t[0],d=g.find(function(i){return i.selfIndex===l});d&&void 0!==d.selfIndex&&d.selfIndex>=0?n=d.selfIndex+1:(o=!0,void 0!==i.selfIndex&&i.selfIndex>=0&&(n=i.selfIndex+1))}else e>=g.length&&(o=!0);o&&c(i,null,i,n,!0,i)}),{parentDeviationRecord:t,registry:n}},[g,h,v,a]),S=N.parentDeviationRecord,j=N.registry;return{activeProposed:b,activeVariants:m,existingRule:x,proposedSections:g,existingSections:h,visibleFields:E,parentDeviationRecord:S,deviationNumberRegistry:j,parseError:y}};export{a as useCognitiveTreeData};
1
+ import{__assign as i,__spreadArray as e}from"tslib";import{useMemo as t}from"react";import{getSideData as n,getRationale as o,hasValue as l,isMissingStr as d,DEVIATION_BADGE_SEPARATOR as s}from"../CognitiveComparehelpers.js";var r={id:"",title:"",similarity:0,sections:[]},a=function(a,v,u,c,f){void 0===f&&(f=!0);var p=JSON.stringify(u||{}),_=t(function(){var t,l,d,s;if(!a||0===Object.keys(a).length)return{activeProposed:{},activeVariants:[],parseError:"Tree data is required"};var r=JSON.parse(p);try{var u=a.nodes||a,c=[],_=[],b=a.base_root_id,m=a.input_index_map||{0:"left",1:"right"},y=a[b]||u[b];if(!y||!1===y.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[],parseError:null};var x=function(e){if(!e||"object"!=typeof e)return e||null;if(e.deviations)return e;if(f)return e;var t=Object.keys(e).filter(function(i){return/^\d+$/.test(i)});if(!t.length)return e;var n=t.sort(function(i,e){return Number(i)-Number(e)}),o=null==m?void 0:m[0],l=null==m?void 0:m[1],d={},s={},r=null;return n.forEach(function(i){var t,n,a,v=e[i];if(v&&"object"==typeof v){r||(r=v);var u=(null===(n=null==v?void 0:v.deviation_highlights)||void 0===n?void 0:n[o])||[],c=(null===(a=null==v?void 0:v.deviation_highlights)||void 0===a?void 0:a[l])||[],f=u[0]||"",p=c[0]||"";d[i]=((t={})[o]=f,t[l]=p,t.deviation_summary=(null==v?void 0:v.deviation_summary)||"",t.deviation_title=null==v?void 0:v.deviation_title,t.deviation_impact=null==v?void 0:v.deviation_impact,t.deviation_explanation=null==v?void 0:v.deviation_explanation,t.evaluation_outputs=null==v?void 0:v.evaluation_outputs,t.cognitive_decisioning=null==v?void 0:v.cognitive_decisioning,t.deviation_highlights=null==v?void 0:v.deviation_highlights,t),s[i]=v}}),i(i({},e),{deviation_title:(null==r?void 0:r.deviation_title)||(null==e?void 0:e.deviation_title),deviation_impact:(null==r?void 0:r.deviation_impact)||(null==e?void 0:e.deviation_impact),deviation_summary:(null==r?void 0:r.deviation_summary)||(null==e?void 0:e.deviation_summary),deviation_explanation:(null==r?void 0:r.deviation_explanation)||(null==e?void 0:e.deviation_explanation),evaluation_outputs:(null==r?void 0:r.evaluation_outputs)||(null==e?void 0:e.evaluation_outputs),cognitive_decisioning:(null==r?void 0:r.cognitive_decisioning)||(null==e?void 0:e.cognitive_decisioning),deviations:d,deviation_entries:s})},g=function(e,t){var l,d,s,v=a[e]||u[e];if(!v||!1===v.display_node)return null;var c=n(v,t,m),f=!1!==(null===(l=c.attributes)||void 0===l?void 0:l.display_title),p=!1!==(null===(d=c.attributes)||void 0===d?void 0:d.display_content),_=!!c.title.trim(),b=!!c.content.trim(),y=o(v),h=(null===(s=null==r?void 0:r[e])||void 0===s?void 0:s.evaluation_result)||v.evaluation_result||null,I=x(h),E=[];v.next&&Object.values(v.next).forEach(function(i){var e=u[i];if(e&&!1!==e.display_node){var n=g(i,t);n&&E.push(n)}});var N=!(!_&&!b);return i(i({id:e,title:_?c.title:"",content:b?c.content:"",displayTitle:f,displayContent:p,subsections:E},N?y:{score:void 0,relation:"not_defined"}),{evaluationResult:I})};if(v){var h=function(t,l){var d,s,v,c,f,p,_,b,y,g,I,E,N,S,j,R,O,P,k,C,T;void 0===l&&(l=0);var V=[],D=[];if(!t)return{refSections:V,baseSections:D};var J={},U={},q=-1,w=-1;for(var F in t){var M=t[F],$=a[M]||u[M];if($&&!1!==$.display_node){var z=o($),A=(null===(d=null==r?void 0:r[M])||void 0===d?void 0:d.evaluation_result)||$.evaluation_result||null,B=x(A),G=n($,"1",m),H=n($,"0",m),K=!1!==(null===(s=G.attributes)||void 0===s?void 0:s.display_title)&&G.title.trim()||!1!==(null===(v=G.attributes)||void 0===v?void 0:v.display_content)&&G.content.trim(),L=!1!==(null===(c=H.attributes)||void 0===c?void 0:c.display_title)&&H.title.trim()||!1!==(null===(f=H.attributes)||void 0===f?void 0:f.display_content)&&H.content.trim(),Q=Number(null!==(_=null===(p=G.attributes)||void 0===p?void 0:p.display_index)&&void 0!==_?_:q--),W=Number(null!==(y=null===(b=H.attributes)||void 0===b?void 0:b.display_index)&&void 0!==y?y:w--),X=J[Q]||i(i({id:M,title:!1!==(null===(g=G.attributes)||void 0===g?void 0:g.display_title)?G.title:"",content:!1!==(null===(I=G.attributes)||void 0===I?void 0:I.display_content)?G.content:"",subsections:[]},K?z:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:Q,evaluationResult:B,displayContent:null===(E=G.attributes)||void 0===E?void 0:E.display_content,displayTitle:null===(N=G.attributes)||void 0===N?void 0:N.display_title}),Y=U[W]||i(i({id:M,title:!1!==(null===(S=H.attributes)||void 0===S?void 0:S.display_title)?H.title:"",content:!1!==(null===(j=H.attributes)||void 0===j?void 0:j.display_content)?H.content:"",subsections:[]},L?z:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:W,evaluationResult:B,displayContent:null===(R=H.attributes)||void 0===R?void 0:R.display_content,displayTitle:null===(O=H.attributes)||void 0===O?void 0:O.display_title});Number(Q)>=0&&Number(W)>=0&&((null===(P=X.refIndexes)||void 0===P?void 0:P.includes(Number(W)))||null===(k=X.refIndexes)||void 0===k||k.push(Number(W)),(null===(C=Y.refIndexes)||void 0===C?void 0:C.includes(Number(Q)))||null===(T=Y.refIndexes)||void 0===T||T.push(Number(Q))),J[Q]=X,U[W]=Y;var Z=h($.next,l+1),ii=Z.refSections,ei=Z.baseSections;ii.length>0&&(X.subsections=e(e([],X.subsections||[],!0),ii,!0)),ei.length>0&&(Y.subsections=e(e([],Y.subsections||[],!0),ei,!0))}}V=Object.values(J),D=Object.values(U);var ti=function(i,e){return i.selfIndex<0&&e.selfIndex>=0?1:i.selfIndex>=0&&e.selfIndex<0?-1:i.selfIndex-e.selfIndex};return V.sort(ti),D.sort(ti),{refSections:V,baseSections:D}},I=h(y.next),E=I.refSections,N=I.baseSections;_=E,c=N}else y.next&&Object.values(y.next).forEach(function(i){var e=a[i]||u[i];e&&!1!==e.display_node&&(c.push(g(i,"0")||{id:i,title:"",content:"",subsections:[]}),_.push(g(i,"1")||{id:i,title:"",content:"",subsections:[]}))});return{activeProposed:{title:(null===(l=null===(t=y.comparison_inputs)||void 0===t?void 0:t[m[0]])||void 0===l?void 0:l.title)||"Uploaded Contract",description:y.decision_scope_description||"",sections:c},activeVariants:[{id:"tree-variant-1",title:(null===(s=null===(d=y.comparison_inputs)||void 0===d?void 0:d[m[1]])||void 0===s?void 0:s.title)||"Reference Template",similarity:0,sections:_,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:y.decision_scope_description||""},fields:{}}}}],parseError:null}}catch(i){return console.error("Data Transformation Error: ",i),{activeProposed:{},activeVariants:[],parseError:i instanceof Error?i.message:"Unknown Parsing Error"}}},[a,v,p,f]),b=_.activeProposed,m=_.activeVariants,y=_.parseError,x=(null==m?void 0:m[0])||r,g=t(function(){return(null==b?void 0:b.sections)||[]},[null==b?void 0:b.sections]),h=t(function(){return x.sections||[]},[x.sections]),I=g.length>0||h.length>0,E=t(function(){return c.fields.filter(function(i){var e=i.key;return(!I||"description"!==e)&&(l(null==b?void 0:b[e])||l(x[e]))})},[b,x,I,c.fields]),N=t(function(){var i,e,t={},n={},o={},l=0,r=null===(i=null==a?void 0:a.input_index_map)||void 0===i?void 0:i[0],u=null===(e=null==a?void 0:a.input_index_map)||void 0===e?void 0:e[1],c=function(i,e,a,v,f,p){var _,b,m,y,x,g,h,I;if(i&&function(i,e){var t,l=(null===(t=null==i?void 0:i.evaluationResult)||void 0===t?void 0:t.deviations)||{};Object.keys(l).sort().forEach(function(t){var a=l[t];if(a){var v=!d(a[r]),c=!d(a[u]);if(v||c){var f="".concat(i.id).concat(s).concat(t);void 0===n[f]&&(void 0===o[e]&&(o[e]=1),n[f]=o[e]++)}}})}(i,v),i&&!f){var E=(null==p?void 0:p.id)||"fallback_parent_".concat(l++);t[E]||(t[E]=[]),t[E].push(i)}for(var N=Math.max((null===(_=null==e?void 0:e.subsections)||void 0===_?void 0:_.length)||0,(null===(b=null==a?void 0:a.subsections)||void 0===b?void 0:b.length)||0,(null===(m=null==i?void 0:i.subsections)||void 0===m?void 0:m.length)||0),S=0;S<N;S++)c((null===(y=null==i?void 0:i.subsections)||void 0===y?void 0:y[S])||(null===(x=null==e?void 0:e.subsections)||void 0===x?void 0:x[S])||(null===(g=null==a?void 0:a.subsections)||void 0===g?void 0:g[S]),null===(h=null==e?void 0:e.subsections)||void 0===h?void 0:h[S],null===(I=null==a?void 0:a.subsections)||void 0===I?void 0:I[S],v,!1,p)};return g.forEach(function(i,e){var t,n=e+1;v&&void 0!==i.selfIndex&&i.selfIndex>=0&&(n=i.selfIndex+1);var o=null;if(v){var l=null===(t=i.refIndexes)||void 0===t?void 0:t[0];o=h.find(function(i){return i.selfIndex===l})}else o=h[e];c(i,i,o,n,!0,i)}),h.forEach(function(i,e){var t,n=e+1,o=!1;if(v){var l=null===(t=i.refIndexes)||void 0===t?void 0:t[0],d=g.find(function(i){return i.selfIndex===l});d&&void 0!==d.selfIndex&&d.selfIndex>=0?n=d.selfIndex+1:(o=!0,void 0!==i.selfIndex&&i.selfIndex>=0&&(n=i.selfIndex+1))}else e>=g.length&&(o=!0);o&&c(i,null,i,n,!0,i)}),{parentDeviationRecord:t,registry:n}},[g,h,v,a]),S=N.parentDeviationRecord,j=N.registry;return{activeProposed:b,activeVariants:m,existingRule:x,proposedSections:g,existingSections:h,visibleFields:E,parentDeviationRecord:S,deviationNumberRegistry:j,parseError:y}};export{a as useCognitiveTreeData};
2
2
  //# sourceMappingURL=useCompareData.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CognitiveCompareTest.d.ts","sourceRoot":"","sources":["../../../src/CognitiveCompareTest.tsx"],"names":[],"mappings":"AAcA,QAAA,MAAM,oBAAoB,+CAsBzB,CAAA;AAED,eAAe,oBAAoB,CAAC"}
1
+ {"version":3,"file":"CognitiveCompareTest.d.ts","sourceRoot":"","sources":["../../../src/CognitiveCompareTest.tsx"],"names":[],"mappings":"AAcA,QAAA,MAAM,oBAAoB,+CAwBzB,CAAA;AAED,eAAe,oBAAoB,CAAC"}
@@ -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,GAg+M/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,GAksY/B,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"CognitiveCompare.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitiveCompare.tsx"],"names":[],"mappings":"AAgCA,OAAO,EAEL,qBAAqB,EAMtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAGL,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AAiBlC,QAAA,MAAM,gBAAgB,4MAmBnB,qBAAqB,4CAqnGvB,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":"AAgCA,OAAO,EAEL,qBAAqB,EAMtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAGL,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AAiBlC,QAAA,MAAM,gBAAgB,4MAmBnB,qBAAqB,4CAkoGvB,CAAC;AAEF,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAClC,eAAe,gBAAgB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"CognitiveSummaryPopup.d.ts","sourceRoot":"","sources":["../../../../../../src/features/CognitiveCompare/components/CognitiveSummaryPopup.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAGtE,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,EAC5C,IAAI,EACJ,QAAQ,EACR,WAAW,EACX,SAAS,EACT,iBAAiB,EACjB,OAAO,EACP,OAAO,EACP,cAAc,EACd,SAAS,GACV,EAAE,0BAA0B,kDAwS5B"}
1
+ {"version":3,"file":"CognitiveSummaryPopup.d.ts","sourceRoot":"","sources":["../../../../../../src/features/CognitiveCompare/components/CognitiveSummaryPopup.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAGtE,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,EAC5C,IAAI,EACJ,QAAQ,EACR,WAAW,EACX,SAAS,EACT,iBAAiB,EACjB,OAAO,EACP,OAAO,EACP,cAAc,EACd,SAAS,GACV,EAAE,0BAA0B,kDAuT5B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viswa-test/test-citation",
3
- "version": "0.0.94",
3
+ "version": "0.0.96",
4
4
  "author": "Viswa Koduru",
5
5
  "description": "",
6
6
  "license": "MIT",