@viswa-test/test-citation 0.0.95 → 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,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,re=b.popupConfig,le=b.deviationData,ue=void 0===le?{}:le,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),rn=t.useRef(null),ln=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,r,l;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!==(l=null===(r=null==Z?void 0:Z.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l: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,rt=Kn.getSubSectionRef,lt=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,r;Ee(!1),Xe.current=!1;var l=Je.current,c=Tt.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=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[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=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===(r=$n.current[c])||void 0===r?void 0:r.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,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?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:l||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,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}},[Qe,Q]),yt=t.useCallback(function(e){Dn(),yn(null),xn(e)},[Dn]),St=function(e,n,t,i,o,r){var l;if(e.stopPropagation(),_n.open&&_n.sectionIdx===o)Dn();else{var c=e.currentTarget,a="left";(null===(l=ln.current)||void 0===l?void 0:l.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 r=o.split(u.DEVIATION_BADGE_SEPARATOR),l="".concat(r[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(r[1]);return"right"===a?null===(e=Zn.current[l])||void 0===e?void 0:e.current:null===(n=Qn.current[l])||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,r))})}},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,r,l,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===(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}},[ut]),Mt=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=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===(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})},[Ln,Gn,Qe,Cn,de]),Vt=t.useCallback(function(n){for(var t,i,o,r,l,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!==(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})},[Ln,Gn,Qe,Cn]),Lt=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(!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,r=null===(t=Xn.current[i])||void 0===t?void 0:t.current;o&&r&&(o.style.height="auto",r.style.height="auto",o.style.minHeight="0px",r.style.minHeight="0px")}),!ze.current){for(var 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,r=null===(t=Xn.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(!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===(r=nt.current[P])||void 0===r?void 0:r.current,B=null===(l=tt.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(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 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(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,r=null===(t=Xn.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=D[i];o.style.minHeight="".concat(l,"px"),r.style.minHeight="".concat(l,"px")}}),ze.current||(Object.entries(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 r=O[e];i.style.minHeight="".concat(r,"px"),o.style.minHeight="".concat(r,"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,r,l,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!==(r=null===(o=dn.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==r?r:0,S=null!==(u=null===(l=ln.current)||void 0===l?void 0:l.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=ln.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,r,l;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===(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=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=ln.current)||void 0===x?void 0:x.getBoundingClientRect().top)&&void 0!==_?_:0,re=ie+(null!==(R=null===(m=dn.current)||void 0===m?void 0:m.clientHeight)&&void 0!==R?R:1/0),le=oe+(null!==(S=null===(y=ln.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,re)-A.top,te=ue(Q.top+Q.height/2,oe,le)-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=ln.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,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=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===(r=null==O?void 0:O.refIndexes)||void 0===r?void 0:r.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,r=null===(t=Zn.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),c=r.getBoundingClientRect(),a=Mt(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-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,r,l,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=ln.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,_=null!==(r=null===(o=dn.current)||void 0===o?void 0:o.clientHeight)&&void 0!==r?r:1/0,m=null!==(c=null===(l=ln.current)||void 0===l?void 0:l.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=ln.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 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(){$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,r,l,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===(r=$n.current[Number(x[3])])||void 0===r?void 0:r.current)||null}else g=(null===(l=it.current[d])||void 0===l?void 0:l.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=ln.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,r,l,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=ln.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===(r=Qn.current[S])||void 0===r?void 0:r.current,R=null===(l=Zn.current[S])||void 0===l?void 0:l.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,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";Dn(),null!=e&&(n?Se("No counterpart exists for this section."):Ae&&je===e?r?ft():null==l||l():(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,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=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===(r=et.current[_])||void 0===r?void 0:r.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=ln.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=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===(r=Qn.current[y])||void 0===r?void 0:r.current)||h,m=(null===(l=Zn.current[y])||void 0===l?void 0:l.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==l||l()};if(!s||!m)return Fe.current=!1,me(!1),void(null==l||l());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,r="string"==typeof i?u.safeStringify(i).trim():u.safeStringify(null==i?void 0:i.deviation_summary).trim(),l=e.currentTarget;Bn();var c="left";(null===(o=ln.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=Zn.current[l])||void 0===e?void 0:e.current:null===(t=Qn.current[l])||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(r&&requestAnimationFrame(function(){var e=a()||l;An({open:!0,anchorEl:e,summary:i})}));Kt(n,t,r?{toggleIfSame:!1,sourceSide:c,onReady:function(){var e=a()||l;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=ln.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 r=!1,l=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 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},d=function(){var n,i,v,g;if(!r){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"),l+=1,void(c=setTimeout(d,450))}else if(!(de?!!ht["left-".concat(B)]:!!ht[String(B)])&&B>=0)return mt(B,"left"),l+=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?ln.current:dn.current:on.current,M&&C){var V=M.getBoundingClientRect();if(0===V.height)return void((l+=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 e,n,t,i,l;if(!r){ti.current=ce;var u=window.getComputedStyle(M).color;P&&(P.style.transition="box-shadow 300ms ease-in-out",P.style.boxShadow="0 0 10px ".concat(u)),F&&(F.style.transition="box-shadow 300ms ease-in-out",F.style.boxShadow="0 0 10px ".concat(u)),setTimeout(function(){P&&(P.style.boxShadow=""),F&&(F.style.boxShadow="")},2e3);var c=(null===(n=null===(e=p.evaluationResult)||void 0===e?void 0:e.deviations)||void 0===n?void 0:n[o])||p,a=(null===(t=p.evaluationResult)||void 0===t?void 0:t.evaluation_outputs)||p.evaluation_outputs;if(!(!!P&&!!F)){var s=k?(null===(i=Zn.current[j])||void 0===i?void 0:i.current)||F:(null===(l=Qn.current[j])||void 0===l?void 0:l.current)||P;return An({open:!0,anchorEl:s,summary:{deviation_summary:c.deviation_summary||c,evaluation_outputs:a}}),void(null==ae||ae())}Kt(N,!1,{toggleIfSame:!1,sourceSide:"left",onReady:function(){var e,n=(null===(e=Qn.current[j])||void 0===e?void 0:e.current)||P;An({open:!0,anchorEl:n,summary:{deviation_summary:c.deviation_summary||c,evaluation_outputs:a}})}})}};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(l+=1)<20&&(c=setTimeout(d,a))}else(l+=1)<20&&(c=setTimeout(d,a))}else(l+=1)<20&&(c=setTimeout(d,a))}};return c=setTimeout(d,a),function(){r=!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,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:xt,setExpandedSubSections:_t,maintainRelativeOrder:de||!1,proposedSections:Ln,existingSections:Gn,treeData:Q,deviationNumberRegistry:zn,connectedSections:Me,activeSideBySideSection:je,resolvedMarkdownStyles:tn,getSubSectionRef:rt,getSubSectionCompareStyle:Vt,getBadgeRef:lt,openMoreFunctionsPopup:St,openSummaryPopup:Ut,showDeviationBadges:ge,resetSideBySide:ft,setConnectedSections:Ve,setConnectedLines:He,cachedConnectedPositions:Ke})};return n.jsxs(i.Box,e.__assign({ref:rn,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:re,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 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?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===(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&&(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(r.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,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){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: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)"},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,r){var l,c,a=!t.title&&!t.content;if(de&&a)return null;var s=t,d=Mt(r,"left"),v=de?!(null===(l=s.refIndexes)||void 0===l?void 0:l.length)||s.selfIndex<0:!Gn[r],f=de?"number"==typeof s.selfIndex&&s.selfIndex>=0?s.selfIndex+1:null:r+1,p=Me.has(r),h=u.extractDeviationScore(s.evaluationResult,null==d?void 0:d.deviationLabel);return n.jsx(i.Box,e.__assign({ref:ot(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:Jn.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:ot("left-accordion-".concat(r)),mb:0,treeData:Q,proposedSections:Ln,existingSections:Gn,deviationNumberRegistry:zn,getSectionCompareStyle:Mt,getBadgeRef:lt,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(r)]:!!ht[String(r)],onToggle:function(){Jt(),mt(r,"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[r],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[r]||{title:"",content:""};St(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:!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(r))}),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(r.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(l.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:ln,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 r,l=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(l.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(l.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(l.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===(r=null==Q?void 0:Q.input_index_map)||void 0===r?void 0:r[1])||"",isExpanded:de?!!ht["right-".concat(o)]:!!ht[String(o)],treeData:Q,proposedSections:Ln,existingSections:Gn,deviationNumberRegistry:zn,getBadgeRef:lt,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":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:cn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),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"),n=require("react/jsx-runtime"),t=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],S=i.useState(null),C=S[0],B=S[1],R=i.useState(0),z=R[0],E=R[1],W="string"==typeof m?{deviation_summary:m}:null!=m?m:{},A=W.deviation_title,T=W.deviation_summary,I=W.deviation_impact,H=W.evaluation_outputs,M=!!String(I||"").trim(),q=(null===(l=null==H?void 0:H.metadata)||void 0===l?void 0:l.label_color)||"#6366F1",k=null!==(a=null==u?void 0:u.getBoundingClientRect().width)&&void 0!==a?a:180,L=Math.max(148,k+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),j(null),void B(null);var e=function(){null!==f.current&&cancelAnimationFrame(f.current),f.current=requestAnimationFrame(function(){var e,n,t=d.getBoundingClientRect(),o=u.getBoundingClientRect(),i=null==p?void 0:p.getBoundingClientRect(),r=null==x?void 0:x.getBoundingClientRect();b({top:t.top,bottom:t.bottom,left:o.left+o.width/2}),j(null!==(e=null==i?void 0:i.bottom)&&void 0!==e?e:null),B(null!==(n=null==r?void 0:r.bottom)&&void 0!==n?n:null),h.current&&E(h.current.offsetHeight)})};e();var n=!0;return window.addEventListener("scroll",e,{passive:!0,capture:n}),window.addEventListener("resize",e),function(){null!==f.current&&cancelAnimationFrame(f.current),window.removeEventListener("scroll",e,n),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 m?n.jsx(t.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:n.jsxs(t.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(q,"26"),borderTop:"3px solid ".concat(q),overflow:"hidden",bgcolor:"#fff"})},{children:[n.jsxs(t.Box,e.__assign({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.75}},{children:[n.jsxs(t.Box,e.__assign({sx:{display:"flex",alignItems:"center",gap:.75,minWidth:0}},{children:[n.jsx(o.Info,{size:14,color:q}),n.jsx(t.Typography,e.__assign({sx:{fontSize:"11px",fontWeight:700,color:q,textTransform:"uppercase",letterSpacing:"0.4px",lineHeight:1.2}},{children:"Summary"}))]})),n.jsx(t.IconButton,e.__assign({size:"small",onClick:g,sx:{p:.25,ml:.5,color:"#64748B"}},{children:n.jsx(o.X,{size:14})}))]})),n.jsxs(t.Box,e.__assign({sx:{display:"flex",flexDirection:"column",gap:1.5}},{children:[n.jsxs(t.Box,{children:[A&&n.jsx(t.Typography,e.__assign({sx:{fontSize:"13px",color:q,lineHeight:1.6,fontWeight:500,overflowWrap:"anywhere"}},{children:A})),n.jsx(t.Typography,e.__assign({sx:{fontSize:"13px",color:"#334155",lineHeight:1.6,fontWeight:400,overflowWrap:"anywhere"}},{children:T||"No summary available."}))]}),M&&n.jsxs(t.Accordion,e.__assign({disableGutters:!0,elevation:0,sx:{backgroundColor:"".concat(q,"0A"),border:"1px solid ".concat(q,"33"),borderRadius:"4px",overflow:"hidden","&:before":{display:"none"},"&.Mui-expanded":{margin:0}}},{children:[n.jsx(t.AccordionSummary,e.__assign({expandIcon:n.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:n.jsx(t.Typography,e.__assign({sx:{fontSize:"11px",fontWeight:700,color:q,textTransform:"uppercase",letterSpacing:"0.5px"}},{children:"Impact"}))})),n.jsx(t.AccordionDetails,e.__assign({sx:{p:1.5,backgroundColor:"#fff"}},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"12px",color:"#475569",lineHeight:1.6,fontWeight:400,overflowWrap:"anywhere"}},{children:String(I).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
- 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 e=_e.split(":"),t=e[0],i=e[1],o=null!=i?i:"0";Ci.current!==_e&&(qn(),Jn(),Nt(),ln(new Set),dn([]),fn.current=[],Ci.current=_e);var r=!1,l=0,u=null,c=150,d=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},a=function(){var e,i,s,v;if(!r){var p=null,f=null;for(var g in dt){var h=dt[g].find(function(e){return e.id===t});if(h){p=g,f=h;break}}if(f&&p){var x=lt.findIndex(function(e){return e.id===p}),m=ut.findIndex(function(e){return e.id===p}),y=-1===x&&-1!==m,b=d(lt,f.id),R=d(ut,f.id);if(b&&!R&&!y){var C=b.split("-"),I=Number(C[0]);if(De){var w=null===(i=null===(e=lt[I])||void 0===e?void 0:e.refIndexes)||void 0===i?void 0:i[0],B=ut.findIndex(function(e){return e.selfIndex===w});-1!==B&&(I=B)}R=n([I],C.slice(1),!0).join("-")}if(b||R){var T=y||!b&&!!R,_=b?Number(b.split("-")[0]):x,E=R?Number(R.split("-")[0]):m;if(T){if(!(De?!!Ht["right-".concat(E)]:!!Ht[String(E)])&&E>=0)return Ot(E,"right"),l+=1,void(u=setTimeout(a,450))}else if(!(De?!!Ht["left-".concat(_)]:!!Ht[String(_)])&&_>=0)return Ot(_,"left"),l+=1,void(u=setTimeout(a,450));var F,D=b||"",k=R||"",M="".concat(f.id).concat(S).concat(o).concat(S).concat(D).concat(S).concat(k),N="".concat(f.id).concat(S).concat(o),A=null===(s=mt.current[N])||void 0===s?void 0:s.current,H=null===(v=yt.current[N])||void 0===v?void 0:v.current,L=T||!A&&!!H,j=L?H:A;if(F=De?L?Bn.current:Dn.current:In.current,j&&F){var O=j.getBoundingClientRect();if(0===O.height)return void((l+=1)<20&&(u=setTimeout(a,c)));var P=F.getBoundingClientRect(),z=O.top-P.top+F.scrollTop-P.height/2+O.height/2,W=function(){var e,n,t,i,l;if(!r){Ri.current=_e;var u=window.getComputedStyle(j).color;A&&(A.style.transition="box-shadow 300ms ease-in-out",A.style.boxShadow="0 0 10px ".concat(u)),H&&(H.style.transition="box-shadow 300ms ease-in-out",H.style.boxShadow="0 0 10px ".concat(u)),setTimeout(function(){A&&(A.style.boxShadow=""),H&&(H.style.boxShadow="")},2e3);var c=(null===(n=null===(e=f.evaluationResult)||void 0===e?void 0:e.deviations)||void 0===n?void 0:n[o])||f,d=(null===(t=f.evaluationResult)||void 0===t?void 0:t.evaluation_outputs)||f.evaluation_outputs;if(!(!!A&&!!H)){var a=L?(null===(i=yt.current[N])||void 0===i?void 0:i.current)||H:(null===(l=mt.current[N])||void 0===l?void 0:l.current)||A;return Kn({open:!0,anchorEl:a,summary:{deviation_summary:c.deviation_summary||c,evaluation_outputs:d}}),void(null==Ee||Ee())}pi(M,!1,{toggleIfSame:!1,sourceSide:"left",onReady:function(){var e,n=(null===(e=mt.current[N])||void 0===e?void 0:e.current)||A;Kn({open:!0,anchorEl:n,summary:{deviation_summary:c.deviation_summary||c,evaluation_outputs:d}})}})}};Math.abs(F.scrollTop-z)<=2?W():(Mn.current=z,Nn.current=W,F.scrollTo({top:z,behavior:"smooth"}),u&&clearTimeout(u),u=setTimeout(function(){if(Nn.current){Mn.current=null;var e=Nn.current;Nn.current=null,e()}},800))}else(l+=1)<20&&(u=setTimeout(a,c))}else(l+=1)<20&&(u=setTimeout(a,c))}else(l+=1)<20&&(u=setTimeout(a,c))}};return u=setTimeout(a,c),function(){r=!0,u&&clearTimeout(u)}}},[_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};
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 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 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,z=h.clipTopEl,B=h.scrollContainerEl,R=h.onClose,W=h.summary;h.markdownStyles,h.isLoading;var E=f(null),H=f(null),A=x(null),I=A[0],M=A[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 W?{deviation_summary:W}:null!=W?W:{},D=q.deviation_title,G=q.deviation_summary,J=q.deviation_impact,V=q.evaluation_outputs,Z=!!String(J||"").trim(),K=(null===(v=null==V?void 0:V.metadata)||void 0===v?void 0:v.label_color)||"#6366F1",Q=null!==(b=null==S?void 0:S.getBoundingClientRect().width)&&void 0!==b?b:180,U=Math.max(148,Q+70),X=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 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();M({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 Y=null!==(w=null!=I?I:X)&&void 0!==w?w:{top:0,bottom:0,left:0},$=Y.bottom+20,ee=$+O,te=null!=k?Math.max(0,k-$):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:Y.bottom-Y.top,top:Y.top,bottom:Y.bottom,left:Y.left,right:Y.left,x:Y.left,y:Y.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:U,maxWidth:U},(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(K,"26"),borderTop:"3px solid ".concat(K),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(p,{size:14,color:K}),t(r,e({sx:{fontSize:"11px",fontWeight:700,color:K,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}},{children:[n(l,{children:[D&&t(r,e({sx:{fontSize:"13px",color:K,lineHeight:1.6,fontWeight:500,overflowWrap:"anywhere"}},{children:D})),t(r,e({sx:{fontSize:"13px",color:"#334155",lineHeight:1.6,fontWeight:400,overflowWrap:"anywhere"}},{children:G||"No summary available."}))]}),Z&&n(c,e({disableGutters:!0,elevation:0,sx:{backgroundColor:"".concat(K,"0A"),border:"1px solid ".concat(K,"33"),borderRadius:"4px",overflow:"hidden","&:before":{display:"none"},"&.Mui-expanded":{margin:0}}},{children:[t(d,e({expandIcon:t(m,{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(r,e({sx:{fontSize:"11px",fontWeight:700,color:K,textTransform:"uppercase",letterSpacing:"0.5px"}},{children:"Impact"}))})),t(u,e({sx:{p:1.5,backgroundColor:"#fff"}},{children:t(r,e({sx:{fontSize:"12px",color:"#475569",lineHeight:1.6,fontWeight:400,overflowWrap:"anywhere"}},{children:String(J).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 +1 @@
1
- {"version":3,"file":"CognitiveCompareTest.d.ts","sourceRoot":"","sources":["../../../src/CognitiveCompareTest.tsx"],"names":[],"mappings":"AAcA,QAAA,MAAM,oBAAoB,+CAuBzB,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,GAswG/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":"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,kDAwT5B"}
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.95",
3
+ "version": "0.0.96",
4
4
  "author": "Viswa Koduru",
5
5
  "description": "",
6
6
  "license": "MIT",