@viswa-test/test-citation 0.0.88 → 0.0.89

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 (30) hide show
  1. package/dist/cjs/features/CognitiveCompare/CitationAnchor.js +1 -1
  2. package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js +1 -1
  3. package/dist/cjs/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
  4. package/dist/cjs/features/CognitiveCompare/components/CognitiveSummaryPopup.js +1 -1
  5. package/dist/cjs/features/CognitiveCompare/components/SectionAccordion.js +1 -1
  6. package/dist/cjs/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
  7. package/dist/cjs/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
  8. package/dist/cjs/features/CognitiveCompare/hooks/useDeviationNavigation.js +1 -1
  9. package/dist/features/CognitiveCompare/CitationAnchor.js +1 -1
  10. package/dist/features/CognitiveCompare/CognitiveCompare.js +1 -1
  11. package/dist/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
  12. package/dist/features/CognitiveCompare/components/CognitiveSummaryPopup.js +1 -1
  13. package/dist/features/CognitiveCompare/components/SectionAccordion.js +1 -1
  14. package/dist/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
  15. package/dist/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
  16. package/dist/features/CognitiveCompare/hooks/useDeviationNavigation.js +1 -1
  17. package/dist/types/src/features/CognitiveCompare/CitationAnchor.d.ts.map +1 -1
  18. package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts +1 -1
  19. package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts.map +1 -1
  20. package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts +2 -0
  21. package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts.map +1 -1
  22. package/dist/types/src/features/CognitiveCompare/CognitiveComparehelpers.d.ts.map +1 -1
  23. package/dist/types/src/features/CognitiveCompare/components/CognitiveSummaryPopup.d.ts +1 -1
  24. package/dist/types/src/features/CognitiveCompare/components/CognitiveSummaryPopup.d.ts.map +1 -1
  25. package/dist/types/src/features/CognitiveCompare/components/SectionAccordion.d.ts.map +1 -1
  26. package/dist/types/src/features/CognitiveCompare/components/SubSectionAccordion.d.ts.map +1 -1
  27. package/dist/types/src/features/CognitiveCompare/hooks/memoizedMarkdown.d.ts.map +1 -1
  28. package/dist/types/src/features/CognitiveCompare/hooks/useDeviationNavigation.d.ts +2 -0
  29. package/dist/types/src/features/CognitiveCompare/hooks/useDeviationNavigation.d.ts.map +1 -1
  30. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),i=require("lucide-react"),l=require("react"),t=require("./ResizableSplitPane.js"),o=require("../PdfViewer/PdfViewer.js"),r=require("../../assests/svg/PdfViewerIcons.js");exports.default=function(a){var s,u,d,c=a.href,g=a.children,v=a.metaData,h=a.chevronUpComponent,f=void 0===h?null:h,p=a.chevronDownComponent,m=void 0===p?null:p,_=a.customStyle,x=void 0===_?{}:_,b=a.defaultState,j=void 0!==b&&b,y=l.useState(j),C=y[0],F=y[1],w=l.useState(!1),P=w[0],S=w[1],D=l.useRef(null),E="string"==typeof g&&(null===(s=null==g?void 0:g.split("\n"))||void 0===s?void 0:s.length)>1?g.split("\n").join(" "):g,k="string"==typeof g?g:g[0],I=null!=f?f:function(e){var l,t;return n.jsx(i.ChevronUp,{size:null!==(l=null==e?void 0:e.fontSize)&&void 0!==l?l:16,color:null!==(t=null==e?void 0:e.color)&&void 0!==t?t:"rgb(214, 51, 132)"})}(null!==(u=null==x?void 0:x.arrow)&&void 0!==u?u:{}),R=null!=m?m:function(e){var l,t;return n.jsx(i.ChevronDown,{size:null!==(l=null==e?void 0:e.fontSize)&&void 0!==l?l:16,color:null!==(t=null==e?void 0:e.color)&&void 0!==t?t:"rgb(214, 51, 132)"})}(null!==(d=null==x?void 0:x.arrow)&&void 0!==d?d:{}),q=["contract","clause"];l.useEffect(function(){var e=function(){S(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",e),function(){return document.removeEventListener("fullscreenchange",e)}},[]);return n.jsxs("span",e.__assign({style:e.__assign({display:"inline"},x.relativeWrapper||{})},{children:[n.jsx("div",e.__assign({style:e.__assign({display:"inline",marginTop:0},x.citationButtonWrapper||{})},{children:n.jsxs("button",e.__assign({type:"button",onClick:function(){return F(function(e){return!e})},style:e.__assign({display:"inline-flex",alignItems:"center",gap:"3px",fontFamily:'"Inter", sans-serif',backgroundColor:"transparent",padding:0,margin:0,fontSize:"13px",borderRadius:9999,cursor:"pointer",fontWeight:700,color:"rgb(214, 51, 132)",border:"none",textDecoration:"none",wordBreak:"break-word",whiteSpace:"normal"},x.citationButton||{})},{children:[n.jsx("span",{children:E}),n.jsx("span",e.__assign({style:{display:"flex",alignItems:"center"}},{children:C?I:R}))]}))})),C&&n.jsxs("div",e.__assign({ref:D,style:e.__assign({boxSizing:"border-box",border:P?"none":"1px solid #E4E7EC",borderRadius:P?"0":"8px",overflow:"hidden",marginTop:"8px",display:"flex",flexDirection:"column",width:"100%",height:P?"100vh":"auto"},P?{position:"fixed",inset:0,zIndex:99999,backgroundColor:"#FAFAFA"}:{})},{children:[n.jsx("div",e.__assign({style:{display:"flex",justifyContent:"flex-end",alignItems:"center",padding:"6px 10px",borderBottom:"1px solid #E4E7EC",backgroundColor:"#FFFFFF",flexShrink:0}},{children:n.jsx("button",e.__assign({onClick:function(){var e=D.current;e&&(document.fullscreenElement?document.exitFullscreen():e.requestFullscreen().catch(function(e){console.error("Fullscreen error: ".concat(e.message))}))},title:P?"Exit fullscreen":"Fullscreen",style:{background:"none",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"4px",borderRadius:"6px",color:"#475467",marginRight:"9px"}},{children:P?n.jsx(r.DefaultFullScreenCloseIcon,{}):n.jsx(r.DefaultFullScreenIcon,{})}))})),n.jsx("div",e.__assign({style:{flex:1,minHeight:0,height:"100%",overflow:"hidden"}},{children:n.jsx(function(){var i,l,r,a,s,u,d,h,f,p,m;console.log("citation details ->","href ->",c,"children ->",g,"metaData ->",v,"citationDisplayTitle ->",E);var _=function(e){try{return new URL(e,window.location.origin).searchParams.get("citationNumber")}catch(e){return null}}(c);if(!_)return null;var x=(null===(i=null==v?void 0:v.citations)||void 0===i?void 0:i[_])||{},b=(null===(l=null==v?void 0:v.docData)||void 0===l?void 0:l.documents)||{},j=(null===(r=null==v?void 0:v.docData)||void 0===r?void 0:r.input_index_map)||{},y=null==j?void 0:j[0],C=null==j?void 0:j[1],F=y?b[y]:null,w=C?b[C]:null,S=y?x[y]:null,D=C?x[C]:null;if(q.includes(k)){console.log("leftDocument",F,"rightDocument",w),console.log("leftCitation",S,"rightCitation",D);var I=S?n.jsx(o.default,{defaultScale:"PageWidth",showFullScreenAction:!1,showHighlightsAction:!1,pdfName:F.title,pdfUrl:F.signed_url,highlightText:[null!==(a=null==S?void 0:S.highlighted_text)&&void 0!==a?a:""],highlightPages:{1:null===(s=null==S?void 0:S.custom_metadata)||void 0===s?void 0:s.pdf_start_page_number},jumpToPageValue:1,highlightCordinatePages:[],useCoordinates:!1,useRange:!0,rangeOfPages:[null===(u=null==S?void 0:S.custom_metadata)||void 0===u?void 0:u.pdf_start_page_number,null===(d=null==S?void 0:S.custom_metadata)||void 0===d?void 0:d.pdf_end_page_number]}):null,R=D?n.jsx(o.default,{defaultScale:"PageWidth",showFullScreenAction:!1,showHighlightsAction:!1,pdfName:w.title,pdfUrl:w.signed_url,jumpToPageValue:1,highlightText:[null!==(h=null==D?void 0:D.highlighted_text)&&void 0!==h?h:""],highlightPages:{1:null===(f=null==D?void 0:D.custom_metadata)||void 0===f?void 0:f.pdf_start_page_number},highlightCordinatePages:[],useCoordinates:!1,useRange:!0,rangeOfPages:[null===(p=null==D?void 0:D.custom_metadata)||void 0===p?void 0:p.pdf_start_page_number,null===(m=null==D?void 0:D.custom_metadata)||void 0===m?void 0:m.pdf_end_page_number]}):null;return S||D?n.jsx("div",e.__assign({style:{height:"100%",display:"flex",flexDirection:"column"}},{children:n.jsx(t.default,{leftComponent:I,rightComponent:R,isFullscreen:P})})):n.jsx("div",{children:"Missing PDF Citation. Please try again later"})}return n.jsx("div",{children:"No Citation Found. Please try again later"})},{})}))]}))]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),i=require("react/jsx-runtime"),n=require("lucide-react"),l=require("react"),t=require("./ResizableSplitPane.js"),o=require("../PdfViewer/PdfViewer.js"),r=require("../../assests/svg/PdfViewerIcons.js"),a=function(n){var l,r,a,d,s,u,c,g,v,p,h,f=n.href,x=n.metaData,_=n.citationTitle,m=n.isFullscreen,b=function(e){try{return new URL(e,window.location.origin).searchParams.get("citationNumber")}catch(e){return null}}(f);if(!b)return null;var j=(null===(l=null==x?void 0:x.citations)||void 0===l?void 0:l[b])||{},y=(null===(r=null==x?void 0:x.docData)||void 0===r?void 0:r.documents)||{},C=(null===(a=null==x?void 0:x.docData)||void 0===a?void 0:a.input_index_map)||{},w=null==C?void 0:C[0],F=null==C?void 0:C[1],P=w?y[w]:null,S=F?y[F]:null,D=w?j[w]:null,k=F?j[F]:null;if(["contract","clause"].includes(_)){var z=D?i.jsx(o.default,{defaultScale:"PageWidth",showFullScreenAction:!1,showHighlightsAction:!1,pdfName:P.title,pdfUrl:P.signed_url,highlightText:[null!==(d=null==D?void 0:D.highlighted_text)&&void 0!==d?d:""],highlightPages:{1:null===(s=null==D?void 0:D.custom_metadata)||void 0===s?void 0:s.pdf_start_page_number},jumpToPageValue:1,highlightCordinatePages:[],useCoordinates:!1,useRange:!0,rangeOfPages:[null===(u=null==D?void 0:D.custom_metadata)||void 0===u?void 0:u.pdf_start_page_number,null===(c=null==D?void 0:D.custom_metadata)||void 0===c?void 0:c.pdf_end_page_number]}):null,R=k?i.jsx(o.default,{defaultScale:"PageWidth",showFullScreenAction:!1,showHighlightsAction:!1,pdfName:S.title,pdfUrl:S.signed_url,jumpToPageValue:1,highlightText:[null!==(g=null==k?void 0:k.highlighted_text)&&void 0!==g?g:""],highlightPages:{1:null===(v=null==k?void 0:k.custom_metadata)||void 0===v?void 0:v.pdf_start_page_number},highlightCordinatePages:[],useCoordinates:!1,useRange:!0,rangeOfPages:[null===(p=null==k?void 0:k.custom_metadata)||void 0===p?void 0:p.pdf_start_page_number,null===(h=null==k?void 0:k.custom_metadata)||void 0===h?void 0:h.pdf_end_page_number]}):null;return D||k?i.jsx("div",e.__assign({style:{height:"100%",display:"flex",flexDirection:"column"}},{children:i.jsx(t.default,{leftComponent:z,rightComponent:R,isFullscreen:m})})):i.jsx("div",{children:"Missing PDF Citation. Please try again later"})}return i.jsx("div",{children:"No Citation Found. Please try again later"})};exports.default=function(t){var o,d,s,u=t.href,c=t.children,g=t.metaData,v=t.chevronUpComponent,p=void 0===v?null:v,h=t.chevronDownComponent,f=void 0===h?null:h,x=t.customStyle,_=void 0===x?{}:x,m=t.defaultState,b=void 0!==m&&m,j=l.useState(b),y=j[0],C=j[1],w=l.useState(!1),F=w[0],P=w[1],S="string"==typeof c&&(null===(o=null==c?void 0:c.split("\n"))||void 0===o?void 0:o.length)>1?c.split("\n").join(" "):c,D="string"==typeof c?c:c[0],k=null!=p?p:function(e){var l,t;return i.jsx(n.ChevronUp,{size:null!==(l=null==e?void 0:e.fontSize)&&void 0!==l?l:16,color:null!==(t=null==e?void 0:e.color)&&void 0!==t?t:"rgb(214, 51, 132)"})}(null!==(d=null==_?void 0:_.arrow)&&void 0!==d?d:{}),z=null!=f?f:function(e){var l,t;return i.jsx(n.ChevronDown,{size:null!==(l=null==e?void 0:e.fontSize)&&void 0!==l?l:16,color:null!==(t=null==e?void 0:e.color)&&void 0!==t?t:"rgb(214, 51, 132)"})}(null!==(s=null==_?void 0:_.arrow)&&void 0!==s?s:{});return i.jsxs("span",e.__assign({style:e.__assign({display:"inline"},_.relativeWrapper||{})},{children:[i.jsx("div",e.__assign({style:e.__assign({display:"inline",marginTop:0},_.citationButtonWrapper||{})},{children:i.jsxs("button",e.__assign({type:"button",onClick:function(){return C(function(e){return!e})},style:e.__assign({display:"inline-flex",alignItems:"center",gap:"3px",fontFamily:'"Inter", sans-serif',backgroundColor:"transparent",padding:0,margin:0,fontSize:"13px",borderRadius:9999,cursor:"pointer",fontWeight:700,color:"rgb(214, 51, 132)",border:"none",textDecoration:"none",wordBreak:"break-word",whiteSpace:"normal"},_.citationButton||{})},{children:[i.jsx("span",{children:S}),i.jsx("span",e.__assign({style:{display:"flex",alignItems:"center"}},{children:y?k:z}))]}))})),y&&i.jsxs("div",e.__assign({style:F?{position:"fixed",inset:0,zIndex:999999,backgroundColor:"#FAFAFA",display:"flex",flexDirection:"column"}:{boxSizing:"border-box",border:"1px solid #E4E7EC",borderRadius:"8px",overflow:"hidden",marginTop:"8px",display:"flex",flexDirection:"column",width:"100%"}},{children:[i.jsx("div",e.__assign({style:{display:"flex",justifyContent:"flex-end",padding:"6px 10px",borderBottom:"1px solid #E4E7EC",backgroundColor:"#FFFFFF",flexShrink:0}},{children:i.jsx("button",e.__assign({onClick:function(){P(function(e){return!e})},style:{background:"none",border:"none",cursor:"pointer",padding:"4px",borderRadius:"6px",color:"#475467",marginRight:"9px"}},{children:F?i.jsx(r.DefaultFullScreenCloseIcon,{}):i.jsx(r.DefaultFullScreenIcon,{})}))})),i.jsx("div",e.__assign({style:{flex:1,minHeight:0,height:"100%",overflow:"hidden"}},{children:i.jsx(a,{href:u,children:c,metaData:g,citationTitle:D,isFullscreen:F})}))]}))]}))};
2
2
  //# sourceMappingURL=CitationAnchor.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("@mui/material"),o=require("lucide-react"),l=require("../../assests/svg/ButtonCognitiveIcon.js"),r=require("./OverlayComponent.js"),u=require("./CognitiveComparehelpers.js"),c=require("./CognitiveCompareConfig.js"),s=require("./CognitiveCompareConstants.js"),a=require("./CognitivePopup.js"),d=require("./MoreFunctionsPopup.js"),v=require("./LoaderComponent.js"),g=require("./components/ThreeDotsLoader.js"),f=require("./hooks/useCompareData.js"),p=require("./hooks/useComparePopups.js"),h=require("./hooks/useSectionRefs.js"),x=require("./hooks/useAccordionState.js"),_=require("./hooks/useDeviationNavigation.js"),m=require("./components/CompareHeader.js"),R=require("./components/SectionAccordion.js"),y=require("./components/SubSectionAccordion.js"),S=require("./components/CognitiveSummaryPopup.js");exports.SHARED_MARKDOWN_STYLES=c.SHARED_MARKDOWN_STYLES,exports.default=function(b){var A,T,E,I,B,C,D,O,j,w,P,N,F,k,M,L=b.componentHeaderText,V=void 0===L?s.DEFAULT_COMPONENT_HEADER_TEXT:L,H=b.treeData,G=b.comparisonConfig,q=b.leftColumnTitleText,z=b.rightColumnTitleText,W=b.markdownStyles,Y=b.displayConfig,K=void 0===Y?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0}:Y,U=b.popupConfig,X=b.deviationData,J=void 0===X?{}:X,Q=b.deviationNodeIdToView,Z=t.useState(K.maintainRelativeOrder),$=Z[0],ee=Z[1],ne=t.useState(!1),te=ne[0],ie=ne[1],oe=t.useState(!1),le=oe[0],re=oe[1],ue=t.useState(null),ce=ue[0],se=ue[1],ae=t.useState(!1),de=ae[0],ve=ae[1],ge=t.useState(!1),fe=ge[0],pe=ge[1],he=t.useState(!1),xe=he[0],_e=he[1],me=t.useState(null),Re=me[0],ye=me[1],Se=t.useRef(!1),be=t.useState(new Set),Ae=be[0],Te=be[1],Ee=t.useState([]),Ie=Ee[0],Be=Ee[1],Ce=t.useRef(null),De=t.useRef(!1),Oe=t.useRef(null),je=t.useRef({}),we=t.useRef([]),Pe=t.useRef(!1),Ne=t.useRef(!1),Fe=t.useRef(null),ke=t.useRef(function(){}),Me=t.useMemo(function(){return(null==H?void 0:H.cognitive_decisioning)||{}},[H]),Le=t.useState({width:0,height:0}),Ve=Le[0],He=Le[1],Ge=t.useMemo(function(){return e.__assign(e.__assign({},c.SHARED_MARKDOWN_STYLES),W)},[W]),qe=t.useRef(null),ze=t.useRef(null),We=t.useRef(null),Ye=t.useRef(null),Ke=t.useRef(null),Ue=t.useRef(null),Xe=t.useRef(null),Je=t.useRef(null),Qe=t.useRef(!1),Ze=p.useComparePopups(qe),$e=Ze.cognitivePopup,en=Ze.setCognitivePopup,nn=Ze.moreFunctions,tn=Ze.setMoreFunctions,on=Ze.position,ln=Ze.setPosition,rn=Ze.activeBadgeId,un=Ze.summaryPopup,cn=Ze.setSummaryPopup,sn=Ze.closeSummaryPopup,an=Ze.setActiveBadgeId,dn=Ze.popupRef,vn=Ze.closeCognitivePopup,gn=Ze.closeMoreFunctionsPopup,fn=t.useMemo(function(){var e,n,t,i,o,l,r;return{fields:null!==(e=null==G?void 0:G.fields)&&void 0!==e?e:c.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(t=null===(n=null==G?void 0:G.thresholds)||void 0===n?void 0:n.high)&&void 0!==t?t:c.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(o=null===(i=null==G?void 0:G.thresholds)||void 0===i?void 0:i.medium)&&void 0!==o?o:c.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(r=null===(l=null==G?void 0:G.thresholds)||void 0===l?void 0:l.exact)&&void 0!==r?r:c.DEFAULT_COMPARISON_CONFIG.thresholds.exact}}},[G]),pn=t.useState(null),hn=pn[0];pn[1];var xn=null===(E=null===(A=null==H?void 0:H.documents)||void 0===A?void 0:A[null===(T=null==H?void 0:H.input_index_map)||void 0===T?void 0:T[0]])||void 0===E?void 0:E.title,_n=null===(C=null===(I=null==H?void 0:H.documents)||void 0===I?void 0:I[null===(B=null==H?void 0:H.input_index_map)||void 0===B?void 0:B[1]])||void 0===C?void 0:C.title,mn=u.safeStringify(q||xn||"Uploaded Contract"),Rn=u.safeStringify(z||_n||"Reference Template"),yn=f.useCognitiveTreeData(H,$,J,fn),Sn=yn.activeProposed,bn=yn.existingRule,An=yn.proposedSections,Tn=yn.existingSections,En=yn.visibleFields,In=yn.parentDeviationRecord,Bn=yn.deviationNumberRegistry,Cn=yn.parseError;t.useEffect(function(){Cn&&se("Failed to load comparison: ".concat(Cn))},[Cn]);var Dn=An.length>0||Tn.length>0,On=h.useSectionRefs(En.map(function(e){return e.key}),Math.max(An.length,Tn.length)),jn=On.leftRefs,wn=On.rightRefs,Pn=On.sectionLeftRefs,Nn=On.sectionRightRefs,Fn=On.lhsBadgeRefs,kn=On.rhsBadgeRefs,Mn=On.sectionRightRowRefs,Ln=On.subSectionLeftRefs,Vn=On.subSectionRightRefs,Hn=On.sectionRowRefs,Gn=On.getSectionRowRef,qn=On.getSubSectionRef,zn=On.getBadgeRef,Wn=bn.analysis,Yn=u.safeStringify(null===(O=null===(D=null==Wn?void 0:Wn.rule_difference_comparison)||void 0===D?void 0:D.summary)||void 0===O?void 0:O.overall_summary),Kn=!!Yn.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),Un=null!==(j=null==H?void 0:H.base_root_id)&&void 0!==j?j:"-1";null==H||H[Un];var Xn=(null===(w=null==J?void 0:J[Un])||void 0===w?void 0:w.evaluation_result)||(null===(N=null===(P=null==H?void 0:H.nodes)||void 0===P?void 0:P[Un])||void 0===N?void 0:N.evaluation_result)||null,Jn=u.extractDeviationScore(Xn),Qn=u.generateColorPalette(null!==(M=null===(k=null===(F=null==Xn?void 0:Xn.evaluation_outputs)||void 0===F?void 0:F.metadata)||void 0===k?void 0:k.label_color)&&void 0!==M?M:""),Zn=t.useCallback(function(){var e,n,t,i;ve(!1),Ne.current=!1;var o=Fe.current,l=dt.current;if(null!==o)if("string"==typeof o&&o.includes(u.DEVIATION_BADGE_SEPARATOR)){var r=o.split(u.DEVIATION_BADGE_SEPARATOR);(c=null===(e=Ln.current[r[2]])||void 0===e?void 0:e.current)&&(c.style.paddingTop="0px")}else{var c;(c=null===(n=Pn.current[o])||void 0===n?void 0:n.current)&&(c.style.paddingTop="0px")}if(null!==l)if("string"==typeof l&&l.includes(u.DEVIATION_BADGE_SEPARATOR)){r=l.split(u.DEVIATION_BADGE_SEPARATOR);(s=null===(t=Vn.current[r[3]])||void 0===t?void 0:t.current)&&(s.style.paddingTop="0px")}else{var s;(s=null===(i=Nn.current[l])||void 0===i?void 0:i.current)&&(s.style.paddingTop="0px")}ye(null),Fe.current=null,dt.current=null,pe(!1),re(!1),Ye.current&&(Ye.current.style.height="0px"),Ke.current&&(Ke.current.style.height="0px"),Ue.current&&(Ue.current.style.height="0px"),Xe.current&&(Xe.current.style.height="0px")},[]),$n=x.useAccordionState({maintainRelativeOrder:!!$,proposedSections:An,existingSections:Tn,activeSideBySideSection:Re,connectedSections:Ae,resetSideBySide:Zn,setConnectedSections:Te,setConnectedLines:Be,cachedConnectedPositions:we,svgContainerRef:Ce,isAnimatingRef:De,animationTimerRef:Oe,calculateLinesRef:ke,sectionLeftRefs:Pn,sectionRightRefs:Nn,subSectionLeftRefs:Ln,subSectionRightRefs:Vn}),et=$n.expandedSections,nt=$n.expandedSubSections,tt=$n.setExpandedSubSections,it=$n.toggleSection,ot=t.useCallback(function(e,n,t,i,o,l,r){var c,s,a,d=u.safeStringify(null==n?void 0:n.id)||u.safeStringify(null==t?void 0:t.id)||"",v=(d?Me[d]:null)||(null==n?void 0:n.cognitiveData)||(null==t?void 0:t.cognitiveData)||{section_id:d,decisioning:[],gap:[],relevance_score:0},g=null!==(s=null===(c=Hn.current[i])||void 0===c?void 0:c.current)&&void 0!==s?s:null;return{isLoading:null!==(a=null==K?void 0:K.isLoading)&&void 0!==a&&a,open:!0,sectionTitle:(null==n?void 0:n.displayTitle)?null==n?void 0:n.title:"no title",refSectionTitle:(null==t?void 0:t.displayTitle)?null==t?void 0:t.title:"no title",cognitiveData:v,anchorEl:e,sectionAnchorEl:g,badgeStyle:l||null,sectionIdx:i,docData:{documents:null==H?void 0:H.documents,input_index_map:null==H?void 0:H.input_index_map},deviationData:(null==n?void 0:n.evaluationResult)||(null==t?void 0:t.evaluationResult)||null,isOrphan:!!o}},[Me,H]),lt=t.useCallback(function(e){gn(),ln(null),en(e)},[gn]),rt=function(e,n,t,i,o,l){e.stopPropagation(),nn.open&&nn.sectionIdx===o?gn():(vn(),tn(ot(e.currentTarget,n,i,o,t,l)))},ut=t.useCallback(function(){null!==nn.sectionIdx&&nn.anchorEl?lt(e.__assign(e.__assign({},nn),{open:!0})):gn()},[nn,gn,lt]),ct=t.useCallback(function(){var e=nn.sectionIdx,n=nn.isOrphan;gn(),sn(),null!==e&&(n?se("No counterpart exists to connect to."):(Ne.current&&Zn(),Be([]),we.current=[],Te(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){ke.current&&ke.current()},50)))},[nn.sectionIdx,nn.isOrphan,gn,sn,Zn]),st=t.useRef(null),at=t.useRef(null),dt=t.useRef(null),vt=t.useRef(null),gt=t.useRef(null),ft=t.useRef(null),pt=t.useState([]),ht=pt[0],xt=pt[1];t.useRef(null);var _t=t.useState(null),mt=_t[0],Rt=_t[1];t.useEffect(function(){if(hn){var e=fn.fields.find(function(e){return e.analysisKey===hn||e.key===hn});if(e){var n=jn.current[e.key]||wn.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[hn,fn.fields]);var yt=t.useCallback(function(e){var n,t,i,o,l,r,u,c,s,a=null===(n=null==Wn?void 0:Wn.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!a||!a[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var d=a[e],v=(null==d?void 0:d.relation)||(null===(i=null===(t=null==d?void 0:d.highlights)||void 0===t?void 0:t.ruleA_spans)||void 0===i?void 0:i.length)||(null===(l=null===(o=null==d?void 0:d.highlights)||void 0===o?void 0:o.ruleB_spans)||void 0===l?void 0:l.length)||(null==d?void 0:d.mappings)&&d.mappings.length>0;if(d.mappings){var g=d.mappings[0]||{};return{score:d.score,relation:g.relation||"",highlightsA:(null===(r=g.highlights)||void 0===r?void 0:r.ruleA_spans)||[],highlightsB:(null===(u=g.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===(s=d.highlights)||void 0===s?void 0:s.ruleB_spans)||[],hasContent:!!v}},[Wn]),St=t.useCallback(function(n,t){var i,o,l,r,c,a,d;void 0===t&&(t="left");var v=null,g=null;if("left"===t)if(v=An[n],$&&v){var f=Tn.filter(function(e){var n;return null===(n=v.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)});g=f.find(function(e){return e.evaluationResult})||f[0]}else g=Tn[n];else if(g=Tn[n],$&&g){var p=An.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(g.selfIndex)});v=p.find(function(e){return e.evaluationResult})||p[0]}else v=An[n];var h=(null==v?void 0:v.relation)&&"not_defined"!==v.relation,x=(null==g?void 0:g.relation)&&"not_defined"!==g.relation,_=!(!(null==v?void 0:v.cognitiveData)&&!(null==g?void 0:g.cognitiveData));if(!h&&!x&&!_)return e.__assign(e.__assign({},u.generateColorPalette(s.DEFAULT_DEVIAION_COLOR)),{label:"Not Defined"});var m=null!==(o=null!==(i=null==v?void 0:v.evaluationResult)&&void 0!==i?i:null==g?void 0:g.evaluationResult)&&void 0!==o?o:null,R=null===(l=null==m?void 0:m.evaluation_outputs)||void 0===l?void 0:l.output_value,y=null!==(a=null===(c=null===(r=null==m?void 0:m.evaluation_outputs)||void 0===r?void 0:r.metadata)||void 0===c?void 0:c.label_color)&&void 0!==a?a:s.DEFAULT_DEVIAION_COLOR;return null!=m?e.__assign(e.__assign({},u.generateColorPalette(y)),{label:null!==(d=R)&&void 0!==d?d:""}):e.__assign(e.__assign({},u.generateColorPalette(y)),{label:null})},[An,Tn,Me,fn,$]),bt=t.useCallback(function(n){for(var t,i,o,l,r,c,a,d,v,g=n.split("-").map(Number),f=An[g[0]],p=Tn[g[0]],h=1;h<g.length;h++)(null==f?void 0:f.subsections)&&(f=f.subsections[g[h]]),(null==p?void 0:p.subsections)&&(p=p.subsections[g[h]]);if(!f&&!p)return null;var x=(null==f?void 0:f.relation)&&"not_defined"!==f.relation,_=(null==p?void 0:p.relation)&&"not_defined"!==p.relation,m=u.safeStringify(null==f?void 0:f.id)||u.safeStringify(null==p?void 0:p.id)||"",R=!(!(null==f?void 0:f.cognitiveData)&&!(null==p?void 0:p.cognitiveData));if(!x&&!_&&!R)return e.__assign(e.__assign({},u.generateColorPalette(s.DEFAULT_DEVIAION_COLOR)),{label:"Not Defined"});null!==(i=null!==(t=null==f?void 0:f.cognitiveRelevanceScore)&&void 0!==t?t:null==p?void 0:p.cognitiveRelevanceScore)&&void 0!==i||m&&(null===(o=Me[m])||void 0===o||o.relevance_score);var y=null!==(r=null!==(l=null==f?void 0:f.evaluationResult)&&void 0!==l?l:null==p?void 0:p.evaluationResult)&&void 0!==r?r:null,S=null===(c=null==y?void 0:y.evaluation_outputs)||void 0===c?void 0:c.output_value,b=null!==(v=null===(d=null===(a=null==y?void 0:y.evaluation_outputs)||void 0===a?void 0:a.metadata)||void 0===d?void 0:d.label_color)&&void 0!==v?v:s.DEFAULT_DEVIAION_COLOR;return null!=y?e.__assign(e.__assign({},u.generateColorPalette(b)),{label:null!=S?S:""}):e.__assign(e.__assign({},u.generateColorPalette(b)),{label:null})},[An,Tn,Me,fn]),At=t.useCallback(function(){var e,n,t,i,o,l,r,c,s,a,d,v,g,f,p,h,x,_;if(!Qe.current&&!De.current){Qe.current=!0;try{if(!st.current)return;var m=function(e){var n=e.split("-"),t=n[0];if(!et[t]&&!1===$)return!1;if($&&!et["left-".concat(t)]&&!et["right-".concat(t)]&&!et[t])return!1;for(var i=t,o=1;o<n.length-1;o++)if(i+="-".concat(n[o]),!nt[i])return!1;return!0},R=st.current.getBoundingClientRect();He({width:R.width,height:R.height});var y=[];if(En.forEach(function(e){var n,t,i=e.key,o=null===(n=jn.current[i])||void 0===n?void 0:n.current,l=null===(t=wn.current[i])||void 0===t?void 0:t.current;o&&l&&(o.style.height="auto",l.style.height="auto",o.style.minHeight="0px",l.style.minHeight="0px")}),!De.current){for(var S=0;S<Math.max(An.length,Tn.length);S++){var b=null===(e=Pn.current[S])||void 0===e?void 0:e.current,A=null===(n=Nn.current[S])||void 0===n?void 0:n.current;b&&(b.style.height="auto",b.style.minHeight="0px"),A&&(A.style.height="auto",A.style.minHeight="0px")}$||Object.keys(Ln.current).forEach(function(e){var n,t;if(m(e)){var i=null===(n=Ln.current[e])||void 0===n?void 0:n.current,o=null===(t=Vn.current[e])||void 0===t?void 0:t.current;i&&o&&(i.style.height="auto",o.style.height="auto",i.style.minHeight="0px",o.style.minHeight="0px")}})}var T={};En.forEach(function(e){var n,t,i=e.key,o=null===(n=jn.current[i])||void 0===n?void 0:n.current,l=null===(t=wn.current[i])||void 0===t?void 0:t.current;if(o&&l){var r=o.getBoundingClientRect(),u=l.getBoundingClientRect();T[i]=Math.max(r.height,u.height)}});var E={left:{},right:{}},I={};if(!De.current)if($){if(de&&null!==Re)if("number"==typeof Re){var B=Re,C=An[B],D=null===(o=Pn.current[B])||void 0===o?void 0:o.current;D&&C&&(C.refIndexes||[]).forEach(function(e){var n,t=Tn.findIndex(function(n){return n.selfIndex===e}),i=null===(n=Nn.current[t])||void 0===n?void 0:n.current;if(i&&(et["left-".concat(B)]||et["right-".concat(t)])){var o=Math.max(D.getBoundingClientRect().height,i.getBoundingClientRect().height);E.left[B]=Math.max(E.left[B]||0,o),E.right[t]=Math.max(E.right[t]||0,o)}})}else{var O=Re.split(u.DEVIATION_BADGE_SEPARATOR)[2];if(O){b=null===(l=Ln.current[O])||void 0===l?void 0:l.current,A=null===(r=Vn.current[O])||void 0===r?void 0:r.current;if(b&&A){j=Math.max(b.getBoundingClientRect().height,A.getBoundingClientRect().height);I[O]=Math.max(I[O]||0,j)}}}}else{Object.keys(Ln.current).forEach(function(e){var n,t;if(m(e)){var i=null===(n=Ln.current[e])||void 0===n?void 0:n.current,o=null===(t=Vn.current[e])||void 0===t?void 0:t.current;if(i&&o&&null!==i.offsetParent&&null!==o.offsetParent){var l=i.getBoundingClientRect(),r=o.getBoundingClientRect(),u=Math.max(l.height,r.height);I[e]=u,i.style.minHeight="".concat(u,"px"),o.style.minHeight="".concat(u,"px")}}});for(S=0;S<Math.min(An.length,Tn.length);S++){var b=null===(t=Pn.current[S])||void 0===t?void 0:t.current,A=null===(i=Nn.current[S])||void 0===i?void 0:i.current;if(b&&A){var j=Math.max(b.getBoundingClientRect().height,A.getBoundingClientRect().height);E.left[S]=j,E.right[S]=j}}}if(En.forEach(function(e){var n,t,i=e.key,o=null===(n=jn.current[i])||void 0===n?void 0:n.current,l=null===(t=wn.current[i])||void 0===t?void 0:t.current;if(o&&l){var r=T[i];o.style.minHeight="".concat(r,"px"),l.style.minHeight="".concat(r,"px")}}),De.current||(Object.entries(E.left).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=Pn.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),Object.entries(E.right).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=Nn.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),$||Object.keys(I).forEach(function(e){var n,t,i=null===(n=Ln.current[e])||void 0===n?void 0:n.current,o=null===(t=Vn.current[e])||void 0===t?void 0:t.current;if(i&&o&&I[e]){var l=I[e];i.style.minHeight="".concat(l,"px"),o.style.minHeight="".concat(l,"px")}})),$)An.forEach(function(e,n){var t;(null===(t=Pn.current[n])||void 0===t?void 0:t.current)&&(e.refIndexes||[]).forEach(function(e){var t,i,o,l,r,u,c=Tn.findIndex(function(n){return n.selfIndex===e});if(-1!==c){var s=null===(t=Fn.current[n])||void 0===t?void 0:t.current,a=null===(i=kn.current[c])||void 0===i?void 0:i.current;if(s&&a){var d,v,g,f=s.getBoundingClientRect(),p=a.getBoundingClientRect(),h=f.right-R.left,x=p.left-R.left,_=f.top+f.height/2-R.top,m=p.top+p.height/2-R.top;if(de&&Re===n){var S=null!==(l=null===(o=Je.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==l?l:0,b=S+(null!==(u=null===(r=Je.current)||void 0===r?void 0:r.clientHeight)&&void 0!==u?u:1/0),A=f.top+f.height/2;d=A,v=S,g=b,m=_=Math.max(v,Math.min(g,d))-R.top}var T=St(n);T&&y.push({id:"line-".concat(n,"-").concat(c),x1:h,y1:_,x2:x,y2:m,style:T,sectionIdx:n,targetRightIdx:c})}}})});else{for(S=0;S<Math.min(An.length,Tn.length);S++){var w=null===(c=Pn.current[S])||void 0===c?void 0:c.current,P=null===(s=Nn.current[S])||void 0===s?void 0:s.current;if(w&&P){var N=w.getBoundingClientRect(),F=P.getBoundingClientRect(),k=Math.max(N.top,F.top)+18-R.top,M=(null===(a=Tn[S])||void 0===a?void 0:a.id)||"sec-".concat(S);(Y=St(S))&&y.push({id:M,x1:N.right-R.left,y1:k,x2:F.left-R.left,y2:k,style:Y,sectionIdx:S,hasCognitive:!!((null===(d=An[S])||void 0===d?void 0:d.cognitiveData)||(null===(v=Tn[S])||void 0===v?void 0:v.cognitiveData)||M&&Me[M]),isSubSection:!1})}}Object.keys(Ln.current).forEach(function(e){var n,t,i,o,l,r;if(m(e)){var c=null===(n=Ln.current[e])||void 0===n?void 0:n.current,s=null===(t=Vn.current[e])||void 0===t?void 0:t.current;if(c&&s){for(var a=e.split("-").map(Number),d=An[a[0]],v=Tn[a[0]],g=1;g<a.length;g++)(null==d?void 0:d.subsections)&&(d=d.subsections[a[g]]),(null==v?void 0:v.subsections)&&(v=v.subsections[a[g]]);var f=!!d&&((null===(i=d.displayTitle)||void 0===i||i)&&u.hasValue(d.title)),p=!!d&&((null===(o=d.displayContent)||void 0===o||o)&&u.hasValue(d.content)),h=!!v&&((null===(l=v.displayTitle)||void 0===l||l)&&u.hasValue(v.title)),x=!!v&&((null===(r=v.displayContent)||void 0===r||r)&&u.hasValue(v.content));if(f&&p||h&&x){var _=c.getBoundingClientRect(),S=s.getBoundingClientRect(),b=Math.max(_.top,S.top)+16-R.top,A=bt(e);A&&"Not Defined"!==A.label&&y.push({id:"subsec-".concat(e),x1:_.right-R.left,y1:b,x2:S.left-R.left,y2:b,style:A,sectionIdx:a[0],isSubSection:!0,subSectionKeyPath:e,hasCognitive:!(!(null==d?void 0:d.cognitiveData)&&!(null==v?void 0:v.cognitiveData))})}}}})}if(de&&"string"==typeof Re&&Re.includes(u.DEVIATION_BADGE_SEPARATOR)){var L=Re.split(u.DEVIATION_BADGE_SEPARATOR),V=L[0],H=L[1],G=L[2],q=(L[3],"".concat(V).concat(u.DEVIATION_BADGE_SEPARATOR).concat(H)),z=null===(g=Fn.current[q])||void 0===g?void 0:g.current,W=null===(f=kn.current[q])||void 0===f?void 0:f.current;if(z&&W){var Y,K=z.getBoundingClientRect(),U=W.getBoundingClientRect(),X=K.right-R.left,J=U.left-R.left,Q=K.top+K.height/2-R.top,Z=(U.top,U.height,R.top);if($){var ee=null!==(h=null===(p=Je.current)||void 0===p?void 0:p.getBoundingClientRect().top)&&void 0!==h?h:0,ne=ee+(null!==(_=null===(x=Je.current)||void 0===x?void 0:x.clientHeight)&&void 0!==_?_:1/0);_e=K.top+K.height/2,me=ee,ye=ne,Q=Math.max(me,Math.min(ye,_e))-R.top}Z=Q,(Y=bt(G))&&y.push({id:"line-subsec-".concat(q),x1:X,y1:Q,x2:J,y2:Z,style:Y,sectionIdx:Number(G.split("-")[0]),isSubSection:!0,subSectionKeyPath:Re})}}if(xt(y),gt.current&&ft.current){var te=gt.current.getBoundingClientRect(),ie=ft.current.getBoundingClientRect(),oe=(te.top+te.height/2-R.top+ie.top+ie.height/2-R.top)/2;Rt({x1:te.right-R.left,x2:ie.left-R.left,y:oe})}else Rt(null);if(Ae.size>0){var le=[],re=Je.current,ue=We.current;if(re&&ue){var ce=[],se=re.getBoundingClientRect().top,ae=ue.getBoundingClientRect().top,ve=se+re.clientHeight,ge=ae+ue.clientHeight,fe=re.scrollTop,pe=ue.scrollTop,he=R.top,xe=function(e,n,t){return Math.max(n,Math.min(t,e))};Ae.forEach(function(e){var n,t,i,o,l;if("string"==typeof e&&e.includes(u.DEVIATION_BADGE_SEPARATOR)){var r=e.split(u.DEVIATION_BADGE_SEPARATOR),c=r[0],s=r[1],a=r[2],d=(r[3],"".concat(c).concat(u.DEVIATION_BADGE_SEPARATOR).concat(s)),v=null===(n=Fn.current[d])||void 0===n?void 0:n.current,g=null===(t=kn.current[d])||void 0===t?void 0:t.current;if(!v||!g)return;var f=v.getBoundingClientRect(),p=g.getBoundingClientRect(),h=bt(a),x=(P=f.right-R.left)+.5*((N=p.left-R.left-0)-P),_=f.top+f.height/2,m=p.top+p.height/2,y=_-se+fe,S=m-ae+pe,b="conn-subsec-".concat(d);ce.push({lhsScrollY:y,rhsScrollY:S,x1:P,x2:N,containerTop:he,leftIdx:e,rhsArrayIdx:e,styleColor:(null==h?void 0:h.badgeBorder)||"#6366F1",styleId:b});var A=xe(_,se,ve),T=xe(m,ae,ge),E=A-he,I=T-he,B=m>=ae-4&&m<=ge+4,C="";C=(F=_>=se-4&&_<=ve+4)&&B?u.getBentArrowPath(P,E,N,I):F&&!B?"M ".concat(P,",").concat(E," L ").concat(x,",").concat(E," L ").concat(x,",").concat(I):!F&&B?"M ".concat(x,",").concat(E," L ").concat(x,",").concat(I," L ").concat(N,",").concat(I):"M ".concat(x,",").concat(E," L ").concat(x,",").concat(I),le.push({id:b,pathD:C,style:h,leftIdx:e,rhsArrayIdx:e})}else if($){var D=e,O=An[D];if(!(null===(l=null==O?void 0:O.refIndexes)||void 0===l?void 0:l.length))return;O.refIndexes.forEach(function(e){var n,t,i=Tn.findIndex(function(n){return n.selfIndex===e});if(-1!==i){var o=null===(n=Fn.current[D])||void 0===n?void 0:n.current,l=null===(t=kn.current[i])||void 0===t?void 0:t.current;if(o&&l){var r=o.getBoundingClientRect(),c=l.getBoundingClientRect(),s=St(D),a=r.right-R.left,d=c.left-R.left-0,v=a+.5*(d-a),g=r.top+r.height/2,f=c.top+c.height/2,p=g-se+fe,h=f-ae+pe,x="conn-".concat(D,"-").concat(i);ce.push({lhsScrollY:p,rhsScrollY:h,x1:a,x2:d,containerTop:he,leftIdx:D,rhsArrayIdx:i,styleColor:(null==s?void 0:s.badgeBorder)||"#6366F1",styleId:x});var _=xe(g,se,ve),m=xe(f,ae,ge),y=_-he,S=m-he,b=g>=se-4&&g<=ve+4,A=f>=ae-4&&f<=ge+4,T="";T=b&&A?u.getBentArrowPath(a,y,d,S):b&&!A?"M ".concat(a,",").concat(y," L ").concat(v,",").concat(y," L ").concat(v,",").concat(S):!b&&A?"M ".concat(v,",").concat(y," L ").concat(v,",").concat(S," L ").concat(d,",").concat(S):"M ".concat(v,",").concat(y," L ").concat(v,",").concat(S),le.push({id:x,pathD:T,style:s,leftIdx:D,rhsArrayIdx:i})}}})}else{var j=e,w=j;v=null===(i=Fn.current[j])||void 0===i?void 0:i.current,g=null===(o=kn.current[w])||void 0===o?void 0:o.current;if(!v||!g)return;var P,N;f=v.getBoundingClientRect(),p=g.getBoundingClientRect(),h=St(j),x=(P=f.right-R.left)+.5*((N=p.left-R.left-0)-P),_=f.top+f.height/2,m=p.top+p.height/2,y=_-se+fe,S=m-ae+pe,b="conn-".concat(j,"-").concat(w);ce.push({lhsScrollY:y,rhsScrollY:S,x1:P,x2:N,containerTop:he,leftIdx:j,rhsArrayIdx:w,styleColor:(null==h?void 0:h.badgeBorder)||"#6366F1",styleId:b});var F;A=xe(_,se,ve),T=xe(m,ae,ge),E=A-he,I=T-he,B=m>=ae-4&&m<=ge+4,C="";C=(F=_>=se-4&&_<=ve+4)&&B?u.getBentArrowPath(P,E,N,I):F&&!B?"M ".concat(P,",").concat(E," L ").concat(x,",").concat(E," L ").concat(x,",").concat(I):!F&&B?"M ".concat(x,",").concat(E," L ").concat(x,",").concat(I," L ").concat(N,",").concat(I):"M ".concat(x,",").concat(E," L ").concat(x,",").concat(I),le.push({id:b,pathD:C,style:h,leftIdx:j,rhsArrayIdx:w})}}),we.current=ce}Be(le)}else Be([]),we.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{Qe.current=!1}var _e,me,ye}},[En,An,Tn,Me,fn,yt,St,$,de,Re,Ae,et,nt]),Tt=t.useCallback(function(){var e,n,t,i,o,l,r,c,s,a,d,v,g,f,p=we.current;if(p.length&&!De.current){var h=null!==(n=null===(e=Je.current)||void 0===e?void 0:e.scrollTop)&&void 0!==n?n:0,x=null!==(i=null===(t=We.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,_=null!==(l=null===(o=Je.current)||void 0===o?void 0:o.clientHeight)&&void 0!==l?l:1/0,m=null!==(c=null===(r=We.current)||void 0===r?void 0:r.clientHeight)&&void 0!==c?c:1/0,R=null!==(a=null===(s=Je.current)||void 0===s?void 0:s.getBoundingClientRect().top)&&void 0!==a?a:0,y=null!==(v=null===(d=We.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==v?v:0,S=R+_,b=y+m,A=null!==(f=null===(g=st.current)||void 0===g?void 0:g.getBoundingClientRect().top)&&void 0!==f?f:0,T=function(e,n,t){return Math.max(n,Math.min(t,e))};p.forEach(function(e){var n=e.lhsScrollY-h+R,t=e.rhsScrollY-x+y,i=je.current[e.styleId+"-stroke"],o=je.current[e.styleId+"-bg"];if(i||o){var l,r=T(n,R,S),c=T(t,y,b),s=r-A,a=c-A,d=n>=R-4&&n<=S+4,v=t>=y-4&&t<=b+4,g=e.x1+.5*(e.x2-e.x1);l=d&&v?u.getBentArrowPath(e.x1,s,e.x2,a):d&&!v?"M ".concat(e.x1,",").concat(s," L ").concat(g,",").concat(s," L ").concat(g,",").concat(a):!d&&v?"M ".concat(g,",").concat(s," L ").concat(g,",").concat(a," L ").concat(e.x2,",").concat(a):"M ".concat(g,",").concat(s," L ").concat(g,",").concat(a),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",l)),o&&(o.setAttribute("visibility","visible"),o.setAttribute("d",l))}})}},[]);t.useEffect(function(){ke.current=At},[At]);var Et=t.useRef(null),It=t.useRef(null),Bt=t.useCallback(function(){we.current.length>0&&!De.current||(null!==Et.current&&clearTimeout(Et.current),Et.current=setTimeout(function(){ke.current(),Et.current=null},50))},[]),Ct=t.useCallback(function(){_e(!0),pe(!1),null!==It.current&&clearTimeout(It.current),null!==Et.current&&(clearTimeout(Et.current),Et.current=null),It.current=setTimeout(function(){var e,n,t,i,o,l,r,c;if(we.current=[],Ne.current&&null!==Fe.current&&null!==dt.current){var s=Fe.current,a=dt.current,d=null,v=null,g=null,f=null;if("string"==typeof s&&s.includes(u.DEVIATION_BADGE_SEPARATOR)){var p=s.split(u.DEVIATION_BADGE_SEPARATOR),h="".concat(p[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(p[1]);d=(null===(e=Fn.current[h])||void 0===e?void 0:e.current)||null,v=(null===(n=kn.current[h])||void 0===n?void 0:n.current)||null,g=(null===(t=Ln.current[p[2]])||void 0===t?void 0:t.current)||null,f=(null===(i=Vn.current[p[3]])||void 0===i?void 0:i.current)||null}else d=(null===(o=Hn.current[s])||void 0===o?void 0:o.current)||null,g=(null===(l=Pn.current[s])||void 0===l?void 0:l.current)||null,v=(null===(r=Mn.current[a])||void 0===r?void 0:r.current)||null,f=(null===(c=Nn.current[a])||void 0===c?void 0:c.current)||null;if(d&&v&&g&&f){if(g.style.paddingTop="0px",f.style.paddingTop="0px",!$){var x=d.getBoundingClientRect(),_=v.getBoundingClientRect(),m=x.top-_.top;m>0?f.style.paddingTop="".concat(m,"px"):m<0&&(g.style.paddingTop="".concat(Math.abs(m),"px"))}var R=Je.current,y=We.current;if(R&&y){var S=d.getBoundingClientRect().top-R.getBoundingClientRect().top+R.scrollTop,b=v.getBoundingClientRect().top-y.getBoundingClientRect().top+y.scrollTop-(S-R.scrollTop);Math.abs(y.scrollTop-b)>1&&(y.scrollTop=b)}}}ke.current(),Ne.current&&pe(!0),_e(!1),It.current=null},150)},[$,An,Tn]),Dt=t.useCallback(function(e){var n,t,i,o,l,r,c,s,a,d;if(!Se.current){if($||Bt(),Ne.current){var v=Fe.current,g=dt.current,f=Je.current,p=We.current;if(null!==v&&null!==g&&f&&p){var h="string"==typeof v&&v.includes(u.DEVIATION_BADGE_SEPARATOR)?null===(n=Fn.current["".concat(v.split(u.DEVIATION_BADGE_SEPARATOR)[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(v.split(u.DEVIATION_BADGE_SEPARATOR)[1])])||void 0===n?void 0:n.current:null===(t=Hn.current[v])||void 0===t?void 0:t.current,x="string"==typeof g&&g.includes(u.DEVIATION_BADGE_SEPARATOR)?null===(i=kn.current["".concat(g.split(u.DEVIATION_BADGE_SEPARATOR)[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(g.split(u.DEVIATION_BADGE_SEPARATOR)[1])])||void 0===i?void 0:i.current:null===(o=Mn.current[g])||void 0===o?void 0:o.current;if(h&&x){var _=h.getBoundingClientRect().top-f.getBoundingClientRect().top+f.scrollTop,m=x.getBoundingClientRect().top-p.getBoundingClientRect().top+p.scrollTop;if(e.currentTarget===f){var R=m-(_-f.scrollTop),y=p.scrollHeight-p.clientHeight,S=Math.max(0,Math.min(R,y));Math.abs(p.scrollTop-S)>1&&(p.scrollTop=S)}else if(e.currentTarget===p){var b=_-(m-p.scrollTop),A=f.scrollHeight-f.clientHeight,T=Math.max(0,Math.min(b,A));Math.abs(f.scrollTop-T)>1&&(f.scrollTop=T)}if(vt.current){var E=void 0,I=void 0;if("string"==typeof v&&v.includes(u.DEVIATION_BADGE_SEPARATOR)){var B=v.split(u.DEVIATION_BADGE_SEPARATOR),C="".concat(B[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(B[1]);E=null===(l=Fn.current[C])||void 0===l?void 0:l.current,I=null===(r=kn.current[C])||void 0===r?void 0:r.current}else E=null===(c=Fn.current[v])||void 0===c?void 0:c.current,I=null===(s=kn.current[g])||void 0===s?void 0:s.current;var D=null!==(d=null===(a=st.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==d?d:0,O=f.getBoundingClientRect().top,j=O+f.clientHeight;p.getBoundingClientRect().top;p.clientHeight;if(E&&I){var w=E.getBoundingClientRect(),P=I.getBoundingClientRect(),N=w.top+w.height/2;P.top,P.height;var F=((M=N,L=O,V=j,Math.max(L,Math.min(V,M)))-D).toString();vt.current.setAttribute("y1",F),vt.current.setAttribute("y2",F);var k=N>=O-4&&N<=j+4;vt.current.setAttribute("visibility",k?"visible":"hidden")}}}}}var M,L,V;we.current.length>0&&!Pe.current&&(Pe.current=!0,requestAnimationFrame(function(){Tt(),Pe.current=!1}))}},[Tt,$,Bt]);t.useEffect(function(){var e=setTimeout(Bt,250);window.addEventListener("resize",Ct);var n=null,t=null;return qe.current&&(n=new ResizeObserver(Bt)).observe(qe.current),st.current&&(t=new ResizeObserver(Bt)).observe(st.current),function(){clearTimeout(e),null!==Et.current&&clearTimeout(Et.current),null!==It.current&&clearTimeout(It.current),window.removeEventListener("resize",Ct),null==n||n.disconnect(),null==t||t.disconnect()}},[Sn,bn,Wn,En,et,nt,An,Tn,fn,Bt,Ct,de,Re,fe,Ae]),t.useEffect(function(){Ne.current=de},[de]),t.useEffect(function(){Fe.current=Re},[Re]);var Ot=t.useCallback(function(e,n,t){var i,o,l,r,c,s,a=null===(i=null==t?void 0:t.toggleIfSame)||void 0===i||i,d=null==t?void 0:t.onReady,v=null!==(o=null==t?void 0:t.sourceSide)&&void 0!==o?o:"left";if(gn(),null!=e)if(n)se("No counterpart exists for this section.");else if(de&&Re===e)a?Zn():null==d||d();else{if(!$){var g=Fe.current,f=dt.current;if(null!==g)if("string"==typeof g&&g.includes(u.DEVIATION_BADGE_SEPARATOR)){var p=g.split(u.DEVIATION_BADGE_SEPARATOR);(h=null===(l=Ln.current[p[2]])||void 0===l?void 0:l.current)&&(h.style.paddingTop="0px")}else{var h;(h=null===(r=Pn.current[g])||void 0===r?void 0:r.current)&&(h.style.paddingTop="0px")}if(null!==f)if("string"==typeof f&&f.includes(u.DEVIATION_BADGE_SEPARATOR)){p=f.split(u.DEVIATION_BADGE_SEPARATOR);(x=null===(c=Vn.current[p[3]])||void 0===c?void 0:c.current)&&(x.style.paddingTop="0px")}else{var x;(x=null===(s=Nn.current[f])||void 0===s?void 0:s.current)&&(x.style.paddingTop="0px")}}Te(new Set),Be([]),we.current=[],re(!0),Se.current=!0,ye(e),Fe.current=e,ve(!0),Ne.current=!0,pe(!1),Ye.current&&(Ye.current.style.height="0px"),Ke.current&&(Ke.current.style.height="0px"),Ue.current&&(Ue.current.style.height="0px"),Xe.current&&(Xe.current.style.height="0px"),requestAnimationFrame(function(){var n,t,i,o,l,r,c,s,a,g,f=null,p=null,h=null,x=null,_=null;if("string"==typeof e&&e.includes(u.DEVIATION_BADGE_SEPARATOR)){var m=e.split(u.DEVIATION_BADGE_SEPARATOR),R="".concat(m[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(m[1]);f=(null===(n=Fn.current[R])||void 0===n?void 0:n.current)||null,_=(p=(null===(t=kn.current[R])||void 0===t?void 0:t.current)||null)?e:null,h=(null===(i=Ln.current[m[2]])||void 0===i?void 0:i.current)||null,x=(null===(o=Vn.current[m[3]])||void 0===o?void 0:o.current)||null}else if(f=(null===(l=Hn.current[e])||void 0===l?void 0:l.current)||null,h=(null===(r=Pn.current[e])||void 0===r?void 0:r.current)||null,$){var y=An[e],S=(null==y?void 0:y.refIndexes)||[];if(S.length>0){var b=S[0],A=Tn.findIndex(function(e){return e.selfIndex===b});-1!==A&&(p=(null===(a=Mn.current[A])||void 0===a?void 0:a.current)||null,x=(null===(g=Nn.current[A])||void 0===g?void 0:g.current)||null,_=A)}}else p=(null===(c=Mn.current[e])||void 0===c?void 0:c.current)||null,x=(null===(s=Nn.current[e])||void 0===s?void 0:s.current)||null,_=p?e:null;dt.current=_;var T=Je.current,E=We.current;if(!f||!T)return Se.current=!1,re(!1),void(null==d||d());if(!p||!E)return pe(!0),ke.current(),Se.current=!1,re(!1),void(null==d||d());if(!$){var I=f.getBoundingClientRect(),B=p.getBoundingClientRect(),C=I.top-B.top;h&&x&&(h.style.paddingTop="0px",x.style.paddingTop="0px",C>0?x.style.paddingTop="".concat(C,"px"):C<0&&(h.style.paddingTop="".concat(Math.abs(C),"px")));var D=0;D="right"===v?p?p.getBoundingClientRect().top:(null==x?void 0:x.getBoundingClientRect().top)||0:f?f.getBoundingClientRect().top:(null==h?void 0:h.getBoundingClientRect().top)||0;var O=qe.current,j=O?O.scrollTop+D-150:0;return O?void u.smoothScrollTo(O,j,200,function(){pe(!0),ke.current(),Se.current=!1,re(!1),null==d||d()}):(pe(!0),ke.current(),Se.current=!1,re(!1),void(null==d||d()))}var w=f.getBoundingClientRect().top-T.getBoundingClientRect().top+T.scrollTop,P=p.getBoundingClientRect().top-E.getBoundingClientRect().top+E.scrollTop,N=200;if("left"===v){var F=P-(w-T.scrollTop);F<0&&Ye.current&&(Ye.current.style.height="".concat(Math.abs(F),"px")),requestAnimationFrame(function(){var e,n=E.scrollHeight-E.clientHeight;if(F<0)e=0;else{if(F>n){var t=F-n;return Ke.current&&(Ke.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){u.smoothScrollTo(E,F,N,function(){pe(!0),ke.current(),Se.current=!1,re(!1),null==d||d()})})}e=F}u.smoothScrollTo(E,e,N,function(){pe(!0),ke.current(),Se.current=!1,re(!1),null==d||d()})})}else{var k=w-(P-E.scrollTop);k<0&&Ue.current&&(Ue.current.style.height="".concat(Math.abs(k),"px")),requestAnimationFrame(function(){var e,n=T.scrollHeight-T.clientHeight;if(k<0)e=0;else{if(k>n){var t=k-n;return Xe.current&&(Xe.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){u.smoothScrollTo(T,k,N,function(){pe(!0),ke.current(),Se.current=!1,re(!1),null==d||d()})})}e=k}u.smoothScrollTo(T,e,N,function(){pe(!0),ke.current(),Se.current=!1,re(!1),null==d||d()})})}})}},[Re,gn,Tn,de,$,An,Zn]),jt=t.useCallback(function(e,n,t,i){var o,l="string"==typeof i?u.safeStringify(i).trim():u.safeStringify(null==i?void 0:i.deviation_summary).trim(),r=e.currentTarget;vn();var c="left";(null===(o=We.current)||void 0===o?void 0:o.contains(r))&&(c="right"),t?l&&cn({open:!0,anchorEl:r,summary:i}):Ot(n,t,l?{toggleIfSame:!1,sourceSide:c,onReady:function(){cn({open:!0,anchorEl:r,summary:i})}}:{toggleIfSame:!1,sourceSide:c})},[Ot,vn,cn]),wt=t.useCallback(function(){var e,n=nn.sectionIdx,t=nn.isOrphan;if(sn(),null!=n){var i="left";nn.anchorEl&&(null===(e=We.current)||void 0===e?void 0:e.contains(nn.anchorEl))&&(i="right"),Ot(n,t,{sourceSide:i})}},[Ot,nn.isOrphan,nn.sectionIdx,nn.anchorEl,sn]),Pt=t.useCallback(function(){sn(),Zn()},[sn,Zn]),Nt=null!==nn.sectionIdx&&Ae.has(nn.sectionIdx),Ft=_.useDeviationNavigation({proposedSections:An,existingSections:Tn,parentDeviationRecord:In,expandedSections:et,maintainRelativeOrder:!!$,scrollContainerRef:qe,leftContainerRef:Je,lhsBadgeRefs:Fn,rhsBadgeRefs:kn}),kt=Ft.showDeviationNavigation,Mt=Ft.showOpenNodeRef,Lt=t.useMemo(function(){if(!Q)return null;for(var e in In){if((In[e]||[]).some(function(e){return e.id===Q}))return e}return null},[Q,In]),Vt=t.useRef(null);t.useEffect(function(){if(Q&&Vt.current!==Q){var n=!1,t=0,i=null,o=150,l=function(e,n){for(var t=function(e,i){if(!e)return null;if(e.id===n)return i;if(!Array.isArray(e.subsections))return null;for(var o=0;o<e.subsections.length;o++){var l=t(e.subsections[o],"".concat(i,"-").concat(o));if(l)return l}return null},i=0;i<e.length;i++){var o=t(e[i],String(i));if(o)return o}return null},r=function(){var c,s,a,d;if(!n){var v=null,g=null;for(var f in In){var p=In[f].find(function(e){return e.id===Q});if(p){v=f,g=p;break}}if(g&&v){var h=An.findIndex(function(e){return e.id===v});if(!($?!!et["left-".concat(h)]:!!et[String(h)])&&h>=0)return it(h,"left"),t+=1,void(i=setTimeout(r,450));var x=l(An,g.id),_=l(Tn,g.id);if(x&&!_){var m=x.split("-"),R=Number(m[0]);if($){var y=null===(s=null===(c=An[R])||void 0===c?void 0:c.refIndexes)||void 0===s?void 0:s[0],S=Tn.findIndex(function(e){return e.selfIndex===y});-1!==S&&(R=S)}_=e.__spreadArray([R],m.slice(1),!0).join("-")}if(x&&_){var b="".concat(g.id).concat(u.DEVIATION_BADGE_SEPARATOR,"0").concat(u.DEVIATION_BADGE_SEPARATOR).concat(x).concat(u.DEVIATION_BADGE_SEPARATOR).concat(_),A="".concat(g.id).concat(u.DEVIATION_BADGE_SEPARATOR,"0"),T=null===(a=Fn.current[A])||void 0===a?void 0:a.current,E=null===(d=kn.current[A])||void 0===d?void 0:d.current,I=$?Je.current:qe.current;if(T&&I){var B=T.getBoundingClientRect();if(0===B.height)return void((t+=1)<20&&(i=setTimeout(r,o)));var C=I.getBoundingClientRect(),D=B.top-C.top+I.scrollTop-C.height/2+B.height/2,O=function(){var e=window.getComputedStyle(T).color;T.style.transition="box-shadow 300ms ease-in-out",T.style.boxShadow="0 0 10px ".concat(e),E&&(E.style.transition="box-shadow 300ms ease-in-out",E.style.boxShadow="0 0 10px ".concat(e)),setTimeout(function(){T&&(T.style.boxShadow=""),E&&(E.style.boxShadow="")},2e3)},j=function(){var e,n,t,i=(null==g?void 0:g.evaluationResult)||(null===(e=null==J?void 0:J[null==g?void 0:g.id])||void 0===e?void 0:e.evaluation_result)||(null===(t=null===(n=null==H?void 0:H.nodes)||void 0===n?void 0:n[null==g?void 0:g.id])||void 0===t?void 0:t.evaluation_result)||null,o=(null==i?void 0:i.deviations)||{},l=Object.keys(o).sort()[0]||null,r=l?o[l]:null,u=(null==r?void 0:r.deviation_summary)||"";cn({open:!0,anchorEl:T,summary:{deviation_summary:u,deviation_title:null==i?void 0:i.deviation_title,evaluation_outputs:null==i?void 0:i.evaluation_outputs}})};Vt.current=Q,$?(I.scrollTo({top:D,behavior:"smooth"}),Ot(b,!1,{toggleIfSame:!1}),j(),setTimeout(function(){ke.current()},0),O()):u.smoothScrollTo(I,D,300,function(){n||(Ot(b,!1,{toggleIfSame:!1}),j(),setTimeout(function(){ke.current()},0),O())})}else(t+=1)<20&&(i=setTimeout(r,o))}else(t+=1)<20&&(i=setTimeout(r,o))}else(t+=1)<20&&(i=setTimeout(r,o))}};return i=setTimeout(r,o),function(){n=!0,i&&clearTimeout(i)}}},[Q,In,An,Tn,$,et,it,J,H,cn,Ot]);var Ht=function(e){var t=e.section,i=e.keyPath,o=e.depth,l=void 0===o?0:o,r=e.columnKey,u=void 0===r?"left":r,c=e.parentNodeId,s=void 0===c?"":c;return n.jsx(y.default,{section:t,keyPath:i,depth:l,columnKey:u,parentNodeId:s,expandedSubSections:nt,setExpandedSubSections:tt,maintainRelativeOrder:$||!1,proposedSections:An,existingSections:Tn,treeData:H,deviationNumberRegistry:Bn,connectedSections:Ae,activeSideBySideSection:Re,resolvedMarkdownStyles:Ge,getSubSectionRef:qn,getSubSectionCompareStyle:bt,getBadgeRef:zn,openMoreFunctionsPopup:rt,openSummaryPopup:jt,resetSideBySide:Zn,setConnectedSections:Te,setConnectedLines:Be,cachedConnectedPositions:we})};return n.jsxs(i.Box,e.__assign({ref:ze,sx:e.__assign(e.__assign({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},$?{}:{overflow:"visible"}),{position:"relative"})},{children:[te&&n.jsx(i.Box,e.__assign({sx:{position:"absolute",inset:0,bgcolor:"rgba(255, 255, 255, 0.6)",backdropFilter:"blur(10px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"8px"}},{children:n.jsx(v.default,{})})),un.open&&n.jsx(S.default,{open:un.open,anchorEl:un.anchorEl,containerEl:at.current,clipTopEl:gt.current,onClose:Pt,summary:un.summary}),n.jsx(d.default,{open:nn.open,anchorEl:nn.anchorEl,sectionTitle:nn.sectionTitle,referenceSectionTitle:nn.refSectionTitle,onClose:gn,onOpenCognitiveCompare:ut,onOpenSideBySide:wt,onConnect:ct,isConnected:Nt,isOrphan:nn.isOrphan}),$e.open&&n.jsx(a.default,{open:$e.open,popupRef:dn,position:on,popupConfig:U,onClose:function(){ln(null),en(function(n){return e.__assign(e.__assign({},n),{open:!1})}),an(null)},markdownStyles:W,sectionTitle:$e.sectionTitle,referenceSectionTitle:$e.refSectionTitle,cognitiveData:$e.cognitiveData,anchorEl:$e.anchorEl,sectionAnchorEl:$e.sectionAnchorEl,scrollContainerEl:qe.current,badgeStyle:$e.badgeStyle,docData:$e.docData,deviationData:$e.deviationData,isLoading:$e.isLoading}),n.jsx(i.Snackbar,e.__assign({open:!!ce,autoHideDuration:8e3,onClose:function(){return se(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(i.Alert,e.__assign({onClose:function(){return se(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:ce}))})),n.jsx(m.default,{componentHeaderText:V,displayConfig:K,maintainRelativeOrder:$,onToggleView:function(e){ie(!0),setTimeout(function(){ee(!e),Zn(),Te(new Set),Be([]),we.current=[],setTimeout(function(){ie(!1)},400)},50)}}),n.jsx(i.Box,e.__assign({ref:qe,onScroll:Dt,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:$?"hidden":"auto",borderTop:Yn&&Kn?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(i.Box,e.__assign({sx:e.__assign({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},$?{flex:1,minHeight:0}:{})},{children:n.jsxs(i.Box,e.__assign({ref:st,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"40px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},$?{flex:1,overflow:"visible"}:{})},{children:[n.jsxs("svg",e.__assign({ref:Ce,style:{position:"absolute",top:0,left:0,width:Ve.width||"100%",height:Ve.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",opacity:xe?0:1,transition:"opacity 0.15s ease-in-out"}},{children:[mt&&n.jsx("g",{children:n.jsx("line",{x1:mt.x1,y1:mt.y,x2:mt.x2,y2:mt.y,stroke:Qn.badgeBorder,strokeWidth:"1.5"})}),ht.map(function(t){var r,c,a,d,v,f,p=t.x1+.5*(t.x2-t.x1),h=(t.y1+t.y2)/2;if("Not Defined"===t.style.label&&!t.hasCognitive)return null;if(t.isSubSection?de&&Re===t.subSectionKeyPath&&fe:de&&Re===t.sectionIdx&&fe)return n.jsxs("g",e.__assign({style:{transition:"opacity 0.2s"}},{children:[n.jsx("defs",{children:n.jsx("marker",e.__assign({id:"arr-".concat(t.id),markerWidth:"7",markerHeight:"5",refX:"7",refY:"2.5",orient:"auto"},{children:n.jsx("polygon",{points:"0 0, 7 2.5, 0 5",fill:t.style.badgeBorder||"#6366F1"})}))}),n.jsx("line",{ref:vt,x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.badgeBorder||"#6366F1",strokeWidth:"1.5",markerEnd:"url(#arr-".concat(t.id,")")})]}),t.id);if(!$){var x=t.isSubSection?u.getBentArrowPath(t.x1,t.y1,t.x2,t.y2):"M ".concat(t.x1," ").concat(t.y1," L ").concat(t.x2," ").concat(t.y2),_=An[t.sectionIdx]||{title:"",content:""},m=Tn[t.sectionIdx]||{title:"",content:""};if(console.log("Base and Ref Sections for Badge:",_,m),t.isSubSection&&t.subSectionKeyPath){var R=t.subSectionKeyPath.split(u.DEVIATION_BADGE_SEPARATOR)[2].split("-").map(Number),y=An[R[0]],S=Tn[R[0]],b=(null==y?void 0:y.title)||"",A=(null==S?void 0:S.title)||"";console.log("Root Parent Titles:",b,A);for(var T=1;T<R.length;T++)(null==y?void 0:y.subsections)&&(y=y.subsections[R[T]]),(null==S?void 0:S.subsections)&&(S=S.subsections[R[T]]);y&&(_=e.__assign(e.__assign({},y),{title:b||y.title})),console.log("Base Section for Subsection Badge:",_),S&&(m=e.__assign(e.__assign({},S),{title:A||S.title})),console.log("Ref Section for Subsection Badge:",m)}var E=!(null===(r=_.cognitiveData)||void 0===r?void 0:r.isMissingRationale)||Boolean(null===(a=null===(c=_.cognitiveData)||void 0===c?void 0:c.decisioning)||void 0===a?void 0:a.length),I=(null===(f=null===(v=null===(d=_.evaluationResult)||void 0===d?void 0:d.cognitive_decisioning)||void 0===v?void 0:v.decisioning_factors)||void 0===f?void 0:f.length)||!1,B=E||I;return n.jsxs("g",{children:[n.jsx("path",{d:x,fill:"none",stroke:t.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),n.jsx("foreignObject",e.__assign({x:p-100,y:h-14,width:"200",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:n.jsx(i.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:n.jsxs(i.Box,e.__assign({onClick:function(e){e.stopPropagation(),B&&($e.open&&rn===t.id?vn():(an(t.id),lt(ot(e.currentTarget,_,m,t.sectionIdx,t.style))))},sx:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:t.style.badgeBg,color:t.style.badgeText,border:"1px solid ".concat(t.style.badgeBorder),borderRadius:"12px",px:1.5,py:.5,fontWeight:600,textAlign:"center",whiteSpace:"nowrap",cursor:B?"pointer":"default"}},{children:[t.style.badgeText===s.DEFAULT_DEVIAION_COLOR&&null==t.style.label?n.jsx(g.default,{color:t.style.badgeText}):0===t.style.label?"Same":t.style.label,n.jsx(i.Box,e.__assign({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n.jsx(l.ButtonCognitiveIcon,{})})),B&&n.jsx(o.ChevronDown,{size:11,style:{transform:$e.open&&rn===t.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},t.id)}return null}),Ie.map(function(t){var i,o=t.pathD,l=(null===(i=t.style)||void 0===i?void 0:i.badgeBorder)||"#6366F1",r="conn-marker-".concat(t.id),u="".concat(t.id,"-bg"),c="".concat(t.id,"-stroke");return n.jsxs("g",{children:[n.jsx("defs",{children:n.jsx("clipPath",e.__assign({id:"connections-clip"},{children:n.jsx("marker",e.__assign({id:r,markerWidth:"8",markerHeight:"6",refX:"7",refY:"3",orient:"auto"},{children:n.jsx("polygon",{points:"0 0, 8 3, 0 6",fill:l})}))}))}),n.jsx("path",{ref:function(e){je.current[u]=e},d:o,fill:"none",stroke:"#FFFFFF",strokeWidth:"4",strokeOpacity:"0.7"}),n.jsx("path",{ref:function(e){je.current[c]=e},d:o,fill:"none",stroke:l,strokeWidth:"1.75",markerEnd:"url(#".concat(r,")")})]},t.id)})]})),n.jsxs(i.Box,e.__assign({sx:e.__assign({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},$?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(i.Box,e.__assign({ref:gt,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:n.jsx(i.Tooltip,e.__assign({title:mn,placement:"top"},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:mn}))}))})),n.jsxs(i.Box,e.__assign({ref:Je,onScroll:Dt,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},$?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-160px",pr:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:Ue,style:{width:"100%",height:"0px",flexShrink:0}}),Dn&&An.map(function(t,l){var r,c,s=!t.title&&!t.content;if($&&s)return null;var a=t,d=St(l,"left"),v=$?!(null===(r=a.refIndexes)||void 0===r?void 0:r.length)||a.selfIndex<0:!Tn[l],f=$?"number"==typeof a.selfIndex&&a.selfIndex>=0?a.selfIndex+1:null:l+1,p=Ae.has(l),h=u.extractDeviationScore(a.evaluationResult,null==d?void 0:d.deviationLabel);return n.jsx(i.Box,e.__assign({ref:Gn(l),sx:{mb:1,width:"100%"}},{children:n.jsxs(i.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[n.jsx(i.Box,e.__assign({ref:Pn.current[l],sx:e.__assign({width:"100%",display:"flex"},p&&{borderRadius:"6px",outline:"2px solid ".concat((null==d?void 0:d.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:n.jsx(R.default,{section:t,idx:l,columnKey:"left",colRef:Gn("left-accordion-".concat(l)),mb:0,treeData:H,proposedSections:An,existingSections:Tn,deviationNumberRegistry:Bn,getSectionCompareStyle:St,getBadgeRef:zn,connectedSections:Ae,openMoreFunctionsPopup:rt,openSummaryPopup:jt,deviationNodeIdToView:Q,deviationTargetParentId:Lt,parentNodeId:(null===(c=null==H?void 0:H.input_index_map)||void 0===c?void 0:c[0])||"",isExpanded:$?!!et["left-".concat(l)]:!!et[String(l)],onToggle:function(){et[$?"left-".concat(l):String(l)]&&sn(),it(l,"left")},navigation:t.id?kt[t.id]:null,showOpenNodeRef:Mt,resolvedMarkdownStyles:Ge,maintainRelativeOrder:$,renderSubSections:Ht})})),$&&d&&n.jsxs(i.Box,e.__assign({ref:Fn.current[l],onClick:function(e){var n=$?Tn.find(function(e){var n;return null===(n=a.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""}:Tn[l]||{title:"",content:""};rt(e,t,v,n,l,d)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:d.badgeBg,color:d.badgeText,border:"1px solid ".concat(d.badgeBorder),borderRadius:"12px",px:1.2,py:.4,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[null!==f&&n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(d.badgeBorder)}},{children:f})),n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",px:.25}},{children:!K.isLoading||null!=a.evaluationResult&&null!=a.evaluationResult?v?"No Deviation Found":"N/A"===h||"NA"===h?"N/A":0==h||null==h?"Same":"".concat(h):n.jsx(g.default,{color:d.badgeText})})),n.jsx(o.EllipsisVertical,{size:11,color:d.badgeText})]}))]}))}),"left-row-".concat(l))}),n.jsx("div",{ref:Xe,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),n.jsx(i.Box,e.__assign({ref:at,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:n.jsx(i.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:n.jsxs(i.Box,e.__assign({onClick:function(n){n.stopPropagation(),$e.open&&rn===Un?vn():(an(Un),lt(ot(n.currentTarget,{title:"",content:"",evaluationResult:Xn,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,Un,!0,e.__assign(e.__assign({},Qn),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-5px",borderRadius:"20px",bgcolor:Qn.badgeBg,color:Qn.badgeText,border:"1px solid ".concat(Qn.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=Jn?Jn:n.jsx(g.default,{}),n.jsx(i.Box,e.__assign({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n.jsx(l.ButtonCognitiveIcon,{})})),n.jsx(o.ChevronDown,{size:11,style:{transform:$e.open&&rn===Un?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),n.jsxs(i.Box,e.__assign({sx:e.__assign({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},$?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[le&&n.jsx(r.default,{sections:11}),n.jsx(i.Box,e.__assign({ref:ft,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"40px",display:"flex",alignItems:"center",overflowX:"hidden"}},{children:n.jsx(i.Tooltip,e.__assign({title:Rn,placement:"top"},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:Rn}))}))})),n.jsxs(i.Box,e.__assign({ref:We,onScroll:Dt,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},$?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-120px",pl:"140px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:Ye,style:{width:"100%",height:"0px",flexShrink:0}}),Dn&&Tn.map(function(t,o){var l,r=t,u=[],c=!1,s=null,a=-1;if($){u=An.filter(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(r.selfIndex))&&e.selfIndex>=0}).map(function(e){return e.selfIndex+1}),a=An.findIndex(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(r.selfIndex))&&e.selfIndex>=0});var d=An.findIndex(function(e,n){var t;return Ae.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(r.selfIndex))});(c=-1!==d)&&(s=St(d))}else u=[o+1],(c=Ae.has(o))&&(s=St(o));var v=St($&&-1!==a?a:o);return n.jsx(i.Box,e.__assign({ref:Mn.current[o],sx:{mb:1,width:"100%"}},{children:n.jsxs(i.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[n.jsx(i.Box,e.__assign({ref:Nn.current[o],sx:e.__assign({width:"100%",display:"flex"},c&&s&&{borderRadius:"6px",outline:"2px solid ".concat(s.badgeBorder),outlineOffset:"1px"})},{children:n.jsx(R.default,{section:t,idx:o,columnKey:"right",colRef:Gn("right-accordion-".concat(o)),mb:0,parentNodeId:(null===(l=null==H?void 0:H.input_index_map)||void 0===l?void 0:l[1])||"",isExpanded:$?!!et["right-".concat(o)]:!!et[String(o)],treeData:H,proposedSections:An,existingSections:Tn,deviationNumberRegistry:Bn,getBadgeRef:zn,getSectionCompareStyle:St,connectedSections:Ae,openMoreFunctionsPopup:rt,openSummaryPopup:jt,deviationNodeIdToView:Q,deviationTargetParentId:Lt,onToggle:function(){et[$?"right-".concat(o):String(o)]&&sn(),it(o,"right")},navigation:t.id?kt[t.id]:null,showOpenNodeRef:Mt,resolvedMarkdownStyles:Ge,maintainRelativeOrder:$,renderSubSections:Ht})})),$&&!le&&v&&n.jsx(i.Box,e.__assign({ref:kn.current[o],"data-section-id":r.id,sx:{position:"absolute",top:"18px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"11px",bgcolor:v.badgeBg,color:v.badgeText,border:"1px solid ".concat(v.badgeBorder),borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:u.length>0?u.join(", "):"-"}))]}))}),"right-row-".concat(o))}),n.jsx("div",{ref:Ke,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),t=require("react"),i=require("@mui/material"),o=require("lucide-react"),r=require("../../assests/svg/ButtonCognitiveIcon.js"),l=require("./OverlayComponent.js"),u=require("./CognitiveComparehelpers.js"),c=require("./CognitiveCompareConfig.js"),a=require("./CognitiveCompareConstants.js"),s=require("./CognitivePopup.js"),d=require("./MoreFunctionsPopup.js"),v=require("./LoaderComponent.js"),g=require("./components/ThreeDotsLoader.js"),f=require("./hooks/useCompareData.js"),p=require("./hooks/useComparePopups.js"),h=require("./hooks/useSectionRefs.js"),x=require("./hooks/useAccordionState.js"),m=require("./hooks/useDeviationNavigation.js"),_=require("./components/CompareHeader.js"),R=require("./components/SectionAccordion.js"),y=require("./components/SubSectionAccordion.js"),S=require("./components/CognitiveSummaryPopup.js");exports.SHARED_MARKDOWN_STYLES=c.SHARED_MARKDOWN_STYLES,exports.default=function(A){var b,E,I,T,B,C,D,O,w,N,j,P,F,k,M,L=A.componentHeaderText,V=void 0===L?a.DEFAULT_COMPONENT_HEADER_TEXT:L,H=A.treeData,G=A.comparisonConfig,q=A.leftColumnTitleText,z=A.rightColumnTitleText,W=A.markdownStyles,Y=A.displayConfig,K=void 0===Y?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0}:Y,U=A.popupConfig,X=A.deviationData,J=void 0===X?{}:X,Q=A.deviationNodeIdToView,Z=A.resetDeviationNodeId,$=t.useState(K.maintainRelativeOrder),ee=$[0],ne=$[1],te=t.useState(!1),ie=te[0],oe=te[1],re=t.useState(!1),le=re[0],ue=re[1],ce=t.useState(null),ae=ce[0],se=ce[1],de=t.useState(!1),ve=de[0],ge=de[1],fe=t.useState(!1),pe=fe[0],he=fe[1],xe=t.useState(!1),me=xe[0],_e=xe[1],Re=t.useState(null),ye=Re[0],Se=Re[1],Ae=t.useRef(!1),be=t.useState(new Set),Ee=be[0],Ie=be[1],Te=t.useState([]),Be=Te[0],Ce=Te[1],De=t.useRef(null),Oe=t.useRef(!1),we=t.useRef(null),Ne=t.useRef({}),je=t.useRef([]),Pe=t.useRef(!1),Fe=t.useRef(!1),ke=t.useRef(null),Me=t.useRef(function(){}),Le=t.useMemo(function(){return(null==H?void 0:H.cognitive_decisioning)||{}},[H]),Ve=t.useState({width:0,height:0}),He=Ve[0],Ge=Ve[1],qe=t.useMemo(function(){return e.__assign(e.__assign({},c.SHARED_MARKDOWN_STYLES),W)},[W]),ze=t.useRef(null),We=t.useRef(null),Ye=t.useRef(null),Ke=t.useRef(null),Ue=t.useRef(null),Xe=t.useRef(null),Je=t.useRef(null),Qe=t.useRef(null),Ze=t.useRef(!1),$e=t.useRef(null),en=t.useRef(null),nn=p.useComparePopups(ze),tn=nn.cognitivePopup,on=nn.setCognitivePopup,rn=nn.moreFunctions,ln=nn.setMoreFunctions,un=nn.position,cn=nn.setPosition,an=nn.activeBadgeId,sn=nn.summaryPopup,dn=nn.setSummaryPopup,vn=nn.closeSummaryPopup,gn=nn.setActiveBadgeId,fn=nn.popupRef,pn=nn.closeCognitivePopup,hn=nn.closeMoreFunctionsPopup,xn=t.useMemo(function(){var e,n,t,i,o,r,l;return{fields:null!==(e=null==G?void 0:G.fields)&&void 0!==e?e:c.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(t=null===(n=null==G?void 0:G.thresholds)||void 0===n?void 0:n.high)&&void 0!==t?t:c.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(o=null===(i=null==G?void 0:G.thresholds)||void 0===i?void 0:i.medium)&&void 0!==o?o:c.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(l=null===(r=null==G?void 0:G.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:c.DEFAULT_COMPARISON_CONFIG.thresholds.exact}}},[G]),mn=t.useState(null),_n=mn[0];mn[1];var Rn=null===(I=null===(b=null==H?void 0:H.documents)||void 0===b?void 0:b[null===(E=null==H?void 0:H.input_index_map)||void 0===E?void 0:E[0]])||void 0===I?void 0:I.title,yn=null===(C=null===(T=null==H?void 0:H.documents)||void 0===T?void 0:T[null===(B=null==H?void 0:H.input_index_map)||void 0===B?void 0:B[1]])||void 0===C?void 0:C.title,Sn=u.safeStringify(q||Rn||"Uploaded Contract"),An=u.safeStringify(z||yn||"Reference Template"),bn=f.useCognitiveTreeData(H,ee,J,xn),En=bn.activeProposed,In=bn.existingRule,Tn=bn.proposedSections,Bn=bn.existingSections,Cn=bn.visibleFields,Dn=bn.parentDeviationRecord,On=bn.deviationNumberRegistry,wn=bn.parseError;t.useEffect(function(){wn&&se("Failed to load comparison: ".concat(wn))},[wn]);var Nn=Tn.length>0||Bn.length>0,jn=h.useSectionRefs(Cn.map(function(e){return e.key}),Math.max(Tn.length,Bn.length)),Pn=jn.leftRefs,Fn=jn.rightRefs,kn=jn.sectionLeftRefs,Mn=jn.sectionRightRefs,Ln=jn.lhsBadgeRefs,Vn=jn.rhsBadgeRefs,Hn=jn.sectionRightRowRefs,Gn=jn.subSectionLeftRefs,qn=jn.subSectionRightRefs,zn=jn.sectionRowRefs,Wn=jn.getSectionRowRef,Yn=jn.getSubSectionRef,Kn=jn.getBadgeRef,Un=In.analysis,Xn=u.safeStringify(null===(O=null===(D=null==Un?void 0:Un.rule_difference_comparison)||void 0===D?void 0:D.summary)||void 0===O?void 0:O.overall_summary),Jn=!!Xn.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),Qn=null!==(w=null==H?void 0:H.base_root_id)&&void 0!==w?w:"-1";null==H||H[Qn];var Zn=(null===(N=null==J?void 0:J[Qn])||void 0===N?void 0:N.evaluation_result)||(null===(P=null===(j=null==H?void 0:H.nodes)||void 0===j?void 0:j[Qn])||void 0===P?void 0:P.evaluation_result)||null,$n=u.extractDeviationScore(Zn),et=u.generateColorPalette(null!==(M=null===(k=null===(F=null==Zn?void 0:Zn.evaluation_outputs)||void 0===F?void 0:F.metadata)||void 0===k?void 0:k.label_color)&&void 0!==M?M:""),nt=t.useCallback(function(){var e,n,t,i,o,r;ge(!1),Fe.current=!1;var l=ke.current,c=ft.current;if(null!==l)if("string"==typeof l&&l.includes(u.DEVIATION_BADGE_SEPARATOR)){var a=l.split(u.DEVIATION_BADGE_SEPARATOR);(s=(null===(e=Gn.current[a[2]])||void 0===e?void 0:e.current)||(null===(n=kn.current[Number(a[2])])||void 0===n?void 0:n.current))&&(s.style.paddingTop="0px")}else{var s;(s=null===(t=kn.current[l])||void 0===t?void 0:t.current)&&(s.style.paddingTop="0px")}if(null!==c)if("string"==typeof c&&c.includes(u.DEVIATION_BADGE_SEPARATOR)){a=c.split(u.DEVIATION_BADGE_SEPARATOR);(d=(null===(i=qn.current[a[3]])||void 0===i?void 0:i.current)||(null===(o=Mn.current[Number(a[3])])||void 0===o?void 0:o.current))&&(d.style.paddingTop="0px")}else{var d;(d=null===(r=Mn.current[c])||void 0===r?void 0:r.current)&&(d.style.paddingTop="0px")}Se(null),ke.current=null,ft.current=null,he(!1),ue(!1),Ke.current&&(Ke.current.style.height="0px"),Ue.current&&(Ue.current.style.height="0px"),Xe.current&&(Xe.current.style.height="0px"),Je.current&&(Je.current.style.height="0px")},[]),tt=x.useAccordionState({maintainRelativeOrder:!!ee,proposedSections:Tn,existingSections:Bn,activeSideBySideSection:ye,connectedSections:Ee,resetSideBySide:nt,setConnectedSections:Ie,setConnectedLines:Ce,cachedConnectedPositions:je,svgContainerRef:De,isAnimatingRef:Oe,animationTimerRef:we,calculateLinesRef:Me,sectionLeftRefs:kn,sectionRightRefs:Mn,subSectionLeftRefs:Gn,subSectionRightRefs:qn}),it=tt.expandedSections,ot=tt.expandedSubSections,rt=tt.setExpandedSubSections,lt=tt.toggleSection,ut=t.useCallback(function(e,n,t,i,o,r,l){var c,a,s,d=u.safeStringify(null==n?void 0:n.id)||u.safeStringify(null==t?void 0:t.id)||"",v=(d?Le[d]:null)||(null==n?void 0:n.cognitiveData)||(null==t?void 0:t.cognitiveData)||{section_id:d,decisioning:[],gap:[],relevance_score:0},g=null!==(a=null===(c=zn.current[i])||void 0===c?void 0:c.current)&&void 0!==a?a:null;return{isLoading:null!==(s=null==K?void 0:K.isLoading)&&void 0!==s&&s,open:!0,sectionTitle:(null==n?void 0:n.displayTitle)?null==n?void 0:n.title:"no title",refSectionTitle:(null==t?void 0:t.displayTitle)?null==t?void 0:t.title:"no title",cognitiveData:v,anchorEl:e,sectionAnchorEl:g,badgeStyle:r||null,sectionIdx:i,docData:{documents:null==H?void 0:H.documents,input_index_map:null==H?void 0:H.input_index_map},deviationData:(null==n?void 0:n.evaluationResult)||(null==t?void 0:t.evaluationResult)||null,isOrphan:!!o}},[Le,H]),ct=t.useCallback(function(e){hn(),cn(null),on(e)},[hn]),at=function(e,n,t,i,o,r){var l;if(e.stopPropagation(),rn.open&&rn.sectionIdx===o)hn();else{var c=e.currentTarget,a="left";(null===(l=Ye.current)||void 0===l?void 0:l.contains(c))&&(a="right");Fe.current&&nt(),Ie(new Set),Ce([]),je.current=[],pn(),sn.open?kt():vn(),requestAnimationFrame(function(){var e=function(){var e,n,t,i;if("string"==typeof o&&o.includes(u.DEVIATION_BADGE_SEPARATOR)){var r=o.split(u.DEVIATION_BADGE_SEPARATOR),l="".concat(r[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(r[1]);return"right"===a?null===(e=Vn.current[l])||void 0===e?void 0:e.current:null===(n=Ln.current[l])||void 0===n?void 0:n.current}return"right"===a?null===(t=Vn.current[o])||void 0===t?void 0:t.current:null===(i=Ln.current[o])||void 0===i?void 0:i.current}()||c;ln(ut(e,n,i,o,t,r))})}},st=t.useCallback(function(){null!==rn.sectionIdx&&rn.anchorEl?ct(e.__assign(e.__assign({},rn),{open:!0})):hn()},[rn,hn,ct]),dt=t.useCallback(function(){var e=rn.sectionIdx,n=rn.isOrphan;hn(),vn(),null!==e&&(n?se("No counterpart exists to connect to."):(Fe.current&&nt(),Ce([]),je.current=[],Ie(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){Me.current&&Me.current()},50)))},[rn.sectionIdx,rn.isOrphan,hn,vn,nt]),vt=t.useRef(null),gt=t.useRef(null),ft=t.useRef(null),pt=t.useRef(null),ht=t.useRef(null),xt=t.useRef(null),mt=t.useState([]),_t=mt[0],Rt=mt[1];t.useRef(null);var yt=t.useState(null),St=yt[0],At=yt[1];t.useEffect(function(){if(_n){var e=xn.fields.find(function(e){return e.analysisKey===_n||e.key===_n});if(e){var n=Pn.current[e.key]||Fn.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[_n,xn.fields]);var bt=t.useCallback(function(e){var n,t,i,o,r,l,u,c,a,s=null===(n=null==Un?void 0:Un.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===(i=null===(t=null==d?void 0:d.highlights)||void 0===t?void 0:t.ruleA_spans)||void 0===i?void 0:i.length)||(null===(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 g=d.mappings[0]||{};return{score:d.score,relation:g.relation||"",highlightsA:(null===(l=g.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(u=g.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}},[Un]),Et=t.useCallback(function(n,t){var i,o,r,l,c,s,d;void 0===t&&(t="left");var v=null,g=null;if("left"===t)if(v=Tn[n],ee&&v){var f=Bn.filter(function(e){var n;return null===(n=v.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)});g=f.find(function(e){return e.evaluationResult})||f[0]}else g=Bn[n];else if(g=Bn[n],ee&&g){var p=Tn.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(g.selfIndex)});v=p.find(function(e){return e.evaluationResult})||p[0]}else v=Tn[n];var h=(null==v?void 0:v.relation)&&"not_defined"!==v.relation,x=(null==g?void 0:g.relation)&&"not_defined"!==g.relation,m=!(!(null==v?void 0:v.cognitiveData)&&!(null==g?void 0:g.cognitiveData));if(!h&&!x&&!m)return e.__assign(e.__assign({},u.generateColorPalette(a.DEFAULT_DEVIAION_COLOR)),{label:"Not Defined"});var _=null!==(o=null!==(i=null==v?void 0:v.evaluationResult)&&void 0!==i?i:null==g?void 0:g.evaluationResult)&&void 0!==o?o:null,R=null===(r=null==_?void 0:_.evaluation_outputs)||void 0===r?void 0:r.output_value,y=null!==(s=null===(c=null===(l=null==_?void 0:_.evaluation_outputs)||void 0===l?void 0:l.metadata)||void 0===c?void 0:c.label_color)&&void 0!==s?s:a.DEFAULT_DEVIAION_COLOR;return null!=_?e.__assign(e.__assign({},u.generateColorPalette(y)),{label:null!==(d=R)&&void 0!==d?d:""}):e.__assign(e.__assign({},u.generateColorPalette(y)),{label:null})},[Tn,Bn,Le,xn,ee]),It=t.useCallback(function(n){for(var t,i,o,r,l,c,s,d,v,g=n.split("-").map(Number),f=Tn[g[0]],p=Bn[g[0]],h=1;h<g.length;h++)(null==f?void 0:f.subsections)&&(f=f.subsections[g[h]]),(null==p?void 0:p.subsections)&&(p=p.subsections[g[h]]);if(!f&&!p)return null;var x=(null==f?void 0:f.relation)&&"not_defined"!==f.relation,m=(null==p?void 0:p.relation)&&"not_defined"!==p.relation,_=u.safeStringify(null==f?void 0:f.id)||u.safeStringify(null==p?void 0:p.id)||"",R=!(!(null==f?void 0:f.cognitiveData)&&!(null==p?void 0:p.cognitiveData));if(!x&&!m&&!R)return e.__assign(e.__assign({},u.generateColorPalette(a.DEFAULT_DEVIAION_COLOR)),{label:"Not Defined"});null!==(i=null!==(t=null==f?void 0:f.cognitiveRelevanceScore)&&void 0!==t?t:null==p?void 0:p.cognitiveRelevanceScore)&&void 0!==i||_&&(null===(o=Le[_])||void 0===o||o.relevance_score);var y=null!==(l=null!==(r=null==f?void 0:f.evaluationResult)&&void 0!==r?r:null==p?void 0:p.evaluationResult)&&void 0!==l?l:null,S=null===(c=null==y?void 0:y.evaluation_outputs)||void 0===c?void 0:c.output_value,A=null!==(v=null===(d=null===(s=null==y?void 0:y.evaluation_outputs)||void 0===s?void 0:s.metadata)||void 0===d?void 0:d.label_color)&&void 0!==v?v:a.DEFAULT_DEVIAION_COLOR;return null!=y?e.__assign(e.__assign({},u.generateColorPalette(A)),{label:null!=S?S:""}):e.__assign(e.__assign({},u.generateColorPalette(A)),{label:null})},[Tn,Bn,Le,xn]),Tt=t.useCallback(function(){var e,n,t,i,o,r,l,c,a,s,d,v,g,f,p,h,x,m,_,R,y,S;if(!Ze.current&&!Oe.current){Ze.current=!0;try{if(!vt.current)return;var A=function(e){var n=e.split("-"),t=n[0];if(!it[t]&&!1===ee)return!1;if(ee&&!it["left-".concat(t)]&&!it["right-".concat(t)]&&!it[t])return!1;for(var i=t,o=1;o<n.length-1;o++)if(i+="-".concat(n[o]),!ot[i])return!1;return!0},b=vt.current.getBoundingClientRect();Ge({width:b.width,height:b.height});var E=[];if(Cn.forEach(function(e){var n,t,i=e.key,o=null===(n=Pn.current[i])||void 0===n?void 0:n.current,r=null===(t=Fn.current[i])||void 0===t?void 0:t.current;o&&r&&(o.style.height="auto",r.style.height="auto",o.style.minHeight="0px",r.style.minHeight="0px")}),!Oe.current){for(var I=0;I<Math.max(Tn.length,Bn.length);I++){var T=null===(e=kn.current[I])||void 0===e?void 0:e.current,B=null===(n=Mn.current[I])||void 0===n?void 0:n.current;T&&(T.style.height="auto",T.style.minHeight="0px"),B&&(B.style.height="auto",B.style.minHeight="0px")}ee||Object.keys(Gn.current).forEach(function(e){var n,t;if(A(e)){var i=null===(n=Gn.current[e])||void 0===n?void 0:n.current,o=null===(t=qn.current[e])||void 0===t?void 0:t.current;i&&o&&(i.style.height="auto",o.style.height="auto",i.style.minHeight="0px",o.style.minHeight="0px")}})}var C={};Cn.forEach(function(e){var n,t,i=e.key,o=null===(n=Pn.current[i])||void 0===n?void 0:n.current,r=null===(t=Fn.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),u=r.getBoundingClientRect();C[i]=Math.max(l.height,u.height)}});var D={left:{},right:{}},O={};if(!Oe.current)if(ee){if(ve&&null!==ye)if("number"==typeof ye){var w=ye,N=Tn[w],j=null===(o=kn.current[w])||void 0===o?void 0:o.current;j&&N&&(N.refIndexes||[]).forEach(function(e){var n,t=Bn.findIndex(function(n){return n.selfIndex===e}),i=null===(n=Mn.current[t])||void 0===n?void 0:n.current;if(i&&(it["left-".concat(w)]||it["right-".concat(t)])){var o=Math.max(j.getBoundingClientRect().height,i.getBoundingClientRect().height);D.left[w]=Math.max(D.left[w]||0,o),D.right[t]=Math.max(D.right[t]||0,o)}})}else{var P=ye.split(u.DEVIATION_BADGE_SEPARATOR)[2];if(P){T=null===(r=Gn.current[P])||void 0===r?void 0:r.current,B=null===(l=qn.current[P])||void 0===l?void 0:l.current;if(T&&B){F=Math.max(T.getBoundingClientRect().height,B.getBoundingClientRect().height);O[P]=Math.max(O[P]||0,F)}}}}else{Object.keys(Gn.current).forEach(function(e){var n,t;if(A(e)){var i=null===(n=Gn.current[e])||void 0===n?void 0:n.current,o=null===(t=qn.current[e])||void 0===t?void 0:t.current;if(i&&o&&null!==i.offsetParent&&null!==o.offsetParent){var r=i.getBoundingClientRect(),l=o.getBoundingClientRect(),u=Math.max(r.height,l.height);O[e]=u,i.style.minHeight="".concat(u,"px"),o.style.minHeight="".concat(u,"px")}}});for(I=0;I<Math.min(Tn.length,Bn.length);I++){var T=null===(t=kn.current[I])||void 0===t?void 0:t.current,B=null===(i=Mn.current[I])||void 0===i?void 0:i.current;if(T&&B){var F=Math.max(T.getBoundingClientRect().height,B.getBoundingClientRect().height);D.left[I]=F,D.right[I]=F}}}if(Cn.forEach(function(e){var n,t,i=e.key,o=null===(n=Pn.current[i])||void 0===n?void 0:n.current,r=null===(t=Fn.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=C[i];o.style.minHeight="".concat(l,"px"),r.style.minHeight="".concat(l,"px")}}),Oe.current||(Object.entries(D.left).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=kn.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),Object.entries(D.right).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=Mn.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),ee||Object.keys(O).forEach(function(e){var n,t,i=null===(n=Gn.current[e])||void 0===n?void 0:n.current,o=null===(t=qn.current[e])||void 0===t?void 0:t.current;if(i&&o&&O[e]){var r=O[e];i.style.minHeight="".concat(r,"px"),o.style.minHeight="".concat(r,"px")}})),ee)Tn.forEach(function(e,n){var t;(null===(t=kn.current[n])||void 0===t?void 0:t.current)&&(e.refIndexes||[]).forEach(function(e){var t,i,o,r,l,u,c,a,s,d,v=Bn.findIndex(function(n){return n.selfIndex===e});if(-1!==v){var g=null===(t=Ln.current[n])||void 0===t?void 0:t.current,f=null===(i=Vn.current[v])||void 0===i?void 0:i.current;if(g&&f){var p=g.getBoundingClientRect(),h=f.getBoundingClientRect(),x=p.right-b.left,m=h.left-b.left,_=p.top+p.height/2-b.top,R=h.top+h.height/2-b.top;if(ve&&ye===n){var y=null!==(r=null===(o=Qe.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==r?r:0,S=null!==(u=null===(l=Ye.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==u?u:0,A=y+(null!==(a=null===(c=Qe.current)||void 0===c?void 0:c.clientHeight)&&void 0!==a?a:1/0),I=S+(null!==(d=null===(s=Ye.current)||void 0===s?void 0:s.clientHeight)&&void 0!==d?d:1/0),T=p.top+p.height/2,B=h.top+h.height/2,C=function(e,n,t){return Math.max(n,Math.min(t,e))};_=C(T,y,A)-b.top,R=C(B,S,I)-b.top}var D=Et(n);D&&E.push({id:"line-".concat(n,"-").concat(v),x1:x,y1:_,x2:m,y2:R,style:D,sectionIdx:n,targetRightIdx:v})}}})});else{for(I=0;I<Math.min(Tn.length,Bn.length);I++){var k=null===(c=kn.current[I])||void 0===c?void 0:c.current,M=null===(a=Mn.current[I])||void 0===a?void 0:a.current;if(k&&M){var L=k.getBoundingClientRect(),V=M.getBoundingClientRect(),H=Math.max(L.top,V.top)+18-b.top,G=(null===(s=Bn[I])||void 0===s?void 0:s.id)||"sec-".concat(I);(J=Et(I))&&E.push({id:G,x1:L.right-b.left,y1:H,x2:V.left-b.left,y2:H,style:J,sectionIdx:I,hasCognitive:!!((null===(d=Tn[I])||void 0===d?void 0:d.cognitiveData)||(null===(v=Bn[I])||void 0===v?void 0:v.cognitiveData)||G&&Le[G]),isSubSection:!1})}}Object.keys(Gn.current).forEach(function(e){var n,t,i,o,r,l;if(A(e)){var c=null===(n=Gn.current[e])||void 0===n?void 0:n.current,a=null===(t=qn.current[e])||void 0===t?void 0:t.current;if(c&&a){for(var s=e.split("-").map(Number),d=Tn[s[0]],v=Bn[s[0]],g=1;g<s.length;g++)(null==d?void 0:d.subsections)&&(d=d.subsections[s[g]]),(null==v?void 0:v.subsections)&&(v=v.subsections[s[g]]);var f=!!d&&((null===(i=d.displayTitle)||void 0===i||i)&&u.hasValue(d.title)),p=!!d&&((null===(o=d.displayContent)||void 0===o||o)&&u.hasValue(d.content)),h=!!v&&((null===(r=v.displayTitle)||void 0===r||r)&&u.hasValue(v.title)),x=!!v&&((null===(l=v.displayContent)||void 0===l||l)&&u.hasValue(v.content));if(f&&p||h&&x){var m=c.getBoundingClientRect(),_=a.getBoundingClientRect(),R=Math.max(m.top,_.top)+16-b.top,y=It(e);y&&"Not Defined"!==y.label&&E.push({id:"subsec-".concat(e),x1:m.right-b.left,y1:R,x2:_.left-b.left,y2:R,style:y,sectionIdx:s[0],isSubSection:!0,subSectionKeyPath:e,hasCognitive:!(!(null==d?void 0:d.cognitiveData)&&!(null==v?void 0:v.cognitiveData))})}}}})}if(ve&&"string"==typeof ye&&ye.includes(u.DEVIATION_BADGE_SEPARATOR)){var q=ye.split(u.DEVIATION_BADGE_SEPARATOR),z=q[0],W=q[1],Y=q[2],K=(q[3],"".concat(z).concat(u.DEVIATION_BADGE_SEPARATOR).concat(W)),U=null===(g=Ln.current[K])||void 0===g?void 0:g.current,X=null===(f=Vn.current[K])||void 0===f?void 0:f.current;if(U&&X){var J,Q=U.getBoundingClientRect(),Z=X.getBoundingClientRect(),$=Q.right-b.left,ne=Z.left-b.left,te=Q.top+Q.height/2-b.top,ie=Z.top+Z.height/2-b.top;if(ee){var oe=null!==(h=null===(p=Qe.current)||void 0===p?void 0:p.getBoundingClientRect().top)&&void 0!==h?h:0,re=null!==(m=null===(x=Ye.current)||void 0===x?void 0:x.getBoundingClientRect().top)&&void 0!==m?m:0,le=oe+(null!==(R=null===(_=Qe.current)||void 0===_?void 0:_.clientHeight)&&void 0!==R?R:1/0),ue=re+(null!==(S=null===(y=Ye.current)||void 0===y?void 0:y.clientHeight)&&void 0!==S?S:1/0),ce=function(e,n,t){return Math.max(n,Math.min(t,e))};te=ce(Q.top+Q.height/2,oe,le)-b.top,ie=ce(Z.top+Z.height/2,re,ue)-b.top}(J=It(Y))&&E.push({id:"line-subsec-".concat(K),x1:$,y1:te,x2:ne,y2:ie,style:J,sectionIdx:Number(Y.split("-")[0]),isSubSection:!0,subSectionKeyPath:ye})}}if(Rt(E),ht.current&&xt.current){var ae=ht.current.getBoundingClientRect(),se=xt.current.getBoundingClientRect(),de=(ae.top+ae.height/2-b.top+se.top+se.height/2-b.top)/2;At({x1:ae.right-b.left,x2:se.left-b.left,y:de})}else At(null);if(Ee.size>0){var ge=[],fe=Qe.current,pe=Ye.current;if(fe&&pe){var he=[],xe=fe.getBoundingClientRect().top,me=pe.getBoundingClientRect().top,_e=xe+fe.clientHeight,Re=me+pe.clientHeight,Se=fe.scrollTop,Ae=pe.scrollTop,be=b.top,Ie=function(e,n,t){return Math.max(n,Math.min(t,e))};Ee.forEach(function(e){var n,t,i,o,r;if("string"==typeof e&&e.includes(u.DEVIATION_BADGE_SEPARATOR)){var l=e.split(u.DEVIATION_BADGE_SEPARATOR),c=l[0],a=l[1],s=l[2],d=(l[3],"".concat(c).concat(u.DEVIATION_BADGE_SEPARATOR).concat(a)),v=null===(n=Ln.current[d])||void 0===n?void 0:n.current,g=null===(t=Vn.current[d])||void 0===t?void 0:t.current;if(!v||!g)return;var f=v.getBoundingClientRect(),p=g.getBoundingClientRect(),h=It(s),x=(j=f.right-b.left)+.5*((P=p.left-b.left-0)-j),m=f.top+f.height/2,_=p.top+p.height/2,R=m-xe+Se,y=_-me+Ae,S="conn-subsec-".concat(d);he.push({lhsScrollY:R,rhsScrollY:y,x1:j,x2:P,containerTop:be,leftIdx:e,rhsArrayIdx:e,styleColor:(null==h?void 0:h.badgeBorder)||"#6366F1",styleId:S});var A=Ie(m,xe,_e),E=Ie(_,me,Re),I=A-be,T=E-be,B=_>=me-4&&_<=Re+4,C="";C=(F=m>=xe-4&&m<=_e+4)&&B?u.getBentArrowPath(j,I,P,T):F&&!B?"M ".concat(j,",").concat(I," L ").concat(x,",").concat(I," L ").concat(x,",").concat(T):!F&&B?"M ".concat(x,",").concat(I," L ").concat(x,",").concat(T," L ").concat(P,",").concat(T):"M ".concat(x,",").concat(I," L ").concat(x,",").concat(T),ge.push({id:S,pathD:C,style:h,leftIdx:e,rhsArrayIdx:e})}else if(ee){var D=e,O=Tn[D];if(!(null===(r=null==O?void 0:O.refIndexes)||void 0===r?void 0:r.length))return;O.refIndexes.forEach(function(e){var n,t,i=Bn.findIndex(function(n){return n.selfIndex===e});if(-1!==i){var o=null===(n=Ln.current[D])||void 0===n?void 0:n.current,r=null===(t=Vn.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),c=r.getBoundingClientRect(),a=Et(D),s=l.right-b.left,d=c.left-b.left-0,v=s+.5*(d-s),g=l.top+l.height/2,f=c.top+c.height/2,p=g-xe+Se,h=f-me+Ae,x="conn-".concat(D,"-").concat(i);he.push({lhsScrollY:p,rhsScrollY:h,x1:s,x2:d,containerTop:be,leftIdx:D,rhsArrayIdx:i,styleColor:(null==a?void 0:a.badgeBorder)||"#6366F1",styleId:x});var m=Ie(g,xe,_e),_=Ie(f,me,Re),R=m-be,y=_-be,S=g>=xe-4&&g<=_e+4,A=f>=me-4&&f<=Re+4,E="";E=S&&A?u.getBentArrowPath(s,R,d,y):S&&!A?"M ".concat(s,",").concat(R," L ").concat(v,",").concat(R," L ").concat(v,",").concat(y):!S&&A?"M ".concat(v,",").concat(R," L ").concat(v,",").concat(y," L ").concat(d,",").concat(y):"M ".concat(v,",").concat(R," L ").concat(v,",").concat(y),ge.push({id:x,pathD:E,style:a,leftIdx:D,rhsArrayIdx:i})}}})}else{var w=e,N=w;v=null===(i=Ln.current[w])||void 0===i?void 0:i.current,g=null===(o=Vn.current[N])||void 0===o?void 0:o.current;if(!v||!g)return;var j,P;f=v.getBoundingClientRect(),p=g.getBoundingClientRect(),h=Et(w),x=(j=f.right-b.left)+.5*((P=p.left-b.left-0)-j),m=f.top+f.height/2,_=p.top+p.height/2,R=m-xe+Se,y=_-me+Ae,S="conn-".concat(w,"-").concat(N);he.push({lhsScrollY:R,rhsScrollY:y,x1:j,x2:P,containerTop:be,leftIdx:w,rhsArrayIdx:N,styleColor:(null==h?void 0:h.badgeBorder)||"#6366F1",styleId:S});var F;A=Ie(m,xe,_e),E=Ie(_,me,Re),I=A-be,T=E-be,B=_>=me-4&&_<=Re+4,C="";C=(F=m>=xe-4&&m<=_e+4)&&B?u.getBentArrowPath(j,I,P,T):F&&!B?"M ".concat(j,",").concat(I," L ").concat(x,",").concat(I," L ").concat(x,",").concat(T):!F&&B?"M ".concat(x,",").concat(I," L ").concat(x,",").concat(T," L ").concat(P,",").concat(T):"M ".concat(x,",").concat(I," L ").concat(x,",").concat(T),ge.push({id:S,pathD:C,style:h,leftIdx:w,rhsArrayIdx:N})}}),je.current=he}Ce(ge)}else Ce([]),je.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{Ze.current=!1}}},[Cn,Tn,Bn,Le,xn,bt,Et,ee,ve,ye,Ee,it,ot]),Bt=t.useCallback(function(){var e,n,t,i,o,r,l,c,a,s,d,v,g,f,p=je.current;if(p.length&&!Oe.current){var h=null!==(n=null===(e=Qe.current)||void 0===e?void 0:e.scrollTop)&&void 0!==n?n:0,x=null!==(i=null===(t=Ye.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,m=null!==(r=null===(o=Qe.current)||void 0===o?void 0:o.clientHeight)&&void 0!==r?r:1/0,_=null!==(c=null===(l=Ye.current)||void 0===l?void 0:l.clientHeight)&&void 0!==c?c:1/0,R=null!==(s=null===(a=Qe.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==s?s:0,y=null!==(v=null===(d=Ye.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==v?v:0,S=R+m,A=y+_,b=null!==(f=null===(g=vt.current)||void 0===g?void 0:g.getBoundingClientRect().top)&&void 0!==f?f:0,E=function(e,n,t){return Math.max(n,Math.min(t,e))};p.forEach(function(e){var n=e.lhsScrollY-h+R,t=e.rhsScrollY-x+y,i=Ne.current[e.styleId+"-stroke"],o=Ne.current[e.styleId+"-bg"];if(i||o){var r,l=E(n,R,S),c=E(t,y,A),a=l-b,s=c-b,d=n>=R-4&&n<=S+4,v=t>=y-4&&t<=A+4,g=e.x1+.5*(e.x2-e.x1);r=d&&v?u.getBentArrowPath(e.x1,a,e.x2,s):d&&!v?"M ".concat(e.x1,",").concat(a," L ").concat(g,",").concat(a," L ").concat(g,",").concat(s):!d&&v?"M ".concat(g,",").concat(a," L ").concat(g,",").concat(s," L ").concat(e.x2,",").concat(s):"M ".concat(g,",").concat(a," L ").concat(g,",").concat(s),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",r)),o&&(o.setAttribute("visibility","visible"),o.setAttribute("d",r))}})}},[]);t.useEffect(function(){Me.current=Tt},[Tt]);var Ct=t.useRef(null),Dt=t.useRef(null),Ot=t.useCallback(function(){je.current.length>0&&!Oe.current||(null!==Ct.current&&clearTimeout(Ct.current),Ct.current=setTimeout(function(){Me.current(),Ct.current=null},50))},[]),wt=t.useCallback(function(){_e(!0),he(!1),null!==Dt.current&&clearTimeout(Dt.current),null!==Ct.current&&(clearTimeout(Ct.current),Ct.current=null),Dt.current=setTimeout(function(){var e,n,t,i,o,r,l,c,a,s;if(je.current=[],Fe.current&&null!==ke.current&&null!==ft.current){var d=ke.current,v=ft.current,g=null,f=null,p=null,h=null;if("string"==typeof d&&d.includes(u.DEVIATION_BADGE_SEPARATOR)){var x=d.split(u.DEVIATION_BADGE_SEPARATOR),m="".concat(x[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(x[1]);g=(null===(e=Ln.current[m])||void 0===e?void 0:e.current)||null,f=(null===(n=Vn.current[m])||void 0===n?void 0:n.current)||null,p=(null===(t=Gn.current[x[2]])||void 0===t?void 0:t.current)||(null===(i=kn.current[Number(x[2])])||void 0===i?void 0:i.current)||null,h=(null===(o=qn.current[x[3]])||void 0===o?void 0:o.current)||(null===(r=Mn.current[Number(x[3])])||void 0===r?void 0:r.current)||null}else g=(null===(l=zn.current[d])||void 0===l?void 0:l.current)||null,p=(null===(c=kn.current[d])||void 0===c?void 0:c.current)||null,f=(null===(a=Hn.current[v])||void 0===a?void 0:a.current)||null,h=(null===(s=Mn.current[v])||void 0===s?void 0:s.current)||null;if(g&&f&&p&&h){if(p.style.paddingTop="0px",h.style.paddingTop="0px",!ee){var _=g.getBoundingClientRect(),R=f.getBoundingClientRect(),y=_.top-R.top;y>0?h.style.paddingTop="".concat(y,"px"):y<0&&(p.style.paddingTop="".concat(Math.abs(y),"px"))}var S=Qe.current,A=Ye.current;if(S&&A){var b=g.getBoundingClientRect().top-S.getBoundingClientRect().top+S.scrollTop,E=f.getBoundingClientRect().top-A.getBoundingClientRect().top+A.scrollTop-(b-S.scrollTop);Math.abs(A.scrollTop-E)>1&&(A.scrollTop=E)}}}Me.current(),Fe.current&&he(!0),_e(!1),Dt.current=null},150)},[ee,Tn,Bn]),Nt=t.useCallback(function(e){var n,t,i,o,r,l,c,a,s,d;if(null!==$e.current&&en.current&&Math.abs(e.currentTarget.scrollTop-$e.current)<=2){var v=en.current;$e.current=null,en.current=null,v()}if(!Ae.current){if(ee||Ot(),Fe.current){var g=ke.current,f=ft.current,p=Qe.current,h=Ye.current;if(null!==g&&null!==f&&p&&h){var x="string"==typeof g&&g.includes(u.DEVIATION_BADGE_SEPARATOR)?null===(n=Ln.current["".concat(g.split(u.DEVIATION_BADGE_SEPARATOR)[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(g.split(u.DEVIATION_BADGE_SEPARATOR)[1])])||void 0===n?void 0:n.current:null===(t=zn.current[g])||void 0===t?void 0:t.current,m="string"==typeof f&&f.includes(u.DEVIATION_BADGE_SEPARATOR)?null===(i=Vn.current["".concat(f.split(u.DEVIATION_BADGE_SEPARATOR)[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(f.split(u.DEVIATION_BADGE_SEPARATOR)[1])])||void 0===i?void 0:i.current:null===(o=Hn.current[f])||void 0===o?void 0:o.current;if(x&&m&&pt.current){var _=void 0,R=void 0;if("string"==typeof g&&g.includes(u.DEVIATION_BADGE_SEPARATOR)){var y=g.split(u.DEVIATION_BADGE_SEPARATOR),S="".concat(y[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(y[1]);_=null===(r=Ln.current[S])||void 0===r?void 0:r.current,R=null===(l=Vn.current[S])||void 0===l?void 0:l.current}else _=null===(c=Ln.current[g])||void 0===c?void 0:c.current,R=null===(a=Vn.current[f])||void 0===a?void 0:a.current;var A=null!==(d=null===(s=vt.current)||void 0===s?void 0:s.getBoundingClientRect().top)&&void 0!==d?d:0,b=p.getBoundingClientRect().top,E=b+p.clientHeight;h.getBoundingClientRect().top;h.clientHeight;if(_&&R){var I=_.getBoundingClientRect(),T=R.getBoundingClientRect(),B=I.top+I.height/2;T.top,T.height;var C=((O=B,w=b,N=E,Math.max(w,Math.min(N,O)))-A).toString();pt.current.setAttribute("y1",C),pt.current.setAttribute("y2",C);var D=B>=b-4&&B<=E+4;pt.current.setAttribute("visibility",D?"visible":"hidden")}}}}var O,w,N;je.current.length>0&&!Pe.current&&(Pe.current=!0,requestAnimationFrame(function(){Bt(),Pe.current=!1}))}},[Bt,ee,Ot]);t.useEffect(function(){var e=setTimeout(Ot,250);window.addEventListener("resize",wt);var n=null,t=null;return ze.current&&(n=new ResizeObserver(Ot)).observe(ze.current),vt.current&&(t=new ResizeObserver(Ot)).observe(vt.current),function(){clearTimeout(e),null!==Ct.current&&clearTimeout(Ct.current),null!==Dt.current&&clearTimeout(Dt.current),window.removeEventListener("resize",wt),null==n||n.disconnect(),null==t||t.disconnect()}},[En,In,Un,Cn,it,ot,Tn,Bn,xn,Ot,wt,ve,ye,pe,Ee]),t.useEffect(function(){Fe.current=ve},[ve]),t.useEffect(function(){ke.current=ye},[ye]);var jt=t.useCallback(function(e,n,t){var i,o,r=null===(i=null==t?void 0:t.toggleIfSame)||void 0===i||i,l=null==t?void 0:t.onReady,c=null!==(o=null==t?void 0:t.sourceSide)&&void 0!==o?o:"left";hn(),null!=e&&(n?se("No counterpart exists for this section."):ve&&ye===e?r?nt():null==l||l():(Ie(new Set([e])),Ce([]),je.current=[],ue(!0),Ae.current=!0,Se(e),ke.current=e,ge(!0),Fe.current=!0,he(!1),Ke.current&&(Ke.current.style.height="0px"),Ue.current&&(Ue.current.style.height="0px"),Xe.current&&(Xe.current.style.height="0px"),Je.current&&(Je.current.style.height="0px"),requestAnimationFrame(function(){var n,t,i,o,r,a="string"==typeof e&&e.includes(u.DEVIATION_BADGE_SEPARATOR),s=null,d=null,v=null;if(a){var g=e.split(u.DEVIATION_BADGE_SEPARATOR),f="".concat(g[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(g[1]);s=(null===(n=Ln.current[f])||void 0===n?void 0:n.current)||null,d=(null===(t=Vn.current[f])||void 0===t?void 0:t.current)||null,v=d?e:null}else if(s=(null===(i=zn.current[e])||void 0===i?void 0:i.current)||null,ee){var p=Tn[e],h=(null==p?void 0:p.refIndexes)||[];if(h.length>0){var x=h[0],m=Bn.findIndex(function(e){return e.selfIndex===x});-1!==m&&(d=(null===(r=Hn.current[m])||void 0===r?void 0:r.current)||null,v=m)}}else d=(null===(o=Hn.current[e])||void 0===o?void 0:o.current)||null,v=d?e:null;ft.current=v;var _=Qe.current,R=Ye.current,y=function(){!function(){var n,t,i,o,r,l,c,s,d,g,f,p,h=null,x=null,m=null,_=null;if(a){var R=e.split(u.DEVIATION_BADGE_SEPARATOR),y="".concat(R[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(R[1]);h=(null===(n=Gn.current[R[2]])||void 0===n?void 0:n.current)||(null===(t=kn.current[Number(R[2])])||void 0===t?void 0:t.current)||null,x=(null===(i=qn.current[R[3]])||void 0===i?void 0:i.current)||(null===(o=Mn.current[Number(R[3])])||void 0===o?void 0:o.current)||null,m=(null===(r=Ln.current[y])||void 0===r?void 0:r.current)||h,_=(null===(l=Vn.current[y])||void 0===l?void 0:l.current)||x}else{var S=Number(e),A=null!==v?Number(v):S;h=(null===(c=kn.current[S])||void 0===c?void 0:c.current)||null,x=(null===(s=Mn.current[A])||void 0===s?void 0:s.current)||null,m=(null===(d=Ln.current[S])||void 0===d?void 0:d.current)||(null===(g=zn.current[S])||void 0===g?void 0:g.current)||h,_=(null===(f=Vn.current[A])||void 0===f?void 0:f.current)||(null===(p=Hn.current[A])||void 0===p?void 0:p.current)||x}if(m&&_&&h&&x){h.style.paddingTop="0px",x.style.paddingTop="0px";var b=m.getBoundingClientRect(),E=_.getBoundingClientRect(),I=b.top-E.top;I>0?x.style.paddingTop="".concat(I,"px"):I<0&&(h.style.paddingTop="".concat(Math.abs(I),"px"))}}(),he(!0),Me.current&&Me.current(),Ae.current=!1,"right"===c&&R?R.dispatchEvent(new Event("scroll")):_&&_.dispatchEvent(new Event("scroll")),ue(!1),null==l||l()};if(!s||!_)return Ae.current=!1,ue(!1),void(null==l||l());if(d&&R){if(!ee){var S=0;S="right"===c?d?d.getBoundingClientRect().top:0:s?s.getBoundingClientRect().top:0;var A=ze.current,b=(null==A?void 0:A.getBoundingClientRect().top)||0,E=A?A.scrollTop+S-b-150:0;return A?void u.smoothScrollTo(A,E,200,y):void y()}var I=s.getBoundingClientRect().top-_.getBoundingClientRect().top+_.scrollTop,T=d.getBoundingClientRect().top-R.getBoundingClientRect().top+R.scrollTop,B=200;if("left"===c){var C=T-(I-_.scrollTop);C<0&&Ke.current&&(Ke.current.style.height="".concat(Math.abs(C),"px")),requestAnimationFrame(function(){var e,n=R.scrollHeight-R.clientHeight;if(C<0)e=0;else{if(C>n){var t=C-n;return Ue.current&&(Ue.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){u.smoothScrollTo(R,C,B,y)})}e=C}u.smoothScrollTo(R,e,B,y)})}else{var D=I-(T-R.scrollTop);D<0&&Xe.current&&(Xe.current.style.height="".concat(Math.abs(D),"px")),requestAnimationFrame(function(){var e,n=_.scrollHeight-_.clientHeight;if(D<0)e=0;else{if(D>n){var t=D-n;return Je.current&&(Je.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){u.smoothScrollTo(_,D,B,y)})}e=D}u.smoothScrollTo(_,e,B,y)})}}else y()})))},[ye,hn,Bn,ve,ee,Tn,nt]),Pt=t.useCallback(function(e,n,t,i){var o,r="string"==typeof i?u.safeStringify(i).trim():u.safeStringify(null==i?void 0:i.deviation_summary).trim(),l=e.currentTarget;pn();var c="left";(null===(o=Ye.current)||void 0===o?void 0:o.contains(l))&&(c="right");var a=function(){var e,t,i,o;if("string"==typeof n&&n.includes(u.DEVIATION_BADGE_SEPARATOR)){var r=n.split(u.DEVIATION_BADGE_SEPARATOR),l="".concat(r[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(r[1]);return"right"===c?null===(e=Vn.current[l])||void 0===e?void 0:e.current:null===(t=Ln.current[l])||void 0===t?void 0:t.current}return"right"===c?null===(i=Vn.current[n])||void 0===i?void 0:i.current:null===(o=Ln.current[n])||void 0===o?void 0:o.current};if(t)return nt(),Ie(new Set),Ce([]),je.current=[],void(r&&requestAnimationFrame(function(){var e=a()||l;dn({open:!0,anchorEl:e,summary:i})}));jt(n,t,r?{toggleIfSame:!1,sourceSide:c,onReady:function(){var e=a()||l;dn({open:!0,anchorEl:e,summary:i})}}:{toggleIfSame:!1,sourceSide:c})},[jt,pn,dn,nt]),Ft=t.useCallback(function(){var e,n=rn.sectionIdx,t=rn.isOrphan;if(vn(),null!=n){var i="left";rn.anchorEl&&(null===(e=Ye.current)||void 0===e?void 0:e.contains(rn.anchorEl))&&(i="right"),jt(n,t,{sourceSide:i})}},[jt,rn.isOrphan,rn.sectionIdx,rn.anchorEl,vn]),kt=t.useCallback(function(){vn(),nt(),Ie(new Set),Ce([]),je.current=[]},[vn,nt]),Mt=null!==rn.sectionIdx&&Ee.has(rn.sectionIdx),Lt=m.useDeviationNavigation({proposedSections:Tn,existingSections:Bn,parentDeviationRecord:Dn,expandedSections:it,maintainRelativeOrder:!!ee,scrollContainerRef:ze,leftContainerRef:Qe,lhsBadgeRefs:Ln,rhsBadgeRefs:Vn}),Vt=Lt.showDeviationNavigation,Ht=Lt.showOpenNodeRef,Gt=t.useMemo(function(){if(!Q)return null;for(var e in Dn){if((Dn[e]||[]).some(function(e){return e.id===Q}))return e}return null},[Q,Dn]),qt=t.useRef(null),zt=t.useRef(null);t.useEffect(function(){if(Q&&qt.current!==Q){zt.current!==Q&&(vn(),pn(),nt(),Ie(new Set),Ce([]),je.current=[],zt.current=Q);var n=!1,t=0,i=null,o=150,r=function(e,n){for(var t=function(e,i){if(!e)return null;if(e.id===n)return i;if(!Array.isArray(e.subsections))return null;for(var o=0;o<e.subsections.length;o++){var r=t(e.subsections[o],"".concat(i,"-").concat(o));if(r)return r}return null},i=0;i<e.length;i++){var o=t(e[i],String(i));if(o)return o}return null},l=function(){var c,a,s,d;if(!n){var v=null,g=null;for(var f in Dn){var p=Dn[f].find(function(e){return e.id===Q});if(p){v=f,g=p;break}}if(g&&v){var h=Tn.findIndex(function(e){return e.id===v}),x=Bn.findIndex(function(e){return e.id===v}),m=-1===h&&-1!==x;if(m){if(!(ee?!!it["right-".concat(x)]:!!it[String(x)]))return lt(x,"right"),t+=1,void(i=setTimeout(l,450))}else if(!(ee?!!it["left-".concat(h)]:!!it[String(h)])&&h>=0)return lt(h,"left"),t+=1,void(i=setTimeout(l,450));var _=r(Tn,g.id),R=r(Bn,g.id);if(_&&!R&&!m){var y=_.split("-"),S=Number(y[0]);if(ee){var A=null===(a=null===(c=Tn[S])||void 0===c?void 0:c.refIndexes)||void 0===a?void 0:a[0],b=Bn.findIndex(function(e){return e.selfIndex===A});-1!==b&&(S=b)}R=e.__spreadArray([S],y.slice(1),!0).join("-")}if(_||R){var E,I=_||"",T=R||"",B="".concat(g.id).concat(u.DEVIATION_BADGE_SEPARATOR,"0").concat(u.DEVIATION_BADGE_SEPARATOR).concat(I).concat(u.DEVIATION_BADGE_SEPARATOR).concat(T),C="".concat(g.id).concat(u.DEVIATION_BADGE_SEPARATOR,"0"),D=null===(s=Ln.current[C])||void 0===s?void 0:s.current,O=null===(d=Vn.current[C])||void 0===d?void 0:d.current,w=m?O:D;if(E=ee?m?Ye.current:Qe.current:ze.current,w&&E){var N=w.getBoundingClientRect();if(0===N.height)return void((t+=1)<20&&(i=setTimeout(l,o)));var j=E.getBoundingClientRect(),P=N.top-j.top+E.scrollTop-j.height/2+N.height/2,F=function(){var e,t,i,o,r;if(!n){qt.current=Q;var l=window.getComputedStyle(w).color;D&&(D.style.transition="box-shadow 300ms ease-in-out",D.style.boxShadow="0 0 10px ".concat(l)),O&&(O.style.transition="box-shadow 300ms ease-in-out",O.style.boxShadow="0 0 10px ".concat(l)),setTimeout(function(){D&&(D.style.boxShadow=""),O&&(O.style.boxShadow="")},2e3);var u=(null===(t=null===(e=g.evaluationResult)||void 0===e?void 0:e.deviations)||void 0===t?void 0:t[0])||g,c=(null===(i=g.evaluationResult)||void 0===i?void 0:i.evaluation_outputs)||g.evaluation_outputs;if(!(D&&O&&!m)){var a=m?(null===(o=Vn.current[C])||void 0===o?void 0:o.current)||O:(null===(r=Ln.current[C])||void 0===r?void 0:r.current)||D;return dn({open:!0,anchorEl:a,summary:{deviation_summary:u.deviation_summary||u,evaluation_outputs:c}}),void(null==Z||Z())}jt(B,!1,{toggleIfSame:!1,sourceSide:"left",onReady:function(){var e,n=(null===(e=Ln.current[C])||void 0===e?void 0:e.current)||D;dn({open:!0,anchorEl:n,summary:{deviation_summary:u.deviation_summary||u,evaluation_outputs:c}})}})}};Math.abs(E.scrollTop-P)<=2?F():($e.current=P,en.current=F,E.scrollTo({top:P,behavior:"smooth"}),i&&clearTimeout(i),i=setTimeout(function(){if(en.current){$e.current=null;var e=en.current;en.current=null,e()}},800))}else(t+=1)<20&&(i=setTimeout(l,o))}else(t+=1)<20&&(i=setTimeout(l,o))}else(t+=1)<20&&(i=setTimeout(l,o))}};return i=setTimeout(l,o),function(){n=!0,i&&clearTimeout(i)}}},[Q,Dn,Tn,Bn,ee,it,lt,jt,dn]);var Wt=function(e){var t=e.section,i=e.keyPath,o=e.depth,r=void 0===o?0:o,l=e.columnKey,u=void 0===l?"left":l,c=e.parentNodeId,a=void 0===c?"":c;return n.jsx(y.default,{section:t,keyPath:i,depth:r,columnKey:u,parentNodeId:a,expandedSubSections:ot,setExpandedSubSections:rt,maintainRelativeOrder:ee||!1,proposedSections:Tn,existingSections:Bn,treeData:H,deviationNumberRegistry:On,connectedSections:Ee,activeSideBySideSection:ye,resolvedMarkdownStyles:qe,getSubSectionRef:Yn,getSubSectionCompareStyle:It,getBadgeRef:Kn,openMoreFunctionsPopup:at,openSummaryPopup:Pt,resetSideBySide:nt,setConnectedSections:Ie,setConnectedLines:Ce,cachedConnectedPositions:je})};return n.jsxs(i.Box,e.__assign({ref:We,sx:e.__assign(e.__assign({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},ee?{}:{overflow:"visible"}),{position:"relative"})},{children:[ie&&n.jsx(i.Box,e.__assign({sx:{position:"absolute",inset:0,bgcolor:"rgba(255, 255, 255, 0.6)",backdropFilter:"blur(10px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"8px"}},{children:n.jsx(v.default,{})})),sn.open&&n.jsx(S.default,{open:sn.open,anchorEl:sn.anchorEl,containerEl:gt.current,clipTopEl:ht.current,scrollContainerEl:ze.current,onClose:kt,summary:sn.summary}),n.jsx(d.default,{open:rn.open,anchorEl:rn.anchorEl,sectionTitle:rn.sectionTitle,referenceSectionTitle:rn.refSectionTitle,onClose:hn,onOpenCognitiveCompare:st,onOpenSideBySide:Ft,onConnect:dt,isConnected:Mt,isOrphan:rn.isOrphan}),tn.open&&n.jsx(s.default,{open:tn.open,popupRef:fn,position:un,popupConfig:U,onClose:function(){cn(null),on(function(n){return e.__assign(e.__assign({},n),{open:!1})}),gn(null)},markdownStyles:W,sectionTitle:tn.sectionTitle,referenceSectionTitle:tn.refSectionTitle,cognitiveData:tn.cognitiveData,anchorEl:tn.anchorEl,sectionAnchorEl:tn.sectionAnchorEl,scrollContainerEl:ze.current,badgeStyle:tn.badgeStyle,docData:tn.docData,deviationData:tn.deviationData,isLoading:tn.isLoading}),n.jsx(i.Snackbar,e.__assign({open:!!ae,autoHideDuration:8e3,onClose:function(){return se(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(i.Alert,e.__assign({onClose:function(){return se(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:ae}))})),n.jsx(_.default,{componentHeaderText:V,displayConfig:K,maintainRelativeOrder:ee,onToggleView:function(e){oe(!0),setTimeout(function(){ne(!e),nt(),vn(),Ie(new Set),Ce([]),je.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){oe(!1)},600)})})},50)}}),n.jsx(i.Box,e.__assign({ref:ze,onScroll:Nt,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:ee?"hidden":"auto",borderTop:Xn&&Jn?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(i.Box,e.__assign({sx:e.__assign({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},ee?{flex:1,minHeight:0}:{})},{children:n.jsxs(i.Box,e.__assign({ref:vt,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"40px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},ee?{flex:1,overflow:"visible"}:{})},{children:[n.jsxs("svg",e.__assign({ref:De,style:{position:"absolute",top:0,left:0,width:He.width||"100%",height:He.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",opacity:me?0:1,transition:"opacity 0.15s ease-in-out"}},{children:[St&&n.jsx("g",{children:n.jsx("line",{x1:St.x1,y1:St.y,x2:St.x2,y2:St.y,stroke:et.badgeBorder,strokeWidth:"1.5"})}),_t.map(function(t){var l,c,s,d,v,f,p=t.x1+.5*(t.x2-t.x1),h=(t.y1+t.y2)/2;if("Not Defined"===t.style.label&&!t.hasCognitive)return null;if(t.isSubSection?ve&&ye===t.subSectionKeyPath&&pe:ve&&ye===t.sectionIdx&&pe)return null;if(!ee){var x=t.isSubSection?u.getBentArrowPath(t.x1,t.y1,t.x2,t.y2):"M ".concat(t.x1," ").concat(t.y1," L ").concat(t.x2," ").concat(t.y2),m=Tn[t.sectionIdx]||{title:"",content:""},_=Bn[t.sectionIdx]||{title:"",content:""};if(console.log("Base and Ref Sections for Badge:",m,_),t.isSubSection&&t.subSectionKeyPath){var R=t.subSectionKeyPath.includes(u.DEVIATION_BADGE_SEPARATOR)?t.subSectionKeyPath.split(u.DEVIATION_BADGE_SEPARATOR):[],y=R[2]||t.subSectionKeyPath,S=R[3]||y,A=y.split("-").map(Number),b=S.split("-").map(Number),E=null,I=null;A.length>0&&(E=Tn[A[0]]),b.length>0&&(I=Bn[b[0]]);var T=(null==E?void 0:E.title)||"",B=(null==I?void 0:I.title)||"";console.log("Root Parent Titles:",T,B);for(var C=1;C<A.length;C++)(null==E?void 0:E.subsections)&&(E=E.subsections[A[C]]);for(C=1;C<b.length;C++)(null==I?void 0:I.subsections)&&(I=I.subsections[b[C]]);E&&(m=e.__assign(e.__assign({},E),{title:T||E.title})),console.log("Base Section for Subsection Badge:",m),I&&(_=e.__assign(e.__assign({},I),{title:B||I.title})),console.log("Ref Section for Subsection Badge:",_)}var D=!(null===(l=m.cognitiveData)||void 0===l?void 0:l.isMissingRationale)||Boolean(null===(s=null===(c=m.cognitiveData)||void 0===c?void 0:c.decisioning)||void 0===s?void 0:s.length),O=(null===(f=null===(v=null===(d=m.evaluationResult)||void 0===d?void 0:d.cognitive_decisioning)||void 0===v?void 0:v.decisioning_factors)||void 0===f?void 0:f.length)||!1,w=D||O;return n.jsxs("g",{children:[n.jsx("path",{d:x,fill:"none",stroke:t.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),n.jsx("foreignObject",e.__assign({x:p-100,y:h-14,width:"200",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:n.jsx(i.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:n.jsxs(i.Box,e.__assign({onClick:function(e){e.stopPropagation(),w&&(tn.open&&an===t.id?pn():(gn(t.id),ct(ut(e.currentTarget,m,_,t.sectionIdx,t.style))))},sx:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:t.style.badgeBg,color:t.style.badgeText,border:"1px solid ".concat(t.style.badgeBorder),borderRadius:"12px",px:1.5,py:.5,fontWeight:600,textAlign:"center",whiteSpace:"nowrap",cursor:w?"pointer":"default"}},{children:[t.style.badgeText===a.DEFAULT_DEVIAION_COLOR&&null==t.style.label?n.jsx(g.default,{color:t.style.badgeText}):0===t.style.label?"Same":t.style.label,n.jsx(i.Box,e.__assign({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n.jsx(r.ButtonCognitiveIcon,{})})),w&&n.jsx(o.ChevronDown,{size:11,style:{transform:tn.open&&an===t.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},t.id)}return null}),Be.map(function(t){var i,o=t.pathD,r=(null===(i=t.style)||void 0===i?void 0:i.badgeBorder)||"#6366F1",l="conn-marker-".concat(t.id),u="".concat(t.id,"-bg"),c="".concat(t.id,"-stroke");return n.jsxs("g",{children:[n.jsx("defs",{children:n.jsx("clipPath",e.__assign({id:"connections-clip"},{children:n.jsx("marker",e.__assign({id:l,markerWidth:"8",markerHeight:"6",refX:"7",refY:"3",orient:"auto"},{children:n.jsx("polygon",{points:"0 0, 8 3, 0 6",fill:r})}))}))}),n.jsx("path",{ref:function(e){Ne.current[u]=e},d:o,fill:"none",stroke:"#FFFFFF",strokeWidth:"4",strokeOpacity:"0.7"}),n.jsx("path",{ref:function(e){Ne.current[c]=e},d:o,fill:"none",stroke:r,strokeWidth:"1.75",markerEnd:"url(#".concat(l,")")})]},t.id)})]})),n.jsxs(i.Box,e.__assign({sx:e.__assign({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},ee?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(i.Box,e.__assign({ref:ht,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:n.jsx(i.Tooltip,e.__assign({title:Sn,placement:"top"},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:Sn}))}))})),n.jsxs(i.Box,e.__assign({ref:Qe,onScroll:Nt,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},ee?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-160px",pr:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:Xe,style:{width:"100%",height:"0px",flexShrink:0}}),Nn&&Tn.map(function(t,r){var l,c,a=!t.title&&!t.content;if(ee&&a)return null;var s=t,d=Et(r,"left"),v=ee?!(null===(l=s.refIndexes)||void 0===l?void 0:l.length)||s.selfIndex<0:!Bn[r],f=ee?"number"==typeof s.selfIndex&&s.selfIndex>=0?s.selfIndex+1:null:r+1,p=Ee.has(r),h=u.extractDeviationScore(s.evaluationResult,null==d?void 0:d.deviationLabel);return n.jsx(i.Box,e.__assign({ref:Wn(r),sx:{mb:1,width:"100%"}},{children:n.jsxs(i.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[n.jsx(i.Box,e.__assign({ref:kn.current[r],sx:e.__assign({width:"100%",display:"flex"},p&&{borderRadius:"6px",outline:"2px solid ".concat((null==d?void 0:d.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:n.jsx(R.default,{section:t,idx:r,columnKey:"left",colRef:Wn("left-accordion-".concat(r)),mb:0,treeData:H,proposedSections:Tn,existingSections:Bn,deviationNumberRegistry:On,getSectionCompareStyle:Et,getBadgeRef:Kn,connectedSections:Ee,openMoreFunctionsPopup:at,openSummaryPopup:Pt,deviationNodeIdToView:Q,deviationTargetParentId:Gt,parentNodeId:(null===(c=null==H?void 0:H.input_index_map)||void 0===c?void 0:c[0])||"",isExpanded:ee?!!it["left-".concat(r)]:!!it[String(r)],onToggle:function(){kt(),lt(r,"left")},navigation:t.id?Vt[t.id]:null,showOpenNodeRef:Ht,resolvedMarkdownStyles:qe,maintainRelativeOrder:ee,renderSubSections:Wt})})),ee&&d&&n.jsxs(i.Box,e.__assign({ref:Ln.current[r],onClick:function(e){var n=ee?Bn.find(function(e){var n;return null===(n=s.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""}:Bn[r]||{title:"",content:""};at(e,t,v,n,r,d)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:d.badgeBg,color:d.badgeText,border:"1px solid ".concat(d.badgeBorder),borderRadius:"12px",px:1.2,py:.4,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[null!==f&&n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(d.badgeBorder)}},{children:f})),n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",px:.25}},{children:!K.isLoading||null!=s.evaluationResult&&null!=s.evaluationResult?v?"No Deviation Found":"N/A"===h||"NA"===h?"N/A":0==h||null==h?"Same":"".concat(h):n.jsx(g.default,{color:d.badgeText})})),n.jsx(o.EllipsisVertical,{size:11,color:d.badgeText})]}))]}))}),"left-row-".concat(r))}),n.jsx("div",{ref:Je,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),n.jsx(i.Box,e.__assign({ref:gt,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:n.jsx(i.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:n.jsxs(i.Box,e.__assign({onClick:function(n){n.stopPropagation(),tn.open&&an===Qn?pn():(gn(Qn),ct(ut(n.currentTarget,{title:"",content:"",evaluationResult:Zn,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,Qn,!0,e.__assign(e.__assign({},et),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-5px",borderRadius:"20px",bgcolor:et.badgeBg,color:et.badgeText,border:"1px solid ".concat(et.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=$n?$n:n.jsx(g.default,{}),n.jsx(i.Box,e.__assign({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n.jsx(r.ButtonCognitiveIcon,{})})),n.jsx(o.ChevronDown,{size:11,style:{transform:tn.open&&an===Qn?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),n.jsxs(i.Box,e.__assign({sx:e.__assign({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},ee?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[le&&n.jsx(l.default,{sections:11}),n.jsx(i.Box,e.__assign({ref:xt,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"40px",display:"flex",alignItems:"center",overflowX:"hidden"}},{children:n.jsx(i.Tooltip,e.__assign({title:An,placement:"top"},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:An}))}))})),n.jsxs(i.Box,e.__assign({ref:Ye,onScroll:Nt,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},ee?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-120px",pl:"140px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:Ke,style:{width:"100%",height:"0px",flexShrink:0}}),Nn&&Bn.map(function(t,o){var r,l=t,u=[],c=!1,a=null,s=-1;if(ee){u=Tn.filter(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(l.selfIndex))&&e.selfIndex>=0}).map(function(e){return e.selfIndex+1}),s=Tn.findIndex(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(l.selfIndex))&&e.selfIndex>=0});var d=Tn.findIndex(function(e,n){var t;return Ee.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(l.selfIndex))});(c=-1!==d)&&(a=Et(d))}else u=[o+1],(c=Ee.has(o))&&(a=Et(o));var v=Et(ee&&-1!==s?s:o);return n.jsx(i.Box,e.__assign({ref:Hn.current[o],sx:{mb:1,width:"100%"}},{children:n.jsxs(i.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[n.jsx(i.Box,e.__assign({ref:Mn.current[o],sx:e.__assign({width:"100%",display:"flex"},c&&a&&{borderRadius:"6px",outline:"2px solid ".concat(a.badgeBorder),outlineOffset:"1px"})},{children:n.jsx(R.default,{section:t,idx:o,columnKey:"right",colRef:Wn("right-accordion-".concat(o)),mb:0,parentNodeId:(null===(r=null==H?void 0:H.input_index_map)||void 0===r?void 0:r[1])||"",isExpanded:ee?!!it["right-".concat(o)]:!!it[String(o)],treeData:H,proposedSections:Tn,existingSections:Bn,deviationNumberRegistry:On,getBadgeRef:Kn,getSectionCompareStyle:Et,connectedSections:Ee,openMoreFunctionsPopup:at,openSummaryPopup:Pt,deviationNodeIdToView:Q,deviationTargetParentId:Gt,onToggle:function(){kt(),lt(o,"right")},navigation:t.id?Vt[t.id]:null,showOpenNodeRef:Ht,resolvedMarkdownStyles:qe,maintainRelativeOrder:ee,renderSubSections:Wt})})),ee&&v&&n.jsx(i.Box,e.__assign({ref:Vn.current[o],"data-section-id":l.id,sx:{position:"absolute",top:"18px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"11px",bgcolor:v.badgeBg,color:v.badgeText,border:"1px solid ".concat(v.badgeBorder),borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:u.length>0?u.join(", "):"-"}))]}))}),"right-row-".concat(o))}),n.jsx("div",{ref:Ue,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))};
2
2
  //# sourceMappingURL=CognitiveCompare.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=function(n){return null==n?"":"string"==typeof n?n:Array.isArray(n)?n.map(t).join("\n\n"):"object"==typeof n?JSON.stringify(n):String(n)},n=function(t){return null!=t&&("string"==typeof t?t.trim().length>0:!Array.isArray(t)||t.length>0&&t.some(function(t){return n(t)}))};exports.DEVIATION_BADGE_SEPARATOR="::",exports.areMarkdownPropsEqual=function(t,n){if(t.content!==n.content)return!1;if(t.sxStyles!==n.sxStyles)return!1;if(t.maintainRelativeOrder!==n.maintainRelativeOrder)return!1;var e=t.highlights||[],r=n.highlights||[];if(e.length!==r.length)return!1;for(var o=0;o<e.length;o++)if(e[o]!==r[o])return!1;var i=t.deviationBadges||[],a=n.deviationBadges||[];if(i.length!==a.length)return!1;for(o=0;o<i.length;o++){if(i[o].id!==a[o].id)return!1;if(i[o].label!==a[o].label)return!1;if(i[o].isConnected!==a[o].isConnected)return!1}return!0},exports.debounce=function(t,n){var e;return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];var i=this;clearTimeout(e),e=setTimeout(function(){return t.apply(i,r)},n)}},exports.escapeRegExp=function(t){var n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return n=(n=(n=(n=n.replace(/['’‘`]/g,"['’‘`]")).replace(/["”“]/g,'["”“]')).replace(/[-—–]/g,"[-—–]")).replace(/\s+/g,"\\s+")},exports.extractDeviationScore=function(t,n){var e,r,o,i,a,u,l;if(!t)return n;var c=null!==(u=null!==(i=null!==(r=null===(e=t.evaluation_output)||void 0===e?void 0:e.output_score)&&void 0!==r?r:null===(o=t.evaluation_outputs)||void 0===o?void 0:o.output_score)&&void 0!==i?i:null===(a=t.evaluation_outputs)||void 0===a?void 0:a.output_value)&&void 0!==u?u:t.output_score;return null!==(l=null!=c?c:n)&&void 0!==l?l:""},exports.generateColorPalette=function(t){var n=function(t,n){var e=function(t){var n=function(t){return 4===t.length?"#"+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]:t}(t).replace("#",""),e=parseInt(n,16);return{r:e>>16&255,g:e>>8&255,b:255&e}}(t),r=e.r,o=e.g,i=e.b;return function(t,n,e){return"#"+[t,n,e].map(function(t){return t.toString(16).padStart(2,"0")}).join("").toUpperCase()}(Math.round(r+(255-r)*n),Math.round(o+(255-o)*n),Math.round(i+(255-i)*n))};return{bg:n(t,.8),border:n(t,.5),badgeBg:n(t,.8),badgeBorder:n(t,.5),badgeText:t.toUpperCase(),highlightBg:n(t,.8)}},exports.getBentArrowPath=function(t,n,e,r,o){void 0===o&&(o=14);var i=t+.5*(e-t),a=r-n;if(Math.abs(a)<3)return"M ".concat(t," ").concat(n," H ").concat(e);var u=a>0?1:-1,l=Math.min(o,Math.abs(a)/2,Math.abs(i-t)/2,Math.abs(e-i)/2);return["M ".concat(t," ").concat(n),"H ".concat(i-l),"Q ".concat(i," ").concat(n," ").concat(i," ").concat(n+u*l),"V ".concat(r-u*l),"Q ".concat(i," ").concat(r," ").concat(i+l," ").concat(r),"H ".concat(e)].join(" ")},exports.getRationale=function(t){if(!t.mapping_rationale)return{cognitiveData:{decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0,citations:[]},score:0,relation:"N/A"};var n=t.mapping_rationale,e=parseInt(n.decision_strength||"0");return{cognitiveData:{decisioning:n.decisioning_factors||[],gap:n.gaps_in_decision||[],relevance_score:e,citations:n.citations},score:0,relation:"N/A"}},exports.getSideData=function(n,e,r){var o,i=r[e],a=null===(o=null==n?void 0:n.comparison_inputs)||void 0===o?void 0:o[i];return{title:t((null==a?void 0:a.title)||""),content:t((null==a?void 0:a.content)||""),attributes:(null==a?void 0:a.additional_attributes)||null,subsections:(null==a?void 0:a.subsections)||[]}},exports.hasValue=n,exports.isMissingStr=function(t){if(!t)return!0;var n=t.trim().toLowerCase();return n.includes("no equivalent")||"n/a"===n||"na"===n||"none"===n},exports.safeStringify=t,exports.smoothScrollTo=function(t,n,e,r,o){void 0===e&&(e=300);var i=t.style.scrollBehavior;t.style.scrollBehavior="auto";var a=t.scrollTop,u=n-a,l=null,c=function(s){null===l&&(l=s);var v,p=s-l;p<e?(t.scrollTop=(v=p,v/=e,u*(--v*v*v+1)+a),o&&o(),requestAnimationFrame(c)):(t.scrollTop=n,t.style.scrollBehavior=i,o&&o(),r&&r())};requestAnimationFrame(c)};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=function(n){return null==n?"":"string"==typeof n?n:Array.isArray(n)?n.map(t).join("\n\n"):"object"==typeof n?JSON.stringify(n):String(n)},n=function(t){return null!=t&&("string"==typeof t?t.trim().length>0:!Array.isArray(t)||t.length>0&&t.some(function(t){return n(t)}))};exports.DEVIATION_BADGE_SEPARATOR="::",exports.areMarkdownPropsEqual=function(t,n){var e,r,o,i,a,l;if(t.content!==n.content)return!1;if(t.sxStyles!==n.sxStyles)return!1;if(t.maintainRelativeOrder!==n.maintainRelativeOrder)return!1;if(t.highlightBg!==n.highlightBg)return!1;var u=t.highlights||[],s=n.highlights||[];if(u.length!==s.length)return!1;for(var c=0;c<u.length;c++)if(u[c]!==s[c])return!1;var d=t.deviationBadges||[],v=n.deviationBadges||[];if(d.length!==v.length)return!1;for(c=0;c<d.length;c++){if(d[c].id!==v[c].id)return!1;if(d[c].actionId!==v[c].actionId)return!1;if(d[c].label!==v[c].label)return!1;if(d[c].score!==v[c].score)return!1;if(d[c].isOrphan!==v[c].isOrphan)return!1;if(d[c].isConnected!==v[c].isConnected)return!1;if((null===(e=d[c].style)||void 0===e?void 0:e.badgeBg)!==(null===(r=v[c].style)||void 0===r?void 0:r.badgeBg))return!1;if((null===(o=d[c].style)||void 0===o?void 0:o.badgeBorder)!==(null===(i=v[c].style)||void 0===i?void 0:i.badgeBorder))return!1;if((null===(a=d[c].style)||void 0===a?void 0:a.badgeText)!==(null===(l=v[c].style)||void 0===l?void 0:l.badgeText))return!1}return!0},exports.debounce=function(t,n){var e;return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];var i=this;clearTimeout(e),e=setTimeout(function(){return t.apply(i,r)},n)}},exports.escapeRegExp=function(t){var n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return n=(n=(n=(n=n.replace(/['’‘`]/g,"['’‘`]")).replace(/["”“]/g,'["”“]')).replace(/[-—–]/g,"[-—–]")).replace(/\s+/g,"\\s+")},exports.extractDeviationScore=function(t,n){var e,r,o,i,a,l,u;if(!t)return n;var s=null!==(l=null!==(i=null!==(r=null===(e=t.evaluation_output)||void 0===e?void 0:e.output_score)&&void 0!==r?r:null===(o=t.evaluation_outputs)||void 0===o?void 0:o.output_score)&&void 0!==i?i:null===(a=t.evaluation_outputs)||void 0===a?void 0:a.output_value)&&void 0!==l?l:t.output_score;return null!==(u=null!=s?s:n)&&void 0!==u?u:""},exports.generateColorPalette=function(t){var n=function(t,n){var e=function(t){var n=function(t){return 4===t.length?"#"+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]:t}(t).replace("#",""),e=parseInt(n,16);return{r:e>>16&255,g:e>>8&255,b:255&e}}(t),r=e.r,o=e.g,i=e.b;return function(t,n,e){return"#"+[t,n,e].map(function(t){return t.toString(16).padStart(2,"0")}).join("").toUpperCase()}(Math.round(r+(255-r)*n),Math.round(o+(255-o)*n),Math.round(i+(255-i)*n))};return{bg:n(t,.8),border:n(t,.5),badgeBg:n(t,.8),badgeBorder:n(t,.5),badgeText:t.toUpperCase(),highlightBg:n(t,.8)}},exports.getBentArrowPath=function(t,n,e,r,o){void 0===o&&(o=14);var i=t+.5*(e-t),a=r-n;if(Math.abs(a)<3)return"M ".concat(t," ").concat(n," H ").concat(e);var l=a>0?1:-1,u=Math.min(o,Math.abs(a)/2,Math.abs(i-t)/2,Math.abs(e-i)/2);return["M ".concat(t," ").concat(n),"H ".concat(i-u),"Q ".concat(i," ").concat(n," ").concat(i," ").concat(n+l*u),"V ".concat(r-l*u),"Q ".concat(i," ").concat(r," ").concat(i+u," ").concat(r),"H ".concat(e)].join(" ")},exports.getRationale=function(t){if(!t.mapping_rationale)return{cognitiveData:{decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0,citations:[]},score:0,relation:"N/A"};var n=t.mapping_rationale,e=parseInt(n.decision_strength||"0");return{cognitiveData:{decisioning:n.decisioning_factors||[],gap:n.gaps_in_decision||[],relevance_score:e,citations:n.citations},score:0,relation:"N/A"}},exports.getSideData=function(n,e,r){var o,i=r[e],a=null===(o=null==n?void 0:n.comparison_inputs)||void 0===o?void 0:o[i];return{title:t((null==a?void 0:a.title)||""),content:t((null==a?void 0:a.content)||""),attributes:(null==a?void 0:a.additional_attributes)||null,subsections:(null==a?void 0:a.subsections)||[]}},exports.hasValue=n,exports.isMissingStr=function(t){if(!t)return!0;var n=t.trim().toLowerCase();return n.includes("no equivalent")||"n/a"===n||"na"===n||"none"===n},exports.safeStringify=t,exports.smoothScrollTo=function(t,n,e,r,o){void 0===e&&(e=300);var i=t.style.scrollBehavior;t.style.scrollBehavior="auto";var a=t.scrollTop,l=n-a,u=null,s=function(c){null===u&&(u=c);var d,v=c-u;v<e?(t.scrollTop=(d=v,d/=e,l*(--d*d*d+1)+a),o&&o(),requestAnimationFrame(s)):(t.scrollTop=n,t.style.scrollBehavior=i,o&&o(),r&&r())};requestAnimationFrame(s)};
2
2
  //# sourceMappingURL=CognitiveComparehelpers.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),n=require("@mui/material"),i=require("lucide-react"),o=require("react");exports.default=function(l){var r,a,s,u=l.open,c=l.anchorEl,d=l.containerEl,p=l.clipTopEl,m=l.onClose,f=l.summary;l.markdownStyles,l.isLoading;var g=o.useRef(null),x=o.useState(null),h=x[0],v=x[1],_=o.useState(null),b=_[0],w=_[1],y="string"==typeof f?{deviation_summary:f}:null!=f?f:{};y.deviation_title;var B=y.deviation_summary,C=y.evaluation_outputs,j=(null===(r=null==C?void 0:C.metadata)||void 0===r?void 0:r.label_color)||"#6366F1",R=null!==(a=null==d?void 0:d.getBoundingClientRect().width)&&void 0!==a?a:180,E=Math.max(148,R+70),S=c&&d?{top:c.getBoundingClientRect().top,bottom:c.getBoundingClientRect().bottom,left:d.getBoundingClientRect().left+d.getBoundingClientRect().width/2}:null;o.useEffect(function(){if(!u||!c||!d)return v(null),void w(null);var e=function(){null!==g.current&&cancelAnimationFrame(g.current),g.current=requestAnimationFrame(function(){var e,t=c.getBoundingClientRect(),n=d.getBoundingClientRect(),i=null==p?void 0:p.getBoundingClientRect();v({top:t.top,bottom:t.bottom,left:n.left+n.width/2}),w(null!==(e=null==i?void 0:i.bottom)&&void 0!==e?e:null)})};e();var t=!0;return window.addEventListener("scroll",e,{passive:!0,capture:t}),window.addEventListener("resize",e),function(){null!==g.current&&cancelAnimationFrame(g.current),window.removeEventListener("scroll",e,t),window.removeEventListener("resize",e)}},[u,c,d,p]);var z=null!==(s=null!=h?h:S)&&void 0!==s?s:{top:0,bottom:0,left:0},q=z.bottom+20,I=null!=b?Math.max(0,b-q):0;return f?t.jsx(n.Popper,e.__assign({open:u,disablePortal:!0,popperOptions:{strategy:"fixed"},anchorEl:{getBoundingClientRect:function(){return{width:0,height:0,top:z.top,bottom:z.top,left:z.left,right:z.left,x:z.left,y:z.top,toJSON:function(){}}}},placement:"bottom",modifiers:[{name:"offset",options:{offset:[0,20]}}],sx:{zIndex:10}},{children:t.jsxs(n.Paper,e.__assign({sx:e.__assign(e.__assign({p:1.5,borderRadius:"12px",width:E,maxWidth:E},I>0&&{clipPath:"inset(".concat(I,"px 0 0 0 round 12px)")}),{transition:"transform 80ms linear",willChange:"transform",backfaceVisibility:"hidden",transform:"translateZ(0)",boxShadow:"0px 10px 24px rgba(15, 23, 42, 0.18)",border:"1px solid ".concat(j,"26"),borderTop:"3px solid ".concat(j),overflow:"hidden",bgcolor:"#fff"})},{children:[t.jsxs(n.Box,e.__assign({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.75}},{children:[t.jsxs(n.Box,e.__assign({sx:{display:"flex",alignItems:"center",gap:.75,minWidth:0}},{children:[t.jsx(i.Info,{size:14,color:j}),t.jsx(n.Typography,e.__assign({sx:{fontSize:"11px",fontWeight:700,color:j,textTransform:"uppercase",letterSpacing:"0.4px",lineHeight:1.2}},{children:"Summary"}))]})),t.jsx(n.IconButton,e.__assign({size:"small",onClick:m,sx:{p:.25,ml:.5,color:"#64748B"}},{children:t.jsx(i.X,{size:14})}))]})),t.jsx(n.Typography,e.__assign({sx:{fontSize:"12px",color:"#475569",lineHeight:1.5,fontWeight:400,overflowWrap:"anywhere"}},{children:B||"No summary available."}))]}))})):null};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),n=require("@mui/material"),o=require("lucide-react"),i=require("react");exports.default=function(l){var r,a,s,u=l.open,c=l.anchorEl,d=l.containerEl,p=l.clipTopEl,m=l.scrollContainerEl,f=l.onClose,g=l.summary;l.markdownStyles,l.isLoading;var x=i.useRef(null),v=i.useRef(null),h=i.useState(null),b=h[0],_=h[1],w=i.useState(null),y=w[0],C=w[1],B=i.useState(null),R=B[0],j=B[1],S=i.useState(0),E=S[0],z=S[1],q="string"==typeof g?{deviation_summary:g}:null!=g?g:{};q.deviation_title;var I=q.deviation_summary,L=q.evaluation_outputs,P=(null===(r=null==L?void 0:L.metadata)||void 0===r?void 0:r.label_color)||"#6366F1",T=null!==(a=null==d?void 0:d.getBoundingClientRect().width)&&void 0!==a?a:180,W=Math.max(148,T+70),F=c&&d?{top:c.getBoundingClientRect().top,bottom:c.getBoundingClientRect().bottom,left:d.getBoundingClientRect().left+d.getBoundingClientRect().width/2}:null;i.useEffect(function(){if(!u||!c||!d)return _(null),C(null),void j(null);var e=function(){null!==x.current&&cancelAnimationFrame(x.current),x.current=requestAnimationFrame(function(){var e,t,n=c.getBoundingClientRect(),o=d.getBoundingClientRect(),i=null==p?void 0:p.getBoundingClientRect(),l=null==m?void 0:m.getBoundingClientRect();_({top:n.top,bottom:n.bottom,left:o.left+o.width/2}),C(null!==(e=null==i?void 0:i.bottom)&&void 0!==e?e:null),j(null!==(t=null==l?void 0:l.bottom)&&void 0!==t?t:null),v.current&&z(v.current.offsetHeight)})};e();var t=!0;return window.addEventListener("scroll",e,{passive:!0,capture:t}),window.addEventListener("resize",e),function(){null!==x.current&&cancelAnimationFrame(x.current),window.removeEventListener("scroll",e,t),window.removeEventListener("resize",e)}},[u,c,d,p,m]);var M=null!==(s=null!=b?b:F)&&void 0!==s?s:{top:0,bottom:0,left:0},k=M.bottom+20,A=k+E,H=null!=y?Math.max(0,y-k):0,O=null!=R?Math.max(0,A-R):0,N=H>0||O>0;return g?t.jsx(n.Popper,e.__assign({open:u,disablePortal:!0,popperOptions:{strategy:"fixed"},anchorEl:{getBoundingClientRect:function(){return{width:0,height:M.bottom-M.top,top:M.top,bottom:M.bottom,left:M.left,right:M.left,x:M.left,y:M.top,toJSON:function(){}}}},placement:"bottom",modifiers:[{name:"offset",options:{offset:[0,20]}}],sx:{zIndex:20}},{children:t.jsxs(n.Paper,e.__assign({ref:v,sx:e.__assign(e.__assign({p:1.5,borderRadius:"12px",width:W,maxWidth:W},N&&{clipPath:"inset(".concat(H,"px 0 ").concat(O-150,"px 0 round 12px)")}),{transition:"transform 80ms linear",willChange:"transform",backfaceVisibility:"hidden",transform:"translateZ(0)",boxShadow:"0px 10px 24px rgba(15, 23, 42, 0.18)",border:"1px solid ".concat(P,"26"),borderTop:"3px solid ".concat(P),overflow:"hidden",bgcolor:"#fff"})},{children:[t.jsxs(n.Box,e.__assign({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.75}},{children:[t.jsxs(n.Box,e.__assign({sx:{display:"flex",alignItems:"center",gap:.75,minWidth:0}},{children:[t.jsx(o.Info,{size:14,color:P}),t.jsx(n.Typography,e.__assign({sx:{fontSize:"11px",fontWeight:700,color:P,textTransform:"uppercase",letterSpacing:"0.4px",lineHeight:1.2}},{children:"Summary"}))]})),t.jsx(n.IconButton,e.__assign({size:"small",onClick:f,sx:{p:.25,ml:.5,color:"#64748B"}},{children:t.jsx(o.X,{size:14})}))]})),t.jsx(n.Typography,e.__assign({sx:{fontSize:"12px",color:"#475569",lineHeight:1.5,fontWeight:400,overflowWrap:"anywhere"}},{children:I||"No summary available."}))]}))})):null};
2
2
  //# sourceMappingURL=CognitiveSummaryPopup.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),i=require("react"),o=require("@mui/material"),t=require("lucide-react"),l=require("../hooks/memoizedMarkdown.js"),r=require("../CognitiveComparehelpers.js"),a=require("../CognitiveCompareConstants.js");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=d(i);exports.default=function(d){var u,c,v,f,p,g,h,x,m,_,b,y,w,I,A,S,R=d.section,B=d.idx,E=d.columnKey,F=d.colRef,j=d.mb,C=void 0===j?1:j,T=d.parentNodeId,k=void 0===T?"":T,D=d.isExpanded,O=d.onToggle,M=d.navigation,N=d.showOpenNodeRef,P=d.resolvedMarkdownStyles,V=d.maintainRelativeOrder,W=d.renderSubSections,q=d.treeData,G=d.proposedSections,z=void 0===G?[]:G,K=d.existingSections,L=void 0===K?[]:K,U=d.deviationNumberRegistry,X=void 0===U?{}:U,Y=d.getBadgeRef,H=d.openSummaryPopup,$=d.getSectionCompareStyle,J=d.connectedSections,Q=d.openMoreFunctionsPopup,Z=d.deviationNodeIdToView,ee=d.deviationTargetParentId,ne=(null===(u=R.displayTitle)||void 0===u||u)&&r.hasValue(R.title),ie=(null===(c=R.displayContent)||void 0===c||c)&&r.hasValue(R.content),oe=!ne&&!ie,te={current:1},le=R.title;ne||(le=ie?"No Title Found":"No Matching Section Found");var re=R.evaluationResult;if(!re&&"right"===E)if(V){var ae=null===(v=R.refIndexes)||void 0===v?void 0:v[0],de=z.find(function(e){return e.selfIndex===ae});re=null==de?void 0:de.evaluationResult}else re=null===(f=z[B])||void 0===f?void 0:f.evaluationResult;var se=null===(p=null==q?void 0:q.input_index_map)||void 0===p?void 0:p[0],ue=null===(g=null==q?void 0:q.input_index_map)||void 0===g?void 0:g[1],ce="left"===E?ue:se,ve="left"===E?R:z[B],fe="right"===E?R:L[B];if(V)if("left"===E){var pe=null===(h=R.refIndexes)||void 0===h?void 0:h[0],ge=L.findIndex(function(e){return e.selfIndex===pe});fe=-1!==ge?L[ge]:void 0}else{var he=null===(x=R.refIndexes)||void 0===x?void 0:x[0],xe=z.findIndex(function(e){return e.selfIndex===he});ve=-1!==xe?z[xe]:void 0}var me="left"===E?!fe:!ve,_e=re||(null==ve?void 0:ve.evaluationResult)||(null==fe?void 0:fe.evaluationResult),be=null!==(b=null===(_=null===(m=null==_e?void 0:_e.evaluation_outputs)||void 0===m?void 0:m.metadata)||void 0===_?void 0:_.label_color)&&void 0!==b?b:a.DEFAULT_DEVIAION_COLOR,ye=r.generateColorPalette(be),we=ye.highlightBg,Ie=null!==(w=null===(y=null==_e?void 0:_e.evaluation_outputs)||void 0===y?void 0:y.output_value)&&void 0!==w?w:null,Ae=(null==_e?void 0:_e.deviations)||{},Se=B+1,Re=R.id;if("right"===E&&V){var Be=null===(I=R.refIndexes)||void 0===I?void 0:I[0];-1!==(xe=z.findIndex(function(e){return e.selfIndex===Be}))&&(Se=xe+1,Re=z[xe].id)}var Ee,Fe=[],je=Object.entries(Ae).map(function(n){var i,o,t,l=n[0],a=n[1],d="".concat(Re).concat(r.DEVIATION_BADGE_SEPARATOR).concat(l),s=X[d];if(!s)return null;var u=a[k],c=r.isMissingStr(u);if(c)u="";else if(!u)return null;Fe.push(u);var v=a[ce],f="left"===E?null===(i=z[B])||void 0===i?void 0:i.content:null===(o=L[B])||void 0===o?void 0:o.content,p=r.safeStringify(f),g=Object.keys(Ae).map(function(e){return{key:e,text:Ae[e][ce]}}).filter(function(e){return!r.isMissingStr(e.text)}).sort(function(e,n){return n.text.length-e.text.length}),h=new Set;g.forEach(function(e){var n=e.text.replace(/\\(['’])/g,"$1").replace(/\\n/g,"\n");if(n){var i=new RegExp(r.escapeRegExp(n));i.test(p)&&(h.add(e.key),p=p.replace(i,"__TOKEN_".concat(e.key,"__")))}});var x=!r.isMissingStr(v)&&!h.has(l),m=me||r.isMissingStr(v)||x,_="".concat(Se,".").concat(s),b="".concat(Re).concat(r.DEVIATION_BADGE_SEPARATOR).concat(l).concat(r.DEVIATION_BADGE_SEPARATOR).concat(B).concat(r.DEVIATION_BADGE_SEPARATOR).concat(B),y=B;if("right"===E&&V){var w=null===(t=R.refIndexes)||void 0===t?void 0:t[0],I=z.findIndex(function(e){return e.selfIndex===w});-1!==I&&(y=I)}var A=$?$(y):null,S=!1;u&&(S=Object.values(Ae).map(function(e){return e[k]}).filter(Boolean).some(function(e){return e.length>u.length&&e.includes(u)}));var F=A?e.__assign(e.__assign({},A),{badgeBg:ye.badgeBg,badgeBorder:ye.badgeBorder,badgeText:ye.badgeText}):e.__assign({},ye);S&&(F.badgeBg="#FFFBEB",F.badgeBorder="#FCD34D",F.badgeText="#B45309",F.highlightBg="#FDE68A");var j=(null==a?void 0:a.deviation_summary)?{deviation_summary:a.deviation_summary,deviation_title:null==_e?void 0:_e.deviation_title,evaluation_outputs:null==_e?void 0:_e.evaluation_outputs}:null;return{id:d,actionId:b,label:_,highlight:u,side:E,style:F,score:Ie,isConnected:null==J?void 0:J.has(b),isOrphan:m,isMissingClause:c,badgeRef:Y(E,d),onClick:function(e){e.stopPropagation(),Q&&Q(e,ve||{id:"orphan-left",title:"",content:""},m,fe||{id:"orphan-right",title:"",content:""},b,F)},onSummaryClick:function(e){e.stopPropagation(),H(e,b,m,j)}}}).filter(Boolean),Ce=R.id&&E===(null==M?void 0:M.columnKey)?M:null,Te=s.default.useRef(!1);return i.useEffect(function(){D||(Te.current=!1)},[D]),i.useEffect(function(){var e=!!Z&&!!ee&&Re===ee,n=!!Z&&(R.subsections||[]).some(function(e){return e.id===Z});if(D&&!Te.current&&!e&&!n){var i=setTimeout(function(){var e,n;Te.current=!0,null===(n=null===(e=null==Ce?void 0:Ce.showBelowRef)||void 0===e?void 0:e.current)||void 0===n||n.scrollIntoView({behavior:"smooth",block:"center"})},600);return function(){return clearTimeout(i)}}},[D,Z,ee,Re,null==Ce?void 0:Ce.showBelow]),n.jsxs(o.Box,e.__assign({ref:F,sx:{mb:C,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:[D&&(null==Ce?void 0:Ce.showAbove)&&n.jsx("div",e.__assign({style:{position:"sticky",top:0,height:"0px",cursor:"pointer"},onClick:function(){var e,n;return null===(n=null===(e=null==Ce?void 0:Ce.showAboveRef)||void 0===e?void 0:e.current)||void 0===n?void 0:n.scrollIntoView({behavior:"smooth",block:"center"})}},{children:n.jsx("div",e.__assign({style:e.__assign({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===E?"+":"-"," 130px))"),position:"absolute",paddingTop:"20px"},"left"===E?{right:"0px"}:{left:"0px"})},{children:n.jsx(t.ChevronUp,{color:window.getComputedStyle(null===(A=null==Ce?void 0:Ce.showAboveRef)||void 0===A?void 0:A.current).color})}))})),n.jsxs(o.Accordion,e.__assign({disableGutters:!0,expanded:!oe&&D,onChange:function(){oe||(O(),N.current=R.id)},sx:{boxShadow:"none",border:oe?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:oe?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flexGrow:1,width:"100%",display:"flex",flexDirection:"column",minWidth:0,"&:before":{display:"none"},"& .MuiAccordion-heading":{position:"sticky",top:-12,zIndex:10,background:"#fff"}}},{children:[n.jsx(o.AccordionSummary,e.__assign({expandIcon:oe?null:n.jsx(t.ChevronDown,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:oe?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:ne&&n.jsx(o.Tooltip,e.__assign({title:le,placement:"top"},{children:n.jsx(o.Typography,e.__assign({component:"div",sx:{fontSize:"12px",color:oe?"#94A3B8":"#19213D",fontWeight:oe?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(Ee=le,Ee?r.safeStringify(Ee).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(e,i){return e.startsWith("**")&&e.endsWith("**")?n.jsx("strong",{children:e.slice(2,-2)},i):n.jsx(s.default.Fragment,{children:e},i)}):null)}))}))})),!oe&&n.jsxs(o.AccordionDetails,e.__assign({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[ie&&n.jsx(l.MemoizedMarkdown,{content:R.content,sxStyles:P,highlights:Fe,maintainRelativeOrder:V,highlightBg:we,deviationBadges:je}),(R.subsections||[]).map(function(e,n){return W({section:e,keyPath:"".concat(B,"-").concat(n),depth:0,columnKey:E,parentNodeId:k,devCounter:te})})]}))]})),D&&(null==Ce?void 0:Ce.showBelow)&&n.jsx("div",e.__assign({style:{position:"sticky",bottom:0,height:"0px",cursor:"pointer"},onClick:function(){var e,n;return null===(n=null===(e=null==Ce?void 0:Ce.showBelowRef)||void 0===e?void 0:e.current)||void 0===n?void 0:n.scrollIntoView({behavior:"smooth",block:"center"})}},{children:n.jsx("div",e.__assign({style:e.__assign({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===E?"+":"-"," 130px))"),position:"absolute",paddingBottom:"20px"},"left"===E?{right:"0px"}:{left:"0px"})},{children:n.jsx(t.ChevronDown,{color:window.getComputedStyle(null===(S=null==Ce?void 0:Ce.showBelowRef)||void 0===S?void 0:S.current).color})}))}))]}),"".concat(E,"-sec-").concat(B))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),i=require("react"),t=require("@mui/material"),o=require("lucide-react"),r=require("../hooks/memoizedMarkdown.js"),l=require("../CognitiveComparehelpers.js"),d=require("../CognitiveCompareConstants.js");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=a(i),u=function(e){var n=function(e){for(var n=(null==e?void 0:e.parentElement)||null;n;){var i=window.getComputedStyle(n).overflowY;if(("auto"===i||"scroll"===i)&&n.scrollHeight>n.clientHeight)return n;n=n.parentElement}return null}(e),i=e.getBoundingClientRect(),t=(null==n?void 0:n.getBoundingClientRect())||{top:0,bottom:window.innerHeight};return i.top>=t.top&&i.bottom<=t.bottom};exports.default=function(a){var c,v,f,p,g,x,h,m,_,y,b,I,w,R,S,A,E=a.section,C=a.idx,j=a.columnKey,D=a.colRef,F=a.mb,T=void 0===F?1:F,k=a.parentNodeId,B=void 0===k?"":k,O=a.isExpanded,M=a.onToggle,P=a.navigation,N=a.showOpenNodeRef,V=a.resolvedMarkdownStyles,W=a.maintainRelativeOrder,q=a.renderSubSections,G=a.treeData,z=a.proposedSections,H=void 0===z?[]:z,K=a.existingSections,Y=void 0===K?[]:K,L=a.deviationNumberRegistry,U=void 0===L?{}:L,X=a.getBadgeRef,$=a.openSummaryPopup,J=a.getSectionCompareStyle,Q=a.connectedSections,Z=a.openMoreFunctionsPopup,ee=a.deviationNodeIdToView,ne=a.deviationTargetParentId,ie=(null===(c=E.displayTitle)||void 0===c||c)&&l.hasValue(E.title),te=(null===(v=E.displayContent)||void 0===v||v)&&l.hasValue(E.content),oe=!ie&&!te,re={current:1},le=E.title;ie||(le=te?"No Title Found":"No Matching Section Found");var de=E.evaluationResult;if(!de&&"right"===j)if(W){var ae=null===(f=E.refIndexes)||void 0===f?void 0:f[0],se=H.find(function(e){return e.selfIndex===ae});de=null==se?void 0:se.evaluationResult}else de=null===(p=H[C])||void 0===p?void 0:p.evaluationResult;var ue=null===(g=null==G?void 0:G.input_index_map)||void 0===g?void 0:g[0],ce=null===(x=null==G?void 0:G.input_index_map)||void 0===x?void 0:x[1],ve="left"===j?ce:ue,fe="left"===j?E:H[C],pe="right"===j?E:Y[C];if(W)if("left"===j){var ge=null===(h=E.refIndexes)||void 0===h?void 0:h[0],xe=Y.findIndex(function(e){return e.selfIndex===ge});pe=-1!==xe?Y[xe]:void 0}else{var he=null===(m=E.refIndexes)||void 0===m?void 0:m[0],me=H.findIndex(function(e){return e.selfIndex===he});fe=-1!==me?H[me]:void 0}var _e="left"===j?!pe:!fe,ye=de||(null==fe?void 0:fe.evaluationResult)||(null==pe?void 0:pe.evaluationResult),be=null!==(b=null===(y=null===(_=null==ye?void 0:ye.evaluation_outputs)||void 0===_?void 0:_.metadata)||void 0===y?void 0:y.label_color)&&void 0!==b?b:d.DEFAULT_DEVIAION_COLOR,Ie=l.generateColorPalette(be),we=Ie.highlightBg,Re=null!==(w=null===(I=null==ye?void 0:ye.evaluation_outputs)||void 0===I?void 0:I.output_value)&&void 0!==w?w:null,Se=(null==ye?void 0:ye.deviations)||{},Ae=C+1,Ee=E.id;if("right"===j&&W){var Ce=null===(R=E.refIndexes)||void 0===R?void 0:R[0];-1!==(me=H.findIndex(function(e){return e.selfIndex===Ce}))&&(Ae=me+1,Ee=H[me].id)}var je,De=i.useRef(ee),Fe=i.useRef(ne||null),Te=[],ke=Object.entries(Se).map(function(n){var i,t,o,r,d,a=n[0],s=n[1],u="".concat(Ee).concat(l.DEVIATION_BADGE_SEPARATOR).concat(a),c=U[u];if(!c)return null;var v=s[B],f=l.isMissingStr(v);if(f)v="";else if(!v)return null;Te.push(v);var p=C,g=C;if(W)if("left"===j){var x=null===(i=E.refIndexes)||void 0===i?void 0:i[0],h=Y.findIndex(function(e){return e.selfIndex===x});g=-1!==h?h:C}else{var m=null===(t=E.refIndexes)||void 0===t?void 0:t[0],_=H.findIndex(function(e){return e.selfIndex===m});p=-1!==_?_:C}var y="".concat(Ee).concat(l.DEVIATION_BADGE_SEPARATOR).concat(a).concat(l.DEVIATION_BADGE_SEPARATOR).concat(p).concat(l.DEVIATION_BADGE_SEPARATOR).concat(g),b="left"===j?null===(o=Y[g])||void 0===o?void 0:o.content:null===(r=H[p])||void 0===r?void 0:r.content,I=s[ve],w=l.safeStringify(b),R=Object.keys(Se).map(function(e){return{key:e,text:Se[e][ve]}}).filter(function(e){return!l.isMissingStr(e.text)}).sort(function(e,n){return n.text.length-e.text.length}),S=new Set;R.forEach(function(e){var n=e.text.replace(/\\(['’])/g,"$1").replace(/\\n/g,"\n");if(n){var i=new RegExp(l.escapeRegExp(n));i.test(w)&&(S.add(e.key),w=w.replace(i,"__TOKEN_".concat(e.key,"__")))}});var A=!l.isMissingStr(I)&&!S.has(a),D=_e||l.isMissingStr(I)||A,F="".concat(Ae,".").concat(c),T=C;if("right"===j&&W){var k=null===(d=E.refIndexes)||void 0===d?void 0:d[0],O=H.findIndex(function(e){return e.selfIndex===k});-1!==O&&(T=O)}var M=J?J(T):null,P=M?e.__assign(e.__assign({},M),{badgeBg:Ie.badgeBg,badgeBorder:Ie.badgeBorder,badgeText:Ie.badgeText}):e.__assign({},Ie),N=(null==s?void 0:s.deviation_summary)?{deviation_summary:s.deviation_summary,deviation_title:null==ye?void 0:ye.deviation_title,evaluation_outputs:null==ye?void 0:ye.evaluation_outputs}:null;return{id:u,actionId:y,label:F,highlight:v,side:j,style:P,score:Re,isConnected:null==Q?void 0:Q.has(y),isOrphan:D,isMissingClause:f,badgeRef:X(j,u),onClick:function(e){e.stopPropagation(),Z&&Z(e,fe||{id:"orphan-left",title:"",content:""},D,pe||{id:"orphan-right",title:"",content:""},y,P)},onSummaryClick:function(e){e.stopPropagation(),$(e,y,D,N)}}}).filter(Boolean),Be=E.id&&j===(null==P?void 0:P.columnKey)?P:null,Oe=s.default.useRef(!1);return i.useEffect(function(){O||(Oe.current=!1)},[O]),i.useEffect(function(){De.current=ee,Fe.current=ne||null},[ee,ne]),i.useEffect(function(){var e=!!De.current&&!!Fe.current&&Ee===Fe.current,n=!!De.current&&(E.subsections||[]).some(function(e){return e.id===De.current});if(O&&!Oe.current&&!e&&!n){var i=setTimeout(function(){var e,n=null===(e=null==Be?void 0:Be.firstDeviationRef)||void 0===e?void 0:e.current,i=null==Be?void 0:Be.firstDeviationPosition;n?"inside"===i||u(n)?Oe.current=!0:(Oe.current=!0,n.scrollIntoView({behavior:"smooth",block:"center"})):Oe.current=!0},600);return function(){return clearTimeout(i)}}},[O,Ee,null==Be?void 0:Be.firstDeviationPosition,null==Be?void 0:Be.firstDeviationRef]),n.jsxs(t.Box,e.__assign({ref:D,sx:{mb:T,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:[O&&(null==Be?void 0:Be.showAbove)&&n.jsx("div",e.__assign({style:{position:"sticky",top:0,height:"0px",cursor:"pointer"},onClick:function(){var e,n;return null===(n=null===(e=null==Be?void 0:Be.showAboveRef)||void 0===e?void 0:e.current)||void 0===n?void 0:n.scrollIntoView({behavior:"smooth",block:"center"})}},{children:n.jsx("div",e.__assign({style:e.__assign({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===j?"+":"-"," 130px))"),position:"absolute",paddingTop:"20px"},"left"===j?{right:"0px"}:{left:"0px"})},{children:n.jsx(o.ChevronUp,{color:window.getComputedStyle(null===(S=null==Be?void 0:Be.showAboveRef)||void 0===S?void 0:S.current).color})}))})),n.jsxs(t.Accordion,e.__assign({disableGutters:!0,expanded:!oe&&O,onChange:function(){oe||(M(),N.current=E.id)},sx:{boxShadow:"none",border:oe?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:oe?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flexGrow:1,width:"100%",display:"flex",flexDirection:"column",minWidth:0,"&:before":{display:"none"},"& .MuiAccordion-heading":{position:"sticky",top:-12,zIndex:10,background:"#fff"}}},{children:[n.jsx(t.AccordionSummary,e.__assign({expandIcon:oe?null:n.jsx(o.ChevronDown,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:oe?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:ie&&n.jsx(t.Tooltip,e.__assign({title:le,placement:"top"},{children:n.jsx(t.Typography,e.__assign({component:"div",sx:{fontSize:"12px",color:oe?"#94A3B8":"#19213D",fontWeight:oe?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(je=le,je?l.safeStringify(je).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(e,i){return e.startsWith("**")&&e.endsWith("**")?n.jsx("strong",{children:e.slice(2,-2)},i):n.jsx(s.default.Fragment,{children:e},i)}):null)}))}))})),!oe&&n.jsxs(t.AccordionDetails,e.__assign({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[te&&n.jsx(r.MemoizedMarkdown,{content:E.content,sxStyles:V,highlights:Te,maintainRelativeOrder:W,highlightBg:we,deviationBadges:ke}),(E.subsections||[]).map(function(e,n){return q({section:e,keyPath:"".concat(C,"-").concat(n),depth:0,columnKey:j,parentNodeId:B,devCounter:re})})]}))]})),O&&(null==Be?void 0:Be.showBelow)&&n.jsx("div",e.__assign({style:{position:"sticky",bottom:0,height:"0px",cursor:"pointer"},onClick:function(){var e,n;return null===(n=null===(e=null==Be?void 0:Be.showBelowRef)||void 0===e?void 0:e.current)||void 0===n?void 0:n.scrollIntoView({behavior:"smooth",block:"center"})}},{children:n.jsx("div",e.__assign({style:e.__assign({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===j?"+":"-"," 130px))"),position:"absolute",paddingBottom:"20px"},"left"===j?{right:"0px"}:{left:"0px"})},{children:n.jsx(o.ChevronDown,{color:window.getComputedStyle(null===(A=null==Be?void 0:Be.showBelowRef)||void 0===A?void 0:A.current).color})}))}))]}),"".concat(j,"-sec-").concat(C))};
2
2
  //# sourceMappingURL=SectionAccordion.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),i=require("react/jsx-runtime"),n=require("react"),t=require("@mui/material"),o=require("lucide-react"),s=require("../hooks/memoizedMarkdown.js"),l=require("../CognitiveComparehelpers.js"),a=require("../CognitiveCompareConstants.js");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=d(n).default.memo(function(n){var d,u,c,v,g,h,p,_,f,m,x,S=n.section,b=n.keyPath,y=n.depth,B=void 0===y?0:y,A=n.columnKey,j=void 0===A?"left":A,R=n.parentNodeId,E=void 0===R?"":R,I=n.expandedSubSections,O=n.setExpandedSubSections,C=n.maintainRelativeOrder,F=n.proposedSections,w=n.existingSections,D=n.treeData,P=n.deviationNumberRegistry,M=n.connectedSections,T=n.activeSideBySideSection,k=n.resolvedMarkdownStyles,N=n.getSubSectionRef,q=n.getSubSectionCompareStyle,V=n.getBadgeRef,W=n.openMoreFunctionsPopup,z=n.openSummaryPopup,G=n.resetSideBySide,L=n.setConnectedSections,U=n.setConnectedLines,H=n.cachedConnectedPositions,K=(null===(d=S.displayTitle)||void 0===d||d)&&l.hasValue(S.title),J=(null===(u=S.displayContent)||void 0===u||u)&&l.hasValue(S.content),Q=!K&&!J,X=K?S.title:J?"No Title Found":"No Matching Section Found",Y=!!I[b],Z=N(j,b),$=b.split("-").map(Number),ee=$[0],ie=F[ee],ne=w[ee],te=b,oe=b;if(C)if("left"===j){var se=null===(c=null==ie?void 0:ie.refIndexes)||void 0===c?void 0:c[0],le=w.findIndex(function(e){return e.selfIndex===se});-1!==le&&(ne=w[le],oe=e.__spreadArray([le],$.slice(1),!0).join("-"))}else{var ae=null===(v=null==ne?void 0:ne.refIndexes)||void 0===v?void 0:v[0];-1!==(ce=F.findIndex(function(e){return e.selfIndex===ae}))&&(ie=F[ce],te=e.__spreadArray([ce],$.slice(1),!0).join("-"))}for(var de=ie,re=ne,ue=1;ue<$.length;ue++)(null==de?void 0:de.subsections)&&(de=de.subsections[$[ue]]),(null==re?void 0:re.subsections)&&(re=re.subsections[$[ue]]);var ce,ve=q(te)||q(b),ge=null===(g=null==D?void 0:D.input_index_map)||void 0===g?void 0:g[0],he=null===(h=null==D?void 0:D.input_index_map)||void 0===h?void 0:h[1],pe="left"===j?he:ge,_e="left"===j?!re:!de,fe=S.evaluationResult||(null==de?void 0:de.evaluationResult)||(null==re?void 0:re.evaluationResult),me=null!==(_=null===(p=null==fe?void 0:fe.evaluation_outputs)||void 0===p?void 0:p.output_value)&&void 0!==_?_:null,xe=ee+1,Se=S.id;"right"===j&&C&&((null==de?void 0:de.id)&&(Se=de.id),ie&&-1!==(ce=F.findIndex(function(e){return e.id===ie.id}))&&(xe=ce+1));var be=null!==(x=null===(m=null===(f=null==fe?void 0:fe.evaluation_outputs)||void 0===f?void 0:f.metadata)||void 0===m?void 0:m.label_color)&&void 0!==x?x:a.DEFAULT_DEVIAION_COLOR,ye=l.generateColorPalette(be),Be=ye.highlightBg,Ae=(null==fe?void 0:fe.deviations)||{},je=[],Re=Object.entries(Ae).map(function(i){var n,t,o,s=i[0],a=i[1],d="".concat(Se).concat(l.DEVIATION_BADGE_SEPARATOR).concat(s),r=P[d];if(!r)return null;var u=a[E],c=l.isMissingStr(u);if(c)u="";else if(!u)return null;je.push(u);var v=a[pe],g=!1;v&&(g=Object.values(Ae).map(function(e){return e[pe]}).filter(Boolean).some(function(e){return e.length>v.length&&e.includes(v)}));var h=_e||l.isMissingStr(v)||g,p="".concat(xe,".").concat(r),_="".concat(Se).concat(l.DEVIATION_BADGE_SEPARATOR).concat(s).concat(l.DEVIATION_BADGE_SEPARATOR).concat(te).concat(l.DEVIATION_BADGE_SEPARATOR).concat(oe),f=e.__assign({},ye),m=!1;u&&(m=Object.values(Ae).map(function(e){return e[E]}).filter(Boolean).some(function(e){return e.length>u.length&&e.includes(u)}));m&&(f.badgeBg="#FFFBEB",f.badgeBorder="#FCD34D",f.badgeText="#B45309",f.highlightBg="#FDE68A");var x=(null==a?void 0:a.deviation_summary)?{deviation_summary:a.deviation_summary||(null===(n=S.evaluationResult)||void 0===n?void 0:n.deviation_summary),deviation_title:null===(t=S.evaluationResult)||void 0===t?void 0:t.deviation_title,evaluation_outputs:null===(o=S.evaluationResult)||void 0===o?void 0:o.evaluation_outputs}:null;return{id:d,actionId:_,label:p,highlight:u,side:j,style:f,score:me,isConnected:M.has(_),isOrphan:h,isMissingClause:c,badgeRef:V(j,d),onClick:function(i){i.stopPropagation();var n=de?e.__assign(e.__assign({},de),{title:(null==ie?void 0:ie.title)||(null==de?void 0:de.title)||""}):{id:"orphan-left",title:"",content:""},t=re?e.__assign(e.__assign({},re),{title:(null==ne?void 0:ne.title)||(null==re?void 0:re.title)||""}):{id:"orphan-right",title:"",content:""};W(i,n,h,t,_,f)},onSummaryClick:function(e){e.stopPropagation(),z(e,_,h,x)}}}).filter(Boolean),Ee=Re.some(function(e){return M.has(e.actionId)});if(!(K||J||S.subsections&&0!==S.subsections.length))return null;var Ie=!C&&K&&J,Oe=Ee&&ve?{borderRadius:"4px",outline:"2px solid ".concat(ve.badgeBorder),outlineOffset:"1px"}:{};return K?i.jsx(t.Box,e.__assign({ref:Z,sx:{mt:1,width:"100%",minWidth:0,position:"relative"}},{children:i.jsx(t.Box,e.__assign({sx:e.__assign({width:"100%"},Oe)},{children:i.jsxs(t.Accordion,e.__assign({disableGutters:!0,expanded:!Q&&Y,onChange:function(){if(!Q){if(Y){var i=String(T||""),n=i.includes(te)||i.includes(oe);n||M.forEach(function(e){(String(e).includes(te)||String(e).includes(oe))&&(n=!0)}),n&&(G(),L(new Set),U([]),H.current=[])}O(function(i){var n;return e.__assign(e.__assign({},i),((n={})[b]=!i[b],n))})}},sx:{mt:0,boxShadow:"none",border:Q?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF",minWidth:0,"&:before":{display:"none"}}},{children:[i.jsx(t.AccordionSummary,e.__assign({expandIcon:Q?null:i.jsx(o.ChevronDown,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"}}},{children:i.jsx(t.Typography,e.__assign({component:"div",sx:{fontSize:"11px",fontWeight:600,color:Q?"#94A3B8":"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:X||"Untitled Subsection"}))})),!Q&&i.jsxs(t.AccordionDetails,e.__assign({sx:{pt:0,pb:1,minWidth:0}},{children:[J&&i.jsx(s.MemoizedMarkdown,{content:S.content,sxStyles:k,deviationBadges:Ie?[]:Re,maintainRelativeOrder:C,highlightBg:Be,highlights:je}),(S.subsections||[]).map(function(t,o){return i.jsx(r,e.__assign({},n,{section:t,keyPath:"".concat(b,"-").concat(o),depth:B+1}),"".concat(b,"-").concat(o))})]}))]}))}))})):i.jsx(t.Box,e.__assign({ref:Z,sx:{mt:0===B?1:.75,width:"100%",minWidth:0,position:"relative"}},{children:!Q&&i.jsxs(t.Box,e.__assign({sx:e.__assign({width:"100%"},Oe)},{children:[J&&i.jsx(s.MemoizedMarkdown,{content:S.content,sxStyles:k,deviationBadges:Re,maintainRelativeOrder:C,highlightBg:Be,highlights:je}),(S.subsections||[]).map(function(t,o){return i.jsx(r,e.__assign({},n,{section:t,keyPath:"".concat(b,"-").concat(o),depth:B+1}),"".concat(b,"-").concat(o))})]}))}))});exports.default=r;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("tslib"),e=require("react/jsx-runtime"),i=require("react"),t=require("@mui/material"),o=require("lucide-react"),l=require("../hooks/memoizedMarkdown.js"),s=require("../CognitiveComparehelpers.js"),a=require("../CognitiveCompareConstants.js");function r(n){return n&&"object"==typeof n&&"default"in n?n:{default:n}}var u=r(i).default.memo(function(r){var d,c,v,f,h,p,g,_,m,x,S,b=r.section,y=r.keyPath,A=r.depth,E=void 0===A?0:A,I=r.columnKey,R=void 0===I?"left":I,j=r.parentNodeId,B=void 0===j?"":j,O=r.expandedSubSections,P=r.setExpandedSubSections,w=r.maintainRelativeOrder,C=r.proposedSections,k=r.existingSections,F=r.treeData,D=r.deviationNumberRegistry,T=r.connectedSections,M=r.activeSideBySideSection,N=r.resolvedMarkdownStyles,q=r.getSubSectionRef,V=r.getSubSectionCompareStyle,W=r.getBadgeRef,z=r.openMoreFunctionsPopup,G=r.openSummaryPopup,L=r.resetSideBySide,U=r.setConnectedSections,H=r.setConnectedLines,K=r.cachedConnectedPositions,J=(null===(d=b.displayTitle)||void 0===d||d)&&s.hasValue(b.title),Q=(null===(c=b.displayContent)||void 0===c||c)&&s.hasValue(b.content),X=!J&&!Q,Y=J?b.title:Q?"No Title Found":"No Matching Section Found",Z=!!O[y],$=q(R,y),nn=y.split("-").map(Number),en=nn[0],tn=C[en],on=k[en],ln=y,sn=y,an=en,rn=en,un=function(n,e,i){if(!n||!e)return null;if(n.id===e)return{section:n,keyPath:i};for(var t=(n.subsections||[]).map(function(n,e){return{section:n,keyPath:"".concat(i,"-").concat(e)}}),o=function(){var n=t.shift();return(null==n?void 0:n.section)?n.section.id===e?{value:n}:void(n.section.subsections||[]).forEach(function(e,i){t.push({section:e,keyPath:"".concat(n.keyPath,"-").concat(i)})}):"continue"};t.length>0;){var l=o();if("object"==typeof l)return l.value}return null};if(w)if("left"===R){var dn=null===(v=null==tn?void 0:tn.refIndexes)||void 0===v?void 0:v[0],cn=k.findIndex(function(n){return n.selfIndex===dn});-1!==cn&&(on=k[cn],rn=cn)}else{var vn=null===(f=null==on?void 0:on.refIndexes)||void 0===f?void 0:f[0];-1!==(mn=C.findIndex(function(n){return n.selfIndex===vn}))&&(tn=C[mn],an=mn)}var fn=tn,hn=on;if(w)if("left"===R){fn=b,ln=y;var pn=un(on,b.id,String(rn));hn=(null==pn?void 0:pn.section)||null,sn=(null==pn?void 0:pn.keyPath)||""}else{hn=b,sn=y;var gn=un(tn,b.id,String(an));fn=(null==gn?void 0:gn.section)||null,ln=(null==gn?void 0:gn.keyPath)||""}else for(var _n=1;_n<nn.length;_n++)(null==fn?void 0:fn.subsections)&&(fn=fn.subsections[nn[_n]]),(null==hn?void 0:hn.subsections)&&(hn=hn.subsections[nn[_n]]);var mn,xn=(ln?V(ln):null)||V(y),Sn=null===(h=null==F?void 0:F.input_index_map)||void 0===h?void 0:h[0],bn=null===(p=null==F?void 0:F.input_index_map)||void 0===p?void 0:p[1],yn="left"===R?bn:Sn,An="left"===R?!hn:!fn,En=b.evaluationResult||(null==fn?void 0:fn.evaluationResult)||(null==hn?void 0:hn.evaluationResult),In=null!==(_=null===(g=null==En?void 0:En.evaluation_outputs)||void 0===g?void 0:g.output_value)&&void 0!==_?_:null,Rn=en+1,jn=b.id||(null==fn?void 0:fn.id)||(null==hn?void 0:hn.id);"right"===R&&w&&(tn&&-1!==(mn=C.findIndex(function(n){return n.id===tn.id}))&&(Rn=mn+1));var Bn=null!==(S=null===(x=null===(m=null==En?void 0:En.evaluation_outputs)||void 0===m?void 0:m.metadata)||void 0===x?void 0:x.label_color)&&void 0!==S?S:a.DEFAULT_DEVIAION_COLOR,On=s.generateColorPalette(Bn),Pn=On.highlightBg,wn=(null==En?void 0:En.deviations)||{},Cn=[],kn=Object.entries(wn).map(function(e){var i=e[0],t=e[1],o="".concat(jn).concat(s.DEVIATION_BADGE_SEPARATOR).concat(i),l=D[o];if(!l)return null;var a=t[B],r=s.isMissingStr(a);if(r)a="";else if(!a)return null;Cn.push(a);var u=t[yn],d=!1;u&&(d=Object.values(wn).map(function(n){return n[yn]}).filter(Boolean).some(function(n){return n.length>u.length&&n.includes(u)}));var c=An||s.isMissingStr(u)||d,v="".concat(Rn,".").concat(l),f="".concat(jn).concat(s.DEVIATION_BADGE_SEPARATOR).concat(i).concat(s.DEVIATION_BADGE_SEPARATOR).concat(ln).concat(s.DEVIATION_BADGE_SEPARATOR).concat(sn),h=n.__assign({},On),p=(null==t?void 0:t.deviation_summary)?{deviation_summary:t.deviation_summary||(null==En?void 0:En.deviation_summary),deviation_title:null==En?void 0:En.deviation_title,evaluation_outputs:null==En?void 0:En.evaluation_outputs}:null;return{id:o,actionId:f,label:v,highlight:a,side:R,style:h,score:In,isConnected:T.has(f),isOrphan:c,isMissingClause:r,badgeRef:W(R,o),onClick:function(e){e.stopPropagation();var i=fn?n.__assign(n.__assign({},fn),{title:(null==tn?void 0:tn.title)||(null==fn?void 0:fn.title)||""}):{id:"orphan-left",title:"",content:""},t=hn?n.__assign(n.__assign({},hn),{title:(null==on?void 0:on.title)||(null==hn?void 0:hn.title)||""}):{id:"orphan-right",title:"",content:""};z(e,i,c,t,f,h)},onSummaryClick:function(n){n.stopPropagation(),G(n,f,c,p)}}}).filter(Boolean).sort(function(n,e){return parseFloat(n.label)-parseFloat(e.label)}),Fn=i.useRef(!1);i.useEffect(function(){Z||(Fn.current=!1)},[Z]),i.useEffect(function(){if(Z&&!Fn.current){var n=setTimeout(function(){var n,e;Fn.current=!0;var i=null===(e=null===(n=kn[0])||void 0===n?void 0:n.badgeRef)||void 0===e?void 0:e.current;i&&i.scrollIntoView({behavior:"smooth",block:"center"})},350);return function(){return clearTimeout(n)}}},[Z,kn]);var Dn=kn.some(function(n){return T.has(n.actionId)});if(!(J||Q||b.subsections&&0!==b.subsections.length))return null;var Tn=!w&&J&&Q,Mn=Dn&&xn?{borderRadius:"4px",outline:"2px solid ".concat(xn.badgeBorder),outlineOffset:"1px"}:{};return J?e.jsx(t.Box,n.__assign({ref:$,sx:{mt:1,width:"100%",minWidth:0,position:"relative"}},{children:e.jsx(t.Box,n.__assign({sx:n.__assign({width:"100%"},Mn)},{children:e.jsxs(t.Accordion,n.__assign({disableGutters:!0,expanded:!X&&Z,onChange:function(){if(!X){if(Z){var e=String(M||""),i=e.includes(ln)||e.includes(sn);i||T.forEach(function(n){(String(n).includes(ln)||String(n).includes(sn))&&(i=!0)}),i&&(L(),U(new Set),H([]),K.current=[])}P(function(e){var i;return n.__assign(n.__assign({},e),((i={})[y]=!e[y],i))})}},sx:{mt:0,boxShadow:"none",border:X?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF",minWidth:0,"&:before":{display:"none"}}},{children:[e.jsx(t.AccordionSummary,n.__assign({expandIcon:X?null:e.jsx(o.ChevronDown,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"}}},{children:e.jsx(t.Typography,n.__assign({component:"div",sx:{fontSize:"11px",fontWeight:600,color:X?"#94A3B8":"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:Y||"Untitled Subsection"}))})),!X&&e.jsxs(t.AccordionDetails,n.__assign({sx:{pt:0,pb:1,minWidth:0}},{children:[Q&&e.jsx(l.MemoizedMarkdown,{content:b.content,sxStyles:N,deviationBadges:Tn?[]:kn,maintainRelativeOrder:w,highlightBg:Pn,highlights:Cn}),(b.subsections||[]).map(function(i,t){return e.jsx(u,n.__assign({},r,{section:i,keyPath:"".concat(y,"-").concat(t),depth:E+1}),"".concat(y,"-").concat(t))})]}))]}))}))})):e.jsx(t.Box,n.__assign({ref:$,sx:{mt:0===E?1:.75,width:"100%",minWidth:0,position:"relative"}},{children:!X&&e.jsxs(t.Box,n.__assign({sx:n.__assign({width:"100%"},Mn)},{children:[Q&&e.jsx(l.MemoizedMarkdown,{content:b.content,sxStyles:N,deviationBadges:kn,maintainRelativeOrder:w,highlightBg:Pn,highlights:Cn}),(b.subsections||[]).map(function(i,t){return e.jsx(u,n.__assign({},r,{section:i,keyPath:"".concat(y,"-").concat(t),depth:E+1}),"".concat(y,"-").concat(t))})]}))}))});exports.default=u;
2
2
  //# sourceMappingURL=SubSectionAccordion.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),r=require("@mui/material"),i=require("react"),o=require("../CognitiveCompareConstants.js"),t=require("lucide-react"),a=require("react-markdown"),s=require("../CognitiveComparehelpers.js"),l=require("rehype-raw");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=c(i),p=c(a),u=c(l),g=d.default.memo(function(a){var l=a.content,c=a.sxStyles,d=a.deviationBadges,g=void 0===d?[]:d,f=a.highlights,_=void 0===f?[]:f,h=a.maintainRelativeOrder,x=void 0===h||h,v=a.highlightBg,m=i.useMemo(function(){return g.reduce(function(n,r){var i;return e.__assign(e.__assign({},n),((i={})[r.id]=r,i))},{})},[g]),b=i.useMemo(function(){return{mark:function(r){var i=r.children;return n.jsx("span",e.__assign({style:{backgroundColor:v,borderRadius:"2px"}},{children:i}))},span:function(i){var a,s,l,c,d,p,u=i.children,g=e.__rest(i,["children"]),f=g["data-badge-id"];if(!f)return n.jsx("span",e.__assign({},g,{children:u}));var _=m[f];return _?n.jsxs(r.Box,e.__assign({component:"span",sx:{position:"static",display:"inline"}},{children:[n.jsxs(r.Box,e.__assign({ref:_.badgeRef,sx:e.__assign(e.__assign({fontStyle:"normal",position:"absolute",zIndex:30,display:"inline-flex",alignItems:"stretch",fontSize:"10px",bgcolor:(null===(a=_.style)||void 0===a?void 0:a.badgeBg)||"#EEF2FF",color:(null===(s=_.style)||void 0===s?void 0:s.badgeText)||o.DEFAULT_DEVIAION_COLOR,border:"1px solid ".concat((null===(l=_.style)||void 0===l?void 0:l.badgeBorder)||"#C7D2FE"),borderRadius:"12px",fontWeight:600,whiteSpace:"nowrap",boxShadow:"0 1px 3px rgba(0,0,0,0.07)",overflow:"hidden"},"left"===_.side?{right:"-16px",transform:"translateY(-20%) translateX(calc(100% + 8px))"}:{left:"-16px",transform:"translateY(-20%) translateX(calc(-100% - 8px))"}),_.isConnected&&_.style&&{outline:"2px solid ".concat(_.style.badgeBorder),outlineOffset:"1px"})},{children:[n.jsxs(r.Box,e.__assign({onClick:function(e){e.stopPropagation(),_.onSummaryClick&&_.onSummaryClick(e)},sx:{display:"flex",alignItems:"center",px:1,py:.3,cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.04)"}}},{children:[n.jsx(r.Box,e.__assign({component:"span",sx:{fontSize:"10px",fontWeight:700}},{children:_.label})),("left"===_.side||_.isOrphan)&&n.jsx(r.Box,e.__assign({component:"span",sx:{fontSize:"10px",pl:.5,ml:.5,borderLeft:"1px solid ".concat((null===(c=_.style)||void 0===c?void 0:c.badgeBorder)||"#C7D2FE")}},{children:null!=_.score&&"N/A"!==_.score&&"NA"!==_.score&&0!==_.score?"".concat(_.score):"N/A"===_.score||"NA"===_.score?"N/A":"Same"}))]})),("left"===_.side||_.isOrphan)&&n.jsx(r.Box,e.__assign({onClick:function(e){e.stopPropagation(),_.onClick&&_.onClick(e)},sx:{display:"flex",alignItems:"center",px:.5,borderLeft:"1px solid ".concat((null===(d=_.style)||void 0===d?void 0:d.badgeBorder)||"#C7D2FE"),cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.06)"}}},{children:n.jsx(t.EllipsisVertical,{size:12,color:(null===(p=_.style)||void 0===p?void 0:p.badgeText)||"#3730A3"})}))]})),u]})):n.jsx("span",e.__assign({},g,{children:u}))}}},[m,x]),y=i.useMemo(function(){var n=function(e){return e?e.replace(/\\([''])/g,"$1").replace(/\\n/g,"\n").replace(/\r\n/g,"\n").split(/(\n{2,})/).map(function(e){return e.startsWith("\n")?e:e.replace(/\n/g," ")}).join(""):""},r=function(e,n,r){return void 0===n&&(n=""),void 0===r&&(r=""),n+e.split(/(\n{2,})/).map(function(e){return/^\n{2,}$/.test(e)?e:e.trim()?"<mark>".concat(e,"</mark>"):e}).join("")+r},i=n(s.safeStringify(l||"")),o=e.__spreadArray([],g,!0).sort(function(e,n){var r,i;return((null===(r=n.highlight)||void 0===r?void 0:r.length)||0)-((null===(i=e.highlight)||void 0===i?void 0:i.length)||0)}),t={},a=0;o.forEach(function(e){if(e&&e.highlight){var o=n(e.highlight);if(o){var s=o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),l="__DEV_TOKEN_".concat(a++,"__");t[l]=r(o,'<span data-badge-id="'.concat(e.id,'">'),"</span>"),i=i.replace(o,l);var c="__HIGHLIGHT_TOKEN_".concat(a++,"__");t[c]=r(o),i=i.replace(new RegExp(s,"g"),c)}}});var c=new Set(o.map(function(e){return n(e.highlight)}).filter(Boolean));return _.forEach(function(e){if(e){var o=n(e);if(o&&!c.has(o)){var s=o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),l="__PLAIN_TOKEN_".concat(a++,"__");t[l]=r(o),i=i.replace(new RegExp(s,"g"),l)}}}),Object.keys(t).forEach(function(e){i=i.split(e).join(t[e])}),i},[l,g,_]);return n.jsx(r.Typography,e.__assign({component:"div",sx:e.__assign(e.__assign({},c),{position:"relative",overflow:"visible",whiteSpace:"pre-wrap","& p, & li, & ul, & ol":{position:"static",overflow:"visible",whiteSpace:"pre-wrap"}})},{children:n.jsx(p.default,e.__assign({components:b,rehypePlugins:[u.default]},{children:s.safeStringify(y).replace(/\\n/g,"\n")}))}))},s.areMarkdownPropsEqual);exports.MemoizedMarkdown=g;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),r=require("@mui/material"),i=require("react"),t=require("../CognitiveCompareConstants.js"),o=require("lucide-react"),a=require("react-markdown"),s=require("../CognitiveComparehelpers.js"),l=require("rehype-raw");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=c(i),p=c(a),u=c(l),g=d.default.memo(function(a){var l=a.content,c=a.sxStyles,d=a.deviationBadges,g=void 0===d?[]:d,f=a.highlights,h=void 0===f?[]:f,_=a.maintainRelativeOrder,x=void 0===_||_,v=a.highlightBg,m=i.useMemo(function(){return g.reduce(function(n,r){var i;return e.__assign(e.__assign({},n),((i={})[r.id]=r,i))},{})},[g]),b=i.useMemo(function(){return{mark:function(r){var i=r.children;return n.jsx("span",e.__assign({style:{backgroundColor:v,borderRadius:"2px"}},{children:i}))},span:function(i){var a,s,l,c,d,p,u=i.children,g=e.__rest(i,["children"]),f=g["data-badge-id"];if(!f)return n.jsx("span",e.__assign({},g,{children:u}));var h=m[f];return h?n.jsxs(r.Box,e.__assign({component:"span",sx:{position:"static",display:"inline"}},{children:[n.jsxs(r.Box,e.__assign({ref:h.badgeRef,sx:e.__assign(e.__assign({fontStyle:"normal",position:"absolute",zIndex:30,display:"inline-flex",alignItems:"stretch",fontSize:"10px",bgcolor:(null===(a=h.style)||void 0===a?void 0:a.badgeBg)||"#EEF2FF",color:(null===(s=h.style)||void 0===s?void 0:s.badgeText)||t.DEFAULT_DEVIAION_COLOR,border:"1px solid ".concat((null===(l=h.style)||void 0===l?void 0:l.badgeBorder)||"#C7D2FE"),borderRadius:"12px",fontWeight:600,whiteSpace:"nowrap",boxShadow:"0 1px 3px rgba(0,0,0,0.07)",overflow:"hidden"},"left"===h.side?{right:"-16px",transform:"translateY(-20%) translateX(calc(100% + 8px))"}:{left:"-16px",transform:"translateY(-20%) translateX(calc(-100% - 8px))"}),h.isConnected&&h.style&&{outline:"2px solid ".concat(h.style.badgeBorder),outlineOffset:"1px"})},{children:[n.jsxs(r.Box,e.__assign({onClick:function(e){e.stopPropagation(),h.onSummaryClick&&h.onSummaryClick(e)},sx:{display:"flex",alignItems:"center",px:1,py:.3,cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.04)"}}},{children:[n.jsx(r.Box,e.__assign({component:"span",sx:{fontSize:"10px",fontWeight:700}},{children:h.label})),("left"===h.side||h.isOrphan)&&n.jsx(r.Box,e.__assign({component:"span",sx:{fontSize:"10px",pl:.5,ml:.5,borderLeft:"1px solid ".concat((null===(c=h.style)||void 0===c?void 0:c.badgeBorder)||"#C7D2FE")}},{children:null!=h.score&&"N/A"!==h.score&&"NA"!==h.score&&0!==h.score?"".concat(h.score):"N/A"===h.score||"NA"===h.score?"N/A":"Same"}))]})),("left"===h.side||h.isOrphan)&&n.jsx(r.Box,e.__assign({onClick:function(e){e.stopPropagation(),h.onClick&&h.onClick(e)},sx:{display:"flex",alignItems:"center",px:.5,borderLeft:"1px solid ".concat((null===(d=h.style)||void 0===d?void 0:d.badgeBorder)||"#C7D2FE"),cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.06)"}}},{children:n.jsx(o.EllipsisVertical,{size:12,color:(null===(p=h.style)||void 0===p?void 0:p.badgeText)||"#3730A3"})}))]})),u]})):n.jsx("span",e.__assign({},g,{children:u}))}}},[m,x]),y=i.useMemo(function(){var n=function(e){return e?e.replace(/\\([''])/g,"$1").replace(/\\n/g,"\n").replace(/\r\n/g,"\n").split(/(\n{2,})/).map(function(e){return e.startsWith("\n")?e:e.replace(/\n/g," ")}).join(""):""},r=function(e,n,r){void 0===n&&(n=""),void 0===r&&(r="");var i=e.startsWith("\n\n"),t=e.endsWith("\n\n");return n+e.split(/(\n{2,})/).map(function(e,n,r){if(/^\n{2,}$/.test(e))return e;if(!e.trim())return e;var o=0===n||1===n&&/^\n{2,}$/.test(r[0]),a=n===r.length-1||n===r.length-2&&/^\n{2,}$/.test(r[r.length-1]);return i&&o||t&&a?e:"<mark>".concat(e,"</mark>")}).join("").replace(/^\n{2,}/,"").replace(/\n{2,}$/,"")+r},i=n(s.safeStringify(l||"")),t=e.__spreadArray([],g,!0).sort(function(e,n){var r,i;return((null===(r=n.highlight)||void 0===r?void 0:r.length)||0)-((null===(i=e.highlight)||void 0===i?void 0:i.length)||0)}),o={},a=0;t.forEach(function(e){if(e&&e.highlight){var t=n(e.highlight);if(t){var s=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),l="__DEV_TOKEN_".concat(a++,"__");o[l]=r(t,'<span data-badge-id="'.concat(e.id,'">'),"</span>"),i=i.replace(t,l);var c="__HIGHLIGHT_TOKEN_".concat(a++,"__");o[c]=r(t),i=i.replace(new RegExp(s,"g"),c)}}});var c=new Set(t.map(function(e){return n(e.highlight)}).filter(Boolean));return h.forEach(function(e){if(e){var t=n(e);if(t&&!c.has(t)){var s=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),l="__PLAIN_TOKEN_".concat(a++,"__");o[l]=r(t),i=i.replace(new RegExp(s,"g"),l)}}}),Object.keys(o).forEach(function(e){i=i.split(e).join(o[e])}),i},[l,g,h]);return n.jsx(r.Typography,e.__assign({component:"div",sx:e.__assign(e.__assign({},c),{position:"relative",overflow:"visible",whiteSpace:"pre-wrap","& p, & li, & ul, & ol":{position:"static",overflow:"visible",whiteSpace:"pre-wrap"}})},{children:n.jsx(p.default,e.__assign({components:b,rehypePlugins:[u.default]},{children:s.safeStringify(y).replace(/\\n/g,"\n")}))}))},s.areMarkdownPropsEqual);exports.MemoizedMarkdown=g;
2
2
  //# sourceMappingURL=memoizedMarkdown.js.map