@viswa-test/test-citation 0.0.40 → 0.0.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),t=require("react"),i=require("@mui/material"),o=require("lucide-react"),r=require("../../assests/svg/ButtonCognitiveIcon.js"),l=require("./OverlayComponent.js"),s=require("react-markdown"),a=require("./CognitiveComparehelpers.js"),c=require("./CognitiveCompareConfig.js"),u=require("./CognitivePopup.js"),d=require("./MoreFunctionsPopup.js"),v=require("./LoaderComponent.js"),f=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(f),_="::",m=p.default.memo(function(r){var l=r.content,s=r.sxStyles,c=r.deviationBadges,u=void 0===c?[]:c,d=r.highlights,v=void 0===d?[]:d,f=r.maintainRelativeOrder,h=void 0===f||f,p=t.useMemo(function(){return u.reduce(function(n,t){var i;return e.__assign(e.__assign({},n),((i={})[t.id]=t,i))},{})},[u]),_=t.useMemo(function(){return{mark:function(t){var i=t.children;return n.jsx("span",e.__assign({style:{backgroundColor:"#fccccc",borderRadius:"2px"}},{children:i}))},span:function(t){var r,l,s,a,c,u=t.children,d=e.__rest(t,["children"]),v=d["data-badge-id"];if(!v)return n.jsx("span",e.__assign({},d,{children:u}));var f=p[v];return f?n.jsxs(i.Box,e.__assign({component:"span",sx:{position:"static",display:"inline"}},{children:[u,n.jsx(i.Box,e.__assign({ref:f.badgeRef,onClick:h?f.onClick:void 0,sx:h?e.__assign(e.__assign({position:"absolute",zIndex:30,display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"10px",bgcolor:(null===(r=f.style)||void 0===r?void 0:r.badgeBg)||"#EEF2FF",color:(null===(l=f.style)||void 0===l?void 0:l.badgeText)||"#3730A3",border:"1px solid ".concat((null===(s=f.style)||void 0===s?void 0:s.badgeBorder)||"#C7D2FE"),borderRadius:"12px",px:1,py:.3,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",boxShadow:"0 1px 3px rgba(0,0,0,0.07)"},"left"===f.side?{right:"-16px",transform:"translateY(-20%) translateX(calc(100% + 8px))"}:{left:"-16px",transform:"translateY(-20%) translateX(calc(-100% - 8px))"}),f.isConnected&&f.style&&{outline:"2px solid ".concat(f.style.badgeBorder),outlineOffset:"1px"}):e.__assign({position:"absolute",width:0,height:0,visibility:"hidden"},"left"===f.side?{right:"-16px",transform:"translateY(-50%)"}:{left:"-16px",transform:"translateY(-50%)"})},{children:h&&n.jsxs(n.Fragment,{children:[n.jsx(i.Box,e.__assign({component:"span",sx:e.__assign({fontSize:"10px",fontWeight:700},"left"===f.side?{pr:.5,borderRight:"1px solid ".concat((null===(a=f.style)||void 0===a?void 0:a.badgeBorder)||"#C7D2FE")}:{})},{children:f.label})),"left"===f.side&&n.jsxs(n.Fragment,{children:[n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"10px",px:.25}},{children:f.isOrphan?"No Deviation Found":0===f.score||null==f.score?"Same":"".concat(f.score,"% Deviation")})),n.jsx(o.EllipsisVertical,{size:10,color:(null===(c=f.style)||void 0===c?void 0:c.badgeText)||"#3730A3"})]})]})}))]})):n.jsx("span",e.__assign({},d,{children:u}))}}},[p,h]),m=t.useMemo(function(){var e=l||"",n=function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")};return u.forEach(function(t){t.highlight&&(e=e.replace(new RegExp(n(t.highlight),"g"),'<span data-badge-id="'.concat(t.id,'"><mark>').concat(t.highlight,"</mark></span>")))}),v.forEach(function(t){t&&(e=e.replace(new RegExp(n(t),"g"),"<mark>".concat(t,"</mark>")))}),e},[l,u,v]);return n.jsx(i.Typography,e.__assign({component:"div",sx:e.__assign(e.__assign({},s),{position:"relative",overflow:"visible","& p, & li, & ul, & ol":{position:"static",overflow:"visible"}})},{children:n.jsx(g.default,e.__assign({components:_,rehypePlugins:[x.default]},{children:a.safeStringify(m).replace(/\\n/g,"\n")}))}))},function(e,n){if(e.content!==n.content)return!1;if(e.sxStyles!==n.sxStyles)return!1;if(e.maintainRelativeOrder!==n.maintainRelativeOrder)return!1;var t=e.highlights||[],i=n.highlights||[];if(t.length!==i.length)return!1;for(var o=0;o<t.length;o++)if(t[o]!==i[o])return!1;return!0}),y=function(e,n,t,i,o){void 0===o&&(o=14);var r=e+.5*(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(o,Math.abs(l)/2,Math.abs(r-e)/2,Math.abs(t-r)/2);return["M ".concat(e," ").concat(n),"H ".concat(r-a),"Q ".concat(r," ").concat(n," ").concat(r," ").concat(n+s*a),"V ".concat(i-s*a),"Q ".concat(r," ").concat(i," ").concat(r+a," ").concat(i),"H ".concat(t)].join(" ")},b={id:"",title:""},S={open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,isOrphan:!1,docData:null,deviationData:null},R=function(e,n,t,i,o){void 0===t&&(t=300);var r=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,v=u-a;v<t?(e.scrollTop=(d=v,d/=t,s*(--d*d*d+1)+l),o&&o(),requestAnimationFrame(c)):(e.scrollTop=n,e.style.scrollBehavior=r,o&&o(),i&&i())};requestAnimationFrame(c)};exports.SHARED_MARKDOWN_STYLES=c.SHARED_MARKDOWN_STYLES,exports.default=function(s){var f,h,g,x,I,C,w,F,j=s.componentHeaderText,B=void 0===j?"Contract Comparison":j,E=s.treeData,T=s.comparisonConfig,k=s.leftColumnTitleText,A=s.rightColumnTitleText,M=s.markdownStyles,D=s.displayConfig,O=void 0===D?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1}:D,N=s.popupConfig,H=s.deviationData,L=void 0===H?{}:H,W=t.useState(O.maintainRelativeOrder),z=W[0],P=W[1],q=t.useState(!1),Y=q[0],V=q[1],K=t.useState(!1),U=K[0],G=K[1],X=t.useState(null),J=X[0],Q=X[1],$=t.useState(!1),Z=$[0],ee=$[1],ne=t.useState(!1),te=ne[0],ie=ne[1],oe=t.useRef(!1),re=t.useState(null),le=re[0],se=re[1],ae=t.useState(new Set),ce=ae[0],ue=ae[1],de=t.useState([]),ve=de[0],fe=de[1],he=t.useRef(null),pe=t.useRef(!1),ge=t.useRef(null),xe=t.useRef({}),_e=t.useRef([]),me=t.useRef(!1),ye=t.useRef(!1),be=t.useRef(null),Se=t.useMemo(function(){return(null==E?void 0:E.cognitive_decisioning)||{}},[E]),Re=t.useState(null),Ie=Re[0],Ce=Re[1],we=t.useRef(null),Fe=t.useState({width:0,height:0}),je=Fe[0],Be=Fe[1],Ee=t.useMemo(function(){return e.__assign(e.__assign({},c.SHARED_MARKDOWN_STYLES),M)},[M]),Te=t.useState({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,isOrphan:!1,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null,deviationData:null}),ke=Te[0],Ae=Te[1],Me=t.useState({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,isOrphan:!1,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null,deviationData:null}),De=Me[0],Oe=Me[1],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),Ye=t.useRef(null),Ve=t.useRef(!1),Ke=t.useRef(null);t.useEffect(function(){Ke.current=null},[ke.sectionIdx,ke.open]);var Ue=t.useCallback(function(){Ce(null),Ae(S),se(null)},[]),Ge=t.useCallback(function(){Oe(S)},[]),Xe=t.useCallback(function(){var e;if(ke.anchorEl&&ke.refSectionTitle){var n=ke.anchorEl.getBoundingClientRect(),t=(null===(e=null==we?void 0:we.current)||void 0===e?void 0:e.offsetHeight)||0,i=Math.min(680,window.innerWidth-24),o=window.innerHeight-n.bottom-12-12,r=n.top-12-12,l=o<t&&r>o;null!==Ke.current?!0===Ke.current&&(l=r>=t||r>=o):l=!(o>=t||o>=r),Ke.current=l;var s=l?r:o,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,v=Math.max(12,Math.min(d,window.innerWidth-i-12)),f=Math.max(14,Math.min(u-v,i-10-4));Ce({top:c,left:v,arrowLeft:f,openAbove:l,maxHeight:s})}},[ke.anchorEl,ke.refSectionTitle]);t.useEffect(function(){if(ke.open){window.addEventListener("resize",Xe);var e=requestAnimationFrame(Xe),n=null;return we.current&&(n=new ResizeObserver(function(){cancelAnimationFrame(e),e=requestAnimationFrame(Xe)})).observe(we.current),function(){cancelAnimationFrame(e),window.removeEventListener("resize",Xe),n&&n.disconnect()}}},[ke.open,Xe]),t.useEffect(function(){var e=Ne.current;if(e&&ke.open){var n=function(e){we.current&&we.current.contains(e.target)||(Ce(null),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]),t.useEffect(function(){var e=Ne.current;if(e&&De.open){var n=function(){Ge()};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})}}},[De.open,Ge]);var Je=t.useMemo(function(){var n,t,i,o,r,l,s,a,u,d,v,f;return{fields:null!==(n=null==T?void 0:T.fields)&&void 0!==n?n:c.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(i=null===(t=null==T?void 0:T.thresholds)||void 0===t?void 0:t.high)&&void 0!==i?i:c.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(r=null===(o=null==T?void 0:T.thresholds)||void 0===o?void 0:o.medium)&&void 0!==r?r:c.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(s=null===(l=null==T?void 0:T.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==T?void 0:T.relationStyles)||void 0===a?void 0:a.noContent)||{}),high:e.__assign(e.__assign({},c.DEFAULT_COMPARISON_CONFIG.relationStyles.high),(null===(u=null==T?void 0:T.relationStyles)||void 0===u?void 0:u.high)||{}),exact:e.__assign(e.__assign({},c.DEFAULT_COMPARISON_CONFIG.relationStyles.exact),(null===(d=null==T?void 0:T.relationStyles)||void 0===d?void 0:d.exact)||{}),medium:e.__assign(e.__assign({},c.DEFAULT_COMPARISON_CONFIG.relationStyles.medium),(null===(v=null==T?void 0:T.relationStyles)||void 0===v?void 0:v.medium)||{}),low:e.__assign(e.__assign({},c.DEFAULT_COMPARISON_CONFIG.relationStyles.low),(null===(f=null==T?void 0:T.relationStyles)||void 0===f?void 0:f.low)||{})}}},[T]),Qe=t.useMemo(function(){if(E&&Object.keys(E).length>0)try{var n=function(n,t,i){var o,r,l,s;void 0===t&&(t=!1),void 0===i&&(i=null);var c=n.nodes||n,u=[],d=[],v=n.base_root_id,f=n.input_index_map||{0:"left",1:"right"},h=n[v]||c[v];if(!h||!1===h.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[]};var p=function(t,o){var r,l,s,u=n[t]||c[t];if(!u||!1===u.display_node)return null;var d=a.getSideData(u,o,f),v=!1!==(null===(r=d.attributes)||void 0===r?void 0:r.display_title),h=!1!==(null===(l=d.attributes)||void 0===l?void 0:l.display_content),g=!!d.title.trim(),x=!!d.content.trim(),_=a.getRationale(u),m=(null===(s=null==i?void 0:i[t])||void 0===s?void 0:s.evaluation_result)||u.evaluation_result||null,y=[];u.next&&Object.values(u.next).forEach(function(e){var n=c[e];if(n&&!1!==n.display_node){var t=p(e,o);t&&y.push(t)}});var b=!(!g&&!x);return e.__assign(e.__assign({id:t,title:g?d.title:"",content:x?d.content:"",displayTitle:v,displayContent:h,subsections:y},b?_:{score:void 0,relation:"not_defined"}),{evaluationResult:m})};if(t){var g=function(t,o){var r,l,s,u,d,v,h,p,x,_,m,y,b,S,R,I,C,w,F,j,B;void 0===o&&(o=0);var E=[],T=[];if(!t)return{refSections:E,baseSections:T};var k={},A={},M=-1,D=-1;for(var O in t){var N=t[O],H=n[N]||c[N];if(H&&!1!==H.display_node){var L=a.getRationale(H),W=(null===(r=null==i?void 0:i[N])||void 0===r?void 0:r.evaluation_result)||H.evaluation_result||null,z=a.getSideData(H,"1",f),P=a.getSideData(H,"0",f),q=!1!==(null===(l=z.attributes)||void 0===l?void 0:l.display_title)&&z.title.trim()||!1!==(null===(s=z.attributes)||void 0===s?void 0:s.display_content)&&z.content.trim(),Y=!1!==(null===(u=P.attributes)||void 0===u?void 0:u.display_title)&&P.title.trim()||!1!==(null===(d=P.attributes)||void 0===d?void 0:d.display_content)&&P.content.trim(),V=Number(null!==(h=null===(v=z.attributes)||void 0===v?void 0:v.display_index)&&void 0!==h?h:M--),K=Number(null!==(x=null===(p=P.attributes)||void 0===p?void 0:p.display_index)&&void 0!==x?x:D--),U=k[V]||e.__assign(e.__assign({id:N,title:!1!==(null===(_=z.attributes)||void 0===_?void 0:_.display_title)?z.title:"",content:!1!==(null===(m=z.attributes)||void 0===m?void 0:m.display_content)?z.content:"",subsections:[]},q?L:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:V,evaluationResult:W,displayContent:null===(y=z.attributes)||void 0===y?void 0:y.display_content,displayTitle:null===(b=z.attributes)||void 0===b?void 0:b.display_title}),G=A[K]||e.__assign(e.__assign({id:N,title:!1!==(null===(S=P.attributes)||void 0===S?void 0:S.display_title)?P.title:"",content:!1!==(null===(R=P.attributes)||void 0===R?void 0:R.display_content)?P.content:"",subsections:[]},Y?L:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:K,evaluationResult:W,displayContent:null===(I=P.attributes)||void 0===I?void 0:I.display_content,displayTitle:null===(C=P.attributes)||void 0===C?void 0:C.display_title});Number(V)>=0&&Number(K)>=0&&((null===(w=U.refIndexes)||void 0===w?void 0:w.includes(Number(K)))||null===(F=U.refIndexes)||void 0===F||F.push(Number(K)),(null===(j=G.refIndexes)||void 0===j?void 0:j.includes(Number(V)))||null===(B=G.refIndexes)||void 0===B||B.push(Number(V))),k[V]=U,A[K]=G;var X=g(H.next,o+1),J=X.refSections,Q=X.baseSections;J.length>0&&(U.subsections=e.__spreadArray(e.__spreadArray([],U.subsections||[],!0),J,!0)),Q.length>0&&(G.subsections=e.__spreadArray(e.__spreadArray([],G.subsections||[],!0),Q,!0))}}return E=Object.values(k).map(function(e){return e}),T=Object.values(A).map(function(e){return e}),E.sort(function(e,n){return e.selfIndex<0&&n.selfIndex>=0?1:e.selfIndex>=0&&n.selfIndex<0?-1:e.selfIndex-n.selfIndex}),T.sort(function(e,n){return e.selfIndex<0&&n.selfIndex>=0?1:e.selfIndex>=0&&n.selfIndex<0?-1:e.selfIndex-n.selfIndex}),{refSections:E,baseSections:T}},x=g(h.next),_=x.refSections,m=x.baseSections;d=_,u=m}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===(r=null===(o=h.comparison_inputs)||void 0===o?void 0:o[f[0]])||void 0===r?void 0:r.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[f[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:{}}}}]}}(E,z,L);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(E),z,JSON.stringify(L)]),$e=Qe.activeProposed,Ze=Qe.activeVariants,en=Qe.parseError;t.useEffect(function(){en&&Q("Failed to load comparison: ".concat(en))},[en]);var nn=t.useState(null),tn=nn[0];nn[1];var on=t.useState({}),rn=on[0],ln=on[1],sn=t.useState({}),an=sn[0],cn=sn[1],un=(null==Ze?void 0:Ze[0])||b,dn=null===(g=null===(f=null==E?void 0:E.documents)||void 0===f?void 0:f[null===(h=null==E?void 0:E.input_index_map)||void 0===h?void 0:h[0]])||void 0===g?void 0:g.title,vn=null===(C=null===(x=null==E?void 0:E.documents)||void 0===x?void 0:x[null===(I=null==E?void 0:E.input_index_map)||void 0===I?void 0:I[1]])||void 0===C?void 0:C.title,fn=a.safeStringify(k||dn||"Uploaded Contract"),hn=a.safeStringify(A||vn||"Reference Template"),pn=t.useMemo(function(){return(null==$e?void 0:$e.sections)||[]},[null==$e?void 0:$e.sections]),gn=t.useMemo(function(){return un.sections||[]},[un.sections]),xn=pn.length>0||gn.length>0,_n=un.analysis,mn=a.safeStringify(null===(F=null===(w=null==_n?void 0:_n.rule_difference_comparison)||void 0===w?void 0:w.summary)||void 0===F?void 0:F.overall_summary),yn=!!mn.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),bn=t.useRef({}),Sn=function(e){return bn.current[e]||(bn.current[e]=p.default.createRef()),bn.current[e]},Rn=t.useCallback(function(){ee(!1),ye.current=!1,Ln(null),be.current=null,En.current=null,ie(!1),G(!1),We.current&&(We.current.style.height="0px"),ze.current&&(ze.current.style.height="0px"),Pe.current&&(Pe.current.style.height="0px"),qe.current&&(qe.current.style.height="0px")},[]),In=t.useCallback(function(e,n,t,i,o,r){var l,s,c=a.safeStringify(n.id)||a.safeStringify(t.id)||"",u=(c?Se[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:r||null,sectionIdx:i,docData:{documents:null==E?void 0:E.documents,input_index_map:null==E?void 0:E.input_index_map},deviationData:n.evaluationResult||t.evaluationResult||null,isOrphan:!!o}},[Se,E]),Cn=t.useCallback(function(e){Ge(),Ce(null),Ae(e)},[Ge]),wn=function(e,n,t,i,o,r){e.stopPropagation(),De.open&&De.sectionIdx===o?Ge():(Ue(),Oe(In(e.currentTarget,n,i,o,t,r)))},Fn=t.useCallback(function(){null!==De.sectionIdx&&De.anchorEl?Cn(e.__assign(e.__assign({},De),{open:!0})):Ge()},[De,Ge,Cn]),jn=t.useCallback(function(){var e=De.sectionIdx,n=De.isOrphan;Ge(),null!==e&&(n?Q("No counterpart exists to connect to."):(ye.current&&Rn(),ue(function(n){return n.has(e)?new Set:new Set([e])})))},[De.sectionIdx,Ge,Rn]),Bn=t.useRef(null),En=t.useRef(null),Tn=t.useRef(null),kn=t.useRef(null),An=t.useRef(null),Mn=t.useState([]),Dn=Mn[0],On=Mn[1],Nn=t.useState(null),Hn=Nn[0],Ln=Nn[1];t.useRef(null);var Wn=t.useState(null),zn=Wn[0],Pn=Wn[1],qn=t.useMemo(function(){return Je.fields.filter(function(e){var n=e.key;return(!xn||"description"!==n)&&(a.hasValue(null==$e?void 0:$e[n])||a.hasValue(un[n]))})},[$e,un,xn,Je.fields]),Yn=t.useRef({}),Vn=t.useRef({}),Kn=t.useRef({}),Un=t.useRef({}),Gn=t.useRef({}),Xn=t.useRef({}),Jn=t.useRef({}),Qn=t.useRef({}),$n=t.useRef({});qn.forEach(function(e){for(var n=e.key,t=0;t<Math.max(pn.length,gn.length);t+=1)Kn.current[t]||(Kn.current[t]=p.default.createRef()),Un.current[t]||(Un.current[t]=p.default.createRef()),Gn.current[t]||(Gn.current[t]=p.default.createRef()),Xn.current[t]||(Xn.current[t]=p.default.createRef()),Jn.current[t]||(Jn.current[t]=p.default.createRef());Yn.current[n]||(Yn.current[n]=p.default.createRef()),Vn.current[n]||(Vn.current[n]=p.default.createRef())});for(var Zn=0;Zn<Math.max(pn.length,gn.length);Zn+=1)Kn.current[Zn]||(Kn.current[Zn]=p.default.createRef()),Un.current[Zn]||(Un.current[Zn]=p.default.createRef()),Gn.current[Zn]||(Gn.current[Zn]=p.default.createRef()),Xn.current[Zn]||(Xn.current[Zn]=p.default.createRef()),Jn.current[Zn]||(Jn.current[Zn]=p.default.createRef());t.useEffect(function(){if(tn){var e=Je.fields.find(function(e){return e.analysisKey===tn||e.key===tn});if(e){var n=Yn.current[e.key]||Vn.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[tn,Je.fields]);var et=t.useCallback(function(e){var n,t,i,o,r,l,s,a,c,u=null===(n=null==_n?void 0:_n.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],v=(null==d?void 0:d.relation)||(null===(i=null===(t=null==d?void 0:d.highlights)||void 0===t?void 0:t.ruleA_spans)||void 0===i?void 0:i.length)||(null===(r=null===(o=null==d?void 0:d.highlights)||void 0===o?void 0:o.ruleB_spans)||void 0===r?void 0:r.length)||(null==d?void 0:d.mappings)&&d.mappings.length>0;if(d.mappings){var f=d.mappings[0]||{};return{score:d.score,relation:f.relation||"",highlightsA:(null===(l=f.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(s=f.highlights)||void 0===s?void 0:s.ruleB_spans)||[],hasContent:!!v}}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:!!v}},[_n]),nt=t.useCallback(function(n){var t,i,o,r=pn[n],l=gn[n],s=(null==r?void 0:r.relation)&&"not_defined"!==r.relation,c=(null==l?void 0:l.relation)&&"not_defined"!==l.relation;a.safeStringify(null==r?void 0:r.id)||a.safeStringify(null==l?void 0:l.id);var u=!(!(null==r?void 0:r.cognitiveData)&&!(null==l?void 0:l.cognitiveData));if(!s&&!c&&!u)return e.__assign(e.__assign({},Je.relationStyles.noContent),{label:"Not Defined"});var d=null!==(i=null!==(t=null==r?void 0:r.evaluationResult)&&void 0!==t?t:null==l?void 0:l.evaluationResult)&&void 0!==i?i:null,v=(null===(o=null==d?void 0:d.evaluation_outputs)||void 0===o?void 0:o.output_value)+"%";return null!=d?e.__assign(e.__assign({},Je.relationStyles.low),{label:v}):e.__assign(e.__assign({},Je.relationStyles.low),{label:"N/A"})},[pn,gn,Se,Je,et]),tt=t.useCallback(function(n){for(var t,i,o,r,l,s,c=n.split("-").map(Number),u=pn[c[0]],d=gn[c[0]],v=1;v<c.length;v++)(null==u?void 0:u.subsections)&&(u=u.subsections[c[v]]),(null==d?void 0:d.subsections)&&(d=d.subsections[c[v]]);if(!u&&!d)return null;var f=(null==u?void 0:u.relation)&&"not_defined"!==u.relation,h=(null==d?void 0:d.relation)&&"not_defined"!==d.relation,p=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(!f&&!h&&!g)return e.__assign(e.__assign({},Je.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||p&&(null===(o=Se[p])||void 0===o||o.relevance_score);var x=null!==(l=null!==(r=null==u?void 0:u.evaluationResult)&&void 0!==r?r:null==d?void 0:d.evaluationResult)&&void 0!==l?l:null,_=(null===(s=null==x?void 0:x.evaluation_outputs)||void 0===s?void 0:s.output_value)+"%";return null!=x?e.__assign(e.__assign({},Je.relationStyles.low),{label:_}):e.__assign(e.__assign({},Je.relationStyles.low),{label:"N/A"})},[pn,gn,Se,Je]),it=t.useCallback(function(){var n,t,i,o,r,l,s,c,u,d,v,f,h,p,g,x,m,b,S,R,I,C;if(!Ve.current&&!pe.current){Ve.current=!0;try{if(!Bn.current)return;var w=function(e){var n=e.split("-"),t=n[0];if(!rn[t]&&!1===z)return!1;if(z&&!rn["left-".concat(t)]&&!rn["right-".concat(t)]&&!rn[t])return!1;for(var i=t,o=1;o<n.length-1;o++)if(i+="-".concat(n[o]),!an[i])return!1;return!0},F=Bn.current.getBoundingClientRect();Be({width:F.width,height:F.height});var j=[];if(qn.forEach(function(e){var n,t,i=e.key,o=null===(n=Yn.current[i])||void 0===n?void 0:n.current,r=null===(t=Vn.current[i])||void 0===t?void 0:t.current;o&&r&&(o.style.height="auto",r.style.height="auto",o.style.minHeight="0px",r.style.minHeight="0px")}),!pe.current){for(var B=0;B<Math.max(pn.length,gn.length);B++){var E=null===(n=Kn.current[B])||void 0===n?void 0:n.current,T=null===(t=Un.current[B])||void 0===t?void 0:t.current;E&&(E.style.height="auto",E.style.minHeight="0px"),T&&(T.style.height="auto",T.style.minHeight="0px")}z||Object.keys(Qn.current).forEach(function(e){var n,t;if(w(e)){var i=null===(n=Qn.current[e])||void 0===n?void 0:n.current,o=null===(t=$n.current[e])||void 0===t?void 0:t.current;i&&o&&(i.style.height="auto",o.style.height="auto",i.style.minHeight="0px",o.style.minHeight="0px")}})}var k={};qn.forEach(function(e){var n,t,i=e.key,o=null===(n=Yn.current[i])||void 0===n?void 0:n.current,r=null===(t=Vn.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),s=r.getBoundingClientRect();k[i]=Math.max(l.height,s.height)}});var A={left:{},right:{}},M={};if(!pe.current)if(z){if(Z&&null!==Hn)if("number"==typeof Hn){var D=Hn,O=pn[D],N=null===(r=Kn.current[D])||void 0===r?void 0:r.current;N&&O&&(O.refIndexes||[]).forEach(function(e){var n,t=gn.findIndex(function(n){return n.selfIndex===e}),i=null===(n=Un.current[t])||void 0===n?void 0:n.current;if(i&&(rn["left-".concat(D)]||rn["right-".concat(t)])){var o=Math.max(N.getBoundingClientRect().height,i.getBoundingClientRect().height);A.left[D]=Math.max(A.left[D]||0,o),A.right[t]=Math.max(A.right[t]||0,o)}})}else{var H=Hn.split(_)[0];E=null===(l=Qn.current[H])||void 0===l?void 0:l.current,T=null===(s=$n.current[H])||void 0===s?void 0:s.current;if(E&&T){L=Math.max(E.getBoundingClientRect().height,T.getBoundingClientRect().height);M[H]=Math.max(M[H]||0,L)}}}else{Object.keys(Qn.current).forEach(function(e){var n,t;if(w(e)){var i=null===(n=Qn.current[e])||void 0===n?void 0:n.current,o=null===(t=$n.current[e])||void 0===t?void 0:t.current;if(i&&o&&null!==i.offsetParent&&null!==o.offsetParent){var r=i.getBoundingClientRect(),l=o.getBoundingClientRect(),s=Math.max(r.height,l.height);M[e]=s,i.style.minHeight="".concat(s,"px"),o.style.minHeight="".concat(s,"px")}}});for(B=0;B<Math.min(pn.length,gn.length);B++){var E=null===(i=Kn.current[B])||void 0===i?void 0:i.current,T=null===(o=Un.current[B])||void 0===o?void 0:o.current;if(E&&T){var L=Math.max(E.getBoundingClientRect().height,T.getBoundingClientRect().height);A.left[B]=L,A.right[B]=L}}}if(qn.forEach(function(e){var n,t,i=e.key,o=null===(n=Yn.current[i])||void 0===n?void 0:n.current,r=null===(t=Vn.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=k[i];o.style.minHeight="".concat(l,"px"),r.style.minHeight="".concat(l,"px")}}),pe.current||(Object.entries(A.left).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=Kn.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),Object.entries(A.right).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=Un.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),z||Object.keys(M).forEach(function(e){var n,t,i=null===(n=Qn.current[e])||void 0===n?void 0:n.current,o=null===(t=$n.current[e])||void 0===t?void 0:t.current;if(i&&o&&M[e]){var r=M[e];i.style.minHeight="".concat(r,"px"),o.style.minHeight="".concat(r,"px")}})),z){if(pn.forEach(function(e,n){var t;(null===(t=Kn.current[n])||void 0===t?void 0:t.current)&&(e.refIndexes||[]).forEach(function(e){var t,i,o,r,l,s,a,c,u,d,v=gn.findIndex(function(n){return n.selfIndex===e});if(-1!==v){var f=null===(t=Gn.current[n])||void 0===t?void 0:t.current,h=null===(i=Xn.current[v])||void 0===i?void 0:i.current;if(f&&h){var p=f.getBoundingClientRect(),g=h.getBoundingClientRect(),x=p.right-F.left,_=g.left-F.left,m=p.top+p.height/2-F.top,y=g.top+g.height/2-F.top;if(Z&&Hn===n){var b=null!==(r=null===(o=Ye.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==r?r:0,S=null!==(s=null===(l=Le.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==s?s:0,R=b+(null!==(c=null===(a=Ye.current)||void 0===a?void 0:a.clientHeight)&&void 0!==c?c:1/0),I=S+(null!==(d=null===(u=Le.current)||void 0===u?void 0:u.clientHeight)&&void 0!==d?d:1/0),C=p.top+p.height/2,w=function(e,n,t){return Math.max(n,Math.min(t,e))};m=w(C,b,R)-F.top,y=w(C,S,I)-F.top}var B=nt(n);B&&j.push({id:"line-".concat(n,"-").concat(v),x1:x,y1:m,x2:_,y2:y,style:B,sectionIdx:n,targetRightIdx:v})}}})}),Z&&"string"==typeof Hn){var W=Hn,P=(H=W.split(_)[0],null===(h=Gn.current[W])||void 0===h?void 0:h.current),q=null===(p=Xn.current[W])||void 0===p?void 0:p.current;if(P&&q){var Y=P.getBoundingClientRect(),V=q.getBoundingClientRect(),K=Y.right-F.left,U=V.left-F.left,G=null!==(x=null===(g=Ye.current)||void 0===g?void 0:g.getBoundingClientRect().top)&&void 0!==x?x:0,X=null!==(b=null===(m=Le.current)||void 0===m?void 0:m.getBoundingClientRect().top)&&void 0!==b?b:0,J=G+(null!==(R=null===(S=Ye.current)||void 0===S?void 0:S.clientHeight)&&void 0!==R?R:1/0),Q=X+(null!==(C=null===(I=Le.current)||void 0===I?void 0:I.clientHeight)&&void 0!==C?C:1/0),$=Y.top+Y.height/2,ee=V.top+V.height/2,ne=function(e,n,t){return Math.max(n,Math.min(t,e))},te=ne($,G,J)-F.top,ie=ne(ee,X,Q)-F.top;(le=tt(H))&&j.push({id:"line-subsec-".concat(W),x1:K,y1:te,x2:U,y2:ie,style:le,sectionIdx:Number(H.split("-")[0]),isSubSection:!0,subSectionKeyPath:W})}}}else{for(B=0;B<Math.min(pn.length,gn.length);B++){var oe=null===(c=Kn.current[B])||void 0===c?void 0:c.current,re=null===(u=Un.current[B])||void 0===u?void 0:u.current;if(oe&&re){var le,se=oe.getBoundingClientRect(),ae=re.getBoundingClientRect(),ue=Math.max(se.top,ae.top)+18-F.top,de=(null===(d=gn[B])||void 0===d?void 0:d.id)||"sec-".concat(B);(le=nt(B))&&j.push({id:de,x1:se.right-F.left,y1:ue,x2:ae.left-F.left,y2:ue,style:le,sectionIdx:B,hasCognitive:!!((null===(v=pn[B])||void 0===v?void 0:v.cognitiveData)||(null===(f=gn[B])||void 0===f?void 0:f.cognitiveData)||de&&Se[de])})}}Object.keys(Gn.current).forEach(function(n){var t,i,o,r,l,s,c,u,d,v;if(n.includes(_)){var f=n.split(_)[0];if(w(f)){var h=null===(t=Gn.current[n])||void 0===t?void 0:t.current,p=null===(i=Xn.current[n])||void 0===i?void 0:i.current;if(h&&p&&null!==h.offsetParent&&null!==p.offsetParent){for(var g=h.getBoundingClientRect(),x=p.getBoundingClientRect(),m=g.top+g.height/2-F.top,y=x.top+x.height/2-F.top,b=f.split("-").map(Number),S=pn[b[0]],R=gn[b[0]],I=1;I<b.length;I++)(null==S?void 0:S.subsections)&&(S=S.subsections[b[I]]),(null==R?void 0:R.subsections)&&(R=R.subsections[b[I]]);if(!S&&!R)return;var C=(null==S?void 0:S.relation)&&"not_defined"!==S.relation,B=(null==R?void 0:R.relation)&&"not_defined"!==R.relation,E=a.safeStringify(null==S?void 0:S.id)||a.safeStringify(null==R?void 0:R.id)||"",T=!(!(null==S?void 0:S.cognitiveData)&&!(null==R?void 0:R.cognitiveData)),k=null;if(C||B||T){var A=null!==(r=null!==(o=null==S?void 0:S.evaluationResult)&&void 0!==o?o:null==R?void 0:R.evaluationResult)&&void 0!==r?r:null,M=null!==(v=null!==(u=null!==(s=null===(l=null==A?void 0:A.evaluation_output)||void 0===l?void 0:l.output_score)&&void 0!==s?s:null===(c=null==A?void 0:A.evaluation_outputs)||void 0===c?void 0:c.output_score)&&void 0!==u?u:null===(d=null==A?void 0:A.evaluation_outputs)||void 0===d?void 0:d.output_value)&&void 0!==v?v:null==A?void 0:A.output_score,D=null!=M?"".concat(M,"%"):"N/A";k=null!=A?e.__assign(e.__assign({},Je.relationStyles.low),{label:D}):e.__assign(e.__assign({},Je.relationStyles.low),{label:"N/A"})}else k={badgeBg:"#EEF2FF",badgeText:"#3730A3",badgeBorder:"#C7D2FE",label:"N/A"};k&&j.push({id:"line-subsec-".concat(n),x1:g.right-F.left,y1:m,x2:x.left-F.left,y2:y,style:k,sectionIdx:b[0],isSubSection:!0,subSectionKeyPath:n,hasCognitive:T||!(!E||!Se[E])})}}}})}if(On(j),kn.current&&An.current){var ve=kn.current.getBoundingClientRect(),he=An.current.getBoundingClientRect(),ge=(ve.top+ve.height/2-F.top+he.top+he.height/2-F.top)/2;Pn({x1:ve.right-F.left,x2:he.left-F.left,y:ge})}else Pn(null);if(z&&ce.size>0){var xe=[],me=Ye.current,ye=Le.current;if(me&&ye){var be=[],Re=me.getBoundingClientRect().top,Ie=ye.getBoundingClientRect().top,Ce=Re+me.clientHeight,we=Ie+ye.clientHeight,Fe=me.scrollTop,je=ye.scrollTop,Ee=F.top,Te=function(e,n,t){return Math.max(n,Math.min(t,e))};ce.forEach(function(e){var n,t,i;if("string"==typeof e){var o=e,r=o.split(_)[0],l=null===(n=Gn.current[o])||void 0===n?void 0:n.current,s=null===(t=Xn.current[o])||void 0===t?void 0:t.current;if(!l||!s)return;var a=l.getBoundingClientRect(),c=s.getBoundingClientRect(),u=tt(r),d=a.right-F.left,v=c.left-F.left-0,f=d+.5*(v-d),h=a.top+a.height/2,p=c.top+c.height/2,g=h-Re+Fe,x=p-Ie+je,m="conn-subsec-".concat(o);be.push({lhsScrollY:g,rhsScrollY:x,x1:d,x2:v,containerTop:Ee,leftIdx:o,rhsArrayIdx:o,styleColor:(null==u?void 0:u.badgeBorder)||"#6366F1",styleId:m});var b=Te(h,Re,Ce),S=Te(p,Ie,we),R=b-Ee,I=S-Ee,C=h>=Re-4&&h<=Ce+4,w=p>=Ie-4&&p<=we+4,j="";j=C&&w?y(d,R,v,I):C&&!w?"M ".concat(d,",").concat(R," L ").concat(f,",").concat(R," L ").concat(f,",").concat(I):!C&&w?"M ".concat(f,",").concat(R," L ").concat(f,",").concat(I," L ").concat(v,",").concat(I):"M ".concat(f,",").concat(R," L ").concat(f,",").concat(I),xe.push({id:m,pathD:j,style:u,leftIdx:o,rhsArrayIdx:o})}else{var B=pn[e];if(!(null===(i=null==B?void 0:B.refIndexes)||void 0===i?void 0:i.length))return;B.refIndexes.forEach(function(n){var t,i,o=gn.findIndex(function(e){return e.selfIndex===n});if(-1!==o){var r=null===(t=Gn.current[e])||void 0===t?void 0:t.current,l=null===(i=Xn.current[o])||void 0===i?void 0:i.current;if(r&&l){var s=r.getBoundingClientRect(),a=l.getBoundingClientRect(),c=nt(e),u=s.right-F.left,d=a.left-F.left-0,v=u+.5*(d-u),f=s.top+s.height/2,h=a.top+a.height/2,p=f-Re+Fe,g=h-Ie+je,x="conn-".concat(e,"-").concat(o);be.push({lhsScrollY:p,rhsScrollY:g,x1:u,x2:d,containerTop:Ee,leftIdx:e,rhsArrayIdx:o,styleColor:(null==c?void 0:c.badgeBorder)||"#6366F1",styleId:x});var _=Te(f,Re,Ce),m=Te(h,Ie,we),b=_-Ee,S=m-Ee,R=f>=Re-4&&f<=Ce+4,I=h>=Ie-4&&h<=we+4,C="";C=R&&I?y(u,b,d,S):R&&!I?"M ".concat(u,",").concat(b," L ").concat(v,",").concat(b," L ").concat(v,",").concat(S):!R&&I?"M ".concat(v,",").concat(b," L ").concat(v,",").concat(S," L ").concat(d,",").concat(S):"M ".concat(v,",").concat(b," L ").concat(v,",").concat(S),xe.push({id:x,pathD:C,style:c,leftIdx:e,rhsArrayIdx:o})}}})}}),_e.current=be}fe(xe)}else fe([]),_e.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{Ve.current=!1}}},[qn,pn,gn,Se,Je,et,nt,z,Z,Hn,ce,rn,an]),ot=t.useCallback(function(){var e,n,t,i,o,r,l,s,a,c,u,d,v,f,h=_e.current;if(h.length&&!pe.current){var p=null!==(n=null===(e=Ye.current)||void 0===e?void 0:e.scrollTop)&&void 0!==n?n:0,g=null!==(i=null===(t=Le.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,x=null!==(r=null===(o=Ye.current)||void 0===o?void 0:o.clientHeight)&&void 0!==r?r:1/0,_=null!==(s=null===(l=Le.current)||void 0===l?void 0:l.clientHeight)&&void 0!==s?s:1/0,m=null!==(c=null===(a=Ye.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==c?c:0,b=null!==(d=null===(u=Le.current)||void 0===u?void 0:u.getBoundingClientRect().top)&&void 0!==d?d:0,S=m+x,R=b+_,I=null!==(f=null===(v=Bn.current)||void 0===v?void 0:v.getBoundingClientRect().top)&&void 0!==f?f:0,C=function(e,n,t){return Math.max(n,Math.min(t,e))};h.forEach(function(e){var n=e.lhsScrollY-p+m,t=e.rhsScrollY-g+b,i=xe.current[e.styleId+"-stroke"],o=xe.current[e.styleId+"-bg"];if(i||o){var r,l=C(n,m,S),s=C(t,b,R),a=l-I,c=s-I,u=n>=m-4&&n<=S+4,d=t>=b-4&&t<=R+4,v=e.x1+.5*(e.x2-e.x1);r=u&&d?y(e.x1,a,e.x2,c):u&&!d?"M ".concat(e.x1,",").concat(a," L ").concat(v,",").concat(a," L ").concat(v,",").concat(c):!u&&d?"M ".concat(v,",").concat(a," L ").concat(v,",").concat(c," L ").concat(e.x2,",").concat(c):"M ".concat(v,",").concat(a," L ").concat(v,",").concat(c),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",r)),o&&(o.setAttribute("visibility","visible"),o.setAttribute("d",r))}})}},[]),rt=t.useRef(it);t.useEffect(function(){rt.current=it},[it]);var lt=t.useRef(null),st=t.useCallback(function(){null!==lt.current&&clearTimeout(lt.current),lt.current=setTimeout(function(){rt.current(),lt.current=null},50)},[]),at=t.useCallback(function(e){var n,t,i,o,r,l,s,a;if(!oe.current){if(z||st(),ye.current){var c=be.current,u=En.current,d=Ye.current,v=Le.current;if(null!==c&&null!==u&&d&&v){var f="string"==typeof c?null===(n=Gn.current[c])||void 0===n?void 0:n.current:null===(t=bn.current[c])||void 0===t?void 0:t.current,h="string"==typeof u?null===(i=Xn.current[u])||void 0===i?void 0:i.current:null===(o=Jn.current[u])||void 0===o?void 0:o.current;if(f&&h){var p=f.getBoundingClientRect().top-d.getBoundingClientRect().top+d.scrollTop,g=h.getBoundingClientRect().top-v.getBoundingClientRect().top+v.scrollTop;if(e.currentTarget===d){var x=g-(p-d.scrollTop),_=v.scrollHeight-v.clientHeight,m=Math.max(0,Math.min(x,_));Math.abs(v.scrollTop-m)>1&&(v.scrollTop=m)}else if(e.currentTarget===v){var y=p-(g-v.scrollTop),b=d.scrollHeight-d.clientHeight,S=Math.max(0,Math.min(y,b));Math.abs(d.scrollTop-S)>1&&(d.scrollTop=S)}if(Tn.current){var R=null===(r=Gn.current[c])||void 0===r?void 0:r.current,I=null===(l=Xn.current[u])||void 0===l?void 0:l.current,C=null!==(a=null===(s=Bn.current)||void 0===s?void 0:s.getBoundingClientRect().top)&&void 0!==a?a:0,w=d.getBoundingClientRect().top,F=w+d.clientHeight,j=v.getBoundingClientRect().top,B=j+v.clientHeight,E=function(e,n,t){return Math.max(n,Math.min(t,e))};if(R&&I){var T=R.getBoundingClientRect(),k=I.getBoundingClientRect(),A=T.top+T.height/2,M=k.top+k.height/2,D=E(A,w,F),O=E(M,j,B);Tn.current.setAttribute("y1",(D-C).toString()),Tn.current.setAttribute("y2",(O-C).toString());var N=A>=w-4&&A<=F+4;Tn.current.setAttribute("visibility",N?"visible":"hidden")}}}}}_e.current.length>0&&!me.current&&(me.current=!0,requestAnimationFrame(function(){ot(),me.current=!1}))}},[ot,z,st]);t.useEffect(function(){var e=setTimeout(st,250);window.addEventListener("resize",st);var n=null,t=null;return Ne.current&&(n=new ResizeObserver(st)).observe(Ne.current),Bn.current&&(t=new ResizeObserver(st)).observe(Bn.current),function(){clearTimeout(e),window.removeEventListener("resize",st),null==n||n.disconnect(),null==t||t.disconnect()}},[$e,un,_n,qn,rn,an,pn,gn,Je,st,Z,Hn,te,ce]),t.useEffect(function(){ye.current=Z},[Z]),t.useEffect(function(){be.current=Hn},[Hn]);var ct=t.useCallback(function(){var e=De.sectionIdx,n=De.isOrphan;Ge(),null!=e&&(n?Q("No counterpart exists for this section."):Z&&Hn===e?Rn():(ue(new Set),fe([]),_e.current=[],G(!0),oe.current=!0,Ln(e),be.current=e,ee(!0),ye.current=!0,ie(!1),We.current&&(We.current.style.height="0px"),ze.current&&(ze.current.style.height="0px"),Pe.current&&(Pe.current.style.height="0px"),qe.current&&(qe.current.style.height="0px"),requestAnimationFrame(function(){var n,t,i,o,r=null,l=null,s=null;if("string"==typeof e)r=(null===(n=Gn.current[e])||void 0===n?void 0:n.current)||null,s=(l=(null===(t=Xn.current[e])||void 0===t?void 0:t.current)||null)?e:null;else{r=(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=gn.findIndex(function(e){return e.selfIndex===u});-1!==d&&(l=(null===(o=Jn.current[d])||void 0===o?void 0:o.current)||null,s=d)}}En.current=s;var v=Ye.current,f=Le.current;if(!r||!v)return oe.current=!1,void G(!1);if(!l||!f)return ie(!0),rt.current(),oe.current=!1,void G(!1);var h=r.getBoundingClientRect().top-v.getBoundingClientRect().top+v.scrollTop,p=l.getBoundingClientRect().top-f.getBoundingClientRect().top+f.scrollTop-(h-v.scrollTop);p<0&&We.current&&(We.current.style.height="".concat(Math.abs(p),"px"));requestAnimationFrame(function(){var e,n=f.scrollHeight-f.clientHeight;if(p<0)e=0;else{if(p>n){var t=p-n;return ze.current&&(ze.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){R(f,p,200,function(){ie(!0),rt.current(),oe.current=!1,G(!1)})})}e=p}R(f,e,200,function(){ie(!0),rt.current(),oe.current=!1,G(!1)})})})))},[Ge,De.sectionIdx,Z,Hn,pn,gn,st,Rn]),ut=null!==De.sectionIdx&&ce.has(De.sectionIdx),dt=function(t){var r,l,s,c=t.section,u=t.idx,d=t.columnKey,v=t.colRef,f=t.mb,h=void 0===f?1:f,g=t.parentNodeId,x=void 0===g?"":g,_=z?!!rn["".concat(d,"-").concat(u)]:!!rn[String(u)],y=(null===(r=c.displayTitle)||void 0===r||r)&&a.hasValue(c.title),b=(null===(l=c.displayContent)||void 0===l||l)&&a.hasValue(c.content),S=!y&&!b,R=c.title;y||(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 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:v,sx:{mb:h,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,o;pe.current=!0,ge.current&&clearTimeout(ge.current),he.current&&(he.current.style.opacity="0");var r=null===(i=Kn.current[n])||void 0===i?void 0:i.current,l=null===(o=Un.current[n])||void 0===o?void 0:o.current;if(r&&(r.style.minHeight="0px"),l&&(l.style.minHeight="0px"),Object.keys(Qn.current).forEach(function(e){var t,i;if(e.startsWith("".concat(n,"-"))){var o=null===(t=Qn.current[e])||void 0===t?void 0:t.current,r=null===(i=$n.current[e])||void 0===i?void 0:i.current;o&&(o.style.minHeight="0px"),r&&(r.style.minHeight="0px")}}),z){var s=pn[n];((null==s?void 0:s.refIndexes)||[]).forEach(function(e){var n,t=gn.findIndex(function(n){return n.selfIndex===e}),i=null===(n=Un.current[t])||void 0===n?void 0:n.current;i&&(i.style.minHeight="0px")});var a=gn[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 o=null===(i=Kn.current[n])||void 0===i?void 0:i.current;o&&(o.style.minHeight="0px")}})}ge.current=setTimeout(function(){pe.current=!1,rt.current(),he.current&&(he.current.style.opacity="1")},650),ln(function(i){var o=e.__assign({},i);if(!z){var r=!!i[String(n)];return o[String(n)]=!r,o}var l="".concat(t,"-").concat(n),s=!i[l];if(o[l]=s,"left"===t)((null==(a=pn[n])?void 0:a.refIndexes)||[]).forEach(function(e){var n=gn.findIndex(function(n){return n.selfIndex===e});-1!==n&&(o["right-".concat(n)]=s)});else{var a,c=null==(a=gn[n])?void 0:a.selfIndex;pn.forEach(function(e,n){var t;(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(c))&&(o["left-".concat(n)]=s)})}return o})}(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(o.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:y&&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:Ee,highlights:C,maintainRelativeOrder:z}),(c.subsections||[]).map(function(e,n){return vt({section:e,keyPath:"".concat(u,"-").concat(n),depth:0,columnKey:d,parentNodeId:x})})]}))]}))}),"".concat(d,"-sec-").concat(u))},vt=function(t){var r,l,s,c,u,d,v,f,h,g=t.section,x=t.keyPath,y=t.depth,b=void 0===y?0:y,S=t.columnKey,R=void 0===S?"left":S,I=t.parentNodeId,C=void 0===I?"":I,w=(null===(r=g.displayTitle)||void 0===r||r)&&a.hasValue(g.title),F=(null===(l=g.displayContent)||void 0===l||l)&&a.hasValue(g.content),j=!w&&!F,B=w?g.title:F?"No Title Found":"No Matching Section Found",T=!!an[x];"left"!==R||Qn.current[x]||(Qn.current[x]=p.default.createRef()),"right"!==R||$n.current[x]||($n.current[x]=p.default.createRef());for(var k="left"===R?Qn.current[x]:$n.current[x],A=tt(x),M=x.split("-").map(Number),D=pn[M[0]],O=gn[M[0]],N=1;N<M.length;N++)(null==D?void 0:D.subsections)&&(D=D.subsections[M[N]]),(null==O?void 0:O.subsections)&&(O=O.subsections[M[N]]);var H=null===(s=null==E?void 0:E.input_index_map)||void 0===s?void 0:s[0],L=null===(c=null==E?void 0:E.input_index_map)||void 0===c?void 0:c[1],W="left"===R?L:H,P=!(null===(u=g.refIndexes)||void 0===u?void 0:u.length)||void 0!==g.selfIndex&&g.selfIndex<0,q=null!==(f=null===(v=null===(d=g.evaluationResult)||void 0===d?void 0:d.evaluation_outputs)||void 0===v?void 0:v.output_value)&&void 0!==f?f:null,Y=Object.entries((null===(h=g.evaluationResult)||void 0===h?void 0:h.deviations)||{}).map(function(e,n){var t=e[0],i=e[1],o=i[C];if(!o||"No equivalent clause present."===o)return null;var r=function(e,n){return"".concat(e).concat(_).concat(n)}(x,t),l=i[W],s=P||!l||"No equivalent clause present."===l,a=M[0]+1,c="".concat(a,".").concat(n+1);return"left"!==R||Gn.current[r]||(Gn.current[r]=p.default.createRef()),"right"!==R||Xn.current[r]||(Xn.current[r]=p.default.createRef()),{id:r,label:c,highlight:o,side:R,style:A,score:q,isConnected:z&&ce.has(r),isOrphan:s,badgeRef:"left"===R?Gn.current[r]:Xn.current[r],onClick:function(e){e.stopPropagation(),wn(e,D||{title:"",content:""},s,O||{title:"",content:""},r,A)}}}).filter(Boolean),V=z&&Y.some(function(e){return ce.has(e.id)});return w||F||g.subsections&&0!==g.subsections.length?w?n.jsx(i.Box,e.__assign({ref:k,sx:{mt:1,width:"100%",minWidth:0,position:"relative"}},{children:n.jsx(i.Box,e.__assign({sx:e.__assign({width:"100%"},V&&A&&{borderRadius:"4px",outline:"2px solid ".concat(A.badgeBorder),outlineOffset:"1px"})},{children:n.jsxs(i.Accordion,e.__assign({disableGutters:!0,expanded:!j&&T,onChange:function(){return!j&&cn(function(n){var t;return e.__assign(e.__assign({},n),((t={})[x]=!n[x],t))})},sx:{mt:0,boxShadow:"none",border:j?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF",minWidth:0,"&:before":{display:"none"}}},{children:[n.jsx(i.AccordionSummary,e.__assign({expandIcon:j?null:n.jsx(o.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:j?"#94A3B8":"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:B||"Untitled Subsection"}))})),!j&&n.jsxs(i.AccordionDetails,e.__assign({sx:{pt:0,pb:1,minWidth:0}},{children:[F&&n.jsx(m,{content:g.content,sxStyles:Ee,deviationBadges:Y,maintainRelativeOrder:z}),(g.subsections||[]).map(function(e,n){return vt({section:e,keyPath:"".concat(x,"-").concat(n),depth:b+1,columnKey:R,parentNodeId:C})})]}))]}))}))}),x):n.jsx(i.Box,e.__assign({ref:k,sx:{mt:0===b?1:.75,width:"100%",minWidth:0,position:"relative"}},{children:!j&&n.jsxs(i.Box,e.__assign({sx:e.__assign({width:"100%"},V&&A&&{borderRadius:"4px",outline:"2px solid ".concat(A.badgeBorder),outlineOffset:"1px"})},{children:[F&&n.jsx(m,{content:g.content,sxStyles:Ee,deviationBadges:Y,maintainRelativeOrder:z}),(g.subsections||[]).map(function(e,n){return vt({section:e,keyPath:"".concat(x,"-").concat(n),depth:b+1,columnKey:R,parentNodeId:C})})]}))}),x):null};return n.jsxs(i.Box,e.__assign({ref:He,sx:e.__assign(e.__assign({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},z?{}:{overflow:"visible"}),{position:"relative"})},{children:[Y&&n.jsx(i.Box,e.__assign({sx:{position:"absolute",inset:0,bgcolor:"rgba(255, 255, 255, 0.6)",backdropFilter:"blur(10px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"8px"}},{children:n.jsx(v.default,{})})),z&&n.jsx(d.default,{open:De.open,anchorEl:De.anchorEl,sectionTitle:De.sectionTitle,referenceSectionTitle:De.refSectionTitle,onClose:Ge,onOpenCognitiveCompare:Fn,onOpenSideBySide:ct,onConnect:jn,isConnected:ut,isOrphan:De.isOrphan}),ke.open&&n.jsx(u.default,{open:ke.open,popupRef:we,position:Ie,popupConfig:N,onClose:function(){Ce(null),Ae(function(n){return e.__assign(e.__assign({},n),{open:!1})}),se(null)},markdownStyles:M,sectionTitle:ke.sectionTitle,referenceSectionTitle:ke.refSectionTitle,cognitiveData:ke.cognitiveData,anchorEl:ke.anchorEl,sectionAnchorEl:ke.sectionAnchorEl,scrollContainerEl:Ne.current,badgeStyle:ke.badgeStyle,docData:ke.docData,deviationData:ke.deviationData}),n.jsx(i.Snackbar,e.__assign({open:!!J,autoHideDuration:8e3,onClose:function(){return Q(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(i.Alert,e.__assign({onClose:function(){return Q(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:J}))})),(O.isHeaderVisible||O.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:O.isHeaderVisible&&n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:600,color:"#0F172A"}},{children:B}))})),O.isToggleVisible&&n.jsx(i.Box,e.__assign({sx:{display:"flex",alignItems:"center"}},{children:n.jsx(i.FormControlLabel,{control:n.jsx(i.Switch,{checked:z,onChange:function(e){var n=e.target.checked;V(!0),setTimeout(function(){P(n),Rn(),ue(new Set),fe([]),_e.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:Ne,onScroll:at,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:z?"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"},z?{flex:1,minHeight:0}:{})},{children:n.jsxs(i.Box,e.__assign({ref:Bn,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"10px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},z?{flex:1,overflow:"visible"}:{})},{children:[n.jsxs("svg",e.__assign({ref:he,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:[zn&&n.jsxs("g",{children:[n.jsx("line",{x1:zn.x1,y1:zn.y,x2:Math.max(zn.x1,(zn.x1+zn.x2)/2-70),y2:zn.y,stroke:"#BBF7D0",strokeWidth:"1.5"}),n.jsx("line",{x1:Math.min(zn.x2,(zn.x1+zn.x2)/2+70),y1:zn.y,x2:zn.x2,y2:zn.y,stroke:"#BBF7D0",strokeWidth:"1.5"})]}),Dn.map(function(t){var l,s=t.x1+.5*(t.x2-t.x1),a=(t.y1+t.y2)/2;if("Not Defined"===t.style.label&&!t.hasCognitive)return null;if(!z){var c=t.isSubSection?y(t.x1,t.y1,t.x2,t.y2):"M ".concat(t.x1," ").concat(t.y1," L ").concat(t.x2," ").concat(t.y2);return n.jsxs("g",{children:[n.jsx("defs",{children:n.jsx("marker",e.__assign({id:"arr-norm-".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||"#E2E8F0"})}))}),n.jsx("path",{d:c,fill:"none",stroke:t.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5",markerEnd:"url(#arr-norm-".concat(t.id,")")}),n.jsx("foreignObject",e.__assign({x:s-100,y:a-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(),ke.open&&le===t.id)Ue();else{var n=pn[t.sectionIdx]||{title:"",content:""},i=gn[t.sectionIdx]||{title:"",content:""};if(t.isSubSection&&t.subSectionKeyPath){for(var o=t.subSectionKeyPath.split("-").map(Number),r=pn[o[0]],l=gn[o[0]],s=1;s<o.length;s++)(null==r?void 0:r.subsections)&&(r=r.subsections[o[s]]),(null==l?void 0:l.subsections)&&(l=l.subsections[o[s]]);r&&(n=r),l&&(i=l)}se(t.id),Cn(In(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(r.ButtonCognitiveIcon,{})})),n.jsx(o.ChevronDown,{size:11,style:{transform:ke.open&&le===t.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},t.id)}var u=!1;if(t.isSubSection)u=Z&&Hn===t.subSectionKeyPath&&te;else{var d=pn[t.sectionIdx];if(!(null===(l=null==d?void 0:d.refIndexes)||void 0===l?void 0:l.length)||(null==d?void 0:d.selfIndex)<0)return null;u=Z&&Hn===t.sectionIdx&&te}return u?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:Tn,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}),ve.map(function(t){var i,o=t.pathD,r=(null===(i=t.style)||void 0===i?void 0:i.badgeBorder)||"#6366F1",l="conn-marker-".concat(t.id),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:r})}))}))}),n.jsx("path",{ref:function(e){xe.current[s]=e},d:o,fill:"none",stroke:"#FFFFFF",strokeWidth:"4",strokeOpacity:"0.7"}),n.jsx("path",{ref:function(e){xe.current[a]=e},d:o,fill:"none",stroke:r,strokeWidth:"1.75",markerEnd:"url(#".concat(l,")")})]},t.id)})]})),n.jsxs(i.Box,e.__assign({sx:e.__assign({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},z?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(i.Box,e.__assign({ref:kn,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:"normal",width:"100%",height:"40px"}},{children:fn}))}))})),n.jsxs(i.Box,e.__assign({ref:Ye,onScroll:at,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},z?{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:Pe,style:{width:"100%",height:"0px",flexShrink:0}}),xn&&pn.map(function(t,r){var l,s,a,c=!t.title&&!t.content;if(z&&c)return null;if(!z)return n.jsx(i.Box,e.__assign({ref:Sn(r),sx:{width:"100%"}},{children:dt({section:t,idx:r,columnKey:"left",colRef:Kn.current[r],parentNodeId:(null===(l=null==E?void 0:E.input_index_map)||void 0===l?void 0:l[0])||""})}),"left-row-".concat(r));var u=t,d=nt(r),v=!(null===(s=u.refIndexes)||void 0===s?void 0:s.length)||u.selfIndex<0,f="number"==typeof u.selfIndex&&u.selfIndex>=0?u.selfIndex+1:null,h=ce.has(r);return n.jsx(i.Box,e.__assign({ref:Sn(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"},h&&{borderRadius:"6px",outline:"2px solid ".concat((null==d?void 0:d.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:dt({section:t,idx:r,columnKey:"left",colRef:p.default.createRef(),mb:0,parentNodeId:(null===(a=null==E?void 0:E.input_index_map)||void 0===a?void 0:a[0])||""})})),d&&n.jsxs(i.Box,e.__assign({ref:Gn.current[r],onClick:function(e){var n=gn.find(function(e){var n;return null===(n=u.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""};wn(e,t,v,n,r,d)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:d.badgeBg,color:d.badgeText,border:"1px solid ".concat(d.badgeBorder),borderRadius:"12px",px:1.2,py:.4,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[null!==f&&n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(d.badgeBorder)}},{children:f})),n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",px:.25}},{children:v?"No Deviation Found":0==d.deviationLabel||void 0===d.deviationLabel?d.label:"".concat(d.deviationLabel,"% Deviation")})),n.jsx(o.EllipsisVertical,{size:11,color:d.badgeText})]}))]}))}),"left-row-".concat(r))}),n.jsx("div",{ref:qe,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(r.ButtonCognitiveIcon,{})})),0,"% Similarity",n.jsx(o.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},z?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[U&&n.jsx(l.default,{sections:11}),n.jsx(i.Box,e.__assign({ref:An,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:hn,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:"normal",width:"100%",height:"40px"}},{children:hn}))}))})),n.jsxs(i.Box,e.__assign({ref:Le,onScroll:at,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},z?{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:We,style:{width:"100%",height:"0px",flexShrink:0}}),xn&&gn.map(function(t,o){var r,l;if(!z)return n.jsx(i.Box,e.__assign({ref:Jn.current[o],sx:{width:"100%"}},{children:dt({section:t,idx:o,columnKey:"right",colRef:Un.current[o],parentNodeId:(null===(r=null==E?void 0:E.input_index_map)||void 0===r?void 0:r[1])||""})}),"right-row-".concat(o));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 ce.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(s.selfIndex))}),u=pn.findIndex(function(e,n){var t;return ce.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(s.selfIndex))}),d=-1!==u?nt(u):null;return n.jsx(i.Box,e.__assign({ref:Jn.current[o],sx:{mb:1}},{children:n.jsxs(i.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[n.jsx(i.Box,e.__assign({ref:Un.current[o],sx:e.__assign({width:"100%",display:"flex"},c&&d&&{borderRadius:"6px",outline:"2px solid ".concat(d.badgeBorder),outlineOffset:"1px"})},{children:dt({section:t,idx:o,columnKey:"right",colRef:p.default.createRef(),mb:0,parentNodeId:(null===(l=null==E?void 0:E.input_index_map)||void 0===l?void 0:l[1])||""})})),!U&&n.jsx(i.Box,e.__assign({ref:Xn.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))}),n.jsx("div",{ref:ze,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"),v=require("./LoaderComponent.js"),f=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(f),_="::",m=h.default.memo(function(o){var l=o.content,s=o.sxStyles,c=o.deviationBadges,u=void 0===c?[]:c,d=o.highlights,v=void 0===d?[]:d,f=o.maintainRelativeOrder,p=void 0===f||f,h=t.useMemo(function(){return u.reduce(function(n,t){var i;return e.__assign(e.__assign({},n),((i={})[t.id]=t,i))},{})},[u]),_=t.useMemo(function(){return{mark:function(t){var i=t.children;return n.jsx("span",e.__assign({style:{backgroundColor:"#fccccc",borderRadius:"2px"}},{children:i}))},span:function(t){var o,l,s,a,c,u=t.children,d=e.__rest(t,["children"]),v=d["data-badge-id"];if(!v)return n.jsx("span",e.__assign({},d,{children:u}));var f=h[v];return f?n.jsxs(i.Box,e.__assign({component:"span",sx:{position:"static",display:"inline"}},{children:[u,n.jsx(i.Box,e.__assign({ref:f.badgeRef,onClick:f.onClick,sx:e.__assign(e.__assign({position:"absolute",zIndex:30,display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"10px",bgcolor:(null===(o=f.style)||void 0===o?void 0:o.badgeBg)||"#EEF2FF",color:(null===(l=f.style)||void 0===l?void 0:l.badgeText)||"#3730A3",border:"1px solid ".concat((null===(s=f.style)||void 0===s?void 0:s.badgeBorder)||"#C7D2FE"),borderRadius:"12px",px:1,py:.3,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",boxShadow:"0 1px 3px rgba(0,0,0,0.07)"},"left"===f.side?{right:"-16px",transform:"translateY(-20%) translateX(calc(100% + 8px))"}:{left:"-16px",transform:"translateY(-20%) translateX(calc(-100% - 8px))"}),f.isConnected&&f.style&&{outline:"2px solid ".concat(f.style.badgeBorder),outlineOffset:"1px"})},{children:n.jsxs(n.Fragment,{children:[n.jsx(i.Box,e.__assign({component:"span",sx:e.__assign({fontSize:"10px",fontWeight:700},"left"===f.side?{pr:.5,borderRight:"1px solid ".concat((null===(a=f.style)||void 0===a?void 0:a.badgeBorder)||"#C7D2FE")}:{})},{children:f.label})),"left"===f.side&&n.jsxs(n.Fragment,{children:[n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"10px",px:.25}},{children:null!=f.score&&"N/A"!==f.score&&"NA"!==f.score&&0!==f.score?"".concat(f.score,"% Deviation"):f.isOrphan?"No Deviation Found":"N/A"===f.score||"NA"===f.score?"N/A":"Same"})),n.jsx(r.EllipsisVertical,{size:10,color:(null===(c=f.style)||void 0===c?void 0:c.badgeText)||"#3730A3"})]})]})}))]})):n.jsx("span",e.__assign({},d,{children:u}))}}},[h,p]),m=t.useMemo(function(){var e=l||"",n=function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")};return u.forEach(function(t){t.highlight&&(e=e.replace(new RegExp(n(t.highlight),"g"),'<span data-badge-id="'.concat(t.id,'"><mark>').concat(t.highlight,"</mark></span>")))}),v.forEach(function(t){t&&(e=e.replace(new RegExp(n(t),"g"),"<mark>".concat(t,"</mark>")))}),e},[l,u,v]);return n.jsx(i.Typography,e.__assign({component:"div",sx:e.__assign(e.__assign({},s),{position:"relative",overflow:"visible","& p, & li, & ul, & ol":{position:"static",overflow:"visible"}})},{children:n.jsx(g.default,e.__assign({components:_,rehypePlugins:[x.default]},{children:a.safeStringify(m).replace(/\\n/g,"\n")}))}))},function(e,n){if(e.content!==n.content)return!1;if(e.sxStyles!==n.sxStyles)return!1;if(e.maintainRelativeOrder!==n.maintainRelativeOrder)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+.5*(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:""},S={open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,isOrphan:!1,docData:null,deviationData:null},R=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,v=u-a;v<t?(e.scrollTop=(d=v,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 f,p,g,x,C,I,w,F,B=s.componentHeaderText,j=void 0===B?"Contract Comparison":B,E=s.treeData,T=s.comparisonConfig,A=s.leftColumnTitleText,M=s.rightColumnTitleText,k=s.markdownStyles,D=s.displayConfig,O=void 0===D?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1}:D,N=s.popupConfig,H=s.deviationData,L=void 0===H?{}:H,W=t.useState(O.maintainRelativeOrder),z=W[0],P=W[1],q=t.useState(!1),Y=q[0],V=q[1],K=t.useState(!1),U=K[0],G=K[1],X=t.useState(null),J=X[0],Q=X[1],$=t.useState(!1),Z=$[0],ee=$[1],ne=t.useState(!1),te=ne[0],ie=ne[1],re=t.useRef(!1),oe=t.useState(null),le=oe[0],se=oe[1],ae=t.useState(new Set),ce=ae[0],ue=ae[1],de=t.useState([]),ve=de[0],fe=de[1],pe=t.useRef(null),he=t.useRef(!1),ge=t.useRef(null),xe=t.useRef({}),_e=t.useRef([]),me=t.useRef(!1),ye=t.useRef(!1),be=t.useRef(null),Se=t.useMemo(function(){return(null==E?void 0:E.cognitive_decisioning)||{}},[E]),Re=t.useState(null),Ce=Re[0],Ie=Re[1],we=t.useRef(null),Fe=t.useState({width:0,height:0}),Be=Fe[0],je=Fe[1],Ee=t.useMemo(function(){return e.__assign(e.__assign({},c.SHARED_MARKDOWN_STYLES),k)},[k]),Te=t.useState({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,isOrphan:!1,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null,deviationData:null}),Ae=Te[0],Me=Te[1],ke=t.useState({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,isOrphan:!1,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null,deviationData:null}),De=ke[0],Oe=ke[1],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),Ye=t.useRef(null),Ve=t.useRef(!1),Ke=t.useRef(null);t.useEffect(function(){Ke.current=null},[Ae.sectionIdx,Ae.open]);var Ue=t.useCallback(function(){Ie(null),Me(S),se(null)},[]),Ge=t.useCallback(function(){Oe(S)},[]),Xe=t.useCallback(function(){var e;if(Ae.anchorEl&&Ae.refSectionTitle){var n=Ae.anchorEl.getBoundingClientRect(),t=(null===(e=null==we?void 0:we.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!==Ke.current?!0===Ke.current&&(l=o>=t||o>=r):l=!(r>=t||r>=o),Ke.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,v=Math.max(12,Math.min(d,window.innerWidth-i-12)),f=Math.max(14,Math.min(u-v,i-10-4));Ie({top:c,left:v,arrowLeft:f,openAbove:l,maxHeight:s})}},[Ae.anchorEl,Ae.refSectionTitle]);t.useEffect(function(){if(Ae.open){window.addEventListener("resize",Xe);var e=requestAnimationFrame(Xe),n=null;return we.current&&(n=new ResizeObserver(function(){cancelAnimationFrame(e),e=requestAnimationFrame(Xe)})).observe(we.current),function(){cancelAnimationFrame(e),window.removeEventListener("resize",Xe),n&&n.disconnect()}}},[Ae.open,Xe]),t.useEffect(function(){var e=Ne.current;if(e&&Ae.open){var n=function(e){we.current&&we.current.contains(e.target)||(Ie(null),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]),t.useEffect(function(){var e=Ne.current;if(e&&De.open){var n=function(){Ge()};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})}}},[De.open,Ge]);var Je=t.useMemo(function(){var n,t,i,r,o,l,s,a,u,d,v,f;return{fields:null!==(n=null==T?void 0:T.fields)&&void 0!==n?n:c.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(i=null===(t=null==T?void 0:T.thresholds)||void 0===t?void 0:t.high)&&void 0!==i?i:c.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(o=null===(r=null==T?void 0:T.thresholds)||void 0===r?void 0:r.medium)&&void 0!==o?o:c.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(s=null===(l=null==T?void 0:T.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==T?void 0:T.relationStyles)||void 0===a?void 0:a.noContent)||{}),high:e.__assign(e.__assign({},c.DEFAULT_COMPARISON_CONFIG.relationStyles.high),(null===(u=null==T?void 0:T.relationStyles)||void 0===u?void 0:u.high)||{}),exact:e.__assign(e.__assign({},c.DEFAULT_COMPARISON_CONFIG.relationStyles.exact),(null===(d=null==T?void 0:T.relationStyles)||void 0===d?void 0:d.exact)||{}),medium:e.__assign(e.__assign({},c.DEFAULT_COMPARISON_CONFIG.relationStyles.medium),(null===(v=null==T?void 0:T.relationStyles)||void 0===v?void 0:v.medium)||{}),low:e.__assign(e.__assign({},c.DEFAULT_COMPARISON_CONFIG.relationStyles.low),(null===(f=null==T?void 0:T.relationStyles)||void 0===f?void 0:f.low)||{})}}},[T]),Qe=t.useMemo(function(){if(E&&Object.keys(E).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=[],v=n.base_root_id,f=n.input_index_map||{0:"left",1:"right"},p=n[v]||c[v];if(!p||!1===p.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[]};var h=function(t,r){var o,l,s,u=n[t]||c[t];if(!u||!1===u.display_node)return null;var d=a.getSideData(u,r,f),v=!1!==(null===(o=d.attributes)||void 0===o?void 0:o.display_title),p=!1!==(null===(l=d.attributes)||void 0===l?void 0:l.display_content),g=!!d.title.trim(),x=!!d.content.trim(),_=a.getRationale(u),m=(null===(s=null==i?void 0:i[t])||void 0===s?void 0:s.evaluation_result)||u.evaluation_result||null,y=[];u.next&&Object.values(u.next).forEach(function(e){var n=c[e];if(n&&!1!==n.display_node){var t=h(e,r);t&&y.push(t)}});var b=!(!g&&!x);return e.__assign(e.__assign({id:t,title:g?d.title:"",content:x?d.content:"",displayTitle:v,displayContent:p,subsections:y},b?_:{score:void 0,relation:"not_defined"}),{evaluationResult:m})};if(t){var g=function(t,r){var o,l,s,u,d,v,p,h,x,_,m,y,b,S,R,C,I,w,F,B,j;void 0===r&&(r=0);var E=[],T=[];if(!t)return{refSections:E,baseSections:T};var A={},M={},k=-1,D=-1;for(var O in t){var N=t[O],H=n[N]||c[N];if(H&&!1!==H.display_node){var L=a.getRationale(H),W=(null===(o=null==i?void 0:i[N])||void 0===o?void 0:o.evaluation_result)||H.evaluation_result||null,z=a.getSideData(H,"1",f),P=a.getSideData(H,"0",f),q=!1!==(null===(l=z.attributes)||void 0===l?void 0:l.display_title)&&z.title.trim()||!1!==(null===(s=z.attributes)||void 0===s?void 0:s.display_content)&&z.content.trim(),Y=!1!==(null===(u=P.attributes)||void 0===u?void 0:u.display_title)&&P.title.trim()||!1!==(null===(d=P.attributes)||void 0===d?void 0:d.display_content)&&P.content.trim(),V=Number(null!==(p=null===(v=z.attributes)||void 0===v?void 0:v.display_index)&&void 0!==p?p:k--),K=Number(null!==(x=null===(h=P.attributes)||void 0===h?void 0:h.display_index)&&void 0!==x?x:D--),U=A[V]||e.__assign(e.__assign({id:N,title:!1!==(null===(_=z.attributes)||void 0===_?void 0:_.display_title)?z.title:"",content:!1!==(null===(m=z.attributes)||void 0===m?void 0:m.display_content)?z.content:"",subsections:[]},q?L:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:V,evaluationResult:W,displayContent:null===(y=z.attributes)||void 0===y?void 0:y.display_content,displayTitle:null===(b=z.attributes)||void 0===b?void 0:b.display_title}),G=M[K]||e.__assign(e.__assign({id:N,title:!1!==(null===(S=P.attributes)||void 0===S?void 0:S.display_title)?P.title:"",content:!1!==(null===(R=P.attributes)||void 0===R?void 0:R.display_content)?P.content:"",subsections:[]},Y?L:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:K,evaluationResult:W,displayContent:null===(C=P.attributes)||void 0===C?void 0:C.display_content,displayTitle:null===(I=P.attributes)||void 0===I?void 0:I.display_title});Number(V)>=0&&Number(K)>=0&&((null===(w=U.refIndexes)||void 0===w?void 0:w.includes(Number(K)))||null===(F=U.refIndexes)||void 0===F||F.push(Number(K)),(null===(B=G.refIndexes)||void 0===B?void 0:B.includes(Number(V)))||null===(j=G.refIndexes)||void 0===j||j.push(Number(V))),A[V]=U,M[K]=G;var X=g(H.next,r+1),J=X.refSections,Q=X.baseSections;J.length>0&&(U.subsections=e.__spreadArray(e.__spreadArray([],U.subsections||[],!0),J,!0)),Q.length>0&&(G.subsections=e.__spreadArray(e.__spreadArray([],G.subsections||[],!0),Q,!0))}}return E=Object.values(A).map(function(e){return e}),T=Object.values(M).map(function(e){return e}),E.sort(function(e,n){return e.selfIndex<0&&n.selfIndex>=0?1:e.selfIndex>=0&&n.selfIndex<0?-1:e.selfIndex-n.selfIndex}),T.sort(function(e,n){return e.selfIndex<0&&n.selfIndex>=0?1:e.selfIndex>=0&&n.selfIndex<0?-1:e.selfIndex-n.selfIndex}),{refSections:E,baseSections:T}},x=g(p.next),_=x.refSections,m=x.baseSections;d=_,u=m}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[f[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[f[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:{}}}}]}}(E,z,L);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(E),z,JSON.stringify(L)]),$e=Qe.activeProposed,Ze=Qe.activeVariants,en=Qe.parseError;t.useEffect(function(){en&&Q("Failed to load comparison: ".concat(en))},[en]);var nn=t.useState(null),tn=nn[0];nn[1];var rn=t.useState({}),on=rn[0],ln=rn[1],sn=t.useState({}),an=sn[0],cn=sn[1],un=(null==Ze?void 0:Ze[0])||b,dn=null===(g=null===(f=null==E?void 0:E.documents)||void 0===f?void 0:f[null===(p=null==E?void 0:E.input_index_map)||void 0===p?void 0:p[0]])||void 0===g?void 0:g.title,vn=null===(I=null===(x=null==E?void 0:E.documents)||void 0===x?void 0:x[null===(C=null==E?void 0:E.input_index_map)||void 0===C?void 0:C[1]])||void 0===I?void 0:I.title,fn=a.safeStringify(A||dn||"Uploaded Contract"),pn=a.safeStringify(M||vn||"Reference Template"),hn=t.useMemo(function(){return(null==$e?void 0:$e.sections)||[]},[null==$e?void 0:$e.sections]),gn=t.useMemo(function(){return un.sections||[]},[un.sections]),xn=hn.length>0||gn.length>0,_n=un.analysis,mn=a.safeStringify(null===(F=null===(w=null==_n?void 0:_n.rule_difference_comparison)||void 0===w?void 0:w.summary)||void 0===F?void 0:F.overall_summary),yn=!!mn.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),bn=t.useRef({}),Sn=function(e){return bn.current[e]||(bn.current[e]=h.default.createRef()),bn.current[e]},Rn=t.useCallback(function(){var e,n,t,i;ee(!1),ye.current=!1;var r=be.current,o=En.current;if(null!==r){var l="string"==typeof r?null===(e=Qn.current[r.split(_)[0]])||void 0===e?void 0:e.current:null===(n=Kn.current[r])||void 0===n?void 0:n.current;l&&(l.style.paddingTop="0px")}if(null!==o){var s="string"==typeof o?null===(t=$n.current[o.split(_)[0]])||void 0===t?void 0:t.current:null===(i=Un.current[o])||void 0===i?void 0:i.current;s&&(s.style.paddingTop="0px")}Ln(null),be.current=null,En.current=null,ie(!1),G(!1),We.current&&(We.current.style.height="0px"),ze.current&&(ze.current.style.height="0px"),Pe.current&&(Pe.current.style.height="0px"),qe.current&&(qe.current.style.height="0px")},[]),Cn=t.useCallback(function(e,n,t,i,r,o){var l,s,c=a.safeStringify(n.id)||a.safeStringify(t.id)||"",u=(c?Se[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==E?void 0:E.documents,input_index_map:null==E?void 0:E.input_index_map},deviationData:n.evaluationResult||t.evaluationResult||null,isOrphan:!!r}},[Se,E]),In=t.useCallback(function(e){Ge(),Ie(null),Me(e)},[Ge]),wn=function(e,n,t,i,r,o){e.stopPropagation(),De.open&&De.sectionIdx===r?Ge():(Ue(),Oe(Cn(e.currentTarget,n,i,r,t,o)))},Fn=t.useCallback(function(){null!==De.sectionIdx&&De.anchorEl?In(e.__assign(e.__assign({},De),{open:!0})):Ge()},[De,Ge,In]),Bn=t.useCallback(function(){var e=De.sectionIdx,n=De.isOrphan;Ge(),null!==e&&(n?Q("No counterpart exists to connect to."):(ye.current&&Rn(),ue(function(n){return n.has(e)?new Set:new Set([e])})))},[De.sectionIdx,Ge,Rn]),jn=t.useRef(null),En=t.useRef(null),Tn=t.useRef(null),An=t.useRef(null),Mn=t.useRef(null),kn=t.useState([]),Dn=kn[0],On=kn[1],Nn=t.useState(null),Hn=Nn[0],Ln=Nn[1];t.useRef(null);var Wn=t.useState(null),zn=Wn[0],Pn=Wn[1],qn=t.useMemo(function(){return Je.fields.filter(function(e){var n=e.key;return(!xn||"description"!==n)&&(a.hasValue(null==$e?void 0:$e[n])||a.hasValue(un[n]))})},[$e,un,xn,Je.fields]),Yn=t.useRef({}),Vn=t.useRef({}),Kn=t.useRef({}),Un=t.useRef({}),Gn=t.useRef({}),Xn=t.useRef({}),Jn=t.useRef({}),Qn=t.useRef({}),$n=t.useRef({});qn.forEach(function(e){for(var n=e.key,t=0;t<Math.max(hn.length,gn.length);t+=1)Kn.current[t]||(Kn.current[t]=h.default.createRef()),Un.current[t]||(Un.current[t]=h.default.createRef()),Gn.current[t]||(Gn.current[t]=h.default.createRef()),Xn.current[t]||(Xn.current[t]=h.default.createRef()),Jn.current[t]||(Jn.current[t]=h.default.createRef());Yn.current[n]||(Yn.current[n]=h.default.createRef()),Vn.current[n]||(Vn.current[n]=h.default.createRef())});for(var Zn=0;Zn<Math.max(hn.length,gn.length);Zn+=1)Kn.current[Zn]||(Kn.current[Zn]=h.default.createRef()),Un.current[Zn]||(Un.current[Zn]=h.default.createRef()),Gn.current[Zn]||(Gn.current[Zn]=h.default.createRef()),Xn.current[Zn]||(Xn.current[Zn]=h.default.createRef()),Jn.current[Zn]||(Jn.current[Zn]=h.default.createRef());t.useEffect(function(){if(tn){var e=Je.fields.find(function(e){return e.analysisKey===tn||e.key===tn});if(e){var n=Yn.current[e.key]||Vn.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[tn,Je.fields]);var et=t.useCallback(function(e){var n,t,i,r,o,l,s,a,c,u=null===(n=null==_n?void 0:_n.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],v=(null==d?void 0:d.relation)||(null===(i=null===(t=null==d?void 0:d.highlights)||void 0===t?void 0:t.ruleA_spans)||void 0===i?void 0:i.length)||(null===(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 f=d.mappings[0]||{};return{score:d.score,relation:f.relation||"",highlightsA:(null===(l=f.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(s=f.highlights)||void 0===s?void 0:s.ruleB_spans)||[],hasContent:!!v}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(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:!!v}},[_n]),nt=t.useCallback(function(n){var t,i,r,o=hn[n],l=gn[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({},Je.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,v=(null===(r=null==d?void 0:d.evaluation_outputs)||void 0===r?void 0:r.output_value)+"%";return null!=d?e.__assign(e.__assign({},Je.relationStyles.low),{label:v}):e.__assign(e.__assign({},Je.relationStyles.low),{label:"N/A"})},[hn,gn,Se,Je,et]),tt=t.useCallback(function(n){for(var t,i,r,o,l,s,c=n.split("-").map(Number),u=hn[c[0]],d=gn[c[0]],v=1;v<c.length;v++)(null==u?void 0:u.subsections)&&(u=u.subsections[c[v]]),(null==d?void 0:d.subsections)&&(d=d.subsections[c[v]]);if(!u&&!d)return null;var f=(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(!f&&!p&&!g)return e.__assign(e.__assign({},Je.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=Se[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,_=(null===(s=null==x?void 0:x.evaluation_outputs)||void 0===s?void 0:s.output_value)+"%";return null!=x?e.__assign(e.__assign({},Je.relationStyles.low),{label:_}):e.__assign(e.__assign({},Je.relationStyles.low),{label:"N/A"})},[hn,gn,Se,Je]),it=t.useCallback(function(){var e,n,t,i,r,o,l,s,a,c,u,d,v,f,p,h,g,x,m,b,S,R;if(!Ve.current&&!he.current){Ve.current=!0;try{if(!jn.current)return;var C=function(e){var n=e.split("-"),t=n[0];if(!on[t]&&!1===z)return!1;if(z&&!on["left-".concat(t)]&&!on["right-".concat(t)]&&!on[t])return!1;for(var i=t,r=1;r<n.length-1;r++)if(i+="-".concat(n[r]),!an[i])return!1;return!0},I=jn.current.getBoundingClientRect();je({width:I.width,height:I.height});var w=[];if(qn.forEach(function(e){var n,t,i=e.key,r=null===(n=Yn.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 F=0;F<Math.max(hn.length,gn.length);F++){var B=null===(e=Kn.current[F])||void 0===e?void 0:e.current,j=null===(n=Un.current[F])||void 0===n?void 0:n.current;B&&(B.style.height="auto",B.style.minHeight="0px"),j&&(j.style.height="auto",j.style.minHeight="0px")}z||Object.keys(Qn.current).forEach(function(e){var n,t;if(C(e)){var i=null===(n=Qn.current[e])||void 0===n?void 0:n.current,r=null===(t=$n.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={};qn.forEach(function(e){var n,t,i=e.key,r=null===(n=Yn.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:{}},A={};if(!he.current)if(z){if(Z&&null!==Hn)if("number"==typeof Hn){var M=Hn,k=hn[M],D=null===(r=Kn.current[M])||void 0===r?void 0:r.current;D&&k&&(k.refIndexes||[]).forEach(function(e){var n,t=gn.findIndex(function(n){return n.selfIndex===e}),i=null===(n=Un.current[t])||void 0===n?void 0:n.current;if(i&&(on["left-".concat(M)]||on["right-".concat(t)])){var r=Math.max(D.getBoundingClientRect().height,i.getBoundingClientRect().height);T.left[M]=Math.max(T.left[M]||0,r),T.right[t]=Math.max(T.right[t]||0,r)}})}else{var O=Hn.split(_)[0];B=null===(o=Qn.current[O])||void 0===o?void 0:o.current,j=null===(l=$n.current[O])||void 0===l?void 0:l.current;if(B&&j){N=Math.max(B.getBoundingClientRect().height,j.getBoundingClientRect().height);A[O]=Math.max(A[O]||0,N)}}}else{Object.keys(Qn.current).forEach(function(e){var n,t;if(C(e)){var i=null===(n=Qn.current[e])||void 0===n?void 0:n.current,r=null===(t=$n.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(),s=Math.max(o.height,l.height);A[e]=s,i.style.minHeight="".concat(s,"px"),r.style.minHeight="".concat(s,"px")}}});for(F=0;F<Math.min(hn.length,gn.length);F++){var B=null===(t=Kn.current[F])||void 0===t?void 0:t.current,j=null===(i=Un.current[F])||void 0===i?void 0:i.current;if(B&&j){var N=Math.max(B.getBoundingClientRect().height,j.getBoundingClientRect().height);T.left[F]=N,T.right[F]=N}}}if(qn.forEach(function(e){var n,t,i=e.key,r=null===(n=Yn.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=Kn.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=Un.current[Number(t)])||void 0===n?void 0:n.current;r&&(r.style.minHeight="".concat(i,"px"))}),z||Object.keys(A).forEach(function(e){var n,t,i=null===(n=Qn.current[e])||void 0===n?void 0:n.current,r=null===(t=$n.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")}})),z)hn.forEach(function(e,n){var t;(null===(t=Kn.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,v=gn.findIndex(function(n){return n.selfIndex===e});if(-1!==v){var f=null===(t=Gn.current[n])||void 0===t?void 0:t.current,p=null===(i=Xn.current[v])||void 0===i?void 0:i.current;if(f&&p){var h=f.getBoundingClientRect(),g=p.getBoundingClientRect(),x=h.right-I.left,_=g.left-I.left,m=h.top+h.height/2-I.top,y=g.top+g.height/2-I.top;if(Z&&Hn===n){var b=null!==(o=null===(r=Ye.current)||void 0===r?void 0:r.getBoundingClientRect().top)&&void 0!==o?o:0,S=null!==(s=null===(l=Le.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==s?s:0,R=b+(null!==(c=null===(a=Ye.current)||void 0===a?void 0:a.clientHeight)&&void 0!==c?c:1/0),C=S+(null!==(d=null===(u=Le.current)||void 0===u?void 0:u.clientHeight)&&void 0!==d?d:1/0),F=h.top+h.height/2,B=function(e,n,t){return Math.max(n,Math.min(t,e))};m=B(F,b,R)-I.top,y=B(F,S,C)-I.top}var j=nt(n);j&&w.push({id:"line-".concat(n,"-").concat(v),x1:x,y1:m,x2:_,y2:y,style:j,sectionIdx:n,targetRightIdx:v})}}})});else for(F=0;F<Math.min(hn.length,gn.length);F++){var H=null===(s=Kn.current[F])||void 0===s?void 0:s.current,L=null===(a=Un.current[F])||void 0===a?void 0:a.current;if(H&&L){var W=H.getBoundingClientRect(),P=L.getBoundingClientRect(),q=Math.max(W.top,P.top)+18-I.top,Y=(null===(c=gn[F])||void 0===c?void 0:c.id)||"sec-".concat(F);(G=nt(F))&&w.push({id:Y,x1:W.right-I.left,y1:q,x2:P.left-I.left,y2:q,style:G,sectionIdx:F,hasCognitive:!!((null===(u=hn[F])||void 0===u?void 0:u.cognitiveData)||(null===(d=gn[F])||void 0===d?void 0:d.cognitiveData)||Y&&Se[Y]),isSubSection:!1})}}if(Z&&"string"==typeof Hn){var V=Hn,K=(O=V.split(_)[0],null===(v=Gn.current[V])||void 0===v?void 0:v.current),U=null===(f=Xn.current[V])||void 0===f?void 0:f.current;if(K&&U){var G,X=K.getBoundingClientRect(),J=U.getBoundingClientRect(),Q=X.right-I.left,$=J.left-I.left,ee=X.top+X.height/2-I.top,ne=J.top+J.height/2-I.top;if(z){var te=null!==(h=null===(p=Ye.current)||void 0===p?void 0:p.getBoundingClientRect().top)&&void 0!==h?h:0,ie=null!==(x=null===(g=Le.current)||void 0===g?void 0:g.getBoundingClientRect().top)&&void 0!==x?x:0,re=te+(null!==(b=null===(m=Ye.current)||void 0===m?void 0:m.clientHeight)&&void 0!==b?b:1/0),oe=ie+(null!==(R=null===(S=Le.current)||void 0===S?void 0:S.clientHeight)&&void 0!==R?R:1/0),le=function(e,n,t){return Math.max(n,Math.min(t,e))};ee=le(X.top+X.height/2,te,re)-I.top,ne=le(J.top+J.height/2,ie,oe)-I.top}(G=tt(O))&&w.push({id:"line-subsec-".concat(V),x1:Q,y1:ee,x2:$,y2:ne,style:G,sectionIdx:Number(O.split("-")[0]),isSubSection:!0,subSectionKeyPath:V})}}if(On(w),An.current&&Mn.current){var se=An.current.getBoundingClientRect(),ae=Mn.current.getBoundingClientRect(),ue=(se.top+se.height/2-I.top+ae.top+ae.height/2-I.top)/2;Pn({x1:se.right-I.left,x2:ae.left-I.left,y:ue})}else Pn(null);if(ce.size>0){var de=[],ve=Ye.current,pe=Le.current;if(ve&&pe){var ge=[],xe=ve.getBoundingClientRect().top,me=pe.getBoundingClientRect().top,ye=xe+ve.clientHeight,be=me+pe.clientHeight,Re=ve.scrollTop,Ce=pe.scrollTop,Ie=I.top,we=function(e,n,t){return Math.max(n,Math.min(t,e))};ce.forEach(function(e){var n,t,i,r,o;if("string"==typeof e){var l=e,s=l.split(_)[0],a=null===(n=Gn.current[l])||void 0===n?void 0:n.current,c=null===(t=Xn.current[l])||void 0===t?void 0:t.current;if(!a||!c)return;var u=a.getBoundingClientRect(),d=c.getBoundingClientRect(),v=tt(s),f=(E=u.right-I.left)+.5*((T=d.left-I.left-0)-E),p=u.top+u.height/2,h=d.top+d.height/2,g=p-xe+Re,x=h-me+Ce,m="conn-subsec-".concat(l);ge.push({lhsScrollY:g,rhsScrollY:x,x1:E,x2:T,containerTop:Ie,leftIdx:l,rhsArrayIdx:l,styleColor:(null==v?void 0:v.badgeBorder)||"#6366F1",styleId:m});var b=we(p,xe,ye),S=we(h,me,be),R=b-Ie,C=S-Ie,w=h>=me-4&&h<=be+4,F="";F=(A=p>=xe-4&&p<=ye+4)&&w?y(E,R,T,C):A&&!w?"M ".concat(E,",").concat(R," L ").concat(f,",").concat(R," L ").concat(f,",").concat(C):!A&&w?"M ".concat(f,",").concat(R," L ").concat(f,",").concat(C," L ").concat(T,",").concat(C):"M ".concat(f,",").concat(R," L ").concat(f,",").concat(C),de.push({id:m,pathD:F,style:v,leftIdx:l,rhsArrayIdx:l})}else if(z){var B=hn[e];if(!(null===(o=null==B?void 0:B.refIndexes)||void 0===o?void 0:o.length))return;B.refIndexes.forEach(function(n){var t,i,r=gn.findIndex(function(e){return e.selfIndex===n});if(-1!==r){var o=null===(t=Gn.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=nt(e),u=s.right-I.left,d=a.left-I.left-0,v=u+.5*(d-u),f=s.top+s.height/2,p=a.top+a.height/2,h=f-xe+Re,g=p-me+Ce,x="conn-".concat(e,"-").concat(r);ge.push({lhsScrollY:h,rhsScrollY:g,x1:u,x2:d,containerTop:Ie,leftIdx:e,rhsArrayIdx:r,styleColor:(null==c?void 0:c.badgeBorder)||"#6366F1",styleId:x});var _=we(f,xe,ye),m=we(p,me,be),b=_-Ie,S=m-Ie,R=f>=xe-4&&f<=ye+4,C=p>=me-4&&p<=be+4,w="";w=R&&C?y(u,b,d,S):R&&!C?"M ".concat(u,",").concat(b," L ").concat(v,",").concat(b," L ").concat(v,",").concat(S):!R&&C?"M ".concat(v,",").concat(b," L ").concat(v,",").concat(S," L ").concat(d,",").concat(S):"M ".concat(v,",").concat(b," L ").concat(v,",").concat(S),de.push({id:x,pathD:w,style:c,leftIdx:e,rhsArrayIdx:r})}}})}else{var j=e;a=null===(i=Gn.current[e])||void 0===i?void 0:i.current,c=null===(r=Xn.current[j])||void 0===r?void 0:r.current;if(!a||!c)return;var E,T;u=a.getBoundingClientRect(),d=c.getBoundingClientRect(),v=nt(e),f=(E=u.right-I.left)+.5*((T=d.left-I.left-0)-E),p=u.top+u.height/2,h=d.top+d.height/2,g=p-xe+Re,x=h-me+Ce,m="conn-".concat(e,"-").concat(j);ge.push({lhsScrollY:g,rhsScrollY:x,x1:E,x2:T,containerTop:Ie,leftIdx:e,rhsArrayIdx:j,styleColor:(null==v?void 0:v.badgeBorder)||"#6366F1",styleId:m});var A;b=we(p,xe,ye),S=we(h,me,be),R=b-Ie,C=S-Ie,w=h>=me-4&&h<=be+4,F="";F=(A=p>=xe-4&&p<=ye+4)&&w?y(E,R,T,C):A&&!w?"M ".concat(E,",").concat(R," L ").concat(f,",").concat(R," L ").concat(f,",").concat(C):!A&&w?"M ".concat(f,",").concat(R," L ").concat(f,",").concat(C," L ").concat(T,",").concat(C):"M ".concat(f,",").concat(R," L ").concat(f,",").concat(C),de.push({id:m,pathD:F,style:v,leftIdx:e,rhsArrayIdx:j})}}),_e.current=ge}fe(de)}else fe([]),_e.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{Ve.current=!1}}},[qn,hn,gn,Se,Je,et,nt,z,Z,Hn,ce,on,an]),rt=t.useCallback(function(){var e,n,t,i,r,o,l,s,a,c,u,d,v,f,p=_e.current;if(p.length&&!he.current){var h=null!==(n=null===(e=Ye.current)||void 0===e?void 0:e.scrollTop)&&void 0!==n?n:0,g=null!==(i=null===(t=Le.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,x=null!==(o=null===(r=Ye.current)||void 0===r?void 0:r.clientHeight)&&void 0!==o?o:1/0,_=null!==(s=null===(l=Le.current)||void 0===l?void 0:l.clientHeight)&&void 0!==s?s:1/0,m=null!==(c=null===(a=Ye.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==c?c:0,b=null!==(d=null===(u=Le.current)||void 0===u?void 0:u.getBoundingClientRect().top)&&void 0!==d?d:0,S=m+x,R=b+_,C=null!==(f=null===(v=jn.current)||void 0===v?void 0:v.getBoundingClientRect().top)&&void 0!==f?f:0,I=function(e,n,t){return Math.max(n,Math.min(t,e))};p.forEach(function(e){var n=e.lhsScrollY-h+m,t=e.rhsScrollY-g+b,i=xe.current[e.styleId+"-stroke"],r=xe.current[e.styleId+"-bg"];if(i||r){var o,l=I(n,m,S),s=I(t,b,R),a=l-C,c=s-C,u=n>=m-4&&n<=S+4,d=t>=b-4&&t<=R+4,v=e.x1+.5*(e.x2-e.x1);o=u&&d?y(e.x1,a,e.x2,c):u&&!d?"M ".concat(e.x1,",").concat(a," L ").concat(v,",").concat(a," L ").concat(v,",").concat(c):!u&&d?"M ".concat(v,",").concat(a," L ").concat(v,",").concat(c," L ").concat(e.x2,",").concat(c):"M ".concat(v,",").concat(a," L ").concat(v,",").concat(c),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",o)),r&&(r.setAttribute("visibility","visible"),r.setAttribute("d",o))}})}},[]),ot=t.useRef(it);t.useEffect(function(){ot.current=it},[it]);var lt=t.useRef(null),st=t.useCallback(function(){null!==lt.current&&clearTimeout(lt.current),lt.current=setTimeout(function(){ot.current(),lt.current=null},50)},[]),at=t.useCallback(function(e){var n,t,i,r,o,l,s,a;if(!re.current){if(z||st(),ye.current){var c=be.current,u=En.current,d=Ye.current,v=Le.current;if(null!==c&&null!==u&&d&&v){var f="string"==typeof c?null===(n=Gn.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=Xn.current[u])||void 0===i?void 0:i.current:null===(r=Jn.current[u])||void 0===r?void 0:r.current;if(f&&p){var h=f.getBoundingClientRect().top-d.getBoundingClientRect().top+d.scrollTop,g=p.getBoundingClientRect().top-v.getBoundingClientRect().top+v.scrollTop;if(e.currentTarget===d){var x=g-(h-d.scrollTop),_=v.scrollHeight-v.clientHeight,m=Math.max(0,Math.min(x,_));Math.abs(v.scrollTop-m)>1&&(v.scrollTop=m)}else if(e.currentTarget===v){var y=h-(g-v.scrollTop),b=d.scrollHeight-d.clientHeight,S=Math.max(0,Math.min(y,b));Math.abs(d.scrollTop-S)>1&&(d.scrollTop=S)}if(Tn.current){var R=null===(o=Gn.current[c])||void 0===o?void 0:o.current,C=null===(l=Xn.current[u])||void 0===l?void 0:l.current,I=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,B=v.getBoundingClientRect().top,j=B+v.clientHeight,E=function(e,n,t){return Math.max(n,Math.min(t,e))};if(R&&C){var T=R.getBoundingClientRect(),A=C.getBoundingClientRect(),M=T.top+T.height/2,k=A.top+A.height/2,D=E(M,w,F),O=E(k,B,j);Tn.current.setAttribute("y1",(D-I).toString()),Tn.current.setAttribute("y2",(O-I).toString());var N=M>=w-4&&M<=F+4;Tn.current.setAttribute("visibility",N?"visible":"hidden")}}}}}_e.current.length>0&&!me.current&&(me.current=!0,requestAnimationFrame(function(){rt(),me.current=!1}))}},[rt,z,st]);t.useEffect(function(){var e=setTimeout(st,250);window.addEventListener("resize",st);var n=null,t=null;return Ne.current&&(n=new ResizeObserver(st)).observe(Ne.current),jn.current&&(t=new ResizeObserver(st)).observe(jn.current),function(){clearTimeout(e),window.removeEventListener("resize",st),null==n||n.disconnect(),null==t||t.disconnect()}},[$e,un,_n,qn,on,an,hn,gn,Je,st,Z,Hn,te,ce]),t.useEffect(function(){ye.current=Z},[Z]),t.useEffect(function(){be.current=Hn},[Hn]);var ct=t.useCallback(function(){var e,n,t,i,r=De.sectionIdx,o=De.isOrphan;if(Ge(),null!=r)if(o)Q("No counterpart exists for this section.");else if(Z&&Hn===r)Rn();else{if(!z){var l=be.current,s=En.current;if(null!==l){var a="string"==typeof l?null===(e=Qn.current[l.split(_)[0]])||void 0===e?void 0:e.current:null===(n=Kn.current[l])||void 0===n?void 0:n.current;a&&(a.style.paddingTop="0px")}if(null!==s){var c="string"==typeof s?null===(t=$n.current[s.split(_)[0]])||void 0===t?void 0:t.current:null===(i=Un.current[s])||void 0===i?void 0:i.current;c&&(c.style.paddingTop="0px")}}ue(new Set),fe([]),_e.current=[],G(!0),re.current=!0,Ln(r),be.current=r,ee(!0),ye.current=!0,ie(!1),We.current&&(We.current.style.height="0px"),ze.current&&(ze.current.style.height="0px"),Pe.current&&(Pe.current.style.height="0px"),qe.current&&(qe.current.style.height="0px"),requestAnimationFrame(function(){var e,n,t,i,o,l,s,a,c,u,d,v=null,f=null,p=null,h=null,g=null;if("string"==typeof r){v=(null===(e=Gn.current[r])||void 0===e?void 0:e.current)||null,g=(f=(null===(n=Xn.current[r])||void 0===n?void 0:n.current)||null)?r:null;var x=r.split(_)[0];p=(null===(t=Qn.current[x])||void 0===t?void 0:t.current)||null,h=(null===(i=$n.current[x])||void 0===i?void 0:i.current)||null}else if(v=(null===(o=bn.current[r])||void 0===o?void 0:o.current)||null,p=(null===(l=Kn.current[r])||void 0===l?void 0:l.current)||null,z){var m=hn[r],y=(null==m?void 0:m.refIndexes)||[];if(y.length>0){var b=y[0],S=gn.findIndex(function(e){return e.selfIndex===b});-1!==S&&(f=(null===(c=Jn.current[S])||void 0===c?void 0:c.current)||null,h=(null===(u=Un.current[S])||void 0===u?void 0:u.current)||null,g=S)}}else f=(null===(s=Jn.current[r])||void 0===s?void 0:s.current)||null,h=(null===(a=Un.current[r])||void 0===a?void 0:a.current)||null,g=f?r:null;En.current=g;var C=Ye.current,I=Le.current;if(!v||!C)return re.current=!1,void G(!1);if(!f||!I)return ie(!0),ot.current(),re.current=!1,void G(!1);if(!z){var w=v.getBoundingClientRect(),F=f.getBoundingClientRect(),B=w.top-F.top;p&&h&&(p.style.paddingTop="0px",h.style.paddingTop="0px",B>0?h.style.paddingTop="".concat(B,"px"):B<0&&(p.style.paddingTop="".concat(Math.abs(B),"px")));var j=v?v.getBoundingClientRect().top:(null==p?void 0:p.getBoundingClientRect().top)||0;return null===(d=Ne.current)||void 0===d||d.scrollTo({top:Ne.current.scrollTop+j-150,behavior:"smooth"}),ie(!0),ot.current(),re.current=!1,void G(!1)}var E=v.getBoundingClientRect().top-C.getBoundingClientRect().top+C.scrollTop,T=f.getBoundingClientRect().top-I.getBoundingClientRect().top+I.scrollTop-(E-C.scrollTop);T<0&&We.current&&(We.current.style.height="".concat(Math.abs(T),"px"));requestAnimationFrame(function(){var e,n=I.scrollHeight-I.clientHeight;if(T<0)e=0;else{if(T>n){var t=T-n;return ze.current&&(ze.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){R(I,T,200,function(){ie(!0),ot.current(),re.current=!1,G(!1)})})}e=T}R(I,e,200,function(){ie(!0),ot.current(),re.current=!1,G(!1)})})})}},[Ge,De.sectionIdx,Z,Hn,hn,gn,st,Rn]),ut=null!==De.sectionIdx&&ce.has(De.sectionIdx),dt=function(t){var o,l,s,c=t.section,u=t.idx,d=t.columnKey,v=t.colRef,f=t.mb,p=void 0===f?1:f,g=t.parentNodeId,x=void 0===g?"":g,_=z?!!on["".concat(d,"-").concat(u)]:!!on[String(u)],y=(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=!y&&!b,R=c.title;y||(R=b?"No Title Found":"No Matching Section Found");var C,I=[];if(null===(s=c.evaluationResult)||void 0===s?void 0:s.deviations){var w=c.evaluationResult.deviations;for(var F in w){var B=w[F][x];B&&I.push(B)}}return n.jsx(i.Box,e.__assign({ref:v,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;he.current=!0,ge.current&&clearTimeout(ge.current),pe.current&&(pe.current.style.opacity="0");var o=null===(i=Kn.current[n])||void 0===i?void 0:i.current,l=null===(r=Un.current[n])||void 0===r?void 0:r.current;if(o&&(o.style.minHeight="0px"),l&&(l.style.minHeight="0px"),Object.keys(Qn.current).forEach(function(e){var t,i;if(e.startsWith("".concat(n,"-"))){var r=null===(t=Qn.current[e])||void 0===t?void 0:t.current,o=null===(i=$n.current[e])||void 0===i?void 0:i.current;r&&(r.style.minHeight="0px"),o&&(o.style.minHeight="0px")}}),z){var s=hn[n];((null==s?void 0:s.refIndexes)||[]).forEach(function(e){var n,t=gn.findIndex(function(n){return n.selfIndex===e}),i=null===(n=Un.current[t])||void 0===n?void 0:n.current;i&&(i.style.minHeight="0px")});var a=gn[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=Kn.current[n])||void 0===i?void 0:i.current;r&&(r.style.minHeight="0px")}})}ge.current=setTimeout(function(){he.current=!1,ot.current(),pe.current&&(pe.current.style.opacity="1")},650),ln(function(i){var r=e.__assign({},i);if(!z){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=gn.findIndex(function(n){return n.selfIndex===e});-1!==n&&(r["right-".concat(n)]=s)});else{var a,c=null==(a=gn[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:y&&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:(C=R,C?a.safeStringify(C).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:[b&&n.jsx(m,{content:c.content,sxStyles:Ee,highlights:I,maintainRelativeOrder:z}),(c.subsections||[]).map(function(e,n){return vt({section:e,keyPath:"".concat(u,"-").concat(n),depth:0,columnKey:d,parentNodeId:x})})]}))]}))}),"".concat(d,"-sec-").concat(u))},vt=function(t){var o,l,s,c,u,d,v,f,p,g=t.section,x=t.keyPath,y=t.depth,b=void 0===y?0:y,S=t.columnKey,R=void 0===S?"left":S,C=t.parentNodeId,I=void 0===C?"":C,w=(null===(o=g.displayTitle)||void 0===o||o)&&a.hasValue(g.title),F=(null===(l=g.displayContent)||void 0===l||l)&&a.hasValue(g.content),B=!w&&!F,j=w?g.title:F?"No Title Found":"No Matching Section Found",T=!!an[x];"left"!==R||Qn.current[x]||(Qn.current[x]=h.default.createRef()),"right"!==R||$n.current[x]||($n.current[x]=h.default.createRef());for(var A="left"===R?Qn.current[x]:$n.current[x],M=tt(x),k=x.split("-").map(Number),D=hn[k[0]],O=gn[k[0]],N=1;N<k.length;N++)(null==D?void 0:D.subsections)&&(D=D.subsections[k[N]]),(null==O?void 0:O.subsections)&&(O=O.subsections[k[N]]);var H=null===(s=null==E?void 0:E.input_index_map)||void 0===s?void 0:s[0],L=null===(c=null==E?void 0:E.input_index_map)||void 0===c?void 0:c[1],W="left"===R?L:H,P=z?!(null===(u=g.refIndexes)||void 0===u?void 0:u.length)||void 0!==g.selfIndex&&g.selfIndex<0:"left"===R?!O:!D,q=null!==(f=null===(v=null===(d=g.evaluationResult)||void 0===d?void 0:d.evaluation_outputs)||void 0===v?void 0:v.output_value)&&void 0!==f?f:null,Y=Object.entries((null===(p=g.evaluationResult)||void 0===p?void 0:p.deviations)||{}).map(function(e,n){var t=e[0],i=e[1],r=i[I];if(!r||"No equivalent clause present."===r)return null;var o=function(e,n){return"".concat(e).concat(_).concat(n)}(x,t),l=i[W],s=P||!l||"No equivalent clause present."===l,a=k[0]+1,c="".concat(a,".").concat(n+1);return"left"!==R||Gn.current[o]||(Gn.current[o]=h.default.createRef()),"right"!==R||Xn.current[o]||(Xn.current[o]=h.default.createRef()),{id:o,label:c,highlight:r,side:R,style:M,score:q,isConnected:ce.has(o),isOrphan:s,badgeRef:"left"===R?Gn.current[o]:Xn.current[o],onClick:function(e){e.stopPropagation(),wn(e,D||{title:"",content:""},s,O||{title:"",content:""},o,M)}}}).filter(Boolean),V=Y.some(function(e){return ce.has(e.id)});return w||F||g.subsections&&0!==g.subsections.length?w?n.jsx(i.Box,e.__assign({ref:A,sx:{mt:1,width:"100%",minWidth:0,position:"relative"}},{children:n.jsx(i.Box,e.__assign({sx:e.__assign({width:"100%"},V&&M&&{borderRadius:"4px",outline:"2px solid ".concat(M.badgeBorder),outlineOffset:"1px"})},{children:n.jsxs(i.Accordion,e.__assign({disableGutters:!0,expanded:!B&&T,onChange:function(){return!B&&cn(function(n){var t;return e.__assign(e.__assign({},n),((t={})[x]=!n[x],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:j||"Untitled Subsection"}))})),!B&&n.jsxs(i.AccordionDetails,e.__assign({sx:{pt:0,pb:1,minWidth:0}},{children:[F&&n.jsx(m,{content:g.content,sxStyles:Ee,deviationBadges:Y,maintainRelativeOrder:z}),(g.subsections||[]).map(function(e,n){return vt({section:e,keyPath:"".concat(x,"-").concat(n),depth:b+1,columnKey:R,parentNodeId:I})})]}))]}))}))}),x):n.jsx(i.Box,e.__assign({ref:A,sx:{mt:0===b?1:.75,width:"100%",minWidth:0,position:"relative"}},{children:!B&&n.jsxs(i.Box,e.__assign({sx:e.__assign({width:"100%"},V&&M&&{borderRadius:"4px",outline:"2px solid ".concat(M.badgeBorder),outlineOffset:"1px"})},{children:[F&&n.jsx(m,{content:g.content,sxStyles:Ee,deviationBadges:Y,maintainRelativeOrder:z}),(g.subsections||[]).map(function(e,n){return vt({section:e,keyPath:"".concat(x,"-").concat(n),depth:b+1,columnKey:R,parentNodeId:I})})]}))}),x):null};return n.jsxs(i.Box,e.__assign({ref:He,sx:e.__assign(e.__assign({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},z?{}:{overflow:"visible"}),{position:"relative"})},{children:[Y&&n.jsx(i.Box,e.__assign({sx:{position:"absolute",inset:0,bgcolor:"rgba(255, 255, 255, 0.6)",backdropFilter:"blur(10px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"8px"}},{children:n.jsx(v.default,{})})),n.jsx(d.default,{open:De.open,anchorEl:De.anchorEl,sectionTitle:De.sectionTitle,referenceSectionTitle:De.refSectionTitle,onClose:Ge,onOpenCognitiveCompare:Fn,onOpenSideBySide:ct,onConnect:Bn,isConnected:ut,isOrphan:De.isOrphan}),Ae.open&&n.jsx(u.default,{open:Ae.open,popupRef:we,position:Ce,popupConfig:N,onClose:function(){Ie(null),Me(function(n){return e.__assign(e.__assign({},n),{open:!1})}),se(null)},markdownStyles:k,sectionTitle:Ae.sectionTitle,referenceSectionTitle:Ae.refSectionTitle,cognitiveData:Ae.cognitiveData,anchorEl:Ae.anchorEl,sectionAnchorEl:Ae.sectionAnchorEl,scrollContainerEl:Ne.current,badgeStyle:Ae.badgeStyle,docData:Ae.docData,deviationData:Ae.deviationData}),n.jsx(i.Snackbar,e.__assign({open:!!J,autoHideDuration:8e3,onClose:function(){return Q(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(i.Alert,e.__assign({onClose:function(){return Q(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:J}))})),(O.isHeaderVisible||O.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:O.isHeaderVisible&&n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:600,color:"#0F172A"}},{children:j}))})),O.isToggleVisible&&n.jsx(i.Box,e.__assign({sx:{display:"flex",alignItems:"center"}},{children:n.jsx(i.FormControlLabel,{control:n.jsx(i.Switch,{checked:z,onChange:function(e){var n=e.target.checked;V(!0),setTimeout(function(){P(n),Rn(),ue(new Set),fe([]),_e.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:Ne,onScroll:at,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:z?"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"},z?{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},z?{flex:1,overflow:"visible"}:{})},{children:[n.jsxs("svg",e.__assign({ref:pe,style:{position:"absolute",top:0,left:0,width:Be.width||"100%",height:Be.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",transition:"opacity 0.15s ease-in-out"}},{children:[zn&&!Z&&n.jsxs("g",{children:[n.jsx("line",{x1:zn.x1,y1:zn.y,x2:Math.max(zn.x1,(zn.x1+zn.x2)/2-70),y2:zn.y,stroke:"#BBF7D0",strokeWidth:"1.5"}),n.jsx("line",{x1:Math.min(zn.x2,(zn.x1+zn.x2)/2+70),y1:zn.y,x2:zn.x2,y2:zn.y,stroke:"#BBF7D0",strokeWidth:"1.5"})]}),Dn.map(function(t){var l,s=t.x1+.5*(t.x2-t.x1),a=(t.y1+t.y2)/2;if("Not Defined"===t.style.label&&!t.hasCognitive)return null;var c=!1;if(t.isSubSection)c=Z&&Hn===t.subSectionKeyPath&&te;else{var u=hn[t.sectionIdx];(z?!(null===(l=null==u?void 0:u.refIndexes)||void 0===l?void 0:l.length)||(null==u?void 0:u.selfIndex)<0:!gn[t.sectionIdx])||(c=Z&&Hn===t.sectionIdx&&te)}if(c)return 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:Tn,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);if(!z){var d=t.isSubSection?y(t.x1,t.y1,t.x2,t.y2):"M ".concat(t.x1," ").concat(t.y1," L ").concat(t.x2," ").concat(t.y2);return n.jsxs("g",{children:[n.jsx("path",{d:d,fill:"none",stroke:t.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),n.jsx("foreignObject",e.__assign({x:s-100,y:a-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(),Ae.open&&le===t.id)Ue();else{var n=hn[t.sectionIdx]||{title:"",content:""},i=gn[t.sectionIdx]||{title:"",content:""};if(t.isSubSection&&t.subSectionKeyPath){for(var r=t.subSectionKeyPath.split("-").map(Number),o=hn[r[0]],l=gn[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)}se(t.id),In(Cn(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:Ae.open&&le===t.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},t.id)}return null}),ve.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){xe.current[s]=e},d:r,fill:"none",stroke:"#FFFFFF",strokeWidth:"4",strokeOpacity:"0.7"}),n.jsx("path",{ref:function(e){xe.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)"},z?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(i.Box,e.__assign({ref:An,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:"normal",width:"100%",height:"40px"}},{children:fn}))}))})),n.jsxs(i.Box,e.__assign({ref:Ye,onScroll:at,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},z?{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:Pe,style:{width:"100%",height:"0px",flexShrink:0}}),xn&&hn.map(function(t,o){var l,s,a=!t.title&&!t.content;if(z&&a)return null;var c=t,u=nt(o),d=z?!(null===(l=c.refIndexes)||void 0===l?void 0:l.length)||c.selfIndex<0:!gn[o],v=z?"number"==typeof c.selfIndex&&c.selfIndex>=0?c.selfIndex+1:null:o+1,f=ce.has(o),p=function(e,n){var t,i,r,o,l,s;if(!e)return n;var a=null!==(s=null!==(o=null!==(i=null===(t=e.evaluation_output)||void 0===t?void 0:t.output_score)&&void 0!==i?i:null===(r=e.evaluation_outputs)||void 0===r?void 0:r.output_score)&&void 0!==o?o:null===(l=e.evaluation_outputs)||void 0===l?void 0:l.output_value)&&void 0!==s?s:e.output_score;return null!=a?a:n}(c.evaluationResult,null==u?void 0:u.deviationLabel);return n.jsx(i.Box,e.__assign({ref:Sn(o),sx:{mb:1,width:"100%"}},{children:n.jsxs(i.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[n.jsx(i.Box,e.__assign({ref:Kn.current[o],sx:e.__assign({width:"100%",display:"flex"},f&&{borderRadius:"6px",outline:"2px solid ".concat((null==u?void 0:u.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:dt({section:t,idx:o,columnKey:"left",colRef:h.default.createRef(),mb:0,parentNodeId:(null===(s=null==E?void 0:E.input_index_map)||void 0===s?void 0:s[0])||""})})),z&&u&&n.jsxs(i.Box,e.__assign({ref:Gn.current[o],onClick:function(e){var n=z?gn.find(function(e){var n;return null===(n=c.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""}:gn[o]||{title:"",content:""};wn(e,t,d,n,o,u)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:u.badgeBg,color:u.badgeText,border:"1px solid ".concat(u.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(u.badgeBorder)}},{children:v})),n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",px:.25}},{children:d?"No Deviation Found":"N/A"===p||"NA"===p?"N/A":0==p||null==p?"Same":"".concat(p,"% Deviation")})),n.jsx(r.EllipsisVertical,{size:11,color:u.badgeText})]}))]}))}),"left-row-".concat(o))}),n.jsx("div",{ref:qe,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},z?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[U&&n.jsx(l.default,{sections:11}),n.jsx(i.Box,e.__assign({ref:Mn,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:pn,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:"normal",width:"100%",height:"40px"}},{children:pn}))}))})),n.jsxs(i.Box,e.__assign({ref:Le,onScroll:at,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},z?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-25px",pl:"45px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:We,style:{width:"100%",height:"0px",flexShrink:0}}),xn&&gn.map(function(t,r){var o,l=t,s=[],a=!1,c=null;if(z){s=hn.filter(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(l.selfIndex))&&e.selfIndex>=0}).map(function(e){return e.selfIndex+1});var u=hn.findIndex(function(e,n){var t;return ce.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(l.selfIndex))});(a=-1!==u)&&(c=nt(u))}else s=[r+1],(a=ce.has(r))&&(c=nt(r));return n.jsx(i.Box,e.__assign({ref:Jn.current[r],sx:{mb:1,width:"100%"}},{children:n.jsxs(i.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[n.jsx(i.Box,e.__assign({ref:Un.current[r],sx:e.__assign({width:"100%",display:"flex"},a&&c&&{borderRadius:"6px",outline:"2px solid ".concat(c.badgeBorder),outlineOffset:"1px"})},{children:dt({section:t,idx:r,columnKey:"right",colRef:h.default.createRef(),mb:0,parentNodeId:(null===(o=null==E?void 0:E.input_index_map)||void 0===o?void 0:o[1])||""})})),z&&!U&&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:s.length>0?s.join(", "):"-"}))]}))}),"right-row-".concat(r))}),n.jsx("div",{ref:ze,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))};
2
2
  //# sourceMappingURL=CognitiveCompare.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e,__rest as t,__spreadArray as n}from"tslib";import{jsx as i,jsxs as r,Fragment as o}from"react/jsx-runtime";import l,{useMemo as c,useState as u,useRef as a,useEffect as d,useCallback as s}from"react";import{Box as v,Typography as f,Snackbar as h,Alert as p,FormControlLabel as g,Switch as x,Tooltip as m,Accordion as y,AccordionSummary as b,AccordionDetails as S}from"@mui/material";import{EllipsisVertical as w,ChevronDown as I}from"lucide-react";import{ButtonCognitiveIcon as R}from"../../assests/svg/ButtonCognitiveIcon.js";import C from"./OverlayComponent.js";import F from"react-markdown";import{safeStringify as E,hasValue as _,getSideData as B,getRationale as T}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as k,DEFAULT_FIELD_CONFIG as M,DEFAULT_COMPARISON_CONFIG as D}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import A from"./CognitivePopup.js";import H from"./MoreFunctionsPopup.js";import O from"./LoaderComponent.js";import N from"rehype-raw";var W="::",z=l.memo(function(n){var l=n.content,u=n.sxStyles,a=n.deviationBadges,d=void 0===a?[]:a,s=n.highlights,h=void 0===s?[]:s,p=n.maintainRelativeOrder,g=void 0===p||p,x=c(function(){return d.reduce(function(t,n){var i;return e(e({},t),((i={})[n.id]=n,i))},{})},[d]),m=c(function(){return{mark:function(t){var n=t.children;return i("span",e({style:{backgroundColor:"#fccccc",borderRadius:"2px"}},{children:n}))},span:function(n){var l,c,u,a,d,s=n.children,f=t(n,["children"]),h=f["data-badge-id"];if(!h)return i("span",e({},f,{children:s}));var p=x[h];return p?r(v,e({component:"span",sx:{position:"static",display:"inline"}},{children:[s,i(v,e({ref:p.badgeRef,onClick:g?p.onClick:void 0,sx:g?e(e({position:"absolute",zIndex:30,display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"10px",bgcolor:(null===(l=p.style)||void 0===l?void 0:l.badgeBg)||"#EEF2FF",color:(null===(c=p.style)||void 0===c?void 0:c.badgeText)||"#3730A3",border:"1px solid ".concat((null===(u=p.style)||void 0===u?void 0:u.badgeBorder)||"#C7D2FE"),borderRadius:"12px",px:1,py:.3,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",boxShadow:"0 1px 3px rgba(0,0,0,0.07)"},"left"===p.side?{right:"-16px",transform:"translateY(-20%) translateX(calc(100% + 8px))"}:{left:"-16px",transform:"translateY(-20%) translateX(calc(-100% - 8px))"}),p.isConnected&&p.style&&{outline:"2px solid ".concat(p.style.badgeBorder),outlineOffset:"1px"}):e({position:"absolute",width:0,height:0,visibility:"hidden"},"left"===p.side?{right:"-16px",transform:"translateY(-50%)"}:{left:"-16px",transform:"translateY(-50%)"})},{children:g&&r(o,{children:[i(v,e({component:"span",sx:e({fontSize:"10px",fontWeight:700},"left"===p.side?{pr:.5,borderRight:"1px solid ".concat((null===(a=p.style)||void 0===a?void 0:a.badgeBorder)||"#C7D2FE")}:{})},{children:p.label})),"left"===p.side&&r(o,{children:[i(v,e({component:"span",sx:{fontSize:"10px",px:.25}},{children:p.isOrphan?"No Deviation Found":0===p.score||null==p.score?"Same":"".concat(p.score,"% Deviation")})),i(w,{size:10,color:(null===(d=p.style)||void 0===d?void 0:d.badgeText)||"#3730A3"})]})]})}))]})):i("span",e({},f,{children:s}))}}},[x,g]),y=c(function(){var e=l||"",t=function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")};return d.forEach(function(n){n.highlight&&(e=e.replace(new RegExp(t(n.highlight),"g"),'<span data-badge-id="'.concat(n.id,'"><mark>').concat(n.highlight,"</mark></span>")))}),h.forEach(function(n){n&&(e=e.replace(new RegExp(t(n),"g"),"<mark>".concat(n,"</mark>")))}),e},[l,d,h]);return i(f,e({component:"div",sx:e(e({},u),{position:"relative",overflow:"visible","& p, & li, & ul, & ol":{position:"static",overflow:"visible"}})},{children:i(F,e({components:m,rehypePlugins:[N]},{children:E(y).replace(/\\n/g,"\n")}))}))},function(e,t){if(e.content!==t.content)return!1;if(e.sxStyles!==t.sxStyles)return!1;if(e.maintainRelativeOrder!==t.maintainRelativeOrder)return!1;var n=e.highlights||[],i=t.highlights||[];if(n.length!==i.length)return!1;for(var r=0;r<n.length;r++)if(n[r]!==i[r])return!1;return!0}),L=function(e,t,n,i,r){void 0===r&&(r=14);var o=e+.5*(n-e),l=i-t;if(Math.abs(l)<3)return"M ".concat(e," ").concat(t," H ").concat(n);var c=l>0?1:-1,u=Math.min(r,Math.abs(l)/2,Math.abs(o-e)/2,Math.abs(n-o)/2);return["M ".concat(e," ").concat(t),"H ".concat(o-u),"Q ".concat(o," ").concat(t," ").concat(o," ").concat(t+c*u),"V ".concat(i-c*u),"Q ".concat(o," ").concat(i," ").concat(o+u," ").concat(i),"H ".concat(n)].join(" ")},j={id:"",title:""},P={open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,isOrphan:!1,docData:null,deviationData:null},Y=function(e,t,n,i,r){void 0===n&&(n=300);var o=e.style.scrollBehavior;e.style.scrollBehavior="auto";var l=e.scrollTop,c=t-l,u=null,a=function(d){null===u&&(u=d);var s,v=d-u;v<n?(e.scrollTop=(s=v,s/=n,c*(--s*s*s+1)+l),r&&r(),requestAnimationFrame(a)):(e.scrollTop=t,e.style.scrollBehavior=o,r&&r(),i&&i())};requestAnimationFrame(a)},K=function(t){var o,F,N,K,V,X,q,U,G=t.componentHeaderText,J=void 0===G?"Contract Comparison":G,Q=t.treeData,$=t.comparisonConfig,Z=t.leftColumnTitleText,ee=t.rightColumnTitleText,te=t.markdownStyles,ne=t.displayConfig,ie=void 0===ne?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1}:ne,re=t.popupConfig,oe=t.deviationData,le=void 0===oe?{}:oe,ce=u(ie.maintainRelativeOrder),ue=ce[0],ae=ce[1],de=u(!1),se=de[0],ve=de[1],fe=u(!1),he=fe[0],pe=fe[1],ge=u(null),xe=ge[0],me=ge[1],ye=u(!1),be=ye[0],Se=ye[1],we=u(!1),Ie=we[0],Re=we[1],Ce=a(!1),Fe=u(null),Ee=Fe[0],_e=Fe[1],Be=u(new Set),Te=Be[0],ke=Be[1],Me=u([]),De=Me[0],Ae=Me[1],He=a(null),Oe=a(!1),Ne=a(null),We=a({}),ze=a([]),Le=a(!1),je=a(!1),Pe=a(null),Ye=c(function(){return(null==Q?void 0:Q.cognitive_decisioning)||{}},[Q]),Ke=u(null),Ve=Ke[0],Xe=Ke[1],qe=a(null),Ue=u({width:0,height:0}),Ge=Ue[0],Je=Ue[1],Qe=c(function(){return e(e({},k),te)},[te]),$e=u({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,isOrphan:!1,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null,deviationData:null}),Ze=$e[0],et=$e[1],tt=u({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,isOrphan:!1,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null,deviationData:null}),nt=tt[0],it=tt[1],rt=a(null),ot=a(null),lt=a(null),ct=a(null),ut=a(null),at=a(null),dt=a(null),st=a(null),vt=a(!1),ft=a(null);d(function(){ft.current=null},[Ze.sectionIdx,Ze.open]);var ht=s(function(){Xe(null),et(P),_e(null)},[]),pt=s(function(){it(P)},[]),gt=s(function(){var e;if(Ze.anchorEl&&Ze.refSectionTitle){var t=Ze.anchorEl.getBoundingClientRect(),n=(null===(e=null==qe?void 0:qe.current)||void 0===e?void 0:e.offsetHeight)||0,i=Math.min(680,window.innerWidth-24),r=window.innerHeight-t.bottom-12-12,o=t.top-12-12,l=r<n&&o>r;null!==ft.current?!0===ft.current&&(l=o>=n||o>=r):l=!(r>=n||r>=o),ft.current=l;var c=l?o:r,u=Math.min(n||9999,c),a=l?t.top-12-u:t.bottom+12,d=t.left+t.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));Xe({top:a,left:v,arrowLeft:f,openAbove:l,maxHeight:c})}},[Ze.anchorEl,Ze.refSectionTitle]);d(function(){if(Ze.open){window.addEventListener("resize",gt);var e=requestAnimationFrame(gt),t=null;return qe.current&&(t=new ResizeObserver(function(){cancelAnimationFrame(e),e=requestAnimationFrame(gt)})).observe(qe.current),function(){cancelAnimationFrame(e),window.removeEventListener("resize",gt),t&&t.disconnect()}}},[Ze.open,gt]),d(function(){var e=rt.current;if(e&&Ze.open){var t=function(e){qe.current&&qe.current.contains(e.target)||(Xe(null),ht())};return e.addEventListener("scroll",t,{capture:!0}),window.addEventListener("scroll",t,{capture:!0}),function(){e.removeEventListener("scroll",t,{capture:!0}),window.removeEventListener("scroll",t,{capture:!0})}}},[Ze.open,ht]),d(function(){var e=rt.current;if(e&&nt.open){var t=function(){pt()};return e.addEventListener("scroll",t,{capture:!0}),window.addEventListener("scroll",t,{capture:!0}),function(){e.removeEventListener("scroll",t,{capture:!0}),window.removeEventListener("scroll",t,{capture:!0})}}},[nt.open,pt]);var xt=c(function(){var t,n,i,r,o,l,c,u,a,d,s,v;return{fields:null!==(t=null==$?void 0:$.fields)&&void 0!==t?t:M,thresholds:{high:null!==(i=null===(n=null==$?void 0:$.thresholds)||void 0===n?void 0:n.high)&&void 0!==i?i:D.thresholds.high,medium:null!==(o=null===(r=null==$?void 0:$.thresholds)||void 0===r?void 0:r.medium)&&void 0!==o?o:D.thresholds.medium,exact:null!==(c=null===(l=null==$?void 0:$.thresholds)||void 0===l?void 0:l.exact)&&void 0!==c?c:D.thresholds.exact},relationStyles:{noContent:e(e({},D.relationStyles.noContent),(null===(u=null==$?void 0:$.relationStyles)||void 0===u?void 0:u.noContent)||{}),high:e(e({},D.relationStyles.high),(null===(a=null==$?void 0:$.relationStyles)||void 0===a?void 0:a.high)||{}),exact:e(e({},D.relationStyles.exact),(null===(d=null==$?void 0:$.relationStyles)||void 0===d?void 0:d.exact)||{}),medium:e(e({},D.relationStyles.medium),(null===(s=null==$?void 0:$.relationStyles)||void 0===s?void 0:s.medium)||{}),low:e(e({},D.relationStyles.low),(null===(v=null==$?void 0:$.relationStyles)||void 0===v?void 0:v.low)||{})}}},[$]),mt=c(function(){if(Q&&Object.keys(Q).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"},h=t[v]||a[v];if(!h||!1===h.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[]};var p=function(n,i){var o,l,c,u=t[n]||a[n];if(!u||!1===u.display_node)return null;var d=B(u,i,f),s=!1!==(null===(o=d.attributes)||void 0===o?void 0:o.display_title),v=!1!==(null===(l=d.attributes)||void 0===l?void 0:l.display_content),h=!!d.title.trim(),g=!!d.content.trim(),x=T(u),m=(null===(c=null==r?void 0:r[n])||void 0===c?void 0:c.evaluation_result)||u.evaluation_result||null,y=[];u.next&&Object.values(u.next).forEach(function(e){var t=a[e];if(t&&!1!==t.display_node){var n=p(e,i);n&&y.push(n)}});var b=!(!h&&!g);return e(e({id:n,title:h?d.title:"",content:g?d.content:"",displayTitle:s,displayContent:v,subsections:y},b?x:{score:void 0,relation:"not_defined"}),{evaluationResult:m})};if(i){var g=function(i,o){var l,c,u,d,s,v,h,p,x,m,y,b,S,w,I,R,C,F,E,_,k;void 0===o&&(o=0);var M=[],D=[];if(!i)return{refSections:M,baseSections:D};var A={},H={},O=-1,N=-1;for(var W in i){var z=i[W],L=t[z]||a[z];if(L&&!1!==L.display_node){var j=T(L),P=(null===(l=null==r?void 0:r[z])||void 0===l?void 0:l.evaluation_result)||L.evaluation_result||null,Y=B(L,"1",f),K=B(L,"0",f),V=!1!==(null===(c=Y.attributes)||void 0===c?void 0:c.display_title)&&Y.title.trim()||!1!==(null===(u=Y.attributes)||void 0===u?void 0:u.display_content)&&Y.content.trim(),X=!1!==(null===(d=K.attributes)||void 0===d?void 0:d.display_title)&&K.title.trim()||!1!==(null===(s=K.attributes)||void 0===s?void 0:s.display_content)&&K.content.trim(),q=Number(null!==(h=null===(v=Y.attributes)||void 0===v?void 0:v.display_index)&&void 0!==h?h:O--),U=Number(null!==(x=null===(p=K.attributes)||void 0===p?void 0:p.display_index)&&void 0!==x?x:N--),G=A[q]||e(e({id:z,title:!1!==(null===(m=Y.attributes)||void 0===m?void 0:m.display_title)?Y.title:"",content:!1!==(null===(y=Y.attributes)||void 0===y?void 0:y.display_content)?Y.content:"",subsections:[]},V?j:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:q,evaluationResult:P,displayContent:null===(b=Y.attributes)||void 0===b?void 0:b.display_content,displayTitle:null===(S=Y.attributes)||void 0===S?void 0:S.display_title}),J=H[U]||e(e({id:z,title:!1!==(null===(w=K.attributes)||void 0===w?void 0:w.display_title)?K.title:"",content:!1!==(null===(I=K.attributes)||void 0===I?void 0:I.display_content)?K.content:"",subsections:[]},X?j:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:U,evaluationResult:P,displayContent:null===(R=K.attributes)||void 0===R?void 0:R.display_content,displayTitle:null===(C=K.attributes)||void 0===C?void 0:C.display_title});Number(q)>=0&&Number(U)>=0&&((null===(F=G.refIndexes)||void 0===F?void 0:F.includes(Number(U)))||null===(E=G.refIndexes)||void 0===E||E.push(Number(U)),(null===(_=J.refIndexes)||void 0===_?void 0:_.includes(Number(q)))||null===(k=J.refIndexes)||void 0===k||k.push(Number(q))),A[q]=G,H[U]=J;var Q=g(L.next,o+1),$=Q.refSections,Z=Q.baseSections;$.length>0&&(G.subsections=n(n([],G.subsections||[],!0),$,!0)),Z.length>0&&(J.subsections=n(n([],J.subsections||[],!0),Z,!0))}}return M=Object.values(A).map(function(e){return e}),D=Object.values(H).map(function(e){return e}),M.sort(function(e,t){return e.selfIndex<0&&t.selfIndex>=0?1:e.selfIndex>=0&&t.selfIndex<0?-1:e.selfIndex-t.selfIndex}),D.sort(function(e,t){return e.selfIndex<0&&t.selfIndex>=0?1:e.selfIndex>=0&&t.selfIndex<0?-1:e.selfIndex-t.selfIndex}),{refSections:M,baseSections:D}},x=g(h.next),m=x.refSections,y=x.baseSections;s=m,d=y}else h.next&&Object.values(h.next).forEach(function(e){var n=t[e]||a[e];n&&!1!==n.display_node&&(d.push(p(e,"0")||{id:e,title:"",content:"",subsections:[]}),s.push(p(e,"1")||{id:e,title:"",content:"",subsections:[]}))});return{activeProposed:{title:(null===(l=null===(o=h.comparison_inputs)||void 0===o?void 0:o[f[0]])||void 0===l?void 0:l.title)||"Uploaded Contract",description:h.decision_scope_description||"",sections:d},activeVariants:[{id:"tree-variant-1",title:(null===(u=null===(c=h.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:h.decision_scope_description||""},fields:{}}}}]}}(Q,ue,le);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(Q),ue,JSON.stringify(le)]),yt=mt.activeProposed,bt=mt.activeVariants,St=mt.parseError;d(function(){St&&me("Failed to load comparison: ".concat(St))},[St]);var wt=u(null),It=wt[0];wt[1];var Rt=u({}),Ct=Rt[0],Ft=Rt[1],Et=u({}),_t=Et[0],Bt=Et[1],Tt=(null==bt?void 0:bt[0])||j,kt=null===(N=null===(o=null==Q?void 0:Q.documents)||void 0===o?void 0:o[null===(F=null==Q?void 0:Q.input_index_map)||void 0===F?void 0:F[0]])||void 0===N?void 0:N.title,Mt=null===(X=null===(K=null==Q?void 0:Q.documents)||void 0===K?void 0:K[null===(V=null==Q?void 0:Q.input_index_map)||void 0===V?void 0:V[1]])||void 0===X?void 0:X.title,Dt=E(Z||kt||"Uploaded Contract"),At=E(ee||Mt||"Reference Template"),Ht=c(function(){return(null==yt?void 0:yt.sections)||[]},[null==yt?void 0:yt.sections]),Ot=c(function(){return Tt.sections||[]},[Tt.sections]),Nt=Ht.length>0||Ot.length>0,Wt=Tt.analysis,zt=E(null===(U=null===(q=null==Wt?void 0:Wt.rule_difference_comparison)||void 0===q?void 0:q.summary)||void 0===U?void 0:U.overall_summary),Lt=!!zt.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),jt=a({}),Pt=function(e){return jt.current[e]||(jt.current[e]=l.createRef()),jt.current[e]},Yt=s(function(){Se(!1),je.current=!1,ln(null),Pe.current=null,Jt.current=null,Re(!1),pe(!1),ct.current&&(ct.current.style.height="0px"),ut.current&&(ut.current.style.height="0px"),at.current&&(at.current.style.height="0px"),dt.current&&(dt.current.style.height="0px")},[]),Kt=s(function(e,t,n,i,r,o){var l,c,u=E(t.id)||E(n.id)||"",a=(u?Ye[u]:null)||t.cognitiveData||n.cognitiveData||{section_id:u,decisioning:[],gap:[],relevance_score:0},d=null!==(c=null===(l=jt.current[i])||void 0===l?void 0:l.current)&&void 0!==c?c:null;return{open:!0,sectionTitle:t.title||"N/A",refSectionTitle:n.title||"NA",cognitiveData:a,anchorEl:e,sectionAnchorEl:d,badgeStyle:o||null,sectionIdx:i,docData:{documents:null==Q?void 0:Q.documents,input_index_map:null==Q?void 0:Q.input_index_map},deviationData:t.evaluationResult||n.evaluationResult||null,isOrphan:!!r}},[Ye,Q]),Vt=s(function(e){pt(),Xe(null),et(e)},[pt]),Xt=function(e,t,n,i,r,o){e.stopPropagation(),nt.open&&nt.sectionIdx===r?pt():(ht(),it(Kt(e.currentTarget,t,i,r,n,o)))},qt=s(function(){null!==nt.sectionIdx&&nt.anchorEl?Vt(e(e({},nt),{open:!0})):pt()},[nt,pt,Vt]),Ut=s(function(){var e=nt.sectionIdx,t=nt.isOrphan;pt(),null!==e&&(t?me("No counterpart exists to connect to."):(je.current&&Yt(),ke(function(t){return t.has(e)?new Set:new Set([e])})))},[nt.sectionIdx,pt,Yt]),Gt=a(null),Jt=a(null),Qt=a(null),$t=a(null),Zt=a(null),en=u([]),tn=en[0],nn=en[1],rn=u(null),on=rn[0],ln=rn[1];a(null);var cn=u(null),un=cn[0],an=cn[1],dn=c(function(){return xt.fields.filter(function(e){var t=e.key;return(!Nt||"description"!==t)&&(_(null==yt?void 0:yt[t])||_(Tt[t]))})},[yt,Tt,Nt,xt.fields]),sn=a({}),vn=a({}),fn=a({}),hn=a({}),pn=a({}),gn=a({}),xn=a({}),mn=a({}),yn=a({});dn.forEach(function(e){for(var t=e.key,n=0;n<Math.max(Ht.length,Ot.length);n+=1)fn.current[n]||(fn.current[n]=l.createRef()),hn.current[n]||(hn.current[n]=l.createRef()),pn.current[n]||(pn.current[n]=l.createRef()),gn.current[n]||(gn.current[n]=l.createRef()),xn.current[n]||(xn.current[n]=l.createRef());sn.current[t]||(sn.current[t]=l.createRef()),vn.current[t]||(vn.current[t]=l.createRef())});for(var bn=0;bn<Math.max(Ht.length,Ot.length);bn+=1)fn.current[bn]||(fn.current[bn]=l.createRef()),hn.current[bn]||(hn.current[bn]=l.createRef()),pn.current[bn]||(pn.current[bn]=l.createRef()),gn.current[bn]||(gn.current[bn]=l.createRef()),xn.current[bn]||(xn.current[bn]=l.createRef());d(function(){if(It){var e=xt.fields.find(function(e){return e.analysisKey===It||e.key===It});if(e){var t=sn.current[e.key]||vn.current[e.key];(null==t?void 0:t.current)&&setTimeout(function(){return t.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[It,xt.fields]);var Sn=s(function(e){var t,n,i,r,o,l,c,u,a,d=null===(t=null==Wt?void 0:Wt.rule_difference_comparison)||void 0===t?void 0:t.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===(n=null==s?void 0:s.highlights)||void 0===n?void 0:n.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}},[Wt]),wn=s(function(t){var n,i,r,o=Ht[t],l=Ot[t],c=(null==o?void 0:o.relation)&&"not_defined"!==o.relation,u=(null==l?void 0:l.relation)&&"not_defined"!==l.relation;E(null==o?void 0:o.id)||E(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({},xt.relationStyles.noContent),{label:"Not Defined"});var d=null!==(i=null!==(n=null==o?void 0:o.evaluationResult)&&void 0!==n?n: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({},xt.relationStyles.low),null!=d?{label:s}:{label:"N/A"})},[Ht,Ot,Ye,xt,Sn]),In=s(function(t){for(var n,i,r,o,l,c,u=t.split("-").map(Number),a=Ht[u[0]],d=Ot[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,h=E(null==a?void 0:a.id)||E(null==d?void 0:d.id)||"",p=!(!(null==a?void 0:a.cognitiveData)&&!(null==d?void 0:d.cognitiveData));if(!v&&!f&&!p)return e(e({},xt.relationStyles.noContent),{label:"Not Defined"});null!==(i=null!==(n=null==a?void 0:a.cognitiveRelevanceScore)&&void 0!==n?n:null==d?void 0:d.cognitiveRelevanceScore)&&void 0!==i||h&&(null===(r=Ye[h])||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({},xt.relationStyles.low),null!=g?{label:x}:{label:"N/A"})},[Ht,Ot,Ye,xt]),Rn=s(function(){var t,n,i,r,o,l,c,u,a,d,s,v,f,h,p,g,x,m,y,b,S,w;if(!vt.current&&!Oe.current){vt.current=!0;try{if(!Gt.current)return;var I=function(e){var t=e.split("-"),n=t[0];if(!Ct[n]&&!1===ue)return!1;if(ue&&!Ct["left-".concat(n)]&&!Ct["right-".concat(n)]&&!Ct[n])return!1;for(var i=n,r=1;r<t.length-1;r++)if(i+="-".concat(t[r]),!_t[i])return!1;return!0},R=Gt.current.getBoundingClientRect();Je({width:R.width,height:R.height});var C=[];if(dn.forEach(function(e){var t,n,i=e.key,r=null===(t=sn.current[i])||void 0===t?void 0:t.current,o=null===(n=vn.current[i])||void 0===n?void 0:n.current;r&&o&&(r.style.height="auto",o.style.height="auto",r.style.minHeight="0px",o.style.minHeight="0px")}),!Oe.current){for(var F=0;F<Math.max(Ht.length,Ot.length);F++){var _=null===(t=fn.current[F])||void 0===t?void 0:t.current,B=null===(n=hn.current[F])||void 0===n?void 0:n.current;_&&(_.style.height="auto",_.style.minHeight="0px"),B&&(B.style.height="auto",B.style.minHeight="0px")}ue||Object.keys(mn.current).forEach(function(e){var t,n;if(I(e)){var i=null===(t=mn.current[e])||void 0===t?void 0:t.current,r=null===(n=yn.current[e])||void 0===n?void 0:n.current;i&&r&&(i.style.height="auto",r.style.height="auto",i.style.minHeight="0px",r.style.minHeight="0px")}})}var T={};dn.forEach(function(e){var t,n,i=e.key,r=null===(t=sn.current[i])||void 0===t?void 0:t.current,o=null===(n=vn.current[i])||void 0===n?void 0:n.current;if(r&&o){var l=r.getBoundingClientRect(),c=o.getBoundingClientRect();T[i]=Math.max(l.height,c.height)}});var k={left:{},right:{}},M={};if(!Oe.current)if(ue){if(be&&null!==on)if("number"==typeof on){var D=on,A=Ht[D],H=null===(o=fn.current[D])||void 0===o?void 0:o.current;H&&A&&(A.refIndexes||[]).forEach(function(e){var t,n=Ot.findIndex(function(t){return t.selfIndex===e}),i=null===(t=hn.current[n])||void 0===t?void 0:t.current;if(i&&(Ct["left-".concat(D)]||Ct["right-".concat(n)])){var r=Math.max(H.getBoundingClientRect().height,i.getBoundingClientRect().height);k.left[D]=Math.max(k.left[D]||0,r),k.right[n]=Math.max(k.right[n]||0,r)}})}else{var O=on.split(W)[0];_=null===(l=mn.current[O])||void 0===l?void 0:l.current,B=null===(c=yn.current[O])||void 0===c?void 0:c.current;if(_&&B){N=Math.max(_.getBoundingClientRect().height,B.getBoundingClientRect().height);M[O]=Math.max(M[O]||0,N)}}}else{Object.keys(mn.current).forEach(function(e){var t,n;if(I(e)){var i=null===(t=mn.current[e])||void 0===t?void 0:t.current,r=null===(n=yn.current[e])||void 0===n?void 0:n.current;if(i&&r&&null!==i.offsetParent&&null!==r.offsetParent){var o=i.getBoundingClientRect(),l=r.getBoundingClientRect(),c=Math.max(o.height,l.height);M[e]=c,i.style.minHeight="".concat(c,"px"),r.style.minHeight="".concat(c,"px")}}});for(F=0;F<Math.min(Ht.length,Ot.length);F++){var _=null===(i=fn.current[F])||void 0===i?void 0:i.current,B=null===(r=hn.current[F])||void 0===r?void 0:r.current;if(_&&B){var N=Math.max(_.getBoundingClientRect().height,B.getBoundingClientRect().height);k.left[F]=N,k.right[F]=N}}}if(dn.forEach(function(e){var t,n,i=e.key,r=null===(t=sn.current[i])||void 0===t?void 0:t.current,o=null===(n=vn.current[i])||void 0===n?void 0:n.current;if(r&&o){var l=T[i];r.style.minHeight="".concat(l,"px"),o.style.minHeight="".concat(l,"px")}}),Oe.current||(Object.entries(k.left).forEach(function(e){var t,n=e[0],i=e[1],r=null===(t=fn.current[Number(n)])||void 0===t?void 0:t.current;r&&(r.style.minHeight="".concat(i,"px"))}),Object.entries(k.right).forEach(function(e){var t,n=e[0],i=e[1],r=null===(t=hn.current[Number(n)])||void 0===t?void 0:t.current;r&&(r.style.minHeight="".concat(i,"px"))}),ue||Object.keys(M).forEach(function(e){var t,n,i=null===(t=mn.current[e])||void 0===t?void 0:t.current,r=null===(n=yn.current[e])||void 0===n?void 0:n.current;if(i&&r&&M[e]){var o=M[e];i.style.minHeight="".concat(o,"px"),r.style.minHeight="".concat(o,"px")}})),ue){if(Ht.forEach(function(e,t){var n;(null===(n=fn.current[t])||void 0===n?void 0:n.current)&&(e.refIndexes||[]).forEach(function(e){var n,i,r,o,l,c,u,a,d,s,v=Ot.findIndex(function(t){return t.selfIndex===e});if(-1!==v){var f=null===(n=pn.current[t])||void 0===n?void 0:n.current,h=null===(i=gn.current[v])||void 0===i?void 0:i.current;if(f&&h){var p=f.getBoundingClientRect(),g=h.getBoundingClientRect(),x=p.right-R.left,m=g.left-R.left,y=p.top+p.height/2-R.top,b=g.top+g.height/2-R.top;if(be&&on===t){var S=null!==(o=null===(r=st.current)||void 0===r?void 0:r.getBoundingClientRect().top)&&void 0!==o?o:0,w=null!==(c=null===(l=lt.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==c?c:0,I=S+(null!==(a=null===(u=st.current)||void 0===u?void 0:u.clientHeight)&&void 0!==a?a:1/0),F=w+(null!==(s=null===(d=lt.current)||void 0===d?void 0:d.clientHeight)&&void 0!==s?s:1/0),E=p.top+p.height/2,_=function(e,t,n){return Math.max(t,Math.min(n,e))};y=_(E,S,I)-R.top,b=_(E,w,F)-R.top}var B=wn(t);B&&C.push({id:"line-".concat(t,"-").concat(v),x1:x,y1:y,x2:m,y2:b,style:B,sectionIdx:t,targetRightIdx:v})}}})}),be&&"string"==typeof on){var z=on,j=(O=z.split(W)[0],null===(f=pn.current[z])||void 0===f?void 0:f.current),P=null===(h=gn.current[z])||void 0===h?void 0:h.current;if(j&&P){var Y=j.getBoundingClientRect(),K=P.getBoundingClientRect(),V=Y.right-R.left,X=K.left-R.left,q=null!==(g=null===(p=st.current)||void 0===p?void 0:p.getBoundingClientRect().top)&&void 0!==g?g:0,U=null!==(m=null===(x=lt.current)||void 0===x?void 0:x.getBoundingClientRect().top)&&void 0!==m?m:0,G=q+(null!==(b=null===(y=st.current)||void 0===y?void 0:y.clientHeight)&&void 0!==b?b:1/0),J=U+(null!==(w=null===(S=lt.current)||void 0===S?void 0:S.clientHeight)&&void 0!==w?w:1/0),Q=Y.top+Y.height/2,$=K.top+K.height/2,Z=function(e,t,n){return Math.max(t,Math.min(n,e))},ee=Z(Q,q,G)-R.top,te=Z($,U,J)-R.top;(re=In(O))&&C.push({id:"line-subsec-".concat(z),x1:V,y1:ee,x2:X,y2:te,style:re,sectionIdx:Number(O.split("-")[0]),isSubSection:!0,subSectionKeyPath:z})}}}else{for(F=0;F<Math.min(Ht.length,Ot.length);F++){var ne=null===(u=fn.current[F])||void 0===u?void 0:u.current,ie=null===(a=hn.current[F])||void 0===a?void 0:a.current;if(ne&&ie){var re,oe=ne.getBoundingClientRect(),le=ie.getBoundingClientRect(),ce=Math.max(oe.top,le.top)+18-R.top,ae=(null===(d=Ot[F])||void 0===d?void 0:d.id)||"sec-".concat(F);(re=wn(F))&&C.push({id:ae,x1:oe.right-R.left,y1:ce,x2:le.left-R.left,y2:ce,style:re,sectionIdx:F,hasCognitive:!!((null===(s=Ht[F])||void 0===s?void 0:s.cognitiveData)||(null===(v=Ot[F])||void 0===v?void 0:v.cognitiveData)||ae&&Ye[ae])})}}Object.keys(pn.current).forEach(function(t){var n,i,r,o,l,c,u,a,d,s;if(t.includes(W)){var v=t.split(W)[0];if(I(v)){var f=null===(n=pn.current[t])||void 0===n?void 0:n.current,h=null===(i=gn.current[t])||void 0===i?void 0:i.current;if(f&&h&&null!==f.offsetParent&&null!==h.offsetParent){for(var p=f.getBoundingClientRect(),g=h.getBoundingClientRect(),x=p.top+p.height/2-R.top,m=g.top+g.height/2-R.top,y=v.split("-").map(Number),b=Ht[y[0]],S=Ot[y[0]],w=1;w<y.length;w++)(null==b?void 0:b.subsections)&&(b=b.subsections[y[w]]),(null==S?void 0:S.subsections)&&(S=S.subsections[y[w]]);if(!b&&!S)return;var F=(null==b?void 0:b.relation)&&"not_defined"!==b.relation,_=(null==S?void 0:S.relation)&&"not_defined"!==S.relation,B=E(null==b?void 0:b.id)||E(null==S?void 0:S.id)||"",T=!(!(null==b?void 0:b.cognitiveData)&&!(null==S?void 0:S.cognitiveData)),k=null;if(F||_||T){var M=null!==(o=null!==(r=null==b?void 0:b.evaluationResult)&&void 0!==r?r:null==S?void 0:S.evaluationResult)&&void 0!==o?o:null,D=null!==(s=null!==(a=null!==(c=null===(l=null==M?void 0:M.evaluation_output)||void 0===l?void 0:l.output_score)&&void 0!==c?c:null===(u=null==M?void 0:M.evaluation_outputs)||void 0===u?void 0:u.output_score)&&void 0!==a?a:null===(d=null==M?void 0:M.evaluation_outputs)||void 0===d?void 0:d.output_value)&&void 0!==s?s:null==M?void 0:M.output_score,A=null!=D?"".concat(D,"%"):"N/A";k=e(e({},xt.relationStyles.low),null!=M?{label:A}:{label:"N/A"})}else k={badgeBg:"#EEF2FF",badgeText:"#3730A3",badgeBorder:"#C7D2FE",label:"N/A"};k&&C.push({id:"line-subsec-".concat(t),x1:p.right-R.left,y1:x,x2:g.left-R.left,y2:m,style:k,sectionIdx:y[0],isSubSection:!0,subSectionKeyPath:t,hasCognitive:T||!(!B||!Ye[B])})}}}})}if(nn(C),$t.current&&Zt.current){var de=$t.current.getBoundingClientRect(),se=Zt.current.getBoundingClientRect(),ve=(de.top+de.height/2-R.top+se.top+se.height/2-R.top)/2;an({x1:de.right-R.left,x2:se.left-R.left,y:ve})}else an(null);if(ue&&Te.size>0){var fe=[],he=st.current,pe=lt.current;if(he&&pe){var ge=[],xe=he.getBoundingClientRect().top,me=pe.getBoundingClientRect().top,ye=xe+he.clientHeight,Se=me+pe.clientHeight,we=he.scrollTop,Ie=pe.scrollTop,Re=R.top,Ce=function(e,t,n){return Math.max(t,Math.min(n,e))};Te.forEach(function(e){var t,n,i;if("string"==typeof e){var r=e,o=r.split(W)[0],l=null===(t=pn.current[r])||void 0===t?void 0:t.current,c=null===(n=gn.current[r])||void 0===n?void 0:n.current;if(!l||!c)return;var u=l.getBoundingClientRect(),a=c.getBoundingClientRect(),d=In(o),s=u.right-R.left,v=a.left-R.left-0,f=s+.5*(v-s),h=u.top+u.height/2,p=a.top+a.height/2,g=h-xe+we,x=p-me+Ie,m="conn-subsec-".concat(r);ge.push({lhsScrollY:g,rhsScrollY:x,x1:s,x2:v,containerTop:Re,leftIdx:r,rhsArrayIdx:r,styleColor:(null==d?void 0:d.badgeBorder)||"#6366F1",styleId:m});var y=Ce(h,xe,ye),b=Ce(p,me,Se),S=y-Re,w=b-Re,I=h>=xe-4&&h<=ye+4,C=p>=me-4&&p<=Se+4,F="";F=I&&C?L(s,S,v,w):I&&!C?"M ".concat(s,",").concat(S," L ").concat(f,",").concat(S," L ").concat(f,",").concat(w):!I&&C?"M ".concat(f,",").concat(S," L ").concat(f,",").concat(w," L ").concat(v,",").concat(w):"M ".concat(f,",").concat(S," L ").concat(f,",").concat(w),fe.push({id:m,pathD:F,style:d,leftIdx:r,rhsArrayIdx:r})}else{var E=Ht[e];if(!(null===(i=null==E?void 0:E.refIndexes)||void 0===i?void 0:i.length))return;E.refIndexes.forEach(function(t){var n,i,r=Ot.findIndex(function(e){return e.selfIndex===t});if(-1!==r){var o=null===(n=pn.current[e])||void 0===n?void 0:n.current,l=null===(i=gn.current[r])||void 0===i?void 0:i.current;if(o&&l){var c=o.getBoundingClientRect(),u=l.getBoundingClientRect(),a=wn(e),d=c.right-R.left,s=u.left-R.left-0,v=d+.5*(s-d),f=c.top+c.height/2,h=u.top+u.height/2,p=f-xe+we,g=h-me+Ie,x="conn-".concat(e,"-").concat(r);ge.push({lhsScrollY:p,rhsScrollY:g,x1:d,x2:s,containerTop:Re,leftIdx:e,rhsArrayIdx:r,styleColor:(null==a?void 0:a.badgeBorder)||"#6366F1",styleId:x});var m=Ce(f,xe,ye),y=Ce(h,me,Se),b=m-Re,S=y-Re,w=f>=xe-4&&f<=ye+4,I=h>=me-4&&h<=Se+4,C="";C=w&&I?L(d,b,s,S):w&&!I?"M ".concat(d,",").concat(b," L ").concat(v,",").concat(b," L ").concat(v,",").concat(S):!w&&I?"M ".concat(v,",").concat(b," L ").concat(v,",").concat(S," L ").concat(s,",").concat(S):"M ".concat(v,",").concat(b," L ").concat(v,",").concat(S),fe.push({id:x,pathD:C,style:a,leftIdx:e,rhsArrayIdx:r})}}})}}),ze.current=ge}Ae(fe)}else Ae([]),ze.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{vt.current=!1}}},[dn,Ht,Ot,Ye,xt,Sn,wn,ue,be,on,Te,Ct,_t]),Cn=s(function(){var e,t,n,i,r,o,l,c,u,a,d,s,v,f,h=ze.current;if(h.length&&!Oe.current){var p=null!==(t=null===(e=st.current)||void 0===e?void 0:e.scrollTop)&&void 0!==t?t:0,g=null!==(i=null===(n=lt.current)||void 0===n?void 0:n.scrollTop)&&void 0!==i?i:0,x=null!==(o=null===(r=st.current)||void 0===r?void 0:r.clientHeight)&&void 0!==o?o:1/0,m=null!==(c=null===(l=lt.current)||void 0===l?void 0:l.clientHeight)&&void 0!==c?c:1/0,y=null!==(a=null===(u=st.current)||void 0===u?void 0:u.getBoundingClientRect().top)&&void 0!==a?a:0,b=null!==(s=null===(d=lt.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==s?s:0,S=y+x,w=b+m,I=null!==(f=null===(v=Gt.current)||void 0===v?void 0:v.getBoundingClientRect().top)&&void 0!==f?f:0,R=function(e,t,n){return Math.max(t,Math.min(n,e))};h.forEach(function(e){var t=e.lhsScrollY-p+y,n=e.rhsScrollY-g+b,i=We.current[e.styleId+"-stroke"],r=We.current[e.styleId+"-bg"];if(i||r){var o,l=R(t,y,S),c=R(n,b,w),u=l-I,a=c-I,d=t>=y-4&&t<=S+4,s=n>=b-4&&n<=w+4,v=e.x1+.5*(e.x2-e.x1);o=d&&s?L(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))}})}},[]),Fn=a(Rn);d(function(){Fn.current=Rn},[Rn]);var En=a(null),_n=s(function(){null!==En.current&&clearTimeout(En.current),En.current=setTimeout(function(){Fn.current(),En.current=null},50)},[]),Bn=s(function(e){var t,n,i,r,o,l,c,u;if(!Ce.current){if(ue||_n(),je.current){var a=Pe.current,d=Jt.current,s=st.current,v=lt.current;if(null!==a&&null!==d&&s&&v){var f="string"==typeof a?null===(t=pn.current[a])||void 0===t?void 0:t.current:null===(n=jt.current[a])||void 0===n?void 0:n.current,h="string"==typeof d?null===(i=gn.current[d])||void 0===i?void 0:i.current:null===(r=xn.current[d])||void 0===r?void 0:r.current;if(f&&h){var p=f.getBoundingClientRect().top-s.getBoundingClientRect().top+s.scrollTop,g=h.getBoundingClientRect().top-v.getBoundingClientRect().top+v.scrollTop;if(e.currentTarget===s){var x=g-(p-s.scrollTop),m=v.scrollHeight-v.clientHeight,y=Math.max(0,Math.min(x,m));Math.abs(v.scrollTop-y)>1&&(v.scrollTop=y)}else if(e.currentTarget===v){var b=p-(g-v.scrollTop),S=s.scrollHeight-s.clientHeight,w=Math.max(0,Math.min(b,S));Math.abs(s.scrollTop-w)>1&&(s.scrollTop=w)}if(Qt.current){var I=null===(o=pn.current[a])||void 0===o?void 0:o.current,R=null===(l=gn.current[d])||void 0===l?void 0:l.current,C=null!==(u=null===(c=Gt.current)||void 0===c?void 0:c.getBoundingClientRect().top)&&void 0!==u?u:0,F=s.getBoundingClientRect().top,E=F+s.clientHeight,_=v.getBoundingClientRect().top,B=_+v.clientHeight,T=function(e,t,n){return Math.max(t,Math.min(n,e))};if(I&&R){var k=I.getBoundingClientRect(),M=R.getBoundingClientRect(),D=k.top+k.height/2,A=M.top+M.height/2,H=T(D,F,E),O=T(A,_,B);Qt.current.setAttribute("y1",(H-C).toString()),Qt.current.setAttribute("y2",(O-C).toString());var N=D>=F-4&&D<=E+4;Qt.current.setAttribute("visibility",N?"visible":"hidden")}}}}}ze.current.length>0&&!Le.current&&(Le.current=!0,requestAnimationFrame(function(){Cn(),Le.current=!1}))}},[Cn,ue,_n]);d(function(){var e=setTimeout(_n,250);window.addEventListener("resize",_n);var t=null,n=null;return rt.current&&(t=new ResizeObserver(_n)).observe(rt.current),Gt.current&&(n=new ResizeObserver(_n)).observe(Gt.current),function(){clearTimeout(e),window.removeEventListener("resize",_n),null==t||t.disconnect(),null==n||n.disconnect()}},[yt,Tt,Wt,dn,Ct,_t,Ht,Ot,xt,_n,be,on,Ie,Te]),d(function(){je.current=be},[be]),d(function(){Pe.current=on},[on]);var Tn=s(function(){var e=nt.sectionIdx,t=nt.isOrphan;pt(),null!=e&&(t?me("No counterpart exists for this section."):be&&on===e?Yt():(ke(new Set),Ae([]),ze.current=[],pe(!0),Ce.current=!0,ln(e),Pe.current=e,Se(!0),je.current=!0,Re(!1),ct.current&&(ct.current.style.height="0px"),ut.current&&(ut.current.style.height="0px"),at.current&&(at.current.style.height="0px"),dt.current&&(dt.current.style.height="0px"),requestAnimationFrame(function(){var t,n,i,r,o=null,l=null,c=null;if("string"==typeof e)o=(null===(t=pn.current[e])||void 0===t?void 0:t.current)||null,c=(l=(null===(n=gn.current[e])||void 0===n?void 0:n.current)||null)?e:null;else{o=(null===(i=jt.current[e])||void 0===i?void 0:i.current)||null;var u=Ht[e],a=(null==u?void 0:u.refIndexes)||[];if(a.length>0){var d=a[0],s=Ot.findIndex(function(e){return e.selfIndex===d});-1!==s&&(l=(null===(r=xn.current[s])||void 0===r?void 0:r.current)||null,c=s)}}Jt.current=c;var v=st.current,f=lt.current;if(!o||!v)return Ce.current=!1,void pe(!1);if(!l||!f)return Re(!0),Fn.current(),Ce.current=!1,void pe(!1);var h=o.getBoundingClientRect().top-v.getBoundingClientRect().top+v.scrollTop,p=l.getBoundingClientRect().top-f.getBoundingClientRect().top+f.scrollTop-(h-v.scrollTop);p<0&&ct.current&&(ct.current.style.height="".concat(Math.abs(p),"px"));requestAnimationFrame(function(){var e,t=f.scrollHeight-f.clientHeight;if(p<0)e=0;else{if(p>t){var n=p-t;return ut.current&&(ut.current.style.height="".concat(n+150,"px")),void requestAnimationFrame(function(){Y(f,p,200,function(){Re(!0),Fn.current(),Ce.current=!1,pe(!1)})})}e=p}Y(f,e,200,function(){Re(!0),Fn.current(),Ce.current=!1,pe(!1)})})})))},[pt,nt.sectionIdx,be,on,Ht,Ot,_n,Yt]),kn=null!==nt.sectionIdx&&Te.has(nt.sectionIdx),Mn=function(t){var n,o,c,u=t.section,a=t.idx,d=t.columnKey,s=t.colRef,h=t.mb,p=void 0===h?1:h,g=t.parentNodeId,x=void 0===g?"":g,w=ue?!!Ct["".concat(d,"-").concat(a)]:!!Ct[String(a)],R=(null===(n=u.displayTitle)||void 0===n||n)&&_(u.title),C=(null===(o=u.displayContent)||void 0===o||o)&&_(u.content),F=!R&&!C,B=u.title;R||(B=C?"No Title Found":"No Matching Section Found");var T,k=[];if(null===(c=u.evaluationResult)||void 0===c?void 0:c.deviations){var M=u.evaluationResult.deviations;for(var D in M){var A=M[D][x];A&&k.push(A)}}return i(v,e({ref:s,sx:{mb:p,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:r(y,e({disableGutters:!0,expanded:!F&&w,onChange:function(){return!F&&function(t,n){var i,r;Oe.current=!0,Ne.current&&clearTimeout(Ne.current),He.current&&(He.current.style.opacity="0");var o=null===(i=fn.current[t])||void 0===i?void 0:i.current,l=null===(r=hn.current[t])||void 0===r?void 0:r.current;if(o&&(o.style.minHeight="0px"),l&&(l.style.minHeight="0px"),Object.keys(mn.current).forEach(function(e){var n,i;if(e.startsWith("".concat(t,"-"))){var r=null===(n=mn.current[e])||void 0===n?void 0:n.current,o=null===(i=yn.current[e])||void 0===i?void 0:i.current;r&&(r.style.minHeight="0px"),o&&(o.style.minHeight="0px")}}),ue){var c=Ht[t];((null==c?void 0:c.refIndexes)||[]).forEach(function(e){var t,n=Ot.findIndex(function(t){return t.selfIndex===e}),i=null===(t=hn.current[n])||void 0===t?void 0:t.current;i&&(i.style.minHeight="0px")});var u=Ot[t],a=null==u?void 0:u.selfIndex;Ht.forEach(function(e,t){var n,i;if(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(a)){var r=null===(i=fn.current[t])||void 0===i?void 0:i.current;r&&(r.style.minHeight="0px")}})}Ne.current=setTimeout(function(){Oe.current=!1,Fn.current(),He.current&&(He.current.style.opacity="1")},650),Ft(function(i){var r=e({},i);if(!ue){var o=!!i[String(t)];return r[String(t)]=!o,r}var l="".concat(n,"-").concat(t),c=!i[l];if(r[l]=c,"left"===n)((null==(u=Ht[t])?void 0:u.refIndexes)||[]).forEach(function(e){var t=Ot.findIndex(function(t){return t.selfIndex===e});-1!==t&&(r["right-".concat(t)]=c)});else{var u,a=null==(u=Ot[t])?void 0:u.selfIndex;Ht.forEach(function(e,t){var n;(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(a))&&(r["left-".concat(t)]=c)})}return r})}(a,d)},sx:{boxShadow:"none",border:F?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:F?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flexGrow:1,width:"100%",display:"flex",flexDirection:"column",minWidth:0,"&:before":{display:"none"}}},{children:[i(b,e({expandIcon:F?null:i(I,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:F?"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&&i(m,e({title:B,placement:"top"},{children:i(f,e({component:"div",sx:{fontSize:"12px",color:F?"#94A3B8":"#19213D",fontWeight:F?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(T=B,T?E(T).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(e,t){return e.startsWith("**")&&e.endsWith("**")?i("strong",{children:e.slice(2,-2)},t):i(l.Fragment,{children:e},t)}):null)}))}))})),!F&&r(S,e({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[C&&i(z,{content:u.content,sxStyles:Qe,highlights:k,maintainRelativeOrder:ue}),(u.subsections||[]).map(function(e,t){return Dn({section:e,keyPath:"".concat(a,"-").concat(t),depth:0,columnKey:d,parentNodeId:x})})]}))]}))}),"".concat(d,"-sec-").concat(a))},Dn=function(t){var n,o,c,u,a,d,s,h,p,g=t.section,x=t.keyPath,m=t.depth,w=void 0===m?0:m,R=t.columnKey,C=void 0===R?"left":R,F=t.parentNodeId,E=void 0===F?"":F,B=(null===(n=g.displayTitle)||void 0===n||n)&&_(g.title),T=(null===(o=g.displayContent)||void 0===o||o)&&_(g.content),k=!B&&!T,M=B?g.title:T?"No Title Found":"No Matching Section Found",D=!!_t[x];"left"!==C||mn.current[x]||(mn.current[x]=l.createRef()),"right"!==C||yn.current[x]||(yn.current[x]=l.createRef());for(var A="left"===C?mn.current[x]:yn.current[x],H=In(x),O=x.split("-").map(Number),N=Ht[O[0]],L=Ot[O[0]],j=1;j<O.length;j++)(null==N?void 0:N.subsections)&&(N=N.subsections[O[j]]),(null==L?void 0:L.subsections)&&(L=L.subsections[O[j]]);var P=null===(c=null==Q?void 0:Q.input_index_map)||void 0===c?void 0:c[0],Y=null===(u=null==Q?void 0:Q.input_index_map)||void 0===u?void 0:u[1],K="left"===C?Y:P,V=!(null===(a=g.refIndexes)||void 0===a?void 0:a.length)||void 0!==g.selfIndex&&g.selfIndex<0,X=null!==(h=null===(s=null===(d=g.evaluationResult)||void 0===d?void 0:d.evaluation_outputs)||void 0===s?void 0:s.output_value)&&void 0!==h?h:null,q=Object.entries((null===(p=g.evaluationResult)||void 0===p?void 0:p.deviations)||{}).map(function(e,t){var n=e[0],i=e[1],r=i[E];if(!r||"No equivalent clause present."===r)return null;var o=function(e,t){return"".concat(e).concat(W).concat(t)}(x,n),c=i[K],u=V||!c||"No equivalent clause present."===c,a=O[0]+1,d="".concat(a,".").concat(t+1);return"left"!==C||pn.current[o]||(pn.current[o]=l.createRef()),"right"!==C||gn.current[o]||(gn.current[o]=l.createRef()),{id:o,label:d,highlight:r,side:C,style:H,score:X,isConnected:ue&&Te.has(o),isOrphan:u,badgeRef:"left"===C?pn.current[o]:gn.current[o],onClick:function(e){e.stopPropagation(),Xt(e,N||{title:"",content:""},u,L||{title:"",content:""},o,H)}}}).filter(Boolean),U=ue&&q.some(function(e){return Te.has(e.id)});return B||T||g.subsections&&0!==g.subsections.length?i(v,B?e({ref:A,sx:{mt:1,width:"100%",minWidth:0,position:"relative"}},{children:i(v,e({sx:e({width:"100%"},U&&H&&{borderRadius:"4px",outline:"2px solid ".concat(H.badgeBorder),outlineOffset:"1px"})},{children:r(y,e({disableGutters:!0,expanded:!k&&D,onChange:function(){return!k&&Bt(function(t){var n;return e(e({},t),((n={})[x]=!t[x],n))})},sx:{mt:0,boxShadow:"none",border:k?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF",minWidth:0,"&:before":{display:"none"}}},{children:[i(b,e({expandIcon:k?null:i(I,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"}}},{children:i(f,e({component:"div",sx:{fontSize:"11px",fontWeight:600,color:k?"#94A3B8":"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:M||"Untitled Subsection"}))})),!k&&r(S,e({sx:{pt:0,pb:1,minWidth:0}},{children:[T&&i(z,{content:g.content,sxStyles:Qe,deviationBadges:q,maintainRelativeOrder:ue}),(g.subsections||[]).map(function(e,t){return Dn({section:e,keyPath:"".concat(x,"-").concat(t),depth:w+1,columnKey:C,parentNodeId:E})})]}))]}))}))}):e({ref:A,sx:{mt:0===w?1:.75,width:"100%",minWidth:0,position:"relative"}},{children:!k&&r(v,e({sx:e({width:"100%"},U&&H&&{borderRadius:"4px",outline:"2px solid ".concat(H.badgeBorder),outlineOffset:"1px"})},{children:[T&&i(z,{content:g.content,sxStyles:Qe,deviationBadges:q,maintainRelativeOrder:ue}),(g.subsections||[]).map(function(e,t){return Dn({section:e,keyPath:"".concat(x,"-").concat(t),depth:w+1,columnKey:C,parentNodeId:E})})]}))}),x):null};return r(v,e({ref:ot,sx:e(e({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},ue?{}:{overflow:"visible"}),{position:"relative"})},{children:[se&&i(v,e({sx:{position:"absolute",inset:0,bgcolor:"rgba(255, 255, 255, 0.6)",backdropFilter:"blur(10px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"8px"}},{children:i(O,{})})),ue&&i(H,{open:nt.open,anchorEl:nt.anchorEl,sectionTitle:nt.sectionTitle,referenceSectionTitle:nt.refSectionTitle,onClose:pt,onOpenCognitiveCompare:qt,onOpenSideBySide:Tn,onConnect:Ut,isConnected:kn,isOrphan:nt.isOrphan}),Ze.open&&i(A,{open:Ze.open,popupRef:qe,position:Ve,popupConfig:re,onClose:function(){Xe(null),et(function(t){return e(e({},t),{open:!1})}),_e(null)},markdownStyles:te,sectionTitle:Ze.sectionTitle,referenceSectionTitle:Ze.refSectionTitle,cognitiveData:Ze.cognitiveData,anchorEl:Ze.anchorEl,sectionAnchorEl:Ze.sectionAnchorEl,scrollContainerEl:rt.current,badgeStyle:Ze.badgeStyle,docData:Ze.docData,deviationData:Ze.deviationData}),i(h,e({open:!!xe,autoHideDuration:8e3,onClose:function(){return me(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:i(p,e({onClose:function(){return me(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:xe}))})),(ie.isHeaderVisible||ie.isToggleVisible)&&r(v,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:[i(v,e({sx:{display:"flex",alignItems:"center",gap:1}},{children:ie.isHeaderVisible&&i(f,e({sx:{fontSize:"16px",fontWeight:600,color:"#0F172A"}},{children:J}))})),ie.isToggleVisible&&i(v,e({sx:{display:"flex",alignItems:"center"}},{children:i(g,{control:i(x,{checked:ue,onChange:function(e){var t=e.target.checked;ve(!0),setTimeout(function(){ae(t),Yt(),ke(new Set),Ae([]),ze.current=[],setTimeout(function(){ve(!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}})}))]})),i(v,e({ref:rt,onScroll:Bn,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:zt&&Lt?"none":"1.5px solid #EEF0F4"}},{children:i(v,e({sx:e({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},ue?{flex:1,minHeight:0}:{})},{children:r(v,e({ref:Gt,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:[r("svg",e({ref:He,style:{position:"absolute",top:0,left:0,width:Ge.width||"100%",height:Ge.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",transition:"opacity 0.15s ease-in-out"}},{children:[un&&r("g",{children:[i("line",{x1:un.x1,y1:un.y,x2:Math.max(un.x1,(un.x1+un.x2)/2-70),y2:un.y,stroke:"#BBF7D0",strokeWidth:"1.5"}),i("line",{x1:Math.min(un.x2,(un.x1+un.x2)/2+70),y1:un.y,x2:un.x2,y2:un.y,stroke:"#BBF7D0",strokeWidth:"1.5"})]}),tn.map(function(t){var n,o=t.x1+.5*(t.x2-t.x1),l=(t.y1+t.y2)/2;if("Not Defined"===t.style.label&&!t.hasCognitive)return null;if(!ue){var c=t.isSubSection?L(t.x1,t.y1,t.x2,t.y2):"M ".concat(t.x1," ").concat(t.y1," L ").concat(t.x2," ").concat(t.y2);return r("g",{children:[i("defs",{children:i("marker",e({id:"arr-norm-".concat(t.id),markerWidth:"7",markerHeight:"5",refX:"7",refY:"2.5",orient:"auto"},{children:i("polygon",{points:"0 0, 7 2.5, 0 5",fill:t.style.badgeBorder||"#E2E8F0"})}))}),i("path",{d:c,fill:"none",stroke:t.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5",markerEnd:"url(#arr-norm-".concat(t.id,")")}),i("foreignObject",e({x:o-100,y:l-14,width:"200",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:i(v,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:r(v,e({onClick:function(e){if(e.stopPropagation(),Ze.open&&Ee===t.id)ht();else{var n=Ht[t.sectionIdx]||{title:"",content:""},i=Ot[t.sectionIdx]||{title:"",content:""};if(t.isSubSection&&t.subSectionKeyPath){for(var r=t.subSectionKeyPath.split("-").map(Number),o=Ht[r[0]],l=Ot[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&&(n=o),l&&(i=l)}_e(t.id),Vt(Kt(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,i(v,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:i(R,{})})),i(I,{size:11,style:{transform:Ze.open&&Ee===t.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},t.id)}var u=!1;if(t.isSubSection)u=be&&on===t.subSectionKeyPath&&Ie;else{var a=Ht[t.sectionIdx];if(!(null===(n=null==a?void 0:a.refIndexes)||void 0===n?void 0:n.length)||(null==a?void 0:a.selfIndex)<0)return null;u=be&&on===t.sectionIdx&&Ie}return u?r("g",e({style:{transition:"opacity 0.2s"}},{children:[i("defs",{children:i("marker",e({id:"arr-".concat(t.id),markerWidth:"7",markerHeight:"5",refX:"7",refY:"2.5",orient:"auto"},{children:i("polygon",{points:"0 0, 7 2.5, 0 5",fill:t.style.badgeBorder||"#6366F1"})}))}),i("line",{ref:Qt,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 n,o=t.pathD,l=(null===(n=t.style)||void 0===n?void 0:n.badgeBorder)||"#6366F1",c="conn-marker-".concat(t.id),u="".concat(t.id,"-bg"),a="".concat(t.id,"-stroke");return r("g",{children:[i("defs",{children:i("clipPath",e({id:"connections-clip"},{children:i("marker",e({id:c,markerWidth:"8",markerHeight:"6",refX:"7",refY:"3",orient:"auto"},{children:i("polygon",{points:"0 0, 8 3, 0 6",fill:l})}))}))}),i("path",{ref:function(e){We.current[u]=e},d:o,fill:"none",stroke:"#FFFFFF",strokeWidth:"4",strokeOpacity:"0.7"}),i("path",{ref:function(e){We.current[a]=e},d:o,fill:"none",stroke:l,strokeWidth:"1.75",markerEnd:"url(#".concat(c,")")})]},t.id)})]})),r(v,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:[i(v,e({ref:$t,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",minHeight:"40px",alignItems:"center",overflowX:"hidden"}},{children:i(m,e({title:Dt,placement:"top"},{children:i(f,e({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center",textOverflow:"ellipsis",whiteSpace:"normal",width:"100%",height:"40px"}},{children:Dt}))}))})),r(v,e({ref:st,onScroll:Bn,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:[i("div",{ref:at,style:{width:"100%",height:"0px",flexShrink:0}}),Nt&&Ht.map(function(t,n){var o,c,u,a=!t.title&&!t.content;if(ue&&a)return null;if(!ue)return i(v,e({ref:Pt(n),sx:{width:"100%"}},{children:Mn({section:t,idx:n,columnKey:"left",colRef:fn.current[n],parentNodeId:(null===(o=null==Q?void 0:Q.input_index_map)||void 0===o?void 0:o[0])||""})}),"left-row-".concat(n));var d=t,s=wn(n),f=!(null===(c=d.refIndexes)||void 0===c?void 0:c.length)||d.selfIndex<0,h="number"==typeof d.selfIndex&&d.selfIndex>=0?d.selfIndex+1:null,p=Te.has(n);return i(v,e({ref:Pt(n),sx:{mb:1}},{children:r(v,e({sx:{position:"relative",width:"100%"}},{children:[i(v,e({ref:fn.current[n],sx:e({width:"100%",display:"flex"},p&&{borderRadius:"6px",outline:"2px solid ".concat((null==s?void 0:s.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:Mn({section:t,idx:n,columnKey:"left",colRef:l.createRef(),mb:0,parentNodeId:(null===(u=null==Q?void 0:Q.input_index_map)||void 0===u?void 0:u[0])||""})})),s&&r(v,e({ref:pn.current[n],onClick:function(e){var i=Ot.find(function(e){var t;return null===(t=d.refIndexes)||void 0===t?void 0:t.includes(e.selfIndex)})||{title:"",content:""};Xt(e,t,f,i,n,s)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:s.badgeBg,color:s.badgeText,border:"1px solid ".concat(s.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!==h&&i(v,e({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(s.badgeBorder)}},{children:h})),i(v,e({component:"span",sx:{fontSize:"11px",px:.25}},{children:f?"No Deviation Found":0==s.deviationLabel||void 0===s.deviationLabel?s.label:"".concat(s.deviationLabel,"% Deviation")})),i(w,{size:11,color:s.badgeText})]}))]}))}),"left-row-".concat(n))}),i("div",{ref:dt,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),i(v,e({sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0}},{children:i(v,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:r(v,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:[i(v,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:i(R,{})})),0,"% Similarity",i(I,{size:11})]}))}))})),r(v,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&&i(C,{sections:11}),i(v,e({ref:Zt,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"40px",display:"flex",alignItems:"center",overflowX:"hidden"}},{children:i(m,e({title:At,placement:"top"},{children:i(f,e({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center",textOverflow:"ellipsis",whiteSpace:"normal",width:"100%",height:"40px"}},{children:At}))}))})),r(v,e({ref:lt,onScroll:Bn,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:[i("div",{ref:ct,style:{width:"100%",height:"0px",flexShrink:0}}),Nt&&Ot.map(function(t,n){var o,c;if(!ue)return i(v,e({ref:xn.current[n],sx:{width:"100%"}},{children:Mn({section:t,idx:n,columnKey:"right",colRef:hn.current[n],parentNodeId:(null===(o=null==Q?void 0:Q.input_index_map)||void 0===o?void 0:o[1])||""})}),"right-row-".concat(n));var u=t,a=Ht.filter(function(e){var t;return(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(u.selfIndex))&&e.selfIndex>=0}).map(function(e){return e.selfIndex+1}),d=Ht.some(function(e,t){var n;return Te.has(t)&&(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(u.selfIndex))}),s=Ht.findIndex(function(e,t){var n;return Te.has(t)&&(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(u.selfIndex))}),f=-1!==s?wn(s):null;return i(v,e({ref:xn.current[n],sx:{mb:1}},{children:r(v,e({sx:{position:"relative",width:"100%"}},{children:[i(v,e({ref:hn.current[n],sx:e({width:"100%",display:"flex"},d&&f&&{borderRadius:"6px",outline:"2px solid ".concat(f.badgeBorder),outlineOffset:"1px"})},{children:Mn({section:t,idx:n,columnKey:"right",colRef:l.createRef(),mb:0,parentNodeId:(null===(c=null==Q?void 0:Q.input_index_map)||void 0===c?void 0:c[1])||""})})),!he&&i(v,e({ref:gn.current[n],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(n))}),i("div",{ref:ut,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))};export{K as default};
1
+ import{__assign as e,__rest as t,__spreadArray as n}from"tslib";import{jsx as i,jsxs as r,Fragment as o}from"react/jsx-runtime";import l,{useMemo as c,useState as u,useRef as a,useEffect as d,useCallback as s}from"react";import{Box as v,Typography as p,Snackbar as f,Alert as h,FormControlLabel as g,Switch as x,Tooltip as m,Accordion as y,AccordionSummary as b,AccordionDetails as S}from"@mui/material";import{EllipsisVertical as I,ChevronDown as w}from"lucide-react";import{ButtonCognitiveIcon as R}from"../../assests/svg/ButtonCognitiveIcon.js";import C from"./OverlayComponent.js";import F from"react-markdown";import{safeStringify as E,hasValue as B,getSideData as _,getRationale as T}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as M,DEFAULT_FIELD_CONFIG as k,DEFAULT_COMPARISON_CONFIG as A}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import D from"./CognitivePopup.js";import H from"./MoreFunctionsPopup.js";import O from"./LoaderComponent.js";import N from"rehype-raw";var W="::",z=l.memo(function(n){var l=n.content,u=n.sxStyles,a=n.deviationBadges,d=void 0===a?[]:a,s=n.highlights,f=void 0===s?[]:s,h=n.maintainRelativeOrder,g=void 0===h||h,x=c(function(){return d.reduce(function(t,n){var i;return e(e({},t),((i={})[n.id]=n,i))},{})},[d]),m=c(function(){return{mark:function(t){var n=t.children;return i("span",e({style:{backgroundColor:"#fccccc",borderRadius:"2px"}},{children:n}))},span:function(n){var l,c,u,a,d,s=n.children,p=t(n,["children"]),f=p["data-badge-id"];if(!f)return i("span",e({},p,{children:s}));var h=x[f];return h?r(v,e({component:"span",sx:{position:"static",display:"inline"}},{children:[s,i(v,e({ref:h.badgeRef,onClick:h.onClick,sx:e(e({position:"absolute",zIndex:30,display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"10px",bgcolor:(null===(l=h.style)||void 0===l?void 0:l.badgeBg)||"#EEF2FF",color:(null===(c=h.style)||void 0===c?void 0:c.badgeText)||"#3730A3",border:"1px solid ".concat((null===(u=h.style)||void 0===u?void 0:u.badgeBorder)||"#C7D2FE"),borderRadius:"12px",px:1,py:.3,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",boxShadow:"0 1px 3px rgba(0,0,0,0.07)"},"left"===h.side?{right:"-16px",transform:"translateY(-20%) translateX(calc(100% + 8px))"}:{left:"-16px",transform:"translateY(-20%) translateX(calc(-100% - 8px))"}),h.isConnected&&h.style&&{outline:"2px solid ".concat(h.style.badgeBorder),outlineOffset:"1px"})},{children:r(o,{children:[i(v,e({component:"span",sx:e({fontSize:"10px",fontWeight:700},"left"===h.side?{pr:.5,borderRight:"1px solid ".concat((null===(a=h.style)||void 0===a?void 0:a.badgeBorder)||"#C7D2FE")}:{})},{children:h.label})),"left"===h.side&&r(o,{children:[i(v,e({component:"span",sx:{fontSize:"10px",px:.25}},{children:null!=h.score&&"N/A"!==h.score&&"NA"!==h.score&&0!==h.score?"".concat(h.score,"% Deviation"):h.isOrphan?"No Deviation Found":"N/A"===h.score||"NA"===h.score?"N/A":"Same"})),i(I,{size:10,color:(null===(d=h.style)||void 0===d?void 0:d.badgeText)||"#3730A3"})]})]})}))]})):i("span",e({},p,{children:s}))}}},[x,g]),y=c(function(){var e=l||"",t=function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")};return d.forEach(function(n){n.highlight&&(e=e.replace(new RegExp(t(n.highlight),"g"),'<span data-badge-id="'.concat(n.id,'"><mark>').concat(n.highlight,"</mark></span>")))}),f.forEach(function(n){n&&(e=e.replace(new RegExp(t(n),"g"),"<mark>".concat(n,"</mark>")))}),e},[l,d,f]);return i(p,e({component:"div",sx:e(e({},u),{position:"relative",overflow:"visible","& p, & li, & ul, & ol":{position:"static",overflow:"visible"}})},{children:i(F,e({components:m,rehypePlugins:[N]},{children:E(y).replace(/\\n/g,"\n")}))}))},function(e,t){if(e.content!==t.content)return!1;if(e.sxStyles!==t.sxStyles)return!1;if(e.maintainRelativeOrder!==t.maintainRelativeOrder)return!1;var n=e.highlights||[],i=t.highlights||[];if(n.length!==i.length)return!1;for(var r=0;r<n.length;r++)if(n[r]!==i[r])return!1;return!0}),L=function(e,t,n,i,r){void 0===r&&(r=14);var o=e+.5*(n-e),l=i-t;if(Math.abs(l)<3)return"M ".concat(e," ").concat(t," H ").concat(n);var c=l>0?1:-1,u=Math.min(r,Math.abs(l)/2,Math.abs(o-e)/2,Math.abs(n-o)/2);return["M ".concat(e," ").concat(t),"H ".concat(o-u),"Q ".concat(o," ").concat(t," ").concat(o," ").concat(t+c*u),"V ".concat(i-c*u),"Q ".concat(o," ").concat(i," ").concat(o+u," ").concat(i),"H ".concat(n)].join(" ")},j={id:"",title:""},P={open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,isOrphan:!1,docData:null,deviationData:null},Y=function(e,t,n,i,r){void 0===n&&(n=300);var o=e.style.scrollBehavior;e.style.scrollBehavior="auto";var l=e.scrollTop,c=t-l,u=null,a=function(d){null===u&&(u=d);var s,v=d-u;v<n?(e.scrollTop=(s=v,s/=n,c*(--s*s*s+1)+l),r&&r(),requestAnimationFrame(a)):(e.scrollTop=t,e.style.scrollBehavior=o,r&&r(),i&&i())};requestAnimationFrame(a)},K=function(t){var o,F,N,K,V,q,X,U,G=t.componentHeaderText,J=void 0===G?"Contract Comparison":G,Q=t.treeData,$=t.comparisonConfig,Z=t.leftColumnTitleText,ee=t.rightColumnTitleText,te=t.markdownStyles,ne=t.displayConfig,ie=void 0===ne?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1}:ne,re=t.popupConfig,oe=t.deviationData,le=void 0===oe?{}:oe,ce=u(ie.maintainRelativeOrder),ue=ce[0],ae=ce[1],de=u(!1),se=de[0],ve=de[1],pe=u(!1),fe=pe[0],he=pe[1],ge=u(null),xe=ge[0],me=ge[1],ye=u(!1),be=ye[0],Se=ye[1],Ie=u(!1),we=Ie[0],Re=Ie[1],Ce=a(!1),Fe=u(null),Ee=Fe[0],Be=Fe[1],_e=u(new Set),Te=_e[0],Me=_e[1],ke=u([]),Ae=ke[0],De=ke[1],He=a(null),Oe=a(!1),Ne=a(null),We=a({}),ze=a([]),Le=a(!1),je=a(!1),Pe=a(null),Ye=c(function(){return(null==Q?void 0:Q.cognitive_decisioning)||{}},[Q]),Ke=u(null),Ve=Ke[0],qe=Ke[1],Xe=a(null),Ue=u({width:0,height:0}),Ge=Ue[0],Je=Ue[1],Qe=c(function(){return e(e({},M),te)},[te]),$e=u({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,isOrphan:!1,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null,deviationData:null}),Ze=$e[0],et=$e[1],tt=u({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,isOrphan:!1,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null,deviationData:null}),nt=tt[0],it=tt[1],rt=a(null),ot=a(null),lt=a(null),ct=a(null),ut=a(null),at=a(null),dt=a(null),st=a(null),vt=a(!1),pt=a(null);d(function(){pt.current=null},[Ze.sectionIdx,Ze.open]);var ft=s(function(){qe(null),et(P),Be(null)},[]),ht=s(function(){it(P)},[]),gt=s(function(){var e;if(Ze.anchorEl&&Ze.refSectionTitle){var t=Ze.anchorEl.getBoundingClientRect(),n=(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-t.bottom-12-12,o=t.top-12-12,l=r<n&&o>r;null!==pt.current?!0===pt.current&&(l=o>=n||o>=r):l=!(r>=n||r>=o),pt.current=l;var c=l?o:r,u=Math.min(n||9999,c),a=l?t.top-12-u:t.bottom+12,d=t.left+t.width/2,s=d-i/2,v=Math.max(12,Math.min(s,window.innerWidth-i-12)),p=Math.max(14,Math.min(d-v,i-10-4));qe({top:a,left:v,arrowLeft:p,openAbove:l,maxHeight:c})}},[Ze.anchorEl,Ze.refSectionTitle]);d(function(){if(Ze.open){window.addEventListener("resize",gt);var e=requestAnimationFrame(gt),t=null;return Xe.current&&(t=new ResizeObserver(function(){cancelAnimationFrame(e),e=requestAnimationFrame(gt)})).observe(Xe.current),function(){cancelAnimationFrame(e),window.removeEventListener("resize",gt),t&&t.disconnect()}}},[Ze.open,gt]),d(function(){var e=rt.current;if(e&&Ze.open){var t=function(e){Xe.current&&Xe.current.contains(e.target)||(qe(null),ft())};return e.addEventListener("scroll",t,{capture:!0}),window.addEventListener("scroll",t,{capture:!0}),function(){e.removeEventListener("scroll",t,{capture:!0}),window.removeEventListener("scroll",t,{capture:!0})}}},[Ze.open,ft]),d(function(){var e=rt.current;if(e&&nt.open){var t=function(){ht()};return e.addEventListener("scroll",t,{capture:!0}),window.addEventListener("scroll",t,{capture:!0}),function(){e.removeEventListener("scroll",t,{capture:!0}),window.removeEventListener("scroll",t,{capture:!0})}}},[nt.open,ht]);var xt=c(function(){var t,n,i,r,o,l,c,u,a,d,s,v;return{fields:null!==(t=null==$?void 0:$.fields)&&void 0!==t?t:k,thresholds:{high:null!==(i=null===(n=null==$?void 0:$.thresholds)||void 0===n?void 0:n.high)&&void 0!==i?i:A.thresholds.high,medium:null!==(o=null===(r=null==$?void 0:$.thresholds)||void 0===r?void 0:r.medium)&&void 0!==o?o:A.thresholds.medium,exact:null!==(c=null===(l=null==$?void 0:$.thresholds)||void 0===l?void 0:l.exact)&&void 0!==c?c:A.thresholds.exact},relationStyles:{noContent:e(e({},A.relationStyles.noContent),(null===(u=null==$?void 0:$.relationStyles)||void 0===u?void 0:u.noContent)||{}),high:e(e({},A.relationStyles.high),(null===(a=null==$?void 0:$.relationStyles)||void 0===a?void 0:a.high)||{}),exact:e(e({},A.relationStyles.exact),(null===(d=null==$?void 0:$.relationStyles)||void 0===d?void 0:d.exact)||{}),medium:e(e({},A.relationStyles.medium),(null===(s=null==$?void 0:$.relationStyles)||void 0===s?void 0:s.medium)||{}),low:e(e({},A.relationStyles.low),(null===(v=null==$?void 0:$.relationStyles)||void 0===v?void 0:v.low)||{})}}},[$]),mt=c(function(){if(Q&&Object.keys(Q).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,p=t.input_index_map||{0:"left",1:"right"},f=t[v]||a[v];if(!f||!1===f.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[]};var h=function(n,i){var o,l,c,u=t[n]||a[n];if(!u||!1===u.display_node)return null;var d=_(u,i,p),s=!1!==(null===(o=d.attributes)||void 0===o?void 0:o.display_title),v=!1!==(null===(l=d.attributes)||void 0===l?void 0:l.display_content),f=!!d.title.trim(),g=!!d.content.trim(),x=T(u),m=(null===(c=null==r?void 0:r[n])||void 0===c?void 0:c.evaluation_result)||u.evaluation_result||null,y=[];u.next&&Object.values(u.next).forEach(function(e){var t=a[e];if(t&&!1!==t.display_node){var n=h(e,i);n&&y.push(n)}});var b=!(!f&&!g);return e(e({id:n,title:f?d.title:"",content:g?d.content:"",displayTitle:s,displayContent:v,subsections:y},b?x:{score:void 0,relation:"not_defined"}),{evaluationResult:m})};if(i){var g=function(i,o){var l,c,u,d,s,v,f,h,x,m,y,b,S,I,w,R,C,F,E,B,M;void 0===o&&(o=0);var k=[],A=[];if(!i)return{refSections:k,baseSections:A};var D={},H={},O=-1,N=-1;for(var W in i){var z=i[W],L=t[z]||a[z];if(L&&!1!==L.display_node){var j=T(L),P=(null===(l=null==r?void 0:r[z])||void 0===l?void 0:l.evaluation_result)||L.evaluation_result||null,Y=_(L,"1",p),K=_(L,"0",p),V=!1!==(null===(c=Y.attributes)||void 0===c?void 0:c.display_title)&&Y.title.trim()||!1!==(null===(u=Y.attributes)||void 0===u?void 0:u.display_content)&&Y.content.trim(),q=!1!==(null===(d=K.attributes)||void 0===d?void 0:d.display_title)&&K.title.trim()||!1!==(null===(s=K.attributes)||void 0===s?void 0:s.display_content)&&K.content.trim(),X=Number(null!==(f=null===(v=Y.attributes)||void 0===v?void 0:v.display_index)&&void 0!==f?f:O--),U=Number(null!==(x=null===(h=K.attributes)||void 0===h?void 0:h.display_index)&&void 0!==x?x:N--),G=D[X]||e(e({id:z,title:!1!==(null===(m=Y.attributes)||void 0===m?void 0:m.display_title)?Y.title:"",content:!1!==(null===(y=Y.attributes)||void 0===y?void 0:y.display_content)?Y.content:"",subsections:[]},V?j:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:X,evaluationResult:P,displayContent:null===(b=Y.attributes)||void 0===b?void 0:b.display_content,displayTitle:null===(S=Y.attributes)||void 0===S?void 0:S.display_title}),J=H[U]||e(e({id:z,title:!1!==(null===(I=K.attributes)||void 0===I?void 0:I.display_title)?K.title:"",content:!1!==(null===(w=K.attributes)||void 0===w?void 0:w.display_content)?K.content:"",subsections:[]},q?j:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:U,evaluationResult:P,displayContent:null===(R=K.attributes)||void 0===R?void 0:R.display_content,displayTitle:null===(C=K.attributes)||void 0===C?void 0:C.display_title});Number(X)>=0&&Number(U)>=0&&((null===(F=G.refIndexes)||void 0===F?void 0:F.includes(Number(U)))||null===(E=G.refIndexes)||void 0===E||E.push(Number(U)),(null===(B=J.refIndexes)||void 0===B?void 0:B.includes(Number(X)))||null===(M=J.refIndexes)||void 0===M||M.push(Number(X))),D[X]=G,H[U]=J;var Q=g(L.next,o+1),$=Q.refSections,Z=Q.baseSections;$.length>0&&(G.subsections=n(n([],G.subsections||[],!0),$,!0)),Z.length>0&&(J.subsections=n(n([],J.subsections||[],!0),Z,!0))}}return k=Object.values(D).map(function(e){return e}),A=Object.values(H).map(function(e){return e}),k.sort(function(e,t){return e.selfIndex<0&&t.selfIndex>=0?1:e.selfIndex>=0&&t.selfIndex<0?-1:e.selfIndex-t.selfIndex}),A.sort(function(e,t){return e.selfIndex<0&&t.selfIndex>=0?1:e.selfIndex>=0&&t.selfIndex<0?-1:e.selfIndex-t.selfIndex}),{refSections:k,baseSections:A}},x=g(f.next),m=x.refSections,y=x.baseSections;s=m,d=y}else f.next&&Object.values(f.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=f.comparison_inputs)||void 0===o?void 0:o[p[0]])||void 0===l?void 0:l.title)||"Uploaded Contract",description:f.decision_scope_description||"",sections:d},activeVariants:[{id:"tree-variant-1",title:(null===(u=null===(c=f.comparison_inputs)||void 0===c?void 0:c[p[1]])||void 0===u?void 0:u.title)||"Reference Template",similarity:0,sections:s,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:f.decision_scope_description||""},fields:{}}}}]}}(Q,ue,le);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(Q),ue,JSON.stringify(le)]),yt=mt.activeProposed,bt=mt.activeVariants,St=mt.parseError;d(function(){St&&me("Failed to load comparison: ".concat(St))},[St]);var It=u(null),wt=It[0];It[1];var Rt=u({}),Ct=Rt[0],Ft=Rt[1],Et=u({}),Bt=Et[0],_t=Et[1],Tt=(null==bt?void 0:bt[0])||j,Mt=null===(N=null===(o=null==Q?void 0:Q.documents)||void 0===o?void 0:o[null===(F=null==Q?void 0:Q.input_index_map)||void 0===F?void 0:F[0]])||void 0===N?void 0:N.title,kt=null===(q=null===(K=null==Q?void 0:Q.documents)||void 0===K?void 0:K[null===(V=null==Q?void 0:Q.input_index_map)||void 0===V?void 0:V[1]])||void 0===q?void 0:q.title,At=E(Z||Mt||"Uploaded Contract"),Dt=E(ee||kt||"Reference Template"),Ht=c(function(){return(null==yt?void 0:yt.sections)||[]},[null==yt?void 0:yt.sections]),Ot=c(function(){return Tt.sections||[]},[Tt.sections]),Nt=Ht.length>0||Ot.length>0,Wt=Tt.analysis,zt=E(null===(U=null===(X=null==Wt?void 0:Wt.rule_difference_comparison)||void 0===X?void 0:X.summary)||void 0===U?void 0:U.overall_summary),Lt=!!zt.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),jt=a({}),Pt=function(e){return jt.current[e]||(jt.current[e]=l.createRef()),jt.current[e]},Yt=s(function(){var e,t,n,i;Se(!1),je.current=!1;var r=Pe.current,o=Jt.current;if(null!==r){var l="string"==typeof r?null===(e=mn.current[r.split(W)[0]])||void 0===e?void 0:e.current:null===(t=pn.current[r])||void 0===t?void 0:t.current;l&&(l.style.paddingTop="0px")}if(null!==o){var c="string"==typeof o?null===(n=yn.current[o.split(W)[0]])||void 0===n?void 0:n.current:null===(i=fn.current[o])||void 0===i?void 0:i.current;c&&(c.style.paddingTop="0px")}ln(null),Pe.current=null,Jt.current=null,Re(!1),he(!1),ct.current&&(ct.current.style.height="0px"),ut.current&&(ut.current.style.height="0px"),at.current&&(at.current.style.height="0px"),dt.current&&(dt.current.style.height="0px")},[]),Kt=s(function(e,t,n,i,r,o){var l,c,u=E(t.id)||E(n.id)||"",a=(u?Ye[u]:null)||t.cognitiveData||n.cognitiveData||{section_id:u,decisioning:[],gap:[],relevance_score:0},d=null!==(c=null===(l=jt.current[i])||void 0===l?void 0:l.current)&&void 0!==c?c:null;return{open:!0,sectionTitle:t.title||"N/A",refSectionTitle:n.title||"NA",cognitiveData:a,anchorEl:e,sectionAnchorEl:d,badgeStyle:o||null,sectionIdx:i,docData:{documents:null==Q?void 0:Q.documents,input_index_map:null==Q?void 0:Q.input_index_map},deviationData:t.evaluationResult||n.evaluationResult||null,isOrphan:!!r}},[Ye,Q]),Vt=s(function(e){ht(),qe(null),et(e)},[ht]),qt=function(e,t,n,i,r,o){e.stopPropagation(),nt.open&&nt.sectionIdx===r?ht():(ft(),it(Kt(e.currentTarget,t,i,r,n,o)))},Xt=s(function(){null!==nt.sectionIdx&&nt.anchorEl?Vt(e(e({},nt),{open:!0})):ht()},[nt,ht,Vt]),Ut=s(function(){var e=nt.sectionIdx,t=nt.isOrphan;ht(),null!==e&&(t?me("No counterpart exists to connect to."):(je.current&&Yt(),Me(function(t){return t.has(e)?new Set:new Set([e])})))},[nt.sectionIdx,ht,Yt]),Gt=a(null),Jt=a(null),Qt=a(null),$t=a(null),Zt=a(null),en=u([]),tn=en[0],nn=en[1],rn=u(null),on=rn[0],ln=rn[1];a(null);var cn=u(null),un=cn[0],an=cn[1],dn=c(function(){return xt.fields.filter(function(e){var t=e.key;return(!Nt||"description"!==t)&&(B(null==yt?void 0:yt[t])||B(Tt[t]))})},[yt,Tt,Nt,xt.fields]),sn=a({}),vn=a({}),pn=a({}),fn=a({}),hn=a({}),gn=a({}),xn=a({}),mn=a({}),yn=a({});dn.forEach(function(e){for(var t=e.key,n=0;n<Math.max(Ht.length,Ot.length);n+=1)pn.current[n]||(pn.current[n]=l.createRef()),fn.current[n]||(fn.current[n]=l.createRef()),hn.current[n]||(hn.current[n]=l.createRef()),gn.current[n]||(gn.current[n]=l.createRef()),xn.current[n]||(xn.current[n]=l.createRef());sn.current[t]||(sn.current[t]=l.createRef()),vn.current[t]||(vn.current[t]=l.createRef())});for(var bn=0;bn<Math.max(Ht.length,Ot.length);bn+=1)pn.current[bn]||(pn.current[bn]=l.createRef()),fn.current[bn]||(fn.current[bn]=l.createRef()),hn.current[bn]||(hn.current[bn]=l.createRef()),gn.current[bn]||(gn.current[bn]=l.createRef()),xn.current[bn]||(xn.current[bn]=l.createRef());d(function(){if(wt){var e=xt.fields.find(function(e){return e.analysisKey===wt||e.key===wt});if(e){var t=sn.current[e.key]||vn.current[e.key];(null==t?void 0:t.current)&&setTimeout(function(){return t.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[wt,xt.fields]);var Sn=s(function(e){var t,n,i,r,o,l,c,u,a,d=null===(t=null==Wt?void 0:Wt.rule_difference_comparison)||void 0===t?void 0:t.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===(n=null==s?void 0:s.highlights)||void 0===n?void 0:n.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 p=s.mappings[0]||{};return{score:s.score,relation:p.relation||"",highlightsA:(null===(l=p.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(c=p.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}},[Wt]),In=s(function(t){var n,i,r,o=Ht[t],l=Ot[t],c=(null==o?void 0:o.relation)&&"not_defined"!==o.relation,u=(null==l?void 0:l.relation)&&"not_defined"!==l.relation;E(null==o?void 0:o.id)||E(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({},xt.relationStyles.noContent),{label:"Not Defined"});var d=null!==(i=null!==(n=null==o?void 0:o.evaluationResult)&&void 0!==n?n: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({},xt.relationStyles.low),null!=d?{label:s}:{label:"N/A"})},[Ht,Ot,Ye,xt,Sn]),wn=s(function(t){for(var n,i,r,o,l,c,u=t.split("-").map(Number),a=Ht[u[0]],d=Ot[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,p=(null==d?void 0:d.relation)&&"not_defined"!==d.relation,f=E(null==a?void 0:a.id)||E(null==d?void 0:d.id)||"",h=!(!(null==a?void 0:a.cognitiveData)&&!(null==d?void 0:d.cognitiveData));if(!v&&!p&&!h)return e(e({},xt.relationStyles.noContent),{label:"Not Defined"});null!==(i=null!==(n=null==a?void 0:a.cognitiveRelevanceScore)&&void 0!==n?n:null==d?void 0:d.cognitiveRelevanceScore)&&void 0!==i||f&&(null===(r=Ye[f])||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({},xt.relationStyles.low),null!=g?{label:x}:{label:"N/A"})},[Ht,Ot,Ye,xt]),Rn=s(function(){var e,t,n,i,r,o,l,c,u,a,d,s,v,p,f,h,g,x,m,y,b,S;if(!vt.current&&!Oe.current){vt.current=!0;try{if(!Gt.current)return;var I=function(e){var t=e.split("-"),n=t[0];if(!Ct[n]&&!1===ue)return!1;if(ue&&!Ct["left-".concat(n)]&&!Ct["right-".concat(n)]&&!Ct[n])return!1;for(var i=n,r=1;r<t.length-1;r++)if(i+="-".concat(t[r]),!Bt[i])return!1;return!0},w=Gt.current.getBoundingClientRect();Je({width:w.width,height:w.height});var R=[];if(dn.forEach(function(e){var t,n,i=e.key,r=null===(t=sn.current[i])||void 0===t?void 0:t.current,o=null===(n=vn.current[i])||void 0===n?void 0:n.current;r&&o&&(r.style.height="auto",o.style.height="auto",r.style.minHeight="0px",o.style.minHeight="0px")}),!Oe.current){for(var C=0;C<Math.max(Ht.length,Ot.length);C++){var F=null===(e=pn.current[C])||void 0===e?void 0:e.current,E=null===(t=fn.current[C])||void 0===t?void 0:t.current;F&&(F.style.height="auto",F.style.minHeight="0px"),E&&(E.style.height="auto",E.style.minHeight="0px")}ue||Object.keys(mn.current).forEach(function(e){var t,n;if(I(e)){var i=null===(t=mn.current[e])||void 0===t?void 0:t.current,r=null===(n=yn.current[e])||void 0===n?void 0:n.current;i&&r&&(i.style.height="auto",r.style.height="auto",i.style.minHeight="0px",r.style.minHeight="0px")}})}var B={};dn.forEach(function(e){var t,n,i=e.key,r=null===(t=sn.current[i])||void 0===t?void 0:t.current,o=null===(n=vn.current[i])||void 0===n?void 0:n.current;if(r&&o){var l=r.getBoundingClientRect(),c=o.getBoundingClientRect();B[i]=Math.max(l.height,c.height)}});var _={left:{},right:{}},T={};if(!Oe.current)if(ue){if(be&&null!==on)if("number"==typeof on){var M=on,k=Ht[M],A=null===(r=pn.current[M])||void 0===r?void 0:r.current;A&&k&&(k.refIndexes||[]).forEach(function(e){var t,n=Ot.findIndex(function(t){return t.selfIndex===e}),i=null===(t=fn.current[n])||void 0===t?void 0:t.current;if(i&&(Ct["left-".concat(M)]||Ct["right-".concat(n)])){var r=Math.max(A.getBoundingClientRect().height,i.getBoundingClientRect().height);_.left[M]=Math.max(_.left[M]||0,r),_.right[n]=Math.max(_.right[n]||0,r)}})}else{var D=on.split(W)[0];F=null===(o=mn.current[D])||void 0===o?void 0:o.current,E=null===(l=yn.current[D])||void 0===l?void 0:l.current;if(F&&E){H=Math.max(F.getBoundingClientRect().height,E.getBoundingClientRect().height);T[D]=Math.max(T[D]||0,H)}}}else{Object.keys(mn.current).forEach(function(e){var t,n;if(I(e)){var i=null===(t=mn.current[e])||void 0===t?void 0:t.current,r=null===(n=yn.current[e])||void 0===n?void 0:n.current;if(i&&r&&null!==i.offsetParent&&null!==r.offsetParent){var o=i.getBoundingClientRect(),l=r.getBoundingClientRect(),c=Math.max(o.height,l.height);T[e]=c,i.style.minHeight="".concat(c,"px"),r.style.minHeight="".concat(c,"px")}}});for(C=0;C<Math.min(Ht.length,Ot.length);C++){var F=null===(n=pn.current[C])||void 0===n?void 0:n.current,E=null===(i=fn.current[C])||void 0===i?void 0:i.current;if(F&&E){var H=Math.max(F.getBoundingClientRect().height,E.getBoundingClientRect().height);_.left[C]=H,_.right[C]=H}}}if(dn.forEach(function(e){var t,n,i=e.key,r=null===(t=sn.current[i])||void 0===t?void 0:t.current,o=null===(n=vn.current[i])||void 0===n?void 0:n.current;if(r&&o){var l=B[i];r.style.minHeight="".concat(l,"px"),o.style.minHeight="".concat(l,"px")}}),Oe.current||(Object.entries(_.left).forEach(function(e){var t,n=e[0],i=e[1],r=null===(t=pn.current[Number(n)])||void 0===t?void 0:t.current;r&&(r.style.minHeight="".concat(i,"px"))}),Object.entries(_.right).forEach(function(e){var t,n=e[0],i=e[1],r=null===(t=fn.current[Number(n)])||void 0===t?void 0:t.current;r&&(r.style.minHeight="".concat(i,"px"))}),ue||Object.keys(T).forEach(function(e){var t,n,i=null===(t=mn.current[e])||void 0===t?void 0:t.current,r=null===(n=yn.current[e])||void 0===n?void 0:n.current;if(i&&r&&T[e]){var o=T[e];i.style.minHeight="".concat(o,"px"),r.style.minHeight="".concat(o,"px")}})),ue)Ht.forEach(function(e,t){var n;(null===(n=pn.current[t])||void 0===n?void 0:n.current)&&(e.refIndexes||[]).forEach(function(e){var n,i,r,o,l,c,u,a,d,s,v=Ot.findIndex(function(t){return t.selfIndex===e});if(-1!==v){var p=null===(n=hn.current[t])||void 0===n?void 0:n.current,f=null===(i=gn.current[v])||void 0===i?void 0:i.current;if(p&&f){var h=p.getBoundingClientRect(),g=f.getBoundingClientRect(),x=h.right-w.left,m=g.left-w.left,y=h.top+h.height/2-w.top,b=g.top+g.height/2-w.top;if(be&&on===t){var S=null!==(o=null===(r=st.current)||void 0===r?void 0:r.getBoundingClientRect().top)&&void 0!==o?o:0,I=null!==(c=null===(l=lt.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==c?c:0,C=S+(null!==(a=null===(u=st.current)||void 0===u?void 0:u.clientHeight)&&void 0!==a?a:1/0),F=I+(null!==(s=null===(d=lt.current)||void 0===d?void 0:d.clientHeight)&&void 0!==s?s:1/0),E=h.top+h.height/2,B=function(e,t,n){return Math.max(t,Math.min(n,e))};y=B(E,S,C)-w.top,b=B(E,I,F)-w.top}var _=In(t);_&&R.push({id:"line-".concat(t,"-").concat(v),x1:x,y1:y,x2:m,y2:b,style:_,sectionIdx:t,targetRightIdx:v})}}})});else for(C=0;C<Math.min(Ht.length,Ot.length);C++){var O=null===(c=pn.current[C])||void 0===c?void 0:c.current,N=null===(u=fn.current[C])||void 0===u?void 0:u.current;if(O&&N){var z=O.getBoundingClientRect(),j=N.getBoundingClientRect(),P=Math.max(z.top,j.top)+18-w.top,Y=(null===(a=Ot[C])||void 0===a?void 0:a.id)||"sec-".concat(C);(X=In(C))&&R.push({id:Y,x1:z.right-w.left,y1:P,x2:j.left-w.left,y2:P,style:X,sectionIdx:C,hasCognitive:!!((null===(d=Ht[C])||void 0===d?void 0:d.cognitiveData)||(null===(s=Ot[C])||void 0===s?void 0:s.cognitiveData)||Y&&Ye[Y]),isSubSection:!1})}}if(be&&"string"==typeof on){var K=on,V=(D=K.split(W)[0],null===(v=hn.current[K])||void 0===v?void 0:v.current),q=null===(p=gn.current[K])||void 0===p?void 0:p.current;if(V&&q){var X,U=V.getBoundingClientRect(),G=q.getBoundingClientRect(),J=U.right-w.left,Q=G.left-w.left,$=U.top+U.height/2-w.top,Z=G.top+G.height/2-w.top;if(ue){var ee=null!==(h=null===(f=st.current)||void 0===f?void 0:f.getBoundingClientRect().top)&&void 0!==h?h:0,te=null!==(x=null===(g=lt.current)||void 0===g?void 0:g.getBoundingClientRect().top)&&void 0!==x?x:0,ne=ee+(null!==(y=null===(m=st.current)||void 0===m?void 0:m.clientHeight)&&void 0!==y?y:1/0),ie=te+(null!==(S=null===(b=lt.current)||void 0===b?void 0:b.clientHeight)&&void 0!==S?S:1/0),re=function(e,t,n){return Math.max(t,Math.min(n,e))};$=re(U.top+U.height/2,ee,ne)-w.top,Z=re(G.top+G.height/2,te,ie)-w.top}(X=wn(D))&&R.push({id:"line-subsec-".concat(K),x1:J,y1:$,x2:Q,y2:Z,style:X,sectionIdx:Number(D.split("-")[0]),isSubSection:!0,subSectionKeyPath:K})}}if(nn(R),$t.current&&Zt.current){var oe=$t.current.getBoundingClientRect(),le=Zt.current.getBoundingClientRect(),ce=(oe.top+oe.height/2-w.top+le.top+le.height/2-w.top)/2;an({x1:oe.right-w.left,x2:le.left-w.left,y:ce})}else an(null);if(Te.size>0){var ae=[],de=st.current,se=lt.current;if(de&&se){var ve=[],pe=de.getBoundingClientRect().top,fe=se.getBoundingClientRect().top,he=pe+de.clientHeight,ge=fe+se.clientHeight,xe=de.scrollTop,me=se.scrollTop,ye=w.top,Se=function(e,t,n){return Math.max(t,Math.min(n,e))};Te.forEach(function(e){var t,n,i,r,o;if("string"==typeof e){var l=e,c=l.split(W)[0],u=null===(t=hn.current[l])||void 0===t?void 0:t.current,a=null===(n=gn.current[l])||void 0===n?void 0:n.current;if(!u||!a)return;var d=u.getBoundingClientRect(),s=a.getBoundingClientRect(),v=wn(c),p=(B=d.right-w.left)+.5*((_=s.left-w.left-0)-B),f=d.top+d.height/2,h=s.top+s.height/2,g=f-pe+xe,x=h-fe+me,m="conn-subsec-".concat(l);ve.push({lhsScrollY:g,rhsScrollY:x,x1:B,x2:_,containerTop:ye,leftIdx:l,rhsArrayIdx:l,styleColor:(null==v?void 0:v.badgeBorder)||"#6366F1",styleId:m});var y=Se(f,pe,he),b=Se(h,fe,ge),S=y-ye,I=b-ye,R=h>=fe-4&&h<=ge+4,C="";C=(T=f>=pe-4&&f<=he+4)&&R?L(B,S,_,I):T&&!R?"M ".concat(B,",").concat(S," L ").concat(p,",").concat(S," L ").concat(p,",").concat(I):!T&&R?"M ".concat(p,",").concat(S," L ").concat(p,",").concat(I," L ").concat(_,",").concat(I):"M ".concat(p,",").concat(S," L ").concat(p,",").concat(I),ae.push({id:m,pathD:C,style:v,leftIdx:l,rhsArrayIdx:l})}else if(ue){var F=Ht[e];if(!(null===(o=null==F?void 0:F.refIndexes)||void 0===o?void 0:o.length))return;F.refIndexes.forEach(function(t){var n,i,r=Ot.findIndex(function(e){return e.selfIndex===t});if(-1!==r){var o=null===(n=hn.current[e])||void 0===n?void 0:n.current,l=null===(i=gn.current[r])||void 0===i?void 0:i.current;if(o&&l){var c=o.getBoundingClientRect(),u=l.getBoundingClientRect(),a=In(e),d=c.right-w.left,s=u.left-w.left-0,v=d+.5*(s-d),p=c.top+c.height/2,f=u.top+u.height/2,h=p-pe+xe,g=f-fe+me,x="conn-".concat(e,"-").concat(r);ve.push({lhsScrollY:h,rhsScrollY:g,x1:d,x2:s,containerTop:ye,leftIdx:e,rhsArrayIdx:r,styleColor:(null==a?void 0:a.badgeBorder)||"#6366F1",styleId:x});var m=Se(p,pe,he),y=Se(f,fe,ge),b=m-ye,S=y-ye,I=p>=pe-4&&p<=he+4,R=f>=fe-4&&f<=ge+4,C="";C=I&&R?L(d,b,s,S):I&&!R?"M ".concat(d,",").concat(b," L ").concat(v,",").concat(b," L ").concat(v,",").concat(S):!I&&R?"M ".concat(v,",").concat(b," L ").concat(v,",").concat(S," L ").concat(s,",").concat(S):"M ".concat(v,",").concat(b," L ").concat(v,",").concat(S),ae.push({id:x,pathD:C,style:a,leftIdx:e,rhsArrayIdx:r})}}})}else{var E=e;u=null===(i=hn.current[e])||void 0===i?void 0:i.current,a=null===(r=gn.current[E])||void 0===r?void 0:r.current;if(!u||!a)return;var B,_;d=u.getBoundingClientRect(),s=a.getBoundingClientRect(),v=In(e),p=(B=d.right-w.left)+.5*((_=s.left-w.left-0)-B),f=d.top+d.height/2,h=s.top+s.height/2,g=f-pe+xe,x=h-fe+me,m="conn-".concat(e,"-").concat(E);ve.push({lhsScrollY:g,rhsScrollY:x,x1:B,x2:_,containerTop:ye,leftIdx:e,rhsArrayIdx:E,styleColor:(null==v?void 0:v.badgeBorder)||"#6366F1",styleId:m});var T;y=Se(f,pe,he),b=Se(h,fe,ge),S=y-ye,I=b-ye,R=h>=fe-4&&h<=ge+4,C="";C=(T=f>=pe-4&&f<=he+4)&&R?L(B,S,_,I):T&&!R?"M ".concat(B,",").concat(S," L ").concat(p,",").concat(S," L ").concat(p,",").concat(I):!T&&R?"M ".concat(p,",").concat(S," L ").concat(p,",").concat(I," L ").concat(_,",").concat(I):"M ".concat(p,",").concat(S," L ").concat(p,",").concat(I),ae.push({id:m,pathD:C,style:v,leftIdx:e,rhsArrayIdx:E})}}),ze.current=ve}De(ae)}else De([]),ze.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{vt.current=!1}}},[dn,Ht,Ot,Ye,xt,Sn,In,ue,be,on,Te,Ct,Bt]),Cn=s(function(){var e,t,n,i,r,o,l,c,u,a,d,s,v,p,f=ze.current;if(f.length&&!Oe.current){var h=null!==(t=null===(e=st.current)||void 0===e?void 0:e.scrollTop)&&void 0!==t?t:0,g=null!==(i=null===(n=lt.current)||void 0===n?void 0:n.scrollTop)&&void 0!==i?i:0,x=null!==(o=null===(r=st.current)||void 0===r?void 0:r.clientHeight)&&void 0!==o?o:1/0,m=null!==(c=null===(l=lt.current)||void 0===l?void 0:l.clientHeight)&&void 0!==c?c:1/0,y=null!==(a=null===(u=st.current)||void 0===u?void 0:u.getBoundingClientRect().top)&&void 0!==a?a:0,b=null!==(s=null===(d=lt.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==s?s:0,S=y+x,I=b+m,w=null!==(p=null===(v=Gt.current)||void 0===v?void 0:v.getBoundingClientRect().top)&&void 0!==p?p:0,R=function(e,t,n){return Math.max(t,Math.min(n,e))};f.forEach(function(e){var t=e.lhsScrollY-h+y,n=e.rhsScrollY-g+b,i=We.current[e.styleId+"-stroke"],r=We.current[e.styleId+"-bg"];if(i||r){var o,l=R(t,y,S),c=R(n,b,I),u=l-w,a=c-w,d=t>=y-4&&t<=S+4,s=n>=b-4&&n<=I+4,v=e.x1+.5*(e.x2-e.x1);o=d&&s?L(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))}})}},[]),Fn=a(Rn);d(function(){Fn.current=Rn},[Rn]);var En=a(null),Bn=s(function(){null!==En.current&&clearTimeout(En.current),En.current=setTimeout(function(){Fn.current(),En.current=null},50)},[]),_n=s(function(e){var t,n,i,r,o,l,c,u;if(!Ce.current){if(ue||Bn(),je.current){var a=Pe.current,d=Jt.current,s=st.current,v=lt.current;if(null!==a&&null!==d&&s&&v){var p="string"==typeof a?null===(t=hn.current[a])||void 0===t?void 0:t.current:null===(n=jt.current[a])||void 0===n?void 0:n.current,f="string"==typeof d?null===(i=gn.current[d])||void 0===i?void 0:i.current:null===(r=xn.current[d])||void 0===r?void 0:r.current;if(p&&f){var h=p.getBoundingClientRect().top-s.getBoundingClientRect().top+s.scrollTop,g=f.getBoundingClientRect().top-v.getBoundingClientRect().top+v.scrollTop;if(e.currentTarget===s){var x=g-(h-s.scrollTop),m=v.scrollHeight-v.clientHeight,y=Math.max(0,Math.min(x,m));Math.abs(v.scrollTop-y)>1&&(v.scrollTop=y)}else if(e.currentTarget===v){var b=h-(g-v.scrollTop),S=s.scrollHeight-s.clientHeight,I=Math.max(0,Math.min(b,S));Math.abs(s.scrollTop-I)>1&&(s.scrollTop=I)}if(Qt.current){var w=null===(o=hn.current[a])||void 0===o?void 0:o.current,R=null===(l=gn.current[d])||void 0===l?void 0:l.current,C=null!==(u=null===(c=Gt.current)||void 0===c?void 0:c.getBoundingClientRect().top)&&void 0!==u?u:0,F=s.getBoundingClientRect().top,E=F+s.clientHeight,B=v.getBoundingClientRect().top,_=B+v.clientHeight,T=function(e,t,n){return Math.max(t,Math.min(n,e))};if(w&&R){var M=w.getBoundingClientRect(),k=R.getBoundingClientRect(),A=M.top+M.height/2,D=k.top+k.height/2,H=T(A,F,E),O=T(D,B,_);Qt.current.setAttribute("y1",(H-C).toString()),Qt.current.setAttribute("y2",(O-C).toString());var N=A>=F-4&&A<=E+4;Qt.current.setAttribute("visibility",N?"visible":"hidden")}}}}}ze.current.length>0&&!Le.current&&(Le.current=!0,requestAnimationFrame(function(){Cn(),Le.current=!1}))}},[Cn,ue,Bn]);d(function(){var e=setTimeout(Bn,250);window.addEventListener("resize",Bn);var t=null,n=null;return rt.current&&(t=new ResizeObserver(Bn)).observe(rt.current),Gt.current&&(n=new ResizeObserver(Bn)).observe(Gt.current),function(){clearTimeout(e),window.removeEventListener("resize",Bn),null==t||t.disconnect(),null==n||n.disconnect()}},[yt,Tt,Wt,dn,Ct,Bt,Ht,Ot,xt,Bn,be,on,we,Te]),d(function(){je.current=be},[be]),d(function(){Pe.current=on},[on]);var Tn=s(function(){var e,t,n,i,r=nt.sectionIdx,o=nt.isOrphan;if(ht(),null!=r)if(o)me("No counterpart exists for this section.");else if(be&&on===r)Yt();else{if(!ue){var l=Pe.current,c=Jt.current;if(null!==l){var u="string"==typeof l?null===(e=mn.current[l.split(W)[0]])||void 0===e?void 0:e.current:null===(t=pn.current[l])||void 0===t?void 0:t.current;u&&(u.style.paddingTop="0px")}if(null!==c){var a="string"==typeof c?null===(n=yn.current[c.split(W)[0]])||void 0===n?void 0:n.current:null===(i=fn.current[c])||void 0===i?void 0:i.current;a&&(a.style.paddingTop="0px")}}Me(new Set),De([]),ze.current=[],he(!0),Ce.current=!0,ln(r),Pe.current=r,Se(!0),je.current=!0,Re(!1),ct.current&&(ct.current.style.height="0px"),ut.current&&(ut.current.style.height="0px"),at.current&&(at.current.style.height="0px"),dt.current&&(dt.current.style.height="0px"),requestAnimationFrame(function(){var e,t,n,i,o,l,c,u,a,d,s,v=null,p=null,f=null,h=null,g=null;if("string"==typeof r){v=(null===(e=hn.current[r])||void 0===e?void 0:e.current)||null,g=(p=(null===(t=gn.current[r])||void 0===t?void 0:t.current)||null)?r:null;var x=r.split(W)[0];f=(null===(n=mn.current[x])||void 0===n?void 0:n.current)||null,h=(null===(i=yn.current[x])||void 0===i?void 0:i.current)||null}else if(v=(null===(o=jt.current[r])||void 0===o?void 0:o.current)||null,f=(null===(l=pn.current[r])||void 0===l?void 0:l.current)||null,ue){var m=Ht[r],y=(null==m?void 0:m.refIndexes)||[];if(y.length>0){var b=y[0],S=Ot.findIndex(function(e){return e.selfIndex===b});-1!==S&&(p=(null===(a=xn.current[S])||void 0===a?void 0:a.current)||null,h=(null===(d=fn.current[S])||void 0===d?void 0:d.current)||null,g=S)}}else p=(null===(c=xn.current[r])||void 0===c?void 0:c.current)||null,h=(null===(u=fn.current[r])||void 0===u?void 0:u.current)||null,g=p?r:null;Jt.current=g;var I=st.current,w=lt.current;if(!v||!I)return Ce.current=!1,void he(!1);if(!p||!w)return Re(!0),Fn.current(),Ce.current=!1,void he(!1);if(!ue){var R=v.getBoundingClientRect(),C=p.getBoundingClientRect(),F=R.top-C.top;f&&h&&(f.style.paddingTop="0px",h.style.paddingTop="0px",F>0?h.style.paddingTop="".concat(F,"px"):F<0&&(f.style.paddingTop="".concat(Math.abs(F),"px")));var E=v?v.getBoundingClientRect().top:(null==f?void 0:f.getBoundingClientRect().top)||0;return null===(s=rt.current)||void 0===s||s.scrollTo({top:rt.current.scrollTop+E-150,behavior:"smooth"}),Re(!0),Fn.current(),Ce.current=!1,void he(!1)}var B=v.getBoundingClientRect().top-I.getBoundingClientRect().top+I.scrollTop,_=p.getBoundingClientRect().top-w.getBoundingClientRect().top+w.scrollTop-(B-I.scrollTop);_<0&&ct.current&&(ct.current.style.height="".concat(Math.abs(_),"px"));requestAnimationFrame(function(){var e,t=w.scrollHeight-w.clientHeight;if(_<0)e=0;else{if(_>t){var n=_-t;return ut.current&&(ut.current.style.height="".concat(n+150,"px")),void requestAnimationFrame(function(){Y(w,_,200,function(){Re(!0),Fn.current(),Ce.current=!1,he(!1)})})}e=_}Y(w,e,200,function(){Re(!0),Fn.current(),Ce.current=!1,he(!1)})})})}},[ht,nt.sectionIdx,be,on,Ht,Ot,Bn,Yt]),Mn=null!==nt.sectionIdx&&Te.has(nt.sectionIdx),kn=function(t){var n,o,c,u=t.section,a=t.idx,d=t.columnKey,s=t.colRef,f=t.mb,h=void 0===f?1:f,g=t.parentNodeId,x=void 0===g?"":g,I=ue?!!Ct["".concat(d,"-").concat(a)]:!!Ct[String(a)],R=(null===(n=u.displayTitle)||void 0===n||n)&&B(u.title),C=(null===(o=u.displayContent)||void 0===o||o)&&B(u.content),F=!R&&!C,_=u.title;R||(_=C?"No Title Found":"No Matching Section Found");var T,M=[];if(null===(c=u.evaluationResult)||void 0===c?void 0:c.deviations){var k=u.evaluationResult.deviations;for(var A in k){var D=k[A][x];D&&M.push(D)}}return i(v,e({ref:s,sx:{mb:h,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:r(y,e({disableGutters:!0,expanded:!F&&I,onChange:function(){return!F&&function(t,n){var i,r;Oe.current=!0,Ne.current&&clearTimeout(Ne.current),He.current&&(He.current.style.opacity="0");var o=null===(i=pn.current[t])||void 0===i?void 0:i.current,l=null===(r=fn.current[t])||void 0===r?void 0:r.current;if(o&&(o.style.minHeight="0px"),l&&(l.style.minHeight="0px"),Object.keys(mn.current).forEach(function(e){var n,i;if(e.startsWith("".concat(t,"-"))){var r=null===(n=mn.current[e])||void 0===n?void 0:n.current,o=null===(i=yn.current[e])||void 0===i?void 0:i.current;r&&(r.style.minHeight="0px"),o&&(o.style.minHeight="0px")}}),ue){var c=Ht[t];((null==c?void 0:c.refIndexes)||[]).forEach(function(e){var t,n=Ot.findIndex(function(t){return t.selfIndex===e}),i=null===(t=fn.current[n])||void 0===t?void 0:t.current;i&&(i.style.minHeight="0px")});var u=Ot[t],a=null==u?void 0:u.selfIndex;Ht.forEach(function(e,t){var n,i;if(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(a)){var r=null===(i=pn.current[t])||void 0===i?void 0:i.current;r&&(r.style.minHeight="0px")}})}Ne.current=setTimeout(function(){Oe.current=!1,Fn.current(),He.current&&(He.current.style.opacity="1")},650),Ft(function(i){var r=e({},i);if(!ue){var o=!!i[String(t)];return r[String(t)]=!o,r}var l="".concat(n,"-").concat(t),c=!i[l];if(r[l]=c,"left"===n)((null==(u=Ht[t])?void 0:u.refIndexes)||[]).forEach(function(e){var t=Ot.findIndex(function(t){return t.selfIndex===e});-1!==t&&(r["right-".concat(t)]=c)});else{var u,a=null==(u=Ot[t])?void 0:u.selfIndex;Ht.forEach(function(e,t){var n;(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(a))&&(r["left-".concat(t)]=c)})}return r})}(a,d)},sx:{boxShadow:"none",border:F?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:F?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flexGrow:1,width:"100%",display:"flex",flexDirection:"column",minWidth:0,"&:before":{display:"none"}}},{children:[i(b,e({expandIcon:F?null:i(w,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:F?"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&&i(m,e({title:_,placement:"top"},{children:i(p,e({component:"div",sx:{fontSize:"12px",color:F?"#94A3B8":"#19213D",fontWeight:F?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(T=_,T?E(T).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(e,t){return e.startsWith("**")&&e.endsWith("**")?i("strong",{children:e.slice(2,-2)},t):i(l.Fragment,{children:e},t)}):null)}))}))})),!F&&r(S,e({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[C&&i(z,{content:u.content,sxStyles:Qe,highlights:M,maintainRelativeOrder:ue}),(u.subsections||[]).map(function(e,t){return An({section:e,keyPath:"".concat(a,"-").concat(t),depth:0,columnKey:d,parentNodeId:x})})]}))]}))}),"".concat(d,"-sec-").concat(a))},An=function(t){var n,o,c,u,a,d,s,f,h,g=t.section,x=t.keyPath,m=t.depth,I=void 0===m?0:m,R=t.columnKey,C=void 0===R?"left":R,F=t.parentNodeId,E=void 0===F?"":F,_=(null===(n=g.displayTitle)||void 0===n||n)&&B(g.title),T=(null===(o=g.displayContent)||void 0===o||o)&&B(g.content),M=!_&&!T,k=_?g.title:T?"No Title Found":"No Matching Section Found",A=!!Bt[x];"left"!==C||mn.current[x]||(mn.current[x]=l.createRef()),"right"!==C||yn.current[x]||(yn.current[x]=l.createRef());for(var D="left"===C?mn.current[x]:yn.current[x],H=wn(x),O=x.split("-").map(Number),N=Ht[O[0]],L=Ot[O[0]],j=1;j<O.length;j++)(null==N?void 0:N.subsections)&&(N=N.subsections[O[j]]),(null==L?void 0:L.subsections)&&(L=L.subsections[O[j]]);var P=null===(c=null==Q?void 0:Q.input_index_map)||void 0===c?void 0:c[0],Y=null===(u=null==Q?void 0:Q.input_index_map)||void 0===u?void 0:u[1],K="left"===C?Y:P,V=ue?!(null===(a=g.refIndexes)||void 0===a?void 0:a.length)||void 0!==g.selfIndex&&g.selfIndex<0:"left"===C?!L:!N,q=null!==(f=null===(s=null===(d=g.evaluationResult)||void 0===d?void 0:d.evaluation_outputs)||void 0===s?void 0:s.output_value)&&void 0!==f?f:null,X=Object.entries((null===(h=g.evaluationResult)||void 0===h?void 0:h.deviations)||{}).map(function(e,t){var n=e[0],i=e[1],r=i[E];if(!r||"No equivalent clause present."===r)return null;var o=function(e,t){return"".concat(e).concat(W).concat(t)}(x,n),c=i[K],u=V||!c||"No equivalent clause present."===c,a=O[0]+1,d="".concat(a,".").concat(t+1);return"left"!==C||hn.current[o]||(hn.current[o]=l.createRef()),"right"!==C||gn.current[o]||(gn.current[o]=l.createRef()),{id:o,label:d,highlight:r,side:C,style:H,score:q,isConnected:Te.has(o),isOrphan:u,badgeRef:"left"===C?hn.current[o]:gn.current[o],onClick:function(e){e.stopPropagation(),qt(e,N||{title:"",content:""},u,L||{title:"",content:""},o,H)}}}).filter(Boolean),U=X.some(function(e){return Te.has(e.id)});return _||T||g.subsections&&0!==g.subsections.length?i(v,_?e({ref:D,sx:{mt:1,width:"100%",minWidth:0,position:"relative"}},{children:i(v,e({sx:e({width:"100%"},U&&H&&{borderRadius:"4px",outline:"2px solid ".concat(H.badgeBorder),outlineOffset:"1px"})},{children:r(y,e({disableGutters:!0,expanded:!M&&A,onChange:function(){return!M&&_t(function(t){var n;return e(e({},t),((n={})[x]=!t[x],n))})},sx:{mt:0,boxShadow:"none",border:M?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF",minWidth:0,"&:before":{display:"none"}}},{children:[i(b,e({expandIcon:M?null:i(w,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"}}},{children:i(p,e({component:"div",sx:{fontSize:"11px",fontWeight:600,color:M?"#94A3B8":"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:k||"Untitled Subsection"}))})),!M&&r(S,e({sx:{pt:0,pb:1,minWidth:0}},{children:[T&&i(z,{content:g.content,sxStyles:Qe,deviationBadges:X,maintainRelativeOrder:ue}),(g.subsections||[]).map(function(e,t){return An({section:e,keyPath:"".concat(x,"-").concat(t),depth:I+1,columnKey:C,parentNodeId:E})})]}))]}))}))}):e({ref:D,sx:{mt:0===I?1:.75,width:"100%",minWidth:0,position:"relative"}},{children:!M&&r(v,e({sx:e({width:"100%"},U&&H&&{borderRadius:"4px",outline:"2px solid ".concat(H.badgeBorder),outlineOffset:"1px"})},{children:[T&&i(z,{content:g.content,sxStyles:Qe,deviationBadges:X,maintainRelativeOrder:ue}),(g.subsections||[]).map(function(e,t){return An({section:e,keyPath:"".concat(x,"-").concat(t),depth:I+1,columnKey:C,parentNodeId:E})})]}))}),x):null};return r(v,e({ref:ot,sx:e(e({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},ue?{}:{overflow:"visible"}),{position:"relative"})},{children:[se&&i(v,e({sx:{position:"absolute",inset:0,bgcolor:"rgba(255, 255, 255, 0.6)",backdropFilter:"blur(10px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"8px"}},{children:i(O,{})})),i(H,{open:nt.open,anchorEl:nt.anchorEl,sectionTitle:nt.sectionTitle,referenceSectionTitle:nt.refSectionTitle,onClose:ht,onOpenCognitiveCompare:Xt,onOpenSideBySide:Tn,onConnect:Ut,isConnected:Mn,isOrphan:nt.isOrphan}),Ze.open&&i(D,{open:Ze.open,popupRef:Xe,position:Ve,popupConfig:re,onClose:function(){qe(null),et(function(t){return e(e({},t),{open:!1})}),Be(null)},markdownStyles:te,sectionTitle:Ze.sectionTitle,referenceSectionTitle:Ze.refSectionTitle,cognitiveData:Ze.cognitiveData,anchorEl:Ze.anchorEl,sectionAnchorEl:Ze.sectionAnchorEl,scrollContainerEl:rt.current,badgeStyle:Ze.badgeStyle,docData:Ze.docData,deviationData:Ze.deviationData}),i(f,e({open:!!xe,autoHideDuration:8e3,onClose:function(){return me(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:i(h,e({onClose:function(){return me(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:xe}))})),(ie.isHeaderVisible||ie.isToggleVisible)&&r(v,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:[i(v,e({sx:{display:"flex",alignItems:"center",gap:1}},{children:ie.isHeaderVisible&&i(p,e({sx:{fontSize:"16px",fontWeight:600,color:"#0F172A"}},{children:J}))})),ie.isToggleVisible&&i(v,e({sx:{display:"flex",alignItems:"center"}},{children:i(g,{control:i(x,{checked:ue,onChange:function(e){var t=e.target.checked;ve(!0),setTimeout(function(){ae(t),Yt(),Me(new Set),De([]),ze.current=[],setTimeout(function(){ve(!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}})}))]})),i(v,e({ref:rt,onScroll:_n,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:zt&&Lt?"none":"1.5px solid #EEF0F4"}},{children:i(v,e({sx:e({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},ue?{flex:1,minHeight:0}:{})},{children:r(v,e({ref:Gt,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:[r("svg",e({ref:He,style:{position:"absolute",top:0,left:0,width:Ge.width||"100%",height:Ge.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",transition:"opacity 0.15s ease-in-out"}},{children:[un&&!be&&r("g",{children:[i("line",{x1:un.x1,y1:un.y,x2:Math.max(un.x1,(un.x1+un.x2)/2-70),y2:un.y,stroke:"#BBF7D0",strokeWidth:"1.5"}),i("line",{x1:Math.min(un.x2,(un.x1+un.x2)/2+70),y1:un.y,x2:un.x2,y2:un.y,stroke:"#BBF7D0",strokeWidth:"1.5"})]}),tn.map(function(t){var n,o=t.x1+.5*(t.x2-t.x1),l=(t.y1+t.y2)/2;if("Not Defined"===t.style.label&&!t.hasCognitive)return null;var c=!1;if(t.isSubSection)c=be&&on===t.subSectionKeyPath&&we;else{var u=Ht[t.sectionIdx];(ue?!(null===(n=null==u?void 0:u.refIndexes)||void 0===n?void 0:n.length)||(null==u?void 0:u.selfIndex)<0:!Ot[t.sectionIdx])||(c=be&&on===t.sectionIdx&&we)}if(c)return r("g",e({style:{transition:"opacity 0.2s"}},{children:[i("defs",{children:i("marker",e({id:"arr-".concat(t.id),markerWidth:"7",markerHeight:"5",refX:"7",refY:"2.5",orient:"auto"},{children:i("polygon",{points:"0 0, 7 2.5, 0 5",fill:t.style.badgeBorder||"#6366F1"})}))}),i("line",{ref:Qt,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);if(!ue){var a=t.isSubSection?L(t.x1,t.y1,t.x2,t.y2):"M ".concat(t.x1," ").concat(t.y1," L ").concat(t.x2," ").concat(t.y2);return r("g",{children:[i("path",{d:a,fill:"none",stroke:t.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),i("foreignObject",e({x:o-100,y:l-14,width:"200",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:i(v,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:r(v,e({onClick:function(e){if(e.stopPropagation(),Ze.open&&Ee===t.id)ft();else{var n=Ht[t.sectionIdx]||{title:"",content:""},i=Ot[t.sectionIdx]||{title:"",content:""};if(t.isSubSection&&t.subSectionKeyPath){for(var r=t.subSectionKeyPath.split("-").map(Number),o=Ht[r[0]],l=Ot[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&&(n=o),l&&(i=l)}Be(t.id),Vt(Kt(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,i(v,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:i(R,{})})),i(w,{size:11,style:{transform:Ze.open&&Ee===t.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},t.id)}return null}),Ae.map(function(t){var n,o=t.pathD,l=(null===(n=t.style)||void 0===n?void 0:n.badgeBorder)||"#6366F1",c="conn-marker-".concat(t.id),u="".concat(t.id,"-bg"),a="".concat(t.id,"-stroke");return r("g",{children:[i("defs",{children:i("clipPath",e({id:"connections-clip"},{children:i("marker",e({id:c,markerWidth:"8",markerHeight:"6",refX:"7",refY:"3",orient:"auto"},{children:i("polygon",{points:"0 0, 8 3, 0 6",fill:l})}))}))}),i("path",{ref:function(e){We.current[u]=e},d:o,fill:"none",stroke:"#FFFFFF",strokeWidth:"4",strokeOpacity:"0.7"}),i("path",{ref:function(e){We.current[a]=e},d:o,fill:"none",stroke:l,strokeWidth:"1.75",markerEnd:"url(#".concat(c,")")})]},t.id)})]})),r(v,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:[i(v,e({ref:$t,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",minHeight:"40px",alignItems:"center",overflowX:"hidden"}},{children:i(m,e({title:At,placement:"top"},{children:i(p,e({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center",textOverflow:"ellipsis",whiteSpace:"normal",width:"100%",height:"40px"}},{children:At}))}))})),r(v,e({ref:st,onScroll:_n,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:[i("div",{ref:at,style:{width:"100%",height:"0px",flexShrink:0}}),Nt&&Ht.map(function(t,n){var o,c,u=!t.title&&!t.content;if(ue&&u)return null;var a=t,d=In(n),s=ue?!(null===(o=a.refIndexes)||void 0===o?void 0:o.length)||a.selfIndex<0:!Ot[n],p=ue?"number"==typeof a.selfIndex&&a.selfIndex>=0?a.selfIndex+1:null:n+1,f=Te.has(n),h=function(e,t){var n,i,r,o,l,c;if(!e)return t;var u=null!==(c=null!==(o=null!==(i=null===(n=e.evaluation_output)||void 0===n?void 0:n.output_score)&&void 0!==i?i:null===(r=e.evaluation_outputs)||void 0===r?void 0:r.output_score)&&void 0!==o?o:null===(l=e.evaluation_outputs)||void 0===l?void 0:l.output_value)&&void 0!==c?c:e.output_score;return null!=u?u:t}(a.evaluationResult,null==d?void 0:d.deviationLabel);return i(v,e({ref:Pt(n),sx:{mb:1,width:"100%"}},{children:r(v,e({sx:{position:"relative",width:"100%"}},{children:[i(v,e({ref:pn.current[n],sx:e({width:"100%",display:"flex"},f&&{borderRadius:"6px",outline:"2px solid ".concat((null==d?void 0:d.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:kn({section:t,idx:n,columnKey:"left",colRef:l.createRef(),mb:0,parentNodeId:(null===(c=null==Q?void 0:Q.input_index_map)||void 0===c?void 0:c[0])||""})})),ue&&d&&r(v,e({ref:hn.current[n],onClick:function(e){var i=ue?Ot.find(function(e){var t;return null===(t=a.refIndexes)||void 0===t?void 0:t.includes(e.selfIndex)})||{title:"",content:""}:Ot[n]||{title:"",content:""};qt(e,t,s,i,n,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!==p&&i(v,e({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(d.badgeBorder)}},{children:p})),i(v,e({component:"span",sx:{fontSize:"11px",px:.25}},{children:s?"No Deviation Found":"N/A"===h||"NA"===h?"N/A":0==h||null==h?"Same":"".concat(h,"% Deviation")})),i(I,{size:11,color:d.badgeText})]}))]}))}),"left-row-".concat(n))}),i("div",{ref:dt,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),i(v,e({sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0}},{children:i(v,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:r(v,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:[i(v,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:i(R,{})})),0,"% Similarity",i(w,{size:11})]}))}))})),r(v,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:[fe&&i(C,{sections:11}),i(v,e({ref:Zt,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"40px",display:"flex",alignItems:"center",overflowX:"hidden"}},{children:i(m,e({title:Dt,placement:"top"},{children:i(p,e({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center",textOverflow:"ellipsis",whiteSpace:"normal",width:"100%",height:"40px"}},{children:Dt}))}))})),r(v,e({ref:lt,onScroll:_n,sx:e({p:"12px",display:"flex",flexDirection:"column"},ue?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-25px",pl:"45px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[i("div",{ref:ct,style:{width:"100%",height:"0px",flexShrink:0}}),Nt&&Ot.map(function(t,n){var o,c=t,u=[],a=!1,d=null;if(ue){u=Ht.filter(function(e){var t;return(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(c.selfIndex))&&e.selfIndex>=0}).map(function(e){return e.selfIndex+1});var s=Ht.findIndex(function(e,t){var n;return Te.has(t)&&(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(c.selfIndex))});(a=-1!==s)&&(d=In(s))}else u=[n+1],(a=Te.has(n))&&(d=In(n));return i(v,e({ref:xn.current[n],sx:{mb:1,width:"100%"}},{children:r(v,e({sx:{position:"relative",width:"100%"}},{children:[i(v,e({ref:fn.current[n],sx:e({width:"100%",display:"flex"},a&&d&&{borderRadius:"6px",outline:"2px solid ".concat(d.badgeBorder),outlineOffset:"1px"})},{children:kn({section:t,idx:n,columnKey:"right",colRef:l.createRef(),mb:0,parentNodeId:(null===(o=null==Q?void 0:Q.input_index_map)||void 0===o?void 0:o[1])||""})})),ue&&!fe&&i(v,e({ref:gn.current[n],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(n))}),i("div",{ref:ut,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))};export{K as default};
2
2
  //# sourceMappingURL=CognitiveCompare.js.map
@@ -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;AA0flC,QAAA,MAAM,gBAAgB,+JAUnB,qBAAqB,4CA27FvB,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;AA2flC,QAAA,MAAM,gBAAgB,+JAUnB,qBAAqB,4CAm7FvB,CAAC;AAEF,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAClC,eAAe,gBAAgB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viswa-test/test-citation",
3
- "version": "0.0.40",
3
+ "version": "0.0.41",
4
4
  "author": "Viswa Koduru",
5
5
  "description": "",
6
6
  "license": "MIT",