@viswa-test/test-citation 0.0.54 → 0.0.56
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.
- package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js +1 -1
- package/dist/features/CognitiveCompare/CognitiveCompare.js +1 -1
- package/dist/types/src/CommonConstants/CommonConstants.d.ts +4311 -64
- package/dist/types/src/CommonConstants/CommonConstants.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),t=require("react"),i=require("@mui/material"),o=require("lucide-react"),l=require("../../assests/svg/ButtonCognitiveIcon.js"),r=require("./OverlayComponent.js"),a=require("react-markdown"),s=require("./CognitiveComparehelpers.js"),c=require("./CognitiveCompareConfig.js"),u=require("./CognitivePopup.js"),d=require("./MoreFunctionsPopup.js"),v=require("./LoaderComponent.js"),f=require("rehype-raw"),p=require("./components/ThreeDotsLoader.js");function g(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var h=g(t),x=g(a),_=g(f),m="::",y=function(e){if(!e)return!0;var n=e.trim().toLowerCase();return n.includes("no equivalent")||"n/a"===n||"na"===n||"none"===n},b=function(e,n){var t,i,o,l,r,a,s;if(!e)return n;var c=null!==(a=null!==(l=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!==l?l:null===(r=e.evaluation_outputs)||void 0===r?void 0:r.output_value)&&void 0!==a?a:e.output_score;return null!==(s=null!=c?c:n)&&void 0!==s?s:""},S=h.default.memo(function(l){var r=l.content,a=l.sxStyles,c=l.deviationBadges,u=void 0===c?[]:c,d=l.highlights,v=void 0===d?[]:d,f=l.maintainRelativeOrder,p=void 0===f||f,g=l.highlightBg,h=t.useMemo(function(){return u.reduce(function(n,t){var i;return e.__assign(e.__assign({},n),((i={})[t.id]=t,i))},{})},[u]),m=t.useMemo(function(){return{mark:function(t){var i=t.children;return n.jsx("span",e.__assign({style:{backgroundColor:g,borderRadius:"2px"}},{children:i}))},span:function(t){var l,r,a,s,c,u=t.children,d=e.__rest(t,["children"]),v=d["data-badge-id"];if(!v)return n.jsx("span",e.__assign({},d,{children:u}));var f=h[v];return f?n.jsxs(i.Box,e.__assign({component:"span",sx:{position:"static",display:"inline"}},{children:[u,n.jsx(i.Box,e.__assign({ref:f.badgeRef,onClick:f.onClick,sx:e.__assign(e.__assign({position:"absolute",zIndex:30,display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"10px",bgcolor:(null===(l=f.style)||void 0===l?void 0:l.badgeBg)||"#EEF2FF",color:(null===(r=f.style)||void 0===r?void 0:r.badgeText)||B,border:"1px solid ".concat((null===(a=f.style)||void 0===a?void 0:a.badgeBorder)||"#C7D2FE"),borderRadius:"12px",px:1,py:.3,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",boxShadow:"0 1px 3px rgba(0,0,0,0.07)"},"left"===f.side?{right:"-16px",transform:"translateY(-20%) translateX(calc(100% + 8px))"}:{left:"-16px",transform:"translateY(-20%) translateX(calc(-100% - 8px))"}),f.isConnected&&f.style&&{outline:"2px solid ".concat(f.style.badgeBorder),outlineOffset:"1px"})},{children:n.jsxs(n.Fragment,{children:[n.jsx(i.Box,e.__assign({component:"span",sx:e.__assign({fontSize:"10px",fontWeight:700},"left"===f.side?{pr:.5,borderRight:"1px solid ".concat((null===(s=f.style)||void 0===s?void 0:s.badgeBorder)||"#C7D2FE")}:{})},{children:f.label})),"left"===f.side&&n.jsxs(n.Fragment,{children:[n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"10px",px:.25}},{children:null!=f.score&&"N/A"!==f.score&&"NA"!==f.score&&0!==f.score?"".concat(f.score):"N/A"===f.score||"NA"===f.score?"N/A":"Same"})),n.jsx(o.EllipsisVertical,{size:10,color:(null===(c=f.style)||void 0===c?void 0:c.badgeText)||"#3730A3"})]})]})}))]})):n.jsx("span",e.__assign({},d,{children:u}))}}},[h,p]),y=t.useMemo(function(){var e=r||"",n={},t=0;return function(){var i=null==u?void 0:u[0];if(i&&i.highlight){var o=i.highlight.replace(/\\(['’])/g,"$1"),l="__DEV_TOKEN_".concat(t++,"__");n[l]='<span data-badge-id="'.concat(i.id,'"><mark>').concat(o,"</mark></span>"),e=e.replace(o,l)}}(),v.forEach(function(i){if(i){var o=i.replace(/\\(['’])/g,"$1"),l="__HL_TOKEN_".concat(t++,"__");n[l]="<mark>".concat(o,"</mark>"),e=e.split(o).join(l)}}),Object.keys(n).forEach(function(t){e=e.split(t).join(n[t])}),e},[r,u,v]);return n.jsx(i.Typography,e.__assign({component:"div",sx:e.__assign(e.__assign({},a),{position:"relative",overflow:"visible","& p, & li, & ul, & ol":{position:"static",overflow:"visible"}})},{children:n.jsx(x.default,e.__assign({components:m,rehypePlugins:[_.default]},{children:s.safeStringify(y).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 l=e.deviationBadges||[],r=n.deviationBadges||[];if(l.length!==r.length)return!1;for(o=0;o<l.length;o++){if(l[o].id!==r[o].id)return!1;if(l[o].label!==r[o].label)return!1;if(l[o].isConnected!==r[o].isConnected)return!1}return!0}),R=function(e,n,t,i,o){void 0===o&&(o=14);var l=e+.5*(t-e),r=i-n;if(Math.abs(r)<3)return"M ".concat(e," ").concat(n," H ").concat(t);var a=r>0?1:-1,s=Math.min(o,Math.abs(r)/2,Math.abs(l-e)/2,Math.abs(t-l)/2);return["M ".concat(e," ").concat(n),"H ".concat(l-s),"Q ".concat(l," ").concat(n," ").concat(l," ").concat(n+a*s),"V ".concat(i-a*s),"Q ".concat(l," ").concat(i," ").concat(l+s," ").concat(i),"H ".concat(t)].join(" ")},I={id:"",title:""},C={isLoading:!1,open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,isOrphan:!1,docData:null,deviationData:null},B="#3730A3",j=function(e,n,t,i,o){void 0===t&&(t=300);var l=e.style.scrollBehavior;e.style.scrollBehavior="auto";var r=e.scrollTop,a=n-r,s=null,c=function(u){null===s&&(s=u);var d,v=u-s;v<t?(e.scrollTop=(d=v,d/=t,a*(--d*d*d+1)+r),o&&o(),requestAnimationFrame(c)):(e.scrollTop=n,e.style.scrollBehavior=l,o&&o(),i&&i())};requestAnimationFrame(c)};exports.SHARED_MARKDOWN_STYLES=c.SHARED_MARKDOWN_STYLES,exports.default=function(a){var f,g,x,_,w,E,T,F,M,k,A,D,O,H,L,N,W,z=a.componentHeaderText,P=void 0===z?"Contract Comparison":z,V=a.treeData,q=a.comparisonConfig,Y=a.leftColumnTitleText,K=a.rightColumnTitleText,X=a.markdownStyles,U=a.displayConfig,G=void 0===U?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0}:U,$=a.popupConfig,J=a.deviationData,Q=void 0===J?{}:J,Z=t.useState(G.maintainRelativeOrder),ee=Z[0],ne=Z[1],te=t.useState(!1),ie=te[0],oe=te[1],le=t.useState(!1),re=le[0],ae=le[1],se=t.useState(null),ce=se[0],ue=se[1],de=t.useState(!1),ve=de[0],fe=de[1],pe=t.useState(!1),ge=pe[0],he=pe[1],xe=t.useRef(!1),_e=t.useState(null),me=_e[0],ye=_e[1],be=t.useState(new Set),Se=be[0],Re=be[1],Ie=t.useState([]),Ce=Ie[0],Be=Ie[1],je=t.useRef(null),we=t.useRef(!1),Ee=t.useRef(null),Te=t.useRef({}),Fe=t.useRef([]),Me=t.useRef(!1),ke=t.useRef(!1),Ae=t.useRef(null),De=t.useMemo(function(){return(null==V?void 0:V.cognitive_decisioning)||{}},[V]),Oe=t.useState(null),He=Oe[0],Le=Oe[1],Ne=t.useRef(null),We=t.useState({width:0,height:0}),ze=We[0],Pe=We[1],Ve=t.useMemo(function(){return e.__assign(e.__assign({},c.SHARED_MARKDOWN_STYLES),X)},[X]),qe=t.useState({isLoading:null!==(f=null==G?void 0:G.isLoading)&&void 0!==f&&f,open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,isOrphan:!1,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null,deviationData:null}),Ye=qe[0],Ke=qe[1],Xe=t.useState({isLoading:null!==(g=null==G?void 0:G.isLoading)&&void 0!==g&&g,open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,isOrphan:!1,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null,deviationData:null}),Ue=Xe[0],Ge=Xe[1],$e=t.useRef(null),Je=t.useRef(null),Qe=t.useRef(null),Ze=t.useRef(null),en=t.useRef(null),nn=t.useRef(null),tn=t.useRef(null),on=t.useRef(null),ln=t.useRef(!1),rn=t.useRef(null);t.useEffect(function(){rn.current=null},[Ye.sectionIdx,Ye.open]);var an=t.useCallback(function(){Le(null),Ke(C),ye(null)},[]),sn=t.useCallback(function(){Ge(C)},[]),cn=t.useCallback(function(){var e;if(Ye.anchorEl&&Ye.refSectionTitle){var n=Ye.anchorEl.getBoundingClientRect(),t=(null===(e=null==Ne?void 0:Ne.current)||void 0===e?void 0:e.offsetHeight)||0,i=Math.min(680,window.innerWidth-24),o=window.innerHeight-n.bottom-12-12,l=n.top-12-12,r=o<t&&l>o;null!==rn.current?!0===rn.current&&(r=l>=t||l>=o):r=!(o>=t||o>=l),rn.current=r;var a=r?l:o,s=Math.min(t||9999,a),c=r?n.top-12-s:n.bottom+12,u=n.left+n.width/2,d=u-i/2,v=Math.max(12,Math.min(d,window.innerWidth-i-12)),f=Math.max(14,Math.min(u-v,i-10-4));Le({top:c,left:v,arrowLeft:f,openAbove:r,maxHeight:a})}},[Ye.anchorEl,Ye.refSectionTitle]);t.useEffect(function(){if(Ye.open){window.addEventListener("resize",cn);var e=requestAnimationFrame(cn),n=null;return Ne.current&&(n=new ResizeObserver(function(){cancelAnimationFrame(e),e=requestAnimationFrame(cn)})).observe(Ne.current),function(){cancelAnimationFrame(e),window.removeEventListener("resize",cn),n&&n.disconnect()}}},[Ye.open,cn]),t.useEffect(function(){var e=$e.current;if(e&&Ye.open){var n=function(e){Ne.current&&Ne.current.contains(e.target)||(Le(null),an())};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})}}},[Ye.open,an]),t.useEffect(function(){var e=$e.current;if(e&&Ue.open){var n=function(){sn()};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})}}},[Ue.open,sn]);var un=t.useMemo(function(){var e,n,t,i,o,l,r;return{fields:null!==(e=null==q?void 0:q.fields)&&void 0!==e?e:c.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(t=null===(n=null==q?void 0:q.thresholds)||void 0===n?void 0:n.high)&&void 0!==t?t:c.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(o=null===(i=null==q?void 0:q.thresholds)||void 0===i?void 0:i.medium)&&void 0!==o?o:c.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(r=null===(l=null==q?void 0:q.thresholds)||void 0===l?void 0:l.exact)&&void 0!==r?r:c.DEFAULT_COMPARISON_CONFIG.thresholds.exact}}},[q]),dn=t.useMemo(function(){if(V&&Object.keys(V).length>0)try{var n=function(n,t,i){var o,l,r,a;void 0===t&&(t=!1),void 0===i&&(i=null);var c=n.nodes||n,u=[],d=[],v=n.base_root_id,f=n.input_index_map||{0:"left",1:"right"},p=n[v]||c[v];if(!p||!1===p.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[]};var g=function(t,o){var l,r,a,u=n[t]||c[t];if(!u||!1===u.display_node)return null;var d=s.getSideData(u,o,f),v=!1!==(null===(l=d.attributes)||void 0===l?void 0:l.display_title),p=!1!==(null===(r=d.attributes)||void 0===r?void 0:r.display_content),h=!!d.title.trim(),x=!!d.content.trim(),_=s.getRationale(u),m=(null===(a=null==i?void 0:i[t])||void 0===a?void 0:a.evaluation_result)||u.evaluation_result||null,y=[];u.next&&Object.values(u.next).forEach(function(e){var n=c[e];if(n&&!1!==n.display_node){var t=g(e,o);t&&y.push(t)}});var b=!(!h&&!x);return e.__assign(e.__assign({id:t,title:h?d.title:"",content:x?d.content:"",displayTitle:v,displayContent:p,subsections:y},b?_:{score:void 0,relation:"not_defined"}),{evaluationResult:m})};if(t){var h=function(t,o){var l,r,a,u,d,v,p,g,x,_,m,y,b,S,R,I,C,B,j,w,E;void 0===o&&(o=0);var T=[],F=[];if(!t)return{refSections:T,baseSections:F};var M={},k={},A=-1,D=-1;for(var O in t){var H=t[O],L=n[H]||c[H];if(L&&!1!==L.display_node){var N=s.getRationale(L),W=(null===(l=null==i?void 0:i[H])||void 0===l?void 0:l.evaluation_result)||L.evaluation_result||null,z=s.getSideData(L,"1",f),P=s.getSideData(L,"0",f),V=!1!==(null===(r=z.attributes)||void 0===r?void 0:r.display_title)&&z.title.trim()||!1!==(null===(a=z.attributes)||void 0===a?void 0:a.display_content)&&z.content.trim(),q=!1!==(null===(u=P.attributes)||void 0===u?void 0:u.display_title)&&P.title.trim()||!1!==(null===(d=P.attributes)||void 0===d?void 0:d.display_content)&&P.content.trim(),Y=Number(null!==(p=null===(v=z.attributes)||void 0===v?void 0:v.display_index)&&void 0!==p?p:A--),K=Number(null!==(x=null===(g=P.attributes)||void 0===g?void 0:g.display_index)&&void 0!==x?x:D--),X=M[Y]||e.__assign(e.__assign({id:H,title:!1!==(null===(_=z.attributes)||void 0===_?void 0:_.display_title)?z.title:"",content:!1!==(null===(m=z.attributes)||void 0===m?void 0:m.display_content)?z.content:"",subsections:[]},V?N:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:Y,evaluationResult:W,displayContent:null===(y=z.attributes)||void 0===y?void 0:y.display_content,displayTitle:null===(b=z.attributes)||void 0===b?void 0:b.display_title}),U=k[K]||e.__assign(e.__assign({id:H,title:!1!==(null===(S=P.attributes)||void 0===S?void 0:S.display_title)?P.title:"",content:!1!==(null===(R=P.attributes)||void 0===R?void 0:R.display_content)?P.content:"",subsections:[]},q?N:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:K,evaluationResult:W,displayContent:null===(I=P.attributes)||void 0===I?void 0:I.display_content,displayTitle:null===(C=P.attributes)||void 0===C?void 0:C.display_title});Number(Y)>=0&&Number(K)>=0&&((null===(B=X.refIndexes)||void 0===B?void 0:B.includes(Number(K)))||null===(j=X.refIndexes)||void 0===j||j.push(Number(K)),(null===(w=U.refIndexes)||void 0===w?void 0:w.includes(Number(Y)))||null===(E=U.refIndexes)||void 0===E||E.push(Number(Y))),M[Y]=X,k[K]=U;var G=h(L.next,o+1),$=G.refSections,J=G.baseSections;$.length>0&&(X.subsections=e.__spreadArray(e.__spreadArray([],X.subsections||[],!0),$,!0)),J.length>0&&(U.subsections=e.__spreadArray(e.__spreadArray([],U.subsections||[],!0),J,!0))}}return T=Object.values(M).map(function(e){return e}),F=Object.values(k).map(function(e){return e}),T.sort(function(e,n){return e.selfIndex<0&&n.selfIndex>=0?1:e.selfIndex>=0&&n.selfIndex<0?-1:e.selfIndex-n.selfIndex}),F.sort(function(e,n){return e.selfIndex<0&&n.selfIndex>=0?1:e.selfIndex>=0&&n.selfIndex<0?-1:e.selfIndex-n.selfIndex}),{refSections:T,baseSections:F}},x=h(p.next),_=x.refSections,m=x.baseSections;d=_,u=m}else p.next&&Object.values(p.next).forEach(function(e){var t=n[e]||c[e];t&&!1!==t.display_node&&(u.push(g(e,"0")||{id:e,title:"",content:"",subsections:[]}),d.push(g(e,"1")||{id:e,title:"",content:"",subsections:[]}))});return{activeProposed:{title:(null===(l=null===(o=p.comparison_inputs)||void 0===o?void 0:o[f[0]])||void 0===l?void 0:l.title)||"Uploaded Contract",description:p.decision_scope_description||"",sections:u},activeVariants:[{id:"tree-variant-1",title:(null===(a=null===(r=p.comparison_inputs)||void 0===r?void 0:r[f[1]])||void 0===a?void 0:a.title)||"Reference Template",similarity:0,sections:d,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:p.decision_scope_description||""},fields:{}}}}]}}(V,ee,Q);return e.__assign(e.__assign({},n),{parseError:null})}catch(e){return console.error("Data Transformation Error: ",e),{activeProposed:{},activeVariants:[],parseError:e instanceof Error?e.message:"Unknown Parsing Error"}}return{activeProposed:{},activeVariants:[],parseError:"Tree data is required"}},[JSON.stringify(V),ee,JSON.stringify(Q)]),vn=dn.activeProposed,fn=dn.activeVariants,pn=dn.parseError;t.useEffect(function(){pn&&ue("Failed to load comparison: ".concat(pn))},[pn]);var gn=t.useState(null),hn=gn[0];gn[1];var xn=t.useState({}),_n=xn[0],mn=xn[1],yn=t.useState({}),bn=yn[0],Sn=yn[1],Rn=(null==fn?void 0:fn[0])||I,In=null===(w=null===(x=null==V?void 0:V.documents)||void 0===x?void 0:x[null===(_=null==V?void 0:V.input_index_map)||void 0===_?void 0:_[0]])||void 0===w?void 0:w.title,Cn=null===(F=null===(E=null==V?void 0:V.documents)||void 0===E?void 0:E[null===(T=null==V?void 0:V.input_index_map)||void 0===T?void 0:T[1]])||void 0===F?void 0:F.title,Bn=s.safeStringify(Y||In||"Uploaded Contract"),jn=s.safeStringify(K||Cn||"Reference Template"),wn=t.useMemo(function(){return(null==vn?void 0:vn.sections)||[]},[null==vn?void 0:vn.sections]),En=t.useMemo(function(){return Rn.sections||[]},[Rn.sections]),Tn=wn.length>0||En.length>0,Fn=Rn.analysis,Mn=s.safeStringify(null===(k=null===(M=null==Fn?void 0:Fn.rule_difference_comparison)||void 0===M?void 0:M.summary)||void 0===k?void 0:k.overall_summary),kn=!!Mn.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),An=null!==(A=null==V?void 0:V.base_root_id)&&void 0!==A?A:"-1";null==V||V[An];var Dn=(null===(D=null==Q?void 0:Q[An])||void 0===D?void 0:D.evaluation_result)||(null===(H=null===(O=null==V?void 0:V.nodes)||void 0===O?void 0:O[An])||void 0===H?void 0:H.evaluation_result)||null,On=b(Dn),Hn=s.generateColorPalette(null!==(W=null===(N=null===(L=null==Dn?void 0:Dn.evaluation_outputs)||void 0===L?void 0:L.metadata)||void 0===N?void 0:N.label_color)&&void 0!==W?W:""),Ln=t.useMemo(function(){var e,n,t={},i={},o=null===(e=null==V?void 0:V.input_index_map)||void 0===e?void 0:e[0],l=null===(n=null==V?void 0:V.input_index_map)||void 0===n?void 0:n[1],r=new Map,a=function(e){return e&&e.id?(r.has(e.id)||r.set(e.id,s.safeStringify(e.content||"").replace(/\\n/g,"\n")),r.get(e.id)):""},c=function(e,n,s,u,d){var v,f,p,g,h,x,_,b;e&&!d&&function(e,n,s,c){var u,d=(null===(u=null==e?void 0:e.evaluationResult)||void 0===u?void 0:u.deviations)||{};Object.keys(d).sort().forEach(function(u){var v=d[u];if(v){var f=v[o],p=v[l],g=!1,h=!1;if(!y(f)){var x=f.replace(/\\(['’])/g,"$1").replace(/\\n/g,"\n");if(n&&x){var _=a(n);_.includes(x)&&(g=!0,r.set(n.id,_.replace(x,"__TOKEN__")))}}if(!y(p)){var b=p.replace(/\\(['’])/g,"$1").replace(/\\n/g,"\n");if(s&&b){var S=a(s);S.includes(b)&&(h=!0,r.set(s.id,S.replace(b,"__TOKEN__")))}}if(g||h){var R="".concat(e.id).concat(m).concat(u);void 0===t[R]&&(void 0===i[c]&&(i[c]=1),t[R]=i[c]++)}}})}(e,n,s,u);for(var S=Math.max((null===(v=null==n?void 0:n.subsections)||void 0===v?void 0:v.length)||0,(null===(f=null==s?void 0:s.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),R=0;R<S;R++)c((null===(g=null==e?void 0:e.subsections)||void 0===g?void 0:g[R])||(null===(h=null==n?void 0:n.subsections)||void 0===h?void 0:h[R])||(null===(x=null==s?void 0:s.subsections)||void 0===x?void 0:x[R]),null===(_=null==n?void 0:n.subsections)||void 0===_?void 0:_[R],null===(b=null==s?void 0:s.subsections)||void 0===b?void 0:b[R],u,!1)};return wn.forEach(function(e,n){var t,i=n+1;ee&&void 0!==e.selfIndex&&e.selfIndex>=0&&(i=e.selfIndex+1);var o=null;if(ee){var l=null===(t=e.refIndexes)||void 0===t?void 0:t[0];o=En.find(function(e){return e.selfIndex===l})}else o=En[n];c(e,e,o,i,!0)}),En.forEach(function(e,n){var t,i=n+1,o=!1;if(ee){var l=null===(t=e.refIndexes)||void 0===t?void 0:t[0],r=wn.find(function(e){return e.selfIndex===l});r&&void 0!==r.selfIndex&&r.selfIndex>=0?i=r.selfIndex+1:(o=!0,void 0!==e.selfIndex&&e.selfIndex>=0&&(i=e.selfIndex+1))}else n>=wn.length&&(o=!0);o&&c(e,null,e,i,!0)}),t},[wn,En,ee,V]),Nn=t.useRef({}),Wn=function(e){return Nn.current[e]||(Nn.current[e]=h.default.createRef()),Nn.current[e]},zn=t.useCallback(function(){var e,n,t,i;fe(!1),ke.current=!1;var o=Ae.current,l=Un.current;if(null!==o)if("string"==typeof o&&o.includes(m)){var r=o.split(m);(a=null===(e=gt.current[r[2]])||void 0===e?void 0:e.current)&&(a.style.paddingTop="0px")}else{var a;(a=null===(n=ut.current[o])||void 0===n?void 0:n.current)&&(a.style.paddingTop="0px")}if(null!==l)if("string"==typeof l&&l.includes(m)){r=l.split(m);(s=null===(t=ht.current[r[3]])||void 0===t?void 0:t.current)&&(s.style.paddingTop="0px")}else{var s;(s=null===(i=dt.current[l])||void 0===i?void 0:i.current)&&(s.style.paddingTop="0px")}it(null),Ae.current=null,Un.current=null,he(!1),ae(!1),Ze.current&&(Ze.current.style.height="0px"),en.current&&(en.current.style.height="0px"),nn.current&&(nn.current.style.height="0px"),tn.current&&(tn.current.style.height="0px")},[]),Pn=t.useCallback(function(e,n,t,i,o,l,r){var a,c,u,d=s.safeStringify(null==n?void 0:n.id)||s.safeStringify(null==t?void 0:t.id)||"",v=(d?De[d]:null)||(null==n?void 0:n.cognitiveData)||(null==t?void 0:t.cognitiveData)||{section_id:d,decisioning:[],gap:[],relevance_score:0},f=null!==(c=null===(a=Nn.current[i])||void 0===a?void 0:a.current)&&void 0!==c?c:null;return{isLoading:null!==(u=null==G?void 0:G.isLoading)&&void 0!==u&&u,open:!0,sectionTitle:(null==n?void 0:n.displayTitle)?null==n?void 0:n.title:"no title",refSectionTitle:(null==t?void 0:t.displayTitle)?null==t?void 0:t.title:"no title",cognitiveData:v,anchorEl:e,sectionAnchorEl:f,badgeStyle:l||null,sectionIdx:i,docData:{documents:null==V?void 0:V.documents,input_index_map:null==V?void 0:V.input_index_map},deviationData:(null==n?void 0:n.evaluationResult)||(null==t?void 0:t.evaluationResult)||null,isOrphan:!!o}},[De,V]),Vn=t.useCallback(function(e){sn(),Le(null),Ke(e)},[sn]),qn=function(e,n,t,i,o,l){e.stopPropagation(),Ue.open&&Ue.sectionIdx===o?sn():(an(),Ge(Pn(e.currentTarget,n,i,o,t,l)))},Yn=t.useCallback(function(){null!==Ue.sectionIdx&&Ue.anchorEl?Vn(e.__assign(e.__assign({},Ue),{open:!0})):sn()},[Ue,sn,Vn]),Kn=t.useCallback(function(){var e=Ue.sectionIdx,n=Ue.isOrphan;sn(),null!==e&&(n?ue("No counterpart exists to connect to."):(ke.current&&zn(),Re(function(n){return n.has(e)?new Set:new Set([e])})))},[Ue.sectionIdx,sn,zn]),Xn=t.useRef(null),Un=t.useRef(null),Gn=t.useRef(null),$n=t.useRef(null),Jn=t.useRef(null),Qn=t.useState([]),Zn=Qn[0],et=Qn[1],nt=t.useState(null),tt=nt[0],it=nt[1];t.useRef(null);var ot=t.useState(null),lt=ot[0],rt=ot[1],at=t.useMemo(function(){return un.fields.filter(function(e){var n=e.key;return(!Tn||"description"!==n)&&(s.hasValue(null==vn?void 0:vn[n])||s.hasValue(Rn[n]))})},[vn,Rn,Tn,un.fields]),st=t.useRef({}),ct=t.useRef({}),ut=t.useRef({}),dt=t.useRef({}),vt=t.useRef({}),ft=t.useRef({}),pt=t.useRef({}),gt=t.useRef({}),ht=t.useRef({});at.forEach(function(e){for(var n=e.key,t=0;t<Math.max(wn.length,En.length);t+=1)ut.current[t]||(ut.current[t]=h.default.createRef()),dt.current[t]||(dt.current[t]=h.default.createRef()),vt.current[t]||(vt.current[t]=h.default.createRef()),ft.current[t]||(ft.current[t]=h.default.createRef()),pt.current[t]||(pt.current[t]=h.default.createRef());st.current[n]||(st.current[n]=h.default.createRef()),ct.current[n]||(ct.current[n]=h.default.createRef())});for(var xt=0;xt<Math.max(wn.length,En.length);xt+=1)ut.current[xt]||(ut.current[xt]=h.default.createRef()),dt.current[xt]||(dt.current[xt]=h.default.createRef()),vt.current[xt]||(vt.current[xt]=h.default.createRef()),ft.current[xt]||(ft.current[xt]=h.default.createRef()),pt.current[xt]||(pt.current[xt]=h.default.createRef());t.useEffect(function(){if(hn){var e=un.fields.find(function(e){return e.analysisKey===hn||e.key===hn});if(e){var n=st.current[e.key]||ct.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[hn,un.fields]);var _t=t.useCallback(function(e){var n,t,i,o,l,r,a,s,c,u=null===(n=null==Fn?void 0:Fn.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!u||!u[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var d=u[e],v=(null==d?void 0:d.relation)||(null===(i=null===(t=null==d?void 0:d.highlights)||void 0===t?void 0:t.ruleA_spans)||void 0===i?void 0:i.length)||(null===(l=null===(o=null==d?void 0:d.highlights)||void 0===o?void 0:o.ruleB_spans)||void 0===l?void 0:l.length)||(null==d?void 0:d.mappings)&&d.mappings.length>0;if(d.mappings){var f=d.mappings[0]||{};return{score:d.score,relation:f.relation||"",highlightsA:(null===(r=f.highlights)||void 0===r?void 0:r.ruleA_spans)||[],highlightsB:(null===(a=f.highlights)||void 0===a?void 0:a.ruleB_spans)||[],hasContent:!!v}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(s=d.highlights)||void 0===s?void 0:s.ruleA_spans)||[],highlightsB:(null===(c=d.highlights)||void 0===c?void 0:c.ruleB_spans)||[],hasContent:!!v}},[Fn]),mt=t.useCallback(function(n){var t,i,o,l,r,a,c,u=wn[n],d=En[n],v=(null==u?void 0:u.relation)&&"not_defined"!==u.relation,f=(null==d?void 0:d.relation)&&"not_defined"!==d.relation;s.safeStringify(null==u?void 0:u.id)||s.safeStringify(null==d?void 0:d.id);var p=!(!(null==u?void 0:u.cognitiveData)&&!(null==d?void 0:d.cognitiveData));if(!v&&!f&&!p)return e.__assign(e.__assign({},s.generateColorPalette(B)),{label:"Not Defined"});var g=null!==(i=null!==(t=null==u?void 0:u.evaluationResult)&&void 0!==t?t:null==d?void 0:d.evaluationResult)&&void 0!==i?i:null,h=null===(o=null==g?void 0:g.evaluation_outputs)||void 0===o?void 0:o.output_value,x=null!==(a=null===(r=null===(l=null==g?void 0:g.evaluation_outputs)||void 0===l?void 0:l.metadata)||void 0===r?void 0:r.label_color)&&void 0!==a?a:B;return null!=g?e.__assign(e.__assign({},s.generateColorPalette(x)),{label:null!==(c=h)&&void 0!==c?c:""}):e.__assign(e.__assign({},s.generateColorPalette(x)),{label:null})},[wn,En,De,un,_t]),yt=t.useCallback(function(n){for(var t,i,o,l,r,a,c,u,d,v=n.split("-").map(Number),f=wn[v[0]],p=En[v[0]],g=1;g<v.length;g++)(null==f?void 0:f.subsections)&&(f=f.subsections[v[g]]),(null==p?void 0:p.subsections)&&(p=p.subsections[v[g]]);if(!f&&!p)return null;var h=(null==f?void 0:f.relation)&&"not_defined"!==f.relation,x=(null==p?void 0:p.relation)&&"not_defined"!==p.relation,_=s.safeStringify(null==f?void 0:f.id)||s.safeStringify(null==p?void 0:p.id)||"",m=!(!(null==f?void 0:f.cognitiveData)&&!(null==p?void 0:p.cognitiveData));if(!h&&!x&&!m)return e.__assign(e.__assign({},s.generateColorPalette(B)),{label:"Not Defined"});null!==(i=null!==(t=null==f?void 0:f.cognitiveRelevanceScore)&&void 0!==t?t:null==p?void 0:p.cognitiveRelevanceScore)&&void 0!==i||_&&(null===(o=De[_])||void 0===o||o.relevance_score);var y=null!==(r=null!==(l=null==f?void 0:f.evaluationResult)&&void 0!==l?l:null==p?void 0:p.evaluationResult)&&void 0!==r?r:null,b=null===(a=null==y?void 0:y.evaluation_outputs)||void 0===a?void 0:a.output_value,S=null!==(d=null===(u=null===(c=null==y?void 0:y.evaluation_outputs)||void 0===c?void 0:c.metadata)||void 0===u?void 0:u.label_color)&&void 0!==d?d:B;return null!=y?e.__assign(e.__assign({},s.generateColorPalette(S)),{label:null!=b?b:""}):e.__assign(e.__assign({},s.generateColorPalette(S)),{label:null})},[wn,En,De,un]),bt=t.useCallback(function(){var e,n,t,i,o,l,r,a,c,u,d,v,f,p,g,h,x,_,y,b,S,I;if(!ln.current&&!we.current){ln.current=!0;try{if(!Xn.current)return;var C=function(e){var n=e.split("-"),t=n[0];if(!_n[t]&&!1===ee)return!1;if(ee&&!_n["left-".concat(t)]&&!_n["right-".concat(t)]&&!_n[t])return!1;for(var i=t,o=1;o<n.length-1;o++)if(i+="-".concat(n[o]),!bn[i])return!1;return!0},B=Xn.current.getBoundingClientRect();Pe({width:B.width,height:B.height});var j=[];if(at.forEach(function(e){var n,t,i=e.key,o=null===(n=st.current[i])||void 0===n?void 0:n.current,l=null===(t=ct.current[i])||void 0===t?void 0:t.current;o&&l&&(o.style.height="auto",l.style.height="auto",o.style.minHeight="0px",l.style.minHeight="0px")}),!we.current){for(var w=0;w<Math.max(wn.length,En.length);w++){var E=null===(e=ut.current[w])||void 0===e?void 0:e.current,T=null===(n=dt.current[w])||void 0===n?void 0:n.current;E&&(E.style.height="auto",E.style.minHeight="0px"),T&&(T.style.height="auto",T.style.minHeight="0px")}ee||Object.keys(gt.current).forEach(function(e){var n,t;if(C(e)){var i=null===(n=gt.current[e])||void 0===n?void 0:n.current,o=null===(t=ht.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 F={};at.forEach(function(e){var n,t,i=e.key,o=null===(n=st.current[i])||void 0===n?void 0:n.current,l=null===(t=ct.current[i])||void 0===t?void 0:t.current;if(o&&l){var r=o.getBoundingClientRect(),a=l.getBoundingClientRect();F[i]=Math.max(r.height,a.height)}});var M={left:{},right:{}},k={};if(!we.current)if(ee){if(ve&&null!==tt)if("number"==typeof tt){var A=tt,D=wn[A],O=null===(o=ut.current[A])||void 0===o?void 0:o.current;O&&D&&(D.refIndexes||[]).forEach(function(e){var n,t=En.findIndex(function(n){return n.selfIndex===e}),i=null===(n=dt.current[t])||void 0===n?void 0:n.current;if(i&&(_n["left-".concat(A)]||_n["right-".concat(t)])){var o=Math.max(O.getBoundingClientRect().height,i.getBoundingClientRect().height);M.left[A]=Math.max(M.left[A]||0,o),M.right[t]=Math.max(M.right[t]||0,o)}})}else{var H=tt.split(m)[2];if(H){E=null===(l=gt.current[H])||void 0===l?void 0:l.current,T=null===(r=ht.current[H])||void 0===r?void 0:r.current;if(E&&T){L=Math.max(E.getBoundingClientRect().height,T.getBoundingClientRect().height);k[H]=Math.max(k[H]||0,L)}}}}else{Object.keys(gt.current).forEach(function(e){var n,t;if(C(e)){var i=null===(n=gt.current[e])||void 0===n?void 0:n.current,o=null===(t=ht.current[e])||void 0===t?void 0:t.current;if(i&&o&&null!==i.offsetParent&&null!==o.offsetParent){var l=i.getBoundingClientRect(),r=o.getBoundingClientRect(),a=Math.max(l.height,r.height);k[e]=a,i.style.minHeight="".concat(a,"px"),o.style.minHeight="".concat(a,"px")}}});for(w=0;w<Math.min(wn.length,En.length);w++){var E=null===(t=ut.current[w])||void 0===t?void 0:t.current,T=null===(i=dt.current[w])||void 0===i?void 0:i.current;if(E&&T){var L=Math.max(E.getBoundingClientRect().height,T.getBoundingClientRect().height);M.left[w]=L,M.right[w]=L}}}if(at.forEach(function(e){var n,t,i=e.key,o=null===(n=st.current[i])||void 0===n?void 0:n.current,l=null===(t=ct.current[i])||void 0===t?void 0:t.current;if(o&&l){var r=F[i];o.style.minHeight="".concat(r,"px"),l.style.minHeight="".concat(r,"px")}}),we.current||(Object.entries(M.left).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=ut.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),Object.entries(M.right).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=dt.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),ee||Object.keys(k).forEach(function(e){var n,t,i=null===(n=gt.current[e])||void 0===n?void 0:n.current,o=null===(t=ht.current[e])||void 0===t?void 0:t.current;if(i&&o&&k[e]){var l=k[e];i.style.minHeight="".concat(l,"px"),o.style.minHeight="".concat(l,"px")}})),ee)wn.forEach(function(e,n){var t;(null===(t=ut.current[n])||void 0===t?void 0:t.current)&&(e.refIndexes||[]).forEach(function(e){var t,i,o,l,r,a,s,c,u,d,v=En.findIndex(function(n){return n.selfIndex===e});if(-1!==v){var f=null===(t=vt.current[n])||void 0===t?void 0:t.current,p=null===(i=ft.current[v])||void 0===i?void 0:i.current;if(f&&p){var g=f.getBoundingClientRect(),h=p.getBoundingClientRect(),x=g.right-B.left,_=h.left-B.left,m=g.top+g.height/2-B.top,y=h.top+h.height/2-B.top;if(ve&&tt===n){var b=null!==(l=null===(o=on.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==l?l:0,S=null!==(a=null===(r=Qe.current)||void 0===r?void 0:r.getBoundingClientRect().top)&&void 0!==a?a:0,R=b+(null!==(c=null===(s=on.current)||void 0===s?void 0:s.clientHeight)&&void 0!==c?c:1/0),I=S+(null!==(d=null===(u=Qe.current)||void 0===u?void 0:u.clientHeight)&&void 0!==d?d:1/0),C=g.top+g.height/2,w=function(e,n,t){return Math.max(n,Math.min(t,e))};m=w(C,b,R)-B.top,y=w(C,S,I)-B.top}var E=mt(n);E&&j.push({id:"line-".concat(n,"-").concat(v),x1:x,y1:m,x2:_,y2:y,style:E,sectionIdx:n,targetRightIdx:v})}}})});else{for(w=0;w<Math.min(wn.length,En.length);w++){var N=null===(a=ut.current[w])||void 0===a?void 0:a.current,W=null===(c=dt.current[w])||void 0===c?void 0:c.current;if(N&&W){var z=N.getBoundingClientRect(),P=W.getBoundingClientRect(),V=Math.max(z.top,P.top)+18-B.top,q=(null===(u=En[w])||void 0===u?void 0:u.id)||"sec-".concat(w);(Q=mt(w))&&j.push({id:q,x1:z.right-B.left,y1:V,x2:P.left-B.left,y2:V,style:Q,sectionIdx:w,hasCognitive:!!((null===(d=wn[w])||void 0===d?void 0:d.cognitiveData)||(null===(v=En[w])||void 0===v?void 0:v.cognitiveData)||q&&De[q]),isSubSection:!1})}}Object.keys(gt.current).forEach(function(e){var n,t,i,o,l,r;if(C(e)){var a=null===(n=gt.current[e])||void 0===n?void 0:n.current,c=null===(t=ht.current[e])||void 0===t?void 0:t.current;if(a&&c){for(var u=e.split("-").map(Number),d=wn[u[0]],v=En[u[0]],f=1;f<u.length;f++)(null==d?void 0:d.subsections)&&(d=d.subsections[u[f]]),(null==v?void 0:v.subsections)&&(v=v.subsections[u[f]]);var p=!!d&&((null===(i=d.displayTitle)||void 0===i||i)&&s.hasValue(d.title)),g=!!d&&((null===(o=d.displayContent)||void 0===o||o)&&s.hasValue(d.content)),h=!!v&&((null===(l=v.displayTitle)||void 0===l||l)&&s.hasValue(v.title)),x=!!v&&((null===(r=v.displayContent)||void 0===r||r)&&s.hasValue(v.content));if(p&&g||h&&x){var _=a.getBoundingClientRect(),m=c.getBoundingClientRect(),y=Math.max(_.top,m.top)+16-B.top,b=yt(e);b&&"Not Defined"!==b.label&&j.push({id:"subsec-".concat(e),x1:_.right-B.left,y1:y,x2:m.left-B.left,y2:y,style:b,sectionIdx:u[0],isSubSection:!0,subSectionKeyPath:e,hasCognitive:!(!(null==d?void 0:d.cognitiveData)&&!(null==v?void 0:v.cognitiveData))})}}}})}if(ve&&"string"==typeof tt&&tt.includes(m)){var Y=tt.split(m),K=Y[0],X=Y[1],U=Y[2],G=(Y[3],"".concat(K).concat(m).concat(X)),$=null===(f=vt.current[G])||void 0===f?void 0:f.current,J=null===(p=ft.current[G])||void 0===p?void 0:p.current;if($&&J){var Q,Z=$.getBoundingClientRect(),ne=J.getBoundingClientRect(),te=Z.right-B.left,ie=ne.left-B.left,oe=Z.top+Z.height/2-B.top,le=ne.top+ne.height/2-B.top;if(ee){var re=null!==(h=null===(g=on.current)||void 0===g?void 0:g.getBoundingClientRect().top)&&void 0!==h?h:0,ae=null!==(_=null===(x=Qe.current)||void 0===x?void 0:x.getBoundingClientRect().top)&&void 0!==_?_:0,se=re+(null!==(b=null===(y=on.current)||void 0===y?void 0:y.clientHeight)&&void 0!==b?b:1/0),ce=ae+(null!==(I=null===(S=Qe.current)||void 0===S?void 0:S.clientHeight)&&void 0!==I?I:1/0),ue=function(e,n,t){return Math.max(n,Math.min(t,e))};oe=ue(Z.top+Z.height/2,re,se)-B.top,le=ue(ne.top+ne.height/2,ae,ce)-B.top}(Q=yt(U))&&j.push({id:"line-subsec-".concat(G),x1:te,y1:oe,x2:ie,y2:le,style:Q,sectionIdx:Number(U.split("-")[0]),isSubSection:!0,subSectionKeyPath:tt})}}if(et(j),$n.current&&Jn.current){var de=$n.current.getBoundingClientRect(),fe=Jn.current.getBoundingClientRect(),pe=(de.top+de.height/2-B.top+fe.top+fe.height/2-B.top)/2;rt({x1:de.right-B.left,x2:fe.left-B.left,y:pe})}else rt(null);if(Se.size>0){var ge=[],he=on.current,xe=Qe.current;if(he&&xe){var _e=[],me=he.getBoundingClientRect().top,ye=xe.getBoundingClientRect().top,be=me+he.clientHeight,Re=ye+xe.clientHeight,Ie=he.scrollTop,Ce=xe.scrollTop,je=B.top,Ee=function(e,n,t){return Math.max(n,Math.min(t,e))};Se.forEach(function(e){var n,t,i,o,l;if("string"==typeof e&&e.includes(m)){var r=e.split(m),a=r[0],s=r[1],c=r[2],u=(r[3],"".concat(a).concat(m).concat(s)),d=null===(n=vt.current[u])||void 0===n?void 0:n.current,v=null===(t=ft.current[u])||void 0===t?void 0:t.current;if(!d||!v)return;var f=d.getBoundingClientRect(),p=v.getBoundingClientRect(),g=yt(c),h=(D=f.right-B.left)+.5*((O=p.left-B.left-0)-D),x=f.top+f.height/2,_=p.top+p.height/2,y=x-me+Ie,b=_-ye+Ce,S="conn-subsec-".concat(u);_e.push({lhsScrollY:y,rhsScrollY:b,x1:D,x2:O,containerTop:je,leftIdx:e,rhsArrayIdx:e,styleColor:(null==g?void 0:g.badgeBorder)||"#6366F1",styleId:S});var I=Ee(x,me,be),C=Ee(_,ye,Re),j=I-je,w=C-je,E=_>=ye-4&&_<=Re+4,T="";T=(H=x>=me-4&&x<=be+4)&&E?R(D,j,O,w):H&&!E?"M ".concat(D,",").concat(j," L ").concat(h,",").concat(j," L ").concat(h,",").concat(w):!H&&E?"M ".concat(h,",").concat(j," L ").concat(h,",").concat(w," L ").concat(O,",").concat(w):"M ".concat(h,",").concat(j," L ").concat(h,",").concat(w),ge.push({id:S,pathD:T,style:g,leftIdx:e,rhsArrayIdx:e})}else if(ee){var F=e,M=wn[F];if(!(null===(l=null==M?void 0:M.refIndexes)||void 0===l?void 0:l.length))return;M.refIndexes.forEach(function(e){var n,t,i=En.findIndex(function(n){return n.selfIndex===e});if(-1!==i){var o=null===(n=vt.current[F])||void 0===n?void 0:n.current,l=null===(t=ft.current[i])||void 0===t?void 0:t.current;if(o&&l){var r=o.getBoundingClientRect(),a=l.getBoundingClientRect(),s=mt(F),c=r.right-B.left,u=a.left-B.left-0,d=c+.5*(u-c),v=r.top+r.height/2,f=a.top+a.height/2,p=v-me+Ie,g=f-ye+Ce,h="conn-".concat(F,"-").concat(i);_e.push({lhsScrollY:p,rhsScrollY:g,x1:c,x2:u,containerTop:je,leftIdx:F,rhsArrayIdx:i,styleColor:(null==s?void 0:s.badgeBorder)||"#6366F1",styleId:h});var x=Ee(v,me,be),_=Ee(f,ye,Re),m=x-je,y=_-je,b=v>=me-4&&v<=be+4,S=f>=ye-4&&f<=Re+4,I="";I=b&&S?R(c,m,u,y):b&&!S?"M ".concat(c,",").concat(m," L ").concat(d,",").concat(m," L ").concat(d,",").concat(y):!b&&S?"M ".concat(d,",").concat(m," L ").concat(d,",").concat(y," L ").concat(u,",").concat(y):"M ".concat(d,",").concat(m," L ").concat(d,",").concat(y),ge.push({id:h,pathD:I,style:s,leftIdx:F,rhsArrayIdx:i})}}})}else{var k=e,A=k;d=null===(i=vt.current[k])||void 0===i?void 0:i.current,v=null===(o=ft.current[A])||void 0===o?void 0:o.current;if(!d||!v)return;var D,O;f=d.getBoundingClientRect(),p=v.getBoundingClientRect(),g=mt(k),h=(D=f.right-B.left)+.5*((O=p.left-B.left-0)-D),x=f.top+f.height/2,_=p.top+p.height/2,y=x-me+Ie,b=_-ye+Ce,S="conn-".concat(k,"-").concat(A);_e.push({lhsScrollY:y,rhsScrollY:b,x1:D,x2:O,containerTop:je,leftIdx:k,rhsArrayIdx:A,styleColor:(null==g?void 0:g.badgeBorder)||"#6366F1",styleId:S});var H;I=Ee(x,me,be),C=Ee(_,ye,Re),j=I-je,w=C-je,E=_>=ye-4&&_<=Re+4,T="";T=(H=x>=me-4&&x<=be+4)&&E?R(D,j,O,w):H&&!E?"M ".concat(D,",").concat(j," L ").concat(h,",").concat(j," L ").concat(h,",").concat(w):!H&&E?"M ".concat(h,",").concat(j," L ").concat(h,",").concat(w," L ").concat(O,",").concat(w):"M ".concat(h,",").concat(j," L ").concat(h,",").concat(w),ge.push({id:S,pathD:T,style:g,leftIdx:k,rhsArrayIdx:A})}}),Fe.current=_e}Be(ge)}else Be([]),Fe.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{ln.current=!1}}},[at,wn,En,De,un,_t,mt,ee,ve,tt,Se,_n,bn]),St=t.useCallback(function(){var e,n,t,i,o,l,r,a,s,c,u,d,v,f,p=Fe.current;if(p.length&&!we.current){var g=null!==(n=null===(e=on.current)||void 0===e?void 0:e.scrollTop)&&void 0!==n?n:0,h=null!==(i=null===(t=Qe.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,x=null!==(l=null===(o=on.current)||void 0===o?void 0:o.clientHeight)&&void 0!==l?l:1/0,_=null!==(a=null===(r=Qe.current)||void 0===r?void 0:r.clientHeight)&&void 0!==a?a:1/0,m=null!==(c=null===(s=on.current)||void 0===s?void 0:s.getBoundingClientRect().top)&&void 0!==c?c:0,y=null!==(d=null===(u=Qe.current)||void 0===u?void 0:u.getBoundingClientRect().top)&&void 0!==d?d:0,b=m+x,S=y+_,I=null!==(f=null===(v=Xn.current)||void 0===v?void 0:v.getBoundingClientRect().top)&&void 0!==f?f:0,C=function(e,n,t){return Math.max(n,Math.min(t,e))};p.forEach(function(e){var n=e.lhsScrollY-g+m,t=e.rhsScrollY-h+y,i=Te.current[e.styleId+"-stroke"],o=Te.current[e.styleId+"-bg"];if(i||o){var l,r=C(n,m,b),a=C(t,y,S),s=r-I,c=a-I,u=n>=m-4&&n<=b+4,d=t>=y-4&&t<=S+4,v=e.x1+.5*(e.x2-e.x1);l=u&&d?R(e.x1,s,e.x2,c):u&&!d?"M ".concat(e.x1,",").concat(s," L ").concat(v,",").concat(s," L ").concat(v,",").concat(c):!u&&d?"M ".concat(v,",").concat(s," L ").concat(v,",").concat(c," L ").concat(e.x2,",").concat(c):"M ".concat(v,",").concat(s," L ").concat(v,",").concat(c),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",l)),o&&(o.setAttribute("visibility","visible"),o.setAttribute("d",l))}})}},[]),Rt=t.useRef(bt);t.useEffect(function(){Rt.current=bt},[bt]);var It=t.useRef(null),Ct=t.useCallback(function(){null!==It.current&&clearTimeout(It.current),It.current=setTimeout(function(){Rt.current(),It.current=null},50)},[]),Bt=t.useCallback(function(e){var n,t,i,o,l,r,a,s,c,u;if(!xe.current){if(ee||Ct(),ke.current){var d=Ae.current,v=Un.current,f=on.current,p=Qe.current;if(null!==d&&null!==v&&f&&p){var g="string"==typeof d&&d.includes(m)?null===(n=vt.current["".concat(d.split(m)[0]).concat(m).concat(d.split(m)[1])])||void 0===n?void 0:n.current:null===(t=Nn.current[d])||void 0===t?void 0:t.current,h="string"==typeof v&&v.includes(m)?null===(i=ft.current["".concat(v.split(m)[0]).concat(m).concat(v.split(m)[1])])||void 0===i?void 0:i.current:null===(o=pt.current[v])||void 0===o?void 0:o.current;if(g&&h){var x=g.getBoundingClientRect().top-f.getBoundingClientRect().top+f.scrollTop,_=h.getBoundingClientRect().top-p.getBoundingClientRect().top+p.scrollTop;if(e.currentTarget===f){var y=_-(x-f.scrollTop),b=p.scrollHeight-p.clientHeight,S=Math.max(0,Math.min(y,b));Math.abs(p.scrollTop-S)>1&&(p.scrollTop=S)}else if(e.currentTarget===p){var R=x-(_-p.scrollTop),I=f.scrollHeight-f.clientHeight,C=Math.max(0,Math.min(R,I));Math.abs(f.scrollTop-C)>1&&(f.scrollTop=C)}if(Gn.current){var B=void 0,j=void 0;if("string"==typeof d&&d.includes(m)){var w=d.split(m),E="".concat(w[0]).concat(m).concat(w[1]);B=null===(l=vt.current[E])||void 0===l?void 0:l.current,j=null===(r=ft.current[E])||void 0===r?void 0:r.current}else B=null===(a=vt.current[d])||void 0===a?void 0:a.current,j=null===(s=ft.current[v])||void 0===s?void 0:s.current;var T=null!==(u=null===(c=Xn.current)||void 0===c?void 0:c.getBoundingClientRect().top)&&void 0!==u?u:0,F=f.getBoundingClientRect().top,M=F+f.clientHeight,k=p.getBoundingClientRect().top,A=k+p.clientHeight,D=function(e,n,t){return Math.max(n,Math.min(t,e))};if(B&&j){var O=B.getBoundingClientRect(),H=j.getBoundingClientRect(),L=O.top+O.height/2,N=H.top+H.height/2,W=D(L,F,M),z=D(N,k,A);Gn.current.setAttribute("y1",(W-T).toString()),Gn.current.setAttribute("y2",(z-T).toString());var P=L>=F-4&&L<=M+4;Gn.current.setAttribute("visibility",P?"visible":"hidden")}}}}}Fe.current.length>0&&!Me.current&&(Me.current=!0,requestAnimationFrame(function(){St(),Me.current=!1}))}},[St,ee,Ct]);t.useEffect(function(){var e=setTimeout(Ct,250);window.addEventListener("resize",Ct);var n=null,t=null;return $e.current&&(n=new ResizeObserver(Ct)).observe($e.current),Xn.current&&(t=new ResizeObserver(Ct)).observe(Xn.current),function(){clearTimeout(e),window.removeEventListener("resize",Ct),null==n||n.disconnect(),null==t||t.disconnect()}},[vn,Rn,Fn,at,_n,bn,wn,En,un,Ct,ve,tt,ge,Se]),t.useEffect(function(){ke.current=ve},[ve]),t.useEffect(function(){Ae.current=tt},[tt]);var jt=t.useCallback(function(){var e,n,t,i,o=Ue.sectionIdx,l=Ue.isOrphan;if(sn(),null!=o)if(l)ue("No counterpart exists for this section.");else if(ve&&tt===o)zn();else{if(!ee){var r=Ae.current,a=Un.current;if(null!==r)if("string"==typeof r&&r.includes(m)){var s=r.split(m);(c=null===(e=gt.current[s[2]])||void 0===e?void 0:e.current)&&(c.style.paddingTop="0px")}else{var c;(c=null===(n=ut.current[r])||void 0===n?void 0:n.current)&&(c.style.paddingTop="0px")}if(null!==a)if("string"==typeof a&&a.includes(m)){s=a.split(m);(u=null===(t=ht.current[s[3]])||void 0===t?void 0:t.current)&&(u.style.paddingTop="0px")}else{var u;(u=null===(i=dt.current[a])||void 0===i?void 0:i.current)&&(u.style.paddingTop="0px")}}Re(new Set),Be([]),Fe.current=[],ae(!0),xe.current=!0,it(o),Ae.current=o,fe(!0),ke.current=!0,he(!1),Ze.current&&(Ze.current.style.height="0px"),en.current&&(en.current.style.height="0px"),nn.current&&(nn.current.style.height="0px"),tn.current&&(tn.current.style.height="0px"),requestAnimationFrame(function(){var e,n,t,i,l,r,a,s,c,u,d,v=null,f=null,p=null,g=null,h=null;if("string"==typeof o&&o.includes(m)){var x=o.split(m),_="".concat(x[0]).concat(m).concat(x[1]);v=(null===(e=vt.current[_])||void 0===e?void 0:e.current)||null,h=(f=(null===(n=ft.current[_])||void 0===n?void 0:n.current)||null)?o:null,p=(null===(t=gt.current[x[2]])||void 0===t?void 0:t.current)||null,g=(null===(i=ht.current[x[3]])||void 0===i?void 0:i.current)||null}else if(v=(null===(l=Nn.current[o])||void 0===l?void 0:l.current)||null,p=(null===(r=ut.current[o])||void 0===r?void 0:r.current)||null,ee){var y=wn[o],b=(null==y?void 0:y.refIndexes)||[];if(b.length>0){var S=b[0],R=En.findIndex(function(e){return e.selfIndex===S});-1!==R&&(f=(null===(c=pt.current[R])||void 0===c?void 0:c.current)||null,g=(null===(u=dt.current[R])||void 0===u?void 0:u.current)||null,h=R)}}else f=(null===(a=pt.current[o])||void 0===a?void 0:a.current)||null,g=(null===(s=dt.current[o])||void 0===s?void 0:s.current)||null,h=f?o:null;Un.current=h;var I=on.current,C=Qe.current;if(!v||!I)return xe.current=!1,void ae(!1);if(!f||!C)return he(!0),Rt.current(),xe.current=!1,void ae(!1);if(!ee){var B=v.getBoundingClientRect(),w=f.getBoundingClientRect(),E=B.top-w.top;p&&g&&(p.style.paddingTop="0px",g.style.paddingTop="0px",E>0?g.style.paddingTop="".concat(E,"px"):E<0&&(p.style.paddingTop="".concat(Math.abs(E),"px")));var T=v?v.getBoundingClientRect().top:(null==p?void 0:p.getBoundingClientRect().top)||0;return null===(d=$e.current)||void 0===d||d.scrollTo({top:$e.current.scrollTop+T-150,behavior:"smooth"}),he(!0),Rt.current(),xe.current=!1,void ae(!1)}var F=v.getBoundingClientRect().top-I.getBoundingClientRect().top+I.scrollTop,M=f.getBoundingClientRect().top-C.getBoundingClientRect().top+C.scrollTop-(F-I.scrollTop);M<0&&Ze.current&&(Ze.current.style.height="".concat(Math.abs(M),"px"));requestAnimationFrame(function(){var e,n=C.scrollHeight-C.clientHeight;if(M<0)e=0;else{if(M>n){var t=M-n;return en.current&&(en.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){j(C,M,200,function(){he(!0),Rt.current(),xe.current=!1,ae(!1)})})}e=M}j(C,e,200,function(){he(!0),Rt.current(),xe.current=!1,ae(!1)})})})}},[sn,Ue.sectionIdx,ve,tt,wn,En,Ct,zn]),wt=null!==Ue.sectionIdx&&Se.has(Ue.sectionIdx),Et=function(t){var l,r,a,c,u,d,v,f=t.section,p=t.idx,g=t.columnKey,x=t.colRef,_=t.mb,m=void 0===_?1:_,y=t.parentNodeId,b=void 0===y?"":y,R=ee?!!_n["".concat(g,"-").concat(p)]:!!_n[String(p)],I=(null===(l=f.displayTitle)||void 0===l||l)&&s.hasValue(f.title),C=(null===(r=f.displayContent)||void 0===r||r)&&s.hasValue(f.content),j=!I&&!C,w={current:1},E=f.title;I||(E=C?"No Title Found":"No Matching Section Found");var T,F=null!==(d=null===(u=null===(c=null===(a=f.evaluationResult)||void 0===a?void 0:a.evaluation_outputs)||void 0===c?void 0:c.metadata)||void 0===u?void 0:u.label_color)&&void 0!==d?d:B,M=s.generateColorPalette(F).highlightBg,k=[];if(null===(v=f.evaluationResult)||void 0===v?void 0:v.deviations){var A=f.evaluationResult.deviations;for(var D in A){var O=A[D][b];O&&k.push(O)}}return n.jsx(i.Box,e.__assign({ref:x,sx:{mb:m,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:n.jsxs(i.Accordion,e.__assign({disableGutters:!0,expanded:!j&&R,onChange:function(){return!j&&function(n,t){var i,o;we.current=!0,Ee.current&&clearTimeout(Ee.current),je.current&&(je.current.style.opacity="0");var l=null===(i=ut.current[n])||void 0===i?void 0:i.current,r=null===(o=dt.current[n])||void 0===o?void 0:o.current;l&&(l.style.minHeight="0px"),r&&(r.style.minHeight="0px"),Ee.current=setTimeout(function(){we.current=!1,Rt.current(),je.current&&(je.current.style.opacity="1")},650),mn(function(i){var o=e.__assign({},i),l=ee?"".concat(t,"-").concat(n):String(n),r=!i[l];if(!r){var a=String(tt||""),s=tt===n||a.startsWith("".concat(n,"-")),c=!1;Se.forEach(function(e){(e===n||String(e).startsWith("".concat(n,"-")))&&(c=!0)}),(s||c)&&(zn(),Re(new Set),Be([]),Fe.current=[])}if(!ee)return o[String(n)]=r,o;if(o[l]=r,"left"===t)((null==(u=wn[n])?void 0:u.refIndexes)||[]).forEach(function(e){var n=En.findIndex(function(n){return n.selfIndex===e});-1!==n&&(o["right-".concat(n)]=r)});else{var u,d=null==(u=En[n])?void 0:u.selfIndex;wn.forEach(function(e,n){var t;(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(d))&&(o["left-".concat(n)]=r)})}return o})}(p,g)},sx:{boxShadow:"none",border:j?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:j?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flexGrow:1,width:"100%",display:"flex",flexDirection:"column",minWidth:0,"&:before":{display:"none"}}},{children:[n.jsx(i.AccordionSummary,e.__assign({expandIcon:j?null:n.jsx(o.ChevronDown,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:j?"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:I&&n.jsx(i.Tooltip,e.__assign({title:E,placement:"top"},{children:n.jsx(i.Typography,e.__assign({component:"div",sx:{fontSize:"12px",color:j?"#94A3B8":"#19213D",fontWeight:j?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(T=E,T?s.safeStringify(T).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(e,t){return e.startsWith("**")&&e.endsWith("**")?n.jsx("strong",{children:e.slice(2,-2)},t):n.jsx(h.default.Fragment,{children:e},t)}):null)}))}))})),!j&&n.jsxs(i.AccordionDetails,e.__assign({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[C&&n.jsx(S,{content:f.content,sxStyles:Ve,highlights:k,maintainRelativeOrder:ee,highlightBg:M}),(f.subsections||[]).map(function(e,n){return Tt({section:e,keyPath:"".concat(p,"-").concat(n),depth:0,columnKey:g,parentNodeId:b,devCounter:w})})]}))]}))}),"".concat(g,"-sec-").concat(p))},Tt=function(t){var l,r,a,c,u,d,v,f,p,g,x,_,b,R,I,C=t.section,j=t.keyPath,w=t.depth,E=void 0===w?0:w,T=t.columnKey,F=void 0===T?"left":T,M=t.parentNodeId,k=void 0===M?"":M,A=(null===(l=C.displayTitle)||void 0===l||l)&&s.hasValue(C.title),D=(null===(r=C.displayContent)||void 0===r||r)&&s.hasValue(C.content),O=!A&&!D,H=A?C.title:D?"No Title Found":"No Matching Section Found",L=!!bn[j];"left"!==F||gt.current[j]||(gt.current[j]=h.default.createRef()),"right"!==F||ht.current[j]||(ht.current[j]=h.default.createRef());var N="left"===F?gt.current[j]:ht.current[j],W=yt(j),z=j.split("-").map(Number),P=z[0],q=wn[P],Y=En[P],K=j,X=j;if(ee)if("left"===F){var U=null===(a=null==q?void 0:q.refIndexes)||void 0===a?void 0:a[0],G=En.findIndex(function(e){return e.selfIndex===U});-1!==G&&(Y=En[G],X=e.__spreadArray([G],z.slice(1),!0).join("-"))}else{var $=null===(c=null==Y?void 0:Y.refIndexes)||void 0===c?void 0:c[0],J=wn.findIndex(function(e){return e.selfIndex===$});-1!==J&&(q=wn[J],K=e.__spreadArray([J],z.slice(1),!0).join("-"))}var Q,Z="left"===F?q:Y;Q=ee&&void 0!==(null==Z?void 0:Z.selfIndex)&&Z.selfIndex>=0?Z.selfIndex+1:P+1;for(var ne=q,te=Y,ie=1;ie<z.length;ie++)(null==ne?void 0:ne.subsections)&&(ne=ne.subsections[z[ie]]),(null==te?void 0:te.subsections)&&(te=te.subsections[z[ie]]);var oe=null===(u=null==V?void 0:V.input_index_map)||void 0===u?void 0:u[0],le=null===(d=null==V?void 0:V.input_index_map)||void 0===d?void 0:d[1],re="left"===F?le:oe,ae=ee?!(null===(v=C.refIndexes)||void 0===v?void 0:v.length)||void 0!==C.selfIndex&&C.selfIndex<0:"left"===F?!te:!ne,se=null!==(g=null===(p=null===(f=C.evaluationResult)||void 0===f?void 0:f.evaluation_outputs)||void 0===p?void 0:p.output_value)&&void 0!==g?g:null,ce=C.id,ue=null!==(R=null===(b=null===(_=null===(x=C.evaluationResult)||void 0===x?void 0:x.evaluation_outputs)||void 0===_?void 0:_.metadata)||void 0===b?void 0:b.label_color)&&void 0!==R?R:B,de=s.generateColorPalette(ue).highlightBg,ve=(null===(I=C.evaluationResult)||void 0===I?void 0:I.deviations)||{},fe=Object.entries(ve).map(function(n){var t=n[0],i=n[1],o="".concat(ce).concat(m).concat(t),l=Ln[o];if(!l)return null;var r=i[k],a=y(r);if(a)r="";else if(!r)return null;var s=i[re],c=ae||y(s),u="".concat(Q,".").concat(l),d="".concat(ce).concat(m).concat(t).concat(m).concat(K).concat(m).concat(X);return"left"!==F||vt.current[o]||(vt.current[o]=h.default.createRef()),"right"!==F||ft.current[o]||(ft.current[o]=h.default.createRef()),{id:o,actionId:d,label:u,highlight:r,side:F,style:W,score:se,isConnected:Se.has(d),isOrphan:c,isMissingClause:a,badgeRef:"left"===F?vt.current[o]:ft.current[o],onClick:function(n){n.stopPropagation();var t=e.__assign(e.__assign({},ne||{title:"",content:""}),{title:(null==q?void 0:q.title)||(null==ne?void 0:ne.title)||""}),i=e.__assign(e.__assign({},te||{title:"",content:""}),{title:(null==Y?void 0:Y.title)||(null==te?void 0:te.title)||""});qn(n,t,c,i,d,W)}}}).filter(Boolean),pe=fe.some(function(e){return Se.has(e.actionId)});if(!(A||D||C.subsections&&0!==C.subsections.length))return null;var ge=function(){var e,n=[];if(null===(e=C.evaluationResult)||void 0===e?void 0:e.deviations){var t=C.evaluationResult.deviations;for(var i in t){var o=t[i][k];o&&n.push(o)}}return n}();if(!A)return n.jsx(i.Box,e.__assign({ref:N,sx:{mt:0===E?1:.75,width:"100%",minWidth:0,position:"relative"}},{children:!O&&n.jsxs(i.Box,e.__assign({sx:e.__assign({width:"100%"},pe&&W&&{borderRadius:"4px",outline:"2px solid ".concat(W.badgeBorder),outlineOffset:"1px"})},{children:[D&&n.jsx(S,{content:C.content,sxStyles:Ve,deviationBadges:fe,maintainRelativeOrder:ee,highlightBg:de,highlights:ge}),(C.subsections||[]).map(function(e,n){return Tt({section:e,keyPath:"".concat(j,"-").concat(n),depth:E+1,columnKey:F,parentNodeId:k})})]}))}),j);var he=!ee&&A&&D;return n.jsx(i.Box,e.__assign({ref:N,sx:{mt:1,width:"100%",minWidth:0,position:"relative"}},{children:n.jsx(i.Box,e.__assign({sx:e.__assign({width:"100%"},pe&&W&&{borderRadius:"4px",outline:"2px solid ".concat(W.badgeBorder),outlineOffset:"1px"})},{children:n.jsxs(i.Accordion,e.__assign({disableGutters:!0,expanded:!O&&L,onChange:function(){if(!O){if(L){var n=String(tt||""),t=n.includes(K)||n.includes(X);t||Se.forEach(function(e){(String(e).includes(K)||String(e).includes(X))&&(t=!0)}),t&&(zn(),Re(new Set),Be([]),Fe.current=[])}Sn(function(n){var t;return e.__assign(e.__assign({},n),((t={})[j]=!n[j],t))})}},sx:{mt:0,boxShadow:"none",border:O?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF",minWidth:0,"&:before":{display:"none"}}},{children:[n.jsx(i.AccordionSummary,e.__assign({expandIcon:O?null:n.jsx(o.ChevronDown,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"}}},{children:n.jsx(i.Typography,e.__assign({component:"div",sx:{fontSize:"11px",fontWeight:600,color:O?"#94A3B8":"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:H||"Untitled Subsection"}))})),!O&&n.jsxs(i.AccordionDetails,e.__assign({sx:{pt:0,pb:1,minWidth:0}},{children:[D&&n.jsx(S,{content:C.content,sxStyles:Ve,deviationBadges:he?[]:fe,maintainRelativeOrder:ee,highlightBg:de,highlights:ge}),(C.subsections||[]).map(function(e,n){return Tt({section:e,keyPath:"".concat(j,"-").concat(n),depth:E+1,columnKey:F,parentNodeId:k})})]}))]}))}))}),j)};return n.jsxs(i.Box,e.__assign({ref:Je,sx:e.__assign(e.__assign({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},ee?{}:{overflow:"visible"}),{position:"relative"})},{children:[ie&&n.jsx(i.Box,e.__assign({sx:{position:"absolute",inset:0,bgcolor:"rgba(255, 255, 255, 0.6)",backdropFilter:"blur(10px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"8px"}},{children:n.jsx(v.default,{})})),n.jsx(d.default,{open:Ue.open,anchorEl:Ue.anchorEl,sectionTitle:Ue.sectionTitle,referenceSectionTitle:Ue.refSectionTitle,onClose:sn,onOpenCognitiveCompare:Yn,onOpenSideBySide:jt,onConnect:Kn,isConnected:wt,isOrphan:Ue.isOrphan}),Ye.open&&n.jsx(u.default,{open:Ye.open,popupRef:Ne,position:He,popupConfig:$,onClose:function(){Le(null),Ke(function(n){return e.__assign(e.__assign({},n),{open:!1})}),ye(null)},markdownStyles:X,sectionTitle:Ye.sectionTitle,referenceSectionTitle:Ye.refSectionTitle,cognitiveData:Ye.cognitiveData,anchorEl:Ye.anchorEl,sectionAnchorEl:Ye.sectionAnchorEl,scrollContainerEl:$e.current,badgeStyle:Ye.badgeStyle,docData:Ye.docData,deviationData:Ye.deviationData,isLoading:Ye.isLoading}),n.jsx(i.Snackbar,e.__assign({open:!!ce,autoHideDuration:8e3,onClose:function(){return ue(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(i.Alert,e.__assign({onClose:function(){return ue(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:ce}))})),(G.isHeaderVisible||G.isToggleVisible)&&n.jsxs(i.Box,e.__assign({sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between",bgcolor:"#FFFFFF",border:"1.5px solid #EEF0F4",borderTopLeftRadius:"8px",borderTopRightRadius:"8px"}},{children:[n.jsx(i.Box,e.__assign({sx:{display:"flex",alignItems:"center",gap:1}},{children:G.isHeaderVisible&&n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:600,color:"#0F172A"}},{children:P}))})),G.isToggleVisible&&n.jsx(i.Box,e.__assign({sx:{display:"flex",alignItems:"center"}},{children:n.jsx(i.FormControlLabel,{control:n.jsx(i.Switch,{checked:!ee,onChange:function(e){var n=e.target.checked;oe(!0),setTimeout(function(){ne(!n),zn(),Re(new Set),Be([]),Fe.current=[],setTimeout(function(){oe(!1)},400)},50)},color:"primary",size:"small",sx:{width:100,height:26,padding:0,"& .MuiSwitch-switchBase":{padding:0,margin:"3px",transitionDuration:"300ms","&.Mui-checked":{transform:"translateX(75px)",color:"#fff","& + .MuiSwitch-track":{backgroundColor:"#5928ED",opacity:1,border:0,"&::before":{content:'"Side by Side"',position:"absolute",left:"13px",top:"50%",transform:"translateY(-50%)",fontSize:"9px",fontWeight:700,color:"#fff",letterSpacing:"0.3px"}}}},"& .MuiSwitch-thumb":{boxSizing:"border-box",width:20,height:20},"& .MuiSwitch-track":{borderRadius:13,backgroundColor:"#9e9e9e",opacity:1,position:"relative","&::after":{content:'"Side by Side"',position:"absolute",right:"13px",top:"50%",transform:"translateY(-50%)",fontSize:"9px",fontWeight:700,color:"#fff",letterSpacing:"0.3px",opacity:1,transition:"opacity 0.2s"}},"& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track":{"&::after":{opacity:0}}}}),label:"",labelPlacement:"start",sx:{m:0,gap:1}})}))]})),n.jsx(i.Box,e.__assign({ref:$e,onScroll:Bt,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:ee?"hidden":"auto",borderTop:Mn&&kn?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(i.Box,e.__assign({sx:e.__assign({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},ee?{flex:1,minHeight:0}:{})},{children:n.jsxs(i.Box,e.__assign({ref:Xn,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"10px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},ee?{flex:1,overflow:"visible"}:{})},{children:[n.jsxs("svg",e.__assign({ref:je,style:{position:"absolute",top:0,left:0,width:ze.width||"100%",height:ze.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",transition:"opacity 0.15s ease-in-out"}},{children:[lt&&!ve&&n.jsx("g",{children:n.jsx("line",{x1:lt.x1,y1:lt.y,x2:lt.x2,y2:lt.y,stroke:Hn.badgeBorder,strokeWidth:"1.5"})}),Zn.map(function(t){var r,a=t.x1+.5*(t.x2-t.x1),s=(t.y1+t.y2)/2;if("Not Defined"===t.style.label&&!t.hasCognitive)return null;var c=!1;if(t.isSubSection)c=ve&&tt===t.subSectionKeyPath&≥else{var u=wn[t.sectionIdx];(ee?!(null===(r=null==u?void 0:u.refIndexes)||void 0===r?void 0:r.length)||(null==u?void 0:u.selfIndex)<0:!En[t.sectionIdx])||(c=ve&&tt===t.sectionIdx&&ge)}if(c)return n.jsxs("g",e.__assign({style:{transition:"opacity 0.2s"}},{children:[n.jsx("defs",{children:n.jsx("marker",e.__assign({id:"arr-".concat(t.id),markerWidth:"7",markerHeight:"5",refX:"7",refY:"2.5",orient:"auto"},{children:n.jsx("polygon",{points:"0 0, 7 2.5, 0 5",fill:t.style.badgeBorder||"#6366F1"})}))}),n.jsx("line",{ref:Gn,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(!ee){var d=t.isSubSection?R(t.x1,t.y1,t.x2,t.y2):"M ".concat(t.x1," ").concat(t.y1," L ").concat(t.x2," ").concat(t.y2);return n.jsxs("g",{children:[n.jsx("path",{d:d,fill:"none",stroke:t.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),n.jsx("foreignObject",e.__assign({x:a-100,y:s-14,width:"200",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:n.jsx(i.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:n.jsxs(i.Box,e.__assign({onClick:function(n){if(n.stopPropagation(),Ye.open&&me===t.id)an();else{var i=wn[t.sectionIdx]||{title:"",content:""},o=En[t.sectionIdx]||{title:"",content:""};if(t.isSubSection&&t.subSectionKeyPath){for(var l=t.subSectionKeyPath.split(m)[2].split("-").map(Number),r=wn[l[0]],a=En[l[0]],s=(null==r?void 0:r.title)||"",c=(null==a?void 0:a.title)||"",u=1;u<l.length;u++)(null==r?void 0:r.subsections)&&(r=r.subsections[l[u]]),(null==a?void 0:a.subsections)&&(a=a.subsections[l[u]]);r&&(i=e.__assign(e.__assign({},r),{title:s||r.title})),a&&(o=e.__assign(e.__assign({},a),{title:c||a.title}))}ye(t.id),Vn(Pn(n.currentTarget,i,o,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:[t.style.badgeText===B&&null==t.style.label?n.jsx(p.default,{color:t.style.badgeText}):0===t.style.label?"Same":t.style.label,n.jsx(i.Box,e.__assign({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n.jsx(l.ButtonCognitiveIcon,{})})),n.jsx(o.ChevronDown,{size:11,style:{transform:Ye.open&&me===t.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},t.id)}return null}),Ce.map(function(t){var i,o=t.pathD,l=(null===(i=t.style)||void 0===i?void 0:i.badgeBorder)||"#6366F1",r="conn-marker-".concat(t.id),a="".concat(t.id,"-bg"),s="".concat(t.id,"-stroke");return n.jsxs("g",{children:[n.jsx("defs",{children:n.jsx("clipPath",e.__assign({id:"connections-clip"},{children:n.jsx("marker",e.__assign({id:r,markerWidth:"8",markerHeight:"6",refX:"7",refY:"3",orient:"auto"},{children:n.jsx("polygon",{points:"0 0, 8 3, 0 6",fill:l})}))}))}),n.jsx("path",{ref:function(e){Te.current[a]=e},d:o,fill:"none",stroke:"#FFFFFF",strokeWidth:"4",strokeOpacity:"0.7"}),n.jsx("path",{ref:function(e){Te.current[s]=e},d:o,fill:"none",stroke:l,strokeWidth:"1.75",markerEnd:"url(#".concat(r,")")})]},t.id)})]})),n.jsxs(i.Box,e.__assign({sx:e.__assign({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},ee?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(i.Box,e.__assign({ref:$n,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",minHeight:"40px",alignItems:"center",overflowX:"hidden"}},{children:n.jsx(i.Tooltip,e.__assign({title:Bn,placement:"top"},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center",textOverflow:"ellipsis",whiteSpace:"normal",width:"100%",height:"40px"}},{children:Bn}))}))})),n.jsxs(i.Box,e.__assign({ref:on,onScroll:Bt,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},ee?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-160px",pr:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:nn,style:{width:"100%",height:"0px",flexShrink:0}}),Tn&&wn.map(function(t,l){var r,a,s=!t.title&&!t.content;if(ee&&s)return null;var c=t,u=mt(l),d=ee?!(null===(r=c.refIndexes)||void 0===r?void 0:r.length)||c.selfIndex<0:!En[l],v=ee?"number"==typeof c.selfIndex&&c.selfIndex>=0?c.selfIndex+1:null:l+1,f=Se.has(l),g=b(c.evaluationResult,null==u?void 0:u.deviationLabel);return n.jsx(i.Box,e.__assign({ref:Wn(l),sx:{mb:1,width:"100%"}},{children:n.jsxs(i.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[n.jsx(i.Box,e.__assign({ref:ut.current[l],sx:e.__assign({width:"100%",display:"flex"},f&&{borderRadius:"6px",outline:"2px solid ".concat((null==u?void 0:u.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:Et({section:t,idx:l,columnKey:"left",colRef:h.default.createRef(),mb:0,parentNodeId:(null===(a=null==V?void 0:V.input_index_map)||void 0===a?void 0:a[0])||""})})),ee&&u&&n.jsxs(i.Box,e.__assign({ref:vt.current[l],onClick:function(e){var n=ee?En.find(function(e){var n;return null===(n=c.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""}:En[l]||{title:"",content:""};qn(e,t,d,n,l,u)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:u.badgeBg,color:u.badgeText,border:"1px solid ".concat(u.badgeBorder),borderRadius:"12px",px:1.2,py:.4,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[null!==v&&n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(u.badgeBorder)}},{children:v})),n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",px:.25}},{children:!G.isLoading||null!=c.evaluationResult&&null!=c.evaluationResult?d?"No Deviation Found":"N/A"===g||"NA"===g?"N/A":0==g||null==g?"Same":"".concat(g):n.jsx(p.default,{color:u.badgeText})})),n.jsx(o.EllipsisVertical,{size:11,color:u.badgeText})]}))]}))}),"left-row-".concat(l))}),n.jsx("div",{ref:tn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),n.jsx(i.Box,e.__assign({sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20}},{children:n.jsx(i.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:n.jsxs(i.Box,e.__assign({sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",borderRadius:"20px",bgcolor:Hn.badgeBg,color:Hn.badgeText,border:"1px solid ".concat(Hn.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1}},{children:[On,n.jsx(i.Box,e.__assign({component:"span",onClick:function(n){n.stopPropagation(),Ye.open&&me===An?an():(ye(An),Vn(Pn(n.currentTarget,{title:"",content:"",evaluationResult:Dn,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,An,!0,e.__assign(e.__assign({},Hn),{label:""}))))},sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n.jsx(l.ButtonCognitiveIcon,{})})),n.jsx(o.ChevronDown,{size:11,style:{transform:Ye.open&&me===An?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),n.jsxs(i.Box,e.__assign({sx:e.__assign({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},ee?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[re&&n.jsx(r.default,{sections:11}),n.jsx(i.Box,e.__assign({ref:Jn,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"40px",display:"flex",alignItems:"center",overflowX:"hidden"}},{children:n.jsx(i.Tooltip,e.__assign({title:jn,placement:"top"},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center",textOverflow:"ellipsis",whiteSpace:"normal",width:"100%",height:"40px"}},{children:jn}))}))})),n.jsxs(i.Box,e.__assign({ref:Qe,onScroll:Bt,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},ee?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-25px",pl:"45px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:Ze,style:{width:"100%",height:"0px",flexShrink:0}}),Tn&&En.map(function(t,o){var l,r=t,a=[],s=!1,c=null;if(ee){a=wn.filter(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(r.selfIndex))&&e.selfIndex>=0}).map(function(e){return e.selfIndex+1});var u=wn.findIndex(function(e,n){var t;return Se.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(r.selfIndex))});(s=-1!==u)&&(c=mt(u))}else a=[o+1],(s=Se.has(o))&&(c=mt(o));var d=mt(o);return n.jsx(i.Box,e.__assign({ref:pt.current[o],sx:{mb:1,width:"100%"}},{children:n.jsxs(i.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[n.jsx(i.Box,e.__assign({ref:dt.current[o],sx:e.__assign({width:"100%",display:"flex"},s&&c&&{borderRadius:"6px",outline:"2px solid ".concat(c.badgeBorder),outlineOffset:"1px"})},{children:Et({section:t,idx:o,columnKey:"right",colRef:h.default.createRef(),mb:0,parentNodeId:(null===(l=null==V?void 0:V.input_index_map)||void 0===l?void 0:l[1])||""})})),ee&&!re&&d&&n.jsx(i.Box,e.__assign({ref:ft.current[o],sx:{position:"absolute",top:"18px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"11px",bgcolor:d.badgeBg,color:d.badgeText,border:"1px solid ".concat(d.badgeBorder),borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:a.length>0?a.join(", "):"-"}))]}))}),"right-row-".concat(o))}),n.jsx("div",{ref:en,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),t=require("react"),i=require("@mui/material"),o=require("lucide-react"),l=require("../../assests/svg/ButtonCognitiveIcon.js"),r=require("./OverlayComponent.js"),a=require("react-markdown"),s=require("./CognitiveComparehelpers.js"),c=require("./CognitiveCompareConfig.js"),u=require("./CognitivePopup.js"),d=require("./MoreFunctionsPopup.js"),v=require("./LoaderComponent.js"),f=require("rehype-raw"),p=require("./components/ThreeDotsLoader.js");function g(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var h=g(t),x=g(a),_=g(f),m="::",y=function(e){if(!e)return!0;var n=e.trim().toLowerCase();return n.includes("no equivalent")||"n/a"===n||"na"===n||"none"===n},b=function(e,n){var t,i,o,l,r,a,s;if(!e)return n;var c=null!==(a=null!==(l=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!==l?l:null===(r=e.evaluation_outputs)||void 0===r?void 0:r.output_value)&&void 0!==a?a:e.output_score;return null!==(s=null!=c?c:n)&&void 0!==s?s:""},S=h.default.memo(function(l){var r=l.content,a=l.sxStyles,c=l.deviationBadges,u=void 0===c?[]:c,d=l.highlights,v=void 0===d?[]:d,f=l.maintainRelativeOrder,p=void 0===f||f,g=l.highlightBg,h=t.useMemo(function(){return u.reduce(function(n,t){var i;return e.__assign(e.__assign({},n),((i={})[t.id]=t,i))},{})},[u]),m=t.useMemo(function(){return{mark:function(t){var i=t.children;return n.jsx("span",e.__assign({style:{backgroundColor:g,borderRadius:"2px"}},{children:i}))},span:function(t){var l,r,a,s,c,u=t.children,d=e.__rest(t,["children"]),v=d["data-badge-id"];if(!v)return n.jsx("span",e.__assign({},d,{children:u}));var f=h[v];return f?n.jsxs(i.Box,e.__assign({component:"span",sx:{position:"static",display:"inline"}},{children:[u,n.jsx(i.Box,e.__assign({ref:f.badgeRef,onClick:f.onClick,sx:e.__assign(e.__assign({position:"absolute",zIndex:30,display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"10px",bgcolor:(null===(l=f.style)||void 0===l?void 0:l.badgeBg)||"#EEF2FF",color:(null===(r=f.style)||void 0===r?void 0:r.badgeText)||B,border:"1px solid ".concat((null===(a=f.style)||void 0===a?void 0:a.badgeBorder)||"#C7D2FE"),borderRadius:"12px",px:1,py:.3,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",boxShadow:"0 1px 3px rgba(0,0,0,0.07)"},"left"===f.side?{right:"-16px",transform:"translateY(-20%) translateX(calc(100% + 8px))"}:{left:"-16px",transform:"translateY(-20%) translateX(calc(-100% - 8px))"}),f.isConnected&&f.style&&{outline:"2px solid ".concat(f.style.badgeBorder),outlineOffset:"1px"})},{children:n.jsxs(n.Fragment,{children:[n.jsx(i.Box,e.__assign({component:"span",sx:e.__assign({fontSize:"10px",fontWeight:700},"left"===f.side?{pr:.5,borderRight:"1px solid ".concat((null===(s=f.style)||void 0===s?void 0:s.badgeBorder)||"#C7D2FE")}:{})},{children:f.label})),"left"===f.side&&n.jsxs(n.Fragment,{children:[n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"10px",px:.25}},{children:null!=f.score&&"N/A"!==f.score&&"NA"!==f.score&&0!==f.score?"".concat(f.score):"N/A"===f.score||"NA"===f.score?"N/A":"Same"})),n.jsx(o.EllipsisVertical,{size:10,color:(null===(c=f.style)||void 0===c?void 0:c.badgeText)||"#3730A3"})]})]})}))]})):n.jsx("span",e.__assign({},d,{children:u}))}}},[h,p]),y=t.useMemo(function(){var e=r||"",n={},t=0;return function(){var i=null==u?void 0:u[0];if(i&&i.highlight){var o=i.highlight.replace(/\\(['’])/g,"$1"),l="__DEV_TOKEN_".concat(t++,"__");n[l]='<span data-badge-id="'.concat(i.id,'"><mark>').concat(o,"</mark></span>"),e=e.replace(o,l)}}(),v.forEach(function(i){if(i){var o=i.replace(/\\(['’])/g,"$1"),l="__HL_TOKEN_".concat(t++,"__");n[l]="<mark>".concat(o,"</mark>"),e=e.split(o).join(l)}}),Object.keys(n).forEach(function(t){e=e.split(t).join(n[t])}),e},[r,u,v]);return n.jsx(i.Typography,e.__assign({component:"div",sx:e.__assign(e.__assign({},a),{position:"relative",overflow:"visible","& p, & li, & ul, & ol":{position:"static",overflow:"visible"}})},{children:n.jsx(x.default,e.__assign({components:m,rehypePlugins:[_.default]},{children:s.safeStringify(y).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 l=e.deviationBadges||[],r=n.deviationBadges||[];if(l.length!==r.length)return!1;for(o=0;o<l.length;o++){if(l[o].id!==r[o].id)return!1;if(l[o].label!==r[o].label)return!1;if(l[o].isConnected!==r[o].isConnected)return!1}return!0}),R=function(e,n,t,i,o){void 0===o&&(o=14);var l=e+.5*(t-e),r=i-n;if(Math.abs(r)<3)return"M ".concat(e," ").concat(n," H ").concat(t);var a=r>0?1:-1,s=Math.min(o,Math.abs(r)/2,Math.abs(l-e)/2,Math.abs(t-l)/2);return["M ".concat(e," ").concat(n),"H ".concat(l-s),"Q ".concat(l," ").concat(n," ").concat(l," ").concat(n+a*s),"V ".concat(i-a*s),"Q ".concat(l," ").concat(i," ").concat(l+s," ").concat(i),"H ".concat(t)].join(" ")},I={id:"",title:""},C={isLoading:!1,open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,isOrphan:!1,docData:null,deviationData:null},B="#3730A3",j=function(e,n,t,i,o){void 0===t&&(t=300);var l=e.style.scrollBehavior;e.style.scrollBehavior="auto";var r=e.scrollTop,a=n-r,s=null,c=function(u){null===s&&(s=u);var d,v=u-s;v<t?(e.scrollTop=(d=v,d/=t,a*(--d*d*d+1)+r),o&&o(),requestAnimationFrame(c)):(e.scrollTop=n,e.style.scrollBehavior=l,o&&o(),i&&i())};requestAnimationFrame(c)};exports.SHARED_MARKDOWN_STYLES=c.SHARED_MARKDOWN_STYLES,exports.default=function(a){var f,g,x,_,w,E,T,F,M,k,A,D,O,H,L,N,W,z=a.componentHeaderText,P=void 0===z?"Contract Comparison":z,V=a.treeData,q=a.comparisonConfig,Y=a.leftColumnTitleText,K=a.rightColumnTitleText,X=a.markdownStyles,U=a.displayConfig,G=void 0===U?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0}:U,$=a.popupConfig,J=a.deviationData,Q=void 0===J?{}:J,Z=t.useState(G.maintainRelativeOrder),ee=Z[0],ne=Z[1],te=t.useState(!1),ie=te[0],oe=te[1],le=t.useState(!1),re=le[0],ae=le[1],se=t.useState(null),ce=se[0],ue=se[1],de=t.useState(!1),ve=de[0],fe=de[1],pe=t.useState(!1),ge=pe[0],he=pe[1],xe=t.useRef(!1),_e=t.useState(null),me=_e[0],ye=_e[1],be=t.useState(new Set),Se=be[0],Re=be[1],Ie=t.useState([]),Ce=Ie[0],Be=Ie[1],je=t.useRef(null),we=t.useRef(!1),Ee=t.useRef(null),Te=t.useRef({}),Fe=t.useRef([]),Me=t.useRef(!1),ke=t.useRef(!1),Ae=t.useRef(null),De=t.useMemo(function(){return(null==V?void 0:V.cognitive_decisioning)||{}},[V]),Oe=t.useState(null),He=Oe[0],Le=Oe[1],Ne=t.useRef(null),We=t.useState({width:0,height:0}),ze=We[0],Pe=We[1],Ve=t.useMemo(function(){return e.__assign(e.__assign({},c.SHARED_MARKDOWN_STYLES),X)},[X]),qe=t.useState({isLoading:null!==(f=null==G?void 0:G.isLoading)&&void 0!==f&&f,open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,isOrphan:!1,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null,deviationData:null}),Ye=qe[0],Ke=qe[1],Xe=t.useState({isLoading:null!==(g=null==G?void 0:G.isLoading)&&void 0!==g&&g,open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,isOrphan:!1,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null,deviationData:null}),Ue=Xe[0],Ge=Xe[1],$e=t.useRef(null),Je=t.useRef(null),Qe=t.useRef(null),Ze=t.useRef(null),en=t.useRef(null),nn=t.useRef(null),tn=t.useRef(null),on=t.useRef(null),ln=t.useRef(!1),rn=t.useRef(null);t.useEffect(function(){rn.current=null},[Ye.sectionIdx,Ye.open]);var an=t.useCallback(function(){Le(null),Ke(C),ye(null)},[]),sn=t.useCallback(function(){Ge(C)},[]),cn=t.useCallback(function(){var e;if(Ye.anchorEl&&Ye.refSectionTitle){var n=Ye.anchorEl.getBoundingClientRect(),t=(null===(e=null==Ne?void 0:Ne.current)||void 0===e?void 0:e.offsetHeight)||0,i=Math.min(680,window.innerWidth-24),o=window.innerHeight-n.bottom-12-12,l=n.top-12-12,r=o<t&&l>o;null!==rn.current?!0===rn.current&&(r=l>=t||l>=o):r=!(o>=t||o>=l),rn.current=r;var a=r?l:o,s=Math.min(t||9999,a),c=r?n.top-12-s:n.bottom+12,u=n.left+n.width/2,d=u-i/2,v=Math.max(12,Math.min(d,window.innerWidth-i-12)),f=Math.max(14,Math.min(u-v,i-10-4));Le({top:c,left:v,arrowLeft:f,openAbove:r,maxHeight:a})}},[Ye.anchorEl,Ye.refSectionTitle]);t.useEffect(function(){if(Ye.open){window.addEventListener("resize",cn);var e=requestAnimationFrame(cn),n=null;return Ne.current&&(n=new ResizeObserver(function(){cancelAnimationFrame(e),e=requestAnimationFrame(cn)})).observe(Ne.current),function(){cancelAnimationFrame(e),window.removeEventListener("resize",cn),n&&n.disconnect()}}},[Ye.open,cn]),t.useEffect(function(){var e=$e.current;if(e&&Ye.open){var n=function(e){Ne.current&&Ne.current.contains(e.target)||(Le(null),an())};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})}}},[Ye.open,an]),t.useEffect(function(){var e=$e.current;if(e&&Ue.open){var n=function(){sn()};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})}}},[Ue.open,sn]);var un=t.useMemo(function(){var e,n,t,i,o,l,r;return{fields:null!==(e=null==q?void 0:q.fields)&&void 0!==e?e:c.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(t=null===(n=null==q?void 0:q.thresholds)||void 0===n?void 0:n.high)&&void 0!==t?t:c.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(o=null===(i=null==q?void 0:q.thresholds)||void 0===i?void 0:i.medium)&&void 0!==o?o:c.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(r=null===(l=null==q?void 0:q.thresholds)||void 0===l?void 0:l.exact)&&void 0!==r?r:c.DEFAULT_COMPARISON_CONFIG.thresholds.exact}}},[q]),dn=t.useMemo(function(){if(V&&Object.keys(V).length>0)try{var n=function(n,t,i){var o,l,r,a;void 0===t&&(t=!1),void 0===i&&(i=null);var c=n.nodes||n,u=[],d=[],v=n.base_root_id,f=n.input_index_map||{0:"left",1:"right"},p=n[v]||c[v];if(!p||!1===p.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[]};var g=function(t,o){var l,r,a,u=n[t]||c[t];if(!u||!1===u.display_node)return null;var d=s.getSideData(u,o,f),v=!1!==(null===(l=d.attributes)||void 0===l?void 0:l.display_title),p=!1!==(null===(r=d.attributes)||void 0===r?void 0:r.display_content),h=!!d.title.trim(),x=!!d.content.trim(),_=s.getRationale(u),m=(null===(a=null==i?void 0:i[t])||void 0===a?void 0:a.evaluation_result)||u.evaluation_result||null,y=[];u.next&&Object.values(u.next).forEach(function(e){var n=c[e];if(n&&!1!==n.display_node){var t=g(e,o);t&&y.push(t)}});var b=!(!h&&!x);return e.__assign(e.__assign({id:t,title:h?d.title:"",content:x?d.content:"",displayTitle:v,displayContent:p,subsections:y},b?_:{score:void 0,relation:"not_defined"}),{evaluationResult:m})};if(t){var h=function(t,o){var l,r,a,u,d,v,p,g,x,_,m,y,b,S,R,I,C,B,j,w,E;void 0===o&&(o=0);var T=[],F=[];if(!t)return{refSections:T,baseSections:F};var M={},k={},A=-1,D=-1;for(var O in t){var H=t[O],L=n[H]||c[H];if(L&&!1!==L.display_node){var N=s.getRationale(L),W=(null===(l=null==i?void 0:i[H])||void 0===l?void 0:l.evaluation_result)||L.evaluation_result||null,z=s.getSideData(L,"1",f),P=s.getSideData(L,"0",f),V=!1!==(null===(r=z.attributes)||void 0===r?void 0:r.display_title)&&z.title.trim()||!1!==(null===(a=z.attributes)||void 0===a?void 0:a.display_content)&&z.content.trim(),q=!1!==(null===(u=P.attributes)||void 0===u?void 0:u.display_title)&&P.title.trim()||!1!==(null===(d=P.attributes)||void 0===d?void 0:d.display_content)&&P.content.trim(),Y=Number(null!==(p=null===(v=z.attributes)||void 0===v?void 0:v.display_index)&&void 0!==p?p:A--),K=Number(null!==(x=null===(g=P.attributes)||void 0===g?void 0:g.display_index)&&void 0!==x?x:D--),X=M[Y]||e.__assign(e.__assign({id:H,title:!1!==(null===(_=z.attributes)||void 0===_?void 0:_.display_title)?z.title:"",content:!1!==(null===(m=z.attributes)||void 0===m?void 0:m.display_content)?z.content:"",subsections:[]},V?N:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:Y,evaluationResult:W,displayContent:null===(y=z.attributes)||void 0===y?void 0:y.display_content,displayTitle:null===(b=z.attributes)||void 0===b?void 0:b.display_title}),U=k[K]||e.__assign(e.__assign({id:H,title:!1!==(null===(S=P.attributes)||void 0===S?void 0:S.display_title)?P.title:"",content:!1!==(null===(R=P.attributes)||void 0===R?void 0:R.display_content)?P.content:"",subsections:[]},q?N:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:K,evaluationResult:W,displayContent:null===(I=P.attributes)||void 0===I?void 0:I.display_content,displayTitle:null===(C=P.attributes)||void 0===C?void 0:C.display_title});Number(Y)>=0&&Number(K)>=0&&((null===(B=X.refIndexes)||void 0===B?void 0:B.includes(Number(K)))||null===(j=X.refIndexes)||void 0===j||j.push(Number(K)),(null===(w=U.refIndexes)||void 0===w?void 0:w.includes(Number(Y)))||null===(E=U.refIndexes)||void 0===E||E.push(Number(Y))),M[Y]=X,k[K]=U;var G=h(L.next,o+1),$=G.refSections,J=G.baseSections;$.length>0&&(X.subsections=e.__spreadArray(e.__spreadArray([],X.subsections||[],!0),$,!0)),J.length>0&&(U.subsections=e.__spreadArray(e.__spreadArray([],U.subsections||[],!0),J,!0))}}return T=Object.values(M).map(function(e){return e}),F=Object.values(k).map(function(e){return e}),T.sort(function(e,n){return e.selfIndex<0&&n.selfIndex>=0?1:e.selfIndex>=0&&n.selfIndex<0?-1:e.selfIndex-n.selfIndex}),F.sort(function(e,n){return e.selfIndex<0&&n.selfIndex>=0?1:e.selfIndex>=0&&n.selfIndex<0?-1:e.selfIndex-n.selfIndex}),{refSections:T,baseSections:F}},x=h(p.next),_=x.refSections,m=x.baseSections;d=_,u=m}else p.next&&Object.values(p.next).forEach(function(e){var t=n[e]||c[e];t&&!1!==t.display_node&&(u.push(g(e,"0")||{id:e,title:"",content:"",subsections:[]}),d.push(g(e,"1")||{id:e,title:"",content:"",subsections:[]}))});return{activeProposed:{title:(null===(l=null===(o=p.comparison_inputs)||void 0===o?void 0:o[f[0]])||void 0===l?void 0:l.title)||"Uploaded Contract",description:p.decision_scope_description||"",sections:u},activeVariants:[{id:"tree-variant-1",title:(null===(a=null===(r=p.comparison_inputs)||void 0===r?void 0:r[f[1]])||void 0===a?void 0:a.title)||"Reference Template",similarity:0,sections:d,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:p.decision_scope_description||""},fields:{}}}}]}}(V,ee,Q);return e.__assign(e.__assign({},n),{parseError:null})}catch(e){return console.error("Data Transformation Error: ",e),{activeProposed:{},activeVariants:[],parseError:e instanceof Error?e.message:"Unknown Parsing Error"}}return{activeProposed:{},activeVariants:[],parseError:"Tree data is required"}},[JSON.stringify(V),ee,JSON.stringify(Q)]),vn=dn.activeProposed,fn=dn.activeVariants,pn=dn.parseError;t.useEffect(function(){pn&&ue("Failed to load comparison: ".concat(pn))},[pn]);var gn=t.useState(null),hn=gn[0];gn[1];var xn=t.useState({}),_n=xn[0],mn=xn[1],yn=t.useState({}),bn=yn[0],Sn=yn[1],Rn=(null==fn?void 0:fn[0])||I,In=null===(w=null===(x=null==V?void 0:V.documents)||void 0===x?void 0:x[null===(_=null==V?void 0:V.input_index_map)||void 0===_?void 0:_[0]])||void 0===w?void 0:w.title,Cn=null===(F=null===(E=null==V?void 0:V.documents)||void 0===E?void 0:E[null===(T=null==V?void 0:V.input_index_map)||void 0===T?void 0:T[1]])||void 0===F?void 0:F.title,Bn=s.safeStringify(Y||In||"Uploaded Contract"),jn=s.safeStringify(K||Cn||"Reference Template"),wn=t.useMemo(function(){return(null==vn?void 0:vn.sections)||[]},[null==vn?void 0:vn.sections]),En=t.useMemo(function(){return Rn.sections||[]},[Rn.sections]),Tn=wn.length>0||En.length>0,Fn=Rn.analysis,Mn=s.safeStringify(null===(k=null===(M=null==Fn?void 0:Fn.rule_difference_comparison)||void 0===M?void 0:M.summary)||void 0===k?void 0:k.overall_summary),kn=!!Mn.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),An=null!==(A=null==V?void 0:V.base_root_id)&&void 0!==A?A:"-1";null==V||V[An];var Dn=(null===(D=null==Q?void 0:Q[An])||void 0===D?void 0:D.evaluation_result)||(null===(H=null===(O=null==V?void 0:V.nodes)||void 0===O?void 0:O[An])||void 0===H?void 0:H.evaluation_result)||null,On=b(Dn),Hn=s.generateColorPalette(null!==(W=null===(N=null===(L=null==Dn?void 0:Dn.evaluation_outputs)||void 0===L?void 0:L.metadata)||void 0===N?void 0:N.label_color)&&void 0!==W?W:""),Ln=t.useMemo(function(){var e,n,t={},i={},o=null===(e=null==V?void 0:V.input_index_map)||void 0===e?void 0:e[0],l=null===(n=null==V?void 0:V.input_index_map)||void 0===n?void 0:n[1],r=new Map,a=function(e){return e&&e.id?(r.has(e.id)||r.set(e.id,s.safeStringify(e.content||"").replace(/\\n/g,"\n")),r.get(e.id)):""},c=function(e,n,s,u,d){var v,f,p,g,h,x,_,b;e&&!d&&function(e,n,s,c){var u,d=(null===(u=null==e?void 0:e.evaluationResult)||void 0===u?void 0:u.deviations)||{};Object.keys(d).sort().forEach(function(u){var v=d[u];if(v){var f=v[o],p=v[l],g=!1,h=!1;if(!y(f)){var x=f.replace(/\\(['’])/g,"$1").replace(/\\n/g,"\n");if(n&&x){var _=a(n);_.includes(x)&&(g=!0,r.set(n.id,_.replace(x,"__TOKEN__")))}}if(!y(p)){var b=p.replace(/\\(['’])/g,"$1").replace(/\\n/g,"\n");if(s&&b){var S=a(s);S.includes(b)&&(h=!0,r.set(s.id,S.replace(b,"__TOKEN__")))}}if(g||h){var R="".concat(e.id).concat(m).concat(u);void 0===t[R]&&(void 0===i[c]&&(i[c]=1),t[R]=i[c]++)}}})}(e,n,s,u);for(var S=Math.max((null===(v=null==n?void 0:n.subsections)||void 0===v?void 0:v.length)||0,(null===(f=null==s?void 0:s.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),R=0;R<S;R++)c((null===(g=null==e?void 0:e.subsections)||void 0===g?void 0:g[R])||(null===(h=null==n?void 0:n.subsections)||void 0===h?void 0:h[R])||(null===(x=null==s?void 0:s.subsections)||void 0===x?void 0:x[R]),null===(_=null==n?void 0:n.subsections)||void 0===_?void 0:_[R],null===(b=null==s?void 0:s.subsections)||void 0===b?void 0:b[R],u,!1)};return wn.forEach(function(e,n){var t,i=n+1;ee&&void 0!==e.selfIndex&&e.selfIndex>=0&&(i=e.selfIndex+1);var o=null;if(ee){var l=null===(t=e.refIndexes)||void 0===t?void 0:t[0];o=En.find(function(e){return e.selfIndex===l})}else o=En[n];c(e,e,o,i,!0)}),En.forEach(function(e,n){var t,i=n+1,o=!1;if(ee){var l=null===(t=e.refIndexes)||void 0===t?void 0:t[0],r=wn.find(function(e){return e.selfIndex===l});r&&void 0!==r.selfIndex&&r.selfIndex>=0?i=r.selfIndex+1:(o=!0,void 0!==e.selfIndex&&e.selfIndex>=0&&(i=e.selfIndex+1))}else n>=wn.length&&(o=!0);o&&c(e,null,e,i,!0)}),t},[wn,En,ee,V]),Nn=t.useRef({}),Wn=function(e){return Nn.current[e]||(Nn.current[e]=h.default.createRef()),Nn.current[e]},zn=t.useCallback(function(){var e,n,t,i;fe(!1),ke.current=!1;var o=Ae.current,l=Un.current;if(null!==o)if("string"==typeof o&&o.includes(m)){var r=o.split(m);(a=null===(e=gt.current[r[2]])||void 0===e?void 0:e.current)&&(a.style.paddingTop="0px")}else{var a;(a=null===(n=ut.current[o])||void 0===n?void 0:n.current)&&(a.style.paddingTop="0px")}if(null!==l)if("string"==typeof l&&l.includes(m)){r=l.split(m);(s=null===(t=ht.current[r[3]])||void 0===t?void 0:t.current)&&(s.style.paddingTop="0px")}else{var s;(s=null===(i=dt.current[l])||void 0===i?void 0:i.current)&&(s.style.paddingTop="0px")}it(null),Ae.current=null,Un.current=null,he(!1),ae(!1),Ze.current&&(Ze.current.style.height="0px"),en.current&&(en.current.style.height="0px"),nn.current&&(nn.current.style.height="0px"),tn.current&&(tn.current.style.height="0px")},[]),Pn=t.useCallback(function(e,n,t,i,o,l,r){var a,c,u,d=s.safeStringify(null==n?void 0:n.id)||s.safeStringify(null==t?void 0:t.id)||"",v=(d?De[d]:null)||(null==n?void 0:n.cognitiveData)||(null==t?void 0:t.cognitiveData)||{section_id:d,decisioning:[],gap:[],relevance_score:0},f=null!==(c=null===(a=Nn.current[i])||void 0===a?void 0:a.current)&&void 0!==c?c:null;return{isLoading:null!==(u=null==G?void 0:G.isLoading)&&void 0!==u&&u,open:!0,sectionTitle:(null==n?void 0:n.displayTitle)?null==n?void 0:n.title:"no title",refSectionTitle:(null==t?void 0:t.displayTitle)?null==t?void 0:t.title:"no title",cognitiveData:v,anchorEl:e,sectionAnchorEl:f,badgeStyle:l||null,sectionIdx:i,docData:{documents:null==V?void 0:V.documents,input_index_map:null==V?void 0:V.input_index_map},deviationData:(null==n?void 0:n.evaluationResult)||(null==t?void 0:t.evaluationResult)||null,isOrphan:!!o}},[De,V]),Vn=t.useCallback(function(e){sn(),Le(null),Ke(e)},[sn]),qn=function(e,n,t,i,o,l){e.stopPropagation(),Ue.open&&Ue.sectionIdx===o?sn():(an(),Ge(Pn(e.currentTarget,n,i,o,t,l)))},Yn=t.useCallback(function(){null!==Ue.sectionIdx&&Ue.anchorEl?Vn(e.__assign(e.__assign({},Ue),{open:!0})):sn()},[Ue,sn,Vn]),Kn=t.useCallback(function(){var e=Ue.sectionIdx,n=Ue.isOrphan;sn(),null!==e&&(n?ue("No counterpart exists to connect to."):(ke.current&&zn(),Re(function(n){return n.has(e)?new Set:new Set([e])})))},[Ue.sectionIdx,sn,zn]),Xn=t.useRef(null),Un=t.useRef(null),Gn=t.useRef(null),$n=t.useRef(null),Jn=t.useRef(null),Qn=t.useState([]),Zn=Qn[0],et=Qn[1],nt=t.useState(null),tt=nt[0],it=nt[1];t.useRef(null);var ot=t.useState(null),lt=ot[0],rt=ot[1],at=t.useMemo(function(){return un.fields.filter(function(e){var n=e.key;return(!Tn||"description"!==n)&&(s.hasValue(null==vn?void 0:vn[n])||s.hasValue(Rn[n]))})},[vn,Rn,Tn,un.fields]),st=t.useRef({}),ct=t.useRef({}),ut=t.useRef({}),dt=t.useRef({}),vt=t.useRef({}),ft=t.useRef({}),pt=t.useRef({}),gt=t.useRef({}),ht=t.useRef({});at.forEach(function(e){for(var n=e.key,t=0;t<Math.max(wn.length,En.length);t+=1)ut.current[t]||(ut.current[t]=h.default.createRef()),dt.current[t]||(dt.current[t]=h.default.createRef()),vt.current[t]||(vt.current[t]=h.default.createRef()),ft.current[t]||(ft.current[t]=h.default.createRef()),pt.current[t]||(pt.current[t]=h.default.createRef());st.current[n]||(st.current[n]=h.default.createRef()),ct.current[n]||(ct.current[n]=h.default.createRef())});for(var xt=0;xt<Math.max(wn.length,En.length);xt+=1)ut.current[xt]||(ut.current[xt]=h.default.createRef()),dt.current[xt]||(dt.current[xt]=h.default.createRef()),vt.current[xt]||(vt.current[xt]=h.default.createRef()),ft.current[xt]||(ft.current[xt]=h.default.createRef()),pt.current[xt]||(pt.current[xt]=h.default.createRef());t.useEffect(function(){if(hn){var e=un.fields.find(function(e){return e.analysisKey===hn||e.key===hn});if(e){var n=st.current[e.key]||ct.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[hn,un.fields]);var _t=t.useCallback(function(e){var n,t,i,o,l,r,a,s,c,u=null===(n=null==Fn?void 0:Fn.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!u||!u[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var d=u[e],v=(null==d?void 0:d.relation)||(null===(i=null===(t=null==d?void 0:d.highlights)||void 0===t?void 0:t.ruleA_spans)||void 0===i?void 0:i.length)||(null===(l=null===(o=null==d?void 0:d.highlights)||void 0===o?void 0:o.ruleB_spans)||void 0===l?void 0:l.length)||(null==d?void 0:d.mappings)&&d.mappings.length>0;if(d.mappings){var f=d.mappings[0]||{};return{score:d.score,relation:f.relation||"",highlightsA:(null===(r=f.highlights)||void 0===r?void 0:r.ruleA_spans)||[],highlightsB:(null===(a=f.highlights)||void 0===a?void 0:a.ruleB_spans)||[],hasContent:!!v}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(s=d.highlights)||void 0===s?void 0:s.ruleA_spans)||[],highlightsB:(null===(c=d.highlights)||void 0===c?void 0:c.ruleB_spans)||[],hasContent:!!v}},[Fn]),mt=t.useCallback(function(n){var t,i,o,l,r,a,c,u=wn[n],d=En[n],v=(null==u?void 0:u.relation)&&"not_defined"!==u.relation,f=(null==d?void 0:d.relation)&&"not_defined"!==d.relation;s.safeStringify(null==u?void 0:u.id)||s.safeStringify(null==d?void 0:d.id);var p=!(!(null==u?void 0:u.cognitiveData)&&!(null==d?void 0:d.cognitiveData));if(!v&&!f&&!p)return e.__assign(e.__assign({},s.generateColorPalette(B)),{label:"Not Defined"});var g=null!==(i=null!==(t=null==u?void 0:u.evaluationResult)&&void 0!==t?t:null==d?void 0:d.evaluationResult)&&void 0!==i?i:null,h=null===(o=null==g?void 0:g.evaluation_outputs)||void 0===o?void 0:o.output_value,x=null!==(a=null===(r=null===(l=null==g?void 0:g.evaluation_outputs)||void 0===l?void 0:l.metadata)||void 0===r?void 0:r.label_color)&&void 0!==a?a:B;return null!=g?e.__assign(e.__assign({},s.generateColorPalette(x)),{label:null!==(c=h)&&void 0!==c?c:""}):e.__assign(e.__assign({},s.generateColorPalette(x)),{label:null})},[wn,En,De,un,_t]),yt=t.useCallback(function(n){for(var t,i,o,l,r,a,c,u,d,v=n.split("-").map(Number),f=wn[v[0]],p=En[v[0]],g=1;g<v.length;g++)(null==f?void 0:f.subsections)&&(f=f.subsections[v[g]]),(null==p?void 0:p.subsections)&&(p=p.subsections[v[g]]);if(!f&&!p)return null;var h=(null==f?void 0:f.relation)&&"not_defined"!==f.relation,x=(null==p?void 0:p.relation)&&"not_defined"!==p.relation,_=s.safeStringify(null==f?void 0:f.id)||s.safeStringify(null==p?void 0:p.id)||"",m=!(!(null==f?void 0:f.cognitiveData)&&!(null==p?void 0:p.cognitiveData));if(!h&&!x&&!m)return e.__assign(e.__assign({},s.generateColorPalette(B)),{label:"Not Defined"});null!==(i=null!==(t=null==f?void 0:f.cognitiveRelevanceScore)&&void 0!==t?t:null==p?void 0:p.cognitiveRelevanceScore)&&void 0!==i||_&&(null===(o=De[_])||void 0===o||o.relevance_score);var y=null!==(r=null!==(l=null==f?void 0:f.evaluationResult)&&void 0!==l?l:null==p?void 0:p.evaluationResult)&&void 0!==r?r:null,b=null===(a=null==y?void 0:y.evaluation_outputs)||void 0===a?void 0:a.output_value,S=null!==(d=null===(u=null===(c=null==y?void 0:y.evaluation_outputs)||void 0===c?void 0:c.metadata)||void 0===u?void 0:u.label_color)&&void 0!==d?d:B;return null!=y?e.__assign(e.__assign({},s.generateColorPalette(S)),{label:null!=b?b:""}):e.__assign(e.__assign({},s.generateColorPalette(S)),{label:null})},[wn,En,De,un]),bt=t.useCallback(function(){var e,n,t,i,o,l,r,a,c,u,d,v,f,p,g,h,x,_,y,b,S,I;if(!ln.current&&!we.current){ln.current=!0;try{if(!Xn.current)return;var C=function(e){var n=e.split("-"),t=n[0];if(!_n[t]&&!1===ee)return!1;if(ee&&!_n["left-".concat(t)]&&!_n["right-".concat(t)]&&!_n[t])return!1;for(var i=t,o=1;o<n.length-1;o++)if(i+="-".concat(n[o]),!bn[i])return!1;return!0},B=Xn.current.getBoundingClientRect();Pe({width:B.width,height:B.height});var j=[];if(at.forEach(function(e){var n,t,i=e.key,o=null===(n=st.current[i])||void 0===n?void 0:n.current,l=null===(t=ct.current[i])||void 0===t?void 0:t.current;o&&l&&(o.style.height="auto",l.style.height="auto",o.style.minHeight="0px",l.style.minHeight="0px")}),!we.current){for(var w=0;w<Math.max(wn.length,En.length);w++){var E=null===(e=ut.current[w])||void 0===e?void 0:e.current,T=null===(n=dt.current[w])||void 0===n?void 0:n.current;E&&(E.style.height="auto",E.style.minHeight="0px"),T&&(T.style.height="auto",T.style.minHeight="0px")}ee||Object.keys(gt.current).forEach(function(e){var n,t;if(C(e)){var i=null===(n=gt.current[e])||void 0===n?void 0:n.current,o=null===(t=ht.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 F={};at.forEach(function(e){var n,t,i=e.key,o=null===(n=st.current[i])||void 0===n?void 0:n.current,l=null===(t=ct.current[i])||void 0===t?void 0:t.current;if(o&&l){var r=o.getBoundingClientRect(),a=l.getBoundingClientRect();F[i]=Math.max(r.height,a.height)}});var M={left:{},right:{}},k={};if(!we.current)if(ee){if(ve&&null!==tt)if("number"==typeof tt){var A=tt,D=wn[A],O=null===(o=ut.current[A])||void 0===o?void 0:o.current;O&&D&&(D.refIndexes||[]).forEach(function(e){var n,t=En.findIndex(function(n){return n.selfIndex===e}),i=null===(n=dt.current[t])||void 0===n?void 0:n.current;if(i&&(_n["left-".concat(A)]||_n["right-".concat(t)])){var o=Math.max(O.getBoundingClientRect().height,i.getBoundingClientRect().height);M.left[A]=Math.max(M.left[A]||0,o),M.right[t]=Math.max(M.right[t]||0,o)}})}else{var H=tt.split(m)[2];if(H){E=null===(l=gt.current[H])||void 0===l?void 0:l.current,T=null===(r=ht.current[H])||void 0===r?void 0:r.current;if(E&&T){L=Math.max(E.getBoundingClientRect().height,T.getBoundingClientRect().height);k[H]=Math.max(k[H]||0,L)}}}}else{Object.keys(gt.current).forEach(function(e){var n,t;if(C(e)){var i=null===(n=gt.current[e])||void 0===n?void 0:n.current,o=null===(t=ht.current[e])||void 0===t?void 0:t.current;if(i&&o&&null!==i.offsetParent&&null!==o.offsetParent){var l=i.getBoundingClientRect(),r=o.getBoundingClientRect(),a=Math.max(l.height,r.height);k[e]=a,i.style.minHeight="".concat(a,"px"),o.style.minHeight="".concat(a,"px")}}});for(w=0;w<Math.min(wn.length,En.length);w++){var E=null===(t=ut.current[w])||void 0===t?void 0:t.current,T=null===(i=dt.current[w])||void 0===i?void 0:i.current;if(E&&T){var L=Math.max(E.getBoundingClientRect().height,T.getBoundingClientRect().height);M.left[w]=L,M.right[w]=L}}}if(at.forEach(function(e){var n,t,i=e.key,o=null===(n=st.current[i])||void 0===n?void 0:n.current,l=null===(t=ct.current[i])||void 0===t?void 0:t.current;if(o&&l){var r=F[i];o.style.minHeight="".concat(r,"px"),l.style.minHeight="".concat(r,"px")}}),we.current||(Object.entries(M.left).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=ut.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),Object.entries(M.right).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=dt.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),ee||Object.keys(k).forEach(function(e){var n,t,i=null===(n=gt.current[e])||void 0===n?void 0:n.current,o=null===(t=ht.current[e])||void 0===t?void 0:t.current;if(i&&o&&k[e]){var l=k[e];i.style.minHeight="".concat(l,"px"),o.style.minHeight="".concat(l,"px")}})),ee)wn.forEach(function(e,n){var t;(null===(t=ut.current[n])||void 0===t?void 0:t.current)&&(e.refIndexes||[]).forEach(function(e){var t,i,o,l,r,a,s,c,u,d,v=En.findIndex(function(n){return n.selfIndex===e});if(-1!==v){var f=null===(t=vt.current[n])||void 0===t?void 0:t.current,p=null===(i=ft.current[v])||void 0===i?void 0:i.current;if(f&&p){var g=f.getBoundingClientRect(),h=p.getBoundingClientRect(),x=g.right-B.left,_=h.left-B.left,m=g.top+g.height/2-B.top,y=h.top+h.height/2-B.top;if(ve&&tt===n){var b=null!==(l=null===(o=on.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==l?l:0,S=null!==(a=null===(r=Qe.current)||void 0===r?void 0:r.getBoundingClientRect().top)&&void 0!==a?a:0,R=b+(null!==(c=null===(s=on.current)||void 0===s?void 0:s.clientHeight)&&void 0!==c?c:1/0),I=S+(null!==(d=null===(u=Qe.current)||void 0===u?void 0:u.clientHeight)&&void 0!==d?d:1/0),C=g.top+g.height/2,w=function(e,n,t){return Math.max(n,Math.min(t,e))};m=w(C,b,R)-B.top,y=w(C,S,I)-B.top}var E=mt(n);E&&j.push({id:"line-".concat(n,"-").concat(v),x1:x,y1:m,x2:_,y2:y,style:E,sectionIdx:n,targetRightIdx:v})}}})});else{for(w=0;w<Math.min(wn.length,En.length);w++){var N=null===(a=ut.current[w])||void 0===a?void 0:a.current,W=null===(c=dt.current[w])||void 0===c?void 0:c.current;if(N&&W){var z=N.getBoundingClientRect(),P=W.getBoundingClientRect(),V=Math.max(z.top,P.top)+18-B.top,q=(null===(u=En[w])||void 0===u?void 0:u.id)||"sec-".concat(w);(Q=mt(w))&&j.push({id:q,x1:z.right-B.left,y1:V,x2:P.left-B.left,y2:V,style:Q,sectionIdx:w,hasCognitive:!!((null===(d=wn[w])||void 0===d?void 0:d.cognitiveData)||(null===(v=En[w])||void 0===v?void 0:v.cognitiveData)||q&&De[q]),isSubSection:!1})}}Object.keys(gt.current).forEach(function(e){var n,t,i,o,l,r;if(C(e)){var a=null===(n=gt.current[e])||void 0===n?void 0:n.current,c=null===(t=ht.current[e])||void 0===t?void 0:t.current;if(a&&c){for(var u=e.split("-").map(Number),d=wn[u[0]],v=En[u[0]],f=1;f<u.length;f++)(null==d?void 0:d.subsections)&&(d=d.subsections[u[f]]),(null==v?void 0:v.subsections)&&(v=v.subsections[u[f]]);var p=!!d&&((null===(i=d.displayTitle)||void 0===i||i)&&s.hasValue(d.title)),g=!!d&&((null===(o=d.displayContent)||void 0===o||o)&&s.hasValue(d.content)),h=!!v&&((null===(l=v.displayTitle)||void 0===l||l)&&s.hasValue(v.title)),x=!!v&&((null===(r=v.displayContent)||void 0===r||r)&&s.hasValue(v.content));if(p&&g||h&&x){var _=a.getBoundingClientRect(),m=c.getBoundingClientRect(),y=Math.max(_.top,m.top)+16-B.top,b=yt(e);b&&"Not Defined"!==b.label&&j.push({id:"subsec-".concat(e),x1:_.right-B.left,y1:y,x2:m.left-B.left,y2:y,style:b,sectionIdx:u[0],isSubSection:!0,subSectionKeyPath:e,hasCognitive:!(!(null==d?void 0:d.cognitiveData)&&!(null==v?void 0:v.cognitiveData))})}}}})}if(ve&&"string"==typeof tt&&tt.includes(m)){var Y=tt.split(m),K=Y[0],X=Y[1],U=Y[2],G=(Y[3],"".concat(K).concat(m).concat(X)),$=null===(f=vt.current[G])||void 0===f?void 0:f.current,J=null===(p=ft.current[G])||void 0===p?void 0:p.current;if($&&J){var Q,Z=$.getBoundingClientRect(),ne=J.getBoundingClientRect(),te=Z.right-B.left,ie=ne.left-B.left,oe=Z.top+Z.height/2-B.top,le=ne.top+ne.height/2-B.top;if(ee){var re=null!==(h=null===(g=on.current)||void 0===g?void 0:g.getBoundingClientRect().top)&&void 0!==h?h:0,ae=null!==(_=null===(x=Qe.current)||void 0===x?void 0:x.getBoundingClientRect().top)&&void 0!==_?_:0,se=re+(null!==(b=null===(y=on.current)||void 0===y?void 0:y.clientHeight)&&void 0!==b?b:1/0),ce=ae+(null!==(I=null===(S=Qe.current)||void 0===S?void 0:S.clientHeight)&&void 0!==I?I:1/0),ue=function(e,n,t){return Math.max(n,Math.min(t,e))};oe=ue(Z.top+Z.height/2,re,se)-B.top,le=ue(ne.top+ne.height/2,ae,ce)-B.top}(Q=yt(U))&&j.push({id:"line-subsec-".concat(G),x1:te,y1:oe,x2:ie,y2:le,style:Q,sectionIdx:Number(U.split("-")[0]),isSubSection:!0,subSectionKeyPath:tt})}}if(et(j),$n.current&&Jn.current){var de=$n.current.getBoundingClientRect(),fe=Jn.current.getBoundingClientRect(),pe=(de.top+de.height/2-B.top+fe.top+fe.height/2-B.top)/2;rt({x1:de.right-B.left,x2:fe.left-B.left,y:pe})}else rt(null);if(Se.size>0){var ge=[],he=on.current,xe=Qe.current;if(he&&xe){var _e=[],me=he.getBoundingClientRect().top,ye=xe.getBoundingClientRect().top,be=me+he.clientHeight,Re=ye+xe.clientHeight,Ie=he.scrollTop,Ce=xe.scrollTop,je=B.top,Ee=function(e,n,t){return Math.max(n,Math.min(t,e))};Se.forEach(function(e){var n,t,i,o,l;if("string"==typeof e&&e.includes(m)){var r=e.split(m),a=r[0],s=r[1],c=r[2],u=(r[3],"".concat(a).concat(m).concat(s)),d=null===(n=vt.current[u])||void 0===n?void 0:n.current,v=null===(t=ft.current[u])||void 0===t?void 0:t.current;if(!d||!v)return;var f=d.getBoundingClientRect(),p=v.getBoundingClientRect(),g=yt(c),h=(D=f.right-B.left)+.5*((O=p.left-B.left-0)-D),x=f.top+f.height/2,_=p.top+p.height/2,y=x-me+Ie,b=_-ye+Ce,S="conn-subsec-".concat(u);_e.push({lhsScrollY:y,rhsScrollY:b,x1:D,x2:O,containerTop:je,leftIdx:e,rhsArrayIdx:e,styleColor:(null==g?void 0:g.badgeBorder)||"#6366F1",styleId:S});var I=Ee(x,me,be),C=Ee(_,ye,Re),j=I-je,w=C-je,E=_>=ye-4&&_<=Re+4,T="";T=(H=x>=me-4&&x<=be+4)&&E?R(D,j,O,w):H&&!E?"M ".concat(D,",").concat(j," L ").concat(h,",").concat(j," L ").concat(h,",").concat(w):!H&&E?"M ".concat(h,",").concat(j," L ").concat(h,",").concat(w," L ").concat(O,",").concat(w):"M ".concat(h,",").concat(j," L ").concat(h,",").concat(w),ge.push({id:S,pathD:T,style:g,leftIdx:e,rhsArrayIdx:e})}else if(ee){var F=e,M=wn[F];if(!(null===(l=null==M?void 0:M.refIndexes)||void 0===l?void 0:l.length))return;M.refIndexes.forEach(function(e){var n,t,i=En.findIndex(function(n){return n.selfIndex===e});if(-1!==i){var o=null===(n=vt.current[F])||void 0===n?void 0:n.current,l=null===(t=ft.current[i])||void 0===t?void 0:t.current;if(o&&l){var r=o.getBoundingClientRect(),a=l.getBoundingClientRect(),s=mt(F),c=r.right-B.left,u=a.left-B.left-0,d=c+.5*(u-c),v=r.top+r.height/2,f=a.top+a.height/2,p=v-me+Ie,g=f-ye+Ce,h="conn-".concat(F,"-").concat(i);_e.push({lhsScrollY:p,rhsScrollY:g,x1:c,x2:u,containerTop:je,leftIdx:F,rhsArrayIdx:i,styleColor:(null==s?void 0:s.badgeBorder)||"#6366F1",styleId:h});var x=Ee(v,me,be),_=Ee(f,ye,Re),m=x-je,y=_-je,b=v>=me-4&&v<=be+4,S=f>=ye-4&&f<=Re+4,I="";I=b&&S?R(c,m,u,y):b&&!S?"M ".concat(c,",").concat(m," L ").concat(d,",").concat(m," L ").concat(d,",").concat(y):!b&&S?"M ".concat(d,",").concat(m," L ").concat(d,",").concat(y," L ").concat(u,",").concat(y):"M ".concat(d,",").concat(m," L ").concat(d,",").concat(y),ge.push({id:h,pathD:I,style:s,leftIdx:F,rhsArrayIdx:i})}}})}else{var k=e,A=k;d=null===(i=vt.current[k])||void 0===i?void 0:i.current,v=null===(o=ft.current[A])||void 0===o?void 0:o.current;if(!d||!v)return;var D,O;f=d.getBoundingClientRect(),p=v.getBoundingClientRect(),g=mt(k),h=(D=f.right-B.left)+.5*((O=p.left-B.left-0)-D),x=f.top+f.height/2,_=p.top+p.height/2,y=x-me+Ie,b=_-ye+Ce,S="conn-".concat(k,"-").concat(A);_e.push({lhsScrollY:y,rhsScrollY:b,x1:D,x2:O,containerTop:je,leftIdx:k,rhsArrayIdx:A,styleColor:(null==g?void 0:g.badgeBorder)||"#6366F1",styleId:S});var H;I=Ee(x,me,be),C=Ee(_,ye,Re),j=I-je,w=C-je,E=_>=ye-4&&_<=Re+4,T="";T=(H=x>=me-4&&x<=be+4)&&E?R(D,j,O,w):H&&!E?"M ".concat(D,",").concat(j," L ").concat(h,",").concat(j," L ").concat(h,",").concat(w):!H&&E?"M ".concat(h,",").concat(j," L ").concat(h,",").concat(w," L ").concat(O,",").concat(w):"M ".concat(h,",").concat(j," L ").concat(h,",").concat(w),ge.push({id:S,pathD:T,style:g,leftIdx:k,rhsArrayIdx:A})}}),Fe.current=_e}Be(ge)}else Be([]),Fe.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{ln.current=!1}}},[at,wn,En,De,un,_t,mt,ee,ve,tt,Se,_n,bn]),St=t.useCallback(function(){var e,n,t,i,o,l,r,a,s,c,u,d,v,f,p=Fe.current;if(p.length&&!we.current){var g=null!==(n=null===(e=on.current)||void 0===e?void 0:e.scrollTop)&&void 0!==n?n:0,h=null!==(i=null===(t=Qe.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,x=null!==(l=null===(o=on.current)||void 0===o?void 0:o.clientHeight)&&void 0!==l?l:1/0,_=null!==(a=null===(r=Qe.current)||void 0===r?void 0:r.clientHeight)&&void 0!==a?a:1/0,m=null!==(c=null===(s=on.current)||void 0===s?void 0:s.getBoundingClientRect().top)&&void 0!==c?c:0,y=null!==(d=null===(u=Qe.current)||void 0===u?void 0:u.getBoundingClientRect().top)&&void 0!==d?d:0,b=m+x,S=y+_,I=null!==(f=null===(v=Xn.current)||void 0===v?void 0:v.getBoundingClientRect().top)&&void 0!==f?f:0,C=function(e,n,t){return Math.max(n,Math.min(t,e))};p.forEach(function(e){var n=e.lhsScrollY-g+m,t=e.rhsScrollY-h+y,i=Te.current[e.styleId+"-stroke"],o=Te.current[e.styleId+"-bg"];if(i||o){var l,r=C(n,m,b),a=C(t,y,S),s=r-I,c=a-I,u=n>=m-4&&n<=b+4,d=t>=y-4&&t<=S+4,v=e.x1+.5*(e.x2-e.x1);l=u&&d?R(e.x1,s,e.x2,c):u&&!d?"M ".concat(e.x1,",").concat(s," L ").concat(v,",").concat(s," L ").concat(v,",").concat(c):!u&&d?"M ".concat(v,",").concat(s," L ").concat(v,",").concat(c," L ").concat(e.x2,",").concat(c):"M ".concat(v,",").concat(s," L ").concat(v,",").concat(c),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",l)),o&&(o.setAttribute("visibility","visible"),o.setAttribute("d",l))}})}},[]),Rt=t.useRef(bt);t.useEffect(function(){Rt.current=bt},[bt]);var It=t.useRef(null),Ct=t.useCallback(function(){null!==It.current&&clearTimeout(It.current),It.current=setTimeout(function(){Rt.current(),It.current=null},50)},[]),Bt=t.useCallback(function(e){var n,t,i,o,l,r,a,s,c,u;if(!xe.current){if(ee||Ct(),ke.current){var d=Ae.current,v=Un.current,f=on.current,p=Qe.current;if(null!==d&&null!==v&&f&&p){var g="string"==typeof d&&d.includes(m)?null===(n=vt.current["".concat(d.split(m)[0]).concat(m).concat(d.split(m)[1])])||void 0===n?void 0:n.current:null===(t=Nn.current[d])||void 0===t?void 0:t.current,h="string"==typeof v&&v.includes(m)?null===(i=ft.current["".concat(v.split(m)[0]).concat(m).concat(v.split(m)[1])])||void 0===i?void 0:i.current:null===(o=pt.current[v])||void 0===o?void 0:o.current;if(g&&h){var x=g.getBoundingClientRect().top-f.getBoundingClientRect().top+f.scrollTop,_=h.getBoundingClientRect().top-p.getBoundingClientRect().top+p.scrollTop;if(e.currentTarget===f){var y=_-(x-f.scrollTop),b=p.scrollHeight-p.clientHeight,S=Math.max(0,Math.min(y,b));Math.abs(p.scrollTop-S)>1&&(p.scrollTop=S)}else if(e.currentTarget===p){var R=x-(_-p.scrollTop),I=f.scrollHeight-f.clientHeight,C=Math.max(0,Math.min(R,I));Math.abs(f.scrollTop-C)>1&&(f.scrollTop=C)}if(Gn.current){var B=void 0,j=void 0;if("string"==typeof d&&d.includes(m)){var w=d.split(m),E="".concat(w[0]).concat(m).concat(w[1]);B=null===(l=vt.current[E])||void 0===l?void 0:l.current,j=null===(r=ft.current[E])||void 0===r?void 0:r.current}else B=null===(a=vt.current[d])||void 0===a?void 0:a.current,j=null===(s=ft.current[v])||void 0===s?void 0:s.current;var T=null!==(u=null===(c=Xn.current)||void 0===c?void 0:c.getBoundingClientRect().top)&&void 0!==u?u:0,F=f.getBoundingClientRect().top,M=F+f.clientHeight,k=p.getBoundingClientRect().top,A=k+p.clientHeight,D=function(e,n,t){return Math.max(n,Math.min(t,e))};if(B&&j){var O=B.getBoundingClientRect(),H=j.getBoundingClientRect(),L=O.top+O.height/2,N=H.top+H.height/2,W=D(L,F,M),z=D(N,k,A);Gn.current.setAttribute("y1",(W-T).toString()),Gn.current.setAttribute("y2",(z-T).toString());var P=L>=F-4&&L<=M+4;Gn.current.setAttribute("visibility",P?"visible":"hidden")}}}}}Fe.current.length>0&&!Me.current&&(Me.current=!0,requestAnimationFrame(function(){St(),Me.current=!1}))}},[St,ee,Ct]);t.useEffect(function(){var e=setTimeout(Ct,250);window.addEventListener("resize",Ct);var n=null,t=null;return $e.current&&(n=new ResizeObserver(Ct)).observe($e.current),Xn.current&&(t=new ResizeObserver(Ct)).observe(Xn.current),function(){clearTimeout(e),window.removeEventListener("resize",Ct),null==n||n.disconnect(),null==t||t.disconnect()}},[vn,Rn,Fn,at,_n,bn,wn,En,un,Ct,ve,tt,ge,Se]),t.useEffect(function(){ke.current=ve},[ve]),t.useEffect(function(){Ae.current=tt},[tt]);var jt=t.useCallback(function(){var e,n,t,i,o=Ue.sectionIdx,l=Ue.isOrphan;if(sn(),null!=o)if(l)ue("No counterpart exists for this section.");else if(ve&&tt===o)zn();else{if(!ee){var r=Ae.current,a=Un.current;if(null!==r)if("string"==typeof r&&r.includes(m)){var s=r.split(m);(c=null===(e=gt.current[s[2]])||void 0===e?void 0:e.current)&&(c.style.paddingTop="0px")}else{var c;(c=null===(n=ut.current[r])||void 0===n?void 0:n.current)&&(c.style.paddingTop="0px")}if(null!==a)if("string"==typeof a&&a.includes(m)){s=a.split(m);(u=null===(t=ht.current[s[3]])||void 0===t?void 0:t.current)&&(u.style.paddingTop="0px")}else{var u;(u=null===(i=dt.current[a])||void 0===i?void 0:i.current)&&(u.style.paddingTop="0px")}}Re(new Set),Be([]),Fe.current=[],ae(!0),xe.current=!0,it(o),Ae.current=o,fe(!0),ke.current=!0,he(!1),Ze.current&&(Ze.current.style.height="0px"),en.current&&(en.current.style.height="0px"),nn.current&&(nn.current.style.height="0px"),tn.current&&(tn.current.style.height="0px"),requestAnimationFrame(function(){var e,n,t,i,l,r,a,s,c,u,d,v=null,f=null,p=null,g=null,h=null;if("string"==typeof o&&o.includes(m)){var x=o.split(m),_="".concat(x[0]).concat(m).concat(x[1]);v=(null===(e=vt.current[_])||void 0===e?void 0:e.current)||null,h=(f=(null===(n=ft.current[_])||void 0===n?void 0:n.current)||null)?o:null,p=(null===(t=gt.current[x[2]])||void 0===t?void 0:t.current)||null,g=(null===(i=ht.current[x[3]])||void 0===i?void 0:i.current)||null}else if(v=(null===(l=Nn.current[o])||void 0===l?void 0:l.current)||null,p=(null===(r=ut.current[o])||void 0===r?void 0:r.current)||null,ee){var y=wn[o],b=(null==y?void 0:y.refIndexes)||[];if(b.length>0){var S=b[0],R=En.findIndex(function(e){return e.selfIndex===S});-1!==R&&(f=(null===(c=pt.current[R])||void 0===c?void 0:c.current)||null,g=(null===(u=dt.current[R])||void 0===u?void 0:u.current)||null,h=R)}}else f=(null===(a=pt.current[o])||void 0===a?void 0:a.current)||null,g=(null===(s=dt.current[o])||void 0===s?void 0:s.current)||null,h=f?o:null;Un.current=h;var I=on.current,C=Qe.current;if(!v||!I)return xe.current=!1,void ae(!1);if(!f||!C)return he(!0),Rt.current(),xe.current=!1,void ae(!1);if(!ee){var B=v.getBoundingClientRect(),w=f.getBoundingClientRect(),E=B.top-w.top;p&&g&&(p.style.paddingTop="0px",g.style.paddingTop="0px",E>0?g.style.paddingTop="".concat(E,"px"):E<0&&(p.style.paddingTop="".concat(Math.abs(E),"px")));var T=v?v.getBoundingClientRect().top:(null==p?void 0:p.getBoundingClientRect().top)||0;return null===(d=$e.current)||void 0===d||d.scrollTo({top:$e.current.scrollTop+T-150,behavior:"smooth"}),he(!0),Rt.current(),xe.current=!1,void ae(!1)}var F=v.getBoundingClientRect().top-I.getBoundingClientRect().top+I.scrollTop,M=f.getBoundingClientRect().top-C.getBoundingClientRect().top+C.scrollTop-(F-I.scrollTop);M<0&&Ze.current&&(Ze.current.style.height="".concat(Math.abs(M),"px"));requestAnimationFrame(function(){var e,n=C.scrollHeight-C.clientHeight;if(M<0)e=0;else{if(M>n){var t=M-n;return en.current&&(en.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){j(C,M,200,function(){he(!0),Rt.current(),xe.current=!1,ae(!1)})})}e=M}j(C,e,200,function(){he(!0),Rt.current(),xe.current=!1,ae(!1)})})})}},[sn,Ue.sectionIdx,ve,tt,wn,En,Ct,zn]),wt=null!==Ue.sectionIdx&&Se.has(Ue.sectionIdx),Et=function(t){var l,r,a,c,u,d,v,f=t.section,p=t.idx,g=t.columnKey,x=t.colRef,_=t.mb,m=void 0===_?1:_,y=t.parentNodeId,b=void 0===y?"":y,R=ee?!!_n["".concat(g,"-").concat(p)]:!!_n[String(p)],I=(null===(l=f.displayTitle)||void 0===l||l)&&s.hasValue(f.title),C=(null===(r=f.displayContent)||void 0===r||r)&&s.hasValue(f.content),j=!I&&!C,w={current:1},E=f.title;I||(E=C?"No Title Found":"No Matching Section Found");var T,F=null!==(d=null===(u=null===(c=null===(a=f.evaluationResult)||void 0===a?void 0:a.evaluation_outputs)||void 0===c?void 0:c.metadata)||void 0===u?void 0:u.label_color)&&void 0!==d?d:B,M=s.generateColorPalette(F).highlightBg,k=[];if(null===(v=f.evaluationResult)||void 0===v?void 0:v.deviations){var A=f.evaluationResult.deviations;for(var D in A){var O=A[D][b];O&&k.push(O)}}return n.jsx(i.Box,e.__assign({ref:x,sx:{mb:m,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:n.jsxs(i.Accordion,e.__assign({disableGutters:!0,expanded:!j&&R,onChange:function(){return!j&&function(n,t){var i,o;we.current=!0,Ee.current&&clearTimeout(Ee.current),je.current&&(je.current.style.opacity="0");var l=null===(i=ut.current[n])||void 0===i?void 0:i.current,r=null===(o=dt.current[n])||void 0===o?void 0:o.current;l&&(l.style.minHeight="0px"),r&&(r.style.minHeight="0px"),Ee.current=setTimeout(function(){we.current=!1,Rt.current(),je.current&&(je.current.style.opacity="1")},650),mn(function(i){var o=e.__assign({},i),l=ee?"".concat(t,"-").concat(n):String(n),r=!i[l];if(!r){var a=String(tt||""),s=tt===n||a.startsWith("".concat(n,"-")),c=!1;Se.forEach(function(e){(e===n||String(e).startsWith("".concat(n,"-")))&&(c=!0)}),(s||c)&&(zn(),Re(new Set),Be([]),Fe.current=[])}if(!ee)return o[String(n)]=r,o;if(o[l]=r,"left"===t)((null==(u=wn[n])?void 0:u.refIndexes)||[]).forEach(function(e){var n=En.findIndex(function(n){return n.selfIndex===e});-1!==n&&(o["right-".concat(n)]=r)});else{var u,d=null==(u=En[n])?void 0:u.selfIndex;wn.forEach(function(e,n){var t;(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(d))&&(o["left-".concat(n)]=r)})}return o})}(p,g)},sx:{boxShadow:"none",border:j?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:j?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flexGrow:1,width:"100%",display:"flex",flexDirection:"column",minWidth:0,"&:before":{display:"none"}}},{children:[n.jsx(i.AccordionSummary,e.__assign({expandIcon:j?null:n.jsx(o.ChevronDown,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:j?"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:I&&n.jsx(i.Tooltip,e.__assign({title:E,placement:"top"},{children:n.jsx(i.Typography,e.__assign({component:"div",sx:{fontSize:"12px",color:j?"#94A3B8":"#19213D",fontWeight:j?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(T=E,T?s.safeStringify(T).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(e,t){return e.startsWith("**")&&e.endsWith("**")?n.jsx("strong",{children:e.slice(2,-2)},t):n.jsx(h.default.Fragment,{children:e},t)}):null)}))}))})),!j&&n.jsxs(i.AccordionDetails,e.__assign({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[C&&n.jsx(S,{content:f.content,sxStyles:Ve,highlights:k,maintainRelativeOrder:ee,highlightBg:M}),(f.subsections||[]).map(function(e,n){return Tt({section:e,keyPath:"".concat(p,"-").concat(n),depth:0,columnKey:g,parentNodeId:b,devCounter:w})})]}))]}))}),"".concat(g,"-sec-").concat(p))},Tt=function(t){var l,r,a,c,u,d,v,f,p,g,x,_,b,R,I,C=t.section,j=t.keyPath,w=t.depth,E=void 0===w?0:w,T=t.columnKey,F=void 0===T?"left":T,M=t.parentNodeId,k=void 0===M?"":M,A=(null===(l=C.displayTitle)||void 0===l||l)&&s.hasValue(C.title),D=(null===(r=C.displayContent)||void 0===r||r)&&s.hasValue(C.content),O=!A&&!D,H=A?C.title:D?"No Title Found":"No Matching Section Found",L=!!bn[j];"left"!==F||gt.current[j]||(gt.current[j]=h.default.createRef()),"right"!==F||ht.current[j]||(ht.current[j]=h.default.createRef());var N="left"===F?gt.current[j]:ht.current[j],W=yt(j),z=j.split("-").map(Number),P=z[0],q=wn[P],Y=En[P],K=j,X=j;if(ee)if("left"===F){var U=null===(a=null==q?void 0:q.refIndexes)||void 0===a?void 0:a[0],G=En.findIndex(function(e){return e.selfIndex===U});-1!==G&&(Y=En[G],X=e.__spreadArray([G],z.slice(1),!0).join("-"))}else{var $=null===(c=null==Y?void 0:Y.refIndexes)||void 0===c?void 0:c[0],J=wn.findIndex(function(e){return e.selfIndex===$});-1!==J&&(q=wn[J],K=e.__spreadArray([J],z.slice(1),!0).join("-"))}var Q,Z="left"===F?q:Y;Q=ee&&void 0!==(null==Z?void 0:Z.selfIndex)&&Z.selfIndex>=0?Z.selfIndex+1:P+1;for(var ne=q,te=Y,ie=1;ie<z.length;ie++)(null==ne?void 0:ne.subsections)&&(ne=ne.subsections[z[ie]]),(null==te?void 0:te.subsections)&&(te=te.subsections[z[ie]]);var oe=null===(u=null==V?void 0:V.input_index_map)||void 0===u?void 0:u[0],le=null===(d=null==V?void 0:V.input_index_map)||void 0===d?void 0:d[1],re="left"===F?le:oe,ae=ee?!(null===(v=C.refIndexes)||void 0===v?void 0:v.length)||void 0!==C.selfIndex&&C.selfIndex<0:"left"===F?!te:!ne,se=null!==(g=null===(p=null===(f=C.evaluationResult)||void 0===f?void 0:f.evaluation_outputs)||void 0===p?void 0:p.output_value)&&void 0!==g?g:null,ce=C.id,ue=null!==(R=null===(b=null===(_=null===(x=C.evaluationResult)||void 0===x?void 0:x.evaluation_outputs)||void 0===_?void 0:_.metadata)||void 0===b?void 0:b.label_color)&&void 0!==R?R:B,de=s.generateColorPalette(ue).highlightBg,ve=(null===(I=C.evaluationResult)||void 0===I?void 0:I.deviations)||{},fe=Object.entries(ve).map(function(n){var t=n[0],i=n[1],o="".concat(ce).concat(m).concat(t),l=Ln[o];if(!l)return null;var r=i[k],a=y(r);if(a)r="";else if(!r)return null;var s=i[re],c=ae||y(s),u="".concat(Q,".").concat(l),d="".concat(ce).concat(m).concat(t).concat(m).concat(K).concat(m).concat(X);return"left"!==F||vt.current[o]||(vt.current[o]=h.default.createRef()),"right"!==F||ft.current[o]||(ft.current[o]=h.default.createRef()),{id:o,actionId:d,label:u,highlight:r,side:F,style:W,score:se,isConnected:Se.has(d),isOrphan:c,isMissingClause:a,badgeRef:"left"===F?vt.current[o]:ft.current[o],onClick:function(n){n.stopPropagation();var t=e.__assign(e.__assign({},ne||{title:"",content:""}),{title:(null==q?void 0:q.title)||(null==ne?void 0:ne.title)||""}),i=e.__assign(e.__assign({},te||{title:"",content:""}),{title:(null==Y?void 0:Y.title)||(null==te?void 0:te.title)||""});qn(n,t,c,i,d,W)}}}).filter(Boolean),pe=fe.some(function(e){return Se.has(e.actionId)});if(!(A||D||C.subsections&&0!==C.subsections.length))return null;var ge=function(){var e,n=[];if(null===(e=C.evaluationResult)||void 0===e?void 0:e.deviations){var t=C.evaluationResult.deviations;for(var i in t){var o=t[i][k];o&&n.push(o)}}return n}();if(!A)return n.jsx(i.Box,e.__assign({ref:N,sx:{mt:0===E?1:.75,width:"100%",minWidth:0,position:"relative"}},{children:!O&&n.jsxs(i.Box,e.__assign({sx:e.__assign({width:"100%"},pe&&W&&{borderRadius:"4px",outline:"2px solid ".concat(W.badgeBorder),outlineOffset:"1px"})},{children:[D&&n.jsx(S,{content:C.content,sxStyles:Ve,deviationBadges:fe,maintainRelativeOrder:ee,highlightBg:de,highlights:ge}),(C.subsections||[]).map(function(e,n){return Tt({section:e,keyPath:"".concat(j,"-").concat(n),depth:E+1,columnKey:F,parentNodeId:k})})]}))}),j);var he=!ee&&A&&D;return n.jsx(i.Box,e.__assign({ref:N,sx:{mt:1,width:"100%",minWidth:0,position:"relative"}},{children:n.jsx(i.Box,e.__assign({sx:e.__assign({width:"100%"},pe&&W&&{borderRadius:"4px",outline:"2px solid ".concat(W.badgeBorder),outlineOffset:"1px"})},{children:n.jsxs(i.Accordion,e.__assign({disableGutters:!0,expanded:!O&&L,onChange:function(){if(!O){if(L){var n=String(tt||""),t=n.includes(K)||n.includes(X);t||Se.forEach(function(e){(String(e).includes(K)||String(e).includes(X))&&(t=!0)}),t&&(zn(),Re(new Set),Be([]),Fe.current=[])}Sn(function(n){var t;return e.__assign(e.__assign({},n),((t={})[j]=!n[j],t))})}},sx:{mt:0,boxShadow:"none",border:O?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF",minWidth:0,"&:before":{display:"none"}}},{children:[n.jsx(i.AccordionSummary,e.__assign({expandIcon:O?null:n.jsx(o.ChevronDown,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"}}},{children:n.jsx(i.Typography,e.__assign({component:"div",sx:{fontSize:"11px",fontWeight:600,color:O?"#94A3B8":"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:H||"Untitled Subsection"}))})),!O&&n.jsxs(i.AccordionDetails,e.__assign({sx:{pt:0,pb:1,minWidth:0}},{children:[D&&n.jsx(S,{content:C.content,sxStyles:Ve,deviationBadges:he?[]:fe,maintainRelativeOrder:ee,highlightBg:de,highlights:ge}),(C.subsections||[]).map(function(e,n){return Tt({section:e,keyPath:"".concat(j,"-").concat(n),depth:E+1,columnKey:F,parentNodeId:k})})]}))]}))}))}),j)};return n.jsxs(i.Box,e.__assign({ref:Je,sx:e.__assign(e.__assign({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},ee?{}:{overflow:"visible"}),{position:"relative"})},{children:[ie&&n.jsx(i.Box,e.__assign({sx:{position:"absolute",inset:0,bgcolor:"rgba(255, 255, 255, 0.6)",backdropFilter:"blur(10px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"8px"}},{children:n.jsx(v.default,{})})),n.jsx(d.default,{open:Ue.open,anchorEl:Ue.anchorEl,sectionTitle:Ue.sectionTitle,referenceSectionTitle:Ue.refSectionTitle,onClose:sn,onOpenCognitiveCompare:Yn,onOpenSideBySide:jt,onConnect:Kn,isConnected:wt,isOrphan:Ue.isOrphan}),Ye.open&&n.jsx(u.default,{open:Ye.open,popupRef:Ne,position:He,popupConfig:$,onClose:function(){Le(null),Ke(function(n){return e.__assign(e.__assign({},n),{open:!1})}),ye(null)},markdownStyles:X,sectionTitle:Ye.sectionTitle,referenceSectionTitle:Ye.refSectionTitle,cognitiveData:Ye.cognitiveData,anchorEl:Ye.anchorEl,sectionAnchorEl:Ye.sectionAnchorEl,scrollContainerEl:$e.current,badgeStyle:Ye.badgeStyle,docData:Ye.docData,deviationData:Ye.deviationData,isLoading:Ye.isLoading}),n.jsx(i.Snackbar,e.__assign({open:!!ce,autoHideDuration:8e3,onClose:function(){return ue(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(i.Alert,e.__assign({onClose:function(){return ue(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:ce}))})),(G.isHeaderVisible||G.isToggleVisible)&&n.jsxs(i.Box,e.__assign({sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between",bgcolor:"#FFFFFF",border:"1.5px solid #EEF0F4",borderTopLeftRadius:"8px",borderTopRightRadius:"8px"}},{children:[n.jsx(i.Box,e.__assign({sx:{display:"flex",alignItems:"center",gap:1}},{children:G.isHeaderVisible&&n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:600,color:"#0F172A"}},{children:P}))})),G.isToggleVisible&&n.jsx(i.Box,e.__assign({sx:{display:"flex",alignItems:"center"}},{children:n.jsx(i.FormControlLabel,{control:n.jsx(i.Switch,{checked:!ee,onChange:function(e){var n=e.target.checked;oe(!0),setTimeout(function(){ne(!n),zn(),Re(new Set),Be([]),Fe.current=[],setTimeout(function(){oe(!1)},400)},50)},color:"primary",size:"small",sx:{width:100,height:26,padding:0,"& .MuiSwitch-switchBase":{padding:0,margin:"3px",transitionDuration:"300ms","&.Mui-checked":{transform:"translateX(75px)",color:"#fff","& + .MuiSwitch-track":{backgroundColor:"#5928ED",opacity:1,border:0,"&::before":{content:'"Side by Side"',position:"absolute",left:"13px",top:"50%",transform:"translateY(-50%)",fontSize:"9px",fontWeight:700,color:"#fff",letterSpacing:"0.3px"}}}},"& .MuiSwitch-thumb":{boxSizing:"border-box",width:20,height:20},"& .MuiSwitch-track":{borderRadius:13,backgroundColor:"#9e9e9e",opacity:1,position:"relative","&::after":{content:'"Side by Side"',position:"absolute",right:"13px",top:"50%",transform:"translateY(-50%)",fontSize:"9px",fontWeight:700,color:"#fff",letterSpacing:"0.3px",opacity:1,transition:"opacity 0.2s"}},"& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track":{"&::after":{opacity:0}}}}),label:"",labelPlacement:"start",sx:{m:0,gap:1}})}))]})),n.jsx(i.Box,e.__assign({ref:$e,onScroll:Bt,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:ee?"hidden":"auto",borderTop:Mn&&kn?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(i.Box,e.__assign({sx:e.__assign({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},ee?{flex:1,minHeight:0}:{})},{children:n.jsxs(i.Box,e.__assign({ref:Xn,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"10px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},ee?{flex:1,overflow:"visible"}:{})},{children:[n.jsxs("svg",e.__assign({ref:je,style:{position:"absolute",top:0,left:0,width:ze.width||"100%",height:ze.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",transition:"opacity 0.15s ease-in-out"}},{children:[lt&&!ve&&n.jsx("g",{children:n.jsx("line",{x1:lt.x1,y1:lt.y,x2:lt.x2,y2:lt.y,stroke:Hn.badgeBorder,strokeWidth:"1.5"})}),Zn.map(function(t){var r,a=t.x1+.5*(t.x2-t.x1),s=(t.y1+t.y2)/2;if("Not Defined"===t.style.label&&!t.hasCognitive)return null;var c=!1;if(t.isSubSection)c=ve&&tt===t.subSectionKeyPath&≥else{var u=wn[t.sectionIdx];(ee?!(null===(r=null==u?void 0:u.refIndexes)||void 0===r?void 0:r.length)||(null==u?void 0:u.selfIndex)<0:!En[t.sectionIdx])||(c=ve&&tt===t.sectionIdx&&ge)}if(c)return n.jsxs("g",e.__assign({style:{transition:"opacity 0.2s"}},{children:[n.jsx("defs",{children:n.jsx("marker",e.__assign({id:"arr-".concat(t.id),markerWidth:"7",markerHeight:"5",refX:"7",refY:"2.5",orient:"auto"},{children:n.jsx("polygon",{points:"0 0, 7 2.5, 0 5",fill:t.style.badgeBorder||"#6366F1"})}))}),n.jsx("line",{ref:Gn,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(!ee){var d=t.isSubSection?R(t.x1,t.y1,t.x2,t.y2):"M ".concat(t.x1," ").concat(t.y1," L ").concat(t.x2," ").concat(t.y2);return n.jsxs("g",{children:[n.jsx("path",{d:d,fill:"none",stroke:t.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),n.jsx("foreignObject",e.__assign({x:a-100,y:s-14,width:"200",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:n.jsx(i.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:n.jsxs(i.Box,e.__assign({onClick:function(n){if(n.stopPropagation(),Ye.open&&me===t.id)an();else{var i=wn[t.sectionIdx]||{title:"",content:""},o=En[t.sectionIdx]||{title:"",content:""};if(t.isSubSection&&t.subSectionKeyPath){for(var l=t.subSectionKeyPath.split(m)[2].split("-").map(Number),r=wn[l[0]],a=En[l[0]],s=(null==r?void 0:r.title)||"",c=(null==a?void 0:a.title)||"",u=1;u<l.length;u++)(null==r?void 0:r.subsections)&&(r=r.subsections[l[u]]),(null==a?void 0:a.subsections)&&(a=a.subsections[l[u]]);r&&(i=e.__assign(e.__assign({},r),{title:s||r.title})),a&&(o=e.__assign(e.__assign({},a),{title:c||a.title}))}ye(t.id),Vn(Pn(n.currentTarget,i,o,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:[t.style.badgeText===B&&null==t.style.label?n.jsx(p.default,{color:t.style.badgeText}):0===t.style.label?"Same":t.style.label,n.jsx(i.Box,e.__assign({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n.jsx(l.ButtonCognitiveIcon,{})})),n.jsx(o.ChevronDown,{size:11,style:{transform:Ye.open&&me===t.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},t.id)}return null}),Ce.map(function(t){var i,o=t.pathD,l=(null===(i=t.style)||void 0===i?void 0:i.badgeBorder)||"#6366F1",r="conn-marker-".concat(t.id),a="".concat(t.id,"-bg"),s="".concat(t.id,"-stroke");return n.jsxs("g",{children:[n.jsx("defs",{children:n.jsx("clipPath",e.__assign({id:"connections-clip"},{children:n.jsx("marker",e.__assign({id:r,markerWidth:"8",markerHeight:"6",refX:"7",refY:"3",orient:"auto"},{children:n.jsx("polygon",{points:"0 0, 8 3, 0 6",fill:l})}))}))}),n.jsx("path",{ref:function(e){Te.current[a]=e},d:o,fill:"none",stroke:"#FFFFFF",strokeWidth:"4",strokeOpacity:"0.7"}),n.jsx("path",{ref:function(e){Te.current[s]=e},d:o,fill:"none",stroke:l,strokeWidth:"1.75",markerEnd:"url(#".concat(r,")")})]},t.id)})]})),n.jsxs(i.Box,e.__assign({sx:e.__assign({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},ee?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(i.Box,e.__assign({ref:$n,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",minHeight:"40px",alignItems:"center",overflowX:"hidden"}},{children:n.jsx(i.Tooltip,e.__assign({title:Bn,placement:"top"},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center",textOverflow:"ellipsis",whiteSpace:"normal",width:"100%",height:"40px"}},{children:Bn}))}))})),n.jsxs(i.Box,e.__assign({ref:on,onScroll:Bt,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},ee?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-160px",pr:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:nn,style:{width:"100%",height:"0px",flexShrink:0}}),Tn&&wn.map(function(t,l){var r,a,s=!t.title&&!t.content;if(ee&&s)return null;var c=t,u=mt(l),d=ee?!(null===(r=c.refIndexes)||void 0===r?void 0:r.length)||c.selfIndex<0:!En[l],v=ee?"number"==typeof c.selfIndex&&c.selfIndex>=0?c.selfIndex+1:null:l+1,f=Se.has(l),g=b(c.evaluationResult,null==u?void 0:u.deviationLabel);return n.jsx(i.Box,e.__assign({ref:Wn(l),sx:{mb:1,width:"100%"}},{children:n.jsxs(i.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[n.jsx(i.Box,e.__assign({ref:ut.current[l],sx:e.__assign({width:"100%",display:"flex"},f&&{borderRadius:"6px",outline:"2px solid ".concat((null==u?void 0:u.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:Et({section:t,idx:l,columnKey:"left",colRef:h.default.createRef(),mb:0,parentNodeId:(null===(a=null==V?void 0:V.input_index_map)||void 0===a?void 0:a[0])||""})})),ee&&u&&n.jsxs(i.Box,e.__assign({ref:vt.current[l],onClick:function(e){var n=ee?En.find(function(e){var n;return null===(n=c.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""}:En[l]||{title:"",content:""};qn(e,t,d,n,l,u)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:u.badgeBg,color:u.badgeText,border:"1px solid ".concat(u.badgeBorder),borderRadius:"12px",px:1.2,py:.4,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[null!==v&&n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(u.badgeBorder)}},{children:v})),n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",px:.25}},{children:!G.isLoading||null!=c.evaluationResult&&null!=c.evaluationResult?d?"No Deviation Found":"N/A"===g||"NA"===g?"N/A":0==g||null==g?"Same":"".concat(g):n.jsx(p.default,{color:u.badgeText})})),n.jsx(o.EllipsisVertical,{size:11,color:u.badgeText})]}))]}))}),"left-row-".concat(l))}),n.jsx("div",{ref:tn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),n.jsx(i.Box,e.__assign({sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:n.jsx(i.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:n.jsxs(i.Box,e.__assign({sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",borderRadius:"20px",bgcolor:Hn.badgeBg,color:Hn.badgeText,border:"1px solid ".concat(Hn.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=On?On:n.jsx(p.default,{}),n.jsx(i.Box,e.__assign({component:"span",onClick:function(n){n.stopPropagation(),Ye.open&&me===An?an():(ye(An),Vn(Pn(n.currentTarget,{title:"",content:"",evaluationResult:Dn,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,An,!0,e.__assign(e.__assign({},Hn),{label:""}))))},sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n.jsx(l.ButtonCognitiveIcon,{})})),n.jsx(o.ChevronDown,{size:11,style:{transform:Ye.open&&me===An?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),n.jsxs(i.Box,e.__assign({sx:e.__assign({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},ee?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[re&&n.jsx(r.default,{sections:11}),n.jsx(i.Box,e.__assign({ref:Jn,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"40px",display:"flex",alignItems:"center",overflowX:"hidden"}},{children:n.jsx(i.Tooltip,e.__assign({title:jn,placement:"top"},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center",textOverflow:"ellipsis",whiteSpace:"normal",width:"100%",height:"40px"}},{children:jn}))}))})),n.jsxs(i.Box,e.__assign({ref:Qe,onScroll:Bt,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},ee?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-25px",pl:"45px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:Ze,style:{width:"100%",height:"0px",flexShrink:0}}),Tn&&En.map(function(t,o){var l,r=t,a=[],s=!1,c=null;if(ee){a=wn.filter(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(r.selfIndex))&&e.selfIndex>=0}).map(function(e){return e.selfIndex+1});var u=wn.findIndex(function(e,n){var t;return Se.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(r.selfIndex))});(s=-1!==u)&&(c=mt(u))}else a=[o+1],(s=Se.has(o))&&(c=mt(o));var d=mt(o);return n.jsx(i.Box,e.__assign({ref:pt.current[o],sx:{mb:1,width:"100%"}},{children:n.jsxs(i.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[n.jsx(i.Box,e.__assign({ref:dt.current[o],sx:e.__assign({width:"100%",display:"flex"},s&&c&&{borderRadius:"6px",outline:"2px solid ".concat(c.badgeBorder),outlineOffset:"1px"})},{children:Et({section:t,idx:o,columnKey:"right",colRef:h.default.createRef(),mb:0,parentNodeId:(null===(l=null==V?void 0:V.input_index_map)||void 0===l?void 0:l[1])||""})})),ee&&!re&&d&&n.jsx(i.Box,e.__assign({ref:ft.current[o],sx:{position:"absolute",top:"18px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"11px",bgcolor:d.badgeBg,color:d.badgeText,border:"1px solid ".concat(d.badgeBorder),borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:a.length>0?a.join(", "):"-"}))]}))}),"right-row-".concat(o))}),n.jsx("div",{ref:en,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))};
|
|
2
2
|
//# sourceMappingURL=CognitiveCompare.js.map
|