@viswa-test/test-citation 0.0.38 → 0.0.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/features/CognitiveCompare/CitationAnchor.js +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
- package/dist/cjs/features/CognitiveCompare/MoreFunctionsPopup.js +1 -1
- package/dist/cjs/features/PdfViewer/PdfViewer.js +1 -1
- package/dist/cjs/features/PdfViewer/usePdfHighlight.js +1 -1
- package/dist/features/CognitiveCompare/CitationAnchor.js +1 -1
- package/dist/features/CognitiveCompare/CognitiveCompare.js +1 -1
- package/dist/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
- package/dist/features/CognitiveCompare/MoreFunctionsPopup.js +1 -1
- package/dist/features/PdfViewer/PdfViewer.js +1 -1
- package/dist/features/PdfViewer/usePdfHighlight.js +1 -1
- package/dist/types/src/CommonConstants/CommonConstants.d.ts +1147 -1264
- package/dist/types/src/CommonConstants/CommonConstants.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/CitationAnchor.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveComparehelpers.d.ts +0 -6
- package/dist/types/src/features/CognitiveCompare/CognitiveComparehelpers.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/MoreFunctionsPopup.d.ts +1 -0
- package/dist/types/src/features/CognitiveCompare/MoreFunctionsPopup.d.ts.map +1 -1
- package/dist/types/src/features/PdfViewer/PdfViewer.d.ts +3 -1
- package/dist/types/src/features/PdfViewer/PdfViewer.d.ts.map +1 -1
- package/dist/types/src/features/PdfViewer/usePdfHighlight.d.ts +1 -1
- package/dist/types/src/features/PdfViewer/usePdfHighlight.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as e,__spreadArray as n}from"tslib";import{jsx as t,jsxs as i}from"react/jsx-runtime";import r,{useMemo as o,useState as l,useRef as c,useEffect as a,useCallback as u}from"react";import{Typography as d,Box as s,Snackbar as v,Alert as f,FormControlLabel as p,Switch as h,Tooltip as g,Accordion as x,AccordionSummary as m,AccordionDetails as b}from"@mui/material";import{ChevronDown as y,EllipsisVertical as S}from"lucide-react";import{ButtonCognitiveIcon as I}from"../../assests/svg/ButtonCognitiveIcon.js";import w from"./OverlayComponent.js";import R from"react-markdown";import{safeStringify as F,hasValue as C,getStyleForRelation as E,cognitiveScoreToRelation as B,getSideData as T,getRationale as _}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as k,DEFAULT_FIELD_CONFIG as D,DEFAULT_COMPARISON_CONFIG as M}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import A from"./CognitivePopup.js";import H from"./MoreFunctionsPopup.js";import z from"./LoaderComponent.js";import W from"rehype-raw";var N=r.memo(function(n){var i=n.content,r=n.sxStyles,l=n.highlights,c=void 0===l?[]:l,a=o(function(){return{mark:function(n){var i=n.children;return t("span",e({style:{backgroundColor:"#fccccc"}},{children:i}))}}},[]),u=o(function(){var e=i;return c.forEach(function(n){e=e.replaceAll(n,"<mark>".concat(n,"</mark>"))}),e},[i,c]);return t(d,e({component:"div",sx:r},{children:t(R,e({components:a,rehypePlugins:[W]},{children:F(u).replace(/\\n/g,"\n")}))}))},function(e,n){if(e.content!==n.content)return!1;if(e.sxStyles!==n.sxStyles)return!1;var t=e.highlights||[],i=n.highlights||[];if(t.length!==i.length)return!1;for(var r=0;r<t.length;r++)if(t[r]!==i[r])return!1;return!0}),L=function(e,n,t,i,r){void 0===r&&(r=14);var o=e+.65*(t-e),l=i-n;if(Math.abs(l)<3)return"M ".concat(e," ").concat(n," H ").concat(t);var c=l>0?1:-1,a=Math.min(r,Math.abs(l)/2,Math.abs(o-e)/2,Math.abs(t-o)/2);return["M ".concat(e," ").concat(n),"H ".concat(o-a),"Q ".concat(o," ").concat(n," ").concat(o," ").concat(n+c*a),"V ".concat(i-c*a),"Q ".concat(o," ").concat(i," ").concat(o+a," ").concat(i),"H ".concat(t)].join(" ")},O={id:"",title:""},j={open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,isOrphan:!1,docData:null,deviationData:null},P=function(e,n,t,i,r){void 0===t&&(t=300);var o=e.style.scrollBehavior;e.style.scrollBehavior="auto";var l=e.scrollTop,c=n-l,a=null,u=function(d){null===a&&(a=d);var s,v=d-a;v<t?(e.scrollTop=(s=v,s/=t,c*(--s*s*s+1)+l),r&&r(),requestAnimationFrame(u)):(e.scrollTop=n,e.style.scrollBehavior=o,r&&r(),i&&i())};requestAnimationFrame(u)},Y=function(R){var W,Y,K,V,X,q,U,G,J=R.componentHeaderText,Q=void 0===J?"Contract Comparison":J,Z=R.treeData,$=R.comparisonConfig,ee=R.leftColumnTitleText,ne=R.rightColumnTitleText,te=R.markdownStyles,ie=R.displayConfig,re=void 0===ie?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1}:ie,oe=R.popupConfig,le=R.deviationData,ce=void 0===le?{}:le,ae=l(re.maintainRelativeOrder),ue=ae[0],de=ae[1],se=l(!1),ve=se[0],fe=se[1],pe=l(!1),he=pe[0],ge=pe[1],xe=l(null),me=xe[0],be=xe[1],ye=l(!1),Se=ye[0],Ie=ye[1],we=l(!1),Re=we[0],Fe=we[1],Ce=c(!1),Ee=l(null),Be=Ee[0],Te=Ee[1],_e=l(new Set),ke=_e[0],De=_e[1],Me=l([]),Ae=Me[0],He=Me[1],ze=c(null),We=c(!1),Ne=c(null),Le=c({}),Oe=c([]),je=c(!1),Pe=c(!1),Ye=c(null),Ke=o(function(){return(null==Z?void 0:Z.cognitive_decisioning)||{}},[Z]),Ve=l(null),Xe=Ve[0],qe=Ve[1],Ue=c(null),Ge=l({width:0,height:0}),Je=Ge[0],Qe=Ge[1],Ze=o(function(){return e(e({},k),te)},[te]),$e=l({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,isOrphan:!1,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null,deviationData:null}),en=$e[0],nn=$e[1],tn=l({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,isOrphan:!1,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null,deviationData:null}),rn=tn[0],on=tn[1],ln=c(null),cn=c(null),an=c(null),un=c(null),dn=c(null),sn=c(null),vn=c(null),fn=c(null),pn=c(!1),hn=c(null);a(function(){hn.current=null},[en.sectionIdx,en.open]);var gn=u(function(){qe(null),nn(j),Te(null)},[]),xn=u(function(){on(j)},[]),mn=u(function(){var e;if(en.anchorEl&&en.refSectionTitle){var n=en.anchorEl.getBoundingClientRect(),t=(null===(e=null==Ue?void 0:Ue.current)||void 0===e?void 0:e.offsetHeight)||0,i=Math.min(680,window.innerWidth-24),r=window.innerHeight-n.bottom-12-12,o=n.top-12-12,l=r<t&&o>r;null!==hn.current?!0===hn.current&&(l=o>=t||o>=r):l=!(r>=t||r>=o),hn.current=l;var c=l?o:r,a=Math.min(t||9999,c),u=l?n.top-12-a:n.bottom+12,d=n.left+n.width/2,s=d-i/2,v=Math.max(12,Math.min(s,window.innerWidth-i-12)),f=Math.max(14,Math.min(d-v,i-10-4));qe({top:u,left:v,arrowLeft:f,openAbove:l,maxHeight:c})}},[en.anchorEl,en.refSectionTitle]);a(function(){if(en.open){window.addEventListener("resize",mn);var e=requestAnimationFrame(mn),n=null;return Ue.current&&(n=new ResizeObserver(function(){cancelAnimationFrame(e),e=requestAnimationFrame(mn)})).observe(Ue.current),function(){cancelAnimationFrame(e),window.removeEventListener("resize",mn),n&&n.disconnect()}}},[en.open,mn]),a(function(){var e=ln.current;if(e&&en.open){var n=function(e){Ue.current&&Ue.current.contains(e.target)||(qe(null),gn())};return e.addEventListener("scroll",n,{capture:!0}),window.addEventListener("scroll",n,{capture:!0}),function(){e.removeEventListener("scroll",n,{capture:!0}),window.removeEventListener("scroll",n,{capture:!0})}}},[en.open,gn]),a(function(){var e=ln.current;if(e&&rn.open){var n=function(){xn()};return e.addEventListener("scroll",n,{capture:!0}),window.addEventListener("scroll",n,{capture:!0}),function(){e.removeEventListener("scroll",n,{capture:!0}),window.removeEventListener("scroll",n,{capture:!0})}}},[rn.open,xn]);var bn=o(function(){var n,t,i,r,o,l,c,a,u,d,s,v;return{fields:null!==(n=null==$?void 0:$.fields)&&void 0!==n?n:D,thresholds:{high:null!==(i=null===(t=null==$?void 0:$.thresholds)||void 0===t?void 0:t.high)&&void 0!==i?i:M.thresholds.high,medium:null!==(o=null===(r=null==$?void 0:$.thresholds)||void 0===r?void 0:r.medium)&&void 0!==o?o:M.thresholds.medium,exact:null!==(c=null===(l=null==$?void 0:$.thresholds)||void 0===l?void 0:l.exact)&&void 0!==c?c:M.thresholds.exact},relationStyles:{noContent:e(e({},M.relationStyles.noContent),(null===(a=null==$?void 0:$.relationStyles)||void 0===a?void 0:a.noContent)||{}),high:e(e({},M.relationStyles.high),(null===(u=null==$?void 0:$.relationStyles)||void 0===u?void 0:u.high)||{}),exact:e(e({},M.relationStyles.exact),(null===(d=null==$?void 0:$.relationStyles)||void 0===d?void 0:d.exact)||{}),medium:e(e({},M.relationStyles.medium),(null===(s=null==$?void 0:$.relationStyles)||void 0===s?void 0:s.medium)||{}),low:e(e({},M.relationStyles.low),(null===(v=null==$?void 0:$.relationStyles)||void 0===v?void 0:v.low)||{})}}},[$]),yn=o(function(){if(Z&&Object.keys(Z).length>0)try{var t=function(t,i,r){var o,l,c,a;void 0===i&&(i=!1),void 0===r&&(r=null);var u=t.nodes||t,d=[],s=[],v=t.base_root_id,f=t.input_index_map||{0:"left",1:"right"},p=t[v]||u[v];if(!p||!1===p.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[]};var h=function(n,i){var o,l=t[n]||u[n];if(!l||!1===l.display_node)return null;var c=T(l,i,f),a=!!c.title.trim(),d=!!c.content.trim(),s=_(l),v=(null===(o=null==r?void 0:r[n])||void 0===o?void 0:o.evaluation_result)||l.evaluation_result||null,p=[];l.next&&Object.values(l.next).forEach(function(e){var n=u[e];if(n&&!1!==n.display_node){var t=h(e,i);t&&p.push(t)}});var g=!(!a&&!d);return e(e({id:n,title:a?c.title:"",content:d?c.content:"",subsections:p},g?s:{score:void 0,relation:"not_defined"}),{evaluationResult:v})};if(i){var g=function(i,o){var l,c,a,d,s,v,p,h,x,m,b,y,S;void 0===o&&(o=0);var I=[],w=[];if(!i)return{refSections:I,baseSections:w};var R={},F={},C=-1,E=-1;for(var B in i){var k=i[B],D=t[k]||u[k];if(D&&!1!==D.display_node){var M=_(D),A=(null===(l=null==r?void 0:r[k])||void 0===l?void 0:l.evaluation_result)||D.evaluation_result||null,H=T(D,"1",f),z=T(D,"0",f),W=H.title.trim()||H.content.trim(),N=z.title.trim()||z.content.trim(),L=Number(null!==(a=null===(c=H.attributes)||void 0===c?void 0:c.display_index)&&void 0!==a?a:C--),O=Number(null!==(s=null===(d=z.attributes)||void 0===d?void 0:d.display_index)&&void 0!==s?s:E--),j=R[L]||e(e({id:k,title:W?H.title:"",content:W?H.content:"",subsections:[]},W?M:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:L,evaluationResult:A,displayContent:null===(v=H.attributes)||void 0===v?void 0:v.display_content,displayTitle:null===(p=H.attributes)||void 0===p?void 0:p.display_title}),P=F[O]||e(e({id:k,title:N?z.title:"",content:N?z.content:"",subsections:[]},N?M:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:O,evaluationResult:A,displayContent:null===(h=z.attributes)||void 0===h?void 0:h.display_content,displayTitle:null===(x=z.attributes)||void 0===x?void 0:x.display_title});Number(L)>=0&&Number(O)>=0&&((null===(m=j.refIndexes)||void 0===m?void 0:m.includes(Number(O)))||null===(b=j.refIndexes)||void 0===b||b.push(Number(O)),(null===(y=P.refIndexes)||void 0===y?void 0:y.includes(Number(L)))||null===(S=P.refIndexes)||void 0===S||S.push(Number(L))),R[L]=j,F[O]=P;var Y=g(D.next,o+1),K=Y.refSections,V=Y.baseSections;K.length>0&&(j.subsections=n(n([],j.subsections||[],!0),K,!0)),V.length>0&&(P.subsections=n(n([],P.subsections||[],!0),V,!0))}}return I=Object.values(R).map(function(e){return e}),w=Object.values(F).map(function(e){return e}),I.sort(function(e,n){return e.selfIndex<0&&n.selfIndex>=0?1:e.selfIndex>=0&&n.selfIndex<0?-1:e.selfIndex-n.selfIndex}),w.sort(function(e,n){return e.selfIndex<0&&n.selfIndex>=0?1:e.selfIndex>=0&&n.selfIndex<0?-1:e.selfIndex-n.selfIndex}),{refSections:I,baseSections:w}},x=g(p.next),m=x.refSections,b=x.baseSections;s=m,d=b}else p.next&&Object.values(p.next).forEach(function(e){var n=t[e]||u[e];n&&!1!==n.display_node&&(d.push(h(e,"0")||{id:e,title:"",content:"",subsections:[]}),s.push(h(e,"1")||{id:e,title:"",content:"",subsections:[]}))});return{activeProposed:{title:(null===(l=null===(o=p.comparison_inputs)||void 0===o?void 0:o[f[0]])||void 0===l?void 0:l.title)||"Uploaded Contract",description:p.decision_scope_description||"",sections:d},activeVariants:[{id:"tree-variant-1",title:(null===(a=null===(c=p.comparison_inputs)||void 0===c?void 0:c[f[1]])||void 0===a?void 0:a.title)||"Reference Template",similarity:0,sections:s,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:p.decision_scope_description||""},fields:{}}}}]}}(Z,ue,ce);return e(e({},t),{parseError:null})}catch(e){return console.error("Data Transformation Error: ",e),{activeProposed:{},activeVariants:[],parseError:e instanceof Error?e.message:"Unknown Parsing Error"}}return{activeProposed:{},activeVariants:[],parseError:"Tree data is required"}},[JSON.stringify(Z),ue,JSON.stringify(ce)]),Sn=yn.activeProposed,In=yn.activeVariants,wn=yn.parseError;a(function(){wn&&be("Failed to load comparison: ".concat(wn))},[wn]);var Rn=l(null),Fn=Rn[0];Rn[1];var Cn=l({}),En=Cn[0],Bn=Cn[1],Tn=l({}),_n=Tn[0],kn=Tn[1],Dn=(null==In?void 0:In[0])||O,Mn=null===(K=null===(W=null==Z?void 0:Z.documents)||void 0===W?void 0:W[null===(Y=null==Z?void 0:Z.input_index_map)||void 0===Y?void 0:Y[0]])||void 0===K?void 0:K.title,An=null===(q=null===(V=null==Z?void 0:Z.documents)||void 0===V?void 0:V[null===(X=null==Z?void 0:Z.input_index_map)||void 0===X?void 0:X[1]])||void 0===q?void 0:q.title,Hn=F(ee||Mn||"Uploaded Contract"),zn=F(ne||An||"Reference Template"),Wn=o(function(){return(null==Sn?void 0:Sn.sections)||[]},[null==Sn?void 0:Sn.sections]),Nn=o(function(){return Dn.sections||[]},[Dn.sections]),Ln=Wn.length>0||Nn.length>0,On=Dn.analysis,jn=F(null===(G=null===(U=null==On?void 0:On.rule_difference_comparison)||void 0===U?void 0:U.summary)||void 0===G?void 0:G.overall_summary),Pn=!!jn.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),Yn=c({}),Kn=function(e){return Yn.current[e]||(Yn.current[e]=r.createRef()),Yn.current[e]},Vn=u(function(){Ie(!1),Pe.current=!1,ct(null),Ye.current=null,Zn.current=null,Fe(!1),ge(!1),un.current&&(un.current.style.height="0px"),dn.current&&(dn.current.style.height="0px"),sn.current&&(sn.current.style.height="0px"),vn.current&&(vn.current.style.height="0px")},[]),Xn=u(function(e,n,t,i,r,o){var l,c,a=F(n.id)||F(t.id)||"",u=(a?Ke[a]:null)||n.cognitiveData||t.cognitiveData||{section_id:a,decisioning:[],gap:[],relevance_score:0},d=null!==(c=null===(l=Yn.current[i])||void 0===l?void 0:l.current)&&void 0!==c?c:null;return{open:!0,sectionTitle:n.title||"N/A",refSectionTitle:t.title||"NA",cognitiveData:u,anchorEl:e,sectionAnchorEl:d,badgeStyle:o||null,sectionIdx:i,docData:{documents:null==Z?void 0:Z.documents,input_index_map:null==Z?void 0:Z.input_index_map},deviationData:n.evaluationResult||t.evaluationResult||null,isOrphan:!!r}},[Ke,Z]),qn=u(function(e){xn(),qe(null),nn(e)},[xn]),Un=function(e,n,t,i,r,o){e.stopPropagation(),rn.open&&rn.sectionIdx===r?xn():(gn(),on(Xn(e.currentTarget,n,i,r,t,o)))},Gn=u(function(){null!==rn.sectionIdx&&rn.anchorEl?qn(e(e({},rn),{open:!0})):xn()},[rn,xn,qn]);u(function(e){xn(),be("".concat(e," is coming soon."))},[xn]);var Jn=u(function(){var e=rn.sectionIdx,n=rn.isOrphan;if(xn(),null!==e){if(n)return be("No counterpart exists to connect to."),void xn();Pe.current&&Vn(),De(function(n){return n.has(e)?new Set:new Set([e])})}},[rn.sectionIdx,xn,Vn]),Qn=c(null),Zn=c(null),$n=c(null),et=c(null),nt=c(null),tt=l([]),it=tt[0],rt=tt[1],ot=l(null),lt=ot[0],ct=ot[1];c(null);var at=l(null),ut=at[0],dt=at[1],st=o(function(){return bn.fields.filter(function(e){var n=e.key;return(!Ln||"description"!==n)&&(C(null==Sn?void 0:Sn[n])||C(Dn[n]))})},[Sn,Dn,Ln,bn.fields]),vt=c({}),ft=c({}),pt=c({}),ht=c({}),gt=c({}),xt=c({}),mt=c({}),bt=c({}),yt=c({});st.forEach(function(e){for(var n=e.key,t=0;t<Math.max(Wn.length,Nn.length);t+=1)pt.current[t]||(pt.current[t]=r.createRef()),ht.current[t]||(ht.current[t]=r.createRef()),gt.current[t]||(gt.current[t]=r.createRef()),xt.current[t]||(xt.current[t]=r.createRef()),mt.current[t]||(mt.current[t]=r.createRef());vt.current[n]||(vt.current[n]=r.createRef()),ft.current[n]||(ft.current[n]=r.createRef())});for(var St=0;St<Math.max(Wn.length,Nn.length);St+=1)pt.current[St]||(pt.current[St]=r.createRef()),ht.current[St]||(ht.current[St]=r.createRef()),gt.current[St]||(gt.current[St]=r.createRef()),xt.current[St]||(xt.current[St]=r.createRef()),mt.current[St]||(mt.current[St]=r.createRef());a(function(){if(Fn){var e=bn.fields.find(function(e){return e.analysisKey===Fn||e.key===Fn});if(e){var n=vt.current[e.key]||ft.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[Fn,bn.fields]);var It=u(function(e){var n,t,i,r,o,l,c,a,u,d=null===(n=null==On?void 0:On.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!d||!d[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var s=d[e],v=(null==s?void 0:s.relation)||(null===(i=null===(t=null==s?void 0:s.highlights)||void 0===t?void 0:t.ruleA_spans)||void 0===i?void 0:i.length)||(null===(o=null===(r=null==s?void 0:s.highlights)||void 0===r?void 0:r.ruleB_spans)||void 0===o?void 0:o.length)||(null==s?void 0:s.mappings)&&s.mappings.length>0;if(s.mappings){var f=s.mappings[0]||{};return{score:s.score,relation:f.relation||"",highlightsA:(null===(l=f.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(c=f.highlights)||void 0===c?void 0:c.ruleB_spans)||[],hasContent:!!v}}return{score:s.score,relation:s.relation||"",highlightsA:(null===(a=s.highlights)||void 0===a?void 0:a.ruleA_spans)||[],highlightsB:(null===(u=s.highlights)||void 0===u?void 0:u.ruleB_spans)||[],hasContent:!!v}},[On]),wt=u(function(n){var t,i,r,o,l=Wn[n],c=Nn[n],a=(null==l?void 0:l.relation)&&"not_defined"!==l.relation,u=(null==c?void 0:c.relation)&&"not_defined"!==c.relation,d=F(null==l?void 0:l.id)||F(null==c?void 0:c.id)||"",s=!(!(null==l?void 0:l.cognitiveData)&&!(null==c?void 0:c.cognitiveData));if(!a&&!u&&!s)return e(e({},bn.relationStyles.noContent),{label:"Not Defined"});var v=It("description");if(null!=(null!==(i=null!==(t=null==l?void 0:l.cognitiveRelevanceScore)&&void 0!==t?t:null==c?void 0:c.cognitiveRelevanceScore)&&void 0!==i?i:d?null===(r=Ke[d])||void 0===r?void 0:r.relevance_score:void 0)){var f=B(),p=f.score,h=f.relation;return E(p,h,!0,bn)}var g=a?l.relation:u?c.relation:v.relation,x=null!==(o=null==l?void 0:l.score)&&void 0!==o?o:null==c?void 0:c.score,m="number"==typeof x?x:v.score;return E(m,g,!0,bn)},[Wn,Nn,Ke,bn,It]),Rt=u(function(n){for(var t,i,r,o,l=n.split("-").map(Number),c=Wn[l[0]],a=Nn[l[0]],u=1;u<l.length;u++)(null==c?void 0:c.subsections)&&(c=c.subsections[l[u]]),(null==a?void 0:a.subsections)&&(a=a.subsections[l[u]]);if(!c&&!a)return null;var d=(null==c?void 0:c.relation)&&"not_defined"!==c.relation,s=(null==a?void 0:a.relation)&&"not_defined"!==a.relation,v=F(null==c?void 0:c.id)||F(null==a?void 0:a.id)||"",f=!(!(null==c?void 0:c.cognitiveData)&&!(null==a?void 0:a.cognitiveData));if(!d&&!s&&!f)return e(e({},bn.relationStyles.noContent),{label:"Not Defined"});if(null!=(null!==(i=null!==(t=null==c?void 0:c.cognitiveRelevanceScore)&&void 0!==t?t:null==a?void 0:a.cognitiveRelevanceScore)&&void 0!==i?i:v?null===(r=Ke[v])||void 0===r?void 0:r.relevance_score:void 0)){var p=B(),h=p.score,g=p.relation;return E(h,g,!0,bn)}var x=d?c.relation:s?a.relation:"not_defined",m=null!==(o=null==c?void 0:c.score)&&void 0!==o?o:null==a?void 0:a.score;return E("number"==typeof m?m:0,x,!0,bn)},[Wn,Nn,Ke,bn]),Ft=u(function(){var e,n,t,i,r,o,l,c,a,u,d,s,v,f,p,h,g,x,m,b,y,S;if(!pn.current&&!We.current){pn.current=!0;try{if(!Qn.current)return;var I=function(e){var n=e.split("-"),t=n[0];if(!En[t]&&!1===ue)return!1;if(ue&&!En["left-".concat(t)]&&!En["right-".concat(t)]&&!En[t])return!1;for(var i=t,r=1;r<n.length-1;r++)if(i+="-".concat(n[r]),!_n[i])return!1;return!0},w=Qn.current.getBoundingClientRect();Qe({width:w.width,height:w.height});var R=[];if(st.forEach(function(e){var n,t,i=e.key,r=null===(n=vt.current[i])||void 0===n?void 0:n.current,o=null===(t=ft.current[i])||void 0===t?void 0:t.current;r&&o&&(r.style.height="auto",o.style.height="auto",r.style.minHeight="0px",o.style.minHeight="0px")}),!We.current){for(var C=0;C<Math.max(Wn.length,Nn.length);C++){var T=null===(e=pt.current[C])||void 0===e?void 0:e.current,_=null===(n=ht.current[C])||void 0===n?void 0:n.current;T&&(T.style.height="auto",T.style.minHeight="0px"),_&&(_.style.height="auto",_.style.minHeight="0px")}ue||Object.keys(bt.current).forEach(function(e){var n,t;if(I(e)){var i=null===(n=bt.current[e])||void 0===n?void 0:n.current,r=null===(t=yt.current[e])||void 0===t?void 0:t.current;i&&r&&(i.style.height="auto",r.style.height="auto",i.style.minHeight="0px",r.style.minHeight="0px")}})}var k={};st.forEach(function(e){var n,t,i=e.key,r=null===(n=vt.current[i])||void 0===n?void 0:n.current,o=null===(t=ft.current[i])||void 0===t?void 0:t.current;if(r&&o){var l=r.getBoundingClientRect(),c=o.getBoundingClientRect();k[i]=Math.max(l.height,c.height)}});var D={left:{},right:{}},M={};if(!We.current)if(ue){if(Se&&null!==lt)if("number"==typeof lt){var A=lt,H=Wn[A],z=null===(r=pt.current[A])||void 0===r?void 0:r.current;z&&H&&(H.refIndexes||[]).forEach(function(e){var n,t=Nn.findIndex(function(n){return n.selfIndex===e}),i=null===(n=ht.current[t])||void 0===n?void 0:n.current;if(i&&(En["left-".concat(A)]||En["right-".concat(t)])){var r=Math.max(z.getBoundingClientRect().height,i.getBoundingClientRect().height);D.left[A]=Math.max(D.left[A]||0,r),D.right[t]=Math.max(D.right[t]||0,r)}})}else{var W=lt;T=null===(o=bt.current[W])||void 0===o?void 0:o.current,_=null===(l=yt.current[W])||void 0===l?void 0:l.current;if(T&&_){O=Math.max(T.getBoundingClientRect().height,_.getBoundingClientRect().height);M[W]=Math.max(M[W]||0,O)}}}else{for(C=0;C<Math.min(Wn.length,Nn.length);C++){var T=null===(t=pt.current[C])||void 0===t?void 0:t.current,_=null===(i=ht.current[C])||void 0===i?void 0:i.current,N=!!En[String(C)];if(T&&_&&N){var O=Math.max(T.getBoundingClientRect().height,_.getBoundingClientRect().height);D.left[C]=O,D.right[C]=O}}Object.keys(bt.current).forEach(function(e){var n,t;if(I(e)){var i=null===(n=bt.current[e])||void 0===n?void 0:n.current,r=null===(t=yt.current[e])||void 0===t?void 0:t.current;if(i&&r&&null!==i.offsetParent&&null!==r.offsetParent){var o=i.getBoundingClientRect(),l=r.getBoundingClientRect();M[e]=Math.max(o.height,l.height)}}})}if(st.forEach(function(e){var n,t,i=e.key,r=null===(n=vt.current[i])||void 0===n?void 0:n.current,o=null===(t=ft.current[i])||void 0===t?void 0:t.current;if(r&&o){var l=k[i];r.style.minHeight="".concat(l,"px"),o.style.minHeight="".concat(l,"px")}}),We.current||(Object.entries(D.left).forEach(function(e){var n,t=e[0],i=e[1],r=null===(n=pt.current[Number(t)])||void 0===n?void 0:n.current;r&&(r.style.minHeight="".concat(i,"px"))}),Object.entries(D.right).forEach(function(e){var n,t=e[0],i=e[1],r=null===(n=ht.current[Number(t)])||void 0===n?void 0:n.current;r&&(r.style.minHeight="".concat(i,"px"))}),ue||Object.keys(M).forEach(function(e){var n,t,i=null===(n=bt.current[e])||void 0===n?void 0:n.current,r=null===(t=yt.current[e])||void 0===t?void 0:t.current;if(i&&r&&M[e]){var o=M[e];i.style.minHeight="".concat(o,"px"),r.style.minHeight="".concat(o,"px")}})),st.forEach(function(e){var n,t,i=e.key,r=e.analysisKey,o=null===(n=vt.current[i])||void 0===n?void 0:n.current,l=null===(t=ft.current[i])||void 0===t?void 0:t.current;if(o&&l){var c=o.getBoundingClientRect(),a=l.getBoundingClientRect(),u=It(r),d=E(u.score,u.relation,u.hasContent,bn);if(!d)return;var s=c.top+c.height/2-w.top;R.push({id:"field-".concat(i),x1:c.right-w.left,y1:s,x2:a.left-w.left,y2:s,style:d})}}),ue){if(Wn.forEach(function(e,n){var t;(null===(t=pt.current[n])||void 0===t?void 0:t.current)&&(e.refIndexes||[]).forEach(function(e){var t,i,r,o,l,c,a,u,d,s,v=Nn.findIndex(function(n){return n.selfIndex===e});if(-1!==v){var f=null===(t=gt.current[n])||void 0===t?void 0:t.current,p=null===(i=xt.current[v])||void 0===i?void 0:i.current;if(f&&p){var h=f.getBoundingClientRect(),g=p.getBoundingClientRect(),x=h.right-w.left,m=g.left-w.left,b=h.top+h.height/2-w.top,y=g.top+g.height/2-w.top;if(Se&<===n){var S=null!==(o=null===(r=fn.current)||void 0===r?void 0:r.getBoundingClientRect().top)&&void 0!==o?o:0,I=null!==(c=null===(l=an.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==c?c:0,F=S+(null!==(u=null===(a=fn.current)||void 0===a?void 0:a.clientHeight)&&void 0!==u?u:1/0),C=I+(null!==(s=null===(d=an.current)||void 0===d?void 0:d.clientHeight)&&void 0!==s?s:1/0),E=h.top+h.height/2,B=function(e,n,t){return Math.max(n,Math.min(t,e))};b=B(E,S,F)-w.top,y=B(E,I,C)-w.top}var T=wt(n);T&&R.push({id:"line-".concat(n,"-").concat(v),x1:x,y1:b,x2:m,y2:y,style:T,sectionIdx:n,targetRightIdx:v})}}})}),Se&&"string"==typeof lt){W=lt;var j=null===(v=gt.current[W])||void 0===v?void 0:v.current,P=null===(f=xt.current[W])||void 0===f?void 0:f.current;if(j&&P){var Y=j.getBoundingClientRect(),K=P.getBoundingClientRect(),V=Y.right-w.left,X=K.left-w.left,q=null!==(h=null===(p=fn.current)||void 0===p?void 0:p.getBoundingClientRect().top)&&void 0!==h?h:0,U=null!==(x=null===(g=an.current)||void 0===g?void 0:g.getBoundingClientRect().top)&&void 0!==x?x:0,G=q+(null!==(b=null===(m=fn.current)||void 0===m?void 0:m.clientHeight)&&void 0!==b?b:1/0),J=U+(null!==(S=null===(y=an.current)||void 0===y?void 0:y.clientHeight)&&void 0!==S?S:1/0),Q=Y.top+Y.height/2,Z=K.top+K.height/2,$=function(e,n,t){return Math.max(n,Math.min(t,e))},ee=$(Q,q,G)-w.top,ne=$(Z,U,J)-w.top;(re=Rt(W))&&R.push({id:"line-subsec-".concat(W),x1:V,y1:ee,x2:X,y2:ne,style:re,sectionIdx:Number(W.split("-")[0]),isSubSection:!0,subSectionKeyPath:W})}}}else{for(C=0;C<Math.min(Wn.length,Nn.length);C++){var te=null===(c=pt.current[C])||void 0===c?void 0:c.current,ie=null===(a=ht.current[C])||void 0===a?void 0:a.current;if(te&&ie){var re,oe=te.getBoundingClientRect(),le=ie.getBoundingClientRect(),ce=(oe.top+18-w.top+le.top+18-w.top)/2,ae=(null===(u=Nn[C])||void 0===u?void 0:u.id)||"sec-".concat(C);(re=wt(C))&&R.push({id:ae,x1:oe.right-w.left,y1:ce,x2:le.left-w.left,y2:ce,style:re,sectionIdx:C,hasCognitive:!!((null===(d=Wn[C])||void 0===d?void 0:d.cognitiveData)||(null===(s=Nn[C])||void 0===s?void 0:s.cognitiveData)||ae&&Ke[ae])})}}Object.keys(bt.current).forEach(function(e){var n,t,i,r,o,l,c;if(I(e)){for(var a=null===(n=bt.current[e])||void 0===n?void 0:n.current,u=e.split("-").map(Number),d=Wn[u[0]],s=1;s<u.length;s++)(null==d?void 0:d.subsections)&&(d=d.subsections[u[s]]);if(d&&(null===(t=d.refIndexes)||void 0===t?void 0:t.length)){var v=null===(i=yt.current[e])||void 0===i?void 0:i.current;if(a&&v&&null!==a.offsetParent&&null!==v.offsetParent){var f=a.getBoundingClientRect(),p=v.getBoundingClientRect(),h=(f.top+16-w.top+p.top+16-w.top)/2,g=e.split("-").map(Number),x=Wn[g[0]],m=Nn[g[0]];for(s=1;s<g.length;s++)(null==x?void 0:x.subsections)&&(x=x.subsections[g[s]]),(null==m?void 0:m.subsections)&&(m=m.subsections[g[s]]);if(!x&&!m)return;var b=(null==x?void 0:x.relation)&&"not_defined"!==x.relation,y=(null==m?void 0:m.relation)&&"not_defined"!==m.relation,S=F(null==x?void 0:x.id)||F(null==m?void 0:m.id)||"",C=!(!(null==x?void 0:x.cognitiveData)&&!(null==m?void 0:m.cognitiveData)),T=null;if(b||y||C){var _=null!==(o=null!==(r=null==x?void 0:x.cognitiveRelevanceScore)&&void 0!==r?r:null==m?void 0:m.cognitiveRelevanceScore)&&void 0!==o?o:S?null===(l=Ke[S])||void 0===l?void 0:l.relevance_score:void 0;if(null!=_){var k=B(_),D=k.score,M=k.relation;T=E(D,M,!0,bn)}else{M=b?x.relation:y?m.relation:"not_defined";var A=null!==(c=null==x?void 0:x.score)&&void 0!==c?c:null==m?void 0:m.score;T=E(D="number"==typeof A?A:0,M,!0,bn)}}else T={badgeBg:"#EEF2FF",badgeText:"#3730A3",badgeBorder:"#C7D2FE",label:"N/A"};T&&R.push({id:"subsec-".concat(e),x1:f.right-w.left,y1:h,x2:p.left-w.left,y2:h,style:T,sectionIdx:g[0],isSubSection:!0,subSectionKeyPath:e,hasCognitive:C||S&&Ke[S]})}}}})}if(rt(R),et.current&&nt.current){var de=et.current.getBoundingClientRect(),se=nt.current.getBoundingClientRect(),ve=(de.top+de.height/2-w.top+se.top+se.height/2-w.top)/2;dt({x1:de.right-w.left,x2:se.left-w.left,y:ve})}else dt(null);if(ue&&ke.size>0){var fe=[],pe=fn.current,he=an.current;if(pe&&he){var ge=[],xe=pe.getBoundingClientRect().top,me=he.getBoundingClientRect().top,be=xe+pe.clientHeight,ye=me+he.clientHeight,Ie=pe.scrollTop,we=he.scrollTop,Re=w.top,Fe=function(e,n,t){return Math.max(n,Math.min(t,e))};ke.forEach(function(e){var n,t,i;if("string"==typeof e){var r=e,o=null===(n=gt.current[r])||void 0===n?void 0:n.current,l=null===(t=xt.current[r])||void 0===t?void 0:t.current;if(!o||!l)return;var c=o.getBoundingClientRect(),a=l.getBoundingClientRect(),u=Rt(r),d=c.right-w.left,s=a.left-w.left-0,v=d+.75*(s-d),f=c.top+c.height/2,p=a.top+a.height/2,h=f-xe+Ie,g=p-me+we,x="conn-subsec-".concat(r);ge.push({lhsScrollY:h,rhsScrollY:g,x1:d,x2:s,containerTop:Re,leftIdx:r,rhsArrayIdx:r,styleColor:(null==u?void 0:u.badgeBorder)||"#6366F1",styleId:x});var m=Fe(f,xe,be),b=Fe(p,me,ye),y=m-Re,S=b-Re,I=f>=xe-4&&f<=be+4,R=p>=me-4&&p<=ye+4,F="";F=I&&R?L(d,y,s,S):I&&!R?"M ".concat(d,",").concat(y," L ").concat(v,",").concat(y," L ").concat(v,",").concat(S):!I&&R?"M ".concat(v,",").concat(y," L ").concat(v,",").concat(S," L ").concat(s,",").concat(S):"M ".concat(v,",").concat(y," L ").concat(v,",").concat(S),fe.push({id:x,pathD:F,style:u,leftIdx:r,rhsArrayIdx:r})}else{var C=Wn[e];if(!(null===(i=null==C?void 0:C.refIndexes)||void 0===i?void 0:i.length))return;C.refIndexes.forEach(function(n){var t,i,r=Nn.findIndex(function(e){return e.selfIndex===n});if(-1!==r){var o=null===(t=gt.current[e])||void 0===t?void 0:t.current,l=null===(i=xt.current[r])||void 0===i?void 0:i.current;if(o&&l){var c=o.getBoundingClientRect(),a=l.getBoundingClientRect(),u=wt(e),d=c.right-w.left,s=a.left-w.left-0,v=d+.75*(s-d),f=c.top+c.height/2,p=a.top+a.height/2,h=f-xe+Ie,g=p-me+we,x="conn-".concat(e,"-").concat(r);ge.push({lhsScrollY:h,rhsScrollY:g,x1:d,x2:s,containerTop:Re,leftIdx:e,rhsArrayIdx:r,styleColor:(null==u?void 0:u.badgeBorder)||"#6366F1",styleId:x});var m=Fe(f,xe,be),b=Fe(p,me,ye),y=m-Re,S=b-Re,I=f>=xe-4&&f<=be+4,R=p>=me-4&&p<=ye+4,F="";F=I&&R?L(d,y,s,S):I&&!R?"M ".concat(d,",").concat(y," L ").concat(v,",").concat(y," L ").concat(v,",").concat(S):!I&&R?"M ".concat(v,",").concat(y," L ").concat(v,",").concat(S," L ").concat(s,",").concat(S):"M ".concat(v,",").concat(y," L ").concat(v,",").concat(S),fe.push({id:x,pathD:F,style:u,leftIdx:e,rhsArrayIdx:r})}}})}}),Oe.current=ge}He(fe)}else He([]),Oe.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{pn.current=!1}}},[st,Wn,Nn,Ke,bn,It,wt,ue,Se,lt,ke,En,_n]),Ct=u(function(){var e,n,t,i,r,o,l,c,a,u,d,s,v,f,p=Oe.current;if(p.length&&!We.current){var h=null!==(n=null===(e=fn.current)||void 0===e?void 0:e.scrollTop)&&void 0!==n?n:0,g=null!==(i=null===(t=an.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,x=null!==(o=null===(r=fn.current)||void 0===r?void 0:r.clientHeight)&&void 0!==o?o:1/0,m=null!==(c=null===(l=an.current)||void 0===l?void 0:l.clientHeight)&&void 0!==c?c:1/0,b=null!==(u=null===(a=fn.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==u?u:0,y=null!==(s=null===(d=an.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==s?s:0,S=b+x,I=y+m,w=null!==(f=null===(v=Qn.current)||void 0===v?void 0:v.getBoundingClientRect().top)&&void 0!==f?f:0,R=function(e,n,t){return Math.max(n,Math.min(t,e))};p.forEach(function(e){var n=e.lhsScrollY-h+b,t=e.rhsScrollY-g+y,i=Le.current[e.styleId+"-stroke"],r=Le.current[e.styleId+"-bg"];if(i||r){var o,l=R(n,b,S),c=R(t,y,I),a=l-w,u=c-w,d=n>=b-4&&n<=S+4,s=t>=y-4&&t<=I+4,v=e.x1+.65*(e.x2-e.x1);o=d&&s?L(e.x1,a,e.x2,u):d&&!s?"M ".concat(e.x1,",").concat(a," L ").concat(v,",").concat(a," L ").concat(v,",").concat(u):!d&&s?"M ".concat(v,",").concat(a," L ").concat(v,",").concat(u," L ").concat(e.x2,",").concat(u):"M ".concat(v,",").concat(a," L ").concat(v,",").concat(u),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",o)),r&&(r.setAttribute("visibility","visible"),r.setAttribute("d",o))}})}},[]),Et=c(Ft);a(function(){Et.current=Ft},[Ft]);var Bt=c(null),Tt=u(function(){null!==Bt.current&&clearTimeout(Bt.current),Bt.current=setTimeout(function(){Et.current(),Bt.current=null},50)},[]),_t=u(function(e){var n,t,i,r,o,l,c,a;if(!Ce.current){if(Pe.current){var u=Ye.current,d=Zn.current,s=fn.current,v=an.current;if(null!==u&&null!==d&&s&&v){var f="string"==typeof u?null===(n=bt.current[u])||void 0===n?void 0:n.current:null===(t=Yn.current[u])||void 0===t?void 0:t.current,p="string"==typeof d?null===(i=yt.current[d])||void 0===i?void 0:i.current:null===(r=mt.current[d])||void 0===r?void 0:r.current;if(f&&p){var h=f.getBoundingClientRect().top-s.getBoundingClientRect().top+s.scrollTop,g=p.getBoundingClientRect().top-v.getBoundingClientRect().top+v.scrollTop;if(e.currentTarget===s){var x=g-(h-s.scrollTop),m=v.scrollHeight-v.clientHeight,b=Math.max(0,Math.min(x,m));Math.abs(v.scrollTop-b)>1&&(v.scrollTop=b)}else if(e.currentTarget===v){var y=h-(g-v.scrollTop),S=s.scrollHeight-s.clientHeight,I=Math.max(0,Math.min(y,S));Math.abs(s.scrollTop-I)>1&&(s.scrollTop=I)}if($n.current){var w=null===(o=gt.current[u])||void 0===o?void 0:o.current,R=null===(l=xt.current[d])||void 0===l?void 0:l.current,F=null!==(a=null===(c=Qn.current)||void 0===c?void 0:c.getBoundingClientRect().top)&&void 0!==a?a:0,C=s.getBoundingClientRect().top,E=C+s.clientHeight,B=v.getBoundingClientRect().top,T=B+v.clientHeight,_=function(e,n,t){return Math.max(n,Math.min(t,e))};if(w&&R){var k=w.getBoundingClientRect(),D=R.getBoundingClientRect(),M=k.top+k.height/2,A=D.top+D.height/2,H=_(M,C,E),z=_(A,B,T);$n.current.setAttribute("y1",(H-F).toString()),$n.current.setAttribute("y2",(z-F).toString());var W=M>=C-4&&M<=E+4;$n.current.setAttribute("visibility",W?"visible":"hidden")}}}}}Oe.current.length>0&&!je.current&&(je.current=!0,requestAnimationFrame(function(){Ct(),je.current=!1}))}},[Ct]);a(function(){var e=setTimeout(Tt,250);window.addEventListener("resize",Tt);var n=null,t=null;return ln.current&&(n=new ResizeObserver(Tt)).observe(ln.current),Qn.current&&(t=new ResizeObserver(Tt)).observe(Qn.current),function(){clearTimeout(e),window.removeEventListener("resize",Tt),null==n||n.disconnect(),null==t||t.disconnect()}},[Sn,Dn,On,st,En,_n,Wn,Nn,bn,Tt,Se,lt,Re,ke]),a(function(){Pe.current=Se},[Se]),a(function(){Ye.current=lt},[lt]);var kt=u(function(){var e=rn.sectionIdx,n=rn.isOrphan;if(null!=e)return n?(be("No counterpart exists for this section."),void xn()):void(Se&<===e?Vn():(De(new Set),He([]),Oe.current=[],ge(!0),Ce.current=!0,ct(e),Ye.current=e,Ie(!0),Pe.current=!0,Fe(!1),un.current&&(un.current.style.height="0px"),dn.current&&(dn.current.style.height="0px"),sn.current&&(sn.current.style.height="0px"),vn.current&&(vn.current.style.height="0px"),requestAnimationFrame(function(){var n,t,i,r,o=null,l=null,c=null;if("string"==typeof e)o=(null===(n=bt.current[e])||void 0===n?void 0:n.current)||null,c=(l=(null===(t=yt.current[e])||void 0===t?void 0:t.current)||null)?e:null;else{o=(null===(i=Yn.current[e])||void 0===i?void 0:i.current)||null;var a=Wn[e],u=(null==a?void 0:a.refIndexes)||[];if(u.length>0){var d=u[0],s=Nn.findIndex(function(e){return e.selfIndex===d});-1!==s&&(l=(null===(r=mt.current[s])||void 0===r?void 0:r.current)||null,c=s)}}Zn.current=c;var v=fn.current,f=an.current;if(!o||!v)return Ce.current=!1,void ge(!1);if(!l||!f)return Fe(!0),Et.current(),Ce.current=!1,void ge(!1);var p=o.getBoundingClientRect().top-v.getBoundingClientRect().top+v.scrollTop,h=l.getBoundingClientRect().top-f.getBoundingClientRect().top+f.scrollTop-(p-v.scrollTop);h<0&&un.current&&(un.current.style.height="".concat(Math.abs(h),"px"));requestAnimationFrame(function(){var e,n=f.scrollHeight-f.clientHeight;if(h<0)e=0;else{if(h>n){var t=h-n;return dn.current&&(dn.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){P(f,h,200,function(){Fe(!0),Et.current(),Ce.current=!1,ge(!1)})})}e=h}P(f,e,200,function(){Fe(!0),Et.current(),Ce.current=!1,ge(!1)})})})));xn()},[xn,rn.sectionIdx,Se,lt,Wn,Nn,Tt,Vn]),Dt=null!==rn.sectionIdx&&ke.has(rn.sectionIdx),Mt=function(n){var o,l,c,a=n.section,u=n.idx,v=n.columnKey,f=n.colRef,p=n.mb,h=void 0===p?1:p,S=n.parentNodeId,I=void 0===S?"":S,w=ue?!!En["".concat(v,"-").concat(u)]:!!En[String(u)],R=(null===(o=a.displayTitle)||void 0===o||o)&&C(a.title),E=(null===(l=a.displayContent)||void 0===l||l)&&C(a.content),B=!R&&!E,T=a.title;R||(T=E?"No Title Found":"No Matching Section Found");var _,k=[];if(null===(c=a.evaluationResult)||void 0===c?void 0:c.deviations){var D=a.evaluationResult.deviations;for(var M in D){var A=D[M][I];A&&k.push(A)}}return t(s,e({ref:f,sx:{mb:h,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:i(x,e({disableGutters:!0,expanded:!B&&w,onChange:function(){return!B&&function(n,t){var i,r;We.current=!0,Ne.current&&clearTimeout(Ne.current),ze.current&&(ze.current.style.opacity="0");var o=null===(i=pt.current[n])||void 0===i?void 0:i.current,l=null===(r=ht.current[n])||void 0===r?void 0:r.current;if(o&&(o.style.minHeight="0px"),l&&(l.style.minHeight="0px"),Object.keys(bt.current).forEach(function(e){var t,i;if(e.startsWith("".concat(n,"-"))){var r=null===(t=bt.current[e])||void 0===t?void 0:t.current,o=null===(i=yt.current[e])||void 0===i?void 0:i.current;r&&(r.style.minHeight="0px"),o&&(o.style.minHeight="0px")}}),ue){var c=Wn[n];((null==c?void 0:c.refIndexes)||[]).forEach(function(e){var n,t=Nn.findIndex(function(n){return n.selfIndex===e}),i=null===(n=ht.current[t])||void 0===n?void 0:n.current;i&&(i.style.minHeight="0px")});var a=Nn[n],u=null==a?void 0:a.selfIndex;Wn.forEach(function(e,n){var t,i;if(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(u)){var r=null===(i=pt.current[n])||void 0===i?void 0:i.current;r&&(r.style.minHeight="0px")}})}Ne.current=setTimeout(function(){We.current=!1,Et.current(),ze.current&&(ze.current.style.opacity="1")},650),Bn(function(i){var r=e({},i);if(!ue){var o=!!i[String(n)];return r[String(n)]=!o,r}var l="".concat(t,"-").concat(n),c=!i[l];if(r[l]=c,"left"===t)((null==(a=Wn[n])?void 0:a.refIndexes)||[]).forEach(function(e){var n=Nn.findIndex(function(n){return n.selfIndex===e});-1!==n&&(r["right-".concat(n)]=c)});else{var a,u=null==(a=Nn[n])?void 0:a.selfIndex;Wn.forEach(function(e,n){var t;(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(u))&&(r["left-".concat(n)]=c)})}return r})}(u,v)},sx:{boxShadow:"none",border:B?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:B?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flexGrow:1,width:"100%",display:"flex",flexDirection:"column",minWidth:0,"&:before":{display:"none"}}},{children:[t(m,e({expandIcon:B?null:t(y,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:B?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:R&&t(g,e({title:T,placement:"top"},{children:t(d,e({component:"div",sx:{fontSize:"12px",color:B?"#94A3B8":"#19213D",fontWeight:B?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(_=T,_?F(_).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(e,n){return e.startsWith("**")&&e.endsWith("**")?t("strong",{children:e.slice(2,-2)},n):t(r.Fragment,{children:e},n)}):null)}))}))})),!B&&i(b,e({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[E&&t(N,{content:a.content,sxStyles:Ze,highlights:k}),(a.subsections||[]).map(function(e,n){return At({section:e,keyPath:"".concat(u,"-").concat(n),depth:0,columnKey:v,parentNodeId:I})})]}))]}))}),"".concat(v,"-sec-").concat(u))},At=function(n){var o,l,c,a=n.section,u=n.keyPath,v=n.depth,f=void 0===v?0:v,p=n.columnKey,h=void 0===p?"left":p,g=n.parentNodeId,I=void 0===g?"":g,w=(null===(o=a.displayTitle)||void 0===o||o)&&C(a.title),R=(null===(l=a.displayContent)||void 0===l||l)&&C(a.content),F=!w&&!R,E=w?a.title:R?"No Title Found":"No Matching Section Found",B=!!_n[u];"left"!==h||bt.current[u]||(bt.current[u]=r.createRef()),"right"!==h||yt.current[u]||(yt.current[u]=r.createRef());var T="left"===h?bt.current[u]:yt.current[u];gt.current[u]||(gt.current[u]=r.createRef()),xt.current[u]||(xt.current[u]=r.createRef());for(var _=u.split("-").map(function(e){return Number(e)+1}).join("."),k=Rt(u),D=ue&&ke.has(u),M=u.split("-").map(Number),A=Wn[M[0]],H=Nn[M[0]],z=1;z<M.length;z++)(null==A?void 0:A.subsections)&&(A=A.subsections[M[z]]),(null==H?void 0:H.subsections)&&(H=H.subsections[M[z]]);var W=!(null===(c=a.refIndexes)||void 0===c?void 0:c.length)||void 0!==a.selfIndex&&a.selfIndex<0,L="left"===h&&W,O="right"===h&&W;return i(s,w?e({ref:T,sx:{mt:1,width:"100%",minWidth:0,position:"relative"}},{children:[t(s,e({sx:e({width:"100%"},D&&k&&{borderRadius:"4px",outline:"2px solid ".concat(k.badgeBorder),outlineOffset:"1px"})},{children:i(x,e({disableGutters:!0,expanded:!F&&B,onChange:function(){return!F&&kn(function(n){var t;return e(e({},n),((t={})[u]=!n[u],t))})},sx:{mt:0,boxShadow:"none",border:F?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF",minWidth:0,"&:before":{display:"none"}}},{children:[t(m,e({expandIcon:F?null:t(y,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"}}},{children:t(d,e({component:"div",sx:{fontSize:"11px",fontWeight:600,color:F?"#94A3B8":"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:E||"Untitled Subsection"}))})),!F&&i(b,e({sx:{pt:0,pb:1,minWidth:0}},{children:[R&&t(N,{content:a.content,sxStyles:Ze,highlights:function(){var e,n;if(!(null===(e=a.evaluationResult)||void 0===e?void 0:e.deviations))return[];var t=(null===(n=a.evaluationResult)||void 0===n?void 0:n.deviations)||{},i=[];for(var r in t){var o=t[r][I];o&&i.push(o)}return i}()}),(a.subsections||[]).map(function(e,n){return At({section:e,keyPath:"".concat(u,"-").concat(n),depth:f+1,columnKey:h,parentNodeId:I})})]}))]}))})),ue&&"left"===h&&k&&!F&&i(s,e({ref:gt.current[u],onClick:function(e){e.stopPropagation();for(var n=u.split("-").map(Number),t=Wn[n[0]],i=Nn[n[0]],r=1;r<n.length;r++)(null==t?void 0:t.subsections)&&(t=t.subsections[n[r]]),(null==i?void 0:i.subsections)&&(i=i.subsections[n[r]]);Un(e,t||{title:"",content:""},L||O,i||{title:"",content:""},u,k)},sx:{position:"absolute",top:"16px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"10px",bgcolor:k.badgeBg,color:k.badgeText,border:"1px solid ".concat(k.badgeBorder),borderRadius:"12px",px:1,py:.3,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[t(s,e({component:"span",sx:{fontSize:"10px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(k.badgeBorder)}},{children:_})),t(s,e({component:"span",sx:{fontSize:"10px",px:.25}},{children:L?"No Deviation Found":0==k.deviationLabel||void 0===k.deviationLabel?"Same":"".concat(k.deviationLabel,"% Deviation")})),t(S,{size:10,color:k.badgeText})]})),ue&&"right"===h&&k&&!F&&!he&&t(s,e({ref:xt.current[u],sx:{position:"absolute",top:"16px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"10px",bgcolor:"#EEF2FF",color:"#3730A3",border:"1px solid #C7D2FE",borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:O?"-":_}))]}):e({ref:T,sx:{mt:0===f?1:.75,width:"100%",minWidth:0,position:"relative"}},{children:[!F&&i(s,e({sx:e({width:"100%"},D&&k&&{borderRadius:"4px",outline:"2px solid ".concat(k.badgeBorder),outlineOffset:"1px"})},{children:[R&&t(N,{content:a.content,sxStyles:Ze,highlights:function(){var e,n;if(!(null===(e=a.evaluationResult)||void 0===e?void 0:e.deviations))return[];var t=(null===(n=a.evaluationResult)||void 0===n?void 0:n.deviations)||{},i=[];for(var r in t){var o=t[r][I];o&&i.push(o)}return i}()}),(a.subsections||[]).map(function(e,n){return At({section:e,keyPath:"".concat(u,"-").concat(n),depth:f+1,columnKey:h,parentNodeId:I})})]})),ue&&"left"===h&&k&&!F&&i(s,e({ref:gt.current[u],onClick:function(e){var n;e.stopPropagation();var t=function(e,n){for(var i=0,r=e;i<r.length;i++){var o=r[i];if(o.selfIndex===n)return o;if(o.subsections){var l=t(o.subsections,n);if(l)return l}}return null},i=null===(n=a.refIndexes)||void 0===n?void 0:n[0],r="number"==typeof i?t(Nn,i):null;Un(e,a,W,r||{title:"",content:""},u,k)},sx:{position:"absolute",top:"16px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"10px",bgcolor:k.badgeBg,color:k.badgeText,border:"1px solid ".concat(k.badgeBorder),borderRadius:"12px",px:1,py:.3,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[t(s,e({component:"span",sx:{fontSize:"10px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(k.badgeBorder)}},{children:_})),t(s,e({component:"span",sx:{fontSize:"10px",px:.25}},{children:L?"No Deviation Found":0==k.deviationLabel||void 0===k.deviationLabel?"Same":"".concat(k.deviationLabel,"% Deviation")})),t(S,{size:10,color:k.badgeText})]})),ue&&"right"===h&&k&&!F&&!he&&t(s,e({ref:xt.current[u],sx:{position:"absolute",top:"16px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"10px",bgcolor:"#EEF2FF",color:"#3730A3",border:"1px solid #C7D2FE",borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:O?"-":_}))]}),u)};return i(s,e({ref:cn,sx:e(e({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},ue?{}:{overflow:"visible"}),{position:"relative"})},{children:[ve&&t(s,e({sx:{position:"absolute",inset:0,bgcolor:"rgba(255, 255, 255, 0.6)",backdropFilter:"blur(10px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"8px"}},{children:t(z,{})})),ue&&t(H,{open:rn.open,anchorEl:rn.anchorEl,sectionTitle:rn.sectionTitle,referenceSectionTitle:rn.refSectionTitle,onClose:xn,onOpenCognitiveCompare:Gn,onOpenSideBySide:kt,onConnect:Jn,isConnected:Dt}),en.open&&t(A,{open:en.open,popupRef:Ue,position:Xe,popupConfig:oe,onClose:function(){qe(null),nn(function(n){return e(e({},n),{open:!1})}),Te(null)},markdownStyles:te,sectionTitle:en.sectionTitle,referenceSectionTitle:en.refSectionTitle,cognitiveData:en.cognitiveData,anchorEl:en.anchorEl,sectionAnchorEl:en.sectionAnchorEl,scrollContainerEl:ln.current,badgeStyle:en.badgeStyle,docData:en.docData,deviationData:en.deviationData}),t(v,e({open:!!me,autoHideDuration:8e3,onClose:function(){return be(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:t(f,e({onClose:function(){return be(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:me}))})),(re.isHeaderVisible||re.isToggleVisible)&&i(s,e({sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between",bgcolor:"#FFFFFF",border:"1.5px solid #EEF0F4",borderTopLeftRadius:"8px",borderTopRightRadius:"8px"}},{children:[t(s,e({sx:{display:"flex",alignItems:"center",gap:1}},{children:re.isHeaderVisible&&t(d,e({sx:{fontSize:"16px",fontWeight:600,color:"#0F172A"}},{children:Q}))})),re.isToggleVisible&&t(s,e({sx:{display:"flex",alignItems:"center"}},{children:t(p,{control:t(h,{checked:ue,onChange:function(e){var n=e.target.checked;fe(!0),setTimeout(function(){de(n),Vn(),De(new Set),He([]),Oe.current=[],setTimeout(function(){fe(!1)},400)},50)},color:"primary",size:"small",sx:{width:100,height:26,padding:0,"& .MuiSwitch-switchBase":{padding:0,margin:"3px",transitionDuration:"300ms","&.Mui-checked":{transform:"translateX(75px)",color:"#fff","& + .MuiSwitch-track":{backgroundColor:"#5928ED",opacity:1,border:0,"&::before":{content:'"Side by Side"',position:"absolute",left:"13px",top:"50%",transform:"translateY(-50%)",fontSize:"9px",fontWeight:700,color:"#fff",letterSpacing:"0.3px"}}}},"& .MuiSwitch-thumb":{boxSizing:"border-box",width:20,height:20},"& .MuiSwitch-track":{borderRadius:13,backgroundColor:"#9e9e9e",opacity:1,position:"relative","&::after":{content:'"Side by Side"',position:"absolute",right:"13px",top:"50%",transform:"translateY(-50%)",fontSize:"9px",fontWeight:700,color:"#fff",letterSpacing:"0.3px",opacity:1,transition:"opacity 0.2s"}},"& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track":{"&::after":{opacity:0}}}}),label:"",labelPlacement:"start",sx:{m:0,gap:1}})}))]})),t(s,e({ref:ln,onScroll:_t,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:ue?"hidden":"auto",borderTop:jn&&Pn?"none":"1.5px solid #EEF0F4"}},{children:t(s,e({sx:e({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},ue?{flex:1,minHeight:0}:{})},{children:i(s,e({ref:Qn,sx:e({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"10px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},ue?{flex:1,overflow:"visible"}:{})},{children:[i("svg",e({ref:ze,style:{position:"absolute",top:0,left:0,width:Je.width||"100%",height:Je.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",transition:"opacity 0.15s ease-in-out"}},{children:[ut&&i("g",{children:[t("line",{x1:ut.x1,y1:ut.y,x2:Math.max(ut.x1,(ut.x1+ut.x2)/2-70),y2:ut.y,stroke:"#BBF7D0",strokeWidth:"1.5"}),t("line",{x1:Math.min(ut.x2,(ut.x1+ut.x2)/2+70),y1:ut.y,x2:ut.x2,y2:ut.y,stroke:"#BBF7D0",strokeWidth:"1.5"})]}),it.map(function(n){var r,o=(n.x1+n.x2)/2;if("Not Defined"===n.style.label&&!n.hasCognitive)return null;if(!ue)return i("g",{children:[t("line",{x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,stroke:n.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),t("foreignObject",e({x:o-100,y:n.y1-14,width:"200",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:t(s,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:i(s,e({onClick:function(e){if(e.stopPropagation(),en.open&&Be===n.id)gn();else{var t=Wn[n.sectionIdx]||{title:"",content:""},i=Nn[n.sectionIdx]||{title:"",content:""};if(n.isSubSection&&n.subSectionKeyPath){for(var r=n.subSectionKeyPath.split("-").map(Number),o=Wn[r[0]],l=Nn[r[0]],c=1;c<r.length;c++)(null==o?void 0:o.subsections)&&(o=o.subsections[r[c]]),(null==l?void 0:l.subsections)&&(l=l.subsections[r[c]]);o&&(t=o),l&&(i=l)}Te(n.id),qn(Xn(e.currentTarget,t,i,n.sectionIdx,n.style))}},sx:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:n.style.badgeBg,color:n.style.badgeText,border:"1px solid ".concat(n.style.badgeBorder),borderRadius:"12px",px:1.5,py:.5,fontWeight:500,textAlign:"center",whiteSpace:"nowrap",cursor:"pointer"}},{children:[n.style.label,t(s,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:t(I,{})})),t(y,{size:11,style:{transform:en.open&&Be===n.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},n.id);var l=!1;if(n.isSubSection)l=Se&<===n.subSectionKeyPath&ℜelse{var c=Wn[n.sectionIdx];if(!(null===(r=null==c?void 0:c.refIndexes)||void 0===r?void 0:r.length)||(null==c?void 0:c.selfIndex)<0)return null;l=Se&<===n.sectionIdx&&Re}return l?i("g",e({style:{transition:"opacity 0.2s"}},{children:[t("defs",{children:t("marker",e({id:"arr-".concat(n.id),markerWidth:"7",markerHeight:"5",refX:"7",refY:"2.5",orient:"auto"},{children:t("polygon",{points:"0 0, 7 2.5, 0 5",fill:n.style.badgeBorder||"#6366F1"})}))}),t("line",{ref:$n,x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,stroke:n.style.badgeBorder||"#6366F1",strokeWidth:"1.5",markerEnd:"url(#arr-".concat(n.id,")")})]}),n.id):null}),Ae.map(function(n){var r,o=n.pathD,l=(null===(r=n.style)||void 0===r?void 0:r.badgeBorder)||"#6366F1",c="conn-marker-".concat(n.id),a="".concat(n.id,"-bg"),u="".concat(n.id,"-stroke");return i("g",{children:[t("defs",{children:t("clipPath",e({id:"connections-clip"},{children:t("marker",e({id:c,markerWidth:"8",markerHeight:"6",refX:"7",refY:"3",orient:"auto"},{children:t("polygon",{points:"0 0, 8 3, 0 6",fill:l})}))}))}),t("path",{ref:function(e){Le.current[a]=e},d:o,fill:"none",stroke:"#FFFFFF",strokeWidth:"4",strokeOpacity:"0.7"}),t("path",{ref:function(e){Le.current[u]=e},d:o,fill:"none",stroke:l,strokeWidth:"1.75",markerEnd:"url(#".concat(c,")")})]},n.id)})]})),i(s,e({sx:e({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},ue?{flex:1,overflow:"visible"}:{})},{children:[t(s,e({ref:et,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",minHeight:"40px",alignItems:"center",overflowX:"hidden"}},{children:t(g,e({title:Hn,placement:"top"},{children:t(d,e({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",height:"40px"}},{children:Hn}))}))})),i(s,e({ref:fn,onScroll:_t,sx:e({p:"12px",display:"flex",flexDirection:"column"},ue?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-160px",pr:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[t("div",{ref:sn,style:{width:"100%",height:"0px",flexShrink:0}}),Ln&&Wn.map(function(n,o){var l,c,a,u=!n.title&&!n.content;if(ue&&u)return null;if(!ue)return t(s,e({ref:Kn(o)},{children:Mt({section:n,idx:o,columnKey:"left",colRef:pt.current[o],parentNodeId:(null===(l=null==Z?void 0:Z.input_index_map)||void 0===l?void 0:l[0])||""})}),"left-row-".concat(o));var d=n,v=wt(o),f=!(null===(c=d.refIndexes)||void 0===c?void 0:c.length)||d.selfIndex<0,p="number"==typeof d.selfIndex&&d.selfIndex>=0?d.selfIndex+1:null,h=ke.has(o);return t(s,e({ref:Kn(o),sx:{mb:1}},{children:i(s,e({sx:{position:"relative",width:"100%"}},{children:[t(s,e({ref:pt.current[o],sx:e({width:"100%",display:"flex"},h&&{borderRadius:"6px",outline:"2px solid ".concat((null==v?void 0:v.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:Mt({section:n,idx:o,columnKey:"left",colRef:r.createRef(),mb:0,parentNodeId:(null===(a=null==Z?void 0:Z.input_index_map)||void 0===a?void 0:a[0])||""})})),v&&i(s,e({ref:gt.current[o],onClick:function(e){var t=Nn.find(function(e){var n;return null===(n=d.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""};Un(e,n,f,t,o,v)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:v.badgeBg,color:v.badgeText,border:"1px solid ".concat(v.badgeBorder),borderRadius:"12px",px:1.2,py:.4,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[null!==p&&t(s,e({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(v.badgeBorder)}},{children:p})),t(s,e({component:"span",sx:{fontSize:"11px",px:.25}},{children:f?"No Deviation Found":0==v.deviationLabel||void 0===v.deviationLabel?"Same":"".concat(v.deviationLabel,"% Deviation")})),t(S,{size:11,color:v.badgeText})]}))]}))}),"left-row-".concat(o))}),t("div",{ref:vn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),t(s,e({sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0}},{children:t(s,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:i(s,e({sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",borderRadius:"20px",bgcolor:"#ECFDF3",border:"1px solid #A7F3D0",color:"#15803D",fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1}},{children:[t(s,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:t(I,{})})),0,"% Similarity",t(y,{size:11})]}))}))})),i(s,e({sx:e({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},ue?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[he&&t(w,{sections:11}),t(s,e({ref:nt,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"40px",display:"flex",alignItems:"center",overflowX:"hidden"}},{children:t(g,e({title:zn,placement:"top"},{children:t(d,e({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",height:"40px"}},{children:zn}))}))})),i(s,e({ref:an,onScroll:_t,sx:e({p:"12px",display:"flex",flexDirection:"column"},ue?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-20px",pl:"40px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[t("div",{ref:un,style:{width:"100%",height:"0px",flexShrink:0}}),Ln&&Nn.map(function(n,o){var l,c;if(!ue)return Mt({section:n,idx:o,columnKey:"right",colRef:ht.current[o],parentNodeId:(null===(l=null==Z?void 0:Z.input_index_map)||void 0===l?void 0:l[1])||""});var a=n,u=Wn.filter(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(a.selfIndex))&&e.selfIndex>=0}).map(function(e){return e.selfIndex+1}),d=Wn.some(function(e,n){var t;return ke.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(a.selfIndex))}),v=Wn.findIndex(function(e,n){var t;return ke.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(a.selfIndex))}),f=-1!==v?wt(v):null;return t(s,e({ref:mt.current[o],sx:{mb:1}},{children:i(s,e({sx:{position:"relative",width:"100%"}},{children:[t(s,e({ref:ht.current[o],sx:e({width:"100%",display:"flex"},d&&f&&{borderRadius:"6px",outline:"2px solid ".concat(f.badgeBorder),outlineOffset:"1px"})},{children:Mt({section:n,idx:o,columnKey:"right",colRef:r.createRef(),mb:0,parentNodeId:(null===(c=null==Z?void 0:Z.input_index_map)||void 0===c?void 0:c[1])||""})})),!he&&t(s,e({ref:xt.current[o],sx:{position:"absolute",top:"18px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"11px",bgcolor:"#EEF2FF",color:"#3730A3",border:"1px solid #C7D2FE",borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:u.length>0?u.join(", "):"-"}))]}))}),"right-row-".concat(o))}),t("div",{ref:dn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))};export{Y as default};
|
|
1
|
+
import{__assign as e,__rest as t,__spreadArray as n}from"tslib";import{jsx as i,jsxs as r,Fragment as o}from"react/jsx-runtime";import l,{useMemo as c,useState as u,useRef as a,useEffect as d,useCallback as s}from"react";import{Box as v,Typography as f,Snackbar as h,Alert as p,FormControlLabel as g,Switch as x,Tooltip as m,Accordion as y,AccordionSummary as b,AccordionDetails as S}from"@mui/material";import{EllipsisVertical as w,ChevronDown as I}from"lucide-react";import{ButtonCognitiveIcon as R}from"../../assests/svg/ButtonCognitiveIcon.js";import C from"./OverlayComponent.js";import F from"react-markdown";import{safeStringify as E,hasValue as _,getSideData as B,getRationale as T}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as k,DEFAULT_FIELD_CONFIG as M,DEFAULT_COMPARISON_CONFIG as D}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import A from"./CognitivePopup.js";import H from"./MoreFunctionsPopup.js";import O from"./LoaderComponent.js";import N from"rehype-raw";var W="::",z=l.memo(function(n){var l=n.content,u=n.sxStyles,a=n.deviationBadges,d=void 0===a?[]:a,s=n.highlights,h=void 0===s?[]:s,p=n.maintainRelativeOrder,g=void 0===p||p,x=c(function(){return d.reduce(function(t,n){var i;return e(e({},t),((i={})[n.id]=n,i))},{})},[d]),m=c(function(){return{mark:function(t){var n=t.children;return i("span",e({style:{backgroundColor:"#fccccc",borderRadius:"2px"}},{children:n}))},span:function(n){var l,c,u,a,d,s=n.children,f=t(n,["children"]),h=f["data-badge-id"];if(!h)return i("span",e({},f,{children:s}));var p=x[h];return p?r(v,e({component:"span",sx:{position:"static",display:"inline"}},{children:[s,i(v,e({ref:p.badgeRef,onClick:g?p.onClick:void 0,sx:g?e(e({position:"absolute",zIndex:30,display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"10px",bgcolor:(null===(l=p.style)||void 0===l?void 0:l.badgeBg)||"#EEF2FF",color:(null===(c=p.style)||void 0===c?void 0:c.badgeText)||"#3730A3",border:"1px solid ".concat((null===(u=p.style)||void 0===u?void 0:u.badgeBorder)||"#C7D2FE"),borderRadius:"12px",px:1,py:.3,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",boxShadow:"0 1px 3px rgba(0,0,0,0.07)"},"left"===p.side?{right:"-16px",transform:"translateY(-20%) translateX(calc(100% + 8px))"}:{left:"-16px",transform:"translateY(-20%) translateX(calc(-100% - 8px))"}),p.isConnected&&p.style&&{outline:"2px solid ".concat(p.style.badgeBorder),outlineOffset:"1px"}):e({position:"absolute",width:0,height:0,visibility:"hidden"},"left"===p.side?{right:"-16px",transform:"translateY(-50%)"}:{left:"-16px",transform:"translateY(-50%)"})},{children:g&&r(o,{children:[i(v,e({component:"span",sx:e({fontSize:"10px",fontWeight:700},"left"===p.side?{pr:.5,borderRight:"1px solid ".concat((null===(a=p.style)||void 0===a?void 0:a.badgeBorder)||"#C7D2FE")}:{})},{children:p.label})),"left"===p.side&&r(o,{children:[i(v,e({component:"span",sx:{fontSize:"10px",px:.25}},{children:p.isOrphan?"No Deviation Found":0===p.score||null==p.score?"Same":"".concat(p.score,"% Deviation")})),i(w,{size:10,color:(null===(d=p.style)||void 0===d?void 0:d.badgeText)||"#3730A3"})]})]})}))]})):i("span",e({},f,{children:s}))}}},[x,g]),y=c(function(){var e=l||"",t=function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")};return d.forEach(function(n){n.highlight&&(e=e.replace(new RegExp(t(n.highlight),"g"),'<span data-badge-id="'.concat(n.id,'"><mark>').concat(n.highlight,"</mark></span>")))}),h.forEach(function(n){n&&(e=e.replace(new RegExp(t(n),"g"),"<mark>".concat(n,"</mark>")))}),e},[l,d,h]);return i(f,e({component:"div",sx:e(e({},u),{position:"relative",overflow:"visible","& p, & li, & ul, & ol":{position:"static",overflow:"visible"}})},{children:i(F,e({components:m,rehypePlugins:[N]},{children:E(y).replace(/\\n/g,"\n")}))}))},function(e,t){if(e.content!==t.content)return!1;if(e.sxStyles!==t.sxStyles)return!1;if(e.maintainRelativeOrder!==t.maintainRelativeOrder)return!1;var n=e.highlights||[],i=t.highlights||[];if(n.length!==i.length)return!1;for(var r=0;r<n.length;r++)if(n[r]!==i[r])return!1;return!0}),L=function(e,t,n,i,r){void 0===r&&(r=14);var o=e+.5*(n-e),l=i-t;if(Math.abs(l)<3)return"M ".concat(e," ").concat(t," H ").concat(n);var c=l>0?1:-1,u=Math.min(r,Math.abs(l)/2,Math.abs(o-e)/2,Math.abs(n-o)/2);return["M ".concat(e," ").concat(t),"H ".concat(o-u),"Q ".concat(o," ").concat(t," ").concat(o," ").concat(t+c*u),"V ".concat(i-c*u),"Q ".concat(o," ").concat(i," ").concat(o+u," ").concat(i),"H ".concat(n)].join(" ")},j={id:"",title:""},P={open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,isOrphan:!1,docData:null,deviationData:null},Y=function(e,t,n,i,r){void 0===n&&(n=300);var o=e.style.scrollBehavior;e.style.scrollBehavior="auto";var l=e.scrollTop,c=t-l,u=null,a=function(d){null===u&&(u=d);var s,v=d-u;v<n?(e.scrollTop=(s=v,s/=n,c*(--s*s*s+1)+l),r&&r(),requestAnimationFrame(a)):(e.scrollTop=t,e.style.scrollBehavior=o,r&&r(),i&&i())};requestAnimationFrame(a)},K=function(t){var o,F,N,K,V,X,q,U,G=t.componentHeaderText,J=void 0===G?"Contract Comparison":G,Q=t.treeData,$=t.comparisonConfig,Z=t.leftColumnTitleText,ee=t.rightColumnTitleText,te=t.markdownStyles,ne=t.displayConfig,ie=void 0===ne?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1}:ne,re=t.popupConfig,oe=t.deviationData,le=void 0===oe?{}:oe,ce=u(ie.maintainRelativeOrder),ue=ce[0],ae=ce[1],de=u(!1),se=de[0],ve=de[1],fe=u(!1),he=fe[0],pe=fe[1],ge=u(null),xe=ge[0],me=ge[1],ye=u(!1),be=ye[0],Se=ye[1],we=u(!1),Ie=we[0],Re=we[1],Ce=a(!1),Fe=u(null),Ee=Fe[0],_e=Fe[1],Be=u(new Set),Te=Be[0],ke=Be[1],Me=u([]),De=Me[0],Ae=Me[1],He=a(null),Oe=a(!1),Ne=a(null),We=a({}),ze=a([]),Le=a(!1),je=a(!1),Pe=a(null),Ye=c(function(){return(null==Q?void 0:Q.cognitive_decisioning)||{}},[Q]),Ke=u(null),Ve=Ke[0],Xe=Ke[1],qe=a(null),Ue=u({width:0,height:0}),Ge=Ue[0],Je=Ue[1],Qe=c(function(){return e(e({},k),te)},[te]),$e=u({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,isOrphan:!1,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null,deviationData:null}),Ze=$e[0],et=$e[1],tt=u({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,isOrphan:!1,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null,deviationData:null}),nt=tt[0],it=tt[1],rt=a(null),ot=a(null),lt=a(null),ct=a(null),ut=a(null),at=a(null),dt=a(null),st=a(null),vt=a(!1),ft=a(null);d(function(){ft.current=null},[Ze.sectionIdx,Ze.open]);var ht=s(function(){Xe(null),et(P),_e(null)},[]),pt=s(function(){it(P)},[]),gt=s(function(){var e;if(Ze.anchorEl&&Ze.refSectionTitle){var t=Ze.anchorEl.getBoundingClientRect(),n=(null===(e=null==qe?void 0:qe.current)||void 0===e?void 0:e.offsetHeight)||0,i=Math.min(680,window.innerWidth-24),r=window.innerHeight-t.bottom-12-12,o=t.top-12-12,l=r<n&&o>r;null!==ft.current?!0===ft.current&&(l=o>=n||o>=r):l=!(r>=n||r>=o),ft.current=l;var c=l?o:r,u=Math.min(n||9999,c),a=l?t.top-12-u:t.bottom+12,d=t.left+t.width/2,s=d-i/2,v=Math.max(12,Math.min(s,window.innerWidth-i-12)),f=Math.max(14,Math.min(d-v,i-10-4));Xe({top:a,left:v,arrowLeft:f,openAbove:l,maxHeight:c})}},[Ze.anchorEl,Ze.refSectionTitle]);d(function(){if(Ze.open){window.addEventListener("resize",gt);var e=requestAnimationFrame(gt),t=null;return qe.current&&(t=new ResizeObserver(function(){cancelAnimationFrame(e),e=requestAnimationFrame(gt)})).observe(qe.current),function(){cancelAnimationFrame(e),window.removeEventListener("resize",gt),t&&t.disconnect()}}},[Ze.open,gt]),d(function(){var e=rt.current;if(e&&Ze.open){var t=function(e){qe.current&&qe.current.contains(e.target)||(Xe(null),ht())};return e.addEventListener("scroll",t,{capture:!0}),window.addEventListener("scroll",t,{capture:!0}),function(){e.removeEventListener("scroll",t,{capture:!0}),window.removeEventListener("scroll",t,{capture:!0})}}},[Ze.open,ht]),d(function(){var e=rt.current;if(e&&nt.open){var t=function(){pt()};return e.addEventListener("scroll",t,{capture:!0}),window.addEventListener("scroll",t,{capture:!0}),function(){e.removeEventListener("scroll",t,{capture:!0}),window.removeEventListener("scroll",t,{capture:!0})}}},[nt.open,pt]);var xt=c(function(){var t,n,i,r,o,l,c,u,a,d,s,v;return{fields:null!==(t=null==$?void 0:$.fields)&&void 0!==t?t:M,thresholds:{high:null!==(i=null===(n=null==$?void 0:$.thresholds)||void 0===n?void 0:n.high)&&void 0!==i?i:D.thresholds.high,medium:null!==(o=null===(r=null==$?void 0:$.thresholds)||void 0===r?void 0:r.medium)&&void 0!==o?o:D.thresholds.medium,exact:null!==(c=null===(l=null==$?void 0:$.thresholds)||void 0===l?void 0:l.exact)&&void 0!==c?c:D.thresholds.exact},relationStyles:{noContent:e(e({},D.relationStyles.noContent),(null===(u=null==$?void 0:$.relationStyles)||void 0===u?void 0:u.noContent)||{}),high:e(e({},D.relationStyles.high),(null===(a=null==$?void 0:$.relationStyles)||void 0===a?void 0:a.high)||{}),exact:e(e({},D.relationStyles.exact),(null===(d=null==$?void 0:$.relationStyles)||void 0===d?void 0:d.exact)||{}),medium:e(e({},D.relationStyles.medium),(null===(s=null==$?void 0:$.relationStyles)||void 0===s?void 0:s.medium)||{}),low:e(e({},D.relationStyles.low),(null===(v=null==$?void 0:$.relationStyles)||void 0===v?void 0:v.low)||{})}}},[$]),mt=c(function(){if(Q&&Object.keys(Q).length>0)try{var t=function(t,i,r){var o,l,c,u;void 0===i&&(i=!1),void 0===r&&(r=null);var a=t.nodes||t,d=[],s=[],v=t.base_root_id,f=t.input_index_map||{0:"left",1:"right"},h=t[v]||a[v];if(!h||!1===h.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[]};var p=function(n,i){var o,l,c,u=t[n]||a[n];if(!u||!1===u.display_node)return null;var d=B(u,i,f),s=!1!==(null===(o=d.attributes)||void 0===o?void 0:o.display_title),v=!1!==(null===(l=d.attributes)||void 0===l?void 0:l.display_content),h=!!d.title.trim(),g=!!d.content.trim(),x=T(u),m=(null===(c=null==r?void 0:r[n])||void 0===c?void 0:c.evaluation_result)||u.evaluation_result||null,y=[];u.next&&Object.values(u.next).forEach(function(e){var t=a[e];if(t&&!1!==t.display_node){var n=p(e,i);n&&y.push(n)}});var b=!(!h&&!g);return e(e({id:n,title:h?d.title:"",content:g?d.content:"",displayTitle:s,displayContent:v,subsections:y},b?x:{score:void 0,relation:"not_defined"}),{evaluationResult:m})};if(i){var g=function(i,o){var l,c,u,d,s,v,h,p,x,m,y,b,S,w,I,R,C,F,E,_,k;void 0===o&&(o=0);var M=[],D=[];if(!i)return{refSections:M,baseSections:D};var A={},H={},O=-1,N=-1;for(var W in i){var z=i[W],L=t[z]||a[z];if(L&&!1!==L.display_node){var j=T(L),P=(null===(l=null==r?void 0:r[z])||void 0===l?void 0:l.evaluation_result)||L.evaluation_result||null,Y=B(L,"1",f),K=B(L,"0",f),V=!1!==(null===(c=Y.attributes)||void 0===c?void 0:c.display_title)&&Y.title.trim()||!1!==(null===(u=Y.attributes)||void 0===u?void 0:u.display_content)&&Y.content.trim(),X=!1!==(null===(d=K.attributes)||void 0===d?void 0:d.display_title)&&K.title.trim()||!1!==(null===(s=K.attributes)||void 0===s?void 0:s.display_content)&&K.content.trim(),q=Number(null!==(h=null===(v=Y.attributes)||void 0===v?void 0:v.display_index)&&void 0!==h?h:O--),U=Number(null!==(x=null===(p=K.attributes)||void 0===p?void 0:p.display_index)&&void 0!==x?x:N--),G=A[q]||e(e({id:z,title:!1!==(null===(m=Y.attributes)||void 0===m?void 0:m.display_title)?Y.title:"",content:!1!==(null===(y=Y.attributes)||void 0===y?void 0:y.display_content)?Y.content:"",subsections:[]},V?j:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:q,evaluationResult:P,displayContent:null===(b=Y.attributes)||void 0===b?void 0:b.display_content,displayTitle:null===(S=Y.attributes)||void 0===S?void 0:S.display_title}),J=H[U]||e(e({id:z,title:!1!==(null===(w=K.attributes)||void 0===w?void 0:w.display_title)?K.title:"",content:!1!==(null===(I=K.attributes)||void 0===I?void 0:I.display_content)?K.content:"",subsections:[]},X?j:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:U,evaluationResult:P,displayContent:null===(R=K.attributes)||void 0===R?void 0:R.display_content,displayTitle:null===(C=K.attributes)||void 0===C?void 0:C.display_title});Number(q)>=0&&Number(U)>=0&&((null===(F=G.refIndexes)||void 0===F?void 0:F.includes(Number(U)))||null===(E=G.refIndexes)||void 0===E||E.push(Number(U)),(null===(_=J.refIndexes)||void 0===_?void 0:_.includes(Number(q)))||null===(k=J.refIndexes)||void 0===k||k.push(Number(q))),A[q]=G,H[U]=J;var Q=g(L.next,o+1),$=Q.refSections,Z=Q.baseSections;$.length>0&&(G.subsections=n(n([],G.subsections||[],!0),$,!0)),Z.length>0&&(J.subsections=n(n([],J.subsections||[],!0),Z,!0))}}return M=Object.values(A).map(function(e){return e}),D=Object.values(H).map(function(e){return e}),M.sort(function(e,t){return e.selfIndex<0&&t.selfIndex>=0?1:e.selfIndex>=0&&t.selfIndex<0?-1:e.selfIndex-t.selfIndex}),D.sort(function(e,t){return e.selfIndex<0&&t.selfIndex>=0?1:e.selfIndex>=0&&t.selfIndex<0?-1:e.selfIndex-t.selfIndex}),{refSections:M,baseSections:D}},x=g(h.next),m=x.refSections,y=x.baseSections;s=m,d=y}else h.next&&Object.values(h.next).forEach(function(e){var n=t[e]||a[e];n&&!1!==n.display_node&&(d.push(p(e,"0")||{id:e,title:"",content:"",subsections:[]}),s.push(p(e,"1")||{id:e,title:"",content:"",subsections:[]}))});return{activeProposed:{title:(null===(l=null===(o=h.comparison_inputs)||void 0===o?void 0:o[f[0]])||void 0===l?void 0:l.title)||"Uploaded Contract",description:h.decision_scope_description||"",sections:d},activeVariants:[{id:"tree-variant-1",title:(null===(u=null===(c=h.comparison_inputs)||void 0===c?void 0:c[f[1]])||void 0===u?void 0:u.title)||"Reference Template",similarity:0,sections:s,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:h.decision_scope_description||""},fields:{}}}}]}}(Q,ue,le);return e(e({},t),{parseError:null})}catch(e){return console.error("Data Transformation Error: ",e),{activeProposed:{},activeVariants:[],parseError:e instanceof Error?e.message:"Unknown Parsing Error"}}return{activeProposed:{},activeVariants:[],parseError:"Tree data is required"}},[JSON.stringify(Q),ue,JSON.stringify(le)]),yt=mt.activeProposed,bt=mt.activeVariants,St=mt.parseError;d(function(){St&&me("Failed to load comparison: ".concat(St))},[St]);var wt=u(null),It=wt[0];wt[1];var Rt=u({}),Ct=Rt[0],Ft=Rt[1],Et=u({}),_t=Et[0],Bt=Et[1],Tt=(null==bt?void 0:bt[0])||j,kt=null===(N=null===(o=null==Q?void 0:Q.documents)||void 0===o?void 0:o[null===(F=null==Q?void 0:Q.input_index_map)||void 0===F?void 0:F[0]])||void 0===N?void 0:N.title,Mt=null===(X=null===(K=null==Q?void 0:Q.documents)||void 0===K?void 0:K[null===(V=null==Q?void 0:Q.input_index_map)||void 0===V?void 0:V[1]])||void 0===X?void 0:X.title,Dt=E(Z||kt||"Uploaded Contract"),At=E(ee||Mt||"Reference Template"),Ht=c(function(){return(null==yt?void 0:yt.sections)||[]},[null==yt?void 0:yt.sections]),Ot=c(function(){return Tt.sections||[]},[Tt.sections]),Nt=Ht.length>0||Ot.length>0,Wt=Tt.analysis,zt=E(null===(U=null===(q=null==Wt?void 0:Wt.rule_difference_comparison)||void 0===q?void 0:q.summary)||void 0===U?void 0:U.overall_summary),Lt=!!zt.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),jt=a({}),Pt=function(e){return jt.current[e]||(jt.current[e]=l.createRef()),jt.current[e]},Yt=s(function(){Se(!1),je.current=!1,ln(null),Pe.current=null,Jt.current=null,Re(!1),pe(!1),ct.current&&(ct.current.style.height="0px"),ut.current&&(ut.current.style.height="0px"),at.current&&(at.current.style.height="0px"),dt.current&&(dt.current.style.height="0px")},[]),Kt=s(function(e,t,n,i,r,o){var l,c,u=E(t.id)||E(n.id)||"",a=(u?Ye[u]:null)||t.cognitiveData||n.cognitiveData||{section_id:u,decisioning:[],gap:[],relevance_score:0},d=null!==(c=null===(l=jt.current[i])||void 0===l?void 0:l.current)&&void 0!==c?c:null;return{open:!0,sectionTitle:t.title||"N/A",refSectionTitle:n.title||"NA",cognitiveData:a,anchorEl:e,sectionAnchorEl:d,badgeStyle:o||null,sectionIdx:i,docData:{documents:null==Q?void 0:Q.documents,input_index_map:null==Q?void 0:Q.input_index_map},deviationData:t.evaluationResult||n.evaluationResult||null,isOrphan:!!r}},[Ye,Q]),Vt=s(function(e){pt(),Xe(null),et(e)},[pt]),Xt=function(e,t,n,i,r,o){e.stopPropagation(),nt.open&&nt.sectionIdx===r?pt():(ht(),it(Kt(e.currentTarget,t,i,r,n,o)))},qt=s(function(){null!==nt.sectionIdx&&nt.anchorEl?Vt(e(e({},nt),{open:!0})):pt()},[nt,pt,Vt]),Ut=s(function(){var e=nt.sectionIdx,t=nt.isOrphan;pt(),null!==e&&(t?me("No counterpart exists to connect to."):(je.current&&Yt(),ke(function(t){return t.has(e)?new Set:new Set([e])})))},[nt.sectionIdx,pt,Yt]),Gt=a(null),Jt=a(null),Qt=a(null),$t=a(null),Zt=a(null),en=u([]),tn=en[0],nn=en[1],rn=u(null),on=rn[0],ln=rn[1];a(null);var cn=u(null),un=cn[0],an=cn[1],dn=c(function(){return xt.fields.filter(function(e){var t=e.key;return(!Nt||"description"!==t)&&(_(null==yt?void 0:yt[t])||_(Tt[t]))})},[yt,Tt,Nt,xt.fields]),sn=a({}),vn=a({}),fn=a({}),hn=a({}),pn=a({}),gn=a({}),xn=a({}),mn=a({}),yn=a({});dn.forEach(function(e){for(var t=e.key,n=0;n<Math.max(Ht.length,Ot.length);n+=1)fn.current[n]||(fn.current[n]=l.createRef()),hn.current[n]||(hn.current[n]=l.createRef()),pn.current[n]||(pn.current[n]=l.createRef()),gn.current[n]||(gn.current[n]=l.createRef()),xn.current[n]||(xn.current[n]=l.createRef());sn.current[t]||(sn.current[t]=l.createRef()),vn.current[t]||(vn.current[t]=l.createRef())});for(var bn=0;bn<Math.max(Ht.length,Ot.length);bn+=1)fn.current[bn]||(fn.current[bn]=l.createRef()),hn.current[bn]||(hn.current[bn]=l.createRef()),pn.current[bn]||(pn.current[bn]=l.createRef()),gn.current[bn]||(gn.current[bn]=l.createRef()),xn.current[bn]||(xn.current[bn]=l.createRef());d(function(){if(It){var e=xt.fields.find(function(e){return e.analysisKey===It||e.key===It});if(e){var t=sn.current[e.key]||vn.current[e.key];(null==t?void 0:t.current)&&setTimeout(function(){return t.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[It,xt.fields]);var Sn=s(function(e){var t,n,i,r,o,l,c,u,a,d=null===(t=null==Wt?void 0:Wt.rule_difference_comparison)||void 0===t?void 0:t.fields;if(!d||!d[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var s=d[e],v=(null==s?void 0:s.relation)||(null===(i=null===(n=null==s?void 0:s.highlights)||void 0===n?void 0:n.ruleA_spans)||void 0===i?void 0:i.length)||(null===(o=null===(r=null==s?void 0:s.highlights)||void 0===r?void 0:r.ruleB_spans)||void 0===o?void 0:o.length)||(null==s?void 0:s.mappings)&&s.mappings.length>0;if(s.mappings){var f=s.mappings[0]||{};return{score:s.score,relation:f.relation||"",highlightsA:(null===(l=f.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(c=f.highlights)||void 0===c?void 0:c.ruleB_spans)||[],hasContent:!!v}}return{score:s.score,relation:s.relation||"",highlightsA:(null===(u=s.highlights)||void 0===u?void 0:u.ruleA_spans)||[],highlightsB:(null===(a=s.highlights)||void 0===a?void 0:a.ruleB_spans)||[],hasContent:!!v}},[Wt]),wn=s(function(t){var n,i,r,o=Ht[t],l=Ot[t],c=(null==o?void 0:o.relation)&&"not_defined"!==o.relation,u=(null==l?void 0:l.relation)&&"not_defined"!==l.relation;E(null==o?void 0:o.id)||E(null==l?void 0:l.id);var a=!(!(null==o?void 0:o.cognitiveData)&&!(null==l?void 0:l.cognitiveData));if(!c&&!u&&!a)return e(e({},xt.relationStyles.noContent),{label:"Not Defined"});var d=null!==(i=null!==(n=null==o?void 0:o.evaluationResult)&&void 0!==n?n:null==l?void 0:l.evaluationResult)&&void 0!==i?i:null,s=(null===(r=null==d?void 0:d.evaluation_outputs)||void 0===r?void 0:r.output_value)+"%";return e(e({},xt.relationStyles.low),null!=d?{label:s}:{label:"N/A"})},[Ht,Ot,Ye,xt,Sn]),In=s(function(t){for(var n,i,r,o,l,c,u=t.split("-").map(Number),a=Ht[u[0]],d=Ot[u[0]],s=1;s<u.length;s++)(null==a?void 0:a.subsections)&&(a=a.subsections[u[s]]),(null==d?void 0:d.subsections)&&(d=d.subsections[u[s]]);if(!a&&!d)return null;var v=(null==a?void 0:a.relation)&&"not_defined"!==a.relation,f=(null==d?void 0:d.relation)&&"not_defined"!==d.relation,h=E(null==a?void 0:a.id)||E(null==d?void 0:d.id)||"",p=!(!(null==a?void 0:a.cognitiveData)&&!(null==d?void 0:d.cognitiveData));if(!v&&!f&&!p)return e(e({},xt.relationStyles.noContent),{label:"Not Defined"});null!==(i=null!==(n=null==a?void 0:a.cognitiveRelevanceScore)&&void 0!==n?n:null==d?void 0:d.cognitiveRelevanceScore)&&void 0!==i||h&&(null===(r=Ye[h])||void 0===r||r.relevance_score);var g=null!==(l=null!==(o=null==a?void 0:a.evaluationResult)&&void 0!==o?o:null==d?void 0:d.evaluationResult)&&void 0!==l?l:null,x=(null===(c=null==g?void 0:g.evaluation_outputs)||void 0===c?void 0:c.output_value)+"%";return e(e({},xt.relationStyles.low),null!=g?{label:x}:{label:"N/A"})},[Ht,Ot,Ye,xt]),Rn=s(function(){var t,n,i,r,o,l,c,u,a,d,s,v,f,h,p,g,x,m,y,b,S,w;if(!vt.current&&!Oe.current){vt.current=!0;try{if(!Gt.current)return;var I=function(e){var t=e.split("-"),n=t[0];if(!Ct[n]&&!1===ue)return!1;if(ue&&!Ct["left-".concat(n)]&&!Ct["right-".concat(n)]&&!Ct[n])return!1;for(var i=n,r=1;r<t.length-1;r++)if(i+="-".concat(t[r]),!_t[i])return!1;return!0},R=Gt.current.getBoundingClientRect();Je({width:R.width,height:R.height});var C=[];if(dn.forEach(function(e){var t,n,i=e.key,r=null===(t=sn.current[i])||void 0===t?void 0:t.current,o=null===(n=vn.current[i])||void 0===n?void 0:n.current;r&&o&&(r.style.height="auto",o.style.height="auto",r.style.minHeight="0px",o.style.minHeight="0px")}),!Oe.current){for(var F=0;F<Math.max(Ht.length,Ot.length);F++){var _=null===(t=fn.current[F])||void 0===t?void 0:t.current,B=null===(n=hn.current[F])||void 0===n?void 0:n.current;_&&(_.style.height="auto",_.style.minHeight="0px"),B&&(B.style.height="auto",B.style.minHeight="0px")}ue||Object.keys(mn.current).forEach(function(e){var t,n;if(I(e)){var i=null===(t=mn.current[e])||void 0===t?void 0:t.current,r=null===(n=yn.current[e])||void 0===n?void 0:n.current;i&&r&&(i.style.height="auto",r.style.height="auto",i.style.minHeight="0px",r.style.minHeight="0px")}})}var T={};dn.forEach(function(e){var t,n,i=e.key,r=null===(t=sn.current[i])||void 0===t?void 0:t.current,o=null===(n=vn.current[i])||void 0===n?void 0:n.current;if(r&&o){var l=r.getBoundingClientRect(),c=o.getBoundingClientRect();T[i]=Math.max(l.height,c.height)}});var k={left:{},right:{}},M={};if(!Oe.current)if(ue){if(be&&null!==on)if("number"==typeof on){var D=on,A=Ht[D],H=null===(o=fn.current[D])||void 0===o?void 0:o.current;H&&A&&(A.refIndexes||[]).forEach(function(e){var t,n=Ot.findIndex(function(t){return t.selfIndex===e}),i=null===(t=hn.current[n])||void 0===t?void 0:t.current;if(i&&(Ct["left-".concat(D)]||Ct["right-".concat(n)])){var r=Math.max(H.getBoundingClientRect().height,i.getBoundingClientRect().height);k.left[D]=Math.max(k.left[D]||0,r),k.right[n]=Math.max(k.right[n]||0,r)}})}else{var O=on.split(W)[0];_=null===(l=mn.current[O])||void 0===l?void 0:l.current,B=null===(c=yn.current[O])||void 0===c?void 0:c.current;if(_&&B){N=Math.max(_.getBoundingClientRect().height,B.getBoundingClientRect().height);M[O]=Math.max(M[O]||0,N)}}}else{Object.keys(mn.current).forEach(function(e){var t,n;if(I(e)){var i=null===(t=mn.current[e])||void 0===t?void 0:t.current,r=null===(n=yn.current[e])||void 0===n?void 0:n.current;if(i&&r&&null!==i.offsetParent&&null!==r.offsetParent){var o=i.getBoundingClientRect(),l=r.getBoundingClientRect(),c=Math.max(o.height,l.height);M[e]=c,i.style.minHeight="".concat(c,"px"),r.style.minHeight="".concat(c,"px")}}});for(F=0;F<Math.min(Ht.length,Ot.length);F++){var _=null===(i=fn.current[F])||void 0===i?void 0:i.current,B=null===(r=hn.current[F])||void 0===r?void 0:r.current;if(_&&B){var N=Math.max(_.getBoundingClientRect().height,B.getBoundingClientRect().height);k.left[F]=N,k.right[F]=N}}}if(dn.forEach(function(e){var t,n,i=e.key,r=null===(t=sn.current[i])||void 0===t?void 0:t.current,o=null===(n=vn.current[i])||void 0===n?void 0:n.current;if(r&&o){var l=T[i];r.style.minHeight="".concat(l,"px"),o.style.minHeight="".concat(l,"px")}}),Oe.current||(Object.entries(k.left).forEach(function(e){var t,n=e[0],i=e[1],r=null===(t=fn.current[Number(n)])||void 0===t?void 0:t.current;r&&(r.style.minHeight="".concat(i,"px"))}),Object.entries(k.right).forEach(function(e){var t,n=e[0],i=e[1],r=null===(t=hn.current[Number(n)])||void 0===t?void 0:t.current;r&&(r.style.minHeight="".concat(i,"px"))}),ue||Object.keys(M).forEach(function(e){var t,n,i=null===(t=mn.current[e])||void 0===t?void 0:t.current,r=null===(n=yn.current[e])||void 0===n?void 0:n.current;if(i&&r&&M[e]){var o=M[e];i.style.minHeight="".concat(o,"px"),r.style.minHeight="".concat(o,"px")}})),ue){if(Ht.forEach(function(e,t){var n;(null===(n=fn.current[t])||void 0===n?void 0:n.current)&&(e.refIndexes||[]).forEach(function(e){var n,i,r,o,l,c,u,a,d,s,v=Ot.findIndex(function(t){return t.selfIndex===e});if(-1!==v){var f=null===(n=pn.current[t])||void 0===n?void 0:n.current,h=null===(i=gn.current[v])||void 0===i?void 0:i.current;if(f&&h){var p=f.getBoundingClientRect(),g=h.getBoundingClientRect(),x=p.right-R.left,m=g.left-R.left,y=p.top+p.height/2-R.top,b=g.top+g.height/2-R.top;if(be&&on===t){var S=null!==(o=null===(r=st.current)||void 0===r?void 0:r.getBoundingClientRect().top)&&void 0!==o?o:0,w=null!==(c=null===(l=lt.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==c?c:0,I=S+(null!==(a=null===(u=st.current)||void 0===u?void 0:u.clientHeight)&&void 0!==a?a:1/0),F=w+(null!==(s=null===(d=lt.current)||void 0===d?void 0:d.clientHeight)&&void 0!==s?s:1/0),E=p.top+p.height/2,_=function(e,t,n){return Math.max(t,Math.min(n,e))};y=_(E,S,I)-R.top,b=_(E,w,F)-R.top}var B=wn(t);B&&C.push({id:"line-".concat(t,"-").concat(v),x1:x,y1:y,x2:m,y2:b,style:B,sectionIdx:t,targetRightIdx:v})}}})}),be&&"string"==typeof on){var z=on,j=(O=z.split(W)[0],null===(f=pn.current[z])||void 0===f?void 0:f.current),P=null===(h=gn.current[z])||void 0===h?void 0:h.current;if(j&&P){var Y=j.getBoundingClientRect(),K=P.getBoundingClientRect(),V=Y.right-R.left,X=K.left-R.left,q=null!==(g=null===(p=st.current)||void 0===p?void 0:p.getBoundingClientRect().top)&&void 0!==g?g:0,U=null!==(m=null===(x=lt.current)||void 0===x?void 0:x.getBoundingClientRect().top)&&void 0!==m?m:0,G=q+(null!==(b=null===(y=st.current)||void 0===y?void 0:y.clientHeight)&&void 0!==b?b:1/0),J=U+(null!==(w=null===(S=lt.current)||void 0===S?void 0:S.clientHeight)&&void 0!==w?w:1/0),Q=Y.top+Y.height/2,$=K.top+K.height/2,Z=function(e,t,n){return Math.max(t,Math.min(n,e))},ee=Z(Q,q,G)-R.top,te=Z($,U,J)-R.top;(re=In(O))&&C.push({id:"line-subsec-".concat(z),x1:V,y1:ee,x2:X,y2:te,style:re,sectionIdx:Number(O.split("-")[0]),isSubSection:!0,subSectionKeyPath:z})}}}else{for(F=0;F<Math.min(Ht.length,Ot.length);F++){var ne=null===(u=fn.current[F])||void 0===u?void 0:u.current,ie=null===(a=hn.current[F])||void 0===a?void 0:a.current;if(ne&&ie){var re,oe=ne.getBoundingClientRect(),le=ie.getBoundingClientRect(),ce=Math.max(oe.top,le.top)+18-R.top,ae=(null===(d=Ot[F])||void 0===d?void 0:d.id)||"sec-".concat(F);(re=wn(F))&&C.push({id:ae,x1:oe.right-R.left,y1:ce,x2:le.left-R.left,y2:ce,style:re,sectionIdx:F,hasCognitive:!!((null===(s=Ht[F])||void 0===s?void 0:s.cognitiveData)||(null===(v=Ot[F])||void 0===v?void 0:v.cognitiveData)||ae&&Ye[ae])})}}Object.keys(pn.current).forEach(function(t){var n,i,r,o,l,c,u,a,d,s;if(t.includes(W)){var v=t.split(W)[0];if(I(v)){var f=null===(n=pn.current[t])||void 0===n?void 0:n.current,h=null===(i=gn.current[t])||void 0===i?void 0:i.current;if(f&&h&&null!==f.offsetParent&&null!==h.offsetParent){for(var p=f.getBoundingClientRect(),g=h.getBoundingClientRect(),x=p.top+p.height/2-R.top,m=g.top+g.height/2-R.top,y=v.split("-").map(Number),b=Ht[y[0]],S=Ot[y[0]],w=1;w<y.length;w++)(null==b?void 0:b.subsections)&&(b=b.subsections[y[w]]),(null==S?void 0:S.subsections)&&(S=S.subsections[y[w]]);if(!b&&!S)return;var F=(null==b?void 0:b.relation)&&"not_defined"!==b.relation,_=(null==S?void 0:S.relation)&&"not_defined"!==S.relation,B=E(null==b?void 0:b.id)||E(null==S?void 0:S.id)||"",T=!(!(null==b?void 0:b.cognitiveData)&&!(null==S?void 0:S.cognitiveData)),k=null;if(F||_||T){var M=null!==(o=null!==(r=null==b?void 0:b.evaluationResult)&&void 0!==r?r:null==S?void 0:S.evaluationResult)&&void 0!==o?o:null,D=null!==(s=null!==(a=null!==(c=null===(l=null==M?void 0:M.evaluation_output)||void 0===l?void 0:l.output_score)&&void 0!==c?c:null===(u=null==M?void 0:M.evaluation_outputs)||void 0===u?void 0:u.output_score)&&void 0!==a?a:null===(d=null==M?void 0:M.evaluation_outputs)||void 0===d?void 0:d.output_value)&&void 0!==s?s:null==M?void 0:M.output_score,A=null!=D?"".concat(D,"%"):"N/A";k=e(e({},xt.relationStyles.low),null!=M?{label:A}:{label:"N/A"})}else k={badgeBg:"#EEF2FF",badgeText:"#3730A3",badgeBorder:"#C7D2FE",label:"N/A"};k&&C.push({id:"line-subsec-".concat(t),x1:p.right-R.left,y1:x,x2:g.left-R.left,y2:m,style:k,sectionIdx:y[0],isSubSection:!0,subSectionKeyPath:t,hasCognitive:T||!(!B||!Ye[B])})}}}})}if(nn(C),$t.current&&Zt.current){var de=$t.current.getBoundingClientRect(),se=Zt.current.getBoundingClientRect(),ve=(de.top+de.height/2-R.top+se.top+se.height/2-R.top)/2;an({x1:de.right-R.left,x2:se.left-R.left,y:ve})}else an(null);if(ue&&Te.size>0){var fe=[],he=st.current,pe=lt.current;if(he&&pe){var ge=[],xe=he.getBoundingClientRect().top,me=pe.getBoundingClientRect().top,ye=xe+he.clientHeight,Se=me+pe.clientHeight,we=he.scrollTop,Ie=pe.scrollTop,Re=R.top,Ce=function(e,t,n){return Math.max(t,Math.min(n,e))};Te.forEach(function(e){var t,n,i;if("string"==typeof e){var r=e,o=r.split(W)[0],l=null===(t=pn.current[r])||void 0===t?void 0:t.current,c=null===(n=gn.current[r])||void 0===n?void 0:n.current;if(!l||!c)return;var u=l.getBoundingClientRect(),a=c.getBoundingClientRect(),d=In(o),s=u.right-R.left,v=a.left-R.left-0,f=s+.5*(v-s),h=u.top+u.height/2,p=a.top+a.height/2,g=h-xe+we,x=p-me+Ie,m="conn-subsec-".concat(r);ge.push({lhsScrollY:g,rhsScrollY:x,x1:s,x2:v,containerTop:Re,leftIdx:r,rhsArrayIdx:r,styleColor:(null==d?void 0:d.badgeBorder)||"#6366F1",styleId:m});var y=Ce(h,xe,ye),b=Ce(p,me,Se),S=y-Re,w=b-Re,I=h>=xe-4&&h<=ye+4,C=p>=me-4&&p<=Se+4,F="";F=I&&C?L(s,S,v,w):I&&!C?"M ".concat(s,",").concat(S," L ").concat(f,",").concat(S," L ").concat(f,",").concat(w):!I&&C?"M ".concat(f,",").concat(S," L ").concat(f,",").concat(w," L ").concat(v,",").concat(w):"M ".concat(f,",").concat(S," L ").concat(f,",").concat(w),fe.push({id:m,pathD:F,style:d,leftIdx:r,rhsArrayIdx:r})}else{var E=Ht[e];if(!(null===(i=null==E?void 0:E.refIndexes)||void 0===i?void 0:i.length))return;E.refIndexes.forEach(function(t){var n,i,r=Ot.findIndex(function(e){return e.selfIndex===t});if(-1!==r){var o=null===(n=pn.current[e])||void 0===n?void 0:n.current,l=null===(i=gn.current[r])||void 0===i?void 0:i.current;if(o&&l){var c=o.getBoundingClientRect(),u=l.getBoundingClientRect(),a=wn(e),d=c.right-R.left,s=u.left-R.left-0,v=d+.5*(s-d),f=c.top+c.height/2,h=u.top+u.height/2,p=f-xe+we,g=h-me+Ie,x="conn-".concat(e,"-").concat(r);ge.push({lhsScrollY:p,rhsScrollY:g,x1:d,x2:s,containerTop:Re,leftIdx:e,rhsArrayIdx:r,styleColor:(null==a?void 0:a.badgeBorder)||"#6366F1",styleId:x});var m=Ce(f,xe,ye),y=Ce(h,me,Se),b=m-Re,S=y-Re,w=f>=xe-4&&f<=ye+4,I=h>=me-4&&h<=Se+4,C="";C=w&&I?L(d,b,s,S):w&&!I?"M ".concat(d,",").concat(b," L ").concat(v,",").concat(b," L ").concat(v,",").concat(S):!w&&I?"M ".concat(v,",").concat(b," L ").concat(v,",").concat(S," L ").concat(s,",").concat(S):"M ".concat(v,",").concat(b," L ").concat(v,",").concat(S),fe.push({id:x,pathD:C,style:a,leftIdx:e,rhsArrayIdx:r})}}})}}),ze.current=ge}Ae(fe)}else Ae([]),ze.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{vt.current=!1}}},[dn,Ht,Ot,Ye,xt,Sn,wn,ue,be,on,Te,Ct,_t]),Cn=s(function(){var e,t,n,i,r,o,l,c,u,a,d,s,v,f,h=ze.current;if(h.length&&!Oe.current){var p=null!==(t=null===(e=st.current)||void 0===e?void 0:e.scrollTop)&&void 0!==t?t:0,g=null!==(i=null===(n=lt.current)||void 0===n?void 0:n.scrollTop)&&void 0!==i?i:0,x=null!==(o=null===(r=st.current)||void 0===r?void 0:r.clientHeight)&&void 0!==o?o:1/0,m=null!==(c=null===(l=lt.current)||void 0===l?void 0:l.clientHeight)&&void 0!==c?c:1/0,y=null!==(a=null===(u=st.current)||void 0===u?void 0:u.getBoundingClientRect().top)&&void 0!==a?a:0,b=null!==(s=null===(d=lt.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==s?s:0,S=y+x,w=b+m,I=null!==(f=null===(v=Gt.current)||void 0===v?void 0:v.getBoundingClientRect().top)&&void 0!==f?f:0,R=function(e,t,n){return Math.max(t,Math.min(n,e))};h.forEach(function(e){var t=e.lhsScrollY-p+y,n=e.rhsScrollY-g+b,i=We.current[e.styleId+"-stroke"],r=We.current[e.styleId+"-bg"];if(i||r){var o,l=R(t,y,S),c=R(n,b,w),u=l-I,a=c-I,d=t>=y-4&&t<=S+4,s=n>=b-4&&n<=w+4,v=e.x1+.5*(e.x2-e.x1);o=d&&s?L(e.x1,u,e.x2,a):d&&!s?"M ".concat(e.x1,",").concat(u," L ").concat(v,",").concat(u," L ").concat(v,",").concat(a):!d&&s?"M ".concat(v,",").concat(u," L ").concat(v,",").concat(a," L ").concat(e.x2,",").concat(a):"M ".concat(v,",").concat(u," L ").concat(v,",").concat(a),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",o)),r&&(r.setAttribute("visibility","visible"),r.setAttribute("d",o))}})}},[]),Fn=a(Rn);d(function(){Fn.current=Rn},[Rn]);var En=a(null),_n=s(function(){null!==En.current&&clearTimeout(En.current),En.current=setTimeout(function(){Fn.current(),En.current=null},50)},[]),Bn=s(function(e){var t,n,i,r,o,l,c,u;if(!Ce.current){if(ue||_n(),je.current){var a=Pe.current,d=Jt.current,s=st.current,v=lt.current;if(null!==a&&null!==d&&s&&v){var f="string"==typeof a?null===(t=pn.current[a])||void 0===t?void 0:t.current:null===(n=jt.current[a])||void 0===n?void 0:n.current,h="string"==typeof d?null===(i=gn.current[d])||void 0===i?void 0:i.current:null===(r=xn.current[d])||void 0===r?void 0:r.current;if(f&&h){var p=f.getBoundingClientRect().top-s.getBoundingClientRect().top+s.scrollTop,g=h.getBoundingClientRect().top-v.getBoundingClientRect().top+v.scrollTop;if(e.currentTarget===s){var x=g-(p-s.scrollTop),m=v.scrollHeight-v.clientHeight,y=Math.max(0,Math.min(x,m));Math.abs(v.scrollTop-y)>1&&(v.scrollTop=y)}else if(e.currentTarget===v){var b=p-(g-v.scrollTop),S=s.scrollHeight-s.clientHeight,w=Math.max(0,Math.min(b,S));Math.abs(s.scrollTop-w)>1&&(s.scrollTop=w)}if(Qt.current){var I=null===(o=pn.current[a])||void 0===o?void 0:o.current,R=null===(l=gn.current[d])||void 0===l?void 0:l.current,C=null!==(u=null===(c=Gt.current)||void 0===c?void 0:c.getBoundingClientRect().top)&&void 0!==u?u:0,F=s.getBoundingClientRect().top,E=F+s.clientHeight,_=v.getBoundingClientRect().top,B=_+v.clientHeight,T=function(e,t,n){return Math.max(t,Math.min(n,e))};if(I&&R){var k=I.getBoundingClientRect(),M=R.getBoundingClientRect(),D=k.top+k.height/2,A=M.top+M.height/2,H=T(D,F,E),O=T(A,_,B);Qt.current.setAttribute("y1",(H-C).toString()),Qt.current.setAttribute("y2",(O-C).toString());var N=D>=F-4&&D<=E+4;Qt.current.setAttribute("visibility",N?"visible":"hidden")}}}}}ze.current.length>0&&!Le.current&&(Le.current=!0,requestAnimationFrame(function(){Cn(),Le.current=!1}))}},[Cn,ue,_n]);d(function(){var e=setTimeout(_n,250);window.addEventListener("resize",_n);var t=null,n=null;return rt.current&&(t=new ResizeObserver(_n)).observe(rt.current),Gt.current&&(n=new ResizeObserver(_n)).observe(Gt.current),function(){clearTimeout(e),window.removeEventListener("resize",_n),null==t||t.disconnect(),null==n||n.disconnect()}},[yt,Tt,Wt,dn,Ct,_t,Ht,Ot,xt,_n,be,on,Ie,Te]),d(function(){je.current=be},[be]),d(function(){Pe.current=on},[on]);var Tn=s(function(){var e=nt.sectionIdx,t=nt.isOrphan;pt(),null!=e&&(t?me("No counterpart exists for this section."):be&&on===e?Yt():(ke(new Set),Ae([]),ze.current=[],pe(!0),Ce.current=!0,ln(e),Pe.current=e,Se(!0),je.current=!0,Re(!1),ct.current&&(ct.current.style.height="0px"),ut.current&&(ut.current.style.height="0px"),at.current&&(at.current.style.height="0px"),dt.current&&(dt.current.style.height="0px"),requestAnimationFrame(function(){var t,n,i,r,o=null,l=null,c=null;if("string"==typeof e)o=(null===(t=pn.current[e])||void 0===t?void 0:t.current)||null,c=(l=(null===(n=gn.current[e])||void 0===n?void 0:n.current)||null)?e:null;else{o=(null===(i=jt.current[e])||void 0===i?void 0:i.current)||null;var u=Ht[e],a=(null==u?void 0:u.refIndexes)||[];if(a.length>0){var d=a[0],s=Ot.findIndex(function(e){return e.selfIndex===d});-1!==s&&(l=(null===(r=xn.current[s])||void 0===r?void 0:r.current)||null,c=s)}}Jt.current=c;var v=st.current,f=lt.current;if(!o||!v)return Ce.current=!1,void pe(!1);if(!l||!f)return Re(!0),Fn.current(),Ce.current=!1,void pe(!1);var h=o.getBoundingClientRect().top-v.getBoundingClientRect().top+v.scrollTop,p=l.getBoundingClientRect().top-f.getBoundingClientRect().top+f.scrollTop-(h-v.scrollTop);p<0&&ct.current&&(ct.current.style.height="".concat(Math.abs(p),"px"));requestAnimationFrame(function(){var e,t=f.scrollHeight-f.clientHeight;if(p<0)e=0;else{if(p>t){var n=p-t;return ut.current&&(ut.current.style.height="".concat(n+150,"px")),void requestAnimationFrame(function(){Y(f,p,200,function(){Re(!0),Fn.current(),Ce.current=!1,pe(!1)})})}e=p}Y(f,e,200,function(){Re(!0),Fn.current(),Ce.current=!1,pe(!1)})})})))},[pt,nt.sectionIdx,be,on,Ht,Ot,_n,Yt]),kn=null!==nt.sectionIdx&&Te.has(nt.sectionIdx),Mn=function(t){var n,o,c,u=t.section,a=t.idx,d=t.columnKey,s=t.colRef,h=t.mb,p=void 0===h?1:h,g=t.parentNodeId,x=void 0===g?"":g,w=ue?!!Ct["".concat(d,"-").concat(a)]:!!Ct[String(a)],R=(null===(n=u.displayTitle)||void 0===n||n)&&_(u.title),C=(null===(o=u.displayContent)||void 0===o||o)&&_(u.content),F=!R&&!C,B=u.title;R||(B=C?"No Title Found":"No Matching Section Found");var T,k=[];if(null===(c=u.evaluationResult)||void 0===c?void 0:c.deviations){var M=u.evaluationResult.deviations;for(var D in M){var A=M[D][x];A&&k.push(A)}}return i(v,e({ref:s,sx:{mb:p,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:r(y,e({disableGutters:!0,expanded:!F&&w,onChange:function(){return!F&&function(t,n){var i,r;Oe.current=!0,Ne.current&&clearTimeout(Ne.current),He.current&&(He.current.style.opacity="0");var o=null===(i=fn.current[t])||void 0===i?void 0:i.current,l=null===(r=hn.current[t])||void 0===r?void 0:r.current;if(o&&(o.style.minHeight="0px"),l&&(l.style.minHeight="0px"),Object.keys(mn.current).forEach(function(e){var n,i;if(e.startsWith("".concat(t,"-"))){var r=null===(n=mn.current[e])||void 0===n?void 0:n.current,o=null===(i=yn.current[e])||void 0===i?void 0:i.current;r&&(r.style.minHeight="0px"),o&&(o.style.minHeight="0px")}}),ue){var c=Ht[t];((null==c?void 0:c.refIndexes)||[]).forEach(function(e){var t,n=Ot.findIndex(function(t){return t.selfIndex===e}),i=null===(t=hn.current[n])||void 0===t?void 0:t.current;i&&(i.style.minHeight="0px")});var u=Ot[t],a=null==u?void 0:u.selfIndex;Ht.forEach(function(e,t){var n,i;if(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(a)){var r=null===(i=fn.current[t])||void 0===i?void 0:i.current;r&&(r.style.minHeight="0px")}})}Ne.current=setTimeout(function(){Oe.current=!1,Fn.current(),He.current&&(He.current.style.opacity="1")},650),Ft(function(i){var r=e({},i);if(!ue){var o=!!i[String(t)];return r[String(t)]=!o,r}var l="".concat(n,"-").concat(t),c=!i[l];if(r[l]=c,"left"===n)((null==(u=Ht[t])?void 0:u.refIndexes)||[]).forEach(function(e){var t=Ot.findIndex(function(t){return t.selfIndex===e});-1!==t&&(r["right-".concat(t)]=c)});else{var u,a=null==(u=Ot[t])?void 0:u.selfIndex;Ht.forEach(function(e,t){var n;(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(a))&&(r["left-".concat(t)]=c)})}return r})}(a,d)},sx:{boxShadow:"none",border:F?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:F?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flexGrow:1,width:"100%",display:"flex",flexDirection:"column",minWidth:0,"&:before":{display:"none"}}},{children:[i(b,e({expandIcon:F?null:i(I,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:F?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:R&&i(m,e({title:B,placement:"top"},{children:i(f,e({component:"div",sx:{fontSize:"12px",color:F?"#94A3B8":"#19213D",fontWeight:F?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(T=B,T?E(T).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(e,t){return e.startsWith("**")&&e.endsWith("**")?i("strong",{children:e.slice(2,-2)},t):i(l.Fragment,{children:e},t)}):null)}))}))})),!F&&r(S,e({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[C&&i(z,{content:u.content,sxStyles:Qe,highlights:k,maintainRelativeOrder:ue}),(u.subsections||[]).map(function(e,t){return Dn({section:e,keyPath:"".concat(a,"-").concat(t),depth:0,columnKey:d,parentNodeId:x})})]}))]}))}),"".concat(d,"-sec-").concat(a))},Dn=function(t){var n,o,c,u,a,d,s,h,p,g=t.section,x=t.keyPath,m=t.depth,w=void 0===m?0:m,R=t.columnKey,C=void 0===R?"left":R,F=t.parentNodeId,E=void 0===F?"":F,B=(null===(n=g.displayTitle)||void 0===n||n)&&_(g.title),T=(null===(o=g.displayContent)||void 0===o||o)&&_(g.content),k=!B&&!T,M=B?g.title:T?"No Title Found":"No Matching Section Found",D=!!_t[x];"left"!==C||mn.current[x]||(mn.current[x]=l.createRef()),"right"!==C||yn.current[x]||(yn.current[x]=l.createRef());for(var A="left"===C?mn.current[x]:yn.current[x],H=In(x),O=x.split("-").map(Number),N=Ht[O[0]],L=Ot[O[0]],j=1;j<O.length;j++)(null==N?void 0:N.subsections)&&(N=N.subsections[O[j]]),(null==L?void 0:L.subsections)&&(L=L.subsections[O[j]]);var P=null===(c=null==Q?void 0:Q.input_index_map)||void 0===c?void 0:c[0],Y=null===(u=null==Q?void 0:Q.input_index_map)||void 0===u?void 0:u[1],K="left"===C?Y:P,V=!(null===(a=g.refIndexes)||void 0===a?void 0:a.length)||void 0!==g.selfIndex&&g.selfIndex<0,X=null!==(h=null===(s=null===(d=g.evaluationResult)||void 0===d?void 0:d.evaluation_outputs)||void 0===s?void 0:s.output_value)&&void 0!==h?h:null,q=Object.entries((null===(p=g.evaluationResult)||void 0===p?void 0:p.deviations)||{}).map(function(e,t){var n=e[0],i=e[1],r=i[E];if(!r||"No equivalent clause present."===r)return null;var o=function(e,t){return"".concat(e).concat(W).concat(t)}(x,n),c=i[K],u=V||!c||"No equivalent clause present."===c,a=O[0]+1,d="".concat(a,".").concat(t+1);return"left"!==C||pn.current[o]||(pn.current[o]=l.createRef()),"right"!==C||gn.current[o]||(gn.current[o]=l.createRef()),{id:o,label:d,highlight:r,side:C,style:H,score:X,isConnected:ue&&Te.has(o),isOrphan:u,badgeRef:"left"===C?pn.current[o]:gn.current[o],onClick:function(e){e.stopPropagation(),Xt(e,N||{title:"",content:""},u,L||{title:"",content:""},o,H)}}}).filter(Boolean),U=ue&&q.some(function(e){return Te.has(e.id)});return B||T||g.subsections&&0!==g.subsections.length?i(v,B?e({ref:A,sx:{mt:1,width:"100%",minWidth:0,position:"relative"}},{children:i(v,e({sx:e({width:"100%"},U&&H&&{borderRadius:"4px",outline:"2px solid ".concat(H.badgeBorder),outlineOffset:"1px"})},{children:r(y,e({disableGutters:!0,expanded:!k&&D,onChange:function(){return!k&&Bt(function(t){var n;return e(e({},t),((n={})[x]=!t[x],n))})},sx:{mt:0,boxShadow:"none",border:k?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF",minWidth:0,"&:before":{display:"none"}}},{children:[i(b,e({expandIcon:k?null:i(I,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"}}},{children:i(f,e({component:"div",sx:{fontSize:"11px",fontWeight:600,color:k?"#94A3B8":"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:M||"Untitled Subsection"}))})),!k&&r(S,e({sx:{pt:0,pb:1,minWidth:0}},{children:[T&&i(z,{content:g.content,sxStyles:Qe,deviationBadges:q,maintainRelativeOrder:ue}),(g.subsections||[]).map(function(e,t){return Dn({section:e,keyPath:"".concat(x,"-").concat(t),depth:w+1,columnKey:C,parentNodeId:E})})]}))]}))}))}):e({ref:A,sx:{mt:0===w?1:.75,width:"100%",minWidth:0,position:"relative"}},{children:!k&&r(v,e({sx:e({width:"100%"},U&&H&&{borderRadius:"4px",outline:"2px solid ".concat(H.badgeBorder),outlineOffset:"1px"})},{children:[T&&i(z,{content:g.content,sxStyles:Qe,deviationBadges:q,maintainRelativeOrder:ue}),(g.subsections||[]).map(function(e,t){return Dn({section:e,keyPath:"".concat(x,"-").concat(t),depth:w+1,columnKey:C,parentNodeId:E})})]}))}),x):null};return r(v,e({ref:ot,sx:e(e({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},ue?{}:{overflow:"visible"}),{position:"relative"})},{children:[se&&i(v,e({sx:{position:"absolute",inset:0,bgcolor:"rgba(255, 255, 255, 0.6)",backdropFilter:"blur(10px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"8px"}},{children:i(O,{})})),ue&&i(H,{open:nt.open,anchorEl:nt.anchorEl,sectionTitle:nt.sectionTitle,referenceSectionTitle:nt.refSectionTitle,onClose:pt,onOpenCognitiveCompare:qt,onOpenSideBySide:Tn,onConnect:Ut,isConnected:kn,isOrphan:nt.isOrphan}),Ze.open&&i(A,{open:Ze.open,popupRef:qe,position:Ve,popupConfig:re,onClose:function(){Xe(null),et(function(t){return e(e({},t),{open:!1})}),_e(null)},markdownStyles:te,sectionTitle:Ze.sectionTitle,referenceSectionTitle:Ze.refSectionTitle,cognitiveData:Ze.cognitiveData,anchorEl:Ze.anchorEl,sectionAnchorEl:Ze.sectionAnchorEl,scrollContainerEl:rt.current,badgeStyle:Ze.badgeStyle,docData:Ze.docData,deviationData:Ze.deviationData}),i(h,e({open:!!xe,autoHideDuration:8e3,onClose:function(){return me(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:i(p,e({onClose:function(){return me(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:xe}))})),(ie.isHeaderVisible||ie.isToggleVisible)&&r(v,e({sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between",bgcolor:"#FFFFFF",border:"1.5px solid #EEF0F4",borderTopLeftRadius:"8px",borderTopRightRadius:"8px"}},{children:[i(v,e({sx:{display:"flex",alignItems:"center",gap:1}},{children:ie.isHeaderVisible&&i(f,e({sx:{fontSize:"16px",fontWeight:600,color:"#0F172A"}},{children:J}))})),ie.isToggleVisible&&i(v,e({sx:{display:"flex",alignItems:"center"}},{children:i(g,{control:i(x,{checked:ue,onChange:function(e){var t=e.target.checked;ve(!0),setTimeout(function(){ae(t),Yt(),ke(new Set),Ae([]),ze.current=[],setTimeout(function(){ve(!1)},400)},50)},color:"primary",size:"small",sx:{width:100,height:26,padding:0,"& .MuiSwitch-switchBase":{padding:0,margin:"3px",transitionDuration:"300ms","&.Mui-checked":{transform:"translateX(75px)",color:"#fff","& + .MuiSwitch-track":{backgroundColor:"#5928ED",opacity:1,border:0,"&::before":{content:'"Side by Side"',position:"absolute",left:"13px",top:"50%",transform:"translateY(-50%)",fontSize:"9px",fontWeight:700,color:"#fff",letterSpacing:"0.3px"}}}},"& .MuiSwitch-thumb":{boxSizing:"border-box",width:20,height:20},"& .MuiSwitch-track":{borderRadius:13,backgroundColor:"#9e9e9e",opacity:1,position:"relative","&::after":{content:'"Side by Side"',position:"absolute",right:"13px",top:"50%",transform:"translateY(-50%)",fontSize:"9px",fontWeight:700,color:"#fff",letterSpacing:"0.3px",opacity:1,transition:"opacity 0.2s"}},"& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track":{"&::after":{opacity:0}}}}),label:"",labelPlacement:"start",sx:{m:0,gap:1}})}))]})),i(v,e({ref:rt,onScroll:Bn,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:ue?"hidden":"auto",borderTop:zt&&Lt?"none":"1.5px solid #EEF0F4"}},{children:i(v,e({sx:e({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},ue?{flex:1,minHeight:0}:{})},{children:r(v,e({ref:Gt,sx:e({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"10px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},ue?{flex:1,overflow:"visible"}:{})},{children:[r("svg",e({ref:He,style:{position:"absolute",top:0,left:0,width:Ge.width||"100%",height:Ge.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",transition:"opacity 0.15s ease-in-out"}},{children:[un&&r("g",{children:[i("line",{x1:un.x1,y1:un.y,x2:Math.max(un.x1,(un.x1+un.x2)/2-70),y2:un.y,stroke:"#BBF7D0",strokeWidth:"1.5"}),i("line",{x1:Math.min(un.x2,(un.x1+un.x2)/2+70),y1:un.y,x2:un.x2,y2:un.y,stroke:"#BBF7D0",strokeWidth:"1.5"})]}),tn.map(function(t){var n,o=t.x1+.5*(t.x2-t.x1),l=(t.y1+t.y2)/2;if("Not Defined"===t.style.label&&!t.hasCognitive)return null;if(!ue){var c=t.isSubSection?L(t.x1,t.y1,t.x2,t.y2):"M ".concat(t.x1," ").concat(t.y1," L ").concat(t.x2," ").concat(t.y2);return r("g",{children:[i("defs",{children:i("marker",e({id:"arr-norm-".concat(t.id),markerWidth:"7",markerHeight:"5",refX:"7",refY:"2.5",orient:"auto"},{children:i("polygon",{points:"0 0, 7 2.5, 0 5",fill:t.style.badgeBorder||"#E2E8F0"})}))}),i("path",{d:c,fill:"none",stroke:t.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5",markerEnd:"url(#arr-norm-".concat(t.id,")")}),i("foreignObject",e({x:o-100,y:l-14,width:"200",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:i(v,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:r(v,e({onClick:function(e){if(e.stopPropagation(),Ze.open&&Ee===t.id)ht();else{var n=Ht[t.sectionIdx]||{title:"",content:""},i=Ot[t.sectionIdx]||{title:"",content:""};if(t.isSubSection&&t.subSectionKeyPath){for(var r=t.subSectionKeyPath.split("-").map(Number),o=Ht[r[0]],l=Ot[r[0]],c=1;c<r.length;c++)(null==o?void 0:o.subsections)&&(o=o.subsections[r[c]]),(null==l?void 0:l.subsections)&&(l=l.subsections[r[c]]);o&&(n=o),l&&(i=l)}_e(t.id),Vt(Kt(e.currentTarget,n,i,t.sectionIdx,t.style))}},sx:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:t.style.badgeBg,color:t.style.badgeText,border:"1px solid ".concat(t.style.badgeBorder),borderRadius:"12px",px:1.5,py:.5,fontWeight:500,textAlign:"center",whiteSpace:"nowrap",cursor:"pointer"}},{children:[t.style.label,i(v,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:i(R,{})})),i(I,{size:11,style:{transform:Ze.open&&Ee===t.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},t.id)}var u=!1;if(t.isSubSection)u=be&&on===t.subSectionKeyPath&&Ie;else{var a=Ht[t.sectionIdx];if(!(null===(n=null==a?void 0:a.refIndexes)||void 0===n?void 0:n.length)||(null==a?void 0:a.selfIndex)<0)return null;u=be&&on===t.sectionIdx&&Ie}return u?r("g",e({style:{transition:"opacity 0.2s"}},{children:[i("defs",{children:i("marker",e({id:"arr-".concat(t.id),markerWidth:"7",markerHeight:"5",refX:"7",refY:"2.5",orient:"auto"},{children:i("polygon",{points:"0 0, 7 2.5, 0 5",fill:t.style.badgeBorder||"#6366F1"})}))}),i("line",{ref:Qt,x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.badgeBorder||"#6366F1",strokeWidth:"1.5",markerEnd:"url(#arr-".concat(t.id,")")})]}),t.id):null}),De.map(function(t){var n,o=t.pathD,l=(null===(n=t.style)||void 0===n?void 0:n.badgeBorder)||"#6366F1",c="conn-marker-".concat(t.id),u="".concat(t.id,"-bg"),a="".concat(t.id,"-stroke");return r("g",{children:[i("defs",{children:i("clipPath",e({id:"connections-clip"},{children:i("marker",e({id:c,markerWidth:"8",markerHeight:"6",refX:"7",refY:"3",orient:"auto"},{children:i("polygon",{points:"0 0, 8 3, 0 6",fill:l})}))}))}),i("path",{ref:function(e){We.current[u]=e},d:o,fill:"none",stroke:"#FFFFFF",strokeWidth:"4",strokeOpacity:"0.7"}),i("path",{ref:function(e){We.current[a]=e},d:o,fill:"none",stroke:l,strokeWidth:"1.75",markerEnd:"url(#".concat(c,")")})]},t.id)})]})),r(v,e({sx:e({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},ue?{flex:1,overflow:"visible"}:{})},{children:[i(v,e({ref:$t,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",minHeight:"40px",alignItems:"center",overflowX:"hidden"}},{children:i(m,e({title:Dt,placement:"top"},{children:i(f,e({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center",textOverflow:"ellipsis",whiteSpace:"normal",width:"100%",height:"40px"}},{children:Dt}))}))})),r(v,e({ref:st,onScroll:Bn,sx:e({p:"12px",display:"flex",flexDirection:"column"},ue?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-160px",pr:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[i("div",{ref:at,style:{width:"100%",height:"0px",flexShrink:0}}),Nt&&Ht.map(function(t,n){var o,c,u,a=!t.title&&!t.content;if(ue&&a)return null;if(!ue)return i(v,e({ref:Pt(n),sx:{width:"100%"}},{children:Mn({section:t,idx:n,columnKey:"left",colRef:fn.current[n],parentNodeId:(null===(o=null==Q?void 0:Q.input_index_map)||void 0===o?void 0:o[0])||""})}),"left-row-".concat(n));var d=t,s=wn(n),f=!(null===(c=d.refIndexes)||void 0===c?void 0:c.length)||d.selfIndex<0,h="number"==typeof d.selfIndex&&d.selfIndex>=0?d.selfIndex+1:null,p=Te.has(n);return i(v,e({ref:Pt(n),sx:{mb:1}},{children:r(v,e({sx:{position:"relative",width:"100%"}},{children:[i(v,e({ref:fn.current[n],sx:e({width:"100%",display:"flex"},p&&{borderRadius:"6px",outline:"2px solid ".concat((null==s?void 0:s.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:Mn({section:t,idx:n,columnKey:"left",colRef:l.createRef(),mb:0,parentNodeId:(null===(u=null==Q?void 0:Q.input_index_map)||void 0===u?void 0:u[0])||""})})),s&&r(v,e({ref:pn.current[n],onClick:function(e){var i=Ot.find(function(e){var t;return null===(t=d.refIndexes)||void 0===t?void 0:t.includes(e.selfIndex)})||{title:"",content:""};Xt(e,t,f,i,n,s)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:s.badgeBg,color:s.badgeText,border:"1px solid ".concat(s.badgeBorder),borderRadius:"12px",px:1.2,py:.4,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[null!==h&&i(v,e({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(s.badgeBorder)}},{children:h})),i(v,e({component:"span",sx:{fontSize:"11px",px:.25}},{children:f?"No Deviation Found":0==s.deviationLabel||void 0===s.deviationLabel?s.label:"".concat(s.deviationLabel,"% Deviation")})),i(w,{size:11,color:s.badgeText})]}))]}))}),"left-row-".concat(n))}),i("div",{ref:dt,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),i(v,e({sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0}},{children:i(v,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:r(v,e({sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",borderRadius:"20px",bgcolor:"#ECFDF3",border:"1px solid #A7F3D0",color:"#15803D",fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1}},{children:[i(v,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:i(R,{})})),0,"% Similarity",i(I,{size:11})]}))}))})),r(v,e({sx:e({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},ue?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[he&&i(C,{sections:11}),i(v,e({ref:Zt,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"40px",display:"flex",alignItems:"center",overflowX:"hidden"}},{children:i(m,e({title:At,placement:"top"},{children:i(f,e({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center",textOverflow:"ellipsis",whiteSpace:"normal",width:"100%",height:"40px"}},{children:At}))}))})),r(v,e({ref:lt,onScroll:Bn,sx:e({p:"12px",display:"flex",flexDirection:"column"},ue?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-20px",pl:"40px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[i("div",{ref:ct,style:{width:"100%",height:"0px",flexShrink:0}}),Nt&&Ot.map(function(t,n){var o,c;if(!ue)return i(v,e({ref:xn.current[n],sx:{width:"100%"}},{children:Mn({section:t,idx:n,columnKey:"right",colRef:hn.current[n],parentNodeId:(null===(o=null==Q?void 0:Q.input_index_map)||void 0===o?void 0:o[1])||""})}),"right-row-".concat(n));var u=t,a=Ht.filter(function(e){var t;return(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(u.selfIndex))&&e.selfIndex>=0}).map(function(e){return e.selfIndex+1}),d=Ht.some(function(e,t){var n;return Te.has(t)&&(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(u.selfIndex))}),s=Ht.findIndex(function(e,t){var n;return Te.has(t)&&(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(u.selfIndex))}),f=-1!==s?wn(s):null;return i(v,e({ref:xn.current[n],sx:{mb:1}},{children:r(v,e({sx:{position:"relative",width:"100%"}},{children:[i(v,e({ref:hn.current[n],sx:e({width:"100%",display:"flex"},d&&f&&{borderRadius:"6px",outline:"2px solid ".concat(f.badgeBorder),outlineOffset:"1px"})},{children:Mn({section:t,idx:n,columnKey:"right",colRef:l.createRef(),mb:0,parentNodeId:(null===(c=null==Q?void 0:Q.input_index_map)||void 0===c?void 0:c[1])||""})})),!he&&i(v,e({ref:gn.current[n],sx:{position:"absolute",top:"18px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"11px",bgcolor:"#EEF2FF",color:"#3730A3",border:"1px solid #C7D2FE",borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:a.length>0?a.join(", "):"-"}))]}))}),"right-row-".concat(n))}),i("div",{ref:ut,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))};export{K as default};
|
|
2
2
|
//# sourceMappingURL=CognitiveCompare.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
var n=function(i){return null==i?"":"string"==typeof i?i:Array.isArray(i)?i.map(n).join("\n\n"):"object"==typeof i?JSON.stringify(i):String(i)},i=function(n){return null!=n&&("string"==typeof n?n.trim().length>0:!Array.isArray(n)||n.length>0&&n.some(function(n){return i(n)}))},t=function(i,t,e){var o,r=e[t],a=null===(o=null==i?void 0:i.comparison_inputs)||void 0===o?void 0:o[r];return{title:n((null==a?void 0:a.title)||""),content:n((null==a?void 0:a.content)||""),attributes:(null==a?void 0:a.additional_attributes)||null,subsections:(null==a?void 0:a.subsections)||[]}},e=function(n){if(!n.mapping_rationale)return{cognitiveData:{decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0,citations:[]},score:0,relation:"N/A"};var i=n.mapping_rationale,t=parseInt(i.decision_strength||"0");return{cognitiveData:{decisioning:i.decisioning_factors||[],gap:i.gaps_in_decision||[],relevance_score:t,citations:i.citations},score:0,relation:"N/A"}};export{e as getRationale,t as getSideData,i as hasValue,n as safeStringify};
|
|
2
2
|
//# sourceMappingURL=CognitiveComparehelpers.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as e}from"tslib";import{jsx as i,jsxs as n}from"react/jsx-runtime";import{Menu as
|
|
1
|
+
import{__assign as e}from"tslib";import{jsx as i,jsxs as n,Fragment as t}from"react/jsx-runtime";import{Menu as o,Box as r,Typography as l,MenuItem as s}from"@mui/material";import{ButtonCognitiveIcon as c}from"../../assests/svg/ButtonCognitiveIcon.js";var C=function(){return i("svg",e({width:"13",height:"13",viewBox:"0 0 13 13",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:i("path",{d:"M2 6.5L5 9.5L11 3.5",stroke:"#15803D",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})}))},d=[{key:"connect",title:"Connect",icon:i("svg",e({width:"15",height:"18",viewBox:"0 0 15 18",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:i("path",{d:"M14.8237 3.89331C14.547 5.57188 13.0559 6.77501 11.3572 6.69242C9.65857 6.60983 8.2925 5.26384 8.18312 3.56742C4.75678 3.67456 3.54027 4.4759 3.73893 6.10536C3.81259 6.71474 4.18089 7.04063 4.85723 7.19911C5.26794 7.2951 5.7233 7.30849 6.13625 7.27054C6.17419 7.26608 6.21437 7.26385 6.25232 7.25938C6.50455 7.19911 6.76125 7.14777 7.01794 7.1076C7.77911 6.9826 8.55366 6.9201 9.29027 6.96027C11.3617 7.07188 12.7724 7.98483 12.8438 9.92233C12.913 11.7996 11.6229 13.1299 9.5425 14.0205C8.87509 14.3063 8.1675 14.5272 7.45991 14.6946C7.14071 14.7705 6.87286 14.8219 6.67419 14.8554C6.49786 16.5496 5.07821 17.842 3.37509 17.8554C1.67196 17.8688 0.229997 16.6031 0.0246403 14.9112C-0.180717 13.2192 0.917498 11.6455 2.57375 11.2527C4.23 10.8598 5.91973 11.7728 6.49562 13.3755C6.70544 13.3375 6.91303 13.2951 7.12062 13.246C7.75009 13.0987 8.37955 12.9022 8.95991 12.6522C10.538 11.9781 11.3996 11.0875 11.3595 9.9759C11.3237 8.98036 10.6095 8.52054 9.21214 8.44465C8.5983 8.41117 7.92643 8.46474 7.26348 8.57411C7.07821 8.60536 6.90857 8.63661 6.75902 8.6701C6.67196 8.68795 6.61169 8.70358 6.58491 8.71027L6.51571 8.72367C6.4666 8.73036 6.38402 8.74152 6.27687 8.75268C5.71884 8.80402 5.11393 8.78617 4.52464 8.65001C3.2925 8.36206 2.42866 7.59643 2.26794 6.2884C1.9175 3.47143 4.02241 2.16563 8.42866 2.07188C9.07821 0.500452 10.8037 -0.336602 12.4376 0.129916C14.0737 0.596434 15.1005 2.21474 14.8237 3.89331V3.89331ZM3.34161 12.6478C3.09741 12.6478 2.85562 12.6959 2.63002 12.7894C2.40442 12.8828 2.19944 13.0198 2.02678 13.1925C1.85412 13.3652 1.71717 13.5702 1.62373 13.7958C1.5303 14.0214 1.48222 14.2632 1.48223 14.5074C1.48224 14.7516 1.53036 14.9934 1.62382 15.219C1.71728 15.4446 1.85426 15.6495 2.02694 15.8222C2.19962 15.9949 2.40462 16.1318 2.63022 16.2252C2.85583 16.3187 3.09764 16.3668 3.34183 16.3667C3.83499 16.3667 4.30795 16.1708 4.65665 15.822C5.00535 15.4733 5.20123 15.0003 5.2012 14.5071C5.20117 14.014 5.00524 13.541 4.65649 13.1923C4.30775 12.8436 3.83477 12.6477 3.34161 12.6478ZM11.5224 1.49152C11.2782 1.49154 11.0364 1.53965 10.8108 1.63311C10.5852 1.72657 10.3802 1.86355 10.2076 2.03623C10.0349 2.20891 9.89797 2.41391 9.80454 2.63952C9.7111 2.86513 9.66302 3.10693 9.66303 3.35112C9.66305 3.59531 9.71116 3.83711 9.80462 4.06271C9.89808 4.28831 10.0351 4.49329 10.2077 4.66594C10.3804 4.8386 10.5854 4.97556 10.811 5.06899C11.0366 5.16243 11.2784 5.21051 11.5226 5.2105C12.0158 5.21047 12.4888 5.01453 12.8375 4.66579C13.1862 4.31704 13.382 3.84406 13.382 3.3509C13.382 2.85773 13.186 2.38478 12.8373 2.03608C12.4886 1.68738 12.0156 1.49149 11.5224 1.49152V1.49152Z",fill:"#1D2939",fillOpacity:"0.85"})}))},{key:"side-by-side",title:"Side by Side",icon:i("svg",e({width:"17",height:"17",viewBox:"0 0 17 17",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:i("path",{d:"M3.19922 8.19922H13.1992M3.19922 8.19922L4.86589 10.6992M3.19922 8.19922L4.86589 5.69922M13.1992 8.19922L11.5326 10.6992M13.1992 8.19922L11.5326 5.69922M15.6992 0.699219V15.6992M0.699219 0.699219V15.6992",stroke:"#3F4957",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})}))},{key:"cognitive-decisioning",title:"Cognitive Decisioning",icon:i(c,{})}],a=function(c){var a=c.open,h=c.anchorEl;c.sectionTitle,c.referenceSectionTitle;var p=c.onClose,g=c.onOpenCognitiveCompare,x=c.onOpenSideBySide,f=c.onConnect,m=c.isConnected,u=void 0!==m&&m,v=c.isOrphan;return i(o,e({open:a,anchorEl:h,onClose:p,disableScrollLock:!0,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},PaperProps:{sx:{ml:.75,minWidth:190,maxWidth:220,borderRadius:"12px",border:"1px solid #E4E7EC",boxShadow:"0px 12px 28px rgba(16, 24, 40, 0.12)",overflow:"hidden"}},MenuListProps:{sx:{p:.5,bgcolor:"#FFFFFF"}}},{children:d.map(function(o){var c="connect"===o.key,d=c&&u,a=v&&("connect"===o.key||"side-by-side"===o.key);console.log("LOG: Printing isDsiabled: ",a);var h=n(t,{children:[i(r,e({sx:e(e({width:18,height:18,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,"& svg":{display:"block"}},a&&{opacity:.15}),d&&{"& svg path":{fill:"#15803D",fillOpacity:1}})},{children:o.icon})),n(r,e({sx:{minWidth:0,display:"flex",flexDirection:"column",flex:1}},{children:[i(l,e({sx:{fontSize:"12px",fontWeight:500,color:a?"#98A2B3":d?"#15803D":"#101828",lineHeight:1.2,whiteSpace:"nowrap"}},{children:c?u?"Disconnect":"Connect":o.title})),a&&i(l,e({sx:{mt:.35,fontSize:"10px",lineHeight:1.3,color:"#98A2B3",whiteSpace:"normal"}},{children:"No counterpart exists to connect to."}))]})),d&&!a&&i(r,e({sx:{display:"flex",alignItems:"center",justifyContent:"center",ml:"auto"}},{children:i(C,{})}))]});return a?i(r,e({"aria-disabled":"true",sx:{px:1.25,py:1,minHeight:22,borderRadius:"10px",display:"flex",alignItems:"flex-start",gap:1,cursor:"not-allowed",userSelect:"none"}},{children:h}),o.key):i(s,e({onClick:function(){return e=o.key,void(v&&("connect"===e||"side-by-side"===e)||("connect"!==e?"side-by-side"!==e?g():x():f()));var e},sx:{px:1.25,py:1,minHeight:40,borderRadius:"10px",display:"flex",alignItems:"center",gap:1,bgcolor:d?"#F0FDF4":"transparent","&:hover":{bgcolor:d?"#DCFCE7":"#F9FAFB"}}},{children:h}),o.key)})}))};export{a as default};
|
|
2
2
|
//# sourceMappingURL=MoreFunctionsPopup.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as e}from"tslib";import{jsx as
|
|
1
|
+
import{__assign as e,__awaiter as t,__generator as i}from"tslib";import{jsx as o,jsxs as n}from"react/jsx-runtime";import{SpecialZoomLevel as r}from"@react-pdf-viewer/core";import a from"./PdfContainer.js";import l from"./PdfToolbar.js";import{pdfStyles as s}from"./PdfStyle.js";import{PdfHighlightControls as c}from"./usePdfHighlight.js";import"@react-pdf-viewer/zoom/lib/styles/index.css";import"@react-pdf-viewer/page-navigation/lib/styles/index.css";import"@react-pdf-viewer/core/lib/styles/index.css";import"@react-pdf-viewer/search/lib/styles/index.css";import{useRef as u,useMemo as d,useEffect as g}from"react";import f from"../ScannedDocCitation/ScannedDocCitation.js";var h=function(e){switch(e){case"ActualSize":return r.ActualSize;case"PageFit":return r.PageFit;case"PageWidth":return r.PageWidth;default:return null!=e?e:r.PageWidth}},m=function(m){var v,p=m.pdfUrl,x=m.highlightText,C=m.highlightPages,P=m.highlightCordinatePages,T=m.highlightColor,w=void 0===T?"yellow":T,y=m.activeHighlightColor,b=void 0===y?"#f7dc51":y,S=m.jumpToPageValue,A=void 0===S?0:S,H=m.pdfName,I=m.onClose,j=m.customStyles,z=m.customClasses,F=m.customIcons,N=m.useCoordinates,_=m.fallbackPages,R=m.activeCitationIndex,V=m.onActiveCitationChange,W=m.headerAction,q=m.isZoomEnabled,D=void 0===q||q,E=m.showHighlightsAction,B=void 0===E||E,O=m.defaultScale,U=void 0===O?r.ActualSize:O,k=m.useRange,Z=void 0!==k&&k,J=m.rangeOfPages,K=void 0===J?null:J,L=u(null),G=d(function(){if(N)return new Set(P.map(function(e){return e.pageIndex}));var e=new Set;return Object.values(C).forEach(function(t){t>0&&e.add(t-1)}),e},[C]),M=(v=x)&&0!==v.length?v.filter(function(e){return!v.some(function(t){return t!==e&&t.includes(e)})}):v,Q=c(M,N?{}:C,L,G,N,N?P:[],w,b),X=Q.highlightIndex,Y=Q.cursorIndex,$=Q.setCursorIndex,ee=Q.orderedKeys,te=Q.totalHighlights,ie=Q.getValidPosition,oe=Q.tryJump,ne=Q.jumpToPage,re=Q.zoomTo,ae=Q.plugins,le=Q.controls,se=Q.hideNonTargetHighlights,ce=Q.deduplicateHighlights,ue=ie(Y);g(function(){void 0!==R&&R!==Y&&$(R)},[R]);var de=e(e({},le),{goToNext:function(){le.goToNext(),V&&V(Y+1)},goToPrevious:function(){le.goToPrevious(),V&&V(Y-1)}});if(!p)return o(f,{pages:_,activeCitationIndex:R,onActiveCitationChange:V,headerAction:W});return n("div",e({ref:L,className:(null==z?void 0:z.pdfViewerWrapper)||"",style:e(e(e({height:"100%",minHeight:0,minWidth:0,overflow:"hidden",display:"flex",flexDirection:"column"},s.pdfViewer),{display:"flex",flexDirection:"column",height:"100%",width:"100%",backgroundColor:"#FAFAFA"}),null==j?void 0:j.pdfViewer)},{children:[o(l,{highlightIndex:X,totalHighlights:te,controls:de,currentPosition:ue,pdfName:H,onClose:I,pdfUrl:p,viewerRef:L,customStyles:j,customClasses:z,customIcons:F,headerAction:W,isZoomEnabled:D,showHighlightsAction:B}),o(a,{defaultScale:h(U),pdfUrl:p,plugins:ae,customStyles:j,onLoad:function(){if(re(r.ActualSize),A>0&&!Z){var e=A-1,o=ee[e],n=C[o],a=P[e];$(e),console.log(a,"cordinateTargetHighlight"),N&&a.pageIndex>0&&ne(a.pageIndex),n>0&&(setTimeout(function(){se(G),ce(n-1)},1e3),N||ne(n-1))}else if(Z&&K&&2===K.length){t(void 0,void 0,void 0,function(){var e,t,o,n,r;return i(this,function(i){switch(i.label){case 0:e=K[0],t=K[1],o=e,i.label=1;case 1:return o<=t?(ne(n=o-1),[4,new Promise(function(e){return setTimeout(e,1e3)})]):[3,4];case 2:if(i.sent(),se(G),(r=ce(n))&&r>0)return[3,4];i.label=3;case 3:return o++,[3,1];case 4:return[2]}})})}else if(!N&&C){var l=ee.find(function(e){return C[e]>0});if(void 0!==l){var s=C[l]-1;ne(s),setTimeout(function(){se(G),ce(s)},1e3)}}requestAnimationFrame(function(){oe(),N||function(){if(L.current){var e=A-1,t=ee[e],i=C[t],o=i>0?i-1:0,n={};ee.forEach(function(e,t){var i=C[e];i>0&&(n[i]||(n[i]=[]),n[i].push(t))});var r=(n[i]||[]).indexOf(e),a=0,l=function(){var e,t;if(!(++a>40)){var i=null===(e=L.current)||void 0===e?void 0:e.querySelector(".rpv-core__inner-pages");if(i){var n=null===(t=L.current)||void 0===t?void 0:t.querySelector('[data-testid="core__page-layer-'.concat(o,'"]'));if(n){var s=i.getBoundingClientRect(),c=n.getBoundingClientRect();if(c.top<s.bottom&&c.bottom>s.top){var u=n.querySelectorAll(".rpv-search__highlight")[r];if(u){var d=u.getBoundingClientRect(),g=i.scrollTop+(d.top-s.top)-i.clientHeight/2+d.height/2;i.scrollTo({top:g,behavior:"smooth"})}else setTimeout(l,100)}else setTimeout(l,100)}else setTimeout(l,100)}else setTimeout(l,100)}};setTimeout(l,500)}}()})},onPageChange:function(e){var t=e.currentPage;G.has(t)?(ce(t),se(G)):se(G)}})]}))};export{m as default};
|
|
2
2
|
//# sourceMappingURL=PdfViewer.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as e}from"tslib";import{jsx as t,Fragment as r}from"react/jsx-runtime";import{useState as o,useRef as n,useMemo as i}from"react";import{searchPlugin as a}from"@react-pdf-viewer/search";import{pageNavigationPlugin as l}from"@react-pdf-viewer/page-navigation";import{zoomPlugin as c}from"@react-pdf-viewer/zoom";import{highlightPlugin as u}from"@react-pdf-viewer/highlight";var s=function(s,p,g,f,v,h,d,m){void 0===d&&(d="yellow"),void 0===m&&(m="#F6D739");var T=o(0),y=T[0],x=T[1],_=n(!1),b=o(0),I=b[0],S=b[1];n([]);var q=function(e){if(!e)return[];return e.replace(/\]\s*\n\s*\(/g,"](").split(/\n+/).map(function(e){var t=e.trim(),r=(t=(t=t.replace(/[\u200B-\u200D\uFEFF]/g,"").replace(/[\u00A0\u2009\u202F]/g," ")).replace(/^[-•]\s+/,"")).match(/^((\d+(?:\.\d+)*[.)]?)|[A-Za-z][.)]|\([A-Za-z0-9]+\)|(?:i|ii|iii|iv|v|vi|vii|viii|ix|x)[.)])\s*/i);return r?t.slice(r[0].length).trim():t}).flatMap(function(e){var t=e.match(/^\s*\|(.+)\|\s*$/);return t?t[1].split("|").map(function(e){return e.trim()}).filter(Boolean):[e]}).map(function(e){return e.replace(/&[#\w]+;/g,function(e){return t=e,(r=document.createElement("textarea")).innerHTML=t,r.value;var t,r}).replace(/<br\s*\/?>/gi,"\n").replace(/\[([^\]]+)\]\(([^)]+)\)/g,"$1").replace(/[^\S\n]+/g," ").trim()}).flatMap(function(e){return e.split(/\n+/)}).flatMap(function(e){for(var t,r=[],o=/([*_]{1,3})([^*_]+)\1|([*_]{1,3})/g,n=0;null!==(t=o.exec(e));){var i=e.slice(n,t.index).trim();i&&r.push(i),t[2]&&r.push(t[2].trim()),n=t.index+t[0].length}var a=e.slice(n).trim();return a&&r.push(a),r.flatMap(function(e){return e.split(/[\u2013\u2014-]/g)}).flatMap(function(e){return e.split(/\n+/)}).map(function(e){return e.replace(/[*_]+/g,"").replace(/`([^`]+)`/g,"$1").replace(/[^\S\n]+/g," ").trim()})})},w=Object.keys(p).map(Number).sort(function(e,t){return e-t}),B=i(function(){return v?h.length:v?0:Object.values(p).filter(function(e){return e>0}).length},[h,p]),A=function(e){if(g.current){var t=g.current.querySelector('[data-testid="search__highlights-'.concat(e,'"]'));if(t){var r=Array.from(t.querySelectorAll(".rpv-search__highlight")),o=function(e){return(e||"").toLowerCase().replace(/[^\w\s]/g,"").replace(/\s+/g," ").trim()},n=M.map(o).filter(Boolean);if(0!==n.length){var i=[],a=null;r.forEach(function(e){var t=o(e.getAttribute("title")||e.textContent||""),r=parseFloat(e.style.top||"0");a?a.title===t&&Math.abs(a.lastTop-r)<=3?(a.elements.push(e),a.lastTop=r):(i.push(a),a={title:t,elements:[e],lastTop:r}):a={title:t,elements:[e],lastTop:r}}),a&&i.push(a);for(var l=0,c=new Set,u=0;u<i.length;u++)for(var p=i[u].title,f=0;f<n.length;f++)if(n[f]===p){for(var v=0,h=new Set,d=f,m=u-1,T=u;T<i.length&&d<n.length;T++){if(i[T].title===n[d]){if(m>=0){var y=i[m].lastTop,x=parseFloat(i[T].elements[0].style.top||"0");if(Math.abs(x-y)>15)break}v++,h.add(T),m=T,d++}else if(d>0&&i[T].title===n[d-1]){y=i[m].lastTop,x=parseFloat(i[T].elements[0].style.top||"0");Math.abs(x-y)<=3&&(h.add(T),m=T)}if(T-m>4)break}v>l&&(l=v,c=h)}i.forEach(function(e,t){var r=c.has(t);e.elements.forEach(function(e){r?(e.classList.add("verified-match"),e.style.display=""):(e.style.display="none",e.classList.remove("verified-match"))})}),console.groupCollapsed("[debug: PDF ordered matching - Page ".concat(e,"]")),console.log("input->",s),console.log("processed text->",M),console.log("Expected sequence length:",n.length),console.log("Matched ordered sequence length:",l),console.groupEnd()}}}},C=function(e){g.current&&g.current.querySelectorAll(".rpv-search__highlights").forEach(function(t){var r=t.getAttribute("data-testid"),o=parseInt((null==r?void 0:r.replace(/search__highlights-/g,""))||"-1"),n=t.querySelectorAll(".rpv-search__highlight");e.has(o)||n.forEach(function(e){e.style.display="none"})})},M=s.map(function(e){return q(e)}).flat(),j=a({keyword:M}),E=l(),F=c(),k=j.jumpToMatch,
|
|
1
|
+
import{__assign as e}from"tslib";import{jsx as t,Fragment as r}from"react/jsx-runtime";import{useState as o,useRef as n,useMemo as i}from"react";import{searchPlugin as a}from"@react-pdf-viewer/search";import{pageNavigationPlugin as l}from"@react-pdf-viewer/page-navigation";import{zoomPlugin as c}from"@react-pdf-viewer/zoom";import{highlightPlugin as u}from"@react-pdf-viewer/highlight";var s=function(s,p,g,f,v,h,d,m){void 0===d&&(d="yellow"),void 0===m&&(m="#F6D739");var T=o(0),y=T[0],x=T[1],_=n(!1),b=o(0),I=b[0],S=b[1];n([]);var q=function(e){if(!e)return[];return e.replace(/\]\s*\n\s*\(/g,"](").split(/\n+/).map(function(e){var t=e.trim(),r=(t=(t=t.replace(/[\u200B-\u200D\uFEFF]/g,"").replace(/[\u00A0\u2009\u202F]/g," ")).replace(/^[-•]\s+/,"")).match(/^((\d+(?:\.\d+)*[.)]?)|[A-Za-z][.)]|\([A-Za-z0-9]+\)|(?:i|ii|iii|iv|v|vi|vii|viii|ix|x)[.)])\s*/i);return r?t.slice(r[0].length).trim():t}).flatMap(function(e){var t=e.match(/^\s*\|(.+)\|\s*$/);return t?t[1].split("|").map(function(e){return e.trim()}).filter(Boolean):[e]}).map(function(e){return e.replace(/&[#\w]+;/g,function(e){return t=e,(r=document.createElement("textarea")).innerHTML=t,r.value;var t,r}).replace(/<br\s*\/?>/gi,"\n").replace(/\[([^\]]+)\]\(([^)]+)\)/g,"$1").replace(/[^\S\n]+/g," ").trim()}).flatMap(function(e){return e.split(/\n+/)}).flatMap(function(e){for(var t,r=[],o=/([*_]{1,3})([^*_]+)\1|([*_]{1,3})/g,n=0;null!==(t=o.exec(e));){var i=e.slice(n,t.index).trim();i&&r.push(i),t[2]&&r.push(t[2].trim()),n=t.index+t[0].length}var a=e.slice(n).trim();return a&&r.push(a),r.flatMap(function(e){return e.split(/[\u2013\u2014-]/g)}).flatMap(function(e){return e.split(/\n+/)}).map(function(e){return e.replace(/[*_]+/g,"").replace(/`([^`]+)`/g,"$1").replace(/[^\S\n]+/g," ").trim()})})},w=Object.keys(p).map(Number).sort(function(e,t){return e-t}),B=i(function(){return v?h.length:v?0:Object.values(p).filter(function(e){return e>0}).length},[h,p]),A=function(e){if(g.current){var t=g.current.querySelector('[data-testid="search__highlights-'.concat(e,'"]'));if(t){var r=Array.from(t.querySelectorAll(".rpv-search__highlight")),o=function(e){return(e||"").toLowerCase().replace(/[^\w\s]/g,"").replace(/\s+/g," ").trim()},n=M.map(o).filter(Boolean);if(0!==n.length){var i=[],a=null;r.forEach(function(e){var t=o(e.getAttribute("title")||e.textContent||""),r=parseFloat(e.style.top||"0");a?a.title===t&&Math.abs(a.lastTop-r)<=3?(a.elements.push(e),a.lastTop=r):(i.push(a),a={title:t,elements:[e],lastTop:r}):a={title:t,elements:[e],lastTop:r}}),a&&i.push(a);for(var l=0,c=new Set,u=0;u<i.length;u++)for(var p=i[u].title,f=0;f<n.length;f++)if(n[f]===p){for(var v=0,h=new Set,d=f,m=u-1,T=u;T<i.length&&d<n.length;T++){if(i[T].title===n[d]){if(m>=0){var y=i[m].lastTop,x=parseFloat(i[T].elements[0].style.top||"0");if(Math.abs(x-y)>15)break}v++,h.add(T),m=T,d++}else if(d>0&&i[T].title===n[d-1]){y=i[m].lastTop,x=parseFloat(i[T].elements[0].style.top||"0");Math.abs(x-y)<=3&&(h.add(T),m=T)}if(T-m>4)break}v>l&&(l=v,c=h)}return i.forEach(function(e,t){var r=c.has(t);e.elements.forEach(function(e){r?(e.classList.add("verified-match"),e.style.display=""):(e.style.display="none",e.classList.remove("verified-match"))})}),console.groupCollapsed("[debug: PDF ordered matching - Page ".concat(e,"]")),console.log("input->",s),console.log("processed text->",M),console.log("Expected sequence length:",n.length),console.log("Matched ordered sequence length:",l),console.log("blocksToKeep",c,"size",c.size),console.groupEnd(),c.size}}}},C=function(e){g.current&&g.current.querySelectorAll(".rpv-search__highlights").forEach(function(t){var r=t.getAttribute("data-testid"),o=parseInt((null==r?void 0:r.replace(/search__highlights-/g,""))||"-1"),n=t.querySelectorAll(".rpv-search__highlight");e.has(o)||n.forEach(function(e){e.style.display="none"})})},M=s.map(function(e){return q(e)}).flat(),j=a({keyword:M}),E=l(),F=c(),k=j.jumpToMatch,z=E.jumpToPage,P=F.zoomTo,Z=F.ZoomInButton,H=F.ZoomOutButton,O=F.ZoomPopover,R=u({renderHighlights:function(o){return t(r,{children:h.map(function(t,r){return e(e({},t),{originalIndex:r})}).filter(function(e){return e.pageNumber?e.pageNumber-1===o.pageIndex:e.pageIndex===o.pageIndex}).map(function(e){var r=e.originalIndex,o=r===I;return t("div",{style:{position:"absolute",left:"".concat(e.left,"%"),top:"".concat(e.top,"%"),width:"".concat(e.width,"%"),height:"".concat(e.height,"%"),background:o?m:d,opacity:o?.7:.4,transition:"background 0.2s, opacity 0.2s"}},r)})})}}),N=function(){if(!_.current)try{k(0),_.current=!0;var e=h[0];e&&v&&D(e.pageIndex,e.top)}catch(e){requestAnimationFrame(N)}},L=function(e,t){if(g.current&&g.current.querySelector(".rpv-core__viewer")){var r=-1,o=function(){var n,i,a=null===(n=g.current)||void 0===n?void 0:n.querySelector(".rpv-core__inner-pages");if(a){if(a.scrollTop!==r)return r=a.scrollTop,void setTimeout(o,100);var l=null===(i=g.current)||void 0===i?void 0:i.querySelector('[data-testid="core__page-layer-'.concat(e,'"]'));if(l){var c=l.querySelectorAll(".rpv-search__highlight")[t];if(c){var u=a.getBoundingClientRect(),s=c.getBoundingClientRect(),p=a.scrollTop+(s.top-u.top)-a.clientHeight/2+s.height/2;a.scrollTo({top:p,behavior:"smooth"})}}}};setTimeout(o,300)}},D=function(e,t){if(g.current){var r=0,o=function(){var n,i;if(!(++r>60)){var a=null===(n=g.current)||void 0===n?void 0:n.querySelector(".rpv-core__inner-pages");if(a){var l=null===(i=g.current)||void 0===i?void 0:i.querySelector('[data-testid="core__page-layer-'.concat(e,'"]'));if(l){var c=l.getBoundingClientRect();if(0!==c.height){var u=a.getBoundingClientRect(),s=t/100*c.height,p=c.top-u.top+s;a.scrollTo({top:a.scrollTop+p-40,behavior:"smooth"})}else setTimeout(o,100)}else setTimeout(o,100)}else setTimeout(o,100)}};setTimeout(o,100)}},$=i(function(){var e={};return w.forEach(function(t,r){var o=p[t];o>0&&(e[o]||(e[o]=[]),e[o].push(r))}),e},[w,p]),K=function(e){var t=p[w[e]];return($[t]||[]).indexOf(e)},J=function(e,t){if(g.current){var r=-1,o=0,n=function(){var i,a;if(!(++o>60)){var l=null===(i=g.current)||void 0===i?void 0:i.querySelector(".rpv-core__inner-pages");if(l){if(l.scrollTop!==r)return r=l.scrollTop,void setTimeout(n,100);var c=null===(a=g.current)||void 0===a?void 0:a.querySelector('[data-testid="core__page-layer-'.concat(e,'"]'));if(c){var u=c.getBoundingClientRect();if(0!==u.height){var s=l.getBoundingClientRect(),p=t/100*u.height,f=u.top-s.top+p;l.scrollTo({top:l.scrollTop+f-40,behavior:"instant"})}else setTimeout(n,100)}else setTimeout(n,100)}else setTimeout(n,100)}};setTimeout(n,100)}};return{setHighlightIndex:x,highlightIndex:y,cursorIndex:I,setCursorIndex:S,orderedKeys:w,totalHighlights:B,getValidPosition:function(e){if(v)return e+1;if(!p)return 0;for(var t=0,r=0;r<=e;r++)p[w[r]]>0&&t++;return t},tryJump:N,jumpToPage:z,zoomTo:P,hideNonTargetHighlights:C,deduplicateHighlights:A,scrollToCoord:D,plugins:[v?R:j,E,F],controls:{ZoomInButton:Z,ZoomOutButton:H,ZoomPopover:O,goToNext:function(){if(v&&h)for(var e=I+1;e<h.length;e++){var t=h[e],r=h[I];return S(e),z(t.pageIndex),void(t.pageIndex!==r.pageIndex?(z(t.pageIndex),J(t.pageIndex,t.top)):D(t.pageIndex,t.top))}else{var o=function(e){var t=w[e];if(p[t]>0){var r=p[t]-1,o=K(e);return S(e),z(p[t]-1),L(r,o),setTimeout(function(){A(r)},500),1===Object.keys(p).length&&C(f),{value:void 0}}};for(e=I+1;e<w.length;e++){var n=o(e);if("object"==typeof n)return n.value}}},goToPrevious:function(){if(v&&h)for(var e=I-1;e>=0;e--){var t=h[e],r=h[I];return S(e),z(t.pageIndex),void(t.pageIndex!==r.pageIndex?(z(t.pageIndex),J(t.pageIndex,t.top)):D(t.pageIndex,t.top))}else{var o=function(e){var t=w[e];if(p[t]>0){var r=p[t]-1,o=K(e);return S(e),z(p[t]-1),L(r,o),setTimeout(function(){A(r)},500),1===Object.keys(p).length&&C(f),{value:void 0}}};for(e=I-1;e>=0;e--){var n=o(e);if("object"==typeof n)return n.value}}}}}};export{s as PdfHighlightControls};
|
|
2
2
|
//# sourceMappingURL=usePdfHighlight.js.map
|