@viswa-test/test-citation 0.0.312 → 0.0.314

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.
Files changed (57) hide show
  1. package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js +1 -1
  2. package/dist/cjs/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js +1 -1
  3. package/dist/cjs/features/CognitiveCompare/Guidelines/components/WebGptPanel.js +1 -1
  4. package/dist/cjs/features/CognitiveCompare/Guidelines/utils/guidelineTargets.js +2 -0
  5. package/dist/cjs/features/CognitiveCompare/Guidelines/utils/guidelineTargets.js.map +1 -0
  6. package/dist/cjs/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js +1 -1
  7. package/dist/cjs/features/CognitiveCompare/Guidelines/utils/resolveGuidelineSelection.js +2 -0
  8. package/dist/cjs/features/CognitiveCompare/Guidelines/utils/resolveGuidelineSelection.js.map +1 -0
  9. package/dist/cjs/features/CognitiveCompare/hooks/useCompareData.js +1 -1
  10. package/dist/cjs/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
  11. package/dist/cjs/features/CognitiveCompare/hooks/useSideBySide.js +1 -1
  12. package/dist/cjs/features/PdfViewer/PdfStyle.js +1 -1
  13. package/dist/cjs/features/PdfViewer/PdfViewer.js +1 -1
  14. package/dist/cjs/features/SegmentReviewComponents/LabelCheck.js +1 -1
  15. package/dist/cjs/features/SegmentReviewComponents/SegmentReviewPdfWrapper.js +1 -1
  16. package/dist/features/CognitiveCompare/CognitiveCompare.js +1 -1
  17. package/dist/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js +1 -1
  18. package/dist/features/CognitiveCompare/Guidelines/components/WebGptPanel.js +1 -1
  19. package/dist/features/CognitiveCompare/Guidelines/utils/guidelineTargets.js +2 -0
  20. package/dist/features/CognitiveCompare/Guidelines/utils/guidelineTargets.js.map +1 -0
  21. package/dist/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js +1 -1
  22. package/dist/features/CognitiveCompare/Guidelines/utils/resolveGuidelineSelection.js +2 -0
  23. package/dist/features/CognitiveCompare/Guidelines/utils/resolveGuidelineSelection.js.map +1 -0
  24. package/dist/features/CognitiveCompare/hooks/useCompareData.js +1 -1
  25. package/dist/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
  26. package/dist/features/CognitiveCompare/hooks/useSideBySide.js +1 -1
  27. package/dist/features/PdfViewer/PdfStyle.js +1 -1
  28. package/dist/features/PdfViewer/PdfViewer.js +1 -1
  29. package/dist/features/SegmentReviewComponents/LabelCheck.js +1 -1
  30. package/dist/features/SegmentReviewComponents/SegmentReviewPdfWrapper.js +1 -1
  31. package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts +1 -1
  32. package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts.map +1 -1
  33. package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts +1 -1
  34. package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts.map +1 -1
  35. package/dist/types/src/features/CognitiveCompare/Guidelines/components/GuidelinePanel.d.ts.map +1 -1
  36. package/dist/types/src/features/CognitiveCompare/Guidelines/components/WebGptPanel.d.ts.map +1 -1
  37. package/dist/types/src/features/CognitiveCompare/Guidelines/constants/guidelines.mockData.d.ts +14771 -829
  38. package/dist/types/src/features/CognitiveCompare/Guidelines/constants/guidelines.mockData.d.ts.map +1 -1
  39. package/dist/types/src/features/CognitiveCompare/Guidelines/utils/guidelineTargets.d.ts +3 -0
  40. package/dist/types/src/features/CognitiveCompare/Guidelines/utils/guidelineTargets.d.ts.map +1 -0
  41. package/dist/types/src/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.d.ts +14 -1
  42. package/dist/types/src/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.d.ts.map +1 -1
  43. package/dist/types/src/features/CognitiveCompare/Guidelines/utils/resolveGuidelineSelection.d.ts +19 -0
  44. package/dist/types/src/features/CognitiveCompare/Guidelines/utils/resolveGuidelineSelection.d.ts.map +1 -0
  45. package/dist/types/src/features/CognitiveCompare/hooks/useCompareData.d.ts +1 -1
  46. package/dist/types/src/features/CognitiveCompare/hooks/useCompareData.d.ts.map +1 -1
  47. package/dist/types/src/features/CognitiveCompare/hooks/useLinesCalculator.d.ts.map +1 -1
  48. package/dist/types/src/features/CognitiveCompare/hooks/useSideBySide.d.ts.map +1 -1
  49. package/dist/types/src/features/PdfViewer/PdfStyle.d.ts.map +1 -1
  50. package/dist/types/src/features/PdfViewer/PdfViewer.d.ts +7 -1
  51. package/dist/types/src/features/PdfViewer/PdfViewer.d.ts.map +1 -1
  52. package/dist/types/src/features/SegmentReviewComponents/LabelCheck.d.ts +6 -1
  53. package/dist/types/src/features/SegmentReviewComponents/LabelCheck.d.ts.map +1 -1
  54. package/dist/types/src/features/SegmentReviewComponents/SegmentReviewPdfWrapper.d.ts +3 -1
  55. package/dist/types/src/features/SegmentReviewComponents/SegmentReviewPdfWrapper.d.ts.map +1 -1
  56. package/dist/types/src/features/SegmentReviewComponents/SegmentReviewRedirectionTest.d.ts.map +1 -1
  57. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),n=require("../CognitiveComparehelpers.js");exports.useSideBySide=function(t){var r=t.isGuidelineMode,i=t.maintainRelativeOrder,l=t.proposedSections,u=t.existingSections,o=t.leftContainerRef,c=t.rightContainerRef,s=t.scrollContainerRef,d=t.sectionLeftRefs,a=t.sectionRightRefs,v=t.subSectionLeftRefs,f=t.subSectionRightRefs,p=t.lhsBadgeRefs,g=t.rhsBadgeRefs,R=t.sectionRowRefs,S=t.sectionRightRowRefs,h=t.rhsTopSpacerRef,A=t.rhsBottomSpacerRef,T=t.lhsTopSpacerRef,y=t.lhsBottomSpacerRef,B=t.calculateLinesRef,m=t.setConnectedSections,E=t.setConnectedLines,x=t.cachedConnectedPositions,C=t.closeMoreFunctionsPopup,I=t.setErrorToast;t.moreFunctions,t.closeSummaryPopup;var O=e.useState(!1),_=O[0],b=O[1],D=e.useState(!1),N=D[0],P=D[1],V=e.useState(!1),G=V[0],w=V[1],L=e.useState(!1),q=L[0],F=L[1],H=e.useState(null),M=H[0],k=H[1],j=e.useRef(!1),z=e.useRef(null),J=e.useRef(!1),K=e.useRef(null),Q=e.useRef(null),U=e.useRef(null),W=e.useRef(new Set),X=function(){W.current.forEach(function(e){n.resetClauseHighlight(e)}),W.current.clear()},Y=function(e,t,r){var i,l,u,s,h,A,T,y,B,m,E,x,C=null,I=null,O=null,_=null,b=null,D=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 P=t.split(n.DEVIATION_BADGE_SEPARATOR),V="".concat(P[0]).concat(n.DEVIATION_BADGE_SEPARATOR).concat(P[1]);C=(null===(i=v.current[P[2]])||void 0===i?void 0:i.current)||(null===(l=d.current[Number(P[2])])||void 0===l?void 0:l.current)||null,I=(null===(u=f.current[P[3]])||void 0===u?void 0:u.current)||(null===(s=a.current[Number(P[3])])||void 0===s?void 0:s.current)||null,O=(null===(h=p.current[V])||void 0===h?void 0:h.current)||C,_=(null===(A=g.current[V])||void 0===A?void 0:A.current)||I}else{var G=Number(t),w=null!==r?Number(r):G;C=(null===(T=d.current[G])||void 0===T?void 0:T.current)||null,I=(null===(y=a.current[w])||void 0===y?void 0:y.current)||null,b=(null===(B=p.current[G])||void 0===B?void 0:B.current)||null,D=(null===(m=g.current[w])||void 0===m?void 0:m.current)||null,O=b||(null===(E=R.current[G])||void 0===E?void 0:E.current)||C,_=D||(null===(x=S.current[w])||void 0===x?void 0:x.current)||I}if(C&&(C.style.paddingTop="0px"),I&&(I.style.paddingTop="0px"),e||(b&&(b.style.marginTop="0px"),D&&(D.style.marginTop="0px")),!e&&b&&D){var L=o.current,q=c.current;if(!N(b,L)||!N(D,q))return;var F=b.getBoundingClientRect(),H=D.getBoundingClientRect(),M=F.top-H.top;if(Math.abs(M)>32)return;M>0&&(D.style.marginTop="".concat(M,"px"))}else if(O&&_&&C&&I){F=O.getBoundingClientRect(),H=_.getBoundingClientRect();(M=F.top-H.top)>0&&(I.style.paddingTop="".concat(M,"px"))}},Z=e.useCallback(function(){var e,t,r,i,l,u,o,c,s=K.current,R=Q.current;if(null!==s)if("string"==typeof s&&s.includes(n.DEVIATION_BADGE_SEPARATOR)){var S=s.split(n.DEVIATION_BADGE_SEPARATOR),B=(null===(e=v.current[S[2]])||void 0===e?void 0:e.current)||(null===(t=d.current[Number(S[2])])||void 0===t?void 0:t.current)||null,m=(null===(r=f.current[S[3]])||void 0===r?void 0:r.current)||(null===(i=a.current[Number(S[3])])||void 0===i?void 0:i.current)||null;B&&(B.style.paddingTop="0px"),m&&(m.style.paddingTop="0px")}else{B=(null===(l=d.current[s])||void 0===l?void 0:l.current)||null,m=(null===(u=a.current[null!=R?R:s])||void 0===u?void 0:u.current)||null;B&&(B.style.paddingTop="0px"),m&&(m.style.paddingTop="0px");var E=(null===(o=p.current[s])||void 0===o?void 0:o.current)||null,x=(null===(c=g.current[null!=R?R:s])||void 0===c?void 0:c.current)||null;E&&(E.style.marginTop="0px"),x&&(x.style.marginTop="0px")}h.current&&(h.current.style.height="0px"),A.current&&(A.current.style.height="0px"),T.current&&(T.current.style.height="0px"),y.current&&(y.current.style.height="0px")},[]);e.useEffect(function(){J.current=_},[_]),e.useEffect(function(){K.current=M},[M]);var $=e.useCallback(function(){X(),b(!1),J.current=!1,z.current=null,Z(),k(null),K.current=null,Q.current=null,P(!1),F(!1)},[Z]),ee=e.useCallback(function(e,t,v){var f,O,D=null===(f=null==v?void 0:v.toggleIfSame)||void 0===f||f,N=null==v?void 0:v.onReady,V=null!==(O=null==v?void 0:v.sourceSide)&&void 0!==O?O:"left";if(C(),null!=e)if(!t||r){X();var G=_&&M===e;_&&null!==M&&Z(),G&&D?$():(m(new Set([e])),E([]),x.current=[],F(!0),j.current=!0,k(e),K.current=e,b(!0),J.current=!0,P(!1),h.current&&(h.current.style.height="0px"),A.current&&(A.current.style.height="0px"),T.current&&(T.current.style.height="0px"),y.current&&(y.current.style.height="0px"),requestAnimationFrame(function(){var t=function(){var t,v,f,T,y,m,E,x,C,I,O,_="string"==typeof e&&e.includes(n.DEVIATION_BADGE_SEPARATOR),b=null,D=null,G=null;if(r){if(_){var w=e.split(n.DEVIATION_BADGE_SEPARATOR),L="".concat(w[0]).concat(n.DEVIATION_BADGE_SEPARATOR).concat(w[1]);b=(null===(t=p.current[L])||void 0===t?void 0:t.current)||null}else b=(null===(v=d.current[e])||void 0===v?void 0:v.current)||(null===(f=R.current[e])||void 0===f?void 0:f.current)||null;D=document.getElementById("guideline-target-0"),G=D?e:null}else if(_){w=e.split(n.DEVIATION_BADGE_SEPARATOR),L="".concat(w[0]).concat(n.DEVIATION_BADGE_SEPARATOR).concat(w[1]);b=(null===(T=p.current[L])||void 0===T?void 0:T.current)||null,D=(null===(y=g.current[L])||void 0===y?void 0:y.current)||null,G=D?e:null}else if(b=(null===(m=d.current[e])||void 0===m?void 0:m.current)||(null===(E=R.current[e])||void 0===E?void 0:E.current)||null,i){var q=l[e],H=(null==q?void 0:q.refIndexes)||[];if(H.length>0){var M=H[0],k=u.findIndex(function(e){return e.selfIndex===M});-1!==k&&(D=(null===(I=a.current[k])||void 0===I?void 0:I.current)||(null===(O=S.current[k])||void 0===O?void 0:O.current)||null,G=k)}}else D=(null===(x=a.current[e])||void 0===x?void 0:x.current)||(null===(C=S.current[e])||void 0===C?void 0:C.current)||null,G=D?e:null;Q.current=G;var z=o.current,J=c.current,K=function(){Y(_,e,G),P(!0),B.current&&B.current(),j.current=!1,"right"===V&&J?J.dispatchEvent(new Event("scroll")):z&&z.dispatchEvent(new Event("scroll")),F(!1),null==N||N()};if(!b||!z)return j.current=!1,F(!1),void(null==N||N());if(D&&J){if(!i){var U=0;U="right"===V?D?D.getBoundingClientRect().top:0:b?b.getBoundingClientRect().top:0;var W=s.current,X=(null==W?void 0:W.getBoundingClientRect().top)||0,Z=W?W.scrollTop+U-X-150:0;return W?void n.smoothScrollTo(W,Z,200,K):void K()}var $=b.getBoundingClientRect().top-z.getBoundingClientRect().top+z.scrollTop,ee=D.getBoundingClientRect().top-J.getBoundingClientRect().top+J.scrollTop,ne=200;if("left"===V){var te=ee-($-z.scrollTop);te<0&&h.current&&!r&&(h.current.style.height="".concat(Math.abs(te),"px")),requestAnimationFrame(function(){var e,t=J.scrollHeight-J.clientHeight;if(te<0)e=0;else{if(te>t){var i=te-t;return A.current&&!r&&(A.current.style.height="".concat(i+150,"px")),void requestAnimationFrame(function(){n.smoothScrollTo(J,te,ne,K)})}e=te}n.smoothScrollTo(J,e,ne,K)})}else{var re=$-(ee-J.scrollTop);requestAnimationFrame(function(){var e,t=z.scrollHeight-z.clientHeight;if(re<0)e=0;else{if(re>t)return void requestAnimationFrame(function(){return n.smoothScrollTo(z,t,ne,K)});e=re}n.smoothScrollTo(z,e,ne,K)})}}else K()};r?setTimeout(t,100):t()}))}else I("No counterpart exists for this section.")},[M,C,u,_,i,l,Z,$,r]);return{isSideBySide:_,setIsSideBySide:b,isArrowVisible:N,setIsArrowVisible:P,isResizing:G,setIsResizing:w,isSideBySideLoading:q,setIsSideBySideLoading:F,activeSideBySideSection:M,setActiveSideBySideSection:k,scrollLock:j,sideBySideCacheRef:z,isSideBySideRef:J,activeSideBySideSectionRef:K,activeSideBySideRightSectionRef:Q,sideBySideLineRef:U,highlightedClauseRefs:W,clearClauseHighlight:X,applyAlignmentPadding:Y,resetSideBySide:$,activateSideBySide:ee}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),n=require("../CognitiveComparehelpers.js"),t=require("../Guidelines/utils/guidelineTargets.js");exports.useSideBySide=function(r){var i=r.isGuidelineMode,l=r.maintainRelativeOrder,u=r.proposedSections,o=r.existingSections,c=r.leftContainerRef,s=r.rightContainerRef,d=r.scrollContainerRef,a=r.sectionLeftRefs,v=r.sectionRightRefs,f=r.subSectionLeftRefs,p=r.subSectionRightRefs,g=r.lhsBadgeRefs,R=r.rhsBadgeRefs,S=r.sectionRowRefs,h=r.sectionRightRowRefs,T=r.rhsTopSpacerRef,A=r.rhsBottomSpacerRef,y=r.lhsTopSpacerRef,B=r.lhsBottomSpacerRef,m=r.calculateLinesRef,E=r.setConnectedSections,x=r.setConnectedLines,C=r.cachedConnectedPositions,I=r.closeMoreFunctionsPopup,O=r.setErrorToast;r.moreFunctions,r.closeSummaryPopup;var _=e.useState(!1),b=_[0],D=_[1],N=e.useState(!1),P=N[0],G=N[1],V=e.useState(!1),q=V[0],w=V[1],L=e.useState(!1),F=L[0],H=L[1],M=e.useState(null),k=M[0],j=M[1],z=e.useRef(!1),J=e.useRef(null),K=e.useRef(!1),Q=e.useRef(null),U=e.useRef(null),W=e.useRef(null),X=e.useRef(new Set),Y=function(){X.current.forEach(function(e){n.resetClauseHighlight(e)}),X.current.clear()},Z=function(e,t,r){var i,l,u,o,d,T,A,y,B,m,E,x,C=null,I=null,O=null,_=null,b=null,D=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 P=t.split(n.DEVIATION_BADGE_SEPARATOR),G="".concat(P[0]).concat(n.DEVIATION_BADGE_SEPARATOR).concat(P[1]);C=(null===(i=f.current[P[2]])||void 0===i?void 0:i.current)||(null===(l=a.current[Number(P[2])])||void 0===l?void 0:l.current)||null,I=(null===(u=p.current[P[3]])||void 0===u?void 0:u.current)||(null===(o=v.current[Number(P[3])])||void 0===o?void 0:o.current)||null,O=(null===(d=g.current[G])||void 0===d?void 0:d.current)||C,_=(null===(T=R.current[G])||void 0===T?void 0:T.current)||I}else{var V=Number(t),q=null!==r?Number(r):V;C=(null===(A=a.current[V])||void 0===A?void 0:A.current)||null,I=(null===(y=v.current[q])||void 0===y?void 0:y.current)||null,b=(null===(B=g.current[V])||void 0===B?void 0:B.current)||null,D=(null===(m=R.current[q])||void 0===m?void 0:m.current)||null,O=b||(null===(E=S.current[V])||void 0===E?void 0:E.current)||C,_=D||(null===(x=h.current[q])||void 0===x?void 0:x.current)||I}if(C&&(C.style.paddingTop="0px"),I&&(I.style.paddingTop="0px"),e||(b&&(b.style.marginTop="0px"),D&&(D.style.marginTop="0px")),!e&&b&&D){var w=c.current,L=s.current;if(!N(b,w)||!N(D,L))return;var F=b.getBoundingClientRect(),H=D.getBoundingClientRect(),M=F.top-H.top;if(Math.abs(M)>32)return;M>0&&(D.style.marginTop="".concat(M,"px"))}else if(O&&_&&C&&I){F=O.getBoundingClientRect(),H=_.getBoundingClientRect();(M=F.top-H.top)>0&&(I.style.paddingTop="".concat(M,"px"))}},$=e.useCallback(function(){var e,t,r,i,l,u,o,c,s=Q.current,d=U.current;if(null!==s)if("string"==typeof s&&s.includes(n.DEVIATION_BADGE_SEPARATOR)){var S=s.split(n.DEVIATION_BADGE_SEPARATOR),h=(null===(e=f.current[S[2]])||void 0===e?void 0:e.current)||(null===(t=a.current[Number(S[2])])||void 0===t?void 0:t.current)||null,m=(null===(r=p.current[S[3]])||void 0===r?void 0:r.current)||(null===(i=v.current[Number(S[3])])||void 0===i?void 0:i.current)||null;h&&(h.style.paddingTop="0px"),m&&(m.style.paddingTop="0px")}else{h=(null===(l=a.current[s])||void 0===l?void 0:l.current)||null,m=(null===(u=v.current[null!=d?d:s])||void 0===u?void 0:u.current)||null;h&&(h.style.paddingTop="0px"),m&&(m.style.paddingTop="0px");var E=(null===(o=g.current[s])||void 0===o?void 0:o.current)||null,x=(null===(c=R.current[null!=d?d:s])||void 0===c?void 0:c.current)||null;E&&(E.style.marginTop="0px"),x&&(x.style.marginTop="0px")}T.current&&(T.current.style.height="0px"),A.current&&(A.current.style.height="0px"),y.current&&(y.current.style.height="0px"),B.current&&(B.current.style.height="0px")},[]);e.useEffect(function(){K.current=b},[b]),e.useEffect(function(){Q.current=k},[k]);var ee=e.useCallback(function(){Y(),D(!1),K.current=!1,J.current=null,$(),j(null),Q.current=null,U.current=null,G(!1),H(!1)},[$]),ne=e.useCallback(function(e,r,f){var p,_,N=null===(p=null==f?void 0:f.toggleIfSame)||void 0===p||p,P=null==f?void 0:f.onReady,V=null!==(_=null==f?void 0:f.sourceSide)&&void 0!==_?_:"left";if(I(),null!=e)if(!r||i){Y();var q=b&&k===e;b&&null!==k&&$(),q&&N?ee():(E(new Set([e])),x([]),C.current=[],H(!0),z.current=!0,j(e),Q.current=e,D(!0),K.current=!0,G(!1),T.current&&(T.current.style.height="0px"),A.current&&(A.current.style.height="0px"),y.current&&(y.current.style.height="0px"),B.current&&(B.current.style.height="0px"),requestAnimationFrame(function(){var r=function(){var r,f,p,y,B,E,x,C,I,O,_,b="string"==typeof e&&e.includes(n.DEVIATION_BADGE_SEPARATOR),D=null,N=null,q=null;if(i){if(b){var w=e.split(n.DEVIATION_BADGE_SEPARATOR),L="".concat(w[0]).concat(n.DEVIATION_BADGE_SEPARATOR).concat(w[1]);D=(null===(r=g.current[L])||void 0===r?void 0:r.current)||null}else D=(null===(f=a.current[e])||void 0===f?void 0:f.current)||(null===(p=S.current[e])||void 0===p?void 0:p.current)||null;N=t.getVisibleGuidelineTargets(s.current)[0]||null,q=N?e:null}else if(b){w=e.split(n.DEVIATION_BADGE_SEPARATOR),L="".concat(w[0]).concat(n.DEVIATION_BADGE_SEPARATOR).concat(w[1]);D=(null===(y=g.current[L])||void 0===y?void 0:y.current)||null,N=(null===(B=R.current[L])||void 0===B?void 0:B.current)||null,q=N?e:null}else if(D=(null===(E=a.current[e])||void 0===E?void 0:E.current)||(null===(x=S.current[e])||void 0===x?void 0:x.current)||null,l){var F=u[e],M=(null==F?void 0:F.refIndexes)||[];if(M.length>0){var k=M[0],j=o.findIndex(function(e){return e.selfIndex===k});-1!==j&&(N=(null===(O=v.current[j])||void 0===O?void 0:O.current)||(null===(_=h.current[j])||void 0===_?void 0:_.current)||null,q=j)}}else N=(null===(C=v.current[e])||void 0===C?void 0:C.current)||(null===(I=h.current[e])||void 0===I?void 0:I.current)||null,q=N?e:null;U.current=q;var J=c.current,K=s.current,Q=function(){Z(b,e,q),G(!0),m.current&&m.current(),z.current=!1,"right"===V&&K?K.dispatchEvent(new Event("scroll")):J&&J.dispatchEvent(new Event("scroll")),H(!1),null==P||P()};if(!D||!J)return z.current=!1,H(!1),void(null==P||P());if(N&&K){if(!l){var W=0;W="right"===V?N?N.getBoundingClientRect().top:0:D?D.getBoundingClientRect().top:0;var X=d.current,Y=(null==X?void 0:X.getBoundingClientRect().top)||0,$=X?X.scrollTop+W-Y-150:0;return X?void n.smoothScrollTo(X,$,200,Q):void Q()}var ee=D.getBoundingClientRect().top-J.getBoundingClientRect().top+J.scrollTop,ne=N.getBoundingClientRect().top-K.getBoundingClientRect().top+K.scrollTop,te=200;if("left"===V){var re=ne-(ee-J.scrollTop);re<0&&T.current&&!i&&(T.current.style.height="".concat(Math.abs(re),"px")),requestAnimationFrame(function(){var e,t=K.scrollHeight-K.clientHeight;if(re<0)e=0;else{if(re>t){var r=re-t;return A.current&&!i&&(A.current.style.height="".concat(r+150,"px")),void requestAnimationFrame(function(){n.smoothScrollTo(K,re,te,Q)})}e=re}n.smoothScrollTo(K,e,te,Q)})}else{var ie=ee-(ne-K.scrollTop);requestAnimationFrame(function(){var e,t=J.scrollHeight-J.clientHeight;if(ie<0)e=0;else{if(ie>t)return void requestAnimationFrame(function(){return n.smoothScrollTo(J,t,te,Q)});e=ie}n.smoothScrollTo(J,e,te,Q)})}}else Q()};i?setTimeout(r,100):r()}))}else O("No counterpart exists for this section.")},[k,I,o,b,l,u,$,ee,i]);return{isSideBySide:b,setIsSideBySide:D,isArrowVisible:P,setIsArrowVisible:G,isResizing:q,setIsResizing:w,isSideBySideLoading:F,setIsSideBySideLoading:H,activeSideBySideSection:k,setActiveSideBySideSection:j,scrollLock:z,sideBySideCacheRef:J,isSideBySideRef:K,activeSideBySideSectionRef:Q,activeSideBySideRightSectionRef:U,sideBySideLineRef:W,highlightedClauseRefs:X,clearClauseHighlight:Y,applyAlignmentPadding:Z,resetSideBySide:ee,activateSideBySide:ne}};
2
2
  //# sourceMappingURL=useSideBySide.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.pdfStyles={pdfViewer:{borderRadius:"12px",padding:"16px",width:"100%",height:"100%",minWidth:0,boxSizing:"border-box",overflow:"hidden"},card:{border:"2px solid #E5E7EB",backgroundColor:"#FFFFFF",borderRadius:"12px",width:"100%",minWidth:0,boxSizing:"border-box",overflow:"hidden"},header:{display:"flex",justifyContent:"space-between",alignItems:"center",position:"relative",width:"100%",minWidth:0,boxSizing:"border-box"},title:{fontSize:"14px",fontWeight:600,color:"#60A3F8",fontFamily:'Roboto, "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif'},toolbar:{display:"flex",alignItems:"center",gap:"8px",position:"relative"},button:{border:"1px solid #DFE5EC",borderRadius:"6px",padding:"4px 8px",fontSize:"12px",cursor:"pointer",backgroundColor:"#FFFFFF"},buttonDisabled:{opacity:.4,cursor:"not-allowed"},counter:{fontSize:"13px",color:"#64748B",margin:"0 6px"},viewerWrapper:{height:"30rem",overflow:"auto",display:"flex",justifyContent:"center",alignItems:"center",border:"1px solid #DEE4EB",borderRadius:"8px"},emptyState:{fontSize:"14px",color:"#EF4444"},pdfConatiner:{height:"100%",overflow:"auto",display:"flex",justifyContent:"center",alignItems:"center"}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.pdfStyles={pdfViewer:{borderRadius:"12px",padding:"16px",width:"100%",height:"100%",minWidth:0,boxSizing:"border-box",overflow:"hidden"},card:{border:"2px solid #E5E7EB",backgroundColor:"#FFFFFF",borderRadius:"12px",width:"100%",minWidth:0,boxSizing:"border-box",overflow:"hidden"},header:{display:"flex",flexShrink:0,justifyContent:"space-between",alignItems:"center",position:"relative",width:"100%",minWidth:0,boxSizing:"border-box"},title:{fontSize:"14px",fontWeight:600,color:"#60A3F8",fontFamily:'Roboto, "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif'},toolbar:{display:"flex",alignItems:"center",gap:"8px",position:"relative"},button:{border:"1px solid #DFE5EC",borderRadius:"6px",padding:"4px 8px",fontSize:"12px",cursor:"pointer",backgroundColor:"#FFFFFF"},buttonDisabled:{opacity:.4,cursor:"not-allowed"},counter:{fontSize:"13px",color:"#64748B",margin:"0 6px"},viewerWrapper:{height:"30rem",overflow:"auto",display:"flex",justifyContent:"center",alignItems:"center",border:"1px solid #DEE4EB",borderRadius:"8px"},emptyState:{fontSize:"14px",color:"#EF4444"},pdfConatiner:{flex:"1 1 0",height:0,minHeight:0,minWidth:0,width:"100%",boxSizing:"border-box",overflow:"hidden",display:"block"}};
2
2
  //# sourceMappingURL=PdfStyle.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),i=require("@react-pdf-viewer/core"),n=require("./PdfContainer.js"),r=require("./PdfToolbar.js"),o=require("./PdfStyle.js"),a=require("./usePdfHighlight.js");require("@react-pdf-viewer/zoom/lib/styles/index.css"),require("@react-pdf-viewer/page-navigation/lib/styles/index.css"),require("@react-pdf-viewer/core/lib/styles/index.css"),require("@react-pdf-viewer/search/lib/styles/index.css");var u=require("react"),l=require("../ScannedDocCitation/ScannedDocCitation.js");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=s(u),d=function(e){switch(e){case"ActualSize":return i.SpecialZoomLevel.ActualSize;case"PageFit":return i.SpecialZoomLevel.PageFit;case"PageWidth":return i.SpecialZoomLevel.PageWidth;default:return null!=e?e:i.SpecialZoomLevel.PageWidth}};exports.default=function(s){var g,f=s.pdfUrl,v=s.highlightText,h=s.highlightPages,p=s.highlightCordinatePages,m=s.highlightColor,_=void 0===m?"yellow":m,x=s.activeHighlightColor,S=void 0===x?"#f7dc51":x,P=s.jumpToPageValue,T=void 0===P?0:P,w=s.pdfName,C=s.onClose,b=s.customStyles,y=s.customClasses,q=s.customIcons,A=s.useCoordinates,R=s.fallbackPages,j=s.activeCitationIndex,I=s.onActiveCitationChange,H=s.headerAction,N=s.isZoomEnabled,F=void 0===N||N,M=s.showHighlightsAction,Z=void 0===M||M,E=s.defaultScale,L=void 0===E?i.SpecialZoomLevel.ActualSize:E,z=s.useRange,B=void 0!==z&&z,D=s.rangeOfPages,V=void 0===D?null:D,W=s.showFullScreenAction,O=void 0===W||W,k=s.segments,U=void 0===k?[{title:"Document 2",start_page:52,end_page:52,page_count:1}]:k,J=s.segmentTooltipText,K=s.onCurrentPageChange,G=s.navigationRequest,Q=s.onNavigationSettled,X=s.renderPage,Y=s.setRenderRange,$=u.useRef(null),ee=u.useState(0),te=ee[0],ie=ee[1],ne=u.useState(0),re=ne[0],oe=ne[1],ae=u.useRef(null),ue=u.useRef(null),le=u.useRef(0),se=u.useMemo(function(){if(A)return new Set(p.map(function(e){return e.pageIndex}));var e=new Set;return Object.values(h).forEach(function(t){t>0&&e.add(t-1)}),e},[p,h,A]),ce=(g=v)&&0!==g.length?g.filter(function(e){return!g.some(function(t){return t!==e&&t.includes(e)})}):g,de=a.PdfHighlightControls(ce,A?{}:h,$,se,A,A?p:[],_,S),ge=de.highlightIndex,fe=de.cursorIndex,ve=de.setCursorIndex,he=de.orderedKeys,pe=de.totalHighlights,me=de.getValidPosition,_e=de.tryJump,xe=de.jumpToPage,Se=de.zoomTo,Pe=de.plugins,Te=de.controls,we=de.hideNonTargetHighlights,Ce=de.deduplicateHighlights,be=me(fe),ye=u.useMemo(function(){var e=te+1;return U.find(function(t){return e>=t.start_page&&e<=t.end_page})},[te,U]);u.useEffect(function(){void 0!==j&&j!==fe&&ve(j)},[j]);var qe=e.__assign(e.__assign({},Te),{goToNext:function(){fe>=pe-1||(Te.goToNext(),I&&I(fe+1))},goToPrevious:function(){fe<=0||(Te.goToPrevious(),I&&I(fe-1))}}),Ae=c.default.useCallback(function(e,t){le.current+=1;var i=le.current;null!=ue.current&&window.clearTimeout(ue.current);var n=null,r=0,o=0,a=function(){var u,l;if(le.current===i){var s=null===(u=$.current)||void 0===u?void 0:u.querySelector(".rpv-core__inner-pages"),c=null===(l=$.current)||void 0===l?void 0:l.querySelector('[data-testid="core__page-layer-'.concat(t-1,'"]'));o+=1,s&&(n===s.scrollTop?r+=1:(n=s.scrollTop,r=0));var d=null==s?void 0:s.getBoundingClientRect(),g=null==c?void 0:c.getBoundingClientRect(),f=Boolean(d&&g&&g.bottom>d.top&&g.top<d.bottom);if(r>=2&&f||o>=40)return ue.current=null,void(null==Q||Q({pageNumber:t,requestId:e.requestId}));ue.current=window.setTimeout(a,50)}};ue.current=window.setTimeout(a,50)},[Q]);if(u.useEffect(function(){return function(){le.current+=1,null!=ue.current&&window.clearTimeout(ue.current)}},[]),u.useEffect(function(){var e;if(G&&!(re<=0)){var t=Math.min(Math.max(Math.trunc(G.pageNumber),1),re),i="".concat(null!==(e=G.requestId)&&void 0!==e?e:t,":").concat(t);ae.current!==i&&(ae.current=i,ie(t-1),xe(t-1),Ae(G,t))}},[xe,G,re,Ae]),!f)return t.jsx(l.default,{pages:R,activeCitationIndex:j,onActiveCitationChange:I,headerAction:H});return t.jsxs("div",e.__assign({ref:$,className:(null==y?void 0:y.pdfViewerWrapper)||"",style:e.__assign(e.__assign(e.__assign({height:"100%",minHeight:0,minWidth:0,overflow:"hidden",display:"flex",flexDirection:"column"},o.pdfStyles.pdfViewer),{display:"flex",flexDirection:"column",height:"100%",width:"100%",backgroundColor:"#FAFAFA"}),null==b?void 0:b.pdfViewer)},{children:[t.jsx(r.default,{highlightIndex:ge,totalHighlights:pe,controls:qe,currentPosition:be,pdfName:w,onClose:C,pdfUrl:f,viewerRef:$,customStyles:b,customClasses:y,customIcons:q,headerAction:H,isZoomEnabled:F,showHighlightsAction:Z,showFullScreenAction:O,currentSegment:ye,segmentTooltipText:J,currentPage:te+1,totalPages:re,onPageNavigate:function(e){var t=Math.min(Math.max(e,1),re||e);ie(t-1),xe(t-1)}}),t.jsx(n.default,{defaultScale:d(L),pdfUrl:f,plugins:Pe,customStyles:b,onLoad:function(t){oe(t.doc.numPages);var n=!A&&!B&&T<=0;if(Se(i.SpecialZoomLevel.ActualSize),T>0&&!B){var r=T-1,o=he[r],a=h[o],u=p[r];ve(r),console.log(u,"cordinateTargetHighlight"),A&&u.pageIndex>0&&xe(u.pageIndex),a>0&&(setTimeout(function(){we(se),Ce(a-1)},1e3),A||xe(a-1))}else if(B&&V&&2===V.length){e.__awaiter(void 0,void 0,void 0,function(){var t,i,n,r,o;return e.__generator(this,function(e){switch(e.label){case 0:t=V[0],i=V[1],n=t,e.label=1;case 1:return n<=i?(xe(r=n-1),[4,new Promise(function(e){return setTimeout(e,1e3)})]):[3,4];case 2:if(e.sent(),we(se),(o=Ce(r))&&o>0)return[3,4];e.label=3;case 3:return n++,[3,1];case 4:return[2]}})})}else if(!A&&h){var l=he.find(function(e){return h[e]>0});if(void 0!==l){var s=h[l]-1;xe(s),setTimeout(function(){we(se),Ce(s)},1e3)}}requestAnimationFrame(function(){n&&_e(),!A&&T>0&&!B&&function(){if($.current){var e=T-1,t=he[e],i=h[t],n=i>0?i-1:0,r={};he.forEach(function(e,t){var i=h[e];i>0&&(r[i]||(r[i]=[]),r[i].push(t))});var o=(r[i]||[]).indexOf(e),a=0,u=function(){var e,t;if(!(++a>40)){var i=null===(e=$.current)||void 0===e?void 0:e.querySelector(".rpv-core__inner-pages");if(i){var r=null===(t=$.current)||void 0===t?void 0:t.querySelector('[data-testid="core__page-layer-'.concat(n,'"]'));if(r){var l=i.getBoundingClientRect(),s=r.getBoundingClientRect();if(s.top<l.bottom&&s.bottom>l.top){var c=r.querySelectorAll(".rpv-search__highlight")[o];if(c){var d=c.getBoundingClientRect(),g=i.scrollTop+(d.top-l.top)-i.clientHeight/2+d.height/2;i.scrollTo({top:g,behavior:"smooth"})}else setTimeout(u,100)}else setTimeout(u,100)}else setTimeout(u,100)}else setTimeout(u,100)}};setTimeout(u,500)}}()})},onPageChange:function(e){var t=e.currentPage;ie(t),null==K||K(t+1),se.has(t)?(Ce(t),we(se)):we(se)},renderPage:X,setRenderRange:Y})]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),i=require("@react-pdf-viewer/core"),n=require("./PdfContainer.js"),r=require("./PdfToolbar.js"),o=require("./PdfStyle.js"),a=require("./usePdfHighlight.js");require("@react-pdf-viewer/zoom/lib/styles/index.css"),require("@react-pdf-viewer/page-navigation/lib/styles/index.css"),require("@react-pdf-viewer/core/lib/styles/index.css"),require("@react-pdf-viewer/search/lib/styles/index.css");var u=require("react"),l=require("../ScannedDocCitation/ScannedDocCitation.js");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=s(u),d=function(e){switch(e){case"ActualSize":return i.SpecialZoomLevel.ActualSize;case"PageFit":return i.SpecialZoomLevel.PageFit;case"PageWidth":return i.SpecialZoomLevel.PageWidth;default:return null!=e?e:i.SpecialZoomLevel.PageWidth}};exports.default=function(s){var g,f=s.pdfUrl,v=s.highlightText,h=s.highlightPages,p=s.highlightCordinatePages,m=s.highlightColor,_=void 0===m?"yellow":m,x=s.activeHighlightColor,P=void 0===x?"#f7dc51":x,w=s.jumpToPageValue,S=void 0===w?0:w,T=s.pdfName,C=s.onClose,b=s.customStyles,y=s.customClasses,q=s.customIcons,A=s.useCoordinates,R=s.fallbackPages,j=s.activeCitationIndex,I=s.onActiveCitationChange,H=s.headerAction,N=s.isZoomEnabled,F=void 0===N||N,M=s.showHighlightsAction,E=void 0===M||M,Z=s.defaultScale,B=void 0===Z?i.SpecialZoomLevel.ActualSize:Z,L=s.useRange,D=void 0!==L&&L,V=s.rangeOfPages,W=void 0===V?null:V,z=s.showFullScreenAction,O=void 0===z||z,k=s.segments,U=void 0===k?[{title:"Document 2",start_page:52,end_page:52,page_count:1}]:k,J=s.segmentTooltipText,K=s.onCurrentPageChange,G=s.navigationRequest,Q=s.onNavigationSettled,X=s.disablePdfAnnotations,Y=void 0!==X&&X,$=s.renderPage,ee=s.setRenderRange,te=u.useRef(null),ie=u.useState(0),ne=ie[0],re=ie[1],oe=u.useState(0),ae=oe[0],ue=oe[1],le=u.useRef(null),se=u.useRef(null),ce=u.useRef(0),de=u.useMemo(function(){if(A)return new Set(p.map(function(e){return e.pageIndex}));var e=new Set;return Object.values(h).forEach(function(t){t>0&&e.add(t-1)}),e},[p,h,A]),ge=(g=v)&&0!==g.length?g.filter(function(e){return!g.some(function(t){return t!==e&&t.includes(e)})}):g,fe=a.PdfHighlightControls(ge,A?{}:h,te,de,A,A?p:[],_,P),ve=fe.highlightIndex,he=fe.cursorIndex,pe=fe.setCursorIndex,me=fe.orderedKeys,_e=fe.totalHighlights,xe=fe.getValidPosition,Pe=fe.tryJump,we=fe.jumpToPage,Se=fe.plugins,Te=fe.controls,Ce=fe.hideNonTargetHighlights,be=fe.deduplicateHighlights,ye=xe(he),qe=u.useMemo(function(){var e=ne+1;return U.find(function(t){return e>=t.start_page&&e<=t.end_page})},[ne,U]);u.useEffect(function(){void 0!==j&&j!==he&&pe(j)},[j]);var Ae=e.__assign(e.__assign({},Te),{goToNext:function(){he>=_e-1||(Te.goToNext(),I&&I(he+1))},goToPrevious:function(){he<=0||(Te.goToPrevious(),I&&I(he-1))}}),Re=c.default.useCallback(function(e,t){ce.current+=1;var i=ce.current;null!=se.current&&window.clearTimeout(se.current);var n=null,r=0,o=0,a=function(){var u,l;if(ce.current===i){var s=null===(u=te.current)||void 0===u?void 0:u.querySelector(".rpv-core__inner-pages"),c=null===(l=te.current)||void 0===l?void 0:l.querySelector('[data-testid="core__page-layer-'.concat(t-1,'"]'));o+=1,s&&(n===s.scrollTop?r+=1:(n=s.scrollTop,r=0));var d=null==s?void 0:s.getBoundingClientRect(),g=null==c?void 0:c.getBoundingClientRect(),f=Boolean(d&&g&&g.bottom>d.top&&g.top<d.bottom);if(r>=2&&f||o>=40)return se.current=null,void(null==Q||Q({pageNumber:t,requestId:e.requestId}));se.current=window.setTimeout(a,50)}};se.current=window.setTimeout(a,50)},[Q]);if(u.useEffect(function(){return function(){ce.current+=1,null!=se.current&&window.clearTimeout(se.current)}},[]),u.useEffect(function(){var e;if(G&&!(ae<=0)){var t=Math.min(Math.max(Math.trunc(G.pageNumber),1),ae),i="".concat(null!==(e=G.requestId)&&void 0!==e?e:t,":").concat(t);le.current!==i&&(le.current=i,re(t-1),we(t-1),Re(G,t))}},[we,G,ae,Re]),!f)return t.jsx(l.default,{pages:R,activeCitationIndex:j,onActiveCitationChange:I,headerAction:H});return t.jsxs("div",e.__assign({ref:te,className:(null==y?void 0:y.pdfViewerWrapper)||"","data-disable-pdf-annotations":Y?"true":void 0,style:e.__assign(e.__assign(e.__assign({height:"100%",minHeight:0,minWidth:0,overflow:"hidden",display:"flex",flexDirection:"column"},o.pdfStyles.pdfViewer),{display:"flex",flexDirection:"column",height:"100%",width:"100%",backgroundColor:"#FAFAFA"}),null==b?void 0:b.pdfViewer)},{children:[t.jsx(r.default,{highlightIndex:ve,totalHighlights:_e,controls:Ae,currentPosition:ye,pdfName:T,onClose:C,pdfUrl:f,viewerRef:te,customStyles:b,customClasses:y,customIcons:q,headerAction:H,isZoomEnabled:F,showHighlightsAction:E,showFullScreenAction:O,currentSegment:qe,segmentTooltipText:J,currentPage:ne+1,totalPages:ae,onPageNavigate:function(e){var t=Math.min(Math.max(e,1),ae||e);re(t-1),we(t-1)}}),t.jsx(n.default,{defaultScale:d(B),pdfUrl:f,plugins:Se,customStyles:b,onLoad:function(t){ue(t.doc.numPages);var i=!A&&!D&&S<=0;if(S>0&&!D){var n=S-1,r=me[n],o=h[r],a=p[n];pe(n),console.log(a,"cordinateTargetHighlight"),A&&a.pageIndex>0&&we(a.pageIndex),o>0&&(setTimeout(function(){Ce(de),be(o-1)},1e3),A||we(o-1))}else if(D&&W&&2===W.length){e.__awaiter(void 0,void 0,void 0,function(){var t,i,n,r,o;return e.__generator(this,function(e){switch(e.label){case 0:t=W[0],i=W[1],n=t,e.label=1;case 1:return n<=i?(we(r=n-1),[4,new Promise(function(e){return setTimeout(e,1e3)})]):[3,4];case 2:if(e.sent(),Ce(de),(o=be(r))&&o>0)return[3,4];e.label=3;case 3:return n++,[3,1];case 4:return[2]}})})}else if(!A&&h){var u=me.find(function(e){return h[e]>0});if(void 0!==u){var l=h[u]-1;we(l),setTimeout(function(){Ce(de),be(l)},1e3)}}requestAnimationFrame(function(){i&&Pe(),!A&&S>0&&!D&&function(){if(te.current){var e=S-1,t=me[e],i=h[t],n=i>0?i-1:0,r={};me.forEach(function(e,t){var i=h[e];i>0&&(r[i]||(r[i]=[]),r[i].push(t))});var o=(r[i]||[]).indexOf(e),a=0,u=function(){var e,t;if(!(++a>40)){var i=null===(e=te.current)||void 0===e?void 0:e.querySelector(".rpv-core__inner-pages");if(i){var r=null===(t=te.current)||void 0===t?void 0:t.querySelector('[data-testid="core__page-layer-'.concat(n,'"]'));if(r){var l=i.getBoundingClientRect(),s=r.getBoundingClientRect();if(s.top<l.bottom&&s.bottom>l.top){var c=r.querySelectorAll(".rpv-search__highlight")[o];if(c){var d=c.getBoundingClientRect(),g=i.scrollTop+(d.top-l.top)-i.clientHeight/2+d.height/2;i.scrollTo({top:g,behavior:"smooth"})}else setTimeout(u,100)}else setTimeout(u,100)}else setTimeout(u,100)}else setTimeout(u,100)}};setTimeout(u,500)}}()})},onPageChange:function(e){var t=e.currentPage;re(t),null==K||K(t+1),de.has(t)?(be(t),Ce(de)):Ce(de)},renderPage:$,setRenderRange:ee})]}))};
2
2
  //# sourceMappingURL=PdfViewer.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),i=require("react/jsx-runtime"),t=require("react"),n=require("@mui/icons-material/ChevronRight"),o=require("@mui/icons-material/Close"),r=require("@mui/material/Box"),l=require("@mui/material/Button"),a=require("@mui/material/ButtonBase"),s=require("@mui/material/Divider"),d=require("@mui/material/IconButton"),u=require("@mui/material/Paper"),c=require("@mui/material/Radio"),x=require("@mui/material/Stack"),f=require("@mui/material/TextField"),m=require("@mui/material/Typography"),p=require("./CognitiveIcon.js"),h=require("./CognitiveScoreBadge.js"),b=require("../../assests/icons/InfoAlert.js");function g(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var v,_=g(n),j=g(o),C=g(r),y=g(l),L=g(a),w=g(s),S=g(d),A=g(u),E=g(c),I=g(x),q=g(f),k=g(m),D=function(i,t){return e.__spreadArray([i],Array.isArray(t)?t:null==t?[]:[t],!0)};exports.LabelReviewActionEnum=void 0,(v=exports.LabelReviewActionEnum||(exports.LabelReviewActionEnum={})).KEEP_LABEL="KEEP_LABEL",v.SET_CUSTOM_LABEL="SET_CUSTOM_LABEL";var B=function(e){return e.user_actions.map(function(i){switch(i){case"KEEP_LABEL":return{id:i,title:"Keep as is",description:e.current_label?'Label stays "'.concat(e.current_label,'"'):"Keep the current document label"};case"SET_CUSTOM_LABEL":return{id:i,title:"Enter a custom label",description:"Create your own document label",requiresInput:!0,inputPlaceholder:e.current_label?"e.g. ".concat(e.current_label):"Enter a document label"}}})},z=function(e){return Object.values(exports.LabelReviewActionEnum).includes(e)};exports.createLabelCheckOptions=B,exports.default=function(n){var o,r=n.headerName,l=void 0===r?"Title Check":r,a=n.title,s=n.pageNo,d=n.content,u=void 0===d?"We're not fully confident about this label. Confirm it, choose a different type, or add a new one.":d,c=n.cognitiveScore,x=n.config,f=n.metadata,m=n.selectedIndex,g=n.defaultSelectedIndex,v=void 0===g?null:g,M=n.onSelectionChange,O=n.customLabel,R=n.defaultCustomLabel,T=n.onCustomLabelChange,W=n.onConfirm,F=n.onActionConfirm,P=n.onCognitiveClick;n.onAdjustManually;var K=n.onClose,H=n.confirmLabel,N=void 0===H?"Confirm":H,U=n.customInputAriaLabel,G=void 0===U?"Custom document label":U;n.manualPrompt,n.manualActionLabel;var J=n.cognitiveLabel,Q=void 0===J?"Cognitive Integrity":J;n.showAdjustManually;var V=n.showCognitiveIntegrity,X=void 0===V||V,Y=n.showCloseButton,Z=void 0===Y||Y,$=n.confirmDisabled,ee=void 0!==$&&$,ie=n.disableAllActions,te=void 0!==ie&&ie,ne=n.width,oe=void 0===ne?260:ne,re=n.maxWidth,le=void 0===re?260:re,ae=n.className,se=n.styles,de=t.useMemo(function(){return null!=x?x:f?B(f):[]},[x,f]),ue=t.useState(v),ce=ue[0],xe=ue[1],fe=t.useState(null!==(o=null!=R?R:null==f?void 0:f.custom_label)&&void 0!==o?o:""),me=fe[0],pe=fe[1],he=void 0===m?ce:m,be=void 0===O?me:O,ge=null==he?void 0:de[he],ve=Boolean(null==ge?void 0:ge.requiresInput),_e=te||ee||!W&&!F||!ge||!0===ge.disabled||ve&&0===be.trim().length,je=function(){if(!_e&&null!=he&&ge){var e=ve?be.trim():void 0;null==W||W(he,ge,e),F&&z(ge.id)&&F(ge.id,{selectedIndex:he,option:ge,customLabel:e,metadata:f})}};return i.jsx(A.default,e.__assign({className:ae,elevation:0,sx:D({width:oe,maxWidth:le,borderTop:"4px solid",borderColor:"error.main",borderRadius:2,bgcolor:"background.paper",boxSizing:"border-box",boxShadow:"0 8px 16px rgba(16, 24, 40, 0.2)","@media (max-width: 372px)":{width:"calc(100vw - 32px)"}},null==se?void 0:se.root)},{children:i.jsx(C.default,e.__assign({sx:{overflow:"hidden"}},{children:i.jsxs(I.default,e.__assign({spacing:.75,sx:{p:1}},{children:[i.jsxs(I.default,e.__assign({direction:"row",alignItems:"center",spacing:.75,sx:null==se?void 0:se.header},{children:[i.jsx(b.default,{color:"error",height:16,width:16}),i.jsx(k.default,e.__assign({sx:{flex:1,color:"error.main",fontSize:12,fontWeight:500,lineHeight:1.25,textTransform:"uppercase"}},{children:l})),Z&&i.jsx(S.default,e.__assign({size:"small",onClick:K,disabled:!K,"aria-label":"Close label check",sx:{p:0,"&.Mui-disabled":{color:"text.secondary"}}},{children:i.jsx(j.default,{sx:{fontSize:17}})}))]})),i.jsxs(C.default,{children:[i.jsx(k.default,e.__assign({sx:{color:"text.primary",fontSize:14,fontWeight:500}},{children:a})),null!=s&&i.jsx(k.default,e.__assign({sx:{mt:.125,color:"text.secondary",fontSize:12}},{children:s})),i.jsx(w.default,{sx:{my:.625}}),null!=u&&i.jsx(k.default,e.__assign({component:"div",sx:{color:"text.secondary",fontSize:11.5,lineHeight:1.3}},{children:u}))]}),i.jsxs(I.default,e.__assign({spacing:.625,role:"radiogroup","aria-label":"Label options"},{children:[de.map(function(t,n){var o=he===n;return i.jsxs(A.default,e.__assign({variant:"outlined",sx:D({borderColor:o?"#1976d2":"divider",borderRadius:2,overflow:"hidden"},null==se?void 0:se.option)},{children:[i.jsxs(L.default,e.__assign({role:"radio","aria-checked":o,disabled:ee||t.disabled,onClick:function(){return function(e,i){ee||i.disabled||(void 0===m&&xe(e),null==M||M(e,i))}(n,t)},sx:{width:"100%",justifyContent:"flex-start",px:.75,py:.5,textAlign:"left"}},{children:[i.jsx(E.default,{checked:o,disabled:ee||t.disabled,tabIndex:-1,size:"small",sx:{p:.25,mr:.5}}),i.jsxs(C.default,e.__assign({sx:{minWidth:0}},{children:[i.jsx(k.default,e.__assign({sx:{color:"text.primary",fontSize:12.5,fontWeight:500}},{children:t.title})),null!=t.description&&i.jsx(k.default,e.__assign({sx:{mt:.125,color:"text.secondary",fontSize:11}},{children:t.description}))]}))]})),o&&t.requiresInput&&i.jsx(C.default,e.__assign({sx:{px:1.25,pb:1}},{children:i.jsx(q.default,{autoFocus:!0,fullWidth:!0,size:"small",value:be,disabled:ee,placeholder:t.inputPlaceholder,inputProps:{"aria-label":G},onChange:function(e){return i=e.target.value,void 0===O&&pe(i),void(null==T||T(i));var i},onKeyDown:function(e){"Enter"===e.key&&je()},variant:"outlined",InputProps:{sx:{height:36,borderRadius:2,backgroundColor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"#D0D5DD",borderWidth:"1px"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"#D0D5DD"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"#D0D5DD",borderWidth:"1.5px"},"& .MuiOutlinedInput-input":{height:"100%",boxSizing:"border-box",px:1.25,py:0,fontSize:12,lineHeight:1.25},"& .MuiOutlinedInput-input::placeholder":{color:"#98A2B3",opacity:1}}},sx:null==se?void 0:se.customInput})}))]}),t.id)}),i.jsx(y.default,e.__assign({variant:"contained",fullWidth:!0,disabled:_e,onClick:je,sx:D({minHeight:32,mt:.25,borderRadius:2,fontSize:13,fontWeight:600,textTransform:"none",backgroundColor:"#5925DC","&:hover":{backgroundColor:"#4A1FB8"},"&.Mui-disabled":{backgroundColor:"#D9D6FE",color:"#FFFFFF"}},null==se?void 0:se.confirmButton)},{children:N}))]})),i.jsx(I.default,e.__assign({spacing:.625,sx:null==se?void 0:se.footer},{children:X&&i.jsxs(i.Fragment,{children:[i.jsx(w.default,{}),i.jsxs(L.default,e.__assign({onClick:P,disabled:!P,sx:{justifyContent:"space-between",borderRadius:1,textAlign:"left",cursor:P?"pointer":"not-allowed"}},{children:[i.jsxs(I.default,e.__assign({direction:"row",alignItems:"center",spacing:1},{children:[i.jsx(p.default,{sx:{color:"text.secondary"}}),i.jsx(k.default,e.__assign({sx:{color:"text.primary",fontSize:12}},{children:Q}))]})),i.jsxs(I.default,e.__assign({direction:"row",alignItems:"center",spacing:.75},{children:[i.jsx(h.default,{score:c}),i.jsx(_.default,{sx:{color:"text.secondary",fontSize:18}})]}))]}))]})}))]}))}))}))},exports.isLabelReviewAction=z;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),i=require("react/jsx-runtime"),t=require("react"),n=require("@mui/icons-material/ChevronRight"),o=require("@mui/icons-material/Close"),r=require("@mui/material/Box"),l=require("@mui/material/Button"),a=require("@mui/material/ButtonBase"),s=require("@mui/material/Divider"),d=require("@mui/material/IconButton"),u=require("@mui/material/Paper"),c=require("@mui/material/Radio"),x=require("@mui/material/Stack"),f=require("@mui/material/TextField"),h=require("@mui/material/Typography"),m=require("./CognitiveIcon.js"),p=require("./CognitiveScoreBadge.js"),b=require("../../assests/icons/InfoAlert.js");function g(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var v,_=g(n),j=g(o),C=g(r),y=g(l),w=g(a),A=g(s),L=g(d),S=g(u),E=g(c),I=g(x),q=g(f),k=g(h),B=function(i,t){return e.__spreadArray([i],Array.isArray(t)?t:null==t?[]:[t],!0)};exports.LabelReviewActionEnum=void 0,(v=exports.LabelReviewActionEnum||(exports.LabelReviewActionEnum={})).KEEP_LABEL="KEEP_LABEL",v.SET_CUSTOM_LABEL="SET_CUSTOM_LABEL";var D=function(e){return e.user_actions.map(function(i){switch(i){case"KEEP_LABEL":return{id:i,title:"Keep as is",description:e.current_label?'Label stays "'.concat(e.current_label,'"'):"Keep the current document label"};case"SET_CUSTOM_LABEL":return{id:i,title:"Enter a custom label",description:"Create your own document label",requiresInput:!0,inputPlaceholder:e.current_label?"e.g. ".concat(e.current_label):"Enter a document label"}}})},z=function(e){return Object.values(exports.LabelReviewActionEnum).includes(e)};exports.createLabelCheckOptions=D,exports.default=function(n){var o,r=n.headerName,l=void 0===r?"Title Check":r,a=n.title,s=n.pageNo,d=n.content,u=void 0===d?"We're not fully confident about this label. Confirm it, choose a different type, or add a new one.":d,c=n.cognitiveScore,x=n.config,f=n.metadata,h=n.selectedIndex,g=n.defaultSelectedIndex,v=void 0===g?null:g,M=n.onSelectionChange,O=n.customLabel,W=n.defaultCustomLabel,F=n.onCustomLabelChange,R=n.onConfirm,T=n.onActionConfirm,P=n.onCognitiveClick;n.onAdjustManually;var K=n.onClose,H=n.confirmLabel,N=void 0===H?"Confirm":H,U=n.customInputAriaLabel,G=void 0===U?"Custom document label":U;n.manualPrompt,n.manualActionLabel;var J=n.cognitiveLabel,Q=void 0===J?"Cognitive Integrity":J;n.showAdjustManually;var V=n.showCognitiveIntegrity,X=void 0===V||V,Y=n.showCloseButton,Z=void 0===Y||Y,$=n.confirmDisabled,ee=void 0!==$&&$,ie=n.confirmationBlocked,te=void 0!==ie&&ie,ne=n.confirmationWarning,oe=n.disableAllActions,re=void 0!==oe&&oe,le=n.width,ae=void 0===le?260:le,se=n.maxWidth,de=void 0===se?260:se,ue=n.className,ce=n.styles,xe=t.useMemo(function(){return null!=x?x:f?D(f):[]},[x,f]),fe=t.useState(v),he=fe[0],me=fe[1],pe=t.useState(null!==(o=null!=W?W:null==f?void 0:f.custom_label)&&void 0!==o?o:""),be=pe[0],ge=pe[1],ve=void 0===h?he:h,_e=void 0===O?be:O,je=null==ve?void 0:xe[ve],Ce=Boolean(null==je?void 0:je.requiresInput),ye=te||re||ee||!R&&!T||!je||!0===je.disabled||Ce&&0===_e.trim().length,we=function(){if(!ye&&null!=ve&&je){var e=Ce?_e.trim():void 0;null==R||R(ve,je,e),T&&z(je.id)&&T(je.id,{selectedIndex:ve,option:je,customLabel:e,metadata:f})}};return i.jsx(S.default,e.__assign({className:ue,elevation:0,sx:B({width:ae,maxWidth:de,borderTop:"4px solid",borderColor:"error.main",borderRadius:2,bgcolor:"background.paper",boxSizing:"border-box",boxShadow:"0 8px 16px rgba(16, 24, 40, 0.2)","@media (max-width: 372px)":{width:"calc(100vw - 32px)"}},null==ce?void 0:ce.root)},{children:i.jsx(C.default,e.__assign({sx:{overflow:"hidden"}},{children:i.jsxs(I.default,e.__assign({spacing:.75,sx:{p:1}},{children:[i.jsxs(I.default,e.__assign({direction:"row",alignItems:"center",spacing:.75,sx:null==ce?void 0:ce.header},{children:[i.jsx(b.default,{color:"error",height:16,width:16}),i.jsx(k.default,e.__assign({sx:{flex:1,color:"error.main",fontSize:12,fontWeight:500,lineHeight:1.25,textTransform:"uppercase"}},{children:l})),Z&&i.jsx(L.default,e.__assign({size:"small",onClick:K,disabled:!K,"aria-label":"Close label check",sx:{p:0,"&.Mui-disabled":{color:"text.secondary"}}},{children:i.jsx(j.default,{sx:{fontSize:17}})}))]})),i.jsxs(C.default,{children:[i.jsx(k.default,e.__assign({sx:{color:"text.primary",fontSize:14,fontWeight:500}},{children:a})),null!=s&&i.jsx(k.default,e.__assign({sx:{mt:.125,color:"text.secondary",fontSize:12}},{children:s})),i.jsx(A.default,{sx:{my:.625}}),null!=u&&i.jsx(k.default,e.__assign({component:"div",sx:{color:"text.secondary",fontSize:11.5,lineHeight:1.3}},{children:u}))]}),i.jsxs(I.default,e.__assign({spacing:.625,role:"radiogroup","aria-label":"Label options"},{children:[xe.map(function(t,n){var o=ve===n;return i.jsxs(S.default,e.__assign({variant:"outlined",sx:B({borderColor:o?"#1976d2":"divider",borderRadius:2,overflow:"hidden"},null==ce?void 0:ce.option)},{children:[i.jsxs(w.default,e.__assign({role:"radio","aria-checked":o,disabled:ee||t.disabled||te,onClick:function(){return function(e,i){ee||i.disabled||(void 0===h&&me(e),null==M||M(e,i))}(n,t)},sx:{width:"100%",justifyContent:"flex-start",px:.75,py:.5,textAlign:"left",cursor:"pointer","&.Mui-disabled":{cursor:"not-allowed"}}},{children:[i.jsx(E.default,{checked:o,disabled:ee||t.disabled||te,tabIndex:-1,size:"small",sx:{p:.25,mr:.5,cursor:"pointer","&.Mui-disabled":{cursor:"not-allowed"}}}),i.jsxs(C.default,e.__assign({sx:{minWidth:0}},{children:[i.jsx(k.default,e.__assign({sx:{color:"text.primary",fontSize:12.5,fontWeight:500}},{children:t.title})),null!=t.description&&i.jsx(k.default,e.__assign({sx:{mt:.125,color:"text.secondary",fontSize:11}},{children:t.description}))]}))]})),o&&t.requiresInput&&i.jsx(C.default,e.__assign({sx:{px:1.25,pb:1}},{children:i.jsx(q.default,{autoFocus:!0,fullWidth:!0,size:"small",value:_e,disabled:ee,placeholder:t.inputPlaceholder,inputProps:{"aria-label":G},onChange:function(e){return i=e.target.value,void 0===O&&ge(i),void(null==F||F(i));var i},onKeyDown:function(e){"Enter"===e.key&&we()},variant:"outlined",InputProps:{sx:{height:36,borderRadius:2,backgroundColor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"#D0D5DD",borderWidth:"1px"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"#D0D5DD"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"#D0D5DD",borderWidth:"1.5px"},"& .MuiOutlinedInput-input":{height:"100%",boxSizing:"border-box",px:1.25,py:0,fontSize:12,lineHeight:1.25},"& .MuiOutlinedInput-input::placeholder":{color:"#98A2B3",opacity:1}}},sx:null==ce?void 0:ce.customInput})}))]}),t.id)}),null!=ne&&i.jsxs(I.default,e.__assign({direction:"row",alignItems:"flex-start",spacing:.5,role:"alert",sx:B({px:.75,py:.625,borderRadius:1,bgcolor:"#FEFCE8",color:"#CA8A04"},null==ce?void 0:ce.confirmationWarning)},{children:[i.jsx(b.default,{color:"inherit",height:15,width:15}),i.jsx(k.default,e.__assign({sx:{color:"inherit",fontSize:11.5,lineHeight:1.3}},{children:ne}))]})),i.jsx(y.default,e.__assign({variant:"contained",fullWidth:!0,disabled:ye,onClick:we,sx:B({minHeight:32,mt:.25,borderRadius:2,fontSize:13,fontWeight:600,textTransform:"none",backgroundColor:"#5925DC","&:hover":{backgroundColor:"#4A1FB8"},"&.Mui-disabled":{backgroundColor:"#D9D6FE",color:"#FFFFFF"}},null==ce?void 0:ce.confirmButton)},{children:N}))]})),i.jsx(I.default,e.__assign({spacing:.625,sx:null==ce?void 0:ce.footer},{children:X&&i.jsxs(i.Fragment,{children:[i.jsx(A.default,{}),i.jsxs(w.default,e.__assign({onClick:P,disabled:!P,sx:{justifyContent:"space-between",borderRadius:1,textAlign:"left",cursor:P?"pointer":"not-allowed"}},{children:[i.jsxs(I.default,e.__assign({direction:"row",alignItems:"center",spacing:1},{children:[i.jsx(m.default,{sx:{color:"text.secondary"}}),i.jsx(k.default,e.__assign({sx:{color:"text.primary",fontSize:12}},{children:Q}))]})),i.jsxs(I.default,e.__assign({direction:"row",alignItems:"center",spacing:.75},{children:[i.jsx(p.default,{score:c}),i.jsx(_.default,{sx:{color:"text.secondary",fontSize:18}})]}))]}))]})}))]}))}))}))},exports.isLabelReviewAction=z;
2
2
  //# sourceMappingURL=LabelCheck.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),t=require("react"),i=require("@react-pdf-viewer/core"),r=require("../PdfViewer/PdfViewer.js"),o=require("./BoundaryCard.js"),a=require("./CardWrapper.js"),l=require("./CognitiveIntegrity.js"),s=require("./LabelCheck.js"),u=require("./reviewStepAdapters.js"),d=require("lucide-react"),c=require("@mui/material"),g=require("./helper.js"),f=260,v=function(e){return{reviewId:e.id,segment:e.segment,pageNumber:e.pageNumber}};exports.default=function(p){var m,h,_,b,w,x,y,C,S,E,k=this,j=p.pdfUrl,R=p.pdfName,I=p.segments,N=p.styles,M=p.pdfViewerProps,A=p.showBadges,F=void 0===A||A,B=p.sortByConfidence,P=void 0===B?"low":B,q=p.filterByConfidence,L=void 0===q?"all":q,W=p.showBadgeNavigation,z=void 0===W||W,T=p.autoSelectReviewOnPageChange,O=void 0!==T&&T,D=p.autoAdvanceAfterConfirm,V=void 0===D||D,G=p.badgePreloadPages,H=void 0===G?8:G,U=p.badgeOffsetTop,X=void 0===U?20:U,J=p.badgeOffsetRight,Y=void 0===J?68:J,Z=p.badgeOffsetLeft,K=void 0===Z?0:Z,Q=p.initialReviewId,$=p.onBoundaryAction,ee=p.onLabelAction,ne=p.onActiveReviewChange,te=p.onCurrentPageChange,ie=p.onActionError,re=p.disableAllActions,oe=void 0!==re&&re,ae=p.onAdjustManually,le=p.onCognitiveClick,se=p.className,ue=p.style,de=p.viewerStyle,ce=p.railStyle,ge=p.redirectionData,fe=t.useMemo(function(){return u.extractSegmentReviewData(I)},[I]),ve=fe.boundaryReviews,pe=fe.labelReviews,me=t.useMemo(function(){return new Map(I.map(function(e,n){return[e.stable_key,n+1]}))},[I]),he=t.useRef(null),_e=t.useMemo(function(){return e.__spreadArray(e.__spreadArray([],ve.map(function(n){var t;return e.__assign(e.__assign({},n),{kind:"boundary",pageNumber:null!==(t=n.metadata.focus_page)&&void 0!==t?t:n.segment.start_page})}),!0),pe.map(function(n){return e.__assign(e.__assign({},n),{kind:"label",pageNumber:n.segment.start_page})}),!0).sort(function(e,n){var t,i,r=null!==(t=me.get(e.segment.stable_key))&&void 0!==t?t:Number.MAX_SAFE_INTEGER,o=null!==(i=me.get(n.segment.stable_key))&&void 0!==i?i:Number.MAX_SAFE_INTEGER;return e.pageNumber-n.pageNumber||r-o||e.reviewStepIndex-n.reviewStepIndex||e.id.localeCompare(n.id)})},[ve,pe,me]),be=t.useMemo(function(){return I.map(function(n){var t;return e.__assign(e.__assign({},n),{title:(null===(t=n.label)||void 0===t?void 0:t.trim())||n.title})})},[I]),we=t.useState(1),xe=we[0],ye=we[1],Ce=t.useState(null!=Q?Q:null),Se=Ce[0],Ee=Ce[1],ke=t.useState(null!=Q?Q:null),je=ke[0],Re=ke[1],Ie=t.useState(!1),Ne=Ie[0],Me=Ie[1],Ae=t.useState(null),Fe=Ae[0],Be=Ae[1],Pe=t.useState(null),qe=Pe[0],Le=Pe[1],We=t.useState(function(){return new Set}),ze=We[0],Te=We[1],Oe=t.useState(null),De=Oe[0],Ve=Oe[1],Ge=t.useRef(0),He=t.useRef(null),Ue=t.useRef(null),Xe=t.useRef(new Map),Je=t.useRef(null),Ye=t.useRef(null),Ze=t.useState(f),Ke=Ze[0],Qe=Ze[1],$e=null!==(h=null===(m=null==N?void 0:N.aside)||void 0===m?void 0:m.width)&&void 0!==h?h:"40%",en="min(".concat("number"==typeof $e?"".concat($e,"px"):$e,", ").concat(f,"px, 100%)");t.useEffect(function(){var e=he.current;if(e&&F){var n=function(){var n=e.getBoundingClientRect().width;n>0&&Qe(n)};n();var t="undefined"==typeof ResizeObserver?null:new ResizeObserver(n);return null==t||t.observe(e),function(){return null==t?void 0:t.disconnect()}}},[F]),t.useMemo(function(){var e=new Set(ze);return _e.forEach(function(n){null!=n.review_step.review&&e.add(n.id)}),e},[ze,_e]);var nn=t.useMemo(function(){var e;return null!==(e=_e.find(function(e){return e.id===Se}))&&void 0!==e?e:null},[Se,_e]),tn=null==nn?-1:I.findIndex(function(e){return e.stable_key===nn.segment.stable_key}),rn=tn>0?I[tn-1]:void 0,on=tn>=0?I[tn+1]:void 0,an=(null===(_=null==rn?void 0:rn.label)||void 0===_?void 0:_.trim())||(null==rn?void 0:rn.title),ln=(null===(b=null==on?void 0:on.label)||void 0===b?void 0:b.trim())||(null==on?void 0:on.title),sn=g.getConfidenceColors(null==nn?void 0:nn.review_step.score,null==nn?void 0:nn.review_step.confidence,null===(w=null==nn?void 0:nn.segment.confidence)||void 0===w?void 0:w.awaiting_llm),un=(null===(x=null==nn?void 0:nn.review_step.reasons)||void 0===x?void 0:x.length)?nn.review_step.reasons:null!==(C=null===(y=null==nn?void 0:nn.segment.confidence)||void 0===y?void 0:y.reasons)&&void 0!==C?C:[],dn=Boolean(un.some(function(e){return e.text.trim()&&["evidence","gap"].includes(e.type.trim().toLowerCase())})||(null===(S=null==nn?void 0:nn.review_step.reason)||void 0===S?void 0:S.trim())||(null===(E=null==nn?void 0:nn.review_step.gap)||void 0===E?void 0:E.trim())),cn=t.useCallback(function(e,n){Ge.current+=1,He.current={requestId:Ge.current,pageNumber:e,reviewId:n},Le({pageNumber:e,requestId:Ge.current})},[]),gn=t.useCallback(function(e){var n;!0!==(null===(n=e.segment.confidence)||void 0===n?void 0:n.awaiting_llm)&&(Ee(e.id),Re(e.id),Me(!1),Be(null),cn(e.pageNumber,e.id),null==ne||ne(e.id,e.segment))},[ne,cn]);t.useEffect(function(){if((null==ge?void 0:ge.pageNumber)&&ge.type){var e=Number(ge.pageNumber);if(Number.isInteger(e)&&!(e<1)){var n=_e.find(function(n){return n.segment.start_page===e&&n.kind===ge.type});n&&gn(n)}}},[ge,gn,_e]);var fn=t.useCallback(function(){He.current=null,Me(!1),Ee(null),Be(null),null==ne||ne(null,null)},[ne]),vn=t.useCallback(function(e){var n;if(V){var t=_e.findIndex(function(n){return n.id===e}),i=new Set(_e.map(function(e){return e.id})),r=null!==(n=_e.find(function(n,r){return r>t&&n.id!==e&&i.has(n.id)}))&&void 0!==n?n:_e.find(function(n){return n.id!==e});r?requestAnimationFrame(function(){return gn(r)}):fn()}else fn()},[V,fn,_e,gn,_e]),pn=t.useCallback(function(n,t,i){return e.__awaiter(k,void 0,void 0,function(){var r,a,l,s,u;return e.__generator(this,function(e){switch(e.label){case 0:if(oe)return[2];r=v(n),a=t,l="boundary"===n.kind&&null!=$&&V&&(a===o.BoundaryReviewActionEnum.SPLIT_HERE||a===o.BoundaryReviewActionEnum.MERGE_NEXT||a===o.BoundaryReviewActionEnum.MERGE_PREVIOUS),s=l?I.findIndex(function(e){return e.stable_key===n.segment.stable_key}):-1,l&&s>=0&&(Ue.current={action:a,originalSegmentIndex:s,segmentSignature:JSON.stringify(I.map(function(e){return e.stable_key})),ready:!1}),Ve(n.id),e.label=1;case 1:return e.trys.push([1,6,7,8]),"boundary"!==n.kind?[3,3]:[4,null==$?void 0:$(t,i,r)];case 2:return e.sent(),[3,5];case 3:return[4,null==ee?void 0:ee(t,i,r)];case 4:e.sent(),e.label=5;case 5:return Te(function(e){var t=new Set(e);return t.add(n.id),t}),Ue.current?Ue.current.ready=!0:vn(n.id),[3,8];case 6:return u=e.sent(),l&&(Ue.current=null),null==ie||ie(u,r),[3,8];case 7:return Ve(null),[7];case 8:return[2]}})})},[V,oe,ie,$,ee,I,vn]);t.useEffect(function(){var e=Ue.current;if((null==e?void 0:e.ready)&&JSON.stringify(I.map(function(e){return e.stable_key}))!==e.segmentSignature){var n=e.action===o.BoundaryReviewActionEnum.MERGE_PREVIOUS?e.originalSegmentIndex:e.originalSegmentIndex+1,t=new Map(I.map(function(e,n){return[e.stable_key,n]})),i=_e.find(function(e){var i,r=t.get(e.segment.stable_key);return null!=r&&r>=n&&null==e.review_step.review&&!ze.has(e.id)&&!0!==(null===(i=e.segment.confidence)||void 0===i?void 0:i.awaiting_llm)});if(!i)return Ue.current=null,void fn();requestAnimationFrame(function(){Ue.current=null,gn(i)})}},[fn,ze,_e,I,gn]),t.useEffect(function(){Ue.current||Se&&!_e.some(function(e){return e.id===Se})&&fn()},[Se,fn,_e]),t.useEffect(function(){if(O&&!Ue.current){var e=_e.find(function(e){return e.pageNumber===xe});e&&e.id!==Se&&gn(e)}},[Se,O,xe,gn,_e]),t.useEffect(function(){Ue.current||Se&&!_e.some(function(e){var n;return e.id===Se&&!0!==(null===(n=e.segment.confidence)||void 0===n?void 0:n.awaiting_llm)})&&fn()},[Se,fn,_e]);var mn=t.useMemo(function(){var n=_e.filter(function(e){var n;return!0!==(null===(n=e.segment.confidence)||void 0===n?void 0:n.awaiting_llm)});if("all"===L)return n;var t=["low","medium","high"].filter(function(e){return e!==P}),i=e.__spreadArray([P],t,!0),r=new Map(i.map(function(e,n){return[e,n]}));return n.map(function(e,n){return{item:e,index:n}}).sort(function(e,n){var t,o,a,l,s=null===(t=e.item.review_step.confidence)||void 0===t?void 0:t.trim().toLowerCase(),u=null===(o=n.item.review_step.confidence)||void 0===o?void 0:o.trim().toLowerCase();return(null==s?i.length:null!==(a=r.get(s))&&void 0!==a?a:i.length)-(null==u?i.length:null!==(l=r.get(u))&&void 0!==l?l:i.length)||e.index-n.index}).map(function(e){return e.item})},[L,P,_e]),hn=mn.findIndex(function(e){return e.id===je}),_n=t.useState(null),bn=_n[0],wn=_n[1],xn=t.useRef(!1),yn=t.useCallback(function(e){var n=mn[e];n&&gn(n)},[mn,gn]);t.useEffect(function(){je&&!mn.some(function(e){return e.id===je})&&Re(null)},[mn,je]),t.useEffect(function(){xn.current=!1,wn(hn>=0?String(hn+1):null)},[hn,mn.length]),t.useEffect(function(){if(xn.current&&null!=bn){var e=window.setTimeout(function(){var e=Number(bn.trim()),n=e-1;Number.isInteger(e)&&n>=0&&n<mn.length&&(xn.current=!1,yn(n))},300);return function(){return window.clearTimeout(e)}}},[yn,bn,mn.length]);var Cn=t.useMemo(function(){var e=new Map;_e.forEach(function(n){var t,i=null!==(t=e.get(n.segment.stable_key))&&void 0!==t?t:[];i.push(n),e.set(n.segment.stable_key,i)});var n=new Map;return e.forEach(function(e,t){var i,r=null!==(i=me.get(t))&&void 0!==i?i:1;e.sort(function(e,n){return e.reviewStepIndex-n.reviewStepIndex}).forEach(function(e,t){n.set(e.id,"".concat(r).concat(function(e){for(var n=e+1,t="";n>0;)n-=1,t=String.fromCharCode(65+n%26)+t,n=Math.floor(n/26);return t}(t)))})}),n},[_e,me]),Sn=t.useMemo(function(){var e=new Map;_e.forEach(function(n){var t,i=null!==(t=e.get(n.pageNumber))&&void 0!==t?t:[];i.push(n),e.set(n.pageNumber,i)});var n=new Map;return e.forEach(function(e){e.forEach(function(e,t){return n.set(e.id,t)})}),n},[_e]),En=t.useCallback(function(e){return{startPage:Math.max(0,e.startPage-H),endPage:Math.min(e.numPages-1,e.endPage+H)}},[H]),kn=t.useCallback(function(){var e,n=Je.current,t=Ye.current;if(n&&t){var i=n.getBoundingClientRect(),r=t.querySelector(".rpv-core__inner-pages"),o=null!==(e=null==r?void 0:r.getBoundingClientRect())&&void 0!==e?e:t.getBoundingClientRect();_e.forEach(function(e){var n,r=Xe.current.get(e.id);if(r){var a=t.querySelector('[data-testid="core__page-layer-'.concat(e.pageNumber-1,'"]'));if(a){var l=a.getBoundingClientRect(),s=null!==(n=Sn.get(e.id))&&void 0!==n?n:0,u=l.top+X+40*s,d=u+(r.offsetHeight||32),c=u>=o.top&&d<=o.bottom;r.style.top="".concat(u-i.top,"px"),r.style.visibility=c?"visible":"hidden"}else r.style.visibility="hidden"}})}},[X,Sn,_e]),jn=t.useCallback(function(e){var n=He.current;n&&n.requestId===e.requestId&&n.pageNumber===e.pageNumber&&(He.current=null,kn(),requestAnimationFrame(function(){if(null==He.current){var e=Xe.current.get(n.reviewId);e&&"hidden"!==e.style.visibility&&Be(e)}}))},[kn]);return t.useEffect(function(){var e=Ye.current;if(e&&F){var n=null,t=function(){null==n&&(n=requestAnimationFrame(function(){n=null,kn()}))};e.addEventListener("scroll",t,!0),window.addEventListener("resize",t);var i=new MutationObserver(t);i.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style"]});var r="undefined"==typeof ResizeObserver?null:new ResizeObserver(t);return null==r||r.observe(e),t(),function(){null!=n&&cancelAnimationFrame(n),e.removeEventListener("scroll",t,!0),window.removeEventListener("resize",t),i.disconnect(),null==r||r.disconnect()}}},[F,kn]),n.jsxs("div",e.__assign({ref:Je,className:se,style:e.__assign(e.__assign({},ue),{display:"block",position:"relative",width:"100%",height:"100%",minWidth:0,overflowX:"auto",overflowY:"hidden"})},{children:[n.jsxs("div",e.__assign({className:"segment-review-wrapper__container",style:{display:"flex",alignItems:"stretch",gap:0,width:"100%",minWidth:650,height:"100%"}},{children:[n.jsx("div",e.__assign({ref:Ye,style:e.__assign(e.__assign({},de),{flex:"1 1 auto",width:F?"auto":"100%",minWidth:0,height:"100%",boxSizing:"border-box"})},{children:n.jsx(r.default,e.__assign({defaultScale:i.SpecialZoomLevel.PageFit,highlightText:[],highlightPages:{},highlightCordinatePages:[],useCoordinates:!1},M,{pdfUrl:j,pdfName:R,segments:be,navigationRequest:qe,onNavigationSettled:jn,setRenderRange:En,onCurrentPageChange:function(e){ye(e),null==He.current&&nn&&nn.pageNumber!==e&&fn(),null==te||te(e)}}))})),F&&n.jsxs("aside",e.__assign({"aria-label":"Page review badges",ref:he,style:e.__assign(e.__assign({},ce),{position:"relative",width:en,maxWidth:f,flex:"0 1 ".concat(en),minHeight:0,overflow:"hidden",boxSizing:"border-box"})},{children:[z&&mn.length>0&&n.jsxs("nav",e.__assign({"aria-label":"Review badge navigation",style:{position:"absolute",top:8,right:Y||"auto",left:K||"auto",zIndex:2,display:"flex",alignItems:"center",gap:7,width:128,minHeight:40,padding:"4px 6px",border:"1px solid #CBD5E1",borderRadius:6,backgroundColor:"#FFFFFF",boxSizing:"border-box",boxShadow:"0 1px 2px rgba(16, 24, 40, 0.06)",font:"inherit"}},{children:[n.jsx("input",{type:"text",inputMode:"numeric",pattern:"[0-9]*",value:null!=bn?bn:"-","aria-label":"Review badge number",onChange:function(e){xn.current=!0,wn(e.target.value)},style:{width:30,height:28,padding:0,border:"1px solid #A5B4FC",borderRadius:3,color:"#4F46E5",backgroundColor:"#FFFFFF",textAlign:"center",font:"inherit",fontSize:15,outline:"none"}}),n.jsxs("span",e.__assign({"aria-label":"".concat(mn.length," reviews"),style:{flex:1,color:"#4F46E5",fontSize:14,whiteSpace:"nowrap",textAlign:"center"}},{children:["of ",mn.length]})),["previous","next"].map(function(t){var i="previous"===t,r=hn+(i?-1:1),o=r<0||r>=mn.length;return n.jsx("button",e.__assign({type:"button","aria-label":"".concat(i?"Previous":"Next"," review badge"),disabled:o,onClick:function(){return yn(r)},style:{display:"grid",placeItems:"center",width:17,height:28,padding:0,border:0,background:"transparent",color:o?"#C7D2FE":"#4F46E5",cursor:o?"default":"pointer"}},{children:n.jsx("svg",e.__assign({width:"12",height:"8",viewBox:"0 0 12 8",fill:"none"},{children:n.jsx("path",{d:i?"M1 7L6 2L11 7":"M1 1L6 6L11 1",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})}))}),t)})]})),_e.map(function(t){var i,r,o=Se===t.id,a=null!==(i=Cn.get(t.id))&&void 0!==i?i:"1A",l=t.review_step.score,s=t.review_step.confidence,u=g.formatScore(l,s),f=!0===(null===(r=t.segment.confidence)||void 0===r?void 0:r.awaiting_llm),v=g.getConfidenceColors(l,s,f),p=t.review_step.review&&null!==t.review_step.review.action,m=Boolean(p)||f;return n.jsx(c.Tooltip,e.__assign({title:f?"data is being processed":"",arrow:!0},{children:n.jsx("span",e.__assign({ref:function(e){e?Xe.current.set(t.id,e):Xe.current.delete(t.id)},style:{position:"absolute",top:0,left:10,visibility:"hidden",display:"inline-flex",cursor:m?"not-allowed":"pointer"}},{children:n.jsx("button",e.__assign({disabled:m,type:"button","aria-pressed":o,"aria-label":f?"".concat(t.review_step.type," · Page ").concat(t.pageNumber," · Data is being processed"):"".concat(t.review_step.type," · Page ").concat(t.pageNumber),onClick:function(){return gn(t)},style:{cursor:"inherit",display:"flex",alignItems:"center",justifyContent:"space-around",gap:4,width:p&&!f?105:80,minHeight:25,padding:"2px 5px",border:"1px solid ".concat(p&&!f?"#E2E8F0":v.border),borderRadius:16,backgroundColor:p&&!f?"#F8FAFC":v.background,color:p&&!f?"#475569":v.text,font:"inherit",alignContent:"center",boxShadow:"0 1px 2px rgba(16, 24, 40, 0.08)"}},{children:p&&!f?n.jsxs(c.Typography,e.__assign({fontFamily:"Inter",sx:{display:"flex",gap:1,alignItems:"center",flexDirection:"row"}},{children:[n.jsx("span",e.__assign({style:{fontSize:11,fontWeight:500}},{children:a})),n.jsxs("span",e.__assign({style:{display:"flex",alignItems:"center"}},{children:[n.jsx("svg",e.__assign({width:"2",height:"14",viewBox:"0 0 1 14",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:n.jsx("path",{d:"M0.399902 0V14",stroke:"#CBD5E1",strokeWidth:"0.8"})})),n.jsx("span",e.__assign({style:{fontSize:11,fontWeight:500,marginLeft:"7px",display:"flex",alignItems:"center"}},{children:"N/A"===u?u:"".concat(u,"%")}))]})),n.jsxs("span",e.__assign({style:{fontSize:11,fontWeight:500,display:"flex",alignItems:"center"}},{children:[n.jsx("svg",e.__assign({width:"2",height:"14",viewBox:"0 0 1 14",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:n.jsx("path",{d:"M0.399902 0V14",stroke:"#CBD5E1",strokeWidth:"0.8"})})),n.jsx("span",e.__assign({style:{display:"flex",marginLeft:"7px",alignItems:"center"}},{children:n.jsx(d.CircleCheck,{height:14,width:14,strokeWidth:2,color:"#16A34A"})}))]}))]})):n.jsxs(c.Typography,e.__assign({fontFamily:"Inter",sx:{display:"flex",gap:1,alignItems:"center",flexDirection:"row"}},{children:[n.jsx("span",e.__assign({style:{fontSize:11,fontWeight:500}},{children:a})),n.jsxs("span",e.__assign({style:{display:"flex",alignItems:"center"}},{children:[n.jsx("svg",e.__assign({width:"2",height:"14",viewBox:"0 0 1 14",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:n.jsx("path",{d:"M0.399902 0V14",stroke:v.divider,strokeWidth:"0.8"})})),n.jsx("span",e.__assign({style:{fontSize:11,fontWeight:500,marginLeft:"7px",display:"flex",alignItems:"center"}},{children:"N/A"===u?u:"".concat(u,"%")}))]}))]}))}))}))}),t.id)})]}))]})),nn&&Fe&&n.jsxs(a.default,e.__assign({anchorElement:Fe,placement:"bottom-start",offset:{top:8},width:Math.min(Ke,f),maxWidth:f},{children:[Ne&&n.jsx(l.default,{width:"100%",maxWidth:"100%",score:nn.review_step.score,reasons:un,reason:nn.review_step.reason,gap:nn.review_step.gap,onBack:function(){return Me(!1)},onClose:fn}),n.jsx("div",e.__assign({style:{display:Ne?"none":"block"}},{children:nn.review_step.review&&nn.review_step.human_resolution?n.jsx(n.Fragment,{}):"boundary"===nn.kind?n.jsx(o.default,{width:"100%",maxWidth:"100%",title:nn.segment.label||nn.segment.title,pageNo:"Page ".concat(nn.pageNumber),content:nn.review_step.reason,cognitiveScore:nn.review_step.score,metadata:nn.metadata,previousSegmentTitle:an,nextSegmentTitle:ln,defaultStartPage:nn.segment.start_page,defaultEndPage:nn.segment.end_page,styles:{root:{borderColor:sn.cardBorder},header:{"& > .MuiSvgIcon-root, & .MuiTypography-root":{color:sn.text}}},confirmDisabled:oe||De===nn.id,onConfirm:function(e,n,t){t&&o.isBoundaryReviewAction(n.id)&&pn(nn,n.id,t)},onAdjustManually:function(){return null==ae?void 0:ae(v(nn))},onCognitiveClick:dn?function(){Me(!0),null==le||le(v(nn))}:void 0,onClose:fn},nn.id):n.jsx(s.default,{width:"100%",maxWidth:"100%",title:nn.metadata.current_label||nn.segment.label||nn.segment.title,pageNo:"Pages ".concat(nn.segment.start_page,"-").concat(nn.segment.end_page),content:nn.review_step.reason,cognitiveScore:nn.review_step.score,metadata:nn.metadata,styles:{root:{borderColor:sn.cardBorder},header:{"& > .MuiSvgIcon-root, & .MuiTypography-root":{color:sn.text}}},confirmDisabled:oe||De===nn.id,onActionConfirm:function(e,n){pn(nn,e,n)},onAdjustManually:function(){return null==ae?void 0:ae(v(nn))},onCognitiveClick:dn?function(){Me(!0),null==le||le(v(nn))}:void 0,onClose:fn},nn.id)}))]}))]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),t=require("react"),i=require("@react-pdf-viewer/core"),r=require("../PdfViewer/PdfViewer.js"),o=require("./BoundaryCard.js"),a=require("./CardWrapper.js"),l=require("./CognitiveIntegrity.js"),s=require("./LabelCheck.js"),u=require("./reviewStepAdapters.js"),d=require("lucide-react"),c=require("@mui/material"),g=require("./helper.js"),f=260,v=function(e){return{reviewId:e.id,segment:e.segment,pageNumber:e.pageNumber}};exports.default=function(p){var m,h,_,b,w,x,y,C,S,k,E=this,j=p.pdfUrl,R=p.pdfName,I=p.segments,N=p.styles,M=p.pdfViewerProps,A=p.showBadges,F=void 0===A||A,B=p.sortByConfidence,P=void 0===B?"low":B,q=p.filterByConfidence,L=void 0===q?"all":q,W=p.showBadgeNavigation,z=void 0===W||W,T=p.autoSelectReviewOnPageChange,O=void 0!==T&&T,D=p.autoAdvanceAfterConfirm,V=void 0===D||D,G=p.badgePreloadPages,H=void 0===G?8:G,U=p.badgeOffsetTop,X=void 0===U?20:U,J=p.badgeOffsetRight,Y=void 0===J?68:J,Z=p.badgeOffsetLeft,K=void 0===Z?0:Z,Q=p.initialReviewId,$=p.onBoundaryAction,ee=p.onLabelAction,ne=p.onActiveReviewChange,te=p.onCurrentPageChange,ie=p.onActionError,re=p.disableAllActions,oe=void 0!==re&&re;p.disablePdfAnnotations;var ae=p.disableTitleCheckUntilBoundaryCheckCompleted,le=void 0!==ae&&ae,se=p.onAdjustManually,ue=p.onCognitiveClick,de=p.className,ce=p.style,ge=p.viewerStyle,fe=p.railStyle,ve=p.redirectionData,pe=t.useMemo(function(){return u.extractSegmentReviewData(I)},[I]),me=pe.boundaryReviews,he=pe.labelReviews,_e=t.useMemo(function(){return new Map(I.map(function(e,n){return[e.stable_key,n+1]}))},[I]),be=t.useRef(null),we=t.useMemo(function(){return e.__spreadArray(e.__spreadArray([],me.map(function(n){var t;return e.__assign(e.__assign({},n),{kind:"boundary",pageNumber:null!==(t=n.metadata.focus_page)&&void 0!==t?t:n.segment.start_page})}),!0),he.map(function(n){return e.__assign(e.__assign({},n),{kind:"label",pageNumber:n.segment.start_page})}),!0).sort(function(e,n){var t,i,r=null!==(t=_e.get(e.segment.stable_key))&&void 0!==t?t:Number.MAX_SAFE_INTEGER,o=null!==(i=_e.get(n.segment.stable_key))&&void 0!==i?i:Number.MAX_SAFE_INTEGER;return e.pageNumber-n.pageNumber||r-o||e.reviewStepIndex-n.reviewStepIndex||e.id.localeCompare(n.id)})},[me,he,_e]),xe=t.useMemo(function(){return I.map(function(n){var t;return e.__assign(e.__assign({},n),{title:(null===(t=n.label)||void 0===t?void 0:t.trim())||n.title})})},[I]),ye=t.useState(1),Ce=ye[0],Se=ye[1],ke=t.useState(null!=Q?Q:null),Ee=ke[0],je=ke[1],Re=t.useState(null!=Q?Q:null),Ie=Re[0],Ne=Re[1],Me=t.useState(!1),Ae=Me[0],Fe=Me[1],Be=t.useState(null),Pe=Be[0],qe=Be[1],Le=t.useState(null),We=Le[0],ze=Le[1],Te=t.useState(function(){return new Set}),Oe=Te[0],De=Te[1],Ve=t.useState(null),Ge=Ve[0],He=Ve[1],Ue=t.useRef(0),Xe=t.useRef(null),Je=t.useRef(null),Ye=t.useRef(new Map),Ze=t.useRef(null),Ke=t.useRef(null),Qe=t.useState(f),$e=Qe[0],en=Qe[1],nn=null!==(h=null===(m=null==N?void 0:N.aside)||void 0===m?void 0:m.width)&&void 0!==h?h:"40%",tn="min(".concat("number"==typeof nn?"".concat(nn,"px"):nn,", ").concat(f,"px, 100%)");t.useEffect(function(){var e=be.current;if(e&&F){var n=function(){var n=e.getBoundingClientRect().width;n>0&&en(n)};n();var t="undefined"==typeof ResizeObserver?null:new ResizeObserver(n);return null==t||t.observe(e),function(){return null==t?void 0:t.disconnect()}}},[F]);var rn=t.useMemo(function(){var e=new Set(Oe);return we.forEach(function(n){null!=n.review_step.review&&e.add(n.id)}),e},[Oe,we]),on=t.useMemo(function(){var e;return null!==(e=we.find(function(e){return e.id===Ee}))&&void 0!==e?e:null},[Ee,we]),an=t.useMemo(function(){return!(!le||"label"!==(null==on?void 0:on.kind))&&me.some(function(e){return e.segment.stable_key===on.segment.stable_key&&!rn.has(e.id)})},[on,me,le,rn]),ln=null==on?-1:I.findIndex(function(e){return e.stable_key===on.segment.stable_key}),sn=ln>0?I[ln-1]:void 0,un=ln>=0?I[ln+1]:void 0,dn=(null===(_=null==sn?void 0:sn.label)||void 0===_?void 0:_.trim())||(null==sn?void 0:sn.title),cn=(null===(b=null==un?void 0:un.label)||void 0===b?void 0:b.trim())||(null==un?void 0:un.title),gn=g.getConfidenceColors(null==on?void 0:on.review_step.score,null==on?void 0:on.review_step.confidence,null===(w=null==on?void 0:on.segment.confidence)||void 0===w?void 0:w.awaiting_llm),fn=(null===(x=null==on?void 0:on.review_step.reasons)||void 0===x?void 0:x.length)?on.review_step.reasons:null!==(C=null===(y=null==on?void 0:on.segment.confidence)||void 0===y?void 0:y.reasons)&&void 0!==C?C:[],vn=Boolean(fn.some(function(e){return e.text.trim()&&["evidence","gap"].includes(e.type.trim().toLowerCase())})||(null===(S=null==on?void 0:on.review_step.reason)||void 0===S?void 0:S.trim())||(null===(k=null==on?void 0:on.review_step.gap)||void 0===k?void 0:k.trim())),pn=t.useCallback(function(e,n){Ue.current+=1,Xe.current={requestId:Ue.current,pageNumber:e,reviewId:n},ze({pageNumber:e,requestId:Ue.current})},[]),mn=t.useCallback(function(e){var n;!0!==(null===(n=e.segment.confidence)||void 0===n?void 0:n.awaiting_llm)&&(je(e.id),Ne(e.id),Fe(!1),qe(null),pn(e.pageNumber,e.id),null==ne||ne(e.id,e.segment))},[ne,pn]);t.useEffect(function(){if((null==ve?void 0:ve.pageNumber)&&ve.type){var e=Number(ve.pageNumber);if(Number.isInteger(e)&&!(e<1)){var n=we.find(function(n){return n.segment.start_page===e&&n.kind===ve.type});n&&mn(n)}}},[ve,mn,we]);var hn=t.useCallback(function(){Xe.current=null,Fe(!1),je(null),qe(null),null==ne||ne(null,null)},[ne]),_n=t.useCallback(function(e){var n;if(V){var t=we.findIndex(function(n){return n.id===e}),i=new Set(we.map(function(e){return e.id})),r=null!==(n=we.find(function(n,r){return r>t&&n.id!==e&&i.has(n.id)}))&&void 0!==n?n:we.find(function(n){return n.id!==e});r?requestAnimationFrame(function(){return mn(r)}):hn()}else hn()},[V,hn,we,mn,we]),bn=t.useCallback(function(n,t,i){return e.__awaiter(E,void 0,void 0,function(){var r,a,l,s,u;return e.__generator(this,function(e){switch(e.label){case 0:if(oe)return[2];r=v(n),a=t,l="boundary"===n.kind&&null!=$&&V&&(a===o.BoundaryReviewActionEnum.SPLIT_HERE||a===o.BoundaryReviewActionEnum.MERGE_NEXT||a===o.BoundaryReviewActionEnum.MERGE_PREVIOUS),s=l?I.findIndex(function(e){return e.stable_key===n.segment.stable_key}):-1,l&&s>=0&&(Je.current={action:a,originalSegmentIndex:s,segmentSignature:JSON.stringify(I.map(function(e){return e.stable_key})),ready:!1}),He(n.id),e.label=1;case 1:return e.trys.push([1,6,7,8]),"boundary"!==n.kind?[3,3]:[4,null==$?void 0:$(t,i,r)];case 2:return e.sent(),[3,5];case 3:return[4,null==ee?void 0:ee(t,i,r)];case 4:e.sent(),e.label=5;case 5:return De(function(e){var t=new Set(e);return t.add(n.id),t}),Je.current?Je.current.ready=!0:_n(n.id),[3,8];case 6:return u=e.sent(),l&&(Je.current=null),null==ie||ie(u,r),[3,8];case 7:return He(null),[7];case 8:return[2]}})})},[V,oe,ie,$,ee,I,_n]);t.useEffect(function(){var e=Je.current;if((null==e?void 0:e.ready)&&JSON.stringify(I.map(function(e){return e.stable_key}))!==e.segmentSignature){var n=e.action===o.BoundaryReviewActionEnum.MERGE_PREVIOUS?e.originalSegmentIndex:e.originalSegmentIndex+1,t=new Map(I.map(function(e,n){return[e.stable_key,n]})),i=we.find(function(e){var i,r=t.get(e.segment.stable_key);return null!=r&&r>=n&&null==e.review_step.review&&!Oe.has(e.id)&&!0!==(null===(i=e.segment.confidence)||void 0===i?void 0:i.awaiting_llm)});if(!i)return Je.current=null,void hn();requestAnimationFrame(function(){Je.current=null,mn(i)})}},[hn,Oe,we,I,mn]),t.useEffect(function(){Je.current||Ee&&!we.some(function(e){return e.id===Ee})&&hn()},[Ee,hn,we]),t.useEffect(function(){if(O&&!Je.current){var e=we.find(function(e){return e.pageNumber===Ce});e&&e.id!==Ee&&mn(e)}},[Ee,O,Ce,mn,we]),t.useEffect(function(){Je.current||Ee&&!we.some(function(e){var n;return e.id===Ee&&!0!==(null===(n=e.segment.confidence)||void 0===n?void 0:n.awaiting_llm)})&&hn()},[Ee,hn,we]);var wn=t.useMemo(function(){var n=we.filter(function(e){var n;return!0!==(null===(n=e.segment.confidence)||void 0===n?void 0:n.awaiting_llm)});if("all"===L)return n;var t=["low","medium","high"].filter(function(e){return e!==P}),i=e.__spreadArray([P],t,!0),r=new Map(i.map(function(e,n){return[e,n]}));return n.map(function(e,n){return{item:e,index:n}}).sort(function(e,n){var t,o,a,l,s=null===(t=e.item.review_step.confidence)||void 0===t?void 0:t.trim().toLowerCase(),u=null===(o=n.item.review_step.confidence)||void 0===o?void 0:o.trim().toLowerCase();return(null==s?i.length:null!==(a=r.get(s))&&void 0!==a?a:i.length)-(null==u?i.length:null!==(l=r.get(u))&&void 0!==l?l:i.length)||e.index-n.index}).map(function(e){return e.item})},[L,P,we]),xn=wn.findIndex(function(e){return e.id===Ie}),yn=t.useState(null),Cn=yn[0],Sn=yn[1],kn=t.useRef(!1),En=t.useCallback(function(e){var n=wn[e];n&&mn(n)},[wn,mn]);t.useEffect(function(){Ie&&!wn.some(function(e){return e.id===Ie})&&Ne(null)},[wn,Ie]),t.useEffect(function(){kn.current=!1,Sn(xn>=0?String(xn+1):null)},[xn,wn.length]),t.useEffect(function(){if(kn.current&&null!=Cn){var e=window.setTimeout(function(){var e=Number(Cn.trim()),n=e-1;Number.isInteger(e)&&n>=0&&n<wn.length&&(kn.current=!1,En(n))},300);return function(){return window.clearTimeout(e)}}},[En,Cn,wn.length]);var jn=t.useMemo(function(){var e=new Map;we.forEach(function(n){var t,i=null!==(t=e.get(n.segment.stable_key))&&void 0!==t?t:[];i.push(n),e.set(n.segment.stable_key,i)});var n=new Map;return e.forEach(function(e,t){var i,r=null!==(i=_e.get(t))&&void 0!==i?i:1;e.sort(function(e,n){return e.reviewStepIndex-n.reviewStepIndex}).forEach(function(e,t){n.set(e.id,"".concat(r).concat(function(e){for(var n=e+1,t="";n>0;)n-=1,t=String.fromCharCode(65+n%26)+t,n=Math.floor(n/26);return t}(t)))})}),n},[we,_e]),Rn=t.useMemo(function(){var e=new Map;we.forEach(function(n){var t,i=null!==(t=e.get(n.pageNumber))&&void 0!==t?t:[];i.push(n),e.set(n.pageNumber,i)});var n=new Map;return e.forEach(function(e){e.forEach(function(e,t){return n.set(e.id,t)})}),n},[we]),In=t.useCallback(function(e){return{startPage:Math.max(0,e.startPage-H),endPage:Math.min(e.numPages-1,e.endPage+H)}},[H]),Nn=t.useCallback(function(){var e,n=Ze.current,t=Ke.current;if(n&&t){var i=n.getBoundingClientRect(),r=t.querySelector(".rpv-core__inner-pages"),o=null!==(e=null==r?void 0:r.getBoundingClientRect())&&void 0!==e?e:t.getBoundingClientRect();we.forEach(function(e){var n,r=Ye.current.get(e.id);if(r){var a=t.querySelector('[data-testid="core__page-layer-'.concat(e.pageNumber-1,'"]'));if(a){var l=a.getBoundingClientRect(),s=null!==(n=Rn.get(e.id))&&void 0!==n?n:0,u=l.top+X+40*s,d=u+(r.offsetHeight||32),c=u>=o.top&&d<=o.bottom;r.style.top="".concat(u-i.top,"px"),r.style.visibility=c?"visible":"hidden"}else r.style.visibility="hidden"}})}},[X,Rn,we]),Mn=t.useCallback(function(e){var n=Xe.current;n&&n.requestId===e.requestId&&n.pageNumber===e.pageNumber&&(Xe.current=null,Nn(),requestAnimationFrame(function(){if(null==Xe.current){var e=Ye.current.get(n.reviewId);e&&"hidden"!==e.style.visibility&&qe(e)}}))},[Nn]);return t.useEffect(function(){var e=Ke.current;if(e&&F){var n=null,t=function(){null==n&&(n=requestAnimationFrame(function(){n=null,Nn()}))};e.addEventListener("scroll",t,!0),window.addEventListener("resize",t);var i=new MutationObserver(t);i.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style"]});var r="undefined"==typeof ResizeObserver?null:new ResizeObserver(t);return null==r||r.observe(e),t(),function(){null!=n&&cancelAnimationFrame(n),e.removeEventListener("scroll",t,!0),window.removeEventListener("resize",t),i.disconnect(),null==r||r.disconnect()}}},[F,Nn]),n.jsxs("div",e.__assign({ref:Ze,className:de,style:e.__assign(e.__assign({},ce),{display:"block",position:"relative",width:"100%",height:"100%",minWidth:0,overflowX:"auto",overflowY:"hidden"})},{children:[n.jsxs("div",e.__assign({className:"segment-review-wrapper__container",style:{display:"flex",alignItems:"stretch",gap:0,width:"100%",minWidth:700,height:"100%"}},{children:[n.jsx("div",e.__assign({ref:Ke,style:e.__assign(e.__assign({},ge),{flex:"1 1 auto",width:F?"auto":"100%",minWidth:0,height:"100%",boxSizing:"border-box"})},{children:n.jsx(r.default,e.__assign({defaultScale:i.SpecialZoomLevel.PageFit,disablePdfAnnotations:!0,highlightText:[],highlightPages:{},highlightCordinatePages:[],useCoordinates:!1},M,{pdfUrl:j,pdfName:R,segments:xe,navigationRequest:We,onNavigationSettled:Mn,setRenderRange:In,onCurrentPageChange:function(e){Se(e),null==Xe.current&&on&&on.pageNumber!==e&&hn(),null==te||te(e)}}))})),F&&n.jsxs("aside",e.__assign({"aria-label":"Page review badges",ref:be,style:e.__assign(e.__assign({},fe),{position:"relative",width:tn,maxWidth:f,flex:"0 1 ".concat(tn),minHeight:0,overflow:"hidden",boxSizing:"border-box"})},{children:[z&&wn.length>0&&n.jsxs("nav",e.__assign({"aria-label":"Review badge navigation",style:{position:"absolute",top:8,right:Y||"auto",left:K||"auto",zIndex:2,display:"flex",alignItems:"center",gap:7,width:128,minHeight:40,padding:"4px 6px",border:"1px solid #CBD5E1",borderRadius:6,backgroundColor:"#FFFFFF",boxSizing:"border-box",boxShadow:"0 1px 2px rgba(16, 24, 40, 0.06)",font:"inherit"}},{children:[n.jsx("input",{type:"text",inputMode:"numeric",pattern:"[0-9]*",value:null!=Cn?Cn:"-","aria-label":"Review badge number",onChange:function(e){kn.current=!0,Sn(e.target.value)},style:{width:30,height:28,padding:0,border:"1px solid #A5B4FC",borderRadius:3,color:"#4F46E5",backgroundColor:"#FFFFFF",textAlign:"center",font:"inherit",fontSize:15,outline:"none"}}),n.jsxs("span",e.__assign({"aria-label":"".concat(wn.length," reviews"),style:{flex:1,color:"#4F46E5",fontSize:14,whiteSpace:"nowrap",textAlign:"center"}},{children:["of ",wn.length]})),["previous","next"].map(function(t){var i="previous"===t,r=xn+(i?-1:1),o=r<0||r>=wn.length;return n.jsx("button",e.__assign({type:"button","aria-label":"".concat(i?"Previous":"Next"," review badge"),disabled:o,onClick:function(){return En(r)},style:{display:"grid",placeItems:"center",width:17,height:28,padding:0,border:0,background:"transparent",color:o?"#C7D2FE":"#4F46E5",cursor:o?"default":"pointer"}},{children:n.jsx("svg",e.__assign({width:"12",height:"8",viewBox:"0 0 12 8",fill:"none"},{children:n.jsx("path",{d:i?"M1 7L6 2L11 7":"M1 1L6 6L11 1",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})}))}),t)})]})),we.map(function(t){var i,r,o=Ee===t.id,a=null!==(i=jn.get(t.id))&&void 0!==i?i:"1A",l=t.review_step.score,s=t.review_step.confidence,u=g.formatScore(l,s),f=!0===(null===(r=t.segment.confidence)||void 0===r?void 0:r.awaiting_llm),v=g.getConfidenceColors(l,s,f),p=t.review_step.review&&null!==t.review_step.review.action,m=Boolean(p)||f;return n.jsx(c.Tooltip,e.__assign({title:f?"data is being processed":"",arrow:!0},{children:n.jsx("span",e.__assign({ref:function(e){e?Ye.current.set(t.id,e):Ye.current.delete(t.id)},style:{position:"absolute",top:0,left:10,visibility:"hidden",display:"inline-flex",cursor:m?"not-allowed":"pointer"}},{children:n.jsx("button",e.__assign({disabled:m,type:"button","aria-pressed":o,"aria-label":f?"".concat(t.review_step.type," · Page ").concat(t.pageNumber," · Data is being processed"):"".concat(t.review_step.type," · Page ").concat(t.pageNumber),onClick:function(){return mn(t)},style:{cursor:"inherit",display:"flex",alignItems:"center",justifyContent:"space-around",gap:4,width:p&&!f?105:80,minHeight:25,padding:"2px 5px",border:"1px solid ".concat(p&&!f?"#E2E8F0":v.border),borderRadius:16,backgroundColor:p&&!f?"#F8FAFC":v.background,color:p&&!f?"#475569":v.text,font:"inherit",alignContent:"center",boxShadow:"0 1px 2px rgba(16, 24, 40, 0.08)"}},{children:p&&!f?n.jsxs(c.Typography,e.__assign({fontFamily:"Inter",sx:{display:"flex",gap:1,alignItems:"center",flexDirection:"row"}},{children:[n.jsx("span",e.__assign({style:{fontSize:11,fontWeight:500}},{children:a})),n.jsxs("span",e.__assign({style:{display:"flex",alignItems:"center"}},{children:[n.jsx("svg",e.__assign({width:"2",height:"14",viewBox:"0 0 1 14",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:n.jsx("path",{d:"M0.399902 0V14",stroke:"#CBD5E1",strokeWidth:"0.8"})})),n.jsx("span",e.__assign({style:{fontSize:11,fontWeight:500,marginLeft:"7px",display:"flex",alignItems:"center"}},{children:"N/A"===u?u:"".concat(u,"%")}))]})),n.jsxs("span",e.__assign({style:{fontSize:11,fontWeight:500,display:"flex",alignItems:"center"}},{children:[n.jsx("svg",e.__assign({width:"2",height:"14",viewBox:"0 0 1 14",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:n.jsx("path",{d:"M0.399902 0V14",stroke:"#CBD5E1",strokeWidth:"0.8"})})),n.jsx("span",e.__assign({style:{display:"flex",marginLeft:"7px",alignItems:"center"}},{children:n.jsx(d.CircleCheck,{height:14,width:14,strokeWidth:2,color:"#16A34A"})}))]}))]})):n.jsxs(c.Typography,e.__assign({fontFamily:"Inter",sx:{display:"flex",gap:1,alignItems:"center",flexDirection:"row"}},{children:[n.jsx("span",e.__assign({style:{fontSize:11,fontWeight:500}},{children:a})),n.jsxs("span",e.__assign({style:{display:"flex",alignItems:"center"}},{children:[n.jsx("svg",e.__assign({width:"2",height:"14",viewBox:"0 0 1 14",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:n.jsx("path",{d:"M0.399902 0V14",stroke:v.divider,strokeWidth:"0.8"})})),n.jsx("span",e.__assign({style:{fontSize:11,fontWeight:500,marginLeft:"7px",display:"flex",alignItems:"center"}},{children:"N/A"===u?u:"".concat(u,"%")}))]}))]}))}))}))}),t.id)})]}))]})),on&&Pe&&n.jsxs(a.default,e.__assign({anchorElement:Pe,placement:"bottom-start",offset:{top:8},width:Math.min($e,f),maxWidth:f},{children:[Ae&&n.jsx(l.default,{width:"100%",maxWidth:"100%",score:on.review_step.score,reasons:fn,reason:on.review_step.reason,gap:on.review_step.gap,onBack:function(){return Fe(!1)},onClose:hn}),n.jsx("div",e.__assign({style:{display:Ae?"none":"block"}},{children:on.review_step.review&&on.review_step.human_resolution?n.jsx(n.Fragment,{}):"boundary"===on.kind?n.jsx(o.default,{width:"100%",maxWidth:"100%",title:on.segment.label||on.segment.title,pageNo:"Page ".concat(on.pageNumber),content:on.review_step.reason,cognitiveScore:on.review_step.score,metadata:on.metadata,previousSegmentTitle:dn,nextSegmentTitle:cn,defaultStartPage:on.segment.start_page,defaultEndPage:on.segment.end_page,styles:{root:{borderColor:gn.cardBorder},header:{"& > .MuiSvgIcon-root, & .MuiTypography-root":{color:gn.text}}},confirmDisabled:oe||Ge===on.id,onConfirm:function(e,n,t){t&&o.isBoundaryReviewAction(n.id)&&bn(on,n.id,t)},onAdjustManually:function(){return null==se?void 0:se(v(on))},onCognitiveClick:vn?function(){Fe(!0),null==ue||ue(v(on))}:void 0,onClose:hn},on.id):n.jsx(s.default,{width:"100%",maxWidth:"100%",title:on.metadata.current_label||on.segment.label||on.segment.title,pageNo:"Pages ".concat(on.segment.start_page,"-").concat(on.segment.end_page),content:on.review_step.reason,cognitiveScore:on.review_step.score,metadata:on.metadata,styles:{root:{borderColor:gn.cardBorder},header:{"& > .MuiSvgIcon-root, & .MuiTypography-root":{color:gn.text}}},confirmDisabled:oe||Ge===on.id,confirmationBlocked:an,confirmationWarning:an?"Please confirm the boundary before confirming the title.":void 0,onActionConfirm:function(e,n){bn(on,e,n)},onAdjustManually:function(){return null==se?void 0:se(v(on))},onCognitiveClick:vn?function(){Fe(!0),null==ue||ue(v(on))}:void 0,onClose:hn},on.id)}))]}))]}))};
2
2
  //# sourceMappingURL=SegmentReviewPdfWrapper.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e,__spreadArray as n,__awaiter as i,__generator as t}from"tslib";import{jsx as o,jsxs as r}from"react/jsx-runtime";import{useState as l,useRef as u,useMemo as c,useEffect as a,useCallback as s}from"react";import{Box as d,Snackbar as v,Alert as f,Tooltip as p,Typography as g,Tabs as h,Tab as m}from"@mui/material";import{ChevronDown as S}from"lucide-react";import{ButtonCognitiveIcon as x}from"../../assests/svg/ButtonCognitiveIcon.js";import R from"./OverlayComponent.js";import{safeStringify as b,extractDeviationScore as y,generateColorPalette as C,findKeyPathByNodeId as w,DEVIATION_BADGE_SEPARATOR as B,hasMeaningfulRedlineTags as _,scrollAndHighlightClause as I,scrollAndWait as F,waitForScrollIdle as T}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as E,DEFAULT_FIELD_CONFIG as A,DEFAULT_COMPARISON_CONFIG as D}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import{DEFAULT_DEVIAION_COLOR as k,EMPTY_SUMMARY_POPUP_STATE as O,DEFAULT_COMPONENT_HEADER_TEXT as P}from"./CognitiveCompareConstants.js";import j from"./CognitivePopup.js";import L from"./MoreFunctionsPopup.js";import N from"./LoaderComponent.js";import M from"./components/ThreeDotsLoader.js";import{useCognitiveTreeData as H}from"./hooks/useCompareData.js";import{useComparePopups as z}from"./hooks/useComparePopups.js";import{useSectionRefs as W}from"./hooks/useSectionRefs.js";import{useAccordionState as q}from"./hooks/useAccordionState.js";import{useDeviationNavigation as G}from"./hooks/useDeviationNavigation.js";import V from"./components/CompareHeader.js";import K from"./components/SubSectionAccordion.js";import J from"./components/LHSSectionRow.js";import Y from"./components/RHSSectionRow.js";import X from"./components/CognitiveSummaryPopup.js";import{CompareContextProvider as $}from"./CompareContext.js";import{useStyleHelpers as U}from"./hooks/useStyles.js";import{useResizeHandler as Q}from"./hooks/useResizeHandler.js";import{useLinesCalculator as Z}from"./hooks/useLinesCalculator.js";import{useSideBySide as ee}from"./hooks/useSideBySide.js";import ne from"./components/SvgConnectors.js";import ie from"./Guidelines/components/GuidelinePanel.js";import te from"./Guidelines/components/WebGptPanel.js";var oe=function(oe){var re,le,ue,ce,ae,se,de,ve,fe,pe,ge,he,me,Se,xe,Re,be,ye,Ce,we,Be,_e,Ie,Fe,Te,Ee,Ae,De,ke,Oe,Pe,je,Le,Ne,Me,He=oe.componentHeaderText,ze=void 0===He?P:He,We=oe.treeData,qe=oe.comparisonConfig,Ge=oe.leftColumnTitleText,Ve=oe.rightColumnTitleText,Ke=oe.markdownStyles,Je=oe.resetTrigger,Ye=oe.displayConfig,Xe=void 0===Ye?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1,displayEmailNotifier:!0,isStreamingEnabled:!1}:Ye,$e=oe.onMaintainRelativeOrderChange,Ue=oe.popupConfig,Qe=oe.deviationData,Ze=void 0===Qe?{}:Qe,en=oe.deviationNodeIdToView,nn=oe.resetDeviationNodeId,tn=oe.isProposingFix,on=void 0!==tn&&tn,rn=oe.proposingFixNodeId,ln=oe.isRedlineFlow,un=oe.badgeStyleOverride,cn=oe.guidelinesData,an=oe.gptWebCitationConfig,sn=l(Xe.maintainRelativeOrder),dn=sn[0],vn=sn[1],fn=null!==(re=null==Xe?void 0:Xe.expandLevels)&&void 0!==re?re:0,pn=!!(null==Xe?void 0:Xe.expandAllSections),gn=!!dn||!!(null==Xe?void 0:Xe.showDeviationBadges),hn=l(!1),mn=hn[0],Sn=hn[1],xn=l(null),Rn=xn[0],bn=xn[1],yn=l(null===(ue=null!==(le=null==We?void 0:We.newEvaluationResult)&&void 0!==le?le:null==Xe?void 0:Xe.enableDeviationSchemaBackwardCompatibility)||void 0===ue||ue)[0],Cn=l(new Set),wn=Cn[0],Bn=Cn[1],_n=l([]),In=_n[0],Fn=_n[1],Tn=l(!1),En=Tn[0],An=Tn[1],Dn=l(0),kn=Dn[0],On=Dn[1],Pn=u(null),jn=u(null),Ln=u(null),Nn=u(null),Mn=u(null),Hn=u(!1),zn=u(null),Wn=u({}),qn=u([]),Gn=u(function(){}),Vn=u(null),Kn=u(function(){}),Jn=c(function(){return JSON.stringify(Ze||{})},[JSON.stringify(Ze)]),Yn=c(function(){return Ze||{}},[Jn]),Xn=c(function(){return(null==We?void 0:We.cognitive_decisioning)||{}},[We]),$n=c(function(){return e(e({},E),Ke)},[Ke]),Un=u(null),Qn=u(null),Zn=u(null),ei=u(null),ni=u(null),ii=u(null),ti=u(null),oi=u(null),ri=u(null),li=u(null),ui=z(Un),ci=ui.cognitivePopup,ai=ui.setCognitivePopup,si=ui.moreFunctions,di=ui.setMoreFunctions,vi=ui.position,fi=ui.setPosition,pi=ui.activeBadgeId,gi=ui.summaryPopup,hi=ui.setSummaryPopup,mi=ui.closeSummaryPopup,Si=ui.setActiveBadgeId,xi=ui.popupRef,Ri=ui.handleOpenCognitiveCompare,bi=ui.openCognitivePopupFromState,yi=ui.closeCognitivePopup,Ci=ui.closeMoreFunctionsPopup,wi=c(function(){var e,n,i,t,o,r,l;return{fields:null!==(e=null==qe?void 0:qe.fields)&&void 0!==e?e:A,thresholds:{high:null!==(i=null===(n=null==qe?void 0:qe.thresholds)||void 0===n?void 0:n.high)&&void 0!==i?i:D.thresholds.high,medium:null!==(o=null===(t=null==qe?void 0:qe.thresholds)||void 0===t?void 0:t.medium)&&void 0!==o?o:D.thresholds.medium,exact:null!==(l=null===(r=null==qe?void 0:qe.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:D.thresholds.exact}}},[qe]),Bi=l(null),_i=Bi[0];Bi[1];var Ii=null===(se=null===(ce=null==We?void 0:We.documents)||void 0===ce?void 0:ce[null===(ae=null==We?void 0:We.input_index_map)||void 0===ae?void 0:ae[0]])||void 0===se?void 0:se.title,Fi=null===(fe=null===(de=null==We?void 0:We.documents)||void 0===de?void 0:de[null===(ve=null==We?void 0:We.input_index_map)||void 0===ve?void 0:ve[1]])||void 0===fe?void 0:fe.title,Ti=b(Ge||Ii||"Uploaded Contract"),Ei=null===(me=null===(he=null===(pe=null==We?void 0:We.documents)||void 0===pe?void 0:pe[null===(ge=null==We?void 0:We.input_index_map)||void 0===ge?void 0:ge[0]])||void 0===he?void 0:he.metadata)||void 0===me?void 0:me.file_name,Ai=b(Ei),Di=null===(be=null===(Re=null===(Se=null==We?void 0:We.documents)||void 0===Se?void 0:Se[null===(xe=null==We?void 0:We.input_index_map)||void 0===xe?void 0:xe[1]])||void 0===Re?void 0:Re.metadata)||void 0===be?void 0:be.file_name,ki=b(Di),Oi=b(Ve||Fi||"Reference Template"),Pi=H(We,dn,Yn,wi,yn,cn),ji=Pi.isGuidelineMode,Li=Pi.activeProposed,Ni=Pi.existingRule,Mi=Pi.proposedSections,Hi=Pi.existingSections,zi=Pi.visibleFields,Wi=Pi.parentDeviationRecord,qi=Pi.deviationNumberRegistry,Gi=Pi.deviationParentRegistry,Vi=Pi.parseError;a(function(){Vi&&bn("Failed to load comparison: ".concat(Vi))},[Vi]);var Ki=Mi.length>0||Hi.length>0,Ji=c(function(){if(!ln)return"off";var e=0,n=0,i=function(t){Array.isArray(t)&&t.forEach(function(t){var o,r=(null==t?void 0:t.content)||"";_(r)&&(e+=1,n+=String(r).length),(null===(o=null==t?void 0:t.subsections)||void 0===o?void 0:o.length)&&i(t.subsections)})};return i(Mi),i(Hi),"".concat(e,":").concat(n)},[ln,Mi,Hi]);a(function(){if(Mi.length||Hi.length)if(pn){var e={},n={},i=function(i,t){i.forEach(function(i,o){var r,l=dn?"".concat(t,"-").concat(o):String(o);e[l]=!0;var u=function(e,i){null==e||e.forEach(function(e,t){var o,r="".concat(i,"-").concat(t);n[r]=!0,(null===(o=e.subsections)||void 0===o?void 0:o.length)&&u(e.subsections,r)})};(null===(r=i.subsections)||void 0===r?void 0:r.length)&&u(i.subsections,String(o))})};i(Mi,"left"),i(Hi,"right"),Tt(e),At(n)}else if(fn>0){var t={},o={},r=function(e,n,i){e.forEach(function(e,r){var l;if(i>=1){var u=dn?"".concat(n,"-").concat(r):String(r);t[u]=!0}var c=function(e,n,t){t>i||null==e||e.forEach(function(e,i){var r,l="".concat(n,"-").concat(i);o[l]=!0,(null===(r=e.subsections)||void 0===r?void 0:r.length)&&c(e.subsections,l,t+1)})};(null===(l=e.subsections)||void 0===l?void 0:l.length)&&i>=2&&c(e.subsections,String(r),2)})};r(Mi,"left",fn),r(Hi,"right",fn),Tt(t),At(o)}},[pn,fn,Mi,Hi,dn]);var Yi=W(zi.map(function(e){return e.key}),Math.max(Mi.length,Hi.length)),Xi=Yi.leftRefs,$i=Yi.rightRefs,Ui=Yi.sectionLeftRefs,Qi=Yi.sectionRightRefs,Zi=Yi.lhsBadgeRefs,et=Yi.rhsBadgeRefs,nt=Yi.sectionRightRowRefs,it=Yi.subSectionLeftRefs,tt=Yi.subSectionRightRefs,ot=Yi.sectionRowRefs,rt=Yi.getSectionRowRef,lt=Yi.getSubSectionRef,ut=Yi.getBadgeRef,ct=ee({isGuidelineMode:ji,maintainRelativeOrder:dn,proposedSections:Mi,existingSections:Hi,leftContainerRef:oi,rightContainerRef:Zn,scrollContainerRef:Un,sectionLeftRefs:Ui,sectionRightRefs:Qi,subSectionLeftRefs:it,subSectionRightRefs:tt,lhsBadgeRefs:Zi,rhsBadgeRefs:et,sectionRowRefs:ot,sectionRightRowRefs:nt,rhsTopSpacerRef:ei,rhsBottomSpacerRef:ni,lhsTopSpacerRef:ii,lhsBottomSpacerRef:ti,calculateLinesRef:Gn,setConnectedSections:Bn,setConnectedLines:Fn,cachedConnectedPositions:qn,closeMoreFunctionsPopup:Ci,setErrorToast:bn,moreFunctions:si,closeSummaryPopup:mi}),at=ct.isSideBySide,st=ct.isArrowVisible,dt=ct.setIsArrowVisible,vt=ct.isResizing,ft=ct.setIsResizing,pt=ct.isSideBySideLoading,gt=ct.activeSideBySideSection,ht=ct.scrollLock,mt=ct.sideBySideCacheRef,St=ct.isSideBySideRef,xt=ct.activeSideBySideRightSectionRef,Rt=ct.activeSideBySideSectionRef,bt=ct.sideBySideLineRef,yt=ct.highlightedClauseRefs,Ct=ct.clearClauseHighlight,wt=ct.resetSideBySide,Bt=ct.activateSideBySide,_t=u(Bt);a(function(){_t.current=Bt},[Bt]);var It=q({maintainRelativeOrder:!!dn,proposedSections:Mi,existingSections:Hi,activeSideBySideSection:gt,connectedSections:wn,resetSideBySide:wt,setConnectedSections:Bn,setConnectedLines:Fn,cachedConnectedPositions:qn,svgContainerRef:Pn,isAnimatingRef:Hn,animationTimerRef:zn,calculateLinesRef:Gn,sectionLeftRefs:Ui,sectionRightRefs:Qi,subSectionLeftRefs:it,subSectionRightRefs:tt}),Ft=It.expandedSections,Tt=It.setExpandedSections,Et=It.expandedSubSections,At=It.setExpandedSubSections,Dt=It.handleSubSectionToggle,kt=It.toggleSection,Ot=It.forceExpandCrossWiredSections,Pt=function(){var e,n;if(null!=gt){var i=null===(e=Ui.current[gt])||void 0===e?void 0:e.current,t=null===(n=Qi.current[gt])||void 0===n?void 0:n.current,o=Zn.current;if(i&&t&&o){var r=i.getBoundingClientRect(),l=t.getBoundingClientRect(),u=o.getBoundingClientRect(),c=r.top-u.top,a=l.top-u.top-c;o.scrollBy({top:a,behavior:"smooth"})}}},jt=s(function(e){null==e||e.stopPropagation(),An(function(e){var n=!e;return n&&requestAnimationFrame(function(){Pt()}),n})},[Pt]);a(function(){ln&&"off"!==Ji&&"0:0"!==Ji&&(mt.current=null,qn.current=[],requestAnimationFrame(function(){var e;null===(e=Gn.current)||void 0===e||e.call(Gn)}))},[ln,Ji]);var Lt=c(function(){var e=new Map,n=new Map,i=1;if(dn)Mi.forEach(function(n){!n.title&&!n.content||n.id&&e.set(n.id,i++)}),Hi.forEach(function(t){if(t.id&&!(!t.title&&!t.content)){var o=Mi.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(t.selfIndex)});if(o.length>0){var r=o.map(function(n){return e.get(n.id)}).filter(Boolean);n.set(t.id,r.join(", "))}else n.set(t.id,String(i++))}});else for(var t=Math.max(Mi.length,Hi.length),o=0;o<t;o++){var r=Mi[o],l=Hi[o];r?(e.set(r.id,i),l&&n.set(l.id,String(i)),i++):l&&n.set(l.id,String(i++))}return{leftNums:e,rightNums:n}},[Mi,Hi,dn]),Nt=Ni.analysis,Mt=b(null===(Ce=null===(ye=null==Nt?void 0:Nt.rule_difference_comparison)||void 0===ye?void 0:ye.summary)||void 0===Ce?void 0:Ce.overall_summary),Ht=!!Mt.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),zt=null!==(we=null==We?void 0:We.base_root_id)&&void 0!==we?we:"-1";null==We||We[zt];var Wt=yn?null!==(je=null!==(ke=Ze&&(null===(De=null==Ze?void 0:Ze[zt])||void 0===De?void 0:De.evaluation_result))&&void 0!==ke?ke:null===(Pe=null===(Oe=null==We?void 0:We.nodes)||void 0===Oe?void 0:Oe[zt])||void 0===Pe?void 0:Pe.evaluation_result)&&void 0!==je?je:null:null!==(Ae=null!==(Ie=Ze&&(null===(_e=null===(Be=null==Ze?void 0:Ze[zt])||void 0===Be?void 0:Be.evaluation_result)||void 0===_e?void 0:_e[0]))&&void 0!==Ie?Ie:null===(Ee=null===(Te=null===(Fe=null==We?void 0:We.nodes)||void 0===Fe?void 0:Fe[zt])||void 0===Te?void 0:Te.evaluation_result)||void 0===Ee?void 0:Ee[0])&&void 0!==Ae?Ae:null,qt=y(Wt),Gt=C(null!==(Me=null===(Ne=null===(Le=null==Wt?void 0:Wt.evaluation_outputs)||void 0===Le?void 0:Le.metadata)||void 0===Ne?void 0:Ne.label_color)&&void 0!==Me?Me:k);if(un){var Vt=un(qt);Vt&&(Gt=e(e({},Gt),{badgeBg:Vt.bg,badgeText:Vt.text,badgeBorder:Vt.border}))}var Kt=u(wt);a(function(){Kt.current=wt},[wt]);var Jt=u(yi);a(function(){Jt.current=yi},[yi]);var Yt=s(function(e,n,i,t,o,r){return or.current(e,n,i,t,o,r)},[]),Xt=s(function(e,n,i,t,o){return lr.current(e,n,i,t,o)},[]),$t=s(function(){return ur.current()},[]),Ut=s(function(e,n){return cr.current(e,n)},[]),Qt=s(function(e){return ar.current(e)},[]),Zt=s(function(e){return sr.current(e)},[]),eo=s(function(){return dr.current()},[]),no=s(function(){var e,n;Ct(),null===(e=Kt.current)||void 0===e||e.call(Kt),An(!1),Bn(new Set),Fn([]),qn.current=[],wo([]),_o(null),hi(O),null===(n=Jt.current)||void 0===n||n.call(Jt),requestAnimationFrame(function(){var e;null===(e=Gn.current)||void 0===e||e.call(Gn)})},[]),io=u(no);a(function(){io.current=no},[no]),a(function(){Je&&io.current()},[Je]);var to=c(function(){return{documents:null==We?void 0:We.documents,input_index_map:null==We?void 0:We.input_index_map}},[JSON.stringify(null==We?void 0:We.documents),JSON.stringify(null==We?void 0:We.input_index_map)]),oo=l(""),ro=oo[0],lo=oo[1],uo=u(We);a(function(){var e,n,i;uo.current=We;var t=null===(e=null==We?void 0:We.input_index_map)||void 0===e?void 0:e[0],o=null===(i=null===(n=null==We?void 0:We.documents)||void 0===n?void 0:n[t])||void 0===i?void 0:i.title;lo(o)},[We]);var co=u(Xn);a(function(){co.current=Xn},[Xn]);var ao=s(function(n,i,t,o,r,l,u){var c,a,s,d,v,f,p,g,h,m,S=b(null==i?void 0:i.id)||b(null==t?void 0:t.id)||"",x=(S?null===(c=co.current)||void 0===c?void 0:c[S]:null)||(null==i?void 0:i.cognitiveData)||(null==t?void 0:t.cognitiveData)||{section_id:S,decisioning:[],gap:[],relevance_score:0},R=null!==(s=null===(a=ot.current[o])||void 0===a?void 0:a.current)&&void 0!==s?s:null,y=function(){var n,r,l=(null==i?void 0:i.evaluationResult)||(null==t?void 0:t.evaluationResult)||null,u=function(n){var i=function(e){if(!e||"object"!=typeof e)return null;var n=null==e?void 0:e.deviation_entries;if(n&&"object"==typeof n){var i=Object.keys(n).sort(function(e,n){return Number(e)-Number(n)})[0];if(i&&n[i])return n[i]}var t=Object.keys(e).filter(function(e){return/^\d+$/.test(e)}).sort(function(e,n){return Number(e)-Number(n)});if(t.length&&e[t[0]])return e[t[0]];var o=null==e?void 0:e.deviations;if(o&&"object"==typeof o){var r=Object.keys(o).sort(function(e,n){return Number(e)-Number(n)})[0];if(r&&o[r])return o[r]}return null}(n);return i?e(e({},n),{deviation_summary:(null==n?void 0:n.deviation_summary)||(null==i?void 0:i.deviation_summary),deviation_title:(null==n?void 0:n.deviation_title)||(null==i?void 0:i.deviation_title),deviation_impact:(null==n?void 0:n.deviation_impact)||(null==i?void 0:i.deviation_impact),deviation_explanation:(null==n?void 0:n.deviation_explanation)||(null==i?void 0:i.deviation_explanation),evaluation_outputs:(null==n?void 0:n.evaluation_outputs)||(null==i?void 0:i.evaluation_outputs),cognitive_decisioning:(null==n?void 0:n.cognitive_decisioning)||(null==i?void 0:i.cognitive_decisioning)}):n};if(!("string"==typeof o&&o.includes(B)))return u(l);var c=o.split(B)[1];if(!c)return l;var a=(null==i?void 0:i.evaluationResult)||(null==t?void 0:t.evaluationResult)||{},s=(null===(n=null==a?void 0:a.deviation_entries)||void 0===n?void 0:n[c])||(null===(r=null==a?void 0:a.deviations)||void 0===r?void 0:r[c])||null;return s?e(e(e({},a),s),{deviation_summary:(null==s?void 0:s.deviation_summary)||(null==a?void 0:a.deviation_summary),deviation_title:(null==s?void 0:s.deviation_title)||(null==a?void 0:a.deviation_title),deviation_impact:(null==s?void 0:s.deviation_impact)||(null==a?void 0:a.deviation_impact),deviation_explanation:(null==s?void 0:s.deviation_explanation)||(null==a?void 0:a.deviation_explanation),evaluation_outputs:(null==s?void 0:s.evaluation_outputs)||(null==a?void 0:a.evaluation_outputs),cognitive_decisioning:(null==s?void 0:s.cognitive_decisioning)||(null==a?void 0:a.cognitive_decisioning)}):u(l)}(),C=(null!==(f=null===(v=null===(d=null==y?void 0:y.cognitive_decisioning)||void 0===d?void 0:d.decisioning_factors)||void 0===v?void 0:v.length)&&void 0!==f?f:0)>0||(null!==(h=null===(g=null===(p=null==y?void 0:y.cognitive_decisioning)||void 0===p?void 0:p.gaps_in_decision)||void 0===g?void 0:g.length)&&void 0!==h?h:0)>0,w=null!==(m=null==Xe?void 0:Xe.isLoading)&&void 0!==m&&m,_=!0;if(ji){var I=null==y?void 0:y.deviation_highlights;if(I&&"object"==typeof I)_=Object.values(I).some(function(e){return Array.isArray(e)&&e.length>0});else _=!1}return{isLoading:w&&!C,open:!0,sectionTitle:(null==i?void 0:i.title)?null==i?void 0:i.title:"No Counterpart",refSectionTitle:(null==t?void 0:t.title)?null==t?void 0:t.title:"No Counterpart",cognitiveData:x,anchorEl:n,sectionAnchorEl:R,badgeStyle:l||null,sectionIdx:o,docData:to,deviationData:y,isOrphan:!!r,hasGuidelineMatches:_}},[to,null==Xe?void 0:Xe.isLoading,ji]),so=s(function(e,n,i,t,o,r){var l;if(e.stopPropagation(),si.open&&si.sectionIdx===o)Ci();else{var u=e.currentTarget,c="left";(null===(l=Zn.current)||void 0===l?void 0:l.contains(u))&&(c="right");Ct(),St.current&&wt(),Bn(new Set),Fn([]),qn.current=[],yi(),gi.open?Mo():mi(),requestAnimationFrame(function(){var e=function(){var e,n,i,t;if("string"==typeof o&&o.includes(B)){var r=o.split(B),l="".concat(r[0]).concat(B).concat(r[1]);return"right"===c?null===(e=et.current[l])||void 0===e?void 0:e.current:null===(n=Zi.current[l])||void 0===n?void 0:n.current}return"right"===c?null===(i=et.current[o])||void 0===i?void 0:i.current:null===(t=Zi.current[o])||void 0===t?void 0:t.current}()||u;di(ao(e,n,t,o,i,r))})}},[si.open,si.sectionIdx,Ci,mi,ao]),vo=s(function(){var e=si.sectionIdx;si.isOrphan,Ci(),mi(),null!==e&&(Ot(e),Ct(),St.current&&wt(),Fn([]),qn.current=[],ji&&null!==e&&On(jo(e)),Bn(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){Gn.current&&Gn.current()},50))},[si.sectionIdx,si.isOrphan,Ci,mi,wt]),fo=s(function(){var e=Mn.current;if(e){Mn.current=null;var n=Mi.findIndex(function(n){return n.id===e}),i=Hi.findIndex(function(n){return n.id===e}),t=-1===n?w(Mi,e):null,o=-1===i?w(Hi,e):null,r=-1!==n?n:t?Number(t.split("-")[0]):-1,l=-1!==i?i:o?Number(o.split("-")[0]):-1,u=function(e,n,i,t){var o,r,l,u;return-1!==e?null!==(r=null===(o=i.current[e])||void 0===o?void 0:o.current)&&void 0!==r?r:null:n&&null!==(u=null===(l=t.current[n])||void 0===l?void 0:l.current)&&void 0!==u?u:null},c=function(e,n,i){void 0===i&&(i=30);var t=0,o=function(){var r=e();r&&0!==r.getBoundingClientRect().height?(yt.current.add(r),I(r,n)):t++<i&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(dn)-1!==r&&oi.current&&c(function(){return u(n,t,Ui,it)},oi.current),-1!==l&&Zn.current&&c(function(){return u(i,o,Qi,tt)},Zn.current);else{var a=Un.current;if(!a)return;c(function(){return-1!==r?u(n,t,Ui,it):u(i,o,Qi,tt)},a)}}},[Mi,Hi,dn,Ui,Qi,it,tt,oi,Zn,Un]),po=s(function(n){if(n){Ct(),wt(),Bn(new Set),Fn([]),qn.current=[],mi(),yi();var i=Mi.findIndex(function(e){return e.id===n}),t=Hi.findIndex(function(e){return e.id===n}),o=-1===i?w(Mi,n):null,r=-1===t?w(Hi,n):null;if(-1!==i||o||-1!==t||r){var l=-1!==i?i:o?Number(o.split("-")[0]):-1,u=-1!==t?t:r?Number(r.split("-")[0]):-1;Mn.current=n,Tt(function(n){var i,t=e({},n),o=!1;-1!==l&&(t[i=dn?"left-".concat(l):String(l)]||(t[i]=!0,o=!0));-1!==u&&(t[i=dn?"right-".concat(u):String(u)]||(t[i]=!0,o=!0));return o?t:n}),At(function(n){var i=e({},n),t=!1,l=function(e){for(var n=e.split("-"),o=n[0],r=1;r<n.length;r++)o+="-".concat(n[r]),i[o]||(i[o]=!0,t=!0)};return o&&l(o),r&&l(r),t?i:n}),setTimeout(function(){requestAnimationFrame(function(){Mn.current===n&&go.current()})},50)}else console.warn('scrollToAndHighlightClause: nodeId "'.concat(n,'" not found'))}},[Mi,Hi,dn,Tt,At,wt,mi,yi]),go=u(fo);a(function(){go.current=fo},[fo]);var ho=u(null);a(function(){if(_i){var e=wi.fields.find(function(e){return e.analysisKey===_i||e.key===_i});if(e){var n=Xi.current[e.key]||$i.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[_i,wi.fields]);var mo=s(function(e){var n,i,t,o,r,l,u,c,a,s=null===(n=null==Nt?void 0:Nt.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!s||!s[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var d=s[e],v=(null==d?void 0:d.relation)||(null===(t=null===(i=null==d?void 0:d.highlights)||void 0===i?void 0:i.ruleA_spans)||void 0===t?void 0:t.length)||(null===(r=null===(o=null==d?void 0:d.highlights)||void 0===o?void 0:o.ruleB_spans)||void 0===r?void 0:r.length)||(null==d?void 0:d.mappings)&&d.mappings.length>0;if(d.mappings){var f=d.mappings[0]||{};return{score:d.score,relation:f.relation||"",highlightsA:(null===(l=f.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(u=f.highlights)||void 0===u?void 0:u.ruleB_spans)||[],hasContent:!!v}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(c=d.highlights)||void 0===c?void 0:c.ruleA_spans)||[],highlightsB:(null===(a=d.highlights)||void 0===a?void 0:a.ruleB_spans)||[],hasContent:!!v}},[Nt]),So=U({proposedSections:Mi,existingSections:Hi,maintainRelativeOrder:dn,cognitiveMap:Xn,deviationData:Yn,treeData:We,resolvedComparisonConfig:wi,badgeStyleOverride:un}),xo=So.getSectionCompareStyle,Ro=So.getSubSectionCompareStyle,bo=So.getDeviationStyleByKey,yo=Z({containerRef:jn,leftContainerRef:oi,rightContainerRef:Zn,svgContainerRef:Pn,pathRefs:Wn,leftHeaderRef:Ln,rightHeaderRef:Nn,proposedSections:Mi,existingSections:Hi,visibleFields:zi,leftRefs:Xi,rightRefs:$i,sectionLeftRefs:Ui,sectionRightRefs:Qi,subSectionLeftRefs:it,subSectionRightRefs:tt,lhsBadgeRefs:Zi,rhsBadgeRefs:et,sectionRowRefs:ot,expandedSections:Ft,expandedSubSections:Et,connectedSections:wn,isSideBySide:at,activeSideBySideSection:gt,maintainRelativeOrder:dn,isGuidelineMode:ji,cognitiveMap:Xn,getSectionCompareStyle:xo,getSubSectionCompareStyle:Ro,getDeviationStyleByKey:bo,isArrowVisible:st,isAnimatingRef:Hn,isSideBySideRef:St,sideBySideCacheRef:mt,sideBySideLineRef:bt,activeSideBySideSectionRef:Rt,activeSideBySideRightSectionRef:xt,connectedLines:In,setConnectedLines:Fn,cachedConnectedPositions:qn,calculateLinesRef:Gn,resizeTimerRef:Vn,scrollLock:ht,scrollSyncLocked:En,handleResizeRef:Kn,activeProposed:Li,existingRule:Ni,analysisData:Nt,pendingScrollTargetRef:ri,pendingScrollCallbackRef:li,resolvedComparisonConfig:wi,getFieldData:mo}),Co=yo.lines,wo=yo.setLines,Bo=yo.overallConnector,_o=yo.setOverallConnector,Io=yo.svgDimensions,Fo=yo.handleColumnScroll;a(function(){gi.anchorEl&&requestAnimationFrame(function(){requestAnimationFrame(function(){var e;null===(e=Gn.current)||void 0===e||e.call(Gn)})})},[gi.anchorEl,En]);var To=s(function(){Ct(),An(!1),Tt({}),At({}),wt(),Bn(new Set),Fn([]),qn.current=[],mi(),yi(),Ci(),requestAnimationFrame(function(){Gn.current&&Gn.current()})},[Tt,At,wt,mi,yi,Ci]);a(function(){at||0!==wn.size||An(!1)},[at,wn]);var Eo=c(function(){return Object.values(Ft).some(Boolean)||Object.values(Et).some(Boolean)},[Ft,Et]),Ao=u(null),Do=u(0),ko=u(0),Oo=u(0),Po=Q({timerRef:Ao,ruleComponentRef:Qn,scrollContainerRef:Un,containerRef:jn,maintainRelativeOrder:dn,proposedSections:Mi,existingSections:Hi,isSideBySideRef:St,activeSideBySideSectionRef:Rt,activeSideBySideRightSectionRef:xt,sectionRowRefs:ot,sectionRightRowRefs:nt,sectionLeftRefs:Ui,sectionRightRefs:Qi,subSectionLeftRefs:it,subSectionRightRefs:tt,lhsBadgeRefs:Zi,rhsBadgeRefs:et,leftContainerRef:oi,rightContainerRef:Zn,calculateLinesRef:Gn,handleResizeRef:Kn,setIsResizing:ft,setIsArrowVisible:dt,sideBySideCacheRef:mt,cachedConnectedPositions:qn}).handleResize;a(function(){Kn.current=Po},[Po,Kn]),a(function(){var e=function(e,n,i,t,o){n.current=e.getBoundingClientRect().width;var r=new ResizeObserver(function(e){null!==i.current&&cancelAnimationFrame(i.current),i.current=requestAnimationFrame(function(){var r,l,u;i.current=null;var c=e[e.length-1];if(c){var a=null!==(u=null===(l=null===(r=c.borderBoxSize)||void 0===r?void 0:r[0])||void 0===l?void 0:l.inlineSize)&&void 0!==u?u:c.contentRect.width;Math.abs(a-n.current)<1?o():(n.current=a,t())}})});return r.observe(e),r},n={current:null},i={current:null},t={current:null},o=[],r=[n,i,t];return Qn.current&&o.push(e(Qn.current,Do,n,function(){return Kn.current()},function(){})),Un.current&&o.push(e(Un.current,ko,i,function(){return Kn.current()},function(){return Gn.current()})),jn.current&&o.push(e(jn.current,Oo,t,function(){return Kn.current()},function(){return Gn.current()})),function(){o.forEach(function(e){return e.disconnect()}),r.forEach(function(e){null!==e.current&&(cancelAnimationFrame(e.current),e.current=null)})}},[]),a(function(){St.current=at},[at]),a(function(){Rt.current=gt},[gt]);var jo=s(function(e){var n,i,t,o,r,l="",u="0";if("number"==typeof e)l=(null===(n=Mi[e])||void 0===n?void 0:n.nodeId)||(null===(i=Mi[e])||void 0===i?void 0:i.id)||"";else{var c=String(e).split(B);l=c[0],u=c[1]||"0"}var a=null===(t=null==Yn?void 0:Yn[l])||void 0===t?void 0:t.evaluation_result,s=Array.isArray(a)?a[parseInt(u,10)]:null==a?void 0:a[u];return!1===(null===(r=null===(o=null==s?void 0:s.evaluation_outputs)||void 0===o?void 0:o.guideline_flag)||void 0===r?void 0:r.rulebook_used)?1:0},[Mi,Yn]),Lo=s(function(e){var n,i,t=document.querySelectorAll('[id^="guideline-target-"], [data-web-gpt-active="true"]'),o=oi.current,r=Zn.current,l="string"==typeof e&&e.includes(B),u=e;if(l){var c=e.split(B);c.length>=2&&(u="".concat(c[0]).concat(B).concat(c[1]))}var a=(null===(n=Zi.current[u])||void 0===n?void 0:n.current)||(null===(i=Zi.current[e])||void 0===i?void 0:i.current);if(t.length>0&&a&&o&&r){var s=t[0];ii.current&&(ii.current.style.height="0px"),ei.current&&(ei.current.style.height="0px"),ti.current&&(ti.current.style.height="0px"),ni.current&&(ni.current.style.height="0px"),requestAnimationFrame(function(){var e=a.getBoundingClientRect(),n=s.getBoundingClientRect(),i=o.getBoundingClientRect(),t=r.getBoundingClientRect(),l=o.scrollTop+(e.top-i.top)+e.height/2,u=r.scrollTop+(n.top-t.top)+n.height/2,c=l-i.height/2,d=Math.max(0,c),v=o.scrollHeight-o.clientHeight,f=d>v?d-v:0,p=i.top+l-d,g=t.top+u-p,h=0;g<0&&(h=Math.abs(g),g=0);var m=r.scrollHeight-r.clientHeight+h,S=g>m?g-m:0;ti.current&&(ti.current.style.height="".concat(f,"px")),ei.current&&(ei.current.style.height="".concat(h,"px")),ni.current&&(ni.current.style.height="".concat(S,"px")),requestAnimationFrame(function(){o.scrollTo({top:d,behavior:"smooth"}),r.scrollTo({top:g,behavior:"smooth"}),Gn.current&&setTimeout(function(){return Gn.current()},50)})})}},[B]),No=s(function(){var e,n=si.sectionIdx,i=si.isOrphan;if(mi(),null!=n){var t="left";si.anchorEl&&(null===(e=Zn.current)||void 0===e?void 0:e.contains(si.anchorEl))&&(t="right"),Ot(n),ji&&(On(jo(n)),Bn(new Set([n]))),Bt(n,i,{sourceSide:t,onReady:function(){ji&&setTimeout(function(){return Lo(String(n))},150)}})}},[Bt,si.isOrphan,si.sectionIdx,si.anchorEl,mi,Ot,ji,Lo,jo]),Mo=s(function(){mi(),wt(),Bn(new Set),Fn([]),qn.current=[]},[mi,wt]),Ho=null!==si.sectionIdx&&wn.has(si.sectionIdx),zo=G({proposedSections:Mi,existingSections:Hi,parentDeviationRecord:Wi,expandedSections:Ft,maintainRelativeOrder:!!dn,scrollContainerRef:Un,leftContainerRef:oi,rightContainerRef:Zn,lhsBadgeRefs:Zi,rhsBadgeRefs:et}),Wo=zo.showDeviationNavigation,qo=zo.showOpenNodeRef,Go=zo.adjustScrollForPopup,Vo=s(function(e,n,i,t,o){var r,l="string"==typeof t?b(t).trim():b(null==t?void 0:t.deviation_summary).trim(),u=e.currentTarget;yi();var c="left";(null===(r=Zn.current)||void 0===r?void 0:r.contains(u))&&(c="right");var a=function(){var e,i,t,o;if("string"==typeof n&&n.includes(B)){var r=n.split(B),l="".concat(r[0]).concat(B).concat(r[1]);return"right"===c?null===(e=et.current[l])||void 0===e?void 0:e.current:null===(i=Zi.current[l])||void 0===i?void 0:i.current}return"right"===c?null===(t=et.current[n])||void 0===t?void 0:t.current:null===(o=Zi.current[n])||void 0===o?void 0:o.current};if(i&&!ji)return wt(),Bn(new Set),Fn([]),qn.current=[],void(l&&(Ot(n),requestAnimationFrame(function(){var e=a()||u;e&&(e.getBoundingClientRect().top>.8*window.innerHeight&&e.scrollIntoView({behavior:"smooth",block:"center"}));hi({open:!0,anchorEl:e,summary:t,displayImpact:o})})));Ot(n),ji&&(On(jo(n)),Bn(new Set([n]))),l?setTimeout(function(){Bt(n,i,{toggleIfSame:!1,sourceSide:c,onReady:function(){var e,i,r,l=a()||u;if(ji)setTimeout(function(){return Lo(n)},150);else if(l){var c=l.getBoundingClientRect();if(c.top>.8*window.innerHeight||c.top<100){var s=c.top-window.innerHeight/2;dn?(null===(e=oi.current)||void 0===e||e.scrollBy({top:s,behavior:"smooth"}),null===(i=Zn.current)||void 0===i||i.scrollBy({top:s,behavior:"smooth"})):null===(r=Un.current)||void 0===r||r.scrollBy({top:s,behavior:"smooth"})}}hi({open:!0,anchorEl:l,summary:t,displayImpact:o})}})},350):setTimeout(function(){Bt(n,i,{toggleIfSame:!1,sourceSide:c}),ji&&setTimeout(function(){return Lo(n)},150)},350)},[Bt,yi,hi,wt,Ot,ji,dn,Lo,Yn]),Ko=c(function(){var e;if(!en)return null;var n=null===(e=null==en?void 0:en.id)||void 0===e?void 0:e.split(":")[0];for(var i in Wi){if((Wi[i]||[]).some(function(e){return e.id===n}))return i}return null},[en,Wi]),Jo=u({id:null,triggerMs:null}),Yo=u(null);a(function(){if(null==en?void 0:en.id){var o=Number(en.trigger),r=Jo.current;if((null==r?void 0:r.id)!==en.id||(null==r?void 0:r.triggerMs)!==o){if(en.id.includes(":")&&/:\d+$/.test(en.id)){var l=en.id.split(":"),u=l[0],c=l[1],a=null!=c?c:"0",s="".concat(en.id,":").concat(o);Yo.current!==s&&(mi(),yi(),wt(),Bn(new Set),Fn([]),qn.current=[],Yo.current=s);var d=!1,v=0,f=null,p=null,g=!1,h=function(e,n){for(var i=function(e,t){if(!e)return null;if(n.includes(e.id)||n.includes(e.nodeId)||n.includes(e.contentId))return t;if(!Array.isArray(e.subsections))return null;for(var o=0;o<e.subsections.length;o++){var r=i(e.subsections[o],"".concat(t,"-").concat(o));if(r)return r}return null},t=0;t<e.length;t++){var o=i(e[t],String(t));if(o)return o}return null},m=function(){var r,l,c;if(!d){var s=function(){Jo.current={id:en.id,triggerMs:o}},S=null,x=null;for(var R in Wi){var b=Wi[R].find(function(e){var n;return e.id===u||e.nodeId===u||e.contentId===u||(null===(n=e.evaluationResult)||void 0===n?void 0:n.nodeId)===u});if(b){S=R,x=b;break}}if(x&&S){var y=Array.from(new Set([u,x.id,x.nodeId,x.contentId,null===(r=x.evaluationResult)||void 0===r?void 0:r.nodeId].filter(Boolean))),C=Mi.findIndex(function(e){return e.id===S}),w=Hi.findIndex(function(e){return e.id===S}),_=-1===C&&-1!==w,I=h(Mi,y),E=h(Hi,y);if(I&&!E&&!_){var A=I.split("-"),D=Number(A[0]);if(dn){var k=null===(c=null===(l=Mi[D])||void 0===l?void 0:l.refIndexes)||void 0===c?void 0:c[0],O=Hi.findIndex(function(e){return e.selfIndex===k});-1!==O&&(D=O)}E=n([D],A.slice(1),!0).join("-")}if(I||E){var P=I?Number(I.split("-")[0]):C,j=E?Number(E.split("-")[0]):w,L=j>=0?j:E?Number(E.split("-")[0]):-1,N=Mi[P],M=Hi[L],H=N&&!N.title&&!N.content,z=M&&!M.title&&!M.content,W=_||(!I&&!!E||H&&!z);if(W){if(!(dn?!!rr.current["right-".concat(j)]:!!rr.current[String(j)])&&j>=0)return kt(j,"right"),void(f=setTimeout(m,200))}else if(!(dn?!!rr.current["left-".concat(P)]:!!rr.current[String(P)])&&P>=0)return kt(P,"left"),void(f=setTimeout(m,200));var q=I||"",G=E||"",V=y.map(function(e){return"".concat(e).concat(B).concat(a)}),K=V[0],J=function(){for(var e,n,i=0,t=V;i<t.length;i++){var o=t[i],r=(null===(e=Zi.current[o])||void 0===e?void 0:e.current)||null,l=(null===(n=et.current[o])||void 0===n?void 0:n.current)||null;if(r||l)return{refId:o,left:r,right:l}}return{refId:K,left:null,right:null}},Y=function(e){return"".concat(e).concat(B).concat(q).concat(B).concat(G)};if(!g){Ot(Y(K)),g=!0,v=0;var X=function(){var e=J(),n=e.left,i=e.right;return W||!n&&!!i?i:n};return null==p||p(),void(f=setTimeout(function(){var e,n,i,t,o,r,l,u;d||(e=X,n=function(){d||(p=null,m())},t=0,o=null,r=null,l=performance.now(),u=function(){if(!d)if(performance.now()-l>3e3)n();else{var c=e();if(c&&0!==c.getBoundingClientRect().height){var a=c.getBoundingClientRect(),s=a.top,v=a.height,f=null!==o&&Math.abs(s-o)<.5,p=null!==r&&Math.abs(v-r)<.5;if(f&&p){if(++t>=5)return void n()}else t=0;o=s,r=v,i=requestAnimationFrame(u)}else i=requestAnimationFrame(u)}},i=requestAnimationFrame(u),p=function(){return cancelAnimationFrame(i)})},300))}var $=J(),U=$.refId,Q=$.left,Z=$.right,ee=Y(U);if(Q||Z){var ne=W||!Q&&!!Z,ie=ne?Z:Q,te=dn?ne?Zn.current:oi.current:Un.current;if(ie&&te){var oe=ie.getBoundingClientRect();if(0!==oe.height){var re=te.getBoundingClientRect(),le=oe.top-re.top+te.scrollTop-re.height/2+oe.height/2,ue=(null==I?void 0:I.includes("-"))||(null==E?void 0:E.includes("-")),ce=function(){return i(void 0,void 0,void 0,function(){var n,i,o,r,l,u,c,v,f,p;return t(this,function(t){switch(t.label){case 0:return d?[2]:(s(),n=ie instanceof Element?window.getComputedStyle(ie).color:"",[Q,Z].forEach(function(e){e&&(e.style.transition="box-shadow 300ms ease-in-out",e.style.boxShadow="0 0 10px ".concat(n))}),setTimeout(function(){[Q,Z].forEach(function(e){e&&(e.style.boxShadow="")})},2e3),i=(null===(c=null===(u=x.evaluationResult)||void 0===u?void 0:u.deviations)||void 0===c?void 0:c[a])||x,o=(null===(v=x.evaluationResult)||void 0===v?void 0:v.evaluation_outputs)||x.evaluation_outputs,!!Q&&!!Z||ji?(l=function(e,n){return Promise.race([e,new Promise(function(e){return setTimeout(e,n)})])},dn?[4,Promise.all([oi.current?l(T(oi.current),600):Promise.resolve(),Zn.current?l(T(Zn.current),600):Promise.resolve()])]:[3,2]):(r=ne?(null===(f=et.current[ue?U:j])||void 0===f?void 0:f.current)||Z:(null===(p=Zi.current[ue?U:P])||void 0===p?void 0:p.current)||Q,Go(r,function(){hi({open:!0,anchorEl:r,displayImpact:en.displayImpact,summary:e(e({},i),{evaluation_outputs:o})})},{skipScroll:!0}),null==nn||nn(),[2]));case 1:t.sent(),t.label=2;case 2:return ji&&(On(jo(ee)),Bn(new Set([ee]))),_t.current(ee,!1,{toggleIfSame:!1,sourceSide:_?"right":"left",onReady:function(){var n,t,o,r;s();var l=ne?(null===(n=et.current[U])||void 0===n?void 0:n.current)||Z:(null===(t=Zi.current[U])||void 0===t?void 0:t.current)||Q;if(ji)setTimeout(function(){return Lo(ee)},150);else{var u=(null===(o=Zi.current[U])||void 0===o?void 0:o.current)||Q,c=(null===(r=et.current[U])||void 0===r?void 0:r.current)||Z;u&&(u.style.scrollMarginTop="150px",u.scrollIntoView({behavior:"smooth",block:"start"})),c&&(c.style.scrollMarginTop="150px",c.scrollIntoView({behavior:"smooth",block:"start"}))}hi({open:!0,anchorEl:l,displayImpact:en.displayImpact,summary:e({},i)}),null==nn||nn()}}),[2]}})})};Math.abs(te.scrollTop-le)<=2?ce():F(te,le,ce)}else++v<30&&(f=setTimeout(m,100))}else++v<30&&(f=setTimeout(m,100))}else++v<30&&(f=setTimeout(m,100))}else++v<30&&(f=setTimeout(m,100))}else++v<30&&(f=setTimeout(m,100))}};return f=setTimeout(m,100),function(){d=!0,f&&clearTimeout(f),null==p||p()}}Jo.current={id:en.id,triggerMs:o},po(en.id);var S=Mi.findIndex(function(e){return e.id===en.id}),x=Hi.findIndex(function(e){return e.id===en.id});-1===S&&-1===x||setTimeout(function(){var e=-1!==S?S:x,n=-1===S;ji&&On(jo(e)),Bn(new Set([e])),_t.current(e,n,{sourceSide:n?"right":"left",onReady:function(){ji&&setTimeout(function(){return Lo(String(e))},150)}})},400)}}},[null==en?void 0:en.id,null==en?void 0:en.trigger,null==en?void 0:en.displayImpact,Wi,Mi,Hi,dn,hi,po,ji,jo,Lo]),a(function(){var n,i,t;if(gi.open){var o=gi.anchorEl;if(o&&!o.isConnected){var r=function(e){for(var n,i=0,t=Object.entries(e);i<t.length;i++){var r=t[i],l=r[0];if((null===(n=r[1].current)||void 0===n?void 0:n.textContent)===o.textContent)return l}return null},l=(null===(n=o.dataset)||void 0===n?void 0:n.deviationRefId)||r(Zi.current)||r(et.current);if(l){var u=(null===(i=et.current[l])||void 0===i?void 0:i.current)||(null===(t=Zi.current[l])||void 0===t?void 0:t.current);u&&u.isConnected&&hi(function(n){return e(e({},n),{anchorEl:u})})}}}},[gi.open,gi.anchorEl,En,wn,Ft]);var Xo=ci.open,$o=ci.sectionIdx,Uo=ci.isOrphan,Qo=ci.badgeStyle,Zo=ci.anchorEl,er=ci.sectionAnchorEl;a(function(){var n;if(Xe.isStreamingEnabled&&Xo&&null!=$o&&$o!==zt){var i="string"==typeof $o?$o.split(B)[0]:null,t=function(e,n){var i;if(!e||!Array.isArray(e))return null;for(var o=0,r=e;o<r.length;o++){var l=r[o];if(l.id===n)return l;if(null===(i=l.subsections)||void 0===i?void 0:i.length){var u=t(l.subsections,n);if(u)return u}}return null},o=i&&"string"==typeof i?t(Mi,i):null,r=i&&"string"==typeof i?t(Hi,i):null,l="number"==typeof $o?Mi[$o]||null:o||i&&((null===(n=null==We?void 0:We.nodes)||void 0===n?void 0:n[i])||(null==We?void 0:We[i]))||null,u="number"==typeof $o?Hi[$o]||null:r,c=ao(Zo,l,u,$o,Uo,Qo);ai(function(n){return n.open?b(n.cognitiveData)===b(c.cognitiveData)&&b(n.deviationData)===b(c.deviationData)&&n.sectionTitle===c.sectionTitle&&n.refSectionTitle===c.refSectionTitle?n:e(e(e({},n),c),{open:!0,anchorEl:n.anchorEl,sectionAnchorEl:n.sectionAnchorEl}):n})}},[Xo,$o,Uo,Qo,Zo,er,Mi,Hi,ao]);var nr=s(function(e){var n=e.section,i=e.keyPath,t=e.depth,r=void 0===t?0:t,l=e.columnKey,u=void 0===l?"left":l,c=e.parentNodeId,a=void 0===c?"":c,s=e.sectionOffset,d=e.rhsOrphanVisualIndexes;return o(K,{section:n,keyPath:i,depth:r,columnKey:u,parentNodeId:a,sectionOffset:s,rhsOrphanVisualIndexes:d})},[]),ir=c(function(){return Mi.map(function(e,n){var i,t,r=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),l=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return r&&l&&dn?null:o(J,{section:e,idx:n},null!==(t=null!==(i=null==e?void 0:e.layoutKey)&&void 0!==i?i:null==e?void 0:e.id)&&void 0!==t?t:"left-row-".concat(n))})},[Mi,dn]),tr=c(function(){return Hi.map(function(e,n){var i,t,r=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),l=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return r&&l&&dn?null:o(Y,{section:e,idx:n},null!==(t=null!==(i=null==e?void 0:e.layoutKey)&&void 0!==i?i:null==e?void 0:e.id)&&void 0!==t?t:"right-row-".concat(n))})},[Hi,dn]),or=u(so);a(function(){or.current=so},[so]);var rr=u(Ft);a(function(){rr.current=Ft},[Ft]);var lr=u(Vo);a(function(){lr.current=Vo},[Vo]);var ur=u(Mo);a(function(){ur.current=Mo},[Mo]);var cr=u(kt);a(function(){cr.current=kt},[kt]);var ar=u(Dt);a(function(){ar.current=Dt},[Dt]);var sr=u(nr);a(function(){sr.current=nr},[nr]);var dr=u(wt);a(function(){dr.current=wt},[wt]);var vr=c(function(){return{isGuidelineMode:ji,maintainRelativeOrder:!!dn,showDeviationBadges:gn,isProposingFix:on,proposingFixNodeId:rn,isRedlineFlow:ln,isSideBySide:at,activeSideBySideSection:gt,scrollSyncLocked:En,toggleScrollSyncLocked:jt,summaryPopupAnchorEl:gi.anchorEl,connectedSections:wn,proposedSections:Mi,existingSections:Hi,deviationNumberRegistry:qi,deviationParentRegistry:Gi,treeData:We,displayConfig:Xe,resolvedMarkdownStyles:$n,unifiedNumbering:Lt,expandedSections:Ft,expandedSubSections:Et,setExpandedSubSections:At,getSectionCompareStyle:xo,getSubSectionCompareStyle:Ro,getBadgeRef:ut,getSectionRowRef:rt,getSubSectionRef:lt,sectionLeftRefs:Ui,sectionRightRefs:Qi,sectionRowRefs:ot,sectionRightRowRefs:nt,subSectionLeftRefs:it,subSectionRightRefs:tt,lhsBadgeRefs:Zi,rhsBadgeRefs:et,openMoreFunctionsPopup:Yt,handleOpenSummaryPopup:Xt,openSummaryPopup:Xt,handleCloseSummaryPopup:$t,toggleSection:Ut,handleSubSectionToggle:Qt,renderSubSectionAccordion:Zt,resetSideBySide:eo,setConnectedSections:Bn,setConnectedLines:Fn,cachedConnectedPositions:qn,showDeviationNavigation:Wo,showOpenNodeRef:qo,deviationNodeIdToView:null==en?void 0:en.id,deviationTargetParentId:Ko,guidelinesData:cn,gptWebCitationConfig:an}},[ji,dn,gn,on,rn,ln,at,gt,En,jt,gi.anchorEl,wn,Mi,Hi,qi,Xe,$n,Lt,Ft,Et,At,xo,Ro,ut,rt,lt,Wo,qo,en,Ko,cn,an]),fr=b(ci.sectionTitle||Ai||Ti),pr=b(ji?ki||Oi||ci.refSectionTitle:ci.refSectionTitle||ki||Oi);return o($,e({value:vr},{children:r(d,e({ref:Qn,sx:{display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif',overflow:"visible",position:"relative"}},{children:[mn&&o(d,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:o(N,{})})),gi.open&&o(X,{open:gi.open,anchorEl:gi.anchorEl,containerEl:ho.current,clipTopEl:Ln.current,scrollContainerEl:Un.current,onClose:Mo,summary:gi.summary,displayImpact:gi.displayImpact,isScrollLocked:En}),o(L,{open:si.open,anchorEl:si.anchorEl,maintainRelativeOrder:!!dn,sectionTitle:si.sectionTitle,referenceSectionTitle:si.refSectionTitle,onClose:Ci,onOpenCognitiveCompare:Ri,onOpenSideBySide:No,onConnect:vo,isConnected:Ho,isOrphan:!ji&&!!si.isOrphan,isGuidelineMode:ji,hasGuidelineMatches:si.hasGuidelineMatches}),ci.open&&o(j,{open:ci.open,popupRef:xi,position:vi,popupConfig:Ue,onClose:function(){fi(null),ai(function(n){return e(e({},n),{open:!1})}),Si(null)},markdownStyles:Ke,sectionTitle:fr,referenceSectionTitle:pr,cognitiveData:ci.cognitiveData,anchorEl:ci.anchorEl,sectionAnchorEl:ci.sectionAnchorEl,scrollContainerEl:Un.current,badgeStyle:ci.badgeStyle,docData:ci.docData,deviationData:ci.deviationData,isLoading:ci.isLoading}),o(v,e({open:!!Rn,autoHideDuration:8e3,onClose:function(){return bn(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:o(f,e({onClose:function(){return bn(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:Rn}))})),o(V,{componentHeaderText:ze,displayConfig:Xe,maintainRelativeOrder:dn,onCollapseAll:To,showCollapseAll:Eo,onToggleView:function(e){Sn(!0),setTimeout(function(){vn(!e),null==$e||$e(!e),An(!1),wt(),mi(),Bn(new Set),Fn([]),qn.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){Sn(!1)},600)})})},50)}}),o(d,e({ref:Un,onScroll:Fo,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:dn?"visible":"auto",borderTop:Mt&&Ht?"none":"1.5px solid #EEF0F4"}},{children:o(d,e({sx:e({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},dn?{flex:1}:{})},{children:r(d,e({ref:jn,sx:e({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"100px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},dn?{flex:1,overflow:"visible"}:{})},{children:[o(ne,{svgContainerRef:Pn,svgDimensions:Io,isResizing:vt,overallConnector:Bo,rootDeviationStyle:Gt,lines:Co,isSideBySide:at,activeSideBySideSection:gt,isArrowVisible:st,maintainRelativeOrder:dn,proposedSections:Mi,existingSections:Hi,cognitivePopup:ci,activeBadgeId:pi,closeCognitivePopup:yi,setActiveBadgeId:Si,openCognitivePopupFromState:bi,buildSectionPopupState:ao,connectedLines:In,isGuidelineMode:ji,pathRefs:Wn}),r(d,e({sx:e({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},dn?{flex:1,overflow:"visible"}:{})},{children:[o(d,e({ref:Ln,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center",minHeight:"40px",overflow:"hidden",minWidth:0}},{children:o(p,e({title:Ti,placement:"top"},{children:o(g,e({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:Ti}))}))})),r(d,e({ref:oi,onScroll:Fo,sx:e({p:"12px",display:"flex",flexDirection:"column"},dn?{maxHeight:"calc(100vh - 250px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-180px",pr:"192px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[o("div",{ref:ii,style:{width:"100%",height:"0px",flexShrink:0}}),Ki&&ir,o("div",{ref:ti,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),o(d,e({ref:ho,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:o(d,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:r(d,e({onClick:function(n){n.stopPropagation(),ci.open&&pi===zt?yi():(Si(zt),bi(ao(n.currentTarget,{title:ro,content:"",evaluationResult:Wt,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,zt,!0,e(e({},Gt),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:Gt.badgeBg,color:Gt.badgeText,border:"1px solid ".concat(Gt.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=qt?qt:o(M,{}),o(d,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:o(x,{})})),o(S,{size:11,style:{transform:ci.open&&pi===zt?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),r(d,e({sx:e({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},dn?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[pt&&o(R,{sections:11}),o(d,e({ref:Nn,sx:e({p:"8px",bgcolor:ji?"#F1F3F5":"#F7F8FA",borderBottom:"1px solid #D7DCE2",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center"},dn?e({maxHeight:"calc(100vh - 250px)",overflowY:"auto",overflowX:"hidden",minHeight:0},ji?{"&::-webkit-scrollbar":{width:"6px",display:"block"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{background:"#CBD5E1",borderRadius:"10px"},"&::-webkit-scrollbar-thumb:hover":{background:"#94A3B8"},scrollbarWidth:"thin",scrollbarColor:"#CBD5E1 transparent"}:{"&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}):{})},{children:ji?r(h,e({value:kn,onChange:function(e,n){return On(n)},variant:"fullWidth",TabIndicatorProps:{sx:{display:"none"}},sx:{width:"100%",minHeight:"36px","& .MuiTab-root":{minHeight:"36px",px:1,py:0,borderRadius:"8px",fontSize:"14px",lineHeight:1,fontWeight:500,textTransform:"none",color:"#374151",minWidth:0,transition:"background-color 160ms ease, box-shadow 160ms ease"},"& .Mui-selected":{color:"#374151",bgcolor:"#FFFFFF"}}},{children:[o(m,{label:o(p,e({title:Oi,placement:"top"},{children:o(d,e({component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block",width:"100%"}},{children:"Redline Guidelines"}))}))}),o(m,{label:o(p,e({title:"Web & GPT Sources",placement:"top"},{children:o(d,e({component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block",width:"100%"}},{children:"Web & GPT Sources"}))}))})]})):o(p,e({title:Oi,placement:"top"},{children:o(g,e({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:Oi}))}))})),r(d,e({ref:Zn,onScroll:Fo,sx:e({p:ji?"0px":"12px",display:"flex",flexDirection:"column"},dn?e(e({maxHeight:"calc(100vh - 250px)"},!ji&&{flex:1}),{overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-150px",pl:"165px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}):{})},{children:[o("div",{ref:ei,style:{width:"100%",height:"0px",flexShrink:0}}),ji?0===kn?o(ie,{guidelinesData:cn,deviationData:Ze,connectedSections:wn,proposedSections:Mi}):o(te,{deviationData:Ze,connectedSections:wn,proposedSections:Mi}):Ki&&tr,o("div",{ref:ni,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))}))};export{oe as default};
1
+ import{__assign as e,__spreadArray as n,__awaiter as i,__generator as t}from"tslib";import{jsx as o,jsxs as r}from"react/jsx-runtime";import{useState as l,useRef as u,useMemo as c,useEffect as a,useCallback as s}from"react";import{Box as d,Snackbar as v,Alert as f,Tooltip as p,Typography as g,Tabs as h,Tab as m}from"@mui/material";import{ChevronDown as S}from"lucide-react";import{ButtonCognitiveIcon as x}from"../../assests/svg/ButtonCognitiveIcon.js";import R from"./OverlayComponent.js";import{safeStringify as b,extractDeviationScore as y,generateColorPalette as C,findKeyPathByNodeId as w,DEVIATION_BADGE_SEPARATOR as B,hasMeaningfulRedlineTags as _,scrollAndHighlightClause as I,scrollAndWait as F,waitForScrollIdle as T}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as E,DEFAULT_FIELD_CONFIG as A,DEFAULT_COMPARISON_CONFIG as D}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import{DEFAULT_DEVIAION_COLOR as k,EMPTY_SUMMARY_POPUP_STATE as O,DEFAULT_COMPONENT_HEADER_TEXT as P}from"./CognitiveCompareConstants.js";import j from"./CognitivePopup.js";import L from"./MoreFunctionsPopup.js";import N from"./LoaderComponent.js";import M from"./components/ThreeDotsLoader.js";import{useCognitiveTreeData as H}from"./hooks/useCompareData.js";import{useComparePopups as z}from"./hooks/useComparePopups.js";import{useSectionRefs as W}from"./hooks/useSectionRefs.js";import{useAccordionState as q}from"./hooks/useAccordionState.js";import{useDeviationNavigation as G}from"./hooks/useDeviationNavigation.js";import V from"./components/CompareHeader.js";import K from"./components/SubSectionAccordion.js";import J from"./components/LHSSectionRow.js";import Y from"./components/RHSSectionRow.js";import X from"./components/CognitiveSummaryPopup.js";import{CompareContextProvider as $}from"./CompareContext.js";import{useStyleHelpers as U}from"./hooks/useStyles.js";import{useResizeHandler as Q}from"./hooks/useResizeHandler.js";import{useLinesCalculator as Z}from"./hooks/useLinesCalculator.js";import{useSideBySide as ee}from"./hooks/useSideBySide.js";import ne from"./components/SvgConnectors.js";import ie from"./Guidelines/components/GuidelinePanel.js";import te from"./Guidelines/components/WebGptPanel.js";import{getVisibleGuidelineTargets as oe}from"./Guidelines/utils/guidelineTargets.js";var re=function(re){var le,ue,ce,ae,se,de,ve,fe,pe,ge,he,me,Se,xe,Re,be,ye,Ce,we,Be,_e,Ie,Fe,Te,Ee,Ae,De,ke,Oe,Pe,je,Le,Ne,Me,He,ze=re.componentHeaderText,We=void 0===ze?P:ze,qe=re.treeData,Ge=re.comparisonConfig,Ve=re.leftColumnTitleText,Ke=re.rightColumnTitleText,Je=re.markdownStyles,Ye=re.resetTrigger,Xe=re.displayConfig,$e=void 0===Xe?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1,displayEmailNotifier:!0,isStreamingEnabled:!1}:Xe,Ue=re.onMaintainRelativeOrderChange,Qe=re.popupConfig,Ze=re.deviationData,en=void 0===Ze?{}:Ze,nn=re.deviationNodeIdToView,tn=re.resetDeviationNodeId,on=re.isProposingFix,rn=void 0!==on&&on,ln=re.proposingFixNodeId,un=re.isRedlineFlow,cn=re.badgeStyleOverride,an=re.guidelinesData,sn=re.isGuidelineMode,dn=re.gptWebCitationConfig,vn=l($e.maintainRelativeOrder),fn=vn[0],pn=vn[1],gn=null!==(le=null==$e?void 0:$e.expandLevels)&&void 0!==le?le:0,hn=!!(null==$e?void 0:$e.expandAllSections),mn=!!fn||!!(null==$e?void 0:$e.showDeviationBadges),Sn=l(!1),xn=Sn[0],Rn=Sn[1],bn=l(null),yn=bn[0],Cn=bn[1],wn=l(null===(ce=null!==(ue=null==qe?void 0:qe.newEvaluationResult)&&void 0!==ue?ue:null==$e?void 0:$e.enableDeviationSchemaBackwardCompatibility)||void 0===ce||ce)[0],Bn=l(new Set),_n=Bn[0],In=Bn[1],Fn=l([]),Tn=Fn[0],En=Fn[1],An=l(!1),Dn=An[0],kn=An[1],On=l(0),Pn=On[0],jn=On[1],Ln=u(null),Nn=u(null),Mn=u(null),Hn=u(null),zn=u(null),Wn=u(!1),qn=u(null),Gn=u({}),Vn=u([]),Kn=u(function(){}),Jn=u(null),Yn=u(function(){}),Xn=c(function(){return JSON.stringify(en||{})},[JSON.stringify(en)]),$n=c(function(){return en||{}},[Xn]),Un=c(function(){return(null==qe?void 0:qe.cognitive_decisioning)||{}},[qe]),Qn=c(function(){return e(e({},E),Je)},[Je]),Zn=u(null),ei=u(null),ni=u(null),ii=u(null),ti=u(null),oi=u(null),ri=u(null),li=u(null),ui=u(null),ci=u(null),ai=z(Zn),si=ai.cognitivePopup,di=ai.setCognitivePopup,vi=ai.moreFunctions,fi=ai.setMoreFunctions,pi=ai.position,gi=ai.setPosition,hi=ai.activeBadgeId,mi=ai.summaryPopup,Si=ai.setSummaryPopup,xi=ai.closeSummaryPopup,Ri=ai.setActiveBadgeId,bi=ai.popupRef,yi=ai.handleOpenCognitiveCompare,Ci=ai.openCognitivePopupFromState,wi=ai.closeCognitivePopup,Bi=ai.closeMoreFunctionsPopup,_i=c(function(){var e,n,i,t,o,r,l;return{fields:null!==(e=null==Ge?void 0:Ge.fields)&&void 0!==e?e:A,thresholds:{high:null!==(i=null===(n=null==Ge?void 0:Ge.thresholds)||void 0===n?void 0:n.high)&&void 0!==i?i:D.thresholds.high,medium:null!==(o=null===(t=null==Ge?void 0:Ge.thresholds)||void 0===t?void 0:t.medium)&&void 0!==o?o:D.thresholds.medium,exact:null!==(l=null===(r=null==Ge?void 0:Ge.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:D.thresholds.exact}}},[Ge]),Ii=l(null),Fi=Ii[0];Ii[1];var Ti=null===(de=null===(ae=null==qe?void 0:qe.documents)||void 0===ae?void 0:ae[null===(se=null==qe?void 0:qe.input_index_map)||void 0===se?void 0:se[0]])||void 0===de?void 0:de.title,Ei=null===(pe=null===(ve=null==qe?void 0:qe.documents)||void 0===ve?void 0:ve[null===(fe=null==qe?void 0:qe.input_index_map)||void 0===fe?void 0:fe[1]])||void 0===pe?void 0:pe.title,Ai=b(Ve||Ti||"Uploaded Contract"),Di=null===(Se=null===(me=null===(ge=null==qe?void 0:qe.documents)||void 0===ge?void 0:ge[null===(he=null==qe?void 0:qe.input_index_map)||void 0===he?void 0:he[0]])||void 0===me?void 0:me.metadata)||void 0===Se?void 0:Se.file_name,ki=b(Di),Oi=null===(ye=null===(be=null===(xe=null==qe?void 0:qe.documents)||void 0===xe?void 0:xe[null===(Re=null==qe?void 0:qe.input_index_map)||void 0===Re?void 0:Re[1]])||void 0===be?void 0:be.metadata)||void 0===ye?void 0:ye.file_name,Pi=b(Oi),ji=b(Ke||Ei||"Reference Template"),Li=H(qe,fn,$n,_i,wn,an,sn),Ni=Li.isGuidelineMode,Mi=Li.activeProposed,Hi=Li.existingRule,zi=Li.proposedSections,Wi=Li.existingSections,qi=Li.visibleFields,Gi=Li.parentDeviationRecord,Vi=Li.deviationNumberRegistry,Ki=Li.deviationParentRegistry,Ji=Li.parseError;a(function(){Ji&&Cn("Failed to load comparison: ".concat(Ji))},[Ji]);var Yi=zi.length>0||Wi.length>0,Xi=c(function(){if(!un)return"off";var e=0,n=0,i=function(t){Array.isArray(t)&&t.forEach(function(t){var o,r=(null==t?void 0:t.content)||"";_(r)&&(e+=1,n+=String(r).length),(null===(o=null==t?void 0:t.subsections)||void 0===o?void 0:o.length)&&i(t.subsections)})};return i(zi),i(Wi),"".concat(e,":").concat(n)},[un,zi,Wi]);a(function(){if(zi.length||Wi.length)if(hn){var e={},n={},i=function(i,t){i.forEach(function(i,o){var r,l=fn?"".concat(t,"-").concat(o):String(o);e[l]=!0;var u=function(e,i){null==e||e.forEach(function(e,t){var o,r="".concat(i,"-").concat(t);n[r]=!0,(null===(o=e.subsections)||void 0===o?void 0:o.length)&&u(e.subsections,r)})};(null===(r=i.subsections)||void 0===r?void 0:r.length)&&u(i.subsections,String(o))})};i(zi,"left"),i(Wi,"right"),At(e),kt(n)}else if(gn>0){var t={},o={},r=function(e,n,i){e.forEach(function(e,r){var l;if(i>=1){var u=fn?"".concat(n,"-").concat(r):String(r);t[u]=!0}var c=function(e,n,t){t>i||null==e||e.forEach(function(e,i){var r,l="".concat(n,"-").concat(i);o[l]=!0,(null===(r=e.subsections)||void 0===r?void 0:r.length)&&c(e.subsections,l,t+1)})};(null===(l=e.subsections)||void 0===l?void 0:l.length)&&i>=2&&c(e.subsections,String(r),2)})};r(zi,"left",gn),r(Wi,"right",gn),At(t),kt(o)}},[hn,gn,zi,Wi,fn]);var $i=W(qi.map(function(e){return e.key}),Math.max(zi.length,Wi.length)),Ui=$i.leftRefs,Qi=$i.rightRefs,Zi=$i.sectionLeftRefs,et=$i.sectionRightRefs,nt=$i.lhsBadgeRefs,it=$i.rhsBadgeRefs,tt=$i.sectionRightRowRefs,ot=$i.subSectionLeftRefs,rt=$i.subSectionRightRefs,lt=$i.sectionRowRefs,ut=$i.getSectionRowRef,ct=$i.getSubSectionRef,at=$i.getBadgeRef,st=ee({isGuidelineMode:Ni,maintainRelativeOrder:fn,proposedSections:zi,existingSections:Wi,leftContainerRef:li,rightContainerRef:ni,scrollContainerRef:Zn,sectionLeftRefs:Zi,sectionRightRefs:et,subSectionLeftRefs:ot,subSectionRightRefs:rt,lhsBadgeRefs:nt,rhsBadgeRefs:it,sectionRowRefs:lt,sectionRightRowRefs:tt,rhsTopSpacerRef:ii,rhsBottomSpacerRef:ti,lhsTopSpacerRef:oi,lhsBottomSpacerRef:ri,calculateLinesRef:Kn,setConnectedSections:In,setConnectedLines:En,cachedConnectedPositions:Vn,closeMoreFunctionsPopup:Bi,setErrorToast:Cn,moreFunctions:vi,closeSummaryPopup:xi}),dt=st.isSideBySide,vt=st.isArrowVisible,ft=st.setIsArrowVisible,pt=st.isResizing,gt=st.setIsResizing,ht=st.isSideBySideLoading,mt=st.activeSideBySideSection,St=st.scrollLock,xt=st.sideBySideCacheRef,Rt=st.isSideBySideRef,bt=st.activeSideBySideRightSectionRef,yt=st.activeSideBySideSectionRef,Ct=st.sideBySideLineRef,wt=st.highlightedClauseRefs,Bt=st.clearClauseHighlight,_t=st.resetSideBySide,It=st.activateSideBySide,Ft=u(It);a(function(){Ft.current=It},[It]);var Tt=q({maintainRelativeOrder:!!fn,proposedSections:zi,existingSections:Wi,activeSideBySideSection:mt,connectedSections:_n,resetSideBySide:_t,setConnectedSections:In,setConnectedLines:En,cachedConnectedPositions:Vn,svgContainerRef:Ln,isAnimatingRef:Wn,animationTimerRef:qn,calculateLinesRef:Kn,sectionLeftRefs:Zi,sectionRightRefs:et,subSectionLeftRefs:ot,subSectionRightRefs:rt}),Et=Tt.expandedSections,At=Tt.setExpandedSections,Dt=Tt.expandedSubSections,kt=Tt.setExpandedSubSections,Ot=Tt.handleSubSectionToggle,Pt=Tt.toggleSection,jt=Tt.forceExpandCrossWiredSections,Lt=function(){var e,n;if(null!=mt){var i=null===(e=Zi.current[mt])||void 0===e?void 0:e.current,t=null===(n=et.current[mt])||void 0===n?void 0:n.current,o=ni.current;if(i&&t&&o){var r=i.getBoundingClientRect(),l=t.getBoundingClientRect(),u=o.getBoundingClientRect(),c=r.top-u.top,a=l.top-u.top-c;o.scrollBy({top:a,behavior:"smooth"})}}},Nt=s(function(e){null==e||e.stopPropagation(),kn(function(e){var n=!e;return n&&requestAnimationFrame(function(){Lt()}),n})},[Lt]);a(function(){un&&"off"!==Xi&&"0:0"!==Xi&&(xt.current=null,Vn.current=[],requestAnimationFrame(function(){var e;null===(e=Kn.current)||void 0===e||e.call(Kn)}))},[un,Xi]);var Mt=c(function(){var e=new Map,n=new Map,i=1;if(fn)zi.forEach(function(n){!n.title&&!n.content||n.id&&e.set(n.id,i++)}),Wi.forEach(function(t){if(t.id&&!(!t.title&&!t.content)){var o=zi.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(t.selfIndex)});if(o.length>0){var r=o.map(function(n){return e.get(n.id)}).filter(Boolean);n.set(t.id,r.join(", "))}else n.set(t.id,String(i++))}});else for(var t=Math.max(zi.length,Wi.length),o=0;o<t;o++){var r=zi[o],l=Wi[o];r?(e.set(r.id,i),l&&n.set(l.id,String(i)),i++):l&&n.set(l.id,String(i++))}return{leftNums:e,rightNums:n}},[zi,Wi,fn]),Ht=Hi.analysis,zt=b(null===(we=null===(Ce=null==Ht?void 0:Ht.rule_difference_comparison)||void 0===Ce?void 0:Ce.summary)||void 0===we?void 0:we.overall_summary),Wt=!!zt.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),qt=null!==(Be=null==qe?void 0:qe.base_root_id)&&void 0!==Be?Be:"-1";null==qe||qe[qt];var Gt=wn?null!==(Le=null!==(Oe=en&&(null===(ke=null==en?void 0:en[qt])||void 0===ke?void 0:ke.evaluation_result))&&void 0!==Oe?Oe:null===(je=null===(Pe=null==qe?void 0:qe.nodes)||void 0===Pe?void 0:Pe[qt])||void 0===je?void 0:je.evaluation_result)&&void 0!==Le?Le:null:null!==(De=null!==(Fe=en&&(null===(Ie=null===(_e=null==en?void 0:en[qt])||void 0===_e?void 0:_e.evaluation_result)||void 0===Ie?void 0:Ie[0]))&&void 0!==Fe?Fe:null===(Ae=null===(Ee=null===(Te=null==qe?void 0:qe.nodes)||void 0===Te?void 0:Te[qt])||void 0===Ee?void 0:Ee.evaluation_result)||void 0===Ae?void 0:Ae[0])&&void 0!==De?De:null,Vt=y(Gt),Kt=C(null!==(He=null===(Me=null===(Ne=null==Gt?void 0:Gt.evaluation_outputs)||void 0===Ne?void 0:Ne.metadata)||void 0===Me?void 0:Me.label_color)&&void 0!==He?He:k);if(cn){var Jt=cn(Vt);Jt&&(Kt=e(e({},Kt),{badgeBg:Jt.bg,badgeText:Jt.text,badgeBorder:Jt.border}))}var Yt=u(_t);a(function(){Yt.current=_t},[_t]);var Xt=u(wi);a(function(){Xt.current=wi},[wi]);var $t=s(function(e,n,i,t,o,r){return lr.current(e,n,i,t,o,r)},[]),Ut=s(function(e,n,i,t,o){return cr.current(e,n,i,t,o)},[]),Qt=s(function(){return ar.current()},[]),Zt=s(function(e,n){return sr.current(e,n)},[]),eo=s(function(e){return dr.current(e)},[]),no=s(function(e){return vr.current(e)},[]),io=s(function(){return fr.current()},[]),to=s(function(){var e,n;Bt(),null===(e=Yt.current)||void 0===e||e.call(Yt),kn(!1),In(new Set),En([]),Vn.current=[],_o([]),Fo(null),Si(O),null===(n=Xt.current)||void 0===n||n.call(Xt),requestAnimationFrame(function(){var e;null===(e=Kn.current)||void 0===e||e.call(Kn)})},[]),oo=u(to);a(function(){oo.current=to},[to]),a(function(){Ye&&oo.current()},[Ye]);var ro=c(function(){return{documents:null==qe?void 0:qe.documents,input_index_map:null==qe?void 0:qe.input_index_map}},[JSON.stringify(null==qe?void 0:qe.documents),JSON.stringify(null==qe?void 0:qe.input_index_map)]),lo=l(""),uo=lo[0],co=lo[1],ao=u(qe);a(function(){var e,n,i;ao.current=qe;var t=null===(e=null==qe?void 0:qe.input_index_map)||void 0===e?void 0:e[0],o=null===(i=null===(n=null==qe?void 0:qe.documents)||void 0===n?void 0:n[t])||void 0===i?void 0:i.title;co(o)},[qe]);var so=u(Un);a(function(){so.current=Un},[Un]);var vo=s(function(n,i,t,o,r,l,u){var c,a,s,d,v,f,p,g,h,m,S=b(null==i?void 0:i.id)||b(null==t?void 0:t.id)||"",x=(S?null===(c=so.current)||void 0===c?void 0:c[S]:null)||(null==i?void 0:i.cognitiveData)||(null==t?void 0:t.cognitiveData)||{section_id:S,decisioning:[],gap:[],relevance_score:0},R=null!==(s=null===(a=lt.current[o])||void 0===a?void 0:a.current)&&void 0!==s?s:null,y=function(){var n,r,l=(null==i?void 0:i.evaluationResult)||(null==t?void 0:t.evaluationResult)||null,u=function(n){var i=function(e){if(!e||"object"!=typeof e)return null;var n=null==e?void 0:e.deviation_entries;if(n&&"object"==typeof n){var i=Object.keys(n).sort(function(e,n){return Number(e)-Number(n)})[0];if(i&&n[i])return n[i]}var t=Object.keys(e).filter(function(e){return/^\d+$/.test(e)}).sort(function(e,n){return Number(e)-Number(n)});if(t.length&&e[t[0]])return e[t[0]];var o=null==e?void 0:e.deviations;if(o&&"object"==typeof o){var r=Object.keys(o).sort(function(e,n){return Number(e)-Number(n)})[0];if(r&&o[r])return o[r]}return null}(n);return i?e(e({},n),{deviation_summary:(null==n?void 0:n.deviation_summary)||(null==i?void 0:i.deviation_summary),deviation_title:(null==n?void 0:n.deviation_title)||(null==i?void 0:i.deviation_title),deviation_impact:(null==n?void 0:n.deviation_impact)||(null==i?void 0:i.deviation_impact),deviation_explanation:(null==n?void 0:n.deviation_explanation)||(null==i?void 0:i.deviation_explanation),evaluation_outputs:(null==n?void 0:n.evaluation_outputs)||(null==i?void 0:i.evaluation_outputs),cognitive_decisioning:(null==n?void 0:n.cognitive_decisioning)||(null==i?void 0:i.cognitive_decisioning)}):n};if(!("string"==typeof o&&o.includes(B)))return u(l);var c=o.split(B)[1];if(!c)return l;var a=(null==i?void 0:i.evaluationResult)||(null==t?void 0:t.evaluationResult)||{},s=(null===(n=null==a?void 0:a.deviation_entries)||void 0===n?void 0:n[c])||(null===(r=null==a?void 0:a.deviations)||void 0===r?void 0:r[c])||null;return s?e(e(e({},a),s),{deviation_summary:(null==s?void 0:s.deviation_summary)||(null==a?void 0:a.deviation_summary),deviation_title:(null==s?void 0:s.deviation_title)||(null==a?void 0:a.deviation_title),deviation_impact:(null==s?void 0:s.deviation_impact)||(null==a?void 0:a.deviation_impact),deviation_explanation:(null==s?void 0:s.deviation_explanation)||(null==a?void 0:a.deviation_explanation),evaluation_outputs:(null==s?void 0:s.evaluation_outputs)||(null==a?void 0:a.evaluation_outputs),cognitive_decisioning:(null==s?void 0:s.cognitive_decisioning)||(null==a?void 0:a.cognitive_decisioning)}):u(l)}(),C=(null!==(f=null===(v=null===(d=null==y?void 0:y.cognitive_decisioning)||void 0===d?void 0:d.decisioning_factors)||void 0===v?void 0:v.length)&&void 0!==f?f:0)>0||(null!==(h=null===(g=null===(p=null==y?void 0:y.cognitive_decisioning)||void 0===p?void 0:p.gaps_in_decision)||void 0===g?void 0:g.length)&&void 0!==h?h:0)>0,w=null!==(m=null==$e?void 0:$e.isLoading)&&void 0!==m&&m,_=!0;if(Ni){var I=null==y?void 0:y.deviation_highlights;if(I&&"object"==typeof I)_=Object.values(I).some(function(e){return Array.isArray(e)&&e.length>0});else _=!1}return{isLoading:w&&!C,open:!0,sectionTitle:(null==i?void 0:i.title)?null==i?void 0:i.title:"No Counterpart",refSectionTitle:(null==t?void 0:t.title)?null==t?void 0:t.title:"No Counterpart",cognitiveData:x,anchorEl:n,sectionAnchorEl:R,badgeStyle:l||null,sectionIdx:o,docData:ro,deviationData:y,isOrphan:!!r,hasGuidelineMatches:_}},[ro,null==$e?void 0:$e.isLoading,Ni]),fo=s(function(e,n,i,t,o,r){var l;if(e.stopPropagation(),vi.open&&vi.sectionIdx===o)Bi();else{var u=e.currentTarget,c="left";(null===(l=ni.current)||void 0===l?void 0:l.contains(u))&&(c="right");Bt(),Rt.current&&_t(),In(new Set),En([]),Vn.current=[],wi(),mi.open?zo():xi(),requestAnimationFrame(function(){var e=function(){var e,n,i,t;if("string"==typeof o&&o.includes(B)){var r=o.split(B),l="".concat(r[0]).concat(B).concat(r[1]);return"right"===c?null===(e=it.current[l])||void 0===e?void 0:e.current:null===(n=nt.current[l])||void 0===n?void 0:n.current}return"right"===c?null===(i=it.current[o])||void 0===i?void 0:i.current:null===(t=nt.current[o])||void 0===t?void 0:t.current}()||u;fi(vo(e,n,t,o,i,r))})}},[vi.open,vi.sectionIdx,Bi,xi,vo]),po=s(function(){var e=vi.sectionIdx;vi.isOrphan,Bi(),xi(),null!==e&&(jt(e),Bt(),Rt.current&&_t(),En([]),Vn.current=[],Ni&&null!==e&&jn(No(e)),In(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){Kn.current&&Kn.current()},50))},[vi.sectionIdx,vi.isOrphan,Bi,xi,_t]),go=s(function(){var e=zn.current;if(e){zn.current=null;var n=zi.findIndex(function(n){return n.id===e}),i=Wi.findIndex(function(n){return n.id===e}),t=-1===n?w(zi,e):null,o=-1===i?w(Wi,e):null,r=-1!==n?n:t?Number(t.split("-")[0]):-1,l=-1!==i?i:o?Number(o.split("-")[0]):-1,u=function(e,n,i,t){var o,r,l,u;return-1!==e?null!==(r=null===(o=i.current[e])||void 0===o?void 0:o.current)&&void 0!==r?r:null:n&&null!==(u=null===(l=t.current[n])||void 0===l?void 0:l.current)&&void 0!==u?u:null},c=function(e,n,i){void 0===i&&(i=30);var t=0,o=function(){var r=e();r&&0!==r.getBoundingClientRect().height?(wt.current.add(r),I(r,n)):t++<i&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(fn)-1!==r&&li.current&&c(function(){return u(n,t,Zi,ot)},li.current),-1!==l&&ni.current&&c(function(){return u(i,o,et,rt)},ni.current);else{var a=Zn.current;if(!a)return;c(function(){return-1!==r?u(n,t,Zi,ot):u(i,o,et,rt)},a)}}},[zi,Wi,fn,Zi,et,ot,rt,li,ni,Zn]),ho=s(function(n){if(n){Bt(),_t(),In(new Set),En([]),Vn.current=[],xi(),wi();var i=zi.findIndex(function(e){return e.id===n}),t=Wi.findIndex(function(e){return e.id===n}),o=-1===i?w(zi,n):null,r=-1===t?w(Wi,n):null;if(-1!==i||o||-1!==t||r){var l=-1!==i?i:o?Number(o.split("-")[0]):-1,u=-1!==t?t:r?Number(r.split("-")[0]):-1;zn.current=n,At(function(n){var i,t=e({},n),o=!1;-1!==l&&(t[i=fn?"left-".concat(l):String(l)]||(t[i]=!0,o=!0));-1!==u&&(t[i=fn?"right-".concat(u):String(u)]||(t[i]=!0,o=!0));return o?t:n}),kt(function(n){var i=e({},n),t=!1,l=function(e){for(var n=e.split("-"),o=n[0],r=1;r<n.length;r++)o+="-".concat(n[r]),i[o]||(i[o]=!0,t=!0)};return o&&l(o),r&&l(r),t?i:n}),setTimeout(function(){requestAnimationFrame(function(){zn.current===n&&mo.current()})},50)}else console.warn('scrollToAndHighlightClause: nodeId "'.concat(n,'" not found'))}},[zi,Wi,fn,At,kt,_t,xi,wi]),mo=u(go);a(function(){mo.current=go},[go]);var So=u(null);a(function(){if(Fi){var e=_i.fields.find(function(e){return e.analysisKey===Fi||e.key===Fi});if(e){var n=Ui.current[e.key]||Qi.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[Fi,_i.fields]);var xo=s(function(e){var n,i,t,o,r,l,u,c,a,s=null===(n=null==Ht?void 0:Ht.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!s||!s[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var d=s[e],v=(null==d?void 0:d.relation)||(null===(t=null===(i=null==d?void 0:d.highlights)||void 0===i?void 0:i.ruleA_spans)||void 0===t?void 0:t.length)||(null===(r=null===(o=null==d?void 0:d.highlights)||void 0===o?void 0:o.ruleB_spans)||void 0===r?void 0:r.length)||(null==d?void 0:d.mappings)&&d.mappings.length>0;if(d.mappings){var f=d.mappings[0]||{};return{score:d.score,relation:f.relation||"",highlightsA:(null===(l=f.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(u=f.highlights)||void 0===u?void 0:u.ruleB_spans)||[],hasContent:!!v}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(c=d.highlights)||void 0===c?void 0:c.ruleA_spans)||[],highlightsB:(null===(a=d.highlights)||void 0===a?void 0:a.ruleB_spans)||[],hasContent:!!v}},[Ht]),Ro=U({proposedSections:zi,existingSections:Wi,maintainRelativeOrder:fn,cognitiveMap:Un,deviationData:$n,treeData:qe,resolvedComparisonConfig:_i,badgeStyleOverride:cn}),bo=Ro.getSectionCompareStyle,yo=Ro.getSubSectionCompareStyle,Co=Ro.getDeviationStyleByKey,wo=Z({containerRef:Nn,leftContainerRef:li,rightContainerRef:ni,svgContainerRef:Ln,pathRefs:Gn,leftHeaderRef:Mn,rightHeaderRef:Hn,proposedSections:zi,existingSections:Wi,visibleFields:qi,leftRefs:Ui,rightRefs:Qi,sectionLeftRefs:Zi,sectionRightRefs:et,subSectionLeftRefs:ot,subSectionRightRefs:rt,lhsBadgeRefs:nt,rhsBadgeRefs:it,sectionRowRefs:lt,expandedSections:Et,expandedSubSections:Dt,connectedSections:_n,isSideBySide:dt,activeSideBySideSection:mt,maintainRelativeOrder:fn,isGuidelineMode:Ni,cognitiveMap:Un,getSectionCompareStyle:bo,getSubSectionCompareStyle:yo,getDeviationStyleByKey:Co,isArrowVisible:vt,isAnimatingRef:Wn,isSideBySideRef:Rt,sideBySideCacheRef:xt,sideBySideLineRef:Ct,activeSideBySideSectionRef:yt,activeSideBySideRightSectionRef:bt,connectedLines:Tn,setConnectedLines:En,cachedConnectedPositions:Vn,calculateLinesRef:Kn,resizeTimerRef:Jn,scrollLock:St,scrollSyncLocked:Dn,handleResizeRef:Yn,activeProposed:Mi,existingRule:Hi,analysisData:Ht,pendingScrollTargetRef:ui,pendingScrollCallbackRef:ci,resolvedComparisonConfig:_i,getFieldData:xo}),Bo=wo.lines,_o=wo.setLines,Io=wo.overallConnector,Fo=wo.setOverallConnector,To=wo.svgDimensions,Eo=wo.handleColumnScroll;a(function(){mi.anchorEl&&requestAnimationFrame(function(){requestAnimationFrame(function(){var e;null===(e=Kn.current)||void 0===e||e.call(Kn)})})},[mi.anchorEl,Dn]);var Ao=s(function(){Bt(),kn(!1),At({}),kt({}),_t(),In(new Set),En([]),Vn.current=[],xi(),wi(),Bi(),requestAnimationFrame(function(){Kn.current&&Kn.current()})},[At,kt,_t,xi,wi,Bi]);a(function(){dt||0!==_n.size||kn(!1)},[dt,_n]);var Do=c(function(){return Object.values(Et).some(Boolean)||Object.values(Dt).some(Boolean)},[Et,Dt]),ko=u(null),Oo=u(0),Po=u(0),jo=u(0),Lo=Q({timerRef:ko,ruleComponentRef:ei,scrollContainerRef:Zn,containerRef:Nn,maintainRelativeOrder:fn,proposedSections:zi,existingSections:Wi,isSideBySideRef:Rt,activeSideBySideSectionRef:yt,activeSideBySideRightSectionRef:bt,sectionRowRefs:lt,sectionRightRowRefs:tt,sectionLeftRefs:Zi,sectionRightRefs:et,subSectionLeftRefs:ot,subSectionRightRefs:rt,lhsBadgeRefs:nt,rhsBadgeRefs:it,leftContainerRef:li,rightContainerRef:ni,calculateLinesRef:Kn,handleResizeRef:Yn,setIsResizing:gt,setIsArrowVisible:ft,sideBySideCacheRef:xt,cachedConnectedPositions:Vn}).handleResize;a(function(){Yn.current=Lo},[Lo,Yn]),a(function(){var e=function(e,n,i,t,o){n.current=e.getBoundingClientRect().width;var r=new ResizeObserver(function(e){null!==i.current&&cancelAnimationFrame(i.current),i.current=requestAnimationFrame(function(){var r,l,u;i.current=null;var c=e[e.length-1];if(c){var a=null!==(u=null===(l=null===(r=c.borderBoxSize)||void 0===r?void 0:r[0])||void 0===l?void 0:l.inlineSize)&&void 0!==u?u:c.contentRect.width;Math.abs(a-n.current)<1?o():(n.current=a,t())}})});return r.observe(e),r},n={current:null},i={current:null},t={current:null},o=[],r=[n,i,t];return ei.current&&o.push(e(ei.current,Oo,n,function(){return Yn.current()},function(){})),Zn.current&&o.push(e(Zn.current,Po,i,function(){return Yn.current()},function(){return Kn.current()})),Nn.current&&o.push(e(Nn.current,jo,t,function(){return Yn.current()},function(){return Kn.current()})),function(){o.forEach(function(e){return e.disconnect()}),r.forEach(function(e){null!==e.current&&(cancelAnimationFrame(e.current),e.current=null)})}},[]),a(function(){Rt.current=dt},[dt]),a(function(){yt.current=mt},[mt]);var No=s(function(e){var n,i,t,o,r,l="",u="0";if("number"==typeof e)l=(null===(n=zi[e])||void 0===n?void 0:n.nodeId)||(null===(i=zi[e])||void 0===i?void 0:i.id)||"";else{var c=String(e).split(B);l=c[0],u=c[1]||"0"}var a=null===(t=null==$n?void 0:$n[l])||void 0===t?void 0:t.evaluation_result,s=Array.isArray(a)?a[parseInt(u,10)]:null==a?void 0:a[u];return!1===(null===(r=null===(o=null==s?void 0:s.evaluation_outputs)||void 0===o?void 0:o.guideline_flag)||void 0===r?void 0:r.rulebook_used)?1:0},[zi,$n]),Mo=s(function(e){var n,i,t=li.current,o=ni.current,r=oe(o),l="string"==typeof e&&e.includes(B),u=e;if(l){var c=e.split(B);c.length>=2&&(u="".concat(c[0]).concat(B).concat(c[1]))}var a=(null===(n=nt.current[u])||void 0===n?void 0:n.current)||(null===(i=nt.current[e])||void 0===i?void 0:i.current);if(r.length>0&&a&&t&&o){var s=r[0];oi.current&&(oi.current.style.height="0px"),ii.current&&(ii.current.style.height="0px"),ri.current&&(ri.current.style.height="0px"),ti.current&&(ti.current.style.height="0px"),requestAnimationFrame(function(){var e=a.getBoundingClientRect(),n=s.getBoundingClientRect(),i=t.getBoundingClientRect(),r=o.getBoundingClientRect(),l=t.scrollTop+(e.top-i.top)+e.height/2,u=o.scrollTop+(n.top-r.top)+n.height/2,c=l-i.height/2,d=Math.max(0,c),v=t.scrollHeight-t.clientHeight,f=d>v?d-v:0,p=i.top+l-d,g=r.top+u-p,h=0;g<0&&(h=Math.abs(g),g=0);var m=o.scrollHeight-o.clientHeight+h,S=g>m?g-m:0;ri.current&&(ri.current.style.height="".concat(f,"px")),ii.current&&(ii.current.style.height="".concat(h,"px")),ti.current&&(ti.current.style.height="".concat(S,"px")),requestAnimationFrame(function(){t.scrollTo({top:d,behavior:"smooth"}),o.scrollTo({top:g,behavior:"smooth"}),Kn.current&&setTimeout(function(){return Kn.current()},50)})})}},[B]),Ho=s(function(){var e,n=vi.sectionIdx,i=vi.isOrphan;if(xi(),null!=n){var t="left";vi.anchorEl&&(null===(e=ni.current)||void 0===e?void 0:e.contains(vi.anchorEl))&&(t="right"),jt(n),Ni&&(jn(No(n)),In(new Set([n]))),It(n,i,{sourceSide:t,onReady:function(){Ni&&setTimeout(function(){return Mo(String(n))},150)}})}},[It,vi.isOrphan,vi.sectionIdx,vi.anchorEl,xi,jt,Ni,Mo,No]),zo=s(function(){xi(),_t(),In(new Set),En([]),Vn.current=[]},[xi,_t]),Wo=null!==vi.sectionIdx&&_n.has(vi.sectionIdx),qo=G({proposedSections:zi,existingSections:Wi,parentDeviationRecord:Gi,expandedSections:Et,maintainRelativeOrder:!!fn,scrollContainerRef:Zn,leftContainerRef:li,rightContainerRef:ni,lhsBadgeRefs:nt,rhsBadgeRefs:it}),Go=qo.showDeviationNavigation,Vo=qo.showOpenNodeRef,Ko=qo.adjustScrollForPopup,Jo=s(function(e,n,i,t,o){var r,l="string"==typeof t?b(t).trim():b(null==t?void 0:t.deviation_summary).trim(),u=e.currentTarget;wi();var c="left";(null===(r=ni.current)||void 0===r?void 0:r.contains(u))&&(c="right");var a=function(){var e,i,t,o;if("string"==typeof n&&n.includes(B)){var r=n.split(B),l="".concat(r[0]).concat(B).concat(r[1]);return"right"===c?null===(e=it.current[l])||void 0===e?void 0:e.current:null===(i=nt.current[l])||void 0===i?void 0:i.current}return"right"===c?null===(t=it.current[n])||void 0===t?void 0:t.current:null===(o=nt.current[n])||void 0===o?void 0:o.current};if(i&&!Ni)return _t(),In(new Set),En([]),Vn.current=[],void(l&&(jt(n),requestAnimationFrame(function(){var e=a()||u;e&&(e.getBoundingClientRect().top>.8*window.innerHeight&&e.scrollIntoView({behavior:"smooth",block:"center"}));Si({open:!0,anchorEl:e,summary:t,displayImpact:o})})));jt(n),Ni&&(jn(No(n)),In(new Set([n]))),l?setTimeout(function(){It(n,i,{toggleIfSame:!1,sourceSide:c,onReady:function(){var e,i,r,l=a()||u;if(Ni)setTimeout(function(){return Mo(n)},150);else if(l){var c=l.getBoundingClientRect();if(c.top>.8*window.innerHeight||c.top<100){var s=c.top-window.innerHeight/2;fn?(null===(e=li.current)||void 0===e||e.scrollBy({top:s,behavior:"smooth"}),null===(i=ni.current)||void 0===i||i.scrollBy({top:s,behavior:"smooth"})):null===(r=Zn.current)||void 0===r||r.scrollBy({top:s,behavior:"smooth"})}}Si({open:!0,anchorEl:l,summary:t,displayImpact:o})}})},350):setTimeout(function(){It(n,i,{toggleIfSame:!1,sourceSide:c}),Ni&&setTimeout(function(){return Mo(n)},150)},350)},[It,wi,Si,_t,jt,Ni,fn,Mo,$n]),Yo=c(function(){var e;if(!nn)return null;var n=null===(e=null==nn?void 0:nn.id)||void 0===e?void 0:e.split(":")[0];for(var i in Gi){if((Gi[i]||[]).some(function(e){return e.id===n}))return i}return null},[nn,Gi]),Xo=u({id:null,triggerMs:null}),$o=u(null);a(function(){if(null==nn?void 0:nn.id){var o=Number(nn.trigger),r=Xo.current;if((null==r?void 0:r.id)!==nn.id||(null==r?void 0:r.triggerMs)!==o){if(nn.id.includes(":")&&/:\d+$/.test(nn.id)){var l=nn.id.split(":"),u=l[0],c=l[1],a=null!=c?c:"0",s="".concat(nn.id,":").concat(o);$o.current!==s&&(xi(),wi(),_t(),In(new Set),En([]),Vn.current=[],$o.current=s);var d=!1,v=0,f=null,p=null,g=!1,h=function(e,n){for(var i=function(e,t){if(!e)return null;if(n.includes(e.id)||n.includes(e.nodeId)||n.includes(e.contentId))return t;if(!Array.isArray(e.subsections))return null;for(var o=0;o<e.subsections.length;o++){var r=i(e.subsections[o],"".concat(t,"-").concat(o));if(r)return r}return null},t=0;t<e.length;t++){var o=i(e[t],String(t));if(o)return o}return null},m=function(){var r,l,c;if(!d){var s=function(){Xo.current={id:nn.id,triggerMs:o}},S=null,x=null;for(var R in Gi){var b=Gi[R].find(function(e){var n;return e.id===u||e.nodeId===u||e.contentId===u||(null===(n=e.evaluationResult)||void 0===n?void 0:n.nodeId)===u});if(b){S=R,x=b;break}}if(x&&S){var y=Array.from(new Set([u,x.id,x.nodeId,x.contentId,null===(r=x.evaluationResult)||void 0===r?void 0:r.nodeId].filter(Boolean))),C=zi.findIndex(function(e){return e.id===S}),w=Wi.findIndex(function(e){return e.id===S}),_=-1===C&&-1!==w,I=h(zi,y),E=h(Wi,y);if(I&&!E&&!_){var A=I.split("-"),D=Number(A[0]);if(fn){var k=null===(c=null===(l=zi[D])||void 0===l?void 0:l.refIndexes)||void 0===c?void 0:c[0],O=Wi.findIndex(function(e){return e.selfIndex===k});-1!==O&&(D=O)}E=n([D],A.slice(1),!0).join("-")}if(I||E){var P=I?Number(I.split("-")[0]):C,j=E?Number(E.split("-")[0]):w,L=j>=0?j:E?Number(E.split("-")[0]):-1,N=zi[P],M=Wi[L],H=N&&!N.title&&!N.content,z=M&&!M.title&&!M.content,W=_||(!I&&!!E||H&&!z);if(W){if(!(fn?!!ur.current["right-".concat(j)]:!!ur.current[String(j)])&&j>=0)return Pt(j,"right"),void(f=setTimeout(m,200))}else if(!(fn?!!ur.current["left-".concat(P)]:!!ur.current[String(P)])&&P>=0)return Pt(P,"left"),void(f=setTimeout(m,200));var q=I||"",G=E||"",V=y.map(function(e){return"".concat(e).concat(B).concat(a)}),K=V[0],J=function(){for(var e,n,i=0,t=V;i<t.length;i++){var o=t[i],r=(null===(e=nt.current[o])||void 0===e?void 0:e.current)||null,l=(null===(n=it.current[o])||void 0===n?void 0:n.current)||null;if(r||l)return{refId:o,left:r,right:l}}return{refId:K,left:null,right:null}},Y=function(e){return"".concat(e).concat(B).concat(q).concat(B).concat(G)};if(!g){jt(Y(K)),g=!0,v=0;var X=function(){var e=J(),n=e.left,i=e.right;return W||!n&&!!i?i:n};return null==p||p(),void(f=setTimeout(function(){var e,n,i,t,o,r,l,u;d||(e=X,n=function(){d||(p=null,m())},t=0,o=null,r=null,l=performance.now(),u=function(){if(!d)if(performance.now()-l>3e3)n();else{var c=e();if(c&&0!==c.getBoundingClientRect().height){var a=c.getBoundingClientRect(),s=a.top,v=a.height,f=null!==o&&Math.abs(s-o)<.5,p=null!==r&&Math.abs(v-r)<.5;if(f&&p){if(++t>=5)return void n()}else t=0;o=s,r=v,i=requestAnimationFrame(u)}else i=requestAnimationFrame(u)}},i=requestAnimationFrame(u),p=function(){return cancelAnimationFrame(i)})},300))}var $=J(),U=$.refId,Q=$.left,Z=$.right,ee=Y(U);if(Q||Z){var ne=W||!Q&&!!Z,ie=ne?Z:Q,te=fn?ne?ni.current:li.current:Zn.current;if(ie&&te){var oe=ie.getBoundingClientRect();if(0!==oe.height){var re=te.getBoundingClientRect(),le=oe.top-re.top+te.scrollTop-re.height/2+oe.height/2,ue=(null==I?void 0:I.includes("-"))||(null==E?void 0:E.includes("-")),ce=function(){return i(void 0,void 0,void 0,function(){var n,i,o,r,l,u,c,v,f,p;return t(this,function(t){switch(t.label){case 0:return d?[2]:(s(),n=ie instanceof Element?window.getComputedStyle(ie).color:"",[Q,Z].forEach(function(e){e&&(e.style.transition="box-shadow 300ms ease-in-out",e.style.boxShadow="0 0 10px ".concat(n))}),setTimeout(function(){[Q,Z].forEach(function(e){e&&(e.style.boxShadow="")})},2e3),i=(null===(c=null===(u=x.evaluationResult)||void 0===u?void 0:u.deviations)||void 0===c?void 0:c[a])||x,o=(null===(v=x.evaluationResult)||void 0===v?void 0:v.evaluation_outputs)||x.evaluation_outputs,!!Q&&!!Z||Ni?(l=function(e,n){return Promise.race([e,new Promise(function(e){return setTimeout(e,n)})])},fn?[4,Promise.all([li.current?l(T(li.current),600):Promise.resolve(),ni.current?l(T(ni.current),600):Promise.resolve()])]:[3,2]):(r=ne?(null===(f=it.current[ue?U:j])||void 0===f?void 0:f.current)||Z:(null===(p=nt.current[ue?U:P])||void 0===p?void 0:p.current)||Q,Ko(r,function(){Si({open:!0,anchorEl:r,displayImpact:nn.displayImpact,summary:e(e({},i),{evaluation_outputs:o})})},{skipScroll:!0}),null==tn||tn(),[2]));case 1:t.sent(),t.label=2;case 2:return Ni&&(jn(No(ee)),In(new Set([ee]))),Ft.current(ee,!1,{toggleIfSame:!1,sourceSide:_?"right":"left",onReady:function(){var n,t,o,r;s();var l=ne?(null===(n=it.current[U])||void 0===n?void 0:n.current)||Z:(null===(t=nt.current[U])||void 0===t?void 0:t.current)||Q;if(Ni)setTimeout(function(){return Mo(ee)},150);else{var u=(null===(o=nt.current[U])||void 0===o?void 0:o.current)||Q,c=(null===(r=it.current[U])||void 0===r?void 0:r.current)||Z;u&&(u.style.scrollMarginTop="150px",u.scrollIntoView({behavior:"smooth",block:"start"})),c&&(c.style.scrollMarginTop="150px",c.scrollIntoView({behavior:"smooth",block:"start"}))}Si({open:!0,anchorEl:l,displayImpact:nn.displayImpact,summary:e({},i)}),null==tn||tn()}}),[2]}})})};Math.abs(te.scrollTop-le)<=2?ce():F(te,le,ce)}else++v<30&&(f=setTimeout(m,100))}else++v<30&&(f=setTimeout(m,100))}else++v<30&&(f=setTimeout(m,100))}else++v<30&&(f=setTimeout(m,100))}else++v<30&&(f=setTimeout(m,100))}};return f=setTimeout(m,100),function(){d=!0,f&&clearTimeout(f),null==p||p()}}Xo.current={id:nn.id,triggerMs:o},ho(nn.id);var S=zi.findIndex(function(e){return e.id===nn.id}),x=Wi.findIndex(function(e){return e.id===nn.id});-1===S&&-1===x||setTimeout(function(){var e=-1!==S?S:x,n=-1===S;Ni&&jn(No(e)),In(new Set([e])),Ft.current(e,n,{sourceSide:n?"right":"left",onReady:function(){Ni&&setTimeout(function(){return Mo(String(e))},150)}})},400)}}},[null==nn?void 0:nn.id,null==nn?void 0:nn.trigger,null==nn?void 0:nn.displayImpact,Gi,zi,Wi,fn,Si,ho,Ni,No,Mo]),a(function(){var n,i,t;if(mi.open){var o=mi.anchorEl;if(o&&!o.isConnected){var r=function(e){for(var n,i=0,t=Object.entries(e);i<t.length;i++){var r=t[i],l=r[0];if((null===(n=r[1].current)||void 0===n?void 0:n.textContent)===o.textContent)return l}return null},l=(null===(n=o.dataset)||void 0===n?void 0:n.deviationRefId)||r(nt.current)||r(it.current);if(l){var u=(null===(i=it.current[l])||void 0===i?void 0:i.current)||(null===(t=nt.current[l])||void 0===t?void 0:t.current);u&&u.isConnected&&Si(function(n){return e(e({},n),{anchorEl:u})})}}}},[mi.open,mi.anchorEl,Dn,_n,Et]);var Uo=si.open,Qo=si.sectionIdx,Zo=si.isOrphan,er=si.badgeStyle,nr=si.anchorEl,ir=si.sectionAnchorEl;a(function(){var n;if($e.isStreamingEnabled&&Uo&&null!=Qo&&Qo!==qt){var i="string"==typeof Qo?Qo.split(B)[0]:null,t=function(e,n){var i;if(!e||!Array.isArray(e))return null;for(var o=0,r=e;o<r.length;o++){var l=r[o];if(l.id===n)return l;if(null===(i=l.subsections)||void 0===i?void 0:i.length){var u=t(l.subsections,n);if(u)return u}}return null},o=i&&"string"==typeof i?t(zi,i):null,r=i&&"string"==typeof i?t(Wi,i):null,l="number"==typeof Qo?zi[Qo]||null:o||i&&((null===(n=null==qe?void 0:qe.nodes)||void 0===n?void 0:n[i])||(null==qe?void 0:qe[i]))||null,u="number"==typeof Qo?Wi[Qo]||null:r,c=vo(nr,l,u,Qo,Zo,er);di(function(n){return n.open?b(n.cognitiveData)===b(c.cognitiveData)&&b(n.deviationData)===b(c.deviationData)&&n.sectionTitle===c.sectionTitle&&n.refSectionTitle===c.refSectionTitle?n:e(e(e({},n),c),{open:!0,anchorEl:n.anchorEl,sectionAnchorEl:n.sectionAnchorEl}):n})}},[Uo,Qo,Zo,er,nr,ir,zi,Wi,vo]);var tr=s(function(e){var n=e.section,i=e.keyPath,t=e.depth,r=void 0===t?0:t,l=e.columnKey,u=void 0===l?"left":l,c=e.parentNodeId,a=void 0===c?"":c,s=e.sectionOffset,d=e.rhsOrphanVisualIndexes;return o(K,{section:n,keyPath:i,depth:r,columnKey:u,parentNodeId:a,sectionOffset:s,rhsOrphanVisualIndexes:d})},[]),or=c(function(){return zi.map(function(e,n){var i,t,r=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),l=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return r&&l&&fn?null:o(J,{section:e,idx:n},null!==(t=null!==(i=null==e?void 0:e.layoutKey)&&void 0!==i?i:null==e?void 0:e.id)&&void 0!==t?t:"left-row-".concat(n))})},[zi,fn]),rr=c(function(){return Wi.map(function(e,n){var i,t,r=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),l=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return r&&l&&fn?null:o(Y,{section:e,idx:n},null!==(t=null!==(i=null==e?void 0:e.layoutKey)&&void 0!==i?i:null==e?void 0:e.id)&&void 0!==t?t:"right-row-".concat(n))})},[Wi,fn]),lr=u(fo);a(function(){lr.current=fo},[fo]);var ur=u(Et);a(function(){ur.current=Et},[Et]);var cr=u(Jo);a(function(){cr.current=Jo},[Jo]);var ar=u(zo);a(function(){ar.current=zo},[zo]);var sr=u(Pt);a(function(){sr.current=Pt},[Pt]);var dr=u(Ot);a(function(){dr.current=Ot},[Ot]);var vr=u(tr);a(function(){vr.current=tr},[tr]);var fr=u(_t);a(function(){fr.current=_t},[_t]);var pr=c(function(){return{isGuidelineMode:Ni,maintainRelativeOrder:!!fn,showDeviationBadges:mn,isProposingFix:rn,proposingFixNodeId:ln,isRedlineFlow:un,isSideBySide:dt,activeSideBySideSection:mt,scrollSyncLocked:Dn,toggleScrollSyncLocked:Nt,summaryPopupAnchorEl:mi.anchorEl,connectedSections:_n,proposedSections:zi,existingSections:Wi,deviationNumberRegistry:Vi,deviationParentRegistry:Ki,treeData:qe,displayConfig:$e,resolvedMarkdownStyles:Qn,unifiedNumbering:Mt,expandedSections:Et,expandedSubSections:Dt,setExpandedSubSections:kt,getSectionCompareStyle:bo,getSubSectionCompareStyle:yo,getBadgeRef:at,getSectionRowRef:ut,getSubSectionRef:ct,sectionLeftRefs:Zi,sectionRightRefs:et,sectionRowRefs:lt,sectionRightRowRefs:tt,subSectionLeftRefs:ot,subSectionRightRefs:rt,lhsBadgeRefs:nt,rhsBadgeRefs:it,openMoreFunctionsPopup:$t,handleOpenSummaryPopup:Ut,openSummaryPopup:Ut,handleCloseSummaryPopup:Qt,toggleSection:Zt,handleSubSectionToggle:eo,renderSubSectionAccordion:no,resetSideBySide:io,setConnectedSections:In,setConnectedLines:En,cachedConnectedPositions:Vn,showDeviationNavigation:Go,showOpenNodeRef:Vo,deviationNodeIdToView:null==nn?void 0:nn.id,deviationTargetParentId:Yo,guidelinesData:an,gptWebCitationConfig:dn}},[Ni,fn,mn,rn,ln,un,dt,mt,Dn,Nt,mi.anchorEl,_n,zi,Wi,Vi,$e,Qn,Mt,Et,Dt,kt,bo,yo,at,ut,ct,Go,Vo,nn,Yo,an,dn]),gr=b(si.sectionTitle||ki||Ai),hr=b(Ni?Pi||ji||si.refSectionTitle:si.refSectionTitle||Pi||ji);return o($,e({value:pr},{children:r(d,e({ref:ei,sx:{display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif',overflow:"visible",position:"relative"}},{children:[xn&&o(d,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:o(N,{})})),mi.open&&o(X,{open:mi.open,anchorEl:mi.anchorEl,containerEl:So.current,clipTopEl:Mn.current,scrollContainerEl:Zn.current,onClose:zo,summary:mi.summary,displayImpact:mi.displayImpact,isScrollLocked:Dn}),o(L,{open:vi.open,anchorEl:vi.anchorEl,maintainRelativeOrder:!!fn,sectionTitle:vi.sectionTitle,referenceSectionTitle:vi.refSectionTitle,onClose:Bi,onOpenCognitiveCompare:yi,onOpenSideBySide:Ho,onConnect:po,isConnected:Wo,isOrphan:!Ni&&!!vi.isOrphan,isGuidelineMode:Ni,hasGuidelineMatches:vi.hasGuidelineMatches}),si.open&&o(j,{open:si.open,popupRef:bi,position:pi,popupConfig:Qe,onClose:function(){gi(null),di(function(n){return e(e({},n),{open:!1})}),Ri(null)},markdownStyles:Je,sectionTitle:gr,referenceSectionTitle:hr,cognitiveData:si.cognitiveData,anchorEl:si.anchorEl,sectionAnchorEl:si.sectionAnchorEl,scrollContainerEl:Zn.current,badgeStyle:si.badgeStyle,docData:si.docData,deviationData:si.deviationData,isLoading:si.isLoading}),o(v,e({open:!!yn,autoHideDuration:8e3,onClose:function(){return Cn(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:o(f,e({onClose:function(){return Cn(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:yn}))})),o(V,{componentHeaderText:We,displayConfig:$e,maintainRelativeOrder:fn,onCollapseAll:Ao,showCollapseAll:Do,onToggleView:function(e){Rn(!0),setTimeout(function(){pn(!e),null==Ue||Ue(!e),kn(!1),_t(),xi(),In(new Set),En([]),Vn.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){Rn(!1)},600)})})},50)}}),o(d,e({ref:Zn,onScroll:Eo,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:fn?"visible":"auto",borderTop:zt&&Wt?"none":"1.5px solid #EEF0F4"}},{children:o(d,e({sx:e({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},fn?{flex:1}:{})},{children:r(d,e({ref:Nn,sx:e({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"100px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},fn?{flex:1,overflow:"visible"}:{})},{children:[o(ne,{svgContainerRef:Ln,svgDimensions:To,isResizing:pt,overallConnector:Io,rootDeviationStyle:Kt,lines:Bo,isSideBySide:dt,activeSideBySideSection:mt,isArrowVisible:vt,maintainRelativeOrder:fn,proposedSections:zi,existingSections:Wi,cognitivePopup:si,activeBadgeId:hi,closeCognitivePopup:wi,setActiveBadgeId:Ri,openCognitivePopupFromState:Ci,buildSectionPopupState:vo,connectedLines:Tn,isGuidelineMode:Ni,pathRefs:Gn}),r(d,e({sx:e({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},fn?{flex:1,overflow:"visible"}:{})},{children:[o(d,e({ref:Mn,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center",minHeight:"40px",overflow:"hidden",minWidth:0}},{children:o(p,e({title:Ai,placement:"top"},{children:o(g,e({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:Ai}))}))})),r(d,e({ref:li,onScroll:Eo,sx:e({p:"12px",display:"flex",flexDirection:"column"},fn?{maxHeight:"calc(100vh - 250px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-180px",pr:"192px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[o("div",{ref:oi,style:{width:"100%",height:"0px",flexShrink:0}}),Yi&&or,o("div",{ref:ri,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),o(d,e({ref:So,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:o(d,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:r(d,e({onClick:function(n){n.stopPropagation(),si.open&&hi===qt?wi():(Ri(qt),Ci(vo(n.currentTarget,{title:uo,content:"",evaluationResult:Gt,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,qt,!0,e(e({},Kt),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:Kt.badgeBg,color:Kt.badgeText,border:"1px solid ".concat(Kt.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=Vt?Vt:o(M,{}),o(d,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:o(x,{})})),o(S,{size:11,style:{transform:si.open&&hi===qt?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),r(d,e({sx:e({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},fn?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[ht&&o(R,{sections:11}),o(d,e({ref:Hn,sx:e({p:"8px",bgcolor:Ni?"#F1F3F5":"#F7F8FA",borderBottom:"1px solid #D7DCE2",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center"},fn?e({maxHeight:"calc(100vh - 250px)",overflowY:"auto",overflowX:"hidden",minHeight:0},Ni?{"&::-webkit-scrollbar":{width:"6px",display:"block"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{background:"#CBD5E1",borderRadius:"10px"},"&::-webkit-scrollbar-thumb:hover":{background:"#94A3B8"},scrollbarWidth:"thin",scrollbarColor:"#CBD5E1 transparent"}:{"&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}):{})},{children:Ni?r(h,e({value:Pn,onChange:function(e,n){return jn(n)},variant:"fullWidth",TabIndicatorProps:{sx:{display:"none"}},sx:{width:"100%",minHeight:"36px","& .MuiTab-root":{minHeight:"36px",px:1,py:0,borderRadius:"8px",fontSize:"14px",lineHeight:1,fontWeight:500,textTransform:"none",color:"#374151",minWidth:0,transition:"background-color 160ms ease, box-shadow 160ms ease"},"& .Mui-selected":{color:"#374151",bgcolor:"#FFFFFF"}}},{children:[o(m,{label:o(p,e({title:ji,placement:"top"},{children:o(d,e({component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block",width:"100%"}},{children:"Redline Guidelines"}))}))}),o(m,{label:o(p,e({title:"Web & GPT Sources",placement:"top"},{children:o(d,e({component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block",width:"100%"}},{children:"Web & GPT Sources"}))}))})]})):o(p,e({title:ji,placement:"top"},{children:o(g,e({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:ji}))}))})),r(d,e({ref:ni,onScroll:Eo,sx:e({p:Ni?"0px":"12px",display:"flex",flexDirection:"column"},fn?e(e({maxHeight:"calc(100vh - 250px)"},!Ni&&{flex:1}),{overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-150px",pl:"165px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}):{})},{children:[o("div",{ref:ii,style:{width:"100%",height:"0px",flexShrink:0}}),Ni?0===Pn?o(ie,{guidelinesData:an,deviationData:en,connectedSections:_n,proposedSections:zi}):o(te,{deviationData:en,connectedSections:_n,proposedSections:zi}):Yi&&rr,o("div",{ref:ti,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))}))};export{re as default};
2
2
  //# sourceMappingURL=CognitiveCompare.js.map
@@ -1,2 +1,2 @@
1
- import{__spreadArray as o,__assign as i}from"tslib";import{jsx as r}from"react/jsx-runtime";import{useMemo as e}from"react";import{Box as t}from"@mui/material";import l from"react-markdown";import a from"rehype-raw";import{SHARED_MARKDOWN_STYLES as n}from"../../CognitiveCompareConfig.js";import{DEVIATION_BADGE_SEPARATOR as u,generateColorPalette as d}from"../../CognitiveComparehelpers.js";import{processGuidelinesMarkdown as s}from"../utils/processGuidelinesMarkdown.js";var g=function(g){var v=g.guidelinesData,p=g.deviationData,m=g.connectedSections,f=g.proposedSections,h=Array.from(m)[0],c=e(function(){var i;if(null==h||!p)return{targetHighlights:[],labelColor:""};var r="";"number"==typeof h?r=(null===(i=f[h])||void 0===i?void 0:i.nodeId)||"":"string"==typeof h&&(r=h.includes(u)?h.split(u)[0]:h.split("::")[0].split(":")[0]);var e=p[r];if(!e)return{targetHighlights:[],labelColor:""};var t=[],l=e.evaluation_result||{},a="";return Object.values(l).forEach(function(i){var r,e,l,n,u;(null===(r=null==i?void 0:i.deviation_highlights)||void 0===r?void 0:r.rulebook_guidelines)&&(t=o(o([],t,!0),i.deviation_highlights.rulebook_guidelines,!0),a=(null===(l=null===(e=i.evaluation_outputs)||void 0===e?void 0:e.metadata)||void 0===l?void 0:l.label_color)?d(null===(u=null===(n=i.evaluation_outputs)||void 0===n?void 0:n.metadata)||void 0===u?void 0:u.label_color).bg:"")}),{targetHighlights:t.filter(Boolean),labelColor:a}},[h,p,f]),b=c.targetHighlights,C=c.labelColor,_=e(function(){return s({guidelinesData:v,targetHighlights:b,labelColor:C||"#FEF08A"})},[v,b,C]);return r(t,i({sx:i(i({padding:"0px 12px",backgroundColor:"#FFFFFF",borderRadius:"8px"},n),{overflow:"visible"})},{children:r(l,i({rehypePlugins:[a]},{children:_}))}))};export{g as default};
1
+ import{__assign as r}from"tslib";import{jsx as o}from"react/jsx-runtime";import{useMemo as e}from"react";import{Box as i}from"@mui/material";import t from"react-markdown";import l from"rehype-raw";import{SHARED_MARKDOWN_STYLES as a}from"../../CognitiveCompareConfig.js";import{generateColorPalette as n}from"../../CognitiveComparehelpers.js";import{processGuidelinesMarkdown as s}from"../utils/processGuidelinesMarkdown.js";import{resolveGuidelineSelection as m}from"../utils/resolveGuidelineSelection.js";var p=function(p){var g=p.guidelinesData,u=p.deviationData,d=p.connectedSections,f=p.proposedSections,c=Array.from(d)[0],h=e(function(){if(null==c||!u)return{targetHighlights:[],labelColor:""};var r=m({activeIdentifier:c,deviationData:u,proposedSections:f}),o=r.labelColor?n(r.labelColor):null;return{targetHighlights:r.targetHighlights,labelColor:(null==o?void 0:o.bg)||""}},[c,u,f]),v=h.targetHighlights,C=h.labelColor,b=e(function(){return s({guidelinesData:g,targetHighlights:v,labelColor:C||"#FEF08A"})},[g,v,C]);return o(i,r({sx:r(r({padding:"0px 12px",backgroundColor:"#FFFFFF",borderRadius:"8px"},a),{overflow:"visible"})},{children:o(t,r({rehypePlugins:[l]},{children:b}))}))};export{p as default};
2
2
  //# sourceMappingURL=GuidelinePanel.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e,__rest as r}from"tslib";import{jsx as n}from"react/jsx-runtime";import{useMemo as o}from"react";import{Box as t,Typography as a}from"@mui/material";import i from"react-markdown";import d from"rehype-raw";import{SHARED_MARKDOWN_STYLES as l}from"../../CognitiveCompareConfig.js";import{DEVIATION_BADGE_SEPARATOR as u,generateColorPalette as c}from"../../CognitiveComparehelpers.js";import s from"../../CitationAnchor.js";var v=function(e){var r,n,o=e.evalNode;return!1===(null===(n=null===(r=null==o?void 0:o.evaluation_outputs)||void 0===r?void 0:r.guideline_flag)||void 0===n?void 0:n.rulebook_used)},p=function(e,r,n){return"".concat(e,"::").concat(r,"::").concat(n)},f=function(e,r){return"".concat(e,"::").concat(r)},m={relativeWrapper:{verticalAlign:"baseline"},arrow:{color:"#6D28D9"}},w=function(w){var b=w.deviationData,y=w.connectedSections,h=w.proposedSections,g=Array.from(y||[])[0],x=o(function(){return function(e,r){var n;return"number"==typeof e?(null===(n=r[e])||void 0===n?void 0:n.nodeId)||"":e&&"string"==typeof e&&e.trim()?e.includes(u)?e.split(u)[0]:e.split("::")[0].split(":")[0]:""}(g,h||[])},[g,h]),K=o(function(){if(!b||"object"!=typeof b)return[];return Object.entries(b).flatMap(function(e){var r=e[0];return function(e){var r=e&&"object"==typeof e?e.evaluation_result:null;return!r||"object"!=typeof r&&!Array.isArray(r)?[]:Array.isArray(r)?r.map(function(e,r){return{evalNode:e,evaluationKey:String(r)}}):"object"==typeof r?Object.entries(r).map(function(e){var r=e[0];return{evalNode:e[1],evaluationKey:r}}):[]}(e[1]).filter(v).map(function(e){var n,o,t,a=e.evalNode,i=e.evaluationKey;return{nodeId:r,evaluationKey:i,answerKey:f(r,i),evaluation:a,webSearchAnswer:a.web_search_answer,colorPalette:null!==(t=c((null===(o=null===(n=null==a?void 0:a.evaluation_outputs)||void 0===n?void 0:n.metadata)||void 0===o?void 0:o.label_color)||""))&&void 0!==t?t:{border:m.arrow.color}}}).filter(function(e){var r=e.webSearchAnswer;return!!(null==r?void 0:r.enhanced_content)})}).map(function(r,n){return e(e({},r),{answerOrder:n})})},[b]),A=o(function(){return K.reduce(function(e,r){var n,o=(null===(n=r.webSearchAnswer)||void 0===n?void 0:n.extraMetaData)||{};return Object.entries(o).forEach(function(n){var o=n[0],t=n[1],a=p(r.nodeId,r.evaluationKey,o);e[a]={nodeId:r.nodeId,evaluationKey:r.evaluationKey,answerKey:r.answerKey,answerOrder:r.answerOrder,reasoningId:o,evaluation:r.evaluation,webSearchAnswer:r.webSearchAnswer,extraMetaData:t}}),e},{})},[K]),F=o(function(){return K.reduce(function(e,o){return e[o.answerKey]={a:function(e){var t=e.href,a=void 0===t?"":t,i=e.children,d=e.type,l=e.reason,u=r(e,["href","children","type","reason"]),c=null==u?void 0:u["data-cognitive-reasoning"],v=c?p(o.nodeId,o.evaluationKey,String(c)):"",f=v?A[v]:null;return n(s,{href:a,children:i,citationType:d,citationReason:l,metaData:{webGpt:f,webGptMetaKey:v},customStyle:m})}},e},{})},[K,A]);return n(t,e({sx:e(e({padding:"12px 12px 12px 0px",backgroundColor:"#FFFFFF",borderRadius:"8px"},l),{overflow:"visible"})},{children:K.length>0?K.map(function(r,o){return n(t,e({id:r.nodeId===x?"guideline-target-0":void 0,"data-web-gpt-node-id":r.nodeId,"data-web-gpt-evaluation-key":r.evaluationKey,"data-web-gpt-answer-order":r.answerOrder,"data-web-gpt-active":r.nodeId===x?"true":"false",sx:{mb:1.5,border:r.nodeId===x?"2px solid ".concat(r.colorPalette.border):"1px solid #d3d3d3",borderRadius:"6px",padding:"8px",backgroundColor:"#FFFFFF"}},{children:n(i,e({rehypePlugins:[d],components:F[r.answerKey]},{children:r.webSearchAnswer.enhanced_content}))}),r.answerKey)}):n(a,e({sx:{color:"#64748B",fontSize:"14px",py:1}},{children:"No web GPT data available."}))}))};export{w as default};
1
+ import{__assign as e,__rest as r}from"tslib";import{jsx as n}from"react/jsx-runtime";import{useMemo as o}from"react";import{Box as t,Typography as a}from"@mui/material";import i from"react-markdown";import d from"rehype-raw";import{SHARED_MARKDOWN_STYLES as u}from"../../CognitiveCompareConfig.js";import{generateColorPalette as l}from"../../CognitiveComparehelpers.js";import c from"../../CitationAnchor.js";import{resolveGuidelineSelection as v}from"../utils/resolveGuidelineSelection.js";var s=function(e){var r,n,o=e.evalNode;return!1===(null===(n=null===(r=null==o?void 0:o.evaluation_outputs)||void 0===r?void 0:r.guideline_flag)||void 0===n?void 0:n.rulebook_used)},p=function(e,r,n){return"".concat(e,"::").concat(r,"::").concat(n)},f=function(e,r){return"".concat(e,"::").concat(r)},w={relativeWrapper:{verticalAlign:"baseline"},arrow:{color:"#6D28D9"}},y=function(y){var b=y.deviationData,m=y.connectedSections,h=y.proposedSections,g=Array.from(m||[])[0],K=o(function(){return v({activeIdentifier:g,deviationData:b,proposedSections:h||[]})},[g,b,h]),x=o(function(){if(!b||"object"!=typeof b)return[];return Object.entries(b).flatMap(function(e){var r=e[0];return function(e){var r=e&&"object"==typeof e?e.evaluation_result:null;return!r||"object"!=typeof r&&!Array.isArray(r)?[]:Array.isArray(r)?r.map(function(e,r){return{evalNode:e,evaluationKey:String(r)}}):"object"==typeof r?Object.entries(r).map(function(e){var r=e[0];return{evalNode:e[1],evaluationKey:r}}):[]}(e[1]).filter(s).map(function(e){var n,o,t,a=e.evalNode,i=e.evaluationKey;return{nodeId:r,evaluationKey:i,answerKey:f(r,i),evaluation:a,webSearchAnswer:a.web_search_answer,colorPalette:null!==(t=l((null===(o=null===(n=null==a?void 0:a.evaluation_outputs)||void 0===n?void 0:n.metadata)||void 0===o?void 0:o.label_color)||""))&&void 0!==t?t:{border:w.arrow.color}}}).filter(function(e){var r=e.webSearchAnswer;return!!(null==r?void 0:r.enhanced_content)})}).map(function(r,n){return e(e({},r),{answerOrder:n})})},[b]),S=o(function(){var e;return null===(e=(null==K.evaluationKey?void 0:x.find(function(e){return e.nodeId===K.baseNodeId&&e.evaluationKey===K.evaluationKey}))||x.find(function(e){return e.nodeId===K.baseNodeId}))||void 0===e?void 0:e.answerKey},[K.baseNodeId,K.evaluationKey,x]),A=o(function(){return x.reduce(function(e,r){var n,o=(null===(n=r.webSearchAnswer)||void 0===n?void 0:n.extraMetaData)||{};return Object.entries(o).forEach(function(n){var o=n[0],t=n[1],a=p(r.nodeId,r.evaluationKey,o);e[a]={nodeId:r.nodeId,evaluationKey:r.evaluationKey,answerKey:r.answerKey,answerOrder:r.answerOrder,reasoningId:o,evaluation:r.evaluation,webSearchAnswer:r.webSearchAnswer,extraMetaData:t}}),e},{})},[x]),I=o(function(){return x.reduce(function(e,o){return e[o.answerKey]={a:function(e){var t=e.href,a=void 0===t?"":t,i=e.children,d=e.type,u=e.reason,l=r(e,["href","children","type","reason"]),v=null==l?void 0:l["data-cognitive-reasoning"],s=v?p(o.nodeId,o.evaluationKey,String(v)):"",f=s?A[s]:null;return n(c,{href:a,children:i,citationType:d,citationReason:u,metaData:{webGpt:f,webGptMetaKey:s},customStyle:w})}},e},{})},[x,A]);return n(t,e({sx:e(e({padding:"12px 12px 12px 0px",backgroundColor:"#FFFFFF",borderRadius:"8px"},u),{overflow:"visible"})},{children:x.length>0?x.map(function(r){var o=r.answerKey===S;return n(t,e({id:o?"guideline-target-0":void 0,"data-web-gpt-node-id":r.nodeId,"data-web-gpt-evaluation-key":r.evaluationKey,"data-web-gpt-answer-order":r.answerOrder,"data-web-gpt-active":o?"true":"false",sx:{mb:1.5,border:o?"2px solid ".concat(r.colorPalette.border):"1px solid #d3d3d3",borderRadius:"6px",padding:"8px",backgroundColor:"#FFFFFF"}},{children:n(i,e({rehypePlugins:[d],components:I[r.answerKey]},{children:r.webSearchAnswer.enhanced_content}))}),r.answerKey)}):n(a,e({sx:{color:"#64748B",fontSize:"14px",py:1}},{children:"No web GPT data available."}))}))};export{y as default};
2
2
  //# sourceMappingURL=WebGptPanel.js.map
@@ -0,0 +1,2 @@
1
+ var t='[id^="guideline-target-"], [data-web-gpt-active="true"]',e=function(e){return e?Array.from(e.querySelectorAll(t)).filter(function(t){var e=t.getBoundingClientRect();return e.width>0&&e.height>0}):[]};export{t as GUIDELINE_TARGET_SELECTOR,e as getVisibleGuidelineTargets};
2
+ //# sourceMappingURL=guidelineTargets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guidelineTargets.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}