@viswa-test/test-citation 0.0.87 → 0.0.88
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/features/CognitiveCompare/CitationAnchor.js +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/CognitiveSummaryPopup.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/SectionAccordion.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/useDeviationNavigation.js +1 -1
- package/dist/features/CognitiveCompare/CitationAnchor.js +1 -1
- package/dist/features/CognitiveCompare/CognitiveCompare.js +1 -1
- package/dist/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
- package/dist/features/CognitiveCompare/components/CognitiveSummaryPopup.js +1 -1
- package/dist/features/CognitiveCompare/components/SectionAccordion.js +1 -1
- package/dist/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
- package/dist/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
- package/dist/features/CognitiveCompare/hooks/useDeviationNavigation.js +1 -1
- package/dist/types/src/CognitiveCompareTest.d.ts.map +1 -1
- package/dist/types/src/CommonConstants/CommonConstants.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/CitationAnchor.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts +0 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveComparehelpers.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/components/CognitiveSummaryPopup.d.ts +1 -1
- package/dist/types/src/features/CognitiveCompare/components/CognitiveSummaryPopup.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/components/SectionAccordion.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/components/SubSectionAccordion.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/hooks/memoizedMarkdown.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/hooks/useDeviationNavigation.d.ts +0 -2
- package/dist/types/src/features/CognitiveCompare/hooks/useDeviationNavigation.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),
|
|
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"})},{})}))]}))]}))};
|
|
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"),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"),_=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(A){var b,E,I,T,B,C,D,O,w,j,N,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=t.useState(K.maintainRelativeOrder),$=Z[0],ee=Z[1],ne=t.useState(!1),te=ne[0],ie=ne[1],oe=t.useState(!1),re=oe[0],le=oe[1],ue=t.useState(null),ce=ue[0],ae=ue[1],se=t.useState(!1),de=se[0],ve=se[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),Ae=t.useState(new Set),be=Ae[0],Ee=Ae[1],Ie=t.useState([]),Te=Ie[0],Be=Ie[1],Ce=t.useRef(null),De=t.useRef(!1),Oe=t.useRef(null),we=t.useRef({}),je=t.useRef([]),Ne=t.useRef(!1),Pe=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=t.useRef(null),$e=t.useRef(null),en=p.useComparePopups(qe),nn=en.cognitivePopup,tn=en.setCognitivePopup,on=en.moreFunctions,rn=en.setMoreFunctions,ln=en.position,un=en.setPosition,cn=en.activeBadgeId,an=en.summaryPopup,sn=en.setSummaryPopup,dn=en.closeSummaryPopup,vn=en.setActiveBadgeId,gn=en.popupRef,fn=en.closeCognitivePopup,pn=en.closeMoreFunctionsPopup,hn=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]),xn=t.useState(null),_n=xn[0];xn[1];var mn=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,Rn=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,yn=u.safeStringify(q||mn||"Uploaded Contract"),Sn=u.safeStringify(z||Rn||"Reference Template"),An=f.useCognitiveTreeData(H,$,J,hn),bn=An.activeProposed,En=An.existingRule,In=An.proposedSections,Tn=An.existingSections,Bn=An.visibleFields,Cn=An.parentDeviationRecord,Dn=An.deviationNumberRegistry,On=An.parseError;t.useEffect(function(){On&&ae("Failed to load comparison: ".concat(On))},[On]);var wn=In.length>0||Tn.length>0,jn=h.useSectionRefs(Bn.map(function(e){return e.key}),Math.max(In.length,Tn.length)),Nn=jn.leftRefs,Pn=jn.rightRefs,Fn=jn.sectionLeftRefs,kn=jn.sectionRightRefs,Mn=jn.lhsBadgeRefs,Ln=jn.rhsBadgeRefs,Vn=jn.sectionRightRowRefs,Hn=jn.subSectionLeftRefs,Gn=jn.subSectionRightRefs,qn=jn.sectionRowRefs,zn=jn.getSectionRowRef,Wn=jn.getSubSectionRef,Yn=jn.getBadgeRef,Kn=En.analysis,Un=u.safeStringify(null===(O=null===(D=null==Kn?void 0:Kn.rule_difference_comparison)||void 0===D?void 0:D.summary)||void 0===O?void 0:O.overall_summary),Xn=!!Un.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),Jn=null!==(w=null==H?void 0:H.base_root_id)&&void 0!==w?w:"-1";null==H||H[Jn];var Qn=(null===(j=null==J?void 0:J[Jn])||void 0===j?void 0:j.evaluation_result)||(null===(P=null===(N=null==H?void 0:H.nodes)||void 0===N?void 0:N[Jn])||void 0===P?void 0:P.evaluation_result)||null,Zn=u.extractDeviationScore(Qn),$n=u.generateColorPalette(null!==(M=null===(k=null===(F=null==Qn?void 0:Qn.evaluation_outputs)||void 0===F?void 0:F.metadata)||void 0===k?void 0:k.label_color)&&void 0!==M?M:""),et=t.useCallback(function(){var e,n,t,i,o,r;ve(!1),Pe.current=!1;var l=Fe.current,c=gt.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=Hn.current[a[2]])||void 0===e?void 0:e.current)||(null===(n=Fn.current[Number(a[2])])||void 0===n?void 0:n.current))&&(s.style.paddingTop="0px")}else{var s;(s=null===(t=Fn.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=Gn.current[a[3]])||void 0===i?void 0:i.current)||(null===(o=kn.current[Number(a[3])])||void 0===o?void 0:o.current))&&(d.style.paddingTop="0px")}else{var d;(d=null===(r=kn.current[c])||void 0===r?void 0:r.current)&&(d.style.paddingTop="0px")}ye(null),Fe.current=null,gt.current=null,pe(!1),le(!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")},[]),nt=x.useAccordionState({maintainRelativeOrder:!!$,proposedSections:In,existingSections:Tn,activeSideBySideSection:Re,connectedSections:be,resetSideBySide:et,setConnectedSections:Ee,setConnectedLines:Be,cachedConnectedPositions:je,svgContainerRef:Ce,isAnimatingRef:De,animationTimerRef:Oe,calculateLinesRef:ke,sectionLeftRefs:Fn,sectionRightRefs:kn,subSectionLeftRefs:Hn,subSectionRightRefs:Gn}),tt=nt.expandedSections,it=nt.expandedSubSections,ot=nt.setExpandedSubSections,rt=nt.toggleSection,lt=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?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!==(a=null===(c=qn.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}},[Me,H]),ut=t.useCallback(function(e){pn(),un(null),tn(e)},[pn]),ct=function(e,n,t,i,o,r){var l;if(e.stopPropagation(),on.open&&on.sectionIdx===o)pn();else{var c=e.currentTarget,a="left";(null===(l=We.current)||void 0===l?void 0:l.contains(c))&&(a="right");Pe.current&&et(),Ee(new Set),Be([]),je.current=[],fn(),an.open?Ft():dn(),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=Ln.current[l])||void 0===e?void 0:e.current:null===(n=Mn.current[l])||void 0===n?void 0:n.current}return"right"===a?null===(t=Ln.current[o])||void 0===t?void 0:t.current:null===(i=Mn.current[o])||void 0===i?void 0:i.current}()||c;rn(lt(e,n,i,o,t,r))})}},at=t.useCallback(function(){null!==on.sectionIdx&&on.anchorEl?ut(e.__assign(e.__assign({},on),{open:!0})):pn()},[on,pn,ut]),st=t.useCallback(function(){var e=on.sectionIdx,n=on.isOrphan;pn(),dn(),null!==e&&(n?ae("No counterpart exists to connect to."):(Pe.current&&et(),Be([]),je.current=[],Ee(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){ke.current&&ke.current()},50)))},[on.sectionIdx,on.isOrphan,pn,dn,et]),dt=t.useRef(null),vt=t.useRef(null),gt=t.useRef(null),ft=t.useRef(null),pt=t.useRef(null),ht=t.useRef(null),xt=t.useState([]),_t=xt[0],mt=xt[1];t.useRef(null);var Rt=t.useState(null),yt=Rt[0],St=Rt[1];t.useEffect(function(){if(_n){var e=hn.fields.find(function(e){return e.analysisKey===_n||e.key===_n});if(e){var n=Nn.current[e.key]||Pn.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[_n,hn.fields]);var At=t.useCallback(function(e){var n,t,i,o,r,l,u,c,a,s=null===(n=null==Kn?void 0:Kn.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}},[Kn]),bt=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=In[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=In.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=In[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(a.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===(r=null==m?void 0:m.evaluation_outputs)||void 0===r?void 0:r.output_value,y=null!==(s=null===(c=null===(l=null==m?void 0:m.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!=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})},[In,Tn,Me,hn,$]),Et=t.useCallback(function(n){for(var t,i,o,r,l,c,s,d,v,g=n.split("-").map(Number),f=In[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(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||m&&(null===(o=Me[m])||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})},[In,Tn,Me,hn]),It=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(!Qe.current&&!De.current){Qe.current=!0;try{if(!dt.current)return;var A=function(e){var n=e.split("-"),t=n[0];if(!tt[t]&&!1===$)return!1;if($&&!tt["left-".concat(t)]&&!tt["right-".concat(t)]&&!tt[t])return!1;for(var i=t,o=1;o<n.length-1;o++)if(i+="-".concat(n[o]),!it[i])return!1;return!0},b=dt.current.getBoundingClientRect();He({width:b.width,height:b.height});var E=[];if(Bn.forEach(function(e){var n,t,i=e.key,o=null===(n=Nn.current[i])||void 0===n?void 0:n.current,r=null===(t=Pn.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")}),!De.current){for(var I=0;I<Math.max(In.length,Tn.length);I++){var T=null===(e=Fn.current[I])||void 0===e?void 0:e.current,B=null===(n=kn.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")}$||Object.keys(Hn.current).forEach(function(e){var n,t;if(A(e)){var i=null===(n=Hn.current[e])||void 0===n?void 0:n.current,o=null===(t=Gn.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={};Bn.forEach(function(e){var n,t,i=e.key,o=null===(n=Nn.current[i])||void 0===n?void 0:n.current,r=null===(t=Pn.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(!De.current)if($){if(de&&null!==Re)if("number"==typeof Re){var w=Re,j=In[w],N=null===(o=Fn.current[w])||void 0===o?void 0:o.current;N&&j&&(j.refIndexes||[]).forEach(function(e){var n,t=Tn.findIndex(function(n){return n.selfIndex===e}),i=null===(n=kn.current[t])||void 0===n?void 0:n.current;if(i&&(tt["left-".concat(w)]||tt["right-".concat(t)])){var o=Math.max(N.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=Re.split(u.DEVIATION_BADGE_SEPARATOR)[2];if(P){T=null===(r=Hn.current[P])||void 0===r?void 0:r.current,B=null===(l=Gn.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(Hn.current).forEach(function(e){var n,t;if(A(e)){var i=null===(n=Hn.current[e])||void 0===n?void 0:n.current,o=null===(t=Gn.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(In.length,Tn.length);I++){var T=null===(t=Fn.current[I])||void 0===t?void 0:t.current,B=null===(i=kn.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(Bn.forEach(function(e){var n,t,i=e.key,o=null===(n=Nn.current[i])||void 0===n?void 0:n.current,r=null===(t=Pn.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")}}),De.current||(Object.entries(D.left).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=Fn.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=kn.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),$||Object.keys(O).forEach(function(e){var n,t,i=null===(n=Hn.current[e])||void 0===n?void 0:n.current,o=null===(t=Gn.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")}})),$)In.forEach(function(e,n){var t;(null===(t=Fn.current[n])||void 0===t?void 0:t.current)&&(e.refIndexes||[]).forEach(function(e){var t,i,o,r,l,u,c,a,s,d,v=Tn.findIndex(function(n){return n.selfIndex===e});if(-1!==v){var g=null===(t=Mn.current[n])||void 0===t?void 0:t.current,f=null===(i=Ln.current[v])||void 0===i?void 0:i.current;if(g&&f){var p=g.getBoundingClientRect(),h=f.getBoundingClientRect(),x=p.right-b.left,_=h.left-b.left,m=p.top+p.height/2-b.top,R=h.top+h.height/2-b.top;if(de&&Re===n){var y=null!==(r=null===(o=Je.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==r?r:0,S=null!==(u=null===(l=We.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==u?u:0,A=y+(null!==(a=null===(c=Je.current)||void 0===c?void 0:c.clientHeight)&&void 0!==a?a:1/0),I=S+(null!==(d=null===(s=We.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))};m=C(T,y,A)-b.top,R=C(B,S,I)-b.top}var D=bt(n);D&&E.push({id:"line-".concat(n,"-").concat(v),x1:x,y1:m,x2:_,y2:R,style:D,sectionIdx:n,targetRightIdx:v})}}})});else{for(I=0;I<Math.min(In.length,Tn.length);I++){var k=null===(c=Fn.current[I])||void 0===c?void 0:c.current,M=null===(a=kn.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=Tn[I])||void 0===s?void 0:s.id)||"sec-".concat(I);(J=bt(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=In[I])||void 0===d?void 0:d.cognitiveData)||(null===(v=Tn[I])||void 0===v?void 0:v.cognitiveData)||G&&Me[G]),isSubSection:!1})}}Object.keys(Hn.current).forEach(function(e){var n,t,i,o,r,l;if(A(e)){var c=null===(n=Hn.current[e])||void 0===n?void 0:n.current,a=null===(t=Gn.current[e])||void 0===t?void 0:t.current;if(c&&a){for(var s=e.split("-").map(Number),d=In[s[0]],v=Tn[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 _=c.getBoundingClientRect(),m=a.getBoundingClientRect(),R=Math.max(_.top,m.top)+16-b.top,y=Et(e);y&&"Not Defined"!==y.label&&E.push({id:"subsec-".concat(e),x1:_.right-b.left,y1:R,x2:m.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(de&&"string"==typeof Re&&Re.includes(u.DEVIATION_BADGE_SEPARATOR)){var q=Re.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=Mn.current[K])||void 0===g?void 0:g.current,X=null===(f=Ln.current[K])||void 0===f?void 0:f.current;if(U&&X){var J,Q=U.getBoundingClientRect(),Z=X.getBoundingClientRect(),ee=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($){var oe=null!==(h=null===(p=Je.current)||void 0===p?void 0:p.getBoundingClientRect().top)&&void 0!==h?h:0,re=null!==(_=null===(x=We.current)||void 0===x?void 0:x.getBoundingClientRect().top)&&void 0!==_?_:0,le=oe+(null!==(R=null===(m=Je.current)||void 0===m?void 0:m.clientHeight)&&void 0!==R?R:1/0),ue=re+(null!==(S=null===(y=We.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=Et(Y))&&E.push({id:"line-subsec-".concat(K),x1:ee,y1:te,x2:ne,y2:ie,style:J,sectionIdx:Number(Y.split("-")[0]),isSubSection:!0,subSectionKeyPath:Re})}}if(mt(E),pt.current&&ht.current){var ae=pt.current.getBoundingClientRect(),se=ht.current.getBoundingClientRect(),ve=(ae.top+ae.height/2-b.top+se.top+se.height/2-b.top)/2;St({x1:ae.right-b.left,x2:se.left-b.left,y:ve})}else St(null);if(be.size>0){var ge=[],fe=Je.current,pe=We.current;if(fe&&pe){var he=[],xe=fe.getBoundingClientRect().top,_e=pe.getBoundingClientRect().top,me=xe+fe.clientHeight,ye=_e+pe.clientHeight,Se=fe.scrollTop,Ae=pe.scrollTop,Ee=b.top,Ie=function(e,n,t){return Math.max(n,Math.min(t,e))};be.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=Mn.current[d])||void 0===n?void 0:n.current,g=null===(t=Ln.current[d])||void 0===t?void 0:t.current;if(!v||!g)return;var f=v.getBoundingClientRect(),p=g.getBoundingClientRect(),h=Et(s),x=(N=f.right-b.left)+.5*((P=p.left-b.left-0)-N),_=f.top+f.height/2,m=p.top+p.height/2,R=_-xe+Se,y=m-_e+Ae,S="conn-subsec-".concat(d);he.push({lhsScrollY:R,rhsScrollY:y,x1:N,x2:P,containerTop:Ee,leftIdx:e,rhsArrayIdx:e,styleColor:(null==h?void 0:h.badgeBorder)||"#6366F1",styleId:S});var A=Ie(_,xe,me),E=Ie(m,_e,ye),I=A-Ee,T=E-Ee,B=m>=_e-4&&m<=ye+4,C="";C=(F=_>=xe-4&&_<=me+4)&&B?u.getBentArrowPath(N,I,P,T):F&&!B?"M ".concat(N,",").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($){var D=e,O=In[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=Tn.findIndex(function(n){return n.selfIndex===e});if(-1!==i){var o=null===(n=Mn.current[D])||void 0===n?void 0:n.current,r=null===(t=Ln.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),c=r.getBoundingClientRect(),a=bt(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-_e+Ae,x="conn-".concat(D,"-").concat(i);he.push({lhsScrollY:p,rhsScrollY:h,x1:s,x2:d,containerTop:Ee,leftIdx:D,rhsArrayIdx:i,styleColor:(null==a?void 0:a.badgeBorder)||"#6366F1",styleId:x});var _=Ie(g,xe,me),m=Ie(f,_e,ye),R=_-Ee,y=m-Ee,S=g>=xe-4&&g<=me+4,A=f>=_e-4&&f<=ye+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,j=w;v=null===(i=Mn.current[w])||void 0===i?void 0:i.current,g=null===(o=Ln.current[j])||void 0===o?void 0:o.current;if(!v||!g)return;var N,P;f=v.getBoundingClientRect(),p=g.getBoundingClientRect(),h=bt(w),x=(N=f.right-b.left)+.5*((P=p.left-b.left-0)-N),_=f.top+f.height/2,m=p.top+p.height/2,R=_-xe+Se,y=m-_e+Ae,S="conn-".concat(w,"-").concat(j);he.push({lhsScrollY:R,rhsScrollY:y,x1:N,x2:P,containerTop:Ee,leftIdx:w,rhsArrayIdx:j,styleColor:(null==h?void 0:h.badgeBorder)||"#6366F1",styleId:S});var F;A=Ie(_,xe,me),E=Ie(m,_e,ye),I=A-Ee,T=E-Ee,B=m>=_e-4&&m<=ye+4,C="";C=(F=_>=xe-4&&_<=me+4)&&B?u.getBentArrowPath(N,I,P,T):F&&!B?"M ".concat(N,",").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:j})}}),je.current=he}Be(ge)}else Be([]),je.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{Qe.current=!1}}},[Bn,In,Tn,Me,hn,At,bt,$,de,Re,be,tt,it]),Tt=t.useCallback(function(){var e,n,t,i,o,r,l,c,a,s,d,v,g,f,p=je.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!==(r=null===(o=Je.current)||void 0===o?void 0:o.clientHeight)&&void 0!==r?r:1/0,m=null!==(c=null===(l=We.current)||void 0===l?void 0:l.clientHeight)&&void 0!==c?c:1/0,R=null!==(s=null===(a=Je.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==s?s:0,y=null!==(v=null===(d=We.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==v?v:0,S=R+_,A=y+m,b=null!==(f=null===(g=dt.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=we.current[e.styleId+"-stroke"],o=we.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(){ke.current=It},[It]);var Bt=t.useRef(null),Ct=t.useRef(null),Dt=t.useCallback(function(){je.current.length>0&&!De.current||(null!==Bt.current&&clearTimeout(Bt.current),Bt.current=setTimeout(function(){ke.current(),Bt.current=null},50))},[]),Ot=t.useCallback(function(){_e(!0),pe(!1),null!==Ct.current&&clearTimeout(Ct.current),null!==Bt.current&&(clearTimeout(Bt.current),Bt.current=null),Ct.current=setTimeout(function(){var e,n,t,i,o,r,l,c,a,s;if(je.current=[],Pe.current&&null!==Fe.current&&null!==gt.current){var d=Fe.current,v=gt.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),_="".concat(x[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(x[1]);g=(null===(e=Mn.current[_])||void 0===e?void 0:e.current)||null,f=(null===(n=Ln.current[_])||void 0===n?void 0:n.current)||null,p=(null===(t=Hn.current[x[2]])||void 0===t?void 0:t.current)||(null===(i=Fn.current[Number(x[2])])||void 0===i?void 0:i.current)||null,h=(null===(o=Gn.current[x[3]])||void 0===o?void 0:o.current)||(null===(r=kn.current[Number(x[3])])||void 0===r?void 0:r.current)||null}else g=(null===(l=qn.current[d])||void 0===l?void 0:l.current)||null,p=(null===(c=Fn.current[d])||void 0===c?void 0:c.current)||null,f=(null===(a=Vn.current[v])||void 0===a?void 0:a.current)||null,h=(null===(s=kn.current[v])||void 0===s?void 0:s.current)||null;if(g&&f&&p&&h){if(p.style.paddingTop="0px",h.style.paddingTop="0px",!$){var m=g.getBoundingClientRect(),R=f.getBoundingClientRect(),y=m.top-R.top;y>0?h.style.paddingTop="".concat(y,"px"):y<0&&(p.style.paddingTop="".concat(Math.abs(y),"px"))}var S=Je.current,A=We.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)}}}ke.current(),Pe.current&&pe(!0),_e(!1),Ct.current=null},150)},[$,In,Tn]),wt=t.useCallback(function(e){var n,t,i,o,r,l,c,a,s,d;if(null!==Ze.current&&$e.current&&Math.abs(e.currentTarget.scrollTop-Ze.current)<=2){var v=$e.current;Ze.current=null,$e.current=null,v()}if(!Se.current){if($||Dt(),Pe.current){var g=Fe.current,f=gt.current,p=Je.current,h=We.current;if(null!==g&&null!==f&&p&&h){var x="string"==typeof g&&g.includes(u.DEVIATION_BADGE_SEPARATOR)?null===(n=Mn.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=qn.current[g])||void 0===t?void 0:t.current,_="string"==typeof f&&f.includes(u.DEVIATION_BADGE_SEPARATOR)?null===(i=Ln.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=Vn.current[f])||void 0===o?void 0:o.current;if(x&&_&&ft.current){var m=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]);m=null===(r=Mn.current[S])||void 0===r?void 0:r.current,R=null===(l=Ln.current[S])||void 0===l?void 0:l.current}else m=null===(c=Mn.current[g])||void 0===c?void 0:c.current,R=null===(a=Ln.current[f])||void 0===a?void 0:a.current;var A=null!==(d=null===(s=dt.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(m&&R){var I=m.getBoundingClientRect(),T=R.getBoundingClientRect(),B=I.top+I.height/2;T.top,T.height;var C=((O=B,w=b,j=E,Math.max(w,Math.min(j,O)))-A).toString();ft.current.setAttribute("y1",C),ft.current.setAttribute("y2",C);var D=B>=b-4&&B<=E+4;ft.current.setAttribute("visibility",D?"visible":"hidden")}}}}var O,w,j;je.current.length>0&&!Ne.current&&(Ne.current=!0,requestAnimationFrame(function(){Tt(),Ne.current=!1}))}},[Tt,$,Dt]);t.useEffect(function(){var e=setTimeout(Dt,250);window.addEventListener("resize",Ot);var n=null,t=null;return qe.current&&(n=new ResizeObserver(Dt)).observe(qe.current),dt.current&&(t=new ResizeObserver(Dt)).observe(dt.current),function(){clearTimeout(e),null!==Bt.current&&clearTimeout(Bt.current),null!==Ct.current&&clearTimeout(Ct.current),window.removeEventListener("resize",Ot),null==n||n.disconnect(),null==t||t.disconnect()}},[bn,En,Kn,Bn,tt,it,In,Tn,hn,Dt,Ot,de,Re,fe,be]),t.useEffect(function(){Pe.current=de},[de]),t.useEffect(function(){Fe.current=Re},[Re]);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";pn(),null!=e&&(n?ae("No counterpart exists for this section."):de&&Re===e?r?et():null==l||l():(Ee(new Set([e])),Be([]),je.current=[],le(!0),Se.current=!0,ye(e),Fe.current=e,ve(!0),Pe.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,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=Mn.current[f])||void 0===n?void 0:n.current)||null,d=(null===(t=Ln.current[f])||void 0===t?void 0:t.current)||null,v=d?e:null}else if(s=(null===(i=qn.current[e])||void 0===i?void 0:i.current)||null,$){var p=In[e],h=(null==p?void 0:p.refIndexes)||[];if(h.length>0){var x=h[0],_=Tn.findIndex(function(e){return e.selfIndex===x});-1!==_&&(d=(null===(r=Vn.current[_])||void 0===r?void 0:r.current)||null,v=_)}}else d=(null===(o=Vn.current[e])||void 0===o?void 0:o.current)||null,v=d?e:null;gt.current=v;var m=Je.current,R=We.current,y=function(){!function(){var n,t,i,o,r,l,c,s,d,g,f,p,h=null,x=null,_=null,m=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=Hn.current[R[2]])||void 0===n?void 0:n.current)||(null===(t=Fn.current[Number(R[2])])||void 0===t?void 0:t.current)||null,x=(null===(i=Gn.current[R[3]])||void 0===i?void 0:i.current)||(null===(o=kn.current[Number(R[3])])||void 0===o?void 0:o.current)||null,_=(null===(r=Mn.current[y])||void 0===r?void 0:r.current)||h,m=(null===(l=Ln.current[y])||void 0===l?void 0:l.current)||x}else{var S=Number(e),A=null!==v?Number(v):S;h=(null===(c=Fn.current[S])||void 0===c?void 0:c.current)||null,x=(null===(s=kn.current[A])||void 0===s?void 0:s.current)||null,_=(null===(d=Mn.current[S])||void 0===d?void 0:d.current)||(null===(g=qn.current[S])||void 0===g?void 0:g.current)||h,m=(null===(f=Ln.current[A])||void 0===f?void 0:f.current)||(null===(p=Vn.current[A])||void 0===p?void 0:p.current)||x}if(_&&m&&h&&x){h.style.paddingTop="0px",x.style.paddingTop="0px";var b=_.getBoundingClientRect(),E=m.getBoundingClientRect(),I=b.top-E.top;I>0?x.style.paddingTop="".concat(I,"px"):I<0&&(h.style.paddingTop="".concat(Math.abs(I),"px"))}}(),pe(!0),ke.current&&ke.current(),Se.current=!1,"right"===c&&R?R.dispatchEvent(new Event("scroll")):m&&m.dispatchEvent(new Event("scroll")),le(!1),null==l||l()};if(!s||!m)return Se.current=!1,le(!1),void(null==l||l());if(d&&R){if(!$){var S=0;S="right"===c?d?d.getBoundingClientRect().top:0:s?s.getBoundingClientRect().top:0;var A=qe.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-m.getBoundingClientRect().top+m.scrollTop,T=d.getBoundingClientRect().top-R.getBoundingClientRect().top+R.scrollTop,B=200;if("left"===c){var C=T-(I-m.scrollTop);C<0&&Ye.current&&(Ye.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 Ke.current&&(Ke.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&&Ue.current&&(Ue.current.style.height="".concat(Math.abs(D),"px")),requestAnimationFrame(function(){var e,n=m.scrollHeight-m.clientHeight;if(D<0)e=0;else{if(D>n){var t=D-n;return Xe.current&&(Xe.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){u.smoothScrollTo(m,D,B,y)})}e=D}u.smoothScrollTo(m,e,B,y)})}}else y()})))},[Re,pn,Tn,de,$,In,et]),Nt=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;fn();var c="left";(null===(o=We.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=Ln.current[l])||void 0===e?void 0:e.current:null===(t=Mn.current[l])||void 0===t?void 0:t.current}return"right"===c?null===(i=Ln.current[n])||void 0===i?void 0:i.current:null===(o=Mn.current[n])||void 0===o?void 0:o.current};if(t)return et(),Ee(new Set),Be([]),je.current=[],void(r&&requestAnimationFrame(function(){var e=a()||l;sn({open:!0,anchorEl:e,summary:i})}));jt(n,t,r?{toggleIfSame:!1,sourceSide:c,onReady:function(){var e=a()||l;sn({open:!0,anchorEl:e,summary:i})}}:{toggleIfSame:!1,sourceSide:c})},[jt,fn,sn,et]),Pt=t.useCallback(function(){var e,n=on.sectionIdx,t=on.isOrphan;if(dn(),null!=n){var i="left";on.anchorEl&&(null===(e=We.current)||void 0===e?void 0:e.contains(on.anchorEl))&&(i="right"),jt(n,t,{sourceSide:i})}},[jt,on.isOrphan,on.sectionIdx,on.anchorEl,dn]),Ft=t.useCallback(function(){dn(),et(),Ee(new Set),Be([]),je.current=[]},[dn,et]),kt=null!==on.sectionIdx&&be.has(on.sectionIdx),Mt=_.useDeviationNavigation({proposedSections:In,existingSections:Tn,parentDeviationRecord:Cn,expandedSections:tt,maintainRelativeOrder:!!$,scrollContainerRef:qe,leftContainerRef:Je,lhsBadgeRefs:Mn,rhsBadgeRefs:Ln}),Lt=Mt.showDeviationNavigation,Vt=Mt.showOpenNodeRef,Ht=t.useMemo(function(){if(!Q)return null;for(var e in Cn){if((Cn[e]||[]).some(function(e){return e.id===Q}))return e}return null},[Q,Cn]),Gt=t.useRef(null),qt=t.useRef(null);t.useEffect(function(){if(Q&&Gt.current!==Q){qt.current!==Q&&(dn(),fn(),et(),Ee(new Set),Be([]),je.current=[],qt.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 Cn){var p=Cn[f].find(function(e){return e.id===Q});if(p){v=f,g=p;break}}if(g&&v){var h=In.findIndex(function(e){return e.id===v}),x=Tn.findIndex(function(e){return e.id===v}),_=-1===h&&-1!==x;if(_){if(!($?!!tt["right-".concat(x)]:!!tt[String(x)]))return rt(x,"right"),t+=1,void(i=setTimeout(l,450))}else if(!($?!!tt["left-".concat(h)]:!!tt[String(h)])&&h>=0)return rt(h,"left"),t+=1,void(i=setTimeout(l,450));var m=r(In,g.id),R=r(Tn,g.id);if(m&&!R&&!_){var y=m.split("-"),S=Number(y[0]);if($){var A=null===(a=null===(c=In[S])||void 0===c?void 0:c.refIndexes)||void 0===a?void 0:a[0],b=Tn.findIndex(function(e){return e.selfIndex===A});-1!==b&&(S=b)}R=e.__spreadArray([S],y.slice(1),!0).join("-")}if(m||R){var E,I=m||"",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=Mn.current[C])||void 0===s?void 0:s.current,O=null===(d=Ln.current[C])||void 0===d?void 0:d.current,w=_?O:D;if(E=$?_?We.current:Je.current:qe.current,w&&E){var j=w.getBoundingClientRect();if(0===j.height)return void((t+=1)<20&&(i=setTimeout(l,o)));var N=E.getBoundingClientRect(),P=j.top-N.top+E.scrollTop-N.height/2+j.height/2,F=function(){var e,t,i,o,r;if(!n){Gt.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&&!_)jt(B,!1,{toggleIfSame:!1,sourceSide:"left",onReady:function(){var e,n=(null===(e=Mn.current[C])||void 0===e?void 0:e.current)||D;sn({open:!0,anchorEl:n,summary:{deviation_summary:u.deviation_summary||u,evaluation_outputs:c}})}});else{var a=_?(null===(o=Ln.current[C])||void 0===o?void 0:o.current)||O:(null===(r=Mn.current[C])||void 0===r?void 0:r.current)||D;sn({open:!0,anchorEl:a,summary:{deviation_summary:u.deviation_summary||u,evaluation_outputs:c}})}}};Math.abs(E.scrollTop-P)<=2?F():(Ze.current=P,$e.current=F,E.scrollTo({top:P,behavior:"smooth"}),i&&clearTimeout(i),i=setTimeout(function(){if($e.current){Ze.current=null;var e=$e.current;$e.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,Cn,In,Tn,$,tt,rt,jt,sn]);var zt=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:it,setExpandedSubSections:ot,maintainRelativeOrder:$||!1,proposedSections:In,existingSections:Tn,treeData:H,deviationNumberRegistry:Dn,connectedSections:be,activeSideBySideSection:Re,resolvedMarkdownStyles:Ge,getSubSectionRef:Wn,getSubSectionCompareStyle:Et,getBadgeRef:Yn,openMoreFunctionsPopup:ct,openSummaryPopup:Nt,resetSideBySide:et,setConnectedSections:Ee,setConnectedLines:Be,cachedConnectedPositions:je})};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,{})})),an.open&&n.jsx(S.default,{open:an.open,anchorEl:an.anchorEl,containerEl:vt.current,clipTopEl:pt.current,scrollContainerEl:qe.current,onClose:Ft,summary:an.summary}),n.jsx(d.default,{open:on.open,anchorEl:on.anchorEl,sectionTitle:on.sectionTitle,referenceSectionTitle:on.refSectionTitle,onClose:pn,onOpenCognitiveCompare:at,onOpenSideBySide:Pt,onConnect:st,isConnected:kt,isOrphan:on.isOrphan}),nn.open&&n.jsx(s.default,{open:nn.open,popupRef:gn,position:ln,popupConfig:U,onClose:function(){un(null),tn(function(n){return e.__assign(e.__assign({},n),{open:!1})}),vn(null)},markdownStyles:W,sectionTitle:nn.sectionTitle,referenceSectionTitle:nn.refSectionTitle,cognitiveData:nn.cognitiveData,anchorEl:nn.anchorEl,sectionAnchorEl:nn.sectionAnchorEl,scrollContainerEl:qe.current,badgeStyle:nn.badgeStyle,docData:nn.docData,deviationData:nn.deviationData,isLoading:nn.isLoading}),n.jsx(i.Snackbar,e.__assign({open:!!ce,autoHideDuration:8e3,onClose:function(){return ae(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(i.Alert,e.__assign({onClose:function(){return ae(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),et(),dn(),Ee(new Set),Be([]),je.current=[],setTimeout(function(){ie(!1)},400)},50)}}),n.jsx(i.Box,e.__assign({ref:qe,onScroll:wt,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:Un&&Xn?"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:dt,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:[yt&&n.jsx("g",{children:n.jsx("line",{x1:yt.x1,y1:yt.y,x2:yt.x2,y2:yt.y,stroke:$n.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?de&&Re===t.subSectionKeyPath&&fe:de&&Re===t.sectionIdx&&fe)return null;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),_=In[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.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=In[A[0]]),b.length>0&&(I=Tn[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&&(_=e.__assign(e.__assign({},E),{title:T||E.title})),console.log("Base Section for Subsection Badge:",_),I&&(m=e.__assign(e.__assign({},I),{title:B||I.title})),console.log("Ref Section for Subsection Badge:",m)}var D=!(null===(l=_.cognitiveData)||void 0===l?void 0:l.isMissingRationale)||Boolean(null===(s=null===(c=_.cognitiveData)||void 0===c?void 0:c.decisioning)||void 0===s?void 0:s.length),O=(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,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&&(nn.open&&cn===t.id?fn():(vn(t.id),ut(lt(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:nn.open&&cn===t.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},t.id)}return null}),Te.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){we.current[u]=e},d:o,fill:"none",stroke:"#FFFFFF",strokeWidth:"4",strokeOpacity:"0.7"}),n.jsx("path",{ref:function(e){we.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)"},$?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(i.Box,e.__assign({ref:pt,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:yn,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:yn}))}))})),n.jsxs(i.Box,e.__assign({ref:Je,onScroll:wt,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}}),wn&&In.map(function(t,r){var l,c,a=!t.title&&!t.content;if($&&a)return null;var s=t,d=bt(r,"left"),v=$?!(null===(l=s.refIndexes)||void 0===l?void 0:l.length)||s.selfIndex<0:!Tn[r],f=$?"number"==typeof s.selfIndex&&s.selfIndex>=0?s.selfIndex+1:null:r+1,p=be.has(r),h=u.extractDeviationScore(s.evaluationResult,null==d?void 0:d.deviationLabel);return n.jsx(i.Box,e.__assign({ref:zn(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:Fn.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:zn("left-accordion-".concat(r)),mb:0,treeData:H,proposedSections:In,existingSections:Tn,deviationNumberRegistry:Dn,getSectionCompareStyle:bt,getBadgeRef:Yn,connectedSections:be,openMoreFunctionsPopup:ct,openSummaryPopup:Nt,deviationNodeIdToView:Q,deviationTargetParentId:Ht,parentNodeId:(null===(c=null==H?void 0:H.input_index_map)||void 0===c?void 0:c[0])||"",isExpanded:$?!!tt["left-".concat(r)]:!!tt[String(r)],onToggle:function(){Ft(),rt(r,"left")},navigation:t.id?Lt[t.id]:null,showOpenNodeRef:Vt,resolvedMarkdownStyles:Ge,maintainRelativeOrder:$,renderSubSections:zt})})),$&&d&&n.jsxs(i.Box,e.__assign({ref:Mn.current[r],onClick:function(e){var n=$?Tn.find(function(e){var n;return null===(n=s.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""}:Tn[r]||{title:"",content:""};ct(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:Xe,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),n.jsx(i.Box,e.__assign({ref:vt,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(),nn.open&&cn===Jn?fn():(vn(Jn),ut(lt(n.currentTarget,{title:"",content:"",evaluationResult:Qn,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,Jn,!0,e.__assign(e.__assign({},$n),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-5px",borderRadius:"20px",bgcolor:$n.badgeBg,color:$n.badgeText,border:"1px solid ".concat($n.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=Zn?Zn: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:nn.open&&cn===Jn?"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:[re&&n.jsx(l.default,{sections:11}),n.jsx(i.Box,e.__assign({ref:ht,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:Sn,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:Sn}))}))})),n.jsxs(i.Box,e.__assign({ref:We,onScroll:wt,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}}),wn&&Tn.map(function(t,o){var r,l=t,u=[],c=!1,a=null,s=-1;if($){u=In.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=In.findIndex(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(l.selfIndex))&&e.selfIndex>=0});var d=In.findIndex(function(e,n){var t;return be.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(l.selfIndex))});(c=-1!==d)&&(a=bt(d))}else u=[o+1],(c=be.has(o))&&(a=bt(o));var v=bt($&&-1!==s?s:o);return n.jsx(i.Box,e.__assign({ref:Vn.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:kn.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:zn("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:$?!!tt["right-".concat(o)]:!!tt[String(o)],treeData:H,proposedSections:In,existingSections:Tn,deviationNumberRegistry:Dn,getBadgeRef:Yn,getSectionCompareStyle:bt,connectedSections:be,openMoreFunctionsPopup:ct,openSummaryPopup:Nt,deviationNodeIdToView:Q,deviationTargetParentId:Ht,onToggle:function(){Ft(),rt(o,"right")},navigation:t.id?Lt[t.id]:null,showOpenNodeRef:Vt,resolvedMarkdownStyles:Ge,maintainRelativeOrder:$,renderSubSections:zt})})),$&&v&&n.jsx(i.Box,e.__assign({ref:Ln.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: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"),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}})]}))]}))]}))}))}))]}))};
|
|
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){
|
|
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)};
|
|
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"),
|
|
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};
|
|
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"),
|
|
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))};
|
|
2
2
|
//# sourceMappingURL=SectionAccordion.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var
|
|
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;
|
|
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"),
|
|
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;
|
|
2
2
|
//# sourceMappingURL=memoizedMarkdown.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react"),o=require("../CognitiveComparehelpers.js");exports.useDeviationNavigation=function(t){var i=t.proposedSections,r=t.existingSections,l=t.parentDeviationRecord,u=t.expandedSections,c=t.maintainRelativeOrder,d=t.scrollContainerRef,s=t.leftContainerRef,v=t.lhsBadgeRefs,a=t.rhsBadgeRefs,f=n.useState({}),h=f[0],w=f[1],R=n.useRef();return n.useEffect(function(){if(d.current){var n=c?s.current:d.current;if(n){var t=null,f=setTimeout(function(){var s=function(e,n){var o=e.getBoundingClientRect(),t=n.getBoundingClientRect();return o.bottom<t.top?"above":o.top>t.bottom?"below":"inside"};t=o.debounce(function(){w(function(n){var t=e.__assign({},n);return i.forEach(function(e,n){var i=c?!!u["left-".concat(n)]:!!u[String(n)],r=!1,a=!1,f=null,h=null;i&&(null==e?void 0:e.id)&&(l[e.id]||[]).forEach(function(n){var t="".concat(n.id).concat(o.DEVIATION_BADGE_SEPARATOR,"0"),i=v.current[t];if((null==i?void 0:i.current)&&d.current){var l=s(i.current,d.current);"above"===l?(r=!0,f=i):"below"!==l||a?R.current===e.id&&(R.current=""):(a=!0,h=i)}}),e.id&&(t[e.id]={showAbove:r,showBelow:a,showAboveRef:f,showBelowRef:h,columnKey:"left"})}),c||r.forEach(function(e,n){var i=!!u[String(n)],r=!1,c=!1,v=null,f=null;i&&(null==e?void 0:e.id)&&(l[e.id]||[]).forEach(function(n){var i,l,u,h,w,g=!(null===(i=n.refIndexes)||void 0===i?void 0:i.length)||void 0!==n.selfIndex&&n.selfIndex<0,b="".concat(n.id).concat(o.DEVIATION_BADGE_SEPARATOR,"0"),B=a.current[b];if((null==B?void 0:B.current)&&d.current&&g&&(null==e?void 0:e.id)){var A=s(B.current,d.current);if("above"===A){var p=null===(u=null===(l=t[e.id])||void 0===l?void 0:l.showAboveRef)||void 0===u?void 0:u.current;(!p||p.getBoundingClientRect().top<B.current.getBoundingClientRect().top)&&(r=!0,v=B)}else if("below"!==A||c)R.current===e.id&&(R.current="");else{var E=null===(w=null===(h=t[e.id])||void 0===h?void 0:h.showBelowRef)||void 0===w?void 0:w.current;(!E||E.getBoundingClientRect().top>B.current.getBoundingClientRect().top)&&(c=!0,f=B)}}}),e.id&&i&&(r&&(t[e.id]=t[e.id]||{showAbove:!1,showAboveRef:null,showBelow:!1,showBelowRef:null,columnKey:"right"},t[e.id].showAbove=r,t[e.id].showAboveRef=v,t[e.id].columnKey="right"),c&&(t[e.id]=t[e.id]||{showAbove:!1,showAboveRef:null,showBelow:!1,showBelowRef:null,columnKey:"right"},t[e.id].showBelow=c,t[e.id].showBelowRef=f,t[e.id].columnKey="right"))}),t})},100),t(),null==n||n.addEventListener("scroll",t)},0);return function(){clearTimeout(f),t&&n.removeEventListener("scroll",t)}}}},[i,r,l,u,c,d,s,v,a]),{showDeviationNavigation:h,showOpenNodeRef:R}};
|
|
2
2
|
//# sourceMappingURL=useDeviationNavigation.js.map
|