@viswa-test/test-citation 0.0.99 → 0.0.101
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitiveComparehelpers.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/features/CognitiveCompare/CognitiveCompare.js +1 -1
- package/dist/features/CognitiveCompare/CognitiveComparehelpers.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/types/src/CommonConstants/CommonConstants.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts +5 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveComparehelpers.d.ts +3 -0
- package/dist/types/src/features/CognitiveCompare/CognitiveComparehelpers.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/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),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"),f=require("./components/ThreeDotsLoader.js"),g=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,N,j,P,F,k,M,V,L,G,H,q,z,W,Y,K,U,X,J=A.componentHeaderText,$=void 0===J?a.DEFAULT_COMPONENT_HEADER_TEXT:J,Q=A.treeData,Z=A.comparisonConfig,ee=A.leftColumnTitleText,ne=A.rightColumnTitleText,te=A.markdownStyles,ie=A.displayConfig,oe=void 0===ie?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!0}:ie,re=A.popupConfig,le=A.deviationData,ue=void 0===le?{}:le,ce=A.deviationNodeIdToView,ae=A.resetDeviationNodeId,se=t.useState(oe.maintainRelativeOrder),de=se[0],ve=se[1],fe=!!de||!!(null==oe?void 0:oe.showDeviationBadges),ge=t.useState(!1),pe=ge[0],he=ge[1],xe=t.useState(!1),_e=xe[0],me=xe[1],Re=t.useState(null),ye=Re[0],Se=Re[1],Ae=t.useState(!1),be=Ae[0],Ee=Ae[1],Ie=t.useState(null===(E=null!==(b=null==Q?void 0:Q.newEvaluationResult)&&void 0!==b?b:null==oe?void 0:oe.enableDeviationSchemaBackwardCompatibility)||void 0===E||E)[0],Te=t.useState(!1),Be=Te[0],Ce=Te[1],De=t.useState(!1),Oe=De[0],we=De[1],Ne=t.useState(null),je=Ne[0],Pe=Ne[1],Fe=t.useRef(!1),ke=t.useState(new Set),Me=ke[0],Ve=ke[1],Le=t.useState([]),Ge=Le[0],He=Le[1],qe=t.useRef(null),ze=t.useRef(!1),We=t.useRef(null),Ye=t.useRef({}),Ke=t.useRef([]),Ue=t.useRef(!1),Xe=t.useRef(!1),Je=t.useRef(null),$e=t.useRef(function(){}),Qe=t.useMemo(function(){return(null==Q?void 0:Q.cognitive_decisioning)||{}},[Q]),Ze=t.useState({width:0,height:0}),en=Ze[0],nn=Ze[1],tn=t.useMemo(function(){return e.__assign(e.__assign({},c.SHARED_MARKDOWN_STYLES),te)},[te]),on=t.useRef(null),rn=t.useRef(null),ln=t.useRef(null),un=t.useRef(null),cn=t.useRef(null),an=t.useRef(null),sn=t.useRef(null),dn=t.useRef(null),vn=t.useRef(!1),fn=t.useRef(null),gn=t.useRef(null),pn=p.useComparePopups(on),hn=pn.cognitivePopup,xn=pn.setCognitivePopup,_n=pn.moreFunctions,mn=pn.setMoreFunctions,Rn=pn.position,yn=pn.setPosition,Sn=pn.activeBadgeId,An=pn.summaryPopup,bn=pn.setSummaryPopup,En=pn.closeSummaryPopup,In=pn.setActiveBadgeId,Tn=pn.popupRef,Bn=pn.closeCognitivePopup,Cn=pn.closeMoreFunctionsPopup,Dn=t.useMemo(function(){var e,n,t,i,o,r,l;return{fields:null!==(e=null==Z?void 0:Z.fields)&&void 0!==e?e:c.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(t=null===(n=null==Z?void 0:Z.thresholds)||void 0===n?void 0:n.high)&&void 0!==t?t:c.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(o=null===(i=null==Z?void 0:Z.thresholds)||void 0===i?void 0:i.medium)&&void 0!==o?o:c.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(l=null===(r=null==Z?void 0:Z.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:c.DEFAULT_COMPARISON_CONFIG.thresholds.exact}}},[Z]),On=t.useState(null),wn=On[0];On[1];var Nn=null===(B=null===(I=null==Q?void 0:Q.documents)||void 0===I?void 0:I[null===(T=null==Q?void 0:Q.input_index_map)||void 0===T?void 0:T[0]])||void 0===B?void 0:B.title,jn=null===(O=null===(C=null==Q?void 0:Q.documents)||void 0===C?void 0:C[null===(D=null==Q?void 0:Q.input_index_map)||void 0===D?void 0:D[1]])||void 0===O?void 0:O.title,Pn=u.safeStringify(ee||Nn||"Uploaded Contract"),Fn=u.safeStringify(ne||jn||"Reference Template"),kn=g.useCognitiveTreeData(Q,de,ue,Dn,Ie),Mn=kn.activeProposed,Vn=kn.existingRule,Ln=kn.proposedSections,Gn=kn.existingSections,Hn=kn.visibleFields,qn=kn.parentDeviationRecord,zn=kn.deviationNumberRegistry,Wn=kn.parseError;t.useEffect(function(){Wn&&Se("Failed to load comparison: ".concat(Wn))},[Wn]);var Yn=Ln.length>0||Gn.length>0,Kn=h.useSectionRefs(Hn.map(function(e){return e.key}),Math.max(Ln.length,Gn.length)),Un=Kn.leftRefs,Xn=Kn.rightRefs,Jn=Kn.sectionLeftRefs,$n=Kn.sectionRightRefs,Qn=Kn.lhsBadgeRefs,Zn=Kn.rhsBadgeRefs,et=Kn.sectionRightRowRefs,nt=Kn.subSectionLeftRefs,tt=Kn.subSectionRightRefs,it=Kn.sectionRowRefs,ot=Kn.getSectionRowRef,rt=Kn.getSubSectionRef,lt=Kn.getBadgeRef,ut=Vn.analysis,ct=u.safeStringify(null===(N=null===(w=null==ut?void 0:ut.rule_difference_comparison)||void 0===w?void 0:w.summary)||void 0===N?void 0:N.overall_summary),at=!!ct.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),st=null!==(j=null==Q?void 0:Q.base_root_id)&&void 0!==j?j:"-1";null==Q||Q[st];var dt=Ie?null!==(Y=null!==(q=ue&&(null===(H=null==ue?void 0:ue[st])||void 0===H?void 0:H.evaluation_result))&&void 0!==q?q:null===(W=null===(z=null==Q?void 0:Q.nodes)||void 0===z?void 0:z[st])||void 0===W?void 0:W.evaluation_result)&&void 0!==Y?Y:null:null!==(G=null!==(k=ue&&(null===(F=null===(P=null==ue?void 0:ue[st])||void 0===P?void 0:P.evaluation_result)||void 0===F?void 0:F[0]))&&void 0!==k?k:null===(L=null===(V=null===(M=null==Q?void 0:Q.nodes)||void 0===M?void 0:M[st])||void 0===V?void 0:V.evaluation_result)||void 0===L?void 0:L[0])&&void 0!==G?G:null,vt=u.extractDeviationScore(dt),ft=u.generateColorPalette(null!==(X=null===(U=null===(K=null==dt?void 0:dt.evaluation_outputs)||void 0===K?void 0:K.metadata)||void 0===U?void 0:U.label_color)&&void 0!==X?X:""),gt=t.useCallback(function(){var e,n,t,i,o,r;Ee(!1),Xe.current=!1;var l=Je.current,c=Bt.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=nt.current[a[2]])||void 0===e?void 0:e.current)||(null===(n=Jn.current[Number(a[2])])||void 0===n?void 0:n.current))&&(s.style.paddingTop="0px")}else{var s;(s=null===(t=Jn.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=tt.current[a[3]])||void 0===i?void 0:i.current)||(null===(o=$n.current[Number(a[3])])||void 0===o?void 0:o.current))&&(d.style.paddingTop="0px")}else{var d;(d=null===(r=$n.current[c])||void 0===r?void 0:r.current)&&(d.style.paddingTop="0px")}Pe(null),Je.current=null,Bt.current=null,Ce(!1),me(!1),un.current&&(un.current.style.height="0px"),cn.current&&(cn.current.style.height="0px"),an.current&&(an.current.style.height="0px"),sn.current&&(sn.current.style.height="0px")},[]),pt=x.useAccordionState({maintainRelativeOrder:!!de,proposedSections:Ln,existingSections:Gn,activeSideBySideSection:je,connectedSections:Me,resetSideBySide:gt,setConnectedSections:Ve,setConnectedLines:He,cachedConnectedPositions:Ke,svgContainerRef:qe,isAnimatingRef:ze,animationTimerRef:We,calculateLinesRef:$e,sectionLeftRefs:Jn,sectionRightRefs:$n,subSectionLeftRefs:nt,subSectionRightRefs:tt}),ht=pt.expandedSections,xt=pt.setExpandedSections,_t=pt.expandedSubSections,mt=pt.setExpandedSubSections,Rt=pt.toggleSection,yt=t.useCallback(function(n,t,i,o,r,l,c){var a,s,d,v=u.safeStringify(null==t?void 0:t.id)||u.safeStringify(null==i?void 0:i.id)||"",f=(v?Qe[v]:null)||(null==t?void 0:t.cognitiveData)||(null==i?void 0:i.cognitiveData)||{section_id:v,decisioning:[],gap:[],relevance_score:0},g=null!==(s=null===(a=it.current[o])||void 0===a?void 0:a.current)&&void 0!==s?s:null;return{isLoading:null!==(d=null==oe?void 0:oe.isLoading)&&void 0!==d&&d,open:!0,sectionTitle:(null==t?void 0:t.displayTitle)?null==t?void 0:t.title:"no title",refSectionTitle:(null==i?void 0:i.displayTitle)?null==i?void 0:i.title:"no title",cognitiveData:f,anchorEl:n,sectionAnchorEl:g,badgeStyle:l||null,sectionIdx:o,docData:{documents:null==Q?void 0:Q.documents,input_index_map:null==Q?void 0:Q.input_index_map},deviationData:function(){var n,r,l=(null==t?void 0:t.evaluationResult)||(null==i?void 0:i.evaluationResult)||null,c=function(n){var t=function(e){if(!e||"object"!=typeof e)return null;var n=null==e?void 0:e.deviation_entries;if(n&&"object"==typeof n){var t=Object.keys(n).sort(function(e,n){return Number(e)-Number(n)})[0];if(t&&n[t])return n[t]}var i=Object.keys(e).filter(function(e){return/^\d+$/.test(e)}).sort(function(e,n){return Number(e)-Number(n)});if(i.length&&e[i[0]])return e[i[0]];var o=null==e?void 0:e.deviations;if(o&&"object"==typeof o){var r=Object.keys(o).sort(function(e,n){return Number(e)-Number(n)})[0];if(r&&o[r])return o[r]}return null}(n);return t?e.__assign(e.__assign({},n),{deviation_summary:(null==n?void 0:n.deviation_summary)||(null==t?void 0:t.deviation_summary),deviation_title:(null==n?void 0:n.deviation_title)||(null==t?void 0:t.deviation_title),deviation_impact:(null==n?void 0:n.deviation_impact)||(null==t?void 0:t.deviation_impact),deviation_explanation:(null==n?void 0:n.deviation_explanation)||(null==t?void 0:t.deviation_explanation),evaluation_outputs:(null==n?void 0:n.evaluation_outputs)||(null==t?void 0:t.evaluation_outputs),cognitive_decisioning:(null==n?void 0:n.cognitive_decisioning)||(null==t?void 0:t.cognitive_decisioning)}):n};if(!("string"==typeof o&&o.includes(u.DEVIATION_BADGE_SEPARATOR)))return c(l);var a=o.split(u.DEVIATION_BADGE_SEPARATOR)[1];if(!a)return l;var s=(null==t?void 0:t.evaluationResult)||(null==i?void 0:i.evaluationResult)||{},d=(null===(n=null==s?void 0:s.deviation_entries)||void 0===n?void 0:n[a])||(null===(r=null==s?void 0:s.deviations)||void 0===r?void 0:r[a])||null;return d?e.__assign(e.__assign(e.__assign({},s),d),{deviation_summary:(null==d?void 0:d.deviation_summary)||(null==s?void 0:s.deviation_summary),deviation_title:(null==d?void 0:d.deviation_title)||(null==s?void 0:s.deviation_title),deviation_impact:(null==d?void 0:d.deviation_impact)||(null==s?void 0:s.deviation_impact),deviation_explanation:(null==d?void 0:d.deviation_explanation)||(null==s?void 0:s.deviation_explanation),evaluation_outputs:(null==d?void 0:d.evaluation_outputs)||(null==s?void 0:s.evaluation_outputs),cognitive_decisioning:(null==d?void 0:d.cognitive_decisioning)||(null==s?void 0:s.cognitive_decisioning)}):c(l)}(),isOrphan:!!r}},[Qe,Q]),St=t.useCallback(function(e){Cn(),yn(null),xn(e)},[Cn]),At=function(e,n,t,i,o,r){var l;if(e.stopPropagation(),_n.open&&_n.sectionIdx===o)Cn();else{var c=e.currentTarget,a="left";(null===(l=ln.current)||void 0===l?void 0:l.contains(c))&&(a="right");Xe.current&>(),Ve(new Set),He([]),Ke.current=[],Bn(),An.open?ii():En(),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=Zn.current[l])||void 0===e?void 0:e.current:null===(n=Qn.current[l])||void 0===n?void 0:n.current}return"right"===a?null===(t=Zn.current[o])||void 0===t?void 0:t.current:null===(i=Qn.current[o])||void 0===i?void 0:i.current}()||c;mn(yt(e,n,i,o,t,r))})}},bt=t.useCallback(function(){null!==_n.sectionIdx&&_n.anchorEl?St(e.__assign(e.__assign({},_n),{open:!0})):Cn()},[_n,Cn,St]),Et=t.useCallback(function(){var e=_n.sectionIdx,n=_n.isOrphan;Cn(),En(),null!==e&&(n?Se("No counterpart exists to connect to."):(Xe.current&>(),He([]),Ke.current=[],Ve(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){$e.current&&$e.current()},50)))},[_n.sectionIdx,_n.isOrphan,Cn,En,gt]),It=t.useRef(null),Tt=t.useRef(null),Bt=t.useRef(null),Ct=t.useRef(null),Dt=t.useRef(null),Ot=t.useRef(null),wt=t.useState([]),Nt=wt[0],jt=wt[1];t.useRef(null);var Pt=t.useState(null),Ft=Pt[0],kt=Pt[1];t.useEffect(function(){if(wn){var e=Dn.fields.find(function(e){return e.analysisKey===wn||e.key===wn});if(e){var n=Un.current[e.key]||Xn.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[wn,Dn.fields]);var Mt=t.useCallback(function(e){var n,t,i,o,r,l,u,c,a,s=null===(n=null==ut?void 0:ut.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 f=d.mappings[0]||{};return{score:d.score,relation:f.relation||"",highlightsA:(null===(l=f.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(u=f.highlights)||void 0===u?void 0:u.ruleB_spans)||[],hasContent:!!v}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(c=d.highlights)||void 0===c?void 0:c.ruleA_spans)||[],highlightsB:(null===(a=d.highlights)||void 0===a?void 0:a.ruleB_spans)||[],hasContent:!!v}},[ut]),Vt=t.useCallback(function(n,t){var i,o,r,l,c,s,d;void 0===t&&(t="left");var v=null,f=null;if("left"===t)if(v=Ln[n],de&&v){var g=Gn.filter(function(e){var n;return null===(n=v.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)});f=g.find(function(e){return e.evaluationResult})||g[0]}else f=Gn[n];else if(f=Gn[n],de&&f){var p=Ln.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(f.selfIndex)});v=p.find(function(e){return e.evaluationResult})||p[0]}else v=Ln[n];var h=(null==v?void 0:v.relation)&&"not_defined"!==v.relation,x=(null==f?void 0:f.relation)&&"not_defined"!==f.relation,_=!(!(null==v?void 0:v.cognitiveData)&&!(null==f?void 0:f.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==f?void 0:f.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})},[Ln,Gn,Qe,Dn,de]),Lt=t.useCallback(function(n){for(var t,i,o,r,l,c,s,d,v,f=n.split("-").map(Number),g=Ln[f[0]],p=Gn[f[0]],h=1;h<f.length;h++)(null==g?void 0:g.subsections)&&(g=g.subsections[f[h]]),(null==p?void 0:p.subsections)&&(p=p.subsections[f[h]]);if(!g&&!p)return null;var x=(null==g?void 0:g.relation)&&"not_defined"!==g.relation,_=(null==p?void 0:p.relation)&&"not_defined"!==p.relation,m=u.safeStringify(null==g?void 0:g.id)||u.safeStringify(null==p?void 0:p.id)||"",R=!(!(null==g?void 0:g.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==g?void 0:g.cognitiveRelevanceScore)&&void 0!==t?t:null==p?void 0:p.cognitiveRelevanceScore)&&void 0!==i||m&&(null===(o=Qe[m])||void 0===o||o.relevance_score);var y=null!==(l=null!==(r=null==g?void 0:g.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})},[Ln,Gn,Qe,Dn]),Gt=t.useCallback(function(){xt({}),mt({}),gt(),Ve(new Set),He([]),Ke.current=[],En(),Bn(),Cn(),requestAnimationFrame(function(){$e.current&&$e.current()})},[xt,mt,gt,En,Bn,Cn]),Ht=t.useMemo(function(){return Object.values(ht).some(Boolean)||Object.values(_t).some(Boolean)},[ht,_t]),qt=t.useCallback(function(){var e,n,t,i,o,r,l,c,a,s,d,v,f,g,p,h,x,_,m,R,y,S;if(!vn.current&&!ze.current){vn.current=!0;try{if(!It.current)return;var A=function(e){var n=e.split("-"),t=n[0];if(!ht[t]&&!1===de)return!1;if(de&&!ht["left-".concat(t)]&&!ht["right-".concat(t)]&&!ht[t])return!1;for(var i=t,o=1;o<n.length-1;o++)if(i+="-".concat(n[o]),!_t[i])return!1;return!0},b=It.current.getBoundingClientRect();nn({width:b.width,height:b.height});var E=[];if(Hn.forEach(function(e){var n,t,i=e.key,o=null===(n=Un.current[i])||void 0===n?void 0:n.current,r=null===(t=Xn.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")}),!ze.current){for(var I=0;I<Math.max(Ln.length,Gn.length);I++){var T=null===(e=Jn.current[I])||void 0===e?void 0:e.current,B=null===(n=$n.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")}de||Object.keys(nt.current).forEach(function(e){var n,t;if(A(e)){var i=null===(n=nt.current[e])||void 0===n?void 0:n.current,o=null===(t=tt.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={};Hn.forEach(function(e){var n,t,i=e.key,o=null===(n=Un.current[i])||void 0===n?void 0:n.current,r=null===(t=Xn.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(!ze.current)if(de){if(be&&null!==je)if("number"==typeof je){var w=je,N=Ln[w],j=null===(o=Jn.current[w])||void 0===o?void 0:o.current;j&&N&&(N.refIndexes||[]).forEach(function(e){var n,t=Gn.findIndex(function(n){return n.selfIndex===e}),i=null===(n=$n.current[t])||void 0===n?void 0:n.current;if(i&&(ht["left-".concat(w)]||ht["right-".concat(t)])){var o=Math.max(j.getBoundingClientRect().height,i.getBoundingClientRect().height);D.left[w]=Math.max(D.left[w]||0,o),D.right[t]=Math.max(D.right[t]||0,o)}})}else{var P=je.split(u.DEVIATION_BADGE_SEPARATOR)[2];if(P){T=null===(r=nt.current[P])||void 0===r?void 0:r.current,B=null===(l=tt.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(nt.current).forEach(function(e){var n,t;if(A(e)){var i=null===(n=nt.current[e])||void 0===n?void 0:n.current,o=null===(t=tt.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(Ln.length,Gn.length);I++){var T=null===(t=Jn.current[I])||void 0===t?void 0:t.current,B=null===(i=$n.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(Hn.forEach(function(e){var n,t,i=e.key,o=null===(n=Un.current[i])||void 0===n?void 0:n.current,r=null===(t=Xn.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")}}),ze.current||(Object.entries(D.left).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=Jn.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=$n.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),de||Object.keys(O).forEach(function(e){var n,t,i=null===(n=nt.current[e])||void 0===n?void 0:n.current,o=null===(t=tt.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")}})),de)Ln.forEach(function(e,n){var t;(null===(t=Jn.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=Gn.findIndex(function(n){return n.selfIndex===e});if(-1!==v){var f=null===(t=Qn.current[n])||void 0===t?void 0:t.current,g=null===(i=Zn.current[v])||void 0===i?void 0:i.current;if(f&&g){var p=f.getBoundingClientRect(),h=g.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(be&&je===n){var y=null!==(r=null===(o=dn.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==r?r:0,S=null!==(u=null===(l=ln.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==u?u:0,A=y+(null!==(a=null===(c=dn.current)||void 0===c?void 0:c.clientHeight)&&void 0!==a?a:1/0),I=S+(null!==(d=null===(s=ln.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=Vt(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(Ln.length,Gn.length);I++){var k=null===(c=Jn.current[I])||void 0===c?void 0:c.current,M=null===(a=$n.current[I])||void 0===a?void 0:a.current;if(k&&M){var V=k.getBoundingClientRect(),L=M.getBoundingClientRect(),G=Math.max(V.top,L.top)+18-b.top,H=(null===(s=Gn[I])||void 0===s?void 0:s.id)||"sec-".concat(I);(J=Vt(I))&&E.push({id:H,x1:V.right-b.left,y1:G,x2:L.left-b.left,y2:G,style:J,sectionIdx:I,hasCognitive:!!((null===(d=Ln[I])||void 0===d?void 0:d.cognitiveData)||(null===(v=Gn[I])||void 0===v?void 0:v.cognitiveData)||H&&Qe[H]),isSubSection:!1})}}Object.keys(nt.current).forEach(function(e){var n,t,i,o,r,l;if(A(e)){var c=null===(n=nt.current[e])||void 0===n?void 0:n.current,a=null===(t=tt.current[e])||void 0===t?void 0:t.current;if(c&&a){for(var s=e.split("-").map(Number),d=Ln[s[0]],v=Gn[s[0]],f=1;f<s.length;f++)(null==d?void 0:d.subsections)&&(d=d.subsections[s[f]]),(null==v?void 0:v.subsections)&&(v=v.subsections[s[f]]);var g=!!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(g&&p||h&&x){var _=c.getBoundingClientRect(),m=a.getBoundingClientRect(),R=Math.max(_.top,m.top)+16-b.top,y=Lt(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(be&&"string"==typeof je&&je.includes(u.DEVIATION_BADGE_SEPARATOR)){var q=je.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===(f=Qn.current[K])||void 0===f?void 0:f.current,X=null===(g=Zn.current[K])||void 0===g?void 0:g.current;if(U&&X){var J,$=U.getBoundingClientRect(),Q=X.getBoundingClientRect(),Z=$.right-b.left,ee=Q.left-b.left,ne=$.top+$.height/2-b.top,te=Q.top+Q.height/2-b.top;if(de){var ie=null!==(h=null===(p=dn.current)||void 0===p?void 0:p.getBoundingClientRect().top)&&void 0!==h?h:0,oe=null!==(_=null===(x=ln.current)||void 0===x?void 0:x.getBoundingClientRect().top)&&void 0!==_?_:0,re=ie+(null!==(R=null===(m=dn.current)||void 0===m?void 0:m.clientHeight)&&void 0!==R?R:1/0),le=oe+(null!==(S=null===(y=ln.current)||void 0===y?void 0:y.clientHeight)&&void 0!==S?S:1/0),ue=function(e,n,t){return Math.max(n,Math.min(t,e))};ne=ue($.top+$.height/2,ie,re)-b.top,te=ue(Q.top+Q.height/2,oe,le)-b.top}(J=Lt(Y))&&E.push({id:"line-subsec-".concat(K),x1:Z,y1:ne,x2:ee,y2:te,style:J,sectionIdx:Number(Y.split("-")[0]),isSubSection:!0,subSectionKeyPath:je})}}if(jt(E),Dt.current&&Ot.current){var ce=Dt.current.getBoundingClientRect(),ae=Ot.current.getBoundingClientRect(),se=(ce.top+ce.height/2-b.top+ae.top+ae.height/2-b.top)/2;kt({x1:ce.right-b.left,x2:ae.left-b.left,y:se})}else kt(null);if(Me.size>0){var ve=[],fe=dn.current,ge=ln.current;if(fe&&ge){var pe=[],he=fe.getBoundingClientRect().top,xe=ge.getBoundingClientRect().top,_e=he+fe.clientHeight,me=xe+ge.clientHeight,Re=fe.scrollTop,ye=ge.scrollTop,Se=b.top,Ae=function(e,n,t){return Math.max(n,Math.min(t,e))};Me.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=Qn.current[d])||void 0===n?void 0:n.current,f=null===(t=Zn.current[d])||void 0===t?void 0:t.current;if(!v||!f)return;var g=v.getBoundingClientRect(),p=f.getBoundingClientRect(),h=Lt(s),x=(j=g.right-b.left)+.5*((P=p.left-b.left-0)-j),_=g.top+g.height/2,m=p.top+p.height/2,R=_-he+Re,y=m-xe+ye,S="conn-subsec-".concat(d);pe.push({lhsScrollY:R,rhsScrollY:y,x1:j,x2:P,containerTop:Se,leftIdx:e,rhsArrayIdx:e,styleColor:(null==h?void 0:h.badgeBorder)||"#6366F1",styleId:S});var A=Ae(_,he,_e),E=Ae(m,xe,me),I=A-Se,T=E-Se,B=m>=xe-4&&m<=me+4,C="";C=(F=_>=he-4&&_<=_e+4)&&B?u.getBentArrowPath(j,I,P,T):F&&!B?"M ".concat(j,",").concat(I," L ").concat(x,",").concat(I," L ").concat(x,",").concat(T):!F&&B?"M ".concat(x,",").concat(I," L ").concat(x,",").concat(T," L ").concat(P,",").concat(T):"M ".concat(x,",").concat(I," L ").concat(x,",").concat(T),ve.push({id:S,pathD:C,style:h,leftIdx:e,rhsArrayIdx:e})}else if(de){var D=e,O=Ln[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=Gn.findIndex(function(n){return n.selfIndex===e});if(-1!==i){var o=null===(n=Qn.current[D])||void 0===n?void 0:n.current,r=null===(t=Zn.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),c=r.getBoundingClientRect(),a=Vt(D),s=l.right-b.left,d=c.left-b.left-0,v=s+.5*(d-s),f=l.top+l.height/2,g=c.top+c.height/2,p=f-he+Re,h=g-xe+ye,x="conn-".concat(D,"-").concat(i);pe.push({lhsScrollY:p,rhsScrollY:h,x1:s,x2:d,containerTop:Se,leftIdx:D,rhsArrayIdx:i,styleColor:(null==a?void 0:a.badgeBorder)||"#6366F1",styleId:x});var _=Ae(f,he,_e),m=Ae(g,xe,me),R=_-Se,y=m-Se,S=f>=he-4&&f<=_e+4,A=g>=xe-4&&g<=me+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),ve.push({id:x,pathD:E,style:a,leftIdx:D,rhsArrayIdx:i})}}})}else{var w=e,N=w;v=null===(i=Qn.current[w])||void 0===i?void 0:i.current,f=null===(o=Zn.current[N])||void 0===o?void 0:o.current;if(!v||!f)return;var j,P;g=v.getBoundingClientRect(),p=f.getBoundingClientRect(),h=Vt(w),x=(j=g.right-b.left)+.5*((P=p.left-b.left-0)-j),_=g.top+g.height/2,m=p.top+p.height/2,R=_-he+Re,y=m-xe+ye,S="conn-".concat(w,"-").concat(N);pe.push({lhsScrollY:R,rhsScrollY:y,x1:j,x2:P,containerTop:Se,leftIdx:w,rhsArrayIdx:N,styleColor:(null==h?void 0:h.badgeBorder)||"#6366F1",styleId:S});var F;A=Ae(_,he,_e),E=Ae(m,xe,me),I=A-Se,T=E-Se,B=m>=xe-4&&m<=me+4,C="";C=(F=_>=he-4&&_<=_e+4)&&B?u.getBentArrowPath(j,I,P,T):F&&!B?"M ".concat(j,",").concat(I," L ").concat(x,",").concat(I," L ").concat(x,",").concat(T):!F&&B?"M ".concat(x,",").concat(I," L ").concat(x,",").concat(T," L ").concat(P,",").concat(T):"M ".concat(x,",").concat(I," L ").concat(x,",").concat(T),ve.push({id:S,pathD:C,style:h,leftIdx:w,rhsArrayIdx:N})}}),Ke.current=pe}He(ve)}else He([]),Ke.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{vn.current=!1}}},[Hn,Ln,Gn,Qe,Dn,Mt,Vt,de,be,je,Me,ht,_t]),zt=t.useCallback(function(){var e,n,t,i,o,r,l,c,a,s,d,v,f,g,p=Ke.current;if(p.length&&!ze.current){var h=null!==(n=null===(e=dn.current)||void 0===e?void 0:e.scrollTop)&&void 0!==n?n:0,x=null!==(i=null===(t=ln.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,_=null!==(r=null===(o=dn.current)||void 0===o?void 0:o.clientHeight)&&void 0!==r?r:1/0,m=null!==(c=null===(l=ln.current)||void 0===l?void 0:l.clientHeight)&&void 0!==c?c:1/0,R=null!==(s=null===(a=dn.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==s?s:0,y=null!==(v=null===(d=ln.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==v?v:0,S=R+_,A=y+m,b=null!==(g=null===(f=It.current)||void 0===f?void 0:f.getBoundingClientRect().top)&&void 0!==g?g: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=Ye.current[e.styleId+"-stroke"],o=Ye.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,f=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(f,",").concat(a," L ").concat(f,",").concat(s):!d&&v?"M ".concat(f,",").concat(a," L ").concat(f,",").concat(s," L ").concat(e.x2,",").concat(s):"M ".concat(f,",").concat(a," L ").concat(f,",").concat(s),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",r)),o&&(o.setAttribute("visibility","visible"),o.setAttribute("d",r))}})}},[]);t.useEffect(function(){$e.current=qt},[qt]);var Wt=t.useRef(null),Yt=t.useRef(null),Kt=t.useCallback(function(){Ke.current.length>0&&!ze.current||(null!==Wt.current&&clearTimeout(Wt.current),Wt.current=setTimeout(function(){$e.current(),Wt.current=null},50))},[]),Ut=t.useCallback(function(){we(!0),Ce(!1),null!==Yt.current&&clearTimeout(Yt.current),null!==Wt.current&&(clearTimeout(Wt.current),Wt.current=null),Yt.current=setTimeout(function(){var e,n,t,i,o,r,l,c,a,s;if(Ke.current=[],Xe.current&&null!==Je.current&&null!==Bt.current){var d=Je.current,v=Bt.current,f=null,g=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]);f=(null===(e=Qn.current[_])||void 0===e?void 0:e.current)||null,g=(null===(n=Zn.current[_])||void 0===n?void 0:n.current)||null,p=(null===(t=nt.current[x[2]])||void 0===t?void 0:t.current)||(null===(i=Jn.current[Number(x[2])])||void 0===i?void 0:i.current)||null,h=(null===(o=tt.current[x[3]])||void 0===o?void 0:o.current)||(null===(r=$n.current[Number(x[3])])||void 0===r?void 0:r.current)||null}else f=(null===(l=it.current[d])||void 0===l?void 0:l.current)||null,p=(null===(c=Jn.current[d])||void 0===c?void 0:c.current)||null,g=(null===(a=et.current[v])||void 0===a?void 0:a.current)||null,h=(null===(s=$n.current[v])||void 0===s?void 0:s.current)||null;if(f&&g&&p&&h){if(p.style.paddingTop="0px",h.style.paddingTop="0px",!de){var m=f.getBoundingClientRect(),R=g.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=dn.current,A=ln.current;if(S&&A){var b=f.getBoundingClientRect().top-S.getBoundingClientRect().top+S.scrollTop,E=g.getBoundingClientRect().top-A.getBoundingClientRect().top+A.scrollTop-(b-S.scrollTop);Math.abs(A.scrollTop-E)>1&&(A.scrollTop=E)}}}$e.current(),Xe.current&&Ce(!0),we(!1),Yt.current=null},150)},[de,Ln,Gn]),Xt=t.useCallback(function(e){var n,t,i,o,r,l,c,a,s,d;if(null!==fn.current&&gn.current&&Math.abs(e.currentTarget.scrollTop-fn.current)<=2){var v=gn.current;fn.current=null,gn.current=null,v()}if(!Fe.current){if(de||Kt(),Xe.current){var f=Je.current,g=Bt.current,p=dn.current,h=ln.current;if(null!==f&&null!==g&&p&&h){var x="string"==typeof f&&f.includes(u.DEVIATION_BADGE_SEPARATOR)?null===(n=Qn.current["".concat(f.split(u.DEVIATION_BADGE_SEPARATOR)[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(f.split(u.DEVIATION_BADGE_SEPARATOR)[1])])||void 0===n?void 0:n.current:null===(t=it.current[f])||void 0===t?void 0:t.current,_="string"==typeof g&&g.includes(u.DEVIATION_BADGE_SEPARATOR)?null===(i=Zn.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=et.current[g])||void 0===o?void 0:o.current;if(x&&_&&Ct.current){var m=void 0,R=void 0;if("string"==typeof f&&f.includes(u.DEVIATION_BADGE_SEPARATOR)){var y=f.split(u.DEVIATION_BADGE_SEPARATOR),S="".concat(y[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(y[1]);m=null===(r=Qn.current[S])||void 0===r?void 0:r.current,R=null===(l=Zn.current[S])||void 0===l?void 0:l.current}else m=null===(c=Qn.current[f])||void 0===c?void 0:c.current,R=null===(a=Zn.current[g])||void 0===a?void 0:a.current;var A=null!==(d=null===(s=It.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,N=E,Math.max(w,Math.min(N,O)))-A).toString();Ct.current.setAttribute("y1",C),Ct.current.setAttribute("y2",C);var D=B>=b-4&&B<=E+4;Ct.current.setAttribute("visibility",D?"visible":"hidden")}}}}var O,w,N;Ke.current.length>0&&!Ue.current&&(Ue.current=!0,requestAnimationFrame(function(){zt(),Ue.current=!1}))}},[zt,de,Kt]),Jt=t.useRef(0),$t=t.useRef(0),Qt=t.useRef(0),Zt=t.useRef(function(){});t.useRef(null),t.useEffect(function(){Zt.current=Ut},[Ut]),t.useEffect(function(){var e=setTimeout(Kt,250),n=function(){return Zt.current()};return window.addEventListener("resize",n),function(){clearTimeout(e),null!==Wt.current&&clearTimeout(Wt.current),null!==Yt.current&&clearTimeout(Yt.current),window.removeEventListener("resize",n)}},[Mn,Vn,ut,Hn,ht,_t,Ln,Gn,Dn,Kt,be,je,Be,Me]),t.useEffect(function(){var e=function(e,n,t,i,o){n.current=e.getBoundingClientRect().width;var r=new ResizeObserver(function(e){null!==t.current&&cancelAnimationFrame(t.current),t.current=requestAnimationFrame(function(){var r,l,u;t.current=null;var c=e[e.length-1];if(c){var a=null!==(u=null===(l=null===(r=c.borderBoxSize)||void 0===r?void 0:r[0])||void 0===l?void 0:l.inlineSize)&&void 0!==u?u:c.contentRect.width;Math.abs(a-n.current)<1?o():(n.current=a,i())}})});return r.observe(e),r},n={current:null},t={current:null},i={current:null},o=[],r=[n,t,i];return rn.current&&o.push(e(rn.current,Jt,n,function(){return Zt.current()},function(){})),on.current&&o.push(e(on.current,$t,t,function(){return Zt.current()},function(){return $e.current()})),It.current&&o.push(e(It.current,Qt,i,function(){return Zt.current()},function(){return $e.current()})),function(){o.forEach(function(e){return e.disconnect()}),r.forEach(function(e){null!==e.current&&(cancelAnimationFrame(e.current),e.current=null)})}},[]),t.useEffect(function(){Xe.current=be},[be]),t.useEffect(function(){Je.current=je},[je]);var ei=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";Cn(),null!=e&&(n?Se("No counterpart exists for this section."):be&&je===e?r?gt():null==l||l():(Ve(new Set([e])),He([]),Ke.current=[],me(!0),Fe.current=!0,Pe(e),Je.current=e,Ee(!0),Xe.current=!0,Ce(!1),un.current&&(un.current.style.height="0px"),cn.current&&(cn.current.style.height="0px"),an.current&&(an.current.style.height="0px"),sn.current&&(sn.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 f=e.split(u.DEVIATION_BADGE_SEPARATOR),g="".concat(f[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(f[1]);s=(null===(n=Qn.current[g])||void 0===n?void 0:n.current)||null,d=(null===(t=Zn.current[g])||void 0===t?void 0:t.current)||null,v=d?e:null}else if(s=(null===(i=it.current[e])||void 0===i?void 0:i.current)||null,de){var p=Ln[e],h=(null==p?void 0:p.refIndexes)||[];if(h.length>0){var x=h[0],_=Gn.findIndex(function(e){return e.selfIndex===x});-1!==_&&(d=(null===(r=et.current[_])||void 0===r?void 0:r.current)||null,v=_)}}else d=(null===(o=et.current[e])||void 0===o?void 0:o.current)||null,v=d?e:null;Bt.current=v;var m=dn.current,R=ln.current,y=function(){!function(){var n,t,i,o,r,l,c,s,d,f,g,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=nt.current[R[2]])||void 0===n?void 0:n.current)||(null===(t=Jn.current[Number(R[2])])||void 0===t?void 0:t.current)||null,x=(null===(i=tt.current[R[3]])||void 0===i?void 0:i.current)||(null===(o=$n.current[Number(R[3])])||void 0===o?void 0:o.current)||null,_=(null===(r=Qn.current[y])||void 0===r?void 0:r.current)||h,m=(null===(l=Zn.current[y])||void 0===l?void 0:l.current)||x}else{var S=Number(e),A=null!==v?Number(v):S;h=(null===(c=Jn.current[S])||void 0===c?void 0:c.current)||null,x=(null===(s=$n.current[A])||void 0===s?void 0:s.current)||null,_=(null===(d=Qn.current[S])||void 0===d?void 0:d.current)||(null===(f=it.current[S])||void 0===f?void 0:f.current)||h,m=(null===(g=Zn.current[A])||void 0===g?void 0:g.current)||(null===(p=et.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"))}}(),Ce(!0),$e.current&&$e.current(),Fe.current=!1,"right"===c&&R?R.dispatchEvent(new Event("scroll")):m&&m.dispatchEvent(new Event("scroll")),me(!1),null==l||l()};if(!s||!m)return Fe.current=!1,me(!1),void(null==l||l());if(d&&R){if(!de){var S=0;S="right"===c?d?d.getBoundingClientRect().top:0:s?s.getBoundingClientRect().top:0;var A=on.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&&un.current&&(un.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 cn.current&&(cn.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&&an.current&&(an.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 sn.current&&(sn.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()})))},[je,Cn,Gn,be,de,Ln,gt]),ni=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;Bn();var c="left";(null===(o=ln.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=Zn.current[l])||void 0===e?void 0:e.current:null===(t=Qn.current[l])||void 0===t?void 0:t.current}return"right"===c?null===(i=Zn.current[n])||void 0===i?void 0:i.current:null===(o=Qn.current[n])||void 0===o?void 0:o.current};if(t)return gt(),Ve(new Set),He([]),Ke.current=[],void(r&&requestAnimationFrame(function(){var e=a()||l;bn({open:!0,anchorEl:e,summary:i})}));ei(n,t,r?{toggleIfSame:!1,sourceSide:c,onReady:function(){var e=a()||l;bn({open:!0,anchorEl:e,summary:i})}}:{toggleIfSame:!1,sourceSide:c})},[ei,Bn,bn,gt]),ti=t.useCallback(function(){var e,n=_n.sectionIdx,t=_n.isOrphan;if(En(),null!=n){var i="left";_n.anchorEl&&(null===(e=ln.current)||void 0===e?void 0:e.contains(_n.anchorEl))&&(i="right"),ei(n,t,{sourceSide:i})}},[ei,_n.isOrphan,_n.sectionIdx,_n.anchorEl,En]),ii=t.useCallback(function(){En(),gt(),Ve(new Set),He([]),Ke.current=[]},[En,gt]),oi=null!==_n.sectionIdx&&Me.has(_n.sectionIdx),ri=_.useDeviationNavigation({proposedSections:Ln,existingSections:Gn,parentDeviationRecord:qn,expandedSections:ht,maintainRelativeOrder:!!de,scrollContainerRef:on,leftContainerRef:dn,lhsBadgeRefs:Qn,rhsBadgeRefs:Zn}),li=ri.showDeviationNavigation,ui=ri.showOpenNodeRef,ci=t.useMemo(function(){if(!ce)return null;var e=ce.split(":")[0];for(var n in qn){if((qn[n]||[]).some(function(n){return n.id===e}))return n}return null},[ce,qn]),ai=t.useRef(null),si=t.useRef(null);t.useEffect(function(){if(ce&&ai.current!==ce){var n=ce.split(":"),t=n[0],i=n[1],o=null!=i?i:"0";si.current!==ce&&(En(),Bn(),gt(),Ve(new Set),He([]),Ke.current=[],si.current=ce);var r=!1,l=0,c=null,a=150,s=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},d=function(){var n,i,v,f;if(!r){var g=null,p=null;for(var h in qn){var x=qn[h].find(function(e){return e.id===t});if(x){g=h,p=x;break}}if(p&&g){var _=Ln.findIndex(function(e){return e.id===g}),m=Gn.findIndex(function(e){return e.id===g}),R=-1===_&&-1!==m,y=s(Ln,p.id),S=s(Gn,p.id);if(y&&!S&&!R){var A=y.split("-"),b=Number(A[0]);if(de){var E=null===(i=null===(n=Ln[b])||void 0===n?void 0:n.refIndexes)||void 0===i?void 0:i[0],I=Gn.findIndex(function(e){return e.selfIndex===E});-1!==I&&(b=I)}S=e.__spreadArray([b],A.slice(1),!0).join("-")}if(y||S){var T=R||!y&&!!S,B=y?Number(y.split("-")[0]):_,C=S?Number(S.split("-")[0]):m;if(T){if(!(de?!!ht["right-".concat(C)]:!!ht[String(C)])&&C>=0)return Rt(C,"right"),l+=1,void(c=setTimeout(d,450))}else if(!(de?!!ht["left-".concat(B)]:!!ht[String(B)])&&B>=0)return Rt(B,"left"),l+=1,void(c=setTimeout(d,450));var D,O=y||"",w=S||"",N="".concat(p.id).concat(u.DEVIATION_BADGE_SEPARATOR).concat(o).concat(u.DEVIATION_BADGE_SEPARATOR).concat(O).concat(u.DEVIATION_BADGE_SEPARATOR).concat(w),j="".concat(p.id).concat(u.DEVIATION_BADGE_SEPARATOR).concat(o),P=null===(v=Qn.current[j])||void 0===v?void 0:v.current,F=null===(f=Zn.current[j])||void 0===f?void 0:f.current,k=T||!P&&!!F,M=k?F:P;if(D=de?k?ln.current:dn.current:on.current,M&&D){var V=M.getBoundingClientRect();if(0===V.height)return void((l+=1)<20&&(c=setTimeout(d,a)));var L=D.getBoundingClientRect(),G=V.top-L.top+D.scrollTop-L.height/2+V.height/2,H=function(){var n,t,i,l,u;if(!r){ai.current=ce;var c=window.getComputedStyle(M).color;P&&(P.style.transition="box-shadow 300ms ease-in-out",P.style.boxShadow="0 0 10px ".concat(c)),F&&(F.style.transition="box-shadow 300ms ease-in-out",F.style.boxShadow="0 0 10px ".concat(c)),setTimeout(function(){P&&(P.style.boxShadow=""),F&&(F.style.boxShadow="")},2e3);var a=(null===(t=null===(n=p.evaluationResult)||void 0===n?void 0:n.deviations)||void 0===t?void 0:t[o])||p,s=(null===(i=p.evaluationResult)||void 0===i?void 0:i.evaluation_outputs)||p.evaluation_outputs;if(!(!!P&&!!F)){var d=k?(null===(l=Zn.current[j])||void 0===l?void 0:l.current)||F:(null===(u=Qn.current[j])||void 0===u?void 0:u.current)||P;return bn({open:!0,anchorEl:d,summary:e.__assign(e.__assign({},a),{evaluation_outputs:s})}),void(null==ae||ae())}ei(N,!1,{toggleIfSame:!1,sourceSide:"left",onReady:function(){var n,t=(null===(n=Qn.current[j])||void 0===n?void 0:n.current)||P;bn({open:!0,anchorEl:t,summary:e.__assign(e.__assign({},a),{evaluation_outputs:s})})}})}};Math.abs(D.scrollTop-G)<=2?H():(fn.current=G,gn.current=H,D.scrollTo({top:G,behavior:"smooth"}),c&&clearTimeout(c),c=setTimeout(function(){if(gn.current){fn.current=null;var e=gn.current;gn.current=null,e()}},800))}else(l+=1)<20&&(c=setTimeout(d,a))}else(l+=1)<20&&(c=setTimeout(d,a))}else(l+=1)<20&&(c=setTimeout(d,a))}};return c=setTimeout(d,a),function(){r=!0,c&&clearTimeout(c)}}},[ce,qn,Ln,Gn,de,ht,Rt,ei,bn]);var di=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:_t,setExpandedSubSections:mt,maintainRelativeOrder:de||!1,proposedSections:Ln,existingSections:Gn,treeData:Q,deviationNumberRegistry:zn,connectedSections:Me,activeSideBySideSection:je,resolvedMarkdownStyles:tn,getSubSectionRef:rt,getSubSectionCompareStyle:Lt,getBadgeRef:lt,openMoreFunctionsPopup:At,openSummaryPopup:ni,showDeviationBadges:fe,resetSideBySide:gt,setConnectedSections:Ve,setConnectedLines:He,cachedConnectedPositions:Ke})};return n.jsxs(i.Box,e.__assign({ref:rn,sx:e.__assign(e.__assign({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},de?{}:{overflow:"visible"}),{position:"relative"})},{children:[pe&&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:Tt.current,clipTopEl:Dt.current,scrollContainerEl:on.current,onClose:ii,summary:An.summary}),n.jsx(d.default,{open:_n.open,anchorEl:_n.anchorEl,sectionTitle:_n.sectionTitle,referenceSectionTitle:_n.refSectionTitle,onClose:Cn,onOpenCognitiveCompare:bt,onOpenSideBySide:ti,onConnect:Et,isConnected:oi,isOrphan:_n.isOrphan}),hn.open&&n.jsx(s.default,{open:hn.open,popupRef:Tn,position:Rn,popupConfig:re,onClose:function(){yn(null),xn(function(n){return e.__assign(e.__assign({},n),{open:!1})}),In(null)},markdownStyles:te,sectionTitle:hn.sectionTitle,referenceSectionTitle:hn.refSectionTitle,cognitiveData:hn.cognitiveData,anchorEl:hn.anchorEl,sectionAnchorEl:hn.sectionAnchorEl,scrollContainerEl:on.current,badgeStyle:hn.badgeStyle,docData:hn.docData,deviationData:hn.deviationData,isLoading:hn.isLoading}),n.jsx(i.Snackbar,e.__assign({open:!!ye,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:ye}))})),n.jsx(m.default,{componentHeaderText:$,displayConfig:oe,maintainRelativeOrder:de,onCollapseAll:Gt,showCollapseAll:Ht,onToggleView:function(e){he(!0),setTimeout(function(){ve(!e),gt(),En(),Ve(new Set),He([]),Ke.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){he(!1)},600)})})},50)}}),n.jsx(i.Box,e.__assign({ref:on,onScroll:Xt,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:de?"hidden":"auto",borderTop:ct&&at?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(i.Box,e.__assign({sx:e.__assign({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},de?{flex:1,minHeight:0}:{})},{children:n.jsxs(i.Box,e.__assign({ref:It,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"40px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},de?{flex:1,overflow:"visible"}:{})},{children:[n.jsxs("svg",e.__assign({ref:qe,style:{position:"absolute",top:0,left:0,width:en.width||"100%",height:en.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",opacity:Oe?0:1,transition:"opacity 0.15s ease-in-out"}},{children:[Ft&&n.jsx("g",{children:n.jsx("line",{x1:Ft.x1,y1:Ft.y,x2:Ft.x2,y2:Ft.y,stroke:ft.badgeBorder,strokeWidth:"1.5"})}),Nt.map(function(t){var l,c,s,d,v,g,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?be&&je===t.subSectionKeyPath&&Be:be&&je===t.sectionIdx&&Be)return null;if(!de){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),_=Ln[t.sectionIdx]||{title:"",content:""},m=Gn[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=Ln[A[0]]),b.length>0&&(I=Gn[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===(g=null===(v=null===(d=_.evaluationResult)||void 0===d?void 0:d.cognitive_decisioning)||void 0===v?void 0:v.decisioning_factors)||void 0===g?void 0:g.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&&(hn.open&&Sn===t.id?Bn():(In(t.id),St(yt(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(f.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:hn.open&&Sn===t.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},t.id)}return null}),Ge.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){Ye.current[u]=e},d:o,fill:"none",stroke:"#FFFFFF",strokeWidth:"4",strokeOpacity:"0.7"}),n.jsx("path",{ref:function(e){Ye.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)"},de?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(i.Box,e.__assign({ref:Dt,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:Pn,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:Pn}))}))})),n.jsxs(i.Box,e.__assign({ref:dn,onScroll:Xt,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},de?{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:an,style:{width:"100%",height:"0px",flexShrink:0}}),Yn&&Ln.map(function(t,r){var l,c,a=!t.title&&!t.content;if(de&&a)return null;var s=t,d=Vt(r,"left"),v=de?!(null===(l=s.refIndexes)||void 0===l?void 0:l.length)||s.selfIndex<0:!Gn[r],g=de?"number"==typeof s.selfIndex&&s.selfIndex>=0?s.selfIndex+1:null:r+1,p=Me.has(r),h=u.extractDeviationScore(s.evaluationResult,null==d?void 0:d.deviationLabel);return n.jsx(i.Box,e.__assign({ref:ot(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:Jn.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:ot("left-accordion-".concat(r)),mb:0,treeData:Q,proposedSections:Ln,existingSections:Gn,deviationNumberRegistry:zn,getSectionCompareStyle:Vt,getBadgeRef:lt,connectedSections:Me,openMoreFunctionsPopup:At,openSummaryPopup:ni,deviationNodeIdToView:ce,deviationTargetParentId:ci,parentNodeId:(null===(c=null==Q?void 0:Q.input_index_map)||void 0===c?void 0:c[0])||"",isExpanded:de?!!ht["left-".concat(r)]:!!ht[String(r)],onToggle:function(){ii(),Rt(r,"left")},navigation:t.id?li[t.id]:null,showOpenNodeRef:ui,resolvedMarkdownStyles:tn,maintainRelativeOrder:de,showDeviationBadges:fe,renderSubSections:di})})),de&&d&&n.jsxs(i.Box,e.__assign({ref:Qn.current[r],onClick:function(e){var n=de?Gn.find(function(e){var n;return null===(n=s.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""}:Gn[r]||{title:"",content:""};At(e,t,v,n,r,d)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:d.badgeBg,color:d.badgeText,border:"1px solid ".concat(d.badgeBorder),borderRadius:"12px",px:1.2,py:.4,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[null!==g&&n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(d.badgeBorder)}},{children:g})),n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",px:.25}},{children:!oe.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(f.default,{color:d.badgeText})})),n.jsx(o.EllipsisVertical,{size:11,color:d.badgeText})]}))]}))}),"left-row-".concat(r))}),n.jsx("div",{ref:sn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),n.jsx(i.Box,e.__assign({ref:Tt,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(),hn.open&&Sn===st?Bn():(In(st),St(yt(n.currentTarget,{title:"",content:"",evaluationResult:dt,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,st,!0,e.__assign(e.__assign({},ft),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:ft.badgeBg,color:ft.badgeText,border:"1px solid ".concat(ft.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=vt?vt:n.jsx(f.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:hn.open&&Sn===st?"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},de?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[_e&&n.jsx(l.default,{sections:11}),n.jsx(i.Box,e.__assign({ref:Ot,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:Fn,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:Fn}))}))})),n.jsxs(i.Box,e.__assign({ref:ln,onScroll:Xt,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},de?{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:un,style:{width:"100%",height:"0px",flexShrink:0}}),Yn&&Gn.map(function(t,o){var r,l=t,u=[],c=!1,a=null,s=-1;if(de){u=Ln.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=Ln.findIndex(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(l.selfIndex))&&e.selfIndex>=0});var d=Ln.findIndex(function(e,n){var t;return Me.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(l.selfIndex))});(c=-1!==d)&&(a=Vt(d))}else u=[o+1],(c=Me.has(o))&&(a=Vt(o));var v=Vt(de&&-1!==s?s:o);return n.jsx(i.Box,e.__assign({ref:et.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:$n.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:ot("right-accordion-".concat(o)),mb:0,parentNodeId:(null===(r=null==Q?void 0:Q.input_index_map)||void 0===r?void 0:r[1])||"",isExpanded:de?!!ht["right-".concat(o)]:!!ht[String(o)],treeData:Q,proposedSections:Ln,existingSections:Gn,deviationNumberRegistry:zn,getBadgeRef:lt,getSectionCompareStyle:Vt,connectedSections:Me,openMoreFunctionsPopup:At,openSummaryPopup:ni,deviationNodeIdToView:ce,deviationTargetParentId:ci,onToggle:function(){ii(),Rt(o,"right")},navigation:t.id?li[t.id]:null,showOpenNodeRef:ui,resolvedMarkdownStyles:tn,maintainRelativeOrder:de,showDeviationBadges:fe,renderSubSections:di})})),de&&v&&n.jsx(i.Box,e.__assign({ref:Zn.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:cn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),t=require("react"),i=require("@mui/material"),o=require("lucide-react"),r=require("../../assests/svg/ButtonCognitiveIcon.js"),l=require("./OverlayComponent.js"),u=require("./CognitiveComparehelpers.js"),c=require("./CognitiveCompareConfig.js"),a=require("./CognitiveCompareConstants.js"),s=require("./CognitivePopup.js"),d=require("./MoreFunctionsPopup.js"),v=require("./LoaderComponent.js"),f=require("./components/ThreeDotsLoader.js"),g=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,E,T,I,B,C,D,O,w,N,j,P,F,k,M,V,L,G,H,q,z,W,Y,K,U,X,J=b.componentHeaderText,$=void 0===J?a.DEFAULT_COMPONENT_HEADER_TEXT:J,Q=b.treeData,Z=b.comparisonConfig,ee=b.leftColumnTitleText,ne=b.rightColumnTitleText,te=b.markdownStyles,ie=b.resetTrigger,oe=b.displayConfig,re=void 0===oe?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!0}:oe,le=b.popupConfig,ue=b.deviationData,ce=void 0===ue?{}:ue,ae=b.deviationNodeIdToView,se=b.resetDeviationNodeId,de=t.useState(re.maintainRelativeOrder),ve=de[0],fe=de[1],ge=!!ve||!!(null==re?void 0:re.showDeviationBadges),pe=t.useState(!1),he=pe[0],xe=pe[1],_e=t.useState(!1),me=_e[0],Re=_e[1],ye=t.useState(null),Se=ye[0],be=ye[1],Ae=t.useState(!1),Ee=Ae[0],Te=Ae[1],Ie=t.useState(null===(E=null!==(A=null==Q?void 0:Q.newEvaluationResult)&&void 0!==A?A:null==re?void 0:re.enableDeviationSchemaBackwardCompatibility)||void 0===E||E)[0],Be=t.useState(!1),Ce=Be[0],De=Be[1],Oe=t.useState(!1),we=Oe[0],Ne=Oe[1],je=t.useState(null),Pe=je[0],Fe=je[1],ke=t.useRef(!1),Me=t.useState(new Set),Ve=Me[0],Le=Me[1],Ge=t.useState([]),He=Ge[0],qe=Ge[1],ze=t.useRef(null),We=t.useRef(!1),Ye=t.useRef(null),Ke=t.useRef({}),Ue=t.useRef([]),Xe=t.useRef(!1),Je=t.useRef(!1),$e=t.useRef(null),Qe=t.useRef(function(){}),Ze=t.useMemo(function(){return(null==Q?void 0:Q.cognitive_decisioning)||{}},[Q]),en=t.useState({width:0,height:0}),nn=en[0],tn=en[1],on=t.useMemo(function(){return e.__assign(e.__assign({},c.SHARED_MARKDOWN_STYLES),te)},[te]),rn=t.useRef(null),ln=t.useRef(null),un=t.useRef(null),cn=t.useRef(null),an=t.useRef(null),sn=t.useRef(null),dn=t.useRef(null),vn=t.useRef(null),fn=t.useRef(!1),gn=t.useRef(null),pn=t.useRef(null),hn=p.useComparePopups(rn),xn=hn.cognitivePopup,_n=hn.setCognitivePopup,mn=hn.moreFunctions,Rn=hn.setMoreFunctions,yn=hn.position,Sn=hn.setPosition,bn=hn.activeBadgeId,An=hn.summaryPopup,En=hn.setSummaryPopup,Tn=hn.closeSummaryPopup,In=hn.setActiveBadgeId,Bn=hn.popupRef,Cn=hn.closeCognitivePopup,Dn=hn.closeMoreFunctionsPopup,On=t.useMemo(function(){var e,n,t,i,o,r,l;return{fields:null!==(e=null==Z?void 0:Z.fields)&&void 0!==e?e:c.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(t=null===(n=null==Z?void 0:Z.thresholds)||void 0===n?void 0:n.high)&&void 0!==t?t:c.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(o=null===(i=null==Z?void 0:Z.thresholds)||void 0===i?void 0:i.medium)&&void 0!==o?o:c.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(l=null===(r=null==Z?void 0:Z.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:c.DEFAULT_COMPARISON_CONFIG.thresholds.exact}}},[Z]),wn=t.useState(null),Nn=wn[0];wn[1];var jn=null===(B=null===(T=null==Q?void 0:Q.documents)||void 0===T?void 0:T[null===(I=null==Q?void 0:Q.input_index_map)||void 0===I?void 0:I[0]])||void 0===B?void 0:B.title,Pn=null===(O=null===(C=null==Q?void 0:Q.documents)||void 0===C?void 0:C[null===(D=null==Q?void 0:Q.input_index_map)||void 0===D?void 0:D[1]])||void 0===O?void 0:O.title,Fn=u.safeStringify(ee||jn||"Uploaded Contract"),kn=u.safeStringify(ne||Pn||"Reference Template"),Mn=g.useCognitiveTreeData(Q,ve,ce,On,Ie),Vn=Mn.activeProposed,Ln=Mn.existingRule,Gn=Mn.proposedSections,Hn=Mn.existingSections,qn=Mn.visibleFields,zn=Mn.parentDeviationRecord,Wn=Mn.deviationNumberRegistry,Yn=Mn.parseError;t.useEffect(function(){Yn&&be("Failed to load comparison: ".concat(Yn))},[Yn]);var Kn=Gn.length>0||Hn.length>0,Un=h.useSectionRefs(qn.map(function(e){return e.key}),Math.max(Gn.length,Hn.length)),Xn=Un.leftRefs,Jn=Un.rightRefs,$n=Un.sectionLeftRefs,Qn=Un.sectionRightRefs,Zn=Un.lhsBadgeRefs,et=Un.rhsBadgeRefs,nt=Un.sectionRightRowRefs,tt=Un.subSectionLeftRefs,it=Un.subSectionRightRefs,ot=Un.sectionRowRefs,rt=Un.getSectionRowRef,lt=Un.getSubSectionRef,ut=Un.getBadgeRef,ct=Ln.analysis,at=u.safeStringify(null===(N=null===(w=null==ct?void 0:ct.rule_difference_comparison)||void 0===w?void 0:w.summary)||void 0===N?void 0:N.overall_summary),st=!!at.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),dt=null!==(j=null==Q?void 0:Q.base_root_id)&&void 0!==j?j:"-1";null==Q||Q[dt];var vt=Ie?null!==(Y=null!==(q=ce&&(null===(H=null==ce?void 0:ce[dt])||void 0===H?void 0:H.evaluation_result))&&void 0!==q?q:null===(W=null===(z=null==Q?void 0:Q.nodes)||void 0===z?void 0:z[dt])||void 0===W?void 0:W.evaluation_result)&&void 0!==Y?Y:null:null!==(G=null!==(k=ce&&(null===(F=null===(P=null==ce?void 0:ce[dt])||void 0===P?void 0:P.evaluation_result)||void 0===F?void 0:F[0]))&&void 0!==k?k:null===(L=null===(V=null===(M=null==Q?void 0:Q.nodes)||void 0===M?void 0:M[dt])||void 0===V?void 0:V.evaluation_result)||void 0===L?void 0:L[0])&&void 0!==G?G:null,ft=u.extractDeviationScore(vt),gt=u.generateColorPalette(null!==(X=null===(U=null===(K=null==vt?void 0:vt.evaluation_outputs)||void 0===K?void 0:K.metadata)||void 0===U?void 0:U.label_color)&&void 0!==X?X:""),pt=t.useCallback(function(){var e,n,t,i,o,r;Te(!1),Je.current=!1;var l=$e.current,c=Dt.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=tt.current[a[2]])||void 0===e?void 0:e.current)||(null===(n=$n.current[Number(a[2])])||void 0===n?void 0:n.current))&&(s.style.paddingTop="0px")}else{var s;(s=null===(t=$n.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=it.current[a[3]])||void 0===i?void 0:i.current)||(null===(o=Qn.current[Number(a[3])])||void 0===o?void 0:o.current))&&(d.style.paddingTop="0px")}else{var d;(d=null===(r=Qn.current[c])||void 0===r?void 0:r.current)&&(d.style.paddingTop="0px")}Fe(null),$e.current=null,Dt.current=null,De(!1),Re(!1),cn.current&&(cn.current.style.height="0px"),an.current&&(an.current.style.height="0px"),sn.current&&(sn.current.style.height="0px"),dn.current&&(dn.current.style.height="0px")},[]),ht=t.useCallback(function(){pt(),Le(new Set),qe([]),Ue.current=[],En(a.EMPTY_SUMMARY_POPUP_STATE)},[]);t.useEffect(function(){ht()},[ie]);var xt=x.useAccordionState({maintainRelativeOrder:!!ve,proposedSections:Gn,existingSections:Hn,activeSideBySideSection:Pe,connectedSections:Ve,resetSideBySide:pt,setConnectedSections:Le,setConnectedLines:qe,cachedConnectedPositions:Ue,svgContainerRef:ze,isAnimatingRef:We,animationTimerRef:Ye,calculateLinesRef:Qe,sectionLeftRefs:$n,sectionRightRefs:Qn,subSectionLeftRefs:tt,subSectionRightRefs:it}),_t=xt.expandedSections,mt=xt.setExpandedSections,Rt=xt.expandedSubSections,yt=xt.setExpandedSubSections,St=xt.toggleSection,bt=t.useCallback(function(n,t,i,o,r,l,c){var a,s,d,v=u.safeStringify(null==t?void 0:t.id)||u.safeStringify(null==i?void 0:i.id)||"",f=(v?Ze[v]:null)||(null==t?void 0:t.cognitiveData)||(null==i?void 0:i.cognitiveData)||{section_id:v,decisioning:[],gap:[],relevance_score:0},g=null!==(s=null===(a=ot.current[o])||void 0===a?void 0:a.current)&&void 0!==s?s:null;return{isLoading:null!==(d=null==re?void 0:re.isLoading)&&void 0!==d&&d,open:!0,sectionTitle:(null==t?void 0:t.displayTitle)?null==t?void 0:t.title:"no title",refSectionTitle:(null==i?void 0:i.displayTitle)?null==i?void 0:i.title:"no title",cognitiveData:f,anchorEl:n,sectionAnchorEl:g,badgeStyle:l||null,sectionIdx:o,docData:{documents:null==Q?void 0:Q.documents,input_index_map:null==Q?void 0:Q.input_index_map},deviationData:function(){var n,r,l=(null==t?void 0:t.evaluationResult)||(null==i?void 0:i.evaluationResult)||null,c=function(n){var t=function(e){if(!e||"object"!=typeof e)return null;var n=null==e?void 0:e.deviation_entries;if(n&&"object"==typeof n){var t=Object.keys(n).sort(function(e,n){return Number(e)-Number(n)})[0];if(t&&n[t])return n[t]}var i=Object.keys(e).filter(function(e){return/^\d+$/.test(e)}).sort(function(e,n){return Number(e)-Number(n)});if(i.length&&e[i[0]])return e[i[0]];var o=null==e?void 0:e.deviations;if(o&&"object"==typeof o){var r=Object.keys(o).sort(function(e,n){return Number(e)-Number(n)})[0];if(r&&o[r])return o[r]}return null}(n);return t?e.__assign(e.__assign({},n),{deviation_summary:(null==n?void 0:n.deviation_summary)||(null==t?void 0:t.deviation_summary),deviation_title:(null==n?void 0:n.deviation_title)||(null==t?void 0:t.deviation_title),deviation_impact:(null==n?void 0:n.deviation_impact)||(null==t?void 0:t.deviation_impact),deviation_explanation:(null==n?void 0:n.deviation_explanation)||(null==t?void 0:t.deviation_explanation),evaluation_outputs:(null==n?void 0:n.evaluation_outputs)||(null==t?void 0:t.evaluation_outputs),cognitive_decisioning:(null==n?void 0:n.cognitive_decisioning)||(null==t?void 0:t.cognitive_decisioning)}):n};if(!("string"==typeof o&&o.includes(u.DEVIATION_BADGE_SEPARATOR)))return c(l);var a=o.split(u.DEVIATION_BADGE_SEPARATOR)[1];if(!a)return l;var s=(null==t?void 0:t.evaluationResult)||(null==i?void 0:i.evaluationResult)||{},d=(null===(n=null==s?void 0:s.deviation_entries)||void 0===n?void 0:n[a])||(null===(r=null==s?void 0:s.deviations)||void 0===r?void 0:r[a])||null;return d?e.__assign(e.__assign(e.__assign({},s),d),{deviation_summary:(null==d?void 0:d.deviation_summary)||(null==s?void 0:s.deviation_summary),deviation_title:(null==d?void 0:d.deviation_title)||(null==s?void 0:s.deviation_title),deviation_impact:(null==d?void 0:d.deviation_impact)||(null==s?void 0:s.deviation_impact),deviation_explanation:(null==d?void 0:d.deviation_explanation)||(null==s?void 0:s.deviation_explanation),evaluation_outputs:(null==d?void 0:d.evaluation_outputs)||(null==s?void 0:s.evaluation_outputs),cognitive_decisioning:(null==d?void 0:d.cognitive_decisioning)||(null==s?void 0:s.cognitive_decisioning)}):c(l)}(),isOrphan:!!r}},[Ze,Q]),At=t.useCallback(function(e){Dn(),Sn(null),_n(e)},[Dn]),Et=function(e,n,t,i,o,r){var l;if(e.stopPropagation(),mn.open&&mn.sectionIdx===o)Dn();else{var c=e.currentTarget,a="left";(null===(l=un.current)||void 0===l?void 0:l.contains(c))&&(a="right");Je.current&&pt(),Le(new Set),qe([]),Ue.current=[],Cn(),An.open?li():Tn(),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=et.current[l])||void 0===e?void 0:e.current:null===(n=Zn.current[l])||void 0===n?void 0:n.current}return"right"===a?null===(t=et.current[o])||void 0===t?void 0:t.current:null===(i=Zn.current[o])||void 0===i?void 0:i.current}()||c;Rn(bt(e,n,i,o,t,r))})}},Tt=t.useCallback(function(){null!==mn.sectionIdx&&mn.anchorEl?At(e.__assign(e.__assign({},mn),{open:!0})):Dn()},[mn,Dn,At]),It=t.useCallback(function(){var e=mn.sectionIdx,n=mn.isOrphan;Dn(),Tn(),null!==e&&(n?be("No counterpart exists to connect to."):(Je.current&&pt(),qe([]),Ue.current=[],Le(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){Qe.current&&Qe.current()},50)))},[mn.sectionIdx,mn.isOrphan,Dn,Tn,pt]),Bt=t.useRef(null),Ct=t.useRef(null),Dt=t.useRef(null),Ot=t.useRef(null),wt=t.useRef(null),Nt=t.useRef(null),jt=t.useState([]),Pt=jt[0],Ft=jt[1];t.useRef(null);var kt=t.useState(null),Mt=kt[0],Vt=kt[1];t.useEffect(function(){if(Nn){var e=On.fields.find(function(e){return e.analysisKey===Nn||e.key===Nn});if(e){var n=Xn.current[e.key]||Jn.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[Nn,On.fields]);var Lt=t.useCallback(function(e){var n,t,i,o,r,l,u,c,a,s=null===(n=null==ct?void 0:ct.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 f=d.mappings[0]||{};return{score:d.score,relation:f.relation||"",highlightsA:(null===(l=f.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(u=f.highlights)||void 0===u?void 0:u.ruleB_spans)||[],hasContent:!!v}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(c=d.highlights)||void 0===c?void 0:c.ruleA_spans)||[],highlightsB:(null===(a=d.highlights)||void 0===a?void 0:a.ruleB_spans)||[],hasContent:!!v}},[ct]),Gt=t.useCallback(function(n,t){var i,o,r;void 0===t&&(t="left");var l=null,c=null;if("left"===t)if(l=Gn[n],ve&&l){var s=Hn.filter(function(e){var n;return null===(n=l.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)});c=s.find(function(e){return e.evaluationResult})||s[0]}else c=Hn[n];else if(c=Hn[n],ve&&c){var d=Gn.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(c.selfIndex)});l=d.find(function(e){return e.evaluationResult})||d[0]}else l=Gn[n];var v=(null==l?void 0:l.relation)&&"not_defined"!==l.relation,f=(null==c?void 0:c.relation)&&"not_defined"!==c.relation,g=!(!(null==l?void 0:l.cognitiveData)&&!(null==c?void 0:c.cognitiveData));if(!v&&!f&&!g)return e.__assign(e.__assign({},u.generateColorPalette(a.DEFAULT_DEVIAION_COLOR)),{label:"Not Defined"});var p=null!==(o=null!==(i=null==l?void 0:l.evaluationResult)&&void 0!==i?i:null==c?void 0:c.evaluationResult)&&void 0!==o?o:null,h=u.getFirstDeviationOutputValue(p),x=u.getFirstDeviationColor(p);return null!=p?e.__assign(e.__assign({},u.generateColorPalette(x)),{label:null!==(r=h)&&void 0!==r?r:""}):e.__assign(e.__assign({},u.generateColorPalette(x)),{label:null})},[Gn,Hn,Ze,On,ve]),Ht=t.useCallback(function(n){for(var t,i,o,r,l,c=n.split("-").map(Number),s=Gn[c[0]],d=Hn[c[0]],v=1;v<c.length;v++)(null==s?void 0:s.subsections)&&(s=s.subsections[c[v]]),(null==d?void 0:d.subsections)&&(d=d.subsections[c[v]]);if(!s&&!d)return null;var f=(null==s?void 0:s.relation)&&"not_defined"!==s.relation,g=(null==d?void 0:d.relation)&&"not_defined"!==d.relation,p=u.safeStringify(null==s?void 0:s.id)||u.safeStringify(null==d?void 0:d.id)||"",h=!(!(null==s?void 0:s.cognitiveData)&&!(null==d?void 0:d.cognitiveData));if(!f&&!g&&!h)return e.__assign(e.__assign({},u.generateColorPalette(a.DEFAULT_DEVIAION_COLOR)),{label:"Not Defined"});null!==(i=null!==(t=null==s?void 0:s.cognitiveRelevanceScore)&&void 0!==t?t:null==d?void 0:d.cognitiveRelevanceScore)&&void 0!==i||p&&(null===(o=Ze[p])||void 0===o||o.relevance_score);var x=null!==(l=null!==(r=null==s?void 0:s.evaluationResult)&&void 0!==r?r:null==d?void 0:d.evaluationResult)&&void 0!==l?l:null,_=u.getFirstDeviationOutputValue(x),m=u.getFirstDeviationColor(x);return null!=x?e.__assign(e.__assign({},u.generateColorPalette(m)),{label:null!=_?_:""}):e.__assign(e.__assign({},u.generateColorPalette(m)),{label:null})},[Gn,Hn,Ze,On]),qt=t.useCallback(function(n,t){var i,o,r,l,c,s,d,v,f,g,p,h,x,_,m,R,y;if(!n||null==t)return null;var S=null!==(d=null!==(c=null!==(o=null===(i=null==ce?void 0:ce[n])||void 0===i?void 0:i.evaluation_result)&&void 0!==o?o:null===(l=null===(r=null==Q?void 0:Q.nodes)||void 0===r?void 0:r[n])||void 0===l?void 0:l.evaluation_result)&&void 0!==c?c:null===(s=null==Q?void 0:Q[n])||void 0===s?void 0:s.evaluation_result)&&void 0!==d?d:null;if(!S||"object"!=typeof S)return null;var b=null!==(p=null!==(f=null===(v=null==S?void 0:S.deviations)||void 0===v?void 0:v[t])&&void 0!==f?f:null===(g=null==S?void 0:S.deviation_entries)||void 0===g?void 0:g[t])&&void 0!==p?p:null==S?void 0:S[t],A=null!==(y=null!==(_=null===(x=null===(h=null==b?void 0:b.evaluation_outputs)||void 0===h?void 0:h.metadata)||void 0===x?void 0:x.label_color)&&void 0!==_?_:null===(R=null===(m=null==S?void 0:S.evaluation_outputs)||void 0===m?void 0:m.metadata)||void 0===R?void 0:R.label_color)&&void 0!==y?y:a.DEFAULT_DEVIAION_COLOR;return e.__assign(e.__assign({},u.generateColorPalette(A)),{label:null})},[ce,Q]),zt=t.useCallback(function(){mt({}),yt({}),pt(),Le(new Set),qe([]),Ue.current=[],Tn(),Cn(),Dn(),requestAnimationFrame(function(){Qe.current&&Qe.current()})},[mt,yt,pt,Tn,Cn,Dn]),Wt=t.useMemo(function(){return Object.values(_t).some(Boolean)||Object.values(Rt).some(Boolean)},[_t,Rt]),Yt=t.useCallback(function(){var e,n,t,i,o,r,l,c,a,s,d,v,f,g,p,h,x,_,m,R,y,S,b;if(!fn.current&&!We.current){fn.current=!0;try{if(!Bt.current)return;var A=function(e){var n=e.split("-"),t=n[0];if(!_t[t]&&!1===ve)return!1;if(ve&&!_t["left-".concat(t)]&&!_t["right-".concat(t)]&&!_t[t])return!1;for(var i=t,o=1;o<n.length-1;o++)if(i+="-".concat(n[o]),!Rt[i])return!1;return!0},E=Bt.current.getBoundingClientRect();tn({width:E.width,height:E.height});var T=[];if(qn.forEach(function(e){var n,t,i=e.key,o=null===(n=Xn.current[i])||void 0===n?void 0:n.current,r=null===(t=Jn.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")}),!We.current){for(var I=0;I<Math.max(Gn.length,Hn.length);I++){var B=null===(e=$n.current[I])||void 0===e?void 0:e.current,C=null===(n=Qn.current[I])||void 0===n?void 0:n.current;B&&(B.style.height="auto",B.style.minHeight="0px"),C&&(C.style.height="auto",C.style.minHeight="0px")}ve||Object.keys(tt.current).forEach(function(e){var n,t;if(A(e)){var i=null===(n=tt.current[e])||void 0===n?void 0:n.current,o=null===(t=it.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 D={};qn.forEach(function(e){var n,t,i=e.key,o=null===(n=Xn.current[i])||void 0===n?void 0:n.current,r=null===(t=Jn.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),u=r.getBoundingClientRect();D[i]=Math.max(l.height,u.height)}});var O={left:{},right:{}},w={};if(!We.current)if(ve){if(Ee&&null!==Pe)if("number"==typeof Pe){var N=Pe,j=Gn[N],P=null===(o=$n.current[N])||void 0===o?void 0:o.current;P&&j&&(j.refIndexes||[]).forEach(function(e){var n,t=Hn.findIndex(function(n){return n.selfIndex===e}),i=null===(n=Qn.current[t])||void 0===n?void 0:n.current;if(i&&(_t["left-".concat(N)]||_t["right-".concat(t)])){var o=Math.max(P.getBoundingClientRect().height,i.getBoundingClientRect().height);O.left[N]=Math.max(O.left[N]||0,o),O.right[t]=Math.max(O.right[t]||0,o)}})}else{var F=Pe.split(u.DEVIATION_BADGE_SEPARATOR)[2];if(F){B=null===(r=tt.current[F])||void 0===r?void 0:r.current,C=null===(l=it.current[F])||void 0===l?void 0:l.current;if(B&&C){k=Math.max(B.getBoundingClientRect().height,C.getBoundingClientRect().height);w[F]=Math.max(w[F]||0,k)}}}}else{Object.keys(tt.current).forEach(function(e){var n,t;if(A(e)){var i=null===(n=tt.current[e])||void 0===n?void 0:n.current,o=null===(t=it.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);w[e]=u,i.style.minHeight="".concat(u,"px"),o.style.minHeight="".concat(u,"px")}}});for(I=0;I<Math.min(Gn.length,Hn.length);I++){var B=null===(t=$n.current[I])||void 0===t?void 0:t.current,C=null===(i=Qn.current[I])||void 0===i?void 0:i.current;if(B&&C){var k=Math.max(B.getBoundingClientRect().height,C.getBoundingClientRect().height);O.left[I]=k,O.right[I]=k}}}if(qn.forEach(function(e){var n,t,i=e.key,o=null===(n=Xn.current[i])||void 0===n?void 0:n.current,r=null===(t=Jn.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=D[i];o.style.minHeight="".concat(l,"px"),r.style.minHeight="".concat(l,"px")}}),We.current||(Object.entries(O.left).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=$n.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),Object.entries(O.right).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=Qn.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),ve||Object.keys(w).forEach(function(e){var n,t,i=null===(n=tt.current[e])||void 0===n?void 0:n.current,o=null===(t=it.current[e])||void 0===t?void 0:t.current;if(i&&o&&w[e]){var r=w[e];i.style.minHeight="".concat(r,"px"),o.style.minHeight="".concat(r,"px")}})),ve)Gn.forEach(function(e,n){var t;(null===(t=$n.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=Hn.findIndex(function(n){return n.selfIndex===e});if(-1!==v){var f=null===(t=Zn.current[n])||void 0===t?void 0:t.current,g=null===(i=et.current[v])||void 0===i?void 0:i.current;if(f&&g){var p=f.getBoundingClientRect(),h=g.getBoundingClientRect(),x=p.right-E.left,_=h.left-E.left,m=p.top+p.height/2-E.top,R=h.top+h.height/2-E.top;if(Ee&&Pe===n){var y=null!==(r=null===(o=vn.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==r?r:0,S=null!==(u=null===(l=un.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==u?u:0,b=y+(null!==(a=null===(c=vn.current)||void 0===c?void 0:c.clientHeight)&&void 0!==a?a:1/0),A=S+(null!==(d=null===(s=un.current)||void 0===s?void 0:s.clientHeight)&&void 0!==d?d:1/0),I=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(I,y,b)-E.top,R=C(B,S,A)-E.top}var D=Gt(n);D&&T.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(Gn.length,Hn.length);I++){var M=null===(c=$n.current[I])||void 0===c?void 0:c.current,V=null===(a=Qn.current[I])||void 0===a?void 0:a.current;if(M&&V){var L=M.getBoundingClientRect(),G=V.getBoundingClientRect(),H=Math.max(L.top,G.top)+18-E.top,q=(null===(s=Hn[I])||void 0===s?void 0:s.id)||"sec-".concat(I);($=Gt(I))&&T.push({id:q,x1:L.right-E.left,y1:H,x2:G.left-E.left,y2:H,style:$,sectionIdx:I,hasCognitive:!!((null===(d=Gn[I])||void 0===d?void 0:d.cognitiveData)||(null===(v=Hn[I])||void 0===v?void 0:v.cognitiveData)||q&&Ze[q]),isSubSection:!1})}}Object.keys(tt.current).forEach(function(e){var n,t,i,o,r,l;if(A(e)){var c=null===(n=tt.current[e])||void 0===n?void 0:n.current,a=null===(t=it.current[e])||void 0===t?void 0:t.current;if(c&&a){for(var s=e.split("-").map(Number),d=Gn[s[0]],v=Hn[s[0]],f=1;f<s.length;f++)(null==d?void 0:d.subsections)&&(d=d.subsections[s[f]]),(null==v?void 0:v.subsections)&&(v=v.subsections[s[f]]);var g=!!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(g&&p||h&&x){var _=c.getBoundingClientRect(),m=a.getBoundingClientRect(),R=Math.max(_.top,m.top)+16-E.top,y=Ht(e);y&&"Not Defined"!==y.label&&T.push({id:"subsec-".concat(e),x1:_.right-E.left,y1:R,x2:m.left-E.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(Ee&&"string"==typeof Pe&&Pe.includes(u.DEVIATION_BADGE_SEPARATOR)){var z=Pe.split(u.DEVIATION_BADGE_SEPARATOR),W=z[0],Y=z[1],K=z[2],U=(z[3],"".concat(W).concat(u.DEVIATION_BADGE_SEPARATOR).concat(Y)),X=null===(f=Zn.current[U])||void 0===f?void 0:f.current,J=null===(g=et.current[U])||void 0===g?void 0:g.current;if(X&&J){var $,Q=X.getBoundingClientRect(),Z=J.getBoundingClientRect(),ee=Q.right-E.left,ne=Z.left-E.left,te=Q.top+Q.height/2-E.top,ie=Z.top+Z.height/2-E.top;if(ve){var oe=null!==(h=null===(p=vn.current)||void 0===p?void 0:p.getBoundingClientRect().top)&&void 0!==h?h:0,re=null!==(_=null===(x=un.current)||void 0===x?void 0:x.getBoundingClientRect().top)&&void 0!==_?_:0,le=oe+(null!==(R=null===(m=vn.current)||void 0===m?void 0:m.clientHeight)&&void 0!==R?R:1/0),ue=re+(null!==(S=null===(y=un.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)-E.top,ie=ce(Z.top+Z.height/2,re,ue)-E.top}($=null!==(b=qt(W,Y))&&void 0!==b?b:Ht(K))&&T.push({id:"line-subsec-".concat(U),x1:ee,y1:te,x2:ne,y2:ie,style:$,sectionIdx:Number(K.split("-")[0]),isSubSection:!0,subSectionKeyPath:Pe})}}if(Ft(T),wt.current&&Nt.current){var ae=wt.current.getBoundingClientRect(),se=Nt.current.getBoundingClientRect(),de=(ae.top+ae.height/2-E.top+se.top+se.height/2-E.top)/2;Vt({x1:ae.right-E.left,x2:se.left-E.left,y:de})}else Vt(null);if(Ve.size>0){var fe=[],ge=vn.current,pe=un.current;if(ge&&pe){var he=[],xe=ge.getBoundingClientRect().top,_e=pe.getBoundingClientRect().top,me=xe+ge.clientHeight,Re=_e+pe.clientHeight,ye=ge.scrollTop,Se=pe.scrollTop,be=E.top,Ae=function(e,n,t){return Math.max(n,Math.min(t,e))};Ve.forEach(function(e){var n,t,i,o,r,l;if("string"==typeof e&&e.includes(u.DEVIATION_BADGE_SEPARATOR)){var c=e.split(u.DEVIATION_BADGE_SEPARATOR),a=c[0],s=c[1],d=c[2],v=(c[3],"".concat(a).concat(u.DEVIATION_BADGE_SEPARATOR).concat(s)),f=null===(n=Zn.current[v])||void 0===n?void 0:n.current,g=null===(t=et.current[v])||void 0===t?void 0:t.current;if(!f||!g)return;var p=f.getBoundingClientRect(),h=g.getBoundingClientRect(),x=null!==(i=qt(a,s))&&void 0!==i?i:Ht(d),_=(P=p.right-E.left)+.5*((F=h.left-E.left-0)-P),m=p.top+p.height/2,R=h.top+h.height/2,y=m-xe+ye,S=R-_e+Se,b="conn-subsec-".concat(v);he.push({lhsScrollY:y,rhsScrollY:S,x1:P,x2:F,containerTop:be,leftIdx:e,rhsArrayIdx:e,styleColor:(null==x?void 0:x.badgeBorder)||"#6366F1",styleId:b});var A=Ae(m,xe,me),T=Ae(R,_e,Re),I=A-be,B=T-be,C=R>=_e-4&&R<=Re+4,D="";D=(k=m>=xe-4&&m<=me+4)&&C?u.getBentArrowPath(P,I,F,B):k&&!C?"M ".concat(P,",").concat(I," L ").concat(_,",").concat(I," L ").concat(_,",").concat(B):!k&&C?"M ".concat(_,",").concat(I," L ").concat(_,",").concat(B," L ").concat(F,",").concat(B):"M ".concat(_,",").concat(I," L ").concat(_,",").concat(B),fe.push({id:b,pathD:D,style:x,leftIdx:e,rhsArrayIdx:e})}else if(ve){var O=e,w=Gn[O];if(!(null===(l=null==w?void 0:w.refIndexes)||void 0===l?void 0:l.length))return;w.refIndexes.forEach(function(e){var n,t,i=Hn.findIndex(function(n){return n.selfIndex===e});if(-1!==i){var o=null===(n=Zn.current[O])||void 0===n?void 0:n.current,r=null===(t=et.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),c=r.getBoundingClientRect(),a=Gt(O),s=l.right-E.left,d=c.left-E.left-0,v=s+.5*(d-s),f=l.top+l.height/2,g=c.top+c.height/2,p=f-xe+ye,h=g-_e+Se,x="conn-".concat(O,"-").concat(i);he.push({lhsScrollY:p,rhsScrollY:h,x1:s,x2:d,containerTop:be,leftIdx:O,rhsArrayIdx:i,styleColor:(null==a?void 0:a.badgeBorder)||"#6366F1",styleId:x});var _=Ae(f,xe,me),m=Ae(g,_e,Re),R=_-be,y=m-be,S=f>=xe-4&&f<=me+4,b=g>=_e-4&&g<=Re+4,A="";A=S&&b?u.getBentArrowPath(s,R,d,y):S&&!b?"M ".concat(s,",").concat(R," L ").concat(v,",").concat(R," L ").concat(v,",").concat(y):!S&&b?"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),fe.push({id:x,pathD:A,style:a,leftIdx:O,rhsArrayIdx:i})}}})}else{var N=e,j=N;f=null===(o=Zn.current[N])||void 0===o?void 0:o.current,g=null===(r=et.current[j])||void 0===r?void 0:r.current;if(!f||!g)return;var P,F;p=f.getBoundingClientRect(),h=g.getBoundingClientRect(),x=Gt(N),_=(P=p.right-E.left)+.5*((F=h.left-E.left-0)-P),m=p.top+p.height/2,R=h.top+h.height/2,y=m-xe+ye,S=R-_e+Se,b="conn-".concat(N,"-").concat(j);he.push({lhsScrollY:y,rhsScrollY:S,x1:P,x2:F,containerTop:be,leftIdx:N,rhsArrayIdx:j,styleColor:(null==x?void 0:x.badgeBorder)||"#6366F1",styleId:b});var k;A=Ae(m,xe,me),T=Ae(R,_e,Re),I=A-be,B=T-be,C=R>=_e-4&&R<=Re+4,D="";D=(k=m>=xe-4&&m<=me+4)&&C?u.getBentArrowPath(P,I,F,B):k&&!C?"M ".concat(P,",").concat(I," L ").concat(_,",").concat(I," L ").concat(_,",").concat(B):!k&&C?"M ".concat(_,",").concat(I," L ").concat(_,",").concat(B," L ").concat(F,",").concat(B):"M ".concat(_,",").concat(I," L ").concat(_,",").concat(B),fe.push({id:b,pathD:D,style:x,leftIdx:N,rhsArrayIdx:j})}}),Ue.current=he}qe(fe)}else qe([]),Ue.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{fn.current=!1}}},[qn,Gn,Hn,Ze,On,Lt,Gt,qt,ve,Ee,Pe,Ve,_t,Rt]),Kt=t.useCallback(function(){var e,n,t,i,o,r,l,c,a,s,d,v,f,g,p=Ue.current;if(p.length&&!We.current){var h=null!==(n=null===(e=vn.current)||void 0===e?void 0:e.scrollTop)&&void 0!==n?n:0,x=null!==(i=null===(t=un.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,_=null!==(r=null===(o=vn.current)||void 0===o?void 0:o.clientHeight)&&void 0!==r?r:1/0,m=null!==(c=null===(l=un.current)||void 0===l?void 0:l.clientHeight)&&void 0!==c?c:1/0,R=null!==(s=null===(a=vn.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==s?s:0,y=null!==(v=null===(d=un.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==v?v:0,S=R+_,b=y+m,A=null!==(g=null===(f=Bt.current)||void 0===f?void 0:f.getBoundingClientRect().top)&&void 0!==g?g: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=Ke.current[e.styleId+"-stroke"],o=Ke.current[e.styleId+"-bg"];if(i||o){var r,l=E(n,R,S),c=E(t,y,b),a=l-A,s=c-A,d=n>=R-4&&n<=S+4,v=t>=y-4&&t<=b+4,f=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(f,",").concat(a," L ").concat(f,",").concat(s):!d&&v?"M ".concat(f,",").concat(a," L ").concat(f,",").concat(s," L ").concat(e.x2,",").concat(s):"M ".concat(f,",").concat(a," L ").concat(f,",").concat(s),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",r)),o&&(o.setAttribute("visibility","visible"),o.setAttribute("d",r))}})}},[]);t.useEffect(function(){Qe.current=Yt},[Yt]);var Ut=t.useRef(null),Xt=t.useRef(null),Jt=t.useCallback(function(){Ue.current.length>0&&!We.current||(null!==Ut.current&&clearTimeout(Ut.current),Ut.current=setTimeout(function(){Qe.current(),Ut.current=null},50))},[]),$t=t.useCallback(function(){Ne(!0),De(!1),null!==Xt.current&&clearTimeout(Xt.current),null!==Ut.current&&(clearTimeout(Ut.current),Ut.current=null),Xt.current=setTimeout(function(){var e,n,t,i,o,r,l,c,a,s;if(Ue.current=[],Je.current&&null!==$e.current&&null!==Dt.current){var d=$e.current,v=Dt.current,f=null,g=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]);f=(null===(e=Zn.current[_])||void 0===e?void 0:e.current)||null,g=(null===(n=et.current[_])||void 0===n?void 0:n.current)||null,p=(null===(t=tt.current[x[2]])||void 0===t?void 0:t.current)||(null===(i=$n.current[Number(x[2])])||void 0===i?void 0:i.current)||null,h=(null===(o=it.current[x[3]])||void 0===o?void 0:o.current)||(null===(r=Qn.current[Number(x[3])])||void 0===r?void 0:r.current)||null}else f=(null===(l=ot.current[d])||void 0===l?void 0:l.current)||null,p=(null===(c=$n.current[d])||void 0===c?void 0:c.current)||null,g=(null===(a=nt.current[v])||void 0===a?void 0:a.current)||null,h=(null===(s=Qn.current[v])||void 0===s?void 0:s.current)||null;if(f&&g&&p&&h){if(p.style.paddingTop="0px",h.style.paddingTop="0px",!ve){var m=f.getBoundingClientRect(),R=g.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=vn.current,b=un.current;if(S&&b){var A=f.getBoundingClientRect().top-S.getBoundingClientRect().top+S.scrollTop,E=g.getBoundingClientRect().top-b.getBoundingClientRect().top+b.scrollTop-(A-S.scrollTop);Math.abs(b.scrollTop-E)>1&&(b.scrollTop=E)}}}Qe.current(),Je.current&&De(!0),Ne(!1),Xt.current=null},150)},[ve,Gn,Hn]),Qt=t.useCallback(function(e){var n,t,i,o,r,l,c,a,s,d;if(null!==gn.current&&pn.current&&Math.abs(e.currentTarget.scrollTop-gn.current)<=2){var v=pn.current;gn.current=null,pn.current=null,v()}if(!ke.current){if(ve||Jt(),Je.current){var f=$e.current,g=Dt.current,p=vn.current,h=un.current;if(null!==f&&null!==g&&p&&h){var x="string"==typeof f&&f.includes(u.DEVIATION_BADGE_SEPARATOR)?null===(n=Zn.current["".concat(f.split(u.DEVIATION_BADGE_SEPARATOR)[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(f.split(u.DEVIATION_BADGE_SEPARATOR)[1])])||void 0===n?void 0:n.current:null===(t=ot.current[f])||void 0===t?void 0:t.current,_="string"==typeof g&&g.includes(u.DEVIATION_BADGE_SEPARATOR)?null===(i=et.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=nt.current[g])||void 0===o?void 0:o.current;if(x&&_&&Ot.current){var m=void 0,R=void 0;if("string"==typeof f&&f.includes(u.DEVIATION_BADGE_SEPARATOR)){var y=f.split(u.DEVIATION_BADGE_SEPARATOR),S="".concat(y[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(y[1]);m=null===(r=Zn.current[S])||void 0===r?void 0:r.current,R=null===(l=et.current[S])||void 0===l?void 0:l.current}else m=null===(c=Zn.current[f])||void 0===c?void 0:c.current,R=null===(a=et.current[g])||void 0===a?void 0:a.current;var b=null!==(d=null===(s=Bt.current)||void 0===s?void 0:s.getBoundingClientRect().top)&&void 0!==d?d:0,A=p.getBoundingClientRect().top,E=A+p.clientHeight;h.getBoundingClientRect().top;h.clientHeight;if(m&&R){var T=m.getBoundingClientRect(),I=R.getBoundingClientRect(),B=T.top+T.height/2;I.top,I.height;var C=((O=B,w=A,N=E,Math.max(w,Math.min(N,O)))-b).toString();Ot.current.setAttribute("y1",C),Ot.current.setAttribute("y2",C);var D=B>=A-4&&B<=E+4;Ot.current.setAttribute("visibility",D?"visible":"hidden")}}}}var O,w,N;Ue.current.length>0&&!Xe.current&&(Xe.current=!0,requestAnimationFrame(function(){Kt(),Xe.current=!1}))}},[Kt,ve,Jt]),Zt=t.useRef(0),ei=t.useRef(0),ni=t.useRef(0),ti=t.useRef(function(){});t.useRef(null),t.useEffect(function(){ti.current=$t},[$t]),t.useEffect(function(){var e=setTimeout(Jt,250),n=function(){return ti.current()};return window.addEventListener("resize",n),function(){clearTimeout(e),null!==Ut.current&&clearTimeout(Ut.current),null!==Xt.current&&clearTimeout(Xt.current),window.removeEventListener("resize",n)}},[Vn,Ln,ct,qn,_t,Rt,Gn,Hn,On,Jt,Ee,Pe,Ce,Ve]),t.useEffect(function(){var e=function(e,n,t,i,o){n.current=e.getBoundingClientRect().width;var r=new ResizeObserver(function(e){null!==t.current&&cancelAnimationFrame(t.current),t.current=requestAnimationFrame(function(){var r,l,u;t.current=null;var c=e[e.length-1];if(c){var a=null!==(u=null===(l=null===(r=c.borderBoxSize)||void 0===r?void 0:r[0])||void 0===l?void 0:l.inlineSize)&&void 0!==u?u:c.contentRect.width;Math.abs(a-n.current)<1?o():(n.current=a,i())}})});return r.observe(e),r},n={current:null},t={current:null},i={current:null},o=[],r=[n,t,i];return ln.current&&o.push(e(ln.current,Zt,n,function(){return ti.current()},function(){})),rn.current&&o.push(e(rn.current,ei,t,function(){return ti.current()},function(){return Qe.current()})),Bt.current&&o.push(e(Bt.current,ni,i,function(){return ti.current()},function(){return Qe.current()})),function(){o.forEach(function(e){return e.disconnect()}),r.forEach(function(e){null!==e.current&&(cancelAnimationFrame(e.current),e.current=null)})}},[]),t.useEffect(function(){Je.current=Ee},[Ee]),t.useEffect(function(){$e.current=Pe},[Pe]);var ii=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";Dn(),null!=e&&(n?be("No counterpart exists for this section."):Ee&&Pe===e?r?pt():null==l||l():(Le(new Set([e])),qe([]),Ue.current=[],Re(!0),ke.current=!0,Fe(e),$e.current=e,Te(!0),Je.current=!0,De(!1),cn.current&&(cn.current.style.height="0px"),an.current&&(an.current.style.height="0px"),sn.current&&(sn.current.style.height="0px"),dn.current&&(dn.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 f=e.split(u.DEVIATION_BADGE_SEPARATOR),g="".concat(f[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(f[1]);s=(null===(n=Zn.current[g])||void 0===n?void 0:n.current)||null,d=(null===(t=et.current[g])||void 0===t?void 0:t.current)||null,v=d?e:null}else if(s=(null===(i=ot.current[e])||void 0===i?void 0:i.current)||null,ve){var p=Gn[e],h=(null==p?void 0:p.refIndexes)||[];if(h.length>0){var x=h[0],_=Hn.findIndex(function(e){return e.selfIndex===x});-1!==_&&(d=(null===(r=nt.current[_])||void 0===r?void 0:r.current)||null,v=_)}}else d=(null===(o=nt.current[e])||void 0===o?void 0:o.current)||null,v=d?e:null;Dt.current=v;var m=vn.current,R=un.current,y=function(){!function(){var n,t,i,o,r,l,c,s,d,f,g,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=tt.current[R[2]])||void 0===n?void 0:n.current)||(null===(t=$n.current[Number(R[2])])||void 0===t?void 0:t.current)||null,x=(null===(i=it.current[R[3]])||void 0===i?void 0:i.current)||(null===(o=Qn.current[Number(R[3])])||void 0===o?void 0:o.current)||null,_=(null===(r=Zn.current[y])||void 0===r?void 0:r.current)||h,m=(null===(l=et.current[y])||void 0===l?void 0:l.current)||x}else{var S=Number(e),b=null!==v?Number(v):S;h=(null===(c=$n.current[S])||void 0===c?void 0:c.current)||null,x=(null===(s=Qn.current[b])||void 0===s?void 0:s.current)||null,_=(null===(d=Zn.current[S])||void 0===d?void 0:d.current)||(null===(f=ot.current[S])||void 0===f?void 0:f.current)||h,m=(null===(g=et.current[b])||void 0===g?void 0:g.current)||(null===(p=nt.current[b])||void 0===p?void 0:p.current)||x}if(_&&m&&h&&x){h.style.paddingTop="0px",x.style.paddingTop="0px";var A=_.getBoundingClientRect(),E=m.getBoundingClientRect(),T=A.top-E.top;T>0?x.style.paddingTop="".concat(T,"px"):T<0&&(h.style.paddingTop="".concat(Math.abs(T),"px"))}}(),De(!0),Qe.current&&Qe.current(),ke.current=!1,"right"===c&&R?R.dispatchEvent(new Event("scroll")):m&&m.dispatchEvent(new Event("scroll")),Re(!1),null==l||l()};if(!s||!m)return ke.current=!1,Re(!1),void(null==l||l());if(d&&R){if(!ve){var S=0;S="right"===c?d?d.getBoundingClientRect().top:0:s?s.getBoundingClientRect().top:0;var b=rn.current,A=(null==b?void 0:b.getBoundingClientRect().top)||0,E=b?b.scrollTop+S-A-150:0;return b?void u.smoothScrollTo(b,E,200,y):void y()}var T=s.getBoundingClientRect().top-m.getBoundingClientRect().top+m.scrollTop,I=d.getBoundingClientRect().top-R.getBoundingClientRect().top+R.scrollTop,B=200;if("left"===c){var C=I-(T-m.scrollTop);C<0&&cn.current&&(cn.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 an.current&&(an.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=T-(I-R.scrollTop);D<0&&sn.current&&(sn.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 dn.current&&(dn.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()})))},[Pe,Dn,Hn,Ee,ve,Gn,pt]),oi=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;Cn();var c="left";(null===(o=un.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=et.current[l])||void 0===e?void 0:e.current:null===(t=Zn.current[l])||void 0===t?void 0:t.current}return"right"===c?null===(i=et.current[n])||void 0===i?void 0:i.current:null===(o=Zn.current[n])||void 0===o?void 0:o.current};if(t)return pt(),Le(new Set),qe([]),Ue.current=[],void(r&&requestAnimationFrame(function(){var e=a()||l;En({open:!0,anchorEl:e,summary:i})}));ii(n,t,r?{toggleIfSame:!1,sourceSide:c,onReady:function(){var e=a()||l;En({open:!0,anchorEl:e,summary:i})}}:{toggleIfSame:!1,sourceSide:c})},[ii,Cn,En,pt]),ri=t.useCallback(function(){var e,n=mn.sectionIdx,t=mn.isOrphan;if(Tn(),null!=n){var i="left";mn.anchorEl&&(null===(e=un.current)||void 0===e?void 0:e.contains(mn.anchorEl))&&(i="right"),ii(n,t,{sourceSide:i})}},[ii,mn.isOrphan,mn.sectionIdx,mn.anchorEl,Tn]),li=t.useCallback(function(){Tn(),pt(),Le(new Set),qe([]),Ue.current=[]},[Tn,pt]),ui=null!==mn.sectionIdx&&Ve.has(mn.sectionIdx),ci=_.useDeviationNavigation({proposedSections:Gn,existingSections:Hn,parentDeviationRecord:zn,expandedSections:_t,maintainRelativeOrder:!!ve,scrollContainerRef:rn,leftContainerRef:vn,lhsBadgeRefs:Zn,rhsBadgeRefs:et}),ai=ci.showDeviationNavigation,si=ci.showOpenNodeRef,di=t.useMemo(function(){if(!ae)return null;var e=ae.id.split(":")[0];for(var n in zn){if((zn[n]||[]).some(function(n){return n.id===e}))return n}return null},[ae,zn]),vi=t.useRef({id:null,triggerMs:null}),fi=t.useRef(null);t.useEffect(function(){if(null==ae?void 0:ae.id){var n=Number(ae.trigger),t=vi.current;if(!(t.id===ae.id&&null!=t.triggerMs&&n-t.triggerMs<=1e3)){vi.current={id:ae.id,triggerMs:n};var i=ae.id.split(":"),o=i[0],r=i[1],l=null!=r?r:"0";fi.current!==ae.id&&(Tn(),Cn(),pt(),Le(new Set),qe([]),Ue.current=[],fi.current=ae.id);var c=!1,a=0,s=null,d=150,v=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},f=function(){var n,t,i,r;if(!c){var g=null,p=null;for(var h in zn){var x=zn[h].find(function(e){return e.id===o});if(x){g=h,p=x;break}}if(p&&g){var _=Gn.findIndex(function(e){return e.id===g}),m=Hn.findIndex(function(e){return e.id===g}),R=-1===_&&-1!==m,y=v(Gn,p.id),S=v(Hn,p.id);if(y&&!S&&!R){var b=y.split("-"),A=Number(b[0]);if(ve){var E=null===(t=null===(n=Gn[A])||void 0===n?void 0:n.refIndexes)||void 0===t?void 0:t[0],T=Hn.findIndex(function(e){return e.selfIndex===E});-1!==T&&(A=T)}S=e.__spreadArray([A],b.slice(1),!0).join("-")}if(y||S){var I=R||!y&&!!S,B=y?Number(y.split("-")[0]):_,C=S?Number(S.split("-")[0]):m;if(I){if(!(ve?!!_t["right-".concat(C)]:!!_t[String(C)])&&C>=0)return St(C,"right"),a+=1,void(s=setTimeout(f,450))}else if(!(ve?!!_t["left-".concat(B)]:!!_t[String(B)])&&B>=0)return St(B,"left"),a+=1,void(s=setTimeout(f,450));var D,O=y||"",w=S||"",N="".concat(p.id).concat(u.DEVIATION_BADGE_SEPARATOR).concat(l).concat(u.DEVIATION_BADGE_SEPARATOR).concat(O).concat(u.DEVIATION_BADGE_SEPARATOR).concat(w),j="".concat(p.id).concat(u.DEVIATION_BADGE_SEPARATOR).concat(l),P=null===(i=Zn.current[j])||void 0===i?void 0:i.current,F=null===(r=et.current[j])||void 0===r?void 0:r.current,k=I||!P&&!!F,M=k?F:P;if(D=ve?k?un.current:vn.current:rn.current,M&&D){var V=M.getBoundingClientRect();if(0===V.height)return void((a+=1)<20&&(s=setTimeout(f,d)));var L=D.getBoundingClientRect(),G=V.top-L.top+D.scrollTop-L.height/2+V.height/2,H=function(){var n,t,i,o,r;if(!c){var u=window.getComputedStyle(M).color;P&&(P.style.transition="box-shadow 300ms ease-in-out",P.style.boxShadow="0 0 10px ".concat(u)),F&&(F.style.transition="box-shadow 300ms ease-in-out",F.style.boxShadow="0 0 10px ".concat(u)),setTimeout(function(){P&&(P.style.boxShadow=""),F&&(F.style.boxShadow="")},2e3);var a=(null===(t=null===(n=p.evaluationResult)||void 0===n?void 0:n.deviations)||void 0===t?void 0:t[l])||p,s=(null===(i=p.evaluationResult)||void 0===i?void 0:i.evaluation_outputs)||p.evaluation_outputs;if(!(!!P&&!!F)){var d=k?(null===(o=et.current[j])||void 0===o?void 0:o.current)||F:(null===(r=Zn.current[j])||void 0===r?void 0:r.current)||P;return En({open:!0,anchorEl:d,summary:e.__assign(e.__assign({},a),{evaluation_outputs:s})}),void(null==se||se())}ii(N,!1,{toggleIfSame:!1,sourceSide:"left",onReady:function(){var n,t=(null===(n=Zn.current[j])||void 0===n?void 0:n.current)||P;En({open:!0,anchorEl:t,summary:e.__assign(e.__assign({},a),{evaluation_outputs:s})})}})}};Math.abs(D.scrollTop-G)<=2?H():(gn.current=G,pn.current=H,D.scrollTo({top:G,behavior:"smooth"}),s&&clearTimeout(s),s=setTimeout(function(){if(pn.current){gn.current=null;var e=pn.current;pn.current=null,e()}},800))}else(a+=1)<20&&(s=setTimeout(f,d))}else(a+=1)<20&&(s=setTimeout(f,d))}else(a+=1)<20&&(s=setTimeout(f,d))}};return s=setTimeout(f,d),function(){c=!0,s&&clearTimeout(s)}}}},[ae,zn,Gn,Hn,ve,_t,St,ii,En]);var gi=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:Rt,setExpandedSubSections:yt,maintainRelativeOrder:ve||!1,proposedSections:Gn,existingSections:Hn,treeData:Q,deviationNumberRegistry:Wn,connectedSections:Ve,activeSideBySideSection:Pe,resolvedMarkdownStyles:on,getSubSectionRef:lt,getSubSectionCompareStyle:Ht,getBadgeRef:ut,openMoreFunctionsPopup:Et,openSummaryPopup:oi,showDeviationBadges:ge,resetSideBySide:pt,setConnectedSections:Le,setConnectedLines:qe,cachedConnectedPositions:Ue})};return n.jsxs(i.Box,e.__assign({ref:ln,sx:e.__assign(e.__assign({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},ve?{}:{overflow:"visible"}),{position:"relative"})},{children:[he&&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:Ct.current,clipTopEl:wt.current,scrollContainerEl:rn.current,onClose:li,summary:An.summary}),n.jsx(d.default,{open:mn.open,anchorEl:mn.anchorEl,sectionTitle:mn.sectionTitle,referenceSectionTitle:mn.refSectionTitle,onClose:Dn,onOpenCognitiveCompare:Tt,onOpenSideBySide:ri,onConnect:It,isConnected:ui,isOrphan:mn.isOrphan}),xn.open&&n.jsx(s.default,{open:xn.open,popupRef:Bn,position:yn,popupConfig:le,onClose:function(){Sn(null),_n(function(n){return e.__assign(e.__assign({},n),{open:!1})}),In(null)},markdownStyles:te,sectionTitle:xn.sectionTitle,referenceSectionTitle:xn.refSectionTitle,cognitiveData:xn.cognitiveData,anchorEl:xn.anchorEl,sectionAnchorEl:xn.sectionAnchorEl,scrollContainerEl:rn.current,badgeStyle:xn.badgeStyle,docData:xn.docData,deviationData:xn.deviationData,isLoading:xn.isLoading}),n.jsx(i.Snackbar,e.__assign({open:!!Se,autoHideDuration:8e3,onClose:function(){return be(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(i.Alert,e.__assign({onClose:function(){return be(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:Se}))})),n.jsx(m.default,{componentHeaderText:$,displayConfig:re,maintainRelativeOrder:ve,onCollapseAll:zt,showCollapseAll:Wt,onToggleView:function(e){xe(!0),setTimeout(function(){fe(!e),pt(),Tn(),Le(new Set),qe([]),Ue.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){xe(!1)},600)})})},50)}}),n.jsx(i.Box,e.__assign({ref:rn,onScroll:Qt,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:ve?"hidden":"auto",borderTop:at&&st?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(i.Box,e.__assign({sx:e.__assign({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},ve?{flex:1,minHeight:0}:{})},{children:n.jsxs(i.Box,e.__assign({ref:Bt,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"40px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},ve?{flex:1,overflow:"visible"}:{})},{children:[n.jsxs("svg",e.__assign({ref:ze,style:{position:"absolute",top:0,left:0,width:nn.width||"100%",height:nn.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",opacity:we?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:gt.badgeBorder,strokeWidth:"1.5"})}),Pt.map(function(t){var l,c,s,d,v,g,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?Ee&&Pe===t.subSectionKeyPath&&Ce:Ee&&Pe===t.sectionIdx&&Ce)return null;if(!ve){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),_=Gn[t.sectionIdx]||{title:"",content:""},m=Hn[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,b=y.split("-").map(Number),A=S.split("-").map(Number),E=null,T=null;b.length>0&&(E=Gn[b[0]]),A.length>0&&(T=Hn[A[0]]);var I=(null==E?void 0:E.title)||"",B=(null==T?void 0:T.title)||"";console.log("Root Parent Titles:",I,B);for(var C=1;C<b.length;C++)(null==E?void 0:E.subsections)&&(E=E.subsections[b[C]]);for(C=1;C<A.length;C++)(null==T?void 0:T.subsections)&&(T=T.subsections[A[C]]);E&&(_=e.__assign(e.__assign({},E),{title:I||E.title})),console.log("Base Section for Subsection Badge:",_),T&&(m=e.__assign(e.__assign({},T),{title:B||T.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===(g=null===(v=null===(d=_.evaluationResult)||void 0===d?void 0:d.cognitive_decisioning)||void 0===v?void 0:v.decisioning_factors)||void 0===g?void 0:g.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&&(xn.open&&bn===t.id?Cn():(In(t.id),At(bt(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(f.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:xn.open&&bn===t.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},t.id)}return null}),He.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){Ke.current[u]=e},d:o,fill:"none",stroke:"#FFFFFF",strokeWidth:"4",strokeOpacity:"0.7"}),n.jsx("path",{ref:function(e){Ke.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)"},ve?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(i.Box,e.__assign({ref:wt,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:Fn,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:Fn}))}))})),n.jsxs(i.Box,e.__assign({ref:vn,onScroll:Qt,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},ve?{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:sn,style:{width:"100%",height:"0px",flexShrink:0}}),Kn&&Gn.map(function(t,r){var l,c,a=!t.title&&!t.content;if(ve&&a)return null;var s=t,d=Gt(r,"left"),v=ve?!(null===(l=s.refIndexes)||void 0===l?void 0:l.length)||s.selfIndex<0:!Hn[r],g=ve?"number"==typeof s.selfIndex&&s.selfIndex>=0?s.selfIndex+1:null:r+1,p=Ve.has(r),h=u.extractDeviationScore(s.evaluationResult,null==d?void 0:d.deviationLabel);return n.jsx(i.Box,e.__assign({ref:rt(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:$n.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:rt("left-accordion-".concat(r)),mb:0,treeData:Q,proposedSections:Gn,existingSections:Hn,deviationNumberRegistry:Wn,getSectionCompareStyle:Gt,getBadgeRef:ut,connectedSections:Ve,openMoreFunctionsPopup:Et,openSummaryPopup:oi,deviationNodeIdToView:null==ae?void 0:ae.id,deviationTargetParentId:di,parentNodeId:(null===(c=null==Q?void 0:Q.input_index_map)||void 0===c?void 0:c[0])||"",isExpanded:ve?!!_t["left-".concat(r)]:!!_t[String(r)],onToggle:function(){li(),St(r,"left")},navigation:t.id?ai[t.id]:null,showOpenNodeRef:si,resolvedMarkdownStyles:on,maintainRelativeOrder:ve,showDeviationBadges:ge,renderSubSections:gi})})),ve&&d&&n.jsxs(i.Box,e.__assign({ref:Zn.current[r],onClick:function(e){var n=ve?Hn.find(function(e){var n;return null===(n=s.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""}:Hn[r]||{title:"",content:""};Et(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!==g&&n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(d.badgeBorder)}},{children:g})),n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",px:.25}},{children:!re.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(f.default,{color:d.badgeText})})),n.jsx(o.EllipsisVertical,{size:11,color:d.badgeText})]}))]}))}),"left-row-".concat(r))}),n.jsx("div",{ref:dn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),n.jsx(i.Box,e.__assign({ref:Ct,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(),xn.open&&bn===dt?Cn():(In(dt),At(bt(n.currentTarget,{title:"",content:"",evaluationResult:vt,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,dt,!0,e.__assign(e.__assign({},gt),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:gt.badgeBg,color:gt.badgeText,border:"1px solid ".concat(gt.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=ft?ft:n.jsx(f.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:xn.open&&bn===dt?"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},ve?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[me&&n.jsx(l.default,{sections:11}),n.jsx(i.Box,e.__assign({ref:Nt,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"40px",display:"flex",alignItems:"center",overflowX:"hidden"}},{children:n.jsx(i.Tooltip,e.__assign({title:kn,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:kn}))}))})),n.jsxs(i.Box,e.__assign({ref:un,onScroll:Qt,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},ve?{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:cn,style:{width:"100%",height:"0px",flexShrink:0}}),Kn&&Hn.map(function(t,o){var r,l=t,u=[],c=!1,a=null,s=-1;if(ve){u=Gn.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=Gn.findIndex(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(l.selfIndex))&&e.selfIndex>=0});var d=Gn.findIndex(function(e,n){var t;return Ve.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(l.selfIndex))});(c=-1!==d)&&(a=Gt(d))}else u=[o+1],(c=Ve.has(o))&&(a=Gt(o));var v=Gt(ve&&-1!==s?s:o);return n.jsx(i.Box,e.__assign({ref:nt.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:Qn.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:rt("right-accordion-".concat(o)),mb:0,parentNodeId:(null===(r=null==Q?void 0:Q.input_index_map)||void 0===r?void 0:r[1])||"",isExpanded:ve?!!_t["right-".concat(o)]:!!_t[String(o)],treeData:Q,proposedSections:Gn,existingSections:Hn,deviationNumberRegistry:Wn,getBadgeRef:ut,getSectionCompareStyle:Gt,connectedSections:Ve,openMoreFunctionsPopup:Et,openSummaryPopup:oi,deviationNodeIdToView:null==ae?void 0:ae.id,deviationTargetParentId:di,onToggle:function(){li(),St(o,"right")},navigation:t.id?ai[t.id]:null,showOpenNodeRef:si,resolvedMarkdownStyles:on,maintainRelativeOrder:ve,showDeviationBadges:ge,renderSubSections:gi})})),ve&&v&&n.jsx(i.Box,e.__assign({ref:et.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:an,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(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("./CognitiveCompareConstants.js"),n=function(t){return null==t?"":"string"==typeof t?t:Array.isArray(t)?t.map(n).join("\n\n"):"object"==typeof t?JSON.stringify(t):String(t)},o=function(t){return null!=t&&("string"==typeof t?t.trim().length>0:!Array.isArray(t)||t.length>0&&t.some(function(t){return o(t)}))};var e=["#B91C1C","#A16207","#1D4ED8","#000000"],r=function(t){var n=e.findIndex(function(n){return n.toLowerCase()===t.toLowerCase()});return-1===n?e.length:n};exports.DEVIATION_BADGE_SEPARATOR="::",exports.areMarkdownPropsEqual=function(t,n){var o,e,r,i,u,a;if(t.content!==n.content)return!1;if(t.sxStyles!==n.sxStyles)return!1;if(t.maintainRelativeOrder!==n.maintainRelativeOrder)return!1;if(t.highlightBg!==n.highlightBg)return!1;var l=t.highlights||[],s=n.highlights||[];if(l.length!==s.length)return!1;for(var v=0;v<l.length;v++)if(l[v]!==s[v])return!1;var d=t.deviationBadges||[],c=n.deviationBadges||[];if(d.length!==c.length)return!1;for(v=0;v<d.length;v++){if(d[v].id!==c[v].id)return!1;if(d[v].actionId!==c[v].actionId)return!1;if(d[v].label!==c[v].label)return!1;if(d[v].score!==c[v].score)return!1;if(d[v].isOrphan!==c[v].isOrphan)return!1;if(d[v].isConnected!==c[v].isConnected)return!1;if((null===(o=d[v].style)||void 0===o?void 0:o.badgeBg)!==(null===(e=c[v].style)||void 0===e?void 0:e.badgeBg))return!1;if((null===(r=d[v].style)||void 0===r?void 0:r.badgeBorder)!==(null===(i=c[v].style)||void 0===i?void 0:i.badgeBorder))return!1;if((null===(u=d[v].style)||void 0===u?void 0:u.badgeText)!==(null===(a=c[v].style)||void 0===a?void 0:a.badgeText))return!1}return!0},exports.debounce=function(t,n){var o;return function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var i=this;clearTimeout(o),o=setTimeout(function(){return t.apply(i,e)},n)}},exports.extractDeviationScore=function(t,n){var o,e,r,i,u,a,l;if(!t)return n;var s=null!==(a=null!==(i=null!==(e=null===(o=t.evaluation_output)||void 0===o?void 0:o.output_score)&&void 0!==e?e:null===(r=t.evaluation_outputs)||void 0===r?void 0:r.output_score)&&void 0!==i?i:null===(u=t.evaluation_outputs)||void 0===u?void 0:u.output_value)&&void 0!==a?a:t.output_score;return null!==(l=null!=s?s:n)&&void 0!==l?l:""},exports.generateColorPalette=function(t){var n=function(t,n){var o=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("#",""),o=parseInt(n,16);return{r:o>>16&255,g:o>>8&255,b:255&o}}(t),e=o.r,r=o.g,i=o.b;return function(t,n,o){return"#"+[t,n,o].map(function(t){return t.toString(16).padStart(2,"0")}).join("").toUpperCase()}(Math.round(e+(255-e)*n),Math.round(r+(255-r)*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,o,e,r){void 0===r&&(r=14);var i=t+.5*(o-t),u=e-n;if(Math.abs(u)<3)return"M ".concat(t," ").concat(n," H ").concat(o);var a=u>0?1:-1,l=Math.min(r,Math.abs(u)/2,Math.abs(i-t)/2,Math.abs(o-i)/2);return["M ".concat(t," ").concat(n),"H ".concat(i-l),"Q ".concat(i," ").concat(n," ").concat(i," ").concat(n+a*l),"V ".concat(e-a*l),"Q ".concat(i," ").concat(e," ").concat(i+l," ").concat(e),"H ".concat(o)].join(" ")},exports.getFirstDeviationColor=function(n){for(var o,e,i,u,a,l,s,v,d,c,p,g,f,h=[],b=0,_=Object.keys((null==n?void 0:n.deviations)||{}).sort(function(t,n){return Number(t)-Number(n)});b<_.length;b++){var m=_[b];(C=null===(u=null===(i=null===(e=null===(o=null==n?void 0:n.deviations)||void 0===o?void 0:o[m])||void 0===e?void 0:e.evaluation_outputs)||void 0===i?void 0:i.metadata)||void 0===u?void 0:u.label_color)&&h.push(C)}for(var y=0,x=Object.keys((null==n?void 0:n.deviation_entries)||{}).sort(function(t,n){return Number(t)-Number(n)});y<x.length;y++){m=x[y];(C=null===(v=null===(s=null===(l=null===(a=null==n?void 0:n.deviation_entries)||void 0===a?void 0:a[m])||void 0===l?void 0:l.evaluation_outputs)||void 0===s?void 0:s.metadata)||void 0===v?void 0:v.label_color)&&h.push(C)}for(var O=0,B=Object.keys(n||{}).filter(function(t){return/^\d+$/.test(t)}).sort(function(t,n){return Number(t)-Number(n)});O<B.length;O++){var C;m=B[O];(C=null===(p=null===(c=null===(d=null==n?void 0:n[m])||void 0===d?void 0:d.evaluation_outputs)||void 0===c?void 0:c.metadata)||void 0===p?void 0:p.label_color)&&h.push(C)}return 0===h.length?(null===(f=null===(g=null==n?void 0:n.evaluation_outputs)||void 0===g?void 0:g.metadata)||void 0===f?void 0:f.label_color)?n.evaluation_outputs.metadata.label_color:t.DEFAULT_DEVIAION_COLOR:h.sort(function(t,n){return r(t)-r(n)})[0]},exports.getFirstDeviationOutputValue=function(t){for(var n,o,e,r,i,u,a,l,s,v=0,d=Object.keys((null==t?void 0:t.deviations)||{}).sort(function(t,n){return Number(t)-Number(n)});v<d.length;v++){var c=d[v];if(b=null===(e=null===(o=null===(n=null==t?void 0:t.deviations)||void 0===n?void 0:n[c])||void 0===o?void 0:o.evaluation_outputs)||void 0===e?void 0:e.output_value)return b}for(var p=0,g=Object.keys((null==t?void 0:t.deviation_entries)||{}).sort(function(t,n){return Number(t)-Number(n)});p<g.length;p++){c=g[p];if(b=null===(u=null===(i=null===(r=null==t?void 0:t.deviation_entries)||void 0===r?void 0:r[c])||void 0===i?void 0:i.evaluation_outputs)||void 0===u?void 0:u.output_value)return b}for(var f=0,h=Object.keys(t||{}).filter(function(t){return/^\d+$/.test(t)}).sort(function(t,n){return Number(t)-Number(n)});f<h.length;f++){var b;c=h[f];if(b=null===(l=null===(a=null==t?void 0:t[c])||void 0===a?void 0:a.evaluation_outputs)||void 0===l?void 0:l.output_value)return b}return(null===(s=null==t?void 0:t.evaluation_outputs)||void 0===s?void 0:s.output_value)?t.evaluation_outputs.output_value:null},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,o=parseInt(n.decision_strength||"0");return{cognitiveData:{decisioning:n.decisioning_factors||[],gap:n.gaps_in_decision||[],relevance_score:o,citations:n.citations},score:0,relation:"N/A"}},exports.getSideData=function(t,o,e){var r,i=e[o],u=null===(r=null==t?void 0:t.comparison_inputs)||void 0===r?void 0:r[i];return{title:n((null==u?void 0:u.title)||""),content:n((null==u?void 0:u.content)||""),attributes:(null==u?void 0:u.additional_attributes)||null,subsections:(null==u?void 0:u.subsections)||[]}},exports.hasValue=o,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.mixHexColors=function(t,n,o){void 0===o&&(o=50);var e=t.replace("#",""),r=n.replace("#",""),i=parseInt(e.substring(0,2),16),u=parseInt(e.substring(2,4),16),a=parseInt(e.substring(4,6),16),l=parseInt(r.substring(0,2),16),s=parseInt(r.substring(2,4),16),v=parseInt(r.substring(4,6),16),d=o/100,c=1-d,p=Math.round(i*d+l*c),g=Math.round(u*d+s*c),f=Math.round(a*d+v*c),h=function(t){return t.toString(16).padStart(2,"0").toUpperCase()};return"#".concat(h(p)).concat(h(g)).concat(h(f))},exports.safeStringify=n,exports.smoothScrollTo=function(t,n,o,e,r){void 0===o&&(o=300);var i=t.style.scrollBehavior;t.style.scrollBehavior="auto";var u=t.scrollTop,a=n-u,l=null,s=function(v){null===l&&(l=v);var d,c=v-l;c<o?(t.scrollTop=(d=c,d/=o,a*(--d*d*d+1)+u),r&&r(),requestAnimationFrame(s)):(t.scrollTop=n,t.style.scrollBehavior=i,r&&r(),e&&e())};requestAnimationFrame(s)};
|
|
2
2
|
//# sourceMappingURL=CognitiveComparehelpers.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 n=require("tslib"),i=require("react/jsx-runtime"),e=require("react"),o=require("@mui/material"),t=require("lucide-react"),l=require("../hooks/memoizedMarkdown.js"),d=require("../CognitiveComparehelpers.js"),r=require("../CognitiveCompareConstants.js");function a(n){return n&&"object"==typeof n&&"default"in n?n:{default:n}}var s=a(e);exports.default=function(a){var u,c,v,f,p,x,g,h,m,_,I,y,b,w,A=a.section,S=a.idx,R=a.columnKey,j=a.colRef,C=a.mb,F=void 0===C?1:C,O=a.parentNodeId,B=void 0===O?"":O,E=a.isExpanded,D=a.onToggle,T=a.navigation,k=a.showOpenNodeRef,M=a.resolvedMarkdownStyles,P=a.maintainRelativeOrder,N=a.showDeviationBadges,V=void 0!==N&&N,W=a.renderSubSections,q=a.treeData,G=a.proposedSections,z=void 0===G?[]:G,K=a.existingSections,L=void 0===K?[]:K,U=a.deviationNumberRegistry,X=void 0===U?{}:U,Y=a.getBadgeRef,H=a.openSummaryPopup,J=a.getSectionCompareStyle,Q=a.connectedSections,Z=a.openMoreFunctionsPopup;a.deviationNodeIdToView,a.deviationTargetParentId;var $=(null===(u=A.displayTitle)||void 0===u||u)&&d.hasValue(A.title),nn=(null===(c=A.displayContent)||void 0===c||c)&&d.hasValue(A.content),en=!$&&!nn,on={current:1},tn=A.title;$||(tn=nn?"No Title Found":"No Matching Section Found");var ln=A.evaluationResult;if(!ln&&"right"===R)if(P){var dn=null===(v=A.refIndexes)||void 0===v?void 0:v[0],rn=z.find(function(n){return n.selfIndex===dn});ln=null==rn?void 0:rn.evaluationResult}else ln=null===(f=z[S])||void 0===f?void 0:f.evaluationResult;var an=null===(p=null==q?void 0:q.input_index_map)||void 0===p?void 0:p[0],sn=null===(x=null==q?void 0:q.input_index_map)||void 0===x?void 0:x[1],un="left"===R?sn:an,cn=function(n,i){return n.find(function(n){return(null==n?void 0:n.id)&&i&&n.id===i})},vn="left"===R?A:z[S],fn="right"===R?A:L[S];if(P)if("left"===R){var pn=null===(g=A.refIndexes)||void 0===g?void 0:g[0],xn=L.findIndex(function(n){return n.selfIndex===pn});fn=-1!==xn?L[xn]:cn(L,A.id)}else{var gn=null===(h=A.refIndexes)||void 0===h?void 0:h[0],hn=z.findIndex(function(n){return n.selfIndex===gn});vn=-1!==hn?z[hn]:cn(z,A.id)}var mn="left"===R?!fn:!vn,_n=ln||(null==vn?void 0:vn.evaluationResult)||(null==fn?void 0:fn.evaluationResult),In=null!==(I=null===(_=null===(m=null==_n?void 0:_n.evaluation_outputs)||void 0===m?void 0:m.metadata)||void 0===_?void 0:_.label_color)&&void 0!==I?I:r.DEFAULT_DEVIAION_COLOR,yn=d.generateColorPalette(In).highlightBg,bn=(null==_n?void 0:_n.deviations)||{},wn=S+1,An=A.id;if("right"===R&&P){var Sn=null===(y=A.refIndexes)||void 0===y?void 0:y[0],Rn=-1!==(hn=z.findIndex(function(n){return n.selfIndex===Sn}))?z[hn]:cn(z,A.id);if(Rn){var jn=z.findIndex(function(n){return n.id===Rn.id});-1!==jn&&(wn=jn+1),An=Rn.id}}var Cn,Fn=[],On=Object.entries(bn).map(function(i){var e,o,t,l,r,a,s=i[0],u=i[1],c="".concat(An).concat(d.DEVIATION_BADGE_SEPARATOR).concat(s),v=X[c];if(null==v)return null;var f=u[B],p=d.isMissingStr(f);if(p)f="";else if(!f)return null;Fn.push(f);var x=S,g=S;if(P)if("left"===R){var h=null===(e=A.refIndexes)||void 0===e?void 0:e[0],m=L.findIndex(function(n){return n.selfIndex===h});if(-1!==m)g=m;else{var _=L.findIndex(function(n){return n.id===A.id});g=-1!==_?_:S}}else{var I=null===(o=A.refIndexes)||void 0===o?void 0:o[0],y=z.findIndex(function(n){return n.selfIndex===I});if(-1!==y)x=y;else x=-1!==(O=z.findIndex(function(n){return n.id===A.id}))?O:S}var b="".concat(An).concat(d.DEVIATION_BADGE_SEPARATOR).concat(s).concat(d.DEVIATION_BADGE_SEPARATOR).concat(x).concat(d.DEVIATION_BADGE_SEPARATOR).concat(g),w=u[un],j=mn||d.isMissingStr(w),C="".concat(wn,".").concat(v),F=S;if("right"===R&&P){var O,E=null===(t=A.refIndexes)||void 0===t?void 0:t[0],D=z.findIndex(function(n){return n.selfIndex===E});if(-1!==D)F=D;else-1!==(O=z.findIndex(function(n){return n.id===A.id}))&&(F=O)}var T=J?J(F):null,k=(null==u?void 0:u.evaluation_outputs)||(null==_n?void 0:_n.evaluation_outputs),M=null!==(l=null==k?void 0:k.output_value)&&void 0!==l?l:null,N=null!==(a=null===(r=null==k?void 0:k.metadata)||void 0===r?void 0:r.label_color)&&void 0!==a?a:In,V=d.generateColorPalette(N),W=T?n.__assign(n.__assign({},T),{badgeBg:V.badgeBg,badgeBorder:V.badgeBorder,badgeText:V.badgeText}):n.__assign({},V),q=(null==u?void 0:u.deviation_summary)?{deviation_summary:u.deviation_summary,deviation_title:(null==u?void 0:u.deviation_title)||(null==_n?void 0:_n.deviation_title),deviation_impact:(null==u?void 0:u.deviation_impact)||(null==_n?void 0:_n.deviation_impact),deviation_explanation:(null==u?void 0:u.deviation_explanation)||(null==_n?void 0:_n.deviation_explanation),evaluation_outputs:k,cognitive_decisioning:(null==u?void 0:u.cognitive_decisioning)||(null==_n?void 0:_n.cognitive_decisioning)}:null,G=0,K=A.content||"";if(f&&K){var U=K.split(/\n{2,}/),$=U.findIndex(function(n){return n.includes(f)});if(-1!==$){var nn=Object.entries(bn).filter(function(n){n[0];var i=n[1][B];return i&&U[$].includes(i)}).sort(function(n,i){return U[$].indexOf(n[1][B])-U[$].indexOf(i[1][B])});G=Math.max(0,nn.findIndex(function(n){return n[0]===s}))}}return{id:c,actionId:b,label:C,highlight:f,side:R,style:W,stackIndex:G,score:M,isConnected:null==Q?void 0:Q.has(b),isOrphan:j,isMissingClause:p,badgeRef:Y(R,c),onClick:function(n){n.stopPropagation(),Z&&Z(n,vn||{id:"orphan-left",title:"",content:""},j,fn||{id:"orphan-right",title:"",content:""},b,W)},onSummaryClick:function(n){n.stopPropagation(),H(n,b,j,q)}}}).filter(Boolean),Bn=V?On:[],En=A.id&&R===(null==T?void 0:T.columnKey)?T:null,Dn=s.default.useRef(!1);return e.useEffect(function(){E||(Dn.current=!1)},[E]),i.jsxs(o.Box,n.__assign({ref:j,sx:{mb:F,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:[E&&(null==En?void 0:En.showAbove)&&i.jsx("div",n.__assign({style:{position:"sticky",top:0,height:"0px",cursor:"pointer"},onClick:function(){var n,i;return null===(i=null===(n=null==En?void 0:En.showAboveRef)||void 0===n?void 0:n.current)||void 0===i?void 0:i.scrollIntoView({behavior:"smooth",block:"center"})}},{children:i.jsx("div",n.__assign({style:n.__assign({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===R?"+":"-"," 130px))"),position:"absolute",paddingTop:"20px"},"left"===R?{right:"0px"}:{left:"0px"})},{children:i.jsx(t.ChevronUp,{color:window.getComputedStyle(null===(b=null==En?void 0:En.showAboveRef)||void 0===b?void 0:b.current).color})}))})),i.jsxs(o.Accordion,n.__assign({disableGutters:!0,expanded:!en&&E,onChange:function(){en||(D(),k.current=A.id)},sx:{boxShadow:"none",border:en?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:en?"#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:[i.jsx(o.AccordionSummary,n.__assign({expandIcon:en?null:i.jsx(t.ChevronDown,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:en?"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:$&&i.jsx(o.Tooltip,n.__assign({title:tn,placement:"top"},{children:i.jsx(o.Typography,n.__assign({component:"div",sx:{fontSize:"12px",color:en?"#94A3B8":"#19213D",fontWeight:en?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(Cn=tn,Cn?d.safeStringify(Cn).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(n,e){return n.startsWith("**")&&n.endsWith("**")?i.jsx("strong",{children:n.slice(2,-2)},e):i.jsx(s.default.Fragment,{children:n},e)}):null)}))}))})),!en&&i.jsxs(o.AccordionDetails,n.__assign({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[nn&&i.jsx(l.MemoizedMarkdown,{content:A.content,sxStyles:M,highlights:Fn,maintainRelativeOrder:P,highlightBg:yn,deviationBadges:Bn}),(A.subsections||[]).map(function(n,i){return W({section:n,keyPath:"".concat(S,"-").concat(i),depth:0,columnKey:R,parentNodeId:B,devCounter:on})})]}))]})),E&&(null==En?void 0:En.showBelow)&&i.jsx("div",n.__assign({style:{position:"sticky",bottom:0,height:"0px",cursor:"pointer"},onClick:function(){var n,i;return null===(i=null===(n=null==En?void 0:En.showBelowRef)||void 0===n?void 0:n.current)||void 0===i?void 0:i.scrollIntoView({behavior:"smooth",block:"center"})}},{children:i.jsx("div",n.__assign({style:n.__assign({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===R?"+":"-"," 130px))"),position:"absolute",paddingBottom:"20px"},"left"===R?{right:"0px"}:{left:"0px"})},{children:i.jsx(t.ChevronDown,{color:window.getComputedStyle(null===(w=null==En?void 0:En.showBelowRef)||void 0===w?void 0:w.current).color})}))}))]}),"".concat(R,"-sec-").concat(S))};
|
|
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 n=require("tslib"),i=require("react/jsx-runtime"),e=require("react"),t=require("@mui/material"),o=require("lucide-react"),l=require("../hooks/memoizedMarkdown.js"),a=require("../CognitiveComparehelpers.js"),s=require("../CognitiveCompareConstants.js");function d(n){return n&&"object"==typeof n&&"default"in n?n:{default:n}}var r=d(e).default.memo(function(d){var u,c,v,f,h,p,g,_,m,x,b=d.section,S=d.keyPath,y=d.depth,I=void 0===y?0:y,A=d.columnKey,E=void 0===A?"left":A,R=d.parentNodeId,j=void 0===R?"":R,O=d.expandedSubSections,B=d.setExpandedSubSections,P=d.maintainRelativeOrder,w=d.showDeviationBadges,C=void 0!==w&&w,k=d.proposedSections,D=d.existingSections,F=d.treeData,M=d.deviationNumberRegistry,T=d.connectedSections,N=d.activeSideBySideSection,q=d.resolvedMarkdownStyles,V=d.getSubSectionRef,W=d.getSubSectionCompareStyle,z=d.getBadgeRef,G=d.openMoreFunctionsPopup,L=d.openSummaryPopup,U=d.resetSideBySide,H=d.setConnectedSections,K=d.setConnectedLines,J=d.cachedConnectedPositions,Q=(null===(u=b.displayTitle)||void 0===u||u)&&a.hasValue(b.title),X=(null===(c=b.displayContent)||void 0===c||c)&&a.hasValue(b.content),Y=!Q&&!X,Z=Q?b.title:X?"No Title Found":"No Matching Section Found",$=!!O[S],nn=V(E,S),en=S.split("-").map(Number),tn=en[0],on=k[tn],ln=D[tn],an=S,sn=S,dn=tn,rn=tn,un=function(n,i,e){if(!n||!i)return null;if(n.id===i)return{section:n,keyPath:e};for(var t=(n.subsections||[]).map(function(n,i){return{section:n,keyPath:"".concat(e,"-").concat(i)}}),o=function(){var n=t.shift();return(null==n?void 0:n.section)?n.section.id===i?{value:n}:void(n.section.subsections||[]).forEach(function(i,e){t.push({section:i,keyPath:"".concat(n.keyPath,"-").concat(e)})}):"continue"};t.length>0;){var l=o();if("object"==typeof l)return l.value}return null};if(P)if("left"===E){var cn=null===(v=null==on?void 0:on.refIndexes)||void 0===v?void 0:v[0],vn=D.findIndex(function(n){return n.selfIndex===cn});-1!==vn&&(ln=D[vn],rn=vn)}else{var fn=null===(f=null==ln?void 0:ln.refIndexes)||void 0===f?void 0:f[0];-1!==(xn=k.findIndex(function(n){return n.selfIndex===fn}))&&(on=k[xn],dn=xn)}var hn=on,pn=ln;if(P)if("left"===E){hn=b,an=S;var gn=un(ln,b.id,String(rn));pn=(null==gn?void 0:gn.section)||null,sn=(null==gn?void 0:gn.keyPath)||""}else{pn=b,sn=S;var _n=un(on,b.id,String(dn));hn=(null==_n?void 0:_n.section)||null,an=(null==_n?void 0:_n.keyPath)||""}else for(var mn=1;mn<en.length;mn++)(null==hn?void 0:hn.subsections)&&(hn=hn.subsections[en[mn]]),(null==pn?void 0:pn.subsections)&&(pn=pn.subsections[en[mn]]);var xn,bn=(an?W(an):null)||W(S),Sn=null===(h=null==F?void 0:F.input_index_map)||void 0===h?void 0:h[0],yn=null===(p=null==F?void 0:F.input_index_map)||void 0===p?void 0:p[1],In="left"===E?yn:Sn,An="left"===E?!pn:!hn,En=b.evaluationResult||(null==hn?void 0:hn.evaluationResult)||(null==pn?void 0:pn.evaluationResult),Rn=tn+1,jn=b.id||(null==hn?void 0:hn.id)||(null==pn?void 0:pn.id);"right"===E&&P&&(on&&-1!==(xn=k.findIndex(function(n){return n.id===on.id}))&&(Rn=xn+1));var On=null!==(m=null===(_=null===(g=null==En?void 0:En.evaluation_outputs)||void 0===g?void 0:g.metadata)||void 0===_?void 0:_.label_color)&&void 0!==m?m:s.DEFAULT_DEVIAION_COLOR,Bn=a.generateColorPalette(On).highlightBg,Pn=(null==En?void 0:En.deviations)||{},wn=[],Cn=Object.entries(Pn).map(function(i){var e,t,o,l=i[0],s=i[1],d="".concat(jn).concat(a.DEVIATION_BADGE_SEPARATOR).concat(l),r=M[d];if(null==r)return null;var u=s[j],c=a.isMissingStr(u);if(c)u="";else if(!u)return null;wn.push(u);var v=s[In],f=An||a.isMissingStr(v),h="".concat(Rn,".").concat(r),p="".concat(jn).concat(a.DEVIATION_BADGE_SEPARATOR).concat(l).concat(a.DEVIATION_BADGE_SEPARATOR).concat(an).concat(a.DEVIATION_BADGE_SEPARATOR).concat(sn),g=(null==s?void 0:s.evaluation_outputs)||(null==En?void 0:En.evaluation_outputs),_=null!==(e=null==g?void 0:g.output_value)&&void 0!==e?e:null,m=null!==(o=null===(t=null==g?void 0:g.metadata)||void 0===t?void 0:t.label_color)&&void 0!==o?o:On,x=a.generateColorPalette(m),S=n.__assign({},x),y=(null==s?void 0:s.deviation_summary)?{deviation_summary:s.deviation_summary||(null==En?void 0:En.deviation_summary),deviation_title:(null==s?void 0:s.deviation_title)||(null==En?void 0:En.deviation_title),deviation_impact:(null==s?void 0:s.deviation_impact)||(null==En?void 0:En.deviation_impact),deviation_explanation:(null==s?void 0:s.deviation_explanation)||(null==En?void 0:En.deviation_explanation),evaluation_outputs:g,cognitive_decisioning:(null==s?void 0:s.cognitive_decisioning)||(null==En?void 0:En.cognitive_decisioning)}:null,I=0,A=b.content||"";if(u&&A){var R=A.split(/\n{2,}/),O=R.findIndex(function(n){return n.includes(u)});if(-1!==O){var B=Object.entries(Pn).filter(function(n){n[0];var i=n[1][j];return i&&R[O].includes(i)}).sort(function(n,i){return R[O].indexOf(n[1][j])-R[O].indexOf(i[1][j])});I=Math.max(0,B.findIndex(function(n){return n[0]===l}))}}return{id:d,actionId:p,label:h,highlight:u,side:E,style:S,stackIndex:I,score:_,isConnected:T.has(p),isOrphan:f,isMissingClause:c,badgeRef:z(E,d),onClick:function(i){i.stopPropagation();var e=hn?n.__assign(n.__assign({},hn),{title:(null==on?void 0:on.title)||(null==hn?void 0:hn.title)||""}):{id:"orphan-left",title:"",content:""},t=pn?n.__assign(n.__assign({},pn),{title:(null==ln?void 0:ln.title)||(null==pn?void 0:pn.title)||""}):{id:"orphan-right",title:"",content:""};G(i,e,f,t,p,S)},onSummaryClick:function(n){n.stopPropagation(),L(n,p,f,y)}}}).filter(Boolean).sort(function(n,i){return parseFloat(n.label)-parseFloat(i.label)}),kn=C?Cn:[],Dn=e.useRef(!1);e.useEffect(function(){$||(Dn.current=!1)},[$]),e.useEffect(function(){if($&&!Dn.current){var n=setTimeout(function(){var n,i;Dn.current=!0;var e=null===(i=null===(n=Cn[0])||void 0===n?void 0:n.badgeRef)||void 0===i?void 0:i.current;e&&e.scrollIntoView({behavior:"smooth",block:"center"})},350);return function(){return clearTimeout(n)}}},[$,Cn]);var Fn=Cn.find(function(n){return T.has(n.actionId)}),Mn=!!Fn;if(!(Q||X||b.subsections&&0!==b.subsections.length))return null;var Tn=(null===(x=null==Fn?void 0:Fn.style)||void 0===x?void 0:x.badgeBorder)||(null==bn?void 0:bn.badgeBorder),Nn=Mn&&Tn?{borderRadius:"4px",outline:"2px solid ".concat(Tn),outlineOffset:"1px"}:{};return Q?i.jsx(t.Box,n.__assign({ref:nn,sx:{mt:1,width:"100%",minWidth:0,position:"relative"}},{children:i.jsx(t.Box,n.__assign({sx:n.__assign({width:"100%"},Nn)},{children:i.jsxs(t.Accordion,n.__assign({disableGutters:!0,expanded:!Y&&$,onChange:function(){if(!Y){if($){var i=String(N||""),e=i.includes(an)||i.includes(sn);e||T.forEach(function(n){(String(n).includes(an)||String(n).includes(sn))&&(e=!0)}),e&&(U(),H(new Set),K([]),J.current=[])}B(function(i){var e;return n.__assign(n.__assign({},i),((e={})[S]=!i[S],e))})}},sx:{mt:0,boxShadow:"none",border:Y?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF",minWidth:0,"&:before":{display:"none"}}},{children:[i.jsx(t.AccordionSummary,n.__assign({expandIcon:Y?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,n.__assign({component:"div",sx:{fontSize:"11px",fontWeight:600,color:Y?"#94A3B8":"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:Z||"Untitled Subsection"}))})),!Y&&i.jsxs(t.AccordionDetails,n.__assign({sx:{pt:0,pb:1,minWidth:0}},{children:[X&&i.jsx(l.MemoizedMarkdown,{content:b.content,sxStyles:q,deviationBadges:kn,maintainRelativeOrder:P,highlightBg:Bn,highlights:wn}),(b.subsections||[]).map(function(e,t){return i.jsx(r,n.__assign({},d,{section:e,keyPath:"".concat(S,"-").concat(t),depth:I+1}),"".concat(S,"-").concat(t))})]}))]}))}))})):i.jsx(t.Box,n.__assign({ref:nn,sx:{mt:0===I?1:.75,width:"100%",minWidth:0,position:"relative"}},{children:!Y&&i.jsxs(t.Box,n.__assign({sx:n.__assign({width:"100%"},Nn)},{children:[X&&i.jsx(l.MemoizedMarkdown,{content:b.content,sxStyles:q,deviationBadges:kn,maintainRelativeOrder:P,highlightBg:Bn,highlights:wn}),(b.subsections||[]).map(function(e,t){return i.jsx(r,n.__assign({},d,{section:e,keyPath:"".concat(S,"-").concat(t),depth:I+1}),"".concat(S,"-").concat(t))})]}))}))});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"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),i=require("react/jsx-runtime"),n=require("@mui/material"),r=require("react"),t=require("../CognitiveCompareConstants.js"),o=require("lucide-react"),l=require("react-markdown"),a=require("../CognitiveComparehelpers.js"),s=require("rehype-raw");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=d(r),g=d(l),h=d(s),u=c.default.memo(function(l){var s=l.content,d=l.sxStyles,u=l.deviationBadges,p=void 0===u?[]:u,f=l.highlights,v=void 0===f?[]:f,_=l.maintainRelativeOrder,x=void 0===_||_,m=l.highlightBg,b=r.useMemo(function(){return p.reduce(function(i,n){var r;return e.__assign(e.__assign({},i),((r={})[n.id]=n,r))},{})},[p]),y=function(i,n){return c.default.Children.map(i,function(i){var r;if(!c.default.isValidElement(i))return i;var t=(null===(r=i.props)||void 0===r?void 0:r.children)?y(i.props.children,n):i.props.children,o=c.default.cloneElement(i,e.__assign(e.__assign({},i.props),{children:t}));return n(o)})},C=r.useMemo(function(){return{mark:function(n){var r,t,o,l,a=n.children,s=e.__rest(n,["children"]),d=s["data-badge-id"],c=d?b[d]:null,g=s["data-highlight-color"],h=null!==(l=null!==(t=null!=g?g:null===(r=null==c?void 0:c.style)||void 0===r?void 0:r.highlightBg)&&void 0!==t?t:null===(o=null==c?void 0:c.style)||void 0===o?void 0:o.badgeBg)&&void 0!==l?l:m;return i.jsx("span",e.__assign({style:e.__assign(e.__assign({},s.isSuggestedDeviationFix?{}:{backgroundColor:h}),{borderRadius:"2px"})},{children:a}))},span:function(r){var l,a,s,d,c,g,h=r.children,u=e.__rest(r,["children"]),p=u["data-badge-id"];if(!p)return i.jsx("span",e.__assign({},u,{children:h}));var f=b[p];if(!f)return i.jsx("span",e.__assign({},u,{children:h}));var v="number"==typeof f.stackIndex?f.stackIndex:0,_="translateY(calc(-20% + ".concat(24*v,"px))");return i.jsxs(n.Box,e.__assign({component:"span",sx:{position:"static",display:"inline"}},{children:[i.jsxs(n.Box,e.__assign({ref:f.badgeRef,sx:e.__assign(e.__assign({fontStyle:"normal",position:"absolute",zIndex:30+v,display:"inline-flex",alignItems:"stretch",fontSize:"10px",bgcolor:(null===(l=f.style)||void 0===l?void 0:l.badgeBg)||"#EEF2FF",color:(null===(a=f.style)||void 0===a?void 0:a.badgeText)||t.DEFAULT_DEVIAION_COLOR,border:"1px solid ".concat((null===(s=f.style)||void 0===s?void 0:s.badgeBorder)||"#C7D2FE"),borderRadius:"12px",fontWeight:600,whiteSpace:"nowrap",boxShadow:"0 1px 3px rgba(0,0,0,0.07)",overflow:"hidden"},"left"===f.side?{right:"-16px",transform:"".concat(_," translateX(calc(100% + 8px))")}:{left:"-16px",transform:"".concat(_," translateX(calc(-100% - 8px))")}),f.isConnected&&f.style&&{outline:"2px solid ".concat(f.style.badgeBorder),outlineOffset:"1px"})},{children:[i.jsxs(n.Box,e.__assign({onClick:function(e){e.stopPropagation(),f.onSummaryClick&&f.onSummaryClick(e)},sx:{display:"flex",alignItems:"center",px:1,py:.3,cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.04)"}}},{children:[i.jsx(n.Box,e.__assign({component:"span",sx:{fontSize:"10px",fontWeight:700}},{children:f.label})),("left"===f.side||f.isOrphan)&&i.jsx(n.Box,e.__assign({component:"span",sx:{fontSize:"10px",pl:.5,ml:.5,borderLeft:"1px solid ".concat((null===(d=f.style)||void 0===d?void 0:d.badgeBorder)||"#C7D2FE")}},{children:null!=f.score&&"N/A"!==f.score&&"NA"!==f.score&&0!==f.score?"".concat(f.score):"N/A"===f.score||"NA"===f.score?"N/A":"Same"}))]})),("left"===f.side||f.isOrphan)&&i.jsx(n.Box,e.__assign({onClick:function(e){e.stopPropagation(),f.onClick&&f.onClick(e)},sx:{display:"flex",alignItems:"center",px:.5,borderLeft:"1px solid ".concat((null===(c=f.style)||void 0===c?void 0:c.badgeBorder)||"#C7D2FE"),cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.06)"}}},{children:i.jsx(o.EllipsisVertical,{size:12,color:(null===(g=f.style)||void 0===g?void 0:g.badgeText)||"#3730A3"})}))]})),h]}))},updated:function(n){var r=n.children;return e.__rest(n,["children"]),i.jsx(i.Fragment,{children:r})},deleted:function(n){var r=n.children;e.__rest(n,["children"]),console.log("nitish: ",r);var t=y(r,function(e){return c.default.cloneElement(e,{isSuggestedDeviationFix:!0})});return i.jsx("span",e.__assign({style:{borderTop:"1px solid #EF4444",borderBottom:"1px solid #EF4444",backgroundColor:"#FCCCCC",textDecoration:"line-through"}},{children:t}))},changed:function(n){var r=n.children;e.__rest(n,["children"]);var t=y(r,function(e){return c.default.cloneElement(e,{isSuggestedDeviationFix:!0})});return i.jsx("span",e.__assign({style:{borderTop:"1px solid #2F59FF",borderBottom:"1px solid #2F59FF",backgroundColor:"#D5E8FF"}},{children:t}))}}},[b,x]),E=r.useMemo(function(){var i=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(""):""},n=function(e,i,n,r,t){void 0===i&&(i=""),void 0===n&&(n=""),void 0===r&&(r="");var o=e.startsWith("\n\n"),l=e.endsWith("\n\n"),a=t?' data-highlight-color="'.concat(t,'"'):"";return n+e.split(/(\n{2,})/).map(function(e,n,r){if(/^\n{2,}$/.test(e))return e;if(!e.trim())return e;var t=0===n||1===n&&/^\n{2,}$/.test(r[0]),s=n===r.length-1||n===r.length-2&&/^\n{2,}$/.test(r[r.length-1]);return o&&t||l&&s?e:'<mark data-badge-id="'.concat(i,'"').concat(a,">").concat(e,"</mark>")}).join("").replace(/^\n{2,}/,"").replace(/\n{2,}$/,"")+r},r=i(a.safeStringify(s||"")),t=(p||[]).map(function(e){var n,r;return{id:null==e?void 0:e.id,highlight:i((null==e?void 0:e.highlight)||""),highlightColor:(null===(n=null==e?void 0:e.style)||void 0===n?void 0:n.highlightBg)||(null===(r=null==e?void 0:e.style)||void 0===r?void 0:r.badgeBg)||m}}).filter(function(e){return e.id&&e.highlight}),o=new Set,l=function(e,i){var r=e.highlight;return t.filter(function(i){return i.id!==e.id&&e.highlight.length>i.highlight.length&&e.highlight.includes(i.highlight)}).sort(function(e,i){return i.highlight.length-e.highlight.length}).forEach(function(t){var l=a.mixHexColors(e.highlightColor,t.highlightColor),s=i?'<span data-badge-id="'.concat(t.id,'">'):"",d=i?"</span>":"";i&&o.add(t.id);var c=n(t.highlight,t.id,s,d,l);r=r.split(t.highlight).join(c)}),r},d=e.__spreadArray([],t,!0).sort(function(e,i){return i.highlight.length-e.highlight.length}),c={},g=0;d.forEach(function(e){if(null==e?void 0:e.highlight){var i=e.highlight,t=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a="__DEV_TOKEN_".concat(g++,"__"),s=r.includes(i),d=l(e,s),h=l(e,!1);!o.has(e.id)&&s&&(c[a]=n(d,e.id,'<span data-badge-id="'.concat(e.id,'">'),"</span>"),r=r.replace(i,a));var u="__HIGHLIGHT_TOKEN_".concat(g++,"__");c[u]=n(h,e.id),r=r.replace(new RegExp(t,"g"),u)}});var h=new Set(d.map(function(e){return e.highlight}).filter(Boolean));return v.forEach(function(e){if(e){var t=i(e);if(t&&!h.has(t)){var o=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),l="__PLAIN_TOKEN_".concat(g++,"__");c[l]=n(t),r=r.replace(new RegExp(o,"g"),l)}}}),Object.keys(c).forEach(function(e){r=r.split(e).join(c[e])}),r},[s,p,v]);return i.jsx(n.Typography,e.__assign({component:"div",sx:e.__assign(e.__assign({},d),{position:"relative",overflow:"visible",whiteSpace:"pre-wrap","& p, & li, & ul, & ol":{position:"static",overflow:"visible",whiteSpace:"pre-wrap"}})},{children:i.jsx(g.default,e.__assign({components:C,rehypePlugins:[h.default]},{children:a.safeStringify(E).replace(/\\n/g,"\n")}))}))},a.areMarkdownPropsEqual);exports.MemoizedMarkdown=u;
|
|
2
2
|
//# sourceMappingURL=memoizedMarkdown.js.map
|