@e-llm-studio/requirement-ai 0.0.255 → 0.0.257

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 (80) hide show
  1. package/dist/cjs/features/CognitiveCompare/CitationAnchor.js +1 -1
  2. package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js +1 -1
  3. package/dist/cjs/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
  4. package/dist/cjs/features/CognitiveCompare/CognitivePopup.js +1 -1
  5. package/dist/cjs/features/CognitiveCompare/components/SectionAccordion.js +1 -1
  6. package/dist/cjs/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
  7. package/dist/cjs/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
  8. package/dist/cjs/features/CognitiveCompare/hooks/useCompareData.js +1 -1
  9. package/dist/cjs/features/CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.js +1 -1
  10. package/dist/cjs/features/GptWebCitation/GptWebCitation.js +1 -1
  11. package/dist/cjs/features/GptWebCitation/GptWebCitationImageCitation.js +1 -1
  12. package/dist/cjs/features/ManageRemainders/ManageRemainder.module.css.js +1 -1
  13. package/dist/cjs/features/RequirementAI/components/RequirementAIWrapper/RequirementAIWrapper.js +1 -1
  14. package/dist/cjs/features/RequirementAI/components/ai-reasoning/AiReasonMarkdownWrapper.js +1 -1
  15. package/dist/cjs/features/RequirementAI/components/ai-reasoning/AiReasoningCitationContent.js +1 -1
  16. package/dist/cjs/features/RequirementAI/components/citations/file-citation/FileCitationContent.js +1 -1
  17. package/dist/cjs/features/RequirementAI/components/citations/file-citation/FileCitationContent.module.css.js +1 -1
  18. package/dist/cjs/features/RequirementAI/components/citations/file-citation/FileCitationRender.js +1 -1
  19. package/dist/cjs/features/RequirementAI/components/userstory-with-citation/UserStoryWithCitation.js +1 -1
  20. package/dist/cjs/features/RequirementAI/components/userstory-with-citation/UserStoryWithCitation.module.css.js +1 -1
  21. package/dist/cjs/features/RequirementAI/hooks/useStreamContentHandler.js +1 -1
  22. package/dist/cjs/features/RequirementAI/utils/proccess-stream.utils.js +1 -1
  23. package/dist/features/CognitiveCompare/CitationAnchor.js +1 -1
  24. package/dist/features/CognitiveCompare/CognitiveCompare.js +1 -1
  25. package/dist/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
  26. package/dist/features/CognitiveCompare/CognitivePopup.js +1 -1
  27. package/dist/features/CognitiveCompare/components/SectionAccordion.js +1 -1
  28. package/dist/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
  29. package/dist/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
  30. package/dist/features/CognitiveCompare/hooks/useCompareData.js +1 -1
  31. package/dist/features/CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.js +1 -1
  32. package/dist/features/GptWebCitation/GptWebCitation.js +1 -1
  33. package/dist/features/GptWebCitation/GptWebCitationImageCitation.js +1 -1
  34. package/dist/features/ManageRemainders/ManageRemainder.module.css.js +1 -1
  35. package/dist/features/RequirementAI/components/RequirementAIWrapper/RequirementAIWrapper.js +1 -1
  36. package/dist/features/RequirementAI/components/ai-reasoning/AiReasonMarkdownWrapper.js +1 -1
  37. package/dist/features/RequirementAI/components/ai-reasoning/AiReasoningCitationContent.js +1 -1
  38. package/dist/features/RequirementAI/components/citations/file-citation/FileCitationContent.js +1 -1
  39. package/dist/features/RequirementAI/components/citations/file-citation/FileCitationContent.module.css.js +1 -1
  40. package/dist/features/RequirementAI/components/citations/file-citation/FileCitationRender.js +1 -1
  41. package/dist/features/RequirementAI/components/userstory-with-citation/UserStoryWithCitation.js +1 -1
  42. package/dist/features/RequirementAI/components/userstory-with-citation/UserStoryWithCitation.module.css.js +1 -1
  43. package/dist/features/RequirementAI/hooks/useStreamContentHandler.js +1 -1
  44. package/dist/features/RequirementAI/utils/proccess-stream.utils.js +1 -1
  45. package/dist/types/src/features/CognitiveCompare/CitationAnchor.d.ts.map +1 -1
  46. package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts.map +1 -1
  47. package/dist/types/src/features/CognitiveCompare/CognitiveComparehelpers.d.ts +5 -0
  48. package/dist/types/src/features/CognitiveCompare/CognitiveComparehelpers.d.ts.map +1 -1
  49. package/dist/types/src/features/CognitiveCompare/components/SectionAccordion.d.ts.map +1 -1
  50. package/dist/types/src/features/CognitiveCompare/components/SubSectionAccordion.d.ts.map +1 -1
  51. package/dist/types/src/features/CognitiveCompare/hooks/memoizedMarkdown.d.ts.map +1 -1
  52. package/dist/types/src/features/CognitiveCompare/hooks/useCompareData.d.ts.map +1 -1
  53. package/dist/types/src/features/CognitiveCompare/hooks/useCompareLayout.d.ts +1 -0
  54. package/dist/types/src/features/CognitiveCompare/hooks/useCompareLayout.d.ts.map +1 -1
  55. package/dist/types/src/features/CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.d.ts +1 -0
  56. package/dist/types/src/features/CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.d.ts.map +1 -1
  57. package/dist/types/src/features/GptWebCitation/GptWebCitation.d.ts.map +1 -1
  58. package/dist/types/src/features/GptWebCitation/GptWebCitationImageCitation.d.ts +2 -1
  59. package/dist/types/src/features/GptWebCitation/GptWebCitationImageCitation.d.ts.map +1 -1
  60. package/dist/types/src/features/GptWebCitation/types.d.ts +4 -0
  61. package/dist/types/src/features/GptWebCitation/types.d.ts.map +1 -1
  62. package/dist/types/src/features/RequirementAI/components/RequirementAIWrapper/RequirementAIWrapper.d.ts +5 -1
  63. package/dist/types/src/features/RequirementAI/components/RequirementAIWrapper/RequirementAIWrapper.d.ts.map +1 -1
  64. package/dist/types/src/features/RequirementAI/components/UserStoryCard/CognitiveComponents/userstory.mock.data.d.ts +2509 -0
  65. package/dist/types/src/features/RequirementAI/components/UserStoryCard/CognitiveComponents/userstory.mock.data.d.ts.map +1 -0
  66. package/dist/types/src/features/RequirementAI/components/ai-reasoning/AiReasonMarkdownWrapper.d.ts +3 -2
  67. package/dist/types/src/features/RequirementAI/components/ai-reasoning/AiReasonMarkdownWrapper.d.ts.map +1 -1
  68. package/dist/types/src/features/RequirementAI/components/ai-reasoning/AiReasoningCitationContent.d.ts.map +1 -1
  69. package/dist/types/src/features/RequirementAI/components/citations/file-citation/FileCitationContent.d.ts +1 -0
  70. package/dist/types/src/features/RequirementAI/components/citations/file-citation/FileCitationContent.d.ts.map +1 -1
  71. package/dist/types/src/features/RequirementAI/components/citations/file-citation/FileCitationRender.d.ts +1 -0
  72. package/dist/types/src/features/RequirementAI/components/citations/file-citation/FileCitationRender.d.ts.map +1 -1
  73. package/dist/types/src/features/RequirementAI/components/common/onDemandCitationButton.d.ts +12 -0
  74. package/dist/types/src/features/RequirementAI/components/common/onDemandCitationButton.d.ts.map +1 -0
  75. package/dist/types/src/features/RequirementAI/components/userstory-with-citation/UserStoryWithCitation.d.ts.map +1 -1
  76. package/dist/types/src/features/RequirementAI/hooks/useStreamContentHandler.d.ts.map +1 -1
  77. package/dist/types/src/features/RequirementAI/types/aiReasoning.type.d.ts +1 -0
  78. package/dist/types/src/features/RequirementAI/types/aiReasoning.type.d.ts.map +1 -1
  79. package/dist/types/src/features/RequirementAI/utils/proccess-stream.utils.d.ts.map +1 -1
  80. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),i=require("react/jsx-runtime"),n=require("lucide-react"),t=require("react"),o=require("./ResizableSplitPane.js"),l=require("../PdfViewer/PdfViewer.js"),a=require("../../assests/svg/PdfViewerIcons.js"),r=require("react-markdown"),u=require("rehype-raw"),d=require("@mui/material"),s=require("./CognitiveCompareConfig.js");require("react-dom");var c=require("./CompareContext.js"),v=require("./Guidelines/utils/processGuidelinesMarkdown.js"),p=require("../GptWebCitation/GptWebCitation.js"),g=require("../GptWebCitation/types.js");function h(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("./MoreFunctionsPopup.js"),require("./components/SubSectionAccordion.js"),require("./components/LHSSectionRow.js"),require("./components/RHSSectionRow.js");var m=h(r),x=h(u),f=function(e){var i,n,t;return(null===(t=null===(n=null===(i=(null==e?void 0:e.extraMetaData)||e)||void 0===i?void 0:i.aiReasoningCitation)||void 0===n?void 0:n.gpt_citation)||void 0===t?void 0:t[0])||null},_="https://dev-proposals-ai.techo.camp/utility/ca-workflow-composer-agent/get_citation",b="sai.siddhartha@techolution.com",y="672e32f7a0e8fe2e8e50bcba",w="TNV Sai Siddhartha",C="90vh",j="calc(".concat(C," - 120px)"),D=function(){var e;return"function"==typeof(null===(e=globalThis.crypto)||void 0===e?void 0:e.randomUUID)?globalThis.crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var i=Math.floor(16*Math.random());return("x"===e?i:i%4+8).toString(16)})},F=function(e,i){var n=function(e){var i;return(null==e?void 0:e.payloadCitationId)||(null===(i=null==e?void 0:e.extraMetaData)||void 0===i?void 0:i.payloadCitationId)||""}(e)||i||D();return function(e,i){e&&"object"==typeof e&&(e.payloadCitationId=i,e.extraMetaData&&"object"==typeof e.extraMetaData&&(e.extraMetaData.payloadCitationId=i))}(e,n),n},S=function(o){var l,a=o.metaData,r=o.isFullscreen,u=void 0!==r&&r,d=c.useCompareContext().gptWebCitationConfig,s=t.useMemo(function(){return function(e){return{endpoint:(null==e?void 0:e.endpoint)||_,userEmail:(null==e?void 0:e.userEmail)||b,userId:(null==e?void 0:e.userId)||y,userName:(null==e?void 0:e.userName)||w,headers:null==e?void 0:e.headers}}(d)},[d]),v=null==a?void 0:a.webGpt,h=t.useRef(null);h.current||(h.current=D());var m=t.useMemo(function(){return function(e,i,n){var t,o,l=f(e),a=(null==l?void 0:l.customMetaData)||{},r=(null==a?void 0:a.value)||{},u=(null==e?void 0:e.webSearchAnswer)||{},d=(null==e?void 0:e.extraMetaData)||e||{};return{userEmail:(null==e?void 0:e.userEmail)||(null==u?void 0:u.userEmail)||(null==i?void 0:i.userEmail)||"",userId:(null==e?void 0:e.userId)||(null==u?void 0:u.userId)||(null==i?void 0:i.userId)||"",userName:(null==e?void 0:e.userName)||(null==u?void 0:u.userName)||(null==i?void 0:i.userName)||"",citationId:F(e,n),citationUrl:(null==r?void 0:r.citationUrl)||(null==u?void 0:u.citationUrl)||"",content:(null==d?void 0:d.Reasoning)||(null==u?void 0:u.enhanced_content)||"",citationType:(null==r?void 0:r.citationType)||"web",citatioNumber:null!==(o=null!==(t=null==a?void 0:a.citation_number)&&void 0!==t?t:null==l?void 0:l.citation_number)&&void 0!==o?o:Number((null==e?void 0:e.reasoningId)||0)}}(v,s,h.current||void 0)},[v,s]),x=t.useMemo(function(){return f(v)},[v]),C=(null===(l=null==x?void 0:x.customMetaData)||void 0===l?void 0:l.value)||{},S=(null==v?void 0:v.extraMetaData)||v||{},P=t.useState(),T=P[0],k=P[1],M=t.useState("pending"),N=M[0],I=M[1],R=t.useState(!0),G=R[0],U=R[1];t.useEffect(function(){var i=!0;return e.__awaiter(void 0,void 0,void 0,function(){var n,t,o,l;return e.__generator(this,function(a){switch(a.label){case 0:if(!s.endpoint||!(null==m?void 0:m.citationUrl)||!(null==m?void 0:m.content))return I("error"),[2];I("pending"),a.label=1;case 1:return a.trys.push([1,4,,5]),[4,fetch(s.endpoint,{method:"POST",headers:e.__assign({"actor-id":m.userEmail,Accept:"application/json, text/plain, */*","Content-Type":"application/json"},s.headers||{}),body:JSON.stringify(m)})];case 2:if(!(n=a.sent()).ok)throw new Error("Failed to fetch GPT web citation (".concat(n.status,")"));return[4,n.json()];case 3:return t=a.sent(),o=(null==t?void 0:t.responseData)||(null==t?void 0:t.result)||(null==t?void 0:t.data)||t,i?(k(o),I("success"),[3,5]):[2];case 4:return l=a.sent(),i?(console.error("Failed to load GPT web citation",l),I("error"),[3,5]):[2];case 5:return[2]}})}),function(){i=!1}},[m,s]);var E=t.useMemo(function(){return{item:{confidence_score:Number((null==S?void 0:S.Confidence_score)||0),text:(null==C?void 0:C.paraphrase)||"Web citation reasoning",dataSource:(null==C?void 0:C.text)||(null==S?void 0:S.Reasoning)||"",paraphrase:(null==C?void 0:C.paraphrase)||""},headerTitle:"GPT Web Citation",index:Number((null==m?void 0:m.citatioNumber)||1)-1,iconsConfig:{ChevronDownIcon:n.ChevronDown,ChevronUpIcon:n.ChevronUp,MaximizeIcon:n.Maximize2,CloseIcon:n.X}}},[C,null==m?void 0:m.citatioNumber,S]),q=t.useMemo(function(){return e.__assign(e.__assign({},E),u?{bodyHeight:j}:{})},[E,u]);return i.jsx(p.default,{gptCitation:q,defaultCitationUrl:(null==m?void 0:m.citationUrl)||"",citationType:g.CitationType.GPT_WEB,webCitationData:T,webCitationStatus:N,showWebCitation:G,onToggleCitationView:function(){return U(function(e){return!e})},iconsConfig:{MaximizeIcon:n.Maximize2,ExternalLinkIcon:n.ExternalLink},isFixedHeight:!0})},P=function(n){var a,r,u,p,g,h,f,_=n.href,b=n.metaData,y=n.citationTitle,w=n.citationType,C=n.citationReason,j=n.isFullscreen,D=c.useCompareContext().guidelinesData,F=function(e){try{var i=function(e){var i=e.match(/^(?:pdf_citation|deviation_summary)\$(\d+)/);if(i)try{var n=e.indexOf("?"),t=n>=0?e.slice(n):"";return{citationNumber:i[1],parsedUrl:new URL(t||"./",window.location.origin)}}catch(e){return{citationNumber:i[1],parsedUrl:null}}try{var o=new URL(e,window.location.origin);return{citationNumber:o.searchParams.get("citationNumber")||o.searchParams.get("citation_number"),parsedUrl:o}}catch(e){return{citationNumber:null,parsedUrl:null}}}(e),n=i.citationNumber,t=i.parsedUrl;return{citationNumber:n,phraseToHighlight:(null==t?void 0:t.searchParams.get("phrase_to_highlight"))||null,citationTypeFromHref:(null==t?void 0:t.searchParams.get("citation_type"))||null}}catch(e){return{citationNumber:null,phraseToHighlight:null,citationTypeFromHref:null}}}(_),P=F.citationNumber,T=F.phraseToHighlight,k=F.citationTypeFromHref,M=w||k||void 0,N="il_rulebook_citation"===M?"rulebook_citation":M,I=P&&(null===(a=null==b?void 0:b.citations)||void 0===a?void 0:a[P])||{},R=(null===(r=null==b?void 0:b.docData)||void 0===r?void 0:r.documents)||{},G=(null===(u=null==b?void 0:b.docData)||void 0===u?void 0:u.input_index_map)||{},U=Object.keys((null==b?void 0:b.citations)||{}).length>0||Object.keys((null==b?void 0:b.docData)||{}).length>0,E=null==G?void 0:G[0],q=null==G?void 0:G[1],A=E?R[E]:null,H=q?R[q]:null,W=E?I[E]:null,z=q?I[q]:null,O=t.useMemo(function(){var e,n,t,o;return W&&A?i.jsx(l.default,{defaultScale:"PageWidth",showFullScreenAction:!1,showHighlightsAction:!1,pdfName:null==A?void 0:A.title,pdfUrl:null==A?void 0:A.signed_url,highlightText:[null!==(e=null==W?void 0:W.highlighted_text)&&void 0!==e?e:""],highlightPages:{1:null===(n=null==W?void 0:W.custom_metadata)||void 0===n?void 0:n.pdf_start_page_number},jumpToPageValue:1,highlightCordinatePages:[],useCoordinates:!1,useRange:!0,rangeOfPages:[null===(t=null==W?void 0:W.custom_metadata)||void 0===t?void 0:t.pdf_start_page_number,null===(o=null==W?void 0:W.custom_metadata)||void 0===o?void 0:o.pdf_end_page_number]}):null},[null==A?void 0:A.title,null==A?void 0:A.signed_url,null==W?void 0:W.highlighted_text,null===(p=null==W?void 0:W.custom_metadata)||void 0===p?void 0:p.pdf_start_page_number,null===(g=null==W?void 0:W.custom_metadata)||void 0===g?void 0:g.pdf_end_page_number]),B=t.useMemo(function(){var e,n,t,o;return z&&H?i.jsx(l.default,{defaultScale:"PageWidth",showFullScreenAction:!1,showHighlightsAction:!1,pdfName:null==H?void 0:H.title,pdfUrl:null==H?void 0:H.signed_url,jumpToPageValue:1,highlightText:[null!==(e=null==z?void 0:z.highlighted_text)&&void 0!==e?e:""],highlightPages:{1:null===(n=null==z?void 0:z.custom_metadata)||void 0===n?void 0:n.pdf_start_page_number},highlightCordinatePages:[],useCoordinates:!1,useRange:!0,rangeOfPages:[null===(t=null==z?void 0:z.custom_metadata)||void 0===t?void 0:t.pdf_start_page_number,null===(o=null==z?void 0:z.custom_metadata)||void 0===o?void 0:o.pdf_end_page_number]}):null},[null==H?void 0:H.title,null==H?void 0:H.signed_url,null==z?void 0:z.highlighted_text,null===(h=null==z?void 0:z.custom_metadata)||void 0===h?void 0:h.pdf_start_page_number,null===(f=null==z?void 0:z.custom_metadata)||void 0===f?void 0:f.pdf_end_page_number]),L="dual_citation"===N,V=L&&!!(null==b?void 0:b.webGpt),J=t.useMemo(function(){if(!O)return null;var n=V?i.jsx(S,{metaData:b,isFullscreen:j}):"rulebook_citation"===N?i.jsx(i.Fragment,{children:i.jsx(d.Box,e.__assign({sx:e.__assign(e.__assign({padding:"0px 20px",backgroundColor:"#FFFFFF",borderRadius:"8px"},s.SHARED_MARKDOWN_STYLES),{overflow:"auto"})},{children:i.jsx(m.default,e.__assign({rehypePlugins:[x.default]},{children:v.processGuidelinesMarkdown({guidelinesData:D,targetHighlights:[T],labelColor:"#FEF08A"})}))}))}):B;return n?i.jsx(o.default,{leftComponent:O,rightComponent:n,isFullscreen:j}):O},[O,B,N,V,b,j,D,T]);return(null==b?void 0:b.webGpt)&&!U?i.jsx(S,{metaData:b,isFullscreen:j}):P?"rulebook_citation"===N?W?i.jsx("div",e.__assign({style:{height:"100%",display:"flex",flexDirection:"column"}},{children:J})):i.jsx("div",e.__assign({style:{padding:"12px",fontSize:"13px",color:"#344054",lineHeight:1.5}},{children:C||"Rulebook citation selected."})):L?W||z?i.jsx("div",e.__assign({style:{height:"100%",display:"flex",flexDirection:"column"}},{children:J})):(null==b?void 0:b.webGpt)?i.jsx(S,{metaData:b,isFullscreen:j}):i.jsx("div",{children:"Missing PDF Citation. Please try again later"}):["contract","clause"].includes(y)?W||z?i.jsx("div",e.__assign({style:{height:"100%",display:"flex",flexDirection:"column"}},{children:J})):i.jsx("div",{children:"Missing PDF Citation. Please try again later"}):i.jsx("div",{children:"No Citation Found. Please try again later"}):null};exports.default=function(o){var l,r,u,s,c,v,p,g=o.href,h=o.children,m=o.citationType,x=o.citationReason,f=o.metaData,_=o.chevronUpComponent,b=void 0===_?null:_,y=o.chevronDownComponent,w=void 0===y?null:y,j=o.customStyle,D=void 0===j?{}:j,F=o.defaultState,S=void 0!==F&&F,T=o.onFullscreenChange,k=t.useState(S),M=k[0],N=k[1],I=t.useState(!1),R=I[0],G=I[1],U="string"==typeof h&&(null===(l=null==h?void 0:h.split("\n"))||void 0===l?void 0:l.length)>1?h.split("\n").join(" "):h;t.useEffect(function(){if(null==T||T(R),R)return function(){null==T||T(!1)}},[R,T]);var E="string"==typeof h?h:h[0],q=null!=b?b:function(e){var t,o;return i.jsx(n.ChevronUp,{size:null!==(t=null==e?void 0:e.fontSize)&&void 0!==t?t:16,color:null!==(o=null==e?void 0:e.color)&&void 0!==o?o:"rgb(214, 51, 132)"})}(null!==(r=null==D?void 0:D.arrow)&&void 0!==r?r:{}),A=null!=w?w:function(e){var t,o;return i.jsx(n.ChevronDown,{size:null!==(t=null==e?void 0:e.fontSize)&&void 0!==t?t:16,color:null!==(o=null==e?void 0:e.color)&&void 0!==o?o:"rgb(214, 51, 132)"})}(null!==(u=null==D?void 0:D.arrow)&&void 0!==u?u:{}),H=i.jsxs("div",e.__assign({style:{boxSizing:"border-box",border:R?"none":"1px solid #E4E7EC",borderRadius:R?0:"8px",overflow:"hidden",marginTop:R?0:"8px",display:"flex",flexDirection:"column",width:"100%",height:R?"100%":void 0,backgroundColor:"#FAFAFA"}},{children:[i.jsx("div",e.__assign({style:{display:"flex",justifyContent:"flex-end",padding:"6px 10px",borderBottom:"1px solid #E4E7EC",backgroundColor:"#FFFFFF",flexShrink:0}},{children:i.jsx("button",e.__assign({onClick:function(){G(function(e){return!e})},style:{background:"none",border:"none",cursor:"pointer",padding:"4px",borderRadius:"6px",color:"#475467",marginRight:"9px"}},{children:R?i.jsx(a.DefaultFullScreenCloseIcon,{}):i.jsx(a.DefaultFullScreenIcon,{})}))})),i.jsx("div",e.__assign({style:{flex:1,minHeight:0,height:"100%",overflow:"hidden"}},{children:i.jsx(P,{href:g,children:h,metaData:f,citationTitle:E,citationType:m,citationReason:x,isFullscreen:R})}))]}));return i.jsxs("span",e.__assign({style:e.__assign({display:"inline"},D.relativeWrapper||{})},{children:[i.jsx("div",e.__assign({style:e.__assign({display:"inline",marginTop:0},D.citationButtonWrapper||{})},{children:i.jsxs("button",e.__assign({type:"button",onClick:function(){return N(function(e){return!e})},style:e.__assign({display:(null==f?void 0:f.webGpt)?"inline":"inline-flex",alignItems:(null==f?void 0:f.webGpt)?void 0:"center",gap:(null==f?void 0:f.webGpt)?void 0:"3px",fontFamily:'"Inter", sans-serif',backgroundColor:"transparent",padding:0,margin:0,fontSize:"13px",borderRadius:9999,cursor:"pointer",fontWeight:(null==f?void 0:f.webGpt)?600:700,color:(null==f?void 0:f.webGpt)?"#6D28D9":"rgb(214, 51, 132)",border:"none",textDecoration:"none",wordBreak:"break-word",whiteSpace:"normal"},D.citationButton||{})},{children:[(null==f?void 0:f.webGpt)&&i.jsx(n.Globe,{size:null!==(c=null===(s=D.arrow)||void 0===s?void 0:s.fontSize)&&void 0!==c?c:"1em",color:null!==(p=null===(v=D.arrow)||void 0===v?void 0:v.color)&&void 0!==p?p:"#6D28D9",style:{display:"inline-block",width:"1em",height:"1em",marginRight:"3px",verticalAlign:"-0.125em",flexShrink:0}}),i.jsx("span",{children:U}),i.jsx("span",e.__assign({style:{display:"inline-flex",alignItems:"center",marginLeft:(null==f?void 0:f.webGpt)?"3px":void 0,verticalAlign:(null==f?void 0:f.webGpt)?"-0.125em":void 0}},{children:M?q:A}))]}))})),M&&(R?i.jsx(d.Dialog,e.__assign({open:R,onClose:function(){return G(!1)},maxWidth:!1,BackdropProps:{sx:{backgroundColor:"rgba(0, 0, 0, 0.6)",backdropFilter:"blur(4px)"}},PaperProps:{sx:{backgroundColor:"#FAFAFA",borderRadius:"16px",height:C,m:0,maxHeight:C,maxWidth:"95vw",overflow:"hidden",width:"95vw"}}},{children:H})):H)]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),i=require("react/jsx-runtime"),n=require("lucide-react"),t=require("react"),o=require("./ResizableSplitPane.js"),l=require("../PdfViewer/PdfViewer.js"),a=require("../../assests/svg/PdfViewerIcons.js"),r=require("react-markdown"),u=require("rehype-raw"),d=require("@mui/material"),s=require("./CognitiveCompareConfig.js");require("react-dom");var c=require("./CompareContext.js"),v=require("./Guidelines/utils/processGuidelinesMarkdown.js"),p=require("../GptWebCitation/GptWebCitation.js"),g=require("../GptWebCitation/types.js");function h(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("./MoreFunctionsPopup.js"),require("./components/SubSectionAccordion.js"),require("./components/LHSSectionRow.js"),require("./components/RHSSectionRow.js");var m=h(r),x=h(u),f=function(e){var i,n,t;return(null===(t=null===(n=null===(i=(null==e?void 0:e.extraMetaData)||e)||void 0===i?void 0:i.aiReasoningCitation)||void 0===n?void 0:n.gpt_citation)||void 0===t?void 0:t[0])||null},_="https://dev-proposals-ai.techo.camp/utility/ca-workflow-composer-agent/get_citation",b="sai.siddhartha@techolution.com",y="672e32f7a0e8fe2e8e50bcba",C="TNV Sai Siddhartha",w="90vh",j="calc(".concat(w," - 120px)"),F=function(){var e;return"function"==typeof(null===(e=globalThis.crypto)||void 0===e?void 0:e.randomUUID)?globalThis.crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var i=Math.floor(16*Math.random());return("x"===e?i:i%4+8).toString(16)})},D=function(e,i){var n=function(e){var i;return(null==e?void 0:e.payloadCitationId)||(null===(i=null==e?void 0:e.extraMetaData)||void 0===i?void 0:i.payloadCitationId)||""}(e)||i||F();return function(e,i){e&&"object"==typeof e&&(e.payloadCitationId=i,e.extraMetaData&&"object"==typeof e.extraMetaData&&(e.extraMetaData.payloadCitationId=i))}(e,n),n},S=function(o){var l,a=o.metaData,r=o.isFullscreen,u=void 0!==r&&r,d=o.onFullscreenChange,s=c.useCompareContext().gptWebCitationConfig,v=t.useMemo(function(){return function(e){return{endpoint:(null==e?void 0:e.endpoint)||_,userEmail:(null==e?void 0:e.userEmail)||b,userId:(null==e?void 0:e.userId)||y,userName:(null==e?void 0:e.userName)||C,headers:null==e?void 0:e.headers}}(s)},[s]),h=null==a?void 0:a.webGpt,m=t.useRef(null);m.current||(m.current=F());var x=t.useMemo(function(){return function(e,i,n){var t,o,l=f(e),a=(null==l?void 0:l.customMetaData)||{},r=(null==a?void 0:a.value)||{},u=(null==e?void 0:e.webSearchAnswer)||{},d=(null==e?void 0:e.extraMetaData)||e||{};return{userEmail:(null==e?void 0:e.userEmail)||(null==u?void 0:u.userEmail)||(null==i?void 0:i.userEmail)||"",userId:(null==e?void 0:e.userId)||(null==u?void 0:u.userId)||(null==i?void 0:i.userId)||"",userName:(null==e?void 0:e.userName)||(null==u?void 0:u.userName)||(null==i?void 0:i.userName)||"",citationId:D(e,n),citationUrl:(null==r?void 0:r.citationUrl)||(null==u?void 0:u.citationUrl)||"",content:(null==d?void 0:d.Reasoning)||(null==u?void 0:u.enhanced_content)||"",citationType:(null==r?void 0:r.citationType)||"web",citatioNumber:null!==(o=null!==(t=null==a?void 0:a.citation_number)&&void 0!==t?t:null==l?void 0:l.citation_number)&&void 0!==o?o:Number((null==e?void 0:e.reasoningId)||0)}}(h,v,m.current||void 0)},[h,v]),w=t.useMemo(function(){return f(h)},[h]),S=(null===(l=null==w?void 0:w.customMetaData)||void 0===l?void 0:l.value)||{},P=(null==h?void 0:h.extraMetaData)||h||{},T=t.useState(),k=T[0],M=T[1],N=t.useState("pending"),I=N[0],R=N[1],G=t.useState(!0),U=G[0],E=G[1];t.useEffect(function(){var i=!0;return e.__awaiter(void 0,void 0,void 0,function(){var n,t,o,l;return e.__generator(this,function(a){switch(a.label){case 0:if(!v.endpoint||!(null==x?void 0:x.citationUrl)||!(null==x?void 0:x.content))return R("error"),[2];R("pending"),a.label=1;case 1:return a.trys.push([1,4,,5]),[4,fetch(v.endpoint,{method:"POST",headers:e.__assign({"actor-id":x.userEmail,Accept:"application/json, text/plain, */*","Content-Type":"application/json"},v.headers||{}),body:JSON.stringify(x)})];case 2:if(!(n=a.sent()).ok)throw new Error("Failed to fetch GPT web citation (".concat(n.status,")"));return[4,n.json()];case 3:return t=a.sent(),o=(null==t?void 0:t.responseData)||(null==t?void 0:t.result)||(null==t?void 0:t.data)||t,i?(M(o),R("success"),[3,5]):[2];case 4:return l=a.sent(),i?(console.error("Failed to load GPT web citation",l),R("error"),[3,5]):[2];case 5:return[2]}})}),function(){i=!1}},[x,v]);var q=t.useMemo(function(){return{item:{confidence_score:Number((null==P?void 0:P.Confidence_score)||0),text:(null==S?void 0:S.paraphrase)||"Web citation reasoning",dataSource:(null==S?void 0:S.text)||(null==P?void 0:P.Reasoning)||"",paraphrase:(null==S?void 0:S.paraphrase)||""},headerTitle:"GPT Web Citation",index:Number((null==x?void 0:x.citatioNumber)||1)-1,iconsConfig:{ChevronDownIcon:n.ChevronDown,ChevronUpIcon:n.ChevronUp,MaximizeIcon:n.Maximize2,CloseIcon:n.X}}},[S,null==x?void 0:x.citatioNumber,P]),A=t.useMemo(function(){return e.__assign(e.__assign({},q),u?{bodyHeight:j}:{})},[q,u]);return i.jsx(p.default,{gptCitation:A,defaultCitationUrl:(null==x?void 0:x.citationUrl)||"",citationType:g.CitationType.GPT_WEB,webCitationData:k,webCitationStatus:I,showWebCitation:U,onToggleCitationView:function(){return E(function(e){return!e})},iconsConfig:{MaximizeIcon:n.Maximize2,ExternalLinkIcon:n.ExternalLink},isFixedHeight:!0,onFullscreenChange:d})},P=function(n){var a,r,u,p,g,h,f,_=n.href,b=n.metaData,y=n.citationTitle,C=n.citationType,w=n.citationReason,j=n.isFullscreen,F=n.onFullscreenChange,D=c.useCompareContext().guidelinesData,P=function(e){try{var i=function(e){var i=e.match(/^(?:pdf_citation|deviation_summary)\$(\d+)/);if(i)try{var n=e.indexOf("?"),t=n>=0?e.slice(n):"";return{citationNumber:i[1],parsedUrl:new URL(t||"./",window.location.origin)}}catch(e){return{citationNumber:i[1],parsedUrl:null}}try{var o=new URL(e,window.location.origin);return{citationNumber:o.searchParams.get("citationNumber")||o.searchParams.get("citation_number"),parsedUrl:o}}catch(e){return{citationNumber:null,parsedUrl:null}}}(e),n=i.citationNumber,t=i.parsedUrl;return{citationNumber:n,phraseToHighlight:(null==t?void 0:t.searchParams.get("phrase_to_highlight"))||null,citationTypeFromHref:(null==t?void 0:t.searchParams.get("citation_type"))||null}}catch(e){return{citationNumber:null,phraseToHighlight:null,citationTypeFromHref:null}}}(_),T=P.citationNumber,k=P.phraseToHighlight,M=P.citationTypeFromHref,N=C||M||void 0,I="il_rulebook_citation"===N?"rulebook_citation":N,R=T&&(null===(a=null==b?void 0:b.citations)||void 0===a?void 0:a[T])||{},G=(null===(r=null==b?void 0:b.docData)||void 0===r?void 0:r.documents)||{},U=(null===(u=null==b?void 0:b.docData)||void 0===u?void 0:u.input_index_map)||{},E=Object.keys((null==b?void 0:b.citations)||{}).length>0||Object.keys((null==b?void 0:b.docData)||{}).length>0,q=null==U?void 0:U[0],A=null==U?void 0:U[1],H=q?G[q]:null,W=A?G[A]:null,z=q?R[q]:null,O=A?R[A]:null,B=t.useMemo(function(){var e,n,t,o;return z&&H?i.jsx(l.default,{defaultScale:"PageWidth",showFullScreenAction:!1,showHighlightsAction:!1,pdfName:null==H?void 0:H.title,pdfUrl:null==H?void 0:H.signed_url,highlightText:[null!==(e=null==z?void 0:z.highlighted_text)&&void 0!==e?e:""],highlightPages:{1:null===(n=null==z?void 0:z.custom_metadata)||void 0===n?void 0:n.pdf_start_page_number},jumpToPageValue:1,highlightCordinatePages:[],useCoordinates:!1,useRange:!0,rangeOfPages:[null===(t=null==z?void 0:z.custom_metadata)||void 0===t?void 0:t.pdf_start_page_number,null===(o=null==z?void 0:z.custom_metadata)||void 0===o?void 0:o.pdf_end_page_number]}):null},[null==H?void 0:H.title,null==H?void 0:H.signed_url,null==z?void 0:z.highlighted_text,null===(p=null==z?void 0:z.custom_metadata)||void 0===p?void 0:p.pdf_start_page_number,null===(g=null==z?void 0:z.custom_metadata)||void 0===g?void 0:g.pdf_end_page_number]),L=t.useMemo(function(){var e,n,t,o;return O&&W?i.jsx(l.default,{defaultScale:"PageWidth",showFullScreenAction:!1,showHighlightsAction:!1,pdfName:null==W?void 0:W.title,pdfUrl:null==W?void 0:W.signed_url,jumpToPageValue:1,highlightText:[null!==(e=null==O?void 0:O.highlighted_text)&&void 0!==e?e:""],highlightPages:{1:null===(n=null==O?void 0:O.custom_metadata)||void 0===n?void 0:n.pdf_start_page_number},highlightCordinatePages:[],useCoordinates:!1,useRange:!0,rangeOfPages:[null===(t=null==O?void 0:O.custom_metadata)||void 0===t?void 0:t.pdf_start_page_number,null===(o=null==O?void 0:O.custom_metadata)||void 0===o?void 0:o.pdf_end_page_number]}):null},[null==W?void 0:W.title,null==W?void 0:W.signed_url,null==O?void 0:O.highlighted_text,null===(h=null==O?void 0:O.custom_metadata)||void 0===h?void 0:h.pdf_start_page_number,null===(f=null==O?void 0:O.custom_metadata)||void 0===f?void 0:f.pdf_end_page_number]),V="dual_citation"===I,J=V&&!!(null==b?void 0:b.webGpt),K=t.useMemo(function(){var n=J?i.jsx(S,{metaData:b,isFullscreen:j,onFullscreenChange:F}):"rulebook_citation"===I?i.jsx(i.Fragment,{children:i.jsx(d.Box,e.__assign({sx:e.__assign(e.__assign({padding:"0px 20px",backgroundColor:"#FFFFFF",borderRadius:"8px"},s.SHARED_MARKDOWN_STYLES),{overflow:"auto"})},{children:i.jsx(m.default,e.__assign({rehypePlugins:[x.default]},{children:v.processGuidelinesMarkdown({guidelinesData:D,targetHighlights:[k],labelColor:"#FEF08A"})}))}))}):L;return i.jsx(o.default,{leftComponent:B,rightComponent:n,isFullscreen:j})},[B,L,I,J,b,j,D,k,F]);return(null==b?void 0:b.webGpt)&&!E?i.jsx(S,{metaData:b,isFullscreen:j,onFullscreenChange:F}):T?"rulebook_citation"===I?z?i.jsx("div",e.__assign({style:{height:"100%",display:"flex",flexDirection:"column"}},{children:K})):i.jsx("div",e.__assign({style:{padding:"12px",fontSize:"13px",color:"#344054",lineHeight:1.5}},{children:w||"Rulebook citation selected."})):V?z||O?i.jsx("div",e.__assign({style:{height:"100%",display:"flex",flexDirection:"column"}},{children:K})):(null==b?void 0:b.webGpt)?i.jsx(S,{metaData:b,isFullscreen:j,onFullscreenChange:F}):i.jsx("div",{children:"Missing PDF Citation. Please try again later"}):["contract","clause"].includes(y)?z||O?i.jsx("div",e.__assign({style:{height:"100%",display:"flex",flexDirection:"column"}},{children:K})):i.jsx("div",{children:"Missing PDF Citation. Please try again later"}):i.jsx("div",{children:"No Citation Found. Please try again later"}):null};exports.default=function(o){var l,r,u,s,c,v,p,g=o.href,h=o.children,m=o.citationType,x=o.citationReason,f=o.metaData,_=o.chevronUpComponent,b=void 0===_?null:_,y=o.chevronDownComponent,C=void 0===y?null:y,j=o.customStyle,F=void 0===j?{}:j,D=o.defaultState,S=void 0!==D&&D,T=o.onFullscreenChange,k=t.useState(S),M=k[0],N=k[1],I=t.useState(!1),R=I[0],G=I[1],U="string"==typeof h&&(null===(l=null==h?void 0:h.split("\n"))||void 0===l?void 0:l.length)>1?h.split("\n").join(" "):h;t.useEffect(function(){if(null==T||T(R),R)return function(){null==T||T(!1)}},[R,T]);var E="string"==typeof h?h:h[0],q=null!=b?b:function(e){var t,o;return i.jsx(n.ChevronUp,{size:null!==(t=null==e?void 0:e.fontSize)&&void 0!==t?t:16,color:null!==(o=null==e?void 0:e.color)&&void 0!==o?o:"rgb(214, 51, 132)"})}(null!==(r=null==F?void 0:F.arrow)&&void 0!==r?r:{}),A=null!=C?C:function(e){var t,o;return i.jsx(n.ChevronDown,{size:null!==(t=null==e?void 0:e.fontSize)&&void 0!==t?t:16,color:null!==(o=null==e?void 0:e.color)&&void 0!==o?o:"rgb(214, 51, 132)"})}(null!==(u=null==F?void 0:F.arrow)&&void 0!==u?u:{}),H=i.jsxs("div",e.__assign({style:{boxSizing:"border-box",border:R?"none":"1px solid #E4E7EC",borderRadius:R?0:"8px",overflow:"hidden",marginTop:R?0:"8px",display:"flex",flexDirection:"column",width:"100%",height:R?"100%":void 0,backgroundColor:"#FAFAFA"}},{children:[i.jsx("div",e.__assign({style:{display:"flex",justifyContent:"flex-end",padding:"6px 10px",borderBottom:"1px solid #E4E7EC",backgroundColor:"#FFFFFF",flexShrink:0}},{children:i.jsx("button",e.__assign({onClick:function(){G(function(e){var i=!e;return null==T||T(i),i})},style:{background:"none",border:"none",cursor:"pointer",padding:"4px",borderRadius:"6px",color:"#475467",marginRight:"9px"}},{children:R?i.jsx(a.DefaultFullScreenCloseIcon,{}):i.jsx(a.DefaultFullScreenIcon,{})}))})),i.jsx("div",e.__assign({style:{flex:1,minHeight:0,height:"100%",overflow:"hidden"}},{children:i.jsx(P,{href:g,children:h,metaData:f,citationTitle:E,citationType:m,citationReason:x,isFullscreen:R,onFullscreenChange:T})}))]}));return i.jsxs("span",e.__assign({style:e.__assign({display:"inline"},F.relativeWrapper||{})},{children:[i.jsx("div",e.__assign({style:e.__assign({display:"inline",marginTop:0},F.citationButtonWrapper||{})},{children:i.jsxs("button",e.__assign({type:"button",onClick:function(){return N(function(e){return!e})},style:e.__assign({display:(null==f?void 0:f.webGpt)?"inline":"inline-flex",alignItems:(null==f?void 0:f.webGpt)?void 0:"center",gap:(null==f?void 0:f.webGpt)?void 0:"3px",fontFamily:'"Inter", sans-serif',backgroundColor:"transparent",padding:0,margin:0,fontSize:"13px",borderRadius:9999,cursor:"pointer",fontWeight:(null==f?void 0:f.webGpt)?600:700,color:(null==f?void 0:f.webGpt)?"#6D28D9":"rgb(214, 51, 132)",border:"none",textDecoration:"none",wordBreak:"break-word",whiteSpace:"normal"},F.citationButton||{})},{children:[(null==f?void 0:f.webGpt)&&i.jsx(n.Globe,{size:null!==(c=null===(s=F.arrow)||void 0===s?void 0:s.fontSize)&&void 0!==c?c:"1em",color:null!==(p=null===(v=F.arrow)||void 0===v?void 0:v.color)&&void 0!==p?p:"#6D28D9",style:{display:"inline-block",width:"1em",height:"1em",marginRight:"3px",verticalAlign:"-0.125em",flexShrink:0}}),i.jsx("span",{children:U}),i.jsx("span",e.__assign({style:{display:"inline-flex",alignItems:"center",marginLeft:(null==f?void 0:f.webGpt)?"3px":void 0,verticalAlign:(null==f?void 0:f.webGpt)?"-0.125em":void 0}},{children:M?q:A}))]}))})),M&&(R?i.jsx(d.Dialog,e.__assign({open:R,onClose:function(){G(!1),null==T||T(!1)},maxWidth:!1,BackdropProps:{sx:{backgroundColor:"rgba(0, 0, 0, 0.6)",backdropFilter:"blur(4px)"}},PaperProps:{sx:{backgroundColor:"#FAFAFA",borderRadius:"16px",height:w,m:0,maxHeight:w,maxWidth:"95vw",overflow:"hidden",width:"95vw"}}},{children:H})):H)]}))};
2
2
  //# sourceMappingURL=CitationAnchor.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),i=require("react"),t=require("@mui/material"),o=require("lucide-react"),r=require("../../assests/svg/ButtonCognitiveIcon.js"),l=require("./OverlayComponent.js"),u=require("./CognitiveComparehelpers.js"),s=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"),T=require("./hooks/useLinesCalculator.js"),w=require("./hooks/useSideBySide.js"),I=require("./components/SvgConnectors.js"),B=require("./Guidelines/components/GuidelinePanel.js"),D=require("./Guidelines/components/WebGptPanel.js");exports.SHARED_MARKDOWN_STYLES=s.SHARED_MARKDOWN_STYLES,exports.default=function(O){var F,j,P,k,N,M,L,q,H,G,V,W,z,K,U,Y,J,X,$,Q,Z,ee,ne,ie,te,oe,re,le,ue,se,ae,ce,de,fe,ve,ge=O.componentHeaderText,pe=void 0===ge?a.DEFAULT_COMPONENT_HEADER_TEXT:ge,he=O.treeData,me=O.comparisonConfig,Se=O.leftColumnTitleText,Re=O.rightColumnTitleText,xe=O.markdownStyles,_e=O.resetTrigger,be=O.displayConfig,ye=void 0===be?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1,displayEmailNotifier:!0,isStreamingEnabled:!1}:be,Ce=O.onMaintainRelativeOrderChange,Ee=O.popupConfig,Ae=O.deviationData,Te=void 0===Ae?{}:Ae,we=O.deviationNodeIdToView,Ie=O.resetDeviationNodeId,Be=O.isProposingFix,De=void 0!==Be&&Be,Oe=O.proposingFixNodeId,Fe=O.isRedlineFlow,je=O.badgeStyleOverride,Pe=O.guidelinesData,ke=O.gptWebCitationConfig,Ne=i.useState(ye.maintainRelativeOrder),Me=Ne[0],Le=Ne[1],qe=null!==(F=null==ye?void 0:ye.expandLevels)&&void 0!==F?F:0,He=!!(null==ye?void 0:ye.expandAllSections),Ge=!!Me||!!(null==ye?void 0:ye.showDeviationBadges),Ve=i.useState(!1),We=Ve[0],ze=Ve[1],Ke=i.useState(null),Ue=Ke[0],Ye=Ke[1],Je=i.useState(null===(P=null!==(j=null==he?void 0:he.newEvaluationResult)&&void 0!==j?j:null==ye?void 0:ye.enableDeviationSchemaBackwardCompatibility)||void 0===P||P)[0],Xe=i.useState(new Set),$e=Xe[0],Qe=Xe[1],Ze=i.useState([]),en=Ze[0],nn=Ze[1],tn=i.useState(!1),on=tn[0],rn=tn[1],ln=i.useState(0),un=ln[0],sn=ln[1],an=i.useRef(null),cn=i.useRef(null),dn=i.useRef(null),fn=i.useRef(null),vn=i.useRef(null),gn=i.useRef(!1),pn=i.useRef(null),hn=i.useRef({}),mn=i.useRef([]),Sn=i.useRef(function(){}),Rn=i.useRef(null),xn=i.useRef(function(){}),_n=i.useMemo(function(){return JSON.stringify(Te||{})},[JSON.stringify(Te)]),bn=i.useMemo(function(){return Te||{}},[_n]),yn=i.useMemo(function(){return(null==he?void 0:he.cognitive_decisioning)||{}},[he]),Cn=i.useMemo(function(){return e.__assign(e.__assign({},s.SHARED_MARKDOWN_STYLES),xe)},[xe]),En=i.useRef(null),An=i.useRef(null),Tn=i.useRef(null),wn=i.useRef(null),In=i.useRef(null),Bn=i.useRef(null),Dn=i.useRef(null),On=i.useRef(null),Fn=i.useRef(null),jn=i.useRef(null),Pn=p.useComparePopups(En),kn=Pn.cognitivePopup,Nn=Pn.setCognitivePopup,Mn=Pn.moreFunctions,Ln=Pn.setMoreFunctions,qn=Pn.position,Hn=Pn.setPosition,Gn=Pn.activeBadgeId,Vn=Pn.summaryPopup,Wn=Pn.setSummaryPopup,zn=Pn.closeSummaryPopup,Kn=Pn.setActiveBadgeId,Un=Pn.popupRef,Yn=Pn.handleOpenCognitiveCompare,Jn=Pn.openCognitivePopupFromState,Xn=Pn.closeCognitivePopup,$n=Pn.closeMoreFunctionsPopup,Qn=i.useMemo(function(){var e,n,i,t,o,r,l;return{fields:null!==(e=null==me?void 0:me.fields)&&void 0!==e?e:s.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(i=null===(n=null==me?void 0:me.thresholds)||void 0===n?void 0:n.high)&&void 0!==i?i:s.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(o=null===(t=null==me?void 0:me.thresholds)||void 0===t?void 0:t.medium)&&void 0!==o?o:s.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(l=null===(r=null==me?void 0:me.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:s.DEFAULT_COMPARISON_CONFIG.thresholds.exact}}},[me]),Zn=i.useState(null),ei=Zn[0];Zn[1];var ni=null===(M=null===(k=null==he?void 0:he.documents)||void 0===k?void 0:k[null===(N=null==he?void 0:he.input_index_map)||void 0===N?void 0:N[0]])||void 0===M?void 0:M.title,ii=null===(H=null===(L=null==he?void 0:he.documents)||void 0===L?void 0:L[null===(q=null==he?void 0:he.input_index_map)||void 0===q?void 0:q[1]])||void 0===H?void 0:H.title,ti=u.safeStringify(Se||ni||"Uploaded Contract"),oi=null===(z=null===(W=null===(G=null==he?void 0:he.documents)||void 0===G?void 0:G[null===(V=null==he?void 0:he.input_index_map)||void 0===V?void 0:V[0]])||void 0===W?void 0:W.metadata)||void 0===z?void 0:z.file_name,ri=u.safeStringify(oi),li=null===(J=null===(Y=null===(K=null==he?void 0:he.documents)||void 0===K?void 0:K[null===(U=null==he?void 0:he.input_index_map)||void 0===U?void 0:U[1]])||void 0===Y?void 0:Y.metadata)||void 0===J?void 0:J.file_name,ui=u.safeStringify(li),si=u.safeStringify(Re||ii||"Reference Template"),ai=g.useCognitiveTreeData(he,Me,bn,Qn,Je,Pe),ci=ai.isGuidelineMode,di=ai.activeProposed,fi=ai.existingRule,vi=ai.proposedSections,gi=ai.existingSections,pi=ai.visibleFields,hi=ai.parentDeviationRecord,mi=ai.deviationNumberRegistry,Si=ai.deviationParentRegistry,Ri=ai.parseError;i.useEffect(function(){Ri&&Ye("Failed to load comparison: ".concat(Ri))},[Ri]);var xi=vi.length>0||gi.length>0,_i=i.useMemo(function(){if(!Fe)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)||"";u.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(vi),i(gi),"".concat(e,":").concat(n)},[Fe,vi,gi]);i.useEffect(function(){if(vi.length||gi.length)if(He){var e={},n={},i=function(i,t){i.forEach(function(i,o){var r,l=Me?"".concat(t,"-").concat(o):String(o);e[l]=!0;var u=function(e,i){null==e||e.forEach(function(e,t){var o,r="".concat(i,"-").concat(t);n[r]=!0,(null===(o=e.subsections)||void 0===o?void 0:o.length)&&u(e.subsections,r)})};(null===(r=i.subsections)||void 0===r?void 0:r.length)&&u(i.subsections,String(o))})};i(vi,"left"),i(gi,"right"),tt(e),rt(n)}else if(qe>0){var t={},o={},r=function(e,n,i){e.forEach(function(e,r){var l;if(i>=1){var u=Me?"".concat(n,"-").concat(r):String(r);t[u]=!0}var s=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)&&s(e.subsections,l,t+1)})};(null===(l=e.subsections)||void 0===l?void 0:l.length)&&i>=2&&s(e.subsections,String(r),2)})};r(vi,"left",qe),r(gi,"right",qe),tt(t),rt(o)}},[He,qe,vi,gi,Me]);var bi=h.useSectionRefs(pi.map(function(e){return e.key}),Math.max(vi.length,gi.length)),yi=bi.leftRefs,Ci=bi.rightRefs,Ei=bi.sectionLeftRefs,Ai=bi.sectionRightRefs,Ti=bi.lhsBadgeRefs,wi=bi.rhsBadgeRefs,Ii=bi.sectionRightRowRefs,Bi=bi.subSectionLeftRefs,Di=bi.subSectionRightRefs,Oi=bi.sectionRowRefs,Fi=bi.getSectionRowRef,ji=bi.getSubSectionRef,Pi=bi.getBadgeRef,ki=w.useSideBySide({isGuidelineMode:ci,maintainRelativeOrder:Me,proposedSections:vi,existingSections:gi,leftContainerRef:On,rightContainerRef:Tn,scrollContainerRef:En,sectionLeftRefs:Ei,sectionRightRefs:Ai,subSectionLeftRefs:Bi,subSectionRightRefs:Di,lhsBadgeRefs:Ti,rhsBadgeRefs:wi,sectionRowRefs:Oi,sectionRightRowRefs:Ii,rhsTopSpacerRef:wn,rhsBottomSpacerRef:In,lhsTopSpacerRef:Bn,lhsBottomSpacerRef:Dn,calculateLinesRef:Sn,setConnectedSections:Qe,setConnectedLines:nn,cachedConnectedPositions:mn,closeMoreFunctionsPopup:$n,setErrorToast:Ye,moreFunctions:Mn,closeSummaryPopup:zn}),Ni=ki.isSideBySide,Mi=ki.isArrowVisible,Li=ki.setIsArrowVisible,qi=ki.isResizing,Hi=ki.setIsResizing,Gi=ki.isSideBySideLoading,Vi=ki.activeSideBySideSection,Wi=ki.scrollLock,zi=ki.sideBySideCacheRef,Ki=ki.isSideBySideRef,Ui=ki.activeSideBySideRightSectionRef,Yi=ki.activeSideBySideSectionRef,Ji=ki.sideBySideLineRef,Xi=ki.highlightedClauseRefs,$i=ki.clearClauseHighlight,Qi=ki.resetSideBySide,Zi=ki.activateSideBySide,et=i.useRef(Zi);i.useEffect(function(){et.current=Zi},[Zi]);var nt=m.useAccordionState({maintainRelativeOrder:!!Me,proposedSections:vi,existingSections:gi,activeSideBySideSection:Vi,connectedSections:$e,resetSideBySide:Qi,setConnectedSections:Qe,setConnectedLines:nn,cachedConnectedPositions:mn,svgContainerRef:an,isAnimatingRef:gn,animationTimerRef:pn,calculateLinesRef:Sn,sectionLeftRefs:Ei,sectionRightRefs:Ai,subSectionLeftRefs:Bi,subSectionRightRefs:Di}),it=nt.expandedSections,tt=nt.setExpandedSections,ot=nt.expandedSubSections,rt=nt.setExpandedSubSections,lt=nt.handleSubSectionToggle,ut=nt.toggleSection,st=nt.forceExpandCrossWiredSections,at=function(){var e,n;if(null!=Vi){var i=null===(e=Ei.current[Vi])||void 0===e?void 0:e.current,t=null===(n=Ai.current[Vi])||void 0===n?void 0:n.current,o=Tn.current;if(i&&t&&o){var r=i.getBoundingClientRect(),l=t.getBoundingClientRect(),u=o.getBoundingClientRect(),s=r.top-u.top,a=l.top-u.top-s;o.scrollBy({top:a,behavior:"smooth"})}}},ct=i.useCallback(function(e){null==e||e.stopPropagation(),rn(function(e){var n=!e;return n&&requestAnimationFrame(function(){at()}),n})},[at]);i.useEffect(function(){Fe&&"off"!==_i&&"0:0"!==_i&&(zi.current=null,mn.current=[],requestAnimationFrame(function(){var e;null===(e=Sn.current)||void 0===e||e.call(Sn)}))},[Fe,_i]);var dt=i.useMemo(function(){var e=new Map,n=new Map,i=1;if(Me)vi.forEach(function(n){!n.title&&!n.content||n.id&&e.set(n.id,i++)}),gi.forEach(function(t){if(t.id&&!(!t.title&&!t.content)){var o=vi.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(vi.length,gi.length),o=0;o<t;o++){var r=vi[o],l=gi[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}},[vi,gi,Me]),ft=fi.analysis,vt=u.safeStringify(null===($=null===(X=null==ft?void 0:ft.rule_difference_comparison)||void 0===X?void 0:X.summary)||void 0===$?void 0:$.overall_summary),gt=!!vt.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),pt=null!==(Q=null==he?void 0:he.base_root_id)&&void 0!==Q?Q:"-1";null==he||he[pt];var ht=Je?null!==(ce=null!==(ue=Te&&(null===(le=null==Te?void 0:Te[pt])||void 0===le?void 0:le.evaluation_result))&&void 0!==ue?ue:null===(ae=null===(se=null==he?void 0:he.nodes)||void 0===se?void 0:se[pt])||void 0===ae?void 0:ae.evaluation_result)&&void 0!==ce?ce:null:null!==(re=null!==(ne=Te&&(null===(ee=null===(Z=null==Te?void 0:Te[pt])||void 0===Z?void 0:Z.evaluation_result)||void 0===ee?void 0:ee[0]))&&void 0!==ne?ne:null===(oe=null===(te=null===(ie=null==he?void 0:he.nodes)||void 0===ie?void 0:ie[pt])||void 0===te?void 0:te.evaluation_result)||void 0===oe?void 0:oe[0])&&void 0!==re?re:null,mt=u.extractDeviationScore(ht),St=u.generateColorPalette(null!==(ve=null===(fe=null===(de=null==ht?void 0:ht.evaluation_outputs)||void 0===de?void 0:de.metadata)||void 0===fe?void 0:fe.label_color)&&void 0!==ve?ve:a.DEFAULT_DEVIAION_COLOR);if(je){var Rt=je(mt);Rt&&(St=e.__assign(e.__assign({},St),{badgeBg:Rt.bg,badgeText:Rt.text,badgeBorder:Rt.border}))}var xt=i.useRef(Qi);i.useEffect(function(){xt.current=Qi},[Qi]);var _t=i.useRef(Xn);i.useEffect(function(){_t.current=Xn},[Xn]);var bt=i.useCallback(function(e,n,i,t,o,r){return Oo.current(e,n,i,t,o,r)},[]),yt=i.useCallback(function(e,n,i,t,o){return jo.current(e,n,i,t,o)},[]),Ct=i.useCallback(function(){return Po.current()},[]),Et=i.useCallback(function(e,n){return ko.current(e,n)},[]),At=i.useCallback(function(e){return No.current(e)},[]),Tt=i.useCallback(function(e){return Mo.current(e)},[]),wt=i.useCallback(function(){return Lo.current()},[]),It=i.useCallback(function(){var e,n;$i(),null===(e=xt.current)||void 0===e||e.call(xt),rn(!1),Qe(new Set),nn([]),mn.current=[],$t([]),Zt(null),Wn(a.EMPTY_SUMMARY_POPUP_STATE),null===(n=_t.current)||void 0===n||n.call(_t),requestAnimationFrame(function(){var e;null===(e=Sn.current)||void 0===e||e.call(Sn)})},[]),Bt=i.useRef(It);i.useEffect(function(){Bt.current=It},[It]),i.useEffect(function(){_e&&Bt.current()},[_e]);var Dt=i.useMemo(function(){return{documents:null==he?void 0:he.documents,input_index_map:null==he?void 0:he.input_index_map}},[JSON.stringify(null==he?void 0:he.documents),JSON.stringify(null==he?void 0:he.input_index_map)]),Ot=i.useState(""),Ft=Ot[0],jt=Ot[1],Pt=i.useRef(he);i.useEffect(function(){var e,n,i;Pt.current=he;var t=null===(e=null==he?void 0:he.input_index_map)||void 0===e?void 0:e[0],o=null===(i=null===(n=null==he?void 0:he.documents)||void 0===n?void 0:n[t])||void 0===i?void 0:i.title;jt(o)},[he]);var kt=i.useRef(yn);i.useEffect(function(){kt.current=yn},[yn]);var Nt=i.useCallback(function(n,i,t,o,r,l,s){var a,c,d,f,v,g,p,h,m,S,R=u.safeStringify(null==i?void 0:i.id)||u.safeStringify(null==t?void 0:t.id)||"",x=(R?null===(a=kt.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=Oi.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,s=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(u.DEVIATION_BADGE_SEPARATOR)))return s(l);var a=o.split(u.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)}):s(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,C=null!==(S=null==ye?void 0:ye.isLoading)&&void 0!==S&&S,E=!0;if(ci){var A=null==b?void 0:b.deviation_highlights;if(A&&"object"==typeof A)E=Object.values(A).some(function(e){return Array.isArray(e)&&e.length>0});else E=!1}return{isLoading:C&&!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:Dt,deviationData:b,isOrphan:!!r,hasGuidelineMatches:E}},[Dt,null==ye?void 0:ye.isLoading,ci]),Mt=i.useCallback(function(e,n,i,t,o,r){var l;if(e.stopPropagation(),Mn.open&&Mn.sectionIdx===o)$n();else{var s=e.currentTarget,a="left";(null===(l=Tn.current)||void 0===l?void 0:l.contains(s))&&(a="right");$i(),Ki.current&&Qi(),Qe(new Set),nn([]),mn.current=[],Xn(),Vn.open?vo():zn(),requestAnimationFrame(function(){var e=function(){var e,n,i,t;if("string"==typeof o&&o.includes(u.DEVIATION_BADGE_SEPARATOR)){var r=o.split(u.DEVIATION_BADGE_SEPARATOR),l="".concat(r[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(r[1]);return"right"===a?null===(e=wi.current[l])||void 0===e?void 0:e.current:null===(n=Ti.current[l])||void 0===n?void 0:n.current}return"right"===a?null===(i=wi.current[o])||void 0===i?void 0:i.current:null===(t=Ti.current[o])||void 0===t?void 0:t.current}()||s;Ln(Nt(e,n,t,o,i,r))})}},[Mn.open,Mn.sectionIdx,$n,zn,Nt]),Lt=i.useCallback(function(){var e=Mn.sectionIdx;Mn.isOrphan,$n(),zn(),null!==e&&(st(e),$i(),Ki.current&&Qi(),nn([]),mn.current=[],ci&&null!==e&&sn(ao(e)),Qe(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){Sn.current&&Sn.current()},50))},[Mn.sectionIdx,Mn.isOrphan,$n,zn,Qi]),qt=i.useCallback(function(){var e=vn.current;if(e){vn.current=null;var n=vi.findIndex(function(n){return n.id===e}),i=gi.findIndex(function(n){return n.id===e}),t=-1===n?u.findKeyPathByNodeId(vi,e):null,o=-1===i?u.findKeyPathByNodeId(gi,e):null,r=-1!==n?n:t?Number(t.split("-")[0]):-1,l=-1!==i?i:o?Number(o.split("-")[0]):-1,s=function(e,n,i,t){var o,r,l,u;return-1!==e?null!==(r=null===(o=i.current[e])||void 0===o?void 0:o.current)&&void 0!==r?r:null:n&&null!==(u=null===(l=t.current[n])||void 0===l?void 0:l.current)&&void 0!==u?u:null},a=function(e,n,i){void 0===i&&(i=30);var t=0,o=function(){var r=e();r&&0!==r.getBoundingClientRect().height?(Xi.current.add(r),u.scrollAndHighlightClause(r,n)):t++<i&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(Me)-1!==r&&On.current&&a(function(){return s(n,t,Ei,Bi)},On.current),-1!==l&&Tn.current&&a(function(){return s(i,o,Ai,Di)},Tn.current);else{var c=En.current;if(!c)return;a(function(){return-1!==r?s(n,t,Ei,Bi):s(i,o,Ai,Di)},c)}}},[vi,gi,Me,Ei,Ai,Bi,Di,On,Tn,En]),Ht=i.useCallback(function(n){if(n){$i(),Qi(),Qe(new Set),nn([]),mn.current=[],zn(),Xn();var i=vi.findIndex(function(e){return e.id===n}),t=gi.findIndex(function(e){return e.id===n}),o=-1===i?u.findKeyPathByNodeId(vi,n):null,r=-1===t?u.findKeyPathByNodeId(gi,n):null;if(-1!==i||o||-1!==t||r){var l=-1!==i?i:o?Number(o.split("-")[0]):-1,s=-1!==t?t:r?Number(r.split("-")[0]):-1;vn.current=n,tt(function(n){var i,t=e.__assign({},n),o=!1;-1!==l&&(t[i=Me?"left-".concat(l):String(l)]||(t[i]=!0,o=!0));-1!==s&&(t[i=Me?"right-".concat(s):String(s)]||(t[i]=!0,o=!0));return o?t:n}),rt(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(){vn.current===n&&Gt.current()})},50)}else console.warn('scrollToAndHighlightClause: nodeId "'.concat(n,'" not found'))}},[vi,gi,Me,tt,rt,Qi,zn,Xn]),Gt=i.useRef(qt);i.useEffect(function(){Gt.current=qt},[qt]);var Vt=i.useRef(null);i.useEffect(function(){if(ei){var e=Qn.fields.find(function(e){return e.analysisKey===ei||e.key===ei});if(e){var n=yi.current[e.key]||Ci.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[ei,Qn.fields]);var Wt=i.useCallback(function(e){var n,i,t,o,r,l,u,s,a,c=null===(n=null==ft?void 0:ft.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===(u=v.highlights)||void 0===u?void 0:u.ruleB_spans)||[],hasContent:!!f}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(s=d.highlights)||void 0===s?void 0:s.ruleA_spans)||[],highlightsB:(null===(a=d.highlights)||void 0===a?void 0:a.ruleB_spans)||[],hasContent:!!f}},[ft]),zt=E.useStyleHelpers({proposedSections:vi,existingSections:gi,maintainRelativeOrder:Me,cognitiveMap:yn,deviationData:bn,treeData:he,resolvedComparisonConfig:Qn,badgeStyleOverride:je}),Kt=zt.getSectionCompareStyle,Ut=zt.getSubSectionCompareStyle,Yt=zt.getDeviationStyleByKey,Jt=T.useLinesCalculator({containerRef:cn,leftContainerRef:On,rightContainerRef:Tn,svgContainerRef:an,pathRefs:hn,leftHeaderRef:dn,rightHeaderRef:fn,proposedSections:vi,existingSections:gi,visibleFields:pi,leftRefs:yi,rightRefs:Ci,sectionLeftRefs:Ei,sectionRightRefs:Ai,subSectionLeftRefs:Bi,subSectionRightRefs:Di,lhsBadgeRefs:Ti,rhsBadgeRefs:wi,sectionRowRefs:Oi,expandedSections:it,expandedSubSections:ot,connectedSections:$e,isSideBySide:Ni,activeSideBySideSection:Vi,maintainRelativeOrder:Me,isGuidelineMode:ci,cognitiveMap:yn,getSectionCompareStyle:Kt,getSubSectionCompareStyle:Ut,getDeviationStyleByKey:Yt,isArrowVisible:Mi,isAnimatingRef:gn,isSideBySideRef:Ki,sideBySideCacheRef:zi,sideBySideLineRef:Ji,activeSideBySideSectionRef:Yi,activeSideBySideRightSectionRef:Ui,connectedLines:en,setConnectedLines:nn,cachedConnectedPositions:mn,calculateLinesRef:Sn,resizeTimerRef:Rn,scrollLock:Wi,scrollSyncLocked:on,handleResizeRef:xn,activeProposed:di,existingRule:fi,analysisData:ft,pendingScrollTargetRef:Fn,pendingScrollCallbackRef:jn,resolvedComparisonConfig:Qn,getFieldData:Wt}),Xt=Jt.lines,$t=Jt.setLines,Qt=Jt.overallConnector,Zt=Jt.setOverallConnector,eo=Jt.svgDimensions,no=Jt.handleColumnScroll;i.useEffect(function(){Vn.anchorEl&&requestAnimationFrame(function(){requestAnimationFrame(function(){var e;null===(e=Sn.current)||void 0===e||e.call(Sn)})})},[Vn.anchorEl,on]);var io=i.useCallback(function(){$i(),rn(!1),tt({}),rt({}),Qi(),Qe(new Set),nn([]),mn.current=[],zn(),Xn(),$n(),requestAnimationFrame(function(){Sn.current&&Sn.current()})},[tt,rt,Qi,zn,Xn,$n]);i.useEffect(function(){Ni||0!==$e.size||rn(!1)},[Ni,$e]);var to=i.useMemo(function(){return Object.values(it).some(Boolean)||Object.values(ot).some(Boolean)},[it,ot]),oo=i.useRef(null),ro=i.useRef(0),lo=i.useRef(0),uo=i.useRef(0),so=A.useResizeHandler({timerRef:oo,ruleComponentRef:An,scrollContainerRef:En,containerRef:cn,maintainRelativeOrder:Me,proposedSections:vi,existingSections:gi,isSideBySideRef:Ki,activeSideBySideSectionRef:Yi,activeSideBySideRightSectionRef:Ui,sectionRowRefs:Oi,sectionRightRowRefs:Ii,sectionLeftRefs:Ei,sectionRightRefs:Ai,subSectionLeftRefs:Bi,subSectionRightRefs:Di,lhsBadgeRefs:Ti,rhsBadgeRefs:wi,leftContainerRef:On,rightContainerRef:Tn,calculateLinesRef:Sn,handleResizeRef:xn,setIsResizing:Hi,setIsArrowVisible:Li,sideBySideCacheRef:zi,cachedConnectedPositions:mn}).handleResize;i.useEffect(function(){xn.current=so},[so,xn]),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,u;i.current=null;var s=e[e.length-1];if(s){var a=null!==(u=null===(l=null===(r=s.borderBoxSize)||void 0===r?void 0:r[0])||void 0===l?void 0:l.inlineSize)&&void 0!==u?u:s.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 An.current&&o.push(e(An.current,ro,n,function(){return xn.current()},function(){})),En.current&&o.push(e(En.current,lo,i,function(){return xn.current()},function(){return Sn.current()})),cn.current&&o.push(e(cn.current,uo,t,function(){return xn.current()},function(){return Sn.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(){Ki.current=Ni},[Ni]),i.useEffect(function(){Yi.current=Vi},[Vi]);var ao=i.useCallback(function(e){var n,i,t,o,r,l="",s="0";if("number"==typeof e)l=(null===(n=vi[e])||void 0===n?void 0:n.nodeId)||(null===(i=vi[e])||void 0===i?void 0:i.id)||"";else{var a=String(e).split(u.DEVIATION_BADGE_SEPARATOR);l=a[0],s=a[1]||"0"}var c=null===(t=null==bn?void 0:bn[l])||void 0===t?void 0:t.evaluation_result,d=Array.isArray(c)?c[parseInt(s,10)]:null==c?void 0:c[s];return!1===(null===(r=null===(o=null==d?void 0:d.evaluation_outputs)||void 0===o?void 0:o.guideline_flag)||void 0===r?void 0:r.rulebook_used)?1:0},[vi,bn]),co=i.useCallback(function(e){var n,i,t=document.querySelectorAll('[id^="guideline-target-"], [data-web-gpt-active="true"]'),o=On.current,r=Tn.current,l="string"==typeof e&&e.includes(u.DEVIATION_BADGE_SEPARATOR),s=e;if(l){var a=e.split(u.DEVIATION_BADGE_SEPARATOR);a.length>=2&&(s="".concat(a[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(a[1]))}var c=(null===(n=Ti.current[s])||void 0===n?void 0:n.current)||(null===(i=Ti.current[e])||void 0===i?void 0:i.current);if(t.length>0&&c&&o&&r){var d=t[0];Bn.current&&(Bn.current.style.height="0px"),wn.current&&(wn.current.style.height="0px"),Dn.current&&(Dn.current.style.height="0px"),In.current&&(In.current.style.height="0px"),requestAnimationFrame(function(){var e=c.getBoundingClientRect(),n=d.getBoundingClientRect(),i=o.getBoundingClientRect(),t=r.getBoundingClientRect(),l=o.scrollTop+(e.top-i.top)+e.height/2,u=r.scrollTop+(n.top-t.top)+n.height/2,s=l-i.height/2,a=Math.max(0,s),f=o.scrollHeight-o.clientHeight,v=a>f?a-f:0,g=i.top+l-a,p=t.top+u-g,h=0;p<0&&(h=Math.abs(p),p=0);var m=r.scrollHeight-r.clientHeight+h,S=p>m?p-m:0;Dn.current&&(Dn.current.style.height="".concat(v,"px")),wn.current&&(wn.current.style.height="".concat(h,"px")),In.current&&(In.current.style.height="".concat(S,"px")),requestAnimationFrame(function(){o.scrollTo({top:a,behavior:"smooth"}),r.scrollTo({top:p,behavior:"smooth"}),Sn.current&&setTimeout(function(){return Sn.current()},50)})})}},[u.DEVIATION_BADGE_SEPARATOR]),fo=i.useCallback(function(){var e,n=Mn.sectionIdx,i=Mn.isOrphan;if(zn(),null!=n){var t="left";Mn.anchorEl&&(null===(e=Tn.current)||void 0===e?void 0:e.contains(Mn.anchorEl))&&(t="right"),st(n),ci&&(sn(ao(n)),Qe(new Set([n]))),Zi(n,i,{sourceSide:t,onReady:function(){ci&&setTimeout(function(){return co(String(n))},150)}})}},[Zi,Mn.isOrphan,Mn.sectionIdx,Mn.anchorEl,zn,st,ci,co,ao]),vo=i.useCallback(function(){zn(),Qi(),Qe(new Set),nn([]),mn.current=[]},[zn,Qi]),go=null!==Mn.sectionIdx&&$e.has(Mn.sectionIdx),po=S.useDeviationNavigation({proposedSections:vi,existingSections:gi,parentDeviationRecord:hi,expandedSections:it,maintainRelativeOrder:!!Me,scrollContainerRef:En,leftContainerRef:On,rightContainerRef:Tn,lhsBadgeRefs:Ti,rhsBadgeRefs:wi}),ho=po.showDeviationNavigation,mo=po.showOpenNodeRef,So=po.adjustScrollForPopup,Ro=i.useCallback(function(e,n,i,t,o){var r,l="string"==typeof t?u.safeStringify(t).trim():u.safeStringify(null==t?void 0:t.deviation_summary).trim(),s=e.currentTarget;Xn();var a="left";(null===(r=Tn.current)||void 0===r?void 0:r.contains(s))&&(a="right");var c=function(){var e,i,t,o;if("string"==typeof n&&n.includes(u.DEVIATION_BADGE_SEPARATOR)){var r=n.split(u.DEVIATION_BADGE_SEPARATOR),l="".concat(r[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(r[1]);return"right"===a?null===(e=wi.current[l])||void 0===e?void 0:e.current:null===(i=Ti.current[l])||void 0===i?void 0:i.current}return"right"===a?null===(t=wi.current[n])||void 0===t?void 0:t.current:null===(o=Ti.current[n])||void 0===o?void 0:o.current};if(i&&!ci)return Qi(),Qe(new Set),nn([]),mn.current=[],void(l&&(st(n),requestAnimationFrame(function(){var e=c()||s;e&&(e.getBoundingClientRect().top>.8*window.innerHeight&&e.scrollIntoView({behavior:"smooth",block:"center"}));Wn({open:!0,anchorEl:e,summary:t,displayImpact:o})})));st(n),ci&&(sn(ao(n)),Qe(new Set([n]))),l?setTimeout(function(){Zi(n,i,{toggleIfSame:!1,sourceSide:a,onReady:function(){var e,i,r,l=c()||s;if(ci)setTimeout(function(){return co(n)},150);else if(l){var u=l.getBoundingClientRect();if(u.top>.8*window.innerHeight||u.top<100){var a=u.top-window.innerHeight/2;Me?(null===(e=On.current)||void 0===e||e.scrollBy({top:a,behavior:"smooth"}),null===(i=Tn.current)||void 0===i||i.scrollBy({top:a,behavior:"smooth"})):null===(r=En.current)||void 0===r||r.scrollBy({top:a,behavior:"smooth"})}}Wn({open:!0,anchorEl:l,summary:t,displayImpact:o})}})},350):setTimeout(function(){Zi(n,i,{toggleIfSame:!1,sourceSide:a}),ci&&setTimeout(function(){return co(n)},150)},350)},[Zi,Xn,Wn,Qi,st,ci,Me,co,bn]),xo=i.useMemo(function(){var e;if(!we)return null;var n=null===(e=null==we?void 0:we.id)||void 0===e?void 0:e.split(":")[0];for(var i in hi){if((hi[i]||[]).some(function(e){return e.id===n}))return i}return null},[we,hi]),_o=i.useRef({id:null,triggerMs:null}),bo=i.useRef(null);i.useEffect(function(){if(null==we?void 0:we.id){var n=Number(we.trigger),i=_o.current;if((null==i?void 0:i.id)!==we.id||(null==i?void 0:i.triggerMs)!==n){if(we.id.includes(":")&&/:\d+$/.test(we.id)){var t=we.id.split(":"),o=t[0],r=t[1],l=null!=r?r:"0",s="".concat(we.id,":").concat(n);bo.current!==s&&(zn(),Xn(),Qi(),Qe(new Set),nn([]),mn.current=[],bo.current=s);var a=!1,c=0,d=null,f=null,v=!1,g=function(e,n){for(var i=function(e,t){if(!e)return null;if(n.includes(e.id)||n.includes(e.nodeId)||n.includes(e.contentId))return t;if(!Array.isArray(e.subsections))return null;for(var o=0;o<e.subsections.length;o++){var r=i(e.subsections[o],"".concat(t,"-").concat(o));if(r)return r}return null},t=0;t<e.length;t++){var o=i(e[t],String(t));if(o)return o}return null},p=function(){var i,t,r;if(!a){var s=function(){_o.current={id:we.id,triggerMs:n}},h=null,m=null;for(var S in hi){var R=hi[S].find(function(e){var n;return e.id===o||e.nodeId===o||e.contentId===o||(null===(n=e.evaluationResult)||void 0===n?void 0:n.nodeId)===o});if(R){h=S,m=R;break}}if(m&&h){var x=Array.from(new Set([o,m.id,m.nodeId,m.contentId,null===(i=m.evaluationResult)||void 0===i?void 0:i.nodeId].filter(Boolean))),_=vi.findIndex(function(e){return e.id===h}),b=gi.findIndex(function(e){return e.id===h}),y=-1===_&&-1!==b,C=g(vi,x),E=g(gi,x);if(C&&!E&&!y){var A=C.split("-"),T=Number(A[0]);if(Me){var w=null===(r=null===(t=vi[T])||void 0===t?void 0:t.refIndexes)||void 0===r?void 0:r[0],I=gi.findIndex(function(e){return e.selfIndex===w});-1!==I&&(T=I)}E=e.__spreadArray([T],A.slice(1),!0).join("-")}if(C||E){var B=C?Number(C.split("-")[0]):_,D=E?Number(E.split("-")[0]):b,O=D>=0?D:E?Number(E.split("-")[0]):-1,F=vi[B],j=gi[O],P=F&&!F.title&&!F.content,k=j&&!j.title&&!j.content,N=y||(!C&&!!E||P&&!k);if(N){if(!(Me?!!Fo.current["right-".concat(D)]:!!Fo.current[String(D)])&&D>=0)return ut(D,"right"),void(d=setTimeout(p,200))}else if(!(Me?!!Fo.current["left-".concat(B)]:!!Fo.current[String(B)])&&B>=0)return ut(B,"left"),void(d=setTimeout(p,200));var M=C||"",L=E||"",q=x.map(function(e){return"".concat(e).concat(u.DEVIATION_BADGE_SEPARATOR).concat(l)}),H=q[0],G=function(){for(var e,n,i=0,t=q;i<t.length;i++){var o=t[i],r=(null===(e=Ti.current[o])||void 0===e?void 0:e.current)||null,l=(null===(n=wi.current[o])||void 0===n?void 0:n.current)||null;if(r||l)return{refId:o,left:r,right:l}}return{refId:H,left:null,right:null}},V=function(e){return"".concat(e).concat(u.DEVIATION_BADGE_SEPARATOR).concat(M).concat(u.DEVIATION_BADGE_SEPARATOR).concat(L)};if(!v){st(V(H)),v=!0,c=0;var W=function(){var e=G(),n=e.left,i=e.right;return N||!n&&!!i?i:n};return null==f||f(),void(d=setTimeout(function(){var e,n,i,t,o,r,l,u;a||(e=W,n=function(){a||(f=null,p())},t=0,o=null,r=null,l=performance.now(),u=function(){if(!a)if(performance.now()-l>3e3)n();else{var s=e();if(s&&0!==s.getBoundingClientRect().height){var c=s.getBoundingClientRect(),d=c.top,f=c.height,v=null!==o&&Math.abs(d-o)<.5,g=null!==r&&Math.abs(f-r)<.5;if(v&&g){if(++t>=5)return void n()}else t=0;o=d,r=f,i=requestAnimationFrame(u)}else i=requestAnimationFrame(u)}},i=requestAnimationFrame(u),f=function(){return cancelAnimationFrame(i)})},300))}var z=G(),K=z.refId,U=z.left,Y=z.right,J=V(K);if(U||Y){var X=N||!U&&!!Y,$=X?Y:U,Q=Me?X?Tn.current:On.current:En.current;if($&&Q){var Z=$.getBoundingClientRect();if(0!==Z.height){var ee=Q.getBoundingClientRect(),ne=Z.top-ee.top+Q.scrollTop-ee.height/2+Z.height/2,ie=(null==C?void 0:C.includes("-"))||(null==E?void 0:E.includes("-")),te=function(){return e.__awaiter(void 0,void 0,void 0,function(){var n,i,t,o,r,c,d,f,v,g;return e.__generator(this,function(p){switch(p.label){case 0:return a?[2]:(s(),n=$ instanceof Element?window.getComputedStyle($).color:"",[U,Y].forEach(function(e){e&&(e.style.transition="box-shadow 300ms ease-in-out",e.style.boxShadow="0 0 10px ".concat(n))}),setTimeout(function(){[U,Y].forEach(function(e){e&&(e.style.boxShadow="")})},2e3),i=(null===(d=null===(c=m.evaluationResult)||void 0===c?void 0:c.deviations)||void 0===d?void 0:d[l])||m,t=(null===(f=m.evaluationResult)||void 0===f?void 0:f.evaluation_outputs)||m.evaluation_outputs,!!U&&!!Y||ci?(r=function(e,n){return Promise.race([e,new Promise(function(e){return setTimeout(e,n)})])},Me?[4,Promise.all([On.current?r(u.waitForScrollIdle(On.current),600):Promise.resolve(),Tn.current?r(u.waitForScrollIdle(Tn.current),600):Promise.resolve()])]:[3,2]):(o=X?(null===(v=wi.current[ie?K:D])||void 0===v?void 0:v.current)||Y:(null===(g=Ti.current[ie?K:B])||void 0===g?void 0:g.current)||U,So(o,function(){Wn({open:!0,anchorEl:o,displayImpact:we.displayImpact,summary:e.__assign(e.__assign({},i),{evaluation_outputs:t})})},{skipScroll:!0}),null==Ie||Ie(),[2]));case 1:p.sent(),p.label=2;case 2:return ci&&(sn(ao(J)),Qe(new Set([J]))),et.current(J,!1,{toggleIfSame:!1,sourceSide:y?"right":"left",onReady:function(){var n,t,o,r;s();var l=X?(null===(n=wi.current[K])||void 0===n?void 0:n.current)||Y:(null===(t=Ti.current[K])||void 0===t?void 0:t.current)||U;if(ci)setTimeout(function(){return co(J)},150);else{var u=(null===(o=Ti.current[K])||void 0===o?void 0:o.current)||U,a=(null===(r=wi.current[K])||void 0===r?void 0:r.current)||Y;u&&(u.style.scrollMarginTop="150px",u.scrollIntoView({behavior:"smooth",block:"start"})),a&&(a.style.scrollMarginTop="150px",a.scrollIntoView({behavior:"smooth",block:"start"}))}Wn({open:!0,anchorEl:l,displayImpact:we.displayImpact,summary:e.__assign({},i)}),null==Ie||Ie()}}),[2]}})})};Math.abs(Q.scrollTop-ne)<=2?te():u.scrollAndWait(Q,ne,te)}else++c<30&&(d=setTimeout(p,100))}else++c<30&&(d=setTimeout(p,100))}else++c<30&&(d=setTimeout(p,100))}else++c<30&&(d=setTimeout(p,100))}else++c<30&&(d=setTimeout(p,100))}};return d=setTimeout(p,100),function(){a=!0,d&&clearTimeout(d),null==f||f()}}_o.current={id:we.id,triggerMs:n},Ht(we.id);var h=vi.findIndex(function(e){return e.id===we.id}),m=gi.findIndex(function(e){return e.id===we.id});-1===h&&-1===m||setTimeout(function(){var e=-1!==h?h:m,n=-1===h;ci&&sn(ao(e)),Qe(new Set([e])),et.current(e,n,{sourceSide:n?"right":"left",onReady:function(){ci&&setTimeout(function(){return co(String(e))},150)}})},400)}}},[null==we?void 0:we.id,null==we?void 0:we.trigger,null==we?void 0:we.displayImpact,hi,vi,gi,Me,Wn,Ht,ci,ao,co]),i.useEffect(function(){var n,i,t;if(Vn.open){var o=Vn.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(Ti.current)||r(wi.current);if(l){var u=(null===(i=wi.current[l])||void 0===i?void 0:i.current)||(null===(t=Ti.current[l])||void 0===t?void 0:t.current);u&&u.isConnected&&Wn(function(n){return e.__assign(e.__assign({},n),{anchorEl:u})})}}}},[Vn.open,Vn.anchorEl,on,$e,it]);var yo=kn.open,Co=kn.sectionIdx,Eo=kn.isOrphan,Ao=kn.badgeStyle,To=kn.anchorEl,wo=kn.sectionAnchorEl;i.useEffect(function(){var n;if(ye.isStreamingEnabled&&yo&&null!=Co&&Co!==pt){var i="string"==typeof Co?Co.split(u.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 u=t(l.subsections,n);if(u)return u}}return null},o=i&&"string"==typeof i?t(vi,i):null,r=i&&"string"==typeof i?t(gi,i):null,l="number"==typeof Co?vi[Co]||null:o||i&&((null===(n=null==he?void 0:he.nodes)||void 0===n?void 0:n[i])||(null==he?void 0:he[i]))||null,s="number"==typeof Co?gi[Co]||null:r,a=Nt(To,l,s,Co,Eo,Ao);Nn(function(n){return n.open?u.safeStringify(n.cognitiveData)===u.safeStringify(a.cognitiveData)&&u.safeStringify(n.deviationData)===u.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})}},[yo,Co,Eo,Ao,To,wo,vi,gi,Nt]);var Io=i.useCallback(function(e){var i=e.section,t=e.keyPath,o=e.depth,r=void 0===o?0:o,l=e.columnKey,u=void 0===l?"left":l,s=e.parentNodeId,a=void 0===s?"":s,c=e.sectionOffset,d=e.rhsOrphanVisualIndexes;return n.jsx(x.default,{section:i,keyPath:t,depth:r,columnKey:u,parentNodeId:a,sectionOffset:c,rhsOrphanVisualIndexes:d})},[]),Bo=i.useMemo(function(){return vi.map(function(e,i){var t,o,r=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),l=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return r&&l&&Me?null:n.jsx(_.default,{section:e,idx:i},null!==(o=null!==(t=null==e?void 0:e.layoutKey)&&void 0!==t?t:null==e?void 0:e.id)&&void 0!==o?o:"left-row-".concat(i))})},[vi,Me]),Do=i.useMemo(function(){return gi.map(function(e,i){var t,o,r=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),l=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return r&&l&&Me?null:n.jsx(b.default,{section:e,idx:i},null!==(o=null!==(t=null==e?void 0:e.layoutKey)&&void 0!==t?t:null==e?void 0:e.id)&&void 0!==o?o:"right-row-".concat(i))})},[gi,Me]),Oo=i.useRef(Mt);i.useEffect(function(){Oo.current=Mt},[Mt]);var Fo=i.useRef(it);i.useEffect(function(){Fo.current=it},[it]);var jo=i.useRef(Ro);i.useEffect(function(){jo.current=Ro},[Ro]);var Po=i.useRef(vo);i.useEffect(function(){Po.current=vo},[vo]);var ko=i.useRef(ut);i.useEffect(function(){ko.current=ut},[ut]);var No=i.useRef(lt);i.useEffect(function(){No.current=lt},[lt]);var Mo=i.useRef(Io);i.useEffect(function(){Mo.current=Io},[Io]);var Lo=i.useRef(Qi);i.useEffect(function(){Lo.current=Qi},[Qi]);var qo=i.useMemo(function(){return{isGuidelineMode:ci,maintainRelativeOrder:!!Me,showDeviationBadges:Ge,isProposingFix:De,proposingFixNodeId:Oe,isRedlineFlow:Fe,isSideBySide:Ni,activeSideBySideSection:Vi,scrollSyncLocked:on,toggleScrollSyncLocked:ct,summaryPopupAnchorEl:Vn.anchorEl,connectedSections:$e,proposedSections:vi,existingSections:gi,deviationNumberRegistry:mi,deviationParentRegistry:Si,treeData:he,displayConfig:ye,resolvedMarkdownStyles:Cn,unifiedNumbering:dt,expandedSections:it,expandedSubSections:ot,setExpandedSubSections:rt,getSectionCompareStyle:Kt,getSubSectionCompareStyle:Ut,getBadgeRef:Pi,getSectionRowRef:Fi,getSubSectionRef:ji,sectionLeftRefs:Ei,sectionRightRefs:Ai,sectionRowRefs:Oi,sectionRightRowRefs:Ii,subSectionLeftRefs:Bi,subSectionRightRefs:Di,lhsBadgeRefs:Ti,rhsBadgeRefs:wi,openMoreFunctionsPopup:bt,handleOpenSummaryPopup:yt,openSummaryPopup:yt,handleCloseSummaryPopup:Ct,toggleSection:Et,handleSubSectionToggle:At,renderSubSectionAccordion:Tt,resetSideBySide:wt,setConnectedSections:Qe,setConnectedLines:nn,cachedConnectedPositions:mn,showDeviationNavigation:ho,showOpenNodeRef:mo,deviationNodeIdToView:null==we?void 0:we.id,deviationTargetParentId:xo,guidelinesData:Pe,gptWebCitationConfig:ke}},[ci,Me,Ge,De,Oe,Fe,Ni,Vi,on,ct,Vn.anchorEl,$e,vi,gi,mi,ye,Cn,dt,it,ot,rt,Kt,Ut,Pi,Fi,ji,ho,mo,we,xo,Pe,ke]),Ho=u.safeStringify(kn.sectionTitle||ri||ti),Go=u.safeStringify(ci?ui||si||kn.refSectionTitle:kn.refSectionTitle||ui||si);return n.jsx(C.CompareContextProvider,e.__assign({value:qo},{children:n.jsxs(t.Box,e.__assign({ref:An,sx:{display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif',overflow:"visible",position:"relative"}},{children:[We&&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,{})})),Vn.open&&n.jsx(y.default,{open:Vn.open,anchorEl:Vn.anchorEl,containerEl:Vt.current,clipTopEl:dn.current,scrollContainerEl:En.current,onClose:vo,summary:Vn.summary,displayImpact:Vn.displayImpact,isScrollLocked:on}),n.jsx(d.default,{open:Mn.open,anchorEl:Mn.anchorEl,maintainRelativeOrder:!!Me,sectionTitle:Mn.sectionTitle,referenceSectionTitle:Mn.refSectionTitle,onClose:$n,onOpenCognitiveCompare:Yn,onOpenSideBySide:fo,onConnect:Lt,isConnected:go,isOrphan:!ci&&!!Mn.isOrphan,isGuidelineMode:ci,hasGuidelineMatches:Mn.hasGuidelineMatches}),kn.open&&n.jsx(c.default,{open:kn.open,popupRef:Un,position:qn,popupConfig:Ee,onClose:function(){Hn(null),Nn(function(n){return e.__assign(e.__assign({},n),{open:!1})}),Kn(null)},markdownStyles:xe,sectionTitle:Ho,referenceSectionTitle:Go,cognitiveData:kn.cognitiveData,anchorEl:kn.anchorEl,sectionAnchorEl:kn.sectionAnchorEl,scrollContainerEl:En.current,badgeStyle:kn.badgeStyle,docData:kn.docData,deviationData:kn.deviationData,isLoading:kn.isLoading}),n.jsx(t.Snackbar,e.__assign({open:!!Ue,autoHideDuration:8e3,onClose:function(){return Ye(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(t.Alert,e.__assign({onClose:function(){return Ye(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:Ue}))})),n.jsx(R.default,{componentHeaderText:pe,displayConfig:ye,maintainRelativeOrder:Me,onCollapseAll:io,showCollapseAll:to,onToggleView:function(e){ze(!0),setTimeout(function(){Le(!e),null==Ce||Ce(!e),rn(!1),Qi(),zn(),Qe(new Set),nn([]),mn.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){ze(!1)},600)})})},50)}}),n.jsx(t.Box,e.__assign({ref:En,onScroll:no,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:Me?"visible":"auto",borderTop:vt&&gt?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(t.Box,e.__assign({sx:e.__assign({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},Me?{flex:1}:{})},{children:n.jsxs(t.Box,e.__assign({ref:cn,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"100px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},Me?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(I.default,{svgContainerRef:an,svgDimensions:eo,isResizing:qi,overallConnector:Qt,rootDeviationStyle:St,lines:Xt,isSideBySide:Ni,activeSideBySideSection:Vi,isArrowVisible:Mi,maintainRelativeOrder:Me,proposedSections:vi,existingSections:gi,cognitivePopup:kn,activeBadgeId:Gn,closeCognitivePopup:Xn,setActiveBadgeId:Kn,openCognitivePopupFromState:Jn,buildSectionPopupState:Nt,connectedLines:en,isGuidelineMode:ci,pathRefs:hn}),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)"},Me?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(t.Box,e.__assign({ref:dn,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:ti,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:ti}))}))})),n.jsxs(t.Box,e.__assign({ref:On,onScroll:no,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},Me?{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:Bn,style:{width:"100%",height:"0px",flexShrink:0}}),xi&&Bo,n.jsx("div",{ref:Dn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),n.jsx(t.Box,e.__assign({ref:Vt,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:n.jsx(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(),kn.open&&Gn===pt?Xn():(Kn(pt),Jn(Nt(n.currentTarget,{title:Ft,content:"",evaluationResult:ht,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,pt,!0,e.__assign(e.__assign({},St),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:St.badgeBg,color:St.badgeText,border:"1px solid ".concat(St.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=mt?mt: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:kn.open&&Gn===pt?"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},Me?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[Gi&&n.jsx(l.default,{sections:11}),n.jsx(t.Box,e.__assign({ref:fn,sx:e.__assign({p:"8px",bgcolor:ci?"#F1F3F5":"#F7F8FA",borderBottom:"1px solid #D7DCE2",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center"},Me?e.__assign({maxHeight:"calc(100vh - 250px)",overflowY:"auto",overflowX:"hidden",minHeight:0},ci?{"&::-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:ci?n.jsxs(t.Tabs,e.__assign({value:un,onChange:function(e,n){return sn(n)},variant:"fullWidth",TabIndicatorProps:{sx:{display:"none"}},sx:{width:"100%",minHeight:"36px","& .MuiTab-root":{minHeight:"36px",px:1,py:0,borderRadius:"8px",fontSize:"14px",lineHeight:1,fontWeight:500,textTransform:"none",color:"#374151",minWidth:0,transition:"background-color 160ms ease, box-shadow 160ms ease"},"& .Mui-selected":{color:"#374151",bgcolor:"#FFFFFF"}}},{children:[n.jsx(t.Tab,{label:n.jsx(t.Tooltip,e.__assign({title:si,placement:"top"},{children:n.jsx(t.Box,e.__assign({component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block",width:"100%"}},{children:"Redline Guidelines"}))}))}),n.jsx(t.Tab,{label:n.jsx(t.Tooltip,e.__assign({title:"Web & GPT Sources",placement:"top"},{children:n.jsx(t.Box,e.__assign({component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block",width:"100%"}},{children:"Web & GPT Sources"}))}))})]})):n.jsx(t.Tooltip,e.__assign({title:si,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:si}))}))})),n.jsxs(t.Box,e.__assign({ref:Tn,onScroll:no,sx:e.__assign({p:ci?"0px":"12px",display:"flex",flexDirection:"column"},Me?e.__assign(e.__assign({maxHeight:"calc(100vh - 250px)"},!ci&&{flex:1}),{overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-150px",pl:"165px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}):{})},{children:[n.jsx("div",{ref:wn,style:{width:"100%",height:"0px",flexShrink:0}}),ci?0===un?n.jsx(B.default,{guidelinesData:Pe,deviationData:Te,connectedSections:$e,proposedSections:vi}):n.jsx(D.default,{deviationData:Te,connectedSections:$e,proposedSections:vi}):xi&&Do,n.jsx("div",{ref:In,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"),u=require("./CognitiveComparehelpers.js"),s=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"),T=require("./hooks/useLinesCalculator.js"),w=require("./hooks/useSideBySide.js"),I=require("./components/SvgConnectors.js"),B=require("./Guidelines/components/GuidelinePanel.js"),D=require("./Guidelines/components/WebGptPanel.js");exports.SHARED_MARKDOWN_STYLES=s.SHARED_MARKDOWN_STYLES,exports.default=function(O){var F,j,P,k,N,M,L,q,H,G,V,W,z,K,U,Y,J,X,$,Q,Z,ee,ne,ie,te,oe,re,le,ue,se,ae,ce,de,fe,ve,ge=O.componentHeaderText,pe=void 0===ge?a.DEFAULT_COMPONENT_HEADER_TEXT:ge,he=O.treeData,me=O.comparisonConfig,Se=O.leftColumnTitleText,Re=O.rightColumnTitleText,xe=O.markdownStyles,_e=O.resetTrigger,be=O.displayConfig,ye=void 0===be?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1,displayEmailNotifier:!0,isStreamingEnabled:!1}:be,Ce=O.onMaintainRelativeOrderChange,Ee=O.popupConfig,Ae=O.deviationData,Te=void 0===Ae?{}:Ae,we=O.deviationNodeIdToView,Ie=O.resetDeviationNodeId,Be=O.isProposingFix,De=void 0!==Be&&Be,Oe=O.proposingFixNodeId,Fe=O.isRedlineFlow,je=O.badgeStyleOverride,Pe=O.guidelinesData,ke=O.gptWebCitationConfig,Ne=i.useState(ye.maintainRelativeOrder),Me=Ne[0],Le=Ne[1],qe=null!==(F=null==ye?void 0:ye.expandLevels)&&void 0!==F?F:0,He=!!(null==ye?void 0:ye.expandAllSections),Ge=!!Me||!!(null==ye?void 0:ye.showDeviationBadges),Ve=i.useState(!1),We=Ve[0],ze=Ve[1],Ke=i.useState(null),Ue=Ke[0],Ye=Ke[1],Je=i.useState(null===(P=null!==(j=null==he?void 0:he.newEvaluationResult)&&void 0!==j?j:null==ye?void 0:ye.enableDeviationSchemaBackwardCompatibility)||void 0===P||P)[0],Xe=i.useState(new Set),$e=Xe[0],Qe=Xe[1],Ze=i.useState([]),en=Ze[0],nn=Ze[1],tn=i.useState(!1),on=tn[0],rn=tn[1],ln=i.useState(0),un=ln[0],sn=ln[1],an=i.useRef(null),cn=i.useRef(null),dn=i.useRef(null),fn=i.useRef(null),vn=i.useRef(null),gn=i.useRef(!1),pn=i.useRef(null),hn=i.useRef({}),mn=i.useRef([]),Sn=i.useRef(function(){}),Rn=i.useRef(null),xn=i.useRef(function(){}),_n=i.useMemo(function(){return JSON.stringify(Te||{})},[JSON.stringify(Te)]),bn=i.useMemo(function(){return Te||{}},[_n]),yn=i.useMemo(function(){return(null==he?void 0:he.cognitive_decisioning)||{}},[he]),Cn=i.useMemo(function(){return e.__assign(e.__assign({},s.SHARED_MARKDOWN_STYLES),xe)},[xe]),En=i.useRef(null),An=i.useRef(null),Tn=i.useRef(null),wn=i.useRef(null),In=i.useRef(null),Bn=i.useRef(null),Dn=i.useRef(null),On=i.useRef(null),Fn=i.useRef(null),jn=i.useRef(null),Pn=p.useComparePopups(En),kn=Pn.cognitivePopup,Nn=Pn.setCognitivePopup,Mn=Pn.moreFunctions,Ln=Pn.setMoreFunctions,qn=Pn.position,Hn=Pn.setPosition,Gn=Pn.activeBadgeId,Vn=Pn.summaryPopup,Wn=Pn.setSummaryPopup,zn=Pn.closeSummaryPopup,Kn=Pn.setActiveBadgeId,Un=Pn.popupRef,Yn=Pn.handleOpenCognitiveCompare,Jn=Pn.openCognitivePopupFromState,Xn=Pn.closeCognitivePopup,$n=Pn.closeMoreFunctionsPopup,Qn=i.useMemo(function(){var e,n,i,t,o,r,l;return{fields:null!==(e=null==me?void 0:me.fields)&&void 0!==e?e:s.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(i=null===(n=null==me?void 0:me.thresholds)||void 0===n?void 0:n.high)&&void 0!==i?i:s.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(o=null===(t=null==me?void 0:me.thresholds)||void 0===t?void 0:t.medium)&&void 0!==o?o:s.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(l=null===(r=null==me?void 0:me.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:s.DEFAULT_COMPARISON_CONFIG.thresholds.exact}}},[me]),Zn=i.useState(null),ei=Zn[0];Zn[1];var ni=null===(M=null===(k=null==he?void 0:he.documents)||void 0===k?void 0:k[null===(N=null==he?void 0:he.input_index_map)||void 0===N?void 0:N[0]])||void 0===M?void 0:M.title,ii=null===(H=null===(L=null==he?void 0:he.documents)||void 0===L?void 0:L[null===(q=null==he?void 0:he.input_index_map)||void 0===q?void 0:q[1]])||void 0===H?void 0:H.title,ti=u.safeStringify(Se||ni||"Uploaded Contract"),oi=null===(z=null===(W=null===(G=null==he?void 0:he.documents)||void 0===G?void 0:G[null===(V=null==he?void 0:he.input_index_map)||void 0===V?void 0:V[0]])||void 0===W?void 0:W.metadata)||void 0===z?void 0:z.file_name,ri=u.safeStringify(oi),li=null===(J=null===(Y=null===(K=null==he?void 0:he.documents)||void 0===K?void 0:K[null===(U=null==he?void 0:he.input_index_map)||void 0===U?void 0:U[1]])||void 0===Y?void 0:Y.metadata)||void 0===J?void 0:J.file_name,ui=u.safeStringify(li),si=u.safeStringify(Re||ii||"Reference Template"),ai=g.useCognitiveTreeData(he,Me,bn,Qn,Je,Pe),ci=ai.isGuidelineMode,di=ai.activeProposed,fi=ai.existingRule,vi=ai.proposedSections,gi=ai.existingSections,pi=ai.visibleFields,hi=ai.parentDeviationRecord,mi=ai.deviationNumberRegistry,Si=ai.deviationParentRegistry,Ri=ai.parseError;i.useEffect(function(){Ri&&Ye("Failed to load comparison: ".concat(Ri))},[Ri]);var xi=vi.length>0||gi.length>0,_i=i.useMemo(function(){if(!Fe)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)||"";u.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(vi),i(gi),"".concat(e,":").concat(n)},[Fe,vi,gi]);i.useEffect(function(){if(vi.length||gi.length)if(He){var e={},n={},i=function(i,t){i.forEach(function(i,o){var r,l=Me?"".concat(t,"-").concat(o):String(o);e[l]=!0;var u=function(e,i){null==e||e.forEach(function(e,t){var o,r="".concat(i,"-").concat(t);n[r]=!0,(null===(o=e.subsections)||void 0===o?void 0:o.length)&&u(e.subsections,r)})};(null===(r=i.subsections)||void 0===r?void 0:r.length)&&u(i.subsections,String(o))})};i(vi,"left"),i(gi,"right"),tt(e),rt(n)}else if(qe>0){var t={},o={},r=function(e,n,i){e.forEach(function(e,r){var l;if(i>=1){var u=Me?"".concat(n,"-").concat(r):String(r);t[u]=!0}var s=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)&&s(e.subsections,l,t+1)})};(null===(l=e.subsections)||void 0===l?void 0:l.length)&&i>=2&&s(e.subsections,String(r),2)})};r(vi,"left",qe),r(gi,"right",qe),tt(t),rt(o)}},[He,qe,vi,gi,Me]);var bi=h.useSectionRefs(pi.map(function(e){return e.key}),Math.max(vi.length,gi.length)),yi=bi.leftRefs,Ci=bi.rightRefs,Ei=bi.sectionLeftRefs,Ai=bi.sectionRightRefs,Ti=bi.lhsBadgeRefs,wi=bi.rhsBadgeRefs,Ii=bi.sectionRightRowRefs,Bi=bi.subSectionLeftRefs,Di=bi.subSectionRightRefs,Oi=bi.sectionRowRefs,Fi=bi.getSectionRowRef,ji=bi.getSubSectionRef,Pi=bi.getBadgeRef,ki=w.useSideBySide({isGuidelineMode:ci,maintainRelativeOrder:Me,proposedSections:vi,existingSections:gi,leftContainerRef:On,rightContainerRef:Tn,scrollContainerRef:En,sectionLeftRefs:Ei,sectionRightRefs:Ai,subSectionLeftRefs:Bi,subSectionRightRefs:Di,lhsBadgeRefs:Ti,rhsBadgeRefs:wi,sectionRowRefs:Oi,sectionRightRowRefs:Ii,rhsTopSpacerRef:wn,rhsBottomSpacerRef:In,lhsTopSpacerRef:Bn,lhsBottomSpacerRef:Dn,calculateLinesRef:Sn,setConnectedSections:Qe,setConnectedLines:nn,cachedConnectedPositions:mn,closeMoreFunctionsPopup:$n,setErrorToast:Ye,moreFunctions:Mn,closeSummaryPopup:zn}),Ni=ki.isSideBySide,Mi=ki.isArrowVisible,Li=ki.setIsArrowVisible,qi=ki.isResizing,Hi=ki.setIsResizing,Gi=ki.isSideBySideLoading,Vi=ki.activeSideBySideSection,Wi=ki.scrollLock,zi=ki.sideBySideCacheRef,Ki=ki.isSideBySideRef,Ui=ki.activeSideBySideRightSectionRef,Yi=ki.activeSideBySideSectionRef,Ji=ki.sideBySideLineRef,Xi=ki.highlightedClauseRefs,$i=ki.clearClauseHighlight,Qi=ki.resetSideBySide,Zi=ki.activateSideBySide,et=i.useRef(Zi);i.useEffect(function(){et.current=Zi},[Zi]);var nt=m.useAccordionState({maintainRelativeOrder:!!Me,proposedSections:vi,existingSections:gi,activeSideBySideSection:Vi,connectedSections:$e,resetSideBySide:Qi,setConnectedSections:Qe,setConnectedLines:nn,cachedConnectedPositions:mn,svgContainerRef:an,isAnimatingRef:gn,animationTimerRef:pn,calculateLinesRef:Sn,sectionLeftRefs:Ei,sectionRightRefs:Ai,subSectionLeftRefs:Bi,subSectionRightRefs:Di}),it=nt.expandedSections,tt=nt.setExpandedSections,ot=nt.expandedSubSections,rt=nt.setExpandedSubSections,lt=nt.handleSubSectionToggle,ut=nt.toggleSection,st=nt.forceExpandCrossWiredSections,at=function(){var e,n;if(null!=Vi){var i=null===(e=Ei.current[Vi])||void 0===e?void 0:e.current,t=null===(n=Ai.current[Vi])||void 0===n?void 0:n.current,o=Tn.current;if(i&&t&&o){var r=i.getBoundingClientRect(),l=t.getBoundingClientRect(),u=o.getBoundingClientRect(),s=r.top-u.top,a=l.top-u.top-s;o.scrollBy({top:a,behavior:"smooth"})}}},ct=i.useCallback(function(e){null==e||e.stopPropagation(),rn(function(e){var n=!e;return n&&requestAnimationFrame(function(){at()}),n})},[at]);i.useEffect(function(){Fe&&"off"!==_i&&"0:0"!==_i&&(zi.current=null,mn.current=[],requestAnimationFrame(function(){var e;null===(e=Sn.current)||void 0===e||e.call(Sn)}))},[Fe,_i]);var dt=i.useMemo(function(){var e=new Map,n=new Map,i=1;if(Me)vi.forEach(function(n){!n.title&&!n.content||n.id&&e.set(n.id,i++)}),gi.forEach(function(t){if(t.id&&!(!t.title&&!t.content)){var o=vi.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(vi.length,gi.length),o=0;o<t;o++){var r=vi[o],l=gi[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}},[vi,gi,Me]),ft=fi.analysis,vt=u.safeStringify(null===($=null===(X=null==ft?void 0:ft.rule_difference_comparison)||void 0===X?void 0:X.summary)||void 0===$?void 0:$.overall_summary),gt=!!vt.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),pt=null!==(Q=null==he?void 0:he.base_root_id)&&void 0!==Q?Q:"-1";null==he||he[pt];var ht=Je?null!==(ce=null!==(ue=Te&&(null===(le=null==Te?void 0:Te[pt])||void 0===le?void 0:le.evaluation_result))&&void 0!==ue?ue:null===(ae=null===(se=null==he?void 0:he.nodes)||void 0===se?void 0:se[pt])||void 0===ae?void 0:ae.evaluation_result)&&void 0!==ce?ce:null:null!==(re=null!==(ne=Te&&(null===(ee=null===(Z=null==Te?void 0:Te[pt])||void 0===Z?void 0:Z.evaluation_result)||void 0===ee?void 0:ee[0]))&&void 0!==ne?ne:null===(oe=null===(te=null===(ie=null==he?void 0:he.nodes)||void 0===ie?void 0:ie[pt])||void 0===te?void 0:te.evaluation_result)||void 0===oe?void 0:oe[0])&&void 0!==re?re:null,mt=u.extractDeviationScore(ht),St=u.generateColorPalette(null!==(ve=null===(fe=null===(de=null==ht?void 0:ht.evaluation_outputs)||void 0===de?void 0:de.metadata)||void 0===fe?void 0:fe.label_color)&&void 0!==ve?ve:a.DEFAULT_DEVIAION_COLOR);if(je){var Rt=je(mt);Rt&&(St=e.__assign(e.__assign({},St),{badgeBg:Rt.bg,badgeText:Rt.text,badgeBorder:Rt.border}))}var xt=i.useRef(Qi);i.useEffect(function(){xt.current=Qi},[Qi]);var _t=i.useRef(Xn);i.useEffect(function(){_t.current=Xn},[Xn]);var bt=i.useCallback(function(e,n,i,t,o,r){return Fo.current(e,n,i,t,o,r)},[]),yt=i.useCallback(function(e,n,i,t,o){return Po.current(e,n,i,t,o)},[]),Ct=i.useCallback(function(){return ko.current()},[]),Et=i.useCallback(function(e,n){return No.current(e,n)},[]),At=i.useCallback(function(e){return Mo.current(e)},[]),Tt=i.useCallback(function(e){return Lo.current(e)},[]),wt=i.useCallback(function(){return qo.current()},[]),It=i.useCallback(function(){var e,n;$i(),null===(e=xt.current)||void 0===e||e.call(xt),rn(!1),Qe(new Set),nn([]),mn.current=[],Qt([]),eo(null),Wn(a.EMPTY_SUMMARY_POPUP_STATE),null===(n=_t.current)||void 0===n||n.call(_t),requestAnimationFrame(function(){var e;null===(e=Sn.current)||void 0===e||e.call(Sn)})},[]),Bt=i.useRef(It);i.useEffect(function(){Bt.current=It},[It]),i.useEffect(function(){_e&&Bt.current()},[_e]);var Dt=i.useMemo(function(){return{documents:null==he?void 0:he.documents,input_index_map:null==he?void 0:he.input_index_map}},[JSON.stringify(null==he?void 0:he.documents),JSON.stringify(null==he?void 0:he.input_index_map)]),Ot=i.useState(""),Ft=Ot[0],jt=Ot[1],Pt=u.safeStringify(ii),kt=i.useRef(he);i.useEffect(function(){var e,n,i;kt.current=he;var t=null===(e=null==he?void 0:he.input_index_map)||void 0===e?void 0:e[0],o=null===(i=null===(n=null==he?void 0:he.documents)||void 0===n?void 0:n[t])||void 0===i?void 0:i.title;jt(o)},[he]);var Nt=i.useRef(yn);i.useEffect(function(){Nt.current=yn},[yn]);var Mt=i.useCallback(function(n,i,t,o,r,l,s){var a,c,d,f,v,g,p,h,m,S,R=u.safeStringify(null==i?void 0:i.id)||u.safeStringify(null==t?void 0:t.id)||"",x=(R?null===(a=Nt.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=Oi.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,s=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(u.DEVIATION_BADGE_SEPARATOR)))return s(l);var a=o.split(u.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)}):s(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,C=null!==(S=null==ye?void 0:ye.isLoading)&&void 0!==S&&S,E=!0;if(ci){var A=null==b?void 0:b.deviation_highlights;if(A&&"object"==typeof A)E=Object.values(A).some(function(e){return Array.isArray(e)&&e.length>0});else E=!1}return{isLoading:C&&!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:Dt,deviationData:b,isOrphan:!!r,hasGuidelineMatches:E}},[Dt,null==ye?void 0:ye.isLoading,ci]),Lt=i.useCallback(function(e,n,i,t,o,r){var l;if(e.stopPropagation(),Mn.open&&Mn.sectionIdx===o)$n();else{var s=e.currentTarget,a="left";(null===(l=Tn.current)||void 0===l?void 0:l.contains(s))&&(a="right");$i(),Ki.current&&Qi(),Qe(new Set),nn([]),mn.current=[],Xn(),Vn.open?go():zn(),requestAnimationFrame(function(){var e=function(){var e,n,i,t;if("string"==typeof o&&o.includes(u.DEVIATION_BADGE_SEPARATOR)){var r=o.split(u.DEVIATION_BADGE_SEPARATOR),l="".concat(r[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(r[1]);return"right"===a?null===(e=wi.current[l])||void 0===e?void 0:e.current:null===(n=Ti.current[l])||void 0===n?void 0:n.current}return"right"===a?null===(i=wi.current[o])||void 0===i?void 0:i.current:null===(t=Ti.current[o])||void 0===t?void 0:t.current}()||s;Ln(Mt(e,n,t,o,i,r))})}},[Mn.open,Mn.sectionIdx,$n,zn,Mt]),qt=i.useCallback(function(){var e=Mn.sectionIdx;Mn.isOrphan,$n(),zn(),null!==e&&(st(e),$i(),Ki.current&&Qi(),nn([]),mn.current=[],ci&&null!==e&&sn(co(e)),Qe(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){Sn.current&&Sn.current()},50))},[Mn.sectionIdx,Mn.isOrphan,$n,zn,Qi]),Ht=i.useCallback(function(){var e=vn.current;if(e){vn.current=null;var n=vi.findIndex(function(n){return n.id===e}),i=gi.findIndex(function(n){return n.id===e}),t=-1===n?u.findKeyPathByNodeId(vi,e):null,o=-1===i?u.findKeyPathByNodeId(gi,e):null,r=-1!==n?n:t?Number(t.split("-")[0]):-1,l=-1!==i?i:o?Number(o.split("-")[0]):-1,s=function(e,n,i,t){var o,r,l,u;return-1!==e?null!==(r=null===(o=i.current[e])||void 0===o?void 0:o.current)&&void 0!==r?r:null:n&&null!==(u=null===(l=t.current[n])||void 0===l?void 0:l.current)&&void 0!==u?u:null},a=function(e,n,i){void 0===i&&(i=30);var t=0,o=function(){var r=e();r&&0!==r.getBoundingClientRect().height?(Xi.current.add(r),u.scrollAndHighlightClause(r,n)):t++<i&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(Me)-1!==r&&On.current&&a(function(){return s(n,t,Ei,Bi)},On.current),-1!==l&&Tn.current&&a(function(){return s(i,o,Ai,Di)},Tn.current);else{var c=En.current;if(!c)return;a(function(){return-1!==r?s(n,t,Ei,Bi):s(i,o,Ai,Di)},c)}}},[vi,gi,Me,Ei,Ai,Bi,Di,On,Tn,En]),Gt=i.useCallback(function(n){if(n){$i(),Qi(),Qe(new Set),nn([]),mn.current=[],zn(),Xn();var i=vi.findIndex(function(e){return e.id===n}),t=gi.findIndex(function(e){return e.id===n}),o=-1===i?u.findKeyPathByNodeId(vi,n):null,r=-1===t?u.findKeyPathByNodeId(gi,n):null;if(-1!==i||o||-1!==t||r){var l=-1!==i?i:o?Number(o.split("-")[0]):-1,s=-1!==t?t:r?Number(r.split("-")[0]):-1;vn.current=n,tt(function(n){var i,t=e.__assign({},n),o=!1;-1!==l&&(t[i=Me?"left-".concat(l):String(l)]||(t[i]=!0,o=!0));-1!==s&&(t[i=Me?"right-".concat(s):String(s)]||(t[i]=!0,o=!0));return o?t:n}),rt(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(){vn.current===n&&Vt.current()})},50)}else console.warn('scrollToAndHighlightClause: nodeId "'.concat(n,'" not found'))}},[vi,gi,Me,tt,rt,Qi,zn,Xn]),Vt=i.useRef(Ht);i.useEffect(function(){Vt.current=Ht},[Ht]);var Wt=i.useRef(null);i.useEffect(function(){if(ei){var e=Qn.fields.find(function(e){return e.analysisKey===ei||e.key===ei});if(e){var n=yi.current[e.key]||Ci.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[ei,Qn.fields]);var zt=i.useCallback(function(e){var n,i,t,o,r,l,u,s,a,c=null===(n=null==ft?void 0:ft.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===(u=v.highlights)||void 0===u?void 0:u.ruleB_spans)||[],hasContent:!!f}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(s=d.highlights)||void 0===s?void 0:s.ruleA_spans)||[],highlightsB:(null===(a=d.highlights)||void 0===a?void 0:a.ruleB_spans)||[],hasContent:!!f}},[ft]),Kt=E.useStyleHelpers({proposedSections:vi,existingSections:gi,maintainRelativeOrder:Me,cognitiveMap:yn,deviationData:bn,treeData:he,resolvedComparisonConfig:Qn,badgeStyleOverride:je}),Ut=Kt.getSectionCompareStyle,Yt=Kt.getSubSectionCompareStyle,Jt=Kt.getDeviationStyleByKey,Xt=T.useLinesCalculator({containerRef:cn,leftContainerRef:On,rightContainerRef:Tn,svgContainerRef:an,pathRefs:hn,leftHeaderRef:dn,rightHeaderRef:fn,proposedSections:vi,existingSections:gi,visibleFields:pi,leftRefs:yi,rightRefs:Ci,sectionLeftRefs:Ei,sectionRightRefs:Ai,subSectionLeftRefs:Bi,subSectionRightRefs:Di,lhsBadgeRefs:Ti,rhsBadgeRefs:wi,sectionRowRefs:Oi,expandedSections:it,expandedSubSections:ot,connectedSections:$e,isSideBySide:Ni,activeSideBySideSection:Vi,maintainRelativeOrder:Me,isGuidelineMode:ci,cognitiveMap:yn,getSectionCompareStyle:Ut,getSubSectionCompareStyle:Yt,getDeviationStyleByKey:Jt,isArrowVisible:Mi,isAnimatingRef:gn,isSideBySideRef:Ki,sideBySideCacheRef:zi,sideBySideLineRef:Ji,activeSideBySideSectionRef:Yi,activeSideBySideRightSectionRef:Ui,connectedLines:en,setConnectedLines:nn,cachedConnectedPositions:mn,calculateLinesRef:Sn,resizeTimerRef:Rn,scrollLock:Wi,scrollSyncLocked:on,handleResizeRef:xn,activeProposed:di,existingRule:fi,analysisData:ft,pendingScrollTargetRef:Fn,pendingScrollCallbackRef:jn,resolvedComparisonConfig:Qn,getFieldData:zt}),$t=Xt.lines,Qt=Xt.setLines,Zt=Xt.overallConnector,eo=Xt.setOverallConnector,no=Xt.svgDimensions,io=Xt.handleColumnScroll;i.useEffect(function(){Vn.anchorEl&&requestAnimationFrame(function(){requestAnimationFrame(function(){var e;null===(e=Sn.current)||void 0===e||e.call(Sn)})})},[Vn.anchorEl,on]);var to=i.useCallback(function(){$i(),rn(!1),tt({}),rt({}),Qi(),Qe(new Set),nn([]),mn.current=[],zn(),Xn(),$n(),requestAnimationFrame(function(){Sn.current&&Sn.current()})},[tt,rt,Qi,zn,Xn,$n]);i.useEffect(function(){Ni||0!==$e.size||rn(!1)},[Ni,$e]);var oo=i.useMemo(function(){return Object.values(it).some(Boolean)||Object.values(ot).some(Boolean)},[it,ot]),ro=i.useRef(null),lo=i.useRef(0),uo=i.useRef(0),so=i.useRef(0),ao=A.useResizeHandler({timerRef:ro,ruleComponentRef:An,scrollContainerRef:En,containerRef:cn,maintainRelativeOrder:Me,proposedSections:vi,existingSections:gi,isSideBySideRef:Ki,activeSideBySideSectionRef:Yi,activeSideBySideRightSectionRef:Ui,sectionRowRefs:Oi,sectionRightRowRefs:Ii,sectionLeftRefs:Ei,sectionRightRefs:Ai,subSectionLeftRefs:Bi,subSectionRightRefs:Di,lhsBadgeRefs:Ti,rhsBadgeRefs:wi,leftContainerRef:On,rightContainerRef:Tn,calculateLinesRef:Sn,handleResizeRef:xn,setIsResizing:Hi,setIsArrowVisible:Li,sideBySideCacheRef:zi,cachedConnectedPositions:mn}).handleResize;i.useEffect(function(){xn.current=ao},[ao,xn]),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,u;i.current=null;var s=e[e.length-1];if(s){var a=null!==(u=null===(l=null===(r=s.borderBoxSize)||void 0===r?void 0:r[0])||void 0===l?void 0:l.inlineSize)&&void 0!==u?u:s.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 An.current&&o.push(e(An.current,lo,n,function(){return xn.current()},function(){})),En.current&&o.push(e(En.current,uo,i,function(){return xn.current()},function(){return Sn.current()})),cn.current&&o.push(e(cn.current,so,t,function(){return xn.current()},function(){return Sn.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(){Ki.current=Ni},[Ni]),i.useEffect(function(){Yi.current=Vi},[Vi]);var co=i.useCallback(function(e){var n,i,t,o,r,l="",s="0";if("number"==typeof e)l=(null===(n=vi[e])||void 0===n?void 0:n.nodeId)||(null===(i=vi[e])||void 0===i?void 0:i.id)||"";else{var a=String(e).split(u.DEVIATION_BADGE_SEPARATOR);l=a[0],s=a[1]||"0"}var c=null===(t=null==bn?void 0:bn[l])||void 0===t?void 0:t.evaluation_result,d=Array.isArray(c)?c[parseInt(s,10)]:null==c?void 0:c[s];return!1===(null===(r=null===(o=null==d?void 0:d.evaluation_outputs)||void 0===o?void 0:o.guideline_flag)||void 0===r?void 0:r.rulebook_used)?1:0},[vi,bn]),fo=i.useCallback(function(e){var n,i,t=document.querySelectorAll('[id^="guideline-target-"], [data-web-gpt-active="true"]'),o=On.current,r=Tn.current,l="string"==typeof e&&e.includes(u.DEVIATION_BADGE_SEPARATOR),s=e;if(l){var a=e.split(u.DEVIATION_BADGE_SEPARATOR);a.length>=2&&(s="".concat(a[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(a[1]))}var c=(null===(n=Ti.current[s])||void 0===n?void 0:n.current)||(null===(i=Ti.current[e])||void 0===i?void 0:i.current);if(t.length>0&&c&&o&&r){var d=t[0];Bn.current&&(Bn.current.style.height="0px"),wn.current&&(wn.current.style.height="0px"),Dn.current&&(Dn.current.style.height="0px"),In.current&&(In.current.style.height="0px"),requestAnimationFrame(function(){var e=c.getBoundingClientRect(),n=d.getBoundingClientRect(),i=o.getBoundingClientRect(),t=r.getBoundingClientRect(),l=o.scrollTop+(e.top-i.top)+e.height/2,u=r.scrollTop+(n.top-t.top)+n.height/2,s=l-i.height/2,a=Math.max(0,s),f=o.scrollHeight-o.clientHeight,v=a>f?a-f:0,g=i.top+l-a,p=t.top+u-g,h=0;p<0&&(h=Math.abs(p),p=0);var m=r.scrollHeight-r.clientHeight+h,S=p>m?p-m:0;Dn.current&&(Dn.current.style.height="".concat(v,"px")),wn.current&&(wn.current.style.height="".concat(h,"px")),In.current&&(In.current.style.height="".concat(S,"px")),requestAnimationFrame(function(){o.scrollTo({top:a,behavior:"smooth"}),r.scrollTo({top:p,behavior:"smooth"}),Sn.current&&setTimeout(function(){return Sn.current()},50)})})}},[u.DEVIATION_BADGE_SEPARATOR]),vo=i.useCallback(function(){var e,n=Mn.sectionIdx,i=Mn.isOrphan;if(zn(),null!=n){var t="left";Mn.anchorEl&&(null===(e=Tn.current)||void 0===e?void 0:e.contains(Mn.anchorEl))&&(t="right"),st(n),ci&&(sn(co(n)),Qe(new Set([n]))),Zi(n,i,{sourceSide:t,onReady:function(){ci&&setTimeout(function(){return fo(String(n))},150)}})}},[Zi,Mn.isOrphan,Mn.sectionIdx,Mn.anchorEl,zn,st,ci,fo,co]),go=i.useCallback(function(){zn(),Qi(),Qe(new Set),nn([]),mn.current=[]},[zn,Qi]),po=null!==Mn.sectionIdx&&$e.has(Mn.sectionIdx),ho=S.useDeviationNavigation({proposedSections:vi,existingSections:gi,parentDeviationRecord:hi,expandedSections:it,maintainRelativeOrder:!!Me,scrollContainerRef:En,leftContainerRef:On,rightContainerRef:Tn,lhsBadgeRefs:Ti,rhsBadgeRefs:wi}),mo=ho.showDeviationNavigation,So=ho.showOpenNodeRef,Ro=ho.adjustScrollForPopup,xo=i.useCallback(function(e,n,i,t,o){var r,l="string"==typeof t?u.safeStringify(t).trim():u.safeStringify(null==t?void 0:t.deviation_summary).trim(),s=e.currentTarget;Xn();var a="left";(null===(r=Tn.current)||void 0===r?void 0:r.contains(s))&&(a="right");var c=function(){var e,i,t,o;if("string"==typeof n&&n.includes(u.DEVIATION_BADGE_SEPARATOR)){var r=n.split(u.DEVIATION_BADGE_SEPARATOR),l="".concat(r[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(r[1]);return"right"===a?null===(e=wi.current[l])||void 0===e?void 0:e.current:null===(i=Ti.current[l])||void 0===i?void 0:i.current}return"right"===a?null===(t=wi.current[n])||void 0===t?void 0:t.current:null===(o=Ti.current[n])||void 0===o?void 0:o.current};if(i&&!ci)return Qi(),Qe(new Set),nn([]),mn.current=[],void(l&&(st(n),requestAnimationFrame(function(){var e=c()||s;e&&(e.getBoundingClientRect().top>.8*window.innerHeight&&e.scrollIntoView({behavior:"smooth",block:"center"}));Wn({open:!0,anchorEl:e,summary:t,displayImpact:o})})));st(n),ci&&(sn(co(n)),Qe(new Set([n]))),l?setTimeout(function(){Zi(n,i,{toggleIfSame:!1,sourceSide:a,onReady:function(){var e,i,r,l=c()||s;if(ci)setTimeout(function(){return fo(n)},150);else if(l){var u=l.getBoundingClientRect();if(u.top>.8*window.innerHeight||u.top<100){var a=u.top-window.innerHeight/2;Me?(null===(e=On.current)||void 0===e||e.scrollBy({top:a,behavior:"smooth"}),null===(i=Tn.current)||void 0===i||i.scrollBy({top:a,behavior:"smooth"})):null===(r=En.current)||void 0===r||r.scrollBy({top:a,behavior:"smooth"})}}Wn({open:!0,anchorEl:l,summary:t,displayImpact:o})}})},350):setTimeout(function(){Zi(n,i,{toggleIfSame:!1,sourceSide:a}),ci&&setTimeout(function(){return fo(n)},150)},350)},[Zi,Xn,Wn,Qi,st,ci,Me,fo,bn]),_o=i.useMemo(function(){var e;if(!we)return null;var n=null===(e=null==we?void 0:we.id)||void 0===e?void 0:e.split(":")[0];for(var i in hi){if((hi[i]||[]).some(function(e){return e.id===n}))return i}return null},[we,hi]),bo=i.useRef({id:null,triggerMs:null}),yo=i.useRef(null);i.useEffect(function(){if(null==we?void 0:we.id){var n=Number(we.trigger),i=bo.current;if((null==i?void 0:i.id)!==we.id||(null==i?void 0:i.triggerMs)!==n){if(we.id.includes(":")&&/:\d+$/.test(we.id)){var t=we.id.split(":"),o=t[0],r=t[1],l=null!=r?r:"0",s="".concat(we.id,":").concat(n);yo.current!==s&&(zn(),Xn(),Qi(),Qe(new Set),nn([]),mn.current=[],yo.current=s);var a=!1,c=0,d=null,f=null,v=!1,g=function(e,n){for(var i=function(e,t){if(!e)return null;if(n.includes(e.id)||n.includes(e.nodeId)||n.includes(e.contentId))return t;if(!Array.isArray(e.subsections))return null;for(var o=0;o<e.subsections.length;o++){var r=i(e.subsections[o],"".concat(t,"-").concat(o));if(r)return r}return null},t=0;t<e.length;t++){var o=i(e[t],String(t));if(o)return o}return null},p=function(){var i,t,r;if(!a){var s=function(){bo.current={id:we.id,triggerMs:n}},h=null,m=null;for(var S in hi){var R=hi[S].find(function(e){var n;return e.id===o||e.nodeId===o||e.contentId===o||(null===(n=e.evaluationResult)||void 0===n?void 0:n.nodeId)===o});if(R){h=S,m=R;break}}if(m&&h){var x=Array.from(new Set([o,m.id,m.nodeId,m.contentId,null===(i=m.evaluationResult)||void 0===i?void 0:i.nodeId].filter(Boolean))),_=vi.findIndex(function(e){return e.id===h}),b=gi.findIndex(function(e){return e.id===h}),y=-1===_&&-1!==b,C=g(vi,x),E=g(gi,x);if(C&&!E&&!y){var A=C.split("-"),T=Number(A[0]);if(Me){var w=null===(r=null===(t=vi[T])||void 0===t?void 0:t.refIndexes)||void 0===r?void 0:r[0],I=gi.findIndex(function(e){return e.selfIndex===w});-1!==I&&(T=I)}E=e.__spreadArray([T],A.slice(1),!0).join("-")}if(C||E){var B=C?Number(C.split("-")[0]):_,D=E?Number(E.split("-")[0]):b,O=D>=0?D:E?Number(E.split("-")[0]):-1,F=vi[B],j=gi[O],P=F&&!F.title&&!F.content,k=j&&!j.title&&!j.content,N=y||(!C&&!!E||P&&!k);if(N){if(!(Me?!!jo.current["right-".concat(D)]:!!jo.current[String(D)])&&D>=0)return ut(D,"right"),void(d=setTimeout(p,200))}else if(!(Me?!!jo.current["left-".concat(B)]:!!jo.current[String(B)])&&B>=0)return ut(B,"left"),void(d=setTimeout(p,200));var M=C||"",L=E||"",q=x.map(function(e){return"".concat(e).concat(u.DEVIATION_BADGE_SEPARATOR).concat(l)}),H=q[0],G=function(){for(var e,n,i=0,t=q;i<t.length;i++){var o=t[i],r=(null===(e=Ti.current[o])||void 0===e?void 0:e.current)||null,l=(null===(n=wi.current[o])||void 0===n?void 0:n.current)||null;if(r||l)return{refId:o,left:r,right:l}}return{refId:H,left:null,right:null}},V=function(e){return"".concat(e).concat(u.DEVIATION_BADGE_SEPARATOR).concat(M).concat(u.DEVIATION_BADGE_SEPARATOR).concat(L)};if(!v){st(V(H)),v=!0,c=0;var W=function(){var e=G(),n=e.left,i=e.right;return N||!n&&!!i?i:n};return null==f||f(),void(d=setTimeout(function(){var e,n,i,t,o,r,l,u;a||(e=W,n=function(){a||(f=null,p())},t=0,o=null,r=null,l=performance.now(),u=function(){if(!a)if(performance.now()-l>3e3)n();else{var s=e();if(s&&0!==s.getBoundingClientRect().height){var c=s.getBoundingClientRect(),d=c.top,f=c.height,v=null!==o&&Math.abs(d-o)<.5,g=null!==r&&Math.abs(f-r)<.5;if(v&&g){if(++t>=5)return void n()}else t=0;o=d,r=f,i=requestAnimationFrame(u)}else i=requestAnimationFrame(u)}},i=requestAnimationFrame(u),f=function(){return cancelAnimationFrame(i)})},300))}var z=G(),K=z.refId,U=z.left,Y=z.right,J=V(K);if(U||Y){var X=N||!U&&!!Y,$=X?Y:U,Q=Me?X?Tn.current:On.current:En.current;if($&&Q){var Z=$.getBoundingClientRect();if(0!==Z.height){var ee=Q.getBoundingClientRect(),ne=Z.top-ee.top+Q.scrollTop-ee.height/2+Z.height/2,ie=(null==C?void 0:C.includes("-"))||(null==E?void 0:E.includes("-")),te=function(){return e.__awaiter(void 0,void 0,void 0,function(){var n,i,t,o,r,c,d,f,v,g;return e.__generator(this,function(p){switch(p.label){case 0:return a?[2]:(s(),n=$ instanceof Element?window.getComputedStyle($).color:"",[U,Y].forEach(function(e){e&&(e.style.transition="box-shadow 300ms ease-in-out",e.style.boxShadow="0 0 10px ".concat(n))}),setTimeout(function(){[U,Y].forEach(function(e){e&&(e.style.boxShadow="")})},2e3),i=(null===(d=null===(c=m.evaluationResult)||void 0===c?void 0:c.deviations)||void 0===d?void 0:d[l])||m,t=(null===(f=m.evaluationResult)||void 0===f?void 0:f.evaluation_outputs)||m.evaluation_outputs,!!U&&!!Y||ci?(r=function(e,n){return Promise.race([e,new Promise(function(e){return setTimeout(e,n)})])},Me?[4,Promise.all([On.current?r(u.waitForScrollIdle(On.current),600):Promise.resolve(),Tn.current?r(u.waitForScrollIdle(Tn.current),600):Promise.resolve()])]:[3,2]):(o=X?(null===(v=wi.current[ie?K:D])||void 0===v?void 0:v.current)||Y:(null===(g=Ti.current[ie?K:B])||void 0===g?void 0:g.current)||U,Ro(o,function(){Wn({open:!0,anchorEl:o,displayImpact:we.displayImpact,summary:e.__assign(e.__assign({},i),{evaluation_outputs:t})})},{skipScroll:!0}),null==Ie||Ie(),[2]));case 1:p.sent(),p.label=2;case 2:return ci&&(sn(co(J)),Qe(new Set([J]))),et.current(J,!1,{toggleIfSame:!1,sourceSide:y?"right":"left",onReady:function(){var n,t,o,r;s();var l=X?(null===(n=wi.current[K])||void 0===n?void 0:n.current)||Y:(null===(t=Ti.current[K])||void 0===t?void 0:t.current)||U;if(ci)setTimeout(function(){return fo(J)},150);else{var u=(null===(o=Ti.current[K])||void 0===o?void 0:o.current)||U,a=(null===(r=wi.current[K])||void 0===r?void 0:r.current)||Y;u&&(u.style.scrollMarginTop="150px",u.scrollIntoView({behavior:"smooth",block:"start"})),a&&(a.style.scrollMarginTop="150px",a.scrollIntoView({behavior:"smooth",block:"start"}))}Wn({open:!0,anchorEl:l,displayImpact:we.displayImpact,summary:e.__assign({},i)}),null==Ie||Ie()}}),[2]}})})};Math.abs(Q.scrollTop-ne)<=2?te():u.scrollAndWait(Q,ne,te)}else++c<30&&(d=setTimeout(p,100))}else++c<30&&(d=setTimeout(p,100))}else++c<30&&(d=setTimeout(p,100))}else++c<30&&(d=setTimeout(p,100))}else++c<30&&(d=setTimeout(p,100))}};return d=setTimeout(p,100),function(){a=!0,d&&clearTimeout(d),null==f||f()}}bo.current={id:we.id,triggerMs:n},Gt(we.id);var h=vi.findIndex(function(e){return e.id===we.id}),m=gi.findIndex(function(e){return e.id===we.id});-1===h&&-1===m||setTimeout(function(){var e=-1!==h?h:m,n=-1===h;ci&&sn(co(e)),Qe(new Set([e])),et.current(e,n,{sourceSide:n?"right":"left",onReady:function(){ci&&setTimeout(function(){return fo(String(e))},150)}})},400)}}},[null==we?void 0:we.id,null==we?void 0:we.trigger,null==we?void 0:we.displayImpact,hi,vi,gi,Me,Wn,Gt,ci,co,fo]),i.useEffect(function(){var n,i,t;if(Vn.open){var o=Vn.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(Ti.current)||r(wi.current);if(l){var u=(null===(i=wi.current[l])||void 0===i?void 0:i.current)||(null===(t=Ti.current[l])||void 0===t?void 0:t.current);u&&u.isConnected&&Wn(function(n){return e.__assign(e.__assign({},n),{anchorEl:u})})}}}},[Vn.open,Vn.anchorEl,on,$e,it]);var Co=kn.open,Eo=kn.sectionIdx,Ao=kn.isOrphan,To=kn.badgeStyle,wo=kn.anchorEl,Io=kn.sectionAnchorEl;i.useEffect(function(){var n;if(ye.isStreamingEnabled&&Co&&null!=Eo&&Eo!==pt){var i="string"==typeof Eo?Eo.split(u.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 u=t(l.subsections,n);if(u)return u}}return null},o=i&&"string"==typeof i?t(vi,i):null,r=i&&"string"==typeof i?t(gi,i):null,l="number"==typeof Eo?vi[Eo]||null:o||i&&((null===(n=null==he?void 0:he.nodes)||void 0===n?void 0:n[i])||(null==he?void 0:he[i]))||null,s="number"==typeof Eo?gi[Eo]||null:r,a=Mt(wo,l,s,Eo,Ao,To);Nn(function(n){return n.open?u.safeStringify(n.cognitiveData)===u.safeStringify(a.cognitiveData)&&u.safeStringify(n.deviationData)===u.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})}},[Co,Eo,Ao,To,wo,Io,vi,gi,Mt]);var Bo=i.useCallback(function(e){var i=e.section,t=e.keyPath,o=e.depth,r=void 0===o?0:o,l=e.columnKey,u=void 0===l?"left":l,s=e.parentNodeId,a=void 0===s?"":s,c=e.sectionOffset,d=e.rhsOrphanVisualIndexes;return n.jsx(x.default,{section:i,keyPath:t,depth:r,columnKey:u,parentNodeId:a,sectionOffset:c,rhsOrphanVisualIndexes:d})},[]),Do=i.useMemo(function(){return vi.map(function(e,i){var t,o,r=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),l=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return r&&l&&Me?null:n.jsx(_.default,{section:e,idx:i},null!==(o=null!==(t=null==e?void 0:e.layoutKey)&&void 0!==t?t:null==e?void 0:e.id)&&void 0!==o?o:"left-row-".concat(i))})},[vi,Me]),Oo=i.useMemo(function(){return gi.map(function(e,i){var t,o,r=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),l=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return r&&l&&Me?null:n.jsx(b.default,{section:e,idx:i},null!==(o=null!==(t=null==e?void 0:e.layoutKey)&&void 0!==t?t:null==e?void 0:e.id)&&void 0!==o?o:"right-row-".concat(i))})},[gi,Me]),Fo=i.useRef(Lt);i.useEffect(function(){Fo.current=Lt},[Lt]);var jo=i.useRef(it);i.useEffect(function(){jo.current=it},[it]);var Po=i.useRef(xo);i.useEffect(function(){Po.current=xo},[xo]);var ko=i.useRef(go);i.useEffect(function(){ko.current=go},[go]);var No=i.useRef(ut);i.useEffect(function(){No.current=ut},[ut]);var Mo=i.useRef(lt);i.useEffect(function(){Mo.current=lt},[lt]);var Lo=i.useRef(Bo);i.useEffect(function(){Lo.current=Bo},[Bo]);var qo=i.useRef(Qi);i.useEffect(function(){qo.current=Qi},[Qi]);var Ho=i.useMemo(function(){return{isGuidelineMode:ci,maintainRelativeOrder:!!Me,showDeviationBadges:Ge,isProposingFix:De,proposingFixNodeId:Oe,isRedlineFlow:Fe,isSideBySide:Ni,activeSideBySideSection:Vi,scrollSyncLocked:on,toggleScrollSyncLocked:ct,summaryPopupAnchorEl:Vn.anchorEl,connectedSections:$e,proposedSections:vi,existingSections:gi,deviationNumberRegistry:mi,deviationParentRegistry:Si,treeData:he,displayConfig:ye,resolvedMarkdownStyles:Cn,unifiedNumbering:dt,expandedSections:it,expandedSubSections:ot,setExpandedSubSections:rt,getSectionCompareStyle:Ut,getSubSectionCompareStyle:Yt,getBadgeRef:Pi,getSectionRowRef:Fi,getSubSectionRef:ji,sectionLeftRefs:Ei,sectionRightRefs:Ai,sectionRowRefs:Oi,sectionRightRowRefs:Ii,subSectionLeftRefs:Bi,subSectionRightRefs:Di,lhsBadgeRefs:Ti,rhsBadgeRefs:wi,openMoreFunctionsPopup:bt,handleOpenSummaryPopup:yt,openSummaryPopup:yt,handleCloseSummaryPopup:Ct,toggleSection:Et,handleSubSectionToggle:At,renderSubSectionAccordion:Tt,resetSideBySide:wt,setConnectedSections:Qe,setConnectedLines:nn,cachedConnectedPositions:mn,showDeviationNavigation:mo,showOpenNodeRef:So,deviationNodeIdToView:null==we?void 0:we.id,deviationTargetParentId:_o,guidelinesData:Pe,gptWebCitationConfig:ke}},[ci,Me,Ge,De,Oe,Fe,Ni,Vi,on,ct,Vn.anchorEl,$e,vi,gi,mi,ye,Cn,dt,it,ot,rt,Ut,Yt,Pi,Fi,ji,mo,So,we,_o,Pe,ke]),Go=u.safeStringify(kn.sectionTitle||ri||ti),Vo=u.safeStringify(ci?ui||si||kn.refSectionTitle:kn.refSectionTitle||ui||si);return n.jsx(C.CompareContextProvider,e.__assign({value:Ho},{children:n.jsxs(t.Box,e.__assign({ref:An,sx:{display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif',overflow:"visible",position:"relative"}},{children:[We&&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,{})})),Vn.open&&n.jsx(y.default,{open:Vn.open,anchorEl:Vn.anchorEl,containerEl:Wt.current,clipTopEl:dn.current,scrollContainerEl:En.current,onClose:go,summary:Vn.summary,displayImpact:Vn.displayImpact,isScrollLocked:on}),n.jsx(d.default,{open:Mn.open,anchorEl:Mn.anchorEl,maintainRelativeOrder:!!Me,sectionTitle:Mn.sectionTitle,referenceSectionTitle:Mn.refSectionTitle,onClose:$n,onOpenCognitiveCompare:Yn,onOpenSideBySide:vo,onConnect:qt,isConnected:po,isOrphan:!ci&&!!Mn.isOrphan,isGuidelineMode:ci,hasGuidelineMatches:Mn.hasGuidelineMatches}),kn.open&&n.jsx(c.default,{open:kn.open,popupRef:Un,position:qn,popupConfig:Ee,onClose:function(){Hn(null),Nn(function(n){return e.__assign(e.__assign({},n),{open:!1})}),Kn(null)},markdownStyles:xe,sectionTitle:Go,referenceSectionTitle:Vo,cognitiveData:kn.cognitiveData,anchorEl:kn.anchorEl,sectionAnchorEl:kn.sectionAnchorEl,scrollContainerEl:En.current,badgeStyle:kn.badgeStyle,docData:kn.docData,deviationData:kn.deviationData,isLoading:kn.isLoading}),n.jsx(t.Snackbar,e.__assign({open:!!Ue,autoHideDuration:8e3,onClose:function(){return Ye(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(t.Alert,e.__assign({onClose:function(){return Ye(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:Ue}))})),n.jsx(R.default,{componentHeaderText:pe,displayConfig:ye,maintainRelativeOrder:Me,onCollapseAll:to,showCollapseAll:oo,onToggleView:function(e){ze(!0),setTimeout(function(){Le(!e),null==Ce||Ce(!e),rn(!1),Qi(),zn(),Qe(new Set),nn([]),mn.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){ze(!1)},600)})})},50)}}),n.jsx(t.Box,e.__assign({ref:En,onScroll:io,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:Me?"visible":"auto",borderTop:vt&&gt?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(t.Box,e.__assign({sx:e.__assign({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},Me?{flex:1}:{})},{children:n.jsxs(t.Box,e.__assign({ref:cn,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"100px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},Me?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(I.default,{svgContainerRef:an,svgDimensions:no,isResizing:qi,overallConnector:Zt,rootDeviationStyle:St,lines:$t,isSideBySide:Ni,activeSideBySideSection:Vi,isArrowVisible:Mi,maintainRelativeOrder:Me,proposedSections:vi,existingSections:gi,cognitivePopup:kn,activeBadgeId:Gn,closeCognitivePopup:Xn,setActiveBadgeId:Kn,openCognitivePopupFromState:Jn,buildSectionPopupState:Mt,connectedLines:en,isGuidelineMode:ci,pathRefs:hn}),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)"},Me?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(t.Box,e.__assign({ref:dn,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:ti,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:ti}))}))})),n.jsxs(t.Box,e.__assign({ref:On,onScroll:io,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},Me?{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:Bn,style:{width:"100%",height:"0px",flexShrink:0}}),xi&&Do,n.jsx("div",{ref:Dn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),n.jsx(t.Box,e.__assign({ref:Wt,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(),kn.open&&Gn===pt?Xn():(Kn(pt),Jn(Mt(n.currentTarget,{title:Ft,content:"",evaluationResult:ht,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},{title:Pt,content:""},pt,!0,e.__assign(e.__assign({},St),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:St.badgeBg,color:St.badgeText,border:"1px solid ".concat(St.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=mt?mt: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:kn.open&&Gn===pt?"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},Me?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[Gi&&n.jsx(l.default,{sections:11}),n.jsx(t.Box,e.__assign({ref:fn,sx:e.__assign({p:"8px",bgcolor:ci?"#F1F3F5":"#F7F8FA",borderBottom:"1px solid #D7DCE2",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center"},Me?e.__assign({maxHeight:"calc(100vh - 250px)",overflowY:"auto",overflowX:"hidden",minHeight:0},ci?{"&::-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:ci?n.jsxs(t.Tabs,e.__assign({value:un,onChange:function(e,n){return sn(n)},variant:"fullWidth",TabIndicatorProps:{sx:{display:"none"}},sx:{width:"100%",minHeight:"36px","& .MuiTab-root":{minHeight:"36px",px:1,py:0,borderRadius:"8px",fontSize:"14px",lineHeight:1,fontWeight:500,textTransform:"none",color:"#374151",minWidth:0,transition:"background-color 160ms ease, box-shadow 160ms ease"},"& .Mui-selected":{color:"#374151",bgcolor:"#FFFFFF"}}},{children:[n.jsx(t.Tab,{label:n.jsx(t.Tooltip,e.__assign({title:si,placement:"top"},{children:n.jsx(t.Box,e.__assign({component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block",width:"100%"}},{children:"Redline Guidelines"}))}))}),n.jsx(t.Tab,{label:n.jsx(t.Tooltip,e.__assign({title:"Web & GPT Sources",placement:"top"},{children:n.jsx(t.Box,e.__assign({component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block",width:"100%"}},{children:"Web & GPT Sources"}))}))})]})):n.jsx(t.Tooltip,e.__assign({title:si,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:si}))}))})),n.jsxs(t.Box,e.__assign({ref:Tn,onScroll:io,sx:e.__assign({p:ci?"0px":"12px",display:"flex",flexDirection:"column"},Me?e.__assign(e.__assign({maxHeight:"calc(100vh - 250px)"},!ci&&{flex:1}),{overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-150px",pl:"165px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}):{})},{children:[n.jsx("div",{ref:wn,style:{width:"100%",height:"0px",flexShrink:0}}),ci?0===un?n.jsx(B.default,{guidelinesData:Pe,deviationData:Te,connectedSections:$e,proposedSections:vi}):n.jsx(D.default,{deviationData:Te,connectedSections:$e,proposedSections:vi}):xi&&Oo,n.jsx("div",{ref:In,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))}))};
2
2
  //# sourceMappingURL=CognitiveCompare.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("./CognitiveCompareConstants.js"),n=function(t){return null==t?"":"string"==typeof t?t:Array.isArray(t)?t.map(n).join("\n\n"):"object"==typeof t?JSON.stringify(t):String(t)},e=function(t){return null!=t&&("string"==typeof t?t.trim().length>0:!Array.isArray(t)||t.length>0&&t.some(function(t){return e(t)}))},o=function(t){for(var n=t+1,e="";n>0;){n-=1;e=String.fromCharCode(97+n%26)+e,n=Math.floor(n/26)}return e},r=function(t,n,e,o){var r;void 0===o&&(o={});var i=e[n],l=null===(r=null==t?void 0:t.comparison_inputs)||void 0===r?void 0:r[i];return l?(Array.isArray(l)?l:[l]).map(function(t,n){if(t&&"string"==typeof t&&t.trim()){var e=o[t];return e&&"object"==typeof e&&e?{contentId:t,data:e,attributes:e.additional_attributes||{}}:null}return t&&"object"==typeof t?{contentId:t.content_id||t.id||"".concat(i,"-direct-").concat(n),data:t,attributes:t.additional_attributes||{}}:null}).filter(Boolean):[]};var i=function(t){if(!t)return!0;var n=t.trim().toLowerCase();return n.includes("no equivalent")||"n/a"===n||"na"===n||"none"===n},l=function(t){var n;if("string"!=typeof t||!t)return!1;for(var e=/<(updated|deleted|changed|change)\b[^>]*>([\s\S]*?)<\/\1>/gi,o=null;null!==(o=e.exec(t));){if((null!==(n=o[2])&&void 0!==n?n:"").replace(/<[^>]*>/g,"").trim().length>0)return!0}return!1},u=function(t){return"string"==typeof t&&t?t.replace(/<\/?(updated|deleted|changed|change)\b[^>]*>/gi,""):""},a=["#B91C1C","#A16207","#1D4ED8","#000000"],s=function(t){var n=a.findIndex(function(n){return n.toLowerCase()===t.toLowerCase()});return-1===n?a.length:n},c=function(t,n,e){if(!t)return null;if(t.id===e||t.nodeId===e||t.contentId===e)return n;if(!Array.isArray(t.subsections))return null;for(var o=0;o<t.subsections.length;o++){var r=c(t.subsections[o],"".concat(n,"-").concat(o),e);if(r)return r}return null},d=new WeakMap,v=function(t){if(t){var n=d.get(t);null!=n&&(clearTimeout(n),d.delete(t)),t.style.transition="box-shadow 300ms ease-out, outline 300ms ease-out",requestAnimationFrame(function(){t.style.outline="",t.style.boxShadow=""}),window.setTimeout(function(){t.style.transition="",t.style.borderRadius=""},300)}},f=function(t){if(t){var n=d.get(t);null!=n&&clearTimeout(n),t.style.transition="box-shadow 300ms ease-in-out, outline 300ms ease-in-out",t.style.outline="2px solid #ff9494",t.style.borderRadius="6px",t.style.boxShadow="0 0 12px 2px rgba(244, 113, 113, 0.33)";var e=window.setTimeout(function(){v(t)},3e3);d.set(t,e)}};exports.DEVIATION_BADGE_SEPARATOR="::",exports.areMarkdownPropsEqual=function(t,n){var e,o,r,i,l,u;if(t.content!==n.content)return!1;if(t.overlayContent!==n.overlayContent)return!1;if(t.sxStyles!==n.sxStyles)return!1;if(t.maintainRelativeOrder!==n.maintainRelativeOrder)return!1;if(t.highlightBg!==n.highlightBg)return!1;if(t.suppressHighlightBg!==n.suppressHighlightBg)return!1;if(t.collisionKey!==n.collisionKey)return!1;var a=t.highlights||[],s=n.highlights||[];if(a.length!==s.length)return!1;for(var c=0;c<a.length;c++)if(a[c]!==s[c])return!1;var d=t.deviationBadges||[],v=n.deviationBadges||[];if(d.length!==v.length)return!1;for(c=0;c<d.length;c++){if(d[c].id!==v[c].id)return!1;if(d[c].actionId!==v[c].actionId)return!1;if(d[c].label!==v[c].label)return!1;if(d[c].score!==v[c].score)return!1;if(d[c].isOrphan!==v[c].isOrphan)return!1;if(d[c].isConnected!==v[c].isConnected)return!1;if(d[c].showScrollLockToggle!==v[c].showScrollLockToggle)return!1;if(d[c].scrollSyncLocked!==v[c].scrollSyncLocked)return!1;if((null===(e=d[c].style)||void 0===e?void 0:e.badgeBg)!==(null===(o=v[c].style)||void 0===o?void 0:o.badgeBg))return!1;if((null===(r=d[c].style)||void 0===r?void 0:r.badgeBorder)!==(null===(i=v[c].style)||void 0===i?void 0:i.badgeBorder))return!1;if((null===(l=d[c].style)||void 0===l?void 0:l.badgeText)!==(null===(u=v[c].style)||void 0===u?void 0:u.badgeText))return!1}return!0},exports.debounce=function(t,n){var e;return function(){for(var o=[],r=0;r<arguments.length;r++)o[r]=arguments[r];var i=this;clearTimeout(e),e=setTimeout(function(){return t.apply(i,o)},n)}},exports.extractDeviationScore=function(t,n){var e,o,r,i,l,u,a;if(!t)return n;var s=null!==(u=null!==(i=null!==(o=null===(e=t.evaluation_output)||void 0===e?void 0:e.output_score)&&void 0!==o?o:null===(r=t.evaluation_outputs)||void 0===r?void 0:r.output_score)&&void 0!==i?i:null===(l=t.evaluation_outputs)||void 0===l?void 0:l.output_value)&&void 0!==u?u:t.output_score;return null!==(a=null!=s?s:n)&&void 0!==a?a:""},exports.findKeyPathByNodeId=function(t,n){for(var e=0;e<t.length;e++){var o=c(t[e],String(e),n);if(o)return o}return null},exports.generateColorPalette=function(t){var n=function(t,n){var e=function(t){var n=function(t){return 4===t.length?"#"+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]:t}(t).replace("#",""),e=parseInt(n,16);return{r:e>>16&255,g:e>>8&255,b:255&e}}(t),o=e.r,r=e.g,i=e.b;return function(t,n,e){return"#"+[t,n,e].map(function(t){return t.toString(16).padStart(2,"0")}).join("").toUpperCase()}(Math.round(o+(255-o)*n),Math.round(r+(255-r)*n),Math.round(i+(255-i)*n))};return{bg:n(t,.8),border:n(t,.5),badgeBg:n(t,.8),badgeBorder:n(t,.5),badgeText:t.toUpperCase(),highlightBg:n(t,.8)}},exports.getAlphabeticSuffix=o,exports.getBentArrowPath=function(t,n,e,o,r){void 0===r&&(r=14);var i=t+.5*(e-t),l=o-n;if(Math.abs(l)<3)return"M ".concat(t," ").concat(n," H ").concat(e);var u=l>0?1:-1,a=Math.min(r,Math.abs(l)/2,Math.abs(i-t)/2,Math.abs(e-i)/2);return["M ".concat(t," ").concat(n),"H ".concat(i-a),"Q ".concat(i," ").concat(n," ").concat(i," ").concat(n+u*a),"V ".concat(o-u*a),"Q ".concat(i," ").concat(o," ").concat(i+a," ").concat(o),"H ".concat(e)].join(" ")},exports.getFirstDeviationColor=function(n){for(var e,o,r,i,l,u,a,c,d,v,f,p,g,h=[],b=0,m=Object.keys((null==n?void 0:n.deviations)||{}).sort(function(t,n){return Number(t)-Number(n)});b<m.length;b++){var y=m[b];(T=null===(i=null===(r=null===(o=null===(e=null==n?void 0:n.deviations)||void 0===e?void 0:e[y])||void 0===o?void 0:o.evaluation_outputs)||void 0===r?void 0:r.metadata)||void 0===i?void 0:i.label_color)&&h.push(T)}for(var x=0,_=Object.keys((null==n?void 0:n.deviation_entries)||{}).sort(function(t,n){return Number(t)-Number(n)});x<_.length;x++){y=_[x];(T=null===(c=null===(a=null===(u=null===(l=null==n?void 0:n.deviation_entries)||void 0===l?void 0:l[y])||void 0===u?void 0:u.evaluation_outputs)||void 0===a?void 0:a.metadata)||void 0===c?void 0:c.label_color)&&h.push(T)}for(var I=0,A=Object.keys(n||{}).filter(function(t){return/^\d+$/.test(t)}).sort(function(t,n){return Number(t)-Number(n)});I<A.length;I++){var T;y=A[I];(T=null===(f=null===(v=null===(d=null==n?void 0:n[y])||void 0===d?void 0:d.evaluation_outputs)||void 0===v?void 0:v.metadata)||void 0===f?void 0:f.label_color)&&h.push(T)}return 0===h.length?(null===(g=null===(p=null==n?void 0:n.evaluation_outputs)||void 0===p?void 0:p.metadata)||void 0===g?void 0:g.label_color)?n.evaluation_outputs.metadata.label_color:t.DEFAULT_DEVIAION_COLOR:h.sort(function(t,n){return s(t)-s(n)})[0]},exports.getFirstDeviationOutputValue=function(t){for(var n,e,o,r,i,l,u,a,s,c=0,d=Object.keys((null==t?void 0:t.deviations)||{}).sort(function(t,n){return Number(t)-Number(n)});c<d.length;c++){var v=d[c];if(b=null===(o=null===(e=null===(n=null==t?void 0:t.deviations)||void 0===n?void 0:n[v])||void 0===e?void 0:e.evaluation_outputs)||void 0===o?void 0:o.output_value)return b}for(var f=0,p=Object.keys((null==t?void 0:t.deviation_entries)||{}).sort(function(t,n){return Number(t)-Number(n)});f<p.length;f++){v=p[f];if(b=null===(l=null===(i=null===(r=null==t?void 0:t.deviation_entries)||void 0===r?void 0:r[v])||void 0===i?void 0:i.evaluation_outputs)||void 0===l?void 0:l.output_value)return b}for(var g=0,h=Object.keys(t||{}).filter(function(t){return/^\d+$/.test(t)}).sort(function(t,n){return Number(t)-Number(n)});g<h.length;g++){var b;v=h[g];if(b=null===(a=null===(u=null==t?void 0:t[v])||void 0===u?void 0:u.evaluation_outputs)||void 0===a?void 0:a.output_value)return b}return(null===(s=null==t?void 0:t.evaluation_outputs)||void 0===s?void 0:s.output_value)?t.evaluation_outputs.output_value:null},exports.getLhsDeviationDisplayIndexes=function(t,e,o){var r=new Map;if(!e)return r;var a=function(t){var e=l(t)?u(t):n(t||"");return n(e).replace(/\\n/g,"\n")};return(t||[]).forEach(function(t){var n=new Map,l=function(t){var r;if(t){var u=a(t.content);((null===(r=t.evaluationResults)||void 0===r?void 0:r.length)?t.evaluationResults:t.evaluationResult?[t.evaluationResult]:[]).forEach(function(r){var l=(null==r?void 0:r.nodeId)||t.nodeId||t.id;Object.entries((null==r?void 0:r.deviations)||{}).forEach(function(t){var r=t[0],s=t[1][e],c=a(s);if(c&&!i(s)&&u.includes(c)){var d="".concat(l).concat("::").concat(r),v=o[d];null!=v&&n.set(d,v)}})}),(t.subsections||[]).forEach(l)}};if(l(t),0!==n.size){var u=Math.min.apply(Math,Array.from(n.values()));n.forEach(function(t,n){r.set(n,t-u+1)})}}),r},exports.getRationale=function(t){if(!t.mapping_rationale)return{cognitiveData:{decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0,citations:[]},score:0,relation:"N/A"};var n=t.mapping_rationale,e=parseInt(n.decision_strength||"0");return{cognitiveData:{decisioning:n.decisioning_factors||[],gap:n.gaps_in_decision||[],relevance_score:e,citations:n.citations},score:0,relation:"N/A"}},exports.getRhsMappedSectionNumber=function(t){var n=t.section,e=t.proposedSections,r=t.leftNums,i=t.fallbackNumber,l=t.firstOnly,u=void 0!==l&&l;if(!(null==n?void 0:n.id))return i;var a=(e||[]).map(function(t){var e=Array.isArray(null==t?void 0:t.refIndexes)?t.refIndexes:[],i=e.findIndex(function(t){return t===n.selfIndex});if(-1===i)return null;var l=(null==t?void 0:t.id)?r.get(t.id):void 0;return null==l?null:e.length>1?"".concat(l).concat(o(i)):String(l)}).filter(Boolean);return 0===a.length?i:u?a[0]:a.join(", ")},exports.getSideData=function(t,e,o,i){var l,u,a;void 0===i&&(i={});var s=r(t,e,o,i),c=(null===(l=s[0])||void 0===l?void 0:l.data)||{},d=(null===(u=s[0])||void 0===u?void 0:u.attributes)||null;return{title:n((null==c?void 0:c.title)||""),content:n((null==c?void 0:c.content)||""),change_history:n((null==c?void 0:c.change_history)||""),attributes:d,subsections:(null==c?void 0:c.subsections)||[],contentId:null===(a=s[0])||void 0===a?void 0:a.contentId,allItems:s}},exports.hasMeaningfulRedlineTags=l,exports.hasSingleMappedLhsSection=function(t,n){return null!=(null==t?void 0:t.selfIndex)&&1===(n||[]).filter(function(n){return Array.isArray(null==n?void 0:n.refIndexes)&&n.refIndexes.includes(t.selfIndex)}).length},exports.hasValue=e,exports.highlightClause=f,exports.isMissingStr=i,exports.mixHexColors=function(t,n){var e=function(t){var n=t.replace("#","");return[parseInt(n.substring(0,2),16),parseInt(n.substring(2,4),16),parseInt(n.substring(4,6),16)]},o=function(t){var n=Math.round(t).toString(16);return 1===n.length?"0"+n:n};try{var r=e(t),i=e(n),l=(r[0]+i[0])/2*.95,u=(r[1]+i[1])/2*.95,a=(r[2]+i[2])/2*.95;return"#".concat(o(l)).concat(o(u)).concat(o(a))}catch(t){return"#FDE68A"}},exports.recursivelyFindSubSectionIdxById=c,exports.resetClauseHighlight=v,exports.resolveComparisonInputItems=r,exports.safeStringify=n,exports.scrollAndHighlightClause=function(t,n){var e=n.getBoundingClientRect(),o=t.getBoundingClientRect(),r=n.scrollTop+o.top-e.top-e.height/2+o.height/2;n.scrollTo({top:r,behavior:"smooth"});var i=function(){return f(t)};if("onscrollend"in n)n.addEventListener("scrollend",i,{once:!0});else{var l=n.scrollTop,u=function(){n.scrollTop===l?i():(l=n.scrollTop,requestAnimationFrame(u))};requestAnimationFrame(u)}},exports.scrollAndWait=function(t,n,e){if(Math.abs(t.scrollTop-n)<=2)e();else{var o,r=!1,i=function(){r||(r=!0,clearTimeout(o),t.removeEventListener("scrollend",l),e())},l=function(){return i()};t.addEventListener("scrollend",l),t.scrollTo({top:n,behavior:"smooth"}),o=setTimeout(i,800)}},exports.smoothScrollTo=function(t,n,e,o,r){void 0===e&&(e=300);var i=t.style.scrollBehavior;t.style.scrollBehavior="auto";var l=t.scrollTop,u=n-l,a=null,s=function(c){null===a&&(a=c);var d,v=c-a;v<e?(t.scrollTop=(d=v,d/=e,u*(--d*d*d+1)+l),r&&r(),requestAnimationFrame(s)):(t.scrollTop=n,t.style.scrollBehavior=i,r&&r(),o&&o())};requestAnimationFrame(s)},exports.stripRedlineTags=u,exports.waitForScrollIdle=function(t,n){return void 0===n&&(n=100),new Promise(function(e){var o,r=!1,i=function(){r||(r=!0,t.removeEventListener("scroll",l),e())},l=function(){clearTimeout(o),o=setTimeout(i,n)};t.addEventListener("scroll",l),o=setTimeout(i,n)})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("./CognitiveCompareConstants.js"),n=function(t){return null==t?"":"string"==typeof t?t:Array.isArray(t)?t.map(n).join("\n\n"):"object"==typeof t?JSON.stringify(t):String(t)},e=function(t){return null!=t&&("string"==typeof t?t.trim().length>0:!Array.isArray(t)||t.length>0&&t.some(function(t){return e(t)}))},o=function(t){for(var n=t+1,e="";n>0;){n-=1;e=String.fromCharCode(97+n%26)+e,n=Math.floor(n/26)}return e},r=function(t,n,e,o){var r;void 0===o&&(o={});var i=e[n],l=null===(r=null==t?void 0:t.comparison_inputs)||void 0===r?void 0:r[i];return l?(Array.isArray(l)?l:[l]).map(function(t,n){if(t&&"string"==typeof t&&t.trim()){var e=o[t];return e&&"object"==typeof e&&e?{contentId:t,data:e,attributes:e.additional_attributes||{}}:null}return t&&"object"==typeof t?{contentId:t.content_id||t.id||"".concat(i,"-direct-").concat(n),data:t,attributes:t.additional_attributes||{}}:null}).filter(Boolean):[]};var i=function(t){if(!t)return!0;var n=t.trim().toLowerCase();return n.includes("no equivalent")||"n/a"===n||"na"===n||"none"===n},l=function(t){var n;if("string"!=typeof t||!t)return!1;for(var e=/<(updated|deleted|changed|change)\b[^>]*>([\s\S]*?)<\/\1>/gi,o=null;null!==(o=e.exec(t));){if((null!==(n=o[2])&&void 0!==n?n:"").replace(/<[^>]*>/g,"").trim().length>0)return!0}return!1},u=function(t){return"string"==typeof t&&t?t.replace(/<\/?(updated|deleted|changed|change)\b[^>]*>/gi,""):""},a=function(t,n){for(var e="",o=[],r=[],i=0;i<t.length;i+=1){var l=t[i],u=n&&/[\.,;:]/.test(l),a=/\s/.test(l)||u?" ":/[’‘`]/.test(l)?"'":/[”“]/.test(l)?'"':/[—–]/.test(l)?"-":l;" "===a&&e.endsWith(" ")?r[r.length-1]=i+1:(e+=a,o.push(i),r.push(i+1))}return{text:e,starts:o,ends:r}},s=function(t,n,e){if(void 0===e&&(e=!1),!t||!n)return null;var o=t.indexOf(n);if(-1!==o)return{start:o,end:o+n.length};var r=a(t,e),i=a(n,e).text.trim();if(!i)return null;var l=r.text.indexOf(i);if(-1===l)return null;var u=l+i.length-1,s=r.starts[l],c=r.ends[u];return void 0===s||void 0===c?null:{start:s,end:c}},c=["#B91C1C","#A16207","#1D4ED8","#000000"],d=function(t){var n=c.findIndex(function(n){return n.toLowerCase()===t.toLowerCase()});return-1===n?c.length:n},v=function(t,n,e){if(!t)return null;if(t.id===e||t.nodeId===e||t.contentId===e)return n;if(!Array.isArray(t.subsections))return null;for(var o=0;o<t.subsections.length;o++){var r=v(t.subsections[o],"".concat(n,"-").concat(o),e);if(r)return r}return null},f=new WeakMap,g=function(t){if(t){var n=f.get(t);null!=n&&(clearTimeout(n),f.delete(t)),t.style.transition="box-shadow 300ms ease-out, outline 300ms ease-out",requestAnimationFrame(function(){t.style.outline="",t.style.boxShadow=""}),window.setTimeout(function(){t.style.transition="",t.style.borderRadius=""},300)}},p=function(t){if(t){var n=f.get(t);null!=n&&clearTimeout(n),t.style.transition="box-shadow 300ms ease-in-out, outline 300ms ease-in-out",t.style.outline="2px solid #ff9494",t.style.borderRadius="6px",t.style.boxShadow="0 0 12px 2px rgba(244, 113, 113, 0.33)";var e=window.setTimeout(function(){g(t)},3e3);f.set(t,e)}};exports.DEVIATION_BADGE_SEPARATOR="::",exports.areMarkdownPropsEqual=function(t,n){var e,o,r,i,l,u;if(t.content!==n.content)return!1;if(t.overlayContent!==n.overlayContent)return!1;if(t.sxStyles!==n.sxStyles)return!1;if(t.maintainRelativeOrder!==n.maintainRelativeOrder)return!1;if(t.highlightBg!==n.highlightBg)return!1;if(t.suppressHighlightBg!==n.suppressHighlightBg)return!1;if(t.collisionKey!==n.collisionKey)return!1;var a=t.highlights||[],s=n.highlights||[];if(a.length!==s.length)return!1;for(var c=0;c<a.length;c++)if(a[c]!==s[c])return!1;var d=t.deviationBadges||[],v=n.deviationBadges||[];if(d.length!==v.length)return!1;for(c=0;c<d.length;c++){if(d[c].id!==v[c].id)return!1;if(d[c].actionId!==v[c].actionId)return!1;if(d[c].label!==v[c].label)return!1;if(d[c].score!==v[c].score)return!1;if(d[c].isOrphan!==v[c].isOrphan)return!1;if(d[c].isConnected!==v[c].isConnected)return!1;if(d[c].showScrollLockToggle!==v[c].showScrollLockToggle)return!1;if(d[c].scrollSyncLocked!==v[c].scrollSyncLocked)return!1;if((null===(e=d[c].style)||void 0===e?void 0:e.badgeBg)!==(null===(o=v[c].style)||void 0===o?void 0:o.badgeBg))return!1;if((null===(r=d[c].style)||void 0===r?void 0:r.badgeBorder)!==(null===(i=v[c].style)||void 0===i?void 0:i.badgeBorder))return!1;if((null===(l=d[c].style)||void 0===l?void 0:l.badgeText)!==(null===(u=v[c].style)||void 0===u?void 0:u.badgeText))return!1}return!0},exports.debounce=function(t,n){var e;return function(){for(var o=[],r=0;r<arguments.length;r++)o[r]=arguments[r];var i=this;clearTimeout(e),e=setTimeout(function(){return t.apply(i,o)},n)}},exports.extractDeviationScore=function(t,n){var e,o,r,i,l,u,a;if(!t)return n;var s=null!==(u=null!==(i=null!==(o=null===(e=t.evaluation_output)||void 0===e?void 0:e.output_score)&&void 0!==o?o:null===(r=t.evaluation_outputs)||void 0===r?void 0:r.output_score)&&void 0!==i?i:null===(l=t.evaluation_outputs)||void 0===l?void 0:l.output_value)&&void 0!==u?u:t.output_score;return null!==(a=null!=s?s:n)&&void 0!==a?a:""},exports.findKeyPathByNodeId=function(t,n){for(var e=0;e<t.length;e++){var o=v(t[e],String(e),n);if(o)return o}return null},exports.findTextMatchRange=s,exports.generateColorPalette=function(t){var n=function(t,n){var e=function(t){var n=function(t){return 4===t.length?"#"+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]:t}(t).replace("#",""),e=parseInt(n,16);return{r:e>>16&255,g:e>>8&255,b:255&e}}(t),o=e.r,r=e.g,i=e.b;return function(t,n,e){return"#"+[t,n,e].map(function(t){return t.toString(16).padStart(2,"0")}).join("").toUpperCase()}(Math.round(o+(255-o)*n),Math.round(r+(255-r)*n),Math.round(i+(255-i)*n))};return{bg:n(t,.8),border:n(t,.5),badgeBg:n(t,.8),badgeBorder:n(t,.5),badgeText:t.toUpperCase(),highlightBg:n(t,.8)}},exports.getAlphabeticSuffix=o,exports.getBentArrowPath=function(t,n,e,o,r){void 0===r&&(r=14);var i=t+.5*(e-t),l=o-n;if(Math.abs(l)<3)return"M ".concat(t," ").concat(n," H ").concat(e);var u=l>0?1:-1,a=Math.min(r,Math.abs(l)/2,Math.abs(i-t)/2,Math.abs(e-i)/2);return["M ".concat(t," ").concat(n),"H ".concat(i-a),"Q ".concat(i," ").concat(n," ").concat(i," ").concat(n+u*a),"V ".concat(o-u*a),"Q ".concat(i," ").concat(o," ").concat(i+a," ").concat(o),"H ".concat(e)].join(" ")},exports.getFirstDeviationColor=function(n){for(var e,o,r,i,l,u,a,s,c,v,f,g,p,h=[],b=0,m=Object.keys((null==n?void 0:n.deviations)||{}).sort(function(t,n){return Number(t)-Number(n)});b<m.length;b++){var y=m[b];(A=null===(i=null===(r=null===(o=null===(e=null==n?void 0:n.deviations)||void 0===e?void 0:e[y])||void 0===o?void 0:o.evaluation_outputs)||void 0===r?void 0:r.metadata)||void 0===i?void 0:i.label_color)&&h.push(A)}for(var x=0,_=Object.keys((null==n?void 0:n.deviation_entries)||{}).sort(function(t,n){return Number(t)-Number(n)});x<_.length;x++){y=_[x];(A=null===(s=null===(a=null===(u=null===(l=null==n?void 0:n.deviation_entries)||void 0===l?void 0:l[y])||void 0===u?void 0:u.evaluation_outputs)||void 0===a?void 0:a.metadata)||void 0===s?void 0:s.label_color)&&h.push(A)}for(var I=0,T=Object.keys(n||{}).filter(function(t){return/^\d+$/.test(t)}).sort(function(t,n){return Number(t)-Number(n)});I<T.length;I++){var A;y=T[I];(A=null===(f=null===(v=null===(c=null==n?void 0:n[y])||void 0===c?void 0:c.evaluation_outputs)||void 0===v?void 0:v.metadata)||void 0===f?void 0:f.label_color)&&h.push(A)}return 0===h.length?(null===(p=null===(g=null==n?void 0:n.evaluation_outputs)||void 0===g?void 0:g.metadata)||void 0===p?void 0:p.label_color)?n.evaluation_outputs.metadata.label_color:t.DEFAULT_DEVIAION_COLOR:h.sort(function(t,n){return d(t)-d(n)})[0]},exports.getFirstDeviationOutputValue=function(t){for(var n,e,o,r,i,l,u,a,s,c=0,d=Object.keys((null==t?void 0:t.deviations)||{}).sort(function(t,n){return Number(t)-Number(n)});c<d.length;c++){var v=d[c];if(b=null===(o=null===(e=null===(n=null==t?void 0:t.deviations)||void 0===n?void 0:n[v])||void 0===e?void 0:e.evaluation_outputs)||void 0===o?void 0:o.output_value)return b}for(var f=0,g=Object.keys((null==t?void 0:t.deviation_entries)||{}).sort(function(t,n){return Number(t)-Number(n)});f<g.length;f++){v=g[f];if(b=null===(l=null===(i=null===(r=null==t?void 0:t.deviation_entries)||void 0===r?void 0:r[v])||void 0===i?void 0:i.evaluation_outputs)||void 0===l?void 0:l.output_value)return b}for(var p=0,h=Object.keys(t||{}).filter(function(t){return/^\d+$/.test(t)}).sort(function(t,n){return Number(t)-Number(n)});p<h.length;p++){var b;v=h[p];if(b=null===(a=null===(u=null==t?void 0:t[v])||void 0===u?void 0:u.evaluation_outputs)||void 0===a?void 0:a.output_value)return b}return(null===(s=null==t?void 0:t.evaluation_outputs)||void 0===s?void 0:s.output_value)?t.evaluation_outputs.output_value:null},exports.getLhsDeviationDisplayIndexes=function(t,e,o){var r=new Map;if(!e)return r;var a=function(t){var e=l(t)?u(t):n(t||"");return n(e).replace(/\\n/g,"\n")};return(t||[]).forEach(function(t){var n=new Map,l=function(t){var r;if(t){var u=a(t.content);((null===(r=t.evaluationResults)||void 0===r?void 0:r.length)?t.evaluationResults:t.evaluationResult?[t.evaluationResult]:[]).forEach(function(r){var l=(null==r?void 0:r.nodeId)||t.nodeId||t.id;Object.entries((null==r?void 0:r.deviations)||{}).forEach(function(t){var r=t[0],c=t[1][e],d=a(c);if(d&&!i(c)&&s(u,d)){var v="".concat(l).concat("::").concat(r),f=o[v];null!=f&&n.set(v,f)}})}),(t.subsections||[]).forEach(l)}};if(l(t),0!==n.size){var u=Math.min.apply(Math,Array.from(n.values()));n.forEach(function(t,n){r.set(n,t-u+1)})}}),r},exports.getRationale=function(t){if(!t.mapping_rationale)return{cognitiveData:{decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0,citations:[]},score:0,relation:"N/A"};var n=t.mapping_rationale,e=parseInt(n.decision_strength||"0");return{cognitiveData:{decisioning:n.decisioning_factors||[],gap:n.gaps_in_decision||[],relevance_score:e,citations:n.citations},score:0,relation:"N/A"}},exports.getRhsMappedSectionNumber=function(t){var n=t.section,e=t.proposedSections,r=t.leftNums,i=t.fallbackNumber,l=t.firstOnly,u=void 0!==l&&l;if(!(null==n?void 0:n.id))return i;var a=(e||[]).map(function(t){var e=Array.isArray(null==t?void 0:t.refIndexes)?t.refIndexes:[],i=e.findIndex(function(t){return t===n.selfIndex});if(-1===i)return null;var l=(null==t?void 0:t.id)?r.get(t.id):void 0;return null==l?null:e.length>1?"".concat(l).concat(o(i)):String(l)}).filter(Boolean);return 0===a.length?i:u?a[0]:a.join(", ")},exports.getSideData=function(t,e,o,i){var l,u,a;void 0===i&&(i={});var s=r(t,e,o,i),c=(null===(l=s[0])||void 0===l?void 0:l.data)||{},d=(null===(u=s[0])||void 0===u?void 0:u.attributes)||null;return{title:n((null==c?void 0:c.title)||""),content:n((null==c?void 0:c.content)||""),change_history:n((null==c?void 0:c.change_history)||""),attributes:d,subsections:(null==c?void 0:c.subsections)||[],contentId:null===(a=s[0])||void 0===a?void 0:a.contentId,allItems:s}},exports.hasMeaningfulRedlineTags=l,exports.hasSingleMappedLhsSection=function(t,n){return null!=(null==t?void 0:t.selfIndex)&&1===(n||[]).filter(function(n){return Array.isArray(null==n?void 0:n.refIndexes)&&n.refIndexes.includes(t.selfIndex)}).length},exports.hasValue=e,exports.highlightClause=p,exports.isMissingStr=i,exports.mixHexColors=function(t,n){var e=function(t){var n=t.replace("#","");return[parseInt(n.substring(0,2),16),parseInt(n.substring(2,4),16),parseInt(n.substring(4,6),16)]},o=function(t){var n=Math.round(t).toString(16);return 1===n.length?"0"+n:n};try{var r=e(t),i=e(n),l=(r[0]+i[0])/2*.95,u=(r[1]+i[1])/2*.95,a=(r[2]+i[2])/2*.95;return"#".concat(o(l)).concat(o(u)).concat(o(a))}catch(t){return"#FDE68A"}},exports.recursivelyFindSubSectionIdxById=v,exports.resetClauseHighlight=g,exports.resolveComparisonInputItems=r,exports.safeStringify=n,exports.scrollAndHighlightClause=function(t,n){var e=n.getBoundingClientRect(),o=t.getBoundingClientRect(),r=n.scrollTop+o.top-e.top-e.height/2+o.height/2;n.scrollTo({top:r,behavior:"smooth"});var i=function(){return p(t)};if("onscrollend"in n)n.addEventListener("scrollend",i,{once:!0});else{var l=n.scrollTop,u=function(){n.scrollTop===l?i():(l=n.scrollTop,requestAnimationFrame(u))};requestAnimationFrame(u)}},exports.scrollAndWait=function(t,n,e){if(Math.abs(t.scrollTop-n)<=2)e();else{var o,r=!1,i=function(){r||(r=!0,clearTimeout(o),t.removeEventListener("scrollend",l),e())},l=function(){return i()};t.addEventListener("scrollend",l),t.scrollTo({top:n,behavior:"smooth"}),o=setTimeout(i,800)}},exports.smoothScrollTo=function(t,n,e,o,r){void 0===e&&(e=300);var i=t.style.scrollBehavior;t.style.scrollBehavior="auto";var l=t.scrollTop,u=n-l,a=null,s=function(c){null===a&&(a=c);var d,v=c-a;v<e?(t.scrollTop=(d=v,d/=e,u*(--d*d*d+1)+l),r&&r(),requestAnimationFrame(s)):(t.scrollTop=n,t.style.scrollBehavior=i,r&&r(),o&&o())};requestAnimationFrame(s)},exports.stripRedlineTags=u,exports.waitForScrollIdle=function(t,n){return void 0===n&&(n=100),new Promise(function(e){var o,r=!1,i=function(){r||(r=!0,t.removeEventListener("scroll",l),e())},l=function(){clearTimeout(o),o=setTimeout(i,n)};t.addEventListener("scroll",l),o=setTimeout(i,n)})};
2
2
  //# sourceMappingURL=CognitiveComparehelpers.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var i=require("tslib"),o=require("react/jsx-runtime"),e=require("react"),n=require("@mui/material"),t=require("lucide-react"),s=require("react-dom"),a=require("../../assests/svg/SparkleIcon.js"),r=require("./CognitiveCompareConfig.js"),l=require("./CitationRenderer.js");function c(i){return i&&"object"==typeof i&&"default"in i?i:{default:i}}var d=c(s),x=10;exports.default=function(s){var c,p,g,u,v,h,b,f,_,m,y,F,j,w,C,k,B,D,S,E,T=s.open,I=s.onClose,R=s.sectionTitle,A=s.referenceSectionTitle,L=s.cognitiveData,P=s.relevanceScore,z=s.anchorEl,O=s.badgeStyle,W=s.popupRef,q=s.position,U=s.markdownStyles,H=s.docData,M=s.popupConfig,N=s.deviationData,G=void 0===N?null:N,Y=s.isLoading,K=i.__assign(i.__assign({},r.SHARED_MARKDOWN_STYLES),U),X=e.useMemo(function(){var o,e;return i.__assign(i.__assign(i.__assign({},r.DEFAULT_POPUP_CONFIG),M),{tabs:{deviation:i.__assign(i.__assign({},r.DEFAULT_POPUP_CONFIG.tabs.deviation),null===(o=null==M?void 0:M.tabs)||void 0===o?void 0:o.deviation),association:i.__assign(i.__assign({},r.DEFAULT_POPUP_CONFIG.tabs.association),null===(e=null==M?void 0:M.tabs)||void 0===e?void 0:e.association)},sectionTitles:i.__assign(i.__assign({},r.DEFAULT_POPUP_CONFIG.sectionTitles),null==M?void 0:M.sectionTitles)})},[M]),J=null==L?void 0:L.isMissingRationale,Q=e.useState(J?X.tabs.deviation.key:X.tabs.association.key),V=Q[0],Z=Q[1],$=e.useState(!1),ii=$[0],oi=$[1],ei=e.useCallback(function(i){oi(i)},[]);e.useEffect(function(){T?Z(J?X.tabs.deviation.key:X.tabs.association.key):oi(!1)},[T,J,X.tabs.deviation.key,X.tabs.association.key]);var ni=e.useMemo(function(){if(!O)return{border:X.accentColor,shadow:"".concat(X.accentColor,"2E")};var i=O.badgeText;return"#9F1239"===i||"#B42318"===i?{border:"#E11D48",shadow:"rgba(225,29,72,0.15)"}:"#1D4ED8"===i?{border:"#3B82F6",shadow:"rgba(59,130,246,0.15)"}:"#A16207"===i?{border:"#F59E0B",shadow:"rgba(245,158,11,0.15)"}:{border:X.accentColor,shadow:"".concat(X.accentColor,"2E")}},[O,X.accentColor]);e.useEffect(function(){if(T&&!ii){var i=function(i){var o;(null===(o=W.current)||void 0===o?void 0:o.contains(i.target))||(null==z?void 0:z.contains(i.target))||I()};return document.addEventListener("mousedown",i),function(){return document.removeEventListener("mousedown",i)}}},[T,I,z,W,ii]);var ti=J?[]:[X.tabs.deviation,X.tabs.association];if(1===ti.length&&ti[0].key===X.tabs.deviation.key)return null;if(!T||!L)return null;var si=null!==(g=null!==(p=V===X.tabs.deviation.key?null===(c=null==G?void 0:G.cognitive_decisioning)||void 0===c?void 0:c.decision_strength:L.relevance_score)&&void 0!==p?p:P)&&void 0!==g?g:0,ai=L.decisioning,ri=Array.isArray(ai)?ai:"string"==typeof ai&&ai.trim()?[ai]:[],li=L.gap,ci=Array.isArray(li)?li:"string"==typeof li&&li.trim()?[li]:[],di=q?q.left-150:-9999,xi=(null!==(u=null==q?void 0:q.arrowLeft)&&void 0!==u?u:60)+150,pi=o.jsxs(n.Box,i.__assign({ref:W,sx:{position:"fixed",top:null!==(v=null==q?void 0:q.top)&&void 0!==v?v:-9999,left:di,zIndex:9999,width:"".concat(1050,"px"),maxWidth:"min(".concat(1050,"px, calc(100vw - ").concat(di>0?di:0,"px - ").concat(12,"px))"),bgcolor:"#FFFFFF",borderRadius:"14px",border:"1.5px solid ".concat(ni.border),boxShadow:"0px 8px 32px ".concat(ni.shadow,", 0px 0px 0px 3px ").concat(ni.shadow),overflow:"visible",display:"flex",flexDirection:"column",maxHeight:(null==q?void 0:q.maxHeight)?"min(60vh, ".concat(q.maxHeight,"px)"):"60vh",visibility:!ii&&q?"visible":"hidden",pointerEvents:ii?"none":"auto"}},{children:[q&&(q.openAbove?o.jsxs(o.Fragment,{children:[o.jsx(n.Box,{sx:{position:"absolute",bottom:-11,left:xi-x,width:0,height:0,borderLeft:"".concat(x,"px solid transparent"),borderRight:"".concat(x,"px solid transparent"),borderTop:"".concat(11,"px solid ").concat(ni.border),zIndex:1}}),o.jsx(n.Box,{sx:{position:"absolute",bottom:-9,left:xi-x+1,width:0,height:0,borderLeft:"".concat(9,"px solid transparent"),borderRight:"".concat(9,"px solid transparent"),borderTop:"".concat(x,"px solid #FFFFFF"),zIndex:2}})]}):o.jsxs(o.Fragment,{children:[o.jsx(n.Box,{sx:{position:"absolute",top:-11,left:xi-x,width:0,height:0,borderLeft:"".concat(x,"px solid transparent"),borderRight:"".concat(x,"px solid transparent"),borderBottom:"".concat(11,"px solid ").concat(ni.border),zIndex:1}}),o.jsx(n.Box,{sx:{position:"absolute",top:-9,left:xi-x+1,width:0,height:0,borderLeft:"".concat(9,"px solid transparent"),borderRight:"".concat(9,"px solid transparent"),borderBottom:"".concat(x,"px solid #FFFFFF"),zIndex:2}})]})),o.jsxs(n.Box,i.__assign({sx:{px:2.5,pt:2,pb:1.5,display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0}},{children:[o.jsxs(n.Box,i.__assign({sx:{flex:1,minWidth:0}},{children:[("no counterpart"!==R||"no counterpart"!==A)&&o.jsxs(n.Typography,i.__assign({sx:{fontSize:"16px",fontWeight:600,color:"#101828",lineHeight:1.3,display:"flex",alignItems:"center",gap:1,flexWrap:"nowrap",overflow:"hidden",width:"100%"}},{children:[o.jsx(n.Box,i.__assign({component:"span",title:R,sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:"0 1 auto",maxWidth:"calc(50% - 16px)",minWidth:0}},{children:R})),o.jsx(n.Box,i.__assign({component:"span",sx:{color:"#667085",fontWeight:400,flexShrink:0,mx:.5}},{children:"↔"})),o.jsx(n.Box,i.__assign({component:"span",title:A||"Reference Section",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,minWidth:0}},{children:A||"Reference Section"}))]})),o.jsx(n.Box,i.__assign({sx:{mt:.75,display:"inline-flex",alignItems:"center",gap:.75}},{children:o.jsx(n.Typography,i.__assign({sx:{fontSize:"no counterpart"!==R||"no counterpart"!==A?"13px":"16px",fontWeight:400,color:"#5928ED",lineHeight:1}},{children:null===(h=Object.values(X.tabs).find(function(i){return i.key===V}))||void 0===h?void 0:h.subtitle}))}))]})),o.jsxs(n.Box,i.__assign({sx:{display:"flex",alignItems:"center",gap:1.5,flexShrink:0}},{children:[o.jsxs(n.Box,i.__assign({sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:.5,borderRadius:"20px",bgcolor:"#FFFFFF",border:"1px solid #5928ED",fontSize:"12px",fontWeight:600,color:"#5928ED"}},{children:[o.jsx(a.default,{}),X.decisionStrengthLabel," ",si,"%"]})),o.jsx(n.IconButton,i.__assign({onClick:I,size:"small",sx:{color:"#667085",width:24,height:24,"&:hover":{bgcolor:"transparent",color:"#101828"}}},{children:o.jsx(t.X,{size:22})}))]}))]})),o.jsx(n.Box,i.__assign({sx:{display:"flex",borderBottom:"1px solid #E4E7EC",px:2.5,flexShrink:0}},{children:ti.map(function(e){var t=V===e.key,s=e.key===X.tabs.deviation.key,a=ti.length>1&&s&&Y,r=o.jsx(n.Box,i.__assign({onClick:function(){a||Z(e.key)},sx:{pb:"10px",pt:"4px",mr:3,px:2,cursor:a?"not-allowed":"pointer",opacity:a?.5:1,fontSize:"14px",fontWeight:t?600:400,color:t?X.accentColor:"#667085",backgroundColor:t?"".concat(X.accentColor,"14"):"transparent",borderBottom:t?"2px solid ".concat(X.accentColor):"2px solid transparent",transition:"all 0.15s",userSelect:"none"}},{children:e.label}),e.key);return a?o.jsx(n.Tooltip,i.__assign({title:"Fetching deviation data",arrow:!0,placement:"top"},{children:o.jsx("span",{children:r})}),e.key):r})})),o.jsx(n.Box,i.__assign({sx:{flex:1,minHeight:0,overflowY:"auto",px:2.5,py:2,display:"flex",flexDirection:"column",gap:1.5,"&::-webkit-scrollbar":{width:"6px"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{background:"".concat(ni.border,"55"),borderRadius:"10px"},"&::-webkit-scrollbar-thumb:hover":{background:ni.border},scrollbarWidth:"thin",scrollbarColor:"".concat(ni.border,"55 transparent")}},{children:V===X.tabs.deviation.key?G?o.jsxs(o.Fragment,{children:[(null===(f=(null===(b=null==G?void 0:G.cognitive_decisioning)||void 0===b?void 0:b.decisioning_factors)||[])||void 0===f?void 0:f.length)>0&&o.jsx(l.default,{title:"Decision Making Factors",content:null===(m=null===(_=null==G?void 0:G.cognitive_decisioning)||void 0===_?void 0:_.decisioning_factors)||void 0===m?void 0:m.join("\n\n"),citations:null===(y=null==G?void 0:G.cognitive_decisioning)||void 0===y?void 0:y.citations,styles:K,docData:H,deviationData:G,open:T,onCitationFullscreenChange:ei}),(null===(j=(null===(F=null==G?void 0:G.cognitive_decisioning)||void 0===F?void 0:F.gaps_in_decision)||[])||void 0===j?void 0:j.length)>0&&o.jsx(l.default,{title:"Gaps in Decision",content:null===(C=null===(w=null==G?void 0:G.cognitive_decisioning)||void 0===w?void 0:w.gaps_in_decision)||void 0===C?void 0:C.join("\n\n"),citations:null===(k=null==G?void 0:G.cognitive_decisioning)||void 0===k?void 0:k.citations,styles:K,docData:H,deviationData:G,open:T,onCitationFullscreenChange:ei}),0===(null===(D=(null===(B=null==G?void 0:G.cognitive_decisioning)||void 0===B?void 0:B.decisioning_factors)||[])||void 0===D?void 0:D.length)&&0===(null===(E=(null===(S=null==G?void 0:G.cognitive_decisioning)||void 0===S?void 0:S.gaps_in_decision)||[])||void 0===E?void 0:E.length)&&o.jsx(n.Box,i.__assign({sx:{p:2,bgcolor:"#F8FAFC",borderRadius:"8px",border:"1px solid #E2E8F0"}},{children:o.jsx(n.Typography,i.__assign({sx:{fontSize:"13px",color:"#64748B"}},{children:"No cognitive decisioning data available for this section."}))}))]}):o.jsx(l.default,{title:"Deviation Analysis",content:"Deviation analysis content will appear here. This tab shows\n structural and semantic deviations identified between the two\n sections being compared.",citations:{},styles:K,docData:H,open:T,onCitationFullscreenChange:ei}):o.jsxs(o.Fragment,{children:[ri.length>0&&o.jsx(l.default,{title:X.sectionTitles.decisioningFactors,content:ri.join("\n\n"),citations:L.citations,styles:K,open:T,docData:H,onCitationFullscreenChange:ei}),ci.length>0&&o.jsx(l.default,{title:X.sectionTitles.gaps,content:ci.join("\n\n"),citations:L.citations,styles:K,open:T,docData:H,onCitationFullscreenChange:ei}),0===ri.length&&0===ci.length&&o.jsx(n.Box,i.__assign({sx:{p:2,bgcolor:"#F8FAFC",borderRadius:"8px",border:"1px solid #E2E8F0"}},{children:o.jsx(n.Typography,i.__assign({sx:{fontSize:"13px",color:"#64748B"}},{children:X.emptyStateMessage}))}))]})}))]}));return d.default.createPortal(pi,document.body)};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var i=require("tslib"),o=require("react/jsx-runtime"),e=require("react"),n=require("@mui/material"),t=require("lucide-react"),s=require("react-dom"),a=require("../../assests/svg/SparkleIcon.js"),r=require("./CognitiveCompareConfig.js"),l=require("./CitationRenderer.js");function c(i){return i&&"object"==typeof i&&"default"in i?i:{default:i}}var d=c(s),x=10;exports.default=function(s){var c,p,g,u,v,h,b,f,_,m,y,F,j,w,C,k,B,D,S,E,T=s.open,I=s.onClose,R=s.sectionTitle,A=s.referenceSectionTitle,L=s.cognitiveData,P=s.relevanceScore,z=s.anchorEl,O=s.badgeStyle,W=s.popupRef,q=s.position,U=s.markdownStyles,H=s.docData,M=s.popupConfig,N=s.deviationData,G=void 0===N?null:N,Y=s.isLoading,K=i.__assign(i.__assign({},r.SHARED_MARKDOWN_STYLES),U),X=e.useMemo(function(){var o,e;return i.__assign(i.__assign(i.__assign({},r.DEFAULT_POPUP_CONFIG),M),{tabs:{deviation:i.__assign(i.__assign({},r.DEFAULT_POPUP_CONFIG.tabs.deviation),null===(o=null==M?void 0:M.tabs)||void 0===o?void 0:o.deviation),association:i.__assign(i.__assign({},r.DEFAULT_POPUP_CONFIG.tabs.association),null===(e=null==M?void 0:M.tabs)||void 0===e?void 0:e.association)},sectionTitles:i.__assign(i.__assign({},r.DEFAULT_POPUP_CONFIG.sectionTitles),null==M?void 0:M.sectionTitles)})},[M]),J=null==L?void 0:L.isMissingRationale,Q=e.useState(J?X.tabs.deviation.key:X.tabs.association.key),V=Q[0],Z=Q[1],$=e.useState(!1),ii=$[0],oi=$[1],ei=e.useCallback(function(i){oi(i)},[]);e.useEffect(function(){T?Z(J?X.tabs.deviation.key:X.tabs.association.key):oi(!1)},[T,J,X.tabs.deviation.key,X.tabs.association.key]);var ni=e.useMemo(function(){if(!O)return{border:X.accentColor,shadow:"".concat(X.accentColor,"2E")};var i=O.badgeText;return"#9F1239"===i||"#B42318"===i?{border:"#E11D48",shadow:"rgba(225,29,72,0.15)"}:"#1D4ED8"===i?{border:"#3B82F6",shadow:"rgba(59,130,246,0.15)"}:"#A16207"===i?{border:"#F59E0B",shadow:"rgba(245,158,11,0.15)"}:{border:X.accentColor,shadow:"".concat(X.accentColor,"2E")}},[O,X.accentColor]);e.useEffect(function(){if(T&&!ii){var i=function(i){var o;(null===(o=W.current)||void 0===o?void 0:o.contains(i.target))||(null==z?void 0:z.contains(i.target))||I()};return document.addEventListener("mousedown",i),function(){return document.removeEventListener("mousedown",i)}}},[T,I,z,W,ii]);var ti=J?[]:[X.tabs.deviation,X.tabs.association];if(1===ti.length&&ti[0].key===X.tabs.deviation.key)return null;if(!T||!L)return null;var si=null!==(g=null!==(p=V===X.tabs.deviation.key?null===(c=null==G?void 0:G.cognitive_decisioning)||void 0===c?void 0:c.decision_strength:L.relevance_score)&&void 0!==p?p:P)&&void 0!==g?g:0,ai=L.decisioning,ri=Array.isArray(ai)?ai:"string"==typeof ai&&ai.trim()?[ai]:[],li=L.gap,ci=Array.isArray(li)?li:"string"==typeof li&&li.trim()?[li]:[],di=q?q.left-150:-9999,xi=(null!==(u=null==q?void 0:q.arrowLeft)&&void 0!==u?u:60)+150,pi=o.jsxs(n.Box,i.__assign({ref:W,sx:{position:"fixed",top:null!==(v=null==q?void 0:q.top)&&void 0!==v?v:-9999,left:di,zIndex:9999,width:"".concat(1050,"px"),maxWidth:"min(".concat(1050,"px, calc(100vw - ").concat(di>0?di:0,"px - ").concat(12,"px))"),bgcolor:"#FFFFFF",borderRadius:"14px",border:"1.5px solid ".concat(ni.border),boxShadow:"0px 8px 32px ".concat(ni.shadow,", 0px 0px 0px 3px ").concat(ni.shadow),overflow:"visible",display:ii?"none":"flex",flexDirection:"column",maxHeight:(null==q?void 0:q.maxHeight)?"min(60vh, ".concat(q.maxHeight,"px)"):"60vh",visibility:q?"visible":"hidden",pointerEvents:ii?"none":"auto"}},{children:[q&&(q.openAbove?o.jsxs(o.Fragment,{children:[o.jsx(n.Box,{sx:{position:"absolute",bottom:-11,left:xi-x,width:0,height:0,borderLeft:"".concat(x,"px solid transparent"),borderRight:"".concat(x,"px solid transparent"),borderTop:"".concat(11,"px solid ").concat(ni.border),zIndex:1}}),o.jsx(n.Box,{sx:{position:"absolute",bottom:-9,left:xi-x+1,width:0,height:0,borderLeft:"".concat(9,"px solid transparent"),borderRight:"".concat(9,"px solid transparent"),borderTop:"".concat(x,"px solid #FFFFFF"),zIndex:2}})]}):o.jsxs(o.Fragment,{children:[o.jsx(n.Box,{sx:{position:"absolute",top:-11,left:xi-x,width:0,height:0,borderLeft:"".concat(x,"px solid transparent"),borderRight:"".concat(x,"px solid transparent"),borderBottom:"".concat(11,"px solid ").concat(ni.border),zIndex:1}}),o.jsx(n.Box,{sx:{position:"absolute",top:-9,left:xi-x+1,width:0,height:0,borderLeft:"".concat(9,"px solid transparent"),borderRight:"".concat(9,"px solid transparent"),borderBottom:"".concat(x,"px solid #FFFFFF"),zIndex:2}})]})),o.jsxs(n.Box,i.__assign({sx:{px:2.5,pt:2,pb:1.5,display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0}},{children:[o.jsxs(n.Box,i.__assign({sx:{flex:1,minWidth:0}},{children:[("no counterpart"!==R||"no counterpart"!==A)&&o.jsxs(n.Typography,i.__assign({sx:{fontSize:"16px",fontWeight:600,color:"#101828",lineHeight:1.3,display:"flex",alignItems:"center",gap:1,flexWrap:"nowrap",overflow:"hidden",width:"100%"}},{children:[o.jsx(n.Box,i.__assign({component:"span",title:R,sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:"0 1 auto",maxWidth:"calc(50% - 16px)",minWidth:0}},{children:R})),o.jsx(n.Box,i.__assign({component:"span",sx:{color:"#667085",fontWeight:400,flexShrink:0,mx:.5}},{children:"↔"})),o.jsx(n.Box,i.__assign({component:"span",title:A||"Reference Section",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,minWidth:0}},{children:A||"Reference Section"}))]})),o.jsx(n.Box,i.__assign({sx:{mt:.75,display:"inline-flex",alignItems:"center",gap:.75}},{children:o.jsx(n.Typography,i.__assign({sx:{fontSize:"no counterpart"!==R||"no counterpart"!==A?"13px":"16px",fontWeight:400,color:"#5928ED",lineHeight:1}},{children:null===(h=Object.values(X.tabs).find(function(i){return i.key===V}))||void 0===h?void 0:h.subtitle}))}))]})),o.jsxs(n.Box,i.__assign({sx:{display:"flex",alignItems:"center",gap:1.5,flexShrink:0}},{children:[o.jsxs(n.Box,i.__assign({sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:.5,borderRadius:"20px",bgcolor:"#FFFFFF",border:"1px solid #5928ED",fontSize:"12px",fontWeight:600,color:"#5928ED"}},{children:[o.jsx(a.default,{}),X.decisionStrengthLabel," ",si,"%"]})),o.jsx(n.IconButton,i.__assign({onClick:I,size:"small",sx:{color:"#667085",width:24,height:24,"&:hover":{bgcolor:"transparent",color:"#101828"}}},{children:o.jsx(t.X,{size:22})}))]}))]})),o.jsx(n.Box,i.__assign({sx:{display:"flex",borderBottom:"1px solid #E4E7EC",px:2.5,flexShrink:0}},{children:ti.map(function(e){var t=V===e.key,s=e.key===X.tabs.deviation.key,a=ti.length>1&&s&&Y,r=o.jsx(n.Box,i.__assign({onClick:function(){a||Z(e.key)},sx:{pb:"10px",pt:"4px",mr:3,px:2,cursor:a?"not-allowed":"pointer",opacity:a?.5:1,fontSize:"14px",fontWeight:t?600:400,color:t?X.accentColor:"#667085",backgroundColor:t?"".concat(X.accentColor,"14"):"transparent",borderBottom:t?"2px solid ".concat(X.accentColor):"2px solid transparent",transition:"all 0.15s",userSelect:"none"}},{children:e.label}),e.key);return a?o.jsx(n.Tooltip,i.__assign({title:"Fetching deviation data",arrow:!0,placement:"top"},{children:o.jsx("span",{children:r})}),e.key):r})})),o.jsx(n.Box,i.__assign({sx:{flex:1,minHeight:0,overflowY:"auto",px:2.5,py:2,display:"flex",flexDirection:"column",gap:1.5,"&::-webkit-scrollbar":{width:"6px"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{background:"".concat(ni.border,"55"),borderRadius:"10px"},"&::-webkit-scrollbar-thumb:hover":{background:ni.border},scrollbarWidth:"thin",scrollbarColor:"".concat(ni.border,"55 transparent")}},{children:V===X.tabs.deviation.key?G?o.jsxs(o.Fragment,{children:[(null===(f=(null===(b=null==G?void 0:G.cognitive_decisioning)||void 0===b?void 0:b.decisioning_factors)||[])||void 0===f?void 0:f.length)>0&&o.jsx(l.default,{title:"Decision Making Factors",content:null===(m=null===(_=null==G?void 0:G.cognitive_decisioning)||void 0===_?void 0:_.decisioning_factors)||void 0===m?void 0:m.join("\n\n"),citations:null===(y=null==G?void 0:G.cognitive_decisioning)||void 0===y?void 0:y.citations,styles:K,docData:H,deviationData:G,open:T,onCitationFullscreenChange:ei}),(null===(j=(null===(F=null==G?void 0:G.cognitive_decisioning)||void 0===F?void 0:F.gaps_in_decision)||[])||void 0===j?void 0:j.length)>0&&o.jsx(l.default,{title:"Gaps in Decision",content:null===(C=null===(w=null==G?void 0:G.cognitive_decisioning)||void 0===w?void 0:w.gaps_in_decision)||void 0===C?void 0:C.join("\n\n"),citations:null===(k=null==G?void 0:G.cognitive_decisioning)||void 0===k?void 0:k.citations,styles:K,docData:H,deviationData:G,open:T,onCitationFullscreenChange:ei}),0===(null===(D=(null===(B=null==G?void 0:G.cognitive_decisioning)||void 0===B?void 0:B.decisioning_factors)||[])||void 0===D?void 0:D.length)&&0===(null===(E=(null===(S=null==G?void 0:G.cognitive_decisioning)||void 0===S?void 0:S.gaps_in_decision)||[])||void 0===E?void 0:E.length)&&o.jsx(n.Box,i.__assign({sx:{p:2,bgcolor:"#F8FAFC",borderRadius:"8px",border:"1px solid #E2E8F0"}},{children:o.jsx(n.Typography,i.__assign({sx:{fontSize:"13px",color:"#64748B"}},{children:"No cognitive decisioning data available for this section."}))}))]}):o.jsx(l.default,{title:"Deviation Analysis",content:"Deviation analysis content will appear here. This tab shows\n structural and semantic deviations identified between the two\n sections being compared.",citations:{},styles:K,docData:H,open:T,onCitationFullscreenChange:ei}):o.jsxs(o.Fragment,{children:[ri.length>0&&o.jsx(l.default,{title:X.sectionTitles.decisioningFactors,content:ri.join("\n\n"),citations:L.citations,styles:K,open:T,docData:H,onCitationFullscreenChange:ei}),ci.length>0&&o.jsx(l.default,{title:X.sectionTitles.gaps,content:ci.join("\n\n"),citations:L.citations,styles:K,open:T,docData:H,onCitationFullscreenChange:ei}),0===ri.length&&0===ci.length&&o.jsx(n.Box,i.__assign({sx:{p:2,bgcolor:"#F8FAFC",borderRadius:"8px",border:"1px solid #E2E8F0"}},{children:o.jsx(n.Typography,i.__assign({sx:{fontSize:"13px",color:"#64748B"}},{children:X.emptyStateMessage}))}))]})}))]}));return d.default.createPortal(pi,document.body)};
2
2
  //# sourceMappingURL=CognitivePopup.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("tslib"),e=require("react/jsx-runtime"),i=require("react"),t=require("@mui/material"),o=require("lucide-react"),l=require("../hooks/memoizedMarkdown.js"),r=require("../CompareContext.js"),d=require("../CognitiveComparehelpers.js"),a=require("../CognitiveCompareConstants.js");function s(n){return n&&"object"==typeof n&&"default"in n?n:{default:n}}var u=s(i);exports.default=function(s){var c,v,f,g,p,h,x,I,m,_,y,b,S,A,R,E=s.section,w=s.idx,M=s.columnKey,O=s.colRef,N=s.mb,T=void 0===N?1:N,D=s.isExpanded,j=s.onToggle,B=s.navigation,C=s.parentNodeId,F=void 0===C?"":C,k=r.useCompareContext(),P=k.showOpenNodeRef,V=k.resolvedMarkdownStyles,G=k.maintainRelativeOrder,W=k.showDeviationBadges,q=void 0!==W&&W,L=k.renderSubSectionAccordion,z=k.treeData,K=k.proposedSections,X=k.existingSections,H=k.deviationNumberRegistry,U=k.deviationParentRegistry,Y=k.getBadgeRef,J=k.openSummaryPopup,Q=k.getSectionCompareStyle,Z=k.connectedSections,$=k.openMoreFunctionsPopup,nn=k.isProposingFix,en=k.proposingFixNodeId,tn=k.isRedlineFlow,on=k.isSideBySide,ln=k.activeSideBySideSection,rn=k.scrollSyncLocked,dn=k.unifiedNumbering,an=k.toggleScrollSyncLocked,sn=k.summaryPopupAnchorEl,un="".concat(on?"1":"0","-").concat(String(null!=ln?ln:"")),cn=(null===(c=E.displayTitle)||void 0===c||c)&&d.hasValue(E.title),vn=!(!nn||!en||"left"!==M||E.id!==en&&E.nodeId!==en),fn=d.hasMeaningfulRedlineTags(E.content),gn="boolean"==typeof tn?tn:fn,pn=fn,hn=gn&&fn,xn=hn?d.stripRedlineTags(E.content):E.content,In=hn?E.content:void 0,mn=(null===(v=E.displayContent)||void 0===v||v||fn)&&d.hasValue(E.content),_n=!cn&&!mn,yn=E.title;cn||(yn=mn?"No Title Found":"No Matching Section Found");var bn="left"===M&&(E.isMultipleMapping||(null!==(g=null===(f=E.refContentIds)||void 0===f?void 0:f.length)&&void 0!==g?g:1)>1),Sn="left"===M&&yn.length>29?"".concat(yn.slice(0,29).trimEnd(),"..."):yn,An=E.evaluationResult;if(!An&&"right"===M)if(G){var Rn=null===(p=E.refIndexes)||void 0===p?void 0:p[0],En=K.find(function(n){return n.selfIndex===Rn});An=null==En?void 0:En.evaluationResult}else An=null===(h=K[w])||void 0===h?void 0:h.evaluationResult;var wn=null===(x=null==z?void 0:z.input_index_map)||void 0===x?void 0:x[0],Mn=null===(I=null==z?void 0:z.input_index_map)||void 0===I?void 0:I[1],On="left"===M?Mn:wn,Nn=function(n,e){var i;if(!e||!n)return null;for(var t=0,o=n;t<o.length;t++){var l=o[t];if(l.id===e||l.nodeId===e||l.contentId===e)return l;if(null===(i=l.subsections)||void 0===i?void 0:i.length){var r=Nn(l.subsections,e);if(r)return r}}return null},Tn="left"===M?E:Nn(K,E.id),Dn="right"===M?E:Nn(X,E.id),jn=u.default.useMemo(function(){if(!G)return 0;var n=1/0,e=function(n){var e=d.hasMeaningfulRedlineTags(n)?d.stripRedlineTags(n):n;return d.safeStringify(e||"").replace(/\\n/g,"\n")},i=function(t,o,l,r){if(t){var a=t.nodeId||t.id;if(r&&"right"===M){var s=K.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(t.selfIndex)});s.length>0&&(a=s[0].nodeId||s[0].id)}var u=t.nodeId||t.id||(null==o?void 0:o.nodeId)||(null==o?void 0:o.id)||(null==l?void 0:l.nodeId)||(null==l?void 0:l.id),c=t.evaluationResult||(null==o?void 0:o.evaluationResult)||(null==l?void 0:l.evaluationResult),v=(null==c?void 0:c.deviations)||{};Object.keys(v).forEach(function(i){var r,s=null===(r=v[i])||void 0===r?void 0:r[F];if(function(n,i){if("string"!=typeof i||d.isMissingStr(i))return!1;var t=e(null==n?void 0:n.content),o=e(i);return!!o&&t.includes(o)}("left"===M?o||t:l||t,s)){var c="".concat(a).concat(d.DEVIATION_BADGE_SEPARATOR).concat(i),f=null==H?void 0:H[c];null!=f&&f<n&&(n=f);var g="".concat(u).concat(d.DEVIATION_BADGE_SEPARATOR).concat(i),p=null==H?void 0:H[g];null!=p&&p<n&&(n=p)}});for(var f=t.subsections||[],g=(null==o?void 0:o.subsections)||[],p=(null==l?void 0:l.subsections)||[],h=Math.max(f.length,g.length,p.length),x=0;x<h;x++)i(f[x],g[x],p[x],!1)}},t="right"===M?K.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(E.selfIndex)}):[];if(1===t.length){var o=t[0];(o.refIndexes||[]).map(function(n){return X.find(function(e){return e.selfIndex===n})}).filter(Boolean).forEach(function(n){i(n,o,n,!0)})}else i(E,Tn,Dn,!0);return n!==1/0?n-1:0},[E,Tn,Dn,M,F,H,G,K,X]);if(G)if("left"===M){var Bn=null===(m=E.refIndexes)||void 0===m?void 0:m[0],Cn=X.findIndex(function(n){return n.selfIndex===Bn});Dn=-1!==Cn?X[Cn]:Nn(X,E.id)}else{var Fn=null===(_=E.refIndexes)||void 0===_?void 0:_[0],kn=K.findIndex(function(n){return n.selfIndex===Fn});Tn=-1!==kn?K[kn]:Nn(K,E.id)}var Pn="left"===M?!Dn:!Tn,Vn=G&&"right"===M&&d.hasSingleMappedLhsSection(E,K),Gn=An||(null==Tn?void 0:Tn.evaluationResult)||(null==Dn?void 0:Dn.evaluationResult),Wn=null!==(S=null===(b=null===(y=null==Gn?void 0:Gn.evaluation_outputs)||void 0===y?void 0:y.metadata)||void 0===b?void 0:b.label_color)&&void 0!==S?S:a.DEFAULT_DEVIAION_COLOR,qn=d.generateColorPalette(Wn).highlightBg,Ln=(null==Gn?void 0:Gn.deviations)||{},zn=u.default.useMemo(function(){return G&&"right"===M?d.getLhsDeviationDisplayIndexes(K,wn,H):new Map},[G,M,K,wn,H]),Kn=E.nodeId||E.id;if(G&&"left"!==M){var Xn=K.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(E.selfIndex)});Xn.length>0?Kn=Xn[0].nodeId||Xn[0].id:(null==Tn?void 0:Tn.id)&&(Kn=Tn.nodeId||Tn.id)}var Hn=u.default.useMemo(function(){var n,e=new Map;if(!G||"right"!==M)return e;var i=1,t=K.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(E.selfIndex)}),o=1===t.length&&1===(null===(n=t[0].refIndexes)||void 0===n?void 0:n.length),l=function(n){return d.safeStringify(n||"").replace(/\\n/g,"\n")},r=function(n,e){var i=e?t[0]:Nn(K,n.nodeId||n.id||n.contentId);return{lhsNode:i,evalResult:n.evaluationResult||(null==i?void 0:i.evaluationResult),registryNodeId:i?i.nodeId||i.id:n.nodeId||n.id}};if(o){var a=function(n,e){if(void 0===e&&(e=!1),n){var t=r(n,e),o=t.lhsNode,s=t.evalResult,u=t.registryNodeId,c=l(n.content);Object.entries((null==s?void 0:s.deviations)||{}).forEach(function(n){var e=n[0],t=n[1],r=t[F],a=l(r);if(!!o&&!d.isMissingStr(t[On])&&a&&c.includes(a)){var s="".concat(u).concat(d.DEVIATION_BADGE_SEPARATOR).concat(e),v=H[s];null!=v&&(i=Math.max(i,Math.max(1,v-(jn||0))+1))}}),(n.subsections||[]).forEach(function(n){return a(n)})}};a(E,!0)}var s=function(n,t){if(void 0===t&&(t=!1),n){var o=r(n,t),a=o.lhsNode,u=o.evalResult,c=o.registryNodeId,v=(null==u?void 0:u.deviations)||{},f=l(n.content);Object.entries(v).map(function(n){var e,i=n[0],t=n[1],o=t[F],r=!a||d.isMissingStr(t[On]),s=l(o),u=s?f.indexOf(s):-1,v="".concat(c).concat(d.DEVIATION_BADGE_SEPARATOR).concat(i);return{refId:v,isRenderable:r&&!!s&&!d.isMissingStr(o),position:u,registryIndex:null!==(e=H[v])&&void 0!==e?e:Number.MAX_SAFE_INTEGER}}).filter(function(n){return n.isRenderable}).sort(function(n,e){return(-1===n.position?Number.MAX_SAFE_INTEGER:n.position)-(-1===e.position?Number.MAX_SAFE_INTEGER:e.position)||n.registryIndex-e.registryIndex}).forEach(function(n){e.set(n.refId,i++)}),(n.subsections||[]).forEach(function(n){return s(n)})}};return s(E,!0),e},[G,M,E,K,F,On,H,jn]),Un=Object.keys(Ln)[0],Yn=Un?"".concat(Kn).concat(d.DEVIATION_BADGE_SEPARATOR).concat(Un):null,Jn=Yn?null==U?void 0:U[Yn]:null,Qn=w+1;if(G&&dn){var Zn="left"===M?dn.leftNums.get(null==E?void 0:E.id):dn.rightNums.get(null==E?void 0:E.id);Pn&&void 0!==Zn?Qn=Zn:null!=Jn&&Jn>=0?Qn=Jn:void 0!==Zn&&(Qn=Zn)}else null!=Jn&&Jn>=0&&(Qn=Jn);var $n=Object.entries(Ln).map(function(n){var e=n[0],i=n[1],t="".concat(Kn).concat(d.DEVIATION_BADGE_SEPARATOR).concat(e);return{deviationKey:e,deviationMap:i,refId:t,currentIndex:H[t]}}).filter(function(n){return void 0!==n.currentIndex&&null!==n.currentIndex});$n.sort(function(n,e){return n.currentIndex-e.currentIndex});var ne,ee,ie=$n.map(function(e){var i,t,o,l,r,a,s=e.deviationKey,u=e.deviationMap,c=e.refId,v=e.currentIndex,f=u[F],g=d.isMissingStr(f);if(g)f="";else if(!f)return null;var p=w,h=w;if(G)if("left"===M){var x=null===(i=E.refIndexes)||void 0===i?void 0:i[0],I=X.findIndex(function(n){return n.selfIndex===x});if(-1!==I)h=I;else{var m=X.findIndex(function(n){return n.id===E.id||n.nodeId===E.nodeId||n.contentId===E.contentId});h=-1!==m?m:w}}else{var _=null===(t=E.refIndexes)||void 0===t?void 0:t[0],y=K.findIndex(function(n){return n.selfIndex===_});if(-1!==y)p=y;else p=-1!==(j=K.findIndex(function(n){return n.id===E.id||n.nodeId===E.nodeId||n.contentId===E.contentId}))?j:w}var b="".concat(Kn).concat(d.DEVIATION_BADGE_SEPARATOR).concat(s).concat(d.DEVIATION_BADGE_SEPARATOR).concat(p).concat(d.DEVIATION_BADGE_SEPARATOR).concat(h),S=u[On],A=Pn||d.isMissingStr(S),R=Hn.get(c),O=zn.get(c);G&&"right"===M&&A&&void 0!==R?v=R:G&&"right"===M&&!A&&void 0!==O?v=O:G&&void 0!==jn&&("right"!==M||A||Vn)&&(v-=jn),v=Math.max(1,v);var N=G&&"right"===M&&A&&dn?d.getRhsMappedSectionNumber({section:E,proposedSections:K,leftNums:dn.leftNums,fallbackNumber:String(Qn),firstOnly:!0}):Qn,T="".concat(N,".").concat(v),D=w;if("right"===M&&G){var j,B=null===(o=E.refIndexes)||void 0===o?void 0:o[0],C=K.findIndex(function(n){return n.selfIndex===B});if(-1!==C)D=C;else-1!==(j=K.findIndex(function(n){return n.id===E.id||n.nodeId===E.nodeId||n.contentId===E.contentId}))&&(D=j)}var k=Q?Q(D):null,P=(null==u?void 0:u.evaluation_outputs)||(null==Gn?void 0:Gn.evaluation_outputs),V=null!==(l=null==P?void 0:P.output_value)&&void 0!==l?l:null,W=null!==(a=null===(r=null==P?void 0:P.metadata)||void 0===r?void 0:r.label_color)&&void 0!==a?a:Wn,q=d.generateColorPalette(W),L=k?n.__assign(n.__assign({},k),{badgeBg:q.badgeBg,badgeBorder:q.badgeBorder,badgeText:q.badgeText}):n.__assign({},q),z=(null==u?void 0:u.deviation_summary)?{deviation_summary:u.deviation_summary,deviation_title:(null==u?void 0:u.deviation_title)||(null==Gn?void 0:Gn.deviation_title),deviation_impact:(null==u?void 0:u.deviation_impact)||(null==Gn?void 0:Gn.deviation_impact),deviation_explanation:(null==u?void 0:u.deviation_explanation)||(null==Gn?void 0:Gn.deviation_explanation),evaluation_outputs:P,cognitive_decisioning:(null==u?void 0:u.cognitive_decisioning)||(null==Gn?void 0:Gn.cognitive_decisioning)}:null,H=0,U=xn||"";if(f&&U){var nn=U.split(/\n{2,}/),en=nn.findIndex(function(n){return n.includes(f)});if(-1!==en){var tn=Object.entries(Ln).filter(function(n){n[0];var e=n[1][F];return e&&nn[en].includes(e)}).sort(function(n,e){return nn[en].indexOf(n[1][F])-nn[en].indexOf(e[1][F])}),un=tn.filter(function(n){n[0];var e=n[1][F];return e&&(e.includes(f)||f.includes(e))});un.length>1&&(H=Math.max(0,un.findIndex(function(n){return n[0]===s})))}}var cn=Y(M,c);return{id:c,actionId:b,label:T,highlight:f,side:M,style:L,stackIndex:H,score:V,isConnected:null==Z?void 0:Z.has(b),showScrollLockToggle:(null==Z?void 0:Z.has(b))||on&&ln===b||!!sn&&sn===cn.current,scrollSyncLocked:rn,toggleScrollSyncLocked:an,isOrphan:A,isMissingClause:g,badgeRef:cn,onClick:function(n){n.stopPropagation(),$&&$(n,Tn||{id:"orphan-left",title:"",content:""},A,Dn||{id:"orphan-right",title:"",content:""},b,L)},onSummaryClick:function(n){n.stopPropagation(),J(n,b,A,z)}}}).filter(Boolean),te=q||!gn&&vn?ie:[],oe=ie.map(function(n){return n.highlight}).filter(Boolean),le=E.id&&M===(null==B?void 0:B.columnKey)?B:null,re=u.default.useRef(!1);return i.useEffect(function(){D||(re.current=!1)},[D]),e.jsxs(t.Box,n.__assign({ref:O,sx:{mb:T,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:[D&&(null==le?void 0:le.showAbove)&&e.jsx("div",n.__assign({style:{position:"sticky",top:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==le?void 0:le.showAboveRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:e.jsx("div",n.__assign({style:n.__assign({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===M?"+":"-"," 130px))"),position:"absolute",paddingTop:"20px"},"left"===M?{right:"-20px"}:{left:"-20px"})},{children:e.jsx(o.ChevronUp,{color:(null===(A=null==le?void 0:le.showAboveRef)||void 0===A?void 0:A.current)?window.getComputedStyle(le.showAboveRef.current).color:void 0})}))})),e.jsxs(t.Accordion,n.__assign({disableGutters:!0,expanded:!_n&&D,onChange:function(){_n||(j(),P.current=E.id)},sx:{boxShadow:"none",border:_n?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:_n?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flexGrow:1,width:"100%",display:"flex",flexDirection:"column",minWidth:0,"&:before":{display:"none"},"& .MuiAccordion-heading":{position:"sticky",top:-12,zIndex:10,background:"#fff"}}},{children:[e.jsx(t.AccordionSummary,n.__assign({expandIcon:_n?null:e.jsx(o.ChevronDown,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:_n?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:cn&&e.jsx(t.Tooltip,n.__assign({title:yn,placement:"top"},{children:e.jsx(t.Typography,n.__assign({component:"div",sx:{fontSize:"12px",color:_n?"#94A3B8":"#19213D",fontWeight:_n?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(ne=Sn,ee=bn,void 0===ee&&(ee=!1),ne?d.safeStringify(ne).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(i,t){return i.startsWith("**")&&i.endsWith("**")?e.jsx("strong",{children:i.slice(2,-2)},t):e.jsxs("div",n.__assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px",width:"100%"}},{children:[e.jsx("span",n.__assign({style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:i})),ee&&e.jsx("span",n.__assign({style:{display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"0px 6px",borderRadius:"9999px",background:"#F3F4F6",border:"1px solid #D1D5DB",color:"#6B7280",fontSize:"9px",fontWeight:500,whiteSpace:"nowrap",flexShrink:0,lineHeight:1.4,marginRight:"4px"}},{children:"Multiple"}))]}),t)}):null)}))}))})),!_n&&e.jsxs(t.AccordionDetails,n.__assign({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[mn&&e.jsx(l.MemoizedMarkdown,{content:xn,overlayContent:In,sxStyles:V,highlights:oe,maintainRelativeOrder:G,highlightBg:qn,suppressHighlightBg:pn,deviationBadges:te,collisionKey:un}),(E.subsections||[]).map(function(n,e){return L({section:n,keyPath:"".concat(w,"-").concat(e),depth:0,columnKey:M,parentNodeId:F,sectionOffset:jn,rhsOrphanVisualIndexes:Hn})})]}))]})),D&&(null==le?void 0:le.showBelow)&&e.jsx("div",n.__assign({style:{position:"sticky",bottom:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==le?void 0:le.showBelowRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:e.jsx("div",n.__assign({style:n.__assign({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===M?"+":"-"," 130px))"),position:"absolute",paddingBottom:"20px"},"left"===M?{right:"-20px"}:{left:"-20px"})},{children:e.jsx(o.ChevronDown,{color:(null===(R=null==le?void 0:le.showBelowRef)||void 0===R?void 0:R.current)?window.getComputedStyle(le.showBelowRef.current).color:void 0})}))}))]}),"".concat(M,"-sec-").concat(w))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("tslib"),e=require("react/jsx-runtime"),i=require("react"),t=require("@mui/material"),o=require("lucide-react"),l=require("../hooks/memoizedMarkdown.js"),r=require("../CompareContext.js"),d=require("../CognitiveComparehelpers.js"),a=require("../CognitiveCompareConstants.js");function s(n){return n&&"object"==typeof n&&"default"in n?n:{default:n}}var u=s(i);exports.default=function(s){var c,v,f,g,p,h,x,I,m,_,y,S,b,R,A,E=s.section,w=s.idx,M=s.columnKey,O=s.colRef,T=s.mb,N=void 0===T?1:T,D=s.isExpanded,j=s.onToggle,B=s.navigation,C=s.parentNodeId,F=void 0===C?"":C,k=r.useCompareContext(),P=k.showOpenNodeRef,V=k.resolvedMarkdownStyles,G=k.maintainRelativeOrder,W=k.showDeviationBadges,q=void 0!==W&&W,L=k.renderSubSectionAccordion,z=k.treeData,K=k.proposedSections,X=k.existingSections,H=k.deviationNumberRegistry,U=k.deviationParentRegistry,Y=k.getBadgeRef,J=k.openSummaryPopup,Q=k.getSectionCompareStyle,Z=k.connectedSections,$=k.openMoreFunctionsPopup,nn=k.isProposingFix,en=k.proposingFixNodeId,tn=k.isRedlineFlow,on=k.isSideBySide,ln=k.activeSideBySideSection,rn=k.scrollSyncLocked,dn=k.unifiedNumbering,an=k.toggleScrollSyncLocked,sn=k.summaryPopupAnchorEl,un="".concat(on?"1":"0","-").concat(String(null!=ln?ln:"")),cn=(null===(c=E.displayTitle)||void 0===c||c)&&d.hasValue(E.title),vn=!(!nn||!en||"left"!==M||E.id!==en&&E.nodeId!==en),fn=d.hasMeaningfulRedlineTags(E.content),gn="boolean"==typeof tn?tn:fn,pn=fn,hn=gn&&fn,xn=hn?d.hasValue(E.change_history)?d.safeStringify(E.change_history):d.stripRedlineTags(E.content):E.content,In=hn?E.content:void 0,mn=(null===(v=E.displayContent)||void 0===v||v||fn)&&d.hasValue(E.content),_n=!cn&&!mn,yn=E.title;cn||(yn=mn?"No Title Found":"No Matching Section Found");var Sn="left"===M&&(E.isMultipleMapping||(null!==(g=null===(f=E.refContentIds)||void 0===f?void 0:f.length)&&void 0!==g?g:1)>1),bn="left"===M&&yn.length>29?"".concat(yn.slice(0,29).trimEnd(),"..."):yn,Rn=E.evaluationResult;if(!Rn&&"right"===M)if(G){var An=null===(p=E.refIndexes)||void 0===p?void 0:p[0],En=K.find(function(n){return n.selfIndex===An});Rn=null==En?void 0:En.evaluationResult}else Rn=null===(h=K[w])||void 0===h?void 0:h.evaluationResult;var wn=null===(x=null==z?void 0:z.input_index_map)||void 0===x?void 0:x[0],Mn=null===(I=null==z?void 0:z.input_index_map)||void 0===I?void 0:I[1],On="left"===M?Mn:wn,Tn=function(n,e){var i;if(!e||!n)return null;for(var t=0,o=n;t<o.length;t++){var l=o[t];if(l.id===e||l.nodeId===e||l.contentId===e)return l;if(null===(i=l.subsections)||void 0===i?void 0:i.length){var r=Tn(l.subsections,e);if(r)return r}}return null},Nn="left"===M?E:Tn(K,E.id),Dn="right"===M?E:Tn(X,E.id),jn=u.default.useMemo(function(){if(!G)return 0;var n=1/0,e=function(n){var e=d.hasMeaningfulRedlineTags(n)?d.stripRedlineTags(n):n;return d.safeStringify(e||"").replace(/\\n/g,"\n")},i=function(t,o,l,r){if(t){var a=t.nodeId||t.id;if(r&&"right"===M){var s=K.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(t.selfIndex)});s.length>0&&(a=s[0].nodeId||s[0].id)}var u=t.nodeId||t.id||(null==o?void 0:o.nodeId)||(null==o?void 0:o.id)||(null==l?void 0:l.nodeId)||(null==l?void 0:l.id),c=t.evaluationResult||(null==o?void 0:o.evaluationResult)||(null==l?void 0:l.evaluationResult),v=(null==c?void 0:c.deviations)||{};Object.keys(v).forEach(function(i){var r,s=null===(r=v[i])||void 0===r?void 0:r[F];if(function(n,i){if("string"!=typeof i||d.isMissingStr(i))return!1;var t=e(null==n?void 0:n.content),o=e(i);return!!o&&!!d.findTextMatchRange(t,o)}("left"===M?o||t:l||t,s)){var c="".concat(a).concat(d.DEVIATION_BADGE_SEPARATOR).concat(i),f=null==H?void 0:H[c];null!=f&&f<n&&(n=f);var g="".concat(u).concat(d.DEVIATION_BADGE_SEPARATOR).concat(i),p=null==H?void 0:H[g];null!=p&&p<n&&(n=p)}});for(var f=t.subsections||[],g=(null==o?void 0:o.subsections)||[],p=(null==l?void 0:l.subsections)||[],h=Math.max(f.length,g.length,p.length),x=0;x<h;x++)i(f[x],g[x],p[x],!1)}},t="right"===M?K.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(E.selfIndex)}):[];if(1===t.length){var o=t[0];(o.refIndexes||[]).map(function(n){return X.find(function(e){return e.selfIndex===n})}).filter(Boolean).forEach(function(n){i(n,o,n,!0)})}else i(E,Nn,Dn,!0);return n!==1/0?n-1:0},[E,Nn,Dn,M,F,H,G,K,X]);if(G)if("left"===M){var Bn=null===(m=E.refIndexes)||void 0===m?void 0:m[0],Cn=X.findIndex(function(n){return n.selfIndex===Bn});Dn=-1!==Cn?X[Cn]:Tn(X,E.id)}else{var Fn=null===(_=E.refIndexes)||void 0===_?void 0:_[0],kn=K.findIndex(function(n){return n.selfIndex===Fn});Nn=-1!==kn?K[kn]:Tn(K,E.id)}var Pn="left"===M?!Dn:!Nn,Vn=G&&"right"===M&&d.hasSingleMappedLhsSection(E,K),Gn=Rn||(null==Nn?void 0:Nn.evaluationResult)||(null==Dn?void 0:Dn.evaluationResult),Wn=null!==(b=null===(S=null===(y=null==Gn?void 0:Gn.evaluation_outputs)||void 0===y?void 0:y.metadata)||void 0===S?void 0:S.label_color)&&void 0!==b?b:a.DEFAULT_DEVIAION_COLOR,qn=d.generateColorPalette(Wn).highlightBg,Ln=(null==Gn?void 0:Gn.deviations)||{},zn=u.default.useMemo(function(){return G&&"right"===M?d.getLhsDeviationDisplayIndexes(K,wn,H):new Map},[G,M,K,wn,H]),Kn=E.nodeId||E.id;if(G&&"left"!==M){var Xn=K.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(E.selfIndex)});Xn.length>0?Kn=Xn[0].nodeId||Xn[0].id:(null==Nn?void 0:Nn.id)&&(Kn=Nn.nodeId||Nn.id)}var Hn=u.default.useMemo(function(){var n,e=new Map;if(!G||"right"!==M)return e;var i=1,t=K.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(E.selfIndex)}),o=1===t.length&&1===(null===(n=t[0].refIndexes)||void 0===n?void 0:n.length),l=function(n){return d.safeStringify(n||"").replace(/\\n/g,"\n")},r=function(n,e){var i=e?t[0]:Tn(K,n.nodeId||n.id||n.contentId);return{lhsNode:i,evalResult:n.evaluationResult||(null==i?void 0:i.evaluationResult),registryNodeId:i?i.nodeId||i.id:n.nodeId||n.id}};if(o){var a=function(n,e){if(void 0===e&&(e=!1),n){var t=r(n,e),o=t.lhsNode,s=t.evalResult,u=t.registryNodeId,c=l(n.content);Object.entries((null==s?void 0:s.deviations)||{}).forEach(function(n){var e=n[0],t=n[1],r=t[F],a=l(r);if(!!o&&!d.isMissingStr(t[On])&&a&&d.findTextMatchRange(c,a)){var s="".concat(u).concat(d.DEVIATION_BADGE_SEPARATOR).concat(e),v=H[s];null!=v&&(i=Math.max(i,Math.max(1,v-(jn||0))+1))}}),(n.subsections||[]).forEach(function(n){return a(n)})}};a(E,!0)}var s=function(n,t){if(void 0===t&&(t=!1),n){var o=r(n,t),a=o.lhsNode,u=o.evalResult,c=o.registryNodeId,v=(null==u?void 0:u.deviations)||{},f=l(n.content);Object.entries(v).map(function(n){var e,i,t,o=n[0],r=n[1],s=r[F],u=!a||d.isMissingStr(r[On]),v=l(s),g=v&&null!==(i=null===(e=d.findTextMatchRange(f,v))||void 0===e?void 0:e.start)&&void 0!==i?i:-1,p="".concat(c).concat(d.DEVIATION_BADGE_SEPARATOR).concat(o);return{refId:p,isRenderable:u&&!!v&&!d.isMissingStr(s),position:g,registryIndex:null!==(t=H[p])&&void 0!==t?t:Number.MAX_SAFE_INTEGER}}).filter(function(n){return n.isRenderable}).sort(function(n,e){return(-1===n.position?Number.MAX_SAFE_INTEGER:n.position)-(-1===e.position?Number.MAX_SAFE_INTEGER:e.position)||n.registryIndex-e.registryIndex}).forEach(function(n){e.set(n.refId,i++)}),(n.subsections||[]).forEach(function(n){return s(n)})}};return s(E,!0),e},[G,M,E,K,F,On,H,jn]),Un=Object.keys(Ln)[0],Yn=Un?"".concat(Kn).concat(d.DEVIATION_BADGE_SEPARATOR).concat(Un):null,Jn=Yn?null==U?void 0:U[Yn]:null,Qn=w+1;if(G&&dn){var Zn="left"===M?dn.leftNums.get(null==E?void 0:E.id):dn.rightNums.get(null==E?void 0:E.id);Pn&&void 0!==Zn?Qn=Zn:null!=Jn&&Jn>=0?Qn=Jn:void 0!==Zn&&(Qn=Zn)}else null!=Jn&&Jn>=0&&(Qn=Jn);var $n=Object.entries(Ln).map(function(n){var e=n[0],i=n[1],t="".concat(Kn).concat(d.DEVIATION_BADGE_SEPARATOR).concat(e);return{deviationKey:e,deviationMap:i,refId:t,currentIndex:H[t]}}).filter(function(n){return void 0!==n.currentIndex&&null!==n.currentIndex});$n.sort(function(n,e){return n.currentIndex-e.currentIndex});var ne,ee,ie=$n.map(function(e){var i,t,o,l,r,a,s=e.deviationKey,u=e.deviationMap,c=e.refId,v=e.currentIndex,f=u[F],g=d.isMissingStr(f);if(g)f="";else if(!f)return null;var p=w,h=w;if(G)if("left"===M){var x=null===(i=E.refIndexes)||void 0===i?void 0:i[0],I=X.findIndex(function(n){return n.selfIndex===x});if(-1!==I)h=I;else{var m=X.findIndex(function(n){return n.id===E.id||n.nodeId===E.nodeId||n.contentId===E.contentId});h=-1!==m?m:w}}else{var _=null===(t=E.refIndexes)||void 0===t?void 0:t[0],y=K.findIndex(function(n){return n.selfIndex===_});if(-1!==y)p=y;else p=-1!==(j=K.findIndex(function(n){return n.id===E.id||n.nodeId===E.nodeId||n.contentId===E.contentId}))?j:w}var S="".concat(Kn).concat(d.DEVIATION_BADGE_SEPARATOR).concat(s).concat(d.DEVIATION_BADGE_SEPARATOR).concat(p).concat(d.DEVIATION_BADGE_SEPARATOR).concat(h),b=u[On],R=Pn||d.isMissingStr(b),A=Hn.get(c),O=zn.get(c);G&&"right"===M&&R&&void 0!==A?v=A:G&&"right"===M&&!R&&void 0!==O?v=O:G&&void 0!==jn&&("right"!==M||R||Vn)&&(v-=jn),v=Math.max(1,v);var T=G&&"right"===M&&R&&dn?d.getRhsMappedSectionNumber({section:E,proposedSections:K,leftNums:dn.leftNums,fallbackNumber:String(Qn),firstOnly:!0}):Qn,N="".concat(T,".").concat(v),D=w;if("right"===M&&G){var j,B=null===(o=E.refIndexes)||void 0===o?void 0:o[0],C=K.findIndex(function(n){return n.selfIndex===B});if(-1!==C)D=C;else-1!==(j=K.findIndex(function(n){return n.id===E.id||n.nodeId===E.nodeId||n.contentId===E.contentId}))&&(D=j)}var k=Q?Q(D):null,P=(null==u?void 0:u.evaluation_outputs)||(null==Gn?void 0:Gn.evaluation_outputs),V=null!==(l=null==P?void 0:P.output_value)&&void 0!==l?l:null,W=null!==(a=null===(r=null==P?void 0:P.metadata)||void 0===r?void 0:r.label_color)&&void 0!==a?a:Wn,q=d.generateColorPalette(W),L=k?n.__assign(n.__assign({},k),{badgeBg:q.badgeBg,badgeBorder:q.badgeBorder,badgeText:q.badgeText}):n.__assign({},q),z=(null==u?void 0:u.deviation_summary)?{deviation_summary:u.deviation_summary,deviation_title:(null==u?void 0:u.deviation_title)||(null==Gn?void 0:Gn.deviation_title),deviation_impact:(null==u?void 0:u.deviation_impact)||(null==Gn?void 0:Gn.deviation_impact),deviation_explanation:(null==u?void 0:u.deviation_explanation)||(null==Gn?void 0:Gn.deviation_explanation),evaluation_outputs:P,cognitive_decisioning:(null==u?void 0:u.cognitive_decisioning)||(null==Gn?void 0:Gn.cognitive_decisioning)}:null,H=0,U=xn||"";if(f&&U){var nn=U.split(/\n{2,}/),en=nn.findIndex(function(n){return n.includes(f)});if(-1!==en){var tn=Object.entries(Ln).filter(function(n){n[0];var e=n[1][F];return e&&nn[en].includes(e)}).sort(function(n,e){return nn[en].indexOf(n[1][F])-nn[en].indexOf(e[1][F])}),un=tn.filter(function(n){n[0];var e=n[1][F];return e&&(e.includes(f)||f.includes(e))});un.length>1&&(H=Math.max(0,un.findIndex(function(n){return n[0]===s})))}}var cn=Y(M,c);return{id:c,actionId:S,label:N,highlight:f,side:M,style:L,stackIndex:H,score:V,isConnected:null==Z?void 0:Z.has(S),showScrollLockToggle:(null==Z?void 0:Z.has(S))||on&&ln===S||!!sn&&sn===cn.current,scrollSyncLocked:rn,toggleScrollSyncLocked:an,isOrphan:R,isMissingClause:g,badgeRef:cn,onClick:function(n){n.stopPropagation(),$&&$(n,Nn||{id:"orphan-left",title:"",content:""},R,Dn||{id:"orphan-right",title:"",content:""},S,L)},onSummaryClick:function(n){n.stopPropagation(),J(n,S,R,z)}}}).filter(Boolean),te=q||!gn&&vn?ie:[],oe=ie.map(function(n){return n.highlight}).filter(Boolean),le=E.id&&M===(null==B?void 0:B.columnKey)?B:null,re=u.default.useRef(!1);return i.useEffect(function(){D||(re.current=!1)},[D]),e.jsxs(t.Box,n.__assign({ref:O,sx:{mb:N,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:[D&&(null==le?void 0:le.showAbove)&&e.jsx("div",n.__assign({style:{position:"sticky",top:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==le?void 0:le.showAboveRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:e.jsx("div",n.__assign({style:n.__assign({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===M?"+":"-"," 130px))"),position:"absolute",paddingTop:"20px"},"left"===M?{right:"-20px"}:{left:"-20px"})},{children:e.jsx(o.ChevronUp,{color:(null===(R=null==le?void 0:le.showAboveRef)||void 0===R?void 0:R.current)?window.getComputedStyle(le.showAboveRef.current).color:void 0})}))})),e.jsxs(t.Accordion,n.__assign({disableGutters:!0,expanded:!_n&&D,onChange:function(){_n||(j(),P.current=E.id)},sx:{boxShadow:"none",border:_n?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:_n?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flexGrow:1,width:"100%",display:"flex",flexDirection:"column",minWidth:0,"&:before":{display:"none"},"& .MuiAccordion-heading":{position:"sticky",top:-12,zIndex:10,background:"#fff"}}},{children:[e.jsx(t.AccordionSummary,n.__assign({expandIcon:_n?null:e.jsx(o.ChevronDown,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:_n?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:cn&&e.jsx(t.Tooltip,n.__assign({title:yn,placement:"top"},{children:e.jsx(t.Typography,n.__assign({component:"div",sx:{fontSize:"12px",color:_n?"#94A3B8":"#19213D",fontWeight:_n?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(ne=bn,ee=Sn,void 0===ee&&(ee=!1),ne?d.safeStringify(ne).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(i,t){return i.startsWith("**")&&i.endsWith("**")?e.jsx("strong",{children:i.slice(2,-2)},t):e.jsxs("div",n.__assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px",width:"100%"}},{children:[e.jsx("span",n.__assign({style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:i})),ee&&e.jsx("span",n.__assign({style:{display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"0px 6px",borderRadius:"9999px",background:"#F3F4F6",border:"1px solid #D1D5DB",color:"#6B7280",fontSize:"9px",fontWeight:500,whiteSpace:"nowrap",flexShrink:0,lineHeight:1.4,marginRight:"4px"}},{children:"Multiple"}))]}),t)}):null)}))}))})),!_n&&e.jsxs(t.AccordionDetails,n.__assign({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[mn&&e.jsx(l.MemoizedMarkdown,{content:xn,overlayContent:In,sxStyles:V,highlights:oe,maintainRelativeOrder:G,highlightBg:qn,suppressHighlightBg:pn,deviationBadges:te,collisionKey:un}),(E.subsections||[]).map(function(n,e){return L({section:n,keyPath:"".concat(w,"-").concat(e),depth:0,columnKey:M,parentNodeId:F,sectionOffset:jn,rhsOrphanVisualIndexes:Hn})})]}))]})),D&&(null==le?void 0:le.showBelow)&&e.jsx("div",n.__assign({style:{position:"sticky",bottom:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==le?void 0:le.showBelowRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:e.jsx("div",n.__assign({style:n.__assign({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===M?"+":"-"," 130px))"),position:"absolute",paddingBottom:"20px"},"left"===M?{right:"-20px"}:{left:"-20px"})},{children:e.jsx(o.ChevronDown,{color:(null===(A=null==le?void 0:le.showBelowRef)||void 0===A?void 0:A.current)?window.getComputedStyle(le.showBelowRef.current).color:void 0})}))}))]}),"".concat(M,"-sec-").concat(w))};
2
2
  //# sourceMappingURL=SectionAccordion.js.map