@viswa-test/test-citation 0.0.38 → 0.0.39

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"),r=require("lucide-react"),o=require("../../assests/svg/ButtonCognitiveIcon.js"),l=require("./OverlayComponent.js"),s=require("react-markdown"),a=require("./CognitiveComparehelpers.js"),c=require("./CognitiveCompareConfig.js"),u=require("./CognitivePopup.js"),d=require("./MoreFunctionsPopup.js"),f=require("./LoaderComponent.js"),v=require("rehype-raw");function h(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var p=h(t),g=h(s),x=h(v),m=p.default.memo(function(r){var o=r.content,l=r.sxStyles,s=r.highlights,c=void 0===s?[]:s,u=t.useMemo(function(){return{mark:function(t){var i=t.children;return n.jsx("span",e.__assign({style:{backgroundColor:"#fccccc"}},{children:i}))}}},[]),d=t.useMemo(function(){var e=o;return c.forEach(function(n){e=e.replaceAll(n,"<mark>".concat(n,"</mark>"))}),e},[o,c]);return n.jsx(i.Typography,e.__assign({component:"div",sx:l},{children:n.jsx(g.default,e.__assign({components:u,rehypePlugins:[x.default]},{children:a.safeStringify(d).replace(/\\n/g,"\n")}))}))},function(e,n){if(e.content!==n.content)return!1;if(e.sxStyles!==n.sxStyles)return!1;var t=e.highlights||[],i=n.highlights||[];if(t.length!==i.length)return!1;for(var r=0;r<t.length;r++)if(t[r]!==i[r])return!1;return!0}),y=function(e,n,t,i,r){void 0===r&&(r=14);var o=e+.65*(t-e),l=i-n;if(Math.abs(l)<3)return"M ".concat(e," ").concat(n," H ").concat(t);var s=l>0?1:-1,a=Math.min(r,Math.abs(l)/2,Math.abs(o-e)/2,Math.abs(t-o)/2);return["M ".concat(e," ").concat(n),"H ".concat(o-a),"Q ".concat(o," ").concat(n," ").concat(o," ").concat(n+s*a),"V ".concat(i-s*a),"Q ".concat(o," ").concat(i," ").concat(o+a," ").concat(i),"H ".concat(t)].join(" ")},_={id:"",title:""},b={open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,isOrphan:!1,docData:null,deviationData:null},S=function(e,n,t,i,r){void 0===t&&(t=300);var o=e.style.scrollBehavior;e.style.scrollBehavior="auto";var l=e.scrollTop,s=n-l,a=null,c=function(u){null===a&&(a=u);var d,f=u-a;f<t?(e.scrollTop=(d=f,d/=t,s*(--d*d*d+1)+l),r&&r(),requestAnimationFrame(c)):(e.scrollTop=n,e.style.scrollBehavior=o,r&&r(),i&&i())};requestAnimationFrame(c)};exports.SHARED_MARKDOWN_STYLES=c.SHARED_MARKDOWN_STYLES,exports.default=function(s){var v,h,g,x,R,I,C,F,w=s.componentHeaderText,j=void 0===w?"Contract Comparison":w,B=s.treeData,E=s.comparisonConfig,T=s.leftColumnTitleText,D=s.rightColumnTitleText,k=s.markdownStyles,A=s.displayConfig,M=void 0===A?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1}:A,O=s.popupConfig,N=s.deviationData,H=void 0===N?{}:N,L=t.useState(M.maintainRelativeOrder),W=L[0],z=L[1],P=t.useState(!1),q=P[0],V=P[1],Y=t.useState(!1),K=Y[0],U=Y[1],X=t.useState(null),G=X[0],J=X[1],Q=t.useState(!1),Z=Q[0],$=Q[1],ee=t.useState(!1),ne=ee[0],te=ee[1],ie=t.useRef(!1),re=t.useState(null),oe=re[0],le=re[1],se=t.useState(new Set),ae=se[0],ce=se[1],ue=t.useState([]),de=ue[0],fe=ue[1],ve=t.useRef(null),he=t.useRef(!1),pe=t.useRef(null),ge=t.useRef({}),xe=t.useRef([]),me=t.useRef(!1),ye=t.useRef(!1),_e=t.useRef(null),be=t.useMemo(function(){return(null==B?void 0:B.cognitive_decisioning)||{}},[B]),Se=t.useState(null),Re=Se[0],Ie=Se[1],Ce=t.useRef(null),Fe=t.useState({width:0,height:0}),we=Fe[0],je=Fe[1],Be=t.useMemo(function(){return e.__assign(e.__assign({},c.SHARED_MARKDOWN_STYLES),k)},[k]),Ee=t.useState({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,isOrphan:!1,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null,deviationData:null}),Te=Ee[0],De=Ee[1],ke=t.useState({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,isOrphan:!1,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null,deviationData:null}),Ae=ke[0],Me=ke[1],Oe=t.useRef(null),Ne=t.useRef(null),He=t.useRef(null),Le=t.useRef(null),We=t.useRef(null),ze=t.useRef(null),Pe=t.useRef(null),qe=t.useRef(null),Ve=t.useRef(!1),Ye=t.useRef(null);t.useEffect(function(){Ye.current=null},[Te.sectionIdx,Te.open]);var Ke=t.useCallback(function(){Ie(null),De(b),le(null)},[]),Ue=t.useCallback(function(){Me(b)},[]),Xe=t.useCallback(function(){var e;if(Te.anchorEl&&Te.refSectionTitle){var n=Te.anchorEl.getBoundingClientRect(),t=(null===(e=null==Ce?void 0:Ce.current)||void 0===e?void 0:e.offsetHeight)||0,i=Math.min(680,window.innerWidth-24),r=window.innerHeight-n.bottom-12-12,o=n.top-12-12,l=r<t&&o>r;null!==Ye.current?!0===Ye.current&&(l=o>=t||o>=r):l=!(r>=t||r>=o),Ye.current=l;var s=l?o:r,a=Math.min(t||9999,s),c=l?n.top-12-a:n.bottom+12,u=n.left+n.width/2,d=u-i/2,f=Math.max(12,Math.min(d,window.innerWidth-i-12)),v=Math.max(14,Math.min(u-f,i-10-4));Ie({top:c,left:f,arrowLeft:v,openAbove:l,maxHeight:s})}},[Te.anchorEl,Te.refSectionTitle]);t.useEffect(function(){if(Te.open){window.addEventListener("resize",Xe);var e=requestAnimationFrame(Xe),n=null;return Ce.current&&(n=new ResizeObserver(function(){cancelAnimationFrame(e),e=requestAnimationFrame(Xe)})).observe(Ce.current),function(){cancelAnimationFrame(e),window.removeEventListener("resize",Xe),n&&n.disconnect()}}},[Te.open,Xe]),t.useEffect(function(){var e=Oe.current;if(e&&Te.open){var n=function(e){Ce.current&&Ce.current.contains(e.target)||(Ie(null),Ke())};return e.addEventListener("scroll",n,{capture:!0}),window.addEventListener("scroll",n,{capture:!0}),function(){e.removeEventListener("scroll",n,{capture:!0}),window.removeEventListener("scroll",n,{capture:!0})}}},[Te.open,Ke]),t.useEffect(function(){var e=Oe.current;if(e&&Ae.open){var n=function(){Ue()};return e.addEventListener("scroll",n,{capture:!0}),window.addEventListener("scroll",n,{capture:!0}),function(){e.removeEventListener("scroll",n,{capture:!0}),window.removeEventListener("scroll",n,{capture:!0})}}},[Ae.open,Ue]);var Ge=t.useMemo(function(){var n,t,i,r,o,l,s,a,u,d,f,v;return{fields:null!==(n=null==E?void 0:E.fields)&&void 0!==n?n:c.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(i=null===(t=null==E?void 0:E.thresholds)||void 0===t?void 0:t.high)&&void 0!==i?i:c.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(o=null===(r=null==E?void 0:E.thresholds)||void 0===r?void 0:r.medium)&&void 0!==o?o:c.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(s=null===(l=null==E?void 0:E.thresholds)||void 0===l?void 0:l.exact)&&void 0!==s?s:c.DEFAULT_COMPARISON_CONFIG.thresholds.exact},relationStyles:{noContent:e.__assign(e.__assign({},c.DEFAULT_COMPARISON_CONFIG.relationStyles.noContent),(null===(a=null==E?void 0:E.relationStyles)||void 0===a?void 0:a.noContent)||{}),high:e.__assign(e.__assign({},c.DEFAULT_COMPARISON_CONFIG.relationStyles.high),(null===(u=null==E?void 0:E.relationStyles)||void 0===u?void 0:u.high)||{}),exact:e.__assign(e.__assign({},c.DEFAULT_COMPARISON_CONFIG.relationStyles.exact),(null===(d=null==E?void 0:E.relationStyles)||void 0===d?void 0:d.exact)||{}),medium:e.__assign(e.__assign({},c.DEFAULT_COMPARISON_CONFIG.relationStyles.medium),(null===(f=null==E?void 0:E.relationStyles)||void 0===f?void 0:f.medium)||{}),low:e.__assign(e.__assign({},c.DEFAULT_COMPARISON_CONFIG.relationStyles.low),(null===(v=null==E?void 0:E.relationStyles)||void 0===v?void 0:v.low)||{})}}},[E]),Je=t.useMemo(function(){if(B&&Object.keys(B).length>0)try{var n=function(n,t,i){var r,o,l,s;void 0===t&&(t=!1),void 0===i&&(i=null);var c=n.nodes||n,u=[],d=[],f=n.base_root_id,v=n.input_index_map||{0:"left",1:"right"},h=n[f]||c[f];if(!h||!1===h.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[]};var p=function(t,r){var o,l=n[t]||c[t];if(!l||!1===l.display_node)return null;var s=a.getSideData(l,r,v),u=!!s.title.trim(),d=!!s.content.trim(),f=a.getRationale(l),h=(null===(o=null==i?void 0:i[t])||void 0===o?void 0:o.evaluation_result)||l.evaluation_result||null,g=[];l.next&&Object.values(l.next).forEach(function(e){var n=c[e];if(n&&!1!==n.display_node){var t=p(e,r);t&&g.push(t)}});var x=!(!u&&!d);return e.__assign(e.__assign({id:t,title:u?s.title:"",content:d?s.content:"",subsections:g},x?f:{score:void 0,relation:"not_defined"}),{evaluationResult:h})};if(t){var g=function(t,r){var o,l,s,u,d,f,h,p,x,m,y,_,b;void 0===r&&(r=0);var S=[],R=[];if(!t)return{refSections:S,baseSections:R};var I={},C={},F=-1,w=-1;for(var j in t){var B=t[j],E=n[B]||c[B];if(E&&!1!==E.display_node){var T=a.getRationale(E),D=(null===(o=null==i?void 0:i[B])||void 0===o?void 0:o.evaluation_result)||E.evaluation_result||null,k=a.getSideData(E,"1",v),A=a.getSideData(E,"0",v),M=k.title.trim()||k.content.trim(),O=A.title.trim()||A.content.trim(),N=Number(null!==(s=null===(l=k.attributes)||void 0===l?void 0:l.display_index)&&void 0!==s?s:F--),H=Number(null!==(d=null===(u=A.attributes)||void 0===u?void 0:u.display_index)&&void 0!==d?d:w--),L=I[N]||e.__assign(e.__assign({id:B,title:M?k.title:"",content:M?k.content:"",subsections:[]},M?T:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:N,evaluationResult:D,displayContent:null===(f=k.attributes)||void 0===f?void 0:f.display_content,displayTitle:null===(h=k.attributes)||void 0===h?void 0:h.display_title}),W=C[H]||e.__assign(e.__assign({id:B,title:O?A.title:"",content:O?A.content:"",subsections:[]},O?T:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:H,evaluationResult:D,displayContent:null===(p=A.attributes)||void 0===p?void 0:p.display_content,displayTitle:null===(x=A.attributes)||void 0===x?void 0:x.display_title});Number(N)>=0&&Number(H)>=0&&((null===(m=L.refIndexes)||void 0===m?void 0:m.includes(Number(H)))||null===(y=L.refIndexes)||void 0===y||y.push(Number(H)),(null===(_=W.refIndexes)||void 0===_?void 0:_.includes(Number(N)))||null===(b=W.refIndexes)||void 0===b||b.push(Number(N))),I[N]=L,C[H]=W;var z=g(E.next,r+1),P=z.refSections,q=z.baseSections;P.length>0&&(L.subsections=e.__spreadArray(e.__spreadArray([],L.subsections||[],!0),P,!0)),q.length>0&&(W.subsections=e.__spreadArray(e.__spreadArray([],W.subsections||[],!0),q,!0))}}return S=Object.values(I).map(function(e){return e}),R=Object.values(C).map(function(e){return e}),S.sort(function(e,n){return e.selfIndex<0&&n.selfIndex>=0?1:e.selfIndex>=0&&n.selfIndex<0?-1:e.selfIndex-n.selfIndex}),R.sort(function(e,n){return e.selfIndex<0&&n.selfIndex>=0?1:e.selfIndex>=0&&n.selfIndex<0?-1:e.selfIndex-n.selfIndex}),{refSections:S,baseSections:R}},x=g(h.next),m=x.refSections,y=x.baseSections;d=m,u=y}else h.next&&Object.values(h.next).forEach(function(e){var t=n[e]||c[e];t&&!1!==t.display_node&&(u.push(p(e,"0")||{id:e,title:"",content:"",subsections:[]}),d.push(p(e,"1")||{id:e,title:"",content:"",subsections:[]}))});return{activeProposed:{title:(null===(o=null===(r=h.comparison_inputs)||void 0===r?void 0:r[v[0]])||void 0===o?void 0:o.title)||"Uploaded Contract",description:h.decision_scope_description||"",sections:u},activeVariants:[{id:"tree-variant-1",title:(null===(s=null===(l=h.comparison_inputs)||void 0===l?void 0:l[v[1]])||void 0===s?void 0:s.title)||"Reference Template",similarity:0,sections:d,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:h.decision_scope_description||""},fields:{}}}}]}}(B,W,H);return e.__assign(e.__assign({},n),{parseError:null})}catch(e){return console.error("Data Transformation Error: ",e),{activeProposed:{},activeVariants:[],parseError:e instanceof Error?e.message:"Unknown Parsing Error"}}return{activeProposed:{},activeVariants:[],parseError:"Tree data is required"}},[JSON.stringify(B),W,JSON.stringify(H)]),Qe=Je.activeProposed,Ze=Je.activeVariants,$e=Je.parseError;t.useEffect(function(){$e&&J("Failed to load comparison: ".concat($e))},[$e]);var en=t.useState(null),nn=en[0];en[1];var tn=t.useState({}),rn=tn[0],on=tn[1],ln=t.useState({}),sn=ln[0],an=ln[1],cn=(null==Ze?void 0:Ze[0])||_,un=null===(g=null===(v=null==B?void 0:B.documents)||void 0===v?void 0:v[null===(h=null==B?void 0:B.input_index_map)||void 0===h?void 0:h[0]])||void 0===g?void 0:g.title,dn=null===(I=null===(x=null==B?void 0:B.documents)||void 0===x?void 0:x[null===(R=null==B?void 0:B.input_index_map)||void 0===R?void 0:R[1]])||void 0===I?void 0:I.title,fn=a.safeStringify(T||un||"Uploaded Contract"),vn=a.safeStringify(D||dn||"Reference Template"),hn=t.useMemo(function(){return(null==Qe?void 0:Qe.sections)||[]},[null==Qe?void 0:Qe.sections]),pn=t.useMemo(function(){return cn.sections||[]},[cn.sections]),gn=hn.length>0||pn.length>0,xn=cn.analysis,mn=a.safeStringify(null===(F=null===(C=null==xn?void 0:xn.rule_difference_comparison)||void 0===C?void 0:C.summary)||void 0===F?void 0:F.overall_summary),yn=!!mn.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),_n=t.useRef({}),bn=function(e){return _n.current[e]||(_n.current[e]=p.default.createRef()),_n.current[e]},Sn=t.useCallback(function(){$(!1),ye.current=!1,Hn(null),_e.current=null,Bn.current=null,te(!1),U(!1),Le.current&&(Le.current.style.height="0px"),We.current&&(We.current.style.height="0px"),ze.current&&(ze.current.style.height="0px"),Pe.current&&(Pe.current.style.height="0px")},[]),Rn=t.useCallback(function(e,n,t,i,r,o){var l,s,c=a.safeStringify(n.id)||a.safeStringify(t.id)||"",u=(c?be[c]:null)||n.cognitiveData||t.cognitiveData||{section_id:c,decisioning:[],gap:[],relevance_score:0},d=null!==(s=null===(l=_n.current[i])||void 0===l?void 0:l.current)&&void 0!==s?s:null;return{open:!0,sectionTitle:n.title||"N/A",refSectionTitle:t.title||"NA",cognitiveData:u,anchorEl:e,sectionAnchorEl:d,badgeStyle:o||null,sectionIdx:i,docData:{documents:null==B?void 0:B.documents,input_index_map:null==B?void 0:B.input_index_map},deviationData:n.evaluationResult||t.evaluationResult||null,isOrphan:!!r}},[be,B]),In=t.useCallback(function(e){Ue(),Ie(null),De(e)},[Ue]),Cn=function(e,n,t,i,r,o){e.stopPropagation(),Ae.open&&Ae.sectionIdx===r?Ue():(Ke(),Me(Rn(e.currentTarget,n,i,r,t,o)))},Fn=t.useCallback(function(){null!==Ae.sectionIdx&&Ae.anchorEl?In(e.__assign(e.__assign({},Ae),{open:!0})):Ue()},[Ae,Ue,In]);t.useCallback(function(e){Ue(),J("".concat(e," is coming soon."))},[Ue]);var wn=t.useCallback(function(){var e=Ae.sectionIdx,n=Ae.isOrphan;if(Ue(),null!==e){if(n)return J("No counterpart exists to connect to."),void Ue();ye.current&&Sn(),ce(function(n){return n.has(e)?new Set:new Set([e])})}},[Ae.sectionIdx,Ue,Sn]),jn=t.useRef(null),Bn=t.useRef(null),En=t.useRef(null),Tn=t.useRef(null),Dn=t.useRef(null),kn=t.useState([]),An=kn[0],Mn=kn[1],On=t.useState(null),Nn=On[0],Hn=On[1];t.useRef(null);var Ln=t.useState(null),Wn=Ln[0],zn=Ln[1],Pn=t.useMemo(function(){return Ge.fields.filter(function(e){var n=e.key;return(!gn||"description"!==n)&&(a.hasValue(null==Qe?void 0:Qe[n])||a.hasValue(cn[n]))})},[Qe,cn,gn,Ge.fields]),qn=t.useRef({}),Vn=t.useRef({}),Yn=t.useRef({}),Kn=t.useRef({}),Un=t.useRef({}),Xn=t.useRef({}),Gn=t.useRef({}),Jn=t.useRef({}),Qn=t.useRef({});Pn.forEach(function(e){for(var n=e.key,t=0;t<Math.max(hn.length,pn.length);t+=1)Yn.current[t]||(Yn.current[t]=p.default.createRef()),Kn.current[t]||(Kn.current[t]=p.default.createRef()),Un.current[t]||(Un.current[t]=p.default.createRef()),Xn.current[t]||(Xn.current[t]=p.default.createRef()),Gn.current[t]||(Gn.current[t]=p.default.createRef());qn.current[n]||(qn.current[n]=p.default.createRef()),Vn.current[n]||(Vn.current[n]=p.default.createRef())});for(var Zn=0;Zn<Math.max(hn.length,pn.length);Zn+=1)Yn.current[Zn]||(Yn.current[Zn]=p.default.createRef()),Kn.current[Zn]||(Kn.current[Zn]=p.default.createRef()),Un.current[Zn]||(Un.current[Zn]=p.default.createRef()),Xn.current[Zn]||(Xn.current[Zn]=p.default.createRef()),Gn.current[Zn]||(Gn.current[Zn]=p.default.createRef());t.useEffect(function(){if(nn){var e=Ge.fields.find(function(e){return e.analysisKey===nn||e.key===nn});if(e){var n=qn.current[e.key]||Vn.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[nn,Ge.fields]);var $n=t.useCallback(function(e){var n,t,i,r,o,l,s,a,c,u=null===(n=null==xn?void 0:xn.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!u||!u[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var d=u[e],f=(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===(o=null===(r=null==d?void 0:d.highlights)||void 0===r?void 0:r.ruleB_spans)||void 0===o?void 0:o.length)||(null==d?void 0:d.mappings)&&d.mappings.length>0;if(d.mappings){var v=d.mappings[0]||{};return{score:d.score,relation:v.relation||"",highlightsA:(null===(l=v.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(s=v.highlights)||void 0===s?void 0:s.ruleB_spans)||[],hasContent:!!f}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(a=d.highlights)||void 0===a?void 0:a.ruleA_spans)||[],highlightsB:(null===(c=d.highlights)||void 0===c?void 0:c.ruleB_spans)||[],hasContent:!!f}},[xn]),et=t.useCallback(function(n){var t,i,r,o,l=hn[n],s=pn[n],c=(null==l?void 0:l.relation)&&"not_defined"!==l.relation,u=(null==s?void 0:s.relation)&&"not_defined"!==s.relation,d=a.safeStringify(null==l?void 0:l.id)||a.safeStringify(null==s?void 0:s.id)||"",f=!(!(null==l?void 0:l.cognitiveData)&&!(null==s?void 0:s.cognitiveData));if(!c&&!u&&!f)return e.__assign(e.__assign({},Ge.relationStyles.noContent),{label:"Not Defined"});var v=$n("description");if(null!=(null!==(i=null!==(t=null==l?void 0:l.cognitiveRelevanceScore)&&void 0!==t?t:null==s?void 0:s.cognitiveRelevanceScore)&&void 0!==i?i:d?null===(r=be[d])||void 0===r?void 0:r.relevance_score:void 0)){var h=a.cognitiveScoreToRelation(),p=h.score,g=h.relation;return a.getStyleForRelation(p,g,!0,Ge)}var x=c?l.relation:u?s.relation:v.relation,m=null!==(o=null==l?void 0:l.score)&&void 0!==o?o:null==s?void 0:s.score,y="number"==typeof m?m:v.score;return a.getStyleForRelation(y,x,!0,Ge)},[hn,pn,be,Ge,$n]),nt=t.useCallback(function(n){for(var t,i,r,o,l=n.split("-").map(Number),s=hn[l[0]],c=pn[l[0]],u=1;u<l.length;u++)(null==s?void 0:s.subsections)&&(s=s.subsections[l[u]]),(null==c?void 0:c.subsections)&&(c=c.subsections[l[u]]);if(!s&&!c)return null;var d=(null==s?void 0:s.relation)&&"not_defined"!==s.relation,f=(null==c?void 0:c.relation)&&"not_defined"!==c.relation,v=a.safeStringify(null==s?void 0:s.id)||a.safeStringify(null==c?void 0:c.id)||"",h=!(!(null==s?void 0:s.cognitiveData)&&!(null==c?void 0:c.cognitiveData));if(!d&&!f&&!h)return e.__assign(e.__assign({},Ge.relationStyles.noContent),{label:"Not Defined"});if(null!=(null!==(i=null!==(t=null==s?void 0:s.cognitiveRelevanceScore)&&void 0!==t?t:null==c?void 0:c.cognitiveRelevanceScore)&&void 0!==i?i:v?null===(r=be[v])||void 0===r?void 0:r.relevance_score:void 0)){var p=a.cognitiveScoreToRelation(),g=p.score,x=p.relation;return a.getStyleForRelation(g,x,!0,Ge)}var m=d?s.relation:f?c.relation:"not_defined",y=null!==(o=null==s?void 0:s.score)&&void 0!==o?o:null==c?void 0:c.score,_="number"==typeof y?y:0;return a.getStyleForRelation(_,m,!0,Ge)},[hn,pn,be,Ge]),tt=t.useCallback(function(){var e,n,t,i,r,o,l,s,c,u,d,f,v,h,p,g,x,m,_,b,S,R;if(!Ve.current&&!he.current){Ve.current=!0;try{if(!jn.current)return;var I=function(e){var n=e.split("-"),t=n[0];if(!rn[t]&&!1===W)return!1;if(W&&!rn["left-".concat(t)]&&!rn["right-".concat(t)]&&!rn[t])return!1;for(var i=t,r=1;r<n.length-1;r++)if(i+="-".concat(n[r]),!sn[i])return!1;return!0},C=jn.current.getBoundingClientRect();je({width:C.width,height:C.height});var F=[];if(Pn.forEach(function(e){var n,t,i=e.key,r=null===(n=qn.current[i])||void 0===n?void 0:n.current,o=null===(t=Vn.current[i])||void 0===t?void 0:t.current;r&&o&&(r.style.height="auto",o.style.height="auto",r.style.minHeight="0px",o.style.minHeight="0px")}),!he.current){for(var w=0;w<Math.max(hn.length,pn.length);w++){var j=null===(e=Yn.current[w])||void 0===e?void 0:e.current,B=null===(n=Kn.current[w])||void 0===n?void 0:n.current;j&&(j.style.height="auto",j.style.minHeight="0px"),B&&(B.style.height="auto",B.style.minHeight="0px")}W||Object.keys(Jn.current).forEach(function(e){var n,t;if(I(e)){var i=null===(n=Jn.current[e])||void 0===n?void 0:n.current,r=null===(t=Qn.current[e])||void 0===t?void 0:t.current;i&&r&&(i.style.height="auto",r.style.height="auto",i.style.minHeight="0px",r.style.minHeight="0px")}})}var E={};Pn.forEach(function(e){var n,t,i=e.key,r=null===(n=qn.current[i])||void 0===n?void 0:n.current,o=null===(t=Vn.current[i])||void 0===t?void 0:t.current;if(r&&o){var l=r.getBoundingClientRect(),s=o.getBoundingClientRect();E[i]=Math.max(l.height,s.height)}});var T={left:{},right:{}},D={};if(!he.current)if(W){if(Z&&null!==Nn)if("number"==typeof Nn){var k=Nn,A=hn[k],M=null===(r=Yn.current[k])||void 0===r?void 0:r.current;M&&A&&(A.refIndexes||[]).forEach(function(e){var n,t=pn.findIndex(function(n){return n.selfIndex===e}),i=null===(n=Kn.current[t])||void 0===n?void 0:n.current;if(i&&(rn["left-".concat(k)]||rn["right-".concat(t)])){var r=Math.max(M.getBoundingClientRect().height,i.getBoundingClientRect().height);T.left[k]=Math.max(T.left[k]||0,r),T.right[t]=Math.max(T.right[t]||0,r)}})}else{var O=Nn;j=null===(o=Jn.current[O])||void 0===o?void 0:o.current,B=null===(l=Qn.current[O])||void 0===l?void 0:l.current;if(j&&B){H=Math.max(j.getBoundingClientRect().height,B.getBoundingClientRect().height);D[O]=Math.max(D[O]||0,H)}}}else{for(w=0;w<Math.min(hn.length,pn.length);w++){var j=null===(t=Yn.current[w])||void 0===t?void 0:t.current,B=null===(i=Kn.current[w])||void 0===i?void 0:i.current,N=!!rn[String(w)];if(j&&B&&N){var H=Math.max(j.getBoundingClientRect().height,B.getBoundingClientRect().height);T.left[w]=H,T.right[w]=H}}Object.keys(Jn.current).forEach(function(e){var n,t;if(I(e)){var i=null===(n=Jn.current[e])||void 0===n?void 0:n.current,r=null===(t=Qn.current[e])||void 0===t?void 0:t.current;if(i&&r&&null!==i.offsetParent&&null!==r.offsetParent){var o=i.getBoundingClientRect(),l=r.getBoundingClientRect();D[e]=Math.max(o.height,l.height)}}})}if(Pn.forEach(function(e){var n,t,i=e.key,r=null===(n=qn.current[i])||void 0===n?void 0:n.current,o=null===(t=Vn.current[i])||void 0===t?void 0:t.current;if(r&&o){var l=E[i];r.style.minHeight="".concat(l,"px"),o.style.minHeight="".concat(l,"px")}}),he.current||(Object.entries(T.left).forEach(function(e){var n,t=e[0],i=e[1],r=null===(n=Yn.current[Number(t)])||void 0===n?void 0:n.current;r&&(r.style.minHeight="".concat(i,"px"))}),Object.entries(T.right).forEach(function(e){var n,t=e[0],i=e[1],r=null===(n=Kn.current[Number(t)])||void 0===n?void 0:n.current;r&&(r.style.minHeight="".concat(i,"px"))}),W||Object.keys(D).forEach(function(e){var n,t,i=null===(n=Jn.current[e])||void 0===n?void 0:n.current,r=null===(t=Qn.current[e])||void 0===t?void 0:t.current;if(i&&r&&D[e]){var o=D[e];i.style.minHeight="".concat(o,"px"),r.style.minHeight="".concat(o,"px")}})),Pn.forEach(function(e){var n,t,i=e.key,r=e.analysisKey,o=null===(n=qn.current[i])||void 0===n?void 0:n.current,l=null===(t=Vn.current[i])||void 0===t?void 0:t.current;if(o&&l){var s=o.getBoundingClientRect(),c=l.getBoundingClientRect(),u=$n(r),d=a.getStyleForRelation(u.score,u.relation,u.hasContent,Ge);if(!d)return;var f=s.top+s.height/2-C.top;F.push({id:"field-".concat(i),x1:s.right-C.left,y1:f,x2:c.left-C.left,y2:f,style:d})}}),W){if(hn.forEach(function(e,n){var t;(null===(t=Yn.current[n])||void 0===t?void 0:t.current)&&(e.refIndexes||[]).forEach(function(e){var t,i,r,o,l,s,a,c,u,d,f=pn.findIndex(function(n){return n.selfIndex===e});if(-1!==f){var v=null===(t=Un.current[n])||void 0===t?void 0:t.current,h=null===(i=Xn.current[f])||void 0===i?void 0:i.current;if(v&&h){var p=v.getBoundingClientRect(),g=h.getBoundingClientRect(),x=p.right-C.left,m=g.left-C.left,y=p.top+p.height/2-C.top,_=g.top+g.height/2-C.top;if(Z&&Nn===n){var b=null!==(o=null===(r=qe.current)||void 0===r?void 0:r.getBoundingClientRect().top)&&void 0!==o?o:0,S=null!==(s=null===(l=He.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==s?s:0,R=b+(null!==(c=null===(a=qe.current)||void 0===a?void 0:a.clientHeight)&&void 0!==c?c:1/0),I=S+(null!==(d=null===(u=He.current)||void 0===u?void 0:u.clientHeight)&&void 0!==d?d:1/0),w=p.top+p.height/2,j=function(e,n,t){return Math.max(n,Math.min(t,e))};y=j(w,b,R)-C.top,_=j(w,S,I)-C.top}var B=et(n);B&&F.push({id:"line-".concat(n,"-").concat(f),x1:x,y1:y,x2:m,y2:_,style:B,sectionIdx:n,targetRightIdx:f})}}})}),Z&&"string"==typeof Nn){O=Nn;var L=null===(v=Un.current[O])||void 0===v?void 0:v.current,z=null===(h=Xn.current[O])||void 0===h?void 0:h.current;if(L&&z){var P=L.getBoundingClientRect(),q=z.getBoundingClientRect(),V=P.right-C.left,Y=q.left-C.left,K=null!==(g=null===(p=qe.current)||void 0===p?void 0:p.getBoundingClientRect().top)&&void 0!==g?g:0,U=null!==(m=null===(x=He.current)||void 0===x?void 0:x.getBoundingClientRect().top)&&void 0!==m?m:0,X=K+(null!==(b=null===(_=qe.current)||void 0===_?void 0:_.clientHeight)&&void 0!==b?b:1/0),G=U+(null!==(R=null===(S=He.current)||void 0===S?void 0:S.clientHeight)&&void 0!==R?R:1/0),J=P.top+P.height/2,Q=q.top+q.height/2,$=function(e,n,t){return Math.max(n,Math.min(t,e))},ee=$(J,K,X)-C.top,ne=$(Q,U,G)-C.top;(re=nt(O))&&F.push({id:"line-subsec-".concat(O),x1:V,y1:ee,x2:Y,y2:ne,style:re,sectionIdx:Number(O.split("-")[0]),isSubSection:!0,subSectionKeyPath:O})}}}else{for(w=0;w<Math.min(hn.length,pn.length);w++){var te=null===(s=Yn.current[w])||void 0===s?void 0:s.current,ie=null===(c=Kn.current[w])||void 0===c?void 0:c.current;if(te&&ie){var re,oe=te.getBoundingClientRect(),le=ie.getBoundingClientRect(),se=(oe.top+18-C.top+le.top+18-C.top)/2,ce=(null===(u=pn[w])||void 0===u?void 0:u.id)||"sec-".concat(w);(re=et(w))&&F.push({id:ce,x1:oe.right-C.left,y1:se,x2:le.left-C.left,y2:se,style:re,sectionIdx:w,hasCognitive:!!((null===(d=hn[w])||void 0===d?void 0:d.cognitiveData)||(null===(f=pn[w])||void 0===f?void 0:f.cognitiveData)||ce&&be[ce])})}}Object.keys(Jn.current).forEach(function(e){var n,t,i,r,o,l,s;if(I(e)){for(var c=null===(n=Jn.current[e])||void 0===n?void 0:n.current,u=e.split("-").map(Number),d=hn[u[0]],f=1;f<u.length;f++)(null==d?void 0:d.subsections)&&(d=d.subsections[u[f]]);if(d&&(null===(t=d.refIndexes)||void 0===t?void 0:t.length)){var v=null===(i=Qn.current[e])||void 0===i?void 0:i.current;if(c&&v&&null!==c.offsetParent&&null!==v.offsetParent){var h=c.getBoundingClientRect(),p=v.getBoundingClientRect(),g=(h.top+16-C.top+p.top+16-C.top)/2,x=e.split("-").map(Number),m=hn[x[0]],y=pn[x[0]];for(f=1;f<x.length;f++)(null==m?void 0:m.subsections)&&(m=m.subsections[x[f]]),(null==y?void 0:y.subsections)&&(y=y.subsections[x[f]]);if(!m&&!y)return;var _=(null==m?void 0:m.relation)&&"not_defined"!==m.relation,b=(null==y?void 0:y.relation)&&"not_defined"!==y.relation,S=a.safeStringify(null==m?void 0:m.id)||a.safeStringify(null==y?void 0:y.id)||"",R=!(!(null==m?void 0:m.cognitiveData)&&!(null==y?void 0:y.cognitiveData)),w=null;if(_||b||R){var j=null!==(o=null!==(r=null==m?void 0:m.cognitiveRelevanceScore)&&void 0!==r?r:null==y?void 0:y.cognitiveRelevanceScore)&&void 0!==o?o:S?null===(l=be[S])||void 0===l?void 0:l.relevance_score:void 0;if(null!=j){var B=a.cognitiveScoreToRelation(j),E=B.score,T=B.relation;w=a.getStyleForRelation(E,T,!0,Ge)}else{T=_?m.relation:b?y.relation:"not_defined";var D=null!==(s=null==m?void 0:m.score)&&void 0!==s?s:null==y?void 0:y.score;E="number"==typeof D?D:0;w=a.getStyleForRelation(E,T,!0,Ge)}}else w={badgeBg:"#EEF2FF",badgeText:"#3730A3",badgeBorder:"#C7D2FE",label:"N/A"};w&&F.push({id:"subsec-".concat(e),x1:h.right-C.left,y1:g,x2:p.left-C.left,y2:g,style:w,sectionIdx:x[0],isSubSection:!0,subSectionKeyPath:e,hasCognitive:R||S&&be[S]})}}}})}if(Mn(F),Tn.current&&Dn.current){var ue=Tn.current.getBoundingClientRect(),de=Dn.current.getBoundingClientRect(),ve=(ue.top+ue.height/2-C.top+de.top+de.height/2-C.top)/2;zn({x1:ue.right-C.left,x2:de.left-C.left,y:ve})}else zn(null);if(W&&ae.size>0){var pe=[],ge=qe.current,me=He.current;if(ge&&me){var ye=[],_e=ge.getBoundingClientRect().top,Se=me.getBoundingClientRect().top,Re=_e+ge.clientHeight,Ie=Se+me.clientHeight,Ce=ge.scrollTop,Fe=me.scrollTop,we=C.top,Be=function(e,n,t){return Math.max(n,Math.min(t,e))};ae.forEach(function(e){var n,t,i;if("string"==typeof e){var r=e,o=null===(n=Un.current[r])||void 0===n?void 0:n.current,l=null===(t=Xn.current[r])||void 0===t?void 0:t.current;if(!o||!l)return;var s=o.getBoundingClientRect(),a=l.getBoundingClientRect(),c=nt(r),u=s.right-C.left,d=a.left-C.left-0,f=u+.75*(d-u),v=s.top+s.height/2,h=a.top+a.height/2,p=v-_e+Ce,g=h-Se+Fe,x="conn-subsec-".concat(r);ye.push({lhsScrollY:p,rhsScrollY:g,x1:u,x2:d,containerTop:we,leftIdx:r,rhsArrayIdx:r,styleColor:(null==c?void 0:c.badgeBorder)||"#6366F1",styleId:x});var m=Be(v,_e,Re),_=Be(h,Se,Ie),b=m-we,S=_-we,R=v>=_e-4&&v<=Re+4,I=h>=Se-4&&h<=Ie+4,F="";F=R&&I?y(u,b,d,S):R&&!I?"M ".concat(u,",").concat(b," L ").concat(f,",").concat(b," L ").concat(f,",").concat(S):!R&&I?"M ".concat(f,",").concat(b," L ").concat(f,",").concat(S," L ").concat(d,",").concat(S):"M ".concat(f,",").concat(b," L ").concat(f,",").concat(S),pe.push({id:x,pathD:F,style:c,leftIdx:r,rhsArrayIdx:r})}else{var w=hn[e];if(!(null===(i=null==w?void 0:w.refIndexes)||void 0===i?void 0:i.length))return;w.refIndexes.forEach(function(n){var t,i,r=pn.findIndex(function(e){return e.selfIndex===n});if(-1!==r){var o=null===(t=Un.current[e])||void 0===t?void 0:t.current,l=null===(i=Xn.current[r])||void 0===i?void 0:i.current;if(o&&l){var s=o.getBoundingClientRect(),a=l.getBoundingClientRect(),c=et(e),u=s.right-C.left,d=a.left-C.left-0,f=u+.75*(d-u),v=s.top+s.height/2,h=a.top+a.height/2,p=v-_e+Ce,g=h-Se+Fe,x="conn-".concat(e,"-").concat(r);ye.push({lhsScrollY:p,rhsScrollY:g,x1:u,x2:d,containerTop:we,leftIdx:e,rhsArrayIdx:r,styleColor:(null==c?void 0:c.badgeBorder)||"#6366F1",styleId:x});var m=Be(v,_e,Re),_=Be(h,Se,Ie),b=m-we,S=_-we,R=v>=_e-4&&v<=Re+4,I=h>=Se-4&&h<=Ie+4,F="";F=R&&I?y(u,b,d,S):R&&!I?"M ".concat(u,",").concat(b," L ").concat(f,",").concat(b," L ").concat(f,",").concat(S):!R&&I?"M ".concat(f,",").concat(b," L ").concat(f,",").concat(S," L ").concat(d,",").concat(S):"M ".concat(f,",").concat(b," L ").concat(f,",").concat(S),pe.push({id:x,pathD:F,style:c,leftIdx:e,rhsArrayIdx:r})}}})}}),xe.current=ye}fe(pe)}else fe([]),xe.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{Ve.current=!1}}},[Pn,hn,pn,be,Ge,$n,et,W,Z,Nn,ae,rn,sn]),it=t.useCallback(function(){var e,n,t,i,r,o,l,s,a,c,u,d,f,v,h=xe.current;if(h.length&&!he.current){var p=null!==(n=null===(e=qe.current)||void 0===e?void 0:e.scrollTop)&&void 0!==n?n:0,g=null!==(i=null===(t=He.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,x=null!==(o=null===(r=qe.current)||void 0===r?void 0:r.clientHeight)&&void 0!==o?o:1/0,m=null!==(s=null===(l=He.current)||void 0===l?void 0:l.clientHeight)&&void 0!==s?s:1/0,_=null!==(c=null===(a=qe.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==c?c:0,b=null!==(d=null===(u=He.current)||void 0===u?void 0:u.getBoundingClientRect().top)&&void 0!==d?d:0,S=_+x,R=b+m,I=null!==(v=null===(f=jn.current)||void 0===f?void 0:f.getBoundingClientRect().top)&&void 0!==v?v:0,C=function(e,n,t){return Math.max(n,Math.min(t,e))};h.forEach(function(e){var n=e.lhsScrollY-p+_,t=e.rhsScrollY-g+b,i=ge.current[e.styleId+"-stroke"],r=ge.current[e.styleId+"-bg"];if(i||r){var o,l=C(n,_,S),s=C(t,b,R),a=l-I,c=s-I,u=n>=_-4&&n<=S+4,d=t>=b-4&&t<=R+4,f=e.x1+.65*(e.x2-e.x1);o=u&&d?y(e.x1,a,e.x2,c):u&&!d?"M ".concat(e.x1,",").concat(a," L ").concat(f,",").concat(a," L ").concat(f,",").concat(c):!u&&d?"M ".concat(f,",").concat(a," L ").concat(f,",").concat(c," L ").concat(e.x2,",").concat(c):"M ".concat(f,",").concat(a," L ").concat(f,",").concat(c),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",o)),r&&(r.setAttribute("visibility","visible"),r.setAttribute("d",o))}})}},[]),rt=t.useRef(tt);t.useEffect(function(){rt.current=tt},[tt]);var ot=t.useRef(null),lt=t.useCallback(function(){null!==ot.current&&clearTimeout(ot.current),ot.current=setTimeout(function(){rt.current(),ot.current=null},50)},[]),st=t.useCallback(function(e){var n,t,i,r,o,l,s,a;if(!ie.current){if(ye.current){var c=_e.current,u=Bn.current,d=qe.current,f=He.current;if(null!==c&&null!==u&&d&&f){var v="string"==typeof c?null===(n=Jn.current[c])||void 0===n?void 0:n.current:null===(t=_n.current[c])||void 0===t?void 0:t.current,h="string"==typeof u?null===(i=Qn.current[u])||void 0===i?void 0:i.current:null===(r=Gn.current[u])||void 0===r?void 0:r.current;if(v&&h){var p=v.getBoundingClientRect().top-d.getBoundingClientRect().top+d.scrollTop,g=h.getBoundingClientRect().top-f.getBoundingClientRect().top+f.scrollTop;if(e.currentTarget===d){var x=g-(p-d.scrollTop),m=f.scrollHeight-f.clientHeight,y=Math.max(0,Math.min(x,m));Math.abs(f.scrollTop-y)>1&&(f.scrollTop=y)}else if(e.currentTarget===f){var _=p-(g-f.scrollTop),b=d.scrollHeight-d.clientHeight,S=Math.max(0,Math.min(_,b));Math.abs(d.scrollTop-S)>1&&(d.scrollTop=S)}if(En.current){var R=null===(o=Un.current[c])||void 0===o?void 0:o.current,I=null===(l=Xn.current[u])||void 0===l?void 0:l.current,C=null!==(a=null===(s=jn.current)||void 0===s?void 0:s.getBoundingClientRect().top)&&void 0!==a?a:0,F=d.getBoundingClientRect().top,w=F+d.clientHeight,j=f.getBoundingClientRect().top,B=j+f.clientHeight,E=function(e,n,t){return Math.max(n,Math.min(t,e))};if(R&&I){var T=R.getBoundingClientRect(),D=I.getBoundingClientRect(),k=T.top+T.height/2,A=D.top+D.height/2,M=E(k,F,w),O=E(A,j,B);En.current.setAttribute("y1",(M-C).toString()),En.current.setAttribute("y2",(O-C).toString());var N=k>=F-4&&k<=w+4;En.current.setAttribute("visibility",N?"visible":"hidden")}}}}}xe.current.length>0&&!me.current&&(me.current=!0,requestAnimationFrame(function(){it(),me.current=!1}))}},[it]);t.useEffect(function(){var e=setTimeout(lt,250);window.addEventListener("resize",lt);var n=null,t=null;return Oe.current&&(n=new ResizeObserver(lt)).observe(Oe.current),jn.current&&(t=new ResizeObserver(lt)).observe(jn.current),function(){clearTimeout(e),window.removeEventListener("resize",lt),null==n||n.disconnect(),null==t||t.disconnect()}},[Qe,cn,xn,Pn,rn,sn,hn,pn,Ge,lt,Z,Nn,ne,ae]),t.useEffect(function(){ye.current=Z},[Z]),t.useEffect(function(){_e.current=Nn},[Nn]);var at=t.useCallback(function(){var e=Ae.sectionIdx,n=Ae.isOrphan;if(null!=e)return n?(J("No counterpart exists for this section."),void Ue()):void(Z&&Nn===e?Sn():(ce(new Set),fe([]),xe.current=[],U(!0),ie.current=!0,Hn(e),_e.current=e,$(!0),ye.current=!0,te(!1),Le.current&&(Le.current.style.height="0px"),We.current&&(We.current.style.height="0px"),ze.current&&(ze.current.style.height="0px"),Pe.current&&(Pe.current.style.height="0px"),requestAnimationFrame(function(){var n,t,i,r,o=null,l=null,s=null;if("string"==typeof e)o=(null===(n=Jn.current[e])||void 0===n?void 0:n.current)||null,s=(l=(null===(t=Qn.current[e])||void 0===t?void 0:t.current)||null)?e:null;else{o=(null===(i=_n.current[e])||void 0===i?void 0:i.current)||null;var a=hn[e],c=(null==a?void 0:a.refIndexes)||[];if(c.length>0){var u=c[0],d=pn.findIndex(function(e){return e.selfIndex===u});-1!==d&&(l=(null===(r=Gn.current[d])||void 0===r?void 0:r.current)||null,s=d)}}Bn.current=s;var f=qe.current,v=He.current;if(!o||!f)return ie.current=!1,void U(!1);if(!l||!v)return te(!0),rt.current(),ie.current=!1,void U(!1);var h=o.getBoundingClientRect().top-f.getBoundingClientRect().top+f.scrollTop,p=l.getBoundingClientRect().top-v.getBoundingClientRect().top+v.scrollTop-(h-f.scrollTop);p<0&&Le.current&&(Le.current.style.height="".concat(Math.abs(p),"px"));requestAnimationFrame(function(){var e,n=v.scrollHeight-v.clientHeight;if(p<0)e=0;else{if(p>n){var t=p-n;return We.current&&(We.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){S(v,p,200,function(){te(!0),rt.current(),ie.current=!1,U(!1)})})}e=p}S(v,e,200,function(){te(!0),rt.current(),ie.current=!1,U(!1)})})})));Ue()},[Ue,Ae.sectionIdx,Z,Nn,hn,pn,lt,Sn]),ct=null!==Ae.sectionIdx&&ae.has(Ae.sectionIdx),ut=function(t){var o,l,s,c=t.section,u=t.idx,d=t.columnKey,f=t.colRef,v=t.mb,h=void 0===v?1:v,g=t.parentNodeId,x=void 0===g?"":g,y=W?!!rn["".concat(d,"-").concat(u)]:!!rn[String(u)],_=(null===(o=c.displayTitle)||void 0===o||o)&&a.hasValue(c.title),b=(null===(l=c.displayContent)||void 0===l||l)&&a.hasValue(c.content),S=!_&&!b,R=c.title;_||(R=b?"No Title Found":"No Matching Section Found");var I,C=[];if(null===(s=c.evaluationResult)||void 0===s?void 0:s.deviations){var F=c.evaluationResult.deviations;for(var w in F){var j=F[w][x];j&&C.push(j)}}return n.jsx(i.Box,e.__assign({ref:f,sx:{mb:h,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:n.jsxs(i.Accordion,e.__assign({disableGutters:!0,expanded:!S&&y,onChange:function(){return!S&&function(n,t){var i,r;he.current=!0,pe.current&&clearTimeout(pe.current),ve.current&&(ve.current.style.opacity="0");var o=null===(i=Yn.current[n])||void 0===i?void 0:i.current,l=null===(r=Kn.current[n])||void 0===r?void 0:r.current;if(o&&(o.style.minHeight="0px"),l&&(l.style.minHeight="0px"),Object.keys(Jn.current).forEach(function(e){var t,i;if(e.startsWith("".concat(n,"-"))){var r=null===(t=Jn.current[e])||void 0===t?void 0:t.current,o=null===(i=Qn.current[e])||void 0===i?void 0:i.current;r&&(r.style.minHeight="0px"),o&&(o.style.minHeight="0px")}}),W){var s=hn[n];((null==s?void 0:s.refIndexes)||[]).forEach(function(e){var n,t=pn.findIndex(function(n){return n.selfIndex===e}),i=null===(n=Kn.current[t])||void 0===n?void 0:n.current;i&&(i.style.minHeight="0px")});var a=pn[n],c=null==a?void 0:a.selfIndex;hn.forEach(function(e,n){var t,i;if(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(c)){var r=null===(i=Yn.current[n])||void 0===i?void 0:i.current;r&&(r.style.minHeight="0px")}})}pe.current=setTimeout(function(){he.current=!1,rt.current(),ve.current&&(ve.current.style.opacity="1")},650),on(function(i){var r=e.__assign({},i);if(!W){var o=!!i[String(n)];return r[String(n)]=!o,r}var l="".concat(t,"-").concat(n),s=!i[l];if(r[l]=s,"left"===t)((null==(a=hn[n])?void 0:a.refIndexes)||[]).forEach(function(e){var n=pn.findIndex(function(n){return n.selfIndex===e});-1!==n&&(r["right-".concat(n)]=s)});else{var a,c=null==(a=pn[n])?void 0:a.selfIndex;hn.forEach(function(e,n){var t;(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(c))&&(r["left-".concat(n)]=s)})}return r})}(u,d)},sx:{boxShadow:"none",border:S?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:S?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flexGrow:1,width:"100%",display:"flex",flexDirection:"column",minWidth:0,"&:before":{display:"none"}}},{children:[n.jsx(i.AccordionSummary,e.__assign({expandIcon:S?null:n.jsx(r.ChevronDown,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:S?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:_&&n.jsx(i.Tooltip,e.__assign({title:R,placement:"top"},{children:n.jsx(i.Typography,e.__assign({component:"div",sx:{fontSize:"12px",color:S?"#94A3B8":"#19213D",fontWeight:S?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(I=R,I?a.safeStringify(I).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(e,t){return e.startsWith("**")&&e.endsWith("**")?n.jsx("strong",{children:e.slice(2,-2)},t):n.jsx(p.default.Fragment,{children:e},t)}):null)}))}))})),!S&&n.jsxs(i.AccordionDetails,e.__assign({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[b&&n.jsx(m,{content:c.content,sxStyles:Be,highlights:C}),(c.subsections||[]).map(function(e,n){return dt({section:e,keyPath:"".concat(u,"-").concat(n),depth:0,columnKey:d,parentNodeId:x})})]}))]}))}),"".concat(d,"-sec-").concat(u))},dt=function(t){var o,l,s,c=t.section,u=t.keyPath,d=t.depth,f=void 0===d?0:d,v=t.columnKey,h=void 0===v?"left":v,g=t.parentNodeId,x=void 0===g?"":g,y=(null===(o=c.displayTitle)||void 0===o||o)&&a.hasValue(c.title),_=(null===(l=c.displayContent)||void 0===l||l)&&a.hasValue(c.content),b=!y&&!_,S=y?c.title:_?"No Title Found":"No Matching Section Found",R=!!sn[u];"left"!==h||Jn.current[u]||(Jn.current[u]=p.default.createRef()),"right"!==h||Qn.current[u]||(Qn.current[u]=p.default.createRef());var I="left"===h?Jn.current[u]:Qn.current[u];Un.current[u]||(Un.current[u]=p.default.createRef()),Xn.current[u]||(Xn.current[u]=p.default.createRef());for(var C=u.split("-").map(function(e){return Number(e)+1}).join("."),F=nt(u),w=W&&ae.has(u),j=u.split("-").map(Number),B=hn[j[0]],E=pn[j[0]],T=1;T<j.length;T++)(null==B?void 0:B.subsections)&&(B=B.subsections[j[T]]),(null==E?void 0:E.subsections)&&(E=E.subsections[j[T]]);var D=!(null===(s=c.refIndexes)||void 0===s?void 0:s.length)||void 0!==c.selfIndex&&c.selfIndex<0,k="left"===h&&D,A="right"===h&&D;return y?n.jsxs(i.Box,e.__assign({ref:I,sx:{mt:1,width:"100%",minWidth:0,position:"relative"}},{children:[n.jsx(i.Box,e.__assign({sx:e.__assign({width:"100%"},w&&F&&{borderRadius:"4px",outline:"2px solid ".concat(F.badgeBorder),outlineOffset:"1px"})},{children:n.jsxs(i.Accordion,e.__assign({disableGutters:!0,expanded:!b&&R,onChange:function(){return!b&&an(function(n){var t;return e.__assign(e.__assign({},n),((t={})[u]=!n[u],t))})},sx:{mt:0,boxShadow:"none",border:b?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF",minWidth:0,"&:before":{display:"none"}}},{children:[n.jsx(i.AccordionSummary,e.__assign({expandIcon:b?null:n.jsx(r.ChevronDown,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"}}},{children:n.jsx(i.Typography,e.__assign({component:"div",sx:{fontSize:"11px",fontWeight:600,color:b?"#94A3B8":"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:S||"Untitled Subsection"}))})),!b&&n.jsxs(i.AccordionDetails,e.__assign({sx:{pt:0,pb:1,minWidth:0}},{children:[_&&n.jsx(m,{content:c.content,sxStyles:Be,highlights:function(){var e,n;if(!(null===(e=c.evaluationResult)||void 0===e?void 0:e.deviations))return[];var t=(null===(n=c.evaluationResult)||void 0===n?void 0:n.deviations)||{},i=[];for(var r in t){var o=t[r][x];o&&i.push(o)}return i}()}),(c.subsections||[]).map(function(e,n){return dt({section:e,keyPath:"".concat(u,"-").concat(n),depth:f+1,columnKey:h,parentNodeId:x})})]}))]}))})),W&&"left"===h&&F&&!b&&n.jsxs(i.Box,e.__assign({ref:Un.current[u],onClick:function(e){e.stopPropagation();for(var n=u.split("-").map(Number),t=hn[n[0]],i=pn[n[0]],r=1;r<n.length;r++)(null==t?void 0:t.subsections)&&(t=t.subsections[n[r]]),(null==i?void 0:i.subsections)&&(i=i.subsections[n[r]]);Cn(e,t||{title:"",content:""},k||A,i||{title:"",content:""},u,F)},sx:{position:"absolute",top:"16px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"10px",bgcolor:F.badgeBg,color:F.badgeText,border:"1px solid ".concat(F.badgeBorder),borderRadius:"12px",px:1,py:.3,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"10px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(F.badgeBorder)}},{children:C})),n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"10px",px:.25}},{children:k?"No Deviation Found":0==F.deviationLabel||void 0===F.deviationLabel?"Same":"".concat(F.deviationLabel,"% Deviation")})),n.jsx(r.EllipsisVertical,{size:10,color:F.badgeText})]})),W&&"right"===h&&F&&!b&&!K&&n.jsx(i.Box,e.__assign({ref:Xn.current[u],sx:{position:"absolute",top:"16px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"10px",bgcolor:"#EEF2FF",color:"#3730A3",border:"1px solid #C7D2FE",borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:A?"-":C}))]}),u):n.jsxs(i.Box,e.__assign({ref:I,sx:{mt:0===f?1:.75,width:"100%",minWidth:0,position:"relative"}},{children:[!b&&n.jsxs(i.Box,e.__assign({sx:e.__assign({width:"100%"},w&&F&&{borderRadius:"4px",outline:"2px solid ".concat(F.badgeBorder),outlineOffset:"1px"})},{children:[_&&n.jsx(m,{content:c.content,sxStyles:Be,highlights:function(){var e,n;if(!(null===(e=c.evaluationResult)||void 0===e?void 0:e.deviations))return[];var t=(null===(n=c.evaluationResult)||void 0===n?void 0:n.deviations)||{},i=[];for(var r in t){var o=t[r][x];o&&i.push(o)}return i}()}),(c.subsections||[]).map(function(e,n){return dt({section:e,keyPath:"".concat(u,"-").concat(n),depth:f+1,columnKey:h,parentNodeId:x})})]})),W&&"left"===h&&F&&!b&&n.jsxs(i.Box,e.__assign({ref:Un.current[u],onClick:function(e){var n;e.stopPropagation();var t=function(e,n){for(var i=0,r=e;i<r.length;i++){var o=r[i];if(o.selfIndex===n)return o;if(o.subsections){var l=t(o.subsections,n);if(l)return l}}return null},i=null===(n=c.refIndexes)||void 0===n?void 0:n[0],r="number"==typeof i?t(pn,i):null;Cn(e,c,D,r||{title:"",content:""},u,F)},sx:{position:"absolute",top:"16px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"10px",bgcolor:F.badgeBg,color:F.badgeText,border:"1px solid ".concat(F.badgeBorder),borderRadius:"12px",px:1,py:.3,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"10px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(F.badgeBorder)}},{children:C})),n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"10px",px:.25}},{children:k?"No Deviation Found":0==F.deviationLabel||void 0===F.deviationLabel?"Same":"".concat(F.deviationLabel,"% Deviation")})),n.jsx(r.EllipsisVertical,{size:10,color:F.badgeText})]})),W&&"right"===h&&F&&!b&&!K&&n.jsx(i.Box,e.__assign({ref:Xn.current[u],sx:{position:"absolute",top:"16px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"10px",bgcolor:"#EEF2FF",color:"#3730A3",border:"1px solid #C7D2FE",borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:A?"-":C}))]}),u)};return n.jsxs(i.Box,e.__assign({ref:Ne,sx:e.__assign(e.__assign({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},W?{}:{overflow:"visible"}),{position:"relative"})},{children:[q&&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(f.default,{})})),W&&n.jsx(d.default,{open:Ae.open,anchorEl:Ae.anchorEl,sectionTitle:Ae.sectionTitle,referenceSectionTitle:Ae.refSectionTitle,onClose:Ue,onOpenCognitiveCompare:Fn,onOpenSideBySide:at,onConnect:wn,isConnected:ct}),Te.open&&n.jsx(u.default,{open:Te.open,popupRef:Ce,position:Re,popupConfig:O,onClose:function(){Ie(null),De(function(n){return e.__assign(e.__assign({},n),{open:!1})}),le(null)},markdownStyles:k,sectionTitle:Te.sectionTitle,referenceSectionTitle:Te.refSectionTitle,cognitiveData:Te.cognitiveData,anchorEl:Te.anchorEl,sectionAnchorEl:Te.sectionAnchorEl,scrollContainerEl:Oe.current,badgeStyle:Te.badgeStyle,docData:Te.docData,deviationData:Te.deviationData}),n.jsx(i.Snackbar,e.__assign({open:!!G,autoHideDuration:8e3,onClose:function(){return J(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(i.Alert,e.__assign({onClose:function(){return J(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:G}))})),(M.isHeaderVisible||M.isToggleVisible)&&n.jsxs(i.Box,e.__assign({sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between",bgcolor:"#FFFFFF",border:"1.5px solid #EEF0F4",borderTopLeftRadius:"8px",borderTopRightRadius:"8px"}},{children:[n.jsx(i.Box,e.__assign({sx:{display:"flex",alignItems:"center",gap:1}},{children:M.isHeaderVisible&&n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:600,color:"#0F172A"}},{children:j}))})),M.isToggleVisible&&n.jsx(i.Box,e.__assign({sx:{display:"flex",alignItems:"center"}},{children:n.jsx(i.FormControlLabel,{control:n.jsx(i.Switch,{checked:W,onChange:function(e){var n=e.target.checked;V(!0),setTimeout(function(){z(n),Sn(),ce(new Set),fe([]),xe.current=[],setTimeout(function(){V(!1)},400)},50)},color:"primary",size:"small",sx:{width:100,height:26,padding:0,"& .MuiSwitch-switchBase":{padding:0,margin:"3px",transitionDuration:"300ms","&.Mui-checked":{transform:"translateX(75px)",color:"#fff","& + .MuiSwitch-track":{backgroundColor:"#5928ED",opacity:1,border:0,"&::before":{content:'"Side by Side"',position:"absolute",left:"13px",top:"50%",transform:"translateY(-50%)",fontSize:"9px",fontWeight:700,color:"#fff",letterSpacing:"0.3px"}}}},"& .MuiSwitch-thumb":{boxSizing:"border-box",width:20,height:20},"& .MuiSwitch-track":{borderRadius:13,backgroundColor:"#9e9e9e",opacity:1,position:"relative","&::after":{content:'"Side by Side"',position:"absolute",right:"13px",top:"50%",transform:"translateY(-50%)",fontSize:"9px",fontWeight:700,color:"#fff",letterSpacing:"0.3px",opacity:1,transition:"opacity 0.2s"}},"& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track":{"&::after":{opacity:0}}}}),label:"",labelPlacement:"start",sx:{m:0,gap:1}})}))]})),n.jsx(i.Box,e.__assign({ref:Oe,onScroll:st,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:W?"hidden":"auto",borderTop:mn&&yn?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(i.Box,e.__assign({sx:e.__assign({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},W?{flex:1,minHeight:0}:{})},{children:n.jsxs(i.Box,e.__assign({ref:jn,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"10px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},W?{flex:1,overflow:"visible"}:{})},{children:[n.jsxs("svg",e.__assign({ref:ve,style:{position:"absolute",top:0,left:0,width:we.width||"100%",height:we.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",transition:"opacity 0.15s ease-in-out"}},{children:[Wn&&n.jsxs("g",{children:[n.jsx("line",{x1:Wn.x1,y1:Wn.y,x2:Math.max(Wn.x1,(Wn.x1+Wn.x2)/2-70),y2:Wn.y,stroke:"#BBF7D0",strokeWidth:"1.5"}),n.jsx("line",{x1:Math.min(Wn.x2,(Wn.x1+Wn.x2)/2+70),y1:Wn.y,x2:Wn.x2,y2:Wn.y,stroke:"#BBF7D0",strokeWidth:"1.5"})]}),An.map(function(t){var l,s=(t.x1+t.x2)/2;if("Not Defined"===t.style.label&&!t.hasCognitive)return null;if(!W)return n.jsxs("g",{children:[n.jsx("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),n.jsx("foreignObject",e.__assign({x:s-100,y:t.y1-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){if(e.stopPropagation(),Te.open&&oe===t.id)Ke();else{var n=hn[t.sectionIdx]||{title:"",content:""},i=pn[t.sectionIdx]||{title:"",content:""};if(t.isSubSection&&t.subSectionKeyPath){for(var r=t.subSectionKeyPath.split("-").map(Number),o=hn[r[0]],l=pn[r[0]],s=1;s<r.length;s++)(null==o?void 0:o.subsections)&&(o=o.subsections[r[s]]),(null==l?void 0:l.subsections)&&(l=l.subsections[r[s]]);o&&(n=o),l&&(i=l)}le(t.id),In(Rn(e.currentTarget,n,i,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:500,textAlign:"center",whiteSpace:"nowrap",cursor:"pointer"}},{children:[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(o.ButtonCognitiveIcon,{})})),n.jsx(r.ChevronDown,{size:11,style:{transform:Te.open&&oe===t.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},t.id);var a=!1;if(t.isSubSection)a=Z&&Nn===t.subSectionKeyPath&&ne;else{var c=hn[t.sectionIdx];if(!(null===(l=null==c?void 0:c.refIndexes)||void 0===l?void 0:l.length)||(null==c?void 0:c.selfIndex)<0)return null;a=Z&&Nn===t.sectionIdx&&ne}return a?n.jsxs("g",e.__assign({style:{transition:"opacity 0.2s"}},{children:[n.jsx("defs",{children:n.jsx("marker",e.__assign({id:"arr-".concat(t.id),markerWidth:"7",markerHeight:"5",refX:"7",refY:"2.5",orient:"auto"},{children:n.jsx("polygon",{points:"0 0, 7 2.5, 0 5",fill:t.style.badgeBorder||"#6366F1"})}))}),n.jsx("line",{ref:En,x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.badgeBorder||"#6366F1",strokeWidth:"1.5",markerEnd:"url(#arr-".concat(t.id,")")})]}),t.id):null}),de.map(function(t){var i,r=t.pathD,o=(null===(i=t.style)||void 0===i?void 0:i.badgeBorder)||"#6366F1",l="conn-marker-".concat(t.id),s="".concat(t.id,"-bg"),a="".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:o})}))}))}),n.jsx("path",{ref:function(e){ge.current[s]=e},d:r,fill:"none",stroke:"#FFFFFF",strokeWidth:"4",strokeOpacity:"0.7"}),n.jsx("path",{ref:function(e){ge.current[a]=e},d:r,fill:"none",stroke:o,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)"},W?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(i.Box,e.__assign({ref:Tn,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",minHeight:"40px",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:"#19213D",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",height:"40px"}},{children:fn}))}))})),n.jsxs(i.Box,e.__assign({ref:qe,onScroll:st,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},W?{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:ze,style:{width:"100%",height:"0px",flexShrink:0}}),gn&&hn.map(function(t,o){var l,s,a,c=!t.title&&!t.content;if(W&&c)return null;if(!W)return n.jsx(i.Box,e.__assign({ref:bn(o)},{children:ut({section:t,idx:o,columnKey:"left",colRef:Yn.current[o],parentNodeId:(null===(l=null==B?void 0:B.input_index_map)||void 0===l?void 0:l[0])||""})}),"left-row-".concat(o));var u=t,d=et(o),f=!(null===(s=u.refIndexes)||void 0===s?void 0:s.length)||u.selfIndex<0,v="number"==typeof u.selfIndex&&u.selfIndex>=0?u.selfIndex+1:null,h=ae.has(o);return n.jsx(i.Box,e.__assign({ref:bn(o),sx:{mb:1}},{children:n.jsxs(i.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[n.jsx(i.Box,e.__assign({ref:Yn.current[o],sx:e.__assign({width:"100%",display:"flex"},h&&{borderRadius:"6px",outline:"2px solid ".concat((null==d?void 0:d.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:ut({section:t,idx:o,columnKey:"left",colRef:p.default.createRef(),mb:0,parentNodeId:(null===(a=null==B?void 0:B.input_index_map)||void 0===a?void 0:a[0])||""})})),d&&n.jsxs(i.Box,e.__assign({ref:Un.current[o],onClick:function(e){var n=pn.find(function(e){var n;return null===(n=u.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""};Cn(e,t,f,n,o,d)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:d.badgeBg,color:d.badgeText,border:"1px solid ".concat(d.badgeBorder),borderRadius:"12px",px:1.2,py:.4,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[null!==v&&n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(d.badgeBorder)}},{children:v})),n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",px:.25}},{children:f?"No Deviation Found":0==d.deviationLabel||void 0===d.deviationLabel?"Same":"".concat(d.deviationLabel,"% Deviation")})),n.jsx(r.EllipsisVertical,{size:11,color:d.badgeText})]}))]}))}),"left-row-".concat(o))}),n.jsx("div",{ref:Pe,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),n.jsx(i.Box,e.__assign({sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0}},{children:n.jsx(i.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:n.jsxs(i.Box,e.__assign({sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",borderRadius:"20px",bgcolor:"#ECFDF3",border:"1px solid #A7F3D0",color:"#15803D",fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1}},{children:[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(o.ButtonCognitiveIcon,{})})),0,"% Similarity",n.jsx(r.ChevronDown,{size:11})]}))}))})),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},W?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[K&&n.jsx(l.default,{sections:11}),n.jsx(i.Box,e.__assign({ref:Dn,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:vn,placement:"top"},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",height:"40px"}},{children:vn}))}))})),n.jsxs(i.Box,e.__assign({ref:He,onScroll:st,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},W?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-20px",pl:"40px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:Le,style:{width:"100%",height:"0px",flexShrink:0}}),gn&&pn.map(function(t,r){var o,l;if(!W)return ut({section:t,idx:r,columnKey:"right",colRef:Kn.current[r],parentNodeId:(null===(o=null==B?void 0:B.input_index_map)||void 0===o?void 0:o[1])||""});var s=t,a=hn.filter(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(s.selfIndex))&&e.selfIndex>=0}).map(function(e){return e.selfIndex+1}),c=hn.some(function(e,n){var t;return ae.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(s.selfIndex))}),u=hn.findIndex(function(e,n){var t;return ae.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(s.selfIndex))}),d=-1!==u?et(u):null;return n.jsx(i.Box,e.__assign({ref:Gn.current[r],sx:{mb:1}},{children:n.jsxs(i.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[n.jsx(i.Box,e.__assign({ref:Kn.current[r],sx:e.__assign({width:"100%",display:"flex"},c&&d&&{borderRadius:"6px",outline:"2px solid ".concat(d.badgeBorder),outlineOffset:"1px"})},{children:ut({section:t,idx:r,columnKey:"right",colRef:p.default.createRef(),mb:0,parentNodeId:(null===(l=null==B?void 0:B.input_index_map)||void 0===l?void 0:l[1])||""})})),!K&&n.jsx(i.Box,e.__assign({ref:Xn.current[r],sx:{position:"absolute",top:"18px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"11px",bgcolor:"#EEF2FF",color:"#3730A3",border:"1px solid #C7D2FE",borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:a.length>0?a.join(", "):"-"}))]}))}),"right-row-".concat(r))}),n.jsx("div",{ref:We,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"),r=require("lucide-react"),o=require("../../assests/svg/ButtonCognitiveIcon.js"),l=require("./OverlayComponent.js"),s=require("react-markdown"),a=require("./CognitiveComparehelpers.js"),c=require("./CognitiveCompareConfig.js"),u=require("./CognitivePopup.js"),d=require("./MoreFunctionsPopup.js"),f=require("./LoaderComponent.js"),v=require("rehype-raw");function p(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var h=p(t),g=p(s),x=p(v),m=h.default.memo(function(r){var o=r.content,l=r.sxStyles,s=r.highlights,c=void 0===s?[]:s,u=t.useMemo(function(){return{mark:function(t){var i=t.children;return n.jsx("span",e.__assign({style:{backgroundColor:"#fccccc"}},{children:i}))}}},[]),d=t.useMemo(function(){var e=o;return c.forEach(function(n){e=e.replaceAll(n,"<mark>".concat(n,"</mark>"))}),e},[o,c]);return n.jsx(i.Typography,e.__assign({component:"div",sx:l},{children:n.jsx(g.default,e.__assign({components:u,rehypePlugins:[x.default]},{children:a.safeStringify(d).replace(/\\n/g,"\n")}))}))},function(e,n){if(e.content!==n.content)return!1;if(e.sxStyles!==n.sxStyles)return!1;var t=e.highlights||[],i=n.highlights||[];if(t.length!==i.length)return!1;for(var r=0;r<t.length;r++)if(t[r]!==i[r])return!1;return!0}),_=function(e,n,t,i,r){void 0===r&&(r=14);var o=e+.65*(t-e),l=i-n;if(Math.abs(l)<3)return"M ".concat(e," ").concat(n," H ").concat(t);var s=l>0?1:-1,a=Math.min(r,Math.abs(l)/2,Math.abs(o-e)/2,Math.abs(t-o)/2);return["M ".concat(e," ").concat(n),"H ".concat(o-a),"Q ".concat(o," ").concat(n," ").concat(o," ").concat(n+s*a),"V ".concat(i-s*a),"Q ".concat(o," ").concat(i," ").concat(o+a," ").concat(i),"H ".concat(t)].join(" ")},b={id:"",title:""},y={open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,isOrphan:!1,docData:null,deviationData:null},S=function(e,n,t,i,r){void 0===t&&(t=300);var o=e.style.scrollBehavior;e.style.scrollBehavior="auto";var l=e.scrollTop,s=n-l,a=null,c=function(u){null===a&&(a=u);var d,f=u-a;f<t?(e.scrollTop=(d=f,d/=t,s*(--d*d*d+1)+l),r&&r(),requestAnimationFrame(c)):(e.scrollTop=n,e.style.scrollBehavior=o,r&&r(),i&&i())};requestAnimationFrame(c)};exports.SHARED_MARKDOWN_STYLES=c.SHARED_MARKDOWN_STYLES,exports.default=function(s){var v,p,g,x,R,I,C,w,F=s.componentHeaderText,j=void 0===F?"Contract Comparison":F,B=s.treeData,E=s.comparisonConfig,T=s.leftColumnTitleText,D=s.rightColumnTitleText,A=s.markdownStyles,k=s.displayConfig,M=void 0===k?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1}:k,O=s.popupConfig,N=s.deviationData,H=void 0===N?{}:N,L=t.useState(M.maintainRelativeOrder),W=L[0],z=L[1],P=t.useState(!1),q=P[0],V=P[1],Y=t.useState(!1),K=Y[0],U=Y[1],X=t.useState(null),G=X[0],J=X[1],Q=t.useState(!1),Z=Q[0],$=Q[1],ee=t.useState(!1),ne=ee[0],te=ee[1],ie=t.useRef(!1),re=t.useState(null),oe=re[0],le=re[1],se=t.useState(new Set),ae=se[0],ce=se[1],ue=t.useState([]),de=ue[0],fe=ue[1],ve=t.useRef(null),pe=t.useRef(!1),he=t.useRef(null),ge=t.useRef({}),xe=t.useRef([]),me=t.useRef(!1),_e=t.useRef(!1),be=t.useRef(null),ye=t.useMemo(function(){return(null==B?void 0:B.cognitive_decisioning)||{}},[B]),Se=t.useState(null),Re=Se[0],Ie=Se[1],Ce=t.useRef(null),we=t.useState({width:0,height:0}),Fe=we[0],je=we[1],Be=t.useMemo(function(){return e.__assign(e.__assign({},c.SHARED_MARKDOWN_STYLES),A)},[A]),Ee=t.useState({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,isOrphan:!1,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null,deviationData:null}),Te=Ee[0],De=Ee[1],Ae=t.useState({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,isOrphan:!1,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null,deviationData:null}),ke=Ae[0],Me=Ae[1],Oe=t.useRef(null),Ne=t.useRef(null),He=t.useRef(null),Le=t.useRef(null),We=t.useRef(null),ze=t.useRef(null),Pe=t.useRef(null),qe=t.useRef(null),Ve=t.useRef(!1),Ye=t.useRef(null);t.useEffect(function(){Ye.current=null},[Te.sectionIdx,Te.open]);var Ke=t.useCallback(function(){Ie(null),De(y),le(null)},[]),Ue=t.useCallback(function(){Me(y)},[]),Xe=t.useCallback(function(){var e;if(Te.anchorEl&&Te.refSectionTitle){var n=Te.anchorEl.getBoundingClientRect(),t=(null===(e=null==Ce?void 0:Ce.current)||void 0===e?void 0:e.offsetHeight)||0,i=Math.min(680,window.innerWidth-24),r=window.innerHeight-n.bottom-12-12,o=n.top-12-12,l=r<t&&o>r;null!==Ye.current?!0===Ye.current&&(l=o>=t||o>=r):l=!(r>=t||r>=o),Ye.current=l;var s=l?o:r,a=Math.min(t||9999,s),c=l?n.top-12-a:n.bottom+12,u=n.left+n.width/2,d=u-i/2,f=Math.max(12,Math.min(d,window.innerWidth-i-12)),v=Math.max(14,Math.min(u-f,i-10-4));Ie({top:c,left:f,arrowLeft:v,openAbove:l,maxHeight:s})}},[Te.anchorEl,Te.refSectionTitle]);t.useEffect(function(){if(Te.open){window.addEventListener("resize",Xe);var e=requestAnimationFrame(Xe),n=null;return Ce.current&&(n=new ResizeObserver(function(){cancelAnimationFrame(e),e=requestAnimationFrame(Xe)})).observe(Ce.current),function(){cancelAnimationFrame(e),window.removeEventListener("resize",Xe),n&&n.disconnect()}}},[Te.open,Xe]),t.useEffect(function(){var e=Oe.current;if(e&&Te.open){var n=function(e){Ce.current&&Ce.current.contains(e.target)||(Ie(null),Ke())};return e.addEventListener("scroll",n,{capture:!0}),window.addEventListener("scroll",n,{capture:!0}),function(){e.removeEventListener("scroll",n,{capture:!0}),window.removeEventListener("scroll",n,{capture:!0})}}},[Te.open,Ke]),t.useEffect(function(){var e=Oe.current;if(e&&ke.open){var n=function(){Ue()};return e.addEventListener("scroll",n,{capture:!0}),window.addEventListener("scroll",n,{capture:!0}),function(){e.removeEventListener("scroll",n,{capture:!0}),window.removeEventListener("scroll",n,{capture:!0})}}},[ke.open,Ue]);var Ge=t.useMemo(function(){var n,t,i,r,o,l,s,a,u,d,f,v;return{fields:null!==(n=null==E?void 0:E.fields)&&void 0!==n?n:c.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(i=null===(t=null==E?void 0:E.thresholds)||void 0===t?void 0:t.high)&&void 0!==i?i:c.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(o=null===(r=null==E?void 0:E.thresholds)||void 0===r?void 0:r.medium)&&void 0!==o?o:c.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(s=null===(l=null==E?void 0:E.thresholds)||void 0===l?void 0:l.exact)&&void 0!==s?s:c.DEFAULT_COMPARISON_CONFIG.thresholds.exact},relationStyles:{noContent:e.__assign(e.__assign({},c.DEFAULT_COMPARISON_CONFIG.relationStyles.noContent),(null===(a=null==E?void 0:E.relationStyles)||void 0===a?void 0:a.noContent)||{}),high:e.__assign(e.__assign({},c.DEFAULT_COMPARISON_CONFIG.relationStyles.high),(null===(u=null==E?void 0:E.relationStyles)||void 0===u?void 0:u.high)||{}),exact:e.__assign(e.__assign({},c.DEFAULT_COMPARISON_CONFIG.relationStyles.exact),(null===(d=null==E?void 0:E.relationStyles)||void 0===d?void 0:d.exact)||{}),medium:e.__assign(e.__assign({},c.DEFAULT_COMPARISON_CONFIG.relationStyles.medium),(null===(f=null==E?void 0:E.relationStyles)||void 0===f?void 0:f.medium)||{}),low:e.__assign(e.__assign({},c.DEFAULT_COMPARISON_CONFIG.relationStyles.low),(null===(v=null==E?void 0:E.relationStyles)||void 0===v?void 0:v.low)||{})}}},[E]),Je=t.useMemo(function(){if(B&&Object.keys(B).length>0)try{var n=function(n,t,i){var r,o,l,s;void 0===t&&(t=!1),void 0===i&&(i=null);var c=n.nodes||n,u=[],d=[],f=n.base_root_id,v=n.input_index_map||{0:"left",1:"right"},p=n[f]||c[f];if(!p||!1===p.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[]};var h=function(t,r){var o,l=n[t]||c[t];if(!l||!1===l.display_node)return null;var s=a.getSideData(l,r,v),u=!!s.title.trim(),d=!!s.content.trim(),f=a.getRationale(l),p=(null===(o=null==i?void 0:i[t])||void 0===o?void 0:o.evaluation_result)||l.evaluation_result||null,g=[];l.next&&Object.values(l.next).forEach(function(e){var n=c[e];if(n&&!1!==n.display_node){var t=h(e,r);t&&g.push(t)}});var x=!(!u&&!d);return e.__assign(e.__assign({id:t,title:u?s.title:"",content:d?s.content:"",subsections:g},x?f:{score:void 0,relation:"not_defined"}),{evaluationResult:p})};if(t){var g=function(t,r){var o,l,s,u,d,f,p,h,x,m,_,b,y;void 0===r&&(r=0);var S=[],R=[];if(!t)return{refSections:S,baseSections:R};var I={},C={},w=-1,F=-1;for(var j in t){var B=t[j],E=n[B]||c[B];if(E&&!1!==E.display_node){var T=a.getRationale(E),D=(null===(o=null==i?void 0:i[B])||void 0===o?void 0:o.evaluation_result)||E.evaluation_result||null,A=a.getSideData(E,"1",v),k=a.getSideData(E,"0",v),M=A.title.trim()||A.content.trim(),O=k.title.trim()||k.content.trim(),N=Number(null!==(s=null===(l=A.attributes)||void 0===l?void 0:l.display_index)&&void 0!==s?s:w--),H=Number(null!==(d=null===(u=k.attributes)||void 0===u?void 0:u.display_index)&&void 0!==d?d:F--),L=I[N]||e.__assign(e.__assign({id:B,title:M?A.title:"",content:M?A.content:"",subsections:[]},M?T:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:N,evaluationResult:D,displayContent:null===(f=A.attributes)||void 0===f?void 0:f.display_content,displayTitle:null===(p=A.attributes)||void 0===p?void 0:p.display_title}),W=C[H]||e.__assign(e.__assign({id:B,title:O?k.title:"",content:O?k.content:"",subsections:[]},O?T:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:H,evaluationResult:D,displayContent:null===(h=k.attributes)||void 0===h?void 0:h.display_content,displayTitle:null===(x=k.attributes)||void 0===x?void 0:x.display_title});Number(N)>=0&&Number(H)>=0&&((null===(m=L.refIndexes)||void 0===m?void 0:m.includes(Number(H)))||null===(_=L.refIndexes)||void 0===_||_.push(Number(H)),(null===(b=W.refIndexes)||void 0===b?void 0:b.includes(Number(N)))||null===(y=W.refIndexes)||void 0===y||y.push(Number(N))),I[N]=L,C[H]=W;var z=g(E.next,r+1),P=z.refSections,q=z.baseSections;P.length>0&&(L.subsections=e.__spreadArray(e.__spreadArray([],L.subsections||[],!0),P,!0)),q.length>0&&(W.subsections=e.__spreadArray(e.__spreadArray([],W.subsections||[],!0),q,!0))}}return S=Object.values(I).map(function(e){return e}),R=Object.values(C).map(function(e){return e}),S.sort(function(e,n){return e.selfIndex<0&&n.selfIndex>=0?1:e.selfIndex>=0&&n.selfIndex<0?-1:e.selfIndex-n.selfIndex}),R.sort(function(e,n){return e.selfIndex<0&&n.selfIndex>=0?1:e.selfIndex>=0&&n.selfIndex<0?-1:e.selfIndex-n.selfIndex}),{refSections:S,baseSections:R}},x=g(p.next),m=x.refSections,_=x.baseSections;d=m,u=_}else p.next&&Object.values(p.next).forEach(function(e){var t=n[e]||c[e];t&&!1!==t.display_node&&(u.push(h(e,"0")||{id:e,title:"",content:"",subsections:[]}),d.push(h(e,"1")||{id:e,title:"",content:"",subsections:[]}))});return{activeProposed:{title:(null===(o=null===(r=p.comparison_inputs)||void 0===r?void 0:r[v[0]])||void 0===o?void 0:o.title)||"Uploaded Contract",description:p.decision_scope_description||"",sections:u},activeVariants:[{id:"tree-variant-1",title:(null===(s=null===(l=p.comparison_inputs)||void 0===l?void 0:l[v[1]])||void 0===s?void 0:s.title)||"Reference Template",similarity:0,sections:d,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:p.decision_scope_description||""},fields:{}}}}]}}(B,W,H);return e.__assign(e.__assign({},n),{parseError:null})}catch(e){return console.error("Data Transformation Error: ",e),{activeProposed:{},activeVariants:[],parseError:e instanceof Error?e.message:"Unknown Parsing Error"}}return{activeProposed:{},activeVariants:[],parseError:"Tree data is required"}},[JSON.stringify(B),W,JSON.stringify(H)]),Qe=Je.activeProposed,Ze=Je.activeVariants,$e=Je.parseError;t.useEffect(function(){$e&&J("Failed to load comparison: ".concat($e))},[$e]);var en=t.useState(null),nn=en[0];en[1];var tn=t.useState({}),rn=tn[0],on=tn[1],ln=t.useState({}),sn=ln[0],an=ln[1],cn=(null==Ze?void 0:Ze[0])||b,un=null===(g=null===(v=null==B?void 0:B.documents)||void 0===v?void 0:v[null===(p=null==B?void 0:B.input_index_map)||void 0===p?void 0:p[0]])||void 0===g?void 0:g.title,dn=null===(I=null===(x=null==B?void 0:B.documents)||void 0===x?void 0:x[null===(R=null==B?void 0:B.input_index_map)||void 0===R?void 0:R[1]])||void 0===I?void 0:I.title,fn=a.safeStringify(T||un||"Uploaded Contract"),vn=a.safeStringify(D||dn||"Reference Template"),pn=t.useMemo(function(){return(null==Qe?void 0:Qe.sections)||[]},[null==Qe?void 0:Qe.sections]),hn=t.useMemo(function(){return cn.sections||[]},[cn.sections]),gn=pn.length>0||hn.length>0,xn=cn.analysis,mn=a.safeStringify(null===(w=null===(C=null==xn?void 0:xn.rule_difference_comparison)||void 0===C?void 0:C.summary)||void 0===w?void 0:w.overall_summary),_n=!!mn.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),bn=t.useRef({}),yn=function(e){return bn.current[e]||(bn.current[e]=h.default.createRef()),bn.current[e]},Sn=t.useCallback(function(){$(!1),_e.current=!1,Hn(null),be.current=null,Bn.current=null,te(!1),U(!1),Le.current&&(Le.current.style.height="0px"),We.current&&(We.current.style.height="0px"),ze.current&&(ze.current.style.height="0px"),Pe.current&&(Pe.current.style.height="0px")},[]),Rn=t.useCallback(function(e,n,t,i,r,o){var l,s,c=a.safeStringify(n.id)||a.safeStringify(t.id)||"",u=(c?ye[c]:null)||n.cognitiveData||t.cognitiveData||{section_id:c,decisioning:[],gap:[],relevance_score:0},d=null!==(s=null===(l=bn.current[i])||void 0===l?void 0:l.current)&&void 0!==s?s:null;return{open:!0,sectionTitle:n.title||"N/A",refSectionTitle:t.title||"NA",cognitiveData:u,anchorEl:e,sectionAnchorEl:d,badgeStyle:o||null,sectionIdx:i,docData:{documents:null==B?void 0:B.documents,input_index_map:null==B?void 0:B.input_index_map},deviationData:n.evaluationResult||t.evaluationResult||null,isOrphan:!!r}},[ye,B]),In=t.useCallback(function(e){Ue(),Ie(null),De(e)},[Ue]),Cn=function(e,n,t,i,r,o){e.stopPropagation(),ke.open&&ke.sectionIdx===r?Ue():(Ke(),Me(Rn(e.currentTarget,n,i,r,t,o)))},wn=t.useCallback(function(){null!==ke.sectionIdx&&ke.anchorEl?In(e.__assign(e.__assign({},ke),{open:!0})):Ue()},[ke,Ue,In]);t.useCallback(function(e){Ue(),J("".concat(e," is coming soon."))},[Ue]);var Fn=t.useCallback(function(){var e=ke.sectionIdx,n=ke.isOrphan;if(Ue(),null!==e){if(n)return J("No counterpart exists to connect to."),void Ue();_e.current&&Sn(),ce(function(n){return n.has(e)?new Set:new Set([e])})}},[ke.sectionIdx,Ue,Sn]),jn=t.useRef(null),Bn=t.useRef(null),En=t.useRef(null),Tn=t.useRef(null),Dn=t.useRef(null),An=t.useState([]),kn=An[0],Mn=An[1],On=t.useState(null),Nn=On[0],Hn=On[1];t.useRef(null);var Ln=t.useState(null),Wn=Ln[0],zn=Ln[1],Pn=t.useMemo(function(){return Ge.fields.filter(function(e){var n=e.key;return(!gn||"description"!==n)&&(a.hasValue(null==Qe?void 0:Qe[n])||a.hasValue(cn[n]))})},[Qe,cn,gn,Ge.fields]),qn=t.useRef({}),Vn=t.useRef({}),Yn=t.useRef({}),Kn=t.useRef({}),Un=t.useRef({}),Xn=t.useRef({}),Gn=t.useRef({}),Jn=t.useRef({}),Qn=t.useRef({});Pn.forEach(function(e){for(var n=e.key,t=0;t<Math.max(pn.length,hn.length);t+=1)Yn.current[t]||(Yn.current[t]=h.default.createRef()),Kn.current[t]||(Kn.current[t]=h.default.createRef()),Un.current[t]||(Un.current[t]=h.default.createRef()),Xn.current[t]||(Xn.current[t]=h.default.createRef()),Gn.current[t]||(Gn.current[t]=h.default.createRef());qn.current[n]||(qn.current[n]=h.default.createRef()),Vn.current[n]||(Vn.current[n]=h.default.createRef())});for(var Zn=0;Zn<Math.max(pn.length,hn.length);Zn+=1)Yn.current[Zn]||(Yn.current[Zn]=h.default.createRef()),Kn.current[Zn]||(Kn.current[Zn]=h.default.createRef()),Un.current[Zn]||(Un.current[Zn]=h.default.createRef()),Xn.current[Zn]||(Xn.current[Zn]=h.default.createRef()),Gn.current[Zn]||(Gn.current[Zn]=h.default.createRef());t.useEffect(function(){if(nn){var e=Ge.fields.find(function(e){return e.analysisKey===nn||e.key===nn});if(e){var n=qn.current[e.key]||Vn.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[nn,Ge.fields]);var $n=t.useCallback(function(e){var n,t,i,r,o,l,s,a,c,u=null===(n=null==xn?void 0:xn.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!u||!u[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var d=u[e],f=(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===(o=null===(r=null==d?void 0:d.highlights)||void 0===r?void 0:r.ruleB_spans)||void 0===o?void 0:o.length)||(null==d?void 0:d.mappings)&&d.mappings.length>0;if(d.mappings){var v=d.mappings[0]||{};return{score:d.score,relation:v.relation||"",highlightsA:(null===(l=v.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(s=v.highlights)||void 0===s?void 0:s.ruleB_spans)||[],hasContent:!!f}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(a=d.highlights)||void 0===a?void 0:a.ruleA_spans)||[],highlightsB:(null===(c=d.highlights)||void 0===c?void 0:c.ruleB_spans)||[],hasContent:!!f}},[xn]),et=t.useCallback(function(n){var t,i,r,o=pn[n],l=hn[n],s=(null==o?void 0:o.relation)&&"not_defined"!==o.relation,c=(null==l?void 0:l.relation)&&"not_defined"!==l.relation;a.safeStringify(null==o?void 0:o.id)||a.safeStringify(null==l?void 0:l.id);var u=!(!(null==o?void 0:o.cognitiveData)&&!(null==l?void 0:l.cognitiveData));if(!s&&!c&&!u)return e.__assign(e.__assign({},Ge.relationStyles.noContent),{label:"Not Defined"});var d=null!==(i=null!==(t=null==o?void 0:o.evaluationResult)&&void 0!==t?t:null==l?void 0:l.evaluationResult)&&void 0!==i?i:null,f=(null===(r=null==d?void 0:d.evaluation_outputs)||void 0===r?void 0:r.output_value)+"%";return null!=d?e.__assign(e.__assign({},Ge.relationStyles.low),{label:f}):e.__assign(e.__assign({},Ge.relationStyles.low),{label:"N/A"})},[pn,hn,ye,Ge,$n]),nt=t.useCallback(function(n){for(var t,i,r,o,l,s,c=n.split("-").map(Number),u=pn[c[0]],d=hn[c[0]],f=1;f<c.length;f++)(null==u?void 0:u.subsections)&&(u=u.subsections[c[f]]),(null==d?void 0:d.subsections)&&(d=d.subsections[c[f]]);if(!u&&!d)return null;var v=(null==u?void 0:u.relation)&&"not_defined"!==u.relation,p=(null==d?void 0:d.relation)&&"not_defined"!==d.relation,h=a.safeStringify(null==u?void 0:u.id)||a.safeStringify(null==d?void 0:d.id)||"",g=!(!(null==u?void 0:u.cognitiveData)&&!(null==d?void 0:d.cognitiveData));if(!v&&!p&&!g)return e.__assign(e.__assign({},Ge.relationStyles.noContent),{label:"Not Defined"});null!==(i=null!==(t=null==u?void 0:u.cognitiveRelevanceScore)&&void 0!==t?t:null==d?void 0:d.cognitiveRelevanceScore)&&void 0!==i||h&&(null===(r=ye[h])||void 0===r||r.relevance_score);var x=null!==(l=null!==(o=null==u?void 0:u.evaluationResult)&&void 0!==o?o:null==d?void 0:d.evaluationResult)&&void 0!==l?l:null,m=(null===(s=null==x?void 0:x.evaluation_outputs)||void 0===s?void 0:s.output_value)+"%";return null!=x?e.__assign(e.__assign({},Ge.relationStyles.low),{label:m}):e.__assign(e.__assign({},Ge.relationStyles.low),{label:"N/A"})},[pn,hn,ye,Ge]),tt=t.useCallback(function(){var n,t,i,r,o,l,s,c,u,d,f,v,p,h,g,x,m,b,y,S,R,I;if(!Ve.current&&!pe.current){Ve.current=!0;try{if(!jn.current)return;var C=function(e){var n=e.split("-"),t=n[0];if(!rn[t]&&!1===W)return!1;if(W&&!rn["left-".concat(t)]&&!rn["right-".concat(t)]&&!rn[t])return!1;for(var i=t,r=1;r<n.length-1;r++)if(i+="-".concat(n[r]),!sn[i])return!1;return!0},w=jn.current.getBoundingClientRect();je({width:w.width,height:w.height});var F=[];if(Pn.forEach(function(e){var n,t,i=e.key,r=null===(n=qn.current[i])||void 0===n?void 0:n.current,o=null===(t=Vn.current[i])||void 0===t?void 0:t.current;r&&o&&(r.style.height="auto",o.style.height="auto",r.style.minHeight="0px",o.style.minHeight="0px")}),!pe.current){for(var j=0;j<Math.max(pn.length,hn.length);j++){var B=null===(n=Yn.current[j])||void 0===n?void 0:n.current,E=null===(t=Kn.current[j])||void 0===t?void 0:t.current;B&&(B.style.height="auto",B.style.minHeight="0px"),E&&(E.style.height="auto",E.style.minHeight="0px")}W||Object.keys(Jn.current).forEach(function(e){var n,t;if(C(e)){var i=null===(n=Jn.current[e])||void 0===n?void 0:n.current,r=null===(t=Qn.current[e])||void 0===t?void 0:t.current;i&&r&&(i.style.height="auto",r.style.height="auto",i.style.minHeight="0px",r.style.minHeight="0px")}})}var T={};Pn.forEach(function(e){var n,t,i=e.key,r=null===(n=qn.current[i])||void 0===n?void 0:n.current,o=null===(t=Vn.current[i])||void 0===t?void 0:t.current;if(r&&o){var l=r.getBoundingClientRect(),s=o.getBoundingClientRect();T[i]=Math.max(l.height,s.height)}});var D={left:{},right:{}},A={};if(!pe.current)if(W){if(Z&&null!==Nn)if("number"==typeof Nn){var k=Nn,M=pn[k],O=null===(o=Yn.current[k])||void 0===o?void 0:o.current;O&&M&&(M.refIndexes||[]).forEach(function(e){var n,t=hn.findIndex(function(n){return n.selfIndex===e}),i=null===(n=Kn.current[t])||void 0===n?void 0:n.current;if(i&&(rn["left-".concat(k)]||rn["right-".concat(t)])){var r=Math.max(O.getBoundingClientRect().height,i.getBoundingClientRect().height);D.left[k]=Math.max(D.left[k]||0,r),D.right[t]=Math.max(D.right[t]||0,r)}})}else{var N=Nn;B=null===(l=Jn.current[N])||void 0===l?void 0:l.current,E=null===(s=Qn.current[N])||void 0===s?void 0:s.current;if(B&&E){L=Math.max(B.getBoundingClientRect().height,E.getBoundingClientRect().height);A[N]=Math.max(A[N]||0,L)}}}else{for(j=0;j<Math.min(pn.length,hn.length);j++){var B=null===(i=Yn.current[j])||void 0===i?void 0:i.current,E=null===(r=Kn.current[j])||void 0===r?void 0:r.current,H=!!rn[String(j)];if(B&&E&&H){var L=Math.max(B.getBoundingClientRect().height,E.getBoundingClientRect().height);D.left[j]=L,D.right[j]=L}}Object.keys(Jn.current).forEach(function(e){var n,t;if(C(e)){var i=null===(n=Jn.current[e])||void 0===n?void 0:n.current,r=null===(t=Qn.current[e])||void 0===t?void 0:t.current;if(i&&r&&null!==i.offsetParent&&null!==r.offsetParent){var o=i.getBoundingClientRect(),l=r.getBoundingClientRect();A[e]=Math.max(o.height,l.height)}}})}if(Pn.forEach(function(e){var n,t,i=e.key,r=null===(n=qn.current[i])||void 0===n?void 0:n.current,o=null===(t=Vn.current[i])||void 0===t?void 0:t.current;if(r&&o){var l=T[i];r.style.minHeight="".concat(l,"px"),o.style.minHeight="".concat(l,"px")}}),pe.current||(Object.entries(D.left).forEach(function(e){var n,t=e[0],i=e[1],r=null===(n=Yn.current[Number(t)])||void 0===n?void 0:n.current;r&&(r.style.minHeight="".concat(i,"px"))}),Object.entries(D.right).forEach(function(e){var n,t=e[0],i=e[1],r=null===(n=Kn.current[Number(t)])||void 0===n?void 0:n.current;r&&(r.style.minHeight="".concat(i,"px"))}),W||Object.keys(A).forEach(function(e){var n,t,i=null===(n=Jn.current[e])||void 0===n?void 0:n.current,r=null===(t=Qn.current[e])||void 0===t?void 0:t.current;if(i&&r&&A[e]){var o=A[e];i.style.minHeight="".concat(o,"px"),r.style.minHeight="".concat(o,"px")}})),W){if(pn.forEach(function(e,n){var t;(null===(t=Yn.current[n])||void 0===t?void 0:t.current)&&(e.refIndexes||[]).forEach(function(e){var t,i,r,o,l,s,a,c,u,d,f=hn.findIndex(function(n){return n.selfIndex===e});if(-1!==f){var v=null===(t=Un.current[n])||void 0===t?void 0:t.current,p=null===(i=Xn.current[f])||void 0===i?void 0:i.current;if(v&&p){var h=v.getBoundingClientRect(),g=p.getBoundingClientRect(),x=h.right-w.left,m=g.left-w.left,_=h.top+h.height/2-w.top,b=g.top+g.height/2-w.top;if(Z&&Nn===n){var y=null!==(o=null===(r=qe.current)||void 0===r?void 0:r.getBoundingClientRect().top)&&void 0!==o?o:0,S=null!==(s=null===(l=He.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==s?s:0,R=y+(null!==(c=null===(a=qe.current)||void 0===a?void 0:a.clientHeight)&&void 0!==c?c:1/0),I=S+(null!==(d=null===(u=He.current)||void 0===u?void 0:u.clientHeight)&&void 0!==d?d:1/0),C=h.top+h.height/2,j=function(e,n,t){return Math.max(n,Math.min(t,e))};_=j(C,y,R)-w.top,b=j(C,S,I)-w.top}var B=et(n);B&&F.push({id:"line-".concat(n,"-").concat(f),x1:x,y1:_,x2:m,y2:b,style:B,sectionIdx:n,targetRightIdx:f})}}})}),Z&&"string"==typeof Nn){N=Nn;var z=null===(p=Un.current[N])||void 0===p?void 0:p.current,P=null===(h=Xn.current[N])||void 0===h?void 0:h.current;if(z&&P){var q=z.getBoundingClientRect(),V=P.getBoundingClientRect(),Y=q.right-w.left,K=V.left-w.left,U=null!==(x=null===(g=qe.current)||void 0===g?void 0:g.getBoundingClientRect().top)&&void 0!==x?x:0,X=null!==(b=null===(m=He.current)||void 0===m?void 0:m.getBoundingClientRect().top)&&void 0!==b?b:0,G=U+(null!==(S=null===(y=qe.current)||void 0===y?void 0:y.clientHeight)&&void 0!==S?S:1/0),J=X+(null!==(I=null===(R=He.current)||void 0===R?void 0:R.clientHeight)&&void 0!==I?I:1/0),Q=q.top+q.height/2,$=V.top+V.height/2,ee=function(e,n,t){return Math.max(n,Math.min(t,e))},ne=ee(Q,U,G)-w.top,te=ee($,X,J)-w.top;(oe=nt(N))&&F.push({id:"line-subsec-".concat(N),x1:Y,y1:ne,x2:K,y2:te,style:oe,sectionIdx:Number(N.split("-")[0]),isSubSection:!0,subSectionKeyPath:N})}}}else{for(j=0;j<Math.min(pn.length,hn.length);j++){var ie=null===(c=Yn.current[j])||void 0===c?void 0:c.current,re=null===(u=Kn.current[j])||void 0===u?void 0:u.current;if(ie&&re){var oe,le=ie.getBoundingClientRect(),se=re.getBoundingClientRect(),ce=(le.top+18-w.top+se.top+18-w.top)/2,ue=(null===(d=hn[j])||void 0===d?void 0:d.id)||"sec-".concat(j);(oe=et(j))&&F.push({id:ue,x1:le.right-w.left,y1:ce,x2:se.left-w.left,y2:ce,style:oe,sectionIdx:j,hasCognitive:!!((null===(f=pn[j])||void 0===f?void 0:f.cognitiveData)||(null===(v=hn[j])||void 0===v?void 0:v.cognitiveData)||ue&&ye[ue])})}}Object.keys(Jn.current).forEach(function(n){var t,i,r,o,l,s;if(C(n)){for(var c=null===(t=Jn.current[n])||void 0===t?void 0:t.current,u=n.split("-").map(Number),d=pn[u[0]],f=1;f<u.length;f++)(null==d?void 0:d.subsections)&&(d=d.subsections[u[f]]);if(d&&(null===(i=d.refIndexes)||void 0===i?void 0:i.length)){var v=null===(r=Qn.current[n])||void 0===r?void 0:r.current;if(c&&v&&null!==c.offsetParent&&null!==v.offsetParent){var p=c.getBoundingClientRect(),h=v.getBoundingClientRect(),g=(p.top+16-w.top+h.top+16-w.top)/2,x=n.split("-").map(Number),m=pn[x[0]],_=hn[x[0]];for(f=1;f<x.length;f++)(null==m?void 0:m.subsections)&&(m=m.subsections[x[f]]),(null==_?void 0:_.subsections)&&(_=_.subsections[x[f]]);if(!m&&!_)return;var b=(null==m?void 0:m.relation)&&"not_defined"!==m.relation,y=(null==_?void 0:_.relation)&&"not_defined"!==_.relation,S=a.safeStringify(null==m?void 0:m.id)||a.safeStringify(null==_?void 0:_.id)||"",R=!(!(null==m?void 0:m.cognitiveData)&&!(null==_?void 0:_.cognitiveData)),I=null;if(b||y||R){var j=null!==(l=null!==(o=null==m?void 0:m.evaluationResult)&&void 0!==o?o:null==_?void 0:_.evaluationResult)&&void 0!==l?l:null,B=(null===(s=null==j?void 0:j.evaluation_outputs)||void 0===s?void 0:s.output_value)+"%";return null!=j?e.__assign(e.__assign({},Ge.relationStyles.low),{label:B}):e.__assign(e.__assign({},Ge.relationStyles.low),{label:"N/A"})}(I={badgeBg:"#EEF2FF",badgeText:"#3730A3",badgeBorder:"#C7D2FE"})&&F.push({id:"subsec-".concat(n),x1:p.right-w.left,y1:g,x2:h.left-w.left,y2:g,style:I,sectionIdx:x[0],isSubSection:!0,subSectionKeyPath:n,hasCognitive:R||S&&ye[S]})}}}})}if(Mn(F),Tn.current&&Dn.current){var de=Tn.current.getBoundingClientRect(),ve=Dn.current.getBoundingClientRect(),he=(de.top+de.height/2-w.top+ve.top+ve.height/2-w.top)/2;zn({x1:de.right-w.left,x2:ve.left-w.left,y:he})}else zn(null);if(W&&ae.size>0){var ge=[],me=qe.current,_e=He.current;if(me&&_e){var be=[],Se=me.getBoundingClientRect().top,Re=_e.getBoundingClientRect().top,Ie=Se+me.clientHeight,Ce=Re+_e.clientHeight,we=me.scrollTop,Fe=_e.scrollTop,Be=w.top,Ee=function(e,n,t){return Math.max(n,Math.min(t,e))};ae.forEach(function(e){var n,t,i;if("string"==typeof e){var r=e,o=null===(n=Un.current[r])||void 0===n?void 0:n.current,l=null===(t=Xn.current[r])||void 0===t?void 0:t.current;if(!o||!l)return;var s=o.getBoundingClientRect(),a=l.getBoundingClientRect(),c=nt(r),u=s.right-w.left,d=a.left-w.left-0,f=u+.75*(d-u),v=s.top+s.height/2,p=a.top+a.height/2,h=v-Se+we,g=p-Re+Fe,x="conn-subsec-".concat(r);be.push({lhsScrollY:h,rhsScrollY:g,x1:u,x2:d,containerTop:Be,leftIdx:r,rhsArrayIdx:r,styleColor:(null==c?void 0:c.badgeBorder)||"#6366F1",styleId:x});var m=Ee(v,Se,Ie),b=Ee(p,Re,Ce),y=m-Be,S=b-Be,R=v>=Se-4&&v<=Ie+4,I=p>=Re-4&&p<=Ce+4,C="";C=R&&I?_(u,y,d,S):R&&!I?"M ".concat(u,",").concat(y," L ").concat(f,",").concat(y," L ").concat(f,",").concat(S):!R&&I?"M ".concat(f,",").concat(y," L ").concat(f,",").concat(S," L ").concat(d,",").concat(S):"M ".concat(f,",").concat(y," L ").concat(f,",").concat(S),ge.push({id:x,pathD:C,style:c,leftIdx:r,rhsArrayIdx:r})}else{var F=pn[e];if(!(null===(i=null==F?void 0:F.refIndexes)||void 0===i?void 0:i.length))return;F.refIndexes.forEach(function(n){var t,i,r=hn.findIndex(function(e){return e.selfIndex===n});if(-1!==r){var o=null===(t=Un.current[e])||void 0===t?void 0:t.current,l=null===(i=Xn.current[r])||void 0===i?void 0:i.current;if(o&&l){var s=o.getBoundingClientRect(),a=l.getBoundingClientRect(),c=et(e),u=s.right-w.left,d=a.left-w.left-0,f=u+.75*(d-u),v=s.top+s.height/2,p=a.top+a.height/2,h=v-Se+we,g=p-Re+Fe,x="conn-".concat(e,"-").concat(r);be.push({lhsScrollY:h,rhsScrollY:g,x1:u,x2:d,containerTop:Be,leftIdx:e,rhsArrayIdx:r,styleColor:(null==c?void 0:c.badgeBorder)||"#6366F1",styleId:x});var m=Ee(v,Se,Ie),b=Ee(p,Re,Ce),y=m-Be,S=b-Be,R=v>=Se-4&&v<=Ie+4,I=p>=Re-4&&p<=Ce+4,C="";C=R&&I?_(u,y,d,S):R&&!I?"M ".concat(u,",").concat(y," L ").concat(f,",").concat(y," L ").concat(f,",").concat(S):!R&&I?"M ".concat(f,",").concat(y," L ").concat(f,",").concat(S," L ").concat(d,",").concat(S):"M ".concat(f,",").concat(y," L ").concat(f,",").concat(S),ge.push({id:x,pathD:C,style:c,leftIdx:e,rhsArrayIdx:r})}}})}}),xe.current=be}fe(ge)}else fe([]),xe.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{Ve.current=!1}}},[Pn,pn,hn,ye,Ge,$n,et,W,Z,Nn,ae,rn,sn]),it=t.useCallback(function(){var e,n,t,i,r,o,l,s,a,c,u,d,f,v,p=xe.current;if(p.length&&!pe.current){var h=null!==(n=null===(e=qe.current)||void 0===e?void 0:e.scrollTop)&&void 0!==n?n:0,g=null!==(i=null===(t=He.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,x=null!==(o=null===(r=qe.current)||void 0===r?void 0:r.clientHeight)&&void 0!==o?o:1/0,m=null!==(s=null===(l=He.current)||void 0===l?void 0:l.clientHeight)&&void 0!==s?s:1/0,b=null!==(c=null===(a=qe.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==c?c:0,y=null!==(d=null===(u=He.current)||void 0===u?void 0:u.getBoundingClientRect().top)&&void 0!==d?d:0,S=b+x,R=y+m,I=null!==(v=null===(f=jn.current)||void 0===f?void 0:f.getBoundingClientRect().top)&&void 0!==v?v:0,C=function(e,n,t){return Math.max(n,Math.min(t,e))};p.forEach(function(e){var n=e.lhsScrollY-h+b,t=e.rhsScrollY-g+y,i=ge.current[e.styleId+"-stroke"],r=ge.current[e.styleId+"-bg"];if(i||r){var o,l=C(n,b,S),s=C(t,y,R),a=l-I,c=s-I,u=n>=b-4&&n<=S+4,d=t>=y-4&&t<=R+4,f=e.x1+.65*(e.x2-e.x1);o=u&&d?_(e.x1,a,e.x2,c):u&&!d?"M ".concat(e.x1,",").concat(a," L ").concat(f,",").concat(a," L ").concat(f,",").concat(c):!u&&d?"M ".concat(f,",").concat(a," L ").concat(f,",").concat(c," L ").concat(e.x2,",").concat(c):"M ".concat(f,",").concat(a," L ").concat(f,",").concat(c),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",o)),r&&(r.setAttribute("visibility","visible"),r.setAttribute("d",o))}})}},[]),rt=t.useRef(tt);t.useEffect(function(){rt.current=tt},[tt]);var ot=t.useRef(null),lt=t.useCallback(function(){null!==ot.current&&clearTimeout(ot.current),ot.current=setTimeout(function(){rt.current(),ot.current=null},50)},[]),st=t.useCallback(function(e){var n,t,i,r,o,l,s,a;if(!ie.current){if(_e.current){var c=be.current,u=Bn.current,d=qe.current,f=He.current;if(null!==c&&null!==u&&d&&f){var v="string"==typeof c?null===(n=Jn.current[c])||void 0===n?void 0:n.current:null===(t=bn.current[c])||void 0===t?void 0:t.current,p="string"==typeof u?null===(i=Qn.current[u])||void 0===i?void 0:i.current:null===(r=Gn.current[u])||void 0===r?void 0:r.current;if(v&&p){var h=v.getBoundingClientRect().top-d.getBoundingClientRect().top+d.scrollTop,g=p.getBoundingClientRect().top-f.getBoundingClientRect().top+f.scrollTop;if(e.currentTarget===d){var x=g-(h-d.scrollTop),m=f.scrollHeight-f.clientHeight,_=Math.max(0,Math.min(x,m));Math.abs(f.scrollTop-_)>1&&(f.scrollTop=_)}else if(e.currentTarget===f){var b=h-(g-f.scrollTop),y=d.scrollHeight-d.clientHeight,S=Math.max(0,Math.min(b,y));Math.abs(d.scrollTop-S)>1&&(d.scrollTop=S)}if(En.current){var R=null===(o=Un.current[c])||void 0===o?void 0:o.current,I=null===(l=Xn.current[u])||void 0===l?void 0:l.current,C=null!==(a=null===(s=jn.current)||void 0===s?void 0:s.getBoundingClientRect().top)&&void 0!==a?a:0,w=d.getBoundingClientRect().top,F=w+d.clientHeight,j=f.getBoundingClientRect().top,B=j+f.clientHeight,E=function(e,n,t){return Math.max(n,Math.min(t,e))};if(R&&I){var T=R.getBoundingClientRect(),D=I.getBoundingClientRect(),A=T.top+T.height/2,k=D.top+D.height/2,M=E(A,w,F),O=E(k,j,B);En.current.setAttribute("y1",(M-C).toString()),En.current.setAttribute("y2",(O-C).toString());var N=A>=w-4&&A<=F+4;En.current.setAttribute("visibility",N?"visible":"hidden")}}}}}xe.current.length>0&&!me.current&&(me.current=!0,requestAnimationFrame(function(){it(),me.current=!1}))}},[it]);t.useEffect(function(){var e=setTimeout(lt,250);window.addEventListener("resize",lt);var n=null,t=null;return Oe.current&&(n=new ResizeObserver(lt)).observe(Oe.current),jn.current&&(t=new ResizeObserver(lt)).observe(jn.current),function(){clearTimeout(e),window.removeEventListener("resize",lt),null==n||n.disconnect(),null==t||t.disconnect()}},[Qe,cn,xn,Pn,rn,sn,pn,hn,Ge,lt,Z,Nn,ne,ae]),t.useEffect(function(){_e.current=Z},[Z]),t.useEffect(function(){be.current=Nn},[Nn]);var at=t.useCallback(function(){var e=ke.sectionIdx,n=ke.isOrphan;if(null!=e)return n?(J("No counterpart exists for this section."),void Ue()):void(Z&&Nn===e?Sn():(ce(new Set),fe([]),xe.current=[],U(!0),ie.current=!0,Hn(e),be.current=e,$(!0),_e.current=!0,te(!1),Le.current&&(Le.current.style.height="0px"),We.current&&(We.current.style.height="0px"),ze.current&&(ze.current.style.height="0px"),Pe.current&&(Pe.current.style.height="0px"),requestAnimationFrame(function(){var n,t,i,r,o=null,l=null,s=null;if("string"==typeof e)o=(null===(n=Jn.current[e])||void 0===n?void 0:n.current)||null,s=(l=(null===(t=Qn.current[e])||void 0===t?void 0:t.current)||null)?e:null;else{o=(null===(i=bn.current[e])||void 0===i?void 0:i.current)||null;var a=pn[e],c=(null==a?void 0:a.refIndexes)||[];if(c.length>0){var u=c[0],d=hn.findIndex(function(e){return e.selfIndex===u});-1!==d&&(l=(null===(r=Gn.current[d])||void 0===r?void 0:r.current)||null,s=d)}}Bn.current=s;var f=qe.current,v=He.current;if(!o||!f)return ie.current=!1,void U(!1);if(!l||!v)return te(!0),rt.current(),ie.current=!1,void U(!1);var p=o.getBoundingClientRect().top-f.getBoundingClientRect().top+f.scrollTop,h=l.getBoundingClientRect().top-v.getBoundingClientRect().top+v.scrollTop-(p-f.scrollTop);h<0&&Le.current&&(Le.current.style.height="".concat(Math.abs(h),"px"));requestAnimationFrame(function(){var e,n=v.scrollHeight-v.clientHeight;if(h<0)e=0;else{if(h>n){var t=h-n;return We.current&&(We.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){S(v,h,200,function(){te(!0),rt.current(),ie.current=!1,U(!1)})})}e=h}S(v,e,200,function(){te(!0),rt.current(),ie.current=!1,U(!1)})})})));Ue()},[Ue,ke.sectionIdx,Z,Nn,pn,hn,lt,Sn]),ct=null!==ke.sectionIdx&&ae.has(ke.sectionIdx),ut=function(t){var o,l,s,c=t.section,u=t.idx,d=t.columnKey,f=t.colRef,v=t.mb,p=void 0===v?1:v,g=t.parentNodeId,x=void 0===g?"":g,_=W?!!rn["".concat(d,"-").concat(u)]:!!rn[String(u)],b=(null===(o=c.displayTitle)||void 0===o||o)&&a.hasValue(c.title),y=(null===(l=c.displayContent)||void 0===l||l)&&a.hasValue(c.content),S=!b&&!y,R=c.title;b||(R=y?"No Title Found":"No Matching Section Found");var I,C=[];if(null===(s=c.evaluationResult)||void 0===s?void 0:s.deviations){var w=c.evaluationResult.deviations;for(var F in w){var j=w[F][x];j&&C.push(j)}}return n.jsx(i.Box,e.__assign({ref:f,sx:{mb:p,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:n.jsxs(i.Accordion,e.__assign({disableGutters:!0,expanded:!S&&_,onChange:function(){return!S&&function(n,t){var i,r;pe.current=!0,he.current&&clearTimeout(he.current),ve.current&&(ve.current.style.opacity="0");var o=null===(i=Yn.current[n])||void 0===i?void 0:i.current,l=null===(r=Kn.current[n])||void 0===r?void 0:r.current;if(o&&(o.style.minHeight="0px"),l&&(l.style.minHeight="0px"),Object.keys(Jn.current).forEach(function(e){var t,i;if(e.startsWith("".concat(n,"-"))){var r=null===(t=Jn.current[e])||void 0===t?void 0:t.current,o=null===(i=Qn.current[e])||void 0===i?void 0:i.current;r&&(r.style.minHeight="0px"),o&&(o.style.minHeight="0px")}}),W){var s=pn[n];((null==s?void 0:s.refIndexes)||[]).forEach(function(e){var n,t=hn.findIndex(function(n){return n.selfIndex===e}),i=null===(n=Kn.current[t])||void 0===n?void 0:n.current;i&&(i.style.minHeight="0px")});var a=hn[n],c=null==a?void 0:a.selfIndex;pn.forEach(function(e,n){var t,i;if(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(c)){var r=null===(i=Yn.current[n])||void 0===i?void 0:i.current;r&&(r.style.minHeight="0px")}})}he.current=setTimeout(function(){pe.current=!1,rt.current(),ve.current&&(ve.current.style.opacity="1")},650),on(function(i){var r=e.__assign({},i);if(!W){var o=!!i[String(n)];return r[String(n)]=!o,r}var l="".concat(t,"-").concat(n),s=!i[l];if(r[l]=s,"left"===t)((null==(a=pn[n])?void 0:a.refIndexes)||[]).forEach(function(e){var n=hn.findIndex(function(n){return n.selfIndex===e});-1!==n&&(r["right-".concat(n)]=s)});else{var a,c=null==(a=hn[n])?void 0:a.selfIndex;pn.forEach(function(e,n){var t;(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(c))&&(r["left-".concat(n)]=s)})}return r})}(u,d)},sx:{boxShadow:"none",border:S?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:S?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flexGrow:1,width:"100%",display:"flex",flexDirection:"column",minWidth:0,"&:before":{display:"none"}}},{children:[n.jsx(i.AccordionSummary,e.__assign({expandIcon:S?null:n.jsx(r.ChevronDown,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:S?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:b&&n.jsx(i.Tooltip,e.__assign({title:R,placement:"top"},{children:n.jsx(i.Typography,e.__assign({component:"div",sx:{fontSize:"12px",color:S?"#94A3B8":"#19213D",fontWeight:S?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(I=R,I?a.safeStringify(I).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(e,t){return e.startsWith("**")&&e.endsWith("**")?n.jsx("strong",{children:e.slice(2,-2)},t):n.jsx(h.default.Fragment,{children:e},t)}):null)}))}))})),!S&&n.jsxs(i.AccordionDetails,e.__assign({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[y&&n.jsx(m,{content:c.content,sxStyles:Be,highlights:C}),(c.subsections||[]).map(function(e,n){return dt({section:e,keyPath:"".concat(u,"-").concat(n),depth:0,columnKey:d,parentNodeId:x})})]}))]}))}),"".concat(d,"-sec-").concat(u))},dt=function(t){var o,l,s,c=t.section,u=t.keyPath,d=t.depth,f=void 0===d?0:d,v=t.columnKey,p=void 0===v?"left":v,g=t.parentNodeId,x=void 0===g?"":g,_=(null===(o=c.displayTitle)||void 0===o||o)&&a.hasValue(c.title),b=(null===(l=c.displayContent)||void 0===l||l)&&a.hasValue(c.content),y=!_&&!b,S=_?c.title:b?"No Title Found":"No Matching Section Found",R=!!sn[u];"left"!==p||Jn.current[u]||(Jn.current[u]=h.default.createRef()),"right"!==p||Qn.current[u]||(Qn.current[u]=h.default.createRef());var I="left"===p?Jn.current[u]:Qn.current[u];Un.current[u]||(Un.current[u]=h.default.createRef()),Xn.current[u]||(Xn.current[u]=h.default.createRef());for(var C=u.split("-").map(function(e){return Number(e)+1}).join("."),w=nt(u),F=W&&ae.has(u),j=u.split("-").map(Number),B=pn[j[0]],E=hn[j[0]],T=1;T<j.length;T++)(null==B?void 0:B.subsections)&&(B=B.subsections[j[T]]),(null==E?void 0:E.subsections)&&(E=E.subsections[j[T]]);var D=!(null===(s=c.refIndexes)||void 0===s?void 0:s.length)||void 0!==c.selfIndex&&c.selfIndex<0,A="left"===p&&D,k="right"===p&&D;return _?n.jsxs(i.Box,e.__assign({ref:I,sx:{mt:1,width:"100%",minWidth:0,position:"relative"}},{children:[n.jsx(i.Box,e.__assign({sx:e.__assign({width:"100%"},F&&w&&{borderRadius:"4px",outline:"2px solid ".concat(w.badgeBorder),outlineOffset:"1px"})},{children:n.jsxs(i.Accordion,e.__assign({disableGutters:!0,expanded:!y&&R,onChange:function(){return!y&&an(function(n){var t;return e.__assign(e.__assign({},n),((t={})[u]=!n[u],t))})},sx:{mt:0,boxShadow:"none",border:y?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF",minWidth:0,"&:before":{display:"none"}}},{children:[n.jsx(i.AccordionSummary,e.__assign({expandIcon:y?null:n.jsx(r.ChevronDown,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"}}},{children:n.jsx(i.Typography,e.__assign({component:"div",sx:{fontSize:"11px",fontWeight:600,color:y?"#94A3B8":"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:S||"Untitled Subsection"}))})),!y&&n.jsxs(i.AccordionDetails,e.__assign({sx:{pt:0,pb:1,minWidth:0}},{children:[b&&n.jsx(m,{content:c.content,sxStyles:Be,highlights:function(){var e,n;if(!(null===(e=c.evaluationResult)||void 0===e?void 0:e.deviations))return[];var t=(null===(n=c.evaluationResult)||void 0===n?void 0:n.deviations)||{},i=[];for(var r in t){var o=t[r][x];o&&i.push(o)}return i}()}),(c.subsections||[]).map(function(e,n){return dt({section:e,keyPath:"".concat(u,"-").concat(n),depth:f+1,columnKey:p,parentNodeId:x})})]}))]}))})),W&&"left"===p&&w&&!y&&n.jsxs(i.Box,e.__assign({ref:Un.current[u],onClick:function(e){e.stopPropagation();for(var n=u.split("-").map(Number),t=pn[n[0]],i=hn[n[0]],r=1;r<n.length;r++)(null==t?void 0:t.subsections)&&(t=t.subsections[n[r]]),(null==i?void 0:i.subsections)&&(i=i.subsections[n[r]]);Cn(e,t||{title:"",content:""},A||k,i||{title:"",content:""},u,w)},sx:{position:"absolute",top:"16px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"10px",bgcolor:w.badgeBg,color:w.badgeText,border:"1px solid ".concat(w.badgeBorder),borderRadius:"12px",px:1,py:.3,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"10px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(w.badgeBorder)}},{children:C})),n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"10px",px:.25}},{children:A?"No Deviation Found":0==w.deviationLabel||void 0===w.deviationLabel?w.label:"".concat(w.deviationLabel,"% Deviation")})),n.jsx(r.EllipsisVertical,{size:10,color:w.badgeText})]})),W&&"right"===p&&w&&!y&&!K&&n.jsx(i.Box,e.__assign({ref:Xn.current[u],sx:{position:"absolute",top:"16px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"10px",bgcolor:"#EEF2FF",color:"#3730A3",border:"1px solid #C7D2FE",borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:k?"-":C}))]}),u):n.jsxs(i.Box,e.__assign({ref:I,sx:{mt:0===f?1:.75,width:"100%",minWidth:0,position:"relative"}},{children:[!y&&n.jsxs(i.Box,e.__assign({sx:e.__assign({width:"100%"},F&&w&&{borderRadius:"4px",outline:"2px solid ".concat(w.badgeBorder),outlineOffset:"1px"})},{children:[b&&n.jsx(m,{content:c.content,sxStyles:Be,highlights:function(){var e,n;if(!(null===(e=c.evaluationResult)||void 0===e?void 0:e.deviations))return[];var t=(null===(n=c.evaluationResult)||void 0===n?void 0:n.deviations)||{},i=[];for(var r in t){var o=t[r][x];o&&i.push(o)}return i}()}),(c.subsections||[]).map(function(e,n){return dt({section:e,keyPath:"".concat(u,"-").concat(n),depth:f+1,columnKey:p,parentNodeId:x})})]})),W&&"left"===p&&w&&!y&&n.jsxs(i.Box,e.__assign({ref:Un.current[u],onClick:function(e){var n;e.stopPropagation();var t=function(e,n){for(var i=0,r=e;i<r.length;i++){var o=r[i];if(o.selfIndex===n)return o;if(o.subsections){var l=t(o.subsections,n);if(l)return l}}return null},i=null===(n=c.refIndexes)||void 0===n?void 0:n[0],r="number"==typeof i?t(hn,i):null;Cn(e,c,D,r||{title:"",content:""},u,w)},sx:{position:"absolute",top:"16px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"10px",bgcolor:w.badgeBg,color:w.badgeText,border:"1px solid ".concat(w.badgeBorder),borderRadius:"12px",px:1,py:.3,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"10px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(w.badgeBorder)}},{children:C})),n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"10px",px:.25}},{children:A?"No Deviation Found":0==w.deviationLabel||void 0===w.deviationLabel?w.label:"".concat(w.deviationLabel,"% Deviation")})),n.jsx(r.EllipsisVertical,{size:10,color:w.badgeText})]})),W&&"right"===p&&w&&!y&&!K&&n.jsx(i.Box,e.__assign({ref:Xn.current[u],sx:{position:"absolute",top:"16px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"10px",bgcolor:"#EEF2FF",color:"#3730A3",border:"1px solid #C7D2FE",borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:k?"-":C}))]}),u)};return n.jsxs(i.Box,e.__assign({ref:Ne,sx:e.__assign(e.__assign({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},W?{}:{overflow:"visible"}),{position:"relative"})},{children:[q&&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(f.default,{})})),W&&n.jsx(d.default,{open:ke.open,anchorEl:ke.anchorEl,sectionTitle:ke.sectionTitle,referenceSectionTitle:ke.refSectionTitle,onClose:Ue,onOpenCognitiveCompare:wn,onOpenSideBySide:at,onConnect:Fn,isConnected:ct}),Te.open&&n.jsx(u.default,{open:Te.open,popupRef:Ce,position:Re,popupConfig:O,onClose:function(){Ie(null),De(function(n){return e.__assign(e.__assign({},n),{open:!1})}),le(null)},markdownStyles:A,sectionTitle:Te.sectionTitle,referenceSectionTitle:Te.refSectionTitle,cognitiveData:Te.cognitiveData,anchorEl:Te.anchorEl,sectionAnchorEl:Te.sectionAnchorEl,scrollContainerEl:Oe.current,badgeStyle:Te.badgeStyle,docData:Te.docData,deviationData:Te.deviationData}),n.jsx(i.Snackbar,e.__assign({open:!!G,autoHideDuration:8e3,onClose:function(){return J(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(i.Alert,e.__assign({onClose:function(){return J(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:G}))})),(M.isHeaderVisible||M.isToggleVisible)&&n.jsxs(i.Box,e.__assign({sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between",bgcolor:"#FFFFFF",border:"1.5px solid #EEF0F4",borderTopLeftRadius:"8px",borderTopRightRadius:"8px"}},{children:[n.jsx(i.Box,e.__assign({sx:{display:"flex",alignItems:"center",gap:1}},{children:M.isHeaderVisible&&n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:600,color:"#0F172A"}},{children:j}))})),M.isToggleVisible&&n.jsx(i.Box,e.__assign({sx:{display:"flex",alignItems:"center"}},{children:n.jsx(i.FormControlLabel,{control:n.jsx(i.Switch,{checked:W,onChange:function(e){var n=e.target.checked;V(!0),setTimeout(function(){z(n),Sn(),ce(new Set),fe([]),xe.current=[],setTimeout(function(){V(!1)},400)},50)},color:"primary",size:"small",sx:{width:100,height:26,padding:0,"& .MuiSwitch-switchBase":{padding:0,margin:"3px",transitionDuration:"300ms","&.Mui-checked":{transform:"translateX(75px)",color:"#fff","& + .MuiSwitch-track":{backgroundColor:"#5928ED",opacity:1,border:0,"&::before":{content:'"Side by Side"',position:"absolute",left:"13px",top:"50%",transform:"translateY(-50%)",fontSize:"9px",fontWeight:700,color:"#fff",letterSpacing:"0.3px"}}}},"& .MuiSwitch-thumb":{boxSizing:"border-box",width:20,height:20},"& .MuiSwitch-track":{borderRadius:13,backgroundColor:"#9e9e9e",opacity:1,position:"relative","&::after":{content:'"Side by Side"',position:"absolute",right:"13px",top:"50%",transform:"translateY(-50%)",fontSize:"9px",fontWeight:700,color:"#fff",letterSpacing:"0.3px",opacity:1,transition:"opacity 0.2s"}},"& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track":{"&::after":{opacity:0}}}}),label:"",labelPlacement:"start",sx:{m:0,gap:1}})}))]})),n.jsx(i.Box,e.__assign({ref:Oe,onScroll:st,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:W?"hidden":"auto",borderTop:mn&&_n?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(i.Box,e.__assign({sx:e.__assign({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},W?{flex:1,minHeight:0}:{})},{children:n.jsxs(i.Box,e.__assign({ref:jn,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"10px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},W?{flex:1,overflow:"visible"}:{})},{children:[n.jsxs("svg",e.__assign({ref:ve,style:{position:"absolute",top:0,left:0,width:Fe.width||"100%",height:Fe.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",transition:"opacity 0.15s ease-in-out"}},{children:[Wn&&n.jsxs("g",{children:[n.jsx("line",{x1:Wn.x1,y1:Wn.y,x2:Math.max(Wn.x1,(Wn.x1+Wn.x2)/2-70),y2:Wn.y,stroke:"#BBF7D0",strokeWidth:"1.5"}),n.jsx("line",{x1:Math.min(Wn.x2,(Wn.x1+Wn.x2)/2+70),y1:Wn.y,x2:Wn.x2,y2:Wn.y,stroke:"#BBF7D0",strokeWidth:"1.5"})]}),kn.map(function(t){var l,s=(t.x1+t.x2)/2;if("Not Defined"===t.style.label&&!t.hasCognitive)return null;if(!W)return n.jsxs("g",{children:[n.jsx("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),n.jsx("foreignObject",e.__assign({x:s-100,y:t.y1-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){if(e.stopPropagation(),Te.open&&oe===t.id)Ke();else{var n=pn[t.sectionIdx]||{title:"",content:""},i=hn[t.sectionIdx]||{title:"",content:""};if(t.isSubSection&&t.subSectionKeyPath){for(var r=t.subSectionKeyPath.split("-").map(Number),o=pn[r[0]],l=hn[r[0]],s=1;s<r.length;s++)(null==o?void 0:o.subsections)&&(o=o.subsections[r[s]]),(null==l?void 0:l.subsections)&&(l=l.subsections[r[s]]);o&&(n=o),l&&(i=l)}le(t.id),In(Rn(e.currentTarget,n,i,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:500,textAlign:"center",whiteSpace:"nowrap",cursor:"pointer"}},{children:[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(o.ButtonCognitiveIcon,{})})),n.jsx(r.ChevronDown,{size:11,style:{transform:Te.open&&oe===t.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},t.id);var a=!1;if(t.isSubSection)a=Z&&Nn===t.subSectionKeyPath&&ne;else{var c=pn[t.sectionIdx];if(!(null===(l=null==c?void 0:c.refIndexes)||void 0===l?void 0:l.length)||(null==c?void 0:c.selfIndex)<0)return null;a=Z&&Nn===t.sectionIdx&&ne}return a?n.jsxs("g",e.__assign({style:{transition:"opacity 0.2s"}},{children:[n.jsx("defs",{children:n.jsx("marker",e.__assign({id:"arr-".concat(t.id),markerWidth:"7",markerHeight:"5",refX:"7",refY:"2.5",orient:"auto"},{children:n.jsx("polygon",{points:"0 0, 7 2.5, 0 5",fill:t.style.badgeBorder||"#6366F1"})}))}),n.jsx("line",{ref:En,x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.badgeBorder||"#6366F1",strokeWidth:"1.5",markerEnd:"url(#arr-".concat(t.id,")")})]}),t.id):null}),de.map(function(t){var i,r=t.pathD,o=(null===(i=t.style)||void 0===i?void 0:i.badgeBorder)||"#6366F1",l="conn-marker-".concat(t.id),s="".concat(t.id,"-bg"),a="".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:o})}))}))}),n.jsx("path",{ref:function(e){ge.current[s]=e},d:r,fill:"none",stroke:"#FFFFFF",strokeWidth:"4",strokeOpacity:"0.7"}),n.jsx("path",{ref:function(e){ge.current[a]=e},d:r,fill:"none",stroke:o,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)"},W?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(i.Box,e.__assign({ref:Tn,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",minHeight:"40px",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:"#19213D",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",height:"40px"}},{children:fn}))}))})),n.jsxs(i.Box,e.__assign({ref:qe,onScroll:st,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},W?{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:ze,style:{width:"100%",height:"0px",flexShrink:0}}),gn&&pn.map(function(t,o){var l,s,a,c=!t.title&&!t.content;if(W&&c)return null;if(!W)return n.jsx(i.Box,e.__assign({ref:yn(o)},{children:ut({section:t,idx:o,columnKey:"left",colRef:Yn.current[o],parentNodeId:(null===(l=null==B?void 0:B.input_index_map)||void 0===l?void 0:l[0])||""})}),"left-row-".concat(o));var u=t,d=et(o),f=!(null===(s=u.refIndexes)||void 0===s?void 0:s.length)||u.selfIndex<0,v="number"==typeof u.selfIndex&&u.selfIndex>=0?u.selfIndex+1:null,p=ae.has(o);return n.jsx(i.Box,e.__assign({ref:yn(o),sx:{mb:1}},{children:n.jsxs(i.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[n.jsx(i.Box,e.__assign({ref:Yn.current[o],sx:e.__assign({width:"100%",display:"flex"},p&&{borderRadius:"6px",outline:"2px solid ".concat((null==d?void 0:d.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:ut({section:t,idx:o,columnKey:"left",colRef:h.default.createRef(),mb:0,parentNodeId:(null===(a=null==B?void 0:B.input_index_map)||void 0===a?void 0:a[0])||""})})),d&&n.jsxs(i.Box,e.__assign({ref:Un.current[o],onClick:function(e){var n=hn.find(function(e){var n;return null===(n=u.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""};Cn(e,t,f,n,o,d)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:d.badgeBg,color:d.badgeText,border:"1px solid ".concat(d.badgeBorder),borderRadius:"12px",px:1.2,py:.4,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[null!==v&&n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(d.badgeBorder)}},{children:v})),n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",px:.25}},{children:f?"No Deviation Found":0==d.deviationLabel||void 0===d.deviationLabel?d.label:"".concat(d.deviationLabel,"% Deviation")})),n.jsx(r.EllipsisVertical,{size:11,color:d.badgeText})]}))]}))}),"left-row-".concat(o))}),n.jsx("div",{ref:Pe,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),n.jsx(i.Box,e.__assign({sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0}},{children:n.jsx(i.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:n.jsxs(i.Box,e.__assign({sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",borderRadius:"20px",bgcolor:"#ECFDF3",border:"1px solid #A7F3D0",color:"#15803D",fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1}},{children:[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(o.ButtonCognitiveIcon,{})})),0,"% Similarity",n.jsx(r.ChevronDown,{size:11})]}))}))})),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},W?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[K&&n.jsx(l.default,{sections:11}),n.jsx(i.Box,e.__assign({ref:Dn,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:vn,placement:"top"},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",height:"40px"}},{children:vn}))}))})),n.jsxs(i.Box,e.__assign({ref:He,onScroll:st,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},W?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-20px",pl:"40px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:Le,style:{width:"100%",height:"0px",flexShrink:0}}),gn&&hn.map(function(t,r){var o,l;if(!W)return ut({section:t,idx:r,columnKey:"right",colRef:Kn.current[r],parentNodeId:(null===(o=null==B?void 0:B.input_index_map)||void 0===o?void 0:o[1])||""});var s=t,a=pn.filter(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(s.selfIndex))&&e.selfIndex>=0}).map(function(e){return e.selfIndex+1}),c=pn.some(function(e,n){var t;return ae.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(s.selfIndex))}),u=pn.findIndex(function(e,n){var t;return ae.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(s.selfIndex))}),d=-1!==u?et(u):null;return n.jsx(i.Box,e.__assign({ref:Gn.current[r],sx:{mb:1}},{children:n.jsxs(i.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[n.jsx(i.Box,e.__assign({ref:Kn.current[r],sx:e.__assign({width:"100%",display:"flex"},c&&d&&{borderRadius:"6px",outline:"2px solid ".concat(d.badgeBorder),outlineOffset:"1px"})},{children:ut({section:t,idx:r,columnKey:"right",colRef:h.default.createRef(),mb:0,parentNodeId:(null===(l=null==B?void 0:B.input_index_map)||void 0===l?void 0:l[1])||""})})),!K&&n.jsx(i.Box,e.__assign({ref:Xn.current[r],sx:{position:"absolute",top:"18px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"11px",bgcolor:"#EEF2FF",color:"#3730A3",border:"1px solid #C7D2FE",borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:a.length>0?a.join(", "):"-"}))]}))}),"right-row-".concat(r))}),n.jsx("div",{ref:We,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 i=require("tslib"),n=function(i){return null==i?"":"string"==typeof i?i:Array.isArray(i)?i.map(n).join("\n\n"):"object"==typeof i?JSON.stringify(i):String(i)},e=function(i){return null!=i&&("string"==typeof i?i.trim().length>0:!Array.isArray(i)||i.length>0&&i.some(function(i){return e(i)}))},t=function(i){return i&&"string"==typeof i?"N/A"===i.toUpperCase()?"N/A":i.split("_").map(function(i){return i.charAt(0).toUpperCase()+i.slice(1).toLowerCase()}).join(" "):"Unknown"};exports.cognitiveScoreToRelation=function(i){return{score:0,relation:"N/A"}},exports.formatRelationToLabel=t,exports.getRationale=function(i){if(!i.mapping_rationale)return{cognitiveData:{decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0,citations:[]},score:0,relation:"N/A"};var n=i.mapping_rationale,e=parseInt(n.decision_strength||"0");return{cognitiveData:{decisioning:n.decisioning_factors||[],gap:n.gaps_in_decision||[],relevance_score:e,citations:n.citations},score:0,relation:"N/A"}},exports.getSideData=function(i,e,t){var s,o=t[e],r=null===(s=null==i?void 0:i.comparison_inputs)||void 0===s?void 0:s[o];return{title:n((null==r?void 0:r.title)||""),content:n((null==r?void 0:r.content)||""),attributes:(null==r?void 0:r.additional_attributes)||null,subsections:(null==r?void 0:r.subsections)||[]}},exports.getStyleForRelation=function(n,e,s,o){var r=100*(n||0),a=o.thresholds,l=o.relationStyles;if(!s)return null;var c=t(e),u=(e||"").toLowerCase();return"n/a"===u||u.includes("no_deviation")?i.__assign(i.__assign({},l.low),{label:c}):u.includes("deviation")||u.includes("high_risk")||u.includes("critical")?i.__assign(i.__assign({},l.high),{label:c}):r>=a.exact?i.__assign(i.__assign({},l.exact),{label:c}):r>=a.high?i.__assign(i.__assign({},l.high),{label:c}):r>=a.medium?i.__assign(i.__assign({},l.medium),{label:c}):i.__assign(i.__assign({},l.low),{label:c})},exports.hasValue=e,exports.safeStringify=n;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=function(i){return null==i?"":"string"==typeof i?i:Array.isArray(i)?i.map(t).join("\n\n"):"object"==typeof i?JSON.stringify(i):String(i)},i=function(t){return null!=t&&("string"==typeof t?t.trim().length>0:!Array.isArray(t)||t.length>0&&t.some(function(t){return i(t)}))};exports.getRationale=function(t){if(!t.mapping_rationale)return{cognitiveData:{decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0,citations:[]},score:0,relation:"N/A"};var i=t.mapping_rationale,n=parseInt(i.decision_strength||"0");return{cognitiveData:{decisioning:i.decisioning_factors||[],gap:i.gaps_in_decision||[],relevance_score:n,citations:i.citations},score:0,relation:"N/A"}},exports.getSideData=function(i,n,e){var o,r=e[n],a=null===(o=null==i?void 0:i.comparison_inputs)||void 0===o?void 0:o[r];return{title:t((null==a?void 0:a.title)||""),content:t((null==a?void 0:a.content)||""),attributes:(null==a?void 0:a.additional_attributes)||null,subsections:(null==a?void 0:a.subsections)||[]}},exports.hasValue=i,exports.safeStringify=t;
2
2
  //# sourceMappingURL=CognitiveComparehelpers.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e,__spreadArray as n}from"tslib";import{jsx as t,jsxs as i}from"react/jsx-runtime";import r,{useMemo as o,useState as l,useRef as c,useEffect as a,useCallback as u}from"react";import{Typography as d,Box as s,Snackbar as v,Alert as f,FormControlLabel as p,Switch as h,Tooltip as g,Accordion as x,AccordionSummary as m,AccordionDetails as b}from"@mui/material";import{ChevronDown as y,EllipsisVertical as S}from"lucide-react";import{ButtonCognitiveIcon as I}from"../../assests/svg/ButtonCognitiveIcon.js";import w from"./OverlayComponent.js";import R from"react-markdown";import{safeStringify as F,hasValue as C,getStyleForRelation as E,cognitiveScoreToRelation as B,getSideData as T,getRationale as _}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as k,DEFAULT_FIELD_CONFIG as D,DEFAULT_COMPARISON_CONFIG as M}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import A from"./CognitivePopup.js";import H from"./MoreFunctionsPopup.js";import z from"./LoaderComponent.js";import W from"rehype-raw";var N=r.memo(function(n){var i=n.content,r=n.sxStyles,l=n.highlights,c=void 0===l?[]:l,a=o(function(){return{mark:function(n){var i=n.children;return t("span",e({style:{backgroundColor:"#fccccc"}},{children:i}))}}},[]),u=o(function(){var e=i;return c.forEach(function(n){e=e.replaceAll(n,"<mark>".concat(n,"</mark>"))}),e},[i,c]);return t(d,e({component:"div",sx:r},{children:t(R,e({components:a,rehypePlugins:[W]},{children:F(u).replace(/\\n/g,"\n")}))}))},function(e,n){if(e.content!==n.content)return!1;if(e.sxStyles!==n.sxStyles)return!1;var t=e.highlights||[],i=n.highlights||[];if(t.length!==i.length)return!1;for(var r=0;r<t.length;r++)if(t[r]!==i[r])return!1;return!0}),L=function(e,n,t,i,r){void 0===r&&(r=14);var o=e+.65*(t-e),l=i-n;if(Math.abs(l)<3)return"M ".concat(e," ").concat(n," H ").concat(t);var c=l>0?1:-1,a=Math.min(r,Math.abs(l)/2,Math.abs(o-e)/2,Math.abs(t-o)/2);return["M ".concat(e," ").concat(n),"H ".concat(o-a),"Q ".concat(o," ").concat(n," ").concat(o," ").concat(n+c*a),"V ".concat(i-c*a),"Q ".concat(o," ").concat(i," ").concat(o+a," ").concat(i),"H ".concat(t)].join(" ")},O={id:"",title:""},j={open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,isOrphan:!1,docData:null,deviationData:null},P=function(e,n,t,i,r){void 0===t&&(t=300);var o=e.style.scrollBehavior;e.style.scrollBehavior="auto";var l=e.scrollTop,c=n-l,a=null,u=function(d){null===a&&(a=d);var s,v=d-a;v<t?(e.scrollTop=(s=v,s/=t,c*(--s*s*s+1)+l),r&&r(),requestAnimationFrame(u)):(e.scrollTop=n,e.style.scrollBehavior=o,r&&r(),i&&i())};requestAnimationFrame(u)},Y=function(R){var W,Y,K,V,X,q,U,G,J=R.componentHeaderText,Q=void 0===J?"Contract Comparison":J,Z=R.treeData,$=R.comparisonConfig,ee=R.leftColumnTitleText,ne=R.rightColumnTitleText,te=R.markdownStyles,ie=R.displayConfig,re=void 0===ie?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1}:ie,oe=R.popupConfig,le=R.deviationData,ce=void 0===le?{}:le,ae=l(re.maintainRelativeOrder),ue=ae[0],de=ae[1],se=l(!1),ve=se[0],fe=se[1],pe=l(!1),he=pe[0],ge=pe[1],xe=l(null),me=xe[0],be=xe[1],ye=l(!1),Se=ye[0],Ie=ye[1],we=l(!1),Re=we[0],Fe=we[1],Ce=c(!1),Ee=l(null),Be=Ee[0],Te=Ee[1],_e=l(new Set),ke=_e[0],De=_e[1],Me=l([]),Ae=Me[0],He=Me[1],ze=c(null),We=c(!1),Ne=c(null),Le=c({}),Oe=c([]),je=c(!1),Pe=c(!1),Ye=c(null),Ke=o(function(){return(null==Z?void 0:Z.cognitive_decisioning)||{}},[Z]),Ve=l(null),Xe=Ve[0],qe=Ve[1],Ue=c(null),Ge=l({width:0,height:0}),Je=Ge[0],Qe=Ge[1],Ze=o(function(){return e(e({},k),te)},[te]),$e=l({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,isOrphan:!1,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null,deviationData:null}),en=$e[0],nn=$e[1],tn=l({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,isOrphan:!1,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null,deviationData:null}),rn=tn[0],on=tn[1],ln=c(null),cn=c(null),an=c(null),un=c(null),dn=c(null),sn=c(null),vn=c(null),fn=c(null),pn=c(!1),hn=c(null);a(function(){hn.current=null},[en.sectionIdx,en.open]);var gn=u(function(){qe(null),nn(j),Te(null)},[]),xn=u(function(){on(j)},[]),mn=u(function(){var e;if(en.anchorEl&&en.refSectionTitle){var n=en.anchorEl.getBoundingClientRect(),t=(null===(e=null==Ue?void 0:Ue.current)||void 0===e?void 0:e.offsetHeight)||0,i=Math.min(680,window.innerWidth-24),r=window.innerHeight-n.bottom-12-12,o=n.top-12-12,l=r<t&&o>r;null!==hn.current?!0===hn.current&&(l=o>=t||o>=r):l=!(r>=t||r>=o),hn.current=l;var c=l?o:r,a=Math.min(t||9999,c),u=l?n.top-12-a:n.bottom+12,d=n.left+n.width/2,s=d-i/2,v=Math.max(12,Math.min(s,window.innerWidth-i-12)),f=Math.max(14,Math.min(d-v,i-10-4));qe({top:u,left:v,arrowLeft:f,openAbove:l,maxHeight:c})}},[en.anchorEl,en.refSectionTitle]);a(function(){if(en.open){window.addEventListener("resize",mn);var e=requestAnimationFrame(mn),n=null;return Ue.current&&(n=new ResizeObserver(function(){cancelAnimationFrame(e),e=requestAnimationFrame(mn)})).observe(Ue.current),function(){cancelAnimationFrame(e),window.removeEventListener("resize",mn),n&&n.disconnect()}}},[en.open,mn]),a(function(){var e=ln.current;if(e&&en.open){var n=function(e){Ue.current&&Ue.current.contains(e.target)||(qe(null),gn())};return e.addEventListener("scroll",n,{capture:!0}),window.addEventListener("scroll",n,{capture:!0}),function(){e.removeEventListener("scroll",n,{capture:!0}),window.removeEventListener("scroll",n,{capture:!0})}}},[en.open,gn]),a(function(){var e=ln.current;if(e&&rn.open){var n=function(){xn()};return e.addEventListener("scroll",n,{capture:!0}),window.addEventListener("scroll",n,{capture:!0}),function(){e.removeEventListener("scroll",n,{capture:!0}),window.removeEventListener("scroll",n,{capture:!0})}}},[rn.open,xn]);var bn=o(function(){var n,t,i,r,o,l,c,a,u,d,s,v;return{fields:null!==(n=null==$?void 0:$.fields)&&void 0!==n?n:D,thresholds:{high:null!==(i=null===(t=null==$?void 0:$.thresholds)||void 0===t?void 0:t.high)&&void 0!==i?i:M.thresholds.high,medium:null!==(o=null===(r=null==$?void 0:$.thresholds)||void 0===r?void 0:r.medium)&&void 0!==o?o:M.thresholds.medium,exact:null!==(c=null===(l=null==$?void 0:$.thresholds)||void 0===l?void 0:l.exact)&&void 0!==c?c:M.thresholds.exact},relationStyles:{noContent:e(e({},M.relationStyles.noContent),(null===(a=null==$?void 0:$.relationStyles)||void 0===a?void 0:a.noContent)||{}),high:e(e({},M.relationStyles.high),(null===(u=null==$?void 0:$.relationStyles)||void 0===u?void 0:u.high)||{}),exact:e(e({},M.relationStyles.exact),(null===(d=null==$?void 0:$.relationStyles)||void 0===d?void 0:d.exact)||{}),medium:e(e({},M.relationStyles.medium),(null===(s=null==$?void 0:$.relationStyles)||void 0===s?void 0:s.medium)||{}),low:e(e({},M.relationStyles.low),(null===(v=null==$?void 0:$.relationStyles)||void 0===v?void 0:v.low)||{})}}},[$]),yn=o(function(){if(Z&&Object.keys(Z).length>0)try{var t=function(t,i,r){var o,l,c,a;void 0===i&&(i=!1),void 0===r&&(r=null);var u=t.nodes||t,d=[],s=[],v=t.base_root_id,f=t.input_index_map||{0:"left",1:"right"},p=t[v]||u[v];if(!p||!1===p.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[]};var h=function(n,i){var o,l=t[n]||u[n];if(!l||!1===l.display_node)return null;var c=T(l,i,f),a=!!c.title.trim(),d=!!c.content.trim(),s=_(l),v=(null===(o=null==r?void 0:r[n])||void 0===o?void 0:o.evaluation_result)||l.evaluation_result||null,p=[];l.next&&Object.values(l.next).forEach(function(e){var n=u[e];if(n&&!1!==n.display_node){var t=h(e,i);t&&p.push(t)}});var g=!(!a&&!d);return e(e({id:n,title:a?c.title:"",content:d?c.content:"",subsections:p},g?s:{score:void 0,relation:"not_defined"}),{evaluationResult:v})};if(i){var g=function(i,o){var l,c,a,d,s,v,p,h,x,m,b,y,S;void 0===o&&(o=0);var I=[],w=[];if(!i)return{refSections:I,baseSections:w};var R={},F={},C=-1,E=-1;for(var B in i){var k=i[B],D=t[k]||u[k];if(D&&!1!==D.display_node){var M=_(D),A=(null===(l=null==r?void 0:r[k])||void 0===l?void 0:l.evaluation_result)||D.evaluation_result||null,H=T(D,"1",f),z=T(D,"0",f),W=H.title.trim()||H.content.trim(),N=z.title.trim()||z.content.trim(),L=Number(null!==(a=null===(c=H.attributes)||void 0===c?void 0:c.display_index)&&void 0!==a?a:C--),O=Number(null!==(s=null===(d=z.attributes)||void 0===d?void 0:d.display_index)&&void 0!==s?s:E--),j=R[L]||e(e({id:k,title:W?H.title:"",content:W?H.content:"",subsections:[]},W?M:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:L,evaluationResult:A,displayContent:null===(v=H.attributes)||void 0===v?void 0:v.display_content,displayTitle:null===(p=H.attributes)||void 0===p?void 0:p.display_title}),P=F[O]||e(e({id:k,title:N?z.title:"",content:N?z.content:"",subsections:[]},N?M:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:O,evaluationResult:A,displayContent:null===(h=z.attributes)||void 0===h?void 0:h.display_content,displayTitle:null===(x=z.attributes)||void 0===x?void 0:x.display_title});Number(L)>=0&&Number(O)>=0&&((null===(m=j.refIndexes)||void 0===m?void 0:m.includes(Number(O)))||null===(b=j.refIndexes)||void 0===b||b.push(Number(O)),(null===(y=P.refIndexes)||void 0===y?void 0:y.includes(Number(L)))||null===(S=P.refIndexes)||void 0===S||S.push(Number(L))),R[L]=j,F[O]=P;var Y=g(D.next,o+1),K=Y.refSections,V=Y.baseSections;K.length>0&&(j.subsections=n(n([],j.subsections||[],!0),K,!0)),V.length>0&&(P.subsections=n(n([],P.subsections||[],!0),V,!0))}}return I=Object.values(R).map(function(e){return e}),w=Object.values(F).map(function(e){return e}),I.sort(function(e,n){return e.selfIndex<0&&n.selfIndex>=0?1:e.selfIndex>=0&&n.selfIndex<0?-1:e.selfIndex-n.selfIndex}),w.sort(function(e,n){return e.selfIndex<0&&n.selfIndex>=0?1:e.selfIndex>=0&&n.selfIndex<0?-1:e.selfIndex-n.selfIndex}),{refSections:I,baseSections:w}},x=g(p.next),m=x.refSections,b=x.baseSections;s=m,d=b}else p.next&&Object.values(p.next).forEach(function(e){var n=t[e]||u[e];n&&!1!==n.display_node&&(d.push(h(e,"0")||{id:e,title:"",content:"",subsections:[]}),s.push(h(e,"1")||{id:e,title:"",content:"",subsections:[]}))});return{activeProposed:{title:(null===(l=null===(o=p.comparison_inputs)||void 0===o?void 0:o[f[0]])||void 0===l?void 0:l.title)||"Uploaded Contract",description:p.decision_scope_description||"",sections:d},activeVariants:[{id:"tree-variant-1",title:(null===(a=null===(c=p.comparison_inputs)||void 0===c?void 0:c[f[1]])||void 0===a?void 0:a.title)||"Reference Template",similarity:0,sections:s,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:p.decision_scope_description||""},fields:{}}}}]}}(Z,ue,ce);return e(e({},t),{parseError:null})}catch(e){return console.error("Data Transformation Error: ",e),{activeProposed:{},activeVariants:[],parseError:e instanceof Error?e.message:"Unknown Parsing Error"}}return{activeProposed:{},activeVariants:[],parseError:"Tree data is required"}},[JSON.stringify(Z),ue,JSON.stringify(ce)]),Sn=yn.activeProposed,In=yn.activeVariants,wn=yn.parseError;a(function(){wn&&be("Failed to load comparison: ".concat(wn))},[wn]);var Rn=l(null),Fn=Rn[0];Rn[1];var Cn=l({}),En=Cn[0],Bn=Cn[1],Tn=l({}),_n=Tn[0],kn=Tn[1],Dn=(null==In?void 0:In[0])||O,Mn=null===(K=null===(W=null==Z?void 0:Z.documents)||void 0===W?void 0:W[null===(Y=null==Z?void 0:Z.input_index_map)||void 0===Y?void 0:Y[0]])||void 0===K?void 0:K.title,An=null===(q=null===(V=null==Z?void 0:Z.documents)||void 0===V?void 0:V[null===(X=null==Z?void 0:Z.input_index_map)||void 0===X?void 0:X[1]])||void 0===q?void 0:q.title,Hn=F(ee||Mn||"Uploaded Contract"),zn=F(ne||An||"Reference Template"),Wn=o(function(){return(null==Sn?void 0:Sn.sections)||[]},[null==Sn?void 0:Sn.sections]),Nn=o(function(){return Dn.sections||[]},[Dn.sections]),Ln=Wn.length>0||Nn.length>0,On=Dn.analysis,jn=F(null===(G=null===(U=null==On?void 0:On.rule_difference_comparison)||void 0===U?void 0:U.summary)||void 0===G?void 0:G.overall_summary),Pn=!!jn.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),Yn=c({}),Kn=function(e){return Yn.current[e]||(Yn.current[e]=r.createRef()),Yn.current[e]},Vn=u(function(){Ie(!1),Pe.current=!1,ct(null),Ye.current=null,Zn.current=null,Fe(!1),ge(!1),un.current&&(un.current.style.height="0px"),dn.current&&(dn.current.style.height="0px"),sn.current&&(sn.current.style.height="0px"),vn.current&&(vn.current.style.height="0px")},[]),Xn=u(function(e,n,t,i,r,o){var l,c,a=F(n.id)||F(t.id)||"",u=(a?Ke[a]:null)||n.cognitiveData||t.cognitiveData||{section_id:a,decisioning:[],gap:[],relevance_score:0},d=null!==(c=null===(l=Yn.current[i])||void 0===l?void 0:l.current)&&void 0!==c?c:null;return{open:!0,sectionTitle:n.title||"N/A",refSectionTitle:t.title||"NA",cognitiveData:u,anchorEl:e,sectionAnchorEl:d,badgeStyle:o||null,sectionIdx:i,docData:{documents:null==Z?void 0:Z.documents,input_index_map:null==Z?void 0:Z.input_index_map},deviationData:n.evaluationResult||t.evaluationResult||null,isOrphan:!!r}},[Ke,Z]),qn=u(function(e){xn(),qe(null),nn(e)},[xn]),Un=function(e,n,t,i,r,o){e.stopPropagation(),rn.open&&rn.sectionIdx===r?xn():(gn(),on(Xn(e.currentTarget,n,i,r,t,o)))},Gn=u(function(){null!==rn.sectionIdx&&rn.anchorEl?qn(e(e({},rn),{open:!0})):xn()},[rn,xn,qn]);u(function(e){xn(),be("".concat(e," is coming soon."))},[xn]);var Jn=u(function(){var e=rn.sectionIdx,n=rn.isOrphan;if(xn(),null!==e){if(n)return be("No counterpart exists to connect to."),void xn();Pe.current&&Vn(),De(function(n){return n.has(e)?new Set:new Set([e])})}},[rn.sectionIdx,xn,Vn]),Qn=c(null),Zn=c(null),$n=c(null),et=c(null),nt=c(null),tt=l([]),it=tt[0],rt=tt[1],ot=l(null),lt=ot[0],ct=ot[1];c(null);var at=l(null),ut=at[0],dt=at[1],st=o(function(){return bn.fields.filter(function(e){var n=e.key;return(!Ln||"description"!==n)&&(C(null==Sn?void 0:Sn[n])||C(Dn[n]))})},[Sn,Dn,Ln,bn.fields]),vt=c({}),ft=c({}),pt=c({}),ht=c({}),gt=c({}),xt=c({}),mt=c({}),bt=c({}),yt=c({});st.forEach(function(e){for(var n=e.key,t=0;t<Math.max(Wn.length,Nn.length);t+=1)pt.current[t]||(pt.current[t]=r.createRef()),ht.current[t]||(ht.current[t]=r.createRef()),gt.current[t]||(gt.current[t]=r.createRef()),xt.current[t]||(xt.current[t]=r.createRef()),mt.current[t]||(mt.current[t]=r.createRef());vt.current[n]||(vt.current[n]=r.createRef()),ft.current[n]||(ft.current[n]=r.createRef())});for(var St=0;St<Math.max(Wn.length,Nn.length);St+=1)pt.current[St]||(pt.current[St]=r.createRef()),ht.current[St]||(ht.current[St]=r.createRef()),gt.current[St]||(gt.current[St]=r.createRef()),xt.current[St]||(xt.current[St]=r.createRef()),mt.current[St]||(mt.current[St]=r.createRef());a(function(){if(Fn){var e=bn.fields.find(function(e){return e.analysisKey===Fn||e.key===Fn});if(e){var n=vt.current[e.key]||ft.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[Fn,bn.fields]);var It=u(function(e){var n,t,i,r,o,l,c,a,u,d=null===(n=null==On?void 0:On.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!d||!d[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var s=d[e],v=(null==s?void 0:s.relation)||(null===(i=null===(t=null==s?void 0:s.highlights)||void 0===t?void 0:t.ruleA_spans)||void 0===i?void 0:i.length)||(null===(o=null===(r=null==s?void 0:s.highlights)||void 0===r?void 0:r.ruleB_spans)||void 0===o?void 0:o.length)||(null==s?void 0:s.mappings)&&s.mappings.length>0;if(s.mappings){var f=s.mappings[0]||{};return{score:s.score,relation:f.relation||"",highlightsA:(null===(l=f.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(c=f.highlights)||void 0===c?void 0:c.ruleB_spans)||[],hasContent:!!v}}return{score:s.score,relation:s.relation||"",highlightsA:(null===(a=s.highlights)||void 0===a?void 0:a.ruleA_spans)||[],highlightsB:(null===(u=s.highlights)||void 0===u?void 0:u.ruleB_spans)||[],hasContent:!!v}},[On]),wt=u(function(n){var t,i,r,o,l=Wn[n],c=Nn[n],a=(null==l?void 0:l.relation)&&"not_defined"!==l.relation,u=(null==c?void 0:c.relation)&&"not_defined"!==c.relation,d=F(null==l?void 0:l.id)||F(null==c?void 0:c.id)||"",s=!(!(null==l?void 0:l.cognitiveData)&&!(null==c?void 0:c.cognitiveData));if(!a&&!u&&!s)return e(e({},bn.relationStyles.noContent),{label:"Not Defined"});var v=It("description");if(null!=(null!==(i=null!==(t=null==l?void 0:l.cognitiveRelevanceScore)&&void 0!==t?t:null==c?void 0:c.cognitiveRelevanceScore)&&void 0!==i?i:d?null===(r=Ke[d])||void 0===r?void 0:r.relevance_score:void 0)){var f=B(),p=f.score,h=f.relation;return E(p,h,!0,bn)}var g=a?l.relation:u?c.relation:v.relation,x=null!==(o=null==l?void 0:l.score)&&void 0!==o?o:null==c?void 0:c.score,m="number"==typeof x?x:v.score;return E(m,g,!0,bn)},[Wn,Nn,Ke,bn,It]),Rt=u(function(n){for(var t,i,r,o,l=n.split("-").map(Number),c=Wn[l[0]],a=Nn[l[0]],u=1;u<l.length;u++)(null==c?void 0:c.subsections)&&(c=c.subsections[l[u]]),(null==a?void 0:a.subsections)&&(a=a.subsections[l[u]]);if(!c&&!a)return null;var d=(null==c?void 0:c.relation)&&"not_defined"!==c.relation,s=(null==a?void 0:a.relation)&&"not_defined"!==a.relation,v=F(null==c?void 0:c.id)||F(null==a?void 0:a.id)||"",f=!(!(null==c?void 0:c.cognitiveData)&&!(null==a?void 0:a.cognitiveData));if(!d&&!s&&!f)return e(e({},bn.relationStyles.noContent),{label:"Not Defined"});if(null!=(null!==(i=null!==(t=null==c?void 0:c.cognitiveRelevanceScore)&&void 0!==t?t:null==a?void 0:a.cognitiveRelevanceScore)&&void 0!==i?i:v?null===(r=Ke[v])||void 0===r?void 0:r.relevance_score:void 0)){var p=B(),h=p.score,g=p.relation;return E(h,g,!0,bn)}var x=d?c.relation:s?a.relation:"not_defined",m=null!==(o=null==c?void 0:c.score)&&void 0!==o?o:null==a?void 0:a.score;return E("number"==typeof m?m:0,x,!0,bn)},[Wn,Nn,Ke,bn]),Ft=u(function(){var e,n,t,i,r,o,l,c,a,u,d,s,v,f,p,h,g,x,m,b,y,S;if(!pn.current&&!We.current){pn.current=!0;try{if(!Qn.current)return;var I=function(e){var n=e.split("-"),t=n[0];if(!En[t]&&!1===ue)return!1;if(ue&&!En["left-".concat(t)]&&!En["right-".concat(t)]&&!En[t])return!1;for(var i=t,r=1;r<n.length-1;r++)if(i+="-".concat(n[r]),!_n[i])return!1;return!0},w=Qn.current.getBoundingClientRect();Qe({width:w.width,height:w.height});var R=[];if(st.forEach(function(e){var n,t,i=e.key,r=null===(n=vt.current[i])||void 0===n?void 0:n.current,o=null===(t=ft.current[i])||void 0===t?void 0:t.current;r&&o&&(r.style.height="auto",o.style.height="auto",r.style.minHeight="0px",o.style.minHeight="0px")}),!We.current){for(var C=0;C<Math.max(Wn.length,Nn.length);C++){var T=null===(e=pt.current[C])||void 0===e?void 0:e.current,_=null===(n=ht.current[C])||void 0===n?void 0:n.current;T&&(T.style.height="auto",T.style.minHeight="0px"),_&&(_.style.height="auto",_.style.minHeight="0px")}ue||Object.keys(bt.current).forEach(function(e){var n,t;if(I(e)){var i=null===(n=bt.current[e])||void 0===n?void 0:n.current,r=null===(t=yt.current[e])||void 0===t?void 0:t.current;i&&r&&(i.style.height="auto",r.style.height="auto",i.style.minHeight="0px",r.style.minHeight="0px")}})}var k={};st.forEach(function(e){var n,t,i=e.key,r=null===(n=vt.current[i])||void 0===n?void 0:n.current,o=null===(t=ft.current[i])||void 0===t?void 0:t.current;if(r&&o){var l=r.getBoundingClientRect(),c=o.getBoundingClientRect();k[i]=Math.max(l.height,c.height)}});var D={left:{},right:{}},M={};if(!We.current)if(ue){if(Se&&null!==lt)if("number"==typeof lt){var A=lt,H=Wn[A],z=null===(r=pt.current[A])||void 0===r?void 0:r.current;z&&H&&(H.refIndexes||[]).forEach(function(e){var n,t=Nn.findIndex(function(n){return n.selfIndex===e}),i=null===(n=ht.current[t])||void 0===n?void 0:n.current;if(i&&(En["left-".concat(A)]||En["right-".concat(t)])){var r=Math.max(z.getBoundingClientRect().height,i.getBoundingClientRect().height);D.left[A]=Math.max(D.left[A]||0,r),D.right[t]=Math.max(D.right[t]||0,r)}})}else{var W=lt;T=null===(o=bt.current[W])||void 0===o?void 0:o.current,_=null===(l=yt.current[W])||void 0===l?void 0:l.current;if(T&&_){O=Math.max(T.getBoundingClientRect().height,_.getBoundingClientRect().height);M[W]=Math.max(M[W]||0,O)}}}else{for(C=0;C<Math.min(Wn.length,Nn.length);C++){var T=null===(t=pt.current[C])||void 0===t?void 0:t.current,_=null===(i=ht.current[C])||void 0===i?void 0:i.current,N=!!En[String(C)];if(T&&_&&N){var O=Math.max(T.getBoundingClientRect().height,_.getBoundingClientRect().height);D.left[C]=O,D.right[C]=O}}Object.keys(bt.current).forEach(function(e){var n,t;if(I(e)){var i=null===(n=bt.current[e])||void 0===n?void 0:n.current,r=null===(t=yt.current[e])||void 0===t?void 0:t.current;if(i&&r&&null!==i.offsetParent&&null!==r.offsetParent){var o=i.getBoundingClientRect(),l=r.getBoundingClientRect();M[e]=Math.max(o.height,l.height)}}})}if(st.forEach(function(e){var n,t,i=e.key,r=null===(n=vt.current[i])||void 0===n?void 0:n.current,o=null===(t=ft.current[i])||void 0===t?void 0:t.current;if(r&&o){var l=k[i];r.style.minHeight="".concat(l,"px"),o.style.minHeight="".concat(l,"px")}}),We.current||(Object.entries(D.left).forEach(function(e){var n,t=e[0],i=e[1],r=null===(n=pt.current[Number(t)])||void 0===n?void 0:n.current;r&&(r.style.minHeight="".concat(i,"px"))}),Object.entries(D.right).forEach(function(e){var n,t=e[0],i=e[1],r=null===(n=ht.current[Number(t)])||void 0===n?void 0:n.current;r&&(r.style.minHeight="".concat(i,"px"))}),ue||Object.keys(M).forEach(function(e){var n,t,i=null===(n=bt.current[e])||void 0===n?void 0:n.current,r=null===(t=yt.current[e])||void 0===t?void 0:t.current;if(i&&r&&M[e]){var o=M[e];i.style.minHeight="".concat(o,"px"),r.style.minHeight="".concat(o,"px")}})),st.forEach(function(e){var n,t,i=e.key,r=e.analysisKey,o=null===(n=vt.current[i])||void 0===n?void 0:n.current,l=null===(t=ft.current[i])||void 0===t?void 0:t.current;if(o&&l){var c=o.getBoundingClientRect(),a=l.getBoundingClientRect(),u=It(r),d=E(u.score,u.relation,u.hasContent,bn);if(!d)return;var s=c.top+c.height/2-w.top;R.push({id:"field-".concat(i),x1:c.right-w.left,y1:s,x2:a.left-w.left,y2:s,style:d})}}),ue){if(Wn.forEach(function(e,n){var t;(null===(t=pt.current[n])||void 0===t?void 0:t.current)&&(e.refIndexes||[]).forEach(function(e){var t,i,r,o,l,c,a,u,d,s,v=Nn.findIndex(function(n){return n.selfIndex===e});if(-1!==v){var f=null===(t=gt.current[n])||void 0===t?void 0:t.current,p=null===(i=xt.current[v])||void 0===i?void 0:i.current;if(f&&p){var h=f.getBoundingClientRect(),g=p.getBoundingClientRect(),x=h.right-w.left,m=g.left-w.left,b=h.top+h.height/2-w.top,y=g.top+g.height/2-w.top;if(Se&&lt===n){var S=null!==(o=null===(r=fn.current)||void 0===r?void 0:r.getBoundingClientRect().top)&&void 0!==o?o:0,I=null!==(c=null===(l=an.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==c?c:0,F=S+(null!==(u=null===(a=fn.current)||void 0===a?void 0:a.clientHeight)&&void 0!==u?u:1/0),C=I+(null!==(s=null===(d=an.current)||void 0===d?void 0:d.clientHeight)&&void 0!==s?s:1/0),E=h.top+h.height/2,B=function(e,n,t){return Math.max(n,Math.min(t,e))};b=B(E,S,F)-w.top,y=B(E,I,C)-w.top}var T=wt(n);T&&R.push({id:"line-".concat(n,"-").concat(v),x1:x,y1:b,x2:m,y2:y,style:T,sectionIdx:n,targetRightIdx:v})}}})}),Se&&"string"==typeof lt){W=lt;var j=null===(v=gt.current[W])||void 0===v?void 0:v.current,P=null===(f=xt.current[W])||void 0===f?void 0:f.current;if(j&&P){var Y=j.getBoundingClientRect(),K=P.getBoundingClientRect(),V=Y.right-w.left,X=K.left-w.left,q=null!==(h=null===(p=fn.current)||void 0===p?void 0:p.getBoundingClientRect().top)&&void 0!==h?h:0,U=null!==(x=null===(g=an.current)||void 0===g?void 0:g.getBoundingClientRect().top)&&void 0!==x?x:0,G=q+(null!==(b=null===(m=fn.current)||void 0===m?void 0:m.clientHeight)&&void 0!==b?b:1/0),J=U+(null!==(S=null===(y=an.current)||void 0===y?void 0:y.clientHeight)&&void 0!==S?S:1/0),Q=Y.top+Y.height/2,Z=K.top+K.height/2,$=function(e,n,t){return Math.max(n,Math.min(t,e))},ee=$(Q,q,G)-w.top,ne=$(Z,U,J)-w.top;(re=Rt(W))&&R.push({id:"line-subsec-".concat(W),x1:V,y1:ee,x2:X,y2:ne,style:re,sectionIdx:Number(W.split("-")[0]),isSubSection:!0,subSectionKeyPath:W})}}}else{for(C=0;C<Math.min(Wn.length,Nn.length);C++){var te=null===(c=pt.current[C])||void 0===c?void 0:c.current,ie=null===(a=ht.current[C])||void 0===a?void 0:a.current;if(te&&ie){var re,oe=te.getBoundingClientRect(),le=ie.getBoundingClientRect(),ce=(oe.top+18-w.top+le.top+18-w.top)/2,ae=(null===(u=Nn[C])||void 0===u?void 0:u.id)||"sec-".concat(C);(re=wt(C))&&R.push({id:ae,x1:oe.right-w.left,y1:ce,x2:le.left-w.left,y2:ce,style:re,sectionIdx:C,hasCognitive:!!((null===(d=Wn[C])||void 0===d?void 0:d.cognitiveData)||(null===(s=Nn[C])||void 0===s?void 0:s.cognitiveData)||ae&&Ke[ae])})}}Object.keys(bt.current).forEach(function(e){var n,t,i,r,o,l,c;if(I(e)){for(var a=null===(n=bt.current[e])||void 0===n?void 0:n.current,u=e.split("-").map(Number),d=Wn[u[0]],s=1;s<u.length;s++)(null==d?void 0:d.subsections)&&(d=d.subsections[u[s]]);if(d&&(null===(t=d.refIndexes)||void 0===t?void 0:t.length)){var v=null===(i=yt.current[e])||void 0===i?void 0:i.current;if(a&&v&&null!==a.offsetParent&&null!==v.offsetParent){var f=a.getBoundingClientRect(),p=v.getBoundingClientRect(),h=(f.top+16-w.top+p.top+16-w.top)/2,g=e.split("-").map(Number),x=Wn[g[0]],m=Nn[g[0]];for(s=1;s<g.length;s++)(null==x?void 0:x.subsections)&&(x=x.subsections[g[s]]),(null==m?void 0:m.subsections)&&(m=m.subsections[g[s]]);if(!x&&!m)return;var b=(null==x?void 0:x.relation)&&"not_defined"!==x.relation,y=(null==m?void 0:m.relation)&&"not_defined"!==m.relation,S=F(null==x?void 0:x.id)||F(null==m?void 0:m.id)||"",C=!(!(null==x?void 0:x.cognitiveData)&&!(null==m?void 0:m.cognitiveData)),T=null;if(b||y||C){var _=null!==(o=null!==(r=null==x?void 0:x.cognitiveRelevanceScore)&&void 0!==r?r:null==m?void 0:m.cognitiveRelevanceScore)&&void 0!==o?o:S?null===(l=Ke[S])||void 0===l?void 0:l.relevance_score:void 0;if(null!=_){var k=B(_),D=k.score,M=k.relation;T=E(D,M,!0,bn)}else{M=b?x.relation:y?m.relation:"not_defined";var A=null!==(c=null==x?void 0:x.score)&&void 0!==c?c:null==m?void 0:m.score;T=E(D="number"==typeof A?A:0,M,!0,bn)}}else T={badgeBg:"#EEF2FF",badgeText:"#3730A3",badgeBorder:"#C7D2FE",label:"N/A"};T&&R.push({id:"subsec-".concat(e),x1:f.right-w.left,y1:h,x2:p.left-w.left,y2:h,style:T,sectionIdx:g[0],isSubSection:!0,subSectionKeyPath:e,hasCognitive:C||S&&Ke[S]})}}}})}if(rt(R),et.current&&nt.current){var de=et.current.getBoundingClientRect(),se=nt.current.getBoundingClientRect(),ve=(de.top+de.height/2-w.top+se.top+se.height/2-w.top)/2;dt({x1:de.right-w.left,x2:se.left-w.left,y:ve})}else dt(null);if(ue&&ke.size>0){var fe=[],pe=fn.current,he=an.current;if(pe&&he){var ge=[],xe=pe.getBoundingClientRect().top,me=he.getBoundingClientRect().top,be=xe+pe.clientHeight,ye=me+he.clientHeight,Ie=pe.scrollTop,we=he.scrollTop,Re=w.top,Fe=function(e,n,t){return Math.max(n,Math.min(t,e))};ke.forEach(function(e){var n,t,i;if("string"==typeof e){var r=e,o=null===(n=gt.current[r])||void 0===n?void 0:n.current,l=null===(t=xt.current[r])||void 0===t?void 0:t.current;if(!o||!l)return;var c=o.getBoundingClientRect(),a=l.getBoundingClientRect(),u=Rt(r),d=c.right-w.left,s=a.left-w.left-0,v=d+.75*(s-d),f=c.top+c.height/2,p=a.top+a.height/2,h=f-xe+Ie,g=p-me+we,x="conn-subsec-".concat(r);ge.push({lhsScrollY:h,rhsScrollY:g,x1:d,x2:s,containerTop:Re,leftIdx:r,rhsArrayIdx:r,styleColor:(null==u?void 0:u.badgeBorder)||"#6366F1",styleId:x});var m=Fe(f,xe,be),b=Fe(p,me,ye),y=m-Re,S=b-Re,I=f>=xe-4&&f<=be+4,R=p>=me-4&&p<=ye+4,F="";F=I&&R?L(d,y,s,S):I&&!R?"M ".concat(d,",").concat(y," L ").concat(v,",").concat(y," L ").concat(v,",").concat(S):!I&&R?"M ".concat(v,",").concat(y," L ").concat(v,",").concat(S," L ").concat(s,",").concat(S):"M ".concat(v,",").concat(y," L ").concat(v,",").concat(S),fe.push({id:x,pathD:F,style:u,leftIdx:r,rhsArrayIdx:r})}else{var C=Wn[e];if(!(null===(i=null==C?void 0:C.refIndexes)||void 0===i?void 0:i.length))return;C.refIndexes.forEach(function(n){var t,i,r=Nn.findIndex(function(e){return e.selfIndex===n});if(-1!==r){var o=null===(t=gt.current[e])||void 0===t?void 0:t.current,l=null===(i=xt.current[r])||void 0===i?void 0:i.current;if(o&&l){var c=o.getBoundingClientRect(),a=l.getBoundingClientRect(),u=wt(e),d=c.right-w.left,s=a.left-w.left-0,v=d+.75*(s-d),f=c.top+c.height/2,p=a.top+a.height/2,h=f-xe+Ie,g=p-me+we,x="conn-".concat(e,"-").concat(r);ge.push({lhsScrollY:h,rhsScrollY:g,x1:d,x2:s,containerTop:Re,leftIdx:e,rhsArrayIdx:r,styleColor:(null==u?void 0:u.badgeBorder)||"#6366F1",styleId:x});var m=Fe(f,xe,be),b=Fe(p,me,ye),y=m-Re,S=b-Re,I=f>=xe-4&&f<=be+4,R=p>=me-4&&p<=ye+4,F="";F=I&&R?L(d,y,s,S):I&&!R?"M ".concat(d,",").concat(y," L ").concat(v,",").concat(y," L ").concat(v,",").concat(S):!I&&R?"M ".concat(v,",").concat(y," L ").concat(v,",").concat(S," L ").concat(s,",").concat(S):"M ".concat(v,",").concat(y," L ").concat(v,",").concat(S),fe.push({id:x,pathD:F,style:u,leftIdx:e,rhsArrayIdx:r})}}})}}),Oe.current=ge}He(fe)}else He([]),Oe.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{pn.current=!1}}},[st,Wn,Nn,Ke,bn,It,wt,ue,Se,lt,ke,En,_n]),Ct=u(function(){var e,n,t,i,r,o,l,c,a,u,d,s,v,f,p=Oe.current;if(p.length&&!We.current){var h=null!==(n=null===(e=fn.current)||void 0===e?void 0:e.scrollTop)&&void 0!==n?n:0,g=null!==(i=null===(t=an.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,x=null!==(o=null===(r=fn.current)||void 0===r?void 0:r.clientHeight)&&void 0!==o?o:1/0,m=null!==(c=null===(l=an.current)||void 0===l?void 0:l.clientHeight)&&void 0!==c?c:1/0,b=null!==(u=null===(a=fn.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==u?u:0,y=null!==(s=null===(d=an.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==s?s:0,S=b+x,I=y+m,w=null!==(f=null===(v=Qn.current)||void 0===v?void 0:v.getBoundingClientRect().top)&&void 0!==f?f:0,R=function(e,n,t){return Math.max(n,Math.min(t,e))};p.forEach(function(e){var n=e.lhsScrollY-h+b,t=e.rhsScrollY-g+y,i=Le.current[e.styleId+"-stroke"],r=Le.current[e.styleId+"-bg"];if(i||r){var o,l=R(n,b,S),c=R(t,y,I),a=l-w,u=c-w,d=n>=b-4&&n<=S+4,s=t>=y-4&&t<=I+4,v=e.x1+.65*(e.x2-e.x1);o=d&&s?L(e.x1,a,e.x2,u):d&&!s?"M ".concat(e.x1,",").concat(a," L ").concat(v,",").concat(a," L ").concat(v,",").concat(u):!d&&s?"M ".concat(v,",").concat(a," L ").concat(v,",").concat(u," L ").concat(e.x2,",").concat(u):"M ".concat(v,",").concat(a," L ").concat(v,",").concat(u),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",o)),r&&(r.setAttribute("visibility","visible"),r.setAttribute("d",o))}})}},[]),Et=c(Ft);a(function(){Et.current=Ft},[Ft]);var Bt=c(null),Tt=u(function(){null!==Bt.current&&clearTimeout(Bt.current),Bt.current=setTimeout(function(){Et.current(),Bt.current=null},50)},[]),_t=u(function(e){var n,t,i,r,o,l,c,a;if(!Ce.current){if(Pe.current){var u=Ye.current,d=Zn.current,s=fn.current,v=an.current;if(null!==u&&null!==d&&s&&v){var f="string"==typeof u?null===(n=bt.current[u])||void 0===n?void 0:n.current:null===(t=Yn.current[u])||void 0===t?void 0:t.current,p="string"==typeof d?null===(i=yt.current[d])||void 0===i?void 0:i.current:null===(r=mt.current[d])||void 0===r?void 0:r.current;if(f&&p){var h=f.getBoundingClientRect().top-s.getBoundingClientRect().top+s.scrollTop,g=p.getBoundingClientRect().top-v.getBoundingClientRect().top+v.scrollTop;if(e.currentTarget===s){var x=g-(h-s.scrollTop),m=v.scrollHeight-v.clientHeight,b=Math.max(0,Math.min(x,m));Math.abs(v.scrollTop-b)>1&&(v.scrollTop=b)}else if(e.currentTarget===v){var y=h-(g-v.scrollTop),S=s.scrollHeight-s.clientHeight,I=Math.max(0,Math.min(y,S));Math.abs(s.scrollTop-I)>1&&(s.scrollTop=I)}if($n.current){var w=null===(o=gt.current[u])||void 0===o?void 0:o.current,R=null===(l=xt.current[d])||void 0===l?void 0:l.current,F=null!==(a=null===(c=Qn.current)||void 0===c?void 0:c.getBoundingClientRect().top)&&void 0!==a?a:0,C=s.getBoundingClientRect().top,E=C+s.clientHeight,B=v.getBoundingClientRect().top,T=B+v.clientHeight,_=function(e,n,t){return Math.max(n,Math.min(t,e))};if(w&&R){var k=w.getBoundingClientRect(),D=R.getBoundingClientRect(),M=k.top+k.height/2,A=D.top+D.height/2,H=_(M,C,E),z=_(A,B,T);$n.current.setAttribute("y1",(H-F).toString()),$n.current.setAttribute("y2",(z-F).toString());var W=M>=C-4&&M<=E+4;$n.current.setAttribute("visibility",W?"visible":"hidden")}}}}}Oe.current.length>0&&!je.current&&(je.current=!0,requestAnimationFrame(function(){Ct(),je.current=!1}))}},[Ct]);a(function(){var e=setTimeout(Tt,250);window.addEventListener("resize",Tt);var n=null,t=null;return ln.current&&(n=new ResizeObserver(Tt)).observe(ln.current),Qn.current&&(t=new ResizeObserver(Tt)).observe(Qn.current),function(){clearTimeout(e),window.removeEventListener("resize",Tt),null==n||n.disconnect(),null==t||t.disconnect()}},[Sn,Dn,On,st,En,_n,Wn,Nn,bn,Tt,Se,lt,Re,ke]),a(function(){Pe.current=Se},[Se]),a(function(){Ye.current=lt},[lt]);var kt=u(function(){var e=rn.sectionIdx,n=rn.isOrphan;if(null!=e)return n?(be("No counterpart exists for this section."),void xn()):void(Se&&lt===e?Vn():(De(new Set),He([]),Oe.current=[],ge(!0),Ce.current=!0,ct(e),Ye.current=e,Ie(!0),Pe.current=!0,Fe(!1),un.current&&(un.current.style.height="0px"),dn.current&&(dn.current.style.height="0px"),sn.current&&(sn.current.style.height="0px"),vn.current&&(vn.current.style.height="0px"),requestAnimationFrame(function(){var n,t,i,r,o=null,l=null,c=null;if("string"==typeof e)o=(null===(n=bt.current[e])||void 0===n?void 0:n.current)||null,c=(l=(null===(t=yt.current[e])||void 0===t?void 0:t.current)||null)?e:null;else{o=(null===(i=Yn.current[e])||void 0===i?void 0:i.current)||null;var a=Wn[e],u=(null==a?void 0:a.refIndexes)||[];if(u.length>0){var d=u[0],s=Nn.findIndex(function(e){return e.selfIndex===d});-1!==s&&(l=(null===(r=mt.current[s])||void 0===r?void 0:r.current)||null,c=s)}}Zn.current=c;var v=fn.current,f=an.current;if(!o||!v)return Ce.current=!1,void ge(!1);if(!l||!f)return Fe(!0),Et.current(),Ce.current=!1,void ge(!1);var p=o.getBoundingClientRect().top-v.getBoundingClientRect().top+v.scrollTop,h=l.getBoundingClientRect().top-f.getBoundingClientRect().top+f.scrollTop-(p-v.scrollTop);h<0&&un.current&&(un.current.style.height="".concat(Math.abs(h),"px"));requestAnimationFrame(function(){var e,n=f.scrollHeight-f.clientHeight;if(h<0)e=0;else{if(h>n){var t=h-n;return dn.current&&(dn.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){P(f,h,200,function(){Fe(!0),Et.current(),Ce.current=!1,ge(!1)})})}e=h}P(f,e,200,function(){Fe(!0),Et.current(),Ce.current=!1,ge(!1)})})})));xn()},[xn,rn.sectionIdx,Se,lt,Wn,Nn,Tt,Vn]),Dt=null!==rn.sectionIdx&&ke.has(rn.sectionIdx),Mt=function(n){var o,l,c,a=n.section,u=n.idx,v=n.columnKey,f=n.colRef,p=n.mb,h=void 0===p?1:p,S=n.parentNodeId,I=void 0===S?"":S,w=ue?!!En["".concat(v,"-").concat(u)]:!!En[String(u)],R=(null===(o=a.displayTitle)||void 0===o||o)&&C(a.title),E=(null===(l=a.displayContent)||void 0===l||l)&&C(a.content),B=!R&&!E,T=a.title;R||(T=E?"No Title Found":"No Matching Section Found");var _,k=[];if(null===(c=a.evaluationResult)||void 0===c?void 0:c.deviations){var D=a.evaluationResult.deviations;for(var M in D){var A=D[M][I];A&&k.push(A)}}return t(s,e({ref:f,sx:{mb:h,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:i(x,e({disableGutters:!0,expanded:!B&&w,onChange:function(){return!B&&function(n,t){var i,r;We.current=!0,Ne.current&&clearTimeout(Ne.current),ze.current&&(ze.current.style.opacity="0");var o=null===(i=pt.current[n])||void 0===i?void 0:i.current,l=null===(r=ht.current[n])||void 0===r?void 0:r.current;if(o&&(o.style.minHeight="0px"),l&&(l.style.minHeight="0px"),Object.keys(bt.current).forEach(function(e){var t,i;if(e.startsWith("".concat(n,"-"))){var r=null===(t=bt.current[e])||void 0===t?void 0:t.current,o=null===(i=yt.current[e])||void 0===i?void 0:i.current;r&&(r.style.minHeight="0px"),o&&(o.style.minHeight="0px")}}),ue){var c=Wn[n];((null==c?void 0:c.refIndexes)||[]).forEach(function(e){var n,t=Nn.findIndex(function(n){return n.selfIndex===e}),i=null===(n=ht.current[t])||void 0===n?void 0:n.current;i&&(i.style.minHeight="0px")});var a=Nn[n],u=null==a?void 0:a.selfIndex;Wn.forEach(function(e,n){var t,i;if(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(u)){var r=null===(i=pt.current[n])||void 0===i?void 0:i.current;r&&(r.style.minHeight="0px")}})}Ne.current=setTimeout(function(){We.current=!1,Et.current(),ze.current&&(ze.current.style.opacity="1")},650),Bn(function(i){var r=e({},i);if(!ue){var o=!!i[String(n)];return r[String(n)]=!o,r}var l="".concat(t,"-").concat(n),c=!i[l];if(r[l]=c,"left"===t)((null==(a=Wn[n])?void 0:a.refIndexes)||[]).forEach(function(e){var n=Nn.findIndex(function(n){return n.selfIndex===e});-1!==n&&(r["right-".concat(n)]=c)});else{var a,u=null==(a=Nn[n])?void 0:a.selfIndex;Wn.forEach(function(e,n){var t;(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(u))&&(r["left-".concat(n)]=c)})}return r})}(u,v)},sx:{boxShadow:"none",border:B?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:B?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flexGrow:1,width:"100%",display:"flex",flexDirection:"column",minWidth:0,"&:before":{display:"none"}}},{children:[t(m,e({expandIcon:B?null:t(y,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:B?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:R&&t(g,e({title:T,placement:"top"},{children:t(d,e({component:"div",sx:{fontSize:"12px",color:B?"#94A3B8":"#19213D",fontWeight:B?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(_=T,_?F(_).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(e,n){return e.startsWith("**")&&e.endsWith("**")?t("strong",{children:e.slice(2,-2)},n):t(r.Fragment,{children:e},n)}):null)}))}))})),!B&&i(b,e({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[E&&t(N,{content:a.content,sxStyles:Ze,highlights:k}),(a.subsections||[]).map(function(e,n){return At({section:e,keyPath:"".concat(u,"-").concat(n),depth:0,columnKey:v,parentNodeId:I})})]}))]}))}),"".concat(v,"-sec-").concat(u))},At=function(n){var o,l,c,a=n.section,u=n.keyPath,v=n.depth,f=void 0===v?0:v,p=n.columnKey,h=void 0===p?"left":p,g=n.parentNodeId,I=void 0===g?"":g,w=(null===(o=a.displayTitle)||void 0===o||o)&&C(a.title),R=(null===(l=a.displayContent)||void 0===l||l)&&C(a.content),F=!w&&!R,E=w?a.title:R?"No Title Found":"No Matching Section Found",B=!!_n[u];"left"!==h||bt.current[u]||(bt.current[u]=r.createRef()),"right"!==h||yt.current[u]||(yt.current[u]=r.createRef());var T="left"===h?bt.current[u]:yt.current[u];gt.current[u]||(gt.current[u]=r.createRef()),xt.current[u]||(xt.current[u]=r.createRef());for(var _=u.split("-").map(function(e){return Number(e)+1}).join("."),k=Rt(u),D=ue&&ke.has(u),M=u.split("-").map(Number),A=Wn[M[0]],H=Nn[M[0]],z=1;z<M.length;z++)(null==A?void 0:A.subsections)&&(A=A.subsections[M[z]]),(null==H?void 0:H.subsections)&&(H=H.subsections[M[z]]);var W=!(null===(c=a.refIndexes)||void 0===c?void 0:c.length)||void 0!==a.selfIndex&&a.selfIndex<0,L="left"===h&&W,O="right"===h&&W;return i(s,w?e({ref:T,sx:{mt:1,width:"100%",minWidth:0,position:"relative"}},{children:[t(s,e({sx:e({width:"100%"},D&&k&&{borderRadius:"4px",outline:"2px solid ".concat(k.badgeBorder),outlineOffset:"1px"})},{children:i(x,e({disableGutters:!0,expanded:!F&&B,onChange:function(){return!F&&kn(function(n){var t;return e(e({},n),((t={})[u]=!n[u],t))})},sx:{mt:0,boxShadow:"none",border:F?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF",minWidth:0,"&:before":{display:"none"}}},{children:[t(m,e({expandIcon:F?null:t(y,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"}}},{children:t(d,e({component:"div",sx:{fontSize:"11px",fontWeight:600,color:F?"#94A3B8":"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:E||"Untitled Subsection"}))})),!F&&i(b,e({sx:{pt:0,pb:1,minWidth:0}},{children:[R&&t(N,{content:a.content,sxStyles:Ze,highlights:function(){var e,n;if(!(null===(e=a.evaluationResult)||void 0===e?void 0:e.deviations))return[];var t=(null===(n=a.evaluationResult)||void 0===n?void 0:n.deviations)||{},i=[];for(var r in t){var o=t[r][I];o&&i.push(o)}return i}()}),(a.subsections||[]).map(function(e,n){return At({section:e,keyPath:"".concat(u,"-").concat(n),depth:f+1,columnKey:h,parentNodeId:I})})]}))]}))})),ue&&"left"===h&&k&&!F&&i(s,e({ref:gt.current[u],onClick:function(e){e.stopPropagation();for(var n=u.split("-").map(Number),t=Wn[n[0]],i=Nn[n[0]],r=1;r<n.length;r++)(null==t?void 0:t.subsections)&&(t=t.subsections[n[r]]),(null==i?void 0:i.subsections)&&(i=i.subsections[n[r]]);Un(e,t||{title:"",content:""},L||O,i||{title:"",content:""},u,k)},sx:{position:"absolute",top:"16px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"10px",bgcolor:k.badgeBg,color:k.badgeText,border:"1px solid ".concat(k.badgeBorder),borderRadius:"12px",px:1,py:.3,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[t(s,e({component:"span",sx:{fontSize:"10px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(k.badgeBorder)}},{children:_})),t(s,e({component:"span",sx:{fontSize:"10px",px:.25}},{children:L?"No Deviation Found":0==k.deviationLabel||void 0===k.deviationLabel?"Same":"".concat(k.deviationLabel,"% Deviation")})),t(S,{size:10,color:k.badgeText})]})),ue&&"right"===h&&k&&!F&&!he&&t(s,e({ref:xt.current[u],sx:{position:"absolute",top:"16px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"10px",bgcolor:"#EEF2FF",color:"#3730A3",border:"1px solid #C7D2FE",borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:O?"-":_}))]}):e({ref:T,sx:{mt:0===f?1:.75,width:"100%",minWidth:0,position:"relative"}},{children:[!F&&i(s,e({sx:e({width:"100%"},D&&k&&{borderRadius:"4px",outline:"2px solid ".concat(k.badgeBorder),outlineOffset:"1px"})},{children:[R&&t(N,{content:a.content,sxStyles:Ze,highlights:function(){var e,n;if(!(null===(e=a.evaluationResult)||void 0===e?void 0:e.deviations))return[];var t=(null===(n=a.evaluationResult)||void 0===n?void 0:n.deviations)||{},i=[];for(var r in t){var o=t[r][I];o&&i.push(o)}return i}()}),(a.subsections||[]).map(function(e,n){return At({section:e,keyPath:"".concat(u,"-").concat(n),depth:f+1,columnKey:h,parentNodeId:I})})]})),ue&&"left"===h&&k&&!F&&i(s,e({ref:gt.current[u],onClick:function(e){var n;e.stopPropagation();var t=function(e,n){for(var i=0,r=e;i<r.length;i++){var o=r[i];if(o.selfIndex===n)return o;if(o.subsections){var l=t(o.subsections,n);if(l)return l}}return null},i=null===(n=a.refIndexes)||void 0===n?void 0:n[0],r="number"==typeof i?t(Nn,i):null;Un(e,a,W,r||{title:"",content:""},u,k)},sx:{position:"absolute",top:"16px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"10px",bgcolor:k.badgeBg,color:k.badgeText,border:"1px solid ".concat(k.badgeBorder),borderRadius:"12px",px:1,py:.3,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[t(s,e({component:"span",sx:{fontSize:"10px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(k.badgeBorder)}},{children:_})),t(s,e({component:"span",sx:{fontSize:"10px",px:.25}},{children:L?"No Deviation Found":0==k.deviationLabel||void 0===k.deviationLabel?"Same":"".concat(k.deviationLabel,"% Deviation")})),t(S,{size:10,color:k.badgeText})]})),ue&&"right"===h&&k&&!F&&!he&&t(s,e({ref:xt.current[u],sx:{position:"absolute",top:"16px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"10px",bgcolor:"#EEF2FF",color:"#3730A3",border:"1px solid #C7D2FE",borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:O?"-":_}))]}),u)};return i(s,e({ref:cn,sx:e(e({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},ue?{}:{overflow:"visible"}),{position:"relative"})},{children:[ve&&t(s,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:t(z,{})})),ue&&t(H,{open:rn.open,anchorEl:rn.anchorEl,sectionTitle:rn.sectionTitle,referenceSectionTitle:rn.refSectionTitle,onClose:xn,onOpenCognitiveCompare:Gn,onOpenSideBySide:kt,onConnect:Jn,isConnected:Dt}),en.open&&t(A,{open:en.open,popupRef:Ue,position:Xe,popupConfig:oe,onClose:function(){qe(null),nn(function(n){return e(e({},n),{open:!1})}),Te(null)},markdownStyles:te,sectionTitle:en.sectionTitle,referenceSectionTitle:en.refSectionTitle,cognitiveData:en.cognitiveData,anchorEl:en.anchorEl,sectionAnchorEl:en.sectionAnchorEl,scrollContainerEl:ln.current,badgeStyle:en.badgeStyle,docData:en.docData,deviationData:en.deviationData}),t(v,e({open:!!me,autoHideDuration:8e3,onClose:function(){return be(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:t(f,e({onClose:function(){return be(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:me}))})),(re.isHeaderVisible||re.isToggleVisible)&&i(s,e({sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between",bgcolor:"#FFFFFF",border:"1.5px solid #EEF0F4",borderTopLeftRadius:"8px",borderTopRightRadius:"8px"}},{children:[t(s,e({sx:{display:"flex",alignItems:"center",gap:1}},{children:re.isHeaderVisible&&t(d,e({sx:{fontSize:"16px",fontWeight:600,color:"#0F172A"}},{children:Q}))})),re.isToggleVisible&&t(s,e({sx:{display:"flex",alignItems:"center"}},{children:t(p,{control:t(h,{checked:ue,onChange:function(e){var n=e.target.checked;fe(!0),setTimeout(function(){de(n),Vn(),De(new Set),He([]),Oe.current=[],setTimeout(function(){fe(!1)},400)},50)},color:"primary",size:"small",sx:{width:100,height:26,padding:0,"& .MuiSwitch-switchBase":{padding:0,margin:"3px",transitionDuration:"300ms","&.Mui-checked":{transform:"translateX(75px)",color:"#fff","& + .MuiSwitch-track":{backgroundColor:"#5928ED",opacity:1,border:0,"&::before":{content:'"Side by Side"',position:"absolute",left:"13px",top:"50%",transform:"translateY(-50%)",fontSize:"9px",fontWeight:700,color:"#fff",letterSpacing:"0.3px"}}}},"& .MuiSwitch-thumb":{boxSizing:"border-box",width:20,height:20},"& .MuiSwitch-track":{borderRadius:13,backgroundColor:"#9e9e9e",opacity:1,position:"relative","&::after":{content:'"Side by Side"',position:"absolute",right:"13px",top:"50%",transform:"translateY(-50%)",fontSize:"9px",fontWeight:700,color:"#fff",letterSpacing:"0.3px",opacity:1,transition:"opacity 0.2s"}},"& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track":{"&::after":{opacity:0}}}}),label:"",labelPlacement:"start",sx:{m:0,gap:1}})}))]})),t(s,e({ref:ln,onScroll:_t,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:ue?"hidden":"auto",borderTop:jn&&Pn?"none":"1.5px solid #EEF0F4"}},{children:t(s,e({sx:e({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},ue?{flex:1,minHeight:0}:{})},{children:i(s,e({ref:Qn,sx:e({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"10px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},ue?{flex:1,overflow:"visible"}:{})},{children:[i("svg",e({ref:ze,style:{position:"absolute",top:0,left:0,width:Je.width||"100%",height:Je.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",transition:"opacity 0.15s ease-in-out"}},{children:[ut&&i("g",{children:[t("line",{x1:ut.x1,y1:ut.y,x2:Math.max(ut.x1,(ut.x1+ut.x2)/2-70),y2:ut.y,stroke:"#BBF7D0",strokeWidth:"1.5"}),t("line",{x1:Math.min(ut.x2,(ut.x1+ut.x2)/2+70),y1:ut.y,x2:ut.x2,y2:ut.y,stroke:"#BBF7D0",strokeWidth:"1.5"})]}),it.map(function(n){var r,o=(n.x1+n.x2)/2;if("Not Defined"===n.style.label&&!n.hasCognitive)return null;if(!ue)return i("g",{children:[t("line",{x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,stroke:n.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),t("foreignObject",e({x:o-100,y:n.y1-14,width:"200",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:t(s,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:i(s,e({onClick:function(e){if(e.stopPropagation(),en.open&&Be===n.id)gn();else{var t=Wn[n.sectionIdx]||{title:"",content:""},i=Nn[n.sectionIdx]||{title:"",content:""};if(n.isSubSection&&n.subSectionKeyPath){for(var r=n.subSectionKeyPath.split("-").map(Number),o=Wn[r[0]],l=Nn[r[0]],c=1;c<r.length;c++)(null==o?void 0:o.subsections)&&(o=o.subsections[r[c]]),(null==l?void 0:l.subsections)&&(l=l.subsections[r[c]]);o&&(t=o),l&&(i=l)}Te(n.id),qn(Xn(e.currentTarget,t,i,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:500,textAlign:"center",whiteSpace:"nowrap",cursor:"pointer"}},{children:[n.style.label,t(s,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:t(I,{})})),t(y,{size:11,style:{transform:en.open&&Be===n.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},n.id);var l=!1;if(n.isSubSection)l=Se&&lt===n.subSectionKeyPath&&Re;else{var c=Wn[n.sectionIdx];if(!(null===(r=null==c?void 0:c.refIndexes)||void 0===r?void 0:r.length)||(null==c?void 0:c.selfIndex)<0)return null;l=Se&&lt===n.sectionIdx&&Re}return l?i("g",e({style:{transition:"opacity 0.2s"}},{children:[t("defs",{children:t("marker",e({id:"arr-".concat(n.id),markerWidth:"7",markerHeight:"5",refX:"7",refY:"2.5",orient:"auto"},{children:t("polygon",{points:"0 0, 7 2.5, 0 5",fill:n.style.badgeBorder||"#6366F1"})}))}),t("line",{ref:$n,x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,stroke:n.style.badgeBorder||"#6366F1",strokeWidth:"1.5",markerEnd:"url(#arr-".concat(n.id,")")})]}),n.id):null}),Ae.map(function(n){var r,o=n.pathD,l=(null===(r=n.style)||void 0===r?void 0:r.badgeBorder)||"#6366F1",c="conn-marker-".concat(n.id),a="".concat(n.id,"-bg"),u="".concat(n.id,"-stroke");return i("g",{children:[t("defs",{children:t("clipPath",e({id:"connections-clip"},{children:t("marker",e({id:c,markerWidth:"8",markerHeight:"6",refX:"7",refY:"3",orient:"auto"},{children:t("polygon",{points:"0 0, 8 3, 0 6",fill:l})}))}))}),t("path",{ref:function(e){Le.current[a]=e},d:o,fill:"none",stroke:"#FFFFFF",strokeWidth:"4",strokeOpacity:"0.7"}),t("path",{ref:function(e){Le.current[u]=e},d:o,fill:"none",stroke:l,strokeWidth:"1.75",markerEnd:"url(#".concat(c,")")})]},n.id)})]})),i(s,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)"},ue?{flex:1,overflow:"visible"}:{})},{children:[t(s,e({ref:et,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",minHeight:"40px",alignItems:"center",overflowX:"hidden"}},{children:t(g,e({title:Hn,placement:"top"},{children:t(d,e({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",height:"40px"}},{children:Hn}))}))})),i(s,e({ref:fn,onScroll:_t,sx:e({p:"12px",display:"flex",flexDirection:"column"},ue?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-160px",pr:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[t("div",{ref:sn,style:{width:"100%",height:"0px",flexShrink:0}}),Ln&&Wn.map(function(n,o){var l,c,a,u=!n.title&&!n.content;if(ue&&u)return null;if(!ue)return t(s,e({ref:Kn(o)},{children:Mt({section:n,idx:o,columnKey:"left",colRef:pt.current[o],parentNodeId:(null===(l=null==Z?void 0:Z.input_index_map)||void 0===l?void 0:l[0])||""})}),"left-row-".concat(o));var d=n,v=wt(o),f=!(null===(c=d.refIndexes)||void 0===c?void 0:c.length)||d.selfIndex<0,p="number"==typeof d.selfIndex&&d.selfIndex>=0?d.selfIndex+1:null,h=ke.has(o);return t(s,e({ref:Kn(o),sx:{mb:1}},{children:i(s,e({sx:{position:"relative",width:"100%"}},{children:[t(s,e({ref:pt.current[o],sx:e({width:"100%",display:"flex"},h&&{borderRadius:"6px",outline:"2px solid ".concat((null==v?void 0:v.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:Mt({section:n,idx:o,columnKey:"left",colRef:r.createRef(),mb:0,parentNodeId:(null===(a=null==Z?void 0:Z.input_index_map)||void 0===a?void 0:a[0])||""})})),v&&i(s,e({ref:gt.current[o],onClick:function(e){var t=Nn.find(function(e){var n;return null===(n=d.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""};Un(e,n,f,t,o,v)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:v.badgeBg,color:v.badgeText,border:"1px solid ".concat(v.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!==p&&t(s,e({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(v.badgeBorder)}},{children:p})),t(s,e({component:"span",sx:{fontSize:"11px",px:.25}},{children:f?"No Deviation Found":0==v.deviationLabel||void 0===v.deviationLabel?"Same":"".concat(v.deviationLabel,"% Deviation")})),t(S,{size:11,color:v.badgeText})]}))]}))}),"left-row-".concat(o))}),t("div",{ref:vn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),t(s,e({sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0}},{children:t(s,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:i(s,e({sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",borderRadius:"20px",bgcolor:"#ECFDF3",border:"1px solid #A7F3D0",color:"#15803D",fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1}},{children:[t(s,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:t(I,{})})),0,"% Similarity",t(y,{size:11})]}))}))})),i(s,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},ue?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[he&&t(w,{sections:11}),t(s,e({ref:nt,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"40px",display:"flex",alignItems:"center",overflowX:"hidden"}},{children:t(g,e({title:zn,placement:"top"},{children:t(d,e({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",height:"40px"}},{children:zn}))}))})),i(s,e({ref:an,onScroll:_t,sx:e({p:"12px",display:"flex",flexDirection:"column"},ue?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-20px",pl:"40px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[t("div",{ref:un,style:{width:"100%",height:"0px",flexShrink:0}}),Ln&&Nn.map(function(n,o){var l,c;if(!ue)return Mt({section:n,idx:o,columnKey:"right",colRef:ht.current[o],parentNodeId:(null===(l=null==Z?void 0:Z.input_index_map)||void 0===l?void 0:l[1])||""});var a=n,u=Wn.filter(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(a.selfIndex))&&e.selfIndex>=0}).map(function(e){return e.selfIndex+1}),d=Wn.some(function(e,n){var t;return ke.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(a.selfIndex))}),v=Wn.findIndex(function(e,n){var t;return ke.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(a.selfIndex))}),f=-1!==v?wt(v):null;return t(s,e({ref:mt.current[o],sx:{mb:1}},{children:i(s,e({sx:{position:"relative",width:"100%"}},{children:[t(s,e({ref:ht.current[o],sx:e({width:"100%",display:"flex"},d&&f&&{borderRadius:"6px",outline:"2px solid ".concat(f.badgeBorder),outlineOffset:"1px"})},{children:Mt({section:n,idx:o,columnKey:"right",colRef:r.createRef(),mb:0,parentNodeId:(null===(c=null==Z?void 0:Z.input_index_map)||void 0===c?void 0:c[1])||""})})),!he&&t(s,e({ref:xt.current[o],sx:{position:"absolute",top:"18px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"11px",bgcolor:"#EEF2FF",color:"#3730A3",border:"1px solid #C7D2FE",borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:u.length>0?u.join(", "):"-"}))]}))}),"right-row-".concat(o))}),t("div",{ref:dn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))};export{Y as default};
1
+ import{__assign as e,__spreadArray as n}from"tslib";import{jsx as t,jsxs as i}from"react/jsx-runtime";import r,{useMemo as o,useState as l,useRef as c,useEffect as u,useCallback as a}from"react";import{Typography as d,Box as s,Snackbar as v,Alert as f,FormControlLabel as p,Switch as h,Tooltip as g,Accordion as x,AccordionSummary as m,AccordionDetails as b}from"@mui/material";import{ChevronDown as y,EllipsisVertical as S}from"lucide-react";import{ButtonCognitiveIcon as I}from"../../assests/svg/ButtonCognitiveIcon.js";import w from"./OverlayComponent.js";import R from"react-markdown";import{safeStringify as F,hasValue as C,getSideData as E,getRationale as B}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as T,DEFAULT_FIELD_CONFIG as _,DEFAULT_COMPARISON_CONFIG as k}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import D from"./CognitivePopup.js";import M from"./MoreFunctionsPopup.js";import A from"./LoaderComponent.js";import H from"rehype-raw";var z=r.memo(function(n){var i=n.content,r=n.sxStyles,l=n.highlights,c=void 0===l?[]:l,u=o(function(){return{mark:function(n){var i=n.children;return t("span",e({style:{backgroundColor:"#fccccc"}},{children:i}))}}},[]),a=o(function(){var e=i;return c.forEach(function(n){e=e.replaceAll(n,"<mark>".concat(n,"</mark>"))}),e},[i,c]);return t(d,e({component:"div",sx:r},{children:t(R,e({components:u,rehypePlugins:[H]},{children:F(a).replace(/\\n/g,"\n")}))}))},function(e,n){if(e.content!==n.content)return!1;if(e.sxStyles!==n.sxStyles)return!1;var t=e.highlights||[],i=n.highlights||[];if(t.length!==i.length)return!1;for(var r=0;r<t.length;r++)if(t[r]!==i[r])return!1;return!0}),W=function(e,n,t,i,r){void 0===r&&(r=14);var o=e+.65*(t-e),l=i-n;if(Math.abs(l)<3)return"M ".concat(e," ").concat(n," H ").concat(t);var c=l>0?1:-1,u=Math.min(r,Math.abs(l)/2,Math.abs(o-e)/2,Math.abs(t-o)/2);return["M ".concat(e," ").concat(n),"H ".concat(o-u),"Q ".concat(o," ").concat(n," ").concat(o," ").concat(n+c*u),"V ".concat(i-c*u),"Q ".concat(o," ").concat(i," ").concat(o+u," ").concat(i),"H ".concat(t)].join(" ")},N={id:"",title:""},L={open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,isOrphan:!1,docData:null,deviationData:null},O=function(e,n,t,i,r){void 0===t&&(t=300);var o=e.style.scrollBehavior;e.style.scrollBehavior="auto";var l=e.scrollTop,c=n-l,u=null,a=function(d){null===u&&(u=d);var s,v=d-u;v<t?(e.scrollTop=(s=v,s/=t,c*(--s*s*s+1)+l),r&&r(),requestAnimationFrame(a)):(e.scrollTop=n,e.style.scrollBehavior=o,r&&r(),i&&i())};requestAnimationFrame(a)},j=function(R){var H,j,P,Y,K,V,X,q,U=R.componentHeaderText,G=void 0===U?"Contract Comparison":U,J=R.treeData,Q=R.comparisonConfig,Z=R.leftColumnTitleText,$=R.rightColumnTitleText,ee=R.markdownStyles,ne=R.displayConfig,te=void 0===ne?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1}:ne,ie=R.popupConfig,re=R.deviationData,oe=void 0===re?{}:re,le=l(te.maintainRelativeOrder),ce=le[0],ue=le[1],ae=l(!1),de=ae[0],se=ae[1],ve=l(!1),fe=ve[0],pe=ve[1],he=l(null),ge=he[0],xe=he[1],me=l(!1),be=me[0],ye=me[1],Se=l(!1),Ie=Se[0],we=Se[1],Re=c(!1),Fe=l(null),Ce=Fe[0],Ee=Fe[1],Be=l(new Set),Te=Be[0],_e=Be[1],ke=l([]),De=ke[0],Me=ke[1],Ae=c(null),He=c(!1),ze=c(null),We=c({}),Ne=c([]),Le=c(!1),Oe=c(!1),je=c(null),Pe=o(function(){return(null==J?void 0:J.cognitive_decisioning)||{}},[J]),Ye=l(null),Ke=Ye[0],Ve=Ye[1],Xe=c(null),qe=l({width:0,height:0}),Ue=qe[0],Ge=qe[1],Je=o(function(){return e(e({},T),ee)},[ee]),Qe=l({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,isOrphan:!1,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null,deviationData:null}),Ze=Qe[0],$e=Qe[1],en=l({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,isOrphan:!1,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null,deviationData:null}),nn=en[0],tn=en[1],rn=c(null),on=c(null),ln=c(null),cn=c(null),un=c(null),an=c(null),dn=c(null),sn=c(null),vn=c(!1),fn=c(null);u(function(){fn.current=null},[Ze.sectionIdx,Ze.open]);var pn=a(function(){Ve(null),$e(L),Ee(null)},[]),hn=a(function(){tn(L)},[]),gn=a(function(){var e;if(Ze.anchorEl&&Ze.refSectionTitle){var n=Ze.anchorEl.getBoundingClientRect(),t=(null===(e=null==Xe?void 0:Xe.current)||void 0===e?void 0:e.offsetHeight)||0,i=Math.min(680,window.innerWidth-24),r=window.innerHeight-n.bottom-12-12,o=n.top-12-12,l=r<t&&o>r;null!==fn.current?!0===fn.current&&(l=o>=t||o>=r):l=!(r>=t||r>=o),fn.current=l;var c=l?o:r,u=Math.min(t||9999,c),a=l?n.top-12-u:n.bottom+12,d=n.left+n.width/2,s=d-i/2,v=Math.max(12,Math.min(s,window.innerWidth-i-12)),f=Math.max(14,Math.min(d-v,i-10-4));Ve({top:a,left:v,arrowLeft:f,openAbove:l,maxHeight:c})}},[Ze.anchorEl,Ze.refSectionTitle]);u(function(){if(Ze.open){window.addEventListener("resize",gn);var e=requestAnimationFrame(gn),n=null;return Xe.current&&(n=new ResizeObserver(function(){cancelAnimationFrame(e),e=requestAnimationFrame(gn)})).observe(Xe.current),function(){cancelAnimationFrame(e),window.removeEventListener("resize",gn),n&&n.disconnect()}}},[Ze.open,gn]),u(function(){var e=rn.current;if(e&&Ze.open){var n=function(e){Xe.current&&Xe.current.contains(e.target)||(Ve(null),pn())};return e.addEventListener("scroll",n,{capture:!0}),window.addEventListener("scroll",n,{capture:!0}),function(){e.removeEventListener("scroll",n,{capture:!0}),window.removeEventListener("scroll",n,{capture:!0})}}},[Ze.open,pn]),u(function(){var e=rn.current;if(e&&nn.open){var n=function(){hn()};return e.addEventListener("scroll",n,{capture:!0}),window.addEventListener("scroll",n,{capture:!0}),function(){e.removeEventListener("scroll",n,{capture:!0}),window.removeEventListener("scroll",n,{capture:!0})}}},[nn.open,hn]);var xn=o(function(){var n,t,i,r,o,l,c,u,a,d,s,v;return{fields:null!==(n=null==Q?void 0:Q.fields)&&void 0!==n?n:_,thresholds:{high:null!==(i=null===(t=null==Q?void 0:Q.thresholds)||void 0===t?void 0:t.high)&&void 0!==i?i:k.thresholds.high,medium:null!==(o=null===(r=null==Q?void 0:Q.thresholds)||void 0===r?void 0:r.medium)&&void 0!==o?o:k.thresholds.medium,exact:null!==(c=null===(l=null==Q?void 0:Q.thresholds)||void 0===l?void 0:l.exact)&&void 0!==c?c:k.thresholds.exact},relationStyles:{noContent:e(e({},k.relationStyles.noContent),(null===(u=null==Q?void 0:Q.relationStyles)||void 0===u?void 0:u.noContent)||{}),high:e(e({},k.relationStyles.high),(null===(a=null==Q?void 0:Q.relationStyles)||void 0===a?void 0:a.high)||{}),exact:e(e({},k.relationStyles.exact),(null===(d=null==Q?void 0:Q.relationStyles)||void 0===d?void 0:d.exact)||{}),medium:e(e({},k.relationStyles.medium),(null===(s=null==Q?void 0:Q.relationStyles)||void 0===s?void 0:s.medium)||{}),low:e(e({},k.relationStyles.low),(null===(v=null==Q?void 0:Q.relationStyles)||void 0===v?void 0:v.low)||{})}}},[Q]),mn=o(function(){if(J&&Object.keys(J).length>0)try{var t=function(t,i,r){var o,l,c,u;void 0===i&&(i=!1),void 0===r&&(r=null);var a=t.nodes||t,d=[],s=[],v=t.base_root_id,f=t.input_index_map||{0:"left",1:"right"},p=t[v]||a[v];if(!p||!1===p.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[]};var h=function(n,i){var o,l=t[n]||a[n];if(!l||!1===l.display_node)return null;var c=E(l,i,f),u=!!c.title.trim(),d=!!c.content.trim(),s=B(l),v=(null===(o=null==r?void 0:r[n])||void 0===o?void 0:o.evaluation_result)||l.evaluation_result||null,p=[];l.next&&Object.values(l.next).forEach(function(e){var n=a[e];if(n&&!1!==n.display_node){var t=h(e,i);t&&p.push(t)}});var g=!(!u&&!d);return e(e({id:n,title:u?c.title:"",content:d?c.content:"",subsections:p},g?s:{score:void 0,relation:"not_defined"}),{evaluationResult:v})};if(i){var g=function(i,o){var l,c,u,d,s,v,p,h,x,m,b,y,S;void 0===o&&(o=0);var I=[],w=[];if(!i)return{refSections:I,baseSections:w};var R={},F={},C=-1,T=-1;for(var _ in i){var k=i[_],D=t[k]||a[k];if(D&&!1!==D.display_node){var M=B(D),A=(null===(l=null==r?void 0:r[k])||void 0===l?void 0:l.evaluation_result)||D.evaluation_result||null,H=E(D,"1",f),z=E(D,"0",f),W=H.title.trim()||H.content.trim(),N=z.title.trim()||z.content.trim(),L=Number(null!==(u=null===(c=H.attributes)||void 0===c?void 0:c.display_index)&&void 0!==u?u:C--),O=Number(null!==(s=null===(d=z.attributes)||void 0===d?void 0:d.display_index)&&void 0!==s?s:T--),j=R[L]||e(e({id:k,title:W?H.title:"",content:W?H.content:"",subsections:[]},W?M:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:L,evaluationResult:A,displayContent:null===(v=H.attributes)||void 0===v?void 0:v.display_content,displayTitle:null===(p=H.attributes)||void 0===p?void 0:p.display_title}),P=F[O]||e(e({id:k,title:N?z.title:"",content:N?z.content:"",subsections:[]},N?M:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:O,evaluationResult:A,displayContent:null===(h=z.attributes)||void 0===h?void 0:h.display_content,displayTitle:null===(x=z.attributes)||void 0===x?void 0:x.display_title});Number(L)>=0&&Number(O)>=0&&((null===(m=j.refIndexes)||void 0===m?void 0:m.includes(Number(O)))||null===(b=j.refIndexes)||void 0===b||b.push(Number(O)),(null===(y=P.refIndexes)||void 0===y?void 0:y.includes(Number(L)))||null===(S=P.refIndexes)||void 0===S||S.push(Number(L))),R[L]=j,F[O]=P;var Y=g(D.next,o+1),K=Y.refSections,V=Y.baseSections;K.length>0&&(j.subsections=n(n([],j.subsections||[],!0),K,!0)),V.length>0&&(P.subsections=n(n([],P.subsections||[],!0),V,!0))}}return I=Object.values(R).map(function(e){return e}),w=Object.values(F).map(function(e){return e}),I.sort(function(e,n){return e.selfIndex<0&&n.selfIndex>=0?1:e.selfIndex>=0&&n.selfIndex<0?-1:e.selfIndex-n.selfIndex}),w.sort(function(e,n){return e.selfIndex<0&&n.selfIndex>=0?1:e.selfIndex>=0&&n.selfIndex<0?-1:e.selfIndex-n.selfIndex}),{refSections:I,baseSections:w}},x=g(p.next),m=x.refSections,b=x.baseSections;s=m,d=b}else p.next&&Object.values(p.next).forEach(function(e){var n=t[e]||a[e];n&&!1!==n.display_node&&(d.push(h(e,"0")||{id:e,title:"",content:"",subsections:[]}),s.push(h(e,"1")||{id:e,title:"",content:"",subsections:[]}))});return{activeProposed:{title:(null===(l=null===(o=p.comparison_inputs)||void 0===o?void 0:o[f[0]])||void 0===l?void 0:l.title)||"Uploaded Contract",description:p.decision_scope_description||"",sections:d},activeVariants:[{id:"tree-variant-1",title:(null===(u=null===(c=p.comparison_inputs)||void 0===c?void 0:c[f[1]])||void 0===u?void 0:u.title)||"Reference Template",similarity:0,sections:s,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:p.decision_scope_description||""},fields:{}}}}]}}(J,ce,oe);return e(e({},t),{parseError:null})}catch(e){return console.error("Data Transformation Error: ",e),{activeProposed:{},activeVariants:[],parseError:e instanceof Error?e.message:"Unknown Parsing Error"}}return{activeProposed:{},activeVariants:[],parseError:"Tree data is required"}},[JSON.stringify(J),ce,JSON.stringify(oe)]),bn=mn.activeProposed,yn=mn.activeVariants,Sn=mn.parseError;u(function(){Sn&&xe("Failed to load comparison: ".concat(Sn))},[Sn]);var In=l(null),wn=In[0];In[1];var Rn=l({}),Fn=Rn[0],Cn=Rn[1],En=l({}),Bn=En[0],Tn=En[1],_n=(null==yn?void 0:yn[0])||N,kn=null===(P=null===(H=null==J?void 0:J.documents)||void 0===H?void 0:H[null===(j=null==J?void 0:J.input_index_map)||void 0===j?void 0:j[0]])||void 0===P?void 0:P.title,Dn=null===(V=null===(Y=null==J?void 0:J.documents)||void 0===Y?void 0:Y[null===(K=null==J?void 0:J.input_index_map)||void 0===K?void 0:K[1]])||void 0===V?void 0:V.title,Mn=F(Z||kn||"Uploaded Contract"),An=F($||Dn||"Reference Template"),Hn=o(function(){return(null==bn?void 0:bn.sections)||[]},[null==bn?void 0:bn.sections]),zn=o(function(){return _n.sections||[]},[_n.sections]),Wn=Hn.length>0||zn.length>0,Nn=_n.analysis,Ln=F(null===(q=null===(X=null==Nn?void 0:Nn.rule_difference_comparison)||void 0===X?void 0:X.summary)||void 0===q?void 0:q.overall_summary),On=!!Ln.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),jn=c({}),Pn=function(e){return jn.current[e]||(jn.current[e]=r.createRef()),jn.current[e]},Yn=a(function(){ye(!1),Oe.current=!1,ot(null),je.current=null,Jn.current=null,we(!1),pe(!1),cn.current&&(cn.current.style.height="0px"),un.current&&(un.current.style.height="0px"),an.current&&(an.current.style.height="0px"),dn.current&&(dn.current.style.height="0px")},[]),Kn=a(function(e,n,t,i,r,o){var l,c,u=F(n.id)||F(t.id)||"",a=(u?Pe[u]:null)||n.cognitiveData||t.cognitiveData||{section_id:u,decisioning:[],gap:[],relevance_score:0},d=null!==(c=null===(l=jn.current[i])||void 0===l?void 0:l.current)&&void 0!==c?c:null;return{open:!0,sectionTitle:n.title||"N/A",refSectionTitle:t.title||"NA",cognitiveData:a,anchorEl:e,sectionAnchorEl:d,badgeStyle:o||null,sectionIdx:i,docData:{documents:null==J?void 0:J.documents,input_index_map:null==J?void 0:J.input_index_map},deviationData:n.evaluationResult||t.evaluationResult||null,isOrphan:!!r}},[Pe,J]),Vn=a(function(e){hn(),Ve(null),$e(e)},[hn]),Xn=function(e,n,t,i,r,o){e.stopPropagation(),nn.open&&nn.sectionIdx===r?hn():(pn(),tn(Kn(e.currentTarget,n,i,r,t,o)))},qn=a(function(){null!==nn.sectionIdx&&nn.anchorEl?Vn(e(e({},nn),{open:!0})):hn()},[nn,hn,Vn]);a(function(e){hn(),xe("".concat(e," is coming soon."))},[hn]);var Un=a(function(){var e=nn.sectionIdx,n=nn.isOrphan;if(hn(),null!==e){if(n)return xe("No counterpart exists to connect to."),void hn();Oe.current&&Yn(),_e(function(n){return n.has(e)?new Set:new Set([e])})}},[nn.sectionIdx,hn,Yn]),Gn=c(null),Jn=c(null),Qn=c(null),Zn=c(null),$n=c(null),et=l([]),nt=et[0],tt=et[1],it=l(null),rt=it[0],ot=it[1];c(null);var lt=l(null),ct=lt[0],ut=lt[1],at=o(function(){return xn.fields.filter(function(e){var n=e.key;return(!Wn||"description"!==n)&&(C(null==bn?void 0:bn[n])||C(_n[n]))})},[bn,_n,Wn,xn.fields]),dt=c({}),st=c({}),vt=c({}),ft=c({}),pt=c({}),ht=c({}),gt=c({}),xt=c({}),mt=c({});at.forEach(function(e){for(var n=e.key,t=0;t<Math.max(Hn.length,zn.length);t+=1)vt.current[t]||(vt.current[t]=r.createRef()),ft.current[t]||(ft.current[t]=r.createRef()),pt.current[t]||(pt.current[t]=r.createRef()),ht.current[t]||(ht.current[t]=r.createRef()),gt.current[t]||(gt.current[t]=r.createRef());dt.current[n]||(dt.current[n]=r.createRef()),st.current[n]||(st.current[n]=r.createRef())});for(var bt=0;bt<Math.max(Hn.length,zn.length);bt+=1)vt.current[bt]||(vt.current[bt]=r.createRef()),ft.current[bt]||(ft.current[bt]=r.createRef()),pt.current[bt]||(pt.current[bt]=r.createRef()),ht.current[bt]||(ht.current[bt]=r.createRef()),gt.current[bt]||(gt.current[bt]=r.createRef());u(function(){if(wn){var e=xn.fields.find(function(e){return e.analysisKey===wn||e.key===wn});if(e){var n=dt.current[e.key]||st.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[wn,xn.fields]);var yt=a(function(e){var n,t,i,r,o,l,c,u,a,d=null===(n=null==Nn?void 0:Nn.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!d||!d[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var s=d[e],v=(null==s?void 0:s.relation)||(null===(i=null===(t=null==s?void 0:s.highlights)||void 0===t?void 0:t.ruleA_spans)||void 0===i?void 0:i.length)||(null===(o=null===(r=null==s?void 0:s.highlights)||void 0===r?void 0:r.ruleB_spans)||void 0===o?void 0:o.length)||(null==s?void 0:s.mappings)&&s.mappings.length>0;if(s.mappings){var f=s.mappings[0]||{};return{score:s.score,relation:f.relation||"",highlightsA:(null===(l=f.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(c=f.highlights)||void 0===c?void 0:c.ruleB_spans)||[],hasContent:!!v}}return{score:s.score,relation:s.relation||"",highlightsA:(null===(u=s.highlights)||void 0===u?void 0:u.ruleA_spans)||[],highlightsB:(null===(a=s.highlights)||void 0===a?void 0:a.ruleB_spans)||[],hasContent:!!v}},[Nn]),St=a(function(n){var t,i,r,o=Hn[n],l=zn[n],c=(null==o?void 0:o.relation)&&"not_defined"!==o.relation,u=(null==l?void 0:l.relation)&&"not_defined"!==l.relation;F(null==o?void 0:o.id)||F(null==l?void 0:l.id);var a=!(!(null==o?void 0:o.cognitiveData)&&!(null==l?void 0:l.cognitiveData));if(!c&&!u&&!a)return e(e({},xn.relationStyles.noContent),{label:"Not Defined"});var d=null!==(i=null!==(t=null==o?void 0:o.evaluationResult)&&void 0!==t?t:null==l?void 0:l.evaluationResult)&&void 0!==i?i:null,s=(null===(r=null==d?void 0:d.evaluation_outputs)||void 0===r?void 0:r.output_value)+"%";return e(e({},xn.relationStyles.low),null!=d?{label:s}:{label:"N/A"})},[Hn,zn,Pe,xn,yt]),It=a(function(n){for(var t,i,r,o,l,c,u=n.split("-").map(Number),a=Hn[u[0]],d=zn[u[0]],s=1;s<u.length;s++)(null==a?void 0:a.subsections)&&(a=a.subsections[u[s]]),(null==d?void 0:d.subsections)&&(d=d.subsections[u[s]]);if(!a&&!d)return null;var v=(null==a?void 0:a.relation)&&"not_defined"!==a.relation,f=(null==d?void 0:d.relation)&&"not_defined"!==d.relation,p=F(null==a?void 0:a.id)||F(null==d?void 0:d.id)||"",h=!(!(null==a?void 0:a.cognitiveData)&&!(null==d?void 0:d.cognitiveData));if(!v&&!f&&!h)return e(e({},xn.relationStyles.noContent),{label:"Not Defined"});null!==(i=null!==(t=null==a?void 0:a.cognitiveRelevanceScore)&&void 0!==t?t:null==d?void 0:d.cognitiveRelevanceScore)&&void 0!==i||p&&(null===(r=Pe[p])||void 0===r||r.relevance_score);var g=null!==(l=null!==(o=null==a?void 0:a.evaluationResult)&&void 0!==o?o:null==d?void 0:d.evaluationResult)&&void 0!==l?l:null,x=(null===(c=null==g?void 0:g.evaluation_outputs)||void 0===c?void 0:c.output_value)+"%";return e(e({},xn.relationStyles.low),null!=g?{label:x}:{label:"N/A"})},[Hn,zn,Pe,xn]),wt=a(function(){var n,t,i,r,o,l,c,u,a,d,s,v,f,p,h,g,x,m,b,y,S,I;if(!vn.current&&!He.current){vn.current=!0;try{if(!Gn.current)return;var w=function(e){var n=e.split("-"),t=n[0];if(!Fn[t]&&!1===ce)return!1;if(ce&&!Fn["left-".concat(t)]&&!Fn["right-".concat(t)]&&!Fn[t])return!1;for(var i=t,r=1;r<n.length-1;r++)if(i+="-".concat(n[r]),!Bn[i])return!1;return!0},R=Gn.current.getBoundingClientRect();Ge({width:R.width,height:R.height});var C=[];if(at.forEach(function(e){var n,t,i=e.key,r=null===(n=dt.current[i])||void 0===n?void 0:n.current,o=null===(t=st.current[i])||void 0===t?void 0:t.current;r&&o&&(r.style.height="auto",o.style.height="auto",r.style.minHeight="0px",o.style.minHeight="0px")}),!He.current){for(var E=0;E<Math.max(Hn.length,zn.length);E++){var B=null===(n=vt.current[E])||void 0===n?void 0:n.current,T=null===(t=ft.current[E])||void 0===t?void 0:t.current;B&&(B.style.height="auto",B.style.minHeight="0px"),T&&(T.style.height="auto",T.style.minHeight="0px")}ce||Object.keys(xt.current).forEach(function(e){var n,t;if(w(e)){var i=null===(n=xt.current[e])||void 0===n?void 0:n.current,r=null===(t=mt.current[e])||void 0===t?void 0:t.current;i&&r&&(i.style.height="auto",r.style.height="auto",i.style.minHeight="0px",r.style.minHeight="0px")}})}var _={};at.forEach(function(e){var n,t,i=e.key,r=null===(n=dt.current[i])||void 0===n?void 0:n.current,o=null===(t=st.current[i])||void 0===t?void 0:t.current;if(r&&o){var l=r.getBoundingClientRect(),c=o.getBoundingClientRect();_[i]=Math.max(l.height,c.height)}});var k={left:{},right:{}},D={};if(!He.current)if(ce){if(be&&null!==rt)if("number"==typeof rt){var M=rt,A=Hn[M],H=null===(o=vt.current[M])||void 0===o?void 0:o.current;H&&A&&(A.refIndexes||[]).forEach(function(e){var n,t=zn.findIndex(function(n){return n.selfIndex===e}),i=null===(n=ft.current[t])||void 0===n?void 0:n.current;if(i&&(Fn["left-".concat(M)]||Fn["right-".concat(t)])){var r=Math.max(H.getBoundingClientRect().height,i.getBoundingClientRect().height);k.left[M]=Math.max(k.left[M]||0,r),k.right[t]=Math.max(k.right[t]||0,r)}})}else{var z=rt;B=null===(l=xt.current[z])||void 0===l?void 0:l.current,T=null===(c=mt.current[z])||void 0===c?void 0:c.current;if(B&&T){L=Math.max(B.getBoundingClientRect().height,T.getBoundingClientRect().height);D[z]=Math.max(D[z]||0,L)}}}else{for(E=0;E<Math.min(Hn.length,zn.length);E++){var B=null===(i=vt.current[E])||void 0===i?void 0:i.current,T=null===(r=ft.current[E])||void 0===r?void 0:r.current,N=!!Fn[String(E)];if(B&&T&&N){var L=Math.max(B.getBoundingClientRect().height,T.getBoundingClientRect().height);k.left[E]=L,k.right[E]=L}}Object.keys(xt.current).forEach(function(e){var n,t;if(w(e)){var i=null===(n=xt.current[e])||void 0===n?void 0:n.current,r=null===(t=mt.current[e])||void 0===t?void 0:t.current;if(i&&r&&null!==i.offsetParent&&null!==r.offsetParent){var o=i.getBoundingClientRect(),l=r.getBoundingClientRect();D[e]=Math.max(o.height,l.height)}}})}if(at.forEach(function(e){var n,t,i=e.key,r=null===(n=dt.current[i])||void 0===n?void 0:n.current,o=null===(t=st.current[i])||void 0===t?void 0:t.current;if(r&&o){var l=_[i];r.style.minHeight="".concat(l,"px"),o.style.minHeight="".concat(l,"px")}}),He.current||(Object.entries(k.left).forEach(function(e){var n,t=e[0],i=e[1],r=null===(n=vt.current[Number(t)])||void 0===n?void 0:n.current;r&&(r.style.minHeight="".concat(i,"px"))}),Object.entries(k.right).forEach(function(e){var n,t=e[0],i=e[1],r=null===(n=ft.current[Number(t)])||void 0===n?void 0:n.current;r&&(r.style.minHeight="".concat(i,"px"))}),ce||Object.keys(D).forEach(function(e){var n,t,i=null===(n=xt.current[e])||void 0===n?void 0:n.current,r=null===(t=mt.current[e])||void 0===t?void 0:t.current;if(i&&r&&D[e]){var o=D[e];i.style.minHeight="".concat(o,"px"),r.style.minHeight="".concat(o,"px")}})),ce){if(Hn.forEach(function(e,n){var t;(null===(t=vt.current[n])||void 0===t?void 0:t.current)&&(e.refIndexes||[]).forEach(function(e){var t,i,r,o,l,c,u,a,d,s,v=zn.findIndex(function(n){return n.selfIndex===e});if(-1!==v){var f=null===(t=pt.current[n])||void 0===t?void 0:t.current,p=null===(i=ht.current[v])||void 0===i?void 0:i.current;if(f&&p){var h=f.getBoundingClientRect(),g=p.getBoundingClientRect(),x=h.right-R.left,m=g.left-R.left,b=h.top+h.height/2-R.top,y=g.top+g.height/2-R.top;if(be&&rt===n){var S=null!==(o=null===(r=sn.current)||void 0===r?void 0:r.getBoundingClientRect().top)&&void 0!==o?o:0,I=null!==(c=null===(l=ln.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==c?c:0,w=S+(null!==(a=null===(u=sn.current)||void 0===u?void 0:u.clientHeight)&&void 0!==a?a:1/0),F=I+(null!==(s=null===(d=ln.current)||void 0===d?void 0:d.clientHeight)&&void 0!==s?s:1/0),E=h.top+h.height/2,B=function(e,n,t){return Math.max(n,Math.min(t,e))};b=B(E,S,w)-R.top,y=B(E,I,F)-R.top}var T=St(n);T&&C.push({id:"line-".concat(n,"-").concat(v),x1:x,y1:b,x2:m,y2:y,style:T,sectionIdx:n,targetRightIdx:v})}}})}),be&&"string"==typeof rt){z=rt;var O=null===(f=pt.current[z])||void 0===f?void 0:f.current,j=null===(p=ht.current[z])||void 0===p?void 0:p.current;if(O&&j){var P=O.getBoundingClientRect(),Y=j.getBoundingClientRect(),K=P.right-R.left,V=Y.left-R.left,X=null!==(g=null===(h=sn.current)||void 0===h?void 0:h.getBoundingClientRect().top)&&void 0!==g?g:0,q=null!==(m=null===(x=ln.current)||void 0===x?void 0:x.getBoundingClientRect().top)&&void 0!==m?m:0,U=X+(null!==(y=null===(b=sn.current)||void 0===b?void 0:b.clientHeight)&&void 0!==y?y:1/0),G=q+(null!==(I=null===(S=ln.current)||void 0===S?void 0:S.clientHeight)&&void 0!==I?I:1/0),J=P.top+P.height/2,Q=Y.top+Y.height/2,Z=function(e,n,t){return Math.max(n,Math.min(t,e))},$=Z(J,X,U)-R.top,ee=Z(Q,q,G)-R.top;(ie=It(z))&&C.push({id:"line-subsec-".concat(z),x1:K,y1:$,x2:V,y2:ee,style:ie,sectionIdx:Number(z.split("-")[0]),isSubSection:!0,subSectionKeyPath:z})}}}else{for(E=0;E<Math.min(Hn.length,zn.length);E++){var ne=null===(u=vt.current[E])||void 0===u?void 0:u.current,te=null===(a=ft.current[E])||void 0===a?void 0:a.current;if(ne&&te){var ie,re=ne.getBoundingClientRect(),oe=te.getBoundingClientRect(),le=(re.top+18-R.top+oe.top+18-R.top)/2,ue=(null===(d=zn[E])||void 0===d?void 0:d.id)||"sec-".concat(E);(ie=St(E))&&C.push({id:ue,x1:re.right-R.left,y1:le,x2:oe.left-R.left,y2:le,style:ie,sectionIdx:E,hasCognitive:!!((null===(s=Hn[E])||void 0===s?void 0:s.cognitiveData)||(null===(v=zn[E])||void 0===v?void 0:v.cognitiveData)||ue&&Pe[ue])})}}Object.keys(xt.current).forEach(function(n){var t,i,r,o,l,c;if(w(n)){for(var u=null===(t=xt.current[n])||void 0===t?void 0:t.current,a=n.split("-").map(Number),d=Hn[a[0]],s=1;s<a.length;s++)(null==d?void 0:d.subsections)&&(d=d.subsections[a[s]]);if(d&&(null===(i=d.refIndexes)||void 0===i?void 0:i.length)){var v=null===(r=mt.current[n])||void 0===r?void 0:r.current;if(u&&v&&null!==u.offsetParent&&null!==v.offsetParent){var f=u.getBoundingClientRect(),p=v.getBoundingClientRect(),h=(f.top+16-R.top+p.top+16-R.top)/2,g=n.split("-").map(Number),x=Hn[g[0]],m=zn[g[0]];for(s=1;s<g.length;s++)(null==x?void 0:x.subsections)&&(x=x.subsections[g[s]]),(null==m?void 0:m.subsections)&&(m=m.subsections[g[s]]);if(!x&&!m)return;var b=(null==x?void 0:x.relation)&&"not_defined"!==x.relation,y=(null==m?void 0:m.relation)&&"not_defined"!==m.relation,S=F(null==x?void 0:x.id)||F(null==m?void 0:m.id)||"",I=!(!(null==x?void 0:x.cognitiveData)&&!(null==m?void 0:m.cognitiveData)),E=null;if(b||y||I){var B=null!==(l=null!==(o=null==x?void 0:x.evaluationResult)&&void 0!==o?o:null==m?void 0:m.evaluationResult)&&void 0!==l?l:null,T=(null===(c=null==B?void 0:B.evaluation_outputs)||void 0===c?void 0:c.output_value)+"%";return e(e({},xn.relationStyles.low),null!=B?{label:T}:{label:"N/A"})}(E={badgeBg:"#EEF2FF",badgeText:"#3730A3",badgeBorder:"#C7D2FE"})&&C.push({id:"subsec-".concat(n),x1:f.right-R.left,y1:h,x2:p.left-R.left,y2:h,style:E,sectionIdx:g[0],isSubSection:!0,subSectionKeyPath:n,hasCognitive:I||S&&Pe[S]})}}}})}if(tt(C),Zn.current&&$n.current){var ae=Zn.current.getBoundingClientRect(),de=$n.current.getBoundingClientRect(),se=(ae.top+ae.height/2-R.top+de.top+de.height/2-R.top)/2;ut({x1:ae.right-R.left,x2:de.left-R.left,y:se})}else ut(null);if(ce&&Te.size>0){var ve=[],fe=sn.current,pe=ln.current;if(fe&&pe){var he=[],ge=fe.getBoundingClientRect().top,xe=pe.getBoundingClientRect().top,me=ge+fe.clientHeight,ye=xe+pe.clientHeight,Se=fe.scrollTop,Ie=pe.scrollTop,we=R.top,Re=function(e,n,t){return Math.max(n,Math.min(t,e))};Te.forEach(function(e){var n,t,i;if("string"==typeof e){var r=e,o=null===(n=pt.current[r])||void 0===n?void 0:n.current,l=null===(t=ht.current[r])||void 0===t?void 0:t.current;if(!o||!l)return;var c=o.getBoundingClientRect(),u=l.getBoundingClientRect(),a=It(r),d=c.right-R.left,s=u.left-R.left-0,v=d+.75*(s-d),f=c.top+c.height/2,p=u.top+u.height/2,h=f-ge+Se,g=p-xe+Ie,x="conn-subsec-".concat(r);he.push({lhsScrollY:h,rhsScrollY:g,x1:d,x2:s,containerTop:we,leftIdx:r,rhsArrayIdx:r,styleColor:(null==a?void 0:a.badgeBorder)||"#6366F1",styleId:x});var m=Re(f,ge,me),b=Re(p,xe,ye),y=m-we,S=b-we,I=f>=ge-4&&f<=me+4,w=p>=xe-4&&p<=ye+4,F="";F=I&&w?W(d,y,s,S):I&&!w?"M ".concat(d,",").concat(y," L ").concat(v,",").concat(y," L ").concat(v,",").concat(S):!I&&w?"M ".concat(v,",").concat(y," L ").concat(v,",").concat(S," L ").concat(s,",").concat(S):"M ".concat(v,",").concat(y," L ").concat(v,",").concat(S),ve.push({id:x,pathD:F,style:a,leftIdx:r,rhsArrayIdx:r})}else{var C=Hn[e];if(!(null===(i=null==C?void 0:C.refIndexes)||void 0===i?void 0:i.length))return;C.refIndexes.forEach(function(n){var t,i,r=zn.findIndex(function(e){return e.selfIndex===n});if(-1!==r){var o=null===(t=pt.current[e])||void 0===t?void 0:t.current,l=null===(i=ht.current[r])||void 0===i?void 0:i.current;if(o&&l){var c=o.getBoundingClientRect(),u=l.getBoundingClientRect(),a=St(e),d=c.right-R.left,s=u.left-R.left-0,v=d+.75*(s-d),f=c.top+c.height/2,p=u.top+u.height/2,h=f-ge+Se,g=p-xe+Ie,x="conn-".concat(e,"-").concat(r);he.push({lhsScrollY:h,rhsScrollY:g,x1:d,x2:s,containerTop:we,leftIdx:e,rhsArrayIdx:r,styleColor:(null==a?void 0:a.badgeBorder)||"#6366F1",styleId:x});var m=Re(f,ge,me),b=Re(p,xe,ye),y=m-we,S=b-we,I=f>=ge-4&&f<=me+4,w=p>=xe-4&&p<=ye+4,F="";F=I&&w?W(d,y,s,S):I&&!w?"M ".concat(d,",").concat(y," L ").concat(v,",").concat(y," L ").concat(v,",").concat(S):!I&&w?"M ".concat(v,",").concat(y," L ").concat(v,",").concat(S," L ").concat(s,",").concat(S):"M ".concat(v,",").concat(y," L ").concat(v,",").concat(S),ve.push({id:x,pathD:F,style:a,leftIdx:e,rhsArrayIdx:r})}}})}}),Ne.current=he}Me(ve)}else Me([]),Ne.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{vn.current=!1}}},[at,Hn,zn,Pe,xn,yt,St,ce,be,rt,Te,Fn,Bn]),Rt=a(function(){var e,n,t,i,r,o,l,c,u,a,d,s,v,f,p=Ne.current;if(p.length&&!He.current){var h=null!==(n=null===(e=sn.current)||void 0===e?void 0:e.scrollTop)&&void 0!==n?n:0,g=null!==(i=null===(t=ln.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,x=null!==(o=null===(r=sn.current)||void 0===r?void 0:r.clientHeight)&&void 0!==o?o:1/0,m=null!==(c=null===(l=ln.current)||void 0===l?void 0:l.clientHeight)&&void 0!==c?c:1/0,b=null!==(a=null===(u=sn.current)||void 0===u?void 0:u.getBoundingClientRect().top)&&void 0!==a?a:0,y=null!==(s=null===(d=ln.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==s?s:0,S=b+x,I=y+m,w=null!==(f=null===(v=Gn.current)||void 0===v?void 0:v.getBoundingClientRect().top)&&void 0!==f?f:0,R=function(e,n,t){return Math.max(n,Math.min(t,e))};p.forEach(function(e){var n=e.lhsScrollY-h+b,t=e.rhsScrollY-g+y,i=We.current[e.styleId+"-stroke"],r=We.current[e.styleId+"-bg"];if(i||r){var o,l=R(n,b,S),c=R(t,y,I),u=l-w,a=c-w,d=n>=b-4&&n<=S+4,s=t>=y-4&&t<=I+4,v=e.x1+.65*(e.x2-e.x1);o=d&&s?W(e.x1,u,e.x2,a):d&&!s?"M ".concat(e.x1,",").concat(u," L ").concat(v,",").concat(u," L ").concat(v,",").concat(a):!d&&s?"M ".concat(v,",").concat(u," L ").concat(v,",").concat(a," L ").concat(e.x2,",").concat(a):"M ".concat(v,",").concat(u," L ").concat(v,",").concat(a),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",o)),r&&(r.setAttribute("visibility","visible"),r.setAttribute("d",o))}})}},[]),Ft=c(wt);u(function(){Ft.current=wt},[wt]);var Ct=c(null),Et=a(function(){null!==Ct.current&&clearTimeout(Ct.current),Ct.current=setTimeout(function(){Ft.current(),Ct.current=null},50)},[]),Bt=a(function(e){var n,t,i,r,o,l,c,u;if(!Re.current){if(Oe.current){var a=je.current,d=Jn.current,s=sn.current,v=ln.current;if(null!==a&&null!==d&&s&&v){var f="string"==typeof a?null===(n=xt.current[a])||void 0===n?void 0:n.current:null===(t=jn.current[a])||void 0===t?void 0:t.current,p="string"==typeof d?null===(i=mt.current[d])||void 0===i?void 0:i.current:null===(r=gt.current[d])||void 0===r?void 0:r.current;if(f&&p){var h=f.getBoundingClientRect().top-s.getBoundingClientRect().top+s.scrollTop,g=p.getBoundingClientRect().top-v.getBoundingClientRect().top+v.scrollTop;if(e.currentTarget===s){var x=g-(h-s.scrollTop),m=v.scrollHeight-v.clientHeight,b=Math.max(0,Math.min(x,m));Math.abs(v.scrollTop-b)>1&&(v.scrollTop=b)}else if(e.currentTarget===v){var y=h-(g-v.scrollTop),S=s.scrollHeight-s.clientHeight,I=Math.max(0,Math.min(y,S));Math.abs(s.scrollTop-I)>1&&(s.scrollTop=I)}if(Qn.current){var w=null===(o=pt.current[a])||void 0===o?void 0:o.current,R=null===(l=ht.current[d])||void 0===l?void 0:l.current,F=null!==(u=null===(c=Gn.current)||void 0===c?void 0:c.getBoundingClientRect().top)&&void 0!==u?u:0,C=s.getBoundingClientRect().top,E=C+s.clientHeight,B=v.getBoundingClientRect().top,T=B+v.clientHeight,_=function(e,n,t){return Math.max(n,Math.min(t,e))};if(w&&R){var k=w.getBoundingClientRect(),D=R.getBoundingClientRect(),M=k.top+k.height/2,A=D.top+D.height/2,H=_(M,C,E),z=_(A,B,T);Qn.current.setAttribute("y1",(H-F).toString()),Qn.current.setAttribute("y2",(z-F).toString());var W=M>=C-4&&M<=E+4;Qn.current.setAttribute("visibility",W?"visible":"hidden")}}}}}Ne.current.length>0&&!Le.current&&(Le.current=!0,requestAnimationFrame(function(){Rt(),Le.current=!1}))}},[Rt]);u(function(){var e=setTimeout(Et,250);window.addEventListener("resize",Et);var n=null,t=null;return rn.current&&(n=new ResizeObserver(Et)).observe(rn.current),Gn.current&&(t=new ResizeObserver(Et)).observe(Gn.current),function(){clearTimeout(e),window.removeEventListener("resize",Et),null==n||n.disconnect(),null==t||t.disconnect()}},[bn,_n,Nn,at,Fn,Bn,Hn,zn,xn,Et,be,rt,Ie,Te]),u(function(){Oe.current=be},[be]),u(function(){je.current=rt},[rt]);var Tt=a(function(){var e=nn.sectionIdx,n=nn.isOrphan;if(null!=e)return n?(xe("No counterpart exists for this section."),void hn()):void(be&&rt===e?Yn():(_e(new Set),Me([]),Ne.current=[],pe(!0),Re.current=!0,ot(e),je.current=e,ye(!0),Oe.current=!0,we(!1),cn.current&&(cn.current.style.height="0px"),un.current&&(un.current.style.height="0px"),an.current&&(an.current.style.height="0px"),dn.current&&(dn.current.style.height="0px"),requestAnimationFrame(function(){var n,t,i,r,o=null,l=null,c=null;if("string"==typeof e)o=(null===(n=xt.current[e])||void 0===n?void 0:n.current)||null,c=(l=(null===(t=mt.current[e])||void 0===t?void 0:t.current)||null)?e:null;else{o=(null===(i=jn.current[e])||void 0===i?void 0:i.current)||null;var u=Hn[e],a=(null==u?void 0:u.refIndexes)||[];if(a.length>0){var d=a[0],s=zn.findIndex(function(e){return e.selfIndex===d});-1!==s&&(l=(null===(r=gt.current[s])||void 0===r?void 0:r.current)||null,c=s)}}Jn.current=c;var v=sn.current,f=ln.current;if(!o||!v)return Re.current=!1,void pe(!1);if(!l||!f)return we(!0),Ft.current(),Re.current=!1,void pe(!1);var p=o.getBoundingClientRect().top-v.getBoundingClientRect().top+v.scrollTop,h=l.getBoundingClientRect().top-f.getBoundingClientRect().top+f.scrollTop-(p-v.scrollTop);h<0&&cn.current&&(cn.current.style.height="".concat(Math.abs(h),"px"));requestAnimationFrame(function(){var e,n=f.scrollHeight-f.clientHeight;if(h<0)e=0;else{if(h>n){var t=h-n;return un.current&&(un.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){O(f,h,200,function(){we(!0),Ft.current(),Re.current=!1,pe(!1)})})}e=h}O(f,e,200,function(){we(!0),Ft.current(),Re.current=!1,pe(!1)})})})));hn()},[hn,nn.sectionIdx,be,rt,Hn,zn,Et,Yn]),_t=null!==nn.sectionIdx&&Te.has(nn.sectionIdx),kt=function(n){var o,l,c,u=n.section,a=n.idx,v=n.columnKey,f=n.colRef,p=n.mb,h=void 0===p?1:p,S=n.parentNodeId,I=void 0===S?"":S,w=ce?!!Fn["".concat(v,"-").concat(a)]:!!Fn[String(a)],R=(null===(o=u.displayTitle)||void 0===o||o)&&C(u.title),E=(null===(l=u.displayContent)||void 0===l||l)&&C(u.content),B=!R&&!E,T=u.title;R||(T=E?"No Title Found":"No Matching Section Found");var _,k=[];if(null===(c=u.evaluationResult)||void 0===c?void 0:c.deviations){var D=u.evaluationResult.deviations;for(var M in D){var A=D[M][I];A&&k.push(A)}}return t(s,e({ref:f,sx:{mb:h,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:i(x,e({disableGutters:!0,expanded:!B&&w,onChange:function(){return!B&&function(n,t){var i,r;He.current=!0,ze.current&&clearTimeout(ze.current),Ae.current&&(Ae.current.style.opacity="0");var o=null===(i=vt.current[n])||void 0===i?void 0:i.current,l=null===(r=ft.current[n])||void 0===r?void 0:r.current;if(o&&(o.style.minHeight="0px"),l&&(l.style.minHeight="0px"),Object.keys(xt.current).forEach(function(e){var t,i;if(e.startsWith("".concat(n,"-"))){var r=null===(t=xt.current[e])||void 0===t?void 0:t.current,o=null===(i=mt.current[e])||void 0===i?void 0:i.current;r&&(r.style.minHeight="0px"),o&&(o.style.minHeight="0px")}}),ce){var c=Hn[n];((null==c?void 0:c.refIndexes)||[]).forEach(function(e){var n,t=zn.findIndex(function(n){return n.selfIndex===e}),i=null===(n=ft.current[t])||void 0===n?void 0:n.current;i&&(i.style.minHeight="0px")});var u=zn[n],a=null==u?void 0:u.selfIndex;Hn.forEach(function(e,n){var t,i;if(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(a)){var r=null===(i=vt.current[n])||void 0===i?void 0:i.current;r&&(r.style.minHeight="0px")}})}ze.current=setTimeout(function(){He.current=!1,Ft.current(),Ae.current&&(Ae.current.style.opacity="1")},650),Cn(function(i){var r=e({},i);if(!ce){var o=!!i[String(n)];return r[String(n)]=!o,r}var l="".concat(t,"-").concat(n),c=!i[l];if(r[l]=c,"left"===t)((null==(u=Hn[n])?void 0:u.refIndexes)||[]).forEach(function(e){var n=zn.findIndex(function(n){return n.selfIndex===e});-1!==n&&(r["right-".concat(n)]=c)});else{var u,a=null==(u=zn[n])?void 0:u.selfIndex;Hn.forEach(function(e,n){var t;(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(a))&&(r["left-".concat(n)]=c)})}return r})}(a,v)},sx:{boxShadow:"none",border:B?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:B?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flexGrow:1,width:"100%",display:"flex",flexDirection:"column",minWidth:0,"&:before":{display:"none"}}},{children:[t(m,e({expandIcon:B?null:t(y,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:B?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:R&&t(g,e({title:T,placement:"top"},{children:t(d,e({component:"div",sx:{fontSize:"12px",color:B?"#94A3B8":"#19213D",fontWeight:B?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(_=T,_?F(_).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(e,n){return e.startsWith("**")&&e.endsWith("**")?t("strong",{children:e.slice(2,-2)},n):t(r.Fragment,{children:e},n)}):null)}))}))})),!B&&i(b,e({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[E&&t(z,{content:u.content,sxStyles:Je,highlights:k}),(u.subsections||[]).map(function(e,n){return Dt({section:e,keyPath:"".concat(a,"-").concat(n),depth:0,columnKey:v,parentNodeId:I})})]}))]}))}),"".concat(v,"-sec-").concat(a))},Dt=function(n){var o,l,c,u=n.section,a=n.keyPath,v=n.depth,f=void 0===v?0:v,p=n.columnKey,h=void 0===p?"left":p,g=n.parentNodeId,I=void 0===g?"":g,w=(null===(o=u.displayTitle)||void 0===o||o)&&C(u.title),R=(null===(l=u.displayContent)||void 0===l||l)&&C(u.content),F=!w&&!R,E=w?u.title:R?"No Title Found":"No Matching Section Found",B=!!Bn[a];"left"!==h||xt.current[a]||(xt.current[a]=r.createRef()),"right"!==h||mt.current[a]||(mt.current[a]=r.createRef());var T="left"===h?xt.current[a]:mt.current[a];pt.current[a]||(pt.current[a]=r.createRef()),ht.current[a]||(ht.current[a]=r.createRef());for(var _=a.split("-").map(function(e){return Number(e)+1}).join("."),k=It(a),D=ce&&Te.has(a),M=a.split("-").map(Number),A=Hn[M[0]],H=zn[M[0]],W=1;W<M.length;W++)(null==A?void 0:A.subsections)&&(A=A.subsections[M[W]]),(null==H?void 0:H.subsections)&&(H=H.subsections[M[W]]);var N=!(null===(c=u.refIndexes)||void 0===c?void 0:c.length)||void 0!==u.selfIndex&&u.selfIndex<0,L="left"===h&&N,O="right"===h&&N;return i(s,w?e({ref:T,sx:{mt:1,width:"100%",minWidth:0,position:"relative"}},{children:[t(s,e({sx:e({width:"100%"},D&&k&&{borderRadius:"4px",outline:"2px solid ".concat(k.badgeBorder),outlineOffset:"1px"})},{children:i(x,e({disableGutters:!0,expanded:!F&&B,onChange:function(){return!F&&Tn(function(n){var t;return e(e({},n),((t={})[a]=!n[a],t))})},sx:{mt:0,boxShadow:"none",border:F?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF",minWidth:0,"&:before":{display:"none"}}},{children:[t(m,e({expandIcon:F?null:t(y,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"}}},{children:t(d,e({component:"div",sx:{fontSize:"11px",fontWeight:600,color:F?"#94A3B8":"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:E||"Untitled Subsection"}))})),!F&&i(b,e({sx:{pt:0,pb:1,minWidth:0}},{children:[R&&t(z,{content:u.content,sxStyles:Je,highlights:function(){var e,n;if(!(null===(e=u.evaluationResult)||void 0===e?void 0:e.deviations))return[];var t=(null===(n=u.evaluationResult)||void 0===n?void 0:n.deviations)||{},i=[];for(var r in t){var o=t[r][I];o&&i.push(o)}return i}()}),(u.subsections||[]).map(function(e,n){return Dt({section:e,keyPath:"".concat(a,"-").concat(n),depth:f+1,columnKey:h,parentNodeId:I})})]}))]}))})),ce&&"left"===h&&k&&!F&&i(s,e({ref:pt.current[a],onClick:function(e){e.stopPropagation();for(var n=a.split("-").map(Number),t=Hn[n[0]],i=zn[n[0]],r=1;r<n.length;r++)(null==t?void 0:t.subsections)&&(t=t.subsections[n[r]]),(null==i?void 0:i.subsections)&&(i=i.subsections[n[r]]);Xn(e,t||{title:"",content:""},L||O,i||{title:"",content:""},a,k)},sx:{position:"absolute",top:"16px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"10px",bgcolor:k.badgeBg,color:k.badgeText,border:"1px solid ".concat(k.badgeBorder),borderRadius:"12px",px:1,py:.3,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[t(s,e({component:"span",sx:{fontSize:"10px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(k.badgeBorder)}},{children:_})),t(s,e({component:"span",sx:{fontSize:"10px",px:.25}},{children:L?"No Deviation Found":0==k.deviationLabel||void 0===k.deviationLabel?k.label:"".concat(k.deviationLabel,"% Deviation")})),t(S,{size:10,color:k.badgeText})]})),ce&&"right"===h&&k&&!F&&!fe&&t(s,e({ref:ht.current[a],sx:{position:"absolute",top:"16px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"10px",bgcolor:"#EEF2FF",color:"#3730A3",border:"1px solid #C7D2FE",borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:O?"-":_}))]}):e({ref:T,sx:{mt:0===f?1:.75,width:"100%",minWidth:0,position:"relative"}},{children:[!F&&i(s,e({sx:e({width:"100%"},D&&k&&{borderRadius:"4px",outline:"2px solid ".concat(k.badgeBorder),outlineOffset:"1px"})},{children:[R&&t(z,{content:u.content,sxStyles:Je,highlights:function(){var e,n;if(!(null===(e=u.evaluationResult)||void 0===e?void 0:e.deviations))return[];var t=(null===(n=u.evaluationResult)||void 0===n?void 0:n.deviations)||{},i=[];for(var r in t){var o=t[r][I];o&&i.push(o)}return i}()}),(u.subsections||[]).map(function(e,n){return Dt({section:e,keyPath:"".concat(a,"-").concat(n),depth:f+1,columnKey:h,parentNodeId:I})})]})),ce&&"left"===h&&k&&!F&&i(s,e({ref:pt.current[a],onClick:function(e){var n;e.stopPropagation();var t=function(e,n){for(var i=0,r=e;i<r.length;i++){var o=r[i];if(o.selfIndex===n)return o;if(o.subsections){var l=t(o.subsections,n);if(l)return l}}return null},i=null===(n=u.refIndexes)||void 0===n?void 0:n[0],r="number"==typeof i?t(zn,i):null;Xn(e,u,N,r||{title:"",content:""},a,k)},sx:{position:"absolute",top:"16px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"10px",bgcolor:k.badgeBg,color:k.badgeText,border:"1px solid ".concat(k.badgeBorder),borderRadius:"12px",px:1,py:.3,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[t(s,e({component:"span",sx:{fontSize:"10px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(k.badgeBorder)}},{children:_})),t(s,e({component:"span",sx:{fontSize:"10px",px:.25}},{children:L?"No Deviation Found":0==k.deviationLabel||void 0===k.deviationLabel?k.label:"".concat(k.deviationLabel,"% Deviation")})),t(S,{size:10,color:k.badgeText})]})),ce&&"right"===h&&k&&!F&&!fe&&t(s,e({ref:ht.current[a],sx:{position:"absolute",top:"16px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"10px",bgcolor:"#EEF2FF",color:"#3730A3",border:"1px solid #C7D2FE",borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:O?"-":_}))]}),a)};return i(s,e({ref:on,sx:e(e({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},ce?{}:{overflow:"visible"}),{position:"relative"})},{children:[de&&t(s,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:t(A,{})})),ce&&t(M,{open:nn.open,anchorEl:nn.anchorEl,sectionTitle:nn.sectionTitle,referenceSectionTitle:nn.refSectionTitle,onClose:hn,onOpenCognitiveCompare:qn,onOpenSideBySide:Tt,onConnect:Un,isConnected:_t}),Ze.open&&t(D,{open:Ze.open,popupRef:Xe,position:Ke,popupConfig:ie,onClose:function(){Ve(null),$e(function(n){return e(e({},n),{open:!1})}),Ee(null)},markdownStyles:ee,sectionTitle:Ze.sectionTitle,referenceSectionTitle:Ze.refSectionTitle,cognitiveData:Ze.cognitiveData,anchorEl:Ze.anchorEl,sectionAnchorEl:Ze.sectionAnchorEl,scrollContainerEl:rn.current,badgeStyle:Ze.badgeStyle,docData:Ze.docData,deviationData:Ze.deviationData}),t(v,e({open:!!ge,autoHideDuration:8e3,onClose:function(){return xe(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:t(f,e({onClose:function(){return xe(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:ge}))})),(te.isHeaderVisible||te.isToggleVisible)&&i(s,e({sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between",bgcolor:"#FFFFFF",border:"1.5px solid #EEF0F4",borderTopLeftRadius:"8px",borderTopRightRadius:"8px"}},{children:[t(s,e({sx:{display:"flex",alignItems:"center",gap:1}},{children:te.isHeaderVisible&&t(d,e({sx:{fontSize:"16px",fontWeight:600,color:"#0F172A"}},{children:G}))})),te.isToggleVisible&&t(s,e({sx:{display:"flex",alignItems:"center"}},{children:t(p,{control:t(h,{checked:ce,onChange:function(e){var n=e.target.checked;se(!0),setTimeout(function(){ue(n),Yn(),_e(new Set),Me([]),Ne.current=[],setTimeout(function(){se(!1)},400)},50)},color:"primary",size:"small",sx:{width:100,height:26,padding:0,"& .MuiSwitch-switchBase":{padding:0,margin:"3px",transitionDuration:"300ms","&.Mui-checked":{transform:"translateX(75px)",color:"#fff","& + .MuiSwitch-track":{backgroundColor:"#5928ED",opacity:1,border:0,"&::before":{content:'"Side by Side"',position:"absolute",left:"13px",top:"50%",transform:"translateY(-50%)",fontSize:"9px",fontWeight:700,color:"#fff",letterSpacing:"0.3px"}}}},"& .MuiSwitch-thumb":{boxSizing:"border-box",width:20,height:20},"& .MuiSwitch-track":{borderRadius:13,backgroundColor:"#9e9e9e",opacity:1,position:"relative","&::after":{content:'"Side by Side"',position:"absolute",right:"13px",top:"50%",transform:"translateY(-50%)",fontSize:"9px",fontWeight:700,color:"#fff",letterSpacing:"0.3px",opacity:1,transition:"opacity 0.2s"}},"& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track":{"&::after":{opacity:0}}}}),label:"",labelPlacement:"start",sx:{m:0,gap:1}})}))]})),t(s,e({ref:rn,onScroll:Bt,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:ce?"hidden":"auto",borderTop:Ln&&On?"none":"1.5px solid #EEF0F4"}},{children:t(s,e({sx:e({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},ce?{flex:1,minHeight:0}:{})},{children:i(s,e({ref:Gn,sx:e({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"10px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},ce?{flex:1,overflow:"visible"}:{})},{children:[i("svg",e({ref:Ae,style:{position:"absolute",top:0,left:0,width:Ue.width||"100%",height:Ue.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",transition:"opacity 0.15s ease-in-out"}},{children:[ct&&i("g",{children:[t("line",{x1:ct.x1,y1:ct.y,x2:Math.max(ct.x1,(ct.x1+ct.x2)/2-70),y2:ct.y,stroke:"#BBF7D0",strokeWidth:"1.5"}),t("line",{x1:Math.min(ct.x2,(ct.x1+ct.x2)/2+70),y1:ct.y,x2:ct.x2,y2:ct.y,stroke:"#BBF7D0",strokeWidth:"1.5"})]}),nt.map(function(n){var r,o=(n.x1+n.x2)/2;if("Not Defined"===n.style.label&&!n.hasCognitive)return null;if(!ce)return i("g",{children:[t("line",{x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,stroke:n.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),t("foreignObject",e({x:o-100,y:n.y1-14,width:"200",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:t(s,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:i(s,e({onClick:function(e){if(e.stopPropagation(),Ze.open&&Ce===n.id)pn();else{var t=Hn[n.sectionIdx]||{title:"",content:""},i=zn[n.sectionIdx]||{title:"",content:""};if(n.isSubSection&&n.subSectionKeyPath){for(var r=n.subSectionKeyPath.split("-").map(Number),o=Hn[r[0]],l=zn[r[0]],c=1;c<r.length;c++)(null==o?void 0:o.subsections)&&(o=o.subsections[r[c]]),(null==l?void 0:l.subsections)&&(l=l.subsections[r[c]]);o&&(t=o),l&&(i=l)}Ee(n.id),Vn(Kn(e.currentTarget,t,i,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:500,textAlign:"center",whiteSpace:"nowrap",cursor:"pointer"}},{children:[n.style.label,t(s,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:t(I,{})})),t(y,{size:11,style:{transform:Ze.open&&Ce===n.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},n.id);var l=!1;if(n.isSubSection)l=be&&rt===n.subSectionKeyPath&&Ie;else{var c=Hn[n.sectionIdx];if(!(null===(r=null==c?void 0:c.refIndexes)||void 0===r?void 0:r.length)||(null==c?void 0:c.selfIndex)<0)return null;l=be&&rt===n.sectionIdx&&Ie}return l?i("g",e({style:{transition:"opacity 0.2s"}},{children:[t("defs",{children:t("marker",e({id:"arr-".concat(n.id),markerWidth:"7",markerHeight:"5",refX:"7",refY:"2.5",orient:"auto"},{children:t("polygon",{points:"0 0, 7 2.5, 0 5",fill:n.style.badgeBorder||"#6366F1"})}))}),t("line",{ref:Qn,x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,stroke:n.style.badgeBorder||"#6366F1",strokeWidth:"1.5",markerEnd:"url(#arr-".concat(n.id,")")})]}),n.id):null}),De.map(function(n){var r,o=n.pathD,l=(null===(r=n.style)||void 0===r?void 0:r.badgeBorder)||"#6366F1",c="conn-marker-".concat(n.id),u="".concat(n.id,"-bg"),a="".concat(n.id,"-stroke");return i("g",{children:[t("defs",{children:t("clipPath",e({id:"connections-clip"},{children:t("marker",e({id:c,markerWidth:"8",markerHeight:"6",refX:"7",refY:"3",orient:"auto"},{children:t("polygon",{points:"0 0, 8 3, 0 6",fill:l})}))}))}),t("path",{ref:function(e){We.current[u]=e},d:o,fill:"none",stroke:"#FFFFFF",strokeWidth:"4",strokeOpacity:"0.7"}),t("path",{ref:function(e){We.current[a]=e},d:o,fill:"none",stroke:l,strokeWidth:"1.75",markerEnd:"url(#".concat(c,")")})]},n.id)})]})),i(s,e({sx:e({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},ce?{flex:1,overflow:"visible"}:{})},{children:[t(s,e({ref:Zn,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",minHeight:"40px",alignItems:"center",overflowX:"hidden"}},{children:t(g,e({title:Mn,placement:"top"},{children:t(d,e({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",height:"40px"}},{children:Mn}))}))})),i(s,e({ref:sn,onScroll:Bt,sx:e({p:"12px",display:"flex",flexDirection:"column"},ce?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-160px",pr:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[t("div",{ref:an,style:{width:"100%",height:"0px",flexShrink:0}}),Wn&&Hn.map(function(n,o){var l,c,u,a=!n.title&&!n.content;if(ce&&a)return null;if(!ce)return t(s,e({ref:Pn(o)},{children:kt({section:n,idx:o,columnKey:"left",colRef:vt.current[o],parentNodeId:(null===(l=null==J?void 0:J.input_index_map)||void 0===l?void 0:l[0])||""})}),"left-row-".concat(o));var d=n,v=St(o),f=!(null===(c=d.refIndexes)||void 0===c?void 0:c.length)||d.selfIndex<0,p="number"==typeof d.selfIndex&&d.selfIndex>=0?d.selfIndex+1:null,h=Te.has(o);return t(s,e({ref:Pn(o),sx:{mb:1}},{children:i(s,e({sx:{position:"relative",width:"100%"}},{children:[t(s,e({ref:vt.current[o],sx:e({width:"100%",display:"flex"},h&&{borderRadius:"6px",outline:"2px solid ".concat((null==v?void 0:v.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:kt({section:n,idx:o,columnKey:"left",colRef:r.createRef(),mb:0,parentNodeId:(null===(u=null==J?void 0:J.input_index_map)||void 0===u?void 0:u[0])||""})})),v&&i(s,e({ref:pt.current[o],onClick:function(e){var t=zn.find(function(e){var n;return null===(n=d.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""};Xn(e,n,f,t,o,v)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:v.badgeBg,color:v.badgeText,border:"1px solid ".concat(v.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!==p&&t(s,e({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(v.badgeBorder)}},{children:p})),t(s,e({component:"span",sx:{fontSize:"11px",px:.25}},{children:f?"No Deviation Found":0==v.deviationLabel||void 0===v.deviationLabel?v.label:"".concat(v.deviationLabel,"% Deviation")})),t(S,{size:11,color:v.badgeText})]}))]}))}),"left-row-".concat(o))}),t("div",{ref:dn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),t(s,e({sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0}},{children:t(s,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:i(s,e({sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",borderRadius:"20px",bgcolor:"#ECFDF3",border:"1px solid #A7F3D0",color:"#15803D",fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1}},{children:[t(s,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:t(I,{})})),0,"% Similarity",t(y,{size:11})]}))}))})),i(s,e({sx:e({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},ce?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[fe&&t(w,{sections:11}),t(s,e({ref:$n,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"40px",display:"flex",alignItems:"center",overflowX:"hidden"}},{children:t(g,e({title:An,placement:"top"},{children:t(d,e({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",height:"40px"}},{children:An}))}))})),i(s,e({ref:ln,onScroll:Bt,sx:e({p:"12px",display:"flex",flexDirection:"column"},ce?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-20px",pl:"40px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[t("div",{ref:cn,style:{width:"100%",height:"0px",flexShrink:0}}),Wn&&zn.map(function(n,o){var l,c;if(!ce)return kt({section:n,idx:o,columnKey:"right",colRef:ft.current[o],parentNodeId:(null===(l=null==J?void 0:J.input_index_map)||void 0===l?void 0:l[1])||""});var u=n,a=Hn.filter(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(u.selfIndex))&&e.selfIndex>=0}).map(function(e){return e.selfIndex+1}),d=Hn.some(function(e,n){var t;return Te.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(u.selfIndex))}),v=Hn.findIndex(function(e,n){var t;return Te.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(u.selfIndex))}),f=-1!==v?St(v):null;return t(s,e({ref:gt.current[o],sx:{mb:1}},{children:i(s,e({sx:{position:"relative",width:"100%"}},{children:[t(s,e({ref:ft.current[o],sx:e({width:"100%",display:"flex"},d&&f&&{borderRadius:"6px",outline:"2px solid ".concat(f.badgeBorder),outlineOffset:"1px"})},{children:kt({section:n,idx:o,columnKey:"right",colRef:r.createRef(),mb:0,parentNodeId:(null===(c=null==J?void 0:J.input_index_map)||void 0===c?void 0:c[1])||""})})),!fe&&t(s,e({ref:ht.current[o],sx:{position:"absolute",top:"18px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"11px",bgcolor:"#EEF2FF",color:"#3730A3",border:"1px solid #C7D2FE",borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:a.length>0?a.join(", "):"-"}))]}))}),"right-row-".concat(o))}),t("div",{ref:un,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))};export{j as default};
2
2
  //# sourceMappingURL=CognitiveCompare.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as n}from"tslib";var i=function(n){return null==n?"":"string"==typeof n?n:Array.isArray(n)?n.map(i).join("\n\n"):"object"==typeof n?JSON.stringify(n):String(n)},t=function(n){return null!=n&&("string"==typeof n?n.trim().length>0:!Array.isArray(n)||n.length>0&&n.some(function(n){return t(n)}))},e=function(n,t,e){var r,o=e[t],a=null===(r=null==n?void 0:n.comparison_inputs)||void 0===r?void 0:r[o];return{title:i((null==a?void 0:a.title)||""),content:i((null==a?void 0:a.content)||""),attributes:(null==a?void 0:a.additional_attributes)||null,subsections:(null==a?void 0:a.subsections)||[]}},r=function(n){if(!n.mapping_rationale)return{cognitiveData:{decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0,citations:[]},score:0,relation:"N/A"};var i=n.mapping_rationale,t=parseInt(i.decision_strength||"0");return{cognitiveData:{decisioning:i.decisioning_factors||[],gap:i.gaps_in_decision||[],relevance_score:t,citations:i.citations},score:0,relation:"N/A"}},o=function(n){return n&&"string"==typeof n?"N/A"===n.toUpperCase()?"N/A":n.split("_").map(function(n){return n.charAt(0).toUpperCase()+n.slice(1).toLowerCase()}).join(" "):"Unknown"},a=function(i,t,e,r){var a=100*(i||0),l=r.thresholds,s=r.relationStyles;if(!e)return null;var c=o(t),u=(t||"").toLowerCase();return"n/a"===u||u.includes("no_deviation")?n(n({},s.low),{label:c}):u.includes("deviation")||u.includes("high_risk")||u.includes("critical")?n(n({},s.high),{label:c}):a>=l.exact?n(n({},s.exact),{label:c}):a>=l.high?n(n({},s.high),{label:c}):a>=l.medium?n(n({},s.medium),{label:c}):n(n({},s.low),{label:c})},l=function(n){return{score:0,relation:"N/A"}};export{l as cognitiveScoreToRelation,o as formatRelationToLabel,r as getRationale,e as getSideData,a as getStyleForRelation,t as hasValue,i as safeStringify};
1
+ var n=function(i){return null==i?"":"string"==typeof i?i:Array.isArray(i)?i.map(n).join("\n\n"):"object"==typeof i?JSON.stringify(i):String(i)},i=function(n){return null!=n&&("string"==typeof n?n.trim().length>0:!Array.isArray(n)||n.length>0&&n.some(function(n){return i(n)}))},t=function(i,t,e){var o,r=e[t],a=null===(o=null==i?void 0:i.comparison_inputs)||void 0===o?void 0:o[r];return{title:n((null==a?void 0:a.title)||""),content:n((null==a?void 0:a.content)||""),attributes:(null==a?void 0:a.additional_attributes)||null,subsections:(null==a?void 0:a.subsections)||[]}},e=function(n){if(!n.mapping_rationale)return{cognitiveData:{decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0,citations:[]},score:0,relation:"N/A"};var i=n.mapping_rationale,t=parseInt(i.decision_strength||"0");return{cognitiveData:{decisioning:i.decisioning_factors||[],gap:i.gaps_in_decision||[],relevance_score:t,citations:i.citations},score:0,relation:"N/A"}};export{e as getRationale,t as getSideData,i as hasValue,n as safeStringify};
2
2
  //# sourceMappingURL=CognitiveComparehelpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CommonConstants.d.ts","sourceRoot":"","sources":["../../../../src/CommonConstants/CommonConstants.tsx"],"names":[],"mappings":"AACA,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,OAAO,CAAC;AAC5C,eAAO,MAAM,OAAO,EAAE,aAAqB,CAAC;AAC5C,eAAO,MAAM,SAAS,EAAE,aAAuB,CAAC;AAChD,eAAO,MAAM,6BAA6B,yCAAyC,CAAA;AAEnF,eAAO,MAAM,iBAAiB,EAAE,GAgjI/B,CAAA;AAED,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4sL1B,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,GA4pJ/B,CAAA;AAED,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4sL1B,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"CognitiveCompare.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitiveCompare.tsx"],"names":[],"mappings":"AAgCA,OAAO,EAIL,qBAAqB,EAOtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAGL,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AA8XlC,QAAA,MAAM,gBAAgB,+JAUnB,qBAAqB,4CA4pGvB,CAAC;AAEF,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAClC,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"CognitiveCompare.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitiveCompare.tsx"],"names":[],"mappings":"AAgCA,OAAO,EAIL,qBAAqB,EAOtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAGL,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AA8XlC,QAAA,MAAM,gBAAgB,+JAUnB,qBAAqB,4CAmoGvB,CAAC;AAEF,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAClC,eAAe,gBAAgB,CAAC"}
@@ -1,4 +1,3 @@
1
- import { ComparisonConfig, StyleVariant } from "./CognitiveCompareTypes";
2
1
  export declare const safeStringify: (val: unknown) => string;
3
2
  export declare const hasValue: (val: unknown) => boolean;
4
3
  export declare const getSideData: (node: any, sideIndex: "0" | "1", indexMap: Record<string, string>) => {
@@ -29,9 +28,4 @@ export declare const getRationale: (node: any) => {
29
28
  relation: string;
30
29
  };
31
30
  export declare const formatRelationToLabel: (relation: string) => string;
32
- export declare const getStyleForRelation: (score: number, relation: string, hasContent: boolean, config: ComparisonConfig) => StyleVariant | null;
33
- export declare const cognitiveScoreToRelation: (relevanceScore: number) => {
34
- score: number;
35
- relation: string;
36
- };
37
31
  //# sourceMappingURL=CognitiveComparehelpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CognitiveComparehelpers.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitiveComparehelpers.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,YAAY,EACb,MAAM,yBAAyB,CAAC;AAEjC,eAAO,MAAM,aAAa,QAAS,OAAO,KAAG,MAM5C,CAAC;AAGF,eAAO,MAAM,QAAQ,QAAS,OAAO,KAAG,OAKvC,CAAC;AAGF,eAAO,MAAM,WAAW,SAChB,GAAG,aACE,GAAG,GAAG,GAAG,YACV,OAAO,MAAM,EAAE,MAAM,CAAC;;;;;CAUjC,CAAC;AAGF,eAAO,MAAM,YAAY,SAAU,GAAG;;;;;;;;;;;;;;;;;;;;CA2BrC,CAAC;AAGF,eAAO,MAAM,qBAAqB,aAAc,MAAM,KAAG,MAOxD,CAAC;AAEF,eAAO,MAAM,mBAAmB,UACvB,MAAM,YACH,MAAM,cACJ,OAAO,UACX,gBAAgB,KACvB,YAAY,GAAG,IA+BjB,CAAC;AAGF,eAAO,MAAM,wBAAwB,mBACnB,MAAM,KACrB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAMnC,CAAC"}
1
+ {"version":3,"file":"CognitiveComparehelpers.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitiveComparehelpers.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,aAAa,QAAS,OAAO,KAAG,MAM5C,CAAC;AAGF,eAAO,MAAM,QAAQ,QAAS,OAAO,KAAG,OAKvC,CAAC;AAGF,eAAO,MAAM,WAAW,SAChB,GAAG,aACE,GAAG,GAAG,GAAG,YACV,OAAO,MAAM,EAAE,MAAM,CAAC;;;;;CAUjC,CAAC;AAGF,eAAO,MAAM,YAAY,SAAU,GAAG;;;;;;;;;;;;;;;;;;;;CA2BrC,CAAC;AAGF,eAAO,MAAM,qBAAqB,aAAc,MAAM,KAAG,MAOxD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viswa-test/test-citation",
3
- "version": "0.0.38",
3
+ "version": "0.0.39",
4
4
  "author": "Viswa Koduru",
5
5
  "description": "",
6
6
  "license": "MIT",