@viswa-test/test-citation 0.0.24 → 0.0.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),t=require("react"),i=require("@mui/material"),r=require("lucide-react"),o=require("../../assests/svg/ButtonCognitiveIcon.js"),l=require("react-markdown"),s=require("./CognitiveComparehelpers.js"),a=require("./CognitiveCompareConfig.js"),c=require("./CognitivePopup.js"),u=require("./MoreFunctionsPopup.js");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var f=d(t),x=d(l),h={id:"",title:""},p={open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null},g=function(e,n,t,i){void 0===t&&(t=300);var r=e.style.scrollBehavior;e.style.scrollBehavior="auto";var o=e.scrollTop,l=n-o,s=null,a=function(c){null===s&&(s=c);var u,d=c-s;d<t?(e.scrollTop=(u=d,u/=t,l*(--u*u*u+1)+o),requestAnimationFrame(a)):(e.scrollTop=n,e.style.scrollBehavior=r,i&&i())};requestAnimationFrame(a)};exports.SHARED_MARKDOWN_STYLES=a.SHARED_MARKDOWN_STYLES,exports.default=function(l){var d,v,_,m,y,b,S,F,w=l.componentHeaderText,E=void 0===w?"Learning Comparison":w,I=l.treeData,j=l.comparisonConfig,C=l.leftColumnTitleText,R=l.rightColumnTitleText,B=l.markdownStyles,T=l.maintainRelativeOrder,A=void 0!==T&&T,D=l.popupConfig,k=t.useState(A),M=k[0],O=k[1],N=t.useState(null),H=N[0],L=N[1],z=t.useState(!1),W=z[0],q=z[1],P=t.useState(!1),U=P[0],V=P[1],G=t.useRef(!1),Y=t.useMemo(function(){return(null==I?void 0:I.cognitive_decisioning)||{}},[I]),X=t.useState(null),K=X[0],J=X[1],Q=t.useRef(null),Z=t.useState({width:0,height:0}),$=Z[0],ee=Z[1],ne=t.useMemo(function(){return e.__assign(e.__assign({},a.SHARED_MARKDOWN_STYLES),B)},[B]),te=t.useState({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null}),ie=te[0],re=te[1],oe=t.useState({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null}),le=oe[0],se=oe[1],ae=t.useRef(null),ce=t.useRef(null),ue=t.useRef(null),de=t.useRef(null),fe=t.useRef(null),xe=t.useRef(!1),he=t.useRef(null);t.useEffect(function(){he.current=null},[ie.sectionIdx,ie.open]);var pe=t.useCallback(function(){J(null),re(p)},[]),ge=t.useCallback(function(){se(p)},[]),ve=t.useCallback(function(){var e;if(ie.anchorEl&&ie.refSectionTitle){var n=ie.anchorEl.getBoundingClientRect(),t=(null===(e=null==Q?void 0:Q.current)||void 0===e?void 0:e.offsetHeight)||0,i=Math.min(680,window.innerWidth-24),r=window.innerHeight-n.bottom-12-12,o=n.top-12-12,l=r<t&&o>r;null!==he.current?!0===he.current&&(l=o>=t||o>=r):l=!(r>=t||r>=o),he.current=l;var s=l?o:r,a=Math.min(t||9999,s),c=l?n.top-12-a:n.bottom+12,u=n.left+n.width/2,d=u-i/2,f=Math.max(12,Math.min(d,window.innerWidth-i-12)),x=Math.max(14,Math.min(u-f,i-10-4));J({top:c,left:f,arrowLeft:x,openAbove:l,maxHeight:s})}},[ie.anchorEl,ie.refSectionTitle]);t.useEffect(function(){if(ie.open){window.addEventListener("resize",ve);var e=requestAnimationFrame(ve),n=null;return Q.current&&(n=new ResizeObserver(function(){cancelAnimationFrame(e),e=requestAnimationFrame(ve)})).observe(Q.current),function(){cancelAnimationFrame(e),window.removeEventListener("resize",ve),n&&n.disconnect()}}},[ie.open,ve]),t.useEffect(function(){var e=ae.current;if(e&&ie.open){var n=function(e){Q.current&&Q.current.contains(e.target)||(J(null),pe())};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})}}},[ie.open,pe]),t.useEffect(function(){var e=ae.current;if(e&&le.open){var n=function(){ge()};return e.addEventListener("scroll",n,{capture:!0}),window.addEventListener("scroll",n,{capture:!0}),function(){e.removeEventListener("scroll",n,{capture:!0}),window.removeEventListener("scroll",n,{capture:!0})}}},[le.open,ge]);var _e=t.useMemo(function(){var n,t,i,r,o,l,s,c,u,d,f,x;return{fields:null!==(n=null==j?void 0:j.fields)&&void 0!==n?n:a.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(i=null===(t=null==j?void 0:j.thresholds)||void 0===t?void 0:t.high)&&void 0!==i?i:a.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(o=null===(r=null==j?void 0:j.thresholds)||void 0===r?void 0:r.medium)&&void 0!==o?o:a.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(s=null===(l=null==j?void 0:j.thresholds)||void 0===l?void 0:l.exact)&&void 0!==s?s:a.DEFAULT_COMPARISON_CONFIG.thresholds.exact},relationStyles:{noContent:e.__assign(e.__assign({},a.DEFAULT_COMPARISON_CONFIG.relationStyles.noContent),(null===(c=null==j?void 0:j.relationStyles)||void 0===c?void 0:c.noContent)||{}),high:e.__assign(e.__assign({},a.DEFAULT_COMPARISON_CONFIG.relationStyles.high),(null===(u=null==j?void 0:j.relationStyles)||void 0===u?void 0:u.high)||{}),exact:e.__assign(e.__assign({},a.DEFAULT_COMPARISON_CONFIG.relationStyles.exact),(null===(d=null==j?void 0:j.relationStyles)||void 0===d?void 0:d.exact)||{}),medium:e.__assign(e.__assign({},a.DEFAULT_COMPARISON_CONFIG.relationStyles.medium),(null===(f=null==j?void 0:j.relationStyles)||void 0===f?void 0:f.medium)||{}),low:e.__assign(e.__assign({},a.DEFAULT_COMPARISON_CONFIG.relationStyles.low),(null===(x=null==j?void 0:j.relationStyles)||void 0===x?void 0:x.low)||{})}}},[j]),me=t.useMemo(function(){if(I&&Object.keys(I).length>0)try{var n=function(n,t){var i,r,o,l,a,c,u,d;void 0===t&&(t=!1);var f=[],x=[],h=n.base_root_id,p=n.input_index_map||{0:"left",1:"right"},g=n[h];if(!g||!1===g.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[]};var v=function(t,i){var r=n[t];if(!r)return null;var o=s.getSideData(r,i,p),l=!!o.title.trim(),a=!!o.content.trim(),c=s.getRationale(r),u=[];r.next&&Object.values(r.next).forEach(function(e){if(n[e]){var t=v(e,i);t&&u.push(t)}});var d=!(!l&&!a);return e.__assign({id:t,title:l?o.title:"",content:a?o.content:"",subsections:u},d?c:{score:void 0,relation:"not_defined"})};if(t){var _={},m={},y=-1,b=-1;for(var S in n)if(!["base_root_id","documents","input_index_map",h].includes(S)){var F=n[S];if(F&&!1!==F.display_node){var w=s.getRationale(F),E=s.getSideData(F,"0",p),I=s.getSideData(F,"1",p),j=E.title.trim()||E.content.trim(),C=I.title.trim()||I.content.trim(),R=Number(null!==(r=null===(i=E.attributes)||void 0===i?void 0:i.display_index)&&void 0!==r?r:y--),B=Number(null!==(l=null===(o=I.attributes)||void 0===o?void 0:o.display_index)&&void 0!==l?l:b--),T=m[B]||e.__assign(e.__assign({id:S,title:C?I.title:"",content:C?I.content:"",subsections:[]},C?w:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:B}),A=_[R]||e.__assign(e.__assign({id:S,title:j?E.title:"",content:j?E.content:"",subsections:[]},j?w:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:R});Number(B)>=0&&Number(R)>=0&&(T.refIndexes.includes(Number(R))||T.refIndexes.push(Number(R)),A.refIndexes.includes(Number(B))||A.refIndexes.push(Number(B))),m[B]=T,_[R]=A}}x=Object.values(m).map(function(e){return e}),f=Object.values(_).map(function(e){return e}),x.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})}else g.next&&Object.values(g.next).forEach(function(e){var t=n[e];t&&!1!==t.display_node&&(f.push(v(e,"0")||{id:e,title:"",content:"",subsections:[]}),x.push(v(e,"1")||{id:e,title:"",content:"",subsections:[]}))});return{activeProposed:{title:(null===(c=null===(a=g.comparison_inputs)||void 0===a?void 0:a[p[0]])||void 0===c?void 0:c.title)||"Uploaded Contract",description:g.decision_scope_description||"",sections:f},activeVariants:[{id:"tree-variant-1",title:(null===(d=null===(u=g.comparison_inputs)||void 0===u?void 0:u[p[1]])||void 0===d?void 0:d.title)||"Reference Template",similarity:0,sections:x,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:g.decision_scope_description||""},fields:{}}}}]}}(I,M);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"}},[I,M]),ye=me.activeProposed,be=me.activeVariants,Se=me.parseError;t.useEffect(function(){Se&&L("Failed to load comparison: ".concat(Se))},[Se]);var Fe=t.useState(null),we=Fe[0];Fe[1];var Ee=t.useState({}),Ie=Ee[0],je=Ee[1],Ce=t.useState({}),Re=Ce[0],Be=Ce[1],Te=(null==be?void 0:be[0])||h,Ae=null===(_=null===(d=null==I?void 0:I.documents)||void 0===d?void 0:d[null===(v=null==I?void 0:I.input_index_map)||void 0===v?void 0:v[0]])||void 0===_?void 0:_.title,De=null===(b=null===(m=null==I?void 0:I.documents)||void 0===m?void 0:m[null===(y=null==I?void 0:I.input_index_map)||void 0===y?void 0:y[1]])||void 0===b?void 0:b.title,ke=s.safeStringify(C||Ae||"Uploaded Contract"),Me=s.safeStringify(R||De||"Reference Template"),Oe=t.useMemo(function(){return(null==ye?void 0:ye.sections)||[]},[null==ye?void 0:ye.sections]),Ne=t.useMemo(function(){return Te.sections||[]},[Te.sections]),He=Oe.length>0||Ne.length>0,Le=Te.analysis,ze=s.safeStringify(null===(F=null===(S=null==Le?void 0:Le.rule_difference_comparison)||void 0===S?void 0:S.summary)||void 0===F?void 0:F.overall_summary),We=!!ze.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),qe=t.useRef({}),Pe=function(e){return qe.current[e]||(qe.current[e]=f.default.createRef()),qe.current[e]},Ue=t.useCallback(function(e,n,t,i,r){var o,l,a=s.safeStringify(n.id)||s.safeStringify(t.id)||"",c=(a?Y[a]:null)||n.cognitiveData||t.cognitiveData||{section_id:a,decisioning:[],gap:[],relevance_score:0},u=null!==(l=null===(o=qe.current[i])||void 0===o?void 0:o.current)&&void 0!==l?l:null;return{open:!0,sectionTitle:n.title||"N/A",refSectionTitle:t.title||"NA",cognitiveData:c,anchorEl:e,sectionAnchorEl:u,badgeStyle:r||null,sectionIdx:i,docData:{documents:null==I?void 0:I.documents,input_index_map:null==I?void 0:I.input_index_map}}},[Y]),Ve=t.useCallback(function(e){ge(),J(null),re(e)},[ge]),Ge=t.useCallback(function(){null!==le.sectionIdx&&le.anchorEl?Ve(e.__assign(e.__assign({},le),{open:!0})):ge()},[le,ge,Ve]);t.useCallback(function(e){ge(),L("".concat(e," is coming soon."))},[ge]);var Ye=t.useRef(null),Xe=t.useRef(null),Ke=t.useRef(null),Je=t.useState([]),Qe=Je[0],Ze=Je[1],$e=t.useState(null),en=$e[0],nn=$e[1],tn=t.useRef(null),rn=t.useState(null),on=rn[0],ln=rn[1],sn=t.useCallback(function(){null!==tn.current&&window.cancelAnimationFrame(tn.current),tn.current=window.requestAnimationFrame(function(){yn(),tn.current=null})},[]),an=t.useCallback(function(){var e=le.sectionIdx;ge(),null!==e&&(W&&en===e?(q(!1),nn(null),V(!1),de.current&&(de.current.style.height="0px"),fe.current&&(fe.current.style.height="0px")):(G.current=!0,nn(e),q(!0),V(!1),de.current&&(de.current.style.height="0px"),fe.current&&(fe.current.style.height="0px"),requestAnimationFrame(function(){var n,t,i=null===(n=qe.current[e])||void 0===n?void 0:n.current,r=Oe[e],o=(null==r?void 0:r.refIndexes)||[],l=null;if(o.length>0){var s=o[0],a=Ne.findIndex(function(e){return e.selfIndex===s});l=null===(t=gn.current[a])||void 0===t?void 0:t.current}var c=null==i?void 0:i.parentElement,u=ue.current;if(i&&c){var d=c.clientHeight,f=i.offsetTop-(d/2-i.offsetHeight/2),x=c.scrollHeight-d,h=Math.max(0,Math.min(f,x)),p=i.offsetTop-h,v=null;if(l&&u){var _=l.offsetTop-p;if(_<0)de.current&&(de.current.style.height="".concat(Math.abs(_),"px")),v=0;else{var m=u.scrollHeight-u.clientHeight;_>m?(fe.current&&(fe.current.style.height="".concat(_-m+150,"px")),v=_):v=_}}g(c,h,300),u&&null!==v?g(u,v,300,function(){V(!0),sn(),setTimeout(function(){G.current=!1},50)}):setTimeout(function(){V(!0),sn(),G.current=!1},350)}})))},[ge,le.sectionIdx,W,en,Oe,Ne,sn]),cn=t.useMemo(function(){return _e.fields.filter(function(e){var n=e.key;return(!He||"description"!==n)&&(s.hasValue(null==ye?void 0:ye[n])||s.hasValue(Te[n]))})},[ye,Te,He,_e.fields]),un=t.useRef({}),dn=t.useRef({}),fn=t.useRef({}),xn=t.useRef({}),hn=t.useRef({}),pn=t.useRef({}),gn=t.useRef({});cn.forEach(function(e){for(var n=e.key,t=0;t<Math.max(Oe.length,Ne.length);t+=1)fn.current[t]||(fn.current[t]=f.default.createRef()),xn.current[t]||(xn.current[t]=f.default.createRef()),hn.current[t]||(hn.current[t]=f.default.createRef()),pn.current[t]||(pn.current[t]=f.default.createRef()),gn.current[t]||(gn.current[t]=f.default.createRef());un.current[n]||(un.current[n]=f.default.createRef()),dn.current[n]||(dn.current[n]=f.default.createRef())});for(var vn=0;vn<Math.max(Oe.length,Ne.length);vn+=1)fn.current[vn]||(fn.current[vn]=f.default.createRef()),xn.current[vn]||(xn.current[vn]=f.default.createRef()),hn.current[vn]||(hn.current[vn]=f.default.createRef()),pn.current[vn]||(pn.current[vn]=f.default.createRef()),gn.current[vn]||(gn.current[vn]=f.default.createRef());t.useEffect(function(){if(we){var e=_e.fields.find(function(e){return e.analysisKey===we||e.key===we});if(e){var n=un.current[e.key]||dn.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[we,_e.fields]);var _n=t.useCallback(function(e){var n,t,i,r,o,l,s,a,c,u=null===(n=null==Le?void 0:Le.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!u||!u[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var d=u[e],f=(null==d?void 0:d.relation)||(null===(i=null===(t=null==d?void 0:d.highlights)||void 0===t?void 0:t.ruleA_spans)||void 0===i?void 0:i.length)||(null===(o=null===(r=null==d?void 0:d.highlights)||void 0===r?void 0:r.ruleB_spans)||void 0===o?void 0:o.length)||(null==d?void 0:d.mappings)&&d.mappings.length>0;if(d.mappings){var x=d.mappings[0]||{};return{score:d.score,relation:x.relation||"",highlightsA:(null===(l=x.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(s=x.highlights)||void 0===s?void 0:s.ruleB_spans)||[],hasContent:!!f}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(a=d.highlights)||void 0===a?void 0:a.ruleA_spans)||[],highlightsB:(null===(c=d.highlights)||void 0===c?void 0:c.ruleB_spans)||[],hasContent:!!f}},[Le]),mn=t.useCallback(function(n){var t,i,r,o,l=Oe[n],a=Ne[n],c=(null==l?void 0:l.relation)&&"not_defined"!==l.relation,u=(null==a?void 0:a.relation)&&"not_defined"!==a.relation,d=s.safeStringify(null==l?void 0:l.id)||s.safeStringify(null==a?void 0:a.id)||"",f=!(!(null==l?void 0:l.cognitiveData)&&!(null==a?void 0:a.cognitiveData));if(!c&&!u&&!f)return e.__assign(e.__assign({},_e.relationStyles.noContent),{label:"Not Defined"});var x=_n("description");if(null!=(null!==(i=null!==(t=null==l?void 0:l.cognitiveRelevanceScore)&&void 0!==t?t:null==a?void 0:a.cognitiveRelevanceScore)&&void 0!==i?i:d?null===(r=Y[d])||void 0===r?void 0:r.relevance_score:void 0)){var h=s.cognitiveScoreToRelation(),p=h.score,g=h.relation;return s.getStyleForRelation(p,g,!0,_e)}var v=c?l.relation:u?a.relation:x.relation,_=null!==(o=null==l?void 0:l.score)&&void 0!==o?o:null==a?void 0:a.score,m="number"==typeof _?_:x.score;return s.getStyleForRelation(m,v,!0,_e)},[Oe,Ne,Y,_e,_n]),yn=t.useCallback(function(){var e,n,t,i,r,o,l,a,c,u,d;if(!xe.current){xe.current=!0;try{if(!Ye.current)return;var f=Ye.current.getBoundingClientRect();ee({width:f.width,height:f.height});var x=[];if(cn.forEach(function(e){var n,t,i=e.key,r=null===(n=un.current[i])||void 0===n?void 0:n.current,o=null===(t=dn.current[i])||void 0===t?void 0:t.current;r&&o&&(r.style.height="auto",o.style.height="auto",r.style.minHeight="0px",o.style.minHeight="0px")}),!M)for(var h=0;h<Math.min(Oe.length,Ne.length);h++){var p=null===(e=fn.current[h])||void 0===e?void 0:e.current,g=null===(n=xn.current[h])||void 0===n?void 0:n.current;p&&g&&(p.style.height="auto",g.style.height="auto",p.style.minHeight="0px",g.style.minHeight="0px")}var v={};cn.forEach(function(e){var n,t,i=e.key,r=null===(n=un.current[i])||void 0===n?void 0:n.current,o=null===(t=dn.current[i])||void 0===t?void 0:t.current;if(r&&o){var l=r.getBoundingClientRect(),s=o.getBoundingClientRect();v[i]=Math.max(l.height,s.height)}});var _=[];if(!M)for(h=0;h<Math.min(Oe.length,Ne.length);h++){p=null===(t=fn.current[h])||void 0===t?void 0:t.current,g=null===(i=xn.current[h])||void 0===i?void 0:i.current;if(p&&g){var m=p.getBoundingClientRect(),y=g.getBoundingClientRect();_[h]=Math.max(m.height,y.height)}}if(cn.forEach(function(e){var n,t,i=e.key,r=null===(n=un.current[i])||void 0===n?void 0:n.current,o=null===(t=dn.current[i])||void 0===t?void 0:t.current;if(r&&o){var l=v[i];r.style.minHeight="".concat(l,"px"),o.style.minHeight="".concat(l,"px")}}),!M)for(h=0;h<_.length;h++){p=null===(r=fn.current[h])||void 0===r?void 0:r.current,g=null===(o=xn.current[h])||void 0===o?void 0:o.current;if(p&&g){var b=_[h];p.style.minHeight="".concat(b,"px"),g.style.minHeight="".concat(b,"px")}}if(cn.forEach(function(e){var n,t,i=e.key,r=e.analysisKey,o=null===(n=un.current[i])||void 0===n?void 0:n.current,l=null===(t=dn.current[i])||void 0===t?void 0:t.current;if(o&&l){var a=o.getBoundingClientRect(),c=l.getBoundingClientRect(),u=_n(r),d=s.getStyleForRelation(u.score,u.relation,u.hasContent,_e);if(!d)return;var h=a.top+a.height/2-f.top;x.push({id:"field-".concat(i),x1:a.right-f.left,y1:h,x2:c.left-f.left,y2:h,style:d})}}),M)Oe.forEach(function(e,n){var t;(null===(t=fn.current[n])||void 0===t?void 0:t.current)&&(e.refIndexes||[]).forEach(function(e){var t,i,r=Ne.findIndex(function(n){return n.selfIndex===e});if(-1!==r){var o=null===(t=hn.current[n])||void 0===t?void 0:t.current,l=null===(i=pn.current[r])||void 0===i?void 0:i.current;if(o&&l){var s=o.getBoundingClientRect(),a=l.getBoundingClientRect(),c=s.right-f.left,u=a.left-f.left,d=s.top+s.height/2-f.top,h=a.top+a.height/2-f.top;W&&en===n&&(h=d);var p=mn(n);p&&x.push({id:"line-".concat(n,"-").concat(r),x1:c,y1:d,x2:u,y2:h,style:p,sectionIdx:n,targetRightIdx:r})}}})});else for(h=0;h<Math.min(Oe.length,Ne.length);h++){var S=null===(l=fn.current[h])||void 0===l?void 0:l.current,F=null===(a=xn.current[h])||void 0===a?void 0:a.current;if(S&&F){var w=S.querySelector(".MuiAccordionSummary-root"),E=F.querySelector(".MuiAccordionSummary-root");if(w&&E){var I=w.getBoundingClientRect(),j=E.getBoundingClientRect(),C=(I.top+I.height/2-f.top+j.top+j.height/2-f.top)/2,R=(null===(c=Ne[h])||void 0===c?void 0:c.id)||"sec-".concat(h),B=mn(h);B&&x.push({id:R,x1:I.right-f.left,y1:C,x2:j.left-f.left,y2:C,style:B,sectionIdx:h,hasCognitive:!!((null===(u=Oe[h])||void 0===u?void 0:u.cognitiveData)||(null===(d=Ne[h])||void 0===d?void 0:d.cognitiveData)||R&&Y[R])})}}}if(Ze(x),Xe.current&&Ke.current){var T=Xe.current.getBoundingClientRect(),A=Ke.current.getBoundingClientRect(),D=(T.top+T.height/2-f.top+A.top+A.height/2-f.top)/2;ln({x1:T.right-f.left,x2:A.left-f.left,y:D})}else ln(null)}catch(e){console.error("Line render safe fail: ",e)}finally{xe.current=!1}}},[cn,Oe,Ne,Y,_e,_n,mn,M,W,en]),bn=t.useCallback(function(){G.current||(sn(),W&&!G.current&&(q(!1),nn(null),V(!1),de.current&&(de.current.style.height="0px"),fe.current&&(fe.current.style.height="0px")))},[sn,W]);t.useEffect(function(){var e=setTimeout(sn,250);window.addEventListener("resize",sn);var n=null,t=null;return ae.current&&(n=new ResizeObserver(sn)).observe(ae.current),Ye.current&&(t=new ResizeObserver(sn)).observe(Ye.current),function(){clearTimeout(e),window.removeEventListener("resize",sn),null==n||n.disconnect(),null==t||t.disconnect()}},[ye,Te,Le,cn,Ie,Re,Oe,Ne,_e,sn,W,en,U]);var Sn=function(t,o,l,a,c){void 0===c&&(c=1);var u,d=M?!!Ie["".concat(l,"-").concat(o)]:!!Ie[String(o)],h=s.hasValue(t.title),p=s.hasValue(t.content),g=!h&&!p,v=t.title;return h||(v=p?"No Title Found":"No Matching Section Found"),n.jsx(i.Box,e.__assign({ref:a,sx:e.__assign(e.__assign({mb:c},M?{height:"fit-content"}:{minHeight:0}),{display:"flex",flexDirection:"column",position:"relative"})},{children:n.jsxs(i.Accordion,e.__assign({disableGutters:!0,expanded:!g&&d,onChange:function(){return!g&&function(n,t){je(function(i){var r=e.__assign({},i);if(!M){var o=!!i[String(n)];return r[String(n)]=!o,r}var l="".concat(t,"-").concat(n),s=!i[l];if(r[l]=s,"left"===t)((null==(a=Oe[n])?void 0:a.refIndexes)||[]).forEach(function(e){var n=Ne.findIndex(function(n){return n.selfIndex===e});-1!==n&&(r["right-".concat(n)]=s)});else{var a,c=null==(a=Ne[n])?void 0:a.selfIndex;Oe.forEach(function(e,n){var t;(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(c))&&(r["left-".concat(n)]=s)})}return r})}(o,l)},sx:{boxShadow:"none",border:g?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:g?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flex:1,display:"flex",flexDirection:"column","&:before":{display:"none"}}},{children:[n.jsx(i.AccordionSummary,e.__assign({expandIcon:g?null:n.jsx(r.ChevronDown,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:g?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"flex",alignItems:"center",overflow:"hidden"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:n.jsx(i.Tooltip,e.__assign({title:v,placement:"top"},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"12px",color:g?"#94A3B8":"#19213D",fontWeight:g?400:700,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:(u=v,u?s.safeStringify(u).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(f.default.Fragment,{children:e},t)}):null)}))}))})),!g&&n.jsxs(i.AccordionDetails,e.__assign({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column"}},{children:[n.jsx(i.Typography,e.__assign({component:"div",sx:ne},{children:n.jsx(x.default,{children:s.safeStringify(t.content).replace(/\\n/g,"\n")})})),(t.subsections||[]).map(function(e,n){return Fn(e,"".concat(o,"-").concat(n),0)})]}))]}))}),"".concat(l,"-sec-").concat(o))},Fn=function(t,o,l){void 0===l&&(l=0);var a=s.hasValue(t.title),c=s.hasValue(t.content),u=!a&&!c,d=a?t.title:c?"No Title Found":"No Matching Section Found",f=!!Re[o];return t.title?n.jsxs(i.Accordion,e.__assign({disableGutters:!0,expanded:!u&&f,onChange:function(){return!u&&Be(function(n){var t;return e.__assign(e.__assign({},n),((t={})[o]=!n[o],t))})},sx:{mt:1,boxShadow:"none",border:u?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF","&:before":{display:"none"}}},{children:[n.jsx(i.AccordionSummary,e.__assign({expandIcon:u?null:n.jsx(r.ChevronDown,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5}}},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"11px",fontWeight:600,color:u?"#94A3B8":"#19213D"}},{children:d||"Untitled Subsection"}))})),!u&&n.jsxs(i.AccordionDetails,e.__assign({sx:{pt:0,pb:1}},{children:[c&&n.jsx(i.Typography,e.__assign({component:"div",sx:ne},{children:n.jsx(x.default,{children:s.safeStringify(t.content).replace(/\\n/g,"\n")})})),(t.subsections||[]).map(function(e,n){return Fn(e,"".concat(o,"-").concat(n),l+1)})]}))]}),o):n.jsx(i.Box,e.__assign({sx:{mt:0===l?1:.75}},{children:!u&&n.jsxs("div",{children:[c&&n.jsx(i.Typography,e.__assign({component:"div",sx:ne},{children:n.jsx(x.default,{children:s.safeStringify(t.content).replace(/\\n/g,"\n")})})),(t.subsections||[]).map(function(e,n){return Fn(e,"".concat(o,"-").concat(n),l+1)})]})}),o)};return n.jsxs(i.Box,e.__assign({ref:ce,sx:e.__assign(e.__assign({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},M?{}:{overflow:"visible"}),{position:"relative"})},{children:[M&&n.jsx(u.default,{open:le.open,anchorEl:le.anchorEl,sectionTitle:le.sectionTitle,referenceSectionTitle:le.refSectionTitle,onClose:ge,onOpenCognitiveCompare:Ge,onOpenSideBySide:an}),ie.open&&n.jsx(c.default,{open:ie.open,popupRef:Q,position:K,popupConfig:D,onClose:function(){J(null),re(function(n){return e.__assign(e.__assign({},n),{open:!1})})},markdownStyles:B,sectionTitle:ie.sectionTitle,referenceSectionTitle:ie.refSectionTitle,cognitiveData:ie.cognitiveData,anchorEl:ie.anchorEl,sectionAnchorEl:ie.sectionAnchorEl,scrollContainerEl:ae.current,badgeStyle:ie.badgeStyle,docData:ie.docData}),n.jsx(i.Snackbar,e.__assign({open:!!H,autoHideDuration:8e3,onClose:function(){return L(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(i.Alert,e.__assign({onClose:function(){return L(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:H}))})),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:n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:600,color:"#0F172A"}},{children:E}))})),n.jsx(i.Box,e.__assign({sx:{display:"flex",alignItems:"center"}},{children:n.jsx(i.FormControlLabel,{control:n.jsx(i.Switch,{checked:M,onChange:function(e){return O(e.target.checked)},color:"primary",size:"small"}),label:n.jsx(i.Typography,e.__assign({sx:{fontSize:"13px",fontWeight:500,color:"#64748B"}},{children:"Relative Order"})),labelPlacement:"start",sx:{m:0,gap:1}})}))]})),n.jsx(i.Box,e.__assign({ref:ae,onScroll:bn,sx:{flex:1,minHeight:0,pt:1.5,pb:8,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:M?"hidden":"auto",borderTop:ze&&We?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(i.Box,e.__assign({sx:e.__assign({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},M?{flex:1,minHeight:0}:{})},{children:n.jsxs(i.Box,e.__assign({ref:Ye,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},M?{flex:1,overflow:"visible"}:{})},{children:[n.jsxs("svg",e.__assign({style:{position:"absolute",top:0,left:0,width:$.width||"100%",height:$.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible"}},{children:[on&&n.jsxs("g",{children:[n.jsx("line",{x1:on.x1,y1:on.y,x2:Math.max(on.x1,(on.x1+on.x2)/2-70),y2:on.y,stroke:"#BBF7D0",strokeWidth:"1.5"}),n.jsx("line",{x1:Math.min(on.x2,(on.x1+on.x2)/2+70),y1:on.y,x2:on.x2,y2:on.y,stroke:"#BBF7D0",strokeWidth:"1.5"})]}),Qe.map(function(t){var l,s=(t.x1+t.x2)/2;if("Not Defined"===t.style.label&&!t.hasCognitive)return null;if(!M)return n.jsxs("g",{children:[n.jsx("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),n.jsx("foreignObject",e.__assign({x:s-100,y:t.y1-14,width:"200",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:n.jsx(i.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:n.jsxs(i.Box,e.__assign({onClick:function(e){var n=Oe[t.sectionIdx]||{title:"",content:""},i=Ne[t.sectionIdx]||{title:"",content:""};Ve(Ue(e.currentTarget,n,i,t.sectionIdx,t.style))},sx:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:t.style.badgeBg,color:t.style.badgeText,border:"1px solid ".concat(t.style.badgeBorder),borderRadius:"12px",px:1.5,py:.5,fontWeight:500,textAlign:"center",whiteSpace:"nowrap",cursor:"pointer"}},{children:[t.style.label,n.jsx(i.Box,e.__assign({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n.jsx(o.ButtonCognitiveIcon,{})})),n.jsx(r.ChevronDown,{size:11})]}))}))}))]},t.id);var a=Oe[t.sectionIdx];return!(null===(l=null==a?void 0:a.refIndexes)||void 0===l?void 0:l.length)||(null==a?void 0:a.selfIndex)<0?null:W&&en===t.sectionIdx&&U?n.jsxs("g",e.__assign({style:{transition:"opacity 0.2s"}},{children:[n.jsx("defs",{children:n.jsx("marker",e.__assign({id:"arr-".concat(t.id),markerWidth:"7",markerHeight:"5",refX:"7",refY:"2.5",orient:"auto"},{children:n.jsx("polygon",{points:"0 0, 7 2.5, 0 5",fill:t.style.badgeBorder||"#6366F1"})}))}),n.jsx("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.badgeBorder||"#6366F1",strokeWidth:"1.5",markerEnd:"url(#arr-".concat(t.id,")")})]}),t.id):null})]})),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)"},M?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(i.Box,e.__assign({ref:Xe,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:ke,placement:"top"},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",height:"40px"}},{children:ke}))}))})),n.jsx(i.Box,e.__assign({onScroll:bn,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},M?{maxHeight:"500px",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-160px",pr:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:He&&Oe.map(function(t,o){var l;if(!M)return n.jsx(i.Box,e.__assign({ref:Pe(o)},{children:Sn(t,o,"left",fn.current[o])}),"left-row-".concat(o));var s=t,a=mn(o),c=!(null===(l=s.refIndexes)||void 0===l?void 0:l.length)||s.selfIndex<0,u="number"==typeof s.selfIndex&&s.selfIndex>=0?s.selfIndex+1:null;return n.jsx(i.Box,e.__assign({ref:Pe(o),sx:{mb:1}},{children:n.jsxs(i.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[n.jsx(i.Box,e.__assign({ref:fn.current[o],sx:{width:"100%"}},{children:Sn(t,o,"left",f.default.createRef(),0)})),a&&n.jsxs(i.Box,e.__assign({ref:hn.current[o],onClick:function(e){var n=Ne.find(function(e){var n;return null===(n=s.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""};!function(e,n,t,i,r){e.stopPropagation(),le.open&&le.sectionIdx===i?ge():(pe(),se(Ue(e.currentTarget,n,t,i,r)))}(e,t,n,o,a)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:a.badgeBg,color:a.badgeText,border:"1px solid ".concat(a.badgeBorder),borderRadius:"12px",px:1.2,py:.4,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[null!==u&&n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(a.badgeBorder)}},{children:u})),n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",px:.25}},{children:c?"No Deviation Found":0==a.deviationLabel||void 0===a.deviationLabel?"Same":"".concat(a.deviationLabel,"% Deviation")})),n.jsx(r.EllipsisVertical,{size:11,color:a.badgeText})]}))]}))}),"left-row-".concat(o))})}))]})),n.jsx(i.Box,e.__assign({sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"6px",gap:0}},{children:n.jsx(i.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:n.jsxs(i.Box,e.__assign({sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",borderRadius:"20px",bgcolor:"#ECFDF3",border:"1px solid #A7F3D0",color:"#15803D",fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1}},{children:[n.jsx(i.Box,e.__assign({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n.jsx(o.ButtonCognitiveIcon,{})})),0,"% Similarity",n.jsx(r.ChevronDown,{size:11})]}))}))})),n.jsxs(i.Box,e.__assign({sx:e.__assign({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},M?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[n.jsx(i.Box,e.__assign({ref:Ke,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:Me,placement:"top"},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",height:"40px"}},{children:Me}))}))})),n.jsxs(i.Box,e.__assign({ref:ue,onScroll:bn,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},M?{maxHeight:"500px",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-160px",pl:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:de,style:{width:"100%",height:"0px",flexShrink:0}}),He&&Ne.map(function(t,r){if(!M)return Sn(t,r,"right",xn.current[r]);var o=t,l=Oe.filter(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(o.selfIndex))&&e.selfIndex>=0}).map(function(e){return e.selfIndex+1});return n.jsx(i.Box,e.__assign({ref:gn.current[r],sx:{mb:1}},{children:n.jsxs(i.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[n.jsx(i.Box,e.__assign({ref:xn.current[r],sx:{width:"100%"}},{children:Sn(t,r,"right",f.default.createRef(),0)})),n.jsx(i.Box,e.__assign({ref:pn.current[r],sx:{position:"absolute",top:"18px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"11px",bgcolor:"#EEF2FF",color:"#3730A3",border:"1px solid #C7D2FE",borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:l.length>0?l.join(", "):"-"}))]}))}),"right-row-".concat(r))}),n.jsx("div",{ref:fe,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),t=require("react"),i=require("@mui/material"),r=require("lucide-react"),o=require("../../assests/svg/ButtonCognitiveIcon.js"),l=require("react-markdown"),s=require("./CognitiveComparehelpers.js"),a=require("./CognitiveCompareConfig.js"),c=require("./CognitivePopup.js"),u=require("./MoreFunctionsPopup.js");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var f=d(t),x=d(l),h={id:"",title:""},p={open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null};exports.SHARED_MARKDOWN_STYLES=a.SHARED_MARKDOWN_STYLES,exports.default=function(l){var d,v,g,_,m,y,b,S,F=l.componentHeaderText,w=void 0===F?"Learning Comparison":F,E=l.treeData,I=l.comparisonConfig,j=l.leftColumnTitleText,C=l.rightColumnTitleText,R=l.markdownStyles,B=l.maintainRelativeOrder,T=void 0!==B&&B,A=l.popupConfig,D=t.useState(T),k=D[0],O=D[1],M=t.useState(null),N=M[0],L=M[1],z=t.useState(!1),H=z[0],W=z[1],q=t.useState(!1),P=q[0],U=q[1],V=t.useRef(!1),G=t.useMemo(function(){return(null==E?void 0:E.cognitive_decisioning)||{}},[E]),Y=t.useState(null),X=Y[0],K=Y[1],J=t.useRef(null),Q=t.useState({width:0,height:0}),Z=Q[0],$=Q[1],ee=t.useMemo(function(){return e.__assign(e.__assign({},a.SHARED_MARKDOWN_STYLES),R)},[R]),ne=t.useState({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null}),te=ne[0],ie=ne[1],re=t.useState({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null}),oe=re[0],le=re[1],se=t.useRef(null),ae=t.useRef(null),ce=t.useRef(null),ue=t.useRef(null),de=t.useRef(null),fe=t.useRef(!1),xe=t.useRef(null);t.useEffect(function(){xe.current=null},[te.sectionIdx,te.open]);var he=t.useCallback(function(){K(null),ie(p)},[]),pe=t.useCallback(function(){le(p)},[]),ve=t.useCallback(function(){var e;if(te.anchorEl&&te.refSectionTitle){var n=te.anchorEl.getBoundingClientRect(),t=(null===(e=null==J?void 0:J.current)||void 0===e?void 0:e.offsetHeight)||0,i=Math.min(680,window.innerWidth-24),r=window.innerHeight-n.bottom-12-12,o=n.top-12-12,l=r<t&&o>r;null!==xe.current?!0===xe.current&&(l=o>=t||o>=r):l=!(r>=t||r>=o),xe.current=l;var s=l?o:r,a=Math.min(t||9999,s),c=l?n.top-12-a:n.bottom+12,u=n.left+n.width/2,d=u-i/2,f=Math.max(12,Math.min(d,window.innerWidth-i-12)),x=Math.max(14,Math.min(u-f,i-10-4));K({top:c,left:f,arrowLeft:x,openAbove:l,maxHeight:s})}},[te.anchorEl,te.refSectionTitle]);t.useEffect(function(){if(te.open){window.addEventListener("resize",ve);var e=requestAnimationFrame(ve),n=null;return J.current&&(n=new ResizeObserver(function(){cancelAnimationFrame(e),e=requestAnimationFrame(ve)})).observe(J.current),function(){cancelAnimationFrame(e),window.removeEventListener("resize",ve),n&&n.disconnect()}}},[te.open,ve]),t.useEffect(function(){var e=se.current;if(e&&te.open){var n=function(e){J.current&&J.current.contains(e.target)||(K(null),he())};return e.addEventListener("scroll",n,{capture:!0}),window.addEventListener("scroll",n,{capture:!0}),function(){e.removeEventListener("scroll",n,{capture:!0}),window.removeEventListener("scroll",n,{capture:!0})}}},[te.open,he]),t.useEffect(function(){var e=se.current;if(e&&oe.open){var n=function(){pe()};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})}}},[oe.open,pe]);var ge=t.useMemo(function(){var n,t,i,r,o,l,s,c,u,d,f,x;return{fields:null!==(n=null==I?void 0:I.fields)&&void 0!==n?n:a.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(i=null===(t=null==I?void 0:I.thresholds)||void 0===t?void 0:t.high)&&void 0!==i?i:a.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(o=null===(r=null==I?void 0:I.thresholds)||void 0===r?void 0:r.medium)&&void 0!==o?o:a.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(s=null===(l=null==I?void 0:I.thresholds)||void 0===l?void 0:l.exact)&&void 0!==s?s:a.DEFAULT_COMPARISON_CONFIG.thresholds.exact},relationStyles:{noContent:e.__assign(e.__assign({},a.DEFAULT_COMPARISON_CONFIG.relationStyles.noContent),(null===(c=null==I?void 0:I.relationStyles)||void 0===c?void 0:c.noContent)||{}),high:e.__assign(e.__assign({},a.DEFAULT_COMPARISON_CONFIG.relationStyles.high),(null===(u=null==I?void 0:I.relationStyles)||void 0===u?void 0:u.high)||{}),exact:e.__assign(e.__assign({},a.DEFAULT_COMPARISON_CONFIG.relationStyles.exact),(null===(d=null==I?void 0:I.relationStyles)||void 0===d?void 0:d.exact)||{}),medium:e.__assign(e.__assign({},a.DEFAULT_COMPARISON_CONFIG.relationStyles.medium),(null===(f=null==I?void 0:I.relationStyles)||void 0===f?void 0:f.medium)||{}),low:e.__assign(e.__assign({},a.DEFAULT_COMPARISON_CONFIG.relationStyles.low),(null===(x=null==I?void 0:I.relationStyles)||void 0===x?void 0:x.low)||{})}}},[I]),_e=t.useMemo(function(){if(E&&Object.keys(E).length>0)try{var n=function(n,t){var i,r,o,l,a,c,u,d;void 0===t&&(t=!1);var f=[],x=[],h=n.base_root_id,p=n.input_index_map||{0:"left",1:"right"},v=n[h];if(!v||!1===v.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[]};var g=function(t,i){var r=n[t];if(!r)return null;var o=s.getSideData(r,i,p),l=!!o.title.trim(),a=!!o.content.trim(),c=s.getRationale(r),u=[];r.next&&Object.values(r.next).forEach(function(e){if(n[e]){var t=g(e,i);t&&u.push(t)}});var d=!(!l&&!a);return e.__assign({id:t,title:l?o.title:"",content:a?o.content:"",subsections:u},d?c:{score:void 0,relation:"not_defined"})};if(t){var _={},m={},y=-1,b=-1;for(var S in n)if(!["base_root_id","documents","input_index_map",h].includes(S)){var F=n[S];if(F&&!1!==F.display_node){var w=s.getRationale(F),E=s.getSideData(F,"0",p),I=s.getSideData(F,"1",p),j=E.title.trim()||E.content.trim(),C=I.title.trim()||I.content.trim(),R=Number(null!==(r=null===(i=E.attributes)||void 0===i?void 0:i.display_index)&&void 0!==r?r:y--),B=Number(null!==(l=null===(o=I.attributes)||void 0===o?void 0:o.display_index)&&void 0!==l?l:b--),T=m[B]||e.__assign(e.__assign({id:S,title:C?I.title:"",content:C?I.content:"",subsections:[]},C?w:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:B}),A=_[R]||e.__assign(e.__assign({id:S,title:j?E.title:"",content:j?E.content:"",subsections:[]},j?w:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:R});Number(B)>=0&&Number(R)>=0&&(T.refIndexes.includes(Number(R))||T.refIndexes.push(Number(R)),A.refIndexes.includes(Number(B))||A.refIndexes.push(Number(B))),m[B]=T,_[R]=A}}x=Object.values(m).map(function(e){return e}),f=Object.values(_).map(function(e){return e}),x.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})}else v.next&&Object.values(v.next).forEach(function(e){var t=n[e];t&&!1!==t.display_node&&(f.push(g(e,"0")||{id:e,title:"",content:"",subsections:[]}),x.push(g(e,"1")||{id:e,title:"",content:"",subsections:[]}))});return{activeProposed:{title:(null===(c=null===(a=v.comparison_inputs)||void 0===a?void 0:a[p[0]])||void 0===c?void 0:c.title)||"Uploaded Contract",description:v.decision_scope_description||"",sections:f},activeVariants:[{id:"tree-variant-1",title:(null===(d=null===(u=v.comparison_inputs)||void 0===u?void 0:u[p[1]])||void 0===d?void 0:d.title)||"Reference Template",similarity:0,sections:x,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:v.decision_scope_description||""},fields:{}}}}]}}(E,k);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"}},[E,k]),me=_e.activeProposed,ye=_e.activeVariants,be=_e.parseError;t.useEffect(function(){be&&L("Failed to load comparison: ".concat(be))},[be]);var Se=t.useState(null),Fe=Se[0];Se[1];var we=t.useState({}),Ee=we[0],Ie=we[1],je=t.useState({}),Ce=je[0],Re=je[1],Be=(null==ye?void 0:ye[0])||h,Te=null===(g=null===(d=null==E?void 0:E.documents)||void 0===d?void 0:d[null===(v=null==E?void 0:E.input_index_map)||void 0===v?void 0:v[0]])||void 0===g?void 0:g.title,Ae=null===(y=null===(_=null==E?void 0:E.documents)||void 0===_?void 0:_[null===(m=null==E?void 0:E.input_index_map)||void 0===m?void 0:m[1]])||void 0===y?void 0:y.title,De=s.safeStringify(j||Te||"Uploaded Contract"),ke=s.safeStringify(C||Ae||"Reference Template"),Oe=t.useMemo(function(){return(null==me?void 0:me.sections)||[]},[null==me?void 0:me.sections]),Me=t.useMemo(function(){return Be.sections||[]},[Be.sections]),Ne=Oe.length>0||Me.length>0,Le=Be.analysis,ze=s.safeStringify(null===(S=null===(b=null==Le?void 0:Le.rule_difference_comparison)||void 0===b?void 0:b.summary)||void 0===S?void 0:S.overall_summary),He=!!ze.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),We=t.useRef({}),qe=function(e){return We.current[e]||(We.current[e]=f.default.createRef()),We.current[e]},Pe=t.useCallback(function(){W(!1),nn(null),U(!1),ue.current&&(ue.current.style.height="0px"),de.current&&(de.current.style.height="0px")},[]),Ue=t.useCallback(function(e,n,t,i,r){var o,l,a=s.safeStringify(n.id)||s.safeStringify(t.id)||"",c=(a?G[a]:null)||n.cognitiveData||t.cognitiveData||{section_id:a,decisioning:[],gap:[],relevance_score:0},u=null!==(l=null===(o=We.current[i])||void 0===o?void 0:o.current)&&void 0!==l?l:null;return{open:!0,sectionTitle:n.title||"N/A",refSectionTitle:t.title||"NA",cognitiveData:c,anchorEl:e,sectionAnchorEl:u,badgeStyle:r||null,sectionIdx:i,docData:{documents:null==E?void 0:E.documents,input_index_map:null==E?void 0:E.input_index_map}}},[G]),Ve=t.useCallback(function(e){pe(),K(null),ie(e)},[pe]),Ge=t.useCallback(function(){null!==oe.sectionIdx&&oe.anchorEl?Ve(e.__assign(e.__assign({},oe),{open:!0})):pe()},[oe,pe,Ve]);t.useCallback(function(e){pe(),L("".concat(e," is coming soon."))},[pe]);var Ye=t.useRef(null),Xe=t.useRef(null),Ke=t.useRef(null),Je=t.useState([]),Qe=Je[0],Ze=Je[1],$e=t.useState(null),en=$e[0],nn=$e[1],tn=t.useRef(null),rn=t.useState(null),on=rn[0],ln=rn[1],sn=t.useMemo(function(){return ge.fields.filter(function(e){var n=e.key;return(!Ne||"description"!==n)&&(s.hasValue(null==me?void 0:me[n])||s.hasValue(Be[n]))})},[me,Be,Ne,ge.fields]),an=t.useRef({}),cn=t.useRef({}),un=t.useRef({}),dn=t.useRef({}),fn=t.useRef({}),xn=t.useRef({}),hn=t.useRef({});sn.forEach(function(e){for(var n=e.key,t=0;t<Math.max(Oe.length,Me.length);t+=1)un.current[t]||(un.current[t]=f.default.createRef()),dn.current[t]||(dn.current[t]=f.default.createRef()),fn.current[t]||(fn.current[t]=f.default.createRef()),xn.current[t]||(xn.current[t]=f.default.createRef()),hn.current[t]||(hn.current[t]=f.default.createRef());an.current[n]||(an.current[n]=f.default.createRef()),cn.current[n]||(cn.current[n]=f.default.createRef())});for(var pn=0;pn<Math.max(Oe.length,Me.length);pn+=1)un.current[pn]||(un.current[pn]=f.default.createRef()),dn.current[pn]||(dn.current[pn]=f.default.createRef()),fn.current[pn]||(fn.current[pn]=f.default.createRef()),xn.current[pn]||(xn.current[pn]=f.default.createRef()),hn.current[pn]||(hn.current[pn]=f.default.createRef());t.useEffect(function(){if(Fe){var e=ge.fields.find(function(e){return e.analysisKey===Fe||e.key===Fe});if(e){var n=an.current[e.key]||cn.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[Fe,ge.fields]);var vn=t.useCallback(function(e){var n,t,i,r,o,l,s,a,c,u=null===(n=null==Le?void 0:Le.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!u||!u[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var d=u[e],f=(null==d?void 0:d.relation)||(null===(i=null===(t=null==d?void 0:d.highlights)||void 0===t?void 0:t.ruleA_spans)||void 0===i?void 0:i.length)||(null===(o=null===(r=null==d?void 0:d.highlights)||void 0===r?void 0:r.ruleB_spans)||void 0===o?void 0:o.length)||(null==d?void 0:d.mappings)&&d.mappings.length>0;if(d.mappings){var x=d.mappings[0]||{};return{score:d.score,relation:x.relation||"",highlightsA:(null===(l=x.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(s=x.highlights)||void 0===s?void 0:s.ruleB_spans)||[],hasContent:!!f}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(a=d.highlights)||void 0===a?void 0:a.ruleA_spans)||[],highlightsB:(null===(c=d.highlights)||void 0===c?void 0:c.ruleB_spans)||[],hasContent:!!f}},[Le]),gn=t.useCallback(function(n){var t,i,r,o,l=Oe[n],a=Me[n],c=(null==l?void 0:l.relation)&&"not_defined"!==l.relation,u=(null==a?void 0:a.relation)&&"not_defined"!==a.relation,d=s.safeStringify(null==l?void 0:l.id)||s.safeStringify(null==a?void 0:a.id)||"",f=!(!(null==l?void 0:l.cognitiveData)&&!(null==a?void 0:a.cognitiveData));if(!c&&!u&&!f)return e.__assign(e.__assign({},ge.relationStyles.noContent),{label:"Not Defined"});var x=vn("description");if(null!=(null!==(i=null!==(t=null==l?void 0:l.cognitiveRelevanceScore)&&void 0!==t?t:null==a?void 0:a.cognitiveRelevanceScore)&&void 0!==i?i:d?null===(r=G[d])||void 0===r?void 0:r.relevance_score:void 0)){var h=s.cognitiveScoreToRelation(),p=h.score,v=h.relation;return s.getStyleForRelation(p,v,!0,ge)}var g=c?l.relation:u?a.relation:x.relation,_=null!==(o=null==l?void 0:l.score)&&void 0!==o?o:null==a?void 0:a.score,m="number"==typeof _?_:x.score;return s.getStyleForRelation(m,g,!0,ge)},[Oe,Me,G,ge,vn]),_n=t.useCallback(function(){var e,n,t,i,r,o,l,a,c,u,d;if(!fe.current){fe.current=!0;try{if(!Ye.current)return;var f=Ye.current.getBoundingClientRect();$({width:f.width,height:f.height});var x=[];if(sn.forEach(function(e){var n,t,i=e.key,r=null===(n=an.current[i])||void 0===n?void 0:n.current,o=null===(t=cn.current[i])||void 0===t?void 0:t.current;r&&o&&(r.style.height="auto",o.style.height="auto",r.style.minHeight="0px",o.style.minHeight="0px")}),!k)for(var h=0;h<Math.min(Oe.length,Me.length);h++){var p=null===(e=un.current[h])||void 0===e?void 0:e.current,v=null===(n=dn.current[h])||void 0===n?void 0:n.current;p&&v&&(p.style.height="auto",v.style.height="auto",p.style.minHeight="0px",v.style.minHeight="0px")}var g={};sn.forEach(function(e){var n,t,i=e.key,r=null===(n=an.current[i])||void 0===n?void 0:n.current,o=null===(t=cn.current[i])||void 0===t?void 0:t.current;if(r&&o){var l=r.getBoundingClientRect(),s=o.getBoundingClientRect();g[i]=Math.max(l.height,s.height)}});var _=[];if(!k)for(h=0;h<Math.min(Oe.length,Me.length);h++){p=null===(t=un.current[h])||void 0===t?void 0:t.current,v=null===(i=dn.current[h])||void 0===i?void 0:i.current;if(p&&v){var m=p.getBoundingClientRect(),y=v.getBoundingClientRect();_[h]=Math.max(m.height,y.height)}}if(sn.forEach(function(e){var n,t,i=e.key,r=null===(n=an.current[i])||void 0===n?void 0:n.current,o=null===(t=cn.current[i])||void 0===t?void 0:t.current;if(r&&o){var l=g[i];r.style.minHeight="".concat(l,"px"),o.style.minHeight="".concat(l,"px")}}),!k)for(h=0;h<_.length;h++){p=null===(r=un.current[h])||void 0===r?void 0:r.current,v=null===(o=dn.current[h])||void 0===o?void 0:o.current;if(p&&v){var b=_[h];p.style.minHeight="".concat(b,"px"),v.style.minHeight="".concat(b,"px")}}if(sn.forEach(function(e){var n,t,i=e.key,r=e.analysisKey,o=null===(n=an.current[i])||void 0===n?void 0:n.current,l=null===(t=cn.current[i])||void 0===t?void 0:t.current;if(o&&l){var a=o.getBoundingClientRect(),c=l.getBoundingClientRect(),u=vn(r),d=s.getStyleForRelation(u.score,u.relation,u.hasContent,ge);if(!d)return;var h=a.top+a.height/2-f.top;x.push({id:"field-".concat(i),x1:a.right-f.left,y1:h,x2:c.left-f.left,y2:h,style:d})}}),k)Oe.forEach(function(e,n){var t;(null===(t=un.current[n])||void 0===t?void 0:t.current)&&(e.refIndexes||[]).forEach(function(e){var t,i,r=Me.findIndex(function(n){return n.selfIndex===e});if(-1!==r){var o=null===(t=fn.current[n])||void 0===t?void 0:t.current,l=null===(i=xn.current[r])||void 0===i?void 0:i.current;if(o&&l){var s=o.getBoundingClientRect(),a=l.getBoundingClientRect(),c=s.right-f.left,u=a.left-f.left,d=s.top+s.height/2-f.top,h=a.top+a.height/2-f.top;H&&en===n&&(h=d);var p=gn(n);p&&x.push({id:"line-".concat(n,"-").concat(r),x1:c,y1:d,x2:u,y2:h,style:p,sectionIdx:n,targetRightIdx:r})}}})});else for(h=0;h<Math.min(Oe.length,Me.length);h++){var S=null===(l=un.current[h])||void 0===l?void 0:l.current,F=null===(a=dn.current[h])||void 0===a?void 0:a.current;if(S&&F){var w=S.querySelector(".MuiAccordionSummary-root"),E=F.querySelector(".MuiAccordionSummary-root");if(w&&E){var I=w.getBoundingClientRect(),j=E.getBoundingClientRect(),C=(I.top+I.height/2-f.top+j.top+j.height/2-f.top)/2,R=(null===(c=Me[h])||void 0===c?void 0:c.id)||"sec-".concat(h),B=gn(h);B&&x.push({id:R,x1:I.right-f.left,y1:C,x2:j.left-f.left,y2:C,style:B,sectionIdx:h,hasCognitive:!!((null===(u=Oe[h])||void 0===u?void 0:u.cognitiveData)||(null===(d=Me[h])||void 0===d?void 0:d.cognitiveData)||R&&G[R])})}}}if(Ze(x),Xe.current&&Ke.current){var T=Xe.current.getBoundingClientRect(),A=Ke.current.getBoundingClientRect(),D=(T.top+T.height/2-f.top+A.top+A.height/2-f.top)/2;ln({x1:T.right-f.left,x2:A.left-f.left,y:D})}else ln(null)}catch(e){console.error("Line render safe fail: ",e)}finally{fe.current=!1}}},[sn,Oe,Me,G,ge,vn,gn,k,H,en]),mn=t.useRef(_n);t.useEffect(function(){mn.current=_n},[_n]);var yn=t.useCallback(function(){null!==tn.current&&window.cancelAnimationFrame(tn.current),tn.current=window.requestAnimationFrame(function(){mn.current(),tn.current=null})},[]),bn=t.useCallback(function(){var e=oe.sectionIdx;pe(),null!==e&&(H&&en===e?Pe():(V.current=!0,nn(e),W(!0),U(!1),ue.current&&(ue.current.style.height="0px"),de.current&&(de.current.style.height="0px"),requestAnimationFrame(function(){var n,t,i=null===(n=We.current[e])||void 0===n?void 0:n.current,r=Oe[e],o=(null==r?void 0:r.refIndexes)||[],l=null;if(o.length>0){var s=o[0],a=Me.findIndex(function(e){return e.selfIndex===s});l=null===(t=hn.current[a])||void 0===t?void 0:t.current}var c=null==i?void 0:i.parentElement,u=ce.current;if(i&&c){var d=i.offsetTop-c.scrollTop,f=null;if(l&&u){var x=l.offsetTop-d;if(x<0)ue.current&&(ue.current.style.height="".concat(Math.abs(x),"px")),f=0;else{var h=u.scrollHeight-u.clientHeight;x>h?(de.current&&(de.current.style.height="".concat(x-h+150,"px")),f=x):f=x}}u&&null!==f?function(e,n,t,i){void 0===t&&(t=300);var r=e.style.scrollBehavior;e.style.scrollBehavior="auto";var o=e.scrollTop,l=n-o,s=null,a=function(c){null===s&&(s=c);var u,d=c-s;d<t?(e.scrollTop=(u=d,u/=t,l*(--u*u*u+1)+o),requestAnimationFrame(a)):(e.scrollTop=n,e.style.scrollBehavior=r,i&&i())};requestAnimationFrame(a)}(u,f,300,function(){U(!0),yn(),setTimeout(function(){V.current=!1},50)}):setTimeout(function(){U(!0),yn(),V.current=!1},350)}})))},[pe,oe.sectionIdx,H,en,Oe,Me,yn,Pe]),Sn=t.useCallback(function(){V.current||(yn(),H&&!V.current&&(W(!1),nn(null),U(!1),ue.current&&(ue.current.style.height="0px"),de.current&&(de.current.style.height="0px")))},[yn,H]);t.useEffect(function(){var e=setTimeout(yn,250);window.addEventListener("resize",yn);var n=null,t=null;return se.current&&(n=new ResizeObserver(yn)).observe(se.current),Ye.current&&(t=new ResizeObserver(yn)).observe(Ye.current),function(){clearTimeout(e),window.removeEventListener("resize",yn),null==n||n.disconnect(),null==t||t.disconnect()}},[me,Be,Le,sn,Ee,Ce,Oe,Me,ge,yn,H,en,P]);var Fn=function(t,o,l,a,c){void 0===c&&(c=1);var u,d=k?!!Ee["".concat(l,"-").concat(o)]:!!Ee[String(o)],h=s.hasValue(t.title),p=s.hasValue(t.content),v=!h&&!p,g=t.title;return h||(g=p?"No Title Found":"No Matching Section Found"),n.jsx(i.Box,e.__assign({ref:a,sx:e.__assign(e.__assign({mb:c},k?{height:"fit-content"}:{minHeight:0}),{display:"flex",flexDirection:"column",position:"relative"})},{children:n.jsxs(i.Accordion,e.__assign({disableGutters:!0,expanded:!v&&d,onChange:function(){return!v&&function(n,t){Ie(function(i){var r=e.__assign({},i);if(!k){var o=!!i[String(n)];return r[String(n)]=!o,r}var l="".concat(t,"-").concat(n),s=!i[l];if(r[l]=s,"left"===t)((null==(a=Oe[n])?void 0:a.refIndexes)||[]).forEach(function(e){var n=Me.findIndex(function(n){return n.selfIndex===e});-1!==n&&(r["right-".concat(n)]=s)});else{var a,c=null==(a=Me[n])?void 0:a.selfIndex;Oe.forEach(function(e,n){var t;(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(c))&&(r["left-".concat(n)]=s)})}return r})}(o,l)},sx:{boxShadow:"none",border:v?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:v?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flex:1,display:"flex",flexDirection:"column","&:before":{display:"none"}}},{children:[n.jsx(i.AccordionSummary,e.__assign({expandIcon:v?null:n.jsx(r.ChevronDown,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:v?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"flex",alignItems:"center",overflow:"hidden"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:n.jsx(i.Tooltip,e.__assign({title:g,placement:"top"},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"12px",color:v?"#94A3B8":"#19213D",fontWeight:v?400:700,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:(u=g,u?s.safeStringify(u).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(f.default.Fragment,{children:e},t)}):null)}))}))})),!v&&n.jsxs(i.AccordionDetails,e.__assign({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column"}},{children:[n.jsx(i.Typography,e.__assign({component:"div",sx:ee},{children:n.jsx(x.default,{children:s.safeStringify(t.content).replace(/\\n/g,"\n")})})),(t.subsections||[]).map(function(e,n){return wn(e,"".concat(o,"-").concat(n),0)})]}))]}))}),"".concat(l,"-sec-").concat(o))},wn=function(t,o,l){void 0===l&&(l=0);var a=s.hasValue(t.title),c=s.hasValue(t.content),u=!a&&!c,d=a?t.title:c?"No Title Found":"No Matching Section Found",f=!!Ce[o];return t.title?n.jsxs(i.Accordion,e.__assign({disableGutters:!0,expanded:!u&&f,onChange:function(){return!u&&Re(function(n){var t;return e.__assign(e.__assign({},n),((t={})[o]=!n[o],t))})},sx:{mt:1,boxShadow:"none",border:u?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF","&:before":{display:"none"}}},{children:[n.jsx(i.AccordionSummary,e.__assign({expandIcon:u?null:n.jsx(r.ChevronDown,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5}}},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"11px",fontWeight:600,color:u?"#94A3B8":"#19213D"}},{children:d||"Untitled Subsection"}))})),!u&&n.jsxs(i.AccordionDetails,e.__assign({sx:{pt:0,pb:1}},{children:[c&&n.jsx(i.Typography,e.__assign({component:"div",sx:ee},{children:n.jsx(x.default,{children:s.safeStringify(t.content).replace(/\\n/g,"\n")})})),(t.subsections||[]).map(function(e,n){return wn(e,"".concat(o,"-").concat(n),l+1)})]}))]}),o):n.jsx(i.Box,e.__assign({sx:{mt:0===l?1:.75}},{children:!u&&n.jsxs("div",{children:[c&&n.jsx(i.Typography,e.__assign({component:"div",sx:ee},{children:n.jsx(x.default,{children:s.safeStringify(t.content).replace(/\\n/g,"\n")})})),(t.subsections||[]).map(function(e,n){return wn(e,"".concat(o,"-").concat(n),l+1)})]})}),o)};return n.jsxs(i.Box,e.__assign({ref:ae,sx:e.__assign(e.__assign({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},k?{}:{overflow:"visible"}),{position:"relative"})},{children:[k&&n.jsx(u.default,{open:oe.open,anchorEl:oe.anchorEl,sectionTitle:oe.sectionTitle,referenceSectionTitle:oe.refSectionTitle,onClose:pe,onOpenCognitiveCompare:Ge,onOpenSideBySide:bn}),te.open&&n.jsx(c.default,{open:te.open,popupRef:J,position:X,popupConfig:A,onClose:function(){K(null),ie(function(n){return e.__assign(e.__assign({},n),{open:!1})})},markdownStyles:R,sectionTitle:te.sectionTitle,referenceSectionTitle:te.refSectionTitle,cognitiveData:te.cognitiveData,anchorEl:te.anchorEl,sectionAnchorEl:te.sectionAnchorEl,scrollContainerEl:se.current,badgeStyle:te.badgeStyle,docData:te.docData}),n.jsx(i.Snackbar,e.__assign({open:!!N,autoHideDuration:8e3,onClose:function(){return L(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(i.Alert,e.__assign({onClose:function(){return L(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:N}))})),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:n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:600,color:"#0F172A"}},{children:w}))})),n.jsx(i.Box,e.__assign({sx:{display:"flex",alignItems:"center"}},{children:n.jsx(i.FormControlLabel,{control:n.jsx(i.Switch,{checked:k,onChange:function(e){return O(e.target.checked)},color:"primary",size:"small"}),label:n.jsx(i.Typography,e.__assign({sx:{fontSize:"13px",fontWeight:500,color:"#64748B"}},{children:"Relative Order"})),labelPlacement:"start",sx:{m:0,gap:1}})}))]})),n.jsx(i.Box,e.__assign({ref:se,onScroll:Sn,sx:{flex:1,minHeight:0,pt:1.5,pb:8,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:k?"hidden":"auto",borderTop:ze&&He?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(i.Box,e.__assign({sx:e.__assign({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},k?{flex:1,minHeight:0}:{})},{children:n.jsxs(i.Box,e.__assign({ref:Ye,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},k?{flex:1,overflow:"visible"}:{})},{children:[n.jsxs("svg",e.__assign({style:{position:"absolute",top:0,left:0,width:Z.width||"100%",height:Z.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible"}},{children:[on&&n.jsxs("g",{children:[n.jsx("line",{x1:on.x1,y1:on.y,x2:Math.max(on.x1,(on.x1+on.x2)/2-70),y2:on.y,stroke:"#BBF7D0",strokeWidth:"1.5"}),n.jsx("line",{x1:Math.min(on.x2,(on.x1+on.x2)/2+70),y1:on.y,x2:on.x2,y2:on.y,stroke:"#BBF7D0",strokeWidth:"1.5"})]}),Qe.map(function(t){var l,s=(t.x1+t.x2)/2;if("Not Defined"===t.style.label&&!t.hasCognitive)return null;if(!k)return n.jsxs("g",{children:[n.jsx("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),n.jsx("foreignObject",e.__assign({x:s-100,y:t.y1-14,width:"200",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:n.jsx(i.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:n.jsxs(i.Box,e.__assign({onClick:function(e){var n=Oe[t.sectionIdx]||{title:"",content:""},i=Me[t.sectionIdx]||{title:"",content:""};Ve(Ue(e.currentTarget,n,i,t.sectionIdx,t.style))},sx:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:t.style.badgeBg,color:t.style.badgeText,border:"1px solid ".concat(t.style.badgeBorder),borderRadius:"12px",px:1.5,py:.5,fontWeight:500,textAlign:"center",whiteSpace:"nowrap",cursor:"pointer"}},{children:[t.style.label,n.jsx(i.Box,e.__assign({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n.jsx(o.ButtonCognitiveIcon,{})})),n.jsx(r.ChevronDown,{size:11})]}))}))}))]},t.id);var a=Oe[t.sectionIdx];return!(null===(l=null==a?void 0:a.refIndexes)||void 0===l?void 0:l.length)||(null==a?void 0:a.selfIndex)<0?null:H&&en===t.sectionIdx&&P?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",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.badgeBorder||"#6366F1",strokeWidth:"1.5",markerEnd:"url(#arr-".concat(t.id,")")})]}),t.id):null})]})),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)"},k?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(i.Box,e.__assign({ref:Xe,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:De,placement:"top"},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",height:"40px"}},{children:De}))}))})),n.jsx(i.Box,e.__assign({onScroll:Sn,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},k?{maxHeight:"500px",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-160px",pr:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:Ne&&Oe.map(function(t,o){var l;if(!k)return n.jsx(i.Box,e.__assign({ref:qe(o)},{children:Fn(t,o,"left",un.current[o])}),"left-row-".concat(o));var s=t,a=gn(o),c=!(null===(l=s.refIndexes)||void 0===l?void 0:l.length)||s.selfIndex<0,u="number"==typeof s.selfIndex&&s.selfIndex>=0?s.selfIndex+1:null;return n.jsx(i.Box,e.__assign({ref:qe(o),sx:{mb:1}},{children:n.jsxs(i.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[n.jsx(i.Box,e.__assign({ref:un.current[o],sx:{width:"100%"}},{children:Fn(t,o,"left",f.default.createRef(),0)})),a&&n.jsxs(i.Box,e.__assign({ref:fn.current[o],onClick:function(e){var n=Me.find(function(e){var n;return null===(n=s.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""};!function(e,n,t,i,r){e.stopPropagation(),oe.open&&oe.sectionIdx===i?pe():(he(),le(Ue(e.currentTarget,n,t,i,r)))}(e,t,n,o,a)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:a.badgeBg,color:a.badgeText,border:"1px solid ".concat(a.badgeBorder),borderRadius:"12px",px:1.2,py:.4,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[null!==u&&n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(a.badgeBorder)}},{children:u})),n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",px:.25}},{children:c?"No Deviation Found":0==a.deviationLabel||void 0===a.deviationLabel?"Same":"".concat(a.deviationLabel,"% Deviation")})),n.jsx(r.EllipsisVertical,{size:11,color:a.badgeText})]}))]}))}),"left-row-".concat(o))})}))]})),n.jsx(i.Box,e.__assign({sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"6px",gap:0}},{children:n.jsx(i.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:n.jsxs(i.Box,e.__assign({sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",borderRadius:"20px",bgcolor:"#ECFDF3",border:"1px solid #A7F3D0",color:"#15803D",fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1}},{children:[n.jsx(i.Box,e.__assign({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n.jsx(o.ButtonCognitiveIcon,{})})),0,"% Similarity",n.jsx(r.ChevronDown,{size:11})]}))}))})),n.jsxs(i.Box,e.__assign({sx:e.__assign({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},k?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[n.jsx(i.Box,e.__assign({ref:Ke,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:ke,placement:"top"},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",height:"40px"}},{children:ke}))}))})),n.jsxs(i.Box,e.__assign({ref:ce,onScroll:Sn,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},k?{maxHeight:"500px",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-160px",pl:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:ue,style:{width:"100%",height:"0px",flexShrink:0}}),Ne&&Me.map(function(t,r){if(!k)return Fn(t,r,"right",dn.current[r]);var o=t,l=Oe.filter(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(o.selfIndex))&&e.selfIndex>=0}).map(function(e){return e.selfIndex+1});return n.jsx(i.Box,e.__assign({ref:hn.current[r],sx:{mb:1}},{children:n.jsxs(i.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[n.jsx(i.Box,e.__assign({ref:dn.current[r],sx:{width:"100%"}},{children:Fn(t,r,"right",f.default.createRef(),0)})),n.jsx(i.Box,e.__assign({ref:xn.current[r],sx:{position:"absolute",top:"18px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"11px",bgcolor:"#EEF2FF",color:"#3730A3",border:"1px solid #C7D2FE",borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:l.length>0?l.join(", "):"-"}))]}))}),"right-row-".concat(r))}),n.jsx("div",{ref:de,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))};
2
2
  //# sourceMappingURL=CognitiveCompare.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e}from"tslib";import{jsxs as n,jsx as t}from"react/jsx-runtime";import i,{useState as r,useRef as o,useMemo as l,useEffect as c,useCallback as a}from"react";import{Box as d,Snackbar as u,Alert as s,Typography as f,FormControlLabel as h,Switch as v,Tooltip as p,Accordion as x,AccordionSummary as g,AccordionDetails as m}from"@mui/material";import{ChevronDown as y,EllipsisVertical as b}from"lucide-react";import{ButtonCognitiveIcon as w}from"../../assests/svg/ButtonCognitiveIcon.js";import F from"react-markdown";import{safeStringify as I,hasValue as E,getStyleForRelation as S,getRationale as C,getSideData as R,cognitiveScoreToRelation as _}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as T,DEFAULT_FIELD_CONFIG as D,DEFAULT_COMPARISON_CONFIG as A}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import B from"./CognitivePopup.js";import k from"./MoreFunctionsPopup.js";var H={id:"",title:""},z={open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null},M=function(e,n,t,i){void 0===t&&(t=300);var r=e.style.scrollBehavior;e.style.scrollBehavior="auto";var o=e.scrollTop,l=n-o,c=null,a=function(d){null===c&&(c=d);var u,s=d-c;s<t?(e.scrollTop=(u=s,u/=t,l*(--u*u*u+1)+o),requestAnimationFrame(a)):(e.scrollTop=n,e.style.scrollBehavior=r,i&&i())};requestAnimationFrame(a)},W=function(W){var L,j,N,O,P,q,X,Y,V=W.componentHeaderText,U=void 0===V?"Learning Comparison":V,K=W.treeData,G=W.comparisonConfig,J=W.leftColumnTitleText,Q=W.rightColumnTitleText,Z=W.markdownStyles,$=W.maintainRelativeOrder,ee=void 0!==$&&$,ne=W.popupConfig,te=r(ee),ie=te[0],re=te[1],oe=r(null),le=oe[0],ce=oe[1],ae=r(!1),de=ae[0],ue=ae[1],se=r(!1),fe=se[0],he=se[1],ve=o(!1),pe=l(function(){return(null==K?void 0:K.cognitive_decisioning)||{}},[K]),xe=r(null),ge=xe[0],me=xe[1],ye=o(null),be=r({width:0,height:0}),we=be[0],Fe=be[1],Ie=l(function(){return e(e({},T),Z)},[Z]),Ee=r({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null}),Se=Ee[0],Ce=Ee[1],Re=r({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null}),_e=Re[0],Te=Re[1],De=o(null),Ae=o(null),Be=o(null),ke=o(null),He=o(null),ze=o(!1),Me=o(null);c(function(){Me.current=null},[Se.sectionIdx,Se.open]);var We=a(function(){me(null),Ce(z)},[]),Le=a(function(){Te(z)},[]),je=a(function(){var e;if(Se.anchorEl&&Se.refSectionTitle){var n=Se.anchorEl.getBoundingClientRect(),t=(null===(e=null==ye?void 0:ye.current)||void 0===e?void 0:e.offsetHeight)||0,i=Math.min(680,window.innerWidth-24),r=window.innerHeight-n.bottom-12-12,o=n.top-12-12,l=r<t&&o>r;null!==Me.current?!0===Me.current&&(l=o>=t||o>=r):l=!(r>=t||r>=o),Me.current=l;var c=l?o:r,a=Math.min(t||9999,c),d=l?n.top-12-a:n.bottom+12,u=n.left+n.width/2,s=u-i/2,f=Math.max(12,Math.min(s,window.innerWidth-i-12)),h=Math.max(14,Math.min(u-f,i-10-4));me({top:d,left:f,arrowLeft:h,openAbove:l,maxHeight:c})}},[Se.anchorEl,Se.refSectionTitle]);c(function(){if(Se.open){window.addEventListener("resize",je);var e=requestAnimationFrame(je),n=null;return ye.current&&(n=new ResizeObserver(function(){cancelAnimationFrame(e),e=requestAnimationFrame(je)})).observe(ye.current),function(){cancelAnimationFrame(e),window.removeEventListener("resize",je),n&&n.disconnect()}}},[Se.open,je]),c(function(){var e=De.current;if(e&&Se.open){var n=function(e){ye.current&&ye.current.contains(e.target)||(me(null),We())};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})}}},[Se.open,We]),c(function(){var e=De.current;if(e&&_e.open){var n=function(){Le()};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})}}},[_e.open,Le]);var Ne=l(function(){var n,t,i,r,o,l,c,a,d,u,s,f;return{fields:null!==(n=null==G?void 0:G.fields)&&void 0!==n?n:D,thresholds:{high:null!==(i=null===(t=null==G?void 0:G.thresholds)||void 0===t?void 0:t.high)&&void 0!==i?i:A.thresholds.high,medium:null!==(o=null===(r=null==G?void 0:G.thresholds)||void 0===r?void 0:r.medium)&&void 0!==o?o:A.thresholds.medium,exact:null!==(c=null===(l=null==G?void 0:G.thresholds)||void 0===l?void 0:l.exact)&&void 0!==c?c:A.thresholds.exact},relationStyles:{noContent:e(e({},A.relationStyles.noContent),(null===(a=null==G?void 0:G.relationStyles)||void 0===a?void 0:a.noContent)||{}),high:e(e({},A.relationStyles.high),(null===(d=null==G?void 0:G.relationStyles)||void 0===d?void 0:d.high)||{}),exact:e(e({},A.relationStyles.exact),(null===(u=null==G?void 0:G.relationStyles)||void 0===u?void 0:u.exact)||{}),medium:e(e({},A.relationStyles.medium),(null===(s=null==G?void 0:G.relationStyles)||void 0===s?void 0:s.medium)||{}),low:e(e({},A.relationStyles.low),(null===(f=null==G?void 0:G.relationStyles)||void 0===f?void 0:f.low)||{})}}},[G]),Oe=l(function(){if(K&&Object.keys(K).length>0)try{var n=function(n,t){var i,r,o,l,c,a,d,u;void 0===t&&(t=!1);var s=[],f=[],h=n.base_root_id,v=n.input_index_map||{0:"left",1:"right"},p=n[h];if(!p||!1===p.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[]};var x=function(t,i){var r=n[t];if(!r)return null;var o=R(r,i,v),l=!!o.title.trim(),c=!!o.content.trim(),a=C(r),d=[];r.next&&Object.values(r.next).forEach(function(e){if(n[e]){var t=x(e,i);t&&d.push(t)}});var u=!(!l&&!c);return e({id:t,title:l?o.title:"",content:c?o.content:"",subsections:d},u?a:{score:void 0,relation:"not_defined"})};if(t){var g={},m={},y=-1,b=-1;for(var w in n)if(!["base_root_id","documents","input_index_map",h].includes(w)){var F=n[w];if(F&&!1!==F.display_node){var I=C(F),E=R(F,"0",v),S=R(F,"1",v),_=E.title.trim()||E.content.trim(),T=S.title.trim()||S.content.trim(),D=Number(null!==(r=null===(i=E.attributes)||void 0===i?void 0:i.display_index)&&void 0!==r?r:y--),A=Number(null!==(l=null===(o=S.attributes)||void 0===o?void 0:o.display_index)&&void 0!==l?l:b--),B=m[A]||e(e({id:w,title:T?S.title:"",content:T?S.content:"",subsections:[]},T?I:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:A}),k=g[D]||e(e({id:w,title:_?E.title:"",content:_?E.content:"",subsections:[]},_?I:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:D});Number(A)>=0&&Number(D)>=0&&(B.refIndexes.includes(Number(D))||B.refIndexes.push(Number(D)),k.refIndexes.includes(Number(A))||k.refIndexes.push(Number(A))),m[A]=B,g[D]=k}}f=Object.values(m).map(function(e){return e}),s=Object.values(g).map(function(e){return e}),f.sort(function(e,n){return e.selfIndex<0&&n.selfIndex>=0?1:e.selfIndex>=0&&n.selfIndex<0?-1:e.selfIndex-n.selfIndex}),s.sort(function(e,n){return e.selfIndex<0&&n.selfIndex>=0?1:e.selfIndex>=0&&n.selfIndex<0?-1:e.selfIndex-n.selfIndex})}else p.next&&Object.values(p.next).forEach(function(e){var t=n[e];t&&!1!==t.display_node&&(s.push(x(e,"0")||{id:e,title:"",content:"",subsections:[]}),f.push(x(e,"1")||{id:e,title:"",content:"",subsections:[]}))});return{activeProposed:{title:(null===(a=null===(c=p.comparison_inputs)||void 0===c?void 0:c[v[0]])||void 0===a?void 0:a.title)||"Uploaded Contract",description:p.decision_scope_description||"",sections:s},activeVariants:[{id:"tree-variant-1",title:(null===(u=null===(d=p.comparison_inputs)||void 0===d?void 0:d[v[1]])||void 0===u?void 0:u.title)||"Reference Template",similarity:0,sections:f,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:p.decision_scope_description||""},fields:{}}}}]}}(K,ie);return e(e({},n),{parseError:null})}catch(e){return console.error("Data Transformation Error: ",e),{activeProposed:{},activeVariants:[],parseError:e instanceof Error?e.message:"Unknown Parsing Error"}}return{activeProposed:{},activeVariants:[],parseError:"Tree data is required"}},[K,ie]),Pe=Oe.activeProposed,qe=Oe.activeVariants,Xe=Oe.parseError;c(function(){Xe&&ce("Failed to load comparison: ".concat(Xe))},[Xe]);var Ye=r(null),Ve=Ye[0];Ye[1];var Ue=r({}),Ke=Ue[0],Ge=Ue[1],Je=r({}),Qe=Je[0],Ze=Je[1],$e=(null==qe?void 0:qe[0])||H,en=null===(N=null===(L=null==K?void 0:K.documents)||void 0===L?void 0:L[null===(j=null==K?void 0:K.input_index_map)||void 0===j?void 0:j[0]])||void 0===N?void 0:N.title,nn=null===(q=null===(O=null==K?void 0:K.documents)||void 0===O?void 0:O[null===(P=null==K?void 0:K.input_index_map)||void 0===P?void 0:P[1]])||void 0===q?void 0:q.title,tn=I(J||en||"Uploaded Contract"),rn=I(Q||nn||"Reference Template"),on=l(function(){return(null==Pe?void 0:Pe.sections)||[]},[null==Pe?void 0:Pe.sections]),ln=l(function(){return $e.sections||[]},[$e.sections]),cn=on.length>0||ln.length>0,an=$e.analysis,dn=I(null===(Y=null===(X=null==an?void 0:an.rule_difference_comparison)||void 0===X?void 0:X.summary)||void 0===Y?void 0:Y.overall_summary),un=!!dn.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),sn=o({}),fn=function(e){return sn.current[e]||(sn.current[e]=i.createRef()),sn.current[e]},hn=a(function(e,n,t,i,r){var o,l,c=I(n.id)||I(t.id)||"",a=(c?pe[c]:null)||n.cognitiveData||t.cognitiveData||{section_id:c,decisioning:[],gap:[],relevance_score:0},d=null!==(l=null===(o=sn.current[i])||void 0===o?void 0:o.current)&&void 0!==l?l:null;return{open:!0,sectionTitle:n.title||"N/A",refSectionTitle:t.title||"NA",cognitiveData:a,anchorEl:e,sectionAnchorEl:d,badgeStyle:r||null,sectionIdx:i,docData:{documents:null==K?void 0:K.documents,input_index_map:null==K?void 0:K.input_index_map}}},[pe]),vn=a(function(e){Le(),me(null),Ce(e)},[Le]),pn=a(function(){null!==_e.sectionIdx&&_e.anchorEl?vn(e(e({},_e),{open:!0})):Le()},[_e,Le,vn]);a(function(e){Le(),ce("".concat(e," is coming soon."))},[Le]);var xn=o(null),gn=o(null),mn=o(null),yn=r([]),bn=yn[0],wn=yn[1],Fn=r(null),In=Fn[0],En=Fn[1],Sn=o(null),Cn=r(null),Rn=Cn[0],_n=Cn[1],Tn=a(function(){null!==Sn.current&&window.cancelAnimationFrame(Sn.current),Sn.current=window.requestAnimationFrame(function(){Pn(),Sn.current=null})},[]),Dn=a(function(){var e=_e.sectionIdx;Le(),null!==e&&(de&&In===e?(ue(!1),En(null),he(!1),ke.current&&(ke.current.style.height="0px"),He.current&&(He.current.style.height="0px")):(ve.current=!0,En(e),ue(!0),he(!1),ke.current&&(ke.current.style.height="0px"),He.current&&(He.current.style.height="0px"),requestAnimationFrame(function(){var n,t,i=null===(n=sn.current[e])||void 0===n?void 0:n.current,r=on[e],o=(null==r?void 0:r.refIndexes)||[],l=null;if(o.length>0){var c=o[0],a=ln.findIndex(function(e){return e.selfIndex===c});l=null===(t=Ln.current[a])||void 0===t?void 0:t.current}var d=null==i?void 0:i.parentElement,u=Be.current;if(i&&d){var s=d.clientHeight,f=i.offsetTop-(s/2-i.offsetHeight/2),h=d.scrollHeight-s,v=Math.max(0,Math.min(f,h)),p=i.offsetTop-v,x=null;if(l&&u){var g=l.offsetTop-p;if(g<0)ke.current&&(ke.current.style.height="".concat(Math.abs(g),"px")),x=0;else{var m=u.scrollHeight-u.clientHeight;g>m?(He.current&&(He.current.style.height="".concat(g-m+150,"px")),x=g):x=g}}M(d,v,300),u&&null!==x?M(u,x,300,function(){he(!0),Tn(),setTimeout(function(){ve.current=!1},50)}):setTimeout(function(){he(!0),Tn(),ve.current=!1},350)}})))},[Le,_e.sectionIdx,de,In,on,ln,Tn]),An=l(function(){return Ne.fields.filter(function(e){var n=e.key;return(!cn||"description"!==n)&&(E(null==Pe?void 0:Pe[n])||E($e[n]))})},[Pe,$e,cn,Ne.fields]),Bn=o({}),kn=o({}),Hn=o({}),zn=o({}),Mn=o({}),Wn=o({}),Ln=o({});An.forEach(function(e){for(var n=e.key,t=0;t<Math.max(on.length,ln.length);t+=1)Hn.current[t]||(Hn.current[t]=i.createRef()),zn.current[t]||(zn.current[t]=i.createRef()),Mn.current[t]||(Mn.current[t]=i.createRef()),Wn.current[t]||(Wn.current[t]=i.createRef()),Ln.current[t]||(Ln.current[t]=i.createRef());Bn.current[n]||(Bn.current[n]=i.createRef()),kn.current[n]||(kn.current[n]=i.createRef())});for(var jn=0;jn<Math.max(on.length,ln.length);jn+=1)Hn.current[jn]||(Hn.current[jn]=i.createRef()),zn.current[jn]||(zn.current[jn]=i.createRef()),Mn.current[jn]||(Mn.current[jn]=i.createRef()),Wn.current[jn]||(Wn.current[jn]=i.createRef()),Ln.current[jn]||(Ln.current[jn]=i.createRef());c(function(){if(Ve){var e=Ne.fields.find(function(e){return e.analysisKey===Ve||e.key===Ve});if(e){var n=Bn.current[e.key]||kn.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[Ve,Ne.fields]);var Nn=a(function(e){var n,t,i,r,o,l,c,a,d,u=null===(n=null==an?void 0:an.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!u||!u[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var s=u[e],f=(null==s?void 0:s.relation)||(null===(i=null===(t=null==s?void 0:s.highlights)||void 0===t?void 0:t.ruleA_spans)||void 0===i?void 0:i.length)||(null===(o=null===(r=null==s?void 0:s.highlights)||void 0===r?void 0:r.ruleB_spans)||void 0===o?void 0:o.length)||(null==s?void 0:s.mappings)&&s.mappings.length>0;if(s.mappings){var h=s.mappings[0]||{};return{score:s.score,relation:h.relation||"",highlightsA:(null===(l=h.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(c=h.highlights)||void 0===c?void 0:c.ruleB_spans)||[],hasContent:!!f}}return{score:s.score,relation:s.relation||"",highlightsA:(null===(a=s.highlights)||void 0===a?void 0:a.ruleA_spans)||[],highlightsB:(null===(d=s.highlights)||void 0===d?void 0:d.ruleB_spans)||[],hasContent:!!f}},[an]),On=a(function(n){var t,i,r,o,l=on[n],c=ln[n],a=(null==l?void 0:l.relation)&&"not_defined"!==l.relation,d=(null==c?void 0:c.relation)&&"not_defined"!==c.relation,u=I(null==l?void 0:l.id)||I(null==c?void 0:c.id)||"",s=!(!(null==l?void 0:l.cognitiveData)&&!(null==c?void 0:c.cognitiveData));if(!a&&!d&&!s)return e(e({},Ne.relationStyles.noContent),{label:"Not Defined"});var f=Nn("description");if(null!=(null!==(i=null!==(t=null==l?void 0:l.cognitiveRelevanceScore)&&void 0!==t?t:null==c?void 0:c.cognitiveRelevanceScore)&&void 0!==i?i:u?null===(r=pe[u])||void 0===r?void 0:r.relevance_score:void 0)){var h=_(),v=h.score,p=h.relation;return S(v,p,!0,Ne)}var x=a?l.relation:d?c.relation:f.relation,g=null!==(o=null==l?void 0:l.score)&&void 0!==o?o:null==c?void 0:c.score,m="number"==typeof g?g:f.score;return S(m,x,!0,Ne)},[on,ln,pe,Ne,Nn]),Pn=a(function(){var e,n,t,i,r,o,l,c,a,d,u;if(!ze.current){ze.current=!0;try{if(!xn.current)return;var s=xn.current.getBoundingClientRect();Fe({width:s.width,height:s.height});var f=[];if(An.forEach(function(e){var n,t,i=e.key,r=null===(n=Bn.current[i])||void 0===n?void 0:n.current,o=null===(t=kn.current[i])||void 0===t?void 0:t.current;r&&o&&(r.style.height="auto",o.style.height="auto",r.style.minHeight="0px",o.style.minHeight="0px")}),!ie)for(var h=0;h<Math.min(on.length,ln.length);h++){var v=null===(e=Hn.current[h])||void 0===e?void 0:e.current,p=null===(n=zn.current[h])||void 0===n?void 0:n.current;v&&p&&(v.style.height="auto",p.style.height="auto",v.style.minHeight="0px",p.style.minHeight="0px")}var x={};An.forEach(function(e){var n,t,i=e.key,r=null===(n=Bn.current[i])||void 0===n?void 0:n.current,o=null===(t=kn.current[i])||void 0===t?void 0:t.current;if(r&&o){var l=r.getBoundingClientRect(),c=o.getBoundingClientRect();x[i]=Math.max(l.height,c.height)}});var g=[];if(!ie)for(h=0;h<Math.min(on.length,ln.length);h++){v=null===(t=Hn.current[h])||void 0===t?void 0:t.current,p=null===(i=zn.current[h])||void 0===i?void 0:i.current;if(v&&p){var m=v.getBoundingClientRect(),y=p.getBoundingClientRect();g[h]=Math.max(m.height,y.height)}}if(An.forEach(function(e){var n,t,i=e.key,r=null===(n=Bn.current[i])||void 0===n?void 0:n.current,o=null===(t=kn.current[i])||void 0===t?void 0:t.current;if(r&&o){var l=x[i];r.style.minHeight="".concat(l,"px"),o.style.minHeight="".concat(l,"px")}}),!ie)for(h=0;h<g.length;h++){v=null===(r=Hn.current[h])||void 0===r?void 0:r.current,p=null===(o=zn.current[h])||void 0===o?void 0:o.current;if(v&&p){var b=g[h];v.style.minHeight="".concat(b,"px"),p.style.minHeight="".concat(b,"px")}}if(An.forEach(function(e){var n,t,i=e.key,r=e.analysisKey,o=null===(n=Bn.current[i])||void 0===n?void 0:n.current,l=null===(t=kn.current[i])||void 0===t?void 0:t.current;if(o&&l){var c=o.getBoundingClientRect(),a=l.getBoundingClientRect(),d=Nn(r),u=S(d.score,d.relation,d.hasContent,Ne);if(!u)return;var h=c.top+c.height/2-s.top;f.push({id:"field-".concat(i),x1:c.right-s.left,y1:h,x2:a.left-s.left,y2:h,style:u})}}),ie)on.forEach(function(e,n){var t;(null===(t=Hn.current[n])||void 0===t?void 0:t.current)&&(e.refIndexes||[]).forEach(function(e){var t,i,r=ln.findIndex(function(n){return n.selfIndex===e});if(-1!==r){var o=null===(t=Mn.current[n])||void 0===t?void 0:t.current,l=null===(i=Wn.current[r])||void 0===i?void 0:i.current;if(o&&l){var c=o.getBoundingClientRect(),a=l.getBoundingClientRect(),d=c.right-s.left,u=a.left-s.left,h=c.top+c.height/2-s.top,v=a.top+a.height/2-s.top;de&&In===n&&(v=h);var p=On(n);p&&f.push({id:"line-".concat(n,"-").concat(r),x1:d,y1:h,x2:u,y2:v,style:p,sectionIdx:n,targetRightIdx:r})}}})});else for(h=0;h<Math.min(on.length,ln.length);h++){var w=null===(l=Hn.current[h])||void 0===l?void 0:l.current,F=null===(c=zn.current[h])||void 0===c?void 0:c.current;if(w&&F){var I=w.querySelector(".MuiAccordionSummary-root"),E=F.querySelector(".MuiAccordionSummary-root");if(I&&E){var C=I.getBoundingClientRect(),R=E.getBoundingClientRect(),_=(C.top+C.height/2-s.top+R.top+R.height/2-s.top)/2,T=(null===(a=ln[h])||void 0===a?void 0:a.id)||"sec-".concat(h),D=On(h);D&&f.push({id:T,x1:C.right-s.left,y1:_,x2:R.left-s.left,y2:_,style:D,sectionIdx:h,hasCognitive:!!((null===(d=on[h])||void 0===d?void 0:d.cognitiveData)||(null===(u=ln[h])||void 0===u?void 0:u.cognitiveData)||T&&pe[T])})}}}if(wn(f),gn.current&&mn.current){var A=gn.current.getBoundingClientRect(),B=mn.current.getBoundingClientRect(),k=(A.top+A.height/2-s.top+B.top+B.height/2-s.top)/2;_n({x1:A.right-s.left,x2:B.left-s.left,y:k})}else _n(null)}catch(e){console.error("Line render safe fail: ",e)}finally{ze.current=!1}}},[An,on,ln,pe,Ne,Nn,On,ie,de,In]),qn=a(function(){ve.current||(Tn(),de&&!ve.current&&(ue(!1),En(null),he(!1),ke.current&&(ke.current.style.height="0px"),He.current&&(He.current.style.height="0px")))},[Tn,de]);c(function(){var e=setTimeout(Tn,250);window.addEventListener("resize",Tn);var n=null,t=null;return De.current&&(n=new ResizeObserver(Tn)).observe(De.current),xn.current&&(t=new ResizeObserver(Tn)).observe(xn.current),function(){clearTimeout(e),window.removeEventListener("resize",Tn),null==n||n.disconnect(),null==t||t.disconnect()}},[Pe,$e,an,An,Ke,Qe,on,ln,Ne,Tn,de,In,fe]);var Xn=function(r,o,l,c,a){void 0===a&&(a=1);var u,s=ie?!!Ke["".concat(l,"-").concat(o)]:!!Ke[String(o)],h=E(r.title),v=E(r.content),b=!h&&!v,w=r.title;return h||(w=v?"No Title Found":"No Matching Section Found"),t(d,e({ref:c,sx:e(e({mb:a},ie?{height:"fit-content"}:{minHeight:0}),{display:"flex",flexDirection:"column",position:"relative"})},{children:n(x,e({disableGutters:!0,expanded:!b&&s,onChange:function(){return!b&&function(n,t){Ge(function(i){var r=e({},i);if(!ie){var o=!!i[String(n)];return r[String(n)]=!o,r}var l="".concat(t,"-").concat(n),c=!i[l];if(r[l]=c,"left"===t)((null==(a=on[n])?void 0:a.refIndexes)||[]).forEach(function(e){var n=ln.findIndex(function(n){return n.selfIndex===e});-1!==n&&(r["right-".concat(n)]=c)});else{var a,d=null==(a=ln[n])?void 0:a.selfIndex;on.forEach(function(e,n){var t;(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(d))&&(r["left-".concat(n)]=c)})}return r})}(o,l)},sx:{boxShadow:"none",border:b?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:b?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flex:1,display:"flex",flexDirection:"column","&:before":{display:"none"}}},{children:[t(g,e({expandIcon:b?null:t(y,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:b?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"flex",alignItems:"center",overflow:"hidden"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:t(p,e({title:w,placement:"top"},{children:t(f,e({sx:{fontSize:"12px",color:b?"#94A3B8":"#19213D",fontWeight:b?400:700,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:(u=w,u?I(u).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(e,n){return e.startsWith("**")&&e.endsWith("**")?t("strong",{children:e.slice(2,-2)},n):t(i.Fragment,{children:e},n)}):null)}))}))})),!b&&n(m,e({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column"}},{children:[t(f,e({component:"div",sx:Ie},{children:t(F,{children:I(r.content).replace(/\\n/g,"\n")})})),(r.subsections||[]).map(function(e,n){return Yn(e,"".concat(o,"-").concat(n),0)})]}))]}))}),"".concat(l,"-sec-").concat(o))},Yn=function(i,r,o){void 0===o&&(o=0);var l=E(i.title),c=E(i.content),a=!l&&!c,u=l?i.title:c?"No Title Found":"No Matching Section Found",s=!!Qe[r];return i.title?n(x,e({disableGutters:!0,expanded:!a&&s,onChange:function(){return!a&&Ze(function(n){var t;return e(e({},n),((t={})[r]=!n[r],t))})},sx:{mt:1,boxShadow:"none",border:a?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF","&:before":{display:"none"}}},{children:[t(g,e({expandIcon:a?null:t(y,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5}}},{children:t(f,e({sx:{fontSize:"11px",fontWeight:600,color:a?"#94A3B8":"#19213D"}},{children:u||"Untitled Subsection"}))})),!a&&n(m,e({sx:{pt:0,pb:1}},{children:[c&&t(f,e({component:"div",sx:Ie},{children:t(F,{children:I(i.content).replace(/\\n/g,"\n")})})),(i.subsections||[]).map(function(e,n){return Yn(e,"".concat(r,"-").concat(n),o+1)})]}))]}),r):t(d,e({sx:{mt:0===o?1:.75}},{children:!a&&n("div",{children:[c&&t(f,e({component:"div",sx:Ie},{children:t(F,{children:I(i.content).replace(/\\n/g,"\n")})})),(i.subsections||[]).map(function(e,n){return Yn(e,"".concat(r,"-").concat(n),o+1)})]})}),r)};return n(d,e({ref:Ae,sx:e(e({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},ie?{}:{overflow:"visible"}),{position:"relative"})},{children:[ie&&t(k,{open:_e.open,anchorEl:_e.anchorEl,sectionTitle:_e.sectionTitle,referenceSectionTitle:_e.refSectionTitle,onClose:Le,onOpenCognitiveCompare:pn,onOpenSideBySide:Dn}),Se.open&&t(B,{open:Se.open,popupRef:ye,position:ge,popupConfig:ne,onClose:function(){me(null),Ce(function(n){return e(e({},n),{open:!1})})},markdownStyles:Z,sectionTitle:Se.sectionTitle,referenceSectionTitle:Se.refSectionTitle,cognitiveData:Se.cognitiveData,anchorEl:Se.anchorEl,sectionAnchorEl:Se.sectionAnchorEl,scrollContainerEl:De.current,badgeStyle:Se.badgeStyle,docData:Se.docData}),t(u,e({open:!!le,autoHideDuration:8e3,onClose:function(){return ce(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:t(s,e({onClose:function(){return ce(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:le}))})),n(d,e({sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between",bgcolor:"#FFFFFF",border:"1.5px solid #EEF0F4",borderTopLeftRadius:"8px",borderTopRightRadius:"8px"}},{children:[t(d,e({sx:{display:"flex",alignItems:"center",gap:1}},{children:t(f,e({sx:{fontSize:"16px",fontWeight:600,color:"#0F172A"}},{children:U}))})),t(d,e({sx:{display:"flex",alignItems:"center"}},{children:t(h,{control:t(v,{checked:ie,onChange:function(e){return re(e.target.checked)},color:"primary",size:"small"}),label:t(f,e({sx:{fontSize:"13px",fontWeight:500,color:"#64748B"}},{children:"Relative Order"})),labelPlacement:"start",sx:{m:0,gap:1}})}))]})),t(d,e({ref:De,onScroll:qn,sx:{flex:1,minHeight:0,pt:1.5,pb:8,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:ie?"hidden":"auto",borderTop:dn&&un?"none":"1.5px solid #EEF0F4"}},{children:t(d,e({sx:e({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},ie?{flex:1,minHeight:0}:{})},{children:n(d,e({ref:xn,sx:e({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},ie?{flex:1,overflow:"visible"}:{})},{children:[n("svg",e({style:{position:"absolute",top:0,left:0,width:we.width||"100%",height:we.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible"}},{children:[Rn&&n("g",{children:[t("line",{x1:Rn.x1,y1:Rn.y,x2:Math.max(Rn.x1,(Rn.x1+Rn.x2)/2-70),y2:Rn.y,stroke:"#BBF7D0",strokeWidth:"1.5"}),t("line",{x1:Math.min(Rn.x2,(Rn.x1+Rn.x2)/2+70),y1:Rn.y,x2:Rn.x2,y2:Rn.y,stroke:"#BBF7D0",strokeWidth:"1.5"})]}),bn.map(function(i){var r,o=(i.x1+i.x2)/2;if("Not Defined"===i.style.label&&!i.hasCognitive)return null;if(!ie)return n("g",{children:[t("line",{x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,stroke:i.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),t("foreignObject",e({x:o-100,y:i.y1-14,width:"200",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:t(d,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:n(d,e({onClick:function(e){var n=on[i.sectionIdx]||{title:"",content:""},t=ln[i.sectionIdx]||{title:"",content:""};vn(hn(e.currentTarget,n,t,i.sectionIdx,i.style))},sx:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:i.style.badgeBg,color:i.style.badgeText,border:"1px solid ".concat(i.style.badgeBorder),borderRadius:"12px",px:1.5,py:.5,fontWeight:500,textAlign:"center",whiteSpace:"nowrap",cursor:"pointer"}},{children:[i.style.label,t(d,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:t(w,{})})),t(y,{size:11})]}))}))}))]},i.id);var l=on[i.sectionIdx];return!(null===(r=null==l?void 0:l.refIndexes)||void 0===r?void 0:r.length)||(null==l?void 0:l.selfIndex)<0?null:de&&In===i.sectionIdx&&fe?n("g",e({style:{transition:"opacity 0.2s"}},{children:[t("defs",{children:t("marker",e({id:"arr-".concat(i.id),markerWidth:"7",markerHeight:"5",refX:"7",refY:"2.5",orient:"auto"},{children:t("polygon",{points:"0 0, 7 2.5, 0 5",fill:i.style.badgeBorder||"#6366F1"})}))}),t("line",{x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,stroke:i.style.badgeBorder||"#6366F1",strokeWidth:"1.5",markerEnd:"url(#arr-".concat(i.id,")")})]}),i.id):null})]})),n(d,e({sx:e({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},ie?{flex:1,overflow:"visible"}:{})},{children:[t(d,e({ref:gn,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",minHeight:"40px",alignItems:"center",overflowX:"hidden"}},{children:t(p,e({title:tn,placement:"top"},{children:t(f,e({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",height:"40px"}},{children:tn}))}))})),t(d,e({onScroll:qn,sx:e({p:"12px",display:"flex",flexDirection:"column"},ie?{maxHeight:"500px",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-160px",pr:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:cn&&on.map(function(r,o){var l;if(!ie)return t(d,e({ref:fn(o)},{children:Xn(r,o,"left",Hn.current[o])}),"left-row-".concat(o));var c=r,a=On(o),u=!(null===(l=c.refIndexes)||void 0===l?void 0:l.length)||c.selfIndex<0,s="number"==typeof c.selfIndex&&c.selfIndex>=0?c.selfIndex+1:null;return t(d,e({ref:fn(o),sx:{mb:1}},{children:n(d,e({sx:{position:"relative",width:"100%"}},{children:[t(d,e({ref:Hn.current[o],sx:{width:"100%"}},{children:Xn(r,o,"left",i.createRef(),0)})),a&&n(d,e({ref:Mn.current[o],onClick:function(e){var n=ln.find(function(e){var n;return null===(n=c.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""};!function(e,n,t,i,r){e.stopPropagation(),_e.open&&_e.sectionIdx===i?Le():(We(),Te(hn(e.currentTarget,n,t,i,r)))}(e,r,n,o,a)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:a.badgeBg,color:a.badgeText,border:"1px solid ".concat(a.badgeBorder),borderRadius:"12px",px:1.2,py:.4,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[null!==s&&t(d,e({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(a.badgeBorder)}},{children:s})),t(d,e({component:"span",sx:{fontSize:"11px",px:.25}},{children:u?"No Deviation Found":0==a.deviationLabel||void 0===a.deviationLabel?"Same":"".concat(a.deviationLabel,"% Deviation")})),t(b,{size:11,color:a.badgeText})]}))]}))}),"left-row-".concat(o))})}))]})),t(d,e({sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"6px",gap:0}},{children:t(d,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:n(d,e({sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",borderRadius:"20px",bgcolor:"#ECFDF3",border:"1px solid #A7F3D0",color:"#15803D",fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1}},{children:[t(d,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:t(w,{})})),0,"% Similarity",t(y,{size:11})]}))}))})),n(d,e({sx:e({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},ie?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[t(d,e({ref:mn,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"40px",display:"flex",alignItems:"center",overflowX:"hidden"}},{children:t(p,e({title:rn,placement:"top"},{children:t(f,e({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",height:"40px"}},{children:rn}))}))})),n(d,e({ref:Be,onScroll:qn,sx:e({p:"12px",display:"flex",flexDirection:"column"},ie?{maxHeight:"500px",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-160px",pl:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[t("div",{ref:ke,style:{width:"100%",height:"0px",flexShrink:0}}),cn&&ln.map(function(r,o){if(!ie)return Xn(r,o,"right",zn.current[o]);var l=r,c=on.filter(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(l.selfIndex))&&e.selfIndex>=0}).map(function(e){return e.selfIndex+1});return t(d,e({ref:Ln.current[o],sx:{mb:1}},{children:n(d,e({sx:{position:"relative",width:"100%"}},{children:[t(d,e({ref:zn.current[o],sx:{width:"100%"}},{children:Xn(r,o,"right",i.createRef(),0)})),t(d,e({ref:Wn.current[o],sx:{position:"absolute",top:"18px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"11px",bgcolor:"#EEF2FF",color:"#3730A3",border:"1px solid #C7D2FE",borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:c.length>0?c.join(", "):"-"}))]}))}),"right-row-".concat(o))}),t("div",{ref:He,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))};export{W as default};
1
+ import{__assign as e}from"tslib";import{jsxs as n,jsx as t}from"react/jsx-runtime";import i,{useState as r,useRef as o,useMemo as l,useEffect as c,useCallback as a}from"react";import{Box as d,Snackbar as u,Alert as s,Typography as f,FormControlLabel as h,Switch as v,Tooltip as p,Accordion as x,AccordionSummary as g,AccordionDetails as m}from"@mui/material";import{ChevronDown as y,EllipsisVertical as b}from"lucide-react";import{ButtonCognitiveIcon as w}from"../../assests/svg/ButtonCognitiveIcon.js";import F from"react-markdown";import{safeStringify as I,hasValue as E,getStyleForRelation as S,getRationale as C,getSideData as R,cognitiveScoreToRelation as _}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as T,DEFAULT_FIELD_CONFIG as D,DEFAULT_COMPARISON_CONFIG as A}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import B from"./CognitivePopup.js";import k from"./MoreFunctionsPopup.js";var z={id:"",title:""},H={open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null},W=function(W){var M,L,j,N,O,P,q,X,Y=W.componentHeaderText,V=void 0===Y?"Learning Comparison":Y,U=W.treeData,K=W.comparisonConfig,G=W.leftColumnTitleText,J=W.rightColumnTitleText,Q=W.markdownStyles,Z=W.maintainRelativeOrder,$=void 0!==Z&&Z,ee=W.popupConfig,ne=r($),te=ne[0],ie=ne[1],re=r(null),oe=re[0],le=re[1],ce=r(!1),ae=ce[0],de=ce[1],ue=r(!1),se=ue[0],fe=ue[1],he=o(!1),ve=l(function(){return(null==U?void 0:U.cognitive_decisioning)||{}},[U]),pe=r(null),xe=pe[0],ge=pe[1],me=o(null),ye=r({width:0,height:0}),be=ye[0],we=ye[1],Fe=l(function(){return e(e({},T),Q)},[Q]),Ie=r({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null}),Ee=Ie[0],Se=Ie[1],Ce=r({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null}),Re=Ce[0],_e=Ce[1],Te=o(null),De=o(null),Ae=o(null),Be=o(null),ke=o(null),ze=o(!1),He=o(null);c(function(){He.current=null},[Ee.sectionIdx,Ee.open]);var We=a(function(){ge(null),Se(H)},[]),Me=a(function(){_e(H)},[]),Le=a(function(){var e;if(Ee.anchorEl&&Ee.refSectionTitle){var n=Ee.anchorEl.getBoundingClientRect(),t=(null===(e=null==me?void 0:me.current)||void 0===e?void 0:e.offsetHeight)||0,i=Math.min(680,window.innerWidth-24),r=window.innerHeight-n.bottom-12-12,o=n.top-12-12,l=r<t&&o>r;null!==He.current?!0===He.current&&(l=o>=t||o>=r):l=!(r>=t||r>=o),He.current=l;var c=l?o:r,a=Math.min(t||9999,c),d=l?n.top-12-a:n.bottom+12,u=n.left+n.width/2,s=u-i/2,f=Math.max(12,Math.min(s,window.innerWidth-i-12)),h=Math.max(14,Math.min(u-f,i-10-4));ge({top:d,left:f,arrowLeft:h,openAbove:l,maxHeight:c})}},[Ee.anchorEl,Ee.refSectionTitle]);c(function(){if(Ee.open){window.addEventListener("resize",Le);var e=requestAnimationFrame(Le),n=null;return me.current&&(n=new ResizeObserver(function(){cancelAnimationFrame(e),e=requestAnimationFrame(Le)})).observe(me.current),function(){cancelAnimationFrame(e),window.removeEventListener("resize",Le),n&&n.disconnect()}}},[Ee.open,Le]),c(function(){var e=Te.current;if(e&&Ee.open){var n=function(e){me.current&&me.current.contains(e.target)||(ge(null),We())};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})}}},[Ee.open,We]),c(function(){var e=Te.current;if(e&&Re.open){var n=function(){Me()};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})}}},[Re.open,Me]);var je=l(function(){var n,t,i,r,o,l,c,a,d,u,s,f;return{fields:null!==(n=null==K?void 0:K.fields)&&void 0!==n?n:D,thresholds:{high:null!==(i=null===(t=null==K?void 0:K.thresholds)||void 0===t?void 0:t.high)&&void 0!==i?i:A.thresholds.high,medium:null!==(o=null===(r=null==K?void 0:K.thresholds)||void 0===r?void 0:r.medium)&&void 0!==o?o:A.thresholds.medium,exact:null!==(c=null===(l=null==K?void 0:K.thresholds)||void 0===l?void 0:l.exact)&&void 0!==c?c:A.thresholds.exact},relationStyles:{noContent:e(e({},A.relationStyles.noContent),(null===(a=null==K?void 0:K.relationStyles)||void 0===a?void 0:a.noContent)||{}),high:e(e({},A.relationStyles.high),(null===(d=null==K?void 0:K.relationStyles)||void 0===d?void 0:d.high)||{}),exact:e(e({},A.relationStyles.exact),(null===(u=null==K?void 0:K.relationStyles)||void 0===u?void 0:u.exact)||{}),medium:e(e({},A.relationStyles.medium),(null===(s=null==K?void 0:K.relationStyles)||void 0===s?void 0:s.medium)||{}),low:e(e({},A.relationStyles.low),(null===(f=null==K?void 0:K.relationStyles)||void 0===f?void 0:f.low)||{})}}},[K]),Ne=l(function(){if(U&&Object.keys(U).length>0)try{var n=function(n,t){var i,r,o,l,c,a,d,u;void 0===t&&(t=!1);var s=[],f=[],h=n.base_root_id,v=n.input_index_map||{0:"left",1:"right"},p=n[h];if(!p||!1===p.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[]};var x=function(t,i){var r=n[t];if(!r)return null;var o=R(r,i,v),l=!!o.title.trim(),c=!!o.content.trim(),a=C(r),d=[];r.next&&Object.values(r.next).forEach(function(e){if(n[e]){var t=x(e,i);t&&d.push(t)}});var u=!(!l&&!c);return e({id:t,title:l?o.title:"",content:c?o.content:"",subsections:d},u?a:{score:void 0,relation:"not_defined"})};if(t){var g={},m={},y=-1,b=-1;for(var w in n)if(!["base_root_id","documents","input_index_map",h].includes(w)){var F=n[w];if(F&&!1!==F.display_node){var I=C(F),E=R(F,"0",v),S=R(F,"1",v),_=E.title.trim()||E.content.trim(),T=S.title.trim()||S.content.trim(),D=Number(null!==(r=null===(i=E.attributes)||void 0===i?void 0:i.display_index)&&void 0!==r?r:y--),A=Number(null!==(l=null===(o=S.attributes)||void 0===o?void 0:o.display_index)&&void 0!==l?l:b--),B=m[A]||e(e({id:w,title:T?S.title:"",content:T?S.content:"",subsections:[]},T?I:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:A}),k=g[D]||e(e({id:w,title:_?E.title:"",content:_?E.content:"",subsections:[]},_?I:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:D});Number(A)>=0&&Number(D)>=0&&(B.refIndexes.includes(Number(D))||B.refIndexes.push(Number(D)),k.refIndexes.includes(Number(A))||k.refIndexes.push(Number(A))),m[A]=B,g[D]=k}}f=Object.values(m).map(function(e){return e}),s=Object.values(g).map(function(e){return e}),f.sort(function(e,n){return e.selfIndex<0&&n.selfIndex>=0?1:e.selfIndex>=0&&n.selfIndex<0?-1:e.selfIndex-n.selfIndex}),s.sort(function(e,n){return e.selfIndex<0&&n.selfIndex>=0?1:e.selfIndex>=0&&n.selfIndex<0?-1:e.selfIndex-n.selfIndex})}else p.next&&Object.values(p.next).forEach(function(e){var t=n[e];t&&!1!==t.display_node&&(s.push(x(e,"0")||{id:e,title:"",content:"",subsections:[]}),f.push(x(e,"1")||{id:e,title:"",content:"",subsections:[]}))});return{activeProposed:{title:(null===(a=null===(c=p.comparison_inputs)||void 0===c?void 0:c[v[0]])||void 0===a?void 0:a.title)||"Uploaded Contract",description:p.decision_scope_description||"",sections:s},activeVariants:[{id:"tree-variant-1",title:(null===(u=null===(d=p.comparison_inputs)||void 0===d?void 0:d[v[1]])||void 0===u?void 0:u.title)||"Reference Template",similarity:0,sections:f,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:p.decision_scope_description||""},fields:{}}}}]}}(U,te);return e(e({},n),{parseError:null})}catch(e){return console.error("Data Transformation Error: ",e),{activeProposed:{},activeVariants:[],parseError:e instanceof Error?e.message:"Unknown Parsing Error"}}return{activeProposed:{},activeVariants:[],parseError:"Tree data is required"}},[U,te]),Oe=Ne.activeProposed,Pe=Ne.activeVariants,qe=Ne.parseError;c(function(){qe&&le("Failed to load comparison: ".concat(qe))},[qe]);var Xe=r(null),Ye=Xe[0];Xe[1];var Ve=r({}),Ue=Ve[0],Ke=Ve[1],Ge=r({}),Je=Ge[0],Qe=Ge[1],Ze=(null==Pe?void 0:Pe[0])||z,$e=null===(j=null===(M=null==U?void 0:U.documents)||void 0===M?void 0:M[null===(L=null==U?void 0:U.input_index_map)||void 0===L?void 0:L[0]])||void 0===j?void 0:j.title,en=null===(P=null===(N=null==U?void 0:U.documents)||void 0===N?void 0:N[null===(O=null==U?void 0:U.input_index_map)||void 0===O?void 0:O[1]])||void 0===P?void 0:P.title,nn=I(G||$e||"Uploaded Contract"),tn=I(J||en||"Reference Template"),rn=l(function(){return(null==Oe?void 0:Oe.sections)||[]},[null==Oe?void 0:Oe.sections]),on=l(function(){return Ze.sections||[]},[Ze.sections]),ln=rn.length>0||on.length>0,cn=Ze.analysis,an=I(null===(X=null===(q=null==cn?void 0:cn.rule_difference_comparison)||void 0===q?void 0:q.summary)||void 0===X?void 0:X.overall_summary),dn=!!an.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),un=o({}),sn=function(e){return un.current[e]||(un.current[e]=i.createRef()),un.current[e]},fn=a(function(){de(!1),En(null),fe(!1),Be.current&&(Be.current.style.height="0px"),ke.current&&(ke.current.style.height="0px")},[]),hn=a(function(e,n,t,i,r){var o,l,c=I(n.id)||I(t.id)||"",a=(c?ve[c]:null)||n.cognitiveData||t.cognitiveData||{section_id:c,decisioning:[],gap:[],relevance_score:0},d=null!==(l=null===(o=un.current[i])||void 0===o?void 0:o.current)&&void 0!==l?l:null;return{open:!0,sectionTitle:n.title||"N/A",refSectionTitle:t.title||"NA",cognitiveData:a,anchorEl:e,sectionAnchorEl:d,badgeStyle:r||null,sectionIdx:i,docData:{documents:null==U?void 0:U.documents,input_index_map:null==U?void 0:U.input_index_map}}},[ve]),vn=a(function(e){Me(),ge(null),Se(e)},[Me]),pn=a(function(){null!==Re.sectionIdx&&Re.anchorEl?vn(e(e({},Re),{open:!0})):Me()},[Re,Me,vn]);a(function(e){Me(),le("".concat(e," is coming soon."))},[Me]);var xn=o(null),gn=o(null),mn=o(null),yn=r([]),bn=yn[0],wn=yn[1],Fn=r(null),In=Fn[0],En=Fn[1],Sn=o(null),Cn=r(null),Rn=Cn[0],_n=Cn[1],Tn=l(function(){return je.fields.filter(function(e){var n=e.key;return(!ln||"description"!==n)&&(E(null==Oe?void 0:Oe[n])||E(Ze[n]))})},[Oe,Ze,ln,je.fields]),Dn=o({}),An=o({}),Bn=o({}),kn=o({}),zn=o({}),Hn=o({}),Wn=o({});Tn.forEach(function(e){for(var n=e.key,t=0;t<Math.max(rn.length,on.length);t+=1)Bn.current[t]||(Bn.current[t]=i.createRef()),kn.current[t]||(kn.current[t]=i.createRef()),zn.current[t]||(zn.current[t]=i.createRef()),Hn.current[t]||(Hn.current[t]=i.createRef()),Wn.current[t]||(Wn.current[t]=i.createRef());Dn.current[n]||(Dn.current[n]=i.createRef()),An.current[n]||(An.current[n]=i.createRef())});for(var Mn=0;Mn<Math.max(rn.length,on.length);Mn+=1)Bn.current[Mn]||(Bn.current[Mn]=i.createRef()),kn.current[Mn]||(kn.current[Mn]=i.createRef()),zn.current[Mn]||(zn.current[Mn]=i.createRef()),Hn.current[Mn]||(Hn.current[Mn]=i.createRef()),Wn.current[Mn]||(Wn.current[Mn]=i.createRef());c(function(){if(Ye){var e=je.fields.find(function(e){return e.analysisKey===Ye||e.key===Ye});if(e){var n=Dn.current[e.key]||An.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[Ye,je.fields]);var Ln=a(function(e){var n,t,i,r,o,l,c,a,d,u=null===(n=null==cn?void 0:cn.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!u||!u[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var s=u[e],f=(null==s?void 0:s.relation)||(null===(i=null===(t=null==s?void 0:s.highlights)||void 0===t?void 0:t.ruleA_spans)||void 0===i?void 0:i.length)||(null===(o=null===(r=null==s?void 0:s.highlights)||void 0===r?void 0:r.ruleB_spans)||void 0===o?void 0:o.length)||(null==s?void 0:s.mappings)&&s.mappings.length>0;if(s.mappings){var h=s.mappings[0]||{};return{score:s.score,relation:h.relation||"",highlightsA:(null===(l=h.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(c=h.highlights)||void 0===c?void 0:c.ruleB_spans)||[],hasContent:!!f}}return{score:s.score,relation:s.relation||"",highlightsA:(null===(a=s.highlights)||void 0===a?void 0:a.ruleA_spans)||[],highlightsB:(null===(d=s.highlights)||void 0===d?void 0:d.ruleB_spans)||[],hasContent:!!f}},[cn]),jn=a(function(n){var t,i,r,o,l=rn[n],c=on[n],a=(null==l?void 0:l.relation)&&"not_defined"!==l.relation,d=(null==c?void 0:c.relation)&&"not_defined"!==c.relation,u=I(null==l?void 0:l.id)||I(null==c?void 0:c.id)||"",s=!(!(null==l?void 0:l.cognitiveData)&&!(null==c?void 0:c.cognitiveData));if(!a&&!d&&!s)return e(e({},je.relationStyles.noContent),{label:"Not Defined"});var f=Ln("description");if(null!=(null!==(i=null!==(t=null==l?void 0:l.cognitiveRelevanceScore)&&void 0!==t?t:null==c?void 0:c.cognitiveRelevanceScore)&&void 0!==i?i:u?null===(r=ve[u])||void 0===r?void 0:r.relevance_score:void 0)){var h=_(),v=h.score,p=h.relation;return S(v,p,!0,je)}var x=a?l.relation:d?c.relation:f.relation,g=null!==(o=null==l?void 0:l.score)&&void 0!==o?o:null==c?void 0:c.score,m="number"==typeof g?g:f.score;return S(m,x,!0,je)},[rn,on,ve,je,Ln]),Nn=a(function(){var e,n,t,i,r,o,l,c,a,d,u;if(!ze.current){ze.current=!0;try{if(!xn.current)return;var s=xn.current.getBoundingClientRect();we({width:s.width,height:s.height});var f=[];if(Tn.forEach(function(e){var n,t,i=e.key,r=null===(n=Dn.current[i])||void 0===n?void 0:n.current,o=null===(t=An.current[i])||void 0===t?void 0:t.current;r&&o&&(r.style.height="auto",o.style.height="auto",r.style.minHeight="0px",o.style.minHeight="0px")}),!te)for(var h=0;h<Math.min(rn.length,on.length);h++){var v=null===(e=Bn.current[h])||void 0===e?void 0:e.current,p=null===(n=kn.current[h])||void 0===n?void 0:n.current;v&&p&&(v.style.height="auto",p.style.height="auto",v.style.minHeight="0px",p.style.minHeight="0px")}var x={};Tn.forEach(function(e){var n,t,i=e.key,r=null===(n=Dn.current[i])||void 0===n?void 0:n.current,o=null===(t=An.current[i])||void 0===t?void 0:t.current;if(r&&o){var l=r.getBoundingClientRect(),c=o.getBoundingClientRect();x[i]=Math.max(l.height,c.height)}});var g=[];if(!te)for(h=0;h<Math.min(rn.length,on.length);h++){v=null===(t=Bn.current[h])||void 0===t?void 0:t.current,p=null===(i=kn.current[h])||void 0===i?void 0:i.current;if(v&&p){var m=v.getBoundingClientRect(),y=p.getBoundingClientRect();g[h]=Math.max(m.height,y.height)}}if(Tn.forEach(function(e){var n,t,i=e.key,r=null===(n=Dn.current[i])||void 0===n?void 0:n.current,o=null===(t=An.current[i])||void 0===t?void 0:t.current;if(r&&o){var l=x[i];r.style.minHeight="".concat(l,"px"),o.style.minHeight="".concat(l,"px")}}),!te)for(h=0;h<g.length;h++){v=null===(r=Bn.current[h])||void 0===r?void 0:r.current,p=null===(o=kn.current[h])||void 0===o?void 0:o.current;if(v&&p){var b=g[h];v.style.minHeight="".concat(b,"px"),p.style.minHeight="".concat(b,"px")}}if(Tn.forEach(function(e){var n,t,i=e.key,r=e.analysisKey,o=null===(n=Dn.current[i])||void 0===n?void 0:n.current,l=null===(t=An.current[i])||void 0===t?void 0:t.current;if(o&&l){var c=o.getBoundingClientRect(),a=l.getBoundingClientRect(),d=Ln(r),u=S(d.score,d.relation,d.hasContent,je);if(!u)return;var h=c.top+c.height/2-s.top;f.push({id:"field-".concat(i),x1:c.right-s.left,y1:h,x2:a.left-s.left,y2:h,style:u})}}),te)rn.forEach(function(e,n){var t;(null===(t=Bn.current[n])||void 0===t?void 0:t.current)&&(e.refIndexes||[]).forEach(function(e){var t,i,r=on.findIndex(function(n){return n.selfIndex===e});if(-1!==r){var o=null===(t=zn.current[n])||void 0===t?void 0:t.current,l=null===(i=Hn.current[r])||void 0===i?void 0:i.current;if(o&&l){var c=o.getBoundingClientRect(),a=l.getBoundingClientRect(),d=c.right-s.left,u=a.left-s.left,h=c.top+c.height/2-s.top,v=a.top+a.height/2-s.top;ae&&In===n&&(v=h);var p=jn(n);p&&f.push({id:"line-".concat(n,"-").concat(r),x1:d,y1:h,x2:u,y2:v,style:p,sectionIdx:n,targetRightIdx:r})}}})});else for(h=0;h<Math.min(rn.length,on.length);h++){var w=null===(l=Bn.current[h])||void 0===l?void 0:l.current,F=null===(c=kn.current[h])||void 0===c?void 0:c.current;if(w&&F){var I=w.querySelector(".MuiAccordionSummary-root"),E=F.querySelector(".MuiAccordionSummary-root");if(I&&E){var C=I.getBoundingClientRect(),R=E.getBoundingClientRect(),_=(C.top+C.height/2-s.top+R.top+R.height/2-s.top)/2,T=(null===(a=on[h])||void 0===a?void 0:a.id)||"sec-".concat(h),D=jn(h);D&&f.push({id:T,x1:C.right-s.left,y1:_,x2:R.left-s.left,y2:_,style:D,sectionIdx:h,hasCognitive:!!((null===(d=rn[h])||void 0===d?void 0:d.cognitiveData)||(null===(u=on[h])||void 0===u?void 0:u.cognitiveData)||T&&ve[T])})}}}if(wn(f),gn.current&&mn.current){var A=gn.current.getBoundingClientRect(),B=mn.current.getBoundingClientRect(),k=(A.top+A.height/2-s.top+B.top+B.height/2-s.top)/2;_n({x1:A.right-s.left,x2:B.left-s.left,y:k})}else _n(null)}catch(e){console.error("Line render safe fail: ",e)}finally{ze.current=!1}}},[Tn,rn,on,ve,je,Ln,jn,te,ae,In]),On=o(Nn);c(function(){On.current=Nn},[Nn]);var Pn=a(function(){null!==Sn.current&&window.cancelAnimationFrame(Sn.current),Sn.current=window.requestAnimationFrame(function(){On.current(),Sn.current=null})},[]),qn=a(function(){var e=Re.sectionIdx;Me(),null!==e&&(ae&&In===e?fn():(he.current=!0,En(e),de(!0),fe(!1),Be.current&&(Be.current.style.height="0px"),ke.current&&(ke.current.style.height="0px"),requestAnimationFrame(function(){var n,t,i=null===(n=un.current[e])||void 0===n?void 0:n.current,r=rn[e],o=(null==r?void 0:r.refIndexes)||[],l=null;if(o.length>0){var c=o[0],a=on.findIndex(function(e){return e.selfIndex===c});l=null===(t=Wn.current[a])||void 0===t?void 0:t.current}var d=null==i?void 0:i.parentElement,u=Ae.current;if(i&&d){var s=i.offsetTop-d.scrollTop,f=null;if(l&&u){var h=l.offsetTop-s;if(h<0)Be.current&&(Be.current.style.height="".concat(Math.abs(h),"px")),f=0;else{var v=u.scrollHeight-u.clientHeight;h>v?(ke.current&&(ke.current.style.height="".concat(h-v+150,"px")),f=h):f=h}}u&&null!==f?function(e,n,t,i){void 0===t&&(t=300);var r=e.style.scrollBehavior;e.style.scrollBehavior="auto";var o=e.scrollTop,l=n-o,c=null,a=function(d){null===c&&(c=d);var u,s=d-c;s<t?(e.scrollTop=(u=s,u/=t,l*(--u*u*u+1)+o),requestAnimationFrame(a)):(e.scrollTop=n,e.style.scrollBehavior=r,i&&i())};requestAnimationFrame(a)}(u,f,300,function(){fe(!0),Pn(),setTimeout(function(){he.current=!1},50)}):setTimeout(function(){fe(!0),Pn(),he.current=!1},350)}})))},[Me,Re.sectionIdx,ae,In,rn,on,Pn,fn]),Xn=a(function(){he.current||(Pn(),ae&&!he.current&&(de(!1),En(null),fe(!1),Be.current&&(Be.current.style.height="0px"),ke.current&&(ke.current.style.height="0px")))},[Pn,ae]);c(function(){var e=setTimeout(Pn,250);window.addEventListener("resize",Pn);var n=null,t=null;return Te.current&&(n=new ResizeObserver(Pn)).observe(Te.current),xn.current&&(t=new ResizeObserver(Pn)).observe(xn.current),function(){clearTimeout(e),window.removeEventListener("resize",Pn),null==n||n.disconnect(),null==t||t.disconnect()}},[Oe,Ze,cn,Tn,Ue,Je,rn,on,je,Pn,ae,In,se]);var Yn=function(r,o,l,c,a){void 0===a&&(a=1);var u,s=te?!!Ue["".concat(l,"-").concat(o)]:!!Ue[String(o)],h=E(r.title),v=E(r.content),b=!h&&!v,w=r.title;return h||(w=v?"No Title Found":"No Matching Section Found"),t(d,e({ref:c,sx:e(e({mb:a},te?{height:"fit-content"}:{minHeight:0}),{display:"flex",flexDirection:"column",position:"relative"})},{children:n(x,e({disableGutters:!0,expanded:!b&&s,onChange:function(){return!b&&function(n,t){Ke(function(i){var r=e({},i);if(!te){var o=!!i[String(n)];return r[String(n)]=!o,r}var l="".concat(t,"-").concat(n),c=!i[l];if(r[l]=c,"left"===t)((null==(a=rn[n])?void 0:a.refIndexes)||[]).forEach(function(e){var n=on.findIndex(function(n){return n.selfIndex===e});-1!==n&&(r["right-".concat(n)]=c)});else{var a,d=null==(a=on[n])?void 0:a.selfIndex;rn.forEach(function(e,n){var t;(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(d))&&(r["left-".concat(n)]=c)})}return r})}(o,l)},sx:{boxShadow:"none",border:b?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:b?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flex:1,display:"flex",flexDirection:"column","&:before":{display:"none"}}},{children:[t(g,e({expandIcon:b?null:t(y,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:b?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"flex",alignItems:"center",overflow:"hidden"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:t(p,e({title:w,placement:"top"},{children:t(f,e({sx:{fontSize:"12px",color:b?"#94A3B8":"#19213D",fontWeight:b?400:700,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:(u=w,u?I(u).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(e,n){return e.startsWith("**")&&e.endsWith("**")?t("strong",{children:e.slice(2,-2)},n):t(i.Fragment,{children:e},n)}):null)}))}))})),!b&&n(m,e({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column"}},{children:[t(f,e({component:"div",sx:Fe},{children:t(F,{children:I(r.content).replace(/\\n/g,"\n")})})),(r.subsections||[]).map(function(e,n){return Vn(e,"".concat(o,"-").concat(n),0)})]}))]}))}),"".concat(l,"-sec-").concat(o))},Vn=function(i,r,o){void 0===o&&(o=0);var l=E(i.title),c=E(i.content),a=!l&&!c,u=l?i.title:c?"No Title Found":"No Matching Section Found",s=!!Je[r];return i.title?n(x,e({disableGutters:!0,expanded:!a&&s,onChange:function(){return!a&&Qe(function(n){var t;return e(e({},n),((t={})[r]=!n[r],t))})},sx:{mt:1,boxShadow:"none",border:a?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF","&:before":{display:"none"}}},{children:[t(g,e({expandIcon:a?null:t(y,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5}}},{children:t(f,e({sx:{fontSize:"11px",fontWeight:600,color:a?"#94A3B8":"#19213D"}},{children:u||"Untitled Subsection"}))})),!a&&n(m,e({sx:{pt:0,pb:1}},{children:[c&&t(f,e({component:"div",sx:Fe},{children:t(F,{children:I(i.content).replace(/\\n/g,"\n")})})),(i.subsections||[]).map(function(e,n){return Vn(e,"".concat(r,"-").concat(n),o+1)})]}))]}),r):t(d,e({sx:{mt:0===o?1:.75}},{children:!a&&n("div",{children:[c&&t(f,e({component:"div",sx:Fe},{children:t(F,{children:I(i.content).replace(/\\n/g,"\n")})})),(i.subsections||[]).map(function(e,n){return Vn(e,"".concat(r,"-").concat(n),o+1)})]})}),r)};return n(d,e({ref:De,sx:e(e({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},te?{}:{overflow:"visible"}),{position:"relative"})},{children:[te&&t(k,{open:Re.open,anchorEl:Re.anchorEl,sectionTitle:Re.sectionTitle,referenceSectionTitle:Re.refSectionTitle,onClose:Me,onOpenCognitiveCompare:pn,onOpenSideBySide:qn}),Ee.open&&t(B,{open:Ee.open,popupRef:me,position:xe,popupConfig:ee,onClose:function(){ge(null),Se(function(n){return e(e({},n),{open:!1})})},markdownStyles:Q,sectionTitle:Ee.sectionTitle,referenceSectionTitle:Ee.refSectionTitle,cognitiveData:Ee.cognitiveData,anchorEl:Ee.anchorEl,sectionAnchorEl:Ee.sectionAnchorEl,scrollContainerEl:Te.current,badgeStyle:Ee.badgeStyle,docData:Ee.docData}),t(u,e({open:!!oe,autoHideDuration:8e3,onClose:function(){return le(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:t(s,e({onClose:function(){return le(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:oe}))})),n(d,e({sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between",bgcolor:"#FFFFFF",border:"1.5px solid #EEF0F4",borderTopLeftRadius:"8px",borderTopRightRadius:"8px"}},{children:[t(d,e({sx:{display:"flex",alignItems:"center",gap:1}},{children:t(f,e({sx:{fontSize:"16px",fontWeight:600,color:"#0F172A"}},{children:V}))})),t(d,e({sx:{display:"flex",alignItems:"center"}},{children:t(h,{control:t(v,{checked:te,onChange:function(e){return ie(e.target.checked)},color:"primary",size:"small"}),label:t(f,e({sx:{fontSize:"13px",fontWeight:500,color:"#64748B"}},{children:"Relative Order"})),labelPlacement:"start",sx:{m:0,gap:1}})}))]})),t(d,e({ref:Te,onScroll:Xn,sx:{flex:1,minHeight:0,pt:1.5,pb:8,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:te?"hidden":"auto",borderTop:an&&dn?"none":"1.5px solid #EEF0F4"}},{children:t(d,e({sx:e({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},te?{flex:1,minHeight:0}:{})},{children:n(d,e({ref:xn,sx:e({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},te?{flex:1,overflow:"visible"}:{})},{children:[n("svg",e({style:{position:"absolute",top:0,left:0,width:be.width||"100%",height:be.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible"}},{children:[Rn&&n("g",{children:[t("line",{x1:Rn.x1,y1:Rn.y,x2:Math.max(Rn.x1,(Rn.x1+Rn.x2)/2-70),y2:Rn.y,stroke:"#BBF7D0",strokeWidth:"1.5"}),t("line",{x1:Math.min(Rn.x2,(Rn.x1+Rn.x2)/2+70),y1:Rn.y,x2:Rn.x2,y2:Rn.y,stroke:"#BBF7D0",strokeWidth:"1.5"})]}),bn.map(function(i){var r,o=(i.x1+i.x2)/2;if("Not Defined"===i.style.label&&!i.hasCognitive)return null;if(!te)return n("g",{children:[t("line",{x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,stroke:i.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),t("foreignObject",e({x:o-100,y:i.y1-14,width:"200",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:t(d,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:n(d,e({onClick:function(e){var n=rn[i.sectionIdx]||{title:"",content:""},t=on[i.sectionIdx]||{title:"",content:""};vn(hn(e.currentTarget,n,t,i.sectionIdx,i.style))},sx:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:i.style.badgeBg,color:i.style.badgeText,border:"1px solid ".concat(i.style.badgeBorder),borderRadius:"12px",px:1.5,py:.5,fontWeight:500,textAlign:"center",whiteSpace:"nowrap",cursor:"pointer"}},{children:[i.style.label,t(d,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:t(w,{})})),t(y,{size:11})]}))}))}))]},i.id);var l=rn[i.sectionIdx];return!(null===(r=null==l?void 0:l.refIndexes)||void 0===r?void 0:r.length)||(null==l?void 0:l.selfIndex)<0?null:ae&&In===i.sectionIdx&&se?n("g",e({style:{transition:"opacity 0.2s"}},{children:[t("defs",{children:t("marker",e({id:"arr-".concat(i.id),markerWidth:"7",markerHeight:"5",refX:"7",refY:"2.5",orient:"auto"},{children:t("polygon",{points:"0 0, 7 2.5, 0 5",fill:i.style.badgeBorder||"#6366F1"})}))}),t("line",{x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,stroke:i.style.badgeBorder||"#6366F1",strokeWidth:"1.5",markerEnd:"url(#arr-".concat(i.id,")")})]}),i.id):null})]})),n(d,e({sx:e({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},te?{flex:1,overflow:"visible"}:{})},{children:[t(d,e({ref:gn,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",minHeight:"40px",alignItems:"center",overflowX:"hidden"}},{children:t(p,e({title:nn,placement:"top"},{children:t(f,e({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",height:"40px"}},{children:nn}))}))})),t(d,e({onScroll:Xn,sx:e({p:"12px",display:"flex",flexDirection:"column"},te?{maxHeight:"500px",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-160px",pr:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:ln&&rn.map(function(r,o){var l;if(!te)return t(d,e({ref:sn(o)},{children:Yn(r,o,"left",Bn.current[o])}),"left-row-".concat(o));var c=r,a=jn(o),u=!(null===(l=c.refIndexes)||void 0===l?void 0:l.length)||c.selfIndex<0,s="number"==typeof c.selfIndex&&c.selfIndex>=0?c.selfIndex+1:null;return t(d,e({ref:sn(o),sx:{mb:1}},{children:n(d,e({sx:{position:"relative",width:"100%"}},{children:[t(d,e({ref:Bn.current[o],sx:{width:"100%"}},{children:Yn(r,o,"left",i.createRef(),0)})),a&&n(d,e({ref:zn.current[o],onClick:function(e){var n=on.find(function(e){var n;return null===(n=c.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""};!function(e,n,t,i,r){e.stopPropagation(),Re.open&&Re.sectionIdx===i?Me():(We(),_e(hn(e.currentTarget,n,t,i,r)))}(e,r,n,o,a)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:a.badgeBg,color:a.badgeText,border:"1px solid ".concat(a.badgeBorder),borderRadius:"12px",px:1.2,py:.4,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[null!==s&&t(d,e({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(a.badgeBorder)}},{children:s})),t(d,e({component:"span",sx:{fontSize:"11px",px:.25}},{children:u?"No Deviation Found":0==a.deviationLabel||void 0===a.deviationLabel?"Same":"".concat(a.deviationLabel,"% Deviation")})),t(b,{size:11,color:a.badgeText})]}))]}))}),"left-row-".concat(o))})}))]})),t(d,e({sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"6px",gap:0}},{children:t(d,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:n(d,e({sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",borderRadius:"20px",bgcolor:"#ECFDF3",border:"1px solid #A7F3D0",color:"#15803D",fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1}},{children:[t(d,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:t(w,{})})),0,"% Similarity",t(y,{size:11})]}))}))})),n(d,e({sx:e({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},te?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[t(d,e({ref:mn,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"40px",display:"flex",alignItems:"center",overflowX:"hidden"}},{children:t(p,e({title:tn,placement:"top"},{children:t(f,e({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",height:"40px"}},{children:tn}))}))})),n(d,e({ref:Ae,onScroll:Xn,sx:e({p:"12px",display:"flex",flexDirection:"column"},te?{maxHeight:"500px",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-160px",pl:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[t("div",{ref:Be,style:{width:"100%",height:"0px",flexShrink:0}}),ln&&on.map(function(r,o){if(!te)return Yn(r,o,"right",kn.current[o]);var l=r,c=rn.filter(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(l.selfIndex))&&e.selfIndex>=0}).map(function(e){return e.selfIndex+1});return t(d,e({ref:Wn.current[o],sx:{mb:1}},{children:n(d,e({sx:{position:"relative",width:"100%"}},{children:[t(d,e({ref:kn.current[o],sx:{width:"100%"}},{children:Yn(r,o,"right",i.createRef(),0)})),t(d,e({ref:Hn.current[o],sx:{position:"absolute",top:"18px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"11px",bgcolor:"#EEF2FF",color:"#3730A3",border:"1px solid #C7D2FE",borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:c.length>0?c.join(", "):"-"}))]}))}),"right-row-".concat(o))}),t("div",{ref:ke,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))};export{W as default};
2
2
  //# sourceMappingURL=CognitiveCompare.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CommonConstants.d.ts","sourceRoot":"","sources":["../../../../src/CommonConstants/CommonConstants.tsx"],"names":[],"mappings":"AACA,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,OAAO,CAAC;AAC5C,eAAO,MAAM,OAAO,EAAE,aAAqB,CAAC;AAC5C,eAAO,MAAM,SAAS,EAAE,aAAuB,CAAC;AAChD,eAAO,MAAM,6BAA6B,yCAAwC,CAAA;AAElF,eAAO,MAAM,iBAAiB,EAAE,GAutN/B,CAAA"}
1
+ {"version":3,"file":"CommonConstants.d.ts","sourceRoot":"","sources":["../../../../src/CommonConstants/CommonConstants.tsx"],"names":[],"mappings":"AACA,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,OAAO,CAAC;AAC5C,eAAO,MAAM,OAAO,EAAE,aAAqB,CAAC;AAC5C,eAAO,MAAM,SAAS,EAAE,aAAuB,CAAC;AAChD,eAAO,MAAM,6BAA6B,yCAAwC,CAAA;AAElF,eAAO,MAAM,iBAAiB,EAAE,GAyxG/B,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"CognitiveCompare.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitiveCompare.tsx"],"names":[],"mappings":"AA+BA,OAAO,EAIL,qBAAqB,EAMtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAGL,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AA4PlC,QAAA,MAAM,gBAAgB,sLASnB,qBAAqB,4CAy1DvB,CAAC;AACF,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAClC,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"CognitiveCompare.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitiveCompare.tsx"],"names":[],"mappings":"AA+BA,OAAO,EAIL,qBAAqB,EAMtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAGL,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AA4PlC,QAAA,MAAM,gBAAgB,sLASnB,qBAAqB,4CA+0DvB,CAAC;AACF,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAClC,eAAe,gBAAgB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viswa-test/test-citation",
3
- "version": "0.0.24",
3
+ "version": "0.0.25",
4
4
  "author": "Viswa Koduru",
5
5
  "description": "",
6
6
  "license": "MIT",