@viswa-test/test-citation 0.0.233 → 0.0.234

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js +1 -1
  2. package/dist/cjs/features/CognitiveCompare/MoreFunctionsPopup.js +1 -1
  3. package/dist/cjs/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
  4. package/dist/cjs/features/GptWebCitation/GptWebCitationMarkdown.js +2 -0
  5. package/dist/cjs/features/GptWebCitation/GptWebCitationMarkdown.js.map +1 -0
  6. package/dist/cjs/features/RequirementAI/components/RichTextEditor/Editor/Editor.js +1 -1
  7. package/dist/cjs/features/RequirementAI/components/RichTextEditor/Editor/plugins/InitialHtml.js +1 -1
  8. package/dist/cjs/features/RequirementAI/components/RichTextEditor/Editor/plugins/ManualNode.js +1 -1
  9. package/dist/cjs/features/RequirementAI/components/RichTextEditor/Editor/plugins/UpdateNode.js +1 -1
  10. package/dist/cjs/features/RequirementAI/components/RichTextEditor/RichTextEditor.js +1 -1
  11. package/dist/cjs/features/RequirementAI/components/UserStoryCard/CognitiveComponents/CognitiveComponent.js +1 -1
  12. package/dist/cjs/features/RequirementAI/components/UserStoryCard/Popups/DeviationSummary.js +1 -1
  13. package/dist/cjs/features/RequirementAI/components/userstory-with-citation/UserStoryWithCitation.js +1 -1
  14. package/dist/cjs/features/RequirementAI/components/userstory-with-citation/components/InlineManualComponent.js +1 -1
  15. package/dist/cjs/features/RequirementAI/components/userstory-with-citation/components/InlineUpdatedComponent.js +1 -1
  16. package/dist/features/CognitiveCompare/CognitiveCompare.js +1 -1
  17. package/dist/features/CognitiveCompare/MoreFunctionsPopup.js +1 -1
  18. package/dist/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
  19. package/dist/features/GptWebCitation/GptWebCitationMarkdown.js +2 -0
  20. package/dist/features/GptWebCitation/GptWebCitationMarkdown.js.map +1 -0
  21. package/dist/features/RequirementAI/components/RichTextEditor/Editor/Editor.js +1 -1
  22. package/dist/features/RequirementAI/components/RichTextEditor/Editor/plugins/InitialHtml.js +1 -1
  23. package/dist/features/RequirementAI/components/RichTextEditor/Editor/plugins/ManualNode.js +1 -1
  24. package/dist/features/RequirementAI/components/RichTextEditor/Editor/plugins/UpdateNode.js +1 -1
  25. package/dist/features/RequirementAI/components/RichTextEditor/RichTextEditor.js +1 -1
  26. package/dist/features/RequirementAI/components/UserStoryCard/CognitiveComponents/CognitiveComponent.js +1 -1
  27. package/dist/features/RequirementAI/components/UserStoryCard/Popups/DeviationSummary.js +1 -1
  28. package/dist/features/RequirementAI/components/userstory-with-citation/UserStoryWithCitation.js +1 -1
  29. package/dist/features/RequirementAI/components/userstory-with-citation/components/InlineManualComponent.js +1 -1
  30. package/dist/features/RequirementAI/components/userstory-with-citation/components/InlineUpdatedComponent.js +1 -1
  31. package/dist/types/src/CognitiveCompareTest.d.ts.map +1 -1
  32. package/dist/types/src/RedlineApprovalCardTest.d.ts +1 -0
  33. package/dist/types/src/RedlineApprovalCardTest.d.ts.map +1 -0
  34. package/dist/types/src/RedlineEditorTest.d.ts.map +1 -1
  35. package/dist/types/src/RequirementAiTest.d.ts.map +1 -1
  36. package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts.map +1 -1
  37. package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts +1 -0
  38. package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts.map +1 -1
  39. package/dist/types/src/features/CognitiveCompare/Guidelines/constants/guidelines.mockData.d.ts +1759 -979
  40. package/dist/types/src/features/CognitiveCompare/Guidelines/constants/guidelines.mockData.d.ts.map +1 -1
  41. package/dist/types/src/features/CognitiveCompare/MoreFunctionsPopup.d.ts +2 -0
  42. package/dist/types/src/features/CognitiveCompare/MoreFunctionsPopup.d.ts.map +1 -1
  43. package/dist/types/src/features/CognitiveCompare/hooks/useLinesCalculator.d.ts.map +1 -1
  44. package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/plugins/InitialHtml.d.ts.map +1 -1
  45. package/dist/types/src/features/RequirementAI/components/RichTextEditor/RichTextEditor.d.ts.map +1 -1
  46. package/dist/types/src/features/RequirementAI/components/UserStoryCard/CognitiveComponents/CognitiveComponent.d.ts +2 -2
  47. package/dist/types/src/features/RequirementAI/components/UserStoryCard/CognitiveComponents/CognitiveComponent.d.ts.map +1 -1
  48. package/dist/types/src/features/RequirementAI/components/UserStoryCard/Popups/DeviationSummary.d.ts +7 -7
  49. package/dist/types/src/features/RequirementAI/components/UserStoryCard/Popups/DeviationSummary.d.ts.map +1 -1
  50. package/dist/types/src/features/RequirementAI/components/userstory-with-citation/UserStoryWithCitation.d.ts.map +1 -1
  51. package/package.json +1 -1
  52. package/dist/cjs/utils/tagHelper.js +0 -2
  53. package/dist/cjs/utils/tagHelper.js.map +0 -1
  54. package/dist/types/src/constants/deviationData.d.ts +0 -887
  55. package/dist/types/src/constants/deviationData.d.ts.map +0 -1
  56. package/dist/types/src/constants/treeData.d.ts +0 -732
  57. package/dist/types/src/constants/treeData.d.ts.map +0 -1
  58. package/dist/types/src/features/RequirementAI/components/UserStoryCard/Popups/BlockedPopup.d.ts +0 -8
  59. package/dist/types/src/features/RequirementAI/components/UserStoryCard/Popups/BlockedPopup.d.ts.map +0 -1
  60. package/dist/types/src/utils/tagHelper.d.ts +0 -5
  61. package/dist/types/src/utils/tagHelper.d.ts.map +0 -1
  62. package/dist/utils/tagHelper.js +0 -2
  63. package/dist/utils/tagHelper.js.map +0 -1
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),i=require("react"),t=require("@mui/material"),o=require("lucide-react"),r=require("../../assests/svg/ButtonCognitiveIcon.js"),l=require("./OverlayComponent.js"),s=require("./CognitiveComparehelpers.js"),u=require("./CognitiveCompareConfig.js"),a=require("./CognitiveCompareConstants.js"),c=require("./CognitivePopup.js"),d=require("./MoreFunctionsPopup.js"),f=require("./LoaderComponent.js"),v=require("./components/ThreeDotsLoader.js"),g=require("./hooks/useCompareData.js"),p=require("./hooks/useComparePopups.js"),h=require("./hooks/useSectionRefs.js"),m=require("./hooks/useAccordionState.js"),S=require("./hooks/useDeviationNavigation.js"),R=require("./components/CompareHeader.js"),x=require("./components/SubSectionAccordion.js"),_=require("./components/LHSSectionRow.js"),b=require("./components/RHSSectionRow.js"),y=require("./components/CognitiveSummaryPopup.js"),C=require("./CompareContext.js"),E=require("./hooks/useStyles.js"),A=require("./hooks/useResizeHandler.js"),B=require("./hooks/useLinesCalculator.js"),w=require("./hooks/useSideBySide.js"),I=require("./components/SvgConnectors.js"),T=require("./Guidelines/components/GuidelinePanel.js");exports.SHARED_MARKDOWN_STYLES=u.SHARED_MARKDOWN_STYLES,exports.default=function(D){var O,F,j,k,P,N,L,M,q,H,V,z,G,W,K,U,Y,J,X,$,Q,Z,ee,ne,ie,te,oe,re,le,se,ue,ae,ce,de,fe,ve=D.componentHeaderText,ge=void 0===ve?a.DEFAULT_COMPONENT_HEADER_TEXT:ve,pe=D.treeData,he=D.comparisonConfig,me=D.leftColumnTitleText,Se=D.rightColumnTitleText,Re=D.markdownStyles,xe=D.resetTrigger,_e=D.displayConfig,be=void 0===_e?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1,displayEmailNotifier:!0,isStreamingEnabled:!1}:_e,ye=D.onMaintainRelativeOrderChange,Ce=D.popupConfig,Ee=D.deviationData,Ae=void 0===Ee?{}:Ee,Be=D.deviationNodeIdToView,we=D.resetDeviationNodeId,Ie=D.isProposingFix,Te=void 0!==Ie&&Ie,De=D.proposingFixNodeId,Oe=D.isRedlineFlow,Fe=D.badgeStyleOverride,je=D.guidelinesData,ke=i.useState(be.maintainRelativeOrder),Pe=ke[0],Ne=ke[1],Le=null!==(O=null==be?void 0:be.expandLevels)&&void 0!==O?O:0,Me=!!(null==be?void 0:be.expandAllSections),qe=!!Pe||!!(null==be?void 0:be.showDeviationBadges),He=i.useState(!1),Ve=He[0],ze=He[1],Ge=i.useState(null),We=Ge[0],Ke=Ge[1],Ue=i.useState(null===(j=null!==(F=null==pe?void 0:pe.newEvaluationResult)&&void 0!==F?F:null==be?void 0:be.enableDeviationSchemaBackwardCompatibility)||void 0===j||j)[0],Ye=i.useState(new Set),Je=Ye[0],Xe=Ye[1],$e=i.useState([]),Qe=$e[0],Ze=$e[1],en=i.useState(!1),nn=en[0],tn=en[1],on=i.useRef(null),rn=i.useRef(null),ln=i.useRef(null),sn=i.useRef(null),un=i.useRef(null),an=i.useRef(!1),cn=i.useRef(null),dn=i.useRef({}),fn=i.useRef([]),vn=i.useRef(function(){}),gn=i.useRef(null),pn=i.useRef(function(){}),hn=i.useMemo(function(){return JSON.stringify(Ae||{})},[JSON.stringify(Ae)]),mn=i.useMemo(function(){return Ae||{}},[hn]),Sn=i.useMemo(function(){return(null==pe?void 0:pe.cognitive_decisioning)||{}},[pe]),Rn=i.useMemo(function(){return e.__assign(e.__assign({},u.SHARED_MARKDOWN_STYLES),Re)},[Re]),xn=i.useRef(null),_n=i.useRef(null),bn=i.useRef(null),yn=i.useRef(null),Cn=i.useRef(null),En=i.useRef(null),An=i.useRef(null),Bn=i.useRef(null),wn=i.useRef(null),In=i.useRef(null),Tn=p.useComparePopups(xn),Dn=Tn.cognitivePopup,On=Tn.setCognitivePopup,Fn=Tn.moreFunctions,jn=Tn.setMoreFunctions,kn=Tn.position,Pn=Tn.setPosition,Nn=Tn.activeBadgeId,Ln=Tn.summaryPopup,Mn=Tn.setSummaryPopup,qn=Tn.closeSummaryPopup,Hn=Tn.setActiveBadgeId,Vn=Tn.popupRef,zn=Tn.handleOpenCognitiveCompare,Gn=Tn.openCognitivePopupFromState,Wn=Tn.closeCognitivePopup,Kn=Tn.closeMoreFunctionsPopup,Un=i.useMemo(function(){var e,n,i,t,o,r,l;return{fields:null!==(e=null==he?void 0:he.fields)&&void 0!==e?e:u.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(i=null===(n=null==he?void 0:he.thresholds)||void 0===n?void 0:n.high)&&void 0!==i?i:u.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(o=null===(t=null==he?void 0:he.thresholds)||void 0===t?void 0:t.medium)&&void 0!==o?o:u.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(l=null===(r=null==he?void 0:he.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:u.DEFAULT_COMPARISON_CONFIG.thresholds.exact}}},[he]),Yn=i.useState(null),Jn=Yn[0];Yn[1];var Xn=null===(N=null===(k=null==pe?void 0:pe.documents)||void 0===k?void 0:k[null===(P=null==pe?void 0:pe.input_index_map)||void 0===P?void 0:P[0]])||void 0===N?void 0:N.title,$n=null===(q=null===(L=null==pe?void 0:pe.documents)||void 0===L?void 0:L[null===(M=null==pe?void 0:pe.input_index_map)||void 0===M?void 0:M[1]])||void 0===q?void 0:q.title,Qn=s.safeStringify(me||Xn||"Uploaded Contract"),Zn=null===(G=null===(z=null===(H=null==pe?void 0:pe.documents)||void 0===H?void 0:H[null===(V=null==pe?void 0:pe.input_index_map)||void 0===V?void 0:V[0]])||void 0===z?void 0:z.metadata)||void 0===G?void 0:G.file_name,ei=s.safeStringify(Zn),ni=null===(Y=null===(U=null===(W=null==pe?void 0:pe.documents)||void 0===W?void 0:W[null===(K=null==pe?void 0:pe.input_index_map)||void 0===K?void 0:K[1]])||void 0===U?void 0:U.metadata)||void 0===Y?void 0:Y.file_name,ii=s.safeStringify(ni),ti=s.safeStringify(Se||$n||"Reference Template"),oi=g.useCognitiveTreeData(pe,Pe,mn,Un,Ue,je),ri=oi.isGuidelineMode,li=oi.activeProposed,si=oi.existingRule,ui=oi.proposedSections,ai=oi.existingSections,ci=oi.visibleFields,di=oi.parentDeviationRecord,fi=oi.deviationNumberRegistry,vi=oi.deviationParentRegistry,gi=oi.parseError;i.useEffect(function(){gi&&Ke("Failed to load comparison: ".concat(gi))},[gi]);var pi=ui.length>0||ai.length>0,hi=i.useMemo(function(){if(!Oe)return"off";var e=0,n=0,i=function(t){Array.isArray(t)&&t.forEach(function(t){var o,r=(null==t?void 0:t.content)||"";s.hasMeaningfulRedlineTags(r)&&(e+=1,n+=String(r).length),(null===(o=null==t?void 0:t.subsections)||void 0===o?void 0:o.length)&&i(t.subsections)})};return i(ui),i(ai),"".concat(e,":").concat(n)},[Oe,ui,ai]);i.useEffect(function(){if(ui.length||ai.length)if(Me){var e={},n={},i=function(i,t){i.forEach(function(i,o){var r,l=Pe?"".concat(t,"-").concat(o):String(o);e[l]=!0;var s=function(e,i){null==e||e.forEach(function(e,t){var o,r="".concat(i,"-").concat(t);n[r]=!0,(null===(o=e.subsections)||void 0===o?void 0:o.length)&&s(e.subsections,r)})};(null===(r=i.subsections)||void 0===r?void 0:r.length)&&s(i.subsections,String(o))})};i(ui,"left"),i(ai,"right"),$i(e),Zi(n)}else if(Le>0){var t={},o={},r=function(e,n,i){e.forEach(function(e,r){var l;if(i>=1){var s=Pe?"".concat(n,"-").concat(r):String(r);t[s]=!0}var u=function(e,n,t){t>i||null==e||e.forEach(function(e,i){var r,l="".concat(n,"-").concat(i);o[l]=!0,(null===(r=e.subsections)||void 0===r?void 0:r.length)&&u(e.subsections,l,t+1)})};(null===(l=e.subsections)||void 0===l?void 0:l.length)&&i>=2&&u(e.subsections,String(r),2)})};r(ui,"left",Le),r(ai,"right",Le),$i(t),Zi(o)}},[Me,Le,ui,ai,Pe]);var mi=h.useSectionRefs(ci.map(function(e){return e.key}),Math.max(ui.length,ai.length)),Si=mi.leftRefs,Ri=mi.rightRefs,xi=mi.sectionLeftRefs,_i=mi.sectionRightRefs,bi=mi.lhsBadgeRefs,yi=mi.rhsBadgeRefs,Ci=mi.sectionRightRowRefs,Ei=mi.subSectionLeftRefs,Ai=mi.subSectionRightRefs,Bi=mi.sectionRowRefs,wi=mi.getSectionRowRef,Ii=mi.getSubSectionRef,Ti=mi.getBadgeRef,Di=w.useSideBySide({isGuidelineMode:ri,maintainRelativeOrder:Pe,proposedSections:ui,existingSections:ai,leftContainerRef:Bn,rightContainerRef:bn,scrollContainerRef:xn,sectionLeftRefs:xi,sectionRightRefs:_i,subSectionLeftRefs:Ei,subSectionRightRefs:Ai,lhsBadgeRefs:bi,rhsBadgeRefs:yi,sectionRowRefs:Bi,sectionRightRowRefs:Ci,rhsTopSpacerRef:yn,rhsBottomSpacerRef:Cn,lhsTopSpacerRef:En,lhsBottomSpacerRef:An,calculateLinesRef:vn,setConnectedSections:Xe,setConnectedLines:Ze,cachedConnectedPositions:fn,closeMoreFunctionsPopup:Kn,setErrorToast:Ke,moreFunctions:Fn,closeSummaryPopup:qn}),Oi=Di.isSideBySide,Fi=Di.isArrowVisible,ji=Di.setIsArrowVisible,ki=Di.isResizing,Pi=Di.setIsResizing,Ni=Di.isSideBySideLoading,Li=Di.activeSideBySideSection,Mi=Di.scrollLock,qi=Di.sideBySideCacheRef,Hi=Di.isSideBySideRef,Vi=Di.activeSideBySideRightSectionRef,zi=Di.activeSideBySideSectionRef,Gi=Di.sideBySideLineRef,Wi=Di.highlightedClauseRefs,Ki=Di.clearClauseHighlight,Ui=Di.resetSideBySide,Yi=Di.activateSideBySide,Ji=m.useAccordionState({maintainRelativeOrder:!!Pe,proposedSections:ui,existingSections:ai,activeSideBySideSection:Li,connectedSections:Je,resetSideBySide:Ui,setConnectedSections:Xe,setConnectedLines:Ze,cachedConnectedPositions:fn,svgContainerRef:on,isAnimatingRef:an,animationTimerRef:cn,calculateLinesRef:vn,sectionLeftRefs:xi,sectionRightRefs:_i,subSectionLeftRefs:Ei,subSectionRightRefs:Ai}),Xi=Ji.expandedSections,$i=Ji.setExpandedSections,Qi=Ji.expandedSubSections,Zi=Ji.setExpandedSubSections,et=Ji.handleSubSectionToggle,nt=Ji.toggleSection,it=Ji.forceExpandCrossWiredSections,tt=function(){var e,n;if(null!=Li){var i=null===(e=xi.current[Li])||void 0===e?void 0:e.current,t=null===(n=_i.current[Li])||void 0===n?void 0:n.current,o=bn.current;if(i&&t&&o){var r=i.getBoundingClientRect(),l=t.getBoundingClientRect(),s=o.getBoundingClientRect(),u=r.top-s.top,a=l.top-s.top-u;o.scrollBy({top:a,behavior:"smooth"})}}},ot=i.useCallback(function(e){null==e||e.stopPropagation(),tn(function(e){var n=!e;return n&&requestAnimationFrame(function(){tt()}),n})},[tt]);i.useEffect(function(){Oe&&"off"!==hi&&"0:0"!==hi&&(qi.current=null,fn.current=[],requestAnimationFrame(function(){var e;null===(e=vn.current)||void 0===e||e.call(vn)}))},[Oe,hi]);var rt=i.useMemo(function(){var e=new Map,n=new Map,i=1;if(Pe)ui.forEach(function(n){!n.title&&!n.content||n.id&&e.set(n.id,i++)}),ai.forEach(function(t){if(t.id&&!(!t.title&&!t.content)){var o=ui.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(t.selfIndex)});if(o.length>0){var r=o.map(function(n){return e.get(n.id)}).filter(Boolean);n.set(t.id,r.join(", "))}else n.set(t.id,String(i++))}});else for(var t=Math.max(ui.length,ai.length),o=0;o<t;o++){var r=ui[o],l=ai[o];r?(e.set(r.id,i),l&&n.set(l.id,String(i)),i++):l&&n.set(l.id,String(i++))}return{leftNums:e,rightNums:n}},[ui,ai,Pe]),lt=si.analysis,st=s.safeStringify(null===(X=null===(J=null==lt?void 0:lt.rule_difference_comparison)||void 0===J?void 0:J.summary)||void 0===X?void 0:X.overall_summary),ut=!!st.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),at=null!==($=null==pe?void 0:pe.base_root_id)&&void 0!==$?$:"-1";null==pe||pe[at];var ct=Ue?null!==(ae=null!==(le=Ae&&(null===(re=null==Ae?void 0:Ae[at])||void 0===re?void 0:re.evaluation_result))&&void 0!==le?le:null===(ue=null===(se=null==pe?void 0:pe.nodes)||void 0===se?void 0:se[at])||void 0===ue?void 0:ue.evaluation_result)&&void 0!==ae?ae:null:null!==(oe=null!==(ee=Ae&&(null===(Z=null===(Q=null==Ae?void 0:Ae[at])||void 0===Q?void 0:Q.evaluation_result)||void 0===Z?void 0:Z[0]))&&void 0!==ee?ee:null===(te=null===(ie=null===(ne=null==pe?void 0:pe.nodes)||void 0===ne?void 0:ne[at])||void 0===ie?void 0:ie.evaluation_result)||void 0===te?void 0:te[0])&&void 0!==oe?oe:null,dt=s.extractDeviationScore(ct),ft=s.generateColorPalette(null!==(fe=null===(de=null===(ce=null==ct?void 0:ct.evaluation_outputs)||void 0===ce?void 0:ce.metadata)||void 0===de?void 0:de.label_color)&&void 0!==fe?fe:a.DEFAULT_DEVIAION_COLOR);if(Fe){var vt=Fe(dt);vt&&(ft=e.__assign(e.__assign({},ft),{badgeBg:vt.bg,badgeText:vt.text,badgeBorder:vt.border}))}var gt=i.useRef(Ui);i.useEffect(function(){gt.current=Ui},[Ui]);var pt=i.useRef(Wn);i.useEffect(function(){pt.current=Wn},[Wn]);var ht=i.useCallback(function(e,n,i,t,o,r){return _o.current(e,n,i,t,o,r)},[]),mt=i.useCallback(function(e,n,i,t,o){return yo.current(e,n,i,t,o)},[]),St=i.useCallback(function(){return Co.current()},[]),Rt=i.useCallback(function(e,n){return Eo.current(e,n)},[]),xt=i.useCallback(function(e){return Ao.current(e)},[]),_t=i.useCallback(function(e){return Bo.current(e)},[]),bt=i.useCallback(function(){return wo.current()},[]),yt=i.useCallback(function(){var e,n;Ki(),null===(e=gt.current)||void 0===e||e.call(gt),tn(!1),Xe(new Set),Ze([]),fn.current=[],Vt([]),Gt(null),Mn(a.EMPTY_SUMMARY_POPUP_STATE),null===(n=pt.current)||void 0===n||n.call(pt),requestAnimationFrame(function(){var e;null===(e=vn.current)||void 0===e||e.call(vn)})},[]),Ct=i.useRef(yt);i.useEffect(function(){Ct.current=yt},[yt]),i.useEffect(function(){xe&&Ct.current()},[xe]);var Et=i.useMemo(function(){return{documents:null==pe?void 0:pe.documents,input_index_map:null==pe?void 0:pe.input_index_map}},[JSON.stringify(null==pe?void 0:pe.documents),JSON.stringify(null==pe?void 0:pe.input_index_map)]),At=i.useRef(pe);i.useEffect(function(){At.current=pe},[pe]);var Bt=i.useRef(Sn);i.useEffect(function(){Bt.current=Sn},[Sn]);var wt=i.useCallback(function(n,i,t,o,r,l,u){var a,c,d,f,v,g,p,h,m,S,R=s.safeStringify(null==i?void 0:i.id)||s.safeStringify(null==t?void 0:t.id)||"",x=(R?null===(a=Bt.current)||void 0===a?void 0:a[R]:null)||(null==i?void 0:i.cognitiveData)||(null==t?void 0:t.cognitiveData)||{section_id:R,decisioning:[],gap:[],relevance_score:0},_=null!==(d=null===(c=Bi.current[o])||void 0===c?void 0:c.current)&&void 0!==d?d:null,b=function(){var n,r,l=(null==i?void 0:i.evaluationResult)||(null==t?void 0:t.evaluationResult)||null,u=function(n){var i=function(e){if(!e||"object"!=typeof e)return null;var n=null==e?void 0:e.deviation_entries;if(n&&"object"==typeof n){var i=Object.keys(n).sort(function(e,n){return Number(e)-Number(n)})[0];if(i&&n[i])return n[i]}var t=Object.keys(e).filter(function(e){return/^\d+$/.test(e)}).sort(function(e,n){return Number(e)-Number(n)});if(t.length&&e[t[0]])return e[t[0]];var o=null==e?void 0:e.deviations;if(o&&"object"==typeof o){var r=Object.keys(o).sort(function(e,n){return Number(e)-Number(n)})[0];if(r&&o[r])return o[r]}return null}(n);return i?e.__assign(e.__assign({},n),{deviation_summary:(null==n?void 0:n.deviation_summary)||(null==i?void 0:i.deviation_summary),deviation_title:(null==n?void 0:n.deviation_title)||(null==i?void 0:i.deviation_title),deviation_impact:(null==n?void 0:n.deviation_impact)||(null==i?void 0:i.deviation_impact),deviation_explanation:(null==n?void 0:n.deviation_explanation)||(null==i?void 0:i.deviation_explanation),evaluation_outputs:(null==n?void 0:n.evaluation_outputs)||(null==i?void 0:i.evaluation_outputs),cognitive_decisioning:(null==n?void 0:n.cognitive_decisioning)||(null==i?void 0:i.cognitive_decisioning)}):n};if(!("string"==typeof o&&o.includes(s.DEVIATION_BADGE_SEPARATOR)))return u(l);var a=o.split(s.DEVIATION_BADGE_SEPARATOR)[1];if(!a)return l;var c=(null==i?void 0:i.evaluationResult)||(null==t?void 0:t.evaluationResult)||{},d=(null===(n=null==c?void 0:c.deviation_entries)||void 0===n?void 0:n[a])||(null===(r=null==c?void 0:c.deviations)||void 0===r?void 0:r[a])||null;return d?e.__assign(e.__assign(e.__assign({},c),d),{deviation_summary:(null==d?void 0:d.deviation_summary)||(null==c?void 0:c.deviation_summary),deviation_title:(null==d?void 0:d.deviation_title)||(null==c?void 0:c.deviation_title),deviation_impact:(null==d?void 0:d.deviation_impact)||(null==c?void 0:c.deviation_impact),deviation_explanation:(null==d?void 0:d.deviation_explanation)||(null==c?void 0:c.deviation_explanation),evaluation_outputs:(null==d?void 0:d.evaluation_outputs)||(null==c?void 0:c.evaluation_outputs),cognitive_decisioning:(null==d?void 0:d.cognitive_decisioning)||(null==c?void 0:c.cognitive_decisioning)}):u(l)}(),y=(null!==(g=null===(v=null===(f=null==b?void 0:b.cognitive_decisioning)||void 0===f?void 0:f.decisioning_factors)||void 0===v?void 0:v.length)&&void 0!==g?g:0)>0||(null!==(m=null===(h=null===(p=null==b?void 0:b.cognitive_decisioning)||void 0===p?void 0:p.gaps_in_decision)||void 0===h?void 0:h.length)&&void 0!==m?m:0)>0;return{isLoading:null!==(S=null==be?void 0:be.isLoading)&&void 0!==S&&S&&!y,open:!0,sectionTitle:(null==i?void 0:i.title)?null==i?void 0:i.title:"No Counterpart",refSectionTitle:(null==t?void 0:t.title)?null==t?void 0:t.title:"No Counterpart",cognitiveData:x,anchorEl:n,sectionAnchorEl:_,badgeStyle:l||null,sectionIdx:o,docData:Et,deviationData:b,isOrphan:!!r}},[Et,null==be?void 0:be.isLoading]),It=i.useCallback(function(e,n,i,t,o,r){var l;if(e.stopPropagation(),Fn.open&&Fn.sectionIdx===o)Kn();else{var u=e.currentTarget,a="left";(null===(l=bn.current)||void 0===l?void 0:l.contains(u))&&(a="right");Ki(),Hi.current&&Ui(),Xe(new Set),Ze([]),fn.current=[],Wn(),Ln.open?no():qn(),requestAnimationFrame(function(){var e=function(){var e,n,i,t;if("string"==typeof o&&o.includes(s.DEVIATION_BADGE_SEPARATOR)){var r=o.split(s.DEVIATION_BADGE_SEPARATOR),l="".concat(r[0]).concat(s.DEVIATION_BADGE_SEPARATOR).concat(r[1]);return"right"===a?null===(e=yi.current[l])||void 0===e?void 0:e.current:null===(n=bi.current[l])||void 0===n?void 0:n.current}return"right"===a?null===(i=yi.current[o])||void 0===i?void 0:i.current:null===(t=bi.current[o])||void 0===t?void 0:t.current}()||u;jn(wt(e,n,t,o,i,r))})}},[Fn.open,Fn.sectionIdx,Kn,qn,wt]),Tt=i.useCallback(function(){var e=Fn.sectionIdx;Fn.isOrphan,Kn(),qn(),null!==e&&(it(e),Ki(),Hi.current&&Ui(),Ze([]),fn.current=[],Xe(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){vn.current&&vn.current()},50))},[Fn.sectionIdx,Fn.isOrphan,Kn,qn,Ui]),Dt=i.useCallback(function(){var e=un.current;if(e){un.current=null;var n=ui.findIndex(function(n){return n.id===e}),i=ai.findIndex(function(n){return n.id===e}),t=-1===n?s.findKeyPathByNodeId(ui,e):null,o=-1===i?s.findKeyPathByNodeId(ai,e):null,r=-1!==n?n:t?Number(t.split("-")[0]):-1,l=-1!==i?i:o?Number(o.split("-")[0]):-1,u=function(e,n,i,t){var o,r,l,s;return-1!==e?null!==(r=null===(o=i.current[e])||void 0===o?void 0:o.current)&&void 0!==r?r:null:n&&null!==(s=null===(l=t.current[n])||void 0===l?void 0:l.current)&&void 0!==s?s:null},a=function(e,n,i){void 0===i&&(i=30);var t=0,o=function(){var r=e();r&&0!==r.getBoundingClientRect().height?(Wi.current.add(r),s.scrollAndHighlightClause(r,n)):t++<i&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(Pe)-1!==r&&Bn.current&&a(function(){return u(n,t,xi,Ei)},Bn.current),-1!==l&&bn.current&&a(function(){return u(i,o,_i,Ai)},bn.current);else{var c=xn.current;if(!c)return;a(function(){return-1!==r?u(n,t,xi,Ei):u(i,o,_i,Ai)},c)}}},[ui,ai,Pe,xi,_i,Ei,Ai,Bn,bn,xn]),Ot=i.useCallback(function(n){if(n){Ki(),Ui(),Xe(new Set),Ze([]),fn.current=[],qn(),Wn();var i=ui.findIndex(function(e){return e.id===n}),t=ai.findIndex(function(e){return e.id===n}),o=-1===i?s.findKeyPathByNodeId(ui,n):null,r=-1===t?s.findKeyPathByNodeId(ai,n):null;if(-1!==i||o||-1!==t||r){var l=-1!==i?i:o?Number(o.split("-")[0]):-1,u=-1!==t?t:r?Number(r.split("-")[0]):-1;un.current=n,$i(function(n){var i,t=e.__assign({},n),o=!1;-1!==l&&(t[i=Pe?"left-".concat(l):String(l)]||(t[i]=!0,o=!0));-1!==u&&(t[i=Pe?"right-".concat(u):String(u)]||(t[i]=!0,o=!0));return o?t:n}),Zi(function(n){var i=e.__assign({},n),t=!1,l=function(e){for(var n=e.split("-"),o=n[0],r=1;r<n.length;r++)o+="-".concat(n[r]),i[o]||(i[o]=!0,t=!0)};return o&&l(o),r&&l(r),t?i:n}),setTimeout(function(){requestAnimationFrame(function(){un.current===n&&Ft.current()})},50)}else console.warn('scrollToAndHighlightClause: nodeId "'.concat(n,'" not found'))}},[ui,ai,Pe,$i,Zi,Ui,qn,Wn]),Ft=i.useRef(Dt);i.useEffect(function(){Ft.current=Dt},[Dt]);var jt=i.useRef(null);i.useEffect(function(){if(Jn){var e=Un.fields.find(function(e){return e.analysisKey===Jn||e.key===Jn});if(e){var n=Si.current[e.key]||Ri.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[Jn,Un.fields]);var kt=i.useCallback(function(e){var n,i,t,o,r,l,s,u,a,c=null===(n=null==lt?void 0:lt.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!c||!c[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var d=c[e],f=(null==d?void 0:d.relation)||(null===(t=null===(i=null==d?void 0:d.highlights)||void 0===i?void 0:i.ruleA_spans)||void 0===t?void 0:t.length)||(null===(r=null===(o=null==d?void 0:d.highlights)||void 0===o?void 0:o.ruleB_spans)||void 0===r?void 0:r.length)||(null==d?void 0:d.mappings)&&d.mappings.length>0;if(d.mappings){var v=d.mappings[0]||{};return{score:d.score,relation:v.relation||"",highlightsA:(null===(l=v.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(s=v.highlights)||void 0===s?void 0:s.ruleB_spans)||[],hasContent:!!f}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(u=d.highlights)||void 0===u?void 0:u.ruleA_spans)||[],highlightsB:(null===(a=d.highlights)||void 0===a?void 0:a.ruleB_spans)||[],hasContent:!!f}},[lt]),Pt=E.useStyleHelpers({proposedSections:ui,existingSections:ai,maintainRelativeOrder:Pe,cognitiveMap:Sn,deviationData:mn,treeData:pe,resolvedComparisonConfig:Un,badgeStyleOverride:Fe}),Nt=Pt.getSectionCompareStyle,Lt=Pt.getSubSectionCompareStyle,Mt=Pt.getDeviationStyleByKey,qt=B.useLinesCalculator({containerRef:rn,leftContainerRef:Bn,rightContainerRef:bn,svgContainerRef:on,pathRefs:dn,leftHeaderRef:ln,rightHeaderRef:sn,proposedSections:ui,existingSections:ai,visibleFields:ci,leftRefs:Si,rightRefs:Ri,sectionLeftRefs:xi,sectionRightRefs:_i,subSectionLeftRefs:Ei,subSectionRightRefs:Ai,lhsBadgeRefs:bi,rhsBadgeRefs:yi,sectionRowRefs:Bi,expandedSections:Xi,expandedSubSections:Qi,connectedSections:Je,isSideBySide:Oi,activeSideBySideSection:Li,maintainRelativeOrder:Pe,isGuidelineMode:ri,cognitiveMap:Sn,getSectionCompareStyle:Nt,getSubSectionCompareStyle:Lt,getDeviationStyleByKey:Mt,isArrowVisible:Fi,isAnimatingRef:an,isSideBySideRef:Hi,sideBySideCacheRef:qi,sideBySideLineRef:Gi,activeSideBySideSectionRef:zi,activeSideBySideRightSectionRef:Vi,connectedLines:Qe,setConnectedLines:Ze,cachedConnectedPositions:fn,calculateLinesRef:vn,resizeTimerRef:gn,scrollLock:Mi,scrollSyncLocked:nn,handleResizeRef:pn,activeProposed:li,existingRule:si,analysisData:lt,pendingScrollTargetRef:wn,pendingScrollCallbackRef:In,resolvedComparisonConfig:Un,getFieldData:kt}),Ht=qt.lines,Vt=qt.setLines,zt=qt.overallConnector,Gt=qt.setOverallConnector,Wt=qt.svgDimensions,Kt=qt.handleColumnScroll;i.useEffect(function(){Ln.anchorEl&&requestAnimationFrame(function(){requestAnimationFrame(function(){var e;null===(e=vn.current)||void 0===e||e.call(vn)})})},[Ln.anchorEl,nn]);var Ut=i.useCallback(function(){Ki(),tn(!1),$i({}),Zi({}),Ui(),Xe(new Set),Ze([]),fn.current=[],qn(),Wn(),Kn(),requestAnimationFrame(function(){vn.current&&vn.current()})},[$i,Zi,Ui,qn,Wn,Kn]);i.useEffect(function(){Oi||0!==Je.size||tn(!1)},[Oi,Je]);var Yt=i.useMemo(function(){return Object.values(Xi).some(Boolean)||Object.values(Qi).some(Boolean)},[Xi,Qi]),Jt=i.useRef(null),Xt=i.useRef(0),$t=i.useRef(0),Qt=i.useRef(0),Zt=A.useResizeHandler({timerRef:Jt,ruleComponentRef:_n,scrollContainerRef:xn,containerRef:rn,maintainRelativeOrder:Pe,proposedSections:ui,existingSections:ai,isSideBySideRef:Hi,activeSideBySideSectionRef:zi,activeSideBySideRightSectionRef:Vi,sectionRowRefs:Bi,sectionRightRowRefs:Ci,sectionLeftRefs:xi,sectionRightRefs:_i,subSectionLeftRefs:Ei,subSectionRightRefs:Ai,lhsBadgeRefs:bi,rhsBadgeRefs:yi,leftContainerRef:Bn,rightContainerRef:bn,calculateLinesRef:vn,handleResizeRef:pn,setIsResizing:Pi,setIsArrowVisible:ji,sideBySideCacheRef:qi,cachedConnectedPositions:fn}).handleResize;i.useEffect(function(){pn.current=Zt},[Zt,pn]),i.useEffect(function(){var e=function(e,n,i,t,o){n.current=e.getBoundingClientRect().width;var r=new ResizeObserver(function(e){null!==i.current&&cancelAnimationFrame(i.current),i.current=requestAnimationFrame(function(){var r,l,s;i.current=null;var u=e[e.length-1];if(u){var a=null!==(s=null===(l=null===(r=u.borderBoxSize)||void 0===r?void 0:r[0])||void 0===l?void 0:l.inlineSize)&&void 0!==s?s:u.contentRect.width;Math.abs(a-n.current)<1?o():(n.current=a,t())}})});return r.observe(e),r},n={current:null},i={current:null},t={current:null},o=[],r=[n,i,t];return _n.current&&o.push(e(_n.current,Xt,n,function(){return pn.current()},function(){})),xn.current&&o.push(e(xn.current,$t,i,function(){return pn.current()},function(){return vn.current()})),rn.current&&o.push(e(rn.current,Qt,t,function(){return pn.current()},function(){return vn.current()})),function(){o.forEach(function(e){return e.disconnect()}),r.forEach(function(e){null!==e.current&&(cancelAnimationFrame(e.current),e.current=null)})}},[]),i.useEffect(function(){Hi.current=Oi},[Oi]),i.useEffect(function(){zi.current=Li},[Li]);var eo=i.useCallback(function(){var e,n=Fn.sectionIdx,i=Fn.isOrphan;if(qn(),null!=n){var t="left";Fn.anchorEl&&(null===(e=bn.current)||void 0===e?void 0:e.contains(Fn.anchorEl))&&(t="right"),it(n),Yi(n,i,{sourceSide:t})}},[Yi,Fn.isOrphan,Fn.sectionIdx,Fn.anchorEl,qn]),no=i.useCallback(function(){qn(),Ui(),Xe(new Set),Ze([]),fn.current=[]},[qn,Ui]),io=null!==Fn.sectionIdx&&Je.has(Fn.sectionIdx),to=S.useDeviationNavigation({proposedSections:ui,existingSections:ai,parentDeviationRecord:di,expandedSections:Xi,maintainRelativeOrder:!!Pe,scrollContainerRef:xn,leftContainerRef:Bn,rightContainerRef:bn,lhsBadgeRefs:bi,rhsBadgeRefs:yi}),oo=to.showDeviationNavigation,ro=to.showOpenNodeRef,lo=to.adjustScrollForPopup,so=i.useCallback(function(e,n,i,t,o){var r,l="string"==typeof t?s.safeStringify(t).trim():s.safeStringify(null==t?void 0:t.deviation_summary).trim(),u=e.currentTarget;Wn();var a="left";(null===(r=bn.current)||void 0===r?void 0:r.contains(u))&&(a="right");var c=function(){var e,i,t,o;if("string"==typeof n&&n.includes(s.DEVIATION_BADGE_SEPARATOR)){var r=n.split(s.DEVIATION_BADGE_SEPARATOR),l="".concat(r[0]).concat(s.DEVIATION_BADGE_SEPARATOR).concat(r[1]);return"right"===a?null===(e=yi.current[l])||void 0===e?void 0:e.current:null===(i=bi.current[l])||void 0===i?void 0:i.current}return"right"===a?null===(t=yi.current[n])||void 0===t?void 0:t.current:null===(o=bi.current[n])||void 0===o?void 0:o.current};if(i)return Ui(),Xe(new Set),Ze([]),fn.current=[],void(l&&(it(n),requestAnimationFrame(function(){var e=c()||u;e&&(e.getBoundingClientRect().top>.8*window.innerHeight&&e.scrollIntoView({behavior:"smooth",block:"center"}));Mn({open:!0,anchorEl:e,summary:t,displayImpact:o})})));it(n),l?setTimeout(function(){Yi(n,i,{toggleIfSame:!1,sourceSide:a,onReady:function(){var e,n,i,r=c()||u;if(r){var l=r.getBoundingClientRect();if(l.top>.8*window.innerHeight||l.top<100){var s=l.top-window.innerHeight/2;Pe?(null===(e=Bn.current)||void 0===e||e.scrollBy({top:s,behavior:"smooth"}),null===(n=bn.current)||void 0===n||n.scrollBy({top:s,behavior:"smooth"})):null===(i=xn.current)||void 0===i||i.scrollBy({top:s,behavior:"smooth"})}}Mn({open:!0,anchorEl:r,summary:t,displayImpact:o})}})},350):setTimeout(function(){Yi(n,i,{toggleIfSame:!1,sourceSide:a})},350)},[Yi,Wn,Mn,Ui,it]),uo=i.useMemo(function(){var e;if(!Be)return null;var n=null===(e=null==Be?void 0:Be.id)||void 0===e?void 0:e.split(":")[0];for(var i in di){if((di[i]||[]).some(function(e){return e.id===n}))return i}return null},[Be,di]),ao=i.useRef({id:null,triggerMs:null}),co=i.useRef(null);i.useEffect(function(){if(null==Be?void 0:Be.id){var n=Number(Be.trigger),i=ao.current;if((null==i?void 0:i.triggerMs)!==n){if(!(Be.id.includes(":")&&/:\d+$/.test(Be.id)))return ao.current={id:Be.id,triggerMs:n},void Ot(Be.id);var t=Be.id.split(":"),o=t[0],r=t[1],l=null!=r?r:"0";co.current!==Be.id&&(qn(),Wn(),Ui(),Xe(new Set),Ze([]),fn.current=[],co.current=Be.id);var u=!1,a=0,c=null,d=null,f=!1,v=function(e,n){for(var i=function(e,t){if(!e)return null;if(e.id===n)return t;if(!Array.isArray(e.subsections))return null;for(var o=0;o<e.subsections.length;o++){var r=i(e.subsections[o],"".concat(t,"-").concat(o));if(r)return r}return null},t=0;t<e.length;t++){var o=i(e[t],String(t));if(o)return o}return null},g=function(){var i,t,r,p;if(!u){var h=function(){ao.current={id:Be.id,triggerMs:n}},m=null,S=null;for(var R in di){var x=di[R].find(function(e){return e.id===o});if(x){m=R,S=x;break}}if(S&&m){var _=ui.findIndex(function(e){return e.id===m}),b=ai.findIndex(function(e){return e.id===m}),y=-1===_&&-1!==b,C=v(ui,S.id),E=v(ai,S.id);if(C&&!E&&!y){var A=C.split("-"),B=Number(A[0]);if(Pe){var w=null===(t=null===(i=ui[B])||void 0===i?void 0:i.refIndexes)||void 0===t?void 0:t[0],I=ai.findIndex(function(e){return e.selfIndex===w});-1!==I&&(B=I)}E=e.__spreadArray([B],A.slice(1),!0).join("-")}if(C||E){var T=C?Number(C.split("-")[0]):_,D=E?Number(E.split("-")[0]):b,O=D>=0?D:E?Number(E.split("-")[0]):-1,F=ui[T],j=ai[O],k=F&&!F.title&&!F.content,P=j&&!j.title&&!j.content,N=y||(!C&&!!E||k&&!P);if(N){if(!(Pe?!!bo.current["right-".concat(D)]:!!bo.current[String(D)])&&D>=0)return nt(D,"right"),void(c=setTimeout(g,200))}else if(!(Pe?!!bo.current["left-".concat(T)]:!!bo.current[String(T)])&&T>=0)return nt(T,"left"),void(c=setTimeout(g,200));var L=C||"",M=E||"",q="".concat(S.id).concat(s.DEVIATION_BADGE_SEPARATOR).concat(l).concat(s.DEVIATION_BADGE_SEPARATOR).concat(L).concat(s.DEVIATION_BADGE_SEPARATOR).concat(M),H="".concat(S.id).concat(s.DEVIATION_BADGE_SEPARATOR).concat(l);if(!f){it(q),f=!0,a=0;var V=function(){var e,n,i=null===(e=bi.current[H])||void 0===e?void 0:e.current,t=null===(n=yi.current[H])||void 0===n?void 0:n.current;return N||!i&&!!t?t:i};return null==d||d(),void(c=setTimeout(function(){var e,n,i,t,o,r,l;u||(e=V,n=function(){u||(d=null,g())},t=0,o=null,r=null,l=function(){if(!u){var s=e();if(s&&0!==s.getBoundingClientRect().height){var a=s.getBoundingClientRect(),c=a.top,d=a.height,f=null!==o&&Math.abs(c-o)<.5,v=null!==r&&Math.abs(d-r)<.5;if(f&&v){if(++t>=5)return void n()}else t=0;o=c,r=d,i=requestAnimationFrame(l)}else i=requestAnimationFrame(l)}},i=requestAnimationFrame(l),d=function(){return cancelAnimationFrame(i)})},300))}var z=null===(r=bi.current[H])||void 0===r?void 0:r.current,G=null===(p=yi.current[H])||void 0===p?void 0:p.current;if(z||G){var W=N||!z&&!!G,K=W?G:z,U=Pe?W?bn.current:Bn.current:xn.current;if(K&&U){var Y=K.getBoundingClientRect();if(0!==Y.height){var J=U.getBoundingClientRect(),X=Y.top-J.top+U.scrollTop-J.height/2+Y.height/2,$=(null==C?void 0:C.includes("-"))||(null==E?void 0:E.includes("-")),Q=function(){return e.__awaiter(void 0,void 0,void 0,function(){var n,i,t,o,r,a,c,d,f,v;return e.__generator(this,function(g){switch(g.label){case 0:return u?[2]:(h(),n=K instanceof Element?window.getComputedStyle(K).color:"",[z,G].forEach(function(e){e&&(e.style.transition="box-shadow 300ms ease-in-out",e.style.boxShadow="0 0 10px ".concat(n))}),setTimeout(function(){[z,G].forEach(function(e){e&&(e.style.boxShadow="")})},2e3),i=(null===(c=null===(a=S.evaluationResult)||void 0===a?void 0:a.deviations)||void 0===c?void 0:c[l])||S,t=(null===(d=S.evaluationResult)||void 0===d?void 0:d.evaluation_outputs)||S.evaluation_outputs,!!z&&!!G?(r=function(e,n){return Promise.race([e,new Promise(function(e){return setTimeout(e,n)})])},Pe?[4,Promise.all([Bn.current?r(s.waitForScrollIdle(Bn.current),600):Promise.resolve(),bn.current?r(s.waitForScrollIdle(bn.current),600):Promise.resolve()])]:[3,2]):(o=W?(null===(f=yi.current[$?H:D])||void 0===f?void 0:f.current)||G:(null===(v=bi.current[$?H:T])||void 0===v?void 0:v.current)||z,lo(o,function(){Mn({open:!0,anchorEl:o,displayImpact:Be.displayImpact,summary:e.__assign(e.__assign({},i),{evaluation_outputs:t})})},{skipScroll:!0}),null==we||we(),[2]));case 1:g.sent(),g.label=2;case 2:return Yi(q,!1,{toggleIfSame:!1,sourceSide:y?"right":"left",onReady:function(){var n,t,o,r;h();var l=W?(null===(n=yi.current[H])||void 0===n?void 0:n.current)||G:(null===(t=bi.current[H])||void 0===t?void 0:t.current)||z,s=(null===(o=bi.current[H])||void 0===o?void 0:o.current)||z,u=(null===(r=yi.current[H])||void 0===r?void 0:r.current)||G;s&&(s.style.scrollMarginTop="150px",s.scrollIntoView({behavior:"smooth",block:"start"})),u&&(u.style.scrollMarginTop="150px",u.scrollIntoView({behavior:"smooth",block:"start"})),Mn({open:!0,anchorEl:l,displayImpact:Be.displayImpact,summary:e.__assign({},i)}),null==we||we()}}),[2]}})})};Math.abs(U.scrollTop-X)<=2?Q():s.scrollAndWait(U,X,Q)}else++a<2?c=setTimeout(g,100):h()}else++a<2?c=setTimeout(g,100):h()}else++a<2?c=setTimeout(g,100):h()}else++a<2?c=setTimeout(g,100):h()}else++a<2?c=setTimeout(g,100):h()}};return c=setTimeout(g,100),function(){u=!0,c&&clearTimeout(c),null==d||d()}}}},[Be,di,ui,ai,Pe,Xi,Yi,Mn,Ot]),i.useEffect(function(){var n,i,t;if(Ln.open){var o=Ln.anchorEl;if(o&&!o.isConnected){var r=function(e){for(var n,i=0,t=Object.entries(e);i<t.length;i++){var r=t[i],l=r[0];if((null===(n=r[1].current)||void 0===n?void 0:n.textContent)===o.textContent)return l}return null},l=(null===(n=o.dataset)||void 0===n?void 0:n.deviationRefId)||r(bi.current)||r(yi.current);if(l){var s=(null===(i=yi.current[l])||void 0===i?void 0:i.current)||(null===(t=bi.current[l])||void 0===t?void 0:t.current);s&&s.isConnected&&Mn(function(n){return e.__assign(e.__assign({},n),{anchorEl:s})})}}}},[Ln.open,Ln.anchorEl,nn,Je,Xi]);var fo=Dn.open,vo=Dn.sectionIdx,go=Dn.isOrphan,po=Dn.badgeStyle,ho=Dn.anchorEl,mo=Dn.sectionAnchorEl;i.useEffect(function(){var n;if(be.isStreamingEnabled&&fo&&null!=vo&&vo!==at){var i="string"==typeof vo?vo.split(s.DEVIATION_BADGE_SEPARATOR)[0]:null,t=function(e,n){var i;if(!e||!Array.isArray(e))return null;for(var o=0,r=e;o<r.length;o++){var l=r[o];if(l.id===n)return l;if(null===(i=l.subsections)||void 0===i?void 0:i.length){var s=t(l.subsections,n);if(s)return s}}return null},o=i&&"string"==typeof i?t(ui,i):null,r=i&&"string"==typeof i?t(ai,i):null,l="number"==typeof vo?ui[vo]||null:o||i&&((null===(n=null==pe?void 0:pe.nodes)||void 0===n?void 0:n[i])||(null==pe?void 0:pe[i]))||null,u="number"==typeof vo?ai[vo]||null:r,a=wt(ho,l,u,vo,go,po);On(function(n){return n.open?s.safeStringify(n.cognitiveData)===s.safeStringify(a.cognitiveData)&&s.safeStringify(n.deviationData)===s.safeStringify(a.deviationData)&&n.sectionTitle===a.sectionTitle&&n.refSectionTitle===a.refSectionTitle?n:e.__assign(e.__assign(e.__assign({},n),a),{open:!0,anchorEl:n.anchorEl,sectionAnchorEl:n.sectionAnchorEl}):n})}},[fo,vo,go,po,ho,mo,ui,ai,wt]);var So=i.useCallback(function(e){var i=e.section,t=e.keyPath,o=e.depth,r=void 0===o?0:o,l=e.columnKey,s=void 0===l?"left":l,u=e.parentNodeId,a=void 0===u?"":u,c=e.sectionOffset;return n.jsx(x.default,{section:i,keyPath:t,depth:r,columnKey:s,parentNodeId:a,sectionOffset:c})},[]),Ro=i.useMemo(function(){return ui.map(function(e,i){var t,o=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),r=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return o&&r&&Pe?null:n.jsx(_.default,{section:e,idx:i},null!==(t=null==e?void 0:e.id)&&void 0!==t?t:"left-row-".concat(i))})},[ui]),xo=i.useMemo(function(){return ai.map(function(e,i){var t,o=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),r=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return o&&r&&Pe?null:n.jsx(b.default,{section:e,idx:i},null!==(t=null==e?void 0:e.id)&&void 0!==t?t:"right-row-".concat(i))})},[ai]),_o=i.useRef(It);i.useEffect(function(){_o.current=It},[It]);var bo=i.useRef(Xi);i.useEffect(function(){bo.current=Xi},[Xi]);var yo=i.useRef(so);i.useEffect(function(){yo.current=so},[so]);var Co=i.useRef(no);i.useEffect(function(){Co.current=no},[no]);var Eo=i.useRef(nt);i.useEffect(function(){Eo.current=nt},[nt]);var Ao=i.useRef(et);i.useEffect(function(){Ao.current=et},[et]);var Bo=i.useRef(So);i.useEffect(function(){Bo.current=So},[So]);var wo=i.useRef(Ui);i.useEffect(function(){wo.current=Ui},[Ui]);var Io=i.useMemo(function(){return{isGuidelineMode:ri,maintainRelativeOrder:!!Pe,showDeviationBadges:qe,isProposingFix:Te,proposingFixNodeId:De,isRedlineFlow:Oe,isSideBySide:Oi,activeSideBySideSection:Li,scrollSyncLocked:nn,toggleScrollSyncLocked:ot,summaryPopupAnchorEl:Ln.anchorEl,connectedSections:Je,proposedSections:ui,existingSections:ai,deviationNumberRegistry:fi,deviationParentRegistry:vi,treeData:pe,displayConfig:be,resolvedMarkdownStyles:Rn,unifiedNumbering:rt,expandedSections:Xi,expandedSubSections:Qi,setExpandedSubSections:Zi,getSectionCompareStyle:Nt,getSubSectionCompareStyle:Lt,getBadgeRef:Ti,getSectionRowRef:wi,getSubSectionRef:Ii,sectionLeftRefs:xi,sectionRightRefs:_i,sectionRowRefs:Bi,sectionRightRowRefs:Ci,subSectionLeftRefs:Ei,subSectionRightRefs:Ai,lhsBadgeRefs:bi,rhsBadgeRefs:yi,openMoreFunctionsPopup:ht,handleOpenSummaryPopup:mt,openSummaryPopup:mt,handleCloseSummaryPopup:St,toggleSection:Rt,handleSubSectionToggle:xt,renderSubSectionAccordion:_t,resetSideBySide:bt,setConnectedSections:Xe,setConnectedLines:Ze,cachedConnectedPositions:fn,showDeviationNavigation:oo,showOpenNodeRef:ro,deviationNodeIdToView:null==Be?void 0:Be.id,deviationTargetParentId:uo}},[ri,Pe,qe,Te,De,Oe,Oi,Li,nn,ot,Ln.anchorEl,Je,ui,ai,fi,be,Rn,rt,Xi,Qi,Zi,Nt,Lt,Ti,wi,Ii,oo,ro,Be,uo]);return n.jsx(C.CompareContextProvider,e.__assign({value:Io},{children:n.jsxs(t.Box,e.__assign({ref:_n,sx:{display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif',overflow:"visible",position:"relative"}},{children:[Ve&&n.jsx(t.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(f.default,{})})),Ln.open&&n.jsx(y.default,{open:Ln.open,anchorEl:Ln.anchorEl,containerEl:jt.current,clipTopEl:ln.current,scrollContainerEl:xn.current,onClose:no,summary:Ln.summary,displayImpact:Ln.displayImpact,isScrollLocked:nn}),n.jsx(d.default,{open:Fn.open,anchorEl:Fn.anchorEl,maintainRelativeOrder:!!Pe,sectionTitle:Fn.sectionTitle,referenceSectionTitle:Fn.refSectionTitle,onClose:Kn,onOpenCognitiveCompare:zn,onOpenSideBySide:eo,onConnect:Tt,isConnected:io,isOrphan:!ri&&Fn.isOrphan}),Dn.open&&n.jsx(c.default,{open:Dn.open,popupRef:Vn,position:kn,popupConfig:Ce,onClose:function(){Pn(null),On(function(n){return e.__assign(e.__assign({},n),{open:!1})}),Hn(null)},markdownStyles:Re,sectionTitle:ei,referenceSectionTitle:ii,cognitiveData:Dn.cognitiveData,anchorEl:Dn.anchorEl,sectionAnchorEl:Dn.sectionAnchorEl,scrollContainerEl:xn.current,badgeStyle:Dn.badgeStyle,docData:Dn.docData,deviationData:Dn.deviationData,isLoading:Dn.isLoading}),n.jsx(t.Snackbar,e.__assign({open:!!We,autoHideDuration:8e3,onClose:function(){return Ke(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(t.Alert,e.__assign({onClose:function(){return Ke(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:We}))})),n.jsx(R.default,{componentHeaderText:ge,displayConfig:be,maintainRelativeOrder:Pe,onCollapseAll:Ut,showCollapseAll:Yt,onToggleView:function(e){ze(!0),setTimeout(function(){Ne(!e),null==ye||ye(!e),tn(!1),Ui(),qn(),Xe(new Set),Ze([]),fn.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){ze(!1)},600)})})},50)}}),n.jsx(t.Box,e.__assign({ref:xn,onScroll:Kt,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:Pe?"visible":"auto",borderTop:st&&ut?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(t.Box,e.__assign({sx:e.__assign({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},Pe?{flex:1}:{})},{children:n.jsxs(t.Box,e.__assign({ref:rn,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},Pe?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(I.default,{svgContainerRef:on,svgDimensions:Wt,isResizing:ki,overallConnector:zt,rootDeviationStyle:ft,lines:Ht,isSideBySide:Oi,activeSideBySideSection:Li,isArrowVisible:Fi,maintainRelativeOrder:Pe,proposedSections:ui,existingSections:ai,cognitivePopup:Dn,activeBadgeId:Nn,closeCognitivePopup:Wn,setActiveBadgeId:Hn,openCognitivePopupFromState:Gn,buildSectionPopupState:wt,connectedLines:Qe,pathRefs:dn}),n.jsxs(t.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)"},Pe?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(t.Box,e.__assign({ref:ln,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center",minHeight:"40px",overflow:"hidden",minWidth:0}},{children:n.jsx(t.Tooltip,e.__assign({title:Qn,placement:"top"},{children:n.jsx(t.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:Qn}))}))})),n.jsxs(t.Box,e.__assign({ref:Bn,onScroll:Kt,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},Pe?{maxHeight:"calc(100vh - 250px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-180px",pr:"192px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:En,style:{width:"100%",height:"0px",flexShrink:0}}),pi&&Ro,n.jsx("div",{ref:An,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),n.jsx(t.Box,e.__assign({ref:jt,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:n.jsx(t.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:n.jsxs(t.Box,e.__assign({onClick:function(n){n.stopPropagation(),Dn.open&&Nn===at?Wn():(Hn(at),Gn(wt(n.currentTarget,{title:"",content:"",evaluationResult:ct,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,at,!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!=dt?dt:n.jsx(v.default,{}),n.jsx(t.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:Dn.open&&Nn===at?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),n.jsxs(t.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},Pe?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[Ni&&n.jsx(l.default,{sections:11}),n.jsx(t.Box,e.__assign({ref:sn,sx:e.__assign({p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center"},Pe?e.__assign({maxHeight:"calc(100vh - 250px)",overflowY:"auto",overflowX:"hidden",minHeight:0},ri?{"&::-webkit-scrollbar":{width:"6px",display:"block"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{background:"#CBD5E1",borderRadius:"10px"},"&::-webkit-scrollbar-thumb:hover":{background:"#94A3B8"},scrollbarWidth:"thin",scrollbarColor:"#CBD5E1 transparent"}:{"&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}):{})},{children:n.jsx(t.Tooltip,e.__assign({title:ti,placement:"top"},{children:n.jsx(t.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:ti}))}))})),n.jsxs(t.Box,e.__assign({ref:bn,onScroll:Kt,sx:e.__assign({p:ri?"0px":"12px",display:"flex",flexDirection:"column"},Pe?e.__assign(e.__assign({maxHeight:"calc(100vh - 250px)"},!ri&&{flex:1}),{overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-150px",pl:"165px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}):{})},{children:[n.jsx("div",{ref:yn,style:{width:"100%",height:"0px",flexShrink:0}}),ri?n.jsx(T.default,{guidelinesData:je,deviationData:Ae,connectedSections:Je,proposedSections:ui}):pi&&xo,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"),i=require("react"),t=require("@mui/material"),o=require("lucide-react"),r=require("../../assests/svg/ButtonCognitiveIcon.js"),l=require("./OverlayComponent.js"),s=require("./CognitiveComparehelpers.js"),u=require("./CognitiveCompareConfig.js"),a=require("./CognitiveCompareConstants.js"),c=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"),m=require("./hooks/useAccordionState.js"),S=require("./hooks/useDeviationNavigation.js"),R=require("./components/CompareHeader.js"),x=require("./components/SubSectionAccordion.js"),_=require("./components/LHSSectionRow.js"),y=require("./components/RHSSectionRow.js"),b=require("./components/CognitiveSummaryPopup.js"),C=require("./CompareContext.js"),E=require("./hooks/useStyles.js"),A=require("./hooks/useResizeHandler.js"),B=require("./hooks/useLinesCalculator.js"),w=require("./hooks/useSideBySide.js"),I=require("./components/SvgConnectors.js"),T=require("./Guidelines/components/GuidelinePanel.js");exports.SHARED_MARKDOWN_STYLES=u.SHARED_MARKDOWN_STYLES,exports.default=function(D){var O,F,j,k,P,N,M,L,q,H,V,G,z,W,K,Y,U,J,X,$,Q,Z,ee,ne,ie,te,oe,re,le,se,ue,ae,ce,de,ve,fe=D.componentHeaderText,ge=void 0===fe?a.DEFAULT_COMPONENT_HEADER_TEXT:fe,pe=D.treeData,he=D.comparisonConfig,me=D.leftColumnTitleText,Se=D.rightColumnTitleText,Re=D.markdownStyles,xe=D.resetTrigger,_e=D.displayConfig,ye=void 0===_e?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1,displayEmailNotifier:!0,isStreamingEnabled:!1}:_e,be=D.onMaintainRelativeOrderChange,Ce=D.popupConfig,Ee=D.deviationData,Ae=void 0===Ee?{}:Ee,Be=D.deviationNodeIdToView,we=D.resetDeviationNodeId,Ie=D.isProposingFix,Te=void 0!==Ie&&Ie,De=D.proposingFixNodeId,Oe=D.isRedlineFlow,Fe=D.badgeStyleOverride,je=D.guidelinesData,ke=i.useState(ye.maintainRelativeOrder),Pe=ke[0],Ne=ke[1],Me=null!==(O=null==ye?void 0:ye.expandLevels)&&void 0!==O?O:0,Le=!!(null==ye?void 0:ye.expandAllSections),qe=!!Pe||!!(null==ye?void 0:ye.showDeviationBadges),He=i.useState(!1),Ve=He[0],Ge=He[1],ze=i.useState(null),We=ze[0],Ke=ze[1],Ye=i.useState(null===(j=null!==(F=null==pe?void 0:pe.newEvaluationResult)&&void 0!==F?F:null==ye?void 0:ye.enableDeviationSchemaBackwardCompatibility)||void 0===j||j)[0],Ue=i.useState(new Set),Je=Ue[0],Xe=Ue[1],$e=i.useState([]),Qe=$e[0],Ze=$e[1],en=i.useState(!1),nn=en[0],tn=en[1],on=i.useRef(null),rn=i.useRef(null),ln=i.useRef(null),sn=i.useRef(null),un=i.useRef(null),an=i.useRef(!1),cn=i.useRef(null),dn=i.useRef({}),vn=i.useRef([]),fn=i.useRef(function(){}),gn=i.useRef(null),pn=i.useRef(function(){}),hn=i.useMemo(function(){return JSON.stringify(Ae||{})},[JSON.stringify(Ae)]),mn=i.useMemo(function(){return Ae||{}},[hn]),Sn=i.useMemo(function(){return(null==pe?void 0:pe.cognitive_decisioning)||{}},[pe]),Rn=i.useMemo(function(){return e.__assign(e.__assign({},u.SHARED_MARKDOWN_STYLES),Re)},[Re]),xn=i.useRef(null),_n=i.useRef(null),yn=i.useRef(null),bn=i.useRef(null),Cn=i.useRef(null),En=i.useRef(null),An=i.useRef(null),Bn=i.useRef(null),wn=i.useRef(null),In=i.useRef(null),Tn=p.useComparePopups(xn),Dn=Tn.cognitivePopup,On=Tn.setCognitivePopup,Fn=Tn.moreFunctions,jn=Tn.setMoreFunctions,kn=Tn.position,Pn=Tn.setPosition,Nn=Tn.activeBadgeId,Mn=Tn.summaryPopup,Ln=Tn.setSummaryPopup,qn=Tn.closeSummaryPopup,Hn=Tn.setActiveBadgeId,Vn=Tn.popupRef,Gn=Tn.handleOpenCognitiveCompare,zn=Tn.openCognitivePopupFromState,Wn=Tn.closeCognitivePopup,Kn=Tn.closeMoreFunctionsPopup,Yn=i.useMemo(function(){var e,n,i,t,o,r,l;return{fields:null!==(e=null==he?void 0:he.fields)&&void 0!==e?e:u.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(i=null===(n=null==he?void 0:he.thresholds)||void 0===n?void 0:n.high)&&void 0!==i?i:u.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(o=null===(t=null==he?void 0:he.thresholds)||void 0===t?void 0:t.medium)&&void 0!==o?o:u.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(l=null===(r=null==he?void 0:he.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:u.DEFAULT_COMPARISON_CONFIG.thresholds.exact}}},[he]),Un=i.useState(null),Jn=Un[0];Un[1];var Xn=null===(N=null===(k=null==pe?void 0:pe.documents)||void 0===k?void 0:k[null===(P=null==pe?void 0:pe.input_index_map)||void 0===P?void 0:P[0]])||void 0===N?void 0:N.title,$n=null===(q=null===(M=null==pe?void 0:pe.documents)||void 0===M?void 0:M[null===(L=null==pe?void 0:pe.input_index_map)||void 0===L?void 0:L[1]])||void 0===q?void 0:q.title,Qn=s.safeStringify(me||Xn||"Uploaded Contract"),Zn=null===(z=null===(G=null===(H=null==pe?void 0:pe.documents)||void 0===H?void 0:H[null===(V=null==pe?void 0:pe.input_index_map)||void 0===V?void 0:V[0]])||void 0===G?void 0:G.metadata)||void 0===z?void 0:z.file_name,ei=s.safeStringify(Zn),ni=null===(U=null===(Y=null===(W=null==pe?void 0:pe.documents)||void 0===W?void 0:W[null===(K=null==pe?void 0:pe.input_index_map)||void 0===K?void 0:K[1]])||void 0===Y?void 0:Y.metadata)||void 0===U?void 0:U.file_name,ii=s.safeStringify(ni),ti=s.safeStringify(Se||$n||"Reference Template"),oi=g.useCognitiveTreeData(pe,Pe,mn,Yn,Ye,je),ri=oi.isGuidelineMode,li=oi.activeProposed,si=oi.existingRule,ui=oi.proposedSections,ai=oi.existingSections,ci=oi.visibleFields,di=oi.parentDeviationRecord,vi=oi.deviationNumberRegistry,fi=oi.deviationParentRegistry,gi=oi.parseError;i.useEffect(function(){gi&&Ke("Failed to load comparison: ".concat(gi))},[gi]);var pi=ui.length>0||ai.length>0,hi=i.useMemo(function(){if(!Oe)return"off";var e=0,n=0,i=function(t){Array.isArray(t)&&t.forEach(function(t){var o,r=(null==t?void 0:t.content)||"";s.hasMeaningfulRedlineTags(r)&&(e+=1,n+=String(r).length),(null===(o=null==t?void 0:t.subsections)||void 0===o?void 0:o.length)&&i(t.subsections)})};return i(ui),i(ai),"".concat(e,":").concat(n)},[Oe,ui,ai]);i.useEffect(function(){if(ui.length||ai.length)if(Le){var e={},n={},i=function(i,t){i.forEach(function(i,o){var r,l=Pe?"".concat(t,"-").concat(o):String(o);e[l]=!0;var s=function(e,i){null==e||e.forEach(function(e,t){var o,r="".concat(i,"-").concat(t);n[r]=!0,(null===(o=e.subsections)||void 0===o?void 0:o.length)&&s(e.subsections,r)})};(null===(r=i.subsections)||void 0===r?void 0:r.length)&&s(i.subsections,String(o))})};i(ui,"left"),i(ai,"right"),$i(e),Zi(n)}else if(Me>0){var t={},o={},r=function(e,n,i){e.forEach(function(e,r){var l;if(i>=1){var s=Pe?"".concat(n,"-").concat(r):String(r);t[s]=!0}var u=function(e,n,t){t>i||null==e||e.forEach(function(e,i){var r,l="".concat(n,"-").concat(i);o[l]=!0,(null===(r=e.subsections)||void 0===r?void 0:r.length)&&u(e.subsections,l,t+1)})};(null===(l=e.subsections)||void 0===l?void 0:l.length)&&i>=2&&u(e.subsections,String(r),2)})};r(ui,"left",Me),r(ai,"right",Me),$i(t),Zi(o)}},[Le,Me,ui,ai,Pe]);var mi=h.useSectionRefs(ci.map(function(e){return e.key}),Math.max(ui.length,ai.length)),Si=mi.leftRefs,Ri=mi.rightRefs,xi=mi.sectionLeftRefs,_i=mi.sectionRightRefs,yi=mi.lhsBadgeRefs,bi=mi.rhsBadgeRefs,Ci=mi.sectionRightRowRefs,Ei=mi.subSectionLeftRefs,Ai=mi.subSectionRightRefs,Bi=mi.sectionRowRefs,wi=mi.getSectionRowRef,Ii=mi.getSubSectionRef,Ti=mi.getBadgeRef,Di=w.useSideBySide({isGuidelineMode:ri,maintainRelativeOrder:Pe,proposedSections:ui,existingSections:ai,leftContainerRef:Bn,rightContainerRef:yn,scrollContainerRef:xn,sectionLeftRefs:xi,sectionRightRefs:_i,subSectionLeftRefs:Ei,subSectionRightRefs:Ai,lhsBadgeRefs:yi,rhsBadgeRefs:bi,sectionRowRefs:Bi,sectionRightRowRefs:Ci,rhsTopSpacerRef:bn,rhsBottomSpacerRef:Cn,lhsTopSpacerRef:En,lhsBottomSpacerRef:An,calculateLinesRef:fn,setConnectedSections:Xe,setConnectedLines:Ze,cachedConnectedPositions:vn,closeMoreFunctionsPopup:Kn,setErrorToast:Ke,moreFunctions:Fn,closeSummaryPopup:qn}),Oi=Di.isSideBySide,Fi=Di.isArrowVisible,ji=Di.setIsArrowVisible,ki=Di.isResizing,Pi=Di.setIsResizing,Ni=Di.isSideBySideLoading,Mi=Di.activeSideBySideSection,Li=Di.scrollLock,qi=Di.sideBySideCacheRef,Hi=Di.isSideBySideRef,Vi=Di.activeSideBySideRightSectionRef,Gi=Di.activeSideBySideSectionRef,zi=Di.sideBySideLineRef,Wi=Di.highlightedClauseRefs,Ki=Di.clearClauseHighlight,Yi=Di.resetSideBySide,Ui=Di.activateSideBySide,Ji=m.useAccordionState({maintainRelativeOrder:!!Pe,proposedSections:ui,existingSections:ai,activeSideBySideSection:Mi,connectedSections:Je,resetSideBySide:Yi,setConnectedSections:Xe,setConnectedLines:Ze,cachedConnectedPositions:vn,svgContainerRef:on,isAnimatingRef:an,animationTimerRef:cn,calculateLinesRef:fn,sectionLeftRefs:xi,sectionRightRefs:_i,subSectionLeftRefs:Ei,subSectionRightRefs:Ai}),Xi=Ji.expandedSections,$i=Ji.setExpandedSections,Qi=Ji.expandedSubSections,Zi=Ji.setExpandedSubSections,et=Ji.handleSubSectionToggle,nt=Ji.toggleSection,it=Ji.forceExpandCrossWiredSections,tt=function(){var e,n;if(null!=Mi){var i=null===(e=xi.current[Mi])||void 0===e?void 0:e.current,t=null===(n=_i.current[Mi])||void 0===n?void 0:n.current,o=yn.current;if(i&&t&&o){var r=i.getBoundingClientRect(),l=t.getBoundingClientRect(),s=o.getBoundingClientRect(),u=r.top-s.top,a=l.top-s.top-u;o.scrollBy({top:a,behavior:"smooth"})}}},ot=i.useCallback(function(e){null==e||e.stopPropagation(),tn(function(e){var n=!e;return n&&requestAnimationFrame(function(){tt()}),n})},[tt]);i.useEffect(function(){Oe&&"off"!==hi&&"0:0"!==hi&&(qi.current=null,vn.current=[],requestAnimationFrame(function(){var e;null===(e=fn.current)||void 0===e||e.call(fn)}))},[Oe,hi]);var rt=i.useMemo(function(){var e=new Map,n=new Map,i=1;if(Pe)ui.forEach(function(n){!n.title&&!n.content||n.id&&e.set(n.id,i++)}),ai.forEach(function(t){if(t.id&&!(!t.title&&!t.content)){var o=ui.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(t.selfIndex)});if(o.length>0){var r=o.map(function(n){return e.get(n.id)}).filter(Boolean);n.set(t.id,r.join(", "))}else n.set(t.id,String(i++))}});else for(var t=Math.max(ui.length,ai.length),o=0;o<t;o++){var r=ui[o],l=ai[o];r?(e.set(r.id,i),l&&n.set(l.id,String(i)),i++):l&&n.set(l.id,String(i++))}return{leftNums:e,rightNums:n}},[ui,ai,Pe]),lt=si.analysis,st=s.safeStringify(null===(X=null===(J=null==lt?void 0:lt.rule_difference_comparison)||void 0===J?void 0:J.summary)||void 0===X?void 0:X.overall_summary),ut=!!st.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),at=null!==($=null==pe?void 0:pe.base_root_id)&&void 0!==$?$:"-1";null==pe||pe[at];var ct=Ye?null!==(ae=null!==(le=Ae&&(null===(re=null==Ae?void 0:Ae[at])||void 0===re?void 0:re.evaluation_result))&&void 0!==le?le:null===(ue=null===(se=null==pe?void 0:pe.nodes)||void 0===se?void 0:se[at])||void 0===ue?void 0:ue.evaluation_result)&&void 0!==ae?ae:null:null!==(oe=null!==(ee=Ae&&(null===(Z=null===(Q=null==Ae?void 0:Ae[at])||void 0===Q?void 0:Q.evaluation_result)||void 0===Z?void 0:Z[0]))&&void 0!==ee?ee:null===(te=null===(ie=null===(ne=null==pe?void 0:pe.nodes)||void 0===ne?void 0:ne[at])||void 0===ie?void 0:ie.evaluation_result)||void 0===te?void 0:te[0])&&void 0!==oe?oe:null,dt=s.extractDeviationScore(ct),vt=s.generateColorPalette(null!==(ve=null===(de=null===(ce=null==ct?void 0:ct.evaluation_outputs)||void 0===ce?void 0:ce.metadata)||void 0===de?void 0:de.label_color)&&void 0!==ve?ve:a.DEFAULT_DEVIAION_COLOR);if(Fe){var ft=Fe(dt);ft&&(vt=e.__assign(e.__assign({},vt),{badgeBg:ft.bg,badgeText:ft.text,badgeBorder:ft.border}))}var gt=i.useRef(Yi);i.useEffect(function(){gt.current=Yi},[Yi]);var pt=i.useRef(Wn);i.useEffect(function(){pt.current=Wn},[Wn]);var ht=i.useCallback(function(e,n,i,t,o,r){return _o.current(e,n,i,t,o,r)},[]),mt=i.useCallback(function(e,n,i,t,o){return bo.current(e,n,i,t,o)},[]),St=i.useCallback(function(){return Co.current()},[]),Rt=i.useCallback(function(e,n){return Eo.current(e,n)},[]),xt=i.useCallback(function(e){return Ao.current(e)},[]),_t=i.useCallback(function(e){return Bo.current(e)},[]),yt=i.useCallback(function(){return wo.current()},[]),bt=i.useCallback(function(){var e,n;Ki(),null===(e=gt.current)||void 0===e||e.call(gt),tn(!1),Xe(new Set),Ze([]),vn.current=[],Vt([]),zt(null),Ln(a.EMPTY_SUMMARY_POPUP_STATE),null===(n=pt.current)||void 0===n||n.call(pt),requestAnimationFrame(function(){var e;null===(e=fn.current)||void 0===e||e.call(fn)})},[]),Ct=i.useRef(bt);i.useEffect(function(){Ct.current=bt},[bt]),i.useEffect(function(){xe&&Ct.current()},[xe]);var Et=i.useMemo(function(){return{documents:null==pe?void 0:pe.documents,input_index_map:null==pe?void 0:pe.input_index_map}},[JSON.stringify(null==pe?void 0:pe.documents),JSON.stringify(null==pe?void 0:pe.input_index_map)]),At=i.useRef(pe);i.useEffect(function(){At.current=pe},[pe]);var Bt=i.useRef(Sn);i.useEffect(function(){Bt.current=Sn},[Sn]);var wt=i.useCallback(function(n,i,t,o,r,l,u){var a,c,d,v,f,g,p,h,m,S,R,x,_=s.safeStringify(null==i?void 0:i.id)||s.safeStringify(null==t?void 0:t.id)||"",y=(_?null===(a=Bt.current)||void 0===a?void 0:a[_]:null)||(null==i?void 0:i.cognitiveData)||(null==t?void 0:t.cognitiveData)||{section_id:_,decisioning:[],gap:[],relevance_score:0},b=null!==(d=null===(c=Bi.current[o])||void 0===c?void 0:c.current)&&void 0!==d?d:null,C=function(){var n,r,l=(null==i?void 0:i.evaluationResult)||(null==t?void 0:t.evaluationResult)||null,u=function(n){var i=function(e){if(!e||"object"!=typeof e)return null;var n=null==e?void 0:e.deviation_entries;if(n&&"object"==typeof n){var i=Object.keys(n).sort(function(e,n){return Number(e)-Number(n)})[0];if(i&&n[i])return n[i]}var t=Object.keys(e).filter(function(e){return/^\d+$/.test(e)}).sort(function(e,n){return Number(e)-Number(n)});if(t.length&&e[t[0]])return e[t[0]];var o=null==e?void 0:e.deviations;if(o&&"object"==typeof o){var r=Object.keys(o).sort(function(e,n){return Number(e)-Number(n)})[0];if(r&&o[r])return o[r]}return null}(n);return i?e.__assign(e.__assign({},n),{deviation_summary:(null==n?void 0:n.deviation_summary)||(null==i?void 0:i.deviation_summary),deviation_title:(null==n?void 0:n.deviation_title)||(null==i?void 0:i.deviation_title),deviation_impact:(null==n?void 0:n.deviation_impact)||(null==i?void 0:i.deviation_impact),deviation_explanation:(null==n?void 0:n.deviation_explanation)||(null==i?void 0:i.deviation_explanation),evaluation_outputs:(null==n?void 0:n.evaluation_outputs)||(null==i?void 0:i.evaluation_outputs),cognitive_decisioning:(null==n?void 0:n.cognitive_decisioning)||(null==i?void 0:i.cognitive_decisioning)}):n};if(!("string"==typeof o&&o.includes(s.DEVIATION_BADGE_SEPARATOR)))return u(l);var a=o.split(s.DEVIATION_BADGE_SEPARATOR)[1];if(!a)return l;var c=(null==i?void 0:i.evaluationResult)||(null==t?void 0:t.evaluationResult)||{},d=(null===(n=null==c?void 0:c.deviation_entries)||void 0===n?void 0:n[a])||(null===(r=null==c?void 0:c.deviations)||void 0===r?void 0:r[a])||null;return d?e.__assign(e.__assign(e.__assign({},c),d),{deviation_summary:(null==d?void 0:d.deviation_summary)||(null==c?void 0:c.deviation_summary),deviation_title:(null==d?void 0:d.deviation_title)||(null==c?void 0:c.deviation_title),deviation_impact:(null==d?void 0:d.deviation_impact)||(null==c?void 0:c.deviation_impact),deviation_explanation:(null==d?void 0:d.deviation_explanation)||(null==c?void 0:c.deviation_explanation),evaluation_outputs:(null==d?void 0:d.evaluation_outputs)||(null==c?void 0:c.evaluation_outputs),cognitive_decisioning:(null==d?void 0:d.cognitive_decisioning)||(null==c?void 0:c.cognitive_decisioning)}):u(l)}(),E=(null!==(g=null===(f=null===(v=null==C?void 0:C.cognitive_decisioning)||void 0===v?void 0:v.decisioning_factors)||void 0===f?void 0:f.length)&&void 0!==g?g:0)>0||(null!==(m=null===(h=null===(p=null==C?void 0:C.cognitive_decisioning)||void 0===p?void 0:p.gaps_in_decision)||void 0===h?void 0:h.length)&&void 0!==m?m:0)>0,A=null!==(S=null==ye?void 0:ye.isLoading)&&void 0!==S&&S,B=!0;if(ri)if(C&&Object.keys(C).length>0){var w=Array.isArray(C)?C[0]:C,I=null===(x=null===(R=null==w?void 0:w.evaluation_outputs)||void 0===R?void 0:R.metadata)||void 0===x?void 0:x.is_orphan;!0!==I&&"true"!==I&&"Yes"!==I&&"yes"!==I||(B=!1)}else B=!1;return{isLoading:A&&!E,open:!0,sectionTitle:(null==i?void 0:i.title)?null==i?void 0:i.title:"No Counterpart",refSectionTitle:(null==t?void 0:t.title)?null==t?void 0:t.title:"No Counterpart",cognitiveData:y,anchorEl:n,sectionAnchorEl:b,badgeStyle:l||null,sectionIdx:o,docData:Et,deviationData:C,isOrphan:!!r,hasGuidelineMatches:B}},[Et,null==ye?void 0:ye.isLoading,ri]),It=i.useCallback(function(e,n,i,t,o,r){var l;if(e.stopPropagation(),Fn.open&&Fn.sectionIdx===o)Kn();else{var u=e.currentTarget,a="left";(null===(l=yn.current)||void 0===l?void 0:l.contains(u))&&(a="right");Ki(),Hi.current&&Yi(),Xe(new Set),Ze([]),vn.current=[],Wn(),Mn.open?no():qn(),requestAnimationFrame(function(){var e=function(){var e,n,i,t;if("string"==typeof o&&o.includes(s.DEVIATION_BADGE_SEPARATOR)){var r=o.split(s.DEVIATION_BADGE_SEPARATOR),l="".concat(r[0]).concat(s.DEVIATION_BADGE_SEPARATOR).concat(r[1]);return"right"===a?null===(e=bi.current[l])||void 0===e?void 0:e.current:null===(n=yi.current[l])||void 0===n?void 0:n.current}return"right"===a?null===(i=bi.current[o])||void 0===i?void 0:i.current:null===(t=yi.current[o])||void 0===t?void 0:t.current}()||u;jn(wt(e,n,t,o,i,r))})}},[Fn.open,Fn.sectionIdx,Kn,qn,wt]),Tt=i.useCallback(function(){var e=Fn.sectionIdx;Fn.isOrphan,Kn(),qn(),null!==e&&(it(e),Ki(),Hi.current&&Yi(),Ze([]),vn.current=[],Xe(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){fn.current&&fn.current()},50))},[Fn.sectionIdx,Fn.isOrphan,Kn,qn,Yi]),Dt=i.useCallback(function(){var e=un.current;if(e){un.current=null;var n=ui.findIndex(function(n){return n.id===e}),i=ai.findIndex(function(n){return n.id===e}),t=-1===n?s.findKeyPathByNodeId(ui,e):null,o=-1===i?s.findKeyPathByNodeId(ai,e):null,r=-1!==n?n:t?Number(t.split("-")[0]):-1,l=-1!==i?i:o?Number(o.split("-")[0]):-1,u=function(e,n,i,t){var o,r,l,s;return-1!==e?null!==(r=null===(o=i.current[e])||void 0===o?void 0:o.current)&&void 0!==r?r:null:n&&null!==(s=null===(l=t.current[n])||void 0===l?void 0:l.current)&&void 0!==s?s:null},a=function(e,n,i){void 0===i&&(i=30);var t=0,o=function(){var r=e();r&&0!==r.getBoundingClientRect().height?(Wi.current.add(r),s.scrollAndHighlightClause(r,n)):t++<i&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(Pe)-1!==r&&Bn.current&&a(function(){return u(n,t,xi,Ei)},Bn.current),-1!==l&&yn.current&&a(function(){return u(i,o,_i,Ai)},yn.current);else{var c=xn.current;if(!c)return;a(function(){return-1!==r?u(n,t,xi,Ei):u(i,o,_i,Ai)},c)}}},[ui,ai,Pe,xi,_i,Ei,Ai,Bn,yn,xn]),Ot=i.useCallback(function(n){if(n){Ki(),Yi(),Xe(new Set),Ze([]),vn.current=[],qn(),Wn();var i=ui.findIndex(function(e){return e.id===n}),t=ai.findIndex(function(e){return e.id===n}),o=-1===i?s.findKeyPathByNodeId(ui,n):null,r=-1===t?s.findKeyPathByNodeId(ai,n):null;if(-1!==i||o||-1!==t||r){var l=-1!==i?i:o?Number(o.split("-")[0]):-1,u=-1!==t?t:r?Number(r.split("-")[0]):-1;un.current=n,$i(function(n){var i,t=e.__assign({},n),o=!1;-1!==l&&(t[i=Pe?"left-".concat(l):String(l)]||(t[i]=!0,o=!0));-1!==u&&(t[i=Pe?"right-".concat(u):String(u)]||(t[i]=!0,o=!0));return o?t:n}),Zi(function(n){var i=e.__assign({},n),t=!1,l=function(e){for(var n=e.split("-"),o=n[0],r=1;r<n.length;r++)o+="-".concat(n[r]),i[o]||(i[o]=!0,t=!0)};return o&&l(o),r&&l(r),t?i:n}),setTimeout(function(){requestAnimationFrame(function(){un.current===n&&Ft.current()})},50)}else console.warn('scrollToAndHighlightClause: nodeId "'.concat(n,'" not found'))}},[ui,ai,Pe,$i,Zi,Yi,qn,Wn]),Ft=i.useRef(Dt);i.useEffect(function(){Ft.current=Dt},[Dt]);var jt=i.useRef(null);i.useEffect(function(){if(Jn){var e=Yn.fields.find(function(e){return e.analysisKey===Jn||e.key===Jn});if(e){var n=Si.current[e.key]||Ri.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[Jn,Yn.fields]);var kt=i.useCallback(function(e){var n,i,t,o,r,l,s,u,a,c=null===(n=null==lt?void 0:lt.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!c||!c[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var d=c[e],v=(null==d?void 0:d.relation)||(null===(t=null===(i=null==d?void 0:d.highlights)||void 0===i?void 0:i.ruleA_spans)||void 0===t?void 0:t.length)||(null===(r=null===(o=null==d?void 0:d.highlights)||void 0===o?void 0:o.ruleB_spans)||void 0===r?void 0:r.length)||(null==d?void 0:d.mappings)&&d.mappings.length>0;if(d.mappings){var f=d.mappings[0]||{};return{score:d.score,relation:f.relation||"",highlightsA:(null===(l=f.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(s=f.highlights)||void 0===s?void 0:s.ruleB_spans)||[],hasContent:!!v}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(u=d.highlights)||void 0===u?void 0:u.ruleA_spans)||[],highlightsB:(null===(a=d.highlights)||void 0===a?void 0:a.ruleB_spans)||[],hasContent:!!v}},[lt]),Pt=E.useStyleHelpers({proposedSections:ui,existingSections:ai,maintainRelativeOrder:Pe,cognitiveMap:Sn,deviationData:mn,treeData:pe,resolvedComparisonConfig:Yn,badgeStyleOverride:Fe}),Nt=Pt.getSectionCompareStyle,Mt=Pt.getSubSectionCompareStyle,Lt=Pt.getDeviationStyleByKey,qt=B.useLinesCalculator({containerRef:rn,leftContainerRef:Bn,rightContainerRef:yn,svgContainerRef:on,pathRefs:dn,leftHeaderRef:ln,rightHeaderRef:sn,proposedSections:ui,existingSections:ai,visibleFields:ci,leftRefs:Si,rightRefs:Ri,sectionLeftRefs:xi,sectionRightRefs:_i,subSectionLeftRefs:Ei,subSectionRightRefs:Ai,lhsBadgeRefs:yi,rhsBadgeRefs:bi,sectionRowRefs:Bi,expandedSections:Xi,expandedSubSections:Qi,connectedSections:Je,isSideBySide:Oi,activeSideBySideSection:Mi,maintainRelativeOrder:Pe,isGuidelineMode:ri,cognitiveMap:Sn,getSectionCompareStyle:Nt,getSubSectionCompareStyle:Mt,getDeviationStyleByKey:Lt,isArrowVisible:Fi,isAnimatingRef:an,isSideBySideRef:Hi,sideBySideCacheRef:qi,sideBySideLineRef:zi,activeSideBySideSectionRef:Gi,activeSideBySideRightSectionRef:Vi,connectedLines:Qe,setConnectedLines:Ze,cachedConnectedPositions:vn,calculateLinesRef:fn,resizeTimerRef:gn,scrollLock:Li,scrollSyncLocked:nn,handleResizeRef:pn,activeProposed:li,existingRule:si,analysisData:lt,pendingScrollTargetRef:wn,pendingScrollCallbackRef:In,resolvedComparisonConfig:Yn,getFieldData:kt}),Ht=qt.lines,Vt=qt.setLines,Gt=qt.overallConnector,zt=qt.setOverallConnector,Wt=qt.svgDimensions,Kt=qt.handleColumnScroll;i.useEffect(function(){Mn.anchorEl&&requestAnimationFrame(function(){requestAnimationFrame(function(){var e;null===(e=fn.current)||void 0===e||e.call(fn)})})},[Mn.anchorEl,nn]);var Yt=i.useCallback(function(){Ki(),tn(!1),$i({}),Zi({}),Yi(),Xe(new Set),Ze([]),vn.current=[],qn(),Wn(),Kn(),requestAnimationFrame(function(){fn.current&&fn.current()})},[$i,Zi,Yi,qn,Wn,Kn]);i.useEffect(function(){Oi||0!==Je.size||tn(!1)},[Oi,Je]);var Ut=i.useMemo(function(){return Object.values(Xi).some(Boolean)||Object.values(Qi).some(Boolean)},[Xi,Qi]),Jt=i.useRef(null),Xt=i.useRef(0),$t=i.useRef(0),Qt=i.useRef(0),Zt=A.useResizeHandler({timerRef:Jt,ruleComponentRef:_n,scrollContainerRef:xn,containerRef:rn,maintainRelativeOrder:Pe,proposedSections:ui,existingSections:ai,isSideBySideRef:Hi,activeSideBySideSectionRef:Gi,activeSideBySideRightSectionRef:Vi,sectionRowRefs:Bi,sectionRightRowRefs:Ci,sectionLeftRefs:xi,sectionRightRefs:_i,subSectionLeftRefs:Ei,subSectionRightRefs:Ai,lhsBadgeRefs:yi,rhsBadgeRefs:bi,leftContainerRef:Bn,rightContainerRef:yn,calculateLinesRef:fn,handleResizeRef:pn,setIsResizing:Pi,setIsArrowVisible:ji,sideBySideCacheRef:qi,cachedConnectedPositions:vn}).handleResize;i.useEffect(function(){pn.current=Zt},[Zt,pn]),i.useEffect(function(){var e=function(e,n,i,t,o){n.current=e.getBoundingClientRect().width;var r=new ResizeObserver(function(e){null!==i.current&&cancelAnimationFrame(i.current),i.current=requestAnimationFrame(function(){var r,l,s;i.current=null;var u=e[e.length-1];if(u){var a=null!==(s=null===(l=null===(r=u.borderBoxSize)||void 0===r?void 0:r[0])||void 0===l?void 0:l.inlineSize)&&void 0!==s?s:u.contentRect.width;Math.abs(a-n.current)<1?o():(n.current=a,t())}})});return r.observe(e),r},n={current:null},i={current:null},t={current:null},o=[],r=[n,i,t];return _n.current&&o.push(e(_n.current,Xt,n,function(){return pn.current()},function(){})),xn.current&&o.push(e(xn.current,$t,i,function(){return pn.current()},function(){return fn.current()})),rn.current&&o.push(e(rn.current,Qt,t,function(){return pn.current()},function(){return fn.current()})),function(){o.forEach(function(e){return e.disconnect()}),r.forEach(function(e){null!==e.current&&(cancelAnimationFrame(e.current),e.current=null)})}},[]),i.useEffect(function(){Hi.current=Oi},[Oi]),i.useEffect(function(){Gi.current=Mi},[Mi]);var eo=i.useCallback(function(){var e,n=Fn.sectionIdx,i=Fn.isOrphan;if(qn(),null!=n){var t="left";Fn.anchorEl&&(null===(e=yn.current)||void 0===e?void 0:e.contains(Fn.anchorEl))&&(t="right"),it(n),Ui(n,i,{sourceSide:t})}},[Ui,Fn.isOrphan,Fn.sectionIdx,Fn.anchorEl,qn]),no=i.useCallback(function(){qn(),Yi(),Xe(new Set),Ze([]),vn.current=[]},[qn,Yi]),io=null!==Fn.sectionIdx&&Je.has(Fn.sectionIdx),to=S.useDeviationNavigation({proposedSections:ui,existingSections:ai,parentDeviationRecord:di,expandedSections:Xi,maintainRelativeOrder:!!Pe,scrollContainerRef:xn,leftContainerRef:Bn,rightContainerRef:yn,lhsBadgeRefs:yi,rhsBadgeRefs:bi}),oo=to.showDeviationNavigation,ro=to.showOpenNodeRef,lo=to.adjustScrollForPopup,so=i.useCallback(function(e,n,i,t,o){var r,l="string"==typeof t?s.safeStringify(t).trim():s.safeStringify(null==t?void 0:t.deviation_summary).trim(),u=e.currentTarget;Wn();var a="left";(null===(r=yn.current)||void 0===r?void 0:r.contains(u))&&(a="right");var c=function(){var e,i,t,o;if("string"==typeof n&&n.includes(s.DEVIATION_BADGE_SEPARATOR)){var r=n.split(s.DEVIATION_BADGE_SEPARATOR),l="".concat(r[0]).concat(s.DEVIATION_BADGE_SEPARATOR).concat(r[1]);return"right"===a?null===(e=bi.current[l])||void 0===e?void 0:e.current:null===(i=yi.current[l])||void 0===i?void 0:i.current}return"right"===a?null===(t=bi.current[n])||void 0===t?void 0:t.current:null===(o=yi.current[n])||void 0===o?void 0:o.current};if(i)return Yi(),Xe(new Set),Ze([]),vn.current=[],void(l&&(it(n),requestAnimationFrame(function(){var e=c()||u;e&&(e.getBoundingClientRect().top>.8*window.innerHeight&&e.scrollIntoView({behavior:"smooth",block:"center"}));Ln({open:!0,anchorEl:e,summary:t,displayImpact:o})})));it(n),l?setTimeout(function(){Ui(n,i,{toggleIfSame:!1,sourceSide:a,onReady:function(){var e,n,i,r=c()||u;if(r){var l=r.getBoundingClientRect();if(l.top>.8*window.innerHeight||l.top<100){var s=l.top-window.innerHeight/2;Pe?(null===(e=Bn.current)||void 0===e||e.scrollBy({top:s,behavior:"smooth"}),null===(n=yn.current)||void 0===n||n.scrollBy({top:s,behavior:"smooth"})):null===(i=xn.current)||void 0===i||i.scrollBy({top:s,behavior:"smooth"})}}Ln({open:!0,anchorEl:r,summary:t,displayImpact:o})}})},350):setTimeout(function(){Ui(n,i,{toggleIfSame:!1,sourceSide:a})},350)},[Ui,Wn,Ln,Yi,it]),uo=i.useMemo(function(){var e;if(!Be)return null;var n=null===(e=null==Be?void 0:Be.id)||void 0===e?void 0:e.split(":")[0];for(var i in di){if((di[i]||[]).some(function(e){return e.id===n}))return i}return null},[Be,di]),ao=i.useRef({id:null,triggerMs:null}),co=i.useRef(null);i.useEffect(function(){if(null==Be?void 0:Be.id){var n=Number(Be.trigger),i=ao.current;if((null==i?void 0:i.triggerMs)!==n){if(!(Be.id.includes(":")&&/:\d+$/.test(Be.id)))return ao.current={id:Be.id,triggerMs:n},void Ot(Be.id);var t=Be.id.split(":"),o=t[0],r=t[1],l=null!=r?r:"0";co.current!==Be.id&&(qn(),Wn(),Yi(),Xe(new Set),Ze([]),vn.current=[],co.current=Be.id);var u=!1,a=0,c=null,d=null,v=!1,f=function(e,n){for(var i=function(e,t){if(!e)return null;if(e.id===n)return t;if(!Array.isArray(e.subsections))return null;for(var o=0;o<e.subsections.length;o++){var r=i(e.subsections[o],"".concat(t,"-").concat(o));if(r)return r}return null},t=0;t<e.length;t++){var o=i(e[t],String(t));if(o)return o}return null},g=function(){var i,t,r,p;if(!u){var h=function(){ao.current={id:Be.id,triggerMs:n}},m=null,S=null;for(var R in di){var x=di[R].find(function(e){return e.id===o});if(x){m=R,S=x;break}}if(S&&m){var _=ui.findIndex(function(e){return e.id===m}),y=ai.findIndex(function(e){return e.id===m}),b=-1===_&&-1!==y,C=f(ui,S.id),E=f(ai,S.id);if(C&&!E&&!b){var A=C.split("-"),B=Number(A[0]);if(Pe){var w=null===(t=null===(i=ui[B])||void 0===i?void 0:i.refIndexes)||void 0===t?void 0:t[0],I=ai.findIndex(function(e){return e.selfIndex===w});-1!==I&&(B=I)}E=e.__spreadArray([B],A.slice(1),!0).join("-")}if(C||E){var T=C?Number(C.split("-")[0]):_,D=E?Number(E.split("-")[0]):y,O=D>=0?D:E?Number(E.split("-")[0]):-1,F=ui[T],j=ai[O],k=F&&!F.title&&!F.content,P=j&&!j.title&&!j.content,N=b||(!C&&!!E||k&&!P);if(N){if(!(Pe?!!yo.current["right-".concat(D)]:!!yo.current[String(D)])&&D>=0)return nt(D,"right"),void(c=setTimeout(g,200))}else if(!(Pe?!!yo.current["left-".concat(T)]:!!yo.current[String(T)])&&T>=0)return nt(T,"left"),void(c=setTimeout(g,200));var M=C||"",L=E||"",q="".concat(S.id).concat(s.DEVIATION_BADGE_SEPARATOR).concat(l).concat(s.DEVIATION_BADGE_SEPARATOR).concat(M).concat(s.DEVIATION_BADGE_SEPARATOR).concat(L),H="".concat(S.id).concat(s.DEVIATION_BADGE_SEPARATOR).concat(l);if(!v){it(q),v=!0,a=0;var V=function(){var e,n,i=null===(e=yi.current[H])||void 0===e?void 0:e.current,t=null===(n=bi.current[H])||void 0===n?void 0:n.current;return N||!i&&!!t?t:i};return null==d||d(),void(c=setTimeout(function(){var e,n,i,t,o,r,l;u||(e=V,n=function(){u||(d=null,g())},t=0,o=null,r=null,l=function(){if(!u){var s=e();if(s&&0!==s.getBoundingClientRect().height){var a=s.getBoundingClientRect(),c=a.top,d=a.height,v=null!==o&&Math.abs(c-o)<.5,f=null!==r&&Math.abs(d-r)<.5;if(v&&f){if(++t>=5)return void n()}else t=0;o=c,r=d,i=requestAnimationFrame(l)}else i=requestAnimationFrame(l)}},i=requestAnimationFrame(l),d=function(){return cancelAnimationFrame(i)})},300))}var G=null===(r=yi.current[H])||void 0===r?void 0:r.current,z=null===(p=bi.current[H])||void 0===p?void 0:p.current;if(G||z){var W=N||!G&&!!z,K=W?z:G,Y=Pe?W?yn.current:Bn.current:xn.current;if(K&&Y){var U=K.getBoundingClientRect();if(0!==U.height){var J=Y.getBoundingClientRect(),X=U.top-J.top+Y.scrollTop-J.height/2+U.height/2,$=(null==C?void 0:C.includes("-"))||(null==E?void 0:E.includes("-")),Q=function(){return e.__awaiter(void 0,void 0,void 0,function(){var n,i,t,o,r,a,c,d,v,f;return e.__generator(this,function(g){switch(g.label){case 0:return u?[2]:(h(),n=K instanceof Element?window.getComputedStyle(K).color:"",[G,z].forEach(function(e){e&&(e.style.transition="box-shadow 300ms ease-in-out",e.style.boxShadow="0 0 10px ".concat(n))}),setTimeout(function(){[G,z].forEach(function(e){e&&(e.style.boxShadow="")})},2e3),i=(null===(c=null===(a=S.evaluationResult)||void 0===a?void 0:a.deviations)||void 0===c?void 0:c[l])||S,t=(null===(d=S.evaluationResult)||void 0===d?void 0:d.evaluation_outputs)||S.evaluation_outputs,!!G&&!!z?(r=function(e,n){return Promise.race([e,new Promise(function(e){return setTimeout(e,n)})])},Pe?[4,Promise.all([Bn.current?r(s.waitForScrollIdle(Bn.current),600):Promise.resolve(),yn.current?r(s.waitForScrollIdle(yn.current),600):Promise.resolve()])]:[3,2]):(o=W?(null===(v=bi.current[$?H:D])||void 0===v?void 0:v.current)||z:(null===(f=yi.current[$?H:T])||void 0===f?void 0:f.current)||G,lo(o,function(){Ln({open:!0,anchorEl:o,displayImpact:Be.displayImpact,summary:e.__assign(e.__assign({},i),{evaluation_outputs:t})})},{skipScroll:!0}),null==we||we(),[2]));case 1:g.sent(),g.label=2;case 2:return Ui(q,!1,{toggleIfSame:!1,sourceSide:b?"right":"left",onReady:function(){var n,t,o,r;h();var l=W?(null===(n=bi.current[H])||void 0===n?void 0:n.current)||z:(null===(t=yi.current[H])||void 0===t?void 0:t.current)||G,s=(null===(o=yi.current[H])||void 0===o?void 0:o.current)||G,u=(null===(r=bi.current[H])||void 0===r?void 0:r.current)||z;s&&(s.style.scrollMarginTop="150px",s.scrollIntoView({behavior:"smooth",block:"start"})),u&&(u.style.scrollMarginTop="150px",u.scrollIntoView({behavior:"smooth",block:"start"})),Ln({open:!0,anchorEl:l,displayImpact:Be.displayImpact,summary:e.__assign({},i)}),null==we||we()}}),[2]}})})};Math.abs(Y.scrollTop-X)<=2?Q():s.scrollAndWait(Y,X,Q)}else++a<2?c=setTimeout(g,100):h()}else++a<2?c=setTimeout(g,100):h()}else++a<2?c=setTimeout(g,100):h()}else++a<2?c=setTimeout(g,100):h()}else++a<2?c=setTimeout(g,100):h()}};return c=setTimeout(g,100),function(){u=!0,c&&clearTimeout(c),null==d||d()}}}},[Be,di,ui,ai,Pe,Xi,Ui,Ln,Ot]),i.useEffect(function(){var n,i,t;if(Mn.open){var o=Mn.anchorEl;if(o&&!o.isConnected){var r=function(e){for(var n,i=0,t=Object.entries(e);i<t.length;i++){var r=t[i],l=r[0];if((null===(n=r[1].current)||void 0===n?void 0:n.textContent)===o.textContent)return l}return null},l=(null===(n=o.dataset)||void 0===n?void 0:n.deviationRefId)||r(yi.current)||r(bi.current);if(l){var s=(null===(i=bi.current[l])||void 0===i?void 0:i.current)||(null===(t=yi.current[l])||void 0===t?void 0:t.current);s&&s.isConnected&&Ln(function(n){return e.__assign(e.__assign({},n),{anchorEl:s})})}}}},[Mn.open,Mn.anchorEl,nn,Je,Xi]);var vo=Dn.open,fo=Dn.sectionIdx,go=Dn.isOrphan,po=Dn.badgeStyle,ho=Dn.anchorEl,mo=Dn.sectionAnchorEl;i.useEffect(function(){var n;if(ye.isStreamingEnabled&&vo&&null!=fo&&fo!==at){var i="string"==typeof fo?fo.split(s.DEVIATION_BADGE_SEPARATOR)[0]:null,t=function(e,n){var i;if(!e||!Array.isArray(e))return null;for(var o=0,r=e;o<r.length;o++){var l=r[o];if(l.id===n)return l;if(null===(i=l.subsections)||void 0===i?void 0:i.length){var s=t(l.subsections,n);if(s)return s}}return null},o=i&&"string"==typeof i?t(ui,i):null,r=i&&"string"==typeof i?t(ai,i):null,l="number"==typeof fo?ui[fo]||null:o||i&&((null===(n=null==pe?void 0:pe.nodes)||void 0===n?void 0:n[i])||(null==pe?void 0:pe[i]))||null,u="number"==typeof fo?ai[fo]||null:r,a=wt(ho,l,u,fo,go,po);On(function(n){return n.open?s.safeStringify(n.cognitiveData)===s.safeStringify(a.cognitiveData)&&s.safeStringify(n.deviationData)===s.safeStringify(a.deviationData)&&n.sectionTitle===a.sectionTitle&&n.refSectionTitle===a.refSectionTitle?n:e.__assign(e.__assign(e.__assign({},n),a),{open:!0,anchorEl:n.anchorEl,sectionAnchorEl:n.sectionAnchorEl}):n})}},[vo,fo,go,po,ho,mo,ui,ai,wt]);var So=i.useCallback(function(e){var i=e.section,t=e.keyPath,o=e.depth,r=void 0===o?0:o,l=e.columnKey,s=void 0===l?"left":l,u=e.parentNodeId,a=void 0===u?"":u,c=e.sectionOffset;return n.jsx(x.default,{section:i,keyPath:t,depth:r,columnKey:s,parentNodeId:a,sectionOffset:c})},[]),Ro=i.useMemo(function(){return ui.map(function(e,i){var t,o=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),r=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return o&&r&&Pe?null:n.jsx(_.default,{section:e,idx:i},null!==(t=null==e?void 0:e.id)&&void 0!==t?t:"left-row-".concat(i))})},[ui]),xo=i.useMemo(function(){return ai.map(function(e,i){var t,o=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),r=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return o&&r&&Pe?null:n.jsx(y.default,{section:e,idx:i},null!==(t=null==e?void 0:e.id)&&void 0!==t?t:"right-row-".concat(i))})},[ai]),_o=i.useRef(It);i.useEffect(function(){_o.current=It},[It]);var yo=i.useRef(Xi);i.useEffect(function(){yo.current=Xi},[Xi]);var bo=i.useRef(so);i.useEffect(function(){bo.current=so},[so]);var Co=i.useRef(no);i.useEffect(function(){Co.current=no},[no]);var Eo=i.useRef(nt);i.useEffect(function(){Eo.current=nt},[nt]);var Ao=i.useRef(et);i.useEffect(function(){Ao.current=et},[et]);var Bo=i.useRef(So);i.useEffect(function(){Bo.current=So},[So]);var wo=i.useRef(Yi);i.useEffect(function(){wo.current=Yi},[Yi]);var Io=i.useMemo(function(){return{isGuidelineMode:ri,maintainRelativeOrder:!!Pe,showDeviationBadges:qe,isProposingFix:Te,proposingFixNodeId:De,isRedlineFlow:Oe,isSideBySide:Oi,activeSideBySideSection:Mi,scrollSyncLocked:nn,toggleScrollSyncLocked:ot,summaryPopupAnchorEl:Mn.anchorEl,connectedSections:Je,proposedSections:ui,existingSections:ai,deviationNumberRegistry:vi,deviationParentRegistry:fi,treeData:pe,displayConfig:ye,resolvedMarkdownStyles:Rn,unifiedNumbering:rt,expandedSections:Xi,expandedSubSections:Qi,setExpandedSubSections:Zi,getSectionCompareStyle:Nt,getSubSectionCompareStyle:Mt,getBadgeRef:Ti,getSectionRowRef:wi,getSubSectionRef:Ii,sectionLeftRefs:xi,sectionRightRefs:_i,sectionRowRefs:Bi,sectionRightRowRefs:Ci,subSectionLeftRefs:Ei,subSectionRightRefs:Ai,lhsBadgeRefs:yi,rhsBadgeRefs:bi,openMoreFunctionsPopup:ht,handleOpenSummaryPopup:mt,openSummaryPopup:mt,handleCloseSummaryPopup:St,toggleSection:Rt,handleSubSectionToggle:xt,renderSubSectionAccordion:_t,resetSideBySide:yt,setConnectedSections:Xe,setConnectedLines:Ze,cachedConnectedPositions:vn,showDeviationNavigation:oo,showOpenNodeRef:ro,deviationNodeIdToView:null==Be?void 0:Be.id,deviationTargetParentId:uo}},[ri,Pe,qe,Te,De,Oe,Oi,Mi,nn,ot,Mn.anchorEl,Je,ui,ai,vi,ye,Rn,rt,Xi,Qi,Zi,Nt,Mt,Ti,wi,Ii,oo,ro,Be,uo]);return n.jsx(C.CompareContextProvider,e.__assign({value:Io},{children:n.jsxs(t.Box,e.__assign({ref:_n,sx:{display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif',overflow:"visible",position:"relative"}},{children:[Ve&&n.jsx(t.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,{})})),Mn.open&&n.jsx(b.default,{open:Mn.open,anchorEl:Mn.anchorEl,containerEl:jt.current,clipTopEl:ln.current,scrollContainerEl:xn.current,onClose:no,summary:Mn.summary,displayImpact:Mn.displayImpact,isScrollLocked:nn}),n.jsx(d.default,{open:Fn.open,anchorEl:Fn.anchorEl,maintainRelativeOrder:!!Pe,sectionTitle:Fn.sectionTitle,referenceSectionTitle:Fn.refSectionTitle,onClose:Kn,onOpenCognitiveCompare:Gn,onOpenSideBySide:eo,onConnect:Tt,isConnected:io,isOrphan:!ri&&!!Fn.isOrphan,isGuidelineMode:ri,hasGuidelineMatches:Fn.hasGuidelineMatches}),Dn.open&&n.jsx(c.default,{open:Dn.open,popupRef:Vn,position:kn,popupConfig:Ce,onClose:function(){Pn(null),On(function(n){return e.__assign(e.__assign({},n),{open:!1})}),Hn(null)},markdownStyles:Re,sectionTitle:ei,referenceSectionTitle:ii,cognitiveData:Dn.cognitiveData,anchorEl:Dn.anchorEl,sectionAnchorEl:Dn.sectionAnchorEl,scrollContainerEl:xn.current,badgeStyle:Dn.badgeStyle,docData:Dn.docData,deviationData:Dn.deviationData,isLoading:Dn.isLoading}),n.jsx(t.Snackbar,e.__assign({open:!!We,autoHideDuration:8e3,onClose:function(){return Ke(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(t.Alert,e.__assign({onClose:function(){return Ke(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:We}))})),n.jsx(R.default,{componentHeaderText:ge,displayConfig:ye,maintainRelativeOrder:Pe,onCollapseAll:Yt,showCollapseAll:Ut,onToggleView:function(e){Ge(!0),setTimeout(function(){Ne(!e),null==be||be(!e),tn(!1),Yi(),qn(),Xe(new Set),Ze([]),vn.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){Ge(!1)},600)})})},50)}}),n.jsx(t.Box,e.__assign({ref:xn,onScroll:Kt,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:Pe?"visible":"auto",borderTop:st&&ut?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(t.Box,e.__assign({sx:e.__assign({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},Pe?{flex:1}:{})},{children:n.jsxs(t.Box,e.__assign({ref:rn,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},Pe?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(I.default,{svgContainerRef:on,svgDimensions:Wt,isResizing:ki,overallConnector:Gt,rootDeviationStyle:vt,lines:Ht,isSideBySide:Oi,activeSideBySideSection:Mi,isArrowVisible:Fi,maintainRelativeOrder:Pe,proposedSections:ui,existingSections:ai,cognitivePopup:Dn,activeBadgeId:Nn,closeCognitivePopup:Wn,setActiveBadgeId:Hn,openCognitivePopupFromState:zn,buildSectionPopupState:wt,connectedLines:Qe,pathRefs:dn}),n.jsxs(t.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)"},Pe?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(t.Box,e.__assign({ref:ln,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center",minHeight:"40px",overflow:"hidden",minWidth:0}},{children:n.jsx(t.Tooltip,e.__assign({title:Qn,placement:"top"},{children:n.jsx(t.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:Qn}))}))})),n.jsxs(t.Box,e.__assign({ref:Bn,onScroll:Kt,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},Pe?{maxHeight:"calc(100vh - 250px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-180px",pr:"192px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:En,style:{width:"100%",height:"0px",flexShrink:0}}),pi&&Ro,n.jsx("div",{ref:An,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),n.jsx(t.Box,e.__assign({ref:jt,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:n.jsx(t.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:n.jsxs(t.Box,e.__assign({onClick:function(n){n.stopPropagation(),Dn.open&&Nn===at?Wn():(Hn(at),zn(wt(n.currentTarget,{title:"",content:"",evaluationResult:ct,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,at,!0,e.__assign(e.__assign({},vt),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:vt.badgeBg,color:vt.badgeText,border:"1px solid ".concat(vt.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=dt?dt:n.jsx(f.default,{}),n.jsx(t.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:Dn.open&&Nn===at?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),n.jsxs(t.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},Pe?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[Ni&&n.jsx(l.default,{sections:11}),n.jsx(t.Box,e.__assign({ref:sn,sx:e.__assign({p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center"},Pe?e.__assign({maxHeight:"calc(100vh - 250px)",overflowY:"auto",overflowX:"hidden",minHeight:0},ri?{"&::-webkit-scrollbar":{width:"6px",display:"block"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{background:"#CBD5E1",borderRadius:"10px"},"&::-webkit-scrollbar-thumb:hover":{background:"#94A3B8"},scrollbarWidth:"thin",scrollbarColor:"#CBD5E1 transparent"}:{"&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}):{})},{children:n.jsx(t.Tooltip,e.__assign({title:ti,placement:"top"},{children:n.jsx(t.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:ti}))}))})),n.jsxs(t.Box,e.__assign({ref:yn,onScroll:Kt,sx:e.__assign({p:ri?"0px":"12px",display:"flex",flexDirection:"column"},Pe?e.__assign(e.__assign({maxHeight:"calc(100vh - 250px)"},!ri&&{flex:1}),{overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-150px",pl:"165px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}):{})},{children:[n.jsx("div",{ref:bn,style:{width:"100%",height:"0px",flexShrink:0}}),ri?n.jsx(T.default,{guidelinesData:je,deviationData:Ae,connectedSections:Je,proposedSections:ui}):pi&&xo,n.jsx("div",{ref:Cn,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 e=require("tslib"),i=require("react/jsx-runtime"),n=require("@mui/material"),t=require("../../assests/svg/ButtonCognitiveIcon.js"),s=function(){return i.jsx("svg",e.__assign({width:"13",height:"13",viewBox:"0 0 13 13",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:i.jsx("path",{d:"M2 6.5L5 9.5L11 3.5",stroke:"#15803D",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})}))},o=[{key:"connect",title:"Connect",icon:i.jsx("svg",e.__assign({width:"15",height:"18",viewBox:"0 0 15 18",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:i.jsx("path",{d:"M14.8237 3.89331C14.547 5.57188 13.0559 6.77501 11.3572 6.69242C9.65857 6.60983 8.2925 5.26384 8.18312 3.56742C4.75678 3.67456 3.54027 4.4759 3.73893 6.10536C3.81259 6.71474 4.18089 7.04063 4.85723 7.19911C5.26794 7.2951 5.7233 7.30849 6.13625 7.27054C6.17419 7.26608 6.21437 7.26385 6.25232 7.25938C6.50455 7.19911 6.76125 7.14777 7.01794 7.1076C7.77911 6.9826 8.55366 6.9201 9.29027 6.96027C11.3617 7.07188 12.7724 7.98483 12.8438 9.92233C12.913 11.7996 11.6229 13.1299 9.5425 14.0205C8.87509 14.3063 8.1675 14.5272 7.45991 14.6946C7.14071 14.7705 6.87286 14.8219 6.67419 14.8554C6.49786 16.5496 5.07821 17.842 3.37509 17.8554C1.67196 17.8688 0.229997 16.6031 0.0246403 14.9112C-0.180717 13.2192 0.917498 11.6455 2.57375 11.2527C4.23 10.8598 5.91973 11.7728 6.49562 13.3755C6.70544 13.3375 6.91303 13.2951 7.12062 13.246C7.75009 13.0987 8.37955 12.9022 8.95991 12.6522C10.538 11.9781 11.3996 11.0875 11.3595 9.9759C11.3237 8.98036 10.6095 8.52054 9.21214 8.44465C8.5983 8.41117 7.92643 8.46474 7.26348 8.57411C7.07821 8.60536 6.90857 8.63661 6.75902 8.6701C6.67196 8.68795 6.61169 8.70358 6.58491 8.71027L6.51571 8.72367C6.4666 8.73036 6.38402 8.74152 6.27687 8.75268C5.71884 8.80402 5.11393 8.78617 4.52464 8.65001C3.2925 8.36206 2.42866 7.59643 2.26794 6.2884C1.9175 3.47143 4.02241 2.16563 8.42866 2.07188C9.07821 0.500452 10.8037 -0.336602 12.4376 0.129916C14.0737 0.596434 15.1005 2.21474 14.8237 3.89331V3.89331ZM3.34161 12.6478C3.09741 12.6478 2.85562 12.6959 2.63002 12.7894C2.40442 12.8828 2.19944 13.0198 2.02678 13.1925C1.85412 13.3652 1.71717 13.5702 1.62373 13.7958C1.5303 14.0214 1.48222 14.2632 1.48223 14.5074C1.48224 14.7516 1.53036 14.9934 1.62382 15.219C1.71728 15.4446 1.85426 15.6495 2.02694 15.8222C2.19962 15.9949 2.40462 16.1318 2.63022 16.2252C2.85583 16.3187 3.09764 16.3668 3.34183 16.3667C3.83499 16.3667 4.30795 16.1708 4.65665 15.822C5.00535 15.4733 5.20123 15.0003 5.2012 14.5071C5.20117 14.014 5.00524 13.541 4.65649 13.1923C4.30775 12.8436 3.83477 12.6477 3.34161 12.6478ZM11.5224 1.49152C11.2782 1.49154 11.0364 1.53965 10.8108 1.63311C10.5852 1.72657 10.3802 1.86355 10.2076 2.03623C10.0349 2.20891 9.89797 2.41391 9.80454 2.63952C9.7111 2.86513 9.66302 3.10693 9.66303 3.35112C9.66305 3.59531 9.71116 3.83711 9.80462 4.06271C9.89808 4.28831 10.0351 4.49329 10.2077 4.66594C10.3804 4.8386 10.5854 4.97556 10.811 5.06899C11.0366 5.16243 11.2784 5.21051 11.5226 5.2105C12.0158 5.21047 12.4888 5.01453 12.8375 4.66579C13.1862 4.31704 13.382 3.84406 13.382 3.3509C13.382 2.85773 13.186 2.38478 12.8373 2.03608C12.4886 1.68738 12.0156 1.49149 11.5224 1.49152V1.49152Z",fill:"#1D2939",fillOpacity:"0.85"})}))},{key:"side-by-side",title:"Side by Side",icon:i.jsx("svg",e.__assign({width:"17",height:"17",viewBox:"0 0 17 17",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:i.jsx("path",{d:"M3.19922 8.19922H13.1992M3.19922 8.19922L4.86589 10.6992M3.19922 8.19922L4.86589 5.69922M13.1992 8.19922L11.5326 10.6992M13.1992 8.19922L11.5326 5.69922M15.6992 0.699219V15.6992M0.699219 0.699219V15.6992",stroke:"#3F4957",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})}))},{key:"cognitive-decisioning",title:"Cognitive Decisioning",icon:i.jsx(t.ButtonCognitiveIcon,{})}];exports.default=function(t){var r=t.open,l=t.anchorEl;t.sectionTitle,t.referenceSectionTitle;var a=t.onClose,c=t.onOpenCognitiveCompare,d=t.onOpenSideBySide,C=t.onConnect,x=t.isConnected,g=void 0!==x&&x,h=t.isOrphan,p=t.maintainRelativeOrder;return i.jsx(n.Menu,e.__assign({open:r,anchorEl:l,onClose:a,disableScrollLock:!0,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},PaperProps:{sx:{ml:.75,minWidth:190,maxWidth:220,borderRadius:"12px",border:"1px solid #E4E7EC",boxShadow:"0px 12px 28px rgba(16, 24, 40, 0.12)",overflow:"hidden"}},MenuListProps:{sx:{p:.5,bgcolor:"#FFFFFF"}}},{children:o.filter(function(e){return p||"side-by-side"!==e.key}).map(function(t){var o="connect"===t.key,r=o&&g,l=h&&("connect"===t.key||"side-by-side"===t.key),a=i.jsxs(i.Fragment,{children:[i.jsx(n.Box,e.__assign({sx:e.__assign(e.__assign({width:18,height:18,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,"& svg":{display:"block"}},l&&{opacity:.15}),r&&{"& svg path":{fill:"#15803D",fillOpacity:1}})},{children:t.icon})),i.jsxs(n.Box,e.__assign({sx:{minWidth:0,display:"flex",flexDirection:"column",flex:1}},{children:[i.jsx(n.Typography,e.__assign({sx:{fontSize:"12px",fontWeight:500,color:l?"#98A2B3":r?"#15803D":"#101828",lineHeight:1.2,whiteSpace:"nowrap"}},{children:o?g?"Disconnect":"Connect":t.title})),l&&i.jsx(n.Typography,e.__assign({sx:{mt:.35,fontSize:"10px",lineHeight:1.3,color:"#98A2B3",whiteSpace:"normal"}},{children:"No counterpart exists to connect to."}))]})),r&&!l&&i.jsx(n.Box,e.__assign({sx:{display:"flex",alignItems:"center",justifyContent:"center",ml:"auto"}},{children:i.jsx(s,{})}))]});return l?i.jsx(n.Box,e.__assign({"aria-disabled":"true",sx:{px:1.25,py:1,minHeight:22,borderRadius:"10px",display:"flex",alignItems:"flex-start",gap:1,cursor:"not-allowed",userSelect:"none"}},{children:a}),t.key):i.jsx(n.MenuItem,e.__assign({onClick:function(){return e=t.key,void(h&&("connect"===e||"side-by-side"===e)||("connect"!==e?"side-by-side"!==e?c():d():C()));var e},sx:{px:1.25,py:1,minHeight:40,borderRadius:"10px",display:"flex",alignItems:"center",gap:1,bgcolor:r?"#F0FDF4":"transparent","&:hover":{bgcolor:r?"#DCFCE7":"#F9FAFB"}}},{children:a}),t.key)})}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),i=require("react/jsx-runtime"),n=require("@mui/material"),t=require("../../assests/svg/ButtonCognitiveIcon.js"),s=function(){return i.jsx("svg",e.__assign({width:"13",height:"13",viewBox:"0 0 13 13",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:i.jsx("path",{d:"M2 6.5L5 9.5L11 3.5",stroke:"#15803D",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})}))},o=[{key:"connect",title:"Connect",icon:i.jsx("svg",e.__assign({width:"15",height:"18",viewBox:"0 0 15 18",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:i.jsx("path",{d:"M14.8237 3.89331C14.547 5.57188 13.0559 6.77501 11.3572 6.69242C9.65857 6.60983 8.2925 5.26384 8.18312 3.56742C4.75678 3.67456 3.54027 4.4759 3.73893 6.10536C3.81259 6.71474 4.18089 7.04063 4.85723 7.19911C5.26794 7.2951 5.7233 7.30849 6.13625 7.27054C6.17419 7.26608 6.21437 7.26385 6.25232 7.25938C6.50455 7.19911 6.76125 7.14777 7.01794 7.1076C7.77911 6.9826 8.55366 6.9201 9.29027 6.96027C11.3617 7.07188 12.7724 7.98483 12.8438 9.92233C12.913 11.7996 11.6229 13.1299 9.5425 14.0205C8.87509 14.3063 8.1675 14.5272 7.45991 14.6946C7.14071 14.7705 6.87286 14.8219 6.67419 14.8554C6.49786 16.5496 5.07821 17.842 3.37509 17.8554C1.67196 17.8688 0.229997 16.6031 0.0246403 14.9112C-0.180717 13.2192 0.917498 11.6455 2.57375 11.2527C4.23 10.8598 5.91973 11.7728 6.49562 13.3755C6.70544 13.3375 6.91303 13.2951 7.12062 13.246C7.75009 13.0987 8.37955 12.9022 8.95991 12.6522C10.538 11.9781 11.3996 11.0875 11.3595 9.9759C11.3237 8.98036 10.6095 8.52054 9.21214 8.44465C8.5983 8.41117 7.92643 8.46474 7.26348 8.57411C7.07821 8.60536 6.90857 8.63661 6.75902 8.6701C6.67196 8.68795 6.61169 8.70358 6.58491 8.71027L6.51571 8.72367C6.4666 8.73036 6.38402 8.74152 6.27687 8.75268C5.71884 8.80402 5.11393 8.78617 4.52464 8.65001C3.2925 8.36206 2.42866 7.59643 2.26794 6.2884C1.9175 3.47143 4.02241 2.16563 8.42866 2.07188C9.07821 0.500452 10.8037 -0.336602 12.4376 0.129916C14.0737 0.596434 15.1005 2.21474 14.8237 3.89331V3.89331ZM3.34161 12.6478C3.09741 12.6478 2.85562 12.6959 2.63002 12.7894C2.40442 12.8828 2.19944 13.0198 2.02678 13.1925C1.85412 13.3652 1.71717 13.5702 1.62373 13.7958C1.5303 14.0214 1.48222 14.2632 1.48223 14.5074C1.48224 14.7516 1.53036 14.9934 1.62382 15.219C1.71728 15.4446 1.85426 15.6495 2.02694 15.8222C2.19962 15.9949 2.40462 16.1318 2.63022 16.2252C2.85583 16.3187 3.09764 16.3668 3.34183 16.3667C3.83499 16.3667 4.30795 16.1708 4.65665 15.822C5.00535 15.4733 5.20123 15.0003 5.2012 14.5071C5.20117 14.014 5.00524 13.541 4.65649 13.1923C4.30775 12.8436 3.83477 12.6477 3.34161 12.6478ZM11.5224 1.49152C11.2782 1.49154 11.0364 1.53965 10.8108 1.63311C10.5852 1.72657 10.3802 1.86355 10.2076 2.03623C10.0349 2.20891 9.89797 2.41391 9.80454 2.63952C9.7111 2.86513 9.66302 3.10693 9.66303 3.35112C9.66305 3.59531 9.71116 3.83711 9.80462 4.06271C9.89808 4.28831 10.0351 4.49329 10.2077 4.66594C10.3804 4.8386 10.5854 4.97556 10.811 5.06899C11.0366 5.16243 11.2784 5.21051 11.5226 5.2105C12.0158 5.21047 12.4888 5.01453 12.8375 4.66579C13.1862 4.31704 13.382 3.84406 13.382 3.3509C13.382 2.85773 13.186 2.38478 12.8373 2.03608C12.4886 1.68738 12.0156 1.49149 11.5224 1.49152V1.49152Z",fill:"#1D2939",fillOpacity:"0.85"})}))},{key:"side-by-side",title:"Side by Side",icon:i.jsx("svg",e.__assign({width:"17",height:"17",viewBox:"0 0 17 17",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:i.jsx("path",{d:"M3.19922 8.19922H13.1992M3.19922 8.19922L4.86589 10.6992M3.19922 8.19922L4.86589 5.69922M13.1992 8.19922L11.5326 10.6992M13.1992 8.19922L11.5326 5.69922M15.6992 0.699219V15.6992M0.699219 0.699219V15.6992",stroke:"#3F4957",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})}))},{key:"cognitive-decisioning",title:"Cognitive Decisioning",icon:i.jsx(t.ButtonCognitiveIcon,{})}];exports.default=function(t){var r=t.open,l=t.anchorEl;t.sectionTitle,t.referenceSectionTitle;var a=t.onClose,c=t.onOpenCognitiveCompare,d=t.onOpenSideBySide,C=t.onConnect,x=t.isConnected,h=void 0!==x&&x,g=t.isOrphan,p=void 0!==g&&g,u=t.maintainRelativeOrder,y=t.isGuidelineMode,f=t.hasGuidelineMatches,v=y?!(void 0===f||f):p,_=y?"No highlights found in guidelines.":"No counterpart exists to connect to.";return i.jsx(n.Menu,e.__assign({open:r,anchorEl:l,onClose:a,disableScrollLock:!0,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},PaperProps:{sx:{ml:.75,minWidth:190,maxWidth:220,borderRadius:"12px",border:"1px solid #E4E7EC",boxShadow:"0px 12px 28px rgba(16, 24, 40, 0.12)",overflow:"hidden"}},MenuListProps:{sx:{p:.5,bgcolor:"#FFFFFF"}}},{children:o.filter(function(e){return u||"side-by-side"!==e.key}).map(function(t){var o="connect"===t.key,r=o&&h,l=("connect"===t.key||"side-by-side"===t.key)&&v,a=i.jsxs(i.Fragment,{children:[i.jsx(n.Box,e.__assign({sx:e.__assign(e.__assign({width:18,height:18,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,"& svg":{display:"block"}},l&&{opacity:.15}),r&&{"& svg path":{fill:"#15803D",fillOpacity:1}})},{children:t.icon})),i.jsxs(n.Box,e.__assign({sx:{minWidth:0,display:"flex",flexDirection:"column",flex:1}},{children:[i.jsx(n.Typography,e.__assign({sx:{fontSize:"12px",fontWeight:500,color:l?"#98A2B3":r?"#15803D":"#101828",lineHeight:1.2,whiteSpace:"nowrap"}},{children:o?h?"Disconnect":"Connect":t.title})),l&&i.jsx(n.Typography,e.__assign({sx:{mt:.35,fontSize:"10px",lineHeight:1.3,color:"#98A2B3",whiteSpace:"normal"}},{children:_}))]})),r&&!l&&i.jsx(n.Box,e.__assign({sx:{display:"flex",alignItems:"center",justifyContent:"center",ml:"auto"}},{children:i.jsx(s,{})}))]});return l?i.jsx(n.Box,e.__assign({"aria-disabled":"true",sx:{px:1.25,py:1,minHeight:22,borderRadius:"10px",display:"flex",alignItems:"flex-start",gap:1,cursor:"not-allowed",userSelect:"none"}},{children:a}),t.key):i.jsx(n.MenuItem,e.__assign({onClick:function(){var e;("connect"===(e=t.key)||"side-by-side"===e)&&v||("connect"!==e?"side-by-side"!==e?c():d():C())},sx:{px:1.25,py:1,minHeight:40,borderRadius:"10px",display:"flex",alignItems:"center",gap:1,bgcolor:r?"#F0FDF4":"transparent","&:hover":{bgcolor:r?"#DCFCE7":"#F9FAFB"}}},{children:a}),t.key)})}))};
2
2
  //# sourceMappingURL=MoreFunctionsPopup.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),e=require("../CognitiveComparehelpers.js");exports.useLinesCalculator=function(n){var i=n.containerRef,r=n.leftContainerRef,c=n.rightContainerRef;n.svgContainerRef;var l=n.pathRefs,o=n.leftHeaderRef,u=n.rightHeaderRef,a=n.proposedSections,d=n.existingSections,s=n.visibleFields,v=n.leftRefs,h=n.rightRefs,g=n.sectionLeftRefs,f=n.sectionRightRefs,b=n.subSectionLeftRefs,p=n.subSectionRightRefs,A=n.lhsBadgeRefs,y=n.rhsBadgeRefs,R=n.sectionRowRefs,x=n.expandedSections,m=n.expandedSubSections,B=n.connectedSections,S=n.isSideBySide,T=n.activeSideBySideSection,C=n.maintainRelativeOrder,I=n.isGuidelineMode,E=n.cognitiveMap,M=n.getSectionCompareStyle,D=n.getSubSectionCompareStyle,O=n.getDeviationStyleByKey,L=n.isArrowVisible,_=n.isAnimatingRef,F=n.isSideBySideRef,N=n.sideBySideCacheRef,H=n.sideBySideLineRef,P=n.activeSideBySideSectionRef,k=n.activeSideBySideRightSectionRef,G=n.connectedLines,w=n.setConnectedLines,V=n.cachedConnectedPositions,Y=n.calculateLinesRef,j=n.resizeTimerRef,z=n.scrollLock,Q=n.scrollSyncLocked,X=n.handleResizeRef,q=n.activeProposed,K=n.existingRule,J=n.analysisData,U=n.pendingScrollTargetRef,W=n.pendingScrollCallbackRef,Z=n.resolvedComparisonConfig,$=n.getFieldData,tt=t.useState([]),et=tt[0],nt=tt[1],it=t.useState(null),rt=it[0],ct=it[1],lt=t.useState([]),ot=lt[0],ut=lt[1],at=null!=G?G:ot,dt=null!=w?w:ut,st=t.useState({width:0,height:0}),vt=st[0],ht=st[1],gt=t.useRef(!1),ft=t.useRef(!1),bt=t.useRef(!1),pt=t.useRef(null),At=t.useRef([]),yt=null!=V?V:At,Rt=function(t,e,n,i,r,c,l){if(Math.abs(i-e)<=1)return c&&l?"M ".concat(t,",").concat(e," L ").concat(n,",").concat(i):c&&!l?"M ".concat(t,",").concat(e," L ").concat(r,",").concat(e):!c&&l?"M ".concat(r,",").concat(e," L ").concat(n,",").concat(i):"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i);var o=Math.min(15,Math.abs(r-t),Math.abs(i-e)/2),u=Math.min(15,Math.abs(n-r),Math.abs(i-e)/2),a=i>e?o:-o,d=i>e?u:-u,s=n>r?u:-u;return c&&l?"M ".concat(t,",").concat(e," L ").concat(r-o,",").concat(e," Q ").concat(r,",").concat(e," ").concat(r,",").concat(e+a," L ").concat(r,",").concat(i-d," Q ").concat(r,",").concat(i," ").concat(r+s,",").concat(i," L ").concat(n,",").concat(i):c&&!l?"M ".concat(t,",").concat(e," L ").concat(r-o,",").concat(e," Q ").concat(r,",").concat(e," ").concat(r,",").concat(e+a," L ").concat(r,",").concat(i):!c&&l?"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i-d," Q ").concat(r,",").concat(i," ").concat(r+s,",").concat(i," L ").concat(n,",").concat(i):"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i)},xt=t.useCallback(function(){var t,n,l,R,L,F,N,H,P,k,G,w,V,Y,j,z,Q,X;if(!gt.current&&!_.current){gt.current=!0;try{if(!i.current)return;var q=function(t){var e=t.split("-"),n=e[0];if(!x[n]&&!1===C)return!1;if(C&&!x["left-".concat(n)]&&!x["right-".concat(n)]&&!x[n])return!1;for(var i=n,r=1;r<e.length-1;r++)if(i+="-".concat(e[r]),!m[i])return!1;return!0},K=i.current.getBoundingClientRect();ht({width:K.width,height:K.height});var J=[];if(s.forEach(function(t){var e,n,i=t.key,r=null===(e=v.current[i])||void 0===e?void 0:e.current,c=null===(n=h.current[i])||void 0===n?void 0:n.current;r&&c&&(r.style.height="auto",c.style.height="auto",r.style.minHeight="0px",c.style.minHeight="0px")}),!_.current){for(var U=0;U<Math.max(a.length,d.length);U++){var W=null===(t=g.current[U])||void 0===t?void 0:t.current,Z=null===(n=f.current[U])||void 0===n?void 0:n.current;W&&(W.style.height="auto",W.style.minHeight="0px"),Z&&(Z.style.height="auto",Z.style.minHeight="0px")}C||Object.keys(b.current).forEach(function(t){var e,n;if(q(t)){var i=null===(e=b.current[t])||void 0===e?void 0:e.current,r=null===(n=p.current[t])||void 0===n?void 0:n.current;i&&r&&(i.style.height="auto",r.style.height="auto",i.style.minHeight="0px",r.style.minHeight="0px")}})}var $={};s.forEach(function(t){var e,n,i=t.key,r=null===(e=v.current[i])||void 0===e?void 0:e.current,c=null===(n=h.current[i])||void 0===n?void 0:n.current;if(r&&c){var l=r.getBoundingClientRect(),o=c.getBoundingClientRect();$[i]=Math.max(l.height,o.height)}});var tt={left:{},right:{}},et={};if(!_.current)if(C){if(S&&null!==T)if("number"==typeof T){var it=T,rt=a[it],lt=null===(L=g.current[it])||void 0===L?void 0:L.current;lt&&rt&&(rt.refIndexes||[]).forEach(function(t){var e,n=d.findIndex(function(e){return e.selfIndex===t}),i=null===(e=f.current[n])||void 0===e?void 0:e.current;if(i&&(x["left-".concat(it)]||x["right-".concat(n)])){var r=Math.max(lt.getBoundingClientRect().height,i.getBoundingClientRect().height);tt.left[it]=Math.max(tt.left[it]||0,r),tt.right[n]=Math.max(tt.right[n]||0,r)}})}else{var ot=T.split(e.DEVIATION_BADGE_SEPARATOR)[2];if(ot){W=null===(F=b.current[ot])||void 0===F?void 0:F.current,Z=null===(N=p.current[ot])||void 0===N?void 0:N.current;if(W&&Z){ut=Math.max(W.getBoundingClientRect().height,Z.getBoundingClientRect().height);et[ot]=Math.max(et[ot]||0,ut)}}}}else{Object.keys(b.current).forEach(function(t){var e,n;if(q(t)){var i=null===(e=b.current[t])||void 0===e?void 0:e.current,r=null===(n=p.current[t])||void 0===n?void 0:n.current;if(i&&r&&null!==i.offsetParent&&null!==r.offsetParent){var c=i.getBoundingClientRect(),l=r.getBoundingClientRect(),o=Math.max(c.height,l.height);et[t]=o,i.style.minHeight="".concat(o,"px"),r.style.minHeight="".concat(o,"px")}}});for(U=0;U<Math.min(a.length,d.length);U++){var W=null===(l=g.current[U])||void 0===l?void 0:l.current,Z=null===(R=f.current[U])||void 0===R?void 0:R.current;if(W&&Z){var ut=Math.max(W.getBoundingClientRect().height,Z.getBoundingClientRect().height);tt.left[U]=ut,tt.right[U]=ut}}}if(s.forEach(function(t){var e,n,i=t.key,r=null===(e=v.current[i])||void 0===e?void 0:e.current,c=null===(n=h.current[i])||void 0===n?void 0:n.current;if(r&&c){var l=$[i];r.style.minHeight="".concat(l,"px"),c.style.minHeight="".concat(l,"px")}}),_.current||(Object.entries(tt.left).forEach(function(t){var e,n=t[0],i=t[1],r=null===(e=g.current[Number(n)])||void 0===e?void 0:e.current;r&&(r.style.minHeight="".concat(i,"px"))}),Object.entries(tt.right).forEach(function(t){var e,n=t[0],i=t[1],r=null===(e=f.current[Number(n)])||void 0===e?void 0:e.current;r&&(r.style.minHeight="".concat(i,"px"))}),C||Object.keys(et).forEach(function(t){var e,n,i=null===(e=b.current[t])||void 0===e?void 0:e.current,r=null===(n=p.current[t])||void 0===n?void 0:n.current;if(i&&r&&et[t]){var c=et[t];i.style.minHeight="".concat(c,"px"),r.style.minHeight="".concat(c,"px")}})),!I){a.forEach(function(t,e){var n,i=null===(n=g.current[e])||void 0===n?void 0:n.current;if(i){var l=function(t,e){var n=(t.refIndexes||[]).map(function(t){return d.findIndex(function(e){return e.selfIndex===t})}).filter(function(t){return-1!==t});return!n.length&&d[e]?[e]:Array.from(new Set(n))}(t,e);l.forEach(function(n){var l,o,u,a,s,v,h,g,b,p,A=null===(l=f.current[n])||void 0===l?void 0:l.current;if(A){var y=i.getBoundingClientRect(),R=A.getBoundingClientRect(),x=y.right-K.left,m=R.left-K.left,B=y.top+18-K.top,I=R.top+18-K.top;if(C&&S&&T===e){var D=null!==(u=null===(o=r.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==u?u:0,O=null!==(s=null===(a=c.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==s?s:0,L=D+(null!==(h=null===(v=r.current)||void 0===v?void 0:v.clientHeight)&&void 0!==h?h:1/0),_=O+(null!==(b=null===(g=c.current)||void 0===g?void 0:g.clientHeight)&&void 0!==b?b:1/0),F=function(t,e,n){return Math.max(e,Math.min(n,t))};B=F(y.top+18,D,L)-K.top,I=F(R.top+18,O,_)-K.top}var N=M(e);N&&J.push({id:"line-".concat(e,"-").concat(n),x1:x,y1:B,x2:m,y2:I,style:N,sectionIdx:e,targetRightIdx:n,isSubSection:!1,hasCognitive:!!((null==t?void 0:t.cognitiveData)||(null===(p=d[n])||void 0===p?void 0:p.cognitiveData)||(null==t?void 0:t.nodeId)&&E[t.nodeId])})}})}})}if(!I&&S&&"string"==typeof T&&T.includes(e.DEVIATION_BADGE_SEPARATOR)){var at=T.split(e.DEVIATION_BADGE_SEPARATOR),st=at[0],vt=at[1],ft=at[2],bt=(at[3],"".concat(st).concat(e.DEVIATION_BADGE_SEPARATOR).concat(vt)),pt=null===(H=A.current[bt])||void 0===H?void 0:H.current,At=null===(P=y.current[bt])||void 0===P?void 0:P.current;if(pt&&At){var xt=pt.getBoundingClientRect(),Bt=At.getBoundingClientRect(),St=xt.right-K.left,Tt=Bt.left-K.left,Ct=xt.top+xt.height/2-K.top,It=Bt.top+Bt.height/2-K.top;if(C){var Et=null!==(G=null===(k=r.current)||void 0===k?void 0:k.getBoundingClientRect().top)&&void 0!==G?G:0,Mt=null!==(V=null===(w=c.current)||void 0===w?void 0:w.getBoundingClientRect().top)&&void 0!==V?V:0,Dt=Et+(null!==(j=null===(Y=r.current)||void 0===Y?void 0:Y.clientHeight)&&void 0!==j?j:1/0),Ot=Mt+(null!==(Q=null===(z=c.current)||void 0===z?void 0:z.clientHeight)&&void 0!==Q?Q:1/0),Lt=function(t,e,n){return Math.max(e,Math.min(n,t))};Ct=Lt(xt.top+xt.height/2,Et,Dt)-K.top,It=Lt(Bt.top+Bt.height/2,Mt,Ot)-K.top}var _t=null!==(X=O(st,vt))&&void 0!==X?X:D(ft);_t&&J.push({id:"line-subsec-".concat(bt),x1:St,y1:Ct,x2:Tt,y2:It,style:_t,sectionIdx:Number(ft.split("-")[0]),isSubSection:!0,subSectionKeyPath:T})}}if(nt(J),o.current&&u.current){var Ft=o.current.getBoundingClientRect(),Nt=u.current.getBoundingClientRect(),Ht=(Ft.top+Ft.height/2-K.top+Nt.top+Nt.height/2-K.top)/2;ct({x1:Ft.right-K.left,x2:Nt.left-K.left,y:Ht})}else ct(null);if(B.size>0){var Pt=[],kt=r.current,Gt=c.current;if(kt&&Gt){var wt=[],Vt=kt.getBoundingClientRect().top,Yt=Gt.getBoundingClientRect().top,jt=Vt+kt.clientHeight,zt=Yt+Gt.clientHeight,Qt=kt.scrollTop,Xt=Gt.scrollTop,qt=K.top,Kt=function(t,e,n){return Math.max(e,Math.min(n,t))};B.forEach(function(t){var n,i,r,c,l,o,u,s,v;if(I){var h=null,g=null,f=null;if("string"==typeof t&&t.includes(e.DEVIATION_BADGE_SEPARATOR)){var b=t.split(e.DEVIATION_BADGE_SEPARATOR),p=b[0],R=b[1],x=b[2],m="".concat(p).concat(e.DEVIATION_BADGE_SEPARATOR).concat(R);h=null===(n=A.current[m])||void 0===n?void 0:n.current,f=null!==(i=O(p,R))&&void 0!==i?i:D(x),g=Number((null==x?void 0:x.split("-")[0])||0)}else g=Number(t),h=null===(r=A.current[g])||void 0===r?void 0:r.current,f=M(g);if(!h)return;document.querySelectorAll('[id^="guideline-target-"]').forEach(function(n,i){var r=h.getBoundingClientRect(),c=n.getBoundingClientRect(),l=r.right-K.left,o=c.left-K.left-0,u=l+75,a=r.top+r.height/2,d=c.top+c.height/2,s=a-Vt+Qt,v=d-Yt+Xt,g="conn-guide-".concat(t,"-").concat(i),b="";"string"==typeof t&&t.includes(e.DEVIATION_BADGE_SEPARATOR)?b=(t.split(e.DEVIATION_BADGE_SEPARATOR)[2]||"").split("-").map(function(t){return Number(t)+1}).join("."):b=String(Number(t)+1);var p=String.fromCharCode(97+i),A="".concat(b,"(").concat(p,")");wt.push({lhsScrollY:s,rhsScrollY:v,x1:l,x2:o,containerTop:qt,leftIdx:t,rhsArrayIdx:i,styleColor:(null==f?void 0:f.badgeBorder)||"#6366F1",styleBg:(null==f?void 0:f.badgeBg)||"#FFFFFF",styleText:(null==f?void 0:f.badgeText)||"#A16207",styleId:g,centerX:u});var y=Kt(a,Vt,jt),R=Kt(d,Yt,zt),x=y-qt,m=R-qt,B=Rt(l,x,o,m,u,a>=Vt-4&&a<=jt+4,d>=Yt-4&&d<=zt+4);Pt.push({id:g,pathD:B,style:f,leftIdx:t,rhsArrayIdx:i,x1:l,x2:o,y1:x,y2:m,centerX:u,matchLabel:A,isGuideline:!0})})}else if("string"==typeof t&&t.includes(e.DEVIATION_BADGE_SEPARATOR)){var B=t.split(e.DEVIATION_BADGE_SEPARATOR),S=(p=B[0],R=B[1],x=B[2],B[3],m="".concat(p).concat(e.DEVIATION_BADGE_SEPARATOR).concat(R),null===(c=A.current[m])||void 0===c?void 0:c.current),T=null===(l=y.current[m])||void 0===l?void 0:l.current;if(!S||!T)return;var E=S.getBoundingClientRect(),L=T.getBoundingClientRect(),_=null!==(o=O(p,R))&&void 0!==o?o:D(x),F=E.right-K.left,N=L.left-K.left-0,H=F+75,P=E.top+E.height/2,k=L.top+L.height/2,G=P-Vt+Qt,w=k-Yt+Xt,V="conn-subsec-".concat(m),Y=(x||"").split("-").map(function(t){return Number(t)+1}).join("."),j="".concat(Y,"(a)");wt.push({lhsScrollY:G,rhsScrollY:w,x1:F,x2:N,containerTop:qt,leftIdx:t,rhsArrayIdx:t,styleColor:(null==_?void 0:_.badgeBorder)||"#6366F1",styleBg:(null==_?void 0:_.badgeBg)||"#FFFFFF",styleText:(null==_?void 0:_.badgeText)||"#A16207",styleId:V,centerX:H});var z=Kt(P,Vt,jt),Q=Kt(k,Yt,zt),X=Rt(F,Z=z-qt,N,$=Q-qt,H,P>=Vt-4&&P<=jt+4,k>=Yt-4&&k<=zt+4);Pt.push({id:V,pathD:X,style:_,leftIdx:t,rhsArrayIdx:t,x1:F,x2:N,y1:Z,y2:$,matchLabel:j})}else if(C){var q=t,J=a[q];if(!(null===(v=null==J?void 0:J.refIndexes)||void 0===v?void 0:v.length))return;J.refIndexes.forEach(function(e,n){var i,r,c=d.findIndex(function(t){return t.selfIndex===e});if(-1!==c){var l=null===(i=A.current[q])||void 0===i?void 0:i.current,o=null===(r=y.current[c])||void 0===r?void 0:r.current;if(l&&o){var u=l.getBoundingClientRect(),a=o.getBoundingClientRect(),s=M(q),v=u.right-K.left,h=a.left-K.left-0,g=v+75,f=u.top+u.height/2,b=a.top+a.height/2,p=f-Vt+Qt,R=b-Yt+Xt,x="conn-".concat(q,"-").concat(c),m=String(Number(t)+1),B=String.fromCharCode(97+n),S="".concat(m,"(").concat(B,")");wt.push({lhsScrollY:p,rhsScrollY:R,x1:v,x2:h,containerTop:qt,leftIdx:q,rhsArrayIdx:c,styleColor:(null==s?void 0:s.badgeBorder)||"#6366F1",styleBg:(null==s?void 0:s.badgeBg)||"#FFFFFF",styleText:(null==s?void 0:s.badgeText)||"#A16207",styleId:x,centerX:g});var T=Kt(f,Vt,jt),C=Kt(b,Yt,zt),I=T-qt,E=C-qt,D=Rt(v,I,h,E,g,f>=Vt-4&&f<=jt+4,b>=Yt-4&&b<=zt+4);Pt.push({id:x,pathD:D,style:s,leftIdx:q,rhsArrayIdx:c,x1:v,x2:h,y1:I,y2:E,matchLabel:S})}}})}else{var U=t,W=U;S=null===(u=A.current[U])||void 0===u?void 0:u.current,T=null===(s=y.current[W])||void 0===s?void 0:s.current;if(!S||!T)return;E=S.getBoundingClientRect(),L=T.getBoundingClientRect(),_=M(U),F=E.right-K.left,N=L.left-K.left-0,H=F+75,P=E.top+E.height/2,k=L.top+L.height/2,G=P-Vt+Qt,w=k-Yt+Xt,V="conn-".concat(U,"-").concat(W),Y=String(Number(t)+1),j="".concat(Y,"(a)");wt.push({lhsScrollY:G,rhsScrollY:w,x1:F,x2:N,containerTop:qt,leftIdx:U,rhsArrayIdx:W,styleColor:(null==_?void 0:_.badgeBorder)||"#6366F1",styleBg:(null==_?void 0:_.badgeBg)||"#FFFFFF",styleText:(null==_?void 0:_.badgeText)||"#A16207",styleId:V,centerX:H});var Z,$;z=Kt(P,Vt,jt),Q=Kt(k,Yt,zt),X=Rt(F,Z=z-qt,N,$=Q-qt,H,P>=Vt-4&&P<=jt+4,k>=Yt-4&&k<=zt+4);Pt.push({id:V,pathD:X,style:_,leftIdx:U,rhsArrayIdx:W,x1:F,x2:N,y1:Z,y2:$,matchLabel:j})}}),yt.current=wt}dt(Pt),setTimeout(function(){return mt()},10)}else dt([]),yt.current=[],setTimeout(function(){return mt()},10)}catch(t){console.error("Line render safe fail: ",t)}finally{gt.current=!1}}},[s,a,d,E,Z,$,M,O,C,S,T,B,x,m,I]),mt=t.useCallback(function(){var t,e,n,o,u,a,d,s,v,h,g,f,b,p,A,y,R,x,m,B=yt.current;if(!B.length)return null===(t=l.current["guideline-up-stroke"])||void 0===t||t.setAttribute("visibility","hidden"),null===(e=l.current["guideline-up-badge"])||void 0===e||e.setAttribute("visibility","hidden"),null===(n=l.current["guideline-down-stroke"])||void 0===n||n.setAttribute("visibility","hidden"),void(null===(o=l.current["guideline-down-badge"])||void 0===o||o.setAttribute("visibility","hidden"));if(!_.current){var S=null!==(a=null===(u=r.current)||void 0===u?void 0:u.scrollTop)&&void 0!==a?a:0,T=null!==(s=null===(d=c.current)||void 0===d?void 0:d.scrollTop)&&void 0!==s?s:0,C=null!==(h=null===(v=r.current)||void 0===v?void 0:v.clientHeight)&&void 0!==h?h:1/0,I=null!==(f=null===(g=c.current)||void 0===g?void 0:g.clientHeight)&&void 0!==f?f:1/0,E=null!==(p=null===(b=r.current)||void 0===b?void 0:b.getBoundingClientRect().top)&&void 0!==p?p:0,M=null!==(y=null===(A=c.current)||void 0===A?void 0:A.getBoundingClientRect().top)&&void 0!==y?y:0,D=E+C,O=M+I,L=null===(R=i.current)||void 0===R?void 0:R.getBoundingClientRect(),F=null!==(x=null==L?void 0:L.top)&&void 0!==x?x:0,N=null!==(m=null==L?void 0:L.height)&&void 0!==m?m:1/0,H=function(t,e,n){return Math.max(e,Math.min(n,t))},P=0,k=0,G=0,w=0,V="#6366F1",Y="#A16207",j=!1;if(B.forEach(function(t){var e=t.lhsScrollY-S+E,n=t.rhsScrollY-T+M,i=l.current[t.styleId+"-stroke"],r=l.current[t.styleId+"-bg"],c=l.current[t.styleId+"-btn"],o=l.current[t.styleId+"-number"];if(i||r){var u=H(e,E,D),a=H(n,M,O),d=u-F,s=a-F,v=e>=E-4&&e<=D+4,h=n>=M-4&&n<=O+4,g=!0;j=!0;var f=t.centerX||t.x1+75;0===G&&(G=t.x1,w=d,V=t.styleColor,t.styleBg,Y=t.styleText||"#A16207"),n<M-4?(P++,g=!1):n>O+4&&(k++,g=!1);var b=Rt(t.x1,d,t.x2,s,f,v,h);i&&(g&&b?(i.setAttribute("visibility","visible"),i.setAttribute("d",b)):i.setAttribute("visibility","hidden")),r&&(g&&b?(r.setAttribute("visibility","visible"),r.setAttribute("d",b)):r.setAttribute("visibility","hidden")),c&&(v&&g?(c.setAttribute("visibility","visible"),c.setAttribute("y",String(d-12))):c.setAttribute("visibility","hidden")),o&&(v&&g?(o.setAttribute("visibility","visible"),o.setAttribute("transform","translate(".concat(t.x2-42,", ").concat(s,")"))):o.setAttribute("visibility","hidden"))}}),j){var z=l.current["guideline-up-stroke"],Q=l.current["guideline-up-badge"],X=l.current["guideline-up-arrow"],q=l.current["guideline-up-text"],K=l.current["guideline-up-badge-rect"],J=G+75;if(P>0){var U=Math.max(15,M-F+15),W=Math.min(15,Math.abs(J-G),Math.max(0,w-U)),Z="M ".concat(G,",").concat(w," L ").concat(J-W,",").concat(w," Q ").concat(J,",").concat(w," ").concat(J,",").concat(w-W," L ").concat(J,",").concat(U);null==z||z.setAttribute("visibility","visible"),null==z||z.setAttribute("d",Z),null==z||z.setAttribute("stroke",V),null==Q||Q.setAttribute("visibility","visible"),null==Q||Q.setAttribute("transform","translate(".concat(J,", ").concat(U,")")),X&&X.setAttribute("fill",V),q&&(q.textContent="+".concat(P),q.setAttribute("fill",Y)),K&&K.setAttribute("stroke",V)}else null==z||z.setAttribute("visibility","hidden"),null==Q||Q.setAttribute("visibility","hidden");var $=l.current["guideline-down-stroke"],tt=l.current["guideline-down-badge"],et=l.current["guideline-down-arrow"],nt=l.current["guideline-down-text"],it=l.current["guideline-down-badge-rect"];if(k>0){var rt=Math.min(N-15,O-F-15);W=Math.min(15,Math.abs(J-G),Math.max(0,rt-w)),Z="M ".concat(G,",").concat(w," L ").concat(J-W,",").concat(w," Q ").concat(J,",").concat(w," ").concat(J,",").concat(w+W," L ").concat(J,",").concat(rt);null==$||$.setAttribute("visibility","visible"),null==$||$.setAttribute("d",Z),null==$||$.setAttribute("stroke",V),null==tt||tt.setAttribute("visibility","visible"),null==tt||tt.setAttribute("transform","translate(".concat(J,", ").concat(rt,")")),et&&et.setAttribute("fill",V),nt&&(nt.textContent="+".concat(k),nt.setAttribute("fill",Y)),it&&it.setAttribute("stroke",V)}else null==$||$.setAttribute("visibility","hidden"),null==tt||tt.setAttribute("visibility","hidden")}}},[]),Bt=t.useCallback(function(){yt.current.length>0&&!_.current||(null!==pt.current&&clearTimeout(pt.current),pt.current=setTimeout(function(){Y.current(),pt.current=null},50))},[]),St=t.useCallback(function(t){if(null!==U.current&&W.current&&Math.abs(t.currentTarget.scrollTop-U.current)<=2){var n=W.current;U.current=null,W.current=null,n()}if(!bt.current&&!z.current){if(C&&Q&&(F.current||B.size>0)){var l=t.currentTarget,o=r.current,u=c.current,a=l===o?u:l===u?o:null;if(l&&a){var d=function(){var t,n,i,r,c,l,o,u,a,d,s,v=P.current,h=k.current;if(null===v)return{leftAnchor:null,rightAnchor:null};if("string"==typeof v&&v.includes(e.DEVIATION_BADGE_SEPARATOR)){var x=v.split(e.DEVIATION_BADGE_SEPARATOR),m="".concat(x[0]).concat(e.DEVIATION_BADGE_SEPARATOR).concat(x[1]);return{leftAnchor:(null===(t=A.current[m])||void 0===t?void 0:t.current)||(null===(n=b.current[x[2]])||void 0===n?void 0:n.current)||(null===(i=g.current[Number(x[2])])||void 0===i?void 0:i.current)||null,rightAnchor:(null===(r=y.current[m])||void 0===r?void 0:r.current)||(null===(c=p.current[x[3]])||void 0===c?void 0:c.current)||(null===(l=f.current[Number(x[3])])||void 0===l?void 0:l.current)||null}}var B=Number(v),S=null!==h?Number(h):B;return{leftAnchor:(null===(o=A.current[B])||void 0===o?void 0:o.current)||(null===(u=R.current[B])||void 0===u?void 0:u.current)||(null===(a=g.current[B])||void 0===a?void 0:a.current)||null,rightAnchor:(null===(d=y.current[S])||void 0===d?void 0:d.current)||(null===(s=f.current[S])||void 0===s?void 0:s.current)||null}}(),s=d.leftAnchor,v=d.rightAnchor,h=l===o?s:v,x=l===o?v:s,m=null;if(h&&x){var S=h.getBoundingClientRect(),T=x.getBoundingClientRect(),I=a.getBoundingClientRect(),E=S.top+S.height/2;m=T.top-I.top+a.scrollTop+T.height/2-(E-I.top)}else{var M=Math.max(0,l.scrollHeight-l.clientHeight),D=Math.max(0,a.scrollHeight-a.clientHeight);m=M>0?l.scrollTop/M*D:l.scrollTop}var O=Math.max(0,a.scrollHeight-a.clientHeight);m=Math.max(0,Math.min(m,O)),Math.abs(a.scrollTop-m)>1&&(bt.current=!0,a.scrollTop=m,requestAnimationFrame(function(){bt.current=!1}))}}C||Bt(),ft.current||(ft.current=!0,requestAnimationFrame(function(){var t,n,l,o,u,a,d;if(F.current){var s=r.current,v=c.current;if(s&&v&&H.current){if(!N.current){var h=P.current,g=void 0;if("string"==typeof h&&h.includes(e.DEVIATION_BADGE_SEPARATOR)){var f=h.split(e.DEVIATION_BADGE_SEPARATOR),b="".concat(f[0]).concat(e.DEVIATION_BADGE_SEPARATOR).concat(f[1]);g=null===(t=A.current[b])||void 0===t?void 0:t.current}else g=null===(n=A.current[h])||void 0===n?void 0:n.current;if(g){var p=g.getBoundingClientRect();N.current={badgeScreenY:p.top+p.height/2,initialScrollTop:s.scrollTop,leftTop:s.getBoundingClientRect().top,leftBottom:s.getBoundingClientRect().top+s.clientHeight,cTop:null!==(o=null===(l=i.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==o?o:0}}}if(N.current){var y=N.current,R=s.scrollTop-y.initialScrollTop,x=y.badgeScreenY-R,m=((u=x,a=y.leftTop,d=y.leftBottom,Math.max(a,Math.min(d,u)))-y.cTop).toString(),B=x>=y.leftTop-4&&x<=y.leftBottom+4;H.current.setAttribute("y1",m),H.current.setAttribute("y2",m),H.current.setAttribute("visibility",B?"visible":"hidden")}}}mt(),ft.current=!1}))}},[mt,C,Q,B,Bt]);return t.useEffect(function(){Y.current=xt},[xt]),t.useEffect(function(){var t=setTimeout(Bt,250),e=function(){return X.current()};return window.addEventListener("resize",e),function(){clearTimeout(t),null!==pt.current&&clearTimeout(pt.current),null!==j.current&&clearTimeout(j.current),window.removeEventListener("resize",e)}},[q,K,J,s,x,m,a,d,Z,Bt,S,T,L,B]),{lines:et,setLines:nt,overallConnector:rt,setOverallConnector:ct,connectedLines:at,setConnectedLines:dt,svgDimensions:vt,cachedConnectedPositions:yt,calculateLines:xt,calculateLinesRef:Y,calculateLinesDebounced:Bt,handleColumnScroll:St}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),e=require("../CognitiveComparehelpers.js");exports.useLinesCalculator=function(n){var i=n.containerRef,r=n.leftContainerRef,c=n.rightContainerRef;n.svgContainerRef;var l=n.pathRefs,o=n.leftHeaderRef,u=n.rightHeaderRef,a=n.proposedSections,d=n.existingSections,s=n.visibleFields,v=n.leftRefs,h=n.rightRefs,g=n.sectionLeftRefs,f=n.sectionRightRefs,b=n.subSectionLeftRefs,p=n.subSectionRightRefs,A=n.lhsBadgeRefs,y=n.rhsBadgeRefs,R=n.sectionRowRefs,x=n.expandedSections,m=n.expandedSubSections,B=n.connectedSections,S=n.isSideBySide,T=n.activeSideBySideSection,C=n.maintainRelativeOrder,I=n.isGuidelineMode,E=n.cognitiveMap,M=n.getSectionCompareStyle,D=n.getSubSectionCompareStyle,O=n.getDeviationStyleByKey,L=n.isArrowVisible,_=n.isAnimatingRef,F=n.isSideBySideRef,N=n.sideBySideCacheRef,H=n.sideBySideLineRef,P=n.activeSideBySideSectionRef,k=n.activeSideBySideRightSectionRef,G=n.connectedLines,w=n.setConnectedLines,V=n.cachedConnectedPositions,Y=n.calculateLinesRef,j=n.resizeTimerRef,z=n.scrollLock,Q=n.scrollSyncLocked,X=n.handleResizeRef,q=n.activeProposed,K=n.existingRule,J=n.analysisData,U=n.pendingScrollTargetRef,W=n.pendingScrollCallbackRef,Z=n.resolvedComparisonConfig,$=n.getFieldData,tt=t.useState([]),et=tt[0],nt=tt[1],it=t.useState(null),rt=it[0],ct=it[1],lt=t.useState([]),ot=lt[0],ut=lt[1],at=null!=G?G:ot,dt=null!=w?w:ut,st=t.useState({width:0,height:0}),vt=st[0],ht=st[1],gt=t.useRef(!1),ft=t.useRef(!1),bt=t.useRef(!1),pt=t.useRef(null),At=t.useRef([]),yt=null!=V?V:At,Rt=function(t,e,n,i,r,c,l){if(Math.abs(i-e)<=1)return c&&l?"M ".concat(t,",").concat(e," L ").concat(n,",").concat(i):c&&!l?"M ".concat(t,",").concat(e," L ").concat(r,",").concat(e):!c&&l?"M ".concat(r,",").concat(e," L ").concat(n,",").concat(i):"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i);var o=Math.min(15,Math.abs(r-t),Math.abs(i-e)/2),u=Math.min(15,Math.abs(n-r),Math.abs(i-e)/2),a=i>e?o:-o,d=i>e?u:-u,s=n>r?u:-u;return c&&l?"M ".concat(t,",").concat(e," L ").concat(r-o,",").concat(e," Q ").concat(r,",").concat(e," ").concat(r,",").concat(e+a," L ").concat(r,",").concat(i-d," Q ").concat(r,",").concat(i," ").concat(r+s,",").concat(i," L ").concat(n,",").concat(i):c&&!l?"M ".concat(t,",").concat(e," L ").concat(r-o,",").concat(e," Q ").concat(r,",").concat(e," ").concat(r,",").concat(e+a," L ").concat(r,",").concat(i):!c&&l?"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i-d," Q ").concat(r,",").concat(i," ").concat(r+s,",").concat(i," L ").concat(n,",").concat(i):"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i)},xt=t.useCallback(function(){var t,n,l,R,L,F,N,H,P,k,G,w,V,Y,j,z,Q,X;if(!gt.current&&!_.current){gt.current=!0;try{if(!i.current)return;var q=function(t){var e=t.split("-"),n=e[0];if(!x[n]&&!1===C)return!1;if(C&&!x["left-".concat(n)]&&!x["right-".concat(n)]&&!x[n])return!1;for(var i=n,r=1;r<e.length-1;r++)if(i+="-".concat(e[r]),!m[i])return!1;return!0},K=i.current.getBoundingClientRect();ht({width:K.width,height:K.height});var J=[];if(s.forEach(function(t){var e,n,i=t.key,r=null===(e=v.current[i])||void 0===e?void 0:e.current,c=null===(n=h.current[i])||void 0===n?void 0:n.current;r&&c&&(r.style.height="auto",c.style.height="auto",r.style.minHeight="0px",c.style.minHeight="0px")}),!_.current){for(var U=0;U<Math.max(a.length,d.length);U++){var W=null===(t=g.current[U])||void 0===t?void 0:t.current,Z=null===(n=f.current[U])||void 0===n?void 0:n.current;W&&(W.style.height="auto",W.style.minHeight="0px"),Z&&(Z.style.height="auto",Z.style.minHeight="0px")}C||Object.keys(b.current).forEach(function(t){var e,n;if(q(t)){var i=null===(e=b.current[t])||void 0===e?void 0:e.current,r=null===(n=p.current[t])||void 0===n?void 0:n.current;i&&r&&(i.style.height="auto",r.style.height="auto",i.style.minHeight="0px",r.style.minHeight="0px")}})}var $={};s.forEach(function(t){var e,n,i=t.key,r=null===(e=v.current[i])||void 0===e?void 0:e.current,c=null===(n=h.current[i])||void 0===n?void 0:n.current;if(r&&c){var l=r.getBoundingClientRect(),o=c.getBoundingClientRect();$[i]=Math.max(l.height,o.height)}});var tt={left:{},right:{}},et={};if(!_.current)if(C){if(S&&null!==T)if("number"==typeof T){var it=T,rt=a[it],lt=null===(L=g.current[it])||void 0===L?void 0:L.current;lt&&rt&&(rt.refIndexes||[]).forEach(function(t){var e,n=d.findIndex(function(e){return e.selfIndex===t}),i=null===(e=f.current[n])||void 0===e?void 0:e.current;if(i&&(x["left-".concat(it)]||x["right-".concat(n)])){var r=Math.max(lt.getBoundingClientRect().height,i.getBoundingClientRect().height);tt.left[it]=Math.max(tt.left[it]||0,r),tt.right[n]=Math.max(tt.right[n]||0,r)}})}else{var ot=T.split(e.DEVIATION_BADGE_SEPARATOR)[2];if(ot){W=null===(F=b.current[ot])||void 0===F?void 0:F.current,Z=null===(N=p.current[ot])||void 0===N?void 0:N.current;if(W&&Z){ut=Math.max(W.getBoundingClientRect().height,Z.getBoundingClientRect().height);et[ot]=Math.max(et[ot]||0,ut)}}}}else{Object.keys(b.current).forEach(function(t){var e,n;if(q(t)){var i=null===(e=b.current[t])||void 0===e?void 0:e.current,r=null===(n=p.current[t])||void 0===n?void 0:n.current;if(i&&r&&null!==i.offsetParent&&null!==r.offsetParent){var c=i.getBoundingClientRect(),l=r.getBoundingClientRect(),o=Math.max(c.height,l.height);et[t]=o,i.style.minHeight="".concat(o,"px"),r.style.minHeight="".concat(o,"px")}}});for(U=0;U<Math.min(a.length,d.length);U++){var W=null===(l=g.current[U])||void 0===l?void 0:l.current,Z=null===(R=f.current[U])||void 0===R?void 0:R.current;if(W&&Z){var ut=Math.max(W.getBoundingClientRect().height,Z.getBoundingClientRect().height);tt.left[U]=ut,tt.right[U]=ut}}}if(s.forEach(function(t){var e,n,i=t.key,r=null===(e=v.current[i])||void 0===e?void 0:e.current,c=null===(n=h.current[i])||void 0===n?void 0:n.current;if(r&&c){var l=$[i];r.style.minHeight="".concat(l,"px"),c.style.minHeight="".concat(l,"px")}}),_.current||(Object.entries(tt.left).forEach(function(t){var e,n=t[0],i=t[1],r=null===(e=g.current[Number(n)])||void 0===e?void 0:e.current;r&&(r.style.minHeight="".concat(i,"px"))}),Object.entries(tt.right).forEach(function(t){var e,n=t[0],i=t[1],r=null===(e=f.current[Number(n)])||void 0===e?void 0:e.current;r&&(r.style.minHeight="".concat(i,"px"))}),C||Object.keys(et).forEach(function(t){var e,n,i=null===(e=b.current[t])||void 0===e?void 0:e.current,r=null===(n=p.current[t])||void 0===n?void 0:n.current;if(i&&r&&et[t]){var c=et[t];i.style.minHeight="".concat(c,"px"),r.style.minHeight="".concat(c,"px")}})),!I){a.forEach(function(t,e){var n,i=null===(n=g.current[e])||void 0===n?void 0:n.current;if(i){var l=function(t,e){var n=(t.refIndexes||[]).map(function(t){return d.findIndex(function(e){return e.selfIndex===t})}).filter(function(t){return-1!==t});return!n.length&&d[e]?[e]:Array.from(new Set(n))}(t,e);l.forEach(function(n){var l,o,u,a,s,v,h,g,b,p,A=null===(l=f.current[n])||void 0===l?void 0:l.current;if(A){var y=i.getBoundingClientRect(),R=A.getBoundingClientRect(),x=y.right-K.left,m=R.left-K.left,B=y.top+18-K.top,I=R.top+18-K.top;if(C&&S&&T===e){var D=null!==(u=null===(o=r.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==u?u:0,O=null!==(s=null===(a=c.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==s?s:0,L=D+(null!==(h=null===(v=r.current)||void 0===v?void 0:v.clientHeight)&&void 0!==h?h:1/0),_=O+(null!==(b=null===(g=c.current)||void 0===g?void 0:g.clientHeight)&&void 0!==b?b:1/0),F=function(t,e,n){return Math.max(e,Math.min(n,t))};B=F(y.top+18,D,L)-K.top,I=F(R.top+18,O,_)-K.top}var N=M(e);N&&J.push({id:"line-".concat(e,"-").concat(n),x1:x,y1:B,x2:m,y2:I,style:N,sectionIdx:e,targetRightIdx:n,isSubSection:!1,hasCognitive:!!((null==t?void 0:t.cognitiveData)||(null===(p=d[n])||void 0===p?void 0:p.cognitiveData)||(null==t?void 0:t.nodeId)&&E[t.nodeId])})}})}})}if(!I&&S&&"string"==typeof T&&T.includes(e.DEVIATION_BADGE_SEPARATOR)){var at=T.split(e.DEVIATION_BADGE_SEPARATOR),st=at[0],vt=at[1],ft=at[2],bt=(at[3],"".concat(st).concat(e.DEVIATION_BADGE_SEPARATOR).concat(vt)),pt=null===(H=A.current[bt])||void 0===H?void 0:H.current,At=null===(P=y.current[bt])||void 0===P?void 0:P.current;if(pt&&At){var xt=pt.getBoundingClientRect(),Bt=At.getBoundingClientRect(),St=xt.right-K.left,Tt=Bt.left-K.left,Ct=xt.top+xt.height/2-K.top,It=Bt.top+Bt.height/2-K.top;if(C){var Et=null!==(G=null===(k=r.current)||void 0===k?void 0:k.getBoundingClientRect().top)&&void 0!==G?G:0,Mt=null!==(V=null===(w=c.current)||void 0===w?void 0:w.getBoundingClientRect().top)&&void 0!==V?V:0,Dt=Et+(null!==(j=null===(Y=r.current)||void 0===Y?void 0:Y.clientHeight)&&void 0!==j?j:1/0),Ot=Mt+(null!==(Q=null===(z=c.current)||void 0===z?void 0:z.clientHeight)&&void 0!==Q?Q:1/0),Lt=function(t,e,n){return Math.max(e,Math.min(n,t))};Ct=Lt(xt.top+xt.height/2,Et,Dt)-K.top,It=Lt(Bt.top+Bt.height/2,Mt,Ot)-K.top}var _t=null!==(X=O(st,vt))&&void 0!==X?X:D(ft);_t&&J.push({id:"line-subsec-".concat(bt),x1:St,y1:Ct,x2:Tt,y2:It,style:_t,sectionIdx:Number(ft.split("-")[0]),isSubSection:!0,subSectionKeyPath:T})}}if(nt(J),o.current&&u.current){var Ft=o.current.getBoundingClientRect(),Nt=u.current.getBoundingClientRect(),Ht=(Ft.top+Ft.height/2-K.top+Nt.top+Nt.height/2-K.top)/2;ct({x1:Ft.right-K.left,x2:Nt.left-K.left,y:Ht})}else ct(null);if(B.size>0){var Pt=[],kt=r.current,Gt=c.current;if(kt&&Gt){var wt=[],Vt=kt.getBoundingClientRect().top,Yt=Gt.getBoundingClientRect().top,jt=Vt+kt.clientHeight,zt=Yt+Gt.clientHeight,Qt=kt.scrollTop,Xt=Gt.scrollTop,qt=K.top,Kt=function(t,e,n){return Math.max(e,Math.min(n,t))};B.forEach(function(t){var n,i,r,c,l,o,u,s,v;if(I){var h=null,g=null,f=null;if("string"==typeof t&&t.includes(e.DEVIATION_BADGE_SEPARATOR)){var b=t.split(e.DEVIATION_BADGE_SEPARATOR),p=b[0],R=b[1],x=b[2],m="".concat(p).concat(e.DEVIATION_BADGE_SEPARATOR).concat(R);h=null===(n=A.current[m])||void 0===n?void 0:n.current,f=null!==(i=O(p,R))&&void 0!==i?i:D(x),g=Number((null==x?void 0:x.split("-")[0])||0)}else g=Number(t),h=null===(r=A.current[g])||void 0===r?void 0:r.current,f=M(g);if(!h)return;var B=document.querySelectorAll('[id^="guideline-target-"]');B.forEach(function(n,i){var r=h.getBoundingClientRect(),c=n.getBoundingClientRect(),l=r.right-K.left,o=c.left-K.left-0,u=l+75,a=r.top+r.height/2,d=c.top+c.height/2,s=a-Vt+Qt,v=d-Yt+Xt,g="conn-guide-".concat(t,"-").concat(i),b="";"string"==typeof t&&t.includes(e.DEVIATION_BADGE_SEPARATOR)?b=(t.split(e.DEVIATION_BADGE_SEPARATOR)[2]||"").split("-").map(function(t){return Number(t)+1}).join("."):b=String(Number(t)+1);var p=String.fromCharCode(97+i),A=1===B.length?null:"".concat(b,"(").concat(p,")");wt.push({lhsScrollY:s,rhsScrollY:v,x1:l,x2:o,containerTop:qt,leftIdx:t,rhsArrayIdx:i,styleColor:(null==f?void 0:f.badgeBorder)||"#6366F1",styleBg:(null==f?void 0:f.badgeBg)||"#FFFFFF",styleText:(null==f?void 0:f.badgeText)||"#A16207",styleId:g,centerX:u});var y=Kt(a,Vt,jt),R=Kt(d,Yt,zt),x=y-qt,m=R-qt,S=Rt(l,x,o,m,u,a>=Vt-4&&a<=jt+4,d>=Yt-4&&d<=zt+4);Pt.push({id:g,pathD:S,style:f,leftIdx:t,rhsArrayIdx:i,x1:l,x2:o,y1:x,y2:m,centerX:u,matchLabel:A,isGuideline:!0})})}else if("string"==typeof t&&t.includes(e.DEVIATION_BADGE_SEPARATOR)){var S=t.split(e.DEVIATION_BADGE_SEPARATOR),T=(p=S[0],R=S[1],x=S[2],S[3],m="".concat(p).concat(e.DEVIATION_BADGE_SEPARATOR).concat(R),null===(c=A.current[m])||void 0===c?void 0:c.current),E=null===(l=y.current[m])||void 0===l?void 0:l.current;if(!T||!E)return;var L=T.getBoundingClientRect(),_=E.getBoundingClientRect(),F=null!==(o=O(p,R))&&void 0!==o?o:D(x),N=L.right-K.left,H=_.left-K.left-0,P=N+75,k=L.top+L.height/2,G=_.top+_.height/2,w=k-Vt+Qt,V=G-Yt+Xt,Y="conn-subsec-".concat(m),j=((x||"").split("-").map(function(t){return Number(t)+1}).join("."),null);wt.push({lhsScrollY:w,rhsScrollY:V,x1:N,x2:H,containerTop:qt,leftIdx:t,rhsArrayIdx:t,styleColor:(null==F?void 0:F.badgeBorder)||"#6366F1",styleBg:(null==F?void 0:F.badgeBg)||"#FFFFFF",styleText:(null==F?void 0:F.badgeText)||"#A16207",styleId:Y,centerX:P});var z=Kt(k,Vt,jt),Q=Kt(G,Yt,zt),X=Rt(N,Z=z-qt,H,$=Q-qt,P,k>=Vt-4&&k<=jt+4,G>=Yt-4&&G<=zt+4);Pt.push({id:Y,pathD:X,style:F,leftIdx:t,rhsArrayIdx:t,x1:N,x2:H,y1:Z,y2:$,matchLabel:j})}else if(C){var q=t,J=a[q];if(!(null===(v=null==J?void 0:J.refIndexes)||void 0===v?void 0:v.length))return;J.refIndexes.forEach(function(e,n){var i,r,c=d.findIndex(function(t){return t.selfIndex===e});if(-1!==c){var l=null===(i=A.current[q])||void 0===i?void 0:i.current,o=null===(r=y.current[c])||void 0===r?void 0:r.current;if(l&&o){var u=l.getBoundingClientRect(),a=o.getBoundingClientRect(),s=M(q),v=u.right-K.left,h=a.left-K.left-0,g=v+75,f=u.top+u.height/2,b=a.top+a.height/2,p=f-Vt+Qt,R=b-Yt+Xt,x="conn-".concat(q,"-").concat(c),m=String(Number(t)+1),B=String.fromCharCode(97+n),S=1===J.refIndexes.length?null:"".concat(m,"(").concat(B,")");wt.push({lhsScrollY:p,rhsScrollY:R,x1:v,x2:h,containerTop:qt,leftIdx:q,rhsArrayIdx:c,styleColor:(null==s?void 0:s.badgeBorder)||"#6366F1",styleBg:(null==s?void 0:s.badgeBg)||"#FFFFFF",styleText:(null==s?void 0:s.badgeText)||"#A16207",styleId:x,centerX:g});var T=Kt(f,Vt,jt),C=Kt(b,Yt,zt),I=T-qt,E=C-qt,D=Rt(v,I,h,E,g,f>=Vt-4&&f<=jt+4,b>=Yt-4&&b<=zt+4);Pt.push({id:x,pathD:D,style:s,leftIdx:q,rhsArrayIdx:c,x1:v,x2:h,y1:I,y2:E,matchLabel:S})}}})}else{var U=t,W=U;T=null===(u=A.current[U])||void 0===u?void 0:u.current,E=null===(s=y.current[W])||void 0===s?void 0:s.current;if(!T||!E)return;L=T.getBoundingClientRect(),_=E.getBoundingClientRect(),F=M(U),N=L.right-K.left,H=_.left-K.left-0,P=N+75,k=L.top+L.height/2,G=_.top+_.height/2,w=k-Vt+Qt,V=G-Yt+Xt,Y="conn-".concat(U,"-").concat(W),String(Number(t)+1),j=null;wt.push({lhsScrollY:w,rhsScrollY:V,x1:N,x2:H,containerTop:qt,leftIdx:U,rhsArrayIdx:W,styleColor:(null==F?void 0:F.badgeBorder)||"#6366F1",styleBg:(null==F?void 0:F.badgeBg)||"#FFFFFF",styleText:(null==F?void 0:F.badgeText)||"#A16207",styleId:Y,centerX:P});var Z,$;z=Kt(k,Vt,jt),Q=Kt(G,Yt,zt),X=Rt(N,Z=z-qt,H,$=Q-qt,P,k>=Vt-4&&k<=jt+4,G>=Yt-4&&G<=zt+4);Pt.push({id:Y,pathD:X,style:F,leftIdx:U,rhsArrayIdx:W,x1:N,x2:H,y1:Z,y2:$,matchLabel:j})}}),yt.current=wt}dt(Pt),setTimeout(function(){return mt()},10)}else dt([]),yt.current=[],setTimeout(function(){return mt()},10)}catch(t){console.error("Line render safe fail: ",t)}finally{gt.current=!1}}},[s,a,d,E,Z,$,M,O,C,S,T,B,x,m,I]),mt=t.useCallback(function(){var t,e,n,o,u,a,d,s,v,h,g,f,b,p,A,y,R,x,m,B=yt.current;if(!B.length)return null===(t=l.current["guideline-up-stroke"])||void 0===t||t.setAttribute("visibility","hidden"),null===(e=l.current["guideline-up-badge"])||void 0===e||e.setAttribute("visibility","hidden"),null===(n=l.current["guideline-down-stroke"])||void 0===n||n.setAttribute("visibility","hidden"),void(null===(o=l.current["guideline-down-badge"])||void 0===o||o.setAttribute("visibility","hidden"));if(!_.current){var S=null!==(a=null===(u=r.current)||void 0===u?void 0:u.scrollTop)&&void 0!==a?a:0,T=null!==(s=null===(d=c.current)||void 0===d?void 0:d.scrollTop)&&void 0!==s?s:0,C=null!==(h=null===(v=r.current)||void 0===v?void 0:v.clientHeight)&&void 0!==h?h:1/0,I=null!==(f=null===(g=c.current)||void 0===g?void 0:g.clientHeight)&&void 0!==f?f:1/0,E=null!==(p=null===(b=r.current)||void 0===b?void 0:b.getBoundingClientRect().top)&&void 0!==p?p:0,M=null!==(y=null===(A=c.current)||void 0===A?void 0:A.getBoundingClientRect().top)&&void 0!==y?y:0,D=E+C,O=M+I,L=null===(R=i.current)||void 0===R?void 0:R.getBoundingClientRect(),F=null!==(x=null==L?void 0:L.top)&&void 0!==x?x:0,N=null!==(m=null==L?void 0:L.height)&&void 0!==m?m:1/0,H=function(t,e,n){return Math.max(e,Math.min(n,t))},P=0,k=0,G=0,w=0,V="#6366F1",Y="#A16207",j=!1,z=0;if(B.forEach(function(t){var e=t.lhsScrollY-S+E,n=t.rhsScrollY-T+M,i=l.current[t.styleId+"-stroke"],r=l.current[t.styleId+"-bg"],c=l.current[t.styleId+"-btn"],o=l.current[t.styleId+"-number"];if(i||r){var u=H(e,E,D),a=H(n,M,O),d=u-F,s=a-F,v=e>=E-4&&e<=D+4,h=n>=M-4&&n<=O+4,g=!0;j=!0;var f=t.centerX||t.x1+75;0===G&&(G=t.x1,w=d,z=f,V=t.styleColor,t.styleBg,Y=t.styleText||"#A16207"),n<M-4?(P++,g=!1):n>O+4&&(k++,g=!1);var b=Rt(t.x1,d,t.x2,s,z,v,h);i&&(g&&b?(i.setAttribute("visibility","visible"),i.setAttribute("d",b)):i.setAttribute("visibility","hidden")),r&&(g&&b?(r.setAttribute("visibility","visible"),r.setAttribute("d",b)):r.setAttribute("visibility","hidden")),c&&(v&&g?(c.setAttribute("visibility","visible"),c.setAttribute("y",String(d-12))):c.setAttribute("visibility","hidden")),o&&(v&&g?(o.setAttribute("visibility","visible"),o.setAttribute("transform","translate(".concat(t.x2-42,", ").concat(s,")"))):o.setAttribute("visibility","hidden"))}}),j&&z>0){var Q=l.current["guideline-up-stroke"],X=l.current["guideline-up-badge"],q=l.current["guideline-up-arrow"],K=l.current["guideline-up-text"],J=l.current["guideline-up-badge-rect"];if(P>0){var U=Math.max(15,M-F+15),W=Math.min(15,Math.abs(z-G),Math.max(0,w-U)),Z="M ".concat(G,",").concat(w," L ").concat(z-W,",").concat(w," Q ").concat(z,",").concat(w," ").concat(z,",").concat(w-W," L ").concat(z,",").concat(U);null==Q||Q.setAttribute("visibility","visible"),null==Q||Q.setAttribute("d",Z),null==Q||Q.setAttribute("stroke",V),null==X||X.setAttribute("visibility","visible"),null==X||X.setAttribute("transform","translate(".concat(z,", ").concat(U,")")),q&&q.setAttribute("fill",V),K&&(K.textContent="+".concat(P),K.setAttribute("fill",Y)),J&&J.setAttribute("stroke",V)}else null==Q||Q.setAttribute("visibility","hidden"),null==X||X.setAttribute("visibility","hidden");var $=l.current["guideline-down-stroke"],tt=l.current["guideline-down-badge"],et=l.current["guideline-down-arrow"],nt=l.current["guideline-down-text"],it=l.current["guideline-down-badge-rect"];if(k>0){var rt=Math.min(N-15,O-F-15);W=Math.min(15,Math.abs(z-G),Math.max(0,rt-w)),Z="M ".concat(G,",").concat(w," L ").concat(z-W,",").concat(w," Q ").concat(z,",").concat(w," ").concat(z,",").concat(w+W," L ").concat(z,",").concat(rt);null==$||$.setAttribute("visibility","visible"),null==$||$.setAttribute("d",Z),null==$||$.setAttribute("stroke",V),null==tt||tt.setAttribute("visibility","visible"),null==tt||tt.setAttribute("transform","translate(".concat(z,", ").concat(rt,")")),et&&et.setAttribute("fill",V),nt&&(nt.textContent="+".concat(k),nt.setAttribute("fill",Y)),it&&it.setAttribute("stroke",V)}else null==$||$.setAttribute("visibility","hidden"),null==tt||tt.setAttribute("visibility","hidden")}}},[]),Bt=t.useCallback(function(){yt.current.length>0&&!_.current||(null!==pt.current&&clearTimeout(pt.current),pt.current=setTimeout(function(){Y.current(),pt.current=null},50))},[]),St=t.useCallback(function(t){if(null!==U.current&&W.current&&Math.abs(t.currentTarget.scrollTop-U.current)<=2){var n=W.current;U.current=null,W.current=null,n()}if(!bt.current&&!z.current){if(C&&Q&&(F.current||B.size>0)){var l=t.currentTarget,o=r.current,u=c.current,a=l===o?u:l===u?o:null;if(l&&a){var d=function(){var t,n,i,r,c,l,o,u,a,d,s,v=P.current,h=k.current;if(null===v)return{leftAnchor:null,rightAnchor:null};if("string"==typeof v&&v.includes(e.DEVIATION_BADGE_SEPARATOR)){var x=v.split(e.DEVIATION_BADGE_SEPARATOR),m="".concat(x[0]).concat(e.DEVIATION_BADGE_SEPARATOR).concat(x[1]);return{leftAnchor:(null===(t=A.current[m])||void 0===t?void 0:t.current)||(null===(n=b.current[x[2]])||void 0===n?void 0:n.current)||(null===(i=g.current[Number(x[2])])||void 0===i?void 0:i.current)||null,rightAnchor:(null===(r=y.current[m])||void 0===r?void 0:r.current)||(null===(c=p.current[x[3]])||void 0===c?void 0:c.current)||(null===(l=f.current[Number(x[3])])||void 0===l?void 0:l.current)||null}}var B=Number(v),S=null!==h?Number(h):B;return{leftAnchor:(null===(o=A.current[B])||void 0===o?void 0:o.current)||(null===(u=R.current[B])||void 0===u?void 0:u.current)||(null===(a=g.current[B])||void 0===a?void 0:a.current)||null,rightAnchor:(null===(d=y.current[S])||void 0===d?void 0:d.current)||(null===(s=f.current[S])||void 0===s?void 0:s.current)||null}}(),s=d.leftAnchor,v=d.rightAnchor,h=l===o?s:v,x=l===o?v:s,m=null;if(h&&x){var S=h.getBoundingClientRect(),T=x.getBoundingClientRect(),I=a.getBoundingClientRect(),E=S.top+S.height/2;m=T.top-I.top+a.scrollTop+T.height/2-(E-I.top)}else{var M=Math.max(0,l.scrollHeight-l.clientHeight),D=Math.max(0,a.scrollHeight-a.clientHeight);m=M>0?l.scrollTop/M*D:l.scrollTop}var O=Math.max(0,a.scrollHeight-a.clientHeight);m=Math.max(0,Math.min(m,O)),Math.abs(a.scrollTop-m)>1&&(bt.current=!0,a.scrollTop=m,requestAnimationFrame(function(){bt.current=!1}))}}C||Bt(),ft.current||(ft.current=!0,requestAnimationFrame(function(){var t,n,l,o,u,a,d;if(F.current){var s=r.current,v=c.current;if(s&&v&&H.current){if(!N.current){var h=P.current,g=void 0;if("string"==typeof h&&h.includes(e.DEVIATION_BADGE_SEPARATOR)){var f=h.split(e.DEVIATION_BADGE_SEPARATOR),b="".concat(f[0]).concat(e.DEVIATION_BADGE_SEPARATOR).concat(f[1]);g=null===(t=A.current[b])||void 0===t?void 0:t.current}else g=null===(n=A.current[h])||void 0===n?void 0:n.current;if(g){var p=g.getBoundingClientRect();N.current={badgeScreenY:p.top+p.height/2,initialScrollTop:s.scrollTop,leftTop:s.getBoundingClientRect().top,leftBottom:s.getBoundingClientRect().top+s.clientHeight,cTop:null!==(o=null===(l=i.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==o?o:0}}}if(N.current){var y=N.current,R=s.scrollTop-y.initialScrollTop,x=y.badgeScreenY-R,m=((u=x,a=y.leftTop,d=y.leftBottom,Math.max(a,Math.min(d,u)))-y.cTop).toString(),B=x>=y.leftTop-4&&x<=y.leftBottom+4;H.current.setAttribute("y1",m),H.current.setAttribute("y2",m),H.current.setAttribute("visibility",B?"visible":"hidden")}}}mt(),ft.current=!1}))}},[mt,C,Q,B,Bt]);return t.useEffect(function(){Y.current=xt},[xt]),t.useEffect(function(){var t=setTimeout(Bt,250),e=function(){return X.current()};return window.addEventListener("resize",e),function(){clearTimeout(t),null!==pt.current&&clearTimeout(pt.current),null!==j.current&&clearTimeout(j.current),window.removeEventListener("resize",e)}},[q,K,J,s,x,m,a,d,Z,Bt,S,T,L,B]),{lines:et,setLines:nt,overallConnector:rt,setOverallConnector:ct,connectedLines:at,setConnectedLines:dt,svgDimensions:vt,cachedConnectedPositions:yt,calculateLines:xt,calculateLinesRef:Y,calculateLinesDebounced:Bt,handleColumnScroll:St}};
2
2
  //# sourceMappingURL=useLinesCalculator.js.map
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),r=require("react/jsx-runtime"),n=require("react"),t=require("react-markdown"),i=require("rehype-raw"),l=require("./utils/citationData.utils.js"),c=require("./GptWebCitation.module.css.js");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=a(t),u=a(i);exports.default=function(t){var i=t.content,a=t.activeHighlightIndex,o=t.onHighlightCountChange,h=n.useRef(null),d=n.useMemo(function(){var e,r=i.match(/id=["']highlighted-\d+["']/g);if(null==r?void 0:r.length)return r.length;var n=i.match(/<a\b[^>]*>/gi);return null!==(e=null==n?void 0:n.length)&&void 0!==e?e:0},[i]),f=n.useMemo(function(){return/id=["']highlighted-\d+["']/.test(i)},[i]);n.useEffect(function(){null==o||o(d)},[d,o]),n.useEffect(function(){var e;if(h.current){var r=h.current.querySelector("#highlighted-".concat(a));if(r)r.scrollIntoView({behavior:"smooth",block:"center"});else null===(e=h.current.querySelectorAll("a[href]")[a])||void 0===e||e.scrollIntoView({behavior:"smooth",block:"center"})}},[a,i]);var g=n.useMemo(function(){var n=-1;return{span:function(n){n.node;var t=e.__rest(n,["node"]),i=t.id;if(null==i?void 0:i.startsWith("highlighted-")){var l=Number(i.replace("highlighted-",""))===a;return r.jsx("span",e.__assign({},t,{id:i,className:"".concat(c.default.highlight).concat(l?" ".concat(c.default.highlightActive):"")}))}return r.jsx("span",e.__assign({},t))},a:function(t){var i,s=t.children,u=t.href,o=t.title,h=t.className;if(!u)return r.jsx(r.Fragment,{children:s});n+=1;var d=!f&&n===a,g=null!==(i=l.sanitizeExternalUrl(u))&&void 0!==i?i:"#";return r.jsx("a",e.__assign({href:g,title:o,target:"_blank",rel:"noreferrer",className:"".concat(c.default.citationLink).concat(d?" ".concat(c.default.citationLinkActive):"").concat(h?" ".concat(h):"")},{children:s}))},code:function(n){var t=n.children,i=e.__rest(n,["children"]);return r.jsx("code",e.__assign({},i,{children:t}))},ol:function(n){var t=n.children,i=e.__rest(n,["children"]);return r.jsx("ol",e.__assign({},i,{children:t}))},ul:function(n){var t=n.children,i=e.__rest(n,["children"]);return r.jsx("ul",e.__assign({},i,{children:t}))},li:function(n){var t=n.children,i=e.__rest(n,["children"]);return r.jsx("li",e.__assign({},i,{children:t}))},p:function(n){var t=n.children,i=e.__rest(n,["children"]);return r.jsx("p",e.__assign({},i,{children:t}))}}},[a,f,i]);return r.jsx("div",e.__assign({ref:h,className:c.default.markdownBody},{children:r.jsx(s.default,e.__assign({rehypePlugins:[u.default],components:g},{children:i}))}))};
2
+ //# sourceMappingURL=GptWebCitationMarkdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GptWebCitationMarkdown.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),i=require("@lexical/react/LexicalComposer"),l=require("@lexical/react/LexicalHistoryPlugin"),n=require("@lexical/react/LexicalOnChangePlugin"),r=require("@lexical/react/LexicalTabIndentationPlugin"),o=require("@lexical/list"),a=require("@lexical/react/LexicalListPlugin"),u=require("@lexical/react/LexicalLinkPlugin"),s=require("@lexical/link"),d=require("@lexical/rich-text"),c=require("@lexical/react/LexicalTablePlugin"),g=require("@lexical/table"),p=require("lexical");require("./components/EditorToolbar/components/ToolbarButton/ToolbarButton.css.js");var x=require("../../RequirementAIWrapper/RequirementAIWrapper.js"),f=require("./components/EditorContainer/EditorContainer.js"),m=require("./components/EditorToolbar/EditorToolbar.js"),h=require("./plugins/LayoutPlugin.js"),C=require("./theme/theme.js");require("./theme/theme.css.js"),require("./Editor.css.js");var N=require("./components/Context/ContextMenu.js"),q=require("@lexical/mark"),j=require("./plugins/CommentPlugin/HTMLNode.js"),v=require("./constants/editorConfig.js"),T=require("./plugins/InitialHtml.js"),S=require("./plugins/InsertNode.js"),y=require("./plugins/DeleteNode.js"),b=require("./plugins/HighlightNode.js"),P=require("@lexical/react/LexicalComposerContext"),L=require("./plugins/UpdateNode.js"),I=require("./plugins/ManualNode.js"),E=require("./plugins/PreservedNode.js"),R=require("./plugins/InvisibleNode.js");function _(e){console.log(e)}function B({onEditBlocked:e}){const[i]=P.useLexicalComposerContext();return t.useEffect(()=>{const t=e=>{let t=e;for(;t;){if(["preserved","insert","delete"].includes(t.getType()))return t;if(["update","manual"].includes(t.getType())&&t.getStatus()&&"pending"===t.getStatus())return t;t=t.getParent()}return!1};function l(e){var t;let i=e.getParent();for(;i;){if(i instanceof L.UpdateNode||i instanceof I.ManualNode)return null===(t=i.getId())||void 0===t?void 0:t.replaceAll("@","<").replaceAll("#",">");i=i.getParent()}return null}return i.registerCommand(p.KEY_DOWN_COMMAND,i=>{const n=p.$getSelection();if(!p.$isRangeSelection(n))return!1;const r=n.getNodes().find(e=>!!t(e));if(r)return i.preventDefault(),null==e||e(l(r)||""),!0;if(n.isCollapsed()){const r=n.anchor.getNode(),o=t(r);if(o){const t=o?l(o):"";return null==e||e(t||""),i.preventDefault(),!0}if("Backspace"===i.key){const t=r.getPreviousSibling(),o=t&&(["delete","insert","preserved"].includes(t.getType())||["update","manual"].includes(t.getType())&&t.getStatus()&&"pending"===t.getStatus())?t:null;if(0===n.anchor.offset&&o)return null==e||e(l(o)||""),i.preventDefault(),!0}else if("Delete"===i.key){const t=r.getNextSibling(),o=t&&(["delete","insert","preserved"].includes(t.getType())||["update","manual"].includes(t.getType())&&t.getStatus()&&"pending"===t.getStatus())?t:null,a=r.getTextContent().length;if(n.anchor.offset===a&&o)return null==e||e(l(o)||""),i.preventDefault(),!0}}return!1},p.COMMAND_PRIORITY_CRITICAL)},[i]),null}exports.default=function({minHeight:P,height:M,placeholder:k,onFocus:H,onBlur:D,onChange:A,onToolbarButtonClick:O,toolbarConfig:w=v.DEFAULT_TOOLBAR_CONFIG,editorRef:$,editorState:F,initialString:U,customToolbar:W,plugins:Y,nodes:V,dynamicHeight:G,artifactContext:K,commentsPanelState:Q,mode:X,doNotShowBorderInViewMode:z,onEditBlocked:J}){var Z,ee,te;const ie=t.useRef(null),le={namespace:"MyEditor",theme:C.default,onError:_,nodes:[p.TextNode,o.ListNode,o.ListItemNode,s.LinkNode,d.QuoteNode,d.HeadingNode,g.TableNode,g.TableRowNode,g.TableCellNode,q.MarkNode,j.default,S.InsertNode,y.DeleteNode,L.UpdateNode,E.PreservedNode,I.ManualNode,R.InvisibleNode,b.HighlightSpanNode,b.HighlightButtonNode],editorState:F},[ne,re]=t.useState(null),[oe,ae]=t.useState(!1),{customStyles:ue}=x.useRequirementAI(),se=e=>{var t;null===(t=$.current)||void 0===t||t.update(()=>{const t=p.$getSelection();p.$isRangeSelection(t)&&t.getNodes().forEach(t=>{p.$isTextNode(t)&&t.setStyle(`color: ${e}`)})})};return document.getElementById("lexical_editor_wrapper"),e.jsxs(e.Fragment,{children:[(null===(Z=null==ue?void 0:ue.textEditorStyles)||void 0===Z?void 0:Z.themeStyles)&&e.jsx("style",{children:null===(ee=null==ue?void 0:ue.textEditorStyles)||void 0===ee?void 0:ee.themeStyles}),e.jsxs("div",{ref:ie,className:"w-full lexical_editor_wrapper "+(z&&"readOnly"===X?"":"lexical_editor_wrapper_box"),id:"lexical_editor_wrapper",onContextMenu:e=>{var t;e.preventDefault(),null===(t=$.current)||void 0===t||t.update(()=>{const t=p.$getSelection();p.$isRangeSelection(t)&&!t.isCollapsed()?(ae(!0),re({x:e.clientX,y:e.clientY})):(ae(!1),re(null))})},style:{minHeight:P,height:M,...null===(te=null==ue?void 0:ue.textEditorStyles)||void 0===te?void 0:te.textArea},children:[e.jsxs(i.LexicalComposer,{initialConfig:le,children:[" ","edit"===X&&e.jsx(B,{onEditBlocked:J}),"edit"===X&&e.jsx(m.default,{onToolbarButtonClick:O,editorWrapperRef:ie,toolbarConfig:w,customToolbar:W,editorRef:$}),e.jsx(f.default,{placeholder:k}),e.jsx(r.TabIndentationPlugin,{}),e.jsx(l.HistoryPlugin,{}),e.jsx(a.ListPlugin,{}),e.jsx(u.LinkPlugin,{}),e.jsx(c.TablePlugin,{}),e.jsx(h.LayoutPlugin,{onFocus:H,onBlur:D,editorRef:$}),e.jsx(n.OnChangePlugin,{ignoreSelectionChange:!0,ignoreHistoryMergeTagChange:!0,onChange:(e,t,i)=>{A&&A(e,t,i)}}),U&&e.jsx(T.InitialHtml,{initialValue:U.value,initialFormat:U.type,mode:X}),Y&&Y]}),ne&&oe&&"edit"===X&&e.jsx(N.default,{position:ne,options:[{label:"Change Color to Red",action:()=>se("red")},{label:"Change Color to Blue",action:()=>se("blue")}],onClose:()=>{re(null)}})]})]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),i=require("@lexical/react/LexicalComposer"),n=require("@lexical/react/LexicalHistoryPlugin"),r=require("@lexical/react/LexicalOnChangePlugin"),l=require("@lexical/react/LexicalTabIndentationPlugin"),o=require("@lexical/list"),a=require("@lexical/react/LexicalListPlugin"),u=require("@lexical/react/LexicalLinkPlugin"),s=require("@lexical/link"),d=require("@lexical/rich-text"),c=require("@lexical/react/LexicalTablePlugin"),g=require("@lexical/table"),p=require("lexical");require("./components/EditorToolbar/components/ToolbarButton/ToolbarButton.css.js");var x=require("../../RequirementAIWrapper/RequirementAIWrapper.js"),f=require("./components/EditorContainer/EditorContainer.js"),m=require("./components/EditorToolbar/EditorToolbar.js"),h=require("./plugins/LayoutPlugin.js"),C=require("./theme/theme.js");require("./theme/theme.css.js"),require("./Editor.css.js");var N=require("./components/Context/ContextMenu.js"),q=require("@lexical/mark"),j=require("./plugins/CommentPlugin/HTMLNode.js"),v=require("./constants/editorConfig.js"),T=require("./plugins/InitialHtml.js"),S=require("./plugins/InsertNode.js"),y=require("./plugins/DeleteNode.js"),b=require("./plugins/HighlightNode.js"),P=require("@lexical/react/LexicalComposerContext"),L=require("./plugins/UpdateNode.js"),I=require("./plugins/ManualNode.js"),E=require("./plugins/PreservedNode.js"),R=require("./plugins/InvisibleNode.js");function _(e){console.log(e)}function B({onEditBlocked:e}){const[i]=P.useLexicalComposerContext();return t.useEffect(()=>{const t=e=>{let t=e;for(;t;){if(["preserved","insert","delete"].includes(t.getType()))return t;if(["update","manual"].includes(t.getType())&&t.getStatus()&&"pending"===t.getStatus())return t;t=t.getParent()}return!1};function n(e){let t=e.getParent();for(;t;){if(t instanceof L.UpdateNode||t instanceof I.ManualNode)return t.getId();t=t.getParent()}return null}return i.registerCommand(p.KEY_DOWN_COMMAND,i=>{const r=p.$getSelection();if(!p.$isRangeSelection(r))return!1;const l=r.getNodes().find(e=>!!t(e));if(l)return i.preventDefault(),null==e||e(n(l)||""),!0;if(r.isCollapsed()){const l=r.anchor.getNode(),o=t(l);if(o){const t=o?n(o):"";return null==e||e(t||""),i.preventDefault(),!0}if("Backspace"===i.key){const t=l.getPreviousSibling(),o=t&&(["delete","insert","preserved"].includes(t.getType())||["update","manual"].includes(t.getType())&&t.getStatus()&&"pending"===t.getStatus())?t:null;if(0===r.anchor.offset&&o)return null==e||e(n(o)||""),i.preventDefault(),!0}else if("Delete"===i.key){const t=l.getNextSibling(),o=t&&(["delete","insert","preserved"].includes(t.getType())||["update","manual"].includes(t.getType())&&t.getStatus()&&"pending"===t.getStatus())?t:null,a=l.getTextContent().length;if(r.anchor.offset===a&&o)return null==e||e(n(o)||""),i.preventDefault(),!0}}return!1},p.COMMAND_PRIORITY_CRITICAL)},[i]),null}exports.default=function({minHeight:P,height:M,placeholder:k,onFocus:H,onBlur:D,onChange:O,onToolbarButtonClick:A,toolbarConfig:w=v.DEFAULT_TOOLBAR_CONFIG,editorRef:$,editorState:F,initialString:U,customToolbar:W,plugins:Y,nodes:V,dynamicHeight:G,artifactContext:K,commentsPanelState:Q,mode:X,doNotShowBorderInViewMode:z,onEditBlocked:J}){var Z,ee,te;const ie=t.useRef(null),ne={namespace:"MyEditor",theme:C.default,onError:_,nodes:[p.TextNode,o.ListNode,o.ListItemNode,s.LinkNode,d.QuoteNode,d.HeadingNode,g.TableNode,g.TableRowNode,g.TableCellNode,q.MarkNode,j.default,S.InsertNode,y.DeleteNode,L.UpdateNode,E.PreservedNode,I.ManualNode,R.InvisibleNode,b.HighlightSpanNode,b.HighlightButtonNode],editorState:F},[re,le]=t.useState(null),[oe,ae]=t.useState(!1),{customStyles:ue}=x.useRequirementAI(),se=e=>{var t;null===(t=$.current)||void 0===t||t.update(()=>{const t=p.$getSelection();p.$isRangeSelection(t)&&t.getNodes().forEach(t=>{p.$isTextNode(t)&&t.setStyle(`color: ${e}`)})})};return document.getElementById("lexical_editor_wrapper"),e.jsxs(e.Fragment,{children:[(null===(Z=null==ue?void 0:ue.textEditorStyles)||void 0===Z?void 0:Z.themeStyles)&&e.jsx("style",{children:null===(ee=null==ue?void 0:ue.textEditorStyles)||void 0===ee?void 0:ee.themeStyles}),e.jsxs("div",{ref:ie,className:"w-full lexical_editor_wrapper "+(z&&"readOnly"===X?"":"lexical_editor_wrapper_box"),id:"lexical_editor_wrapper",onContextMenu:e=>{var t;e.preventDefault(),null===(t=$.current)||void 0===t||t.update(()=>{const t=p.$getSelection();p.$isRangeSelection(t)&&!t.isCollapsed()?(ae(!0),le({x:e.clientX,y:e.clientY})):(ae(!1),le(null))})},style:{minHeight:P,height:M,...null===(te=null==ue?void 0:ue.textEditorStyles)||void 0===te?void 0:te.textArea},children:[e.jsxs(i.LexicalComposer,{initialConfig:ne,children:[" ","edit"===X&&e.jsx(B,{onEditBlocked:J}),"edit"===X&&e.jsx(m.default,{onToolbarButtonClick:A,editorWrapperRef:ie,toolbarConfig:w,customToolbar:W,editorRef:$}),e.jsx(f.default,{placeholder:k}),e.jsx(l.TabIndentationPlugin,{}),e.jsx(n.HistoryPlugin,{}),e.jsx(a.ListPlugin,{}),e.jsx(u.LinkPlugin,{}),e.jsx(c.TablePlugin,{}),e.jsx(h.LayoutPlugin,{onFocus:H,onBlur:D,editorRef:$}),e.jsx(r.OnChangePlugin,{ignoreSelectionChange:!0,ignoreHistoryMergeTagChange:!0,onChange:(e,t,i)=>{O&&O(e,t,i)}}),U&&e.jsx(T.InitialHtml,{initialValue:U.value,initialFormat:U.type,mode:X}),Y&&Y]}),re&&oe&&"edit"===X&&e.jsx(N.default,{position:re,options:[{label:"Change Color to Red",action:()=>se("red")},{label:"Change Color to Blue",action:()=>se("blue")}],onClose:()=>{le(null)}})]})]})};
2
2
  //# sourceMappingURL=Editor.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("@lexical/react/LexicalComposerContext"),t=require("@lexical/html"),a=require("lexical"),o=require("showdown"),i=require("../../../../../../utils/tagHelper.js");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=l(o);exports.InitialHtml=({initialValue:o,initialFormat:l,mode:n})=>{const[u]=r.useLexicalComposerContext();return e.useEffect(()=>{if(o){if(o=(()=>{let e=i.escapeTagIds(o,["manual","upt"]);return["del","ins","preserved","manual","upt"].forEach(r=>{e=i.splitTagAcrossParagraphs(e,r)}),e})(),l&&"html"!==l){var e=new s.default.Converter;o=e.makeHtml(o)}u.update(()=>{const e=a.$getRoot();e.clear();const r=(new DOMParser).parseFromString(o||"","text/html");t.$generateNodesFromDOM(u,r).forEach(r=>{try{a.$isParagraphNode(r)&&r.setFormat("justify"),e.append(r)}catch(e){console.error("Error appending node to root: ",e)}})})}},[o,u]),e.useEffect(()=>{u.setEditable("edit"===n)},[u,n]),null};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("@lexical/react/LexicalComposerContext"),r=require("@lexical/html"),o=require("lexical");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=a(require("showdown"));exports.InitialHtml=({initialValue:a,initialFormat:l,mode:n})=>{const[s]=t.useLexicalComposerContext();return e.useEffect(()=>{if(a){if(l&&"html"!==l){var e=new i.default.Converter;a=e.makeHtml(a)}s.update(()=>{const e=o.$getRoot();e.clear();const t=(new DOMParser).parseFromString(a||"","text/html");r.$generateNodesFromDOM(s,t).forEach(t=>{try{o.$isParagraphNode(t)&&t.setFormat("justify"),e.append(t)}catch(e){console.error("Error appending node to root: ",e)}})})}},[a,s]),e.useEffect(()=>{s.setEditable("edit"===n)},[s,n]),null};
2
2
  //# sourceMappingURL=InitialHtml.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("lexical");class e extends t.ElementNode{static getType(){return"manual"}static clone(t){return new e(t.__id,t.__status,t.__key)}constructor(t=crypto.randomUUID(),e="",s){super(s),this.__id=t,this.__status=e}getId(){return this.getLatest().__id}getStatus(){return this.getLatest().__status}setStatus(t){this.getWritable().__status=t}createDOM(){const t=document.createElement("manual");return t.dataset.id=this.__id,t.className=`PlaygroundEditorTheme__manual-node-${this.__status}`,this.__status&&(t.dataset.status=this.__status),t.contentEditable="pending"===this.__status?"false":"true",t}exportDOM(){const t=document.createElement("manual");return t.id=this.__id,{element:t}}updateDOM(t,e){return t.__id!==this.__id&&(e.dataset.id=this.__id),t.__status!==this.__status&&(this.__status?e.dataset.status=this.__status:delete e.dataset.status,e.contentEditable="pending"===this.__status?"false":"true"),!1}static importDOM(){return{manual:()=>({conversion:s,priority:1})}}static importJSON(t){var s;return new e(t.id,null!==(s=t.status)&&void 0!==s?s:"")}exportJSON(){return{...super.exportJSON(),type:"manual",version:1,id:this.__id,status:this.__status}}isInline(){return!0}}function s(t){var s;return{node:new e(t.id||crypto.randomUUID(),null!==(s=t.dataset.status)&&void 0!==s?s:"")}}exports.ManualNode=e;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("lexical");class e extends t.ElementNode{static getType(){return"manual"}static clone(t){return new e(t.__id,t.__status,t.__key)}constructor(t=crypto.randomUUID(),e="",s){super(s),this.__id=t,this.__status=e}getId(){return this.getLatest().__id}getStatus(){return this.getLatest().__status}setStatus(t){this.getWritable().__status=t}createDOM(){const t=document.createElement("manual");return t.id=this.__id,t.className=`PlaygroundEditorTheme__manual-node-${this.__status}`,this.__status&&(t.dataset.status=this.__status),t.contentEditable="pending"===this.__status?"false":"true",t}exportDOM(){const t=document.createElement("manual");return t.id=this.__id,{element:t}}updateDOM(t,e){return t.__id!==this.__id&&(e.id=this.__id),t.__status!==this.__status&&(this.__status?e.dataset.status=this.__status:delete e.dataset.status,e.contentEditable="pending"===this.__status?"false":"true"),!1}static importDOM(){return{manual:()=>({conversion:s,priority:1})}}static importJSON(t){var s;return new e(t.id,null!==(s=t.status)&&void 0!==s?s:"")}exportJSON(){return{...super.exportJSON(),type:"manual",version:1,id:this.__id,status:this.__status}}isInline(){return!0}}function s(t){var s;return{node:new e(t.id||crypto.randomUUID(),null!==(s=t.dataset.status)&&void 0!==s?s:"")}}exports.ManualNode=e;
2
2
  //# sourceMappingURL=ManualNode.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("lexical");class e extends t.ElementNode{static getType(){return"update"}static clone(t){return new e(t.__id,t.__status,t.__key)}constructor(t=crypto.randomUUID(),e="",s){super(s),this.__id=t,this.__status=e}getId(){return this.getLatest().__id}getStatus(){return this.getLatest().__status}setStatus(t){this.getWritable().__status=t}createDOM(){const t=document.createElement("upt");return t.dataset.id=this.__id,t.className=`PlaygroundEditorTheme__update-node-${this.__status}`,this.__status&&(t.dataset.status=this.__status),t.contentEditable="pending"===this.__status?"false":"true",t}exportDOM(){const t=document.createElement("upt");return t.id=this.__id,{element:t}}updateDOM(t,e){return t.__id!==this.__id&&(e.dataset.id=this.__id),t.__status!==this.__status&&(this.__status?e.dataset.status=this.__status:delete e.dataset.status,e.contentEditable="pending"===this.__status?"false":"true"),!1}static importDOM(){return{upt:()=>({conversion:s,priority:1})}}static importJSON(t){var s;return new e(t.id,null!==(s=t.status)&&void 0!==s?s:"")}exportJSON(){return{...super.exportJSON(),type:"update",version:1,id:this.__id,status:this.__status}}isInline(){return!0}}function s(t){var s;return{node:new e(t.id||crypto.randomUUID(),null!==(s=t.dataset.status)&&void 0!==s?s:"")}}exports.UpdateNode=e;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("lexical");class e extends t.ElementNode{static getType(){return"update"}static clone(t){return new e(t.__id,t.__status,t.__key)}constructor(t=crypto.randomUUID(),e="",s){super(s),this.__id=t,this.__status=e}getId(){return this.getLatest().__id}getStatus(){return this.getLatest().__status}setStatus(t){this.getWritable().__status=t}createDOM(){const t=document.createElement("upt");return t.id=this.__id,t.className=`PlaygroundEditorTheme__update-node-${this.__status}`,this.__status&&(t.dataset.status=this.__status),t.contentEditable="pending"===this.__status?"false":"true",t}exportDOM(){const t=document.createElement("upt");return t.id=this.__id,{element:t}}updateDOM(t,e){return t.__id!==this.__id&&(e.id=this.__id),t.__status!==this.__status&&(this.__status?e.dataset.status=this.__status:delete e.dataset.status,e.contentEditable="pending"===this.__status?"false":"true"),!1}static importDOM(){return{upt:()=>({conversion:s,priority:1})}}static importJSON(t){var s;return new e(t.id,null!==(s=t.status)&&void 0!==s?s:"")}exportJSON(){return{...super.exportJSON(),type:"update",version:1,id:this.__id,status:this.__status}}isInline(){return!0}}function s(t){var s;return{node:new e(t.id||crypto.randomUUID(),null!==(s=t.dataset.status)&&void 0!==s?s:"")}}exports.UpdateNode=e;
2
2
  //# sourceMappingURL=UpdateNode.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("./Editor/constants/editorConfig.js"),n=require("./Editor/Editor.js"),o=require("../../store/ref.context.js"),a=require("@lexical/html"),l=require("turndown"),i=require("turndown-plugin-gfm"),u=require("../UnsavedChangesPopup/UnsavedChangesPopup.js"),s=require("../../../../utils/tagHelper.js");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const d=new(c(l).default)({headingStyle:"atx",codeBlockStyle:"fenced"});d.keep(["ins","del","mark"]),d.keep(e=>{var t,r;return"A"===e.nodeName&&null!==(r=null===(t=e.getAttribute("href"))||void 0===t?void 0:t.includes("ai_reasoning$"))&&void 0!==r&&r}),d.keep(e=>"SPAN"===e.nodeName&&e.hasAttribute("highlight-id")),d.addRule("md-table-passthrough",{filter:e=>"PRE"===e.nodeName&&"true"===e.getAttribute("data-md-table"),replacement:(e,t)=>t.textContent||""}),d.use(i.tables);const h=e=>(e||"").replace(/\r\n/g,"\n").trim(),p=t.forwardRef(({type:l,value:i,handleUpdateState:c,onBlur:p,placeholder:f,minHeight:g,height:E,mode:m,doNotShowBorderInViewMode:v,onEditBlocked:S,onSaveUnsavedChanges:A,onDiscardUnsavedChanges:y,isSavingUnsavedChanges:$=!1},b)=>{const w=t.useRef(null),[x,q]=t.useState({type:l,value:i}),[C,N]=t.useState(0),[R,T]=t.useState(!1),B=t.useRef(i),j=t.useRef(i),I=t.useRef(Boolean(i)),{contentRef:L,setContentRef:_}=o.useRefStore();t.useEffect(()=>{q(e=>({...e,value:i})),B.current=i,j.current=i,I.current=Boolean(i),T(!1)},[i]),t.useImperativeHandle(b,()=>({requestClose:()=>!("edit"===m&&h(B.current)!==h(j.current))||(T(!0),!1)}),[m]);return t.useEffect(()=>{const e=()=>{L&&L.current&&N(L.current.clientHeight-60)};return e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}},[L]),e.jsxs("div",{style:{position:"relative",width:"100%",height:E,minHeight:g},children:[R&&e.jsx(u.UnsavedChangesPopup,{isSaving:$,onSave:async()=>{await(null==A?void 0:A()),B.current=j.current,T(!1)},onDiscard:()=>{j.current=B.current,null==y||y(),T(!1)}}),e.jsx(n.default,{minHeight:g,height:E,placeholder:f||"Enter some text...",onChange:(e,t)=>{e.read(()=>{const e=a.$generateHtmlFromNodes(t,null),r=(new DOMParser).parseFromString(e,"text/html");r.querySelectorAll("span").forEach(e=>{const t=e.getAttribute("style")||"";t.includes("background-color")&&t.includes("rgb(219, 234, 254)")&&e.setAttribute("data-review","insert"),t.includes("text-decoration")&&t.includes("line-through")&&e.setAttribute("data-review","delete")}),r.querySelectorAll("strong code").forEach(e=>{const t=e.parentElement;t&&t.replaceChild(document.createTextNode(e.textContent||""),e)}),r.querySelectorAll("code strong").forEach(e=>{const t=e.parentElement;t&&t.replaceChild(document.createTextNode(e.textContent||""),e)}),r.querySelectorAll('a[href*="ai_reasoning$"]').forEach(e=>{const t=e.getAttribute("href")||"";e.setAttribute("href",t.replace(/^https?:\/\//,""))});const n=["upt","manual","ins","del","preserved"];function o(e,t){const r=e.cloneNode(!0),a=new Map;r.querySelectorAll(n.join(",")).forEach(e=>{if(e===r)return;const n=`%%NESTED${a.size}%%`;a.set(n,o(e,t)),e.replaceWith(n)});let l=t.turndown(r.innerHTML);a.forEach((e,t)=>{l=l.replace(t,e)});const i=Array.from(e.attributes).map(e=>`${e.name}="${e.value}"`).join(" "),u=e.tagName.toLowerCase();return i?`<${u} ${i}>${l}</${u}>`:`<${u}>${l}</${u}>`}r.querySelectorAll('a[href*="ai_reasoning$"]').forEach(e=>{const t=e.getAttribute("href")||"";e.setAttribute("href",t.replace(/^https?:\/\//,""))});const l=[];r.querySelectorAll("invisible").forEach((e,t)=>{l.push(e.outerHTML),e.replaceWith(r.createTextNode(`%%INVISIBLE_${t}%%`))});const i=[];r.querySelectorAll("upt, manual").forEach((e,t)=>{i.push(o(e,d)),e.replaceWith(r.createTextNode(`%%REVIEW_${t}%%`))});const u=[];r.querySelectorAll("table").forEach((e,t)=>{u.push(e.outerHTML);const n=r.createElement("p");n.textContent=`%%TABLE_${t}%%`,e.replaceWith(n)});let h=d.turndown(r.body.innerHTML);i.forEach((e,t)=>{h=h.replace(`%%REVIEW\\_${t}%%`,` ${e} `)}),l.forEach((e,t)=>{h=h.replace(new RegExp(`%%INVISIBLE\\\\*_${t}%%`,"g"),` ${e} `)}),u.forEach((e,t)=>{h=h.replace(`%%TABLE\\_${t}%%`,`\n\n${e}\n\n`)}),h=h.replace(/\*{4}([^*]+)\*{4}/g,"**$1**");["upt","manual","del","ins","preserved"].forEach(e=>{h=s.mergeTagAcrossParagraphs(h,e)}),h=s.unescapeTagIds(h,["manual","upt"]),I.current&&(B.current=h,I.current=!1),j.current=h,((e,t)=>{c(e,t)})("prompt",h)})},toolbarConfig:r.DEFAULT_TOOLBAR_CONFIG,editorRef:w,mode:m,initialString:{type:x.type,value:x.value},dynamicHeight:C,onBlur:p,doNotShowBorderInViewMode:v||!1,onEditBlocked:S})]})});p.displayName="RichTextEditor",exports.default=p;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("./Editor/constants/editorConfig.js"),n=require("./Editor/Editor.js"),o=require("../../store/ref.context.js"),a=require("@lexical/html"),l=require("turndown"),i=require("turndown-plugin-gfm"),u=require("../UnsavedChangesPopup/UnsavedChangesPopup.js");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const s=new(c(l).default)({headingStyle:"atx",codeBlockStyle:"fenced"});s.keep(["ins","del","mark"]),s.keep(e=>{var t,r;return"A"===e.nodeName&&null!==(r=null===(t=e.getAttribute("href"))||void 0===t?void 0:t.includes("ai_reasoning$"))&&void 0!==r&&r}),s.keep(e=>"SPAN"===e.nodeName&&e.hasAttribute("highlight-id")),s.addRule("md-table-passthrough",{filter:e=>"PRE"===e.nodeName&&"true"===e.getAttribute("data-md-table"),replacement:(e,t)=>t.textContent||""}),s.use(i.tables);const d=e=>(e||"").replace(/\r\n/g,"\n").trim(),h=t.forwardRef(({type:l,value:i,handleUpdateState:c,onBlur:h,placeholder:p,minHeight:f,height:g,mode:E,doNotShowBorderInViewMode:m,onEditBlocked:v,onSaveUnsavedChanges:S,onDiscardUnsavedChanges:A,isSavingUnsavedChanges:y=!1},$)=>{const b=t.useRef(null),[w,x]=t.useState({type:l,value:i}),[q,C]=t.useState(0),[N,R]=t.useState(!1),B=t.useRef(i),T=t.useRef(i),L=t.useRef(Boolean(i)),{contentRef:_,setContentRef:j}=o.useRefStore();t.useEffect(()=>{x(e=>({...e,value:i})),B.current=i,T.current=i,L.current=Boolean(i),R(!1)},[i]),t.useImperativeHandle($,()=>({requestClose:()=>!("edit"===E&&d(B.current)!==d(T.current))||(R(!0),!1)}),[E]);return t.useEffect(()=>{const e=()=>{_&&_.current&&C(_.current.clientHeight-60)};return e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}},[_]),e.jsxs("div",{style:{position:"relative",width:"100%",height:g,minHeight:f},children:[N&&e.jsx(u.UnsavedChangesPopup,{isSaving:y,onSave:async()=>{await(null==S?void 0:S()),B.current=T.current,R(!1)},onDiscard:()=>{T.current=B.current,null==A||A(),R(!1)}}),e.jsx(n.default,{minHeight:f,height:g,placeholder:p||"Enter some text...",onChange:(e,t)=>{e.read(()=>{const e=a.$generateHtmlFromNodes(t,null),r=(new DOMParser).parseFromString(e,"text/html");r.querySelectorAll("span").forEach(e=>{const t=e.getAttribute("style")||"";t.includes("background-color")&&t.includes("rgb(219, 234, 254)")&&e.setAttribute("data-review","insert"),t.includes("text-decoration")&&t.includes("line-through")&&e.setAttribute("data-review","delete")}),r.querySelectorAll("strong code").forEach(e=>{const t=e.parentElement;t&&t.replaceChild(document.createTextNode(e.textContent||""),e)}),r.querySelectorAll("code strong").forEach(e=>{const t=e.parentElement;t&&t.replaceChild(document.createTextNode(e.textContent||""),e)}),r.querySelectorAll('a[href*="ai_reasoning$"]').forEach(e=>{const t=e.getAttribute("href")||"";e.setAttribute("href",t.replace(/^https?:\/\//,""))});const n=["upt","manual","ins","del","preserved"];function o(e,t){const r=e.cloneNode(!0),a=new Map;r.querySelectorAll(n.join(",")).forEach(e=>{if(e===r)return;const n=`%%NESTED${a.size}%%`;a.set(n,o(e,t)),e.replaceWith(n)});let l=t.turndown(r.innerHTML);a.forEach((e,t)=>{l=l.replace(t,e)});const i=Array.from(e.attributes).map(e=>`${e.name}="${e.value}"`).join(" "),u=e.tagName.toLowerCase();return i?`<${u} ${i}>${l}</${u}>`:`<${u}>${l}</${u}>`}r.querySelectorAll('a[href*="ai_reasoning$"]').forEach(e=>{const t=e.getAttribute("href")||"";e.setAttribute("href",t.replace(/^https?:\/\//,""))});const l=[];r.querySelectorAll("invisible").forEach((e,t)=>{l.push(e.outerHTML),e.replaceWith(r.createTextNode(`%%INVISIBLE_${t}%%`))});const i=[];r.querySelectorAll("upt, manual").forEach((e,t)=>{i.push(o(e,s)),e.replaceWith(r.createTextNode(`%%REVIEW_${t}%%`))});const u=[];r.querySelectorAll("table").forEach((e,t)=>{u.push(e.outerHTML);const n=r.createElement("p");n.textContent=`%%TABLE_${t}%%`,e.replaceWith(n)});let d=s.turndown(r.body.innerHTML);l.forEach((e,t)=>{d=d.replace(`%%INVISIBLE\\_${t}%%`,` ${e} `)}),i.forEach((e,t)=>{d=d.replace(`%%REVIEW\\_${t}%%`,` ${e} `)}),u.forEach((e,t)=>{d=d.replace(`%%TABLE\\_${t}%%`,`\n\n${e}\n\n`)}),d=d.replace(/\*{4}([^*]+)\*{4}/g,"**$1**"),L.current&&(B.current=d,L.current=!1),T.current=d,((e,t)=>{c(e,t)})("prompt",d)})},toolbarConfig:r.DEFAULT_TOOLBAR_CONFIG,editorRef:b,mode:E,initialString:{type:w.type,value:w.value},dynamicHeight:q,onBlur:h,doNotShowBorderInViewMode:m||!1,onEditBlocked:v})]})});h.displayName="RichTextEditor",exports.default=h;
2
2
  //# sourceMappingURL=RichTextEditor.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),a=require("react"),i=require("../Popups/PopupDefaults.js"),t=require("react-markdown"),c=require("rehype-raw"),n=require("./CitationComponent.module.css.js"),l=require("lucide-react"),s=require("../icons/cognitiveBrain.svg.js"),d=require("../icons/aiMagic.svg.js"),r=require("./CitationAnchor.js"),o=require("../../../../../service/redlineService.js"),u=require("../../RequirementAIWrapper/RequirementAIWrapper.js");function m(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var x=m(a),f=m(t),_=m(c);const j=({text:a,item:i})=>e.jsx(f.default,{rehypePlugins:[_.default],components:{ol:({children:a})=>e.jsx("ol",{className:n.default["md-ol"],children:a}),ul:({children:a})=>e.jsx("ul",{className:n.default["md-ul"],children:a}),li:({children:a})=>e.jsx("li",{className:n.default["md-li"],children:a}),a:({node:a,href:t,children:c})=>e.jsx(r.default,{href:t,children:c,metaData:{citations:i.citations,docData:i.docData}})},children:a.replace(/<br\s*\/?>/gi,"\n")});exports.default=function({item:t,title:c="Cognitive Decisioning AI",relevanceScore:r=0,showRelevanceScore:m=!0,reason:f="No reasoning provided.",impact:_="No Impact provided.",explaination:h="No explaination provided.",gap:p="None",onClose:v=()=>{},onActionTrigger:N,showResolveBtns:b=!1,sections:y,leftIcon:g,scoreIcon:C,className:I,customStyles:k={},actions:q,disableAllActions:A=!1,actionBtnDisabledStyle:R={},onBackClick:B,isImpactNeeded:D=!0,cognitiveTitle:H="Cognitive Integrity",labels:$={},redlineId:T,aiReasonId:w}){const L=a.useMemo(()=>{const e=Number(r);return Number.isNaN(e)?0:Math.max(0,Math.min(100,Math.round(e)))},[r]),M=a.useMemo(()=>{const e=$&&$.noGapsText||"1. No gaps identified.";return(e=>{if(!e)return!0;const a=e.trim().toLowerCase();return"none"===a||"no gap"===a||"no gaps"===a||"n/a"===a})(p)?e:p},[p]),P=$&&$.impact||"Impact",S=$&&$.explanation||"Explaination",E=$&&$.decisionFactors||"Decision Making Factors",U=$&&$.gaps||"Gaps in Decision",F=$&&$.accept||"Accept",G=$&&$.reject||"Reject",W=$&&$.backAriaLabel||"Go back",{redlineDcoumentId:O,redlineConfig:z,updateRedlineDataParent:J}=u.useRequirementAI(),K=async e=>{var a,i;null==N||N({status:"loading",action:e,metadata:{redlineId:T,aiReasonId:w}});try{const{updated_reqai:t}=await o.resolveRedline({documentId:O,userEmail:null==z?void 0:z.userEmail,userName:null==z?void 0:z.userName,redlineId:null!=T?T:"",action:e,baseApiUrl:null==z?void 0:z.baseApiUrl,redlineConfigId:null!==(a=null==z?void 0:z.redlineConfigId)&&void 0!==a?a:""},null!==(i=null==z?void 0:z.token)&&void 0!==i?i:"");await(null==J?void 0:J(t)),null==N||N({status:"success",action:e,metadata:{redlineId:T,aiReasonId:w}})}catch(e){null==N||N({status:"failed",action:null,metadata:{redlineId:T,aiReasonId:w}})}},Q=q||[{id:"reject",label:G,onClick:()=>K("reject"),className:n.default["btn-reject"]},{id:"accept",label:F,onClick:()=>K("accept"),className:n.default["btn-accept"]}];return e.jsxs("div",{className:`${n.default["cite-acc"]} ${I||""}`,style:{...i.default.CitationAccordionDefaults.container,...null==k?void 0:k.container},children:[B&&e.jsxs("div",{className:n.default["cite-acc__backHeader"],children:[e.jsx("button",{type:"button",className:n.default["cite-acc__backBtn"],onClick:e=>{e.stopPropagation(),B&&B()},"aria-label":W,children:"‹"}),e.jsx("span",{className:n.default["cite-acc__backTitle"],children:H})]}),e.jsx("div",{className:n.default["cite-body"],children:y&&y.length>0?y.map(a=>!1===a.show?null:e.jsxs("div",{className:`${n.default["cite-acc__explain-body"]} ${a.bodyClassName||""}`,children:[e.jsxs("div",{className:n.default["cite-acc__innerHeader"],style:{...i.default.CitationAccordionDefaults.innerHeader,...null==k?void 0:k.innerHeader},children:[e.jsx("div",{className:n.default["cite-acc__innerHeaderLeft"],children:e.jsx("div",{children:e.jsx("div",{className:n.default["cite-acc__innerTitle"],children:a.title})})}),e.jsx("button",{type:"button",onClick:e=>{e.stopPropagation(),v&&v()},children:e.jsx(l.ChevronUp,{})})]}),e.jsx("div",{className:`${n.default["cite-acc__innerBody"]} text-sm text-gray-600`,style:{...i.default.CitationAccordionDefaults.innerBody,...null==k?void 0:k.innerBody},children:"string"==typeof a.content?e.jsx(j,{text:a.content,item:a.item||t||{}}):a.content})]},a.id||a.title)):e.jsxs(e.Fragment,{children:[D&&e.jsxs("div",{className:n.default["cite-acc__explain-body"],children:[e.jsxs("div",{className:n.default["cite-acc__innerHeader"],children:[e.jsx("div",{className:n.default["cite-acc__innerHeaderLeft"],children:e.jsx("div",{children:e.jsx("div",{className:n.default["cite-acc__innerTitle"],children:P})})}),e.jsx("button",{type:"button",onClick:e=>{e.stopPropagation(),v&&v()},children:e.jsx(l.ChevronUp,{})})]}),e.jsx("div",{className:`${n.default["cite-acc__innerBody"]} text-sm text-gray-600`,children:e.jsx(j,{text:_||"",item:t||{}})})]}),e.jsxs("div",{className:n.default["cite-acc__explain-body"],children:[e.jsx("div",{className:n.default["cite-acc__innerHeader"],children:e.jsx("div",{className:n.default["cite-acc__innerHeaderLeft"],children:e.jsx("div",{children:e.jsx("div",{className:n.default["cite-acc__innerTitle"],children:S})})})}),e.jsx("div",{className:`${n.default["cite-acc__innerBody"]} text-sm text-gray-600`,children:e.jsx(j,{text:h||"",item:{}})})]}),b&&e.jsx("div",{className:n.default["cite-acc__btn-container"],children:Q.map(a=>{const i=A||a.disabled;return e.jsx("button",{className:a.className,onClick:i?void 0:a.onClick,disabled:i,style:{...a.style,...i?{opacity:.5,cursor:"not-allowed",...R,...a.disabledStyle}:{}},children:a.label},a.id)})}),e.jsxs("div",{className:n.default["cite-acc__header"],children:[e.jsxs("div",{className:n.default["cite-acc__headerLeft"],children:[e.jsx("span",{className:n.default["cite-acc__titleIcon"],children:g?"function"==typeof g?x.default.createElement(g):g:e.jsx(s.ReactComponent,{})}),e.jsx("div",{className:n.default["cite-acc__title"],children:c})]}),e.jsx("div",{className:n.default["cite-acc__headerRight"],children:m&&e.jsxs("span",{className:n.default["cite-acc__scoreBadge"],children:[C?"function"==typeof C?x.default.createElement(C):C:e.jsx(d.ReactComponent,{}),e.jsxs("span",{className:n.default["cite-acc__scoreText"],children:[L,"%"]})]})})]}),e.jsxs("div",{className:n.default["cite-acc__explain-body"],children:[e.jsx("div",{className:n.default["cite-acc__innerHeader"],children:e.jsx("div",{className:n.default["cite-acc__innerHeaderLeft"],children:e.jsx("div",{children:e.jsx("div",{className:n.default["cite-acc__innerTitle"],children:E})})})}),e.jsx("div",{className:`${n.default["cite-acc__innerBody"]} text-sm text-gray-600`,children:e.jsx(j,{text:f||"",item:t||{}})})]}),e.jsxs("div",{className:`${n.default["cite-acc__explain-body"]} ${n.default["cite-acc__explain-body_border"]}`,children:[e.jsx("div",{className:n.default["cite-acc__innerHeader"],children:e.jsx("div",{className:n.default["cite-acc__innerHeaderLeft"],children:e.jsx("div",{children:e.jsx("div",{className:n.default["cite-acc__innerTitle"],children:U})})})}),e.jsx("div",{className:`${n.default["cite-acc__innerBody"]} text-sm text-gray-600`,children:e.jsx(j,{text:M||"",item:t||{}})})]})]})})]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),a=require("react"),i=require("../Popups/PopupDefaults.js"),t=require("react-markdown"),c=require("rehype-raw"),n=require("./CitationComponent.module.css.js"),l=require("lucide-react"),s=require("../icons/cognitiveBrain.svg.js"),d=require("../icons/aiMagic.svg.js"),r=require("./CitationAnchor.js"),o=require("../../../../../service/redlineService.js"),u=require("../../RequirementAIWrapper/RequirementAIWrapper.js");function m(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var x=m(a),f=m(t),p=m(c);const _=({text:a,item:i})=>e.jsx(f.default,{rehypePlugins:[p.default],components:{ol:({children:a})=>e.jsx("ol",{className:n.default["md-ol"],children:a}),ul:({children:a})=>e.jsx("ul",{className:n.default["md-ul"],children:a}),li:({children:a})=>e.jsx("li",{className:n.default["md-li"],children:a}),a:({node:a,href:t,children:c})=>e.jsx(r.default,{href:t,children:c,metaData:{citations:i.citations,docData:i.docData}})},children:a.replace(/<br\s*\/?>/gi,"\n")});var j=a.memo(function({item:t,title:c="Cognitive Decisioning AI",relevanceScore:r=0,showRelevanceScore:m=!0,reason:f="No reasoning provided.",impact:p="No Impact provided.",explaination:j="No explaination provided.",gap:h="None",onClose:v=()=>{},onActionTrigger:N,showResolveBtns:b=!1,sections:y,leftIcon:g,scoreIcon:I,className:C,customStyles:A={},actions:k,disableAllActions:R=!1,actionBtnDisabledStyle:q={},onBackClick:B,isImpactNeeded:D=!0,cognitiveTitle:H="Cognitive Integrity",labels:$={},redlineId:T,aiReasonId:w}){const L=a.useMemo(()=>{const e=Number(r);return Number.isNaN(e)?0:Math.max(0,Math.min(100,Math.round(e)))},[r]),M=a.useMemo(()=>{const e=$&&$.noGapsText||"1. No gaps identified.";return(e=>{if(!e)return!0;const a=e.trim().toLowerCase();return"none"===a||"no gap"===a||"no gaps"===a||"n/a"===a})(h)?e:h},[h]),P=$&&$.impact||"Impact",S=$&&$.explanation||"Explaination",E=$&&$.decisionFactors||"Decision Making Factors",U=$&&$.gaps||"Gaps in Decision",F=$&&$.accept||"Accept",G=$&&$.reject||"Reject",W=$&&$.backAriaLabel||"Go back",{redlineDcoumentId:O,redlineConfig:z,updateRedlineDataParent:J}=u.useRequirementAI(),K=async e=>{var a,i;null==N||N({status:"loading",action:e,metadata:{redlineId:T,aiReasonId:w}});try{const{updated_reqai:t}=await o.resolveRedline({documentId:O,userEmail:null==z?void 0:z.userEmail,userName:null==z?void 0:z.userName,redlineId:null!=T?T:"",action:e,baseApiUrl:null==z?void 0:z.baseApiUrl,redlineConfigId:null!==(a=null==z?void 0:z.redlineConfigId)&&void 0!==a?a:""},null!==(i=null==z?void 0:z.token)&&void 0!==i?i:"");await(null==J?void 0:J(t)),null==N||N({status:"success",action:e,metadata:{redlineId:T,aiReasonId:w}})}catch(e){null==N||N({status:"failed",action:null,metadata:{redlineId:T,aiReasonId:w}})}},Q=k||[{id:"reject",label:G,onClick:()=>K("reject"),className:n.default["btn-reject"]},{id:"accept",label:F,onClick:()=>K("accept"),className:n.default["btn-accept"]}];return e.jsxs("div",{className:`${n.default["cite-acc"]} ${C||""}`,style:{...i.default.CitationAccordionDefaults.container,...null==A?void 0:A.container},children:[B&&e.jsxs("div",{className:n.default["cite-acc__backHeader"],children:[e.jsx("button",{type:"button",className:n.default["cite-acc__backBtn"],onClick:e=>{e.stopPropagation(),B&&B()},"aria-label":W,children:"‹"}),e.jsx("span",{className:n.default["cite-acc__backTitle"],children:H})]}),e.jsx("div",{className:n.default["cite-body"],children:y&&y.length>0?y.map(a=>!1===a.show?null:e.jsxs("div",{className:`${n.default["cite-acc__explain-body"]} ${a.bodyClassName||""}`,children:[e.jsxs("div",{className:n.default["cite-acc__innerHeader"],style:{...i.default.CitationAccordionDefaults.innerHeader,...null==A?void 0:A.innerHeader},children:[e.jsx("div",{className:n.default["cite-acc__innerHeaderLeft"],children:e.jsx("div",{children:e.jsx("div",{className:n.default["cite-acc__innerTitle"],children:a.title})})}),e.jsx("button",{type:"button",onClick:e=>{e.stopPropagation(),v&&v()},children:e.jsx(l.ChevronUp,{})})]}),e.jsx("div",{className:`${n.default["cite-acc__innerBody"]} text-sm text-gray-600`,style:{...i.default.CitationAccordionDefaults.innerBody,...null==A?void 0:A.innerBody},children:"string"==typeof a.content?e.jsx(_,{text:a.content,item:a.item||t||{}}):a.content})]},a.id||a.title)):e.jsxs(e.Fragment,{children:[D&&e.jsxs("div",{className:n.default["cite-acc__explain-body"],children:[e.jsxs("div",{className:n.default["cite-acc__innerHeader"],children:[e.jsx("div",{className:n.default["cite-acc__innerHeaderLeft"],children:e.jsx("div",{children:e.jsx("div",{className:n.default["cite-acc__innerTitle"],children:P})})}),e.jsx("button",{type:"button",onClick:e=>{e.stopPropagation(),v&&v()},children:e.jsx(l.ChevronUp,{})})]}),e.jsx("div",{className:`${n.default["cite-acc__innerBody"]} text-sm text-gray-600`,children:e.jsx(_,{text:p||"",item:t||{}})})]}),e.jsxs("div",{className:n.default["cite-acc__explain-body"],children:[e.jsx("div",{className:n.default["cite-acc__innerHeader"],children:e.jsx("div",{className:n.default["cite-acc__innerHeaderLeft"],children:e.jsx("div",{children:e.jsx("div",{className:n.default["cite-acc__innerTitle"],children:S})})})}),e.jsx("div",{className:`${n.default["cite-acc__innerBody"]} text-sm text-gray-600`,children:e.jsx(_,{text:j||"",item:{}})})]}),b&&e.jsx("div",{className:n.default["cite-acc__btn-container"],children:Q.map(a=>{const i=R||a.disabled;return e.jsx("button",{className:a.className,onClick:i?void 0:a.onClick,disabled:i,style:{...a.style,...i?{opacity:.5,cursor:"not-allowed",...q,...a.disabledStyle}:{}},children:a.label},a.id)})}),e.jsxs("div",{className:n.default["cite-acc__header"],children:[e.jsxs("div",{className:n.default["cite-acc__headerLeft"],children:[e.jsx("span",{className:n.default["cite-acc__titleIcon"],children:g?"function"==typeof g?x.default.createElement(g):g:e.jsx(s.ReactComponent,{})}),e.jsx("div",{className:n.default["cite-acc__title"],children:c})]}),e.jsx("div",{className:n.default["cite-acc__headerRight"],children:m&&e.jsxs("span",{className:n.default["cite-acc__scoreBadge"],children:[I?"function"==typeof I?x.default.createElement(I):I:e.jsx(d.ReactComponent,{}),e.jsxs("span",{className:n.default["cite-acc__scoreText"],children:[L,"%"]})]})})]}),e.jsxs("div",{className:n.default["cite-acc__explain-body"],children:[e.jsx("div",{className:n.default["cite-acc__innerHeader"],children:e.jsx("div",{className:n.default["cite-acc__innerHeaderLeft"],children:e.jsx("div",{children:e.jsx("div",{className:n.default["cite-acc__innerTitle"],children:E})})})}),e.jsx("div",{className:`${n.default["cite-acc__innerBody"]} text-sm text-gray-600`,children:e.jsx(_,{text:f||"",item:t||{}})})]}),e.jsxs("div",{className:`${n.default["cite-acc__explain-body"]} ${n.default["cite-acc__explain-body_border"]}`,children:[e.jsx("div",{className:n.default["cite-acc__innerHeader"],children:e.jsx("div",{className:n.default["cite-acc__innerHeaderLeft"],children:e.jsx("div",{children:e.jsx("div",{className:n.default["cite-acc__innerTitle"],children:U})})})}),e.jsx("div",{className:`${n.default["cite-acc__innerBody"]} text-sm text-gray-600`,children:e.jsx(_,{text:M||"",item:t||{}})})]})]})})]})},(e,a)=>e.disableAllActions===a.disableAllActions&&(e.redlineId===a.redlineId&&(e.aiReasonId===a.aiReasonId&&(e.relevanceScore===a.relevanceScore&&(e.reason===a.reason&&(e.impact===a.impact&&(e.explaination===a.explaination&&e.gap===a.gap)))))));exports.default=j;
2
2
  //# sourceMappingURL=CognitiveComponent.js.map