@viswa-test/test-citation 0.0.370 → 0.0.372

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 (86) 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/Guidelines/components/GuidelinePanel.js +1 -1
  6. package/dist/cjs/features/CognitiveCompare/Guidelines/components/WebGptPanel.js +1 -1
  7. package/dist/cjs/features/CognitiveCompare/Guidelines/utils/hasGptCitationObjects.js +2 -0
  8. package/dist/cjs/features/CognitiveCompare/Guidelines/utils/hasGptCitationObjects.js.map +1 -0
  9. package/dist/cjs/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js +1 -1
  10. package/dist/cjs/features/CognitiveCompare/components/SectionAccordion.js +1 -1
  11. package/dist/cjs/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
  12. package/dist/cjs/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
  13. package/dist/cjs/features/CognitiveCompare/hooks/useCompareData.js +1 -1
  14. package/dist/cjs/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
  15. package/dist/cjs/features/CognitiveCompare/hooks/useSideBySide.js +1 -1
  16. package/dist/cjs/features/CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.js +1 -1
  17. package/dist/cjs/features/GptWebCitation/GptWebCitation.js +1 -1
  18. package/dist/cjs/features/GptWebCitation/GptWebCitationImageCitation.js +1 -1
  19. package/dist/cjs/features/GptWebCitation/utils/fixedHeight.utils.js +1 -1
  20. package/dist/cjs/features/PdfViewer/PdfContainer.js +1 -1
  21. package/dist/cjs/features/PdfViewer/PdfStyle.js +1 -1
  22. package/dist/cjs/features/PdfViewer/PdfToolbar.js +1 -1
  23. package/dist/cjs/features/PdfViewer/PdfViewer.js +1 -1
  24. package/dist/cjs/index.js +1 -1
  25. package/dist/features/CognitiveCompare/CitationAnchor.js +1 -1
  26. package/dist/features/CognitiveCompare/CognitiveCompare.js +1 -1
  27. package/dist/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
  28. package/dist/features/CognitiveCompare/CognitivePopup.js +1 -1
  29. package/dist/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js +1 -1
  30. package/dist/features/CognitiveCompare/Guidelines/components/WebGptPanel.js +1 -1
  31. package/dist/features/CognitiveCompare/Guidelines/utils/hasGptCitationObjects.js +2 -0
  32. package/dist/features/CognitiveCompare/Guidelines/utils/hasGptCitationObjects.js.map +1 -0
  33. package/dist/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js +1 -1
  34. package/dist/features/CognitiveCompare/components/SectionAccordion.js +1 -1
  35. package/dist/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
  36. package/dist/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
  37. package/dist/features/CognitiveCompare/hooks/useCompareData.js +1 -1
  38. package/dist/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
  39. package/dist/features/CognitiveCompare/hooks/useSideBySide.js +1 -1
  40. package/dist/features/CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.js +1 -1
  41. package/dist/features/GptWebCitation/GptWebCitation.js +1 -1
  42. package/dist/features/GptWebCitation/GptWebCitationImageCitation.js +1 -1
  43. package/dist/features/GptWebCitation/utils/fixedHeight.utils.js +1 -1
  44. package/dist/features/PdfViewer/PdfContainer.js +1 -1
  45. package/dist/features/PdfViewer/PdfStyle.js +1 -1
  46. package/dist/features/PdfViewer/PdfToolbar.js +1 -1
  47. package/dist/features/PdfViewer/PdfViewer.js +1 -1
  48. package/dist/index.js +1 -1
  49. package/dist/types/src/features/CognitiveCompare/CitationAnchor.d.ts.map +1 -1
  50. package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts +1 -1
  51. package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts.map +1 -1
  52. package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts +1 -1
  53. package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts.map +1 -1
  54. package/dist/types/src/features/CognitiveCompare/CognitiveComparehelpers.d.ts +12 -0
  55. package/dist/types/src/features/CognitiveCompare/CognitiveComparehelpers.d.ts.map +1 -1
  56. package/dist/types/src/features/CognitiveCompare/Guidelines/components/GuidelinePanel.d.ts.map +1 -1
  57. package/dist/types/src/features/CognitiveCompare/Guidelines/components/WebGptPanel.d.ts.map +1 -1
  58. package/dist/types/src/features/CognitiveCompare/Guidelines/utils/hasGptCitationObjects.d.ts +3 -0
  59. package/dist/types/src/features/CognitiveCompare/Guidelines/utils/hasGptCitationObjects.d.ts.map +1 -0
  60. package/dist/types/src/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.d.ts +14 -1
  61. package/dist/types/src/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.d.ts.map +1 -1
  62. package/dist/types/src/features/CognitiveCompare/components/SectionAccordion.d.ts.map +1 -1
  63. package/dist/types/src/features/CognitiveCompare/components/SubSectionAccordion.d.ts.map +1 -1
  64. package/dist/types/src/features/CognitiveCompare/hooks/memoizedMarkdown.d.ts.map +1 -1
  65. package/dist/types/src/features/CognitiveCompare/hooks/useCompareData.d.ts +1 -1
  66. package/dist/types/src/features/CognitiveCompare/hooks/useCompareData.d.ts.map +1 -1
  67. package/dist/types/src/features/CognitiveCompare/hooks/useLinesCalculator.d.ts.map +1 -1
  68. package/dist/types/src/features/CognitiveCompare/hooks/useSideBySide.d.ts.map +1 -1
  69. package/dist/types/src/features/CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.d.ts +1 -0
  70. package/dist/types/src/features/CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.d.ts.map +1 -1
  71. package/dist/types/src/features/GptWebCitation/GptWebCitation.d.ts.map +1 -1
  72. package/dist/types/src/features/GptWebCitation/GptWebCitationImageCitation.d.ts +2 -1
  73. package/dist/types/src/features/GptWebCitation/GptWebCitationImageCitation.d.ts.map +1 -1
  74. package/dist/types/src/features/GptWebCitation/types.d.ts +11 -0
  75. package/dist/types/src/features/GptWebCitation/types.d.ts.map +1 -1
  76. package/dist/types/src/features/GptWebCitation/utils/fixedHeight.utils.d.ts +2 -0
  77. package/dist/types/src/features/GptWebCitation/utils/fixedHeight.utils.d.ts.map +1 -1
  78. package/dist/types/src/features/PdfViewer/PdfContainer.d.ts +2 -4
  79. package/dist/types/src/features/PdfViewer/PdfContainer.d.ts.map +1 -1
  80. package/dist/types/src/features/PdfViewer/PdfStyle.d.ts.map +1 -1
  81. package/dist/types/src/features/PdfViewer/PdfToolbar.d.ts.map +1 -1
  82. package/dist/types/src/features/PdfViewer/PdfViewer.d.ts +2 -18
  83. package/dist/types/src/features/PdfViewer/PdfViewer.d.ts.map +1 -1
  84. package/dist/types/src/index.d.ts +0 -4
  85. package/dist/types/src/index.d.ts.map +1 -1
  86. package/package.json +2 -2
@@ -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");require("./utils/normalizeRedlineMarkdown.js");var 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(),M=T[0],k=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?(k(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("div",e.__assign({style:{overflowY:"auto"}},{children:i.jsx(p.default,{gptCitation:A,defaultCitationUrl:(null==x?void 0:x.citationUrl)||"",citationType:g.CitationType.GPT_WEB,webCitationData:M,webCitationStatus:I,showWebCitation:U,onToggleCitationView:function(){return E(function(e){return!e})},iconsConfig:{MaximizeIcon:n.Maximize2,ExternalLinkIcon:n.ExternalLink},showGptMaximizeButton:!1,useParentHeight:!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,M=P.phraseToHighlight,k=P.citationTypeFromHref,N=C||k||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,z=A?G[A]:null,W=q?R[q]:null,O=A?R[A]:null,B=t.useMemo(function(){var e,n,t,o;return W&&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==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==H?void 0:H.title,null==H?void 0:H.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]),L=t.useMemo(function(){var e,n,t,o;return O&&z?i.jsx(l.default,{defaultScale:"PageWidth",showFullScreenAction:!1,showHighlightsAction:!1,pdfName:null==z?void 0:z.title,pdfUrl:null==z?void 0:z.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==z?void 0:z.title,null==z?void 0:z.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,Y=V&&!!(null==b?void 0:b.webGpt),J=t.useMemo(function(){var n=Y?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:[M],labelColor:"#FEF08A"})}))}))}):L;return i.jsx(o.default,{leftComponent:B,rightComponent:n,isFullscreen:j})},[B,L,I,Y,b,j,D,M,F]);return(null==b?void 0:b.webGpt)&&!E?i.jsx(S,{metaData:b,isFullscreen:j,onFullscreenChange:F}):T?"rulebook_citation"===I?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:w||"Rulebook citation selected."})):V?W||O?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,onFullscreenChange:F}):i.jsx("div",{children:"Missing PDF Citation. Please try again later"}):["contract","clause"].includes(y)?W||O?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,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,M=t.useState(S),k=M[0],N=M[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:k?q:A}))]}))})),k&&(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"),O=require("./components/GuidelineSkeletonLoader.js"),j=require("./Guidelines/utils/guidelineTargets.js"),F=require("./Guidelines/utils/hasGptCitationObjects.js");exports.SHARED_MARKDOWN_STYLES=s.SHARED_MARKDOWN_STYLES,exports.default=function(k){var P,N,M,L,q,G,H,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,pe,he,me=k.componentHeaderText,Se=void 0===me?a.DEFAULT_COMPONENT_HEADER_TEXT:me,Re=k.treeData,xe=k.comparisonConfig,_e=k.leftColumnTitleText,be=k.rightColumnTitleText,ye=k.markdownStyles,Ce=k.resetTrigger,Ee=k.displayConfig,Ae=void 0===Ee?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1,displayEmailNotifier:!0,isStreamingEnabled:!1}:Ee,Te=k.onMaintainRelativeOrderChange,we=k.popupConfig,Ie=k.deviationData,Be=void 0===Ie?{}:Ie,De=k.deviationNodeIdToView,Oe=k.resetDeviationNodeId,je=k.isProposingFix,Fe=void 0!==je&&je,ke=k.proposingFixNodeId,Pe=k.isRedlineFlow,Ne=k.badgeStyleOverride,Me=k.guidelinesData,Le=k.isGuidelineMode,qe=k.gptWebCitationConfig,Ge=i.useState(Ae.maintainRelativeOrder),He=Ge[0],Ve=Ge[1],We=null!==(P=null==Ae?void 0:Ae.expandLevels)&&void 0!==P?P:0,ze=!!(null==Ae?void 0:Ae.expandAllSections),Ke=!!He||!!(null==Ae?void 0:Ae.showDeviationBadges),Ue=i.useState(!1),Ye=Ue[0],Je=Ue[1],Xe=i.useState(null),$e=Xe[0],Qe=Xe[1],Ze=i.useState(null===(M=null!==(N=null==Re?void 0:Re.newEvaluationResult)&&void 0!==N?N:null==Ae?void 0:Ae.enableDeviationSchemaBackwardCompatibility)||void 0===M||M)[0],en=i.useState(new Set),nn=en[0],tn=en[1],on=i.useState([]),rn=on[0],ln=on[1],un=i.useState(!1),sn=un[0],an=un[1],cn=i.useState(0),dn=cn[0],fn=cn[1],vn=i.useRef(null),gn=i.useRef(null),pn=i.useRef(null),hn=i.useRef(null),mn=i.useRef(null),Sn=i.useRef(!1),Rn=i.useRef(null),xn=i.useRef({}),_n=i.useRef([]),bn=i.useRef(function(){}),yn=i.useRef(null),Cn=i.useRef(function(){}),En=i.useMemo(function(){return JSON.stringify(Be||{})},[JSON.stringify(Be)]),An=i.useMemo(function(){return Be||{}},[En]),Tn=i.useMemo(function(){return F.hasGptCitationObjects(An)},[An]),wn=i.useMemo(function(){return(null==Re?void 0:Re.cognitive_decisioning)||{}},[Re]),In=i.useMemo(function(){return e.__assign(e.__assign({},s.SHARED_MARKDOWN_STYLES),ye)},[ye]),Bn=i.useRef(null),Dn=i.useRef(null),On=i.useRef(null),jn=i.useRef(null),Fn=i.useRef(null),kn=i.useRef(null),Pn=i.useRef(null),Nn=i.useRef(null),Mn=i.useRef(null),Ln=i.useRef(null),qn=p.useComparePopups(Bn),Gn=qn.cognitivePopup,Hn=qn.setCognitivePopup,Vn=qn.moreFunctions,Wn=qn.setMoreFunctions,zn=qn.position,Kn=qn.setPosition,Un=qn.activeBadgeId,Yn=qn.summaryPopup,Jn=qn.setSummaryPopup,Xn=qn.closeSummaryPopup,$n=qn.setActiveBadgeId,Qn=qn.popupRef,Zn=qn.handleOpenCognitiveCompare,ei=qn.openCognitivePopupFromState,ni=qn.closeCognitivePopup,ii=qn.closeMoreFunctionsPopup,ti=i.useMemo(function(){var e,n,i,t,o,r,l;return{fields:null!==(e=null==xe?void 0:xe.fields)&&void 0!==e?e:s.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(i=null===(n=null==xe?void 0:xe.thresholds)||void 0===n?void 0:n.high)&&void 0!==i?i:s.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(o=null===(t=null==xe?void 0:xe.thresholds)||void 0===t?void 0:t.medium)&&void 0!==o?o:s.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(l=null===(r=null==xe?void 0:xe.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:s.DEFAULT_COMPARISON_CONFIG.thresholds.exact}}},[xe]),oi=i.useState(null),ri=oi[0];oi[1];var li=null===(G=null===(L=null==Re?void 0:Re.documents)||void 0===L?void 0:L[null===(q=null==Re?void 0:Re.input_index_map)||void 0===q?void 0:q[0]])||void 0===G?void 0:G.title,ui=null===(W=null===(H=null==Re?void 0:Re.documents)||void 0===H?void 0:H[null===(V=null==Re?void 0:Re.input_index_map)||void 0===V?void 0:V[1]])||void 0===W?void 0:W.title,si=u.safeStringify(_e||li||"Uploaded Contract"),ai=null===(Y=null===(U=null===(z=null==Re?void 0:Re.documents)||void 0===z?void 0:z[null===(K=null==Re?void 0:Re.input_index_map)||void 0===K?void 0:K[0]])||void 0===U?void 0:U.metadata)||void 0===Y?void 0:Y.file_name,ci=u.safeStringify(ai),di=null===(Q=null===($=null===(J=null==Re?void 0:Re.documents)||void 0===J?void 0:J[null===(X=null==Re?void 0:Re.input_index_map)||void 0===X?void 0:X[1]])||void 0===$?void 0:$.metadata)||void 0===Q?void 0:Q.file_name,fi=u.safeStringify(di),vi=u.safeStringify(be||ui||"Reference Template"),gi=g.useCognitiveTreeData(Re,He,An,ti,Ze,Me,Le),pi=gi.isGuidelineMode,hi=gi.activeProposed,mi=gi.existingRule,Si=gi.proposedSections,Ri=gi.existingSections,xi=gi.visibleFields,_i=gi.parentDeviationRecord,bi=gi.deviationNumberRegistry,yi=gi.deviationParentRegistry,Ci=gi.parseError;i.useEffect(function(){Ci&&Qe("Failed to load comparison: ".concat(Ci))},[Ci]);var Ei=Si.length>0||Ri.length>0,Ai=i.useMemo(function(){if(!Pe)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(Si),i(Ri),"".concat(e,":").concat(n)},[Pe,Si,Ri]);i.useEffect(function(){if(Si.length||Ri.length)if(ze){var e={},n={},i=function(i,t){i.forEach(function(i,o){var r,l=He?"".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(Si,"left"),i(Ri,"right"),st(e),ct(n)}else if(We>0){var t={},o={},r=function(e,n,i){e.forEach(function(e,r){var l;if(i>=1){var u=He?"".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(Si,"left",We),r(Ri,"right",We),st(t),ct(o)}},[ze,We,Si,Ri,He]);var Ti=h.useSectionRefs(xi.map(function(e){return e.key}),Math.max(Si.length,Ri.length)),wi=Ti.leftRefs,Ii=Ti.rightRefs,Bi=Ti.sectionLeftRefs,Di=Ti.sectionRightRefs,Oi=Ti.lhsBadgeRefs,ji=Ti.rhsBadgeRefs,Fi=Ti.sectionRightRowRefs,ki=Ti.subSectionLeftRefs,Pi=Ti.subSectionRightRefs,Ni=Ti.sectionRowRefs,Mi=Ti.getSectionRowRef,Li=Ti.getSubSectionRef,qi=Ti.getBadgeRef,Gi=w.useSideBySide({isGuidelineMode:pi,maintainRelativeOrder:He,proposedSections:Si,existingSections:Ri,leftContainerRef:Nn,rightContainerRef:On,scrollContainerRef:Bn,sectionLeftRefs:Bi,sectionRightRefs:Di,subSectionLeftRefs:ki,subSectionRightRefs:Pi,lhsBadgeRefs:Oi,rhsBadgeRefs:ji,sectionRowRefs:Ni,sectionRightRowRefs:Fi,rhsTopSpacerRef:jn,rhsBottomSpacerRef:Fn,lhsTopSpacerRef:kn,lhsBottomSpacerRef:Pn,calculateLinesRef:bn,setConnectedSections:tn,setConnectedLines:ln,cachedConnectedPositions:_n,closeMoreFunctionsPopup:ii,setErrorToast:Qe,moreFunctions:Vn,closeSummaryPopup:Xn}),Hi=Gi.isSideBySide,Vi=Gi.isArrowVisible,Wi=Gi.setIsArrowVisible,zi=Gi.isResizing,Ki=Gi.setIsResizing,Ui=Gi.isSideBySideLoading,Yi=Gi.activeSideBySideSection,Ji=Gi.scrollLock,Xi=Gi.sideBySideCacheRef,$i=Gi.isSideBySideRef,Qi=Gi.activeSideBySideRightSectionRef,Zi=Gi.activeSideBySideSectionRef,et=Gi.sideBySideLineRef,nt=Gi.highlightedClauseRefs,it=Gi.clearClauseHighlight,tt=Gi.resetSideBySide,ot=Gi.activateSideBySide,rt=i.useRef(ot);i.useEffect(function(){rt.current=ot},[ot]);var lt=m.useAccordionState({maintainRelativeOrder:!!He,proposedSections:Si,existingSections:Ri,activeSideBySideSection:Yi,connectedSections:nn,resetSideBySide:tt,setConnectedSections:tn,setConnectedLines:ln,cachedConnectedPositions:_n,svgContainerRef:vn,isAnimatingRef:Sn,animationTimerRef:Rn,calculateLinesRef:bn,sectionLeftRefs:Bi,sectionRightRefs:Di,subSectionLeftRefs:ki,subSectionRightRefs:Pi}),ut=lt.expandedSections,st=lt.setExpandedSections,at=lt.expandedSubSections,ct=lt.setExpandedSubSections,dt=lt.handleSubSectionToggle,ft=lt.toggleSection,vt=lt.forceExpandCrossWiredSections,gt=function(){var e,n;if(null!=Yi){var i=null===(e=Bi.current[Yi])||void 0===e?void 0:e.current,t=null===(n=Di.current[Yi])||void 0===n?void 0:n.current,o=On.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"})}}},pt=i.useCallback(function(e){null==e||e.stopPropagation(),an(function(e){var n=!e;return n&&requestAnimationFrame(function(){gt()}),n})},[gt]);i.useEffect(function(){Pe&&"off"!==Ai&&"0:0"!==Ai&&(Xi.current=null,_n.current=[],requestAnimationFrame(function(){var e;null===(e=bn.current)||void 0===e||e.call(bn)}))},[Pe,Ai]);var ht=i.useMemo(function(){var e=new Map,n=new Map,i=1;if(He)Si.forEach(function(n){!n.title&&!n.content||n.id&&e.set(n.id,i++)}),Ri.forEach(function(t){if(t.id&&!(!t.title&&!t.content)){var o=Si.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(Si.length,Ri.length),o=0;o<t;o++){var r=Si[o],l=Ri[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}},[Si,Ri,He]),mt=mi.analysis,St=u.safeStringify(null===(ee=null===(Z=null==mt?void 0:mt.rule_difference_comparison)||void 0===Z?void 0:Z.summary)||void 0===ee?void 0:ee.overall_summary),Rt=!!St.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),xt=null!==(ne=null==Re?void 0:Re.base_root_id)&&void 0!==ne?ne:"-1";null==Re||Re[xt];var _t=Ze?null!==(ve=null!==(ce=Be&&(null===(ae=null==Be?void 0:Be[xt])||void 0===ae?void 0:ae.evaluation_result))&&void 0!==ce?ce:null===(fe=null===(de=null==Re?void 0:Re.nodes)||void 0===de?void 0:de[xt])||void 0===fe?void 0:fe.evaluation_result)&&void 0!==ve?ve:null:null!==(se=null!==(oe=Be&&(null===(te=null===(ie=null==Be?void 0:Be[xt])||void 0===ie?void 0:ie.evaluation_result)||void 0===te?void 0:te[0]))&&void 0!==oe?oe:null===(ue=null===(le=null===(re=null==Re?void 0:Re.nodes)||void 0===re?void 0:re[xt])||void 0===le?void 0:le.evaluation_result)||void 0===ue?void 0:ue[0])&&void 0!==se?se:null,bt=u.extractDeviationScore(_t),yt=u.generateColorPalette(null!==(he=null===(pe=null===(ge=null==_t?void 0:_t.evaluation_outputs)||void 0===ge?void 0:ge.metadata)||void 0===pe?void 0:pe.label_color)&&void 0!==he?he:a.DEFAULT_DEVIAION_COLOR);if(Ne){var Ct=Ne(bt);Ct&&(yt=e.__assign(e.__assign({},yt),{badgeBg:Ct.bg,badgeText:Ct.text,badgeBorder:Ct.border}))}var Et=i.useRef(tt);i.useEffect(function(){Et.current=tt},[tt]);var At=i.useRef(ni);i.useEffect(function(){At.current=ni},[ni]);var Tt=i.useCallback(function(e,n,i,t,o,r){return qo.current(e,n,i,t,o,r)},[]),wt=i.useCallback(function(e,n,i,t,o){return Ho.current(e,n,i,t,o)},[]),It=i.useCallback(function(){return Vo.current()},[]),Bt=i.useCallback(function(e,n){return Wo.current(e,n)},[]),Dt=i.useCallback(function(e){return zo.current(e)},[]),Ot=i.useCallback(function(e){return Ko.current(e)},[]),jt=i.useCallback(function(){return Uo.current()},[]),Ft=i.useCallback(function(){var e,n;it(),null===(e=Et.current)||void 0===e||e.call(Et),an(!1),tn(new Set),ln([]),_n.current=[],to([]),ro(null),Jn(a.EMPTY_SUMMARY_POPUP_STATE),null===(n=At.current)||void 0===n||n.call(At),requestAnimationFrame(function(){var e;null===(e=bn.current)||void 0===e||e.call(bn)})},[]),kt=i.useRef(Ft);i.useEffect(function(){kt.current=Ft},[Ft]),i.useEffect(function(){Ce&&kt.current()},[Ce]);var Pt=i.useMemo(function(){return{documents:null==Re?void 0:Re.documents,input_index_map:null==Re?void 0:Re.input_index_map}},[JSON.stringify(null==Re?void 0:Re.documents),JSON.stringify(null==Re?void 0:Re.input_index_map)]),Nt=i.useState(""),Mt=Nt[0],Lt=Nt[1],qt=u.safeStringify(ui),Gt=i.useRef(Re);i.useEffect(function(){var e,n,i;Gt.current=Re;var t=null===(e=null==Re?void 0:Re.input_index_map)||void 0===e?void 0:e[0],o=null===(i=null===(n=null==Re?void 0:Re.documents)||void 0===n?void 0:n[t])||void 0===i?void 0:i.title;Lt(o)},[Re]);var Ht=i.useRef(wn);i.useEffect(function(){Ht.current=wn},[wn]);var Vt=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=Ht.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=Ni.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==Ae?void 0:Ae.isLoading)&&void 0!==S&&S,E=!0;if(pi){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:Pt,deviationData:b,isOrphan:!!r,hasGuidelineMatches:E}},[Pt,null==Ae?void 0:Ae.isLoading,pi]),Wt=i.useCallback(function(e,n,i,t,o,r){var l;if(e.stopPropagation(),Vn.open&&Vn.sectionIdx===o)ii();else{var s=e.currentTarget,a="left";(null===(l=On.current)||void 0===l?void 0:l.contains(s))&&(a="right");it(),$i.current&&tt(),tn(new Set),ln([]),_n.current=[],ni(),Yn.open?_o():Xn(),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=ji.current[l])||void 0===e?void 0:e.current:null===(n=Oi.current[l])||void 0===n?void 0:n.current}return"right"===a?null===(i=ji.current[o])||void 0===i?void 0:i.current:null===(t=Oi.current[o])||void 0===t?void 0:t.current}()||s;Wn(Vt(e,n,t,o,i,r))})}},[Vn.open,Vn.sectionIdx,ii,Xn,Vt]),zt=i.useCallback(function(){var e=Vn.sectionIdx;Vn.isOrphan,ii(),Xn(),null!==e&&(vt(e),it(),$i.current&&tt(),ln([]),_n.current=[],pi&&null!==e&&fn(ho(e)),tn(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){bn.current&&bn.current()},50))},[Vn.sectionIdx,Vn.isOrphan,ii,Xn,tt]),Kt=i.useCallback(function(){var e=mn.current;if(e){mn.current=null;var n=Si.findIndex(function(n){return n.id===e}),i=Ri.findIndex(function(n){return n.id===e}),t=-1===n?u.findKeyPathByNodeId(Si,e):null,o=-1===i?u.findKeyPathByNodeId(Ri,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?(nt.current.add(r),u.scrollAndHighlightClause(r,n)):t++<i&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(He)-1!==r&&Nn.current&&a(function(){return s(n,t,Bi,ki)},Nn.current),-1!==l&&On.current&&a(function(){return s(i,o,Di,Pi)},On.current);else{var c=Bn.current;if(!c)return;a(function(){return-1!==r?s(n,t,Bi,ki):s(i,o,Di,Pi)},c)}}},[Si,Ri,He,Bi,Di,ki,Pi,Nn,On,Bn]),Ut=i.useCallback(function(n){if(n){it(),tt(),tn(new Set),ln([]),_n.current=[],Xn(),ni();var i=Si.findIndex(function(e){return e.id===n}),t=Ri.findIndex(function(e){return e.id===n}),o=-1===i?u.findKeyPathByNodeId(Si,n):null,r=-1===t?u.findKeyPathByNodeId(Ri,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;mn.current=n,st(function(n){var i,t=e.__assign({},n),o=!1;-1!==l&&(t[i=He?"left-".concat(l):String(l)]||(t[i]=!0,o=!0));-1!==s&&(t[i=He?"right-".concat(s):String(s)]||(t[i]=!0,o=!0));return o?t:n}),ct(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(){mn.current===n&&Yt.current()})},50)}else console.warn('scrollToAndHighlightClause: nodeId "'.concat(n,'" not found'))}},[Si,Ri,He,st,ct,tt,Xn,ni]),Yt=i.useRef(Kt);i.useEffect(function(){Yt.current=Kt},[Kt]);var Jt=i.useRef(null);i.useEffect(function(){if(ri){var e=ti.fields.find(function(e){return e.analysisKey===ri||e.key===ri});if(e){var n=wi.current[e.key]||Ii.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[ri,ti.fields]);var Xt=i.useCallback(function(e){var n,i,t,o,r,l,u,s,a,c=null===(n=null==mt?void 0:mt.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}},[mt]),$t=E.useStyleHelpers({proposedSections:Si,existingSections:Ri,maintainRelativeOrder:He,cognitiveMap:wn,deviationData:An,treeData:Re,resolvedComparisonConfig:ti,badgeStyleOverride:Ne}),Qt=$t.getSectionCompareStyle,Zt=$t.getSubSectionCompareStyle,eo=$t.getDeviationStyleByKey,no=T.useLinesCalculator({containerRef:gn,leftContainerRef:Nn,rightContainerRef:On,svgContainerRef:vn,pathRefs:xn,leftHeaderRef:pn,rightHeaderRef:hn,proposedSections:Si,existingSections:Ri,visibleFields:xi,leftRefs:wi,rightRefs:Ii,sectionLeftRefs:Bi,sectionRightRefs:Di,subSectionLeftRefs:ki,subSectionRightRefs:Pi,lhsBadgeRefs:Oi,rhsBadgeRefs:ji,sectionRowRefs:Ni,expandedSections:ut,expandedSubSections:at,connectedSections:nn,isSideBySide:Hi,activeSideBySideSection:Yi,maintainRelativeOrder:He,isGuidelineMode:pi,cognitiveMap:wn,getSectionCompareStyle:Qt,getSubSectionCompareStyle:Zt,getDeviationStyleByKey:eo,isArrowVisible:Vi,isAnimatingRef:Sn,isSideBySideRef:$i,sideBySideCacheRef:Xi,sideBySideLineRef:et,activeSideBySideSectionRef:Zi,activeSideBySideRightSectionRef:Qi,connectedLines:rn,setConnectedLines:ln,cachedConnectedPositions:_n,calculateLinesRef:bn,resizeTimerRef:yn,scrollLock:Ji,scrollSyncLocked:sn,handleResizeRef:Cn,activeProposed:hi,existingRule:mi,analysisData:mt,pendingScrollTargetRef:Mn,pendingScrollCallbackRef:Ln,resolvedComparisonConfig:ti,getFieldData:Xt}),io=no.lines,to=no.setLines,oo=no.overallConnector,ro=no.setOverallConnector,lo=no.svgDimensions,uo=no.handleColumnScroll;i.useEffect(function(){Yn.anchorEl&&requestAnimationFrame(function(){requestAnimationFrame(function(){var e;null===(e=bn.current)||void 0===e||e.call(bn)})})},[Yn.anchorEl,sn]);var so=i.useCallback(function(){it(),an(!1),st({}),ct({}),tt(),tn(new Set),ln([]),_n.current=[],Xn(),ni(),ii(),requestAnimationFrame(function(){bn.current&&bn.current()})},[st,ct,tt,Xn,ni,ii]);i.useEffect(function(){Hi||0!==nn.size||an(!1)},[Hi,nn]);var ao=i.useMemo(function(){return Object.values(ut).some(Boolean)||Object.values(at).some(Boolean)},[ut,at]),co=i.useRef(null),fo=i.useRef(0),vo=i.useRef(0),go=i.useRef(0),po=A.useResizeHandler({timerRef:co,ruleComponentRef:Dn,scrollContainerRef:Bn,containerRef:gn,maintainRelativeOrder:He,proposedSections:Si,existingSections:Ri,isSideBySideRef:$i,activeSideBySideSectionRef:Zi,activeSideBySideRightSectionRef:Qi,sectionRowRefs:Ni,sectionRightRowRefs:Fi,sectionLeftRefs:Bi,sectionRightRefs:Di,subSectionLeftRefs:ki,subSectionRightRefs:Pi,lhsBadgeRefs:Oi,rhsBadgeRefs:ji,leftContainerRef:Nn,rightContainerRef:On,calculateLinesRef:bn,handleResizeRef:Cn,setIsResizing:Ki,setIsArrowVisible:Wi,sideBySideCacheRef:Xi,cachedConnectedPositions:_n}).handleResize;i.useEffect(function(){Cn.current=po},[po,Cn]),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 Dn.current&&o.push(e(Dn.current,fo,n,function(){return Cn.current()},function(){})),Bn.current&&o.push(e(Bn.current,vo,i,function(){return Cn.current()},function(){return bn.current()})),gn.current&&o.push(e(gn.current,go,t,function(){return Cn.current()},function(){return bn.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(){$i.current=Hi},[Hi]),i.useEffect(function(){Zi.current=Yi},[Yi]);var ho=i.useCallback(function(e){var n,i,t,o,r,l="",s="0";if("number"==typeof e)l=(null===(n=Si[e])||void 0===n?void 0:n.nodeId)||(null===(i=Si[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==An?void 0:An[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)&&F.hasGptCitationObjects(d)?1:0},[Si,An]),mo=i.useCallback(function(){tt(),tn(new Set),ln([]),_n.current=[]},[tt]),So=i.useCallback(function(e,n){n!==dn&&(mo(),fn(n))},[dn,mo]);i.useEffect(function(){Tn||0===dn||(mo(),fn(0))},[dn,Tn,mo]);var Ro=i.useCallback(function(e){var n,i,t=Nn.current,o=On.current,r=j.getVisibleGuidelineTargets(o);if(o){var 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=Oi.current[s])||void 0===n?void 0:n.current)||(null===(i=Oi.current[e])||void 0===i?void 0:i.current);if(r.length>0&&c&&t&&o){var d=r[0];kn.current&&(kn.current.style.height="0px"),jn.current&&(jn.current.style.height="0px"),Pn.current&&(Pn.current.style.height="0px"),Fn.current&&(Fn.current.style.height="0px"),requestAnimationFrame(function(){var e=c.getBoundingClientRect(),n=d.getBoundingClientRect(),i=t.getBoundingClientRect(),r=o.getBoundingClientRect(),l=t.scrollTop+(e.top-i.top)+e.height/2,u=o.scrollTop+(n.top-r.top)+n.height/2,s=l-i.height/2,a=Math.max(0,s),f=t.scrollHeight-t.clientHeight,v=a>f?a-f:0,g=i.top+l-a,p=r.top+u-g,h=0;p<0&&(h=Math.abs(p),p=0);var m=o.scrollHeight-o.clientHeight+h,S=p>m?p-m:0;Pn.current&&(Pn.current.style.height="".concat(v,"px")),jn.current&&(jn.current.style.height="".concat(h,"px")),Fn.current&&(Fn.current.style.height="".concat(S,"px")),requestAnimationFrame(function(){t.scrollTo({top:a,behavior:"smooth"}),o.scrollTo({top:p,behavior:"smooth"}),bn.current&&setTimeout(function(){return bn.current()},50)})})}}},[u.DEVIATION_BADGE_SEPARATOR]),xo=i.useCallback(function(){var e,n=Vn.sectionIdx,i=Vn.isOrphan;if(Xn(),null!=n){var t="left";Vn.anchorEl&&(null===(e=On.current)||void 0===e?void 0:e.contains(Vn.anchorEl))&&(t="right"),vt(n),pi&&(fn(ho(n)),tn(new Set([n]))),ot(n,i,{sourceSide:t,onReady:function(){pi&&setTimeout(function(){return Ro(String(n))},150)}})}},[ot,Vn.isOrphan,Vn.sectionIdx,Vn.anchorEl,Xn,vt,pi,Ro,ho]),_o=i.useCallback(function(){Xn(),tt(),tn(new Set),ln([]),_n.current=[]},[Xn,tt]),bo=null!==Vn.sectionIdx&&nn.has(Vn.sectionIdx),yo=S.useDeviationNavigation({proposedSections:Si,existingSections:Ri,parentDeviationRecord:_i,expandedSections:ut,maintainRelativeOrder:!!He,scrollContainerRef:Bn,leftContainerRef:Nn,rightContainerRef:On,lhsBadgeRefs:Oi,rhsBadgeRefs:ji}),Co=yo.showDeviationNavigation,Eo=yo.showOpenNodeRef,Ao=yo.adjustScrollForPopup,To=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;ni();var a="left";(null===(r=On.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=ji.current[l])||void 0===e?void 0:e.current:null===(i=Oi.current[l])||void 0===i?void 0:i.current}return"right"===a?null===(t=ji.current[n])||void 0===t?void 0:t.current:null===(o=Oi.current[n])||void 0===o?void 0:o.current};if(i&&!pi)return tt(),tn(new Set),ln([]),_n.current=[],void(l&&(vt(n),requestAnimationFrame(function(){var e=c()||s;e&&(e.getBoundingClientRect().top>.8*window.innerHeight&&e.scrollIntoView({behavior:"smooth",block:"center"}));Jn({open:!0,anchorEl:e,summary:t,displayImpact:o})})));vt(n),pi&&(fn(ho(n)),tn(new Set([n]))),l?setTimeout(function(){ot(n,i,{toggleIfSame:!1,sourceSide:a,onReady:function(){var e,i,r,l=c()||s;if(pi)setTimeout(function(){return Ro(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;He?(null===(e=Nn.current)||void 0===e||e.scrollBy({top:a,behavior:"smooth"}),null===(i=On.current)||void 0===i||i.scrollBy({top:a,behavior:"smooth"})):null===(r=Bn.current)||void 0===r||r.scrollBy({top:a,behavior:"smooth"})}}Jn({open:!0,anchorEl:l,summary:t,displayImpact:o})}})},350):setTimeout(function(){ot(n,i,{toggleIfSame:!1,sourceSide:a}),pi&&setTimeout(function(){return Ro(n)},150)},350)},[ot,ni,Jn,tt,vt,pi,He,Ro,An]),wo=i.useMemo(function(){var e;if(!De)return null;var n=null===(e=null==De?void 0:De.id)||void 0===e?void 0:e.split(":")[0];for(var i in _i){if((_i[i]||[]).some(function(e){return e.id===n}))return i}return null},[De,_i]),Io=i.useRef({id:null,triggerMs:null}),Bo=i.useRef(null);i.useEffect(function(){if(null==De?void 0:De.id){var n=Number(De.trigger),i=Io.current;if((null==i?void 0:i.id)!==De.id||(null==i?void 0:i.triggerMs)!==n){if(De.id.includes(":")&&/:\d+$/.test(De.id)){var t=De.id.split(":"),o=t[0],r=t[1],l=null!=r?r:"0",s="".concat(De.id,":").concat(n);Bo.current!==s&&(Xn(),ni(),tt(),tn(new Set),ln([]),_n.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(){Io.current={id:De.id,triggerMs:n}},h=null,m=null;for(var S in _i){var R=_i[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))),_=Si.findIndex(function(e){return e.id===h}),b=Ri.findIndex(function(e){return e.id===h}),y=-1===_&&-1!==b,C=g(Si,x),E=g(Ri,x);if(C&&!E&&!y){var A=C.split("-"),T=Number(A[0]);if(He){var w=null===(r=null===(t=Si[T])||void 0===t?void 0:t.refIndexes)||void 0===r?void 0:r[0],I=Ri.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,j=Si[B],F=Ri[O],k=j&&!j.title&&!j.content,P=F&&!F.title&&!F.content,N=y||(!C&&!!E||k&&!P);if(N){if(!(He?!!Go.current["right-".concat(D)]:!!Go.current[String(D)])&&D>=0)return ft(D,"right"),void(d=setTimeout(p,200))}else if(!(He?!!Go.current["left-".concat(B)]:!!Go.current[String(B)])&&B>=0)return ft(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)}),G=q[0],H=function(){for(var e,n,i=0,t=q;i<t.length;i++){var o=t[i],r=(null===(e=Oi.current[o])||void 0===e?void 0:e.current)||null,l=(null===(n=ji.current[o])||void 0===n?void 0:n.current)||null;if(r||l)return{refId:o,left:r,right:l}}return{refId:G,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){vt(V(G)),v=!0,c=0;var W=function(){var e=H(),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=H(),K=z.refId,U=z.left,Y=z.right,J=V(K);if(U||Y){var X=N||!U&&!!Y,$=X?Y:U,Q=He?X?On.current:Nn.current:Bn.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||pi?(r=function(e,n){return Promise.race([e,new Promise(function(e){return setTimeout(e,n)})])},He?[4,Promise.all([Nn.current?r(u.waitForScrollIdle(Nn.current),600):Promise.resolve(),On.current?r(u.waitForScrollIdle(On.current),600):Promise.resolve()])]:[3,2]):(o=X?(null===(v=ji.current[ie?K:D])||void 0===v?void 0:v.current)||Y:(null===(g=Oi.current[ie?K:B])||void 0===g?void 0:g.current)||U,Ao(o,function(){Jn({open:!0,anchorEl:o,displayImpact:De.displayImpact,summary:e.__assign(e.__assign({},i),{evaluation_outputs:t})})},{skipScroll:!0}),null==Oe||Oe(),[2]));case 1:p.sent(),p.label=2;case 2:return pi&&(fn(ho(J)),tn(new Set([J]))),rt.current(J,!1,{toggleIfSame:!1,sourceSide:y?"right":"left",onReady:function(){var n,t,o,r;s();var l=X?(null===(n=ji.current[K])||void 0===n?void 0:n.current)||Y:(null===(t=Oi.current[K])||void 0===t?void 0:t.current)||U;if(pi)setTimeout(function(){return Ro(J)},150);else{var u=(null===(o=Oi.current[K])||void 0===o?void 0:o.current)||U,a=(null===(r=ji.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"}))}Jn({open:!0,anchorEl:l,displayImpact:De.displayImpact,summary:e.__assign({},i)}),null==Oe||Oe()}}),[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()}}Io.current={id:De.id,triggerMs:n},Ut(De.id);var h=Si.findIndex(function(e){return e.id===De.id}),m=Ri.findIndex(function(e){return e.id===De.id});-1===h&&-1===m||setTimeout(function(){var e=-1!==h?h:m,n=-1===h;pi&&fn(ho(e)),tn(new Set([e])),rt.current(e,n,{sourceSide:n?"right":"left",onReady:function(){pi&&setTimeout(function(){return Ro(String(e))},150)}})},400)}}},[null==De?void 0:De.id,null==De?void 0:De.trigger,null==De?void 0:De.displayImpact,_i,Si,Ri,He,Jn,Ut,pi,ho,Ro]),i.useEffect(function(){var n,i,t;if(Yn.open){var o=Yn.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(Oi.current)||r(ji.current);if(l){var u=(null===(i=ji.current[l])||void 0===i?void 0:i.current)||(null===(t=Oi.current[l])||void 0===t?void 0:t.current);u&&u.isConnected&&Jn(function(n){return e.__assign(e.__assign({},n),{anchorEl:u})})}}}},[Yn.open,Yn.anchorEl,sn,nn,ut]);var Do=Gn.open,Oo=Gn.sectionIdx,jo=Gn.isOrphan,Fo=Gn.badgeStyle,ko=Gn.anchorEl,Po=Gn.sectionAnchorEl;i.useEffect(function(){var n;if(Ae.isStreamingEnabled&&Do&&null!=Oo&&Oo!==xt){var i="string"==typeof Oo?Oo.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(Si,i):null,r=i&&"string"==typeof i?t(Ri,i):null,l="number"==typeof Oo?Si[Oo]||null:o||i&&((null===(n=null==Re?void 0:Re.nodes)||void 0===n?void 0:n[i])||(null==Re?void 0:Re[i]))||null,s="number"==typeof Oo?Ri[Oo]||null:r,a=Vt(ko,l,s,Oo,jo,Fo);Hn(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})}},[Do,Oo,jo,Fo,ko,Po,Si,Ri,Vt]);var No=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})},[]),Mo=i.useMemo(function(){return Si.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&&He?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))})},[Si,He]),Lo=i.useMemo(function(){return Ri.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&&He?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))})},[Ri,He]),qo=i.useRef(Wt);i.useEffect(function(){qo.current=Wt},[Wt]);var Go=i.useRef(ut);i.useEffect(function(){Go.current=ut},[ut]);var Ho=i.useRef(To);i.useEffect(function(){Ho.current=To},[To]);var Vo=i.useRef(_o);i.useEffect(function(){Vo.current=_o},[_o]);var Wo=i.useRef(ft);i.useEffect(function(){Wo.current=ft},[ft]);var zo=i.useRef(dt);i.useEffect(function(){zo.current=dt},[dt]);var Ko=i.useRef(No);i.useEffect(function(){Ko.current=No},[No]);var Uo=i.useRef(tt);i.useEffect(function(){Uo.current=tt},[tt]);var Yo=i.useMemo(function(){return{isGuidelineMode:pi,maintainRelativeOrder:!!He,showDeviationBadges:Ke,isProposingFix:Fe,proposingFixNodeId:ke,isRedlineFlow:Pe,isSideBySide:Hi,activeSideBySideSection:Yi,scrollSyncLocked:sn,toggleScrollSyncLocked:pt,summaryPopupAnchorEl:Yn.anchorEl,connectedSections:nn,proposedSections:Si,existingSections:Ri,deviationNumberRegistry:bi,deviationParentRegistry:yi,treeData:Re,displayConfig:Ae,resolvedMarkdownStyles:In,unifiedNumbering:ht,expandedSections:ut,expandedSubSections:at,setExpandedSubSections:ct,getSectionCompareStyle:Qt,getSubSectionCompareStyle:Zt,getBadgeRef:qi,getSectionRowRef:Mi,getSubSectionRef:Li,sectionLeftRefs:Bi,sectionRightRefs:Di,sectionRowRefs:Ni,sectionRightRowRefs:Fi,subSectionLeftRefs:ki,subSectionRightRefs:Pi,lhsBadgeRefs:Oi,rhsBadgeRefs:ji,openMoreFunctionsPopup:Tt,handleOpenSummaryPopup:wt,openSummaryPopup:wt,handleCloseSummaryPopup:It,toggleSection:Bt,handleSubSectionToggle:Dt,renderSubSectionAccordion:Ot,resetSideBySide:jt,setConnectedSections:tn,setConnectedLines:ln,cachedConnectedPositions:_n,showDeviationNavigation:Co,showOpenNodeRef:Eo,deviationNodeIdToView:null==De?void 0:De.id,deviationTargetParentId:wo,guidelinesData:Me,gptWebCitationConfig:qe}},[pi,He,Ke,Fe,ke,Pe,Hi,Yi,sn,pt,Yn.anchorEl,nn,Si,Ri,bi,Ae,In,ht,ut,at,ct,Qt,Zt,qi,Mi,Li,Co,Eo,De,wo,Me,qe]),Jo=u.safeStringify(Gn.sectionTitle||ci||si),Xo=u.safeStringify(pi?fi||vi||Gn.refSectionTitle:Gn.refSectionTitle||fi||vi);return n.jsx(C.CompareContextProvider,e.__assign({value:Yo},{children:n.jsxs(t.Box,e.__assign({ref:Dn,sx:{display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif',overflow:"visible",position:"relative"}},{children:[Ye&&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,{})})),Yn.open&&n.jsx(y.default,{open:Yn.open,anchorEl:Yn.anchorEl,containerEl:Jt.current,clipTopEl:pn.current,scrollContainerEl:Bn.current,onClose:_o,summary:Yn.summary,displayImpact:Yn.displayImpact,isScrollLocked:sn}),n.jsx(d.default,{open:Vn.open,anchorEl:Vn.anchorEl,maintainRelativeOrder:!!He,sectionTitle:Vn.sectionTitle,referenceSectionTitle:Vn.refSectionTitle,onClose:ii,onOpenCognitiveCompare:Zn,onOpenSideBySide:xo,onConnect:zt,isConnected:bo,isOrphan:!pi&&!!Vn.isOrphan,isGuidelineMode:pi,hasGuidelineMatches:Vn.hasGuidelineMatches}),Gn.open&&n.jsx(c.default,{open:Gn.open,popupRef:Qn,position:zn,popupConfig:we,onClose:function(){Kn(null),Hn(function(n){return e.__assign(e.__assign({},n),{open:!1})}),$n(null)},markdownStyles:ye,sectionTitle:Jo,referenceSectionTitle:Xo,cognitiveData:Gn.cognitiveData,anchorEl:Gn.anchorEl,sectionAnchorEl:Gn.sectionAnchorEl,scrollContainerEl:Bn.current,badgeStyle:Gn.badgeStyle,docData:Gn.docData,deviationData:Gn.deviationData,isLoading:Gn.isLoading}),n.jsx(t.Snackbar,e.__assign({open:!!$e,autoHideDuration:8e3,onClose:function(){return Qe(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(t.Alert,e.__assign({onClose:function(){return Qe(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:$e}))})),n.jsx(R.default,{componentHeaderText:Se,displayConfig:Ae,maintainRelativeOrder:He,onCollapseAll:so,showCollapseAll:ao,onToggleView:function(e){Je(!0),setTimeout(function(){Ve(!e),null==Te||Te(!e),an(!1),tt(),Xn(),tn(new Set),ln([]),_n.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){Je(!1)},600)})})},50)}}),n.jsx(t.Box,e.__assign({ref:Bn,onScroll:uo,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:He?"visible":"auto",borderTop:St&&Rt?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(t.Box,e.__assign({sx:e.__assign({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},He?{flex:1}:{})},{children:n.jsxs(t.Box,e.__assign({ref:gn,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"100px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},He?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(I.default,{svgContainerRef:vn,svgDimensions:lo,isResizing:zi,overallConnector:oo,rootDeviationStyle:yt,lines:io,isSideBySide:Hi,activeSideBySideSection:Yi,isArrowVisible:Vi,maintainRelativeOrder:He,proposedSections:Si,existingSections:Ri,cognitivePopup:Gn,activeBadgeId:Un,closeCognitivePopup:ni,setActiveBadgeId:$n,openCognitivePopupFromState:ei,buildSectionPopupState:Vt,connectedLines:rn,isGuidelineMode:pi,pathRefs:xn}),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)"},He?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(t.Box,e.__assign({ref:pn,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:si,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:si}))}))})),n.jsxs(t.Box,e.__assign({ref:Nn,onScroll:uo,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},He?{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:kn,style:{width:"100%",height:"0px",flexShrink:0}}),Ei&&Mo,n.jsx("div",{ref:Pn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),n.jsx(t.Box,e.__assign({ref:Jt,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:n.jsx(t.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:n.jsxs(t.Box,e.__assign({onClick:function(n){n.stopPropagation(),Gn.open&&Un===xt?ni():($n(xt),ei(Vt(n.currentTarget,{title:Mt,content:"",evaluationResult:_t,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},{title:qt,content:""},xt,!0,e.__assign(e.__assign({},yt),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:yt.badgeBg,color:yt.badgeText,border:"1px solid ".concat(yt.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=bt?bt: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:Gn.open&&Un===xt?"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},He?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[Ui&&n.jsx(l.default,{sections:11}),n.jsx(t.Box,e.__assign({ref:hn,sx:e.__assign({p:"8px",bgcolor:pi?"#F1F3F5":"#F7F8FA",borderBottom:"1px solid #D7DCE2",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center"},He?e.__assign({maxHeight:"calc(100vh - 250px)",overflowY:"auto",overflowX:"hidden",minHeight:0},pi?{"&::-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:pi?n.jsxs(t.Tabs,e.__assign({value:dn,onChange:So,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:vi,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"}))}))}),Tn&&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:vi,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:vi}))}))})),n.jsxs(t.Box,e.__assign({ref:On,onScroll:uo,sx:e.__assign({p:pi?"0px":"12px",display:"flex",flexDirection:"column"},He?e.__assign(e.__assign({maxHeight:"calc(100vh - 250px)"},!pi&&{flex:1}),{overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-150px",pl:"165px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}):{})},{children:[n.jsx("div",{ref:jn,style:{width:"100%",height:"0px",flexShrink:0}}),pi?Me?0!==dn&&Tn?n.jsx(D.default,{deviationData:Be,connectedSections:nn,proposedSections:Si}):n.jsx(B.default,{guidelinesData:Me,deviationData:Be,connectedSections:nn,proposedSections:Si}):n.jsx(O.GuidelineSkeleton,{}):Ei&&Lo,n.jsx("div",{ref:Fn,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=require("./utils/normalizeRedlineMarkdown.js"),e=function(t){return null==t?"":"string"==typeof t?t:Array.isArray(t)?t.map(e).join("\n\n"):"object"==typeof t?JSON.stringify(t):String(t)},r=function(t){return null!=t&&("string"==typeof t?t.trim().length>0:!Array.isArray(t)||t.length>0&&t.some(function(t){return r(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},i=function(t,n,e,r){var o;void 0===r&&(r={});var i=e[n],l=null===(o=null==t?void 0:t.comparison_inputs)||void 0===o?void 0:o[i];return l?(Array.isArray(l)?l:[l]).map(function(t,n){if(t&&"string"==typeof t&&t.trim()){var e=r[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 l=function(t){if(!t)return!0;var n=t.trim().toLowerCase();return n.includes("no equivalent")||"n/a"===n||"na"===n||"none"===n},u=function(t){var n;if("string"!=typeof t||!t)return!1;for(var e=/<(updated|deleted|changed|change)\b[^>]*>([\s\S]*?)<\/\1>/gi,r=null;null!==(r=e.exec(t));){if((null!==(n=r[2])&&void 0!==n?n:"").replace(/<[^>]*>/g,"").trim().length>0)return!0}return!1},a=function(t){return"string"==typeof t&&t?t.replace(/<\/?(updated|deleted|changed|change)\b[^>]*>/gi,""):""},s=function(t,n){for(var e="",r=[],o=[],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(" ")?o[o.length-1]=i+1:(e+=a,r.push(i),o.push(i+1))}return{text:e,starts:r,ends:o}},d=function(t,n,e){if(void 0===e&&(e=!1),!t||!n)return null;var r=t.toLowerCase().indexOf(n.toLowerCase());if(-1!==r)return{start:r,end:r+n.length};var o=s(t,e),i=s(n,e).text.trim().toLowerCase();if(!i)return null;var l=o.text.toLowerCase().indexOf(i);if(-1===l)return null;var u=l+i.length-1,a=o.starts[l],d=o.ends[u];return void 0===a||void 0===d?null:{start:a,end:d}},c=["#B91C1C","#A16207","#1D4ED8","#000000"],v=function(t){var n=c.findIndex(function(n){return n.toLowerCase()===t.toLowerCase()});return-1===n?c.length:n},f=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 r=0;r<t.subsections.length;r++){var o=f(t.subsections[r],"".concat(n,"-").concat(r),e);if(o)return o}return null},g=new WeakMap,p=function(t){if(t){var n=g.get(t);null!=n&&(clearTimeout(n),g.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)}},h=function(t){if(t){var n=g.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(){p(t)},3e3);g.set(t,e)}};exports.DEVIATION_BADGE_SEPARATOR="::",exports.areMarkdownPropsEqual=function(t,n){var e,r,o,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 d=0;d<a.length;d++)if(a[d]!==s[d])return!1;var c=t.deviationBadges||[],v=n.deviationBadges||[];if(c.length!==v.length)return!1;for(d=0;d<c.length;d++){if(c[d].id!==v[d].id)return!1;if(c[d].actionId!==v[d].actionId)return!1;if(c[d].label!==v[d].label)return!1;if(c[d].score!==v[d].score)return!1;if(c[d].isOrphan!==v[d].isOrphan)return!1;if(c[d].isConnected!==v[d].isConnected)return!1;if(c[d].showScrollLockToggle!==v[d].showScrollLockToggle)return!1;if(c[d].scrollSyncLocked!==v[d].scrollSyncLocked)return!1;if((null===(e=c[d].style)||void 0===e?void 0:e.badgeBg)!==(null===(r=v[d].style)||void 0===r?void 0:r.badgeBg))return!1;if((null===(o=c[d].style)||void 0===o?void 0:o.badgeBorder)!==(null===(i=v[d].style)||void 0===i?void 0:i.badgeBorder))return!1;if((null===(l=c[d].style)||void 0===l?void 0:l.badgeText)!==(null===(u=v[d].style)||void 0===u?void 0:u.badgeText))return!1}return!0},exports.debounce=function(t,n){var e;return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];var i=this;clearTimeout(e),e=setTimeout(function(){return t.apply(i,r)},n)}},exports.extractDeviationScore=function(t,n){var e,r,o,i,l,u,a;if(!t)return n;var s=null!==(u=null!==(i=null!==(r=null===(e=t.evaluation_output)||void 0===e?void 0:e.output_score)&&void 0!==r?r:null===(o=t.evaluation_outputs)||void 0===o?void 0:o.output_score)&&void 0!==i?i:null===(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 r=f(t[e],String(e),n);if(r)return r}return null},exports.findRedlineTextAnchorRange=function(t,n){var e=d(t,n,!0);if(e)return e;for(var r=0,o=n.split(/\n+/).map(function(t){return t.trim()}).filter(function(t){return!(t.length<12)&&!(""===t.replace(/[|:\-\s]/g,""))});r<o.length;r++){var i=o[r],l=d(t,i,!0);if(l)return l}return null},exports.findTextMatchRange=d,exports.generateColorPalette=function(t){var n=function(t,n){var e=function(t){var n=function(t){return 4===t.length?"#"+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]:t}(t).replace("#",""),e=parseInt(n,16);return{r:e>>16&255,g:e>>8&255,b:255&e}}(t),r=e.r,o=e.g,i=e.b;return function(t,n,e){return"#"+[t,n,e].map(function(t){return t.toString(16).padStart(2,"0")}).join("").toUpperCase()}(Math.round(r+(255-r)*n),Math.round(o+(255-o)*n),Math.round(i+(255-i)*n))};return{bg:n(t,.8),border:n(t,.5),badgeBg:n(t,.8),badgeBorder:n(t,.5),badgeText:t.toUpperCase(),highlightBg:n(t,.8)}},exports.getAlphabeticSuffix=o,exports.getBentArrowPath=function(t,n,e,r,o){void 0===o&&(o=14);var i=t+.5*(e-t),l=r-n;if(Math.abs(l)<3)return"M ".concat(t," ").concat(n," H ").concat(e);var u=l>0?1:-1,a=Math.min(o,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(r-u*a),"Q ".concat(i," ").concat(r," ").concat(i+a," ").concat(r),"H ".concat(e)].join(" ")},exports.getFirstDeviationColor=function(n){for(var e,r,o,i,l,u,a,s,d,c,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 x=m[b];(A=null===(i=null===(o=null===(r=null===(e=null==n?void 0:n.deviations)||void 0===e?void 0:e[x])||void 0===r?void 0:r.evaluation_outputs)||void 0===o?void 0:o.metadata)||void 0===i?void 0:i.label_color)&&h.push(A)}for(var y=0,_=Object.keys((null==n?void 0:n.deviation_entries)||{}).sort(function(t,n){return Number(t)-Number(n)});y<_.length;y++){x=_[y];(A=null===(s=null===(a=null===(u=null===(l=null==n?void 0:n.deviation_entries)||void 0===l?void 0:l[x])||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;x=T[I];(A=null===(f=null===(c=null===(d=null==n?void 0:n[x])||void 0===d?void 0:d.evaluation_outputs)||void 0===c?void 0:c.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 v(t)-v(n)})[0]},exports.getFirstDeviationOutputValue=function(t){for(var n,e,r,o,i,l,u,a,s,d=0,c=Object.keys((null==t?void 0:t.deviations)||{}).sort(function(t,n){return Number(t)-Number(n)});d<c.length;d++){var v=c[d];if(b=null===(r=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===r?void 0:r.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===(o=null==t?void 0:t.deviation_entries)||void 0===o?void 0:o[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,r,o){var i=new Map;if(!r)return i;var s=function(t){var r=e(t||"").replace(/\\n/g,"\n");return u(r)?a(n.normalizeRedlineMarkdown(r)):r};return(t||[]).forEach(function(t){var n=new Map,e=function(t){var i;if(t){var u=s(t.content);((null===(i=t.evaluationResults)||void 0===i?void 0:i.length)?t.evaluationResults:t.evaluationResult?[t.evaluationResult]:[]).forEach(function(e){var i=(null==e?void 0:e.nodeId)||t.nodeId||t.id;Object.entries((null==e?void 0:e.deviations)||{}).forEach(function(t){var e=t[0],a=t[1][r],c=s(a);if(c&&!l(a)&&d(u,c)){var v="".concat(i).concat("::").concat(e),f=o[v];null!=f&&n.set(v,f)}})}),(t.subsections||[]).forEach(e)}};if(e(t),0!==n.size){var u=Math.min.apply(Math,Array.from(n.values()));n.forEach(function(t,n){i.set(n,t-u+1)})}}),i},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,n,r,o){var l,u,a;void 0===o&&(o={});var s=i(t,n,r,o),d=(null===(l=s[0])||void 0===l?void 0:l.data)||{},c=(null===(u=s[0])||void 0===u?void 0:u.attributes)||null;return{title:e((null==d?void 0:d.title)||""),content:e((null==d?void 0:d.content)||""),change_history:e((null==d?void 0:d.change_history)||""),attributes:c,subsections:(null==d?void 0:d.subsections)||[],contentId:null===(a=s[0])||void 0===a?void 0:a.contentId,allItems:s}},exports.hasMeaningfulRedlineTags=u,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=r,exports.highlightClause=h,exports.isMissingStr=l,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)]},r=function(t){var n=Math.round(t).toString(16);return 1===n.length?"0"+n:n};try{var o=e(t),i=e(n),l=(o[0]+i[0])/2*.95,u=(o[1]+i[1])/2*.95,a=(o[2]+i[2])/2*.95;return"#".concat(r(l)).concat(r(u)).concat(r(a))}catch(t){return"#FDE68A"}},exports.recursivelyFindSubSectionIdxById=f,exports.resetClauseHighlight=p,exports.resolveComparisonInputItems=i,exports.safeStringify=e,exports.scrollAndHighlightClause=function(t,n){var e=n.getBoundingClientRect(),r=t.getBoundingClientRect(),o=n.scrollTop+r.top-e.top-e.height/2+r.height/2;n.scrollTo({top:o,behavior:"smooth"});var i=function(){return h(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 r,o=!1,i=function(){o||(o=!0,clearTimeout(r),t.removeEventListener("scrollend",l),e())},l=function(){return i()};t.addEventListener("scrollend",l),t.scrollTo({top:n,behavior:"smooth"}),r=setTimeout(i,800)}},exports.smoothScrollTo=function(t,n,e,r,o){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(d){null===a&&(a=d);var c,v=d-a;v<e?(t.scrollTop=(c=v,c/=e,u*(--c*c*c+1)+l),o&&o(),requestAnimationFrame(s)):(t.scrollTop=n,t.style.scrollBehavior=i,o&&o(),r&&r())};requestAnimationFrame(s)},exports.stripRedlineTags=a,exports.waitForScrollIdle=function(t,n){return void 0===n&&(n=100),new Promise(function(e){var r,o=!1,i=function(){o||(o=!0,t.removeEventListener("scroll",l),e())},l=function(){clearTimeout(r),r=setTimeout(i,n)};t.addEventListener("scroll",l),r=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 e=require("tslib"),r=require("react/jsx-runtime"),i=require("react"),o=require("@mui/material"),l=require("react-markdown"),t=require("rehype-raw"),a=require("../../CognitiveCompareConfig.js"),n=require("../../CognitiveComparehelpers.js"),u=require("../utils/processGuidelinesMarkdown.js");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=s(l),g=s(t);exports.default=function(l){var t=l.guidelinesData,s=l.deviationData,v=l.connectedSections,_=l.proposedSections,p=Array.from(v)[0],c=i.useMemo(function(){var r;if(null==p||!s)return{targetHighlights:[],labelColor:""};var i="";"number"==typeof p?i=(null===(r=_[p])||void 0===r?void 0:r.nodeId)||"":"string"==typeof p&&(i=p.includes(n.DEVIATION_BADGE_SEPARATOR)?p.split(n.DEVIATION_BADGE_SEPARATOR)[0]:p.split("::")[0].split(":")[0]);var o=s[i];if(!o)return{targetHighlights:[],labelColor:""};var l=[],t=o.evaluation_result||{},a="";return Object.values(t).forEach(function(r){var i,o,t,u,s;(null===(i=null==r?void 0:r.deviation_highlights)||void 0===i?void 0:i.rulebook_guidelines)&&(l=e.__spreadArray(e.__spreadArray([],l,!0),r.deviation_highlights.rulebook_guidelines,!0),a=(null===(t=null===(o=r.evaluation_outputs)||void 0===o?void 0:o.metadata)||void 0===t?void 0:t.label_color)?n.generateColorPalette(null===(s=null===(u=r.evaluation_outputs)||void 0===u?void 0:u.metadata)||void 0===s?void 0:s.label_color).bg:"")}),{targetHighlights:l.filter(Boolean),labelColor:a}},[p,s,_]),h=c.targetHighlights,f=c.labelColor,b=i.useMemo(function(){return u.processGuidelinesMarkdown({guidelinesData:t,targetHighlights:h,labelColor:f||"#FEF08A"})},[t,h,f]);return r.jsx(o.Box,e.__assign({sx:e.__assign(e.__assign({padding:"0px 12px",backgroundColor:"#FFFFFF",borderRadius:"8px"},a.SHARED_MARKDOWN_STYLES),{overflow:"visible"})},{children:r.jsx(d.default,e.__assign({rehypePlugins:[g.default]},{children:b}))}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),r=require("react/jsx-runtime"),i=require("react"),t=require("@mui/material"),o=require("react-markdown"),l=require("rehype-raw"),a=require("../../CognitiveCompareConfig.js"),n=require("../../CognitiveComparehelpers.js"),s=require("../utils/processGuidelinesMarkdown.js"),u=require("../utils/resolveGuidelineSelection.js");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var g=d(o),c=d(l);exports.default=function(o){var l=o.guidelinesData,d=o.deviationData,p=o.connectedSections,f=o.proposedSections,h=Array.from(p)[0],v=i.useMemo(function(){if(null==h||!d)return{targetHighlights:[],labelColor:""};var e=u.resolveGuidelineSelection({activeIdentifier:h,deviationData:d,proposedSections:f}),r=e.labelColor?n.generateColorPalette(e.labelColor):null;return{targetHighlights:e.targetHighlights,labelColor:(null==r?void 0:r.bg)||""}},[h,d,f]),b=v.targetHighlights,C=v.labelColor,_=i.useMemo(function(){return s.processGuidelinesMarkdown({guidelinesData:l,targetHighlights:b,labelColor:C||"#FEF08A"})},[l,b,C]);return r.jsx(t.Box,e.__assign({sx:e.__assign(e.__assign({padding:"0px 12px",marginTop:"12px",backgroundColor:"#FFFFFF",borderRadius:"8px"},a.SHARED_MARKDOWN_STYLES),{overflow:"visible"})},{children:r.jsx(g.default,e.__assign({rehypePlugins:[c.default]},{children:_}))}))};
2
2
  //# sourceMappingURL=GuidelinePanel.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),r=require("react/jsx-runtime"),n=require("react"),t=require("@mui/material"),a=require("react-markdown"),o=require("rehype-raw"),i=require("../../CognitiveCompareConfig.js"),u=require("../../CognitiveComparehelpers.js"),d=require("../../CitationAnchor.js");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=l(a),c=l(o),v=function(e){var r,n,t=e.evalNode;return!1===(null===(n=null===(r=null==t?void 0:t.evaluation_outputs)||void 0===r?void 0:r.guideline_flag)||void 0===n?void 0:n.rulebook_used)},p=function(e,r,n){return"".concat(e,"::").concat(r,"::").concat(n)},f=function(e,r){return"".concat(e,"::").concat(r)},y={relativeWrapper:{verticalAlign:"baseline"},arrow:{color:"#6D28D9"}};exports.default=function(a){var o=a.deviationData,l=a.connectedSections,b=a.proposedSections,w=Array.from(l||[])[0],_=n.useMemo(function(){return function(e,r){var n;return"number"==typeof e?(null===(n=r[e])||void 0===n?void 0:n.nodeId)||"":e&&"string"==typeof e&&e.trim()?e.includes(u.DEVIATION_BADGE_SEPARATOR)?e.split(u.DEVIATION_BADGE_SEPARATOR)[0]:e.split("::")[0].split(":")[0]:""}(w,b||[])},[w,b]),g=n.useMemo(function(){if(!o||"object"!=typeof o)return[];return Object.entries(o).flatMap(function(e){var r=e[0];return function(e){var r=e&&"object"==typeof e?e.evaluation_result:null;return!r||"object"!=typeof r&&!Array.isArray(r)?[]:Array.isArray(r)?r.map(function(e,r){return{evalNode:e,evaluationKey:String(r)}}):"object"==typeof r?Object.entries(r).map(function(e){var r=e[0];return{evalNode:e[1],evaluationKey:r}}):[]}(e[1]).filter(v).map(function(e){var n,t,a,o=e.evalNode,i=e.evaluationKey;return{nodeId:r,evaluationKey:i,answerKey:f(r,i),evaluation:o,webSearchAnswer:o.web_search_answer,colorPalette:null!==(a=u.generateColorPalette((null===(t=null===(n=null==o?void 0:o.evaluation_outputs)||void 0===n?void 0:n.metadata)||void 0===t?void 0:t.label_color)||""))&&void 0!==a?a:{border:y.arrow.color}}}).filter(function(e){var r=e.webSearchAnswer;return!!(null==r?void 0:r.enhanced_content)})}).map(function(r,n){return e.__assign(e.__assign({},r),{answerOrder:n})})},[o]),h=n.useMemo(function(){return g.reduce(function(e,r){var n,t=(null===(n=r.webSearchAnswer)||void 0===n?void 0:n.extraMetaData)||{};return Object.entries(t).forEach(function(n){var t=n[0],a=n[1],o=p(r.nodeId,r.evaluationKey,t);e[o]={nodeId:r.nodeId,evaluationKey:r.evaluationKey,answerKey:r.answerKey,answerOrder:r.answerOrder,reasoningId:t,evaluation:r.evaluation,webSearchAnswer:r.webSearchAnswer,extraMetaData:a}}),e},{})},[g]),x=n.useMemo(function(){return g.reduce(function(n,t){return n[t.answerKey]={a:function(n){var a=n.href,o=void 0===a?"":a,i=n.children,u=n.type,l=n.reason,s=e.__rest(n,["href","children","type","reason"]),c=null==s?void 0:s["data-cognitive-reasoning"],v=c?p(t.nodeId,t.evaluationKey,String(c)):"",f=v?h[v]:null;return r.jsx(d.default,{href:o,children:i,citationType:u,citationReason:l,metaData:{webGpt:f,webGptMetaKey:v},customStyle:y})}},n},{})},[g,h]);return r.jsx(t.Box,e.__assign({sx:e.__assign(e.__assign({padding:"12px 12px 12px 0px",backgroundColor:"#FFFFFF",borderRadius:"8px"},i.SHARED_MARKDOWN_STYLES),{overflow:"visible"})},{children:g.length>0?g.map(function(n,a){return r.jsx(t.Box,e.__assign({id:n.nodeId===_?"guideline-target-0":void 0,"data-web-gpt-node-id":n.nodeId,"data-web-gpt-evaluation-key":n.evaluationKey,"data-web-gpt-answer-order":n.answerOrder,"data-web-gpt-active":n.nodeId===_?"true":"false",sx:{mb:1.5,border:n.nodeId===_?"2px solid ".concat(n.colorPalette.border):"1px solid #d3d3d3",borderRadius:"6px",padding:"8px",backgroundColor:"#FFFFFF"}},{children:r.jsx(s.default,e.__assign({rehypePlugins:[c.default],components:x[n.answerKey]},{children:n.webSearchAnswer.enhanced_content}))}),n.answerKey)}):r.jsx(t.Typography,e.__assign({sx:{color:"#64748B",fontSize:"14px",py:1}},{children:"No web GPT data available."}))}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),r=require("react"),a=require("@mui/material"),t=require("react-markdown"),o=require("rehype-raw"),i=require("../../CognitiveCompareConfig.js"),u=require("../../CognitiveComparehelpers.js"),d=require("../../CitationAnchor.js"),l=require("../utils/resolveGuidelineSelection.js");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=s(t),v=s(o),f=function(e){var n,r,a=e.evalNode;return!1===(null===(r=null===(n=null==a?void 0:a.evaluation_outputs)||void 0===n?void 0:n.guideline_flag)||void 0===r?void 0:r.rulebook_used)},p=function(e,n,r){return"".concat(e,"::").concat(n,"::").concat(r)},y=function(e,n){return"".concat(e,"::").concat(n)},b={relativeWrapper:{verticalAlign:"baseline"},arrow:{color:"#6D28D9"}};exports.default=function(t){var o=t.deviationData,s=t.connectedSections,w=t.proposedSections,g=Array.from(s||[])[0],_=r.useMemo(function(){return l.resolveGuidelineSelection({activeIdentifier:g,deviationData:o,proposedSections:w||[]})},[g,o,w]),h=r.useMemo(function(){if(!o||"object"!=typeof o)return[];return Object.entries(o).flatMap(function(e){var n=e[0];return function(e){var n=e&&"object"==typeof e?e.evaluation_result:null;return!n||"object"!=typeof n&&!Array.isArray(n)?[]:Array.isArray(n)?n.map(function(e,n){return{evalNode:e,evaluationKey:String(n)}}):"object"==typeof n?Object.entries(n).map(function(e){var n=e[0];return{evalNode:e[1],evaluationKey:n}}):[]}(e[1]).filter(f).map(function(e){var r,a,t,o=e.evalNode,i=e.evaluationKey;return{nodeId:n,evaluationKey:i,answerKey:y(n,i),evaluation:o,webSearchAnswer:o.web_search_answer,colorPalette:null!==(t=u.generateColorPalette((null===(a=null===(r=null==o?void 0:o.evaluation_outputs)||void 0===r?void 0:r.metadata)||void 0===a?void 0:a.label_color)||""))&&void 0!==t?t:{border:b.arrow.color}}}).filter(function(e){var n=e.webSearchAnswer;return!!(null==n?void 0:n.enhanced_content)})}).map(function(n,r){return e.__assign(e.__assign({},n),{answerOrder:r})})},[o]),x=r.useMemo(function(){var e;return null===(e=(null==_.evaluationKey?void 0:h.find(function(e){return e.nodeId===_.baseNodeId&&e.evaluationKey===_.evaluationKey}))||h.find(function(e){return e.nodeId===_.baseNodeId}))||void 0===e?void 0:e.answerKey},[_.baseNodeId,_.evaluationKey,h]),K=r.useMemo(function(){return h.reduce(function(e,n){var r,a=(null===(r=n.webSearchAnswer)||void 0===r?void 0:r.extraMetaData)||{};return Object.entries(a).forEach(function(r){var a=r[0],t=r[1],o=p(n.nodeId,n.evaluationKey,a);e[o]={nodeId:n.nodeId,evaluationKey:n.evaluationKey,answerKey:n.answerKey,answerOrder:n.answerOrder,reasoningId:a,evaluation:n.evaluation,webSearchAnswer:n.webSearchAnswer,extraMetaData:t}}),e},{})},[h]),m=r.useMemo(function(){return h.reduce(function(r,a){return r[a.answerKey]={a:function(r){var t=r.href,o=void 0===t?"":t,i=r.children,u=r.type,l=r.reason,s=e.__rest(r,["href","children","type","reason"]),c=null==s?void 0:s["data-cognitive-reasoning"],v=c?p(a.nodeId,a.evaluationKey,String(c)):"",f=v?K[v]:null;return n.jsx(d.default,{href:o,children:i,citationType:u,citationReason:l,metaData:{webGpt:f,webGptMetaKey:v},customStyle:b})}},r},{})},[h,K]);return n.jsx(a.Box,e.__assign({sx:e.__assign(e.__assign({padding:"12px 12px 12px 0px",backgroundColor:"#FFFFFF",borderRadius:"8px"},i.SHARED_MARKDOWN_STYLES),{overflow:"visible"})},{children:h.length>0?h.map(function(r){var t=r.answerKey===x;return n.jsx(a.Box,e.__assign({id:t?"guideline-target-0":void 0,"data-web-gpt-node-id":r.nodeId,"data-web-gpt-evaluation-key":r.evaluationKey,"data-web-gpt-answer-order":r.answerOrder,"data-web-gpt-active":t?"true":"false",sx:{mb:1.5,border:t?"2px solid ".concat(r.colorPalette.border):"1px solid #d3d3d3",borderRadius:"6px",padding:"8px",backgroundColor:"#FFFFFF"}},{children:n.jsx(c.default,e.__assign({rehypePlugins:[v.default],components:m[r.answerKey]},{children:r.webSearchAnswer.enhanced_content}))}),r.answerKey)}):n.jsx(a.Typography,e.__assign({sx:{color:"#64748B",fontSize:"14px",py:1}},{children:"No web GPT data available."}))}))};
2
2
  //# sourceMappingURL=WebGptPanel.js.map
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var r=function(r){return null!==r&&"object"==typeof r&&!Array.isArray(r)},t=function(e){if(Array.isArray(e))return e.some(t);if(!r(e))return!1;var n=e.gpt_citation;return!(!Array.isArray(n)||!n.some(function(t){return r(t)}))||Object.values(e).some(t)};exports.hasGptCitationObjects=t;
2
+ //# sourceMappingURL=hasGptCitationObjects.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hasGptCitationObjects.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.processGuidelinesMarkdown=function(t){var a,n,e=t.guidelinesData,o=t.targetHighlights,i=void 0===o?[]:o,r=t.labelColor,l=void 0===r?"#FEF08A":r,c="";if((null==e?void 0:e.learnings_data)&&Object.keys(e.learnings_data).length>0){var u=Object.keys(e.learnings_data)[0],d=e.learnings_data[u];(null==d?void 0:d.instruction_prompt)&&(c=d.instruction_prompt)}else{((null===(n=null===(a=null==e?void 0:e.data)||void 0===a?void 0:a.artifactData)||void 0===n?void 0:n.userStorySnapshot)||[]).forEach(function(t){var a;t.title&&(c+="### ".concat(t.title,"\n\n")),t.value&&(c+="".concat(t.value,"\n\n")),null===(a=t.sub_features)||void 0===a||a.forEach(function(t){t.title&&(c+="#### ".concat(t.title,"\n\n")),t.value&&(c+="".concat(t.value,"\n\n"))})})}return i.forEach(function(t,a){var n=t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),e=new RegExp("(".concat(n,")"),"g");c=c.replace(e,'<mark id="guideline-target-'.concat(a,'" style="background-color: ').concat(l,'; border-radius: 3px; padding: 2px;">$1</mark>'))}),c};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=function(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")},t=function(n){return n.trim().replace(/\s+/g," ")};exports.processGuidelinesMarkdown=function(r){var a,e,i=r.guidelinesData,o=r.targetHighlights,c=void 0===o?[]:o,l=r.labelColor,u=void 0===l?"#FEF08A":l,s="";return"string"==typeof i?s=i:(null==i?void 0:i.learnings_data)&&"object"==typeof i.learnings_data?(a=i.learnings_data,e=new Set,s=Object.values(a).map(function(n){var r="string"==typeof(null==n?void 0:n.title)?n.title.trim():"",a="string"==typeof(null==n?void 0:n.instruction_prompt)?n.instruction_prompt.trim():"";if(!a)return"";var i="".concat(t(r),"\n").concat(t(a));return e.has(i)?"":(e.add(i),r?"# ".concat(r,"\n\n").concat(a):a)}).filter(Boolean).join("\n\n")):s=function(n){var t,r,a=null===(r=null===(t=null==n?void 0:n.data)||void 0===t?void 0:t.artifactData)||void 0===r?void 0:r.userStorySnapshot;if(!Array.isArray(a))return"";var e="";return a.forEach(function(n){(null==n?void 0:n.title)&&(e+="### ".concat(n.title,"\n\n")),(null==n?void 0:n.value)&&(e+="".concat(n.value,"\n\n")),Array.isArray(null==n?void 0:n.sub_features)&&n.sub_features.forEach(function(n){(null==n?void 0:n.title)&&(e+="#### ".concat(n.title,"\n\n")),(null==n?void 0:n.value)&&(e+="".concat(n.value,"\n\n"))})}),e.trim()}(i),function(r,a,e){var i=r,o=new Set,c=0;return a.forEach(function(r){if("string"==typeof r){var a=r.trim(),l=t(a).toLocaleLowerCase();if(l&&!o.has(l)){o.add(l);var u=a.split(/\s+/).map(n).join("\\s+"),s=new RegExp(u,"i").exec(i);if(console.log("LOG: Printing match",s,a,u,i),s){var d='<mark id="guideline-target-'.concat(c,'" style="background-color: ').concat(e,'; border-radius: 3px; padding: 2px;">').concat(s[0],"</mark>");i="".concat(i.slice(0,s.index)).concat(d).concat(i.slice(s.index+s[0].length)),c+=1}}}}),i}(s,Array.isArray(c)?c:[],u||"#FEF08A")};
2
2
  //# sourceMappingURL=processGuidelinesMarkdown.js.map