@viswa-test/test-citation 0.0.231 → 0.0.233
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js +1 -1
- package/dist/cjs/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js +2 -0
- package/dist/cjs/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js.map +1 -0
- package/dist/cjs/features/CognitiveCompare/components/SectionAccordion.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/connectedLines.js +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/useCompareData.js +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/useSideBySide.js +1 -1
- package/dist/features/CognitiveCompare/CognitiveCompare.js +1 -1
- package/dist/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js +2 -0
- package/dist/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js.map +1 -0
- package/dist/features/CognitiveCompare/components/SectionAccordion.js +1 -1
- package/dist/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
- package/dist/features/CognitiveCompare/components/connectedLines.js +1 -1
- package/dist/features/CognitiveCompare/hooks/useCompareData.js +1 -1
- package/dist/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
- package/dist/features/CognitiveCompare/hooks/useSideBySide.js +1 -1
- package/dist/types/src/CognitiveCompareTest.d.ts.map +1 -1
- package/dist/types/src/CommonConstants/CommonConstants.d.ts +0 -1365
- package/dist/types/src/CommonConstants/CommonConstants.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts +5 -0
- package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/CompareContext.d.ts +1 -0
- package/dist/types/src/features/CognitiveCompare/CompareContext.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/Guidelines/components/GuidelinePanel.d.ts +3 -0
- package/dist/types/src/features/CognitiveCompare/Guidelines/components/GuidelinePanel.d.ts.map +1 -0
- package/dist/types/src/features/CognitiveCompare/Guidelines/constants/guidelines.mockData.d.ts +2599 -0
- package/dist/types/src/features/CognitiveCompare/Guidelines/constants/guidelines.mockData.d.ts.map +1 -0
- package/dist/types/src/features/CognitiveCompare/components/SectionAccordion.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/components/SubSectionAccordion.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/components/connectedLines.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/hooks/useCompareData.d.ts +2 -1
- package/dist/types/src/features/CognitiveCompare/hooks/useCompareData.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/hooks/useLinesCalculator.d.ts +1 -1
- package/dist/types/src/features/CognitiveCompare/hooks/useLinesCalculator.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/hooks/useSideBySide.d.ts +1 -1
- package/dist/types/src/features/CognitiveCompare/hooks/useSideBySide.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useState as t,useRef as e,useCallback as n,useEffect as r}from"react";import{DEVIATION_BADGE_SEPARATOR as i,getBentArrowPath as c}from"../CognitiveComparehelpers.js";var o=function(o){var l=o.containerRef,u=o.leftContainerRef,a=o.rightContainerRef;o.svgContainerRef;var d=o.pathRefs,v=o.leftHeaderRef,h=o.rightHeaderRef,s=o.proposedSections,g=o.existingSections,f=o.visibleFields,p=o.leftRefs,y=o.rightRefs,x=o.sectionLeftRefs,m=o.sectionRightRefs,R=o.subSectionLeftRefs,C=o.subSectionRightRefs,B=o.lhsBadgeRefs,b=o.rhsBadgeRefs,S=o.sectionRowRefs,M=o.expandedSections,L=o.expandedSubSections,I=o.connectedSections,T=o.isSideBySide,H=o.activeSideBySideSection,A=o.maintainRelativeOrder,E=o.cognitiveMap,k=o.getSectionCompareStyle,w=o.getSubSectionCompareStyle,D=o.getDeviationStyleByKey,Y=o.isArrowVisible,F=o.isAnimatingRef,N=o.isSideBySideRef,O=o.sideBySideCacheRef,j=o.sideBySideLineRef,z=o.activeSideBySideSectionRef,P=o.activeSideBySideRightSectionRef,q=o.connectedLines,K=o.setConnectedLines,V=o.cachedConnectedPositions,G=o.calculateLinesRef,J=o.resizeTimerRef,Q=o.scrollLock,U=o.scrollSyncLocked,W=o.handleResizeRef,X=o.activeProposed,Z=o.existingRule,$=o.analysisData,_=o.pendingScrollTargetRef,tt=o.pendingScrollCallbackRef,et=o.resolvedComparisonConfig,nt=o.getFieldData,rt=t([]),it=rt[0],ct=rt[1],ot=t(null),lt=ot[0],ut=ot[1],at=t([]),dt=at[0],vt=at[1],ht=null!=q?q:dt,st=null!=K?K:vt,gt=t({width:0,height:0}),ft=gt[0],pt=gt[1],yt=e(!1),xt=e(!1),mt=e(!1),Rt=e(null),Ct=e([]),Bt=null!=V?V:Ct,bt=n(function(){var t,e,n,r,o,d,S,Y,N,O,j,z,P,q,K,V,G,J;if(!yt.current&&!F.current){yt.current=!0;try{if(!l.current)return;var Q=function(t){var e=t.split("-"),n=e[0];if(!M[n]&&!1===A)return!1;if(A&&!M["left-".concat(n)]&&!M["right-".concat(n)]&&!M[n])return!1;for(var r=n,i=1;i<e.length-1;i++)if(r+="-".concat(e[i]),!L[r])return!1;return!0},U=l.current.getBoundingClientRect();pt({width:U.width,height:U.height});var W=[];if(f.forEach(function(t){var e,n,r=t.key,i=null===(e=p.current[r])||void 0===e?void 0:e.current,c=null===(n=y.current[r])||void 0===n?void 0:n.current;i&&c&&(i.style.height="auto",c.style.height="auto",i.style.minHeight="0px",c.style.minHeight="0px")}),!F.current){for(var X=0;X<Math.max(s.length,g.length);X++){var Z=null===(t=x.current[X])||void 0===t?void 0:t.current,$=null===(e=m.current[X])||void 0===e?void 0:e.current;Z&&(Z.style.height="auto",Z.style.minHeight="0px"),$&&($.style.height="auto",$.style.minHeight="0px")}A||Object.keys(R.current).forEach(function(t){var e,n;if(Q(t)){var r=null===(e=R.current[t])||void 0===e?void 0:e.current,i=null===(n=C.current[t])||void 0===n?void 0:n.current;r&&i&&(r.style.height="auto",i.style.height="auto",r.style.minHeight="0px",i.style.minHeight="0px")}})}var _={};f.forEach(function(t){var e,n,r=t.key,i=null===(e=p.current[r])||void 0===e?void 0:e.current,c=null===(n=y.current[r])||void 0===n?void 0:n.current;if(i&&c){var o=i.getBoundingClientRect(),l=c.getBoundingClientRect();_[r]=Math.max(o.height,l.height)}});var tt={left:{},right:{}},et={};if(!F.current)if(A){if(T&&null!==H)if("number"==typeof H){var nt=H,rt=s[nt],it=null===(o=x.current[nt])||void 0===o?void 0:o.current;it&&rt&&(rt.refIndexes||[]).forEach(function(t){var e,n=g.findIndex(function(e){return e.selfIndex===t}),r=null===(e=m.current[n])||void 0===e?void 0:e.current;if(r&&(M["left-".concat(nt)]||M["right-".concat(n)])){var i=Math.max(it.getBoundingClientRect().height,r.getBoundingClientRect().height);tt.left[nt]=Math.max(tt.left[nt]||0,i),tt.right[n]=Math.max(tt.right[n]||0,i)}})}else{var ot=H.split(i)[2];if(ot){Z=null===(d=R.current[ot])||void 0===d?void 0:d.current,$=null===(S=C.current[ot])||void 0===S?void 0:S.current;if(Z&&$){lt=Math.max(Z.getBoundingClientRect().height,$.getBoundingClientRect().height);et[ot]=Math.max(et[ot]||0,lt)}}}}else{Object.keys(R.current).forEach(function(t){var e,n;if(Q(t)){var r=null===(e=R.current[t])||void 0===e?void 0:e.current,i=null===(n=C.current[t])||void 0===n?void 0:n.current;if(r&&i&&null!==r.offsetParent&&null!==i.offsetParent){var c=r.getBoundingClientRect(),o=i.getBoundingClientRect(),l=Math.max(c.height,o.height);et[t]=l,r.style.minHeight="".concat(l,"px"),i.style.minHeight="".concat(l,"px")}}});for(X=0;X<Math.min(s.length,g.length);X++){var Z=null===(n=x.current[X])||void 0===n?void 0:n.current,$=null===(r=m.current[X])||void 0===r?void 0:r.current;if(Z&&$){var lt=Math.max(Z.getBoundingClientRect().height,$.getBoundingClientRect().height);tt.left[X]=lt,tt.right[X]=lt}}}f.forEach(function(t){var e,n,r=t.key,i=null===(e=p.current[r])||void 0===e?void 0:e.current,c=null===(n=y.current[r])||void 0===n?void 0:n.current;if(i&&c){var o=_[r];i.style.minHeight="".concat(o,"px"),c.style.minHeight="".concat(o,"px")}}),F.current||(Object.entries(tt.left).forEach(function(t){var e,n=t[0],r=t[1],i=null===(e=x.current[Number(n)])||void 0===e?void 0:e.current;i&&(i.style.minHeight="".concat(r,"px"))}),Object.entries(tt.right).forEach(function(t){var e,n=t[0],r=t[1],i=null===(e=m.current[Number(n)])||void 0===e?void 0:e.current;i&&(i.style.minHeight="".concat(r,"px"))}),A||Object.keys(et).forEach(function(t){var e,n,r=null===(e=R.current[t])||void 0===e?void 0:e.current,i=null===(n=C.current[t])||void 0===n?void 0:n.current;if(r&&i&&et[t]){var c=et[t];r.style.minHeight="".concat(c,"px"),i.style.minHeight="".concat(c,"px")}}));if(s.forEach(function(t,e){var n,r=null===(n=x.current[e])||void 0===n?void 0:n.current;if(r){var i=function(t,e){var n=(t.refIndexes||[]).map(function(t){return g.findIndex(function(e){return e.selfIndex===t})}).filter(function(t){return-1!==t});return!n.length&&g[e]?[e]:Array.from(new Set(n))}(t,e);i.forEach(function(n){var i,c,o,l,d,v,h,s,f,p,y=null===(i=m.current[n])||void 0===i?void 0:i.current;if(y){var x=r.getBoundingClientRect(),R=y.getBoundingClientRect(),C=x.right-U.left,B=R.left-U.left,b=x.top+18-U.top,S=R.top+18-U.top;if(A&&T&&H===e){var M=null!==(o=null===(c=u.current)||void 0===c?void 0:c.getBoundingClientRect().top)&&void 0!==o?o:0,L=null!==(d=null===(l=a.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==d?d:0,I=M+(null!==(h=null===(v=u.current)||void 0===v?void 0:v.clientHeight)&&void 0!==h?h:1/0),w=L+(null!==(f=null===(s=a.current)||void 0===s?void 0:s.clientHeight)&&void 0!==f?f:1/0),D=function(t,e,n){return Math.max(e,Math.min(n,t))};b=D(x.top+18,M,I)-U.top,S=D(R.top+18,L,w)-U.top}var Y=k(e);Y&&W.push({id:"line-".concat(e,"-").concat(n),x1:C,y1:b,x2:B,y2:S,style:Y,sectionIdx:e,targetRightIdx:n,isSubSection:!1,hasCognitive:!!((null==t?void 0:t.cognitiveData)||(null===(p=g[n])||void 0===p?void 0:p.cognitiveData)||(null==t?void 0:t.nodeId)&&E[t.nodeId])})}})}}),T&&"string"==typeof H&&H.includes(i)){var at=H.split(i),dt=at[0],vt=at[1],ht=at[2],gt=(at[3],"".concat(dt).concat(i).concat(vt)),ft=null===(Y=B.current[gt])||void 0===Y?void 0:Y.current,xt=null===(N=b.current[gt])||void 0===N?void 0:N.current;if(ft&&xt){var mt=ft.getBoundingClientRect(),Rt=xt.getBoundingClientRect(),Ct=mt.right-U.left,bt=Rt.left-U.left,St=mt.top+mt.height/2-U.top,Mt=Rt.top+Rt.height/2-U.top;if(A){var Lt=null!==(j=null===(O=u.current)||void 0===O?void 0:O.getBoundingClientRect().top)&&void 0!==j?j:0,It=null!==(P=null===(z=a.current)||void 0===z?void 0:z.getBoundingClientRect().top)&&void 0!==P?P:0,Tt=Lt+(null!==(K=null===(q=u.current)||void 0===q?void 0:q.clientHeight)&&void 0!==K?K:1/0),Ht=It+(null!==(G=null===(V=a.current)||void 0===V?void 0:V.clientHeight)&&void 0!==G?G:1/0),At=function(t,e,n){return Math.max(e,Math.min(n,t))};St=At(mt.top+mt.height/2,Lt,Tt)-U.top,Mt=At(Rt.top+Rt.height/2,It,Ht)-U.top}var Et=null!==(J=D(dt,vt))&&void 0!==J?J:w(ht);Et&&W.push({id:"line-subsec-".concat(gt),x1:Ct,y1:St,x2:bt,y2:Mt,style:Et,sectionIdx:Number(ht.split("-")[0]),isSubSection:!0,subSectionKeyPath:H})}}if(ct(W),v.current&&h.current){var kt=v.current.getBoundingClientRect(),wt=h.current.getBoundingClientRect(),Dt=(kt.top+kt.height/2-U.top+wt.top+wt.height/2-U.top)/2;ut({x1:kt.right-U.left,x2:wt.left-U.left,y:Dt})}else ut(null);if(I.size>0){var Yt=[],Ft=u.current,Nt=a.current;if(Ft&&Nt){var Ot=[],jt=Ft.getBoundingClientRect().top,zt=Nt.getBoundingClientRect().top,Pt=jt+Ft.clientHeight,qt=zt+Nt.clientHeight,Kt=Ft.scrollTop,Vt=Nt.scrollTop,Gt=U.top,Jt=function(t,e,n){return Math.max(e,Math.min(n,t))};I.forEach(function(t){var e,n,r,o,l,u;if("string"==typeof t&&t.includes(i)){var a=t.split(i),d=a[0],v=a[1],h=a[2],f=(a[3],"".concat(d).concat(i).concat(v)),p=null===(e=B.current[f])||void 0===e?void 0:e.current,y=null===(n=b.current[f])||void 0===n?void 0:n.current;if(!p||!y)return;var x=p.getBoundingClientRect(),m=y.getBoundingClientRect(),R=null!==(r=D(d,v))&&void 0!==r?r:w(h),C=(K=x.right-U.left)+.5*((V=m.left-U.left-0)-K),S=x.top+x.height/2,M=m.top+m.height/2,L=S-jt+Kt,I=M-zt+Vt,T="conn-subsec-".concat(f);Ot.push({lhsScrollY:L,rhsScrollY:I,x1:K,x2:V,containerTop:Gt,leftIdx:t,rhsArrayIdx:t,styleColor:(null==R?void 0:R.badgeBorder)||"#6366F1",styleId:T});var H=Jt(S,jt,Pt),E=Jt(M,zt,qt),Y=H-Gt,F=E-Gt,N=M>=zt-4&&M<=qt+4,O="";O=(G=S>=jt-4&&S<=Pt+4)&&N?c(K,Y,V,F):G&&!N?"M ".concat(K,",").concat(Y," L ").concat(C,",").concat(Y," L ").concat(C,",").concat(F):!G&&N?"M ".concat(C,",").concat(Y," L ").concat(C,",").concat(F," L ").concat(V,",").concat(F):"M ".concat(C,",").concat(Y," L ").concat(C,",").concat(F),Yt.push({id:T,pathD:O,style:R,leftIdx:t,rhsArrayIdx:t,x1:K,x2:V,y1:Y,y2:F})}else if(A){var j=t,z=s[j];if(!(null===(u=null==z?void 0:z.refIndexes)||void 0===u?void 0:u.length))return;z.refIndexes.forEach(function(t){var e,n,r=g.findIndex(function(e){return e.selfIndex===t});if(-1!==r){var i=null===(e=B.current[j])||void 0===e?void 0:e.current,o=null===(n=b.current[r])||void 0===n?void 0:n.current;if(i&&o){var l=i.getBoundingClientRect(),u=o.getBoundingClientRect(),a=k(j),d=l.right-U.left,v=u.left-U.left-0,h=d+.5*(v-d),s=l.top+l.height/2,f=u.top+u.height/2,p=s-jt+Kt,y=f-zt+Vt,x="conn-".concat(j,"-").concat(r);Ot.push({lhsScrollY:p,rhsScrollY:y,x1:d,x2:v,containerTop:Gt,leftIdx:j,rhsArrayIdx:r,styleColor:(null==a?void 0:a.badgeBorder)||"#6366F1",styleId:x});var m=Jt(s,jt,Pt),R=Jt(f,zt,qt),C=m-Gt,S=R-Gt,M=s>=jt-4&&s<=Pt+4,L=f>=zt-4&&f<=qt+4,I="";I=M&&L?c(d,C,v,S):M&&!L?"M ".concat(d,",").concat(C," L ").concat(h,",").concat(C," L ").concat(h,",").concat(S):!M&&L?"M ".concat(h,",").concat(C," L ").concat(h,",").concat(S," L ").concat(v,",").concat(S):"M ".concat(h,",").concat(C," L ").concat(h,",").concat(S),Yt.push({id:x,pathD:I,style:a,leftIdx:j,rhsArrayIdx:r,x1:d,x2:v,y1:C,y2:S})}}})}else{var P=t,q=P;p=null===(o=B.current[P])||void 0===o?void 0:o.current,y=null===(l=b.current[q])||void 0===l?void 0:l.current;if(!p||!y)return;var K,V;x=p.getBoundingClientRect(),m=y.getBoundingClientRect(),R=k(P),C=(K=x.right-U.left)+.5*((V=m.left-U.left-0)-K),S=x.top+x.height/2,M=m.top+m.height/2,L=S-jt+Kt,I=M-zt+Vt,T="conn-".concat(P,"-").concat(q);Ot.push({lhsScrollY:L,rhsScrollY:I,x1:K,x2:V,containerTop:Gt,leftIdx:P,rhsArrayIdx:q,styleColor:(null==R?void 0:R.badgeBorder)||"#6366F1",styleId:T});var G;H=Jt(S,jt,Pt),E=Jt(M,zt,qt),Y=H-Gt,F=E-Gt,N=M>=zt-4&&M<=qt+4,O="";O=(G=S>=jt-4&&S<=Pt+4)&&N?c(K,Y,V,F):G&&!N?"M ".concat(K,",").concat(Y," L ").concat(C,",").concat(Y," L ").concat(C,",").concat(F):!G&&N?"M ".concat(C,",").concat(Y," L ").concat(C,",").concat(F," L ").concat(V,",").concat(F):"M ".concat(C,",").concat(Y," L ").concat(C,",").concat(F),Yt.push({id:T,pathD:O,style:R,leftIdx:P,rhsArrayIdx:q,x1:K,x2:V,y1:Y,y2:F})}}),Bt.current=Ot}st(Yt)}else st([]),Bt.current=[]}catch(t){console.error("Line render safe fail: ",t)}finally{yt.current=!1}}},[f,s,g,E,et,nt,k,D,A,T,H,I,M,L]),St=n(function(){var t,e,n,r,i,o,v,h,s,g,f,p,y,x,m=Bt.current;if(m.length&&!F.current){var R=null!==(e=null===(t=u.current)||void 0===t?void 0:t.scrollTop)&&void 0!==e?e:0,C=null!==(r=null===(n=a.current)||void 0===n?void 0:n.scrollTop)&&void 0!==r?r:0,B=null!==(o=null===(i=u.current)||void 0===i?void 0:i.clientHeight)&&void 0!==o?o:1/0,b=null!==(h=null===(v=a.current)||void 0===v?void 0:v.clientHeight)&&void 0!==h?h:1/0,S=null!==(g=null===(s=u.current)||void 0===s?void 0:s.getBoundingClientRect().top)&&void 0!==g?g:0,M=null!==(p=null===(f=a.current)||void 0===f?void 0:f.getBoundingClientRect().top)&&void 0!==p?p:0,L=S+B,I=M+b,T=null!==(x=null===(y=l.current)||void 0===y?void 0:y.getBoundingClientRect().top)&&void 0!==x?x:0,H=function(t,e,n){return Math.max(e,Math.min(n,t))};m.forEach(function(t){var e=t.lhsScrollY-R+S,n=t.rhsScrollY-C+M,r=d.current[t.styleId+"-stroke"],i=d.current[t.styleId+"-bg"],o=d.current[t.styleId+"-btn"];if(r||i){var l,u=H(e,S,L),a=H(n,M,I),v=u-T,h=a-T,s=e>=S-4&&e<=L+4,g=n>=M-4&&n<=I+4,f=t.x1+.5*(t.x2-t.x1);l=s&&g?c(t.x1,v,t.x2,h):s&&!g?"M ".concat(t.x1,",").concat(v," L ").concat(f,",").concat(v," L ").concat(f,",").concat(h):!s&&g?"M ".concat(f,",").concat(v," L ").concat(f,",").concat(h," L ").concat(t.x2,",").concat(h):"M ".concat(f,",").concat(v," L ").concat(f,",").concat(h),r&&(r.setAttribute("visibility","visible"),r.setAttribute("d",l)),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",l)),o&&(s?(o.setAttribute("visibility","visible"),o.setAttribute("y",String(v-12))):o.setAttribute("visibility","hidden"))}})}},[]),Mt=n(function(){Bt.current.length>0&&!F.current||(null!==Rt.current&&clearTimeout(Rt.current),Rt.current=setTimeout(function(){G.current(),Rt.current=null},50))},[]),Lt=n(function(t){if(null!==_.current&&tt.current&&Math.abs(t.currentTarget.scrollTop-_.current)<=2){var e=tt.current;_.current=null,tt.current=null,e()}if(!mt.current&&!Q.current){if(A&&U&&(N.current||I.size>0)){var n=t.currentTarget,r=u.current,c=a.current,o=n===r?c:n===c?r:null;if(n&&o){var d=function(){var t,e,n,r,c,o,l,u,a,d,v,h=z.current,s=P.current;if(null===h)return{leftAnchor:null,rightAnchor:null};if("string"==typeof h&&h.includes(i)){var g=h.split(i),f="".concat(g[0]).concat(i).concat(g[1]);return{leftAnchor:(null===(t=B.current[f])||void 0===t?void 0:t.current)||(null===(e=R.current[g[2]])||void 0===e?void 0:e.current)||(null===(n=x.current[Number(g[2])])||void 0===n?void 0:n.current)||null,rightAnchor:(null===(r=b.current[f])||void 0===r?void 0:r.current)||(null===(c=C.current[g[3]])||void 0===c?void 0:c.current)||(null===(o=m.current[Number(g[3])])||void 0===o?void 0:o.current)||null}}var p=Number(h),y=null!==s?Number(s):p;return{leftAnchor:(null===(l=B.current[p])||void 0===l?void 0:l.current)||(null===(u=S.current[p])||void 0===u?void 0:u.current)||(null===(a=x.current[p])||void 0===a?void 0:a.current)||null,rightAnchor:(null===(d=b.current[y])||void 0===d?void 0:d.current)||(null===(v=m.current[y])||void 0===v?void 0:v.current)||null}}(),v=d.leftAnchor,h=d.rightAnchor,s=n===r?v:h,g=n===r?h:v,f=null;if(s&&g){var p=s.getBoundingClientRect(),y=g.getBoundingClientRect(),M=o.getBoundingClientRect(),L=p.top+p.height/2;f=y.top-M.top+o.scrollTop+y.height/2-(L-M.top)}else{var T=Math.max(0,n.scrollHeight-n.clientHeight),H=Math.max(0,o.scrollHeight-o.clientHeight);f=T>0?n.scrollTop/T*H:n.scrollTop}var E=Math.max(0,o.scrollHeight-o.clientHeight);f=Math.max(0,Math.min(f,E)),Math.abs(o.scrollTop-f)>1&&(mt.current=!0,o.scrollTop=f,requestAnimationFrame(function(){mt.current=!1}))}}A||Mt(),xt.current||(xt.current=!0,requestAnimationFrame(function(){var t,e,n,r,c,o,d;if(N.current){var v=u.current,h=a.current;if(v&&h&&j.current){if(!O.current){var s=z.current,g=void 0;if("string"==typeof s&&s.includes(i)){var f=s.split(i),p="".concat(f[0]).concat(i).concat(f[1]);g=null===(t=B.current[p])||void 0===t?void 0:t.current}else g=null===(e=B.current[s])||void 0===e?void 0:e.current;if(g){var y=g.getBoundingClientRect();O.current={badgeScreenY:y.top+y.height/2,initialScrollTop:v.scrollTop,leftTop:v.getBoundingClientRect().top,leftBottom:v.getBoundingClientRect().top+v.clientHeight,cTop:null!==(r=null===(n=l.current)||void 0===n?void 0:n.getBoundingClientRect().top)&&void 0!==r?r:0}}}if(O.current){var x=O.current,m=v.scrollTop-x.initialScrollTop,R=x.badgeScreenY-m,C=((c=R,o=x.leftTop,d=x.leftBottom,Math.max(o,Math.min(d,c)))-x.cTop).toString(),b=R>=x.leftTop-4&&R<=x.leftBottom+4;j.current.setAttribute("y1",C),j.current.setAttribute("y2",C),j.current.setAttribute("visibility",b?"visible":"hidden")}}}Bt.current.length>0&&St(),xt.current=!1}))}},[St,A,U,I,Mt]);return r(function(){G.current=bt},[bt]),r(function(){var t=setTimeout(Mt,250),e=function(){return W.current()};return window.addEventListener("resize",e),function(){clearTimeout(t),null!==Rt.current&&clearTimeout(Rt.current),null!==J.current&&clearTimeout(J.current),window.removeEventListener("resize",e)}},[X,Z,$,f,M,L,s,g,et,Mt,T,H,Y,I]),{lines:it,setLines:ct,overallConnector:lt,setOverallConnector:ut,connectedLines:ht,setConnectedLines:st,svgDimensions:ft,cachedConnectedPositions:Bt,calculateLines:bt,calculateLinesRef:G,calculateLinesDebounced:Mt,handleColumnScroll:Lt}};export{o as useLinesCalculator};
|
|
1
|
+
import{useState as t,useRef as e,useCallback as n,useEffect as i}from"react";import{DEVIATION_BADGE_SEPARATOR as r}from"../CognitiveComparehelpers.js";var c=function(c){var o=c.containerRef,l=c.leftContainerRef,u=c.rightContainerRef;c.svgContainerRef;var a=c.pathRefs,d=c.leftHeaderRef,s=c.rightHeaderRef,v=c.proposedSections,h=c.existingSections,g=c.visibleFields,f=c.leftRefs,p=c.rightRefs,b=c.sectionLeftRefs,y=c.sectionRightRefs,x=c.subSectionLeftRefs,m=c.subSectionRightRefs,R=c.lhsBadgeRefs,C=c.rhsBadgeRefs,A=c.sectionRowRefs,B=c.expandedSections,S=c.expandedSubSections,M=c.connectedSections,T=c.isSideBySide,I=c.activeSideBySideSection,L=c.maintainRelativeOrder,F=c.isGuidelineMode,H=c.cognitiveMap,w=c.getSectionCompareStyle,k=c.getSubSectionCompareStyle,E=c.getDeviationStyleByKey,N=c.isArrowVisible,Y=c.isAnimatingRef,D=c.isSideBySideRef,j=c.sideBySideCacheRef,O=c.sideBySideLineRef,z=c.activeSideBySideSectionRef,P=c.activeSideBySideRightSectionRef,Q=c.connectedLines,X=c.setConnectedLines,q=c.cachedConnectedPositions,G=c.calculateLinesRef,K=c.resizeTimerRef,V=c.scrollLock,J=c.scrollSyncLocked,U=c.handleResizeRef,W=c.activeProposed,Z=c.existingRule,$=c.analysisData,_=c.pendingScrollTargetRef,tt=c.pendingScrollCallbackRef,et=c.resolvedComparisonConfig,nt=c.getFieldData,it=t([]),rt=it[0],ct=it[1],ot=t(null),lt=ot[0],ut=ot[1],at=t([]),dt=at[0],st=at[1],vt=null!=Q?Q:dt,ht=null!=X?X:st,gt=t({width:0,height:0}),ft=gt[0],pt=gt[1],bt=e(!1),yt=e(!1),xt=e(!1),mt=e(null),Rt=e([]),Ct=null!=q?q:Rt,At=function(t,e,n,i,r,c,o){if(Math.abs(i-e)<=1)return c&&o?"M ".concat(t,",").concat(e," L ").concat(n,",").concat(i):c&&!o?"M ".concat(t,",").concat(e," L ").concat(r,",").concat(e):!c&&o?"M ".concat(r,",").concat(e," L ").concat(n,",").concat(i):"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i);var l=Math.min(15,Math.abs(r-t),Math.abs(i-e)/2),u=Math.min(15,Math.abs(n-r),Math.abs(i-e)/2),a=i>e?l:-l,d=i>e?u:-u,s=n>r?u:-u;return c&&o?"M ".concat(t,",").concat(e," L ").concat(r-l,",").concat(e," Q ").concat(r,",").concat(e," ").concat(r,",").concat(e+a," L ").concat(r,",").concat(i-d," Q ").concat(r,",").concat(i," ").concat(r+s,",").concat(i," L ").concat(n,",").concat(i):c&&!o?"M ".concat(t,",").concat(e," L ").concat(r-l,",").concat(e," Q ").concat(r,",").concat(e," ").concat(r,",").concat(e+a," L ").concat(r,",").concat(i):!c&&o?"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i-d," Q ").concat(r,",").concat(i," ").concat(r+s,",").concat(i," L ").concat(n,",").concat(i):"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i)},Bt=n(function(){var t,e,n,i,c,a,A,N,D,j,O,z,P,Q,X,q,G,K;if(!bt.current&&!Y.current){bt.current=!0;try{if(!o.current)return;var V=function(t){var e=t.split("-"),n=e[0];if(!B[n]&&!1===L)return!1;if(L&&!B["left-".concat(n)]&&!B["right-".concat(n)]&&!B[n])return!1;for(var i=n,r=1;r<e.length-1;r++)if(i+="-".concat(e[r]),!S[i])return!1;return!0},J=o.current.getBoundingClientRect();pt({width:J.width,height:J.height});var U=[];if(g.forEach(function(t){var e,n,i=t.key,r=null===(e=f.current[i])||void 0===e?void 0:e.current,c=null===(n=p.current[i])||void 0===n?void 0:n.current;r&&c&&(r.style.height="auto",c.style.height="auto",r.style.minHeight="0px",c.style.minHeight="0px")}),!Y.current){for(var W=0;W<Math.max(v.length,h.length);W++){var Z=null===(t=b.current[W])||void 0===t?void 0:t.current,$=null===(e=y.current[W])||void 0===e?void 0:e.current;Z&&(Z.style.height="auto",Z.style.minHeight="0px"),$&&($.style.height="auto",$.style.minHeight="0px")}L||Object.keys(x.current).forEach(function(t){var e,n;if(V(t)){var i=null===(e=x.current[t])||void 0===e?void 0:e.current,r=null===(n=m.current[t])||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 _={};g.forEach(function(t){var e,n,i=t.key,r=null===(e=f.current[i])||void 0===e?void 0:e.current,c=null===(n=p.current[i])||void 0===n?void 0:n.current;if(r&&c){var o=r.getBoundingClientRect(),l=c.getBoundingClientRect();_[i]=Math.max(o.height,l.height)}});var tt={left:{},right:{}},et={};if(!Y.current)if(L){if(T&&null!==I)if("number"==typeof I){var nt=I,it=v[nt],rt=null===(c=b.current[nt])||void 0===c?void 0:c.current;rt&&it&&(it.refIndexes||[]).forEach(function(t){var e,n=h.findIndex(function(e){return e.selfIndex===t}),i=null===(e=y.current[n])||void 0===e?void 0:e.current;if(i&&(B["left-".concat(nt)]||B["right-".concat(n)])){var r=Math.max(rt.getBoundingClientRect().height,i.getBoundingClientRect().height);tt.left[nt]=Math.max(tt.left[nt]||0,r),tt.right[n]=Math.max(tt.right[n]||0,r)}})}else{var ot=I.split(r)[2];if(ot){Z=null===(a=x.current[ot])||void 0===a?void 0:a.current,$=null===(A=m.current[ot])||void 0===A?void 0:A.current;if(Z&&$){lt=Math.max(Z.getBoundingClientRect().height,$.getBoundingClientRect().height);et[ot]=Math.max(et[ot]||0,lt)}}}}else{Object.keys(x.current).forEach(function(t){var e,n;if(V(t)){var i=null===(e=x.current[t])||void 0===e?void 0:e.current,r=null===(n=m.current[t])||void 0===n?void 0:n.current;if(i&&r&&null!==i.offsetParent&&null!==r.offsetParent){var c=i.getBoundingClientRect(),o=r.getBoundingClientRect(),l=Math.max(c.height,o.height);et[t]=l,i.style.minHeight="".concat(l,"px"),r.style.minHeight="".concat(l,"px")}}});for(W=0;W<Math.min(v.length,h.length);W++){var Z=null===(n=b.current[W])||void 0===n?void 0:n.current,$=null===(i=y.current[W])||void 0===i?void 0:i.current;if(Z&&$){var lt=Math.max(Z.getBoundingClientRect().height,$.getBoundingClientRect().height);tt.left[W]=lt,tt.right[W]=lt}}}if(g.forEach(function(t){var e,n,i=t.key,r=null===(e=f.current[i])||void 0===e?void 0:e.current,c=null===(n=p.current[i])||void 0===n?void 0:n.current;if(r&&c){var o=_[i];r.style.minHeight="".concat(o,"px"),c.style.minHeight="".concat(o,"px")}}),Y.current||(Object.entries(tt.left).forEach(function(t){var e,n=t[0],i=t[1],r=null===(e=b.current[Number(n)])||void 0===e?void 0:e.current;r&&(r.style.minHeight="".concat(i,"px"))}),Object.entries(tt.right).forEach(function(t){var e,n=t[0],i=t[1],r=null===(e=y.current[Number(n)])||void 0===e?void 0:e.current;r&&(r.style.minHeight="".concat(i,"px"))}),L||Object.keys(et).forEach(function(t){var e,n,i=null===(e=x.current[t])||void 0===e?void 0:e.current,r=null===(n=m.current[t])||void 0===n?void 0:n.current;if(i&&r&&et[t]){var c=et[t];i.style.minHeight="".concat(c,"px"),r.style.minHeight="".concat(c,"px")}})),!F){v.forEach(function(t,e){var n,i=null===(n=b.current[e])||void 0===n?void 0:n.current;if(i){var r=function(t,e){var n=(t.refIndexes||[]).map(function(t){return h.findIndex(function(e){return e.selfIndex===t})}).filter(function(t){return-1!==t});return!n.length&&h[e]?[e]:Array.from(new Set(n))}(t,e);r.forEach(function(n){var r,c,o,a,d,s,v,g,f,p,b=null===(r=y.current[n])||void 0===r?void 0:r.current;if(b){var x=i.getBoundingClientRect(),m=b.getBoundingClientRect(),R=x.right-J.left,C=m.left-J.left,A=x.top+18-J.top,B=m.top+18-J.top;if(L&&T&&I===e){var S=null!==(o=null===(c=l.current)||void 0===c?void 0:c.getBoundingClientRect().top)&&void 0!==o?o:0,M=null!==(d=null===(a=u.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==d?d:0,F=S+(null!==(v=null===(s=l.current)||void 0===s?void 0:s.clientHeight)&&void 0!==v?v:1/0),k=M+(null!==(f=null===(g=u.current)||void 0===g?void 0:g.clientHeight)&&void 0!==f?f:1/0),E=function(t,e,n){return Math.max(e,Math.min(n,t))};A=E(x.top+18,S,F)-J.top,B=E(m.top+18,M,k)-J.top}var N=w(e);N&&U.push({id:"line-".concat(e,"-").concat(n),x1:R,y1:A,x2:C,y2:B,style:N,sectionIdx:e,targetRightIdx:n,isSubSection:!1,hasCognitive:!!((null==t?void 0:t.cognitiveData)||(null===(p=h[n])||void 0===p?void 0:p.cognitiveData)||(null==t?void 0:t.nodeId)&&H[t.nodeId])})}})}})}if(!F&&T&&"string"==typeof I&&I.includes(r)){var at=I.split(r),dt=at[0],st=at[1],vt=at[2],gt=(at[3],"".concat(dt).concat(r).concat(st)),ft=null===(N=R.current[gt])||void 0===N?void 0:N.current,yt=null===(D=C.current[gt])||void 0===D?void 0:D.current;if(ft&&yt){var xt=ft.getBoundingClientRect(),mt=yt.getBoundingClientRect(),Rt=xt.right-J.left,Bt=mt.left-J.left,Mt=xt.top+xt.height/2-J.top,Tt=mt.top+mt.height/2-J.top;if(L){var It=null!==(O=null===(j=l.current)||void 0===j?void 0:j.getBoundingClientRect().top)&&void 0!==O?O:0,Lt=null!==(P=null===(z=u.current)||void 0===z?void 0:z.getBoundingClientRect().top)&&void 0!==P?P:0,Ft=It+(null!==(X=null===(Q=l.current)||void 0===Q?void 0:Q.clientHeight)&&void 0!==X?X:1/0),Ht=Lt+(null!==(G=null===(q=u.current)||void 0===q?void 0:q.clientHeight)&&void 0!==G?G:1/0),wt=function(t,e,n){return Math.max(e,Math.min(n,t))};Mt=wt(xt.top+xt.height/2,It,Ft)-J.top,Tt=wt(mt.top+mt.height/2,Lt,Ht)-J.top}var kt=null!==(K=E(dt,st))&&void 0!==K?K:k(vt);kt&&U.push({id:"line-subsec-".concat(gt),x1:Rt,y1:Mt,x2:Bt,y2:Tt,style:kt,sectionIdx:Number(vt.split("-")[0]),isSubSection:!0,subSectionKeyPath:I})}}if(ct(U),d.current&&s.current){var Et=d.current.getBoundingClientRect(),Nt=s.current.getBoundingClientRect(),Yt=(Et.top+Et.height/2-J.top+Nt.top+Nt.height/2-J.top)/2;ut({x1:Et.right-J.left,x2:Nt.left-J.left,y:Yt})}else ut(null);if(M.size>0){var Dt=[],jt=l.current,Ot=u.current;if(jt&&Ot){var zt=[],Pt=jt.getBoundingClientRect().top,Qt=Ot.getBoundingClientRect().top,Xt=Pt+jt.clientHeight,qt=Qt+Ot.clientHeight,Gt=jt.scrollTop,Kt=Ot.scrollTop,Vt=J.top,Jt=function(t,e,n){return Math.max(e,Math.min(n,t))};M.forEach(function(t){var e,n,i,c,o,l,u,a,d;if(F){var s=null,g=null,f=null;if("string"==typeof t&&t.includes(r)){var p=t.split(r),b=p[0],y=p[1],x=p[2],m="".concat(b).concat(r).concat(y);s=null===(e=R.current[m])||void 0===e?void 0:e.current,f=null!==(n=E(b,y))&&void 0!==n?n:k(x),g=Number((null==x?void 0:x.split("-")[0])||0)}else g=Number(t),s=null===(i=R.current[g])||void 0===i?void 0:i.current,f=w(g);if(!s)return;document.querySelectorAll('[id^="guideline-target-"]').forEach(function(e,n){var i=s.getBoundingClientRect(),c=e.getBoundingClientRect(),o=i.right-J.left,l=c.left-J.left-0,u=o+75,a=i.top+i.height/2,d=c.top+c.height/2,v=a-Pt+Gt,h=d-Qt+Kt,g="conn-guide-".concat(t,"-").concat(n),p="";"string"==typeof t&&t.includes(r)?p=(t.split(r)[2]||"").split("-").map(function(t){return Number(t)+1}).join("."):p=String(Number(t)+1);var b=String.fromCharCode(97+n),y="".concat(p,"(").concat(b,")");zt.push({lhsScrollY:v,rhsScrollY:h,x1:o,x2:l,containerTop:Vt,leftIdx:t,rhsArrayIdx:n,styleColor:(null==f?void 0:f.badgeBorder)||"#6366F1",styleBg:(null==f?void 0:f.badgeBg)||"#FFFFFF",styleText:(null==f?void 0:f.badgeText)||"#A16207",styleId:g,centerX:u});var x=Jt(a,Pt,Xt),m=Jt(d,Qt,qt),R=x-Vt,C=m-Vt,A=At(o,R,l,C,u,a>=Pt-4&&a<=Xt+4,d>=Qt-4&&d<=qt+4);Dt.push({id:g,pathD:A,style:f,leftIdx:t,rhsArrayIdx:n,x1:o,x2:l,y1:R,y2:C,centerX:u,matchLabel:y,isGuideline:!0})})}else if("string"==typeof t&&t.includes(r)){var A=t.split(r),B=(b=A[0],y=A[1],x=A[2],A[3],m="".concat(b).concat(r).concat(y),null===(c=R.current[m])||void 0===c?void 0:c.current),S=null===(o=C.current[m])||void 0===o?void 0:o.current;if(!B||!S)return;var M=B.getBoundingClientRect(),T=S.getBoundingClientRect(),I=null!==(l=E(b,y))&&void 0!==l?l:k(x),H=M.right-J.left,N=T.left-J.left-0,Y=H+75,D=M.top+M.height/2,j=T.top+T.height/2,O=D-Pt+Gt,z=j-Qt+Kt,P="conn-subsec-".concat(m),Q=(x||"").split("-").map(function(t){return Number(t)+1}).join("."),X="".concat(Q,"(a)");zt.push({lhsScrollY:O,rhsScrollY:z,x1:H,x2:N,containerTop:Vt,leftIdx:t,rhsArrayIdx:t,styleColor:(null==I?void 0:I.badgeBorder)||"#6366F1",styleBg:(null==I?void 0:I.badgeBg)||"#FFFFFF",styleText:(null==I?void 0:I.badgeText)||"#A16207",styleId:P,centerX:Y});var q=Jt(D,Pt,Xt),G=Jt(j,Qt,qt),K=At(H,$=q-Vt,N,_=G-Vt,Y,D>=Pt-4&&D<=Xt+4,j>=Qt-4&&j<=qt+4);Dt.push({id:P,pathD:K,style:I,leftIdx:t,rhsArrayIdx:t,x1:H,x2:N,y1:$,y2:_,matchLabel:X})}else if(L){var V=t,U=v[V];if(!(null===(d=null==U?void 0:U.refIndexes)||void 0===d?void 0:d.length))return;U.refIndexes.forEach(function(e,n){var i,r,c=h.findIndex(function(t){return t.selfIndex===e});if(-1!==c){var o=null===(i=R.current[V])||void 0===i?void 0:i.current,l=null===(r=C.current[c])||void 0===r?void 0:r.current;if(o&&l){var u=o.getBoundingClientRect(),a=l.getBoundingClientRect(),d=w(V),s=u.right-J.left,v=a.left-J.left-0,g=s+75,f=u.top+u.height/2,p=a.top+a.height/2,b=f-Pt+Gt,y=p-Qt+Kt,x="conn-".concat(V,"-").concat(c),m=String(Number(t)+1),A=String.fromCharCode(97+n),B="".concat(m,"(").concat(A,")");zt.push({lhsScrollY:b,rhsScrollY:y,x1:s,x2:v,containerTop:Vt,leftIdx:V,rhsArrayIdx:c,styleColor:(null==d?void 0:d.badgeBorder)||"#6366F1",styleBg:(null==d?void 0:d.badgeBg)||"#FFFFFF",styleText:(null==d?void 0:d.badgeText)||"#A16207",styleId:x,centerX:g});var S=Jt(f,Pt,Xt),M=Jt(p,Qt,qt),T=S-Vt,I=M-Vt,L=At(s,T,v,I,g,f>=Pt-4&&f<=Xt+4,p>=Qt-4&&p<=qt+4);Dt.push({id:x,pathD:L,style:d,leftIdx:V,rhsArrayIdx:c,x1:s,x2:v,y1:T,y2:I,matchLabel:B})}}})}else{var W=t,Z=W;B=null===(u=R.current[W])||void 0===u?void 0:u.current,S=null===(a=C.current[Z])||void 0===a?void 0:a.current;if(!B||!S)return;M=B.getBoundingClientRect(),T=S.getBoundingClientRect(),I=w(W),H=M.right-J.left,N=T.left-J.left-0,Y=H+75,D=M.top+M.height/2,j=T.top+T.height/2,O=D-Pt+Gt,z=j-Qt+Kt,P="conn-".concat(W,"-").concat(Z),Q=String(Number(t)+1),X="".concat(Q,"(a)");zt.push({lhsScrollY:O,rhsScrollY:z,x1:H,x2:N,containerTop:Vt,leftIdx:W,rhsArrayIdx:Z,styleColor:(null==I?void 0:I.badgeBorder)||"#6366F1",styleBg:(null==I?void 0:I.badgeBg)||"#FFFFFF",styleText:(null==I?void 0:I.badgeText)||"#A16207",styleId:P,centerX:Y});var $,_;q=Jt(D,Pt,Xt),G=Jt(j,Qt,qt),K=At(H,$=q-Vt,N,_=G-Vt,Y,D>=Pt-4&&D<=Xt+4,j>=Qt-4&&j<=qt+4);Dt.push({id:P,pathD:K,style:I,leftIdx:W,rhsArrayIdx:Z,x1:H,x2:N,y1:$,y2:_,matchLabel:X})}}),Ct.current=zt}ht(Dt),setTimeout(function(){return St()},10)}else ht([]),Ct.current=[],setTimeout(function(){return St()},10)}catch(t){console.error("Line render safe fail: ",t)}finally{bt.current=!1}}},[g,v,h,H,et,nt,w,E,L,T,I,M,B,S,F]),St=n(function(){var t,e,n,i,r,c,d,s,v,h,g,f,p,b,y,x,m,R,C,A=Ct.current;if(!A.length)return null===(t=a.current["guideline-up-stroke"])||void 0===t||t.setAttribute("visibility","hidden"),null===(e=a.current["guideline-up-badge"])||void 0===e||e.setAttribute("visibility","hidden"),null===(n=a.current["guideline-down-stroke"])||void 0===n||n.setAttribute("visibility","hidden"),void(null===(i=a.current["guideline-down-badge"])||void 0===i||i.setAttribute("visibility","hidden"));if(!Y.current){var B=null!==(c=null===(r=l.current)||void 0===r?void 0:r.scrollTop)&&void 0!==c?c:0,S=null!==(s=null===(d=u.current)||void 0===d?void 0:d.scrollTop)&&void 0!==s?s:0,M=null!==(h=null===(v=l.current)||void 0===v?void 0:v.clientHeight)&&void 0!==h?h:1/0,T=null!==(f=null===(g=u.current)||void 0===g?void 0:g.clientHeight)&&void 0!==f?f:1/0,I=null!==(b=null===(p=l.current)||void 0===p?void 0:p.getBoundingClientRect().top)&&void 0!==b?b:0,L=null!==(x=null===(y=u.current)||void 0===y?void 0:y.getBoundingClientRect().top)&&void 0!==x?x:0,F=I+M,H=L+T,w=null===(m=o.current)||void 0===m?void 0:m.getBoundingClientRect(),k=null!==(R=null==w?void 0:w.top)&&void 0!==R?R:0,E=null!==(C=null==w?void 0:w.height)&&void 0!==C?C:1/0,N=function(t,e,n){return Math.max(e,Math.min(n,t))},D=0,j=0,O=0,z=0,P="#6366F1",Q="#A16207",X=!1;if(A.forEach(function(t){var e=t.lhsScrollY-B+I,n=t.rhsScrollY-S+L,i=a.current[t.styleId+"-stroke"],r=a.current[t.styleId+"-bg"],c=a.current[t.styleId+"-btn"],o=a.current[t.styleId+"-number"];if(i||r){var l=N(e,I,F),u=N(n,L,H),d=l-k,s=u-k,v=e>=I-4&&e<=F+4,h=n>=L-4&&n<=H+4,g=!0;X=!0;var f=t.centerX||t.x1+75;0===O&&(O=t.x1,z=d,P=t.styleColor,t.styleBg,Q=t.styleText||"#A16207"),n<L-4?(D++,g=!1):n>H+4&&(j++,g=!1);var p=At(t.x1,d,t.x2,s,f,v,h);i&&(g&&p?(i.setAttribute("visibility","visible"),i.setAttribute("d",p)):i.setAttribute("visibility","hidden")),r&&(g&&p?(r.setAttribute("visibility","visible"),r.setAttribute("d",p)):r.setAttribute("visibility","hidden")),c&&(v&&g?(c.setAttribute("visibility","visible"),c.setAttribute("y",String(d-12))):c.setAttribute("visibility","hidden")),o&&(v&&g?(o.setAttribute("visibility","visible"),o.setAttribute("transform","translate(".concat(t.x2-42,", ").concat(s,")"))):o.setAttribute("visibility","hidden"))}}),X){var q=a.current["guideline-up-stroke"],G=a.current["guideline-up-badge"],K=a.current["guideline-up-arrow"],V=a.current["guideline-up-text"],J=a.current["guideline-up-badge-rect"],U=O+75;if(D>0){var W=Math.max(15,L-k+15),Z=Math.min(15,Math.abs(U-O),Math.max(0,z-W)),$="M ".concat(O,",").concat(z," L ").concat(U-Z,",").concat(z," Q ").concat(U,",").concat(z," ").concat(U,",").concat(z-Z," L ").concat(U,",").concat(W);null==q||q.setAttribute("visibility","visible"),null==q||q.setAttribute("d",$),null==q||q.setAttribute("stroke",P),null==G||G.setAttribute("visibility","visible"),null==G||G.setAttribute("transform","translate(".concat(U,", ").concat(W,")")),K&&K.setAttribute("fill",P),V&&(V.textContent="+".concat(D),V.setAttribute("fill",Q)),J&&J.setAttribute("stroke",P)}else null==q||q.setAttribute("visibility","hidden"),null==G||G.setAttribute("visibility","hidden");var _=a.current["guideline-down-stroke"],tt=a.current["guideline-down-badge"],et=a.current["guideline-down-arrow"],nt=a.current["guideline-down-text"],it=a.current["guideline-down-badge-rect"];if(j>0){var rt=Math.min(E-15,H-k-15);Z=Math.min(15,Math.abs(U-O),Math.max(0,rt-z)),$="M ".concat(O,",").concat(z," L ").concat(U-Z,",").concat(z," Q ").concat(U,",").concat(z," ").concat(U,",").concat(z+Z," L ").concat(U,",").concat(rt);null==_||_.setAttribute("visibility","visible"),null==_||_.setAttribute("d",$),null==_||_.setAttribute("stroke",P),null==tt||tt.setAttribute("visibility","visible"),null==tt||tt.setAttribute("transform","translate(".concat(U,", ").concat(rt,")")),et&&et.setAttribute("fill",P),nt&&(nt.textContent="+".concat(j),nt.setAttribute("fill",Q)),it&&it.setAttribute("stroke",P)}else null==_||_.setAttribute("visibility","hidden"),null==tt||tt.setAttribute("visibility","hidden")}}},[]),Mt=n(function(){Ct.current.length>0&&!Y.current||(null!==mt.current&&clearTimeout(mt.current),mt.current=setTimeout(function(){G.current(),mt.current=null},50))},[]),Tt=n(function(t){if(null!==_.current&&tt.current&&Math.abs(t.currentTarget.scrollTop-_.current)<=2){var e=tt.current;_.current=null,tt.current=null,e()}if(!xt.current&&!V.current){if(L&&J&&(D.current||M.size>0)){var n=t.currentTarget,i=l.current,c=u.current,a=n===i?c:n===c?i:null;if(n&&a){var d=function(){var t,e,n,i,c,o,l,u,a,d,s,v=z.current,h=P.current;if(null===v)return{leftAnchor:null,rightAnchor:null};if("string"==typeof v&&v.includes(r)){var g=v.split(r),f="".concat(g[0]).concat(r).concat(g[1]);return{leftAnchor:(null===(t=R.current[f])||void 0===t?void 0:t.current)||(null===(e=x.current[g[2]])||void 0===e?void 0:e.current)||(null===(n=b.current[Number(g[2])])||void 0===n?void 0:n.current)||null,rightAnchor:(null===(i=C.current[f])||void 0===i?void 0:i.current)||(null===(c=m.current[g[3]])||void 0===c?void 0:c.current)||(null===(o=y.current[Number(g[3])])||void 0===o?void 0:o.current)||null}}var p=Number(v),B=null!==h?Number(h):p;return{leftAnchor:(null===(l=R.current[p])||void 0===l?void 0:l.current)||(null===(u=A.current[p])||void 0===u?void 0:u.current)||(null===(a=b.current[p])||void 0===a?void 0:a.current)||null,rightAnchor:(null===(d=C.current[B])||void 0===d?void 0:d.current)||(null===(s=y.current[B])||void 0===s?void 0:s.current)||null}}(),s=d.leftAnchor,v=d.rightAnchor,h=n===i?s:v,g=n===i?v:s,f=null;if(h&&g){var p=h.getBoundingClientRect(),B=g.getBoundingClientRect(),S=a.getBoundingClientRect(),T=p.top+p.height/2;f=B.top-S.top+a.scrollTop+B.height/2-(T-S.top)}else{var I=Math.max(0,n.scrollHeight-n.clientHeight),F=Math.max(0,a.scrollHeight-a.clientHeight);f=I>0?n.scrollTop/I*F:n.scrollTop}var H=Math.max(0,a.scrollHeight-a.clientHeight);f=Math.max(0,Math.min(f,H)),Math.abs(a.scrollTop-f)>1&&(xt.current=!0,a.scrollTop=f,requestAnimationFrame(function(){xt.current=!1}))}}L||Mt(),yt.current||(yt.current=!0,requestAnimationFrame(function(){var t,e,n,i,c,a,d;if(D.current){var s=l.current,v=u.current;if(s&&v&&O.current){if(!j.current){var h=z.current,g=void 0;if("string"==typeof h&&h.includes(r)){var f=h.split(r),p="".concat(f[0]).concat(r).concat(f[1]);g=null===(t=R.current[p])||void 0===t?void 0:t.current}else g=null===(e=R.current[h])||void 0===e?void 0:e.current;if(g){var b=g.getBoundingClientRect();j.current={badgeScreenY:b.top+b.height/2,initialScrollTop:s.scrollTop,leftTop:s.getBoundingClientRect().top,leftBottom:s.getBoundingClientRect().top+s.clientHeight,cTop:null!==(i=null===(n=o.current)||void 0===n?void 0:n.getBoundingClientRect().top)&&void 0!==i?i:0}}}if(j.current){var y=j.current,x=s.scrollTop-y.initialScrollTop,m=y.badgeScreenY-x,C=((c=m,a=y.leftTop,d=y.leftBottom,Math.max(a,Math.min(d,c)))-y.cTop).toString(),A=m>=y.leftTop-4&&m<=y.leftBottom+4;O.current.setAttribute("y1",C),O.current.setAttribute("y2",C),O.current.setAttribute("visibility",A?"visible":"hidden")}}}St(),yt.current=!1}))}},[St,L,J,M,Mt]);return i(function(){G.current=Bt},[Bt]),i(function(){var t=setTimeout(Mt,250),e=function(){return U.current()};return window.addEventListener("resize",e),function(){clearTimeout(t),null!==mt.current&&clearTimeout(mt.current),null!==K.current&&clearTimeout(K.current),window.removeEventListener("resize",e)}},[W,Z,$,g,B,S,v,h,et,Mt,T,I,N,M]),{lines:rt,setLines:ct,overallConnector:lt,setOverallConnector:ut,connectedLines:vt,setConnectedLines:ht,svgDimensions:ft,cachedConnectedPositions:Ct,calculateLines:Bt,calculateLinesRef:G,calculateLinesDebounced:Mt,handleColumnScroll:Tt}};export{c as useLinesCalculator};
|
|
2
2
|
//# sourceMappingURL=useLinesCalculator.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useState as e,useRef as n,useCallback as t,useEffect as r}from"react";import{DEVIATION_BADGE_SEPARATOR as i,
|
|
1
|
+
import{useState as e,useRef as n,useCallback as t,useEffect as r}from"react";import{DEVIATION_BADGE_SEPARATOR as i,resetClauseHighlight as l,smoothScrollTo as u}from"../CognitiveComparehelpers.js";var o=function(o){var c=o.isGuidelineMode,d=o.maintainRelativeOrder,s=o.proposedSections,v=o.existingSections,a=o.leftContainerRef,p=o.rightContainerRef,g=o.scrollContainerRef,f=o.sectionLeftRefs,h=o.sectionRightRefs,R=o.subSectionLeftRefs,S=o.subSectionRightRefs,y=o.lhsBadgeRefs,m=o.rhsBadgeRefs,B=o.sectionRowRefs,x=o.sectionRightRowRefs,C=o.rhsTopSpacerRef,T=o.rhsBottomSpacerRef,b=o.lhsTopSpacerRef,A=o.lhsBottomSpacerRef,I=o.calculateLinesRef,w=o.setConnectedSections,L=o.setConnectedLines,E=o.cachedConnectedPositions,F=o.closeMoreFunctionsPopup,N=o.setErrorToast;o.moreFunctions,o.closeSummaryPopup;var q=e(!1),H=q[0],M=q[1],P=e(!1),z=P[0],V=P[1],j=e(!1),k=j[0],G=j[1],O=e(!1),D=O[0],J=O[1],K=e(null),Q=K[0],U=K[1],W=n(!1),X=n(null),Y=n(!1),Z=n(null),$=n(null),_=n(null),ee=n(new Set),ne=function(){ee.current.forEach(function(e){l(e)}),ee.current.clear()},te=function(e,n,t){var r,l,u,o,c,d,s,v,g,C,T,b,A=null,I=null,w=null,L=null,E=null,F=null,N=function(e,n){if(!e||!n)return!0;var t=e.getBoundingClientRect(),r=n.getBoundingClientRect();return t.bottom>=r.top&&t.top<=r.bottom};if(e){var q=n.split(i),H="".concat(q[0]).concat(i).concat(q[1]);A=(null===(r=R.current[q[2]])||void 0===r?void 0:r.current)||(null===(l=f.current[Number(q[2])])||void 0===l?void 0:l.current)||null,I=(null===(u=S.current[q[3]])||void 0===u?void 0:u.current)||(null===(o=h.current[Number(q[3])])||void 0===o?void 0:o.current)||null,w=(null===(c=y.current[H])||void 0===c?void 0:c.current)||A,L=(null===(d=m.current[H])||void 0===d?void 0:d.current)||I}else{var M=Number(n),P=null!==t?Number(t):M;A=(null===(s=f.current[M])||void 0===s?void 0:s.current)||null,I=(null===(v=h.current[P])||void 0===v?void 0:v.current)||null,E=(null===(g=y.current[M])||void 0===g?void 0:g.current)||null,F=(null===(C=m.current[P])||void 0===C?void 0:C.current)||null,w=E||(null===(T=B.current[M])||void 0===T?void 0:T.current)||A,L=F||(null===(b=x.current[P])||void 0===b?void 0:b.current)||I}if(A&&(A.style.paddingTop="0px"),I&&(I.style.paddingTop="0px"),e||(E&&(E.style.marginTop="0px"),F&&(F.style.marginTop="0px")),!e&&E&&F){var z=a.current,V=p.current;if(!N(E,z)||!N(F,V))return;var j=E.getBoundingClientRect(),k=F.getBoundingClientRect(),G=j.top-k.top;if(Math.abs(G)>32)return;G>0&&(F.style.marginTop="".concat(G,"px"))}else if(w&&L&&A&&I){j=w.getBoundingClientRect(),k=L.getBoundingClientRect();(G=j.top-k.top)>0&&(I.style.paddingTop="".concat(G,"px"))}},re=t(function(){var e,n,t,r,l,u,o,c,d=Z.current,s=$.current;if(null!==d)if("string"==typeof d&&d.includes(i)){var v=d.split(i),a=(null===(e=R.current[v[2]])||void 0===e?void 0:e.current)||(null===(n=f.current[Number(v[2])])||void 0===n?void 0:n.current)||null,p=(null===(t=S.current[v[3]])||void 0===t?void 0:t.current)||(null===(r=h.current[Number(v[3])])||void 0===r?void 0:r.current)||null;a&&(a.style.paddingTop="0px"),p&&(p.style.paddingTop="0px")}else{a=(null===(l=f.current[d])||void 0===l?void 0:l.current)||null,p=(null===(u=h.current[null!=s?s:d])||void 0===u?void 0:u.current)||null;a&&(a.style.paddingTop="0px"),p&&(p.style.paddingTop="0px");var g=(null===(o=y.current[d])||void 0===o?void 0:o.current)||null,B=(null===(c=m.current[null!=s?s:d])||void 0===c?void 0:c.current)||null;g&&(g.style.marginTop="0px"),B&&(B.style.marginTop="0px")}C.current&&(C.current.style.height="0px"),T.current&&(T.current.style.height="0px"),b.current&&(b.current.style.height="0px"),A.current&&(A.current.style.height="0px")},[]);r(function(){Y.current=H},[H]),r(function(){Z.current=Q},[Q]);var ie=t(function(){ne(),M(!1),Y.current=!1,X.current=null,re(),U(null),Z.current=null,$.current=null,V(!1),J(!1)},[re]),le=t(function(e,n,t){var r,l,o=null===(r=null==t?void 0:t.toggleIfSame)||void 0===r||r,R=null==t?void 0:t.onReady,S=null!==(l=null==t?void 0:t.sourceSide)&&void 0!==l?l:"left";if(F(),null!=e)if(!n||c){ne();var q=H&&Q===e;H&&null!==Q&&re(),q&&o?ie():(w(new Set([e])),L([]),E.current=[],J(!0),W.current=!0,U(e),Z.current=e,M(!0),Y.current=!0,V(!1),C.current&&(C.current.style.height="0px"),T.current&&(T.current.style.height="0px"),b.current&&(b.current.style.height="0px"),A.current&&(A.current.style.height="0px"),requestAnimationFrame(function(){var n=function(){var n,t,r,l,o,b,A,w,L,E,F,N="string"==typeof e&&e.includes(i),q=null,H=null,M=null;if(c){if(N){var P=e.split(i),z="".concat(P[0]).concat(i).concat(P[1]);q=(null===(n=y.current[z])||void 0===n?void 0:n.current)||null}else q=(null===(t=f.current[e])||void 0===t?void 0:t.current)||(null===(r=B.current[e])||void 0===r?void 0:r.current)||null;H=document.getElementById("guideline-target-0"),M=H?e:null}else if(N){P=e.split(i),z="".concat(P[0]).concat(i).concat(P[1]);q=(null===(l=y.current[z])||void 0===l?void 0:l.current)||null,H=(null===(o=m.current[z])||void 0===o?void 0:o.current)||null,M=H?e:null}else if(q=(null===(b=f.current[e])||void 0===b?void 0:b.current)||(null===(A=B.current[e])||void 0===A?void 0:A.current)||null,d){var j=s[e],k=(null==j?void 0:j.refIndexes)||[];if(k.length>0){var G=k[0],O=v.findIndex(function(e){return e.selfIndex===G});-1!==O&&(H=(null===(E=h.current[O])||void 0===E?void 0:E.current)||(null===(F=x.current[O])||void 0===F?void 0:F.current)||null,M=O)}}else H=(null===(w=h.current[e])||void 0===w?void 0:w.current)||(null===(L=x.current[e])||void 0===L?void 0:L.current)||null,M=H?e:null;$.current=M;var D=a.current,K=p.current,Q=function(){te(N,e,M),V(!0),I.current&&I.current(),W.current=!1,"right"===S&&K?K.dispatchEvent(new Event("scroll")):D&&D.dispatchEvent(new Event("scroll")),J(!1),null==R||R()};if(!q||!D)return W.current=!1,J(!1),void(null==R||R());if(H&&K){if(!d){var U=0;U="right"===S?H?H.getBoundingClientRect().top:0:q?q.getBoundingClientRect().top:0;var X=g.current,Y=(null==X?void 0:X.getBoundingClientRect().top)||0,Z=X?X.scrollTop+U-Y-150:0;return X?void u(X,Z,200,Q):void Q()}var _=q.getBoundingClientRect().top-D.getBoundingClientRect().top+D.scrollTop,ee=H.getBoundingClientRect().top-K.getBoundingClientRect().top+K.scrollTop,ne=200;if("left"===S){var re=ee-(_-D.scrollTop);re<0&&C.current&&!c&&(C.current.style.height="".concat(Math.abs(re),"px")),requestAnimationFrame(function(){var e,n=K.scrollHeight-K.clientHeight;if(re<0)e=0;else{if(re>n){var t=re-n;return T.current&&!c&&(T.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){u(K,re,ne,Q)})}e=re}u(K,e,ne,Q)})}else{var ie=_-(ee-K.scrollTop);requestAnimationFrame(function(){var e,n=D.scrollHeight-D.clientHeight;if(ie<0)e=0;else{if(ie>n)return void requestAnimationFrame(function(){return u(D,n,ne,Q)});e=ie}u(D,e,ne,Q)})}}else Q()};c?setTimeout(n,100):n()}))}else N("No counterpart exists for this section.")},[Q,F,v,H,d,s,re,ie,c]);return{isSideBySide:H,setIsSideBySide:M,isArrowVisible:z,setIsArrowVisible:V,isResizing:k,setIsResizing:G,isSideBySideLoading:D,setIsSideBySideLoading:J,activeSideBySideSection:Q,setActiveSideBySideSection:U,scrollLock:W,sideBySideCacheRef:X,isSideBySideRef:Y,activeSideBySideSectionRef:Z,activeSideBySideRightSectionRef:$,sideBySideLineRef:_,highlightedClauseRefs:ee,clearClauseHighlight:ne,applyAlignmentPadding:te,resetSideBySide:ie,activateSideBySide:le}};export{o as useSideBySide};
|
|
2
2
|
//# sourceMappingURL=useSideBySide.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CognitiveCompareTest.d.ts","sourceRoot":"","sources":["../../../src/CognitiveCompareTest.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CognitiveCompareTest.d.ts","sourceRoot":"","sources":["../../../src/CognitiveCompareTest.tsx"],"names":[],"mappings":"AAOA,QAAA,MAAM,oBAAoB,+CA6MzB,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|