@viswa-test/test-citation 0.0.44 → 0.0.46

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
- 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 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 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 N from"./LoaderComponent.js";import O 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):h.isOrphan?"No Deviation Found":"N/A"===h.score||"NA"===h.score?"N/A":"Same"})),i(w,{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){if(n.highlight){var i=n.highlight.replace(/\\(['’])/g,"$1");e=e.replace(new RegExp(t(i),"g"),'<span data-badge-id="'.concat(n.id,'"><mark>').concat(i,"</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:[O]},{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,O,K,V,q,X,U,G=t.componentHeaderText,J=void 0===G?"Contract Comparison":G,$=t.treeData,Q=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],we=u(!1),Ie=we[0],Re=we[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),Ne=a(!1),Oe=a(null),We=a({}),ze=a([]),Le=a(!1),je=a(!1),Pe=a(null),Ye=c(function(){return(null==$?void 0:$.cognitive_decisioning)||{}},[$]),Ke=u(null),Ve=Ke[0],qe=Ke[1],Xe=a(null),Ue=u({width:0,height:0}),Ge=Ue[0],Je=Ue[1],$e=c(function(){return e(e({},M),te)},[te]),Qe=u({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,isOrphan:!1,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null,deviationData:null}),Ze=Qe[0],et=Qe[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==Q?void 0:Q.fields)&&void 0!==t?t:k,thresholds:{high:null!==(i=null===(n=null==Q?void 0:Q.thresholds)||void 0===n?void 0:n.high)&&void 0!==i?i:A.thresholds.high,medium:null!==(o=null===(r=null==Q?void 0:Q.thresholds)||void 0===r?void 0:r.medium)&&void 0!==o?o:A.thresholds.medium,exact:null!==(c=null===(l=null==Q?void 0:Q.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==Q?void 0:Q.relationStyles)||void 0===u?void 0:u.noContent)||{}),high:e(e({},A.relationStyles.high),(null===(a=null==Q?void 0:Q.relationStyles)||void 0===a?void 0:a.high)||{}),exact:e(e({},A.relationStyles.exact),(null===(d=null==Q?void 0:Q.relationStyles)||void 0===d?void 0:d.exact)||{}),medium:e(e({},A.relationStyles.medium),(null===(s=null==Q?void 0:Q.relationStyles)||void 0===s?void 0:s.medium)||{}),low:e(e({},A.relationStyles.low),(null===(v=null==Q?void 0:Q.relationStyles)||void 0===v?void 0:v.low)||{})}}},[Q]),mt=c(function(){if($&&Object.keys($).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,w,I,R,C,F,E,B,M;void 0===o&&(o=0);var k=[],A=[];if(!i)return{refSections:k,baseSections:A};var D={},H={},N=-1,O=-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:N--),U=Number(null!==(x=null===(h=K.attributes)||void 0===h?void 0:h.display_index)&&void 0!==x?x:O--),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===(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:[]},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 $=g(L.next,o+1),Q=$.refSections,Z=$.baseSections;Q.length>0&&(G.subsections=n(n([],G.subsections||[],!0),Q,!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:{}}}}]}}($,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($),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({}),Bt=Et[0],_t=Et[1],Tt=(null==bt?void 0:bt[0])||j,Mt=null===(O=null===(o=null==$?void 0:$.documents)||void 0===o?void 0:o[null===(F=null==$?void 0:$.input_index_map)||void 0===F?void 0:F[0]])||void 0===O?void 0:O.title,kt=null===(q=null===(K=null==$?void 0:$.documents)||void 0===K?void 0:K[null===(V=null==$?void 0:$.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]),Nt=c(function(){return Tt.sections||[]},[Tt.sections]),Ot=Ht.length>0||Nt.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==$?void 0:$.documents,input_index_map:null==$?void 0:$.input_index_map},deviationData:t.evaluationResult||n.evaluationResult||null,isOrphan:!!r}},[Ye,$]),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),$t=a(null),Qt=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(!Ot||"description"!==t)&&(B(null==yt?void 0:yt[t])||B(Tt[t]))})},[yt,Tt,Ot,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,Nt.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,Nt.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(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 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]),wn=s(function(t){var n,i,r,o=Ht[t],l=Nt[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:null!=s?s:""}:{label:"N/A"})},[Ht,Nt,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=Nt[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:null!=x?x:""}:{label:"N/A"})},[Ht,Nt,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&&!Ne.current){vt.current=!0;try{if(!Gt.current)return;var w=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},I=Gt.current.getBoundingClientRect();Je({width:I.width,height:I.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")}),!Ne.current){for(var C=0;C<Math.max(Ht.length,Nt.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(w(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(!Ne.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=Nt.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(w(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,Nt.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")}}),Ne.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=Nt.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-I.left,m=g.left-I.left,y=h.top+h.height/2-I.top,b=g.top+g.height/2-I.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,C=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=h.top+h.height/2,B=function(e,t,n){return Math.max(t,Math.min(n,e))};y=B(E,S,C)-I.top,b=B(E,w,F)-I.top}var _=wn(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,Nt.length);C++){var N=null===(c=pn.current[C])||void 0===c?void 0:c.current,O=null===(u=fn.current[C])||void 0===u?void 0:u.current;if(N&&O){var z=N.getBoundingClientRect(),j=O.getBoundingClientRect(),P=Math.max(z.top,j.top)+18-I.top,Y=(null===(a=Nt[C])||void 0===a?void 0:a.id)||"sec-".concat(C);(X=wn(C))&&R.push({id:Y,x1:z.right-I.left,y1:P,x2:j.left-I.left,y2:P,style:X,sectionIdx:C,hasCognitive:!!((null===(d=Ht[C])||void 0===d?void 0:d.cognitiveData)||(null===(s=Nt[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-I.left,$=G.left-I.left,Q=U.top+U.height/2-I.top,Z=G.top+G.height/2-I.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))};Q=re(U.top+U.height/2,ee,ne)-I.top,Z=re(G.top+G.height/2,te,ie)-I.top}(X=In(D))&&R.push({id:"line-subsec-".concat(K),x1:J,y1:Q,x2:$,y2:Z,style:X,sectionIdx:Number(D.split("-")[0]),isSubSection:!0,subSectionKeyPath:K})}}if(nn(R),Qt.current&&Zt.current){var oe=Qt.current.getBoundingClientRect(),le=Zt.current.getBoundingClientRect(),ce=(oe.top+oe.height/2-I.top+le.top+le.height/2-I.top)/2;an({x1:oe.right-I.left,x2:le.left-I.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=I.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=In(c),p=(B=d.right-I.left)+.5*((_=s.left-I.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,w=b-ye,R=h>=fe-4&&h<=ge+4,C="";C=(T=f>=pe-4&&f<=he+4)&&R?L(B,S,_,w):T&&!R?"M ".concat(B,",").concat(S," L ").concat(p,",").concat(S," L ").concat(p,",").concat(w):!T&&R?"M ".concat(p,",").concat(S," L ").concat(p,",").concat(w," L ").concat(_,",").concat(w):"M ".concat(p,",").concat(S," L ").concat(p,",").concat(w),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=Nt.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=wn(e),d=c.right-I.left,s=u.left-I.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,w=p>=pe-4&&p<=he+4,R=f>=fe-4&&f<=ge+4,C="";C=w&&R?L(d,b,s,S):w&&!R?"M ".concat(d,",").concat(b," L ").concat(v,",").concat(b," L ").concat(v,",").concat(S):!w&&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=wn(e),p=(B=d.right-I.left)+.5*((_=s.left-I.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,w=b-ye,R=h>=fe-4&&h<=ge+4,C="";C=(T=f>=pe-4&&f<=he+4)&&R?L(B,S,_,w):T&&!R?"M ".concat(B,",").concat(S," L ").concat(p,",").concat(S," L ").concat(p,",").concat(w):!T&&R?"M ".concat(p,",").concat(S," L ").concat(p,",").concat(w," L ").concat(_,",").concat(w):"M ".concat(p,",").concat(S," L ").concat(p,",").concat(w),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,Nt,Ye,xt,Sn,wn,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&&!Ne.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,w=b+m,I=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,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),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,w=Math.max(0,Math.min(b,S));Math.abs(s.scrollTop-w)>1&&(s.scrollTop=w)}if($t.current){var I=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(I&&R){var M=I.getBoundingClientRect(),k=R.getBoundingClientRect(),A=M.top+M.height/2,D=k.top+k.height/2,H=T(A,F,E),N=T(D,B,_);$t.current.setAttribute("y1",(H-C).toString()),$t.current.setAttribute("y2",(N-C).toString());var O=A>=F-4&&A<=E+4;$t.current.setAttribute("visibility",O?"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,Nt,xt,Bn,be,on,Ie,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=Nt.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 w=st.current,I=lt.current;if(!v||!w)return Ce.current=!1,void he(!1);if(!p||!I)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-w.getBoundingClientRect().top+w.scrollTop,_=p.getBoundingClientRect().top-I.getBoundingClientRect().top+I.scrollTop-(B-w.scrollTop);_<0&&ct.current&&(ct.current.style.height="".concat(Math.abs(_),"px"));requestAnimationFrame(function(){var e,t=I.scrollHeight-I.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(I,_,200,function(){Re(!0),Fn.current(),Ce.current=!1,he(!1)})})}e=_}Y(I,e,200,function(){Re(!0),Fn.current(),Ce.current=!1,he(!1)})})})}},[ht,nt.sectionIdx,be,on,Ht,Nt,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,w=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,_={current:1},T=u.title;R||(T=C?"No Title Found":"No Matching Section Found");var M,k=[];if(null===(c=u.evaluationResult)||void 0===c?void 0:c.deviations){var A=u.evaluationResult.deviations;for(var D in A){var H=A[D][x];H&&k.push(H)}}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&&w,onChange:function(){return!F&&function(t,n){var i,r;Ne.current=!0,Oe.current&&clearTimeout(Oe.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;o&&(o.style.minHeight="0px"),l&&(l.style.minHeight="0px"),Oe.current=setTimeout(function(){Ne.current=!1,Fn.current(),He.current&&(He.current.style.opacity="1")},650),Ft(function(i){var r=e({},i),o=ue?"".concat(n,"-").concat(t):String(t),l=!i[o];if(!l){var c=String(on||""),u=on===t||c.startsWith("".concat(t,"-")),a=!1;Te.forEach(function(e){(e===t||String(e).startsWith("".concat(t,"-")))&&(a=!0)}),(u||a)&&(Yt(),Me(new Set),De([]),ze.current=[])}if(!ue)return r[String(t)]=l,r;if(r[o]=l,"left"===n)((null==(d=Ht[t])?void 0:d.refIndexes)||[]).forEach(function(e){var t=Nt.findIndex(function(t){return t.selfIndex===e});-1!==t&&(r["right-".concat(t)]=l)});else{var d,s=null==(d=Nt[t])?void 0:d.selfIndex;Ht.forEach(function(e,t){var n;(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(s))&&(r["left-".concat(t)]=l)})}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:T,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:(M=T,M?E(M).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:$e,highlights:k,maintainRelativeOrder:ue}),(u.subsections||[]).map(function(e,t){return An({section:e,keyPath:"".concat(a,"-").concat(t),depth:0,columnKey:d,parentNodeId:x,devCounter:_})})]}))]}))}),"".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,w=void 0===m?0:m,R=t.columnKey,C=void 0===R?"left":R,F=t.parentNodeId,E=void 0===F?"":F,_=t.devCounter,T=void 0===_?{current:1}:_,M=(null===(n=g.displayTitle)||void 0===n||n)&&B(g.title),k=(null===(o=g.displayContent)||void 0===o||o)&&B(g.content),A=!M&&!k,D=M?g.title:k?"No Title Found":"No Matching Section Found",H=!!Bt[x];"left"!==C||mn.current[x]||(mn.current[x]=l.createRef()),"right"!==C||yn.current[x]||(yn.current[x]=l.createRef());var N,O="left"===C?mn.current[x]:yn.current[x],L=In(x),j=x.split("-").map(Number),P=Ht[j[0]];N=ue&&void 0!==(null==P?void 0:P.selfIndex)&&P.selfIndex>=0?P.selfIndex+1:j[0]+1;for(var Y=Ht[j[0]],K=Nt[j[0]],V=1;V<j.length;V++)(null==Y?void 0:Y.subsections)&&(Y=Y.subsections[j[V]]),(null==K?void 0:K.subsections)&&(K=K.subsections[j[V]]);var q=null===(c=null==$?void 0:$.input_index_map)||void 0===c?void 0:c[0],X=null===(u=null==$?void 0:$.input_index_map)||void 0===u?void 0:u[1],U="left"===C?X:q,G=ue?!(null===(a=g.refIndexes)||void 0===a?void 0:a.length)||void 0!==g.selfIndex&&g.selfIndex<0:"left"===C?!K:!Y,J=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,Q=Object.entries((null===(h=g.evaluationResult)||void 0===h?void 0:h.deviations)||{}).map(function(e){var t=e[0],n=e[1],i=T.current++,r=n[E],o="No equivalent clause present."===r;if(o)r="";else if(!r)return null;var c=function(e,t){return"".concat(e).concat(W).concat(t)}(x,t),u=n[U],a=G||!u||"No equivalent clause present."===u,d="".concat(N,".").concat(i);return"left"!==C||hn.current[c]||(hn.current[c]=l.createRef()),"right"!==C||gn.current[c]||(gn.current[c]=l.createRef()),{id:c,label:d,highlight:r,side:C,style:L,score:J,isConnected:Te.has(c),isOrphan:a,isMissingClause:o,badgeRef:"left"===C?hn.current[c]:gn.current[c],onClick:function(e){e.stopPropagation(),qt(e,Y||{title:"",content:""},a,K||{title:"",content:""},c,L)}}}).filter(Boolean),Z=Q.some(function(e){return Te.has(e.id)});return M||k||g.subsections&&0!==g.subsections.length?i(v,M?e({ref:O,sx:{mt:1,width:"100%",minWidth:0,position:"relative"}},{children:i(v,e({sx:e({width:"100%"},Z&&L&&{borderRadius:"4px",outline:"2px solid ".concat(L.badgeBorder),outlineOffset:"1px"})},{children:r(y,e({disableGutters:!0,expanded:!A&&H,onChange:function(){if(!A){if(H){var t=String(on||"").startsWith(x);t||Te.forEach(function(e){String(e).startsWith(x)&&(t=!0)}),t&&(Yt(),Me(new Set),De([]),ze.current=[])}_t(function(t){var n;return e(e({},t),((n={})[x]=!t[x],n))})}},sx:{mt:0,boxShadow:"none",border:A?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF",minWidth:0,"&:before":{display:"none"}}},{children:[i(b,e({expandIcon:A?null:i(I,{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:A?"#94A3B8":"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:D||"Untitled Subsection"}))})),!A&&r(S,e({sx:{pt:0,pb:1,minWidth:0}},{children:[k&&i(z,{content:g.content,sxStyles:$e,deviationBadges:Q,maintainRelativeOrder:ue}),(g.subsections||[]).map(function(e,t){return An({section:e,keyPath:"".concat(x,"-").concat(t),depth:w+1,columnKey:C,parentNodeId:E,devCounter:T})})]}))]}))}))}):e({ref:O,sx:{mt:0===w?1:.75,width:"100%",minWidth:0,position:"relative"}},{children:!A&&r(v,e({sx:e({width:"100%"},Z&&L&&{borderRadius:"4px",outline:"2px solid ".concat(L.badgeBorder),outlineOffset:"1px"})},{children:[k&&i(z,{content:g.content,sxStyles:$e,deviationBadges:Q,maintainRelativeOrder:ue}),(g.subsections||[]).map(function(e,t){return An({section:e,keyPath:"".concat(x,"-").concat(t),depth:w+1,columnKey:C,parentNodeId:E,devCounter:T})})]}))}),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(N,{})})),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&&Ie;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:!Nt[t.sectionIdx])||(c=be&&on===t.sectionIdx&&Ie)}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:$t,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=Nt[t.sectionIdx]||{title:"",content:""};if(t.isSubSection&&t.subSectionKeyPath){for(var r=t.subSectionKeyPath.split("-").map(Number),o=Ht[r[0]],l=Nt[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:600,textAlign:"center",whiteSpace:"nowrap",cursor:"pointer"}},{children:[0===t.style.label?"Same":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)}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:Qt,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}}),Ot&&Ht.map(function(t,n){var o,c,u=!t.title&&!t.content;if(ue&&u)return null;var a=t,d=wn(n),s=ue?!(null===(o=a.refIndexes)||void 0===o?void 0:o.length)||a.selfIndex<0:!Nt[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==$?void 0:$.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?Nt.find(function(e){var t;return null===(t=a.refIndexes)||void 0===t?void 0:t.includes(e.selfIndex)})||{title:"",content:""}:Nt[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)})),i(w,{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(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:[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}}),Ot&&Nt.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=wn(s))}else u=[n+1],(a=Te.has(n))&&(d=wn(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==$?void 0:$.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};
1
+ import{__assign as e,__rest as n,__spreadArray as t}from"tslib";import{jsx as i,jsxs as o,Fragment as r}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 p,Alert as h,FormControlLabel as g,Switch as x,Tooltip as m,Accordion as y,AccordionSummary as b,AccordionDetails as I}from"@mui/material";import{EllipsisVertical as S,ChevronDown as w}from"lucide-react";import{ButtonCognitiveIcon as R}from"../../assests/svg/ButtonCognitiveIcon.js";import C from"./OverlayComponent.js";import _ from"react-markdown";import{safeStringify as F,hasValue as E,generateColorPalette as B,getSideData as T,getRationale as M}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as k,DEFAULT_FIELD_CONFIG as A,DEFAULT_COMPARISON_CONFIG as D}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import H from"./CognitivePopup.js";import O from"./MoreFunctionsPopup.js";import N from"./LoaderComponent.js";import W from"rehype-raw";var z="::",L=function(e){if(!e)return!0;var n=e.trim().toLowerCase();return n.includes("no equivalent")||"n/a"===n||"na"===n||"none"===n},j=l.memo(function(t){var l=t.content,u=t.sxStyles,a=t.deviationBadges,d=void 0===a?[]:a,s=t.highlights,p=void 0===s?[]:s,h=t.maintainRelativeOrder,g=void 0===h||h,x=t.highlightBg,m=c(function(){return d.reduce(function(n,t){var i;return e(e({},n),((i={})[t.id]=t,i))},{})},[d]),y=c(function(){return{mark:function(n){var t=n.children;return i("span",e({style:{backgroundColor:x,borderRadius:"2px"}},{children:t}))},span:function(t){var l,c,u,a,d,s=t.children,f=n(t,["children"]),p=f["data-badge-id"];if(!p)return i("span",e({},f,{children:s}));var h=m[p];return h?o(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:o(r,{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&&o(r,{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):"N/A"===h.score||"NA"===h.score?"N/A":"Same"})),i(S,{size:10,color:(null===(d=h.style)||void 0===d?void 0:d.badgeText)||"#3730A3"})]})]})}))]})):i("span",e({},f,{children:s}))}}},[m,g]),b=c(function(){var e=l||"",n={},t=0;return d.forEach(function(i){if(i.highlight){var o=i.highlight.replace(/\\(['’])/g,"$1"),r="__DEV_TOKEN_".concat(t++,"__");n[r]='<span data-badge-id="'.concat(i.id,'"><mark>').concat(o,"</mark></span>"),e=e.replace(o,r)}}),p.forEach(function(i){if(i){var o=i.replace(/\\(['’])/g,"$1"),r="__HL_TOKEN_".concat(t++,"__");n[r]="<mark>".concat(o,"</mark>"),e=e.split(o).join(r)}}),Object.keys(n).forEach(function(t){e=e.split(t).join(n[t])}),e},[l,d,p]);return i(f,e({component:"div",sx:e(e({},u),{position:"relative",overflow:"visible","& p, & li, & ul, & ol":{position:"static",overflow:"visible"}})},{children:i(_,e({components:y,rehypePlugins:[W]},{children:F(b).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;var r=e.deviationBadges||[],l=n.deviationBadges||[];if(r.length!==l.length)return!1;for(o=0;o<r.length;o++){if(r[o].id!==l[o].id)return!1;if(r[o].label!==l[o].label)return!1;if(r[o].isConnected!==l[o].isConnected)return!1}return!0}),P=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 c=l>0?1:-1,u=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-u),"Q ".concat(r," ").concat(n," ").concat(r," ").concat(n+c*u),"V ".concat(i-c*u),"Q ".concat(r," ").concat(i," ").concat(r+u," ").concat(i),"H ".concat(t)].join(" ")},Y={id:"",title:""},K={open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,isOrphan:!1,docData:null,deviationData:null},V="#B91C1C",X=function(e,n,t,i,o){void 0===t&&(t=300);var r=e.style.scrollBehavior;e.style.scrollBehavior="auto";var l=e.scrollTop,c=n-l,u=null,a=function(d){null===u&&(u=d);var s,v=d-u;v<t?(e.scrollTop=(s=v,s/=t,c*(--s*s*s+1)+l),o&&o(),requestAnimationFrame(a)):(e.scrollTop=n,e.style.scrollBehavior=r,o&&o(),i&&i())};requestAnimationFrame(a)},q=function(n){var r,_,W,q,U,$,G,J,Q=n.componentHeaderText,Z=void 0===Q?"Contract Comparison":Q,ee=n.treeData,ne=n.comparisonConfig,te=n.leftColumnTitleText,ie=n.rightColumnTitleText,oe=n.markdownStyles,re=n.displayConfig,le=void 0===re?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1}:re,ce=n.popupConfig,ue=n.deviationData,ae=void 0===ue?{}:ue,de=u(le.maintainRelativeOrder),se=de[0],ve=de[1],fe=u(!1),pe=fe[0],he=fe[1],ge=u(!1),xe=ge[0],me=ge[1],ye=u(null),be=ye[0],Ie=ye[1],Se=u(!1),we=Se[0],Re=Se[1],Ce=u(!1),_e=Ce[0],Fe=Ce[1],Ee=a(!1),Be=u(null),Te=Be[0],Me=Be[1],ke=u(new Set),Ae=ke[0],De=ke[1],He=u([]),Oe=He[0],Ne=He[1],We=a(null),ze=a(!1),Le=a(null),je=a({}),Pe=a([]),Ye=a(!1),Ke=a(!1),Ve=a(null),Xe=c(function(){return(null==ee?void 0:ee.cognitive_decisioning)||{}},[ee]),qe=u(null),Ue=qe[0],$e=qe[1],Ge=a(null),Je=u({width:0,height:0}),Qe=Je[0],Ze=Je[1],en=c(function(){return e(e({},k),oe)},[oe]),nn=u({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,isOrphan:!1,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null,deviationData:null}),tn=nn[0],on=nn[1],rn=u({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,isOrphan:!1,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null,deviationData:null}),ln=rn[0],cn=rn[1],un=a(null),an=a(null),dn=a(null),sn=a(null),vn=a(null),fn=a(null),pn=a(null),hn=a(null),gn=a(!1),xn=a(null);d(function(){xn.current=null},[tn.sectionIdx,tn.open]);var mn=s(function(){$e(null),on(K),Me(null)},[]),yn=s(function(){cn(K)},[]),bn=s(function(){var e;if(tn.anchorEl&&tn.refSectionTitle){var n=tn.anchorEl.getBoundingClientRect(),t=(null===(e=null==Ge?void 0:Ge.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!==xn.current?!0===xn.current&&(l=r>=t||r>=o):l=!(o>=t||o>=r),xn.current=l;var c=l?r:o,u=Math.min(t||9999,c),a=l?n.top-12-u:n.bottom+12,d=n.left+n.width/2,s=d-i/2,v=Math.max(12,Math.min(s,window.innerWidth-i-12)),f=Math.max(14,Math.min(d-v,i-10-4));$e({top:a,left:v,arrowLeft:f,openAbove:l,maxHeight:c})}},[tn.anchorEl,tn.refSectionTitle]);d(function(){if(tn.open){window.addEventListener("resize",bn);var e=requestAnimationFrame(bn),n=null;return Ge.current&&(n=new ResizeObserver(function(){cancelAnimationFrame(e),e=requestAnimationFrame(bn)})).observe(Ge.current),function(){cancelAnimationFrame(e),window.removeEventListener("resize",bn),n&&n.disconnect()}}},[tn.open,bn]),d(function(){var e=un.current;if(e&&tn.open){var n=function(e){Ge.current&&Ge.current.contains(e.target)||($e(null),mn())};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})}}},[tn.open,mn]),d(function(){var e=un.current;if(e&&ln.open){var n=function(){yn()};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})}}},[ln.open,yn]);var In=c(function(){var e,n,t,i,o,r,l;return{fields:null!==(e=null==ne?void 0:ne.fields)&&void 0!==e?e:A,thresholds:{high:null!==(t=null===(n=null==ne?void 0:ne.thresholds)||void 0===n?void 0:n.high)&&void 0!==t?t:D.thresholds.high,medium:null!==(o=null===(i=null==ne?void 0:ne.thresholds)||void 0===i?void 0:i.medium)&&void 0!==o?o:D.thresholds.medium,exact:null!==(l=null===(r=null==ne?void 0:ne.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:D.thresholds.exact}}},[ne]),Sn=c(function(){if(ee&&Object.keys(ee).length>0)try{var n=function(n,i,o){var r,l,c,u;void 0===i&&(i=!1),void 0===o&&(o=null);var a=n.nodes||n,d=[],s=[],v=n.base_root_id,f=n.input_index_map||{0:"left",1:"right"},p=n[v]||a[v];if(!p||!1===p.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[]};var h=function(t,i){var r,l,c,u=n[t]||a[t];if(!u||!1===u.display_node)return null;var d=T(u,i,f),s=!1!==(null===(r=d.attributes)||void 0===r?void 0:r.display_title),v=!1!==(null===(l=d.attributes)||void 0===l?void 0:l.display_content),p=!!d.title.trim(),g=!!d.content.trim(),x=M(u),m=(null===(c=null==o?void 0:o[t])||void 0===c?void 0:c.evaluation_result)||u.evaluation_result||null,y=[];u.next&&Object.values(u.next).forEach(function(e){var n=a[e];if(n&&!1!==n.display_node){var t=h(e,i);t&&y.push(t)}});var b=!(!p&&!g);return e(e({id:t,title:p?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,r){var l,c,u,d,s,v,p,h,x,m,y,b,I,S,w,R,C,_,F,E,B;void 0===r&&(r=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=n[z]||a[z];if(L&&!1!==L.display_node){var j=M(L),P=(null===(l=null==o?void 0:o[z])||void 0===l?void 0:l.evaluation_result)||L.evaluation_result||null,Y=T(L,"1",f),K=T(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!==(p=null===(v=Y.attributes)||void 0===v?void 0:v.display_index)&&void 0!==p?p:O--),U=Number(null!==(x=null===(h=K.attributes)||void 0===h?void 0:h.display_index)&&void 0!==x?x:N--),$=D[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===(I=Y.attributes)||void 0===I?void 0:I.display_title}),G=H[U]||e(e({id:z,title:!1!==(null===(S=K.attributes)||void 0===S?void 0:S.display_title)?K.title:"",content:!1!==(null===(w=K.attributes)||void 0===w?void 0:w.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===(_=$.refIndexes)||void 0===_?void 0:_.includes(Number(U)))||null===(F=$.refIndexes)||void 0===F||F.push(Number(U)),(null===(E=G.refIndexes)||void 0===E?void 0:E.includes(Number(q)))||null===(B=G.refIndexes)||void 0===B||B.push(Number(q))),D[q]=$,H[U]=G;var J=g(L.next,r+1),Q=J.refSections,Z=J.baseSections;Q.length>0&&($.subsections=t(t([],$.subsections||[],!0),Q,!0)),Z.length>0&&(G.subsections=t(t([],G.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,n){return e.selfIndex<0&&n.selfIndex>=0?1:e.selfIndex>=0&&n.selfIndex<0?-1:e.selfIndex-n.selfIndex}),A.sort(function(e,n){return e.selfIndex<0&&n.selfIndex>=0?1:e.selfIndex>=0&&n.selfIndex<0?-1:e.selfIndex-n.selfIndex}),{refSections:k,baseSections:A}},x=g(p.next),m=x.refSections,y=x.baseSections;s=m,d=y}else p.next&&Object.values(p.next).forEach(function(e){var t=n[e]||a[e];t&&!1!==t.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===(r=p.comparison_inputs)||void 0===r?void 0:r[f[0]])||void 0===l?void 0:l.title)||"Uploaded Contract",description:p.decision_scope_description||"",sections:d},activeVariants:[{id:"tree-variant-1",title:(null===(u=null===(c=p.comparison_inputs)||void 0===c?void 0:c[f[1]])||void 0===u?void 0:u.title)||"Reference Template",similarity:0,sections:s,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:p.decision_scope_description||""},fields:{}}}}]}}(ee,se,ae);return e(e({},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(ee),se,JSON.stringify(ae)]),wn=Sn.activeProposed,Rn=Sn.activeVariants,Cn=Sn.parseError;d(function(){Cn&&Ie("Failed to load comparison: ".concat(Cn))},[Cn]);var _n=u(null),Fn=_n[0];_n[1];var En=u({}),Bn=En[0],Tn=En[1],Mn=u({}),kn=Mn[0],An=Mn[1],Dn=(null==Rn?void 0:Rn[0])||Y,Hn=null===(W=null===(r=null==ee?void 0:ee.documents)||void 0===r?void 0:r[null===(_=null==ee?void 0:ee.input_index_map)||void 0===_?void 0:_[0]])||void 0===W?void 0:W.title,On=null===($=null===(q=null==ee?void 0:ee.documents)||void 0===q?void 0:q[null===(U=null==ee?void 0:ee.input_index_map)||void 0===U?void 0:U[1]])||void 0===$?void 0:$.title,Nn=F(te||Hn||"Uploaded Contract"),Wn=F(ie||On||"Reference Template"),zn=c(function(){return(null==wn?void 0:wn.sections)||[]},[null==wn?void 0:wn.sections]),Ln=c(function(){return Dn.sections||[]},[Dn.sections]),jn=zn.length>0||Ln.length>0,Pn=Dn.analysis,Yn=F(null===(J=null===(G=null==Pn?void 0:Pn.rule_difference_comparison)||void 0===G?void 0:G.summary)||void 0===J?void 0:J.overall_summary),Kn=!!Yn.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),Vn=c(function(){var e,n,t={},i={},o=null===(e=null==ee?void 0:ee.input_index_map)||void 0===e?void 0:e[0],r=null===(n=null==ee?void 0:ee.input_index_map)||void 0===n?void 0:n[1],l=new Map,c=function(e){return e&&e.id?(l.has(e.id)||l.set(e.id,F(e.content||"").replace(/\\n/g,"\n")),l.get(e.id)):""},u=function(e,n,a,d,s){var v,f,p,h,g,x,m,y;e&&!s&&function(e,n,u,a){var d,s=(null===(d=null==e?void 0:e.evaluationResult)||void 0===d?void 0:d.deviations)||{};Object.keys(s).sort().forEach(function(d){var v=s[d];if(v){var f=v[o],p=v[r],h=!1,g=!1;if(!L(f)){var x=f.replace(/\\(['’])/g,"$1").replace(/\\n/g,"\n");if(n&&x){var m=c(n);m.includes(x)&&(h=!0,l.set(n.id,m.replace(x,"__TOKEN__")))}}if(!L(p)){var y=p.replace(/\\(['’])/g,"$1").replace(/\\n/g,"\n");if(u&&y){var b=c(u);b.includes(y)&&(g=!0,l.set(u.id,b.replace(y,"__TOKEN__")))}}if(h||g){var I="".concat(e.id).concat(z).concat(d);void 0===t[I]&&(void 0===i[a]&&(i[a]=1),t[I]=i[a]++)}}})}(e,n,a,d);for(var b=Math.max((null===(v=null==n?void 0:n.subsections)||void 0===v?void 0:v.length)||0,(null===(f=null==a?void 0:a.subsections)||void 0===f?void 0:f.length)||0,(null===(p=null==e?void 0:e.subsections)||void 0===p?void 0:p.length)||0),I=0;I<b;I++)u((null===(h=null==e?void 0:e.subsections)||void 0===h?void 0:h[I])||(null===(g=null==n?void 0:n.subsections)||void 0===g?void 0:g[I])||(null===(x=null==a?void 0:a.subsections)||void 0===x?void 0:x[I]),null===(m=null==n?void 0:n.subsections)||void 0===m?void 0:m[I],null===(y=null==a?void 0:a.subsections)||void 0===y?void 0:y[I],d,!1)};return zn.forEach(function(e,n){var t,i=n+1;se&&void 0!==e.selfIndex&&e.selfIndex>=0&&(i=e.selfIndex+1);var o=null;if(se){var r=null===(t=e.refIndexes)||void 0===t?void 0:t[0];o=Ln.find(function(e){return e.selfIndex===r})}else o=Ln[n];u(e,e,o,i,!0)}),Ln.forEach(function(e,n){var t,i=n+1,o=!1;if(se){var r=null===(t=e.refIndexes)||void 0===t?void 0:t[0],l=zn.find(function(e){return e.selfIndex===r});l&&void 0!==l.selfIndex&&l.selfIndex>=0?i=l.selfIndex+1:(o=!0,void 0!==e.selfIndex&&e.selfIndex>=0&&(i=e.selfIndex+1))}else n>=zn.length&&(o=!0);o&&u(e,null,e,i,!0)}),t},[zn,Ln,se,ee]),Xn=a({}),qn=function(e){return Xn.current[e]||(Xn.current[e]=l.createRef()),Xn.current[e]},Un=s(function(){var e,n,t,i;Re(!1),Ke.current=!1;var o=Ve.current,r=nt.current;if(null!==o)if("string"==typeof o&&o.includes(z)){var l=o.split(z);(c=null===(e=St.current[l[2]])||void 0===e?void 0:e.current)&&(c.style.paddingTop="0px")}else{var c;(c=null===(n=xt.current[o])||void 0===n?void 0:n.current)&&(c.style.paddingTop="0px")}if(null!==r)if("string"==typeof r&&r.includes(z)){l=r.split(z);(u=null===(t=wt.current[l[3]])||void 0===t?void 0:t.current)&&(u.style.paddingTop="0px")}else{var u;(u=null===(i=mt.current[r])||void 0===i?void 0:i.current)&&(u.style.paddingTop="0px")}dt(null),Ve.current=null,nt.current=null,Fe(!1),me(!1),sn.current&&(sn.current.style.height="0px"),vn.current&&(vn.current.style.height="0px"),fn.current&&(fn.current.style.height="0px"),pn.current&&(pn.current.style.height="0px")},[]),$n=s(function(e,n,t,i,o,r){var l,c,u=F(n.id)||F(t.id)||"",a=(u?Xe[u]:null)||n.cognitiveData||t.cognitiveData||{section_id:u,decisioning:[],gap:[],relevance_score:0},d=null!==(c=null===(l=Xn.current[i])||void 0===l?void 0:l.current)&&void 0!==c?c:null;return{open:!0,sectionTitle:n.displayTitle?n.title:"no title",refSectionTitle:n.displayTitle?n.title:"no title",cognitiveData:a,anchorEl:e,sectionAnchorEl:d,badgeStyle:r||null,sectionIdx:i,docData:{documents:null==ee?void 0:ee.documents,input_index_map:null==ee?void 0:ee.input_index_map},deviationData:n.evaluationResult||t.evaluationResult||null,isOrphan:!!o}},[Xe,ee]),Gn=s(function(e){yn(),$e(null),on(e)},[yn]),Jn=function(e,n,t,i,o,r){e.stopPropagation(),ln.open&&ln.sectionIdx===o?yn():(mn(),cn($n(e.currentTarget,n,i,o,t,r)))},Qn=s(function(){null!==ln.sectionIdx&&ln.anchorEl?Gn(e(e({},ln),{open:!0})):yn()},[ln,yn,Gn]),Zn=s(function(){var e=ln.sectionIdx,n=ln.isOrphan;yn(),null!==e&&(n?Ie("No counterpart exists to connect to."):(Ke.current&&Un(),De(function(n){return n.has(e)?new Set:new Set([e])})))},[ln.sectionIdx,yn,Un]),et=a(null),nt=a(null),tt=a(null),it=a(null),ot=a(null),rt=u([]),lt=rt[0],ct=rt[1],ut=u(null),at=ut[0],dt=ut[1];a(null);var st=u(null),vt=st[0],ft=st[1],pt=c(function(){return In.fields.filter(function(e){var n=e.key;return(!jn||"description"!==n)&&(E(null==wn?void 0:wn[n])||E(Dn[n]))})},[wn,Dn,jn,In.fields]),ht=a({}),gt=a({}),xt=a({}),mt=a({}),yt=a({}),bt=a({}),It=a({}),St=a({}),wt=a({});pt.forEach(function(e){for(var n=e.key,t=0;t<Math.max(zn.length,Ln.length);t+=1)xt.current[t]||(xt.current[t]=l.createRef()),mt.current[t]||(mt.current[t]=l.createRef()),yt.current[t]||(yt.current[t]=l.createRef()),bt.current[t]||(bt.current[t]=l.createRef()),It.current[t]||(It.current[t]=l.createRef());ht.current[n]||(ht.current[n]=l.createRef()),gt.current[n]||(gt.current[n]=l.createRef())});for(var Rt=0;Rt<Math.max(zn.length,Ln.length);Rt+=1)xt.current[Rt]||(xt.current[Rt]=l.createRef()),mt.current[Rt]||(mt.current[Rt]=l.createRef()),yt.current[Rt]||(yt.current[Rt]=l.createRef()),bt.current[Rt]||(bt.current[Rt]=l.createRef()),It.current[Rt]||(It.current[Rt]=l.createRef());d(function(){if(Fn){var e=In.fields.find(function(e){return e.analysisKey===Fn||e.key===Fn});if(e){var n=ht.current[e.key]||gt.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[Fn,In.fields]);var Ct=s(function(e){var n,t,i,o,r,l,c,u,a,d=null===(n=null==Pn?void 0:Pn.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!d||!d[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var s=d[e],v=(null==s?void 0:s.relation)||(null===(i=null===(t=null==s?void 0:s.highlights)||void 0===t?void 0:t.ruleA_spans)||void 0===i?void 0:i.length)||(null===(r=null===(o=null==s?void 0:s.highlights)||void 0===o?void 0:o.ruleB_spans)||void 0===r?void 0:r.length)||(null==s?void 0:s.mappings)&&s.mappings.length>0;if(s.mappings){var 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}},[Pn]),_t=s(function(n){var t,i,o,r,l,c,u,a=zn[n],d=Ln[n],s=(null==a?void 0:a.relation)&&"not_defined"!==a.relation,v=(null==d?void 0:d.relation)&&"not_defined"!==d.relation;F(null==a?void 0:a.id)||F(null==d?void 0:d.id);var f=!(!(null==a?void 0:a.cognitiveData)&&!(null==d?void 0:d.cognitiveData));if(!s&&!v&&!f)return e(e({},B(V)),{label:"Not Defined"});var p=null!==(i=null!==(t=null==a?void 0:a.evaluationResult)&&void 0!==t?t:null==d?void 0:d.evaluationResult)&&void 0!==i?i:null,h=null===(o=null==p?void 0:p.evaluation_outputs)||void 0===o?void 0:o.output_value,g=null!==(c=null===(l=null===(r=null==p?void 0:p.evaluation_outputs)||void 0===r?void 0:r.metadata)||void 0===l?void 0:l.label_color)&&void 0!==c?c:V;return e(e({},B(g)),null!=p?{label:null!==(u=h)&&void 0!==u?u:""}:{label:"N/A"})},[zn,Ln,Xe,In,Ct]),Ft=s(function(n){for(var t,i,o,r,l,c,u,a,d,s=n.split("-").map(Number),v=zn[s[0]],f=Ln[s[0]],p=1;p<s.length;p++)(null==v?void 0:v.subsections)&&(v=v.subsections[s[p]]),(null==f?void 0:f.subsections)&&(f=f.subsections[s[p]]);if(!v&&!f)return null;var h=(null==v?void 0:v.relation)&&"not_defined"!==v.relation,g=(null==f?void 0:f.relation)&&"not_defined"!==f.relation,x=F(null==v?void 0:v.id)||F(null==f?void 0:f.id)||"",m=!(!(null==v?void 0:v.cognitiveData)&&!(null==f?void 0:f.cognitiveData));if(!h&&!g&&!m)return e(e({},B(V)),{label:"Not Defined"});null!==(i=null!==(t=null==v?void 0:v.cognitiveRelevanceScore)&&void 0!==t?t:null==f?void 0:f.cognitiveRelevanceScore)&&void 0!==i||x&&(null===(o=Xe[x])||void 0===o||o.relevance_score);var y=null!==(l=null!==(r=null==v?void 0:v.evaluationResult)&&void 0!==r?r:null==f?void 0:f.evaluationResult)&&void 0!==l?l:null,b=null===(c=null==y?void 0:y.evaluation_outputs)||void 0===c?void 0:c.output_value,I=null!==(d=null===(a=null===(u=null==y?void 0:y.evaluation_outputs)||void 0===u?void 0:u.metadata)||void 0===a?void 0:a.label_color)&&void 0!==d?d:V;return e(e({},B(I)),null!=y?{label:null!=b?b:""}:{label:"N/A"})},[zn,Ln,Xe,In]),Et=s(function(){var e,n,t,i,o,r,l,c,u,a,d,s,v,f,p,h,g,x,m,y,b,I;if(!gn.current&&!ze.current){gn.current=!0;try{if(!et.current)return;var S=function(e){var n=e.split("-"),t=n[0];if(!Bn[t]&&!1===se)return!1;if(se&&!Bn["left-".concat(t)]&&!Bn["right-".concat(t)]&&!Bn[t])return!1;for(var i=t,o=1;o<n.length-1;o++)if(i+="-".concat(n[o]),!kn[i])return!1;return!0},w=et.current.getBoundingClientRect();Ze({width:w.width,height:w.height});var R=[];if(pt.forEach(function(e){var n,t,i=e.key,o=null===(n=ht.current[i])||void 0===n?void 0:n.current,r=null===(t=gt.current[i])||void 0===t?void 0:t.current;o&&r&&(o.style.height="auto",r.style.height="auto",o.style.minHeight="0px",r.style.minHeight="0px")}),!ze.current){for(var C=0;C<Math.max(zn.length,Ln.length);C++){var _=null===(e=xt.current[C])||void 0===e?void 0:e.current,F=null===(n=mt.current[C])||void 0===n?void 0:n.current;_&&(_.style.height="auto",_.style.minHeight="0px"),F&&(F.style.height="auto",F.style.minHeight="0px")}se||Object.keys(St.current).forEach(function(e){var n,t;if(S(e)){var i=null===(n=St.current[e])||void 0===n?void 0:n.current,o=null===(t=wt.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 E={};pt.forEach(function(e){var n,t,i=e.key,o=null===(n=ht.current[i])||void 0===n?void 0:n.current,r=null===(t=gt.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),c=r.getBoundingClientRect();E[i]=Math.max(l.height,c.height)}});var B={left:{},right:{}},T={};if(!ze.current)if(se){if(we&&null!==at)if("number"==typeof at){var M=at,k=zn[M],A=null===(o=xt.current[M])||void 0===o?void 0:o.current;A&&k&&(k.refIndexes||[]).forEach(function(e){var n,t=Ln.findIndex(function(n){return n.selfIndex===e}),i=null===(n=mt.current[t])||void 0===n?void 0:n.current;if(i&&(Bn["left-".concat(M)]||Bn["right-".concat(t)])){var o=Math.max(A.getBoundingClientRect().height,i.getBoundingClientRect().height);B.left[M]=Math.max(B.left[M]||0,o),B.right[t]=Math.max(B.right[t]||0,o)}})}else{var D=at.split(z)[2];if(D){_=null===(r=St.current[D])||void 0===r?void 0:r.current,F=null===(l=wt.current[D])||void 0===l?void 0:l.current;if(_&&F){H=Math.max(_.getBoundingClientRect().height,F.getBoundingClientRect().height);T[D]=Math.max(T[D]||0,H)}}}}else{Object.keys(St.current).forEach(function(e){var n,t;if(S(e)){var i=null===(n=St.current[e])||void 0===n?void 0:n.current,o=null===(t=wt.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(),c=Math.max(r.height,l.height);T[e]=c,i.style.minHeight="".concat(c,"px"),o.style.minHeight="".concat(c,"px")}}});for(C=0;C<Math.min(zn.length,Ln.length);C++){var _=null===(t=xt.current[C])||void 0===t?void 0:t.current,F=null===(i=mt.current[C])||void 0===i?void 0:i.current;if(_&&F){var H=Math.max(_.getBoundingClientRect().height,F.getBoundingClientRect().height);B.left[C]=H,B.right[C]=H}}}if(pt.forEach(function(e){var n,t,i=e.key,o=null===(n=ht.current[i])||void 0===n?void 0:n.current,r=null===(t=gt.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=E[i];o.style.minHeight="".concat(l,"px"),r.style.minHeight="".concat(l,"px")}}),ze.current||(Object.entries(B.left).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=xt.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),Object.entries(B.right).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=mt.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),se||Object.keys(T).forEach(function(e){var n,t,i=null===(n=St.current[e])||void 0===n?void 0:n.current,o=null===(t=wt.current[e])||void 0===t?void 0:t.current;if(i&&o&&T[e]){var r=T[e];i.style.minHeight="".concat(r,"px"),o.style.minHeight="".concat(r,"px")}})),se)zn.forEach(function(e,n){var t;(null===(t=xt.current[n])||void 0===t?void 0:t.current)&&(e.refIndexes||[]).forEach(function(e){var t,i,o,r,l,c,u,a,d,s,v=Ln.findIndex(function(n){return n.selfIndex===e});if(-1!==v){var f=null===(t=yt.current[n])||void 0===t?void 0:t.current,p=null===(i=bt.current[v])||void 0===i?void 0:i.current;if(f&&p){var h=f.getBoundingClientRect(),g=p.getBoundingClientRect(),x=h.right-w.left,m=g.left-w.left,y=h.top+h.height/2-w.top,b=g.top+g.height/2-w.top;if(we&&at===n){var I=null!==(r=null===(o=hn.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==r?r:0,S=null!==(c=null===(l=dn.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==c?c:0,C=I+(null!==(a=null===(u=hn.current)||void 0===u?void 0:u.clientHeight)&&void 0!==a?a:1/0),_=S+(null!==(s=null===(d=dn.current)||void 0===d?void 0:d.clientHeight)&&void 0!==s?s:1/0),F=h.top+h.height/2,E=function(e,n,t){return Math.max(n,Math.min(t,e))};y=E(F,I,C)-w.top,b=E(F,S,_)-w.top}var B=_t(n);B&&R.push({id:"line-".concat(n,"-").concat(v),x1:x,y1:y,x2:m,y2:b,style:B,sectionIdx:n,targetRightIdx:v})}}})});else for(C=0;C<Math.min(zn.length,Ln.length);C++){var O=null===(c=xt.current[C])||void 0===c?void 0:c.current,N=null===(u=mt.current[C])||void 0===u?void 0:u.current;if(O&&N){var W=O.getBoundingClientRect(),L=N.getBoundingClientRect(),j=Math.max(W.top,L.top)+18-w.top,Y=(null===(a=Ln[C])||void 0===a?void 0:a.id)||"sec-".concat(C);(J=_t(C))&&R.push({id:Y,x1:W.right-w.left,y1:j,x2:L.left-w.left,y2:j,style:J,sectionIdx:C,hasCognitive:!!((null===(d=zn[C])||void 0===d?void 0:d.cognitiveData)||(null===(s=Ln[C])||void 0===s?void 0:s.cognitiveData)||Y&&Xe[Y]),isSubSection:!1})}}if(we&&"string"==typeof at&&at.includes(z)){var K=at.split(z),V=K[0],X=K[1],q=K[2],U=(K[3],"".concat(V).concat(z).concat(X)),$=null===(v=yt.current[U])||void 0===v?void 0:v.current,G=null===(f=bt.current[U])||void 0===f?void 0:f.current;if($&&G){var J,Q=$.getBoundingClientRect(),Z=G.getBoundingClientRect(),ee=Q.right-w.left,ne=Z.left-w.left,te=Q.top+Q.height/2-w.top,ie=Z.top+Z.height/2-w.top;if(se){var oe=null!==(h=null===(p=hn.current)||void 0===p?void 0:p.getBoundingClientRect().top)&&void 0!==h?h:0,re=null!==(x=null===(g=dn.current)||void 0===g?void 0:g.getBoundingClientRect().top)&&void 0!==x?x:0,le=oe+(null!==(y=null===(m=hn.current)||void 0===m?void 0:m.clientHeight)&&void 0!==y?y:1/0),ce=re+(null!==(I=null===(b=dn.current)||void 0===b?void 0:b.clientHeight)&&void 0!==I?I:1/0),ue=function(e,n,t){return Math.max(n,Math.min(t,e))};te=ue(Q.top+Q.height/2,oe,le)-w.top,ie=ue(Z.top+Z.height/2,re,ce)-w.top}(J=Ft(q))&&R.push({id:"line-subsec-".concat(U),x1:ee,y1:te,x2:ne,y2:ie,style:J,sectionIdx:Number(q.split("-")[0]),isSubSection:!0,subSectionKeyPath:at})}}if(ct(R),it.current&&ot.current){var ae=it.current.getBoundingClientRect(),de=ot.current.getBoundingClientRect(),ve=(ae.top+ae.height/2-w.top+de.top+de.height/2-w.top)/2;ft({x1:ae.right-w.left,x2:de.left-w.left,y:ve})}else ft(null);if(Ae.size>0){var fe=[],pe=hn.current,he=dn.current;if(pe&&he){var ge=[],xe=pe.getBoundingClientRect().top,me=he.getBoundingClientRect().top,ye=xe+pe.clientHeight,be=me+he.clientHeight,Ie=pe.scrollTop,Se=he.scrollTop,Re=w.top,Ce=function(e,n,t){return Math.max(n,Math.min(t,e))};Ae.forEach(function(e){var n,t,i,o,r;if("string"==typeof e&&e.includes(z)){var l=e.split(z),c=l[0],u=l[1],a=l[2],d=(l[3],"".concat(c).concat(z).concat(u)),s=null===(n=yt.current[d])||void 0===n?void 0:n.current,v=null===(t=bt.current[d])||void 0===t?void 0:t.current;if(!s||!v)return;var f=s.getBoundingClientRect(),p=v.getBoundingClientRect(),h=Ft(a),g=(A=f.right-w.left)+.5*((D=p.left-w.left-0)-A),x=f.top+f.height/2,m=p.top+p.height/2,y=x-xe+Ie,b=m-me+Se,I="conn-subsec-".concat(d);ge.push({lhsScrollY:y,rhsScrollY:b,x1:A,x2:D,containerTop:Re,leftIdx:e,rhsArrayIdx:e,styleColor:(null==h?void 0:h.badgeBorder)||"#6366F1",styleId:I});var S=Ce(x,xe,ye),R=Ce(m,me,be),C=S-Re,_=R-Re,F=m>=me-4&&m<=be+4,E="";E=(H=x>=xe-4&&x<=ye+4)&&F?P(A,C,D,_):H&&!F?"M ".concat(A,",").concat(C," L ").concat(g,",").concat(C," L ").concat(g,",").concat(_):!H&&F?"M ".concat(g,",").concat(C," L ").concat(g,",").concat(_," L ").concat(D,",").concat(_):"M ".concat(g,",").concat(C," L ").concat(g,",").concat(_),fe.push({id:I,pathD:E,style:h,leftIdx:e,rhsArrayIdx:e})}else if(se){var B=e,T=zn[B];if(!(null===(r=null==T?void 0:T.refIndexes)||void 0===r?void 0:r.length))return;T.refIndexes.forEach(function(e){var n,t,i=Ln.findIndex(function(n){return n.selfIndex===e});if(-1!==i){var o=null===(n=yt.current[B])||void 0===n?void 0:n.current,r=null===(t=bt.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),c=r.getBoundingClientRect(),u=_t(B),a=l.right-w.left,d=c.left-w.left-0,s=a+.5*(d-a),v=l.top+l.height/2,f=c.top+c.height/2,p=v-xe+Ie,h=f-me+Se,g="conn-".concat(B,"-").concat(i);ge.push({lhsScrollY:p,rhsScrollY:h,x1:a,x2:d,containerTop:Re,leftIdx:B,rhsArrayIdx:i,styleColor:(null==u?void 0:u.badgeBorder)||"#6366F1",styleId:g});var x=Ce(v,xe,ye),m=Ce(f,me,be),y=x-Re,b=m-Re,I=v>=xe-4&&v<=ye+4,S=f>=me-4&&f<=be+4,R="";R=I&&S?P(a,y,d,b):I&&!S?"M ".concat(a,",").concat(y," L ").concat(s,",").concat(y," L ").concat(s,",").concat(b):!I&&S?"M ".concat(s,",").concat(y," L ").concat(s,",").concat(b," L ").concat(d,",").concat(b):"M ".concat(s,",").concat(y," L ").concat(s,",").concat(b),fe.push({id:g,pathD:R,style:u,leftIdx:B,rhsArrayIdx:i})}}})}else{var M=e,k=M;s=null===(i=yt.current[M])||void 0===i?void 0:i.current,v=null===(o=bt.current[k])||void 0===o?void 0:o.current;if(!s||!v)return;var A,D;f=s.getBoundingClientRect(),p=v.getBoundingClientRect(),h=_t(M),g=(A=f.right-w.left)+.5*((D=p.left-w.left-0)-A),x=f.top+f.height/2,m=p.top+p.height/2,y=x-xe+Ie,b=m-me+Se,I="conn-".concat(M,"-").concat(k);ge.push({lhsScrollY:y,rhsScrollY:b,x1:A,x2:D,containerTop:Re,leftIdx:M,rhsArrayIdx:k,styleColor:(null==h?void 0:h.badgeBorder)||"#6366F1",styleId:I});var H;S=Ce(x,xe,ye),R=Ce(m,me,be),C=S-Re,_=R-Re,F=m>=me-4&&m<=be+4,E="";E=(H=x>=xe-4&&x<=ye+4)&&F?P(A,C,D,_):H&&!F?"M ".concat(A,",").concat(C," L ").concat(g,",").concat(C," L ").concat(g,",").concat(_):!H&&F?"M ".concat(g,",").concat(C," L ").concat(g,",").concat(_," L ").concat(D,",").concat(_):"M ".concat(g,",").concat(C," L ").concat(g,",").concat(_),fe.push({id:I,pathD:E,style:h,leftIdx:M,rhsArrayIdx:k})}}),Pe.current=ge}Ne(fe)}else Ne([]),Pe.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{gn.current=!1}}},[pt,zn,Ln,Xe,In,Ct,_t,se,we,at,Ae,Bn,kn]),Bt=s(function(){var e,n,t,i,o,r,l,c,u,a,d,s,v,f,p=Pe.current;if(p.length&&!ze.current){var h=null!==(n=null===(e=hn.current)||void 0===e?void 0:e.scrollTop)&&void 0!==n?n:0,g=null!==(i=null===(t=dn.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,x=null!==(r=null===(o=hn.current)||void 0===o?void 0:o.clientHeight)&&void 0!==r?r:1/0,m=null!==(c=null===(l=dn.current)||void 0===l?void 0:l.clientHeight)&&void 0!==c?c:1/0,y=null!==(a=null===(u=hn.current)||void 0===u?void 0:u.getBoundingClientRect().top)&&void 0!==a?a:0,b=null!==(s=null===(d=dn.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==s?s:0,I=y+x,S=b+m,w=null!==(f=null===(v=et.current)||void 0===v?void 0:v.getBoundingClientRect().top)&&void 0!==f?f:0,R=function(e,n,t){return Math.max(n,Math.min(t,e))};p.forEach(function(e){var n=e.lhsScrollY-h+y,t=e.rhsScrollY-g+b,i=je.current[e.styleId+"-stroke"],o=je.current[e.styleId+"-bg"];if(i||o){var r,l=R(n,y,I),c=R(t,b,S),u=l-w,a=c-w,d=n>=y-4&&n<=I+4,s=t>=b-4&&t<=S+4,v=e.x1+.5*(e.x2-e.x1);r=d&&s?P(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",r)),o&&(o.setAttribute("visibility","visible"),o.setAttribute("d",r))}})}},[]),Tt=a(Et);d(function(){Tt.current=Et},[Et]);var Mt=a(null),kt=s(function(){null!==Mt.current&&clearTimeout(Mt.current),Mt.current=setTimeout(function(){Tt.current(),Mt.current=null},50)},[]),At=s(function(e){var n,t,i,o,r,l,c,u,a,d;if(!Ee.current){if(se||kt(),Ke.current){var s=Ve.current,v=nt.current,f=hn.current,p=dn.current;if(null!==s&&null!==v&&f&&p){var h="string"==typeof s&&s.includes(z)?null===(n=yt.current["".concat(s.split(z)[0]).concat(z).concat(s.split(z)[1])])||void 0===n?void 0:n.current:null===(t=Xn.current[s])||void 0===t?void 0:t.current,g="string"==typeof v&&v.includes(z)?null===(i=bt.current["".concat(v.split(z)[0]).concat(z).concat(v.split(z)[1])])||void 0===i?void 0:i.current:null===(o=It.current[v])||void 0===o?void 0:o.current;if(h&&g){var x=h.getBoundingClientRect().top-f.getBoundingClientRect().top+f.scrollTop,m=g.getBoundingClientRect().top-p.getBoundingClientRect().top+p.scrollTop;if(e.currentTarget===f){var y=m-(x-f.scrollTop),b=p.scrollHeight-p.clientHeight,I=Math.max(0,Math.min(y,b));Math.abs(p.scrollTop-I)>1&&(p.scrollTop=I)}else if(e.currentTarget===p){var S=x-(m-p.scrollTop),w=f.scrollHeight-f.clientHeight,R=Math.max(0,Math.min(S,w));Math.abs(f.scrollTop-R)>1&&(f.scrollTop=R)}if(tt.current){var C=void 0,_=void 0;if("string"==typeof s&&s.includes(z)){var F=s.split(z),E="".concat(F[0]).concat(z).concat(F[1]);C=null===(r=yt.current[E])||void 0===r?void 0:r.current,_=null===(l=bt.current[E])||void 0===l?void 0:l.current}else C=null===(c=yt.current[s])||void 0===c?void 0:c.current,_=null===(u=bt.current[v])||void 0===u?void 0:u.current;var B=null!==(d=null===(a=et.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==d?d:0,T=f.getBoundingClientRect().top,M=T+f.clientHeight,k=p.getBoundingClientRect().top,A=k+p.clientHeight,D=function(e,n,t){return Math.max(n,Math.min(t,e))};if(C&&_){var H=C.getBoundingClientRect(),O=_.getBoundingClientRect(),N=H.top+H.height/2,W=O.top+O.height/2,L=D(N,T,M),j=D(W,k,A);tt.current.setAttribute("y1",(L-B).toString()),tt.current.setAttribute("y2",(j-B).toString());var P=N>=T-4&&N<=M+4;tt.current.setAttribute("visibility",P?"visible":"hidden")}}}}}Pe.current.length>0&&!Ye.current&&(Ye.current=!0,requestAnimationFrame(function(){Bt(),Ye.current=!1}))}},[Bt,se,kt]);d(function(){var e=setTimeout(kt,250);window.addEventListener("resize",kt);var n=null,t=null;return un.current&&(n=new ResizeObserver(kt)).observe(un.current),et.current&&(t=new ResizeObserver(kt)).observe(et.current),function(){clearTimeout(e),window.removeEventListener("resize",kt),null==n||n.disconnect(),null==t||t.disconnect()}},[wn,Dn,Pn,pt,Bn,kn,zn,Ln,In,kt,we,at,_e,Ae]),d(function(){Ke.current=we},[we]),d(function(){Ve.current=at},[at]);var Dt=s(function(){var e,n,t,i,o=ln.sectionIdx,r=ln.isOrphan;if(yn(),null!=o)if(r)Ie("No counterpart exists for this section.");else if(we&&at===o)Un();else{if(!se){var l=Ve.current,c=nt.current;if(null!==l)if("string"==typeof l&&l.includes(z)){var u=l.split(z);(a=null===(e=St.current[u[2]])||void 0===e?void 0:e.current)&&(a.style.paddingTop="0px")}else{var a;(a=null===(n=xt.current[l])||void 0===n?void 0:n.current)&&(a.style.paddingTop="0px")}if(null!==c)if("string"==typeof c&&c.includes(z)){u=c.split(z);(d=null===(t=wt.current[u[3]])||void 0===t?void 0:t.current)&&(d.style.paddingTop="0px")}else{var d;(d=null===(i=mt.current[c])||void 0===i?void 0:i.current)&&(d.style.paddingTop="0px")}}De(new Set),Ne([]),Pe.current=[],me(!0),Ee.current=!0,dt(o),Ve.current=o,Re(!0),Ke.current=!0,Fe(!1),sn.current&&(sn.current.style.height="0px"),vn.current&&(vn.current.style.height="0px"),fn.current&&(fn.current.style.height="0px"),pn.current&&(pn.current.style.height="0px"),requestAnimationFrame(function(){var e,n,t,i,r,l,c,u,a,d,s,v=null,f=null,p=null,h=null,g=null;if("string"==typeof o&&o.includes(z)){var x=o.split(z),m="".concat(x[0]).concat(z).concat(x[1]);v=(null===(e=yt.current[m])||void 0===e?void 0:e.current)||null,g=(f=(null===(n=bt.current[m])||void 0===n?void 0:n.current)||null)?o:null,p=(null===(t=St.current[x[2]])||void 0===t?void 0:t.current)||null,h=(null===(i=wt.current[x[3]])||void 0===i?void 0:i.current)||null}else if(v=(null===(r=Xn.current[o])||void 0===r?void 0:r.current)||null,p=(null===(l=xt.current[o])||void 0===l?void 0:l.current)||null,se){var y=zn[o],b=(null==y?void 0:y.refIndexes)||[];if(b.length>0){var I=b[0],S=Ln.findIndex(function(e){return e.selfIndex===I});-1!==S&&(f=(null===(a=It.current[S])||void 0===a?void 0:a.current)||null,h=(null===(d=mt.current[S])||void 0===d?void 0:d.current)||null,g=S)}}else f=(null===(c=It.current[o])||void 0===c?void 0:c.current)||null,h=(null===(u=mt.current[o])||void 0===u?void 0:u.current)||null,g=f?o:null;nt.current=g;var w=hn.current,R=dn.current;if(!v||!w)return Ee.current=!1,void me(!1);if(!f||!R)return Fe(!0),Tt.current(),Ee.current=!1,void me(!1);if(!se){var C=v.getBoundingClientRect(),_=f.getBoundingClientRect(),F=C.top-_.top;p&&h&&(p.style.paddingTop="0px",h.style.paddingTop="0px",F>0?h.style.paddingTop="".concat(F,"px"):F<0&&(p.style.paddingTop="".concat(Math.abs(F),"px")));var E=v?v.getBoundingClientRect().top:(null==p?void 0:p.getBoundingClientRect().top)||0;return null===(s=un.current)||void 0===s||s.scrollTo({top:un.current.scrollTop+E-150,behavior:"smooth"}),Fe(!0),Tt.current(),Ee.current=!1,void me(!1)}var B=v.getBoundingClientRect().top-w.getBoundingClientRect().top+w.scrollTop,T=f.getBoundingClientRect().top-R.getBoundingClientRect().top+R.scrollTop-(B-w.scrollTop);T<0&&sn.current&&(sn.current.style.height="".concat(Math.abs(T),"px"));requestAnimationFrame(function(){var e,n=R.scrollHeight-R.clientHeight;if(T<0)e=0;else{if(T>n){var t=T-n;return vn.current&&(vn.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){X(R,T,200,function(){Fe(!0),Tt.current(),Ee.current=!1,me(!1)})})}e=T}X(R,e,200,function(){Fe(!0),Tt.current(),Ee.current=!1,me(!1)})})})}},[yn,ln.sectionIdx,we,at,zn,Ln,kt,Un]),Ht=null!==ln.sectionIdx&&Ae.has(ln.sectionIdx),Ot=function(n){var t,r,c,u,a,d,s,p=n.section,h=n.idx,g=n.columnKey,x=n.colRef,S=n.mb,R=void 0===S?1:S,C=n.parentNodeId,_=void 0===C?"":C,T=se?!!Bn["".concat(g,"-").concat(h)]:!!Bn[String(h)],M=(null===(t=p.displayTitle)||void 0===t||t)&&E(p.title),k=(null===(r=p.displayContent)||void 0===r||r)&&E(p.content),A=!M&&!k,D={current:1},H=p.title;M||(H=k?"No Title Found":"No Matching Section Found");var O,N=null!==(d=null===(a=null===(u=null===(c=p.evaluationResult)||void 0===c?void 0:c.evaluation_outputs)||void 0===u?void 0:u.metadata)||void 0===a?void 0:a.label_color)&&void 0!==d?d:V,W=B(N).highlightBg,z=[];if(null===(s=p.evaluationResult)||void 0===s?void 0:s.deviations){var L=p.evaluationResult.deviations;for(var P in L){var Y=L[P][_];Y&&z.push(Y)}}return i(v,e({ref:x,sx:{mb:R,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:o(y,e({disableGutters:!0,expanded:!A&&T,onChange:function(){return!A&&function(n,t){var i,o;ze.current=!0,Le.current&&clearTimeout(Le.current),We.current&&(We.current.style.opacity="0");var r=null===(i=xt.current[n])||void 0===i?void 0:i.current,l=null===(o=mt.current[n])||void 0===o?void 0:o.current;r&&(r.style.minHeight="0px"),l&&(l.style.minHeight="0px"),Le.current=setTimeout(function(){ze.current=!1,Tt.current(),We.current&&(We.current.style.opacity="1")},650),Tn(function(i){var o=e({},i),r=se?"".concat(t,"-").concat(n):String(n),l=!i[r];if(!l){var c=String(at||""),u=at===n||c.startsWith("".concat(n,"-")),a=!1;Ae.forEach(function(e){(e===n||String(e).startsWith("".concat(n,"-")))&&(a=!0)}),(u||a)&&(Un(),De(new Set),Ne([]),Pe.current=[])}if(!se)return o[String(n)]=l,o;if(o[r]=l,"left"===t)((null==(d=zn[n])?void 0:d.refIndexes)||[]).forEach(function(e){var n=Ln.findIndex(function(n){return n.selfIndex===e});-1!==n&&(o["right-".concat(n)]=l)});else{var d,s=null==(d=Ln[n])?void 0:d.selfIndex;zn.forEach(function(e,n){var t;(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(s))&&(o["left-".concat(n)]=l)})}return o})}(h,g)},sx:{boxShadow:"none",border:A?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:A?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flexGrow:1,width:"100%",display:"flex",flexDirection:"column",minWidth:0,"&:before":{display:"none"}}},{children:[i(b,e({expandIcon:A?null:i(w,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:A?"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:M&&i(m,e({title:H,placement:"top"},{children:i(f,e({component:"div",sx:{fontSize:"12px",color:A?"#94A3B8":"#19213D",fontWeight:A?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(O=H,O?F(O).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(e,n){return e.startsWith("**")&&e.endsWith("**")?i("strong",{children:e.slice(2,-2)},n):i(l.Fragment,{children:e},n)}):null)}))}))})),!A&&o(I,e({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[k&&i(j,{content:p.content,sxStyles:en,highlights:z,maintainRelativeOrder:se,highlightBg:W}),(p.subsections||[]).map(function(e,n){return Nt({section:e,keyPath:"".concat(h,"-").concat(n),depth:0,columnKey:g,parentNodeId:_,devCounter:D})})]}))]}))}),"".concat(g,"-sec-").concat(h))},Nt=function(n){var r,c,u,a,d,s,p,h,g,x,m,S,R,C,_,F=n.section,T=n.keyPath,M=n.depth,k=void 0===M?0:M,A=n.columnKey,D=void 0===A?"left":A,H=n.parentNodeId,O=void 0===H?"":H,N=(null===(r=F.displayTitle)||void 0===r||r)&&E(F.title),W=(null===(c=F.displayContent)||void 0===c||c)&&E(F.content),P=!N&&!W,Y=N?F.title:W?"No Title Found":"No Matching Section Found",K=!!kn[T];"left"!==D||St.current[T]||(St.current[T]=l.createRef()),"right"!==D||wt.current[T]||(wt.current[T]=l.createRef());var X="left"===D?St.current[T]:wt.current[T],q=Ft(T),U=T.split("-").map(Number),$=U[0],G=zn[$],J=Ln[$],Q=T,Z=T;if(se)if("left"===D){var ne=null===(u=null==G?void 0:G.refIndexes)||void 0===u?void 0:u[0],te=Ln.findIndex(function(e){return e.selfIndex===ne});-1!==te&&(J=Ln[te],Z=t([te],U.slice(1),!0).join("-"))}else{var ie=null===(a=null==J?void 0:J.refIndexes)||void 0===a?void 0:a[0],oe=zn.findIndex(function(e){return e.selfIndex===ie});-1!==oe&&(G=zn[oe],Q=t([oe],U.slice(1),!0).join("-"))}var re,le="left"===D?G:J;re=se&&void 0!==(null==le?void 0:le.selfIndex)&&le.selfIndex>=0?le.selfIndex+1:$+1;for(var ce=G,ue=J,ae=1;ae<U.length;ae++)(null==ce?void 0:ce.subsections)&&(ce=ce.subsections[U[ae]]),(null==ue?void 0:ue.subsections)&&(ue=ue.subsections[U[ae]]);var de=null===(d=null==ee?void 0:ee.input_index_map)||void 0===d?void 0:d[0],ve=null===(s=null==ee?void 0:ee.input_index_map)||void 0===s?void 0:s[1],fe="left"===D?ve:de,pe=se?!(null===(p=F.refIndexes)||void 0===p?void 0:p.length)||void 0!==F.selfIndex&&F.selfIndex<0:"left"===D?!ue:!ce,he=null!==(x=null===(g=null===(h=F.evaluationResult)||void 0===h?void 0:h.evaluation_outputs)||void 0===g?void 0:g.output_value)&&void 0!==x?x:null,ge=F.id,xe=null!==(C=null===(R=null===(S=null===(m=F.evaluationResult)||void 0===m?void 0:m.evaluation_outputs)||void 0===S?void 0:S.metadata)||void 0===R?void 0:R.label_color)&&void 0!==C?C:V,me=B(xe).highlightBg,ye=(null===(_=F.evaluationResult)||void 0===_?void 0:_.deviations)||{},be=Object.entries(ye).map(function(n){var t=n[0],i=n[1],o="".concat(ge).concat(z).concat(t),r=Vn[o];if(!r)return null;var c=i[O],u=L(c);if(u)c="";else if(!c)return null;var a=i[fe],d=pe||L(a),s="".concat(re,".").concat(r),v="".concat(ge).concat(z).concat(t).concat(z).concat(Q).concat(z).concat(Z);return"left"!==D||yt.current[o]||(yt.current[o]=l.createRef()),"right"!==D||bt.current[o]||(bt.current[o]=l.createRef()),{id:o,actionId:v,label:s,highlight:c,side:D,style:q,score:he,isConnected:Ae.has(v),isOrphan:d,isMissingClause:u,badgeRef:"left"===D?yt.current[o]:bt.current[o],onClick:function(n){n.stopPropagation();var t=e(e({},ce||{title:"",content:""}),{title:(null==G?void 0:G.title)||(null==ce?void 0:ce.title)||""}),i=e(e({},ue||{title:"",content:""}),{title:(null==J?void 0:J.title)||(null==ue?void 0:ue.title)||""});Jn(n,t,d,i,v,q)}}}).filter(Boolean),Ie=be.some(function(e){return Ae.has(e.actionId)});return N||W||F.subsections&&0!==F.subsections.length?i(v,N?e({ref:X,sx:{mt:1,width:"100%",minWidth:0,position:"relative"}},{children:i(v,e({sx:e({width:"100%"},Ie&&q&&{borderRadius:"4px",outline:"2px solid ".concat(q.badgeBorder),outlineOffset:"1px"})},{children:o(y,e({disableGutters:!0,expanded:!P&&K,onChange:function(){if(!P){if(K){var n=String(at||""),t=n.includes(Q)||n.includes(Z);t||Ae.forEach(function(e){(String(e).includes(Q)||String(e).includes(Z))&&(t=!0)}),t&&(Un(),De(new Set),Ne([]),Pe.current=[])}An(function(n){var t;return e(e({},n),((t={})[T]=!n[T],t))})}},sx:{mt:0,boxShadow:"none",border:P?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF",minWidth:0,"&:before":{display:"none"}}},{children:[i(b,e({expandIcon:P?null:i(w,{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:P?"#94A3B8":"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:Y||"Untitled Subsection"}))})),!P&&o(I,e({sx:{pt:0,pb:1,minWidth:0}},{children:[W&&i(j,{content:F.content,sxStyles:en,deviationBadges:be,maintainRelativeOrder:se,highlightBg:me}),(F.subsections||[]).map(function(e,n){return Nt({section:e,keyPath:"".concat(T,"-").concat(n),depth:k+1,columnKey:D,parentNodeId:O})})]}))]}))}))}):e({ref:X,sx:{mt:0===k?1:.75,width:"100%",minWidth:0,position:"relative"}},{children:!P&&o(v,e({sx:e({width:"100%"},Ie&&q&&{borderRadius:"4px",outline:"2px solid ".concat(q.badgeBorder),outlineOffset:"1px"})},{children:[W&&i(j,{content:F.content,sxStyles:en,deviationBadges:be,maintainRelativeOrder:se,highlightBg:me}),(F.subsections||[]).map(function(e,n){return Nt({section:e,keyPath:"".concat(T,"-").concat(n),depth:k+1,columnKey:D,parentNodeId:O})})]}))}),T):null};return o(v,e({ref:an,sx:e(e({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},se?{}:{overflow:"visible"}),{position:"relative"})},{children:[pe&&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(N,{})})),i(O,{open:ln.open,anchorEl:ln.anchorEl,sectionTitle:ln.sectionTitle,referenceSectionTitle:ln.refSectionTitle,onClose:yn,onOpenCognitiveCompare:Qn,onOpenSideBySide:Dt,onConnect:Zn,isConnected:Ht,isOrphan:ln.isOrphan}),tn.open&&i(H,{open:tn.open,popupRef:Ge,position:Ue,popupConfig:ce,onClose:function(){$e(null),on(function(n){return e(e({},n),{open:!1})}),Me(null)},markdownStyles:oe,sectionTitle:tn.sectionTitle,referenceSectionTitle:tn.refSectionTitle,cognitiveData:tn.cognitiveData,anchorEl:tn.anchorEl,sectionAnchorEl:tn.sectionAnchorEl,scrollContainerEl:un.current,badgeStyle:tn.badgeStyle,docData:tn.docData,deviationData:tn.deviationData}),i(p,e({open:!!be,autoHideDuration:8e3,onClose:function(){return Ie(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:i(h,e({onClose:function(){return Ie(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:be}))})),(le.isHeaderVisible||le.isToggleVisible)&&o(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:le.isHeaderVisible&&i(f,e({sx:{fontSize:"16px",fontWeight:600,color:"#0F172A"}},{children:Z}))})),le.isToggleVisible&&i(v,e({sx:{display:"flex",alignItems:"center"}},{children:i(g,{control:i(x,{checked:!se,onChange:function(e){var n=e.target.checked;he(!0),setTimeout(function(){ve(!n),Un(),De(new Set),Ne([]),Pe.current=[],setTimeout(function(){he(!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:un,onScroll:At,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:se?"hidden":"auto",borderTop:Yn&&Kn?"none":"1.5px solid #EEF0F4"}},{children:i(v,e({sx:e({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},se?{flex:1,minHeight:0}:{})},{children:o(v,e({ref:et,sx:e({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"10px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},se?{flex:1,overflow:"visible"}:{})},{children:[o("svg",e({ref:We,style:{position:"absolute",top:0,left:0,width:Qe.width||"100%",height:Qe.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",transition:"opacity 0.15s ease-in-out"}},{children:[vt&&!we&&o("g",{children:[i("line",{x1:vt.x1,y1:vt.y,x2:Math.max(vt.x1,(vt.x1+vt.x2)/2-70),y2:vt.y,stroke:"#BBF7D0",strokeWidth:"1.5"}),i("line",{x1:Math.min(vt.x2,(vt.x1+vt.x2)/2+70),y1:vt.y,x2:vt.x2,y2:vt.y,stroke:"#BBF7D0",strokeWidth:"1.5"})]}),lt.map(function(n){var t,r=n.x1+.5*(n.x2-n.x1),l=(n.y1+n.y2)/2;if("Not Defined"===n.style.label&&!n.hasCognitive)return null;var c=!1;if(n.isSubSection)c=we&&at===n.subSectionKeyPath&&_e;else{var u=zn[n.sectionIdx];(se?!(null===(t=null==u?void 0:u.refIndexes)||void 0===t?void 0:t.length)||(null==u?void 0:u.selfIndex)<0:!Ln[n.sectionIdx])||(c=we&&at===n.sectionIdx&&_e)}if(c)return o("g",e({style:{transition:"opacity 0.2s"}},{children:[i("defs",{children:i("marker",e({id:"arr-".concat(n.id),markerWidth:"7",markerHeight:"5",refX:"7",refY:"2.5",orient:"auto"},{children:i("polygon",{points:"0 0, 7 2.5, 0 5",fill:n.style.badgeBorder||"#6366F1"})}))}),i("line",{ref:tt,x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,stroke:n.style.badgeBorder||"#6366F1",strokeWidth:"1.5",markerEnd:"url(#arr-".concat(n.id,")")})]}),n.id);if(!se){var a=n.isSubSection?P(n.x1,n.y1,n.x2,n.y2):"M ".concat(n.x1," ").concat(n.y1," L ").concat(n.x2," ").concat(n.y2);return o("g",{children:[i("path",{d:a,fill:"none",stroke:n.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),i("foreignObject",e({x:r-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:o(v,e({onClick:function(t){if(t.stopPropagation(),tn.open&&Te===n.id)mn();else{var i=zn[n.sectionIdx]||{title:"",content:""},o=Ln[n.sectionIdx]||{title:"",content:""};if(n.isSubSection&&n.subSectionKeyPath){for(var r=n.subSectionKeyPath.split(z)[2].split("-").map(Number),l=zn[r[0]],c=Ln[r[0]],u=(null==l?void 0:l.title)||"",a=(null==c?void 0:c.title)||"",d=1;d<r.length;d++)(null==l?void 0:l.subsections)&&(l=l.subsections[r[d]]),(null==c?void 0:c.subsections)&&(c=c.subsections[r[d]]);l&&(i=e(e({},l),{title:u||l.title})),c&&(o=e(e({},c),{title:a||c.title}))}Me(n.id),Gn($n(t.currentTarget,i,o,n.sectionIdx,n.style))}},sx:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:n.style.badgeBg,color:n.style.badgeText,border:"1px solid ".concat(n.style.badgeBorder),borderRadius:"12px",px:1.5,py:.5,fontWeight:600,textAlign:"center",whiteSpace:"nowrap",cursor:"pointer"}},{children:[0===n.style.label?"Same":n.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:tn.open&&Te===n.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},n.id)}return null}),Oe.map(function(n){var t,r=n.pathD,l=(null===(t=n.style)||void 0===t?void 0:t.badgeBorder)||"#6366F1",c="conn-marker-".concat(n.id),u="".concat(n.id,"-bg"),a="".concat(n.id,"-stroke");return o("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){je.current[u]=e},d:r,fill:"none",stroke:"#FFFFFF",strokeWidth:"4",strokeOpacity:"0.7"}),i("path",{ref:function(e){je.current[a]=e},d:r,fill:"none",stroke:l,strokeWidth:"1.75",markerEnd:"url(#".concat(c,")")})]},n.id)})]})),o(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)"},se?{flex:1,overflow:"visible"}:{})},{children:[i(v,e({ref:it,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:Nn,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:Nn}))}))})),o(v,e({ref:hn,onScroll:At,sx:e({p:"12px",display:"flex",flexDirection:"column"},se?{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:fn,style:{width:"100%",height:"0px",flexShrink:0}}),jn&&zn.map(function(n,t){var r,c,u=!n.title&&!n.content;if(se&&u)return null;var a=n,d=_t(t),s=se?!(null===(r=a.refIndexes)||void 0===r?void 0:r.length)||a.selfIndex<0:!Ln[t],f=se?"number"==typeof a.selfIndex&&a.selfIndex>=0?a.selfIndex+1:null:t+1,p=Ae.has(t),h=function(e,n){var t,i,o,r,l,c;if(!e)return n;var u=null!==(c=null!==(r=null!==(i=null===(t=e.evaluation_output)||void 0===t?void 0:t.output_score)&&void 0!==i?i:null===(o=e.evaluation_outputs)||void 0===o?void 0:o.output_score)&&void 0!==r?r:null===(l=e.evaluation_outputs)||void 0===l?void 0:l.output_value)&&void 0!==c?c:e.output_score;return null!=u?u:n}(a.evaluationResult,null==d?void 0:d.deviationLabel);return i(v,e({ref:qn(t),sx:{mb:1,width:"100%"}},{children:o(v,e({sx:{position:"relative",width:"100%"}},{children:[i(v,e({ref:xt.current[t],sx:e({width:"100%",display:"flex"},p&&{borderRadius:"6px",outline:"2px solid ".concat((null==d?void 0:d.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:Ot({section:n,idx:t,columnKey:"left",colRef:l.createRef(),mb:0,parentNodeId:(null===(c=null==ee?void 0:ee.input_index_map)||void 0===c?void 0:c[0])||""})})),se&&d&&o(v,e({ref:yt.current[t],onClick:function(e){var i=se?Ln.find(function(e){var n;return null===(n=a.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""}:Ln[t]||{title:"",content:""};Jn(e,n,s,i,t,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&&i(v,e({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(d.badgeBorder)}},{children:f})),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)})),i(S,{size:11,color:d.badgeText})]}))]}))}),"left-row-".concat(t))}),i("div",{ref:pn,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:o(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})]}))}))})),o(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},se?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[xe&&i(C,{sections:11}),i(v,e({ref:ot,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:Wn,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:Wn}))}))})),o(v,e({ref:dn,onScroll:At,sx:e({p:"12px",display:"flex",flexDirection:"column"},se?{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:sn,style:{width:"100%",height:"0px",flexShrink:0}}),jn&&Ln.map(function(n,t){var r,c=n,u=[],a=!1,d=null;if(se){u=zn.filter(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(c.selfIndex))&&e.selfIndex>=0}).map(function(e){return e.selfIndex+1});var s=zn.findIndex(function(e,n){var t;return Ae.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(c.selfIndex))});(a=-1!==s)&&(d=_t(s))}else u=[t+1],(a=Ae.has(t))&&(d=_t(t));return i(v,e({ref:It.current[t],sx:{mb:1,width:"100%"}},{children:o(v,e({sx:{position:"relative",width:"100%"}},{children:[i(v,e({ref:mt.current[t],sx:e({width:"100%",display:"flex"},a&&d&&{borderRadius:"6px",outline:"2px solid ".concat(d.badgeBorder),outlineOffset:"1px"})},{children:Ot({section:n,idx:t,columnKey:"right",colRef:l.createRef(),mb:0,parentNodeId:(null===(r=null==ee?void 0:ee.input_index_map)||void 0===r?void 0:r[1])||""})})),se&&!xe&&i(v,e({ref:bt.current[t],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(t))}),i("div",{ref:vn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))};export{q as default};
2
2
  //# sourceMappingURL=CognitiveCompare.js.map
@@ -1,2 +1,2 @@
1
- var e=[{key:"title",label:"Title",analysisKey:"title"},{key:"description",label:"Description",analysisKey:"description"}],i={fields:e,thresholds:{exact:90,high:70,medium:40},relationStyles:{noContent:{bg:"#FFFFFF",border:"#E2E8F0",badgeBg:"#F8FAFC",badgeBorder:"#F1F5F9",badgeText:"#64748B",highlightBg:"transparent"},exact:{bg:"#FFF1F2",border:"#FECDD3",badgeBg:"#FFE4E6",badgeBorder:"#FEE2E2",badgeText:"#9F1239",highlightBg:"#FECDD3"},high:{bg:"#FFF5F5",border:"#FECACA",badgeBg:"#FEECEC",badgeBorder:"#F8C2C2",badgeText:"#B42318",highlightBg:"#FDD5D5"},medium:{bg:"#FFFCF6",border:"#FFDD80",badgeBg:"#FEF9C3",badgeBorder:"#FEF08A",badgeText:"#A16207",highlightBg:"#FDDEB3"},low:{bg:"#F5F9FF",border:"#CFE0FF",badgeBg:"#EEF4FF",badgeBorder:"#BFD3FF",badgeText:"#1D4ED8",highlightBg:"#DCEAFF"}}},t={fontSize:"13px",color:"#0B0E1A",lineHeight:1.4,wordBreak:"break-word",overflowWrap:"break-word",overflow:"hidden","& p":{mt:0,mb:1.5},"& p:last-child":{mb:0},"& ul":{mt:0,mb:1.5,pl:2.5,listStyleType:"disc"},"& ol":{mt:0,mb:1.5,pl:2.5,listStyleType:"decimal"},"& li":{mb:.5},"& strong":{fontWeight:600},"& code":{whiteSpace:"pre-wrap",wordBreak:"break-word"}},a={tabs:{deviation:{key:"deviation",label:"Deviation Analysis",subtitle:"Why this is a deviation?",placeholderTitle:"Deviation Analysis",placeholderBody:"Deviation analysis content will appear here..."},association:{key:"association",label:"Association Logic",subtitle:"Why these sections are paired?"}},decisionStrengthLabel:"Decision Strength",sectionTitles:{decisioningFactors:"Decision Making Factors",gaps:"Gaps in Decision"},emptyStateMessage:"No cognitive decisioning data available for this section.",accentColor:"#5928ED"};export{i as DEFAULT_COMPARISON_CONFIG,e as DEFAULT_FIELD_CONFIG,a as DEFAULT_POPUP_CONFIG,t as SHARED_MARKDOWN_STYLES};
1
+ var e=[{key:"title",label:"Title",analysisKey:"title"},{key:"description",label:"Description",analysisKey:"description"}],i={fields:e,thresholds:{exact:90,high:70,medium:40}},t={fontSize:"13px",color:"#0B0E1A",lineHeight:1.4,wordBreak:"break-word",overflowWrap:"break-word",overflow:"hidden","& p":{mt:0,mb:1.5},"& p:last-child":{mb:0},"& ul":{mt:0,mb:1.5,pl:2.5,listStyleType:"disc"},"& ol":{mt:0,mb:1.5,pl:2.5,listStyleType:"decimal"},"& li":{mb:.5},"& strong":{fontWeight:600},"& code":{whiteSpace:"pre-wrap",wordBreak:"break-word"}},a={tabs:{deviation:{key:"deviation",label:"Deviation Analysis",subtitle:"Why this is a deviation?",placeholderTitle:"Deviation Analysis",placeholderBody:"Deviation analysis content will appear here..."},association:{key:"association",label:"Association Logic",subtitle:"Why these sections are paired?"}},decisionStrengthLabel:"Decision Strength",sectionTitles:{decisioningFactors:"Decision Making Factors",gaps:"Gaps in Decision"},emptyStateMessage:"No cognitive decisioning data available for this section.",accentColor:"#5928ED"};export{i as DEFAULT_COMPARISON_CONFIG,e as DEFAULT_FIELD_CONFIG,a as DEFAULT_POPUP_CONFIG,t as SHARED_MARKDOWN_STYLES};
2
2
  //# sourceMappingURL=CognitiveCompareConfig.js.map
@@ -1,2 +1,2 @@
1
- var n=function(i){return null==i?"":"string"==typeof i?i:Array.isArray(i)?i.map(n).join("\n\n"):"object"==typeof i?JSON.stringify(i):String(i)},i=function(n){return null!=n&&("string"==typeof n?n.trim().length>0:!Array.isArray(n)||n.length>0&&n.some(function(n){return i(n)}))},t=function(i,t,e){var o,r=e[t],a=null===(o=null==i?void 0:i.comparison_inputs)||void 0===o?void 0:o[r];return{title:n((null==a?void 0:a.title)||""),content:n((null==a?void 0:a.content)||""),attributes:(null==a?void 0:a.additional_attributes)||null,subsections:(null==a?void 0:a.subsections)||[]}},e=function(n){if(!n.mapping_rationale)return{cognitiveData:{decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0,citations:[]},score:0,relation:"N/A"};var i=n.mapping_rationale,t=parseInt(i.decision_strength||"0");return{cognitiveData:{decisioning:i.decisioning_factors||[],gap:i.gaps_in_decision||[],relevance_score:t,citations:i.citations},score:0,relation:"N/A"}};export{e as getRationale,t as getSideData,i as hasValue,n as safeStringify};
1
+ var n=function(t){return null==t?"":"string"==typeof t?t:Array.isArray(t)?t.map(n).join("\n\n"):"object"==typeof t?JSON.stringify(t):String(t)},t=function(n){return null!=n&&("string"==typeof n?n.trim().length>0:!Array.isArray(n)||n.length>0&&n.some(function(n){return t(n)}))},i=function(t,i,r){var e,o=r[i],a=null===(e=null==t?void 0:t.comparison_inputs)||void 0===e?void 0:e[o];return{title:n((null==a?void 0:a.title)||""),content:n((null==a?void 0:a.content)||""),attributes:(null==a?void 0:a.additional_attributes)||null,subsections:(null==a?void 0:a.subsections)||[]}},r=function(n){if(!n.mapping_rationale)return{cognitiveData:{decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0,citations:[]},score:0,relation:"N/A"};var t=n.mapping_rationale,i=parseInt(t.decision_strength||"0");return{cognitiveData:{decisioning:t.decisioning_factors||[],gap:t.gaps_in_decision||[],relevance_score:i,citations:t.citations},score:0,relation:"N/A"}};function e(n){var t=function(n,t){var i=function(n){var t=function(n){return 4===n.length?"#"+n[1]+n[1]+n[2]+n[2]+n[3]+n[3]:n}(n).replace("#",""),i=parseInt(t,16);return{r:i>>16&255,g:i>>8&255,b:255&i}}(n),r=i.r,e=i.g,o=i.b;return function(n,t,i){return"#"+[n,t,i].map(function(n){return n.toString(16).padStart(2,"0")}).join("").toUpperCase()}(Math.round(r+(255-r)*t),Math.round(e+(255-e)*t),Math.round(o+(255-o)*t))};return{bg:t(n,.8),border:t(n,.5),badgeBg:t(n,.8),badgeBorder:t(n,.5),badgeText:n.toUpperCase(),highlightBg:t(n,.8)}}export{e as generateColorPalette,r as getRationale,i as getSideData,t as hasValue,n as safeStringify};
2
2
  //# sourceMappingURL=CognitiveComparehelpers.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as o}from"tslib";import{jsxs as i,Fragment as n,jsx as t}from"react/jsx-runtime";import{useMemo as e,useState as r,useEffect as l}from"react";import{Box as a,Typography as s,IconButton as c}from"@mui/material";import{X as d}from"lucide-react";import p from"react-dom";import v from"../../assests/svg/SparkleIcon.js";import{SHARED_MARKDOWN_STYLES as x,DEFAULT_POPUP_CONFIG as h}from"./CognitiveCompareConfig.js";import u from"./CitationRenderer.js";var b=10,g=function(g){var f,m,w,y,F,k,S,C,D,E,_,R,z,W,I,T,j,A,B,L,H,M=g.open,O=g.onClose,G=g.sectionTitle,N=g.referenceSectionTitle,P=g.cognitiveData,Y=g.relevanceScore,q=g.anchorEl,J=g.badgeStyle,K=g.popupRef,Q=g.position,U=g.markdownStyles,V=g.docData,X=g.popupConfig,Z=g.deviationData,$=o(o({},x),U),oo=e(function(){var i,n;return o(o(o({},h),X),{tabs:{deviation:o(o({},h.tabs.deviation),null===(i=null==X?void 0:X.tabs)||void 0===i?void 0:i.deviation),association:o(o({},h.tabs.association),null===(n=null==X?void 0:X.tabs)||void 0===n?void 0:n.association)},sectionTitles:o(o({},h.sectionTitles),null==X?void 0:X.sectionTitles)})},[X]),io=null==P?void 0:P.isMissingRationale,no=r(io?oo.tabs.deviation.key:oo.tabs.association.key),to=no[0],eo=no[1];l(function(){M&&eo(io?oo.tabs.deviation.key:oo.tabs.association.key)},[M,io,oo.tabs.deviation.key,oo.tabs.association.key]);var ro=e(function(){if(!J)return{border:oo.accentColor,shadow:"".concat(oo.accentColor,"2E")};var o=J.badgeText;return"#9F1239"===o||"#B42318"===o?{border:"#E11D48",shadow:"rgba(225,29,72,0.15)"}:"#1D4ED8"===o?{border:"#3B82F6",shadow:"rgba(59,130,246,0.15)"}:"#A16207"===o?{border:"#F59E0B",shadow:"rgba(245,158,11,0.15)"}:{border:oo.accentColor,shadow:"".concat(oo.accentColor,"2E")}},[J,oo.accentColor]);if(l(function(){if(M){var o=function(o){var i;(null===(i=K.current)||void 0===i?void 0:i.contains(o.target))||(null==q?void 0:q.contains(o.target))||O()};return document.addEventListener("mousedown",o),function(){return document.removeEventListener("mousedown",o)}}},[M,O,q,K]),!M||!P)return null;var lo=null!==(m=null!==(f=P.relevance_score)&&void 0!==f?f:Y)&&void 0!==m?m:0,ao=P.decisioning,so=Array.isArray(ao)?ao:"string"==typeof ao&&ao.trim()?[ao]:[],co=P.gap,po=Array.isArray(co)?co:"string"==typeof co&&co.trim()?[co]:[],vo=null!==(w=null==Q?void 0:Q.arrowLeft)&&void 0!==w?w:60,xo=i(a,o({ref:K,sx:{position:"fixed",top:null!==(y=null==Q?void 0:Q.top)&&void 0!==y?y:-9999,left:null!==(F=null==Q?void 0:Q.left)&&void 0!==F?F:-9999,zIndex:9999,width:"100%",maxWidth:"min(".concat(880,"px, calc(100vw - ").concat(null!==(k=null==Q?void 0:Q.left)&&void 0!==k?k:0,"px - ").concat(12,"px))"),bgcolor:"#FFFFFF",borderRadius:"14px",border:"1.5px solid ".concat(ro.border),boxShadow:"0px 8px 32px ".concat(ro.shadow,", 0px 0px 0px 3px ").concat(ro.shadow),overflow:"visible",display:"flex",flexDirection:"column",maxHeight:(null==Q?void 0:Q.maxHeight)?"min(60vh, ".concat(Q.maxHeight,"px)"):"60vh",visibility:Q?"visible":"hidden"}},{children:[Q&&(Q.openAbove?i(n,{children:[t(a,{sx:{position:"absolute",bottom:-11,left:vo-b,width:0,height:0,borderLeft:"".concat(b,"px solid transparent"),borderRight:"".concat(b,"px solid transparent"),borderTop:"".concat(11,"px solid ").concat(ro.border),zIndex:1}}),t(a,{sx:{position:"absolute",bottom:-9,left:vo-b+1,width:0,height:0,borderLeft:"".concat(9,"px solid transparent"),borderRight:"".concat(9,"px solid transparent"),borderTop:"".concat(b,"px solid #FFFFFF"),zIndex:2}})]}):i(n,{children:[t(a,{sx:{position:"absolute",top:-11,left:vo-b,width:0,height:0,borderLeft:"".concat(b,"px solid transparent"),borderRight:"".concat(b,"px solid transparent"),borderBottom:"".concat(11,"px solid ").concat(ro.border),zIndex:1}}),t(a,{sx:{position:"absolute",top:-9,left:vo-b+1,width:0,height:0,borderLeft:"".concat(9,"px solid transparent"),borderRight:"".concat(9,"px solid transparent"),borderBottom:"".concat(b,"px solid #FFFFFF"),zIndex:2}})]})),i(a,o({sx:{px:2.5,pt:2,pb:1.5,display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0}},{children:[i(a,o({sx:{flex:1,minWidth:0}},{children:[i(s,o({sx:{fontSize:"16px",fontWeight:600,color:"#101828",lineHeight:1.3,display:"flex",alignItems:"center",gap:1,flexWrap:"nowrap",overflow:"hidden",width:"100%"}},{children:[t(a,o({component:"span",title:G,sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:"0 1 auto",maxWidth:"calc(50% - 16px)",minWidth:0}},{children:G})),t(a,o({component:"span",sx:{color:"#667085",fontWeight:400,flexShrink:0,mx:.5}},{children:"↔"})),t(a,o({component:"span",title:N||"Reference Section",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,minWidth:0}},{children:N||"Reference Section"}))]})),t(a,o({sx:{mt:.75,display:"inline-flex",alignItems:"center",gap:.75}},{children:t(s,o({sx:{fontSize:"13px",fontWeight:400,color:"#5928ED",lineHeight:1}},{children:null===(S=Object.values(oo.tabs).find(function(o){return o.key===to}))||void 0===S?void 0:S.subtitle}))}))]})),i(a,o({sx:{display:"flex",alignItems:"center",gap:1.5,flexShrink:0}},{children:[i(a,o({sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:.5,borderRadius:"20px",bgcolor:"#FFFFFF",border:"1px solid #5928ED",fontSize:"12px",fontWeight:600,color:"#5928ED"}},{children:[t(v,{}),oo.decisionStrengthLabel," ",lo,"%"]})),t(c,o({onClick:O,size:"small",sx:{color:"#667085",width:24,height:24,"&:hover":{bgcolor:"transparent",color:"#101828"}}},{children:t(d,{size:22})}))]}))]})),t(a,o({sx:{display:"flex",borderBottom:"1px solid #E4E7EC",px:2.5,flexShrink:0}},{children:(io?[oo.tabs.deviation]:[oo.tabs.deviation,oo.tabs.association]).map(function(i){var n=to===i.key;return t(a,o({onClick:function(){return eo(i.key)},sx:{pb:"10px",pt:"4px",mr:3,px:2,cursor:"pointer",fontSize:"14px",fontWeight:n?600:400,color:n?oo.accentColor:"#667085",backgroundColor:n?"".concat(oo.accentColor,"14"):"transparent",borderBottom:n?"2px solid ".concat(oo.accentColor):"2px solid transparent",transition:"all 0.15s",userSelect:"none"}},{children:i.label}),i.key)})})),t(a,o({sx:{flex:1,minHeight:0,overflowY:"auto",px:2.5,py:2,display:"flex",flexDirection:"column",gap:1.5,"&::-webkit-scrollbar":{width:"6px"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{background:"".concat(ro.border,"55"),borderRadius:"10px"},"&::-webkit-scrollbar-thumb:hover":{background:ro.border},scrollbarWidth:"thin",scrollbarColor:"".concat(ro.border,"55 transparent")}},{children:to===oo.tabs.deviation.key?Z?i(n,{children:[(null===(D=(null===(C=null==Z?void 0:Z.cognitive_decisioning)||void 0===C?void 0:C.decisioning_factors)||[])||void 0===D?void 0:D.length)>0&&t(u,{title:"Decision Making Factors",content:null===(_=null===(E=null==Z?void 0:Z.cognitive_decisioning)||void 0===E?void 0:E.decisioning_factors)||void 0===_?void 0:_.join("\n\n"),citations:null===(R=null==Z?void 0:Z.cognitive_decisioning)||void 0===R?void 0:R.citations,styles:$,docData:V,open:M}),(null===(W=(null===(z=null==Z?void 0:Z.cognitive_decisioning)||void 0===z?void 0:z.gaps_in_decision)||[])||void 0===W?void 0:W.length)>0&&t(u,{title:"Gaps in Decision",content:null===(T=null===(I=null==Z?void 0:Z.cognitive_decisioning)||void 0===I?void 0:I.gaps_in_decision)||void 0===T?void 0:T.join("\n\n"),citations:null===(j=null==Z?void 0:Z.cognitive_decisioning)||void 0===j?void 0:j.citations,styles:$,docData:V,open:M}),0===(null===(B=(null===(A=null==Z?void 0:Z.cognitive_decisioning)||void 0===A?void 0:A.decisioning_factors)||[])||void 0===B?void 0:B.length)&&0===(null===(H=(null===(L=null==Z?void 0:Z.cognitive_decisioning)||void 0===L?void 0:L.gaps_in_decision)||[])||void 0===H?void 0:H.length)&&t(a,o({sx:{p:2,bgcolor:"#F8FAFC",borderRadius:"8px",border:"1px solid #E2E8F0"}},{children:t(s,o({sx:{fontSize:"13px",color:"#64748B"}},{children:"No cognitive decisioning data available for this section."}))}))]}):t(u,{title:"Deviation Analysis",content:"Deviation analysis content will appear here. This tab shows\n structural and semantic deviations identified between the two\n sections being compared.",citations:{},styles:$,docData:V,open:M}):i(n,{children:[so.length>0&&t(u,{title:oo.sectionTitles.decisioningFactors,content:so.join("\n\n"),citations:P.citations,styles:$,open:M,docData:V}),po.length>0&&t(u,{title:oo.sectionTitles.gaps,content:po.join("\n\n"),citations:P.citations,styles:$,open:M,docData:V}),0===so.length&&0===po.length&&t(a,o({sx:{p:2,bgcolor:"#F8FAFC",borderRadius:"8px",border:"1px solid #E2E8F0"}},{children:t(s,o({sx:{fontSize:"13px",color:"#64748B"}},{children:oo.emptyStateMessage}))}))]})}))]}));return p.createPortal(xo,document.body)};export{g as default};
1
+ import{__assign as o}from"tslib";import{jsxs as i,Fragment as n,jsx as t}from"react/jsx-runtime";import{useMemo as e,useState as r,useEffect as l}from"react";import{Box as a,Typography as c,IconButton as s}from"@mui/material";import{X as d}from"lucide-react";import p from"react-dom";import v from"../../assests/svg/SparkleIcon.js";import{SHARED_MARKDOWN_STYLES as x,DEFAULT_POPUP_CONFIG as h}from"./CognitiveCompareConfig.js";import b from"./CitationRenderer.js";var u=10,g=function(g){var f,m,w,y,F,k,S,C,D,_,E,R,z,W,I,T,j,A,B,L,H=g.open,M=g.onClose,O=g.sectionTitle,G=g.referenceSectionTitle,N=g.cognitiveData,P=g.relevanceScore,Y=g.anchorEl,q=g.badgeStyle,J=g.popupRef,K=g.position,Q=g.markdownStyles,U=g.docData,V=g.popupConfig,X=g.deviationData,Z=o(o({},x),Q),$=e(function(){var i,n;return o(o(o({},h),V),{tabs:{deviation:o(o({},h.tabs.deviation),null===(i=null==V?void 0:V.tabs)||void 0===i?void 0:i.deviation),association:o(o({},h.tabs.association),null===(n=null==V?void 0:V.tabs)||void 0===n?void 0:n.association)},sectionTitles:o(o({},h.sectionTitles),null==V?void 0:V.sectionTitles)})},[V]),oo=null==N?void 0:N.isMissingRationale,io=r(oo?$.tabs.deviation.key:$.tabs.association.key),no=io[0],to=io[1];l(function(){H&&to(oo?$.tabs.deviation.key:$.tabs.association.key)},[H,oo,$.tabs.deviation.key,$.tabs.association.key]);var eo=e(function(){if(!q)return{border:$.accentColor,shadow:"".concat($.accentColor,"2E")};var o=q.badgeText;return"#9F1239"===o||"#B42318"===o?{border:"#E11D48",shadow:"rgba(225,29,72,0.15)"}:"#1D4ED8"===o?{border:"#3B82F6",shadow:"rgba(59,130,246,0.15)"}:"#A16207"===o?{border:"#F59E0B",shadow:"rgba(245,158,11,0.15)"}:{border:$.accentColor,shadow:"".concat($.accentColor,"2E")}},[q,$.accentColor]);if(l(function(){if(H){var o=function(o){var i;(null===(i=J.current)||void 0===i?void 0:i.contains(o.target))||(null==Y?void 0:Y.contains(o.target))||M()};return document.addEventListener("mousedown",o),function(){return document.removeEventListener("mousedown",o)}}},[H,M,Y,J]),!H||!N)return null;var ro=null!==(w=null!==(m=no===$.tabs.deviation.key?null===(f=null==X?void 0:X.cognitive_decisioning)||void 0===f?void 0:f.decision_strength:N.relevance_score)&&void 0!==m?m:P)&&void 0!==w?w:0,lo=N.decisioning,ao=Array.isArray(lo)?lo:"string"==typeof lo&&lo.trim()?[lo]:[],co=N.gap,so=Array.isArray(co)?co:"string"==typeof co&&co.trim()?[co]:[],po=K?K.left-150:-9999,vo=(null!==(y=null==K?void 0:K.arrowLeft)&&void 0!==y?y:60)+150,xo=i(a,o({ref:J,sx:{position:"fixed",top:null!==(F=null==K?void 0:K.top)&&void 0!==F?F:-9999,left:po,zIndex:9999,width:"".concat(1050,"px"),maxWidth:"min(".concat(1050,"px, calc(100vw - ").concat(po>0?po:0,"px - ").concat(12,"px))"),bgcolor:"#FFFFFF",borderRadius:"14px",border:"1.5px solid ".concat(eo.border),boxShadow:"0px 8px 32px ".concat(eo.shadow,", 0px 0px 0px 3px ").concat(eo.shadow),overflow:"visible",display:"flex",flexDirection:"column",maxHeight:(null==K?void 0:K.maxHeight)?"min(60vh, ".concat(K.maxHeight,"px)"):"60vh",visibility:K?"visible":"hidden"}},{children:[K&&(K.openAbove?i(n,{children:[t(a,{sx:{position:"absolute",bottom:-11,left:vo-u,width:0,height:0,borderLeft:"".concat(u,"px solid transparent"),borderRight:"".concat(u,"px solid transparent"),borderTop:"".concat(11,"px solid ").concat(eo.border),zIndex:1}}),t(a,{sx:{position:"absolute",bottom:-9,left:vo-u+1,width:0,height:0,borderLeft:"".concat(9,"px solid transparent"),borderRight:"".concat(9,"px solid transparent"),borderTop:"".concat(u,"px solid #FFFFFF"),zIndex:2}})]}):i(n,{children:[t(a,{sx:{position:"absolute",top:-11,left:vo-u,width:0,height:0,borderLeft:"".concat(u,"px solid transparent"),borderRight:"".concat(u,"px solid transparent"),borderBottom:"".concat(11,"px solid ").concat(eo.border),zIndex:1}}),t(a,{sx:{position:"absolute",top:-9,left:vo-u+1,width:0,height:0,borderLeft:"".concat(9,"px solid transparent"),borderRight:"".concat(9,"px solid transparent"),borderBottom:"".concat(u,"px solid #FFFFFF"),zIndex:2}})]})),i(a,o({sx:{px:2.5,pt:2,pb:1.5,display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0}},{children:[i(a,o({sx:{flex:1,minWidth:0}},{children:[("no title"!==O||"no title"!==G)&&i(c,o({sx:{fontSize:"16px",fontWeight:600,color:"#101828",lineHeight:1.3,display:"flex",alignItems:"center",gap:1,flexWrap:"nowrap",overflow:"hidden",width:"100%"}},{children:[t(a,o({component:"span",title:O,sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:"0 1 auto",maxWidth:"calc(50% - 16px)",minWidth:0}},{children:O})),t(a,o({component:"span",sx:{color:"#667085",fontWeight:400,flexShrink:0,mx:.5}},{children:"↔"})),t(a,o({component:"span",title:G||"Reference Section",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,minWidth:0}},{children:G||"Reference Section"}))]})),t(a,o({sx:{mt:.75,display:"inline-flex",alignItems:"center",gap:.75}},{children:t(c,o({sx:{fontSize:"no title"!==O||"no title"!==G?"13px":"16px",fontWeight:400,color:"#5928ED",lineHeight:1}},{children:null===(k=Object.values($.tabs).find(function(o){return o.key===no}))||void 0===k?void 0:k.subtitle}))}))]})),i(a,o({sx:{display:"flex",alignItems:"center",gap:1.5,flexShrink:0}},{children:[i(a,o({sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:.5,borderRadius:"20px",bgcolor:"#FFFFFF",border:"1px solid #5928ED",fontSize:"12px",fontWeight:600,color:"#5928ED"}},{children:[t(v,{}),$.decisionStrengthLabel," ",ro,"%"]})),t(s,o({onClick:M,size:"small",sx:{color:"#667085",width:24,height:24,"&:hover":{bgcolor:"transparent",color:"#101828"}}},{children:t(d,{size:22})}))]}))]})),t(a,o({sx:{display:"flex",borderBottom:"1px solid #E4E7EC",px:2.5,flexShrink:0}},{children:(oo?[]:[$.tabs.deviation,$.tabs.association]).map(function(i){var n=no===i.key;return t(a,o({onClick:function(){return to(i.key)},sx:{pb:"10px",pt:"4px",mr:3,px:2,cursor:"pointer",fontSize:"14px",fontWeight:n?600:400,color:n?$.accentColor:"#667085",backgroundColor:n?"".concat($.accentColor,"14"):"transparent",borderBottom:n?"2px solid ".concat($.accentColor):"2px solid transparent",transition:"all 0.15s",userSelect:"none"}},{children:i.label}),i.key)})})),t(a,o({sx:{flex:1,minHeight:0,overflowY:"auto",px:2.5,py:2,display:"flex",flexDirection:"column",gap:1.5,"&::-webkit-scrollbar":{width:"6px"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{background:"".concat(eo.border,"55"),borderRadius:"10px"},"&::-webkit-scrollbar-thumb:hover":{background:eo.border},scrollbarWidth:"thin",scrollbarColor:"".concat(eo.border,"55 transparent")}},{children:no===$.tabs.deviation.key?X?i(n,{children:[(null===(C=(null===(S=null==X?void 0:X.cognitive_decisioning)||void 0===S?void 0:S.decisioning_factors)||[])||void 0===C?void 0:C.length)>0&&t(b,{title:"Decision Making Factors",content:null===(_=null===(D=null==X?void 0:X.cognitive_decisioning)||void 0===D?void 0:D.decisioning_factors)||void 0===_?void 0:_.join("\n\n"),citations:null===(E=null==X?void 0:X.cognitive_decisioning)||void 0===E?void 0:E.citations,styles:Z,docData:U,open:H}),(null===(z=(null===(R=null==X?void 0:X.cognitive_decisioning)||void 0===R?void 0:R.gaps_in_decision)||[])||void 0===z?void 0:z.length)>0&&t(b,{title:"Gaps in Decision",content:null===(I=null===(W=null==X?void 0:X.cognitive_decisioning)||void 0===W?void 0:W.gaps_in_decision)||void 0===I?void 0:I.join("\n\n"),citations:null===(T=null==X?void 0:X.cognitive_decisioning)||void 0===T?void 0:T.citations,styles:Z,docData:U,open:H}),0===(null===(A=(null===(j=null==X?void 0:X.cognitive_decisioning)||void 0===j?void 0:j.decisioning_factors)||[])||void 0===A?void 0:A.length)&&0===(null===(L=(null===(B=null==X?void 0:X.cognitive_decisioning)||void 0===B?void 0:B.gaps_in_decision)||[])||void 0===L?void 0:L.length)&&t(a,o({sx:{p:2,bgcolor:"#F8FAFC",borderRadius:"8px",border:"1px solid #E2E8F0"}},{children:t(c,o({sx:{fontSize:"13px",color:"#64748B"}},{children:"No cognitive decisioning data available for this section."}))}))]}):t(b,{title:"Deviation Analysis",content:"Deviation analysis content will appear here. This tab shows\n structural and semantic deviations identified between the two\n sections being compared.",citations:{},styles:Z,docData:U,open:H}):i(n,{children:[ao.length>0&&t(b,{title:$.sectionTitles.decisioningFactors,content:ao.join("\n\n"),citations:N.citations,styles:Z,open:H,docData:U}),so.length>0&&t(b,{title:$.sectionTitles.gaps,content:so.join("\n\n"),citations:N.citations,styles:Z,open:H,docData:U}),0===ao.length&&0===so.length&&t(a,o({sx:{p:2,bgcolor:"#F8FAFC",borderRadius:"8px",border:"1px solid #E2E8F0"}},{children:t(c,o({sx:{fontSize:"13px",color:"#64748B"}},{children:$.emptyStateMessage}))}))]})}))]}));return p.createPortal(xo,document.body)};export{g as default};
2
2
  //# sourceMappingURL=CognitivePopup.js.map