@e-llm-studio/citation 0.0.231 → 0.0.233

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 (57) hide show
  1. package/README.md +47 -0
  2. package/dist/cjs/features/ChatCitation/InternalChatCitationRenderer.js +1 -1
  3. package/dist/cjs/features/CognitiveCompare/CitationAnchor.js +1 -1
  4. package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js +1 -1
  5. package/dist/cjs/features/CognitiveCompare/Guidelines/utils/helper.js +1 -1
  6. package/dist/cjs/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js +1 -1
  7. package/dist/cjs/features/CognitiveCompare/components/SectionAccordion.js +1 -1
  8. package/dist/cjs/features/CognitiveCompare/components/SvgConnectors.js +1 -1
  9. package/dist/cjs/features/CognitiveCompare/hooks/useCompareData.js +1 -1
  10. package/dist/cjs/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
  11. package/dist/cjs/features/CognitiveCompare/utils/buildComparisonRows.js +2 -0
  12. package/dist/cjs/features/CognitiveCompare/utils/buildComparisonRows.js.map +1 -0
  13. package/dist/features/ChatCitation/InternalChatCitationRenderer.js +1 -1
  14. package/dist/features/CognitiveCompare/CitationAnchor.js +1 -1
  15. package/dist/features/CognitiveCompare/CognitiveCompare.js +1 -1
  16. package/dist/features/CognitiveCompare/Guidelines/utils/helper.js +1 -1
  17. package/dist/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js +1 -1
  18. package/dist/features/CognitiveCompare/components/SectionAccordion.js +1 -1
  19. package/dist/features/CognitiveCompare/components/SvgConnectors.js +1 -1
  20. package/dist/features/CognitiveCompare/hooks/useCompareData.js +1 -1
  21. package/dist/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
  22. package/dist/features/CognitiveCompare/utils/buildComparisonRows.js +2 -0
  23. package/dist/features/CognitiveCompare/utils/buildComparisonRows.js.map +1 -0
  24. package/dist/types/src/CognitiveCompareTest.d.ts.map +1 -1
  25. package/dist/types/src/Spbanalysispaneltest.d.ts +3 -0
  26. package/dist/types/src/Spbanalysispaneltest.d.ts.map +1 -0
  27. package/dist/types/src/features/ChatCitation/InternalChatCitationRenderer.d.ts.map +1 -1
  28. package/dist/types/src/features/CognitiveCompare/CitationAnchor.d.ts.map +1 -1
  29. package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts.map +1 -1
  30. package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts +13 -0
  31. package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts.map +1 -1
  32. package/dist/types/src/features/CognitiveCompare/Guidelines/constants/guidelines.mockData.d.ts +1421 -898
  33. package/dist/types/src/features/CognitiveCompare/Guidelines/constants/guidelines.mockData.d.ts.map +1 -1
  34. package/dist/types/src/features/CognitiveCompare/Guidelines/utils/helper.d.ts.map +1 -1
  35. package/dist/types/src/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.d.ts.map +1 -1
  36. package/dist/types/src/features/CognitiveCompare/components/SectionAccordion.d.ts.map +1 -1
  37. package/dist/types/src/features/CognitiveCompare/components/SvgConnectors.d.ts.map +1 -1
  38. package/dist/types/src/features/CognitiveCompare/hooks/useCompareData.d.ts +2 -1
  39. package/dist/types/src/features/CognitiveCompare/hooks/useCompareData.d.ts.map +1 -1
  40. package/dist/types/src/features/CognitiveCompare/hooks/useCompareLayout.d.ts +0 -1
  41. package/dist/types/src/features/CognitiveCompare/hooks/useCompareLayout.d.ts.map +1 -1
  42. package/dist/types/src/features/CognitiveCompare/hooks/useLinesCalculator.d.ts.map +1 -1
  43. package/dist/types/src/features/CognitiveCompare/utils/buildComparisonRows.d.ts +11 -0
  44. package/dist/types/src/features/CognitiveCompare/utils/buildComparisonRows.d.ts.map +1 -0
  45. package/dist/types/src/features/SPBAnalysisPanel/Cognitivereasoningpanel.d.ts +22 -0
  46. package/dist/types/src/features/SPBAnalysisPanel/Cognitivereasoningpanel.d.ts.map +1 -0
  47. package/dist/types/src/features/SPBAnalysisPanel/DependencyGraph.d.ts +37 -0
  48. package/dist/types/src/features/SPBAnalysisPanel/DependencyGraph.d.ts.map +1 -0
  49. package/dist/types/src/features/SPBAnalysisPanel/Internaleditor.d.ts +11 -0
  50. package/dist/types/src/features/SPBAnalysisPanel/Internaleditor.d.ts.map +1 -0
  51. package/dist/types/src/features/SPBAnalysisPanel/Markdownrenderer.d.ts +10 -0
  52. package/dist/types/src/features/SPBAnalysisPanel/Markdownrenderer.d.ts.map +1 -0
  53. package/dist/types/src/features/SPBAnalysisPanel/Spbanalysispanel.d.ts +39 -0
  54. package/dist/types/src/features/SPBAnalysisPanel/Spbanalysispanel.d.ts.map +1 -0
  55. package/dist/types/src/features/SPBAnalysisPanel/index.d.ts +10 -0
  56. package/dist/types/src/features/SPBAnalysisPanel/index.d.ts.map +1 -0
  57. package/package.json +7 -2
package/README.md CHANGED
@@ -39,6 +39,7 @@
39
39
  -[ManageReminders](#ManageReminders) [<img src="https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png" width="18" height="18">](https://github.com/Techolution/e-llm-studio-lib/blob/dev/citation/src/features/ManageRemainders/README.md)
40
40
  - [PromptemonBlockViewer](#promptemonblockviewer) [<img src="https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png" width="18" height="18">](https://github.com/Techolution/e-llm-studio-lib/blob/dev/citation/src/features/PromptemonBlockViewer/PromptemonBlockViewerReadme.md)
41
41
  - [PromptemonViewer](#promptemonviewer) [<img src="https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png" width="18" height="18">](https://github.com/Techolution/e-llm-studio-lib/blob/dev/citation/src/features/PromptemonViewer/PromptemonViewerReadme.md)
42
+ - [SPBAnalysisPanel](#spbanalysispanel) [<img src="https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png" width="18" height="18">](https://github.com/Techolution/e-llm-studio-lib/blob/dev/citation/src/features/SPBAnalysisPanel/SPBAnalysisPanel.md)
42
43
  4. [Common Use Cases](#common-use-cases)
43
44
  5. [Development & Contribution](#development--contribution)
44
45
  6. [License](#license)
@@ -3222,6 +3223,52 @@ import PromptemonViewer from '@e-llm-studio/citation/PromptemonViewer'
3222
3223
  | `showEditMode` | `boolean` | ❌ | `true` | Show/hide the edit pencil icon and edit mode |
3223
3224
  | `showExtractSegments` | `boolean` | ❌ | `true` | Show/hide the Extract Segments button and Show Segments toggle |
3224
3225
 
3226
+
3227
+ ## SPBAnalysisPanel
3228
+
3229
+ ### Overview
3230
+
3231
+ A full-featured interface for reviewing the analysis of a System Prompt Block (SPB). Combines a scrollable left panel — Overview, Functionality, Applicability, Specifications, and Dependency Graph — with an optional persistent Monaco-based right panel for viewing the underlying prompt content. Consumer-controlled — all analysis/data fetching is handled by the consumer.
3232
+
3233
+ ### Features
3234
+
3235
+ - **Overview summary** — Collapsible high-level + detailed summary
3236
+ - **Functionality breakdown** — Nested accordions listing functional areas and their APB references
3237
+ - **Jump-to-code navigation** — Clicking an APB reference highlights that section in the persistent right-side editor
3238
+ - **Applicability** — Side-by-side "When to apply" / "When NOT to apply" panels
3239
+ - **Specifications** — Strict Rules / Input / Output, with automatic `<code>` block extraction in Output
3240
+ - **Dependency Graph** — Interactive, pannable/zoomable graph of APB relationships
3241
+ - **Persistent code panel (optional)** — Dark/light toggle and fullscreen expand, togglable via `showCodePanel`
3242
+ - **Markdown + cognitive decisioning** — Text fields render through a shared markdown renderer supporting citations and expandable "cognitive reasoning" panels
3243
+
3244
+ ### Usage
3245
+
3246
+ ```tsx
3247
+ import SPBAnalysisPanel from '@e-llm-studio/citation/SPBAnalysisPanel'
3248
+
3249
+ <SPBAnalysisPanel
3250
+ promptContent={mySystemPrompt}
3251
+ promptTitle="Persona & Guardrails SPB"
3252
+ isLoading={isLoading}
3253
+ overviewSummary={overviewSummary}
3254
+ functionalityOfSPB={functionalityOfSPB}
3255
+ spbAdditionalInfo={spbAdditionalInfo}
3256
+ showCodePanel={true}
3257
+ />
3258
+ ```
3259
+
3260
+ ### Props
3261
+
3262
+ | Prop Name | Type | Required | Default | Description |
3263
+ |-----------|------|----------|---------|-------------|
3264
+ | `promptContent` | `string` | ✅ | — | Full system prompt text, rendered in the persistent/fullscreen editor |
3265
+ | `promptTitle` | `string` | ❌ | `"SPB Analysis"` | Title shown in the header and code panel top bar |
3266
+ | `isLoading` | `boolean` | ❌ | `false` | Shows skeletons for any section whose data prop is still empty |
3267
+ | `overviewSummary` | `SPBOverviewSummary \| null` | ❌ | — | Overview section content |
3268
+ | `functionalityOfSPB` | `SPBFunctionalityItem[]` | ❌ | `[]` | Functional areas and their APB references |
3269
+ | `spbAdditionalInfo` | `SPBAdditionalInfo \| null` | ❌ | — | Applicability, Specifications, and Dependency Graph content |
3270
+ | `showCodePanel` | `boolean` | ❌ | `true` | Show/hide the persistent right-side editor panel |
3271
+
3225
3272
  ## EmailCitation
3226
3273
 
3227
3274
  A composable React UI component for rendering email-style citations with rich formatting, attachments, and highlight/quote handling. Part of the `@e-llm-studio/citation` package, this component is designed to display email content (subject, sender, recipients, body, attachments, timestamps) in an expandable, accessible, and customizable way.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),l=require("react/jsx-runtime"),i=require("./components/ChatCitation.js"),o=require("./utils/helpers.js"),n=require("./components/Chip.js"),t=require("./assets/message-chat-square.svg.js");require("@mui/icons-material/KeyboardArrowDown"),require("@mui/icons-material/KeyboardArrowUp"),require("@mui/icons-material/Clear");var r=require("./components/InViewNavigation.js"),d=require("./components/DetailedView.js"),s=require("./components/SummarizedView.js"),a=require("./components/RuleBook.js"),u=require("react"),v=require("./constants/renderer.js"),c=require("./components/IconContainer.js"),h=require("lucide-react"),f=require("./BigQueryTable.js");function g(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var p=g(require("@mui/icons-material/CloseOutlined")),b=function(e,l,i){if(void 0===i&&(i="smooth"),l){for(var o=e.parentElement;o;){var n=window.getComputedStyle(o).overflowY;if(("auto"===n||"scroll"===n)&&o.scrollHeight>o.clientHeight)break;if(o===l){o=null;break}o=o.parentElement}var t=null!=o?o:l,r=e.getBoundingClientRect(),d=t.getBoundingClientRect(),s=t.scrollTop+r.top-d.top-(t.clientHeight-r.height)/2;t.scrollTo({top:Math.max(0,s),behavior:i})}};exports.default=function(g){var x,m,y,_,C,w,S,j,k,q,A,T,D,R,F,z,B,E,I,P,H,V,M,N,W,Y,O,K,Q,U,G,J,L,X,Z,$,ee,le,ie,oe,ne,te,re,de,se,ae,ue,ve,ce=g.rootContainer,he=g.chatContainer,fe=void 0===he?{chatData:[]}:he,ge=g.ruleBookContainer,pe=g.renderer,be=g.additionalData,xe=g.tableComponent,me=g.closePreview,ye=g.isRenderedCustomComponent,_e=void 0!==ye&&ye,Ce=g.showRootContainer,we=void 0===Ce||Ce,Se=g.reversePanels,je=void 0!==Se&&Se,ke=u.useState(0),qe=ke[0],Ae=ke[1],Te=u.useState(0),De=Te[0],Re=Te[1],Fe=u.useState(0),ze=Fe[0],Be=Fe[1],Ee=u.useState(0),Ie=Ee[0],Pe=Ee[1],He=u.useRef(null),Ve=u.useRef(null),Me=u.useRef(null),Ne=u.useMemo(function(){return e.__assign(e.__assign({},v.defaultRenderer),pe)},[pe]),We=u.useMemo(function(){return!!((null==xe?void 0:xe.rows)&&Object.keys(xe.rows).length>0)},[xe]),Ye=u.useMemo(function(){var e;return null!==(e=null==be?void 0:be.RuleBookDetailedViewVerticallyStacked)&&void 0!==e&&e},[null==be?void 0:be.RuleBookDetailedViewVerticallyStacked]);u.useEffect(function(){var e,l;if((null==ge?void 0:ge.show)&&He.current){var i=null===(e=He.current)||void 0===e?void 0:e.querySelectorAll(".rule-book-highlight");if(Ae((null==i?void 0:i.length)||0),Re(0),i&&i.length>0){var o=i[0];o.style.backgroundColor="#ffff5c",b(o,He.current)}}if((null==fe?void 0:fe.show)&&(null==Ve?void 0:Ve.current)){var n=null===(l=Ve.current)||void 0===l?void 0:l.querySelectorAll(".user-chat-highlight");if(Be((null==n?void 0:n.length)||0),Pe(0),n&&n.length>0){var t=n[0];t.style.backgroundColor="#ffff5c";var r=requestAnimationFrame(function(){b(t,Me.current)});return function(){return cancelAnimationFrame(r)}}}},[null==fe?void 0:fe.show,null==ge?void 0:ge.show,null==ge?void 0:ge.data,null==fe?void 0:fe.chatData]);var Oe=u.useCallback(function(){var e;if(De+1<qe){var l=null===(e=He.current)||void 0===e?void 0:e.querySelectorAll(".rule-book-highlight");if(!l)return;l[De].style.backgroundColor="#ffffb8";var i=De+1;Re(i);var o=l[i];o.style.backgroundColor="#ffff5c",b(o,He.current)}},[De,qe]),Ke=u.useCallback(function(){var e;if(!(De-1<0)){var l=null===(e=He.current)||void 0===e?void 0:e.querySelectorAll(".rule-book-highlight");if(l){l[De].style.backgroundColor="#ffffb8";var i=De-1,o=l[i];o.style.backgroundColor="#ffff5c",Re(i),b(o,He.current)}}},[De]),Qe=u.useCallback(function(){var e;if(Ie+1<ze){var l=null===(e=Ve.current)||void 0===e?void 0:e.querySelectorAll(".user-chat-highlight");if(!l)return;l[Ie].style.backgroundColor="#ffffb8";var i=Ie+1,o=l[i];o.style.backgroundColor="#ffff5c",Pe(i),b(o,Me.current)}},[Ie,ze]),Ue=u.useCallback(function(){var e;if(!(Ie-1<0)){var l=null===(e=Ve.current)||void 0===e?void 0:e.querySelectorAll(".user-chat-highlight");if(l){l[Ie].style.backgroundColor="#ffffb8";var i=Ie-1,o=l[i];o.style.backgroundColor="#ffff5c",Pe(i),b(o,Me.current)}}},[Ie]),Ge=o.getColorCode((null==ce?void 0:ce.relevanceScore)||0),Je=u.useMemo(function(){var i,o=l.jsxs("span",e.__assign({style:e.__assign({display:"flex",border:"1px solid",alignItems:"center",gap:"4px",borderRadius:"6px",padding:"2px 8px",fontSize:"12px",borderColor:Ge.border,backgroundColor:Ge.background,color:Ge.text},null===(i=null==ce?void 0:ce.slotStyles)||void 0===i?void 0:i.relevanceScore)},{children:[(null==ce?void 0:ce.relevanceTitle)||"Decision Strength",":"," ",(null==ce?void 0:ce.relevanceScore)||0,"%"]}),"relevance-score"),n=l.jsx("span",e.__assign({style:{display:"flex",alignItems:"center",gap:"4px",borderRadius:"6px",padding:"2px 8px",fontSize:"12px",backgroundColor:"white",color:"black",cursor:"pointer"},onClick:me},{children:l.jsx(p.default,{})}),"close-preview");return _e&&!(null==be?void 0:be.isExpanded)?[o,n]:[o]},[_e,Ge.background,Ge.border,Ge.text,null==ce?void 0:ce.relevanceScore,null===(x=null==ce?void 0:ce.slotStyles)||void 0===x?void 0:x.relevanceScore,null==ce?void 0:ce.relevanceTitle]),Le=u.useMemo(function(){return[qe>0&&l.jsx(r.default,{currentItemNumber:De+1,totalItems:qe,disableNext:De+1>=qe,onNext:Oe,onPrevious:Ke,disablePrevious:De<=0},"rulebook-nav")]},[De,Oe,Ke,qe]),Xe=u.useMemo(function(){return(null==be?void 0:be.RuleBookContainerHeight)?be.RuleBookContainerHeight:!(!Ye||(null==be?void 0:be.isExpanded))&&"600px"},[null==be?void 0:be.RuleBookContainerHeight,Ye]),Ze=u.useMemo(function(){var e,i;return[(null===(i=null===(e=null==fe?void 0:fe.detailedTab)||void 0===e?void 0:e.chip)||void 0===i?void 0:i.isActive)&&ze>0&&l.jsx(r.default,{currentItemNumber:Ie+1,totalItems:ze,onNext:Qe,onPrevious:Ue,disableNext:Ie+1>=ze,disablePrevious:Ie<=0},"chat-nav")]},[null===(y=null===(m=null==fe?void 0:fe.detailedTab)||void 0===m?void 0:m.chip)||void 0===y?void 0:y.isActive,Ie,Qe,Ue,ze]),$e=l.jsxs("div",e.__assign({style:e.__assign({display:"flex",flexDirection:je?Ye?"column-reverse":"row-reverse":Ye?"column":"row",gap:[(null==fe?void 0:fe.chatData)&&fe.chatData.length>0&&(fe.show||void 0===fe.show),(null==ge?void 0:ge.data)&&(ge.show||void 0===ge.show),We].filter(Boolean).length>1?"12px":"0",height:Xe||"100%",minHeight:0},null===(_=null==ce?void 0:ce.slotStyles)||void 0===_?void 0:_.container)},{children:[We&&l.jsx("span",e.__assign({style:e.__assign({flex:"1 1 0%",minWidth:0},null===(C=null==fe?void 0:fe.slotStyles)||void 0===C?void 0:C.outerContainer)},{children:l.jsx(i.default,e.__assign({title:"Invoice Data Preview",icon:l.jsx(c.default,{children:l.jsx(h.Table,{size:16})}),slotStyles:{title:{color:"#475569",fontWeight:500}},secondaryActions:[]},{children:l.jsx("div",e.__assign({style:{height:"100%",maxHeight:(null==be?void 0:be.isExpanded)?"none":"275px",border:"2px solid #E2E8F0",borderRadius:"8px",display:"flex",flexDirection:"column",backgroundColor:"#FFFFFF",position:"relative",overflow:"hidden"}},{children:(null==xe?void 0:xe.rows)&&l.jsx(f.BigQueryTable,{rows:xe.rows,columns:xe.columns||[]})}))}))})),(null==ge?void 0:ge.data)&&(ge.show||void 0===ge.show)&&l.jsx("span",e.__assign({style:e.__assign({flex:"1 1 0%",minWidth:0},null===(w=null==ge?void 0:ge.slotStyles)||void 0===w?void 0:w.outerContainer)},{children:l.jsx(i.default,e.__assign({title:null!==(S=null==ge?void 0:ge.title)&&void 0!==S?S:"Rule book",icon:null==ge?void 0:ge.ruleBookIcon,slotStyles:{title:e.__assign({color:"#475569",fontWeight:500},null===(j=null==ge?void 0:ge.slotStyles)||void 0===j?void 0:j.title),body:null===(k=null==ge?void 0:ge.slotStyles)||void 0===k?void 0:k.body},secondaryActions:(null==ge?void 0:ge.secondaryActions)?ge.secondaryActions(Le):Le},{children:l.jsx("div",e.__assign({style:e.__assign({height:"100%",maxHeight:"275px",minHeight:0,border:"2px solid #E2E8F0",borderRadius:"8px",display:"flex",flexDirection:"column",gap:"12px",backgroundColor:"#F8FAFC",position:"relative",overflowY:"auto"},null===(q=null==ge?void 0:ge.slotStyles)||void 0===q?void 0:q.dataContainer)},{children:l.jsx("div",e.__assign({style:{padding:"12px",height:"100%",overflowY:"auto"},ref:He},{children:l.jsx(a.default,{data:ge.data,renderers:null!==(A=null==ge?void 0:ge.renderer)&&void 0!==A?A:Ne})}))}))}))})),(null==fe?void 0:fe.chatData)&&fe.chatData.length>0&&(fe.show||void 0===fe.show)&&l.jsx("span",e.__assign({style:e.__assign({flex:"1 1 0%",minWidth:0},null===(T=null==fe?void 0:fe.slotStyles)||void 0===T?void 0:T.outerContainer)},{children:l.jsx(i.default,e.__assign({title:null!==(D=null==fe?void 0:fe.title)&&void 0!==D?D:"Chat",icon:null==fe?void 0:fe.chatIcon,containerStyles:null===(R=null==fe?void 0:fe.slotStyles)||void 0===R?void 0:R.container,slotStyles:{title:e.__assign({color:"#475569",fontWeight:500},null===(F=null==fe?void 0:fe.slotStyles)||void 0===F?void 0:F.title),body:null===(z=null==fe?void 0:fe.slotStyles)||void 0===z?void 0:z.body},primaryActions:[((null===(E=null===(B=null==fe?void 0:fe.summarizedTab)||void 0===B?void 0:B.chip)||void 0===E?void 0:E.show)||void 0===(null===(P=null===(I=null==fe?void 0:fe.summarizedTab)||void 0===I?void 0:I.chip)||void 0===P?void 0:P.show))&&l.jsx(n.default,e.__assign({label:"Summarized"},null===(H=null==fe?void 0:fe.summarizedTab)||void 0===H?void 0:H.chip)),l.jsx(n.default,e.__assign({label:"Detailed"},null===(V=null==fe?void 0:fe.detailedTab)||void 0===V?void 0:V.chip))],secondaryActions:fe.secondaryActions?null==fe?void 0:fe.secondaryActions(Ze):Ze},{children:l.jsxs("div",e.__assign({ref:Me,style:e.__assign({height:"100%",maxHeight:"275px",border:"2px solid #E2E8F0",borderRadius:"8px",display:"flex",flexDirection:"column",gap:"12px",backgroundColor:"#F8FAFC",position:"relative",overflowY:"auto"},null===(M=null==fe?void 0:fe.slotStyles)||void 0===M?void 0:M.chatDataContainer)},{children:[(null===(W=null===(N=null==fe?void 0:fe.detailedTab)||void 0===N?void 0:N.chip)||void 0===W?void 0:W.isActive)&&l.jsx("div",e.__assign({ref:Ve,style:{position:(null==be?void 0:be.isExpanded)?"absolute":"relative",inset:0,padding:"12px",overflowY:"auto"}},{children:l.jsx(d.default,{chatData:null!==(Y=fe.chatData)&&void 0!==Y?Y:[],assistantChatProps:e.__assign(e.__assign({},null===(K=null===(O=null==fe?void 0:fe.detailedTab)||void 0===O?void 0:O.view)||void 0===K?void 0:K.assistantChatProps),{renderers:null!==(G=null===(U=null===(Q=null==fe?void 0:fe.detailedTab)||void 0===Q?void 0:Q.detailedViewRenderer)||void 0===U?void 0:U.assistantText)&&void 0!==G?G:Ne}),userChatItemProps:e.__assign(e.__assign({},null===(L=null===(J=null==fe?void 0:fe.detailedTab)||void 0===J?void 0:J.view)||void 0===L?void 0:L.userChatItemProps),{renderers:null!==($=null===(Z=null===(X=null==fe?void 0:fe.detailedTab)||void 0===X?void 0:X.detailedViewRenderer)||void 0===Z?void 0:Z.userText)&&void 0!==$?$:Ne})})})),(null===(le=null===(ee=null==fe?void 0:fe.summarizedTab)||void 0===ee?void 0:ee.chip)||void 0===le?void 0:le.show)&&(null===(oe=null===(ie=null==fe?void 0:fe.summarizedTab)||void 0===ie?void 0:ie.chip)||void 0===oe?void 0:oe.isActive)&&l.jsx(s.default,e.__assign({chatData:null!==(ne=fe.chatData)&&void 0!==ne?ne:[]},null===(te=null==fe?void 0:fe.summarizedTab)||void 0===te?void 0:te.view,{renderer:null!==(de=null===(re=null==fe?void 0:fe.summarizedTab)||void 0===re?void 0:re.summarizedViewRenderer)&&void 0!==de?de:Ne}))]}))}))}))]}));return we?l.jsx(i.default,e.__assign({title:null==ce?void 0:ce.title,slotStyles:{title:null===(se=null==ce?void 0:ce.slotStyles)||void 0===se?void 0:se.title,body:null===(ae=null==ce?void 0:ce.slotStyles)||void 0===ae?void 0:ae.body},containerStyles:null===(ue=null==ce?void 0:ce.slotStyles)||void 0===ue?void 0:ue.container,icon:null!==(ve=null==ce?void 0:ce.icon)&&void 0!==ve?ve:l.jsx(c.default,{children:l.jsx("img",{src:t.default,alt:"chat icon",style:{width:16,height:16}})}),secondaryActions:(null==ce?void 0:ce.secondaryActions)?ce.secondaryActions(Je):Je},{children:$e})):$e};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),l=require("react/jsx-runtime"),i=require("./components/ChatCitation.js"),o=require("./utils/helpers.js"),n=require("./components/Chip.js"),t=require("./assets/message-chat-square.svg.js");require("@mui/icons-material/KeyboardArrowDown"),require("@mui/icons-material/KeyboardArrowUp"),require("@mui/icons-material/Clear");var r=require("./components/InViewNavigation.js"),d=require("./components/DetailedView.js"),s=require("./components/SummarizedView.js"),a=require("./components/RuleBook.js"),u=require("react"),v=require("./constants/renderer.js"),c=require("./components/IconContainer.js"),h=require("lucide-react"),f=require("./BigQueryTable.js");function g(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var p=g(require("@mui/icons-material/CloseOutlined")),b=function(e,l,i){if(void 0===i&&(i="smooth"),l){for(var o=e.parentElement;o;){var n=window.getComputedStyle(o).overflowY;if(("auto"===n||"scroll"===n)&&o.scrollHeight>o.clientHeight)break;if(o===l){o=null;break}o=o.parentElement}var t=null!=o?o:l,r=e.getBoundingClientRect(),d=t.getBoundingClientRect(),s=t.scrollTop+r.top-d.top-(t.clientHeight-r.height)/2;t.scrollTo({top:Math.max(0,s),behavior:i})}},x={chatData:[]};exports.default=function(g){var m,y,_,C,w,S,j,k,q,A,T,D,R,F,z,B,E,I,P,H,V,M,N,W,Y,O,K,Q,U,G,J,L,X,Z,$,ee,le,ie,oe,ne,te,re,de,se,ae,ue,ve,ce,he=g.rootContainer,fe=g.chatContainer,ge=void 0===fe?x:fe,pe=g.ruleBookContainer,be=g.renderer,xe=g.additionalData,me=g.tableComponent,ye=g.closePreview,_e=g.isRenderedCustomComponent,Ce=void 0!==_e&&_e,we=g.showRootContainer,Se=void 0===we||we,je=g.reversePanels,ke=void 0!==je&&je,qe=u.useState(0),Ae=qe[0],Te=qe[1],De=u.useState(0),Re=De[0],Fe=De[1],ze=u.useState(0),Be=ze[0],Ee=ze[1],Ie=u.useState(0),Pe=Ie[0],He=Ie[1],Ve=u.useRef(null),Me=u.useRef(null),Ne=u.useRef(null),We=u.useMemo(function(){return e.__assign(e.__assign({},v.defaultRenderer),be)},[be]),Ye=u.useMemo(function(){return!!((null==me?void 0:me.rows)&&Object.keys(me.rows).length>0)},[me]),Oe=u.useMemo(function(){var e;return null!==(e=null==xe?void 0:xe.RuleBookDetailedViewVerticallyStacked)&&void 0!==e&&e},[null==xe?void 0:xe.RuleBookDetailedViewVerticallyStacked]);u.useEffect(function(){var e,l;if((null==pe?void 0:pe.show)&&Ve.current){var i=null===(e=Ve.current)||void 0===e?void 0:e.querySelectorAll(".rule-book-highlight");if(Te((null==i?void 0:i.length)||0),Fe(0),i&&i.length>0){var o=i[0];o.style.backgroundColor="#ffff5c",b(o,Ve.current)}}if((null==ge?void 0:ge.show)&&(null==Me?void 0:Me.current)){var n=null===(l=Me.current)||void 0===l?void 0:l.querySelectorAll(".user-chat-highlight");if(Ee((null==n?void 0:n.length)||0),He(0),n&&n.length>0){var t=n[0];t.style.backgroundColor="#ffff5c";var r=requestAnimationFrame(function(){b(t,Ne.current)});return function(){return cancelAnimationFrame(r)}}}},[null==ge?void 0:ge.show,null==pe?void 0:pe.show,null==pe?void 0:pe.data,null==ge?void 0:ge.chatData]);var Ke=u.useCallback(function(){var e;if(Re+1<Ae){var l=null===(e=Ve.current)||void 0===e?void 0:e.querySelectorAll(".rule-book-highlight");if(!l)return;l[Re].style.backgroundColor="#ffffb8";var i=Re+1;Fe(i);var o=l[i];o.style.backgroundColor="#ffff5c",b(o,Ve.current)}},[Re,Ae]),Qe=u.useCallback(function(){var e;if(!(Re-1<0)){var l=null===(e=Ve.current)||void 0===e?void 0:e.querySelectorAll(".rule-book-highlight");if(l){l[Re].style.backgroundColor="#ffffb8";var i=Re-1,o=l[i];o.style.backgroundColor="#ffff5c",Fe(i),b(o,Ve.current)}}},[Re]),Ue=u.useCallback(function(){var e;if(Pe+1<Be){var l=null===(e=Me.current)||void 0===e?void 0:e.querySelectorAll(".user-chat-highlight");if(!l)return;l[Pe].style.backgroundColor="#ffffb8";var i=Pe+1,o=l[i];o.style.backgroundColor="#ffff5c",He(i),b(o,Ne.current)}},[Pe,Be]),Ge=u.useCallback(function(){var e;if(!(Pe-1<0)){var l=null===(e=Me.current)||void 0===e?void 0:e.querySelectorAll(".user-chat-highlight");if(l){l[Pe].style.backgroundColor="#ffffb8";var i=Pe-1,o=l[i];o.style.backgroundColor="#ffff5c",He(i),b(o,Ne.current)}}},[Pe]),Je=o.getColorCode((null==he?void 0:he.relevanceScore)||0),Le=u.useMemo(function(){var i,o=l.jsxs("span",e.__assign({style:e.__assign({display:"flex",border:"1px solid",alignItems:"center",gap:"4px",borderRadius:"6px",padding:"2px 8px",fontSize:"12px",borderColor:Je.border,backgroundColor:Je.background,color:Je.text},null===(i=null==he?void 0:he.slotStyles)||void 0===i?void 0:i.relevanceScore)},{children:[(null==he?void 0:he.relevanceTitle)||"Decision Strength",":"," ",(null==he?void 0:he.relevanceScore)||0,"%"]}),"relevance-score"),n=l.jsx("span",e.__assign({style:{display:"flex",alignItems:"center",gap:"4px",borderRadius:"6px",padding:"2px 8px",fontSize:"12px",backgroundColor:"white",color:"black",cursor:"pointer"},onClick:ye},{children:l.jsx(p.default,{})}),"close-preview");return Ce&&!(null==xe?void 0:xe.isExpanded)?[o,n]:[o]},[Ce,Je.background,Je.border,Je.text,null==he?void 0:he.relevanceScore,null===(m=null==he?void 0:he.slotStyles)||void 0===m?void 0:m.relevanceScore,null==he?void 0:he.relevanceTitle]),Xe=u.useMemo(function(){return[Ae>0&&l.jsx(r.default,{currentItemNumber:Re+1,totalItems:Ae,disableNext:Re+1>=Ae,onNext:Ke,onPrevious:Qe,disablePrevious:Re<=0},"rulebook-nav")]},[Re,Ke,Qe,Ae]),Ze=u.useMemo(function(){return(null==xe?void 0:xe.RuleBookContainerHeight)?xe.RuleBookContainerHeight:!(!Oe||(null==xe?void 0:xe.isExpanded))&&"600px"},[null==xe?void 0:xe.RuleBookContainerHeight,Oe]),$e=u.useMemo(function(){var e,i;return[(null===(i=null===(e=null==ge?void 0:ge.detailedTab)||void 0===e?void 0:e.chip)||void 0===i?void 0:i.isActive)&&Be>0&&l.jsx(r.default,{currentItemNumber:Pe+1,totalItems:Be,onNext:Ue,onPrevious:Ge,disableNext:Pe+1>=Be,disablePrevious:Pe<=0},"chat-nav")]},[null===(_=null===(y=null==ge?void 0:ge.detailedTab)||void 0===y?void 0:y.chip)||void 0===_?void 0:_.isActive,Pe,Ue,Ge,Be]),el=l.jsxs("div",e.__assign({style:e.__assign({display:"flex",flexDirection:ke?Oe?"column-reverse":"row-reverse":Oe?"column":"row",gap:[(null==ge?void 0:ge.chatData)&&ge.chatData.length>0&&(ge.show||void 0===ge.show),(null==pe?void 0:pe.data)&&(pe.show||void 0===pe.show),Ye].filter(Boolean).length>1?"12px":"0",height:Ze||"100%",minHeight:0},null===(C=null==he?void 0:he.slotStyles)||void 0===C?void 0:C.container)},{children:[Ye&&l.jsx("span",e.__assign({style:e.__assign({flex:"1 1 0%",minWidth:0},null===(w=null==ge?void 0:ge.slotStyles)||void 0===w?void 0:w.outerContainer)},{children:l.jsx(i.default,e.__assign({title:"Invoice Data Preview",icon:l.jsx(c.default,{children:l.jsx(h.Table,{size:16})}),slotStyles:{title:{color:"#475569",fontWeight:500}},secondaryActions:[]},{children:l.jsx("div",e.__assign({style:{height:"100%",maxHeight:(null==xe?void 0:xe.isExpanded)?"none":"275px",border:"2px solid #E2E8F0",borderRadius:"8px",display:"flex",flexDirection:"column",backgroundColor:"#FFFFFF",position:"relative",overflow:"hidden"}},{children:(null==me?void 0:me.rows)&&l.jsx(f.BigQueryTable,{rows:me.rows,columns:me.columns||[]})}))}))})),(null==pe?void 0:pe.data)&&(pe.show||void 0===pe.show)&&l.jsx("span",e.__assign({style:e.__assign({flex:"1 1 0%",minWidth:0},null===(S=null==pe?void 0:pe.slotStyles)||void 0===S?void 0:S.outerContainer)},{children:l.jsx(i.default,e.__assign({title:null!==(j=null==pe?void 0:pe.title)&&void 0!==j?j:"Rule book",icon:null==pe?void 0:pe.ruleBookIcon,slotStyles:{title:e.__assign({color:"#475569",fontWeight:500},null===(k=null==pe?void 0:pe.slotStyles)||void 0===k?void 0:k.title),body:null===(q=null==pe?void 0:pe.slotStyles)||void 0===q?void 0:q.body},secondaryActions:(null==pe?void 0:pe.secondaryActions)?pe.secondaryActions(Xe):Xe},{children:l.jsx("div",e.__assign({style:e.__assign({height:"100%",maxHeight:"275px",minHeight:0,border:"2px solid #E2E8F0",borderRadius:"8px",display:"flex",flexDirection:"column",gap:"12px",backgroundColor:"#F8FAFC",position:"relative",overflowY:"auto"},null===(A=null==pe?void 0:pe.slotStyles)||void 0===A?void 0:A.dataContainer)},{children:l.jsx("div",e.__assign({style:{padding:"12px",height:"100%",overflowY:"auto"},ref:Ve},{children:l.jsx(a.default,{data:pe.data,renderers:null!==(T=null==pe?void 0:pe.renderer)&&void 0!==T?T:We})}))}))}))})),(null==ge?void 0:ge.chatData)&&ge.chatData.length>0&&(ge.show||void 0===ge.show)&&l.jsx("span",e.__assign({style:e.__assign({flex:"1 1 0%",minWidth:0},null===(D=null==ge?void 0:ge.slotStyles)||void 0===D?void 0:D.outerContainer)},{children:l.jsx(i.default,e.__assign({title:null!==(R=null==ge?void 0:ge.title)&&void 0!==R?R:"Chat",icon:null==ge?void 0:ge.chatIcon,containerStyles:null===(F=null==ge?void 0:ge.slotStyles)||void 0===F?void 0:F.container,slotStyles:{title:e.__assign({color:"#475569",fontWeight:500},null===(z=null==ge?void 0:ge.slotStyles)||void 0===z?void 0:z.title),body:null===(B=null==ge?void 0:ge.slotStyles)||void 0===B?void 0:B.body},primaryActions:[((null===(I=null===(E=null==ge?void 0:ge.summarizedTab)||void 0===E?void 0:E.chip)||void 0===I?void 0:I.show)||void 0===(null===(H=null===(P=null==ge?void 0:ge.summarizedTab)||void 0===P?void 0:P.chip)||void 0===H?void 0:H.show))&&l.jsx(n.default,e.__assign({label:"Summarized"},null===(V=null==ge?void 0:ge.summarizedTab)||void 0===V?void 0:V.chip)),l.jsx(n.default,e.__assign({label:"Detailed"},null===(M=null==ge?void 0:ge.detailedTab)||void 0===M?void 0:M.chip))],secondaryActions:ge.secondaryActions?null==ge?void 0:ge.secondaryActions($e):$e},{children:l.jsxs("div",e.__assign({ref:Ne,style:e.__assign({height:"100%",maxHeight:"275px",border:"2px solid #E2E8F0",borderRadius:"8px",display:"flex",flexDirection:"column",gap:"12px",backgroundColor:"#F8FAFC",position:"relative",overflowY:"auto"},null===(N=null==ge?void 0:ge.slotStyles)||void 0===N?void 0:N.chatDataContainer)},{children:[(null===(Y=null===(W=null==ge?void 0:ge.detailedTab)||void 0===W?void 0:W.chip)||void 0===Y?void 0:Y.isActive)&&l.jsx("div",e.__assign({ref:Me,style:{position:(null==xe?void 0:xe.isExpanded)?"absolute":"relative",inset:0,padding:"12px",overflowY:"auto"}},{children:l.jsx(d.default,{chatData:null!==(O=ge.chatData)&&void 0!==O?O:[],assistantChatProps:e.__assign(e.__assign({},null===(Q=null===(K=null==ge?void 0:ge.detailedTab)||void 0===K?void 0:K.view)||void 0===Q?void 0:Q.assistantChatProps),{renderers:null!==(J=null===(G=null===(U=null==ge?void 0:ge.detailedTab)||void 0===U?void 0:U.detailedViewRenderer)||void 0===G?void 0:G.assistantText)&&void 0!==J?J:We}),userChatItemProps:e.__assign(e.__assign({},null===(X=null===(L=null==ge?void 0:ge.detailedTab)||void 0===L?void 0:L.view)||void 0===X?void 0:X.userChatItemProps),{renderers:null!==(ee=null===($=null===(Z=null==ge?void 0:ge.detailedTab)||void 0===Z?void 0:Z.detailedViewRenderer)||void 0===$?void 0:$.userText)&&void 0!==ee?ee:We})})})),(null===(ie=null===(le=null==ge?void 0:ge.summarizedTab)||void 0===le?void 0:le.chip)||void 0===ie?void 0:ie.show)&&(null===(ne=null===(oe=null==ge?void 0:ge.summarizedTab)||void 0===oe?void 0:oe.chip)||void 0===ne?void 0:ne.isActive)&&l.jsx(s.default,e.__assign({chatData:null!==(te=ge.chatData)&&void 0!==te?te:[]},null===(re=null==ge?void 0:ge.summarizedTab)||void 0===re?void 0:re.view,{renderer:null!==(se=null===(de=null==ge?void 0:ge.summarizedTab)||void 0===de?void 0:de.summarizedViewRenderer)&&void 0!==se?se:We}))]}))}))}))]}));return Se?l.jsx(i.default,e.__assign({title:null==he?void 0:he.title,slotStyles:{title:null===(ae=null==he?void 0:he.slotStyles)||void 0===ae?void 0:ae.title,body:null===(ue=null==he?void 0:he.slotStyles)||void 0===ue?void 0:ue.body},containerStyles:null===(ve=null==he?void 0:he.slotStyles)||void 0===ve?void 0:ve.container,icon:null!==(ce=null==he?void 0:he.icon)&&void 0!==ce?ce:l.jsx(c.default,{children:l.jsx("img",{src:t.default,alt:"chat icon",style:{width:16,height:16}})}),secondaryActions:(null==he?void 0:he.secondaryActions)?he.secondaryActions(Le):Le},{children:el})):el};
2
2
  //# sourceMappingURL=InternalChatCitationRenderer.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),i=require("react/jsx-runtime"),n=require("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 x=h(r),m=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)"),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)||C,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 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: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]),m=t.useMemo(function(){return f(v)},[v]),w=(null===(l=null==m?void 0:m.customMetaData)||void 0===l?void 0:l.value)||{},S=(null==v?void 0:v.extraMetaData)||v||{},P=t.useState(),M=P[0],T=P[1],k=t.useState("pending"),I=k[0],R=k[1],G=t.useState(!0),E=G[0],N=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(!s.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(s.endpoint,{method:"POST",headers:e.__assign({"actor-id":x.userEmail,Accept:"application/json, text/plain, */*","Content-Type":"application/json"},s.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?(T(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,s]);var q=t.useMemo(function(){return{item:{confidence_score:Number((null==S?void 0:S.Confidence_score)||0),text:(null==w?void 0:w.paraphrase)||"Web citation reasoning",dataSource:(null==w?void 0:w.text)||(null==S?void 0:S.Reasoning)||"",paraphrase:(null==w?void 0:w.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}}},[w,null==x?void 0:x.citatioNumber,S]),A=t.useMemo(function(){return e.__assign(e.__assign({},q),u?{bodyHeight:j}:{})},[q,u]);return i.jsx(p.default,{gptCitation:A,defaultCitationUrl:(null==x?void 0:x.citationUrl)||"",citationType:g.CitationType.GPT_WEB,webCitationData:M,webCitationStatus:I,showWebCitation:E,onToggleCitationView:function(){return N(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,C=n.citationType,w=n.citationReason,j=n.isFullscreen,D=c.useCompareContext().guidelinesData,F=function(e){try{var i=new URL(e,window.location.origin);return{citationNumber:i.searchParams.get("citationNumber"),phraseToHighlight:i.searchParams.get("phrase_to_highlight")}}catch(e){return{citationNumber:null,phraseToHighlight:null}}}(_),P=F.citationNumber,M=F.phraseToHighlight,T=P&&(null===(a=null==b?void 0:b.citations)||void 0===a?void 0:a[P])||{},k=(null===(r=null==b?void 0:b.docData)||void 0===r?void 0:r.documents)||{},I=(null===(u=null==b?void 0:b.docData)||void 0===u?void 0:u.input_index_map)||{},R=Object.keys((null==b?void 0:b.citations)||{}).length>0||Object.keys((null==b?void 0:b.docData)||{}).length>0,G=null==I?void 0:I[0],E=null==I?void 0:I[1],N=G?k[G]:null,q=E?k[E]:null,A=G?T[G]:null,U=E?T[E]:null,W=t.useMemo(function(){var e,n,t,o;return A&&N?i.jsx(l.default,{defaultScale:"PageWidth",showFullScreenAction:!1,showHighlightsAction:!1,pdfName:null==N?void 0:N.title,pdfUrl:null==N?void 0:N.signed_url,highlightText:[null!==(e=null==A?void 0:A.highlighted_text)&&void 0!==e?e:""],highlightPages:{1:null===(n=null==A?void 0:A.custom_metadata)||void 0===n?void 0:n.pdf_start_page_number},jumpToPageValue:1,highlightCordinatePages:[],useCoordinates:!1,useRange:!0,rangeOfPages:[null===(t=null==A?void 0:A.custom_metadata)||void 0===t?void 0:t.pdf_start_page_number,null===(o=null==A?void 0:A.custom_metadata)||void 0===o?void 0:o.pdf_end_page_number]}):null},[null==N?void 0:N.title,null==N?void 0:N.signed_url,null==A?void 0:A.highlighted_text,null===(p=null==A?void 0:A.custom_metadata)||void 0===p?void 0:p.pdf_start_page_number,null===(g=null==A?void 0:A.custom_metadata)||void 0===g?void 0:g.pdf_end_page_number]),z=t.useMemo(function(){var e,n,t,o;return U&&q?i.jsx(l.default,{defaultScale:"PageWidth",showFullScreenAction:!1,showHighlightsAction:!1,pdfName:null==q?void 0:q.title,pdfUrl:null==q?void 0:q.signed_url,jumpToPageValue:1,highlightText:[null!==(e=null==U?void 0:U.highlighted_text)&&void 0!==e?e:""],highlightPages:{1:null===(n=null==U?void 0:U.custom_metadata)||void 0===n?void 0:n.pdf_start_page_number},highlightCordinatePages:[],useCoordinates:!1,useRange:!0,rangeOfPages:[null===(t=null==U?void 0:U.custom_metadata)||void 0===t?void 0:t.pdf_start_page_number,null===(o=null==U?void 0:U.custom_metadata)||void 0===o?void 0:o.pdf_end_page_number]}):null},[null==q?void 0:q.title,null==q?void 0:q.signed_url,null==U?void 0:U.highlighted_text,null===(h=null==U?void 0:U.custom_metadata)||void 0===h?void 0:h.pdf_start_page_number,null===(f=null==U?void 0:U.custom_metadata)||void 0===f?void 0:f.pdf_end_page_number]),H="dual_citation"===C,O=H&&!!(null==b?void 0:b.webGpt),B=t.useMemo(function(){if(!W)return null;var n=O?i.jsx(S,{metaData:b,isFullscreen:j}):"rulebook_citation"===C?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(x.default,e.__assign({rehypePlugins:[m.default]},{children:v.processGuidelinesMarkdown({guidelinesData:D,targetHighlights:[M],labelColor:"#FEF08A"})}))}))}):z;return n?i.jsx(o.default,{leftComponent:W,rightComponent:n,isFullscreen:j}):W},[W,z,C,O,b,j]);return(null==b?void 0:b.webGpt)&&!R?i.jsx(S,{metaData:b,isFullscreen:j}):P?"rulebook_citation"===C?A?i.jsx("div",e.__assign({style:{height:"100%",display:"flex",flexDirection:"column"}},{children:B})):i.jsx("div",e.__assign({style:{padding:"12px",fontSize:"13px",color:"#344054",lineHeight:1.5}},{children:w||"Rulebook citation selected."})):H?A||U?i.jsx("div",e.__assign({style:{height:"100%",display:"flex",flexDirection:"column"}},{children:B})):(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)?A||U?i.jsx("div",e.__assign({style:{height:"100%",display:"flex",flexDirection:"column"}},{children:B})):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,x=o.citationType,m=o.citationReason,f=o.metaData,_=o.chevronUpComponent,b=void 0===_?null:_,y=o.chevronDownComponent,C=void 0===y?null:y,j=o.customStyle,D=void 0===j?{}:j,F=o.defaultState,S=void 0!==F&&F,M=o.onFullscreenChange,T=t.useState(S),k=T[0],I=T[1],R=t.useState(!1),G=R[0],E=R[1],N="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==M||M(G),G)return function(){null==M||M(!1)}},[G,M]);var q="string"==typeof h?h:h[0],A=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:{}),U=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==D?void 0:D.arrow)&&void 0!==u?u:{}),W=i.jsxs("div",e.__assign({style:{boxSizing:"border-box",border:G?"none":"1px solid #E4E7EC",borderRadius:G?0:"8px",overflow:"hidden",marginTop:G?0:"8px",display:"flex",flexDirection:"column",width:"100%",height:G?"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(){E(function(e){return!e})},style:{background:"none",border:"none",cursor:"pointer",padding:"4px",borderRadius:"6px",color:"#475467",marginRight:"9px"}},{children:G?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:q,citationType:x,citationReason:m,isFullscreen:G})}))]}));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 I(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:N}),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?A:U}))]}))})),k&&(G?i.jsx(d.Dialog,e.__assign({open:G,onClose:function(){return E(!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:W})):W)]}))};
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)]}))};
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 Io.current(e,n,i,t,o,r)},[]),yt=i.useCallback(function(e,n,i,t,o){return Do.current(e,n,i,t,o)},[]),Ct=i.useCallback(function(){return Oo.current()},[]),Et=i.useCallback(function(e,n){return Fo.current(e,n)},[]),At=i.useCallback(function(e){return jo.current(e)},[]),Tt=i.useCallback(function(e){return Po.current(e)},[]),wt=i.useCallback(function(){return ko.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=[],Yt([]),Xt(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.useRef(he);i.useEffect(function(){Ot.current=he},[he]);var Ft=i.useRef(yn);i.useEffect(function(){Ft.current=yn},[yn]);var jt=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=Ft.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]),Pt=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?ao():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(jt(e,n,t,o,i,r))})}},[Mn.open,Mn.sectionIdx,$n,zn,jt]),kt=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(lo(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]),Nt=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]),Mt=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&&Lt.current()})},50)}else console.warn('scrollToAndHighlightClause: nodeId "'.concat(n,'" not found'))}},[vi,gi,Me,tt,rt,Qi,zn,Xn]),Lt=i.useRef(Nt);i.useEffect(function(){Lt.current=Nt},[Nt]);var qt=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 Ht=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]),Gt=E.useStyleHelpers({proposedSections:vi,existingSections:gi,maintainRelativeOrder:Me,cognitiveMap:yn,deviationData:bn,treeData:he,resolvedComparisonConfig:Qn,badgeStyleOverride:je}),Vt=Gt.getSectionCompareStyle,Wt=Gt.getSubSectionCompareStyle,zt=Gt.getDeviationStyleByKey,Kt=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:Vt,getSubSectionCompareStyle:Wt,getDeviationStyleByKey:zt,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:Ht}),Ut=Kt.lines,Yt=Kt.setLines,Jt=Kt.overallConnector,Xt=Kt.setOverallConnector,$t=Kt.svgDimensions,Qt=Kt.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 Zt=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 eo=i.useMemo(function(){return Object.values(it).some(Boolean)||Object.values(ot).some(Boolean)},[it,ot]),no=i.useRef(null),io=i.useRef(0),to=i.useRef(0),oo=i.useRef(0),ro=A.useResizeHandler({timerRef:no,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=ro},[ro,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,io,n,function(){return xn.current()},function(){})),En.current&&o.push(e(En.current,to,i,function(){return xn.current()},function(){return Sn.current()})),cn.current&&o.push(e(cn.current,oo,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 lo=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]),uo=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]),so=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(lo(n)),Qe(new Set([n]))),Zi(n,i,{sourceSide:t,onReady:function(){ci&&setTimeout(function(){return uo(String(n))},150)}})}},[Zi,Mn.isOrphan,Mn.sectionIdx,Mn.anchorEl,zn,st,ci,uo,lo]),ao=i.useCallback(function(){zn(),Qi(),Qe(new Set),nn([]),mn.current=[]},[zn,Qi]),co=null!==Mn.sectionIdx&&$e.has(Mn.sectionIdx),fo=S.useDeviationNavigation({proposedSections:vi,existingSections:gi,parentDeviationRecord:hi,expandedSections:it,maintainRelativeOrder:!!Me,scrollContainerRef:En,leftContainerRef:On,rightContainerRef:Tn,lhsBadgeRefs:Ti,rhsBadgeRefs:wi}),vo=fo.showDeviationNavigation,go=fo.showOpenNodeRef,po=fo.adjustScrollForPopup,ho=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(lo(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 uo(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 uo(n)},150)},350)},[Zi,Xn,Wn,Qi,st,ci,Me,uo,bn]),mo=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]),So=i.useRef({id:null,triggerMs:null}),Ro=i.useRef(null);i.useEffect(function(){if(null==we?void 0:we.id){var n=Number(we.trigger),i=So.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);Ro.current!==s&&(zn(),Xn(),Qi(),Qe(new Set),nn([]),mn.current=[],Ro.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(){So.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?!!Bo.current["right-".concat(D)]:!!Bo.current[String(D)])&&D>=0)return ut(D,"right"),void(d=setTimeout(p,200))}else if(!(Me?!!Bo.current["left-".concat(B)]:!!Bo.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,po(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(lo(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 uo(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()}}So.current={id:we.id,triggerMs:n},Mt(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(lo(e)),Qe(new Set([e])),et.current(e,n,{sourceSide:n?"right":"left",onReady:function(){ci&&setTimeout(function(){return uo(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,Mt,ci,lo,uo]),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 xo=kn.open,_o=kn.sectionIdx,bo=kn.isOrphan,yo=kn.badgeStyle,Co=kn.anchorEl,Eo=kn.sectionAnchorEl;i.useEffect(function(){var n;if(ye.isStreamingEnabled&&xo&&null!=_o&&_o!==pt){var i="string"==typeof _o?_o.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 _o?vi[_o]||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 _o?gi[_o]||null:r,a=jt(Co,l,s,_o,bo,yo);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})}},[xo,_o,bo,yo,Co,Eo,vi,gi,jt]);var Ao=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})},[]),To=i.useMemo(function(){return vi.map(function(e,i){var t,o=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),r=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return o&&r&&Me?null:n.jsx(_.default,{section:e,idx:i},null!==(t=null==e?void 0:e.id)&&void 0!==t?t:"left-row-".concat(i))})},[vi]),wo=i.useMemo(function(){return gi.map(function(e,i){var t,o=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),r=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return o&&r&&Me?null:n.jsx(b.default,{section:e,idx:i},null!==(t=null==e?void 0:e.id)&&void 0!==t?t:"right-row-".concat(i))})},[gi]),Io=i.useRef(Pt);i.useEffect(function(){Io.current=Pt},[Pt]);var Bo=i.useRef(it);i.useEffect(function(){Bo.current=it},[it]);var Do=i.useRef(ho);i.useEffect(function(){Do.current=ho},[ho]);var Oo=i.useRef(ao);i.useEffect(function(){Oo.current=ao},[ao]);var Fo=i.useRef(ut);i.useEffect(function(){Fo.current=ut},[ut]);var jo=i.useRef(lt);i.useEffect(function(){jo.current=lt},[lt]);var Po=i.useRef(Ao);i.useEffect(function(){Po.current=Ao},[Ao]);var ko=i.useRef(Qi);i.useEffect(function(){ko.current=Qi},[Qi]);var No=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:Vt,getSubSectionCompareStyle:Wt,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:vo,showOpenNodeRef:go,deviationNodeIdToView:null==we?void 0:we.id,deviationTargetParentId:mo,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,Vt,Wt,Pi,Fi,ji,vo,go,we,mo,Pe,ke]),Mo=u.safeStringify(kn.sectionTitle||ri||ti),Lo=u.safeStringify(ci?ui||si||kn.refSectionTitle:kn.refSectionTitle||ui||si);return n.jsx(C.CompareContextProvider,e.__assign({value:No},{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:qt.current,clipTopEl:dn.current,scrollContainerEl:En.current,onClose:ao,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:so,onConnect:kt,isConnected:co,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:Mo,referenceSectionTitle:Lo,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:Zt,showCollapseAll:eo,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:Qt,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:$t,isResizing:qi,overallConnector:Jt,rootDeviationStyle:St,lines:Ut,isSideBySide:Ni,activeSideBySideSection:Vi,isArrowVisible:Mi,maintainRelativeOrder:Me,proposedSections:vi,existingSections:gi,cognitivePopup:kn,activeBadgeId:Gn,closeCognitivePopup:Xn,setActiveBadgeId:Kn,openCognitivePopupFromState:Jn,buildSectionPopupState:jt,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:Qt,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&&To,n.jsx("div",{ref:Dn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),n.jsx(t.Box,e.__assign({ref:qt,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(jt(n.currentTarget,{title:"",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:Qt,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&&wo,n.jsx("div",{ref:In,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),i=require("react"),t=require("@mui/material"),o=require("lucide-react"),r=require("../../assests/svg/ButtonCognitiveIcon.js"),l=require("./OverlayComponent.js"),u=require("./CognitiveComparehelpers.js"),s=require("./CognitiveCompareConfig.js"),a=require("./CognitiveCompareConstants.js"),c=require("./CognitivePopup.js"),d=require("./MoreFunctionsPopup.js"),f=require("./LoaderComponent.js"),v=require("./components/ThreeDotsLoader.js"),g=require("./hooks/useCompareData.js"),p=require("./hooks/useComparePopups.js"),h=require("./hooks/useSectionRefs.js"),m=require("./hooks/useAccordionState.js"),S=require("./hooks/useDeviationNavigation.js"),R=require("./components/CompareHeader.js"),x=require("./components/SubSectionAccordion.js"),_=require("./components/LHSSectionRow.js"),b=require("./components/RHSSectionRow.js"),y=require("./components/CognitiveSummaryPopup.js"),C=require("./CompareContext.js"),E=require("./hooks/useStyles.js"),A=require("./hooks/useResizeHandler.js"),T=require("./hooks/useLinesCalculator.js"),w=require("./hooks/useSideBySide.js"),I=require("./components/SvgConnectors.js"),B=require("./Guidelines/components/GuidelinePanel.js"),D=require("./Guidelines/components/WebGptPanel.js");exports.SHARED_MARKDOWN_STYLES=s.SHARED_MARKDOWN_STYLES,exports.default=function(O){var F,j,P,k,N,M,L,q,H,G,V,W,z,K,U,Y,J,X,$,Q,Z,ee,ne,ie,te,oe,re,le,ue,se,ae,ce,de,fe,ve,ge=O.componentHeaderText,pe=void 0===ge?a.DEFAULT_COMPONENT_HEADER_TEXT:ge,he=O.treeData,me=O.comparisonConfig,Se=O.leftColumnTitleText,Re=O.rightColumnTitleText,xe=O.markdownStyles,_e=O.resetTrigger,be=O.displayConfig,ye=void 0===be?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1,displayEmailNotifier:!0,isStreamingEnabled:!1}:be,Ce=O.onMaintainRelativeOrderChange,Ee=O.popupConfig,Ae=O.deviationData,Te=void 0===Ae?{}:Ae,we=O.deviationNodeIdToView,Ie=O.resetDeviationNodeId,Be=O.isProposingFix,De=void 0!==Be&&Be,Oe=O.proposingFixNodeId,Fe=O.isRedlineFlow,je=O.badgeStyleOverride,Pe=O.guidelinesData,ke=O.gptWebCitationConfig,Ne=i.useState(ye.maintainRelativeOrder),Me=Ne[0],Le=Ne[1],qe=null!==(F=null==ye?void 0:ye.expandLevels)&&void 0!==F?F:0,He=!!(null==ye?void 0:ye.expandAllSections),Ge=!!Me||!!(null==ye?void 0:ye.showDeviationBadges),Ve=i.useState(!1),We=Ve[0],ze=Ve[1],Ke=i.useState(null),Ue=Ke[0],Ye=Ke[1],Je=i.useState(null===(P=null!==(j=null==he?void 0:he.newEvaluationResult)&&void 0!==j?j:null==ye?void 0:ye.enableDeviationSchemaBackwardCompatibility)||void 0===P||P)[0],Xe=i.useState(new Set),$e=Xe[0],Qe=Xe[1],Ze=i.useState([]),en=Ze[0],nn=Ze[1],tn=i.useState(!1),on=tn[0],rn=tn[1],ln=i.useState(0),un=ln[0],sn=ln[1],an=i.useRef(null),cn=i.useRef(null),dn=i.useRef(null),fn=i.useRef(null),vn=i.useRef(null),gn=i.useRef(!1),pn=i.useRef(null),hn=i.useRef({}),mn=i.useRef([]),Sn=i.useRef(function(){}),Rn=i.useRef(null),xn=i.useRef(function(){}),_n=i.useMemo(function(){return JSON.stringify(Te||{})},[JSON.stringify(Te)]),bn=i.useMemo(function(){return Te||{}},[_n]),yn=i.useMemo(function(){return(null==he?void 0:he.cognitive_decisioning)||{}},[he]),Cn=i.useMemo(function(){return e.__assign(e.__assign({},s.SHARED_MARKDOWN_STYLES),xe)},[xe]),En=i.useRef(null),An=i.useRef(null),Tn=i.useRef(null),wn=i.useRef(null),In=i.useRef(null),Bn=i.useRef(null),Dn=i.useRef(null),On=i.useRef(null),Fn=i.useRef(null),jn=i.useRef(null),Pn=p.useComparePopups(En),kn=Pn.cognitivePopup,Nn=Pn.setCognitivePopup,Mn=Pn.moreFunctions,Ln=Pn.setMoreFunctions,qn=Pn.position,Hn=Pn.setPosition,Gn=Pn.activeBadgeId,Vn=Pn.summaryPopup,Wn=Pn.setSummaryPopup,zn=Pn.closeSummaryPopup,Kn=Pn.setActiveBadgeId,Un=Pn.popupRef,Yn=Pn.handleOpenCognitiveCompare,Jn=Pn.openCognitivePopupFromState,Xn=Pn.closeCognitivePopup,$n=Pn.closeMoreFunctionsPopup,Qn=i.useMemo(function(){var e,n,i,t,o,r,l;return{fields:null!==(e=null==me?void 0:me.fields)&&void 0!==e?e:s.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(i=null===(n=null==me?void 0:me.thresholds)||void 0===n?void 0:n.high)&&void 0!==i?i:s.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(o=null===(t=null==me?void 0:me.thresholds)||void 0===t?void 0:t.medium)&&void 0!==o?o:s.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(l=null===(r=null==me?void 0:me.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:s.DEFAULT_COMPARISON_CONFIG.thresholds.exact}}},[me]),Zn=i.useState(null),ei=Zn[0];Zn[1];var ni=null===(M=null===(k=null==he?void 0:he.documents)||void 0===k?void 0:k[null===(N=null==he?void 0:he.input_index_map)||void 0===N?void 0:N[0]])||void 0===M?void 0:M.title,ii=null===(H=null===(L=null==he?void 0:he.documents)||void 0===L?void 0:L[null===(q=null==he?void 0:he.input_index_map)||void 0===q?void 0:q[1]])||void 0===H?void 0:H.title,ti=u.safeStringify(Se||ni||"Uploaded Contract"),oi=null===(z=null===(W=null===(G=null==he?void 0:he.documents)||void 0===G?void 0:G[null===(V=null==he?void 0:he.input_index_map)||void 0===V?void 0:V[0]])||void 0===W?void 0:W.metadata)||void 0===z?void 0:z.file_name,ri=u.safeStringify(oi),li=null===(J=null===(Y=null===(K=null==he?void 0:he.documents)||void 0===K?void 0:K[null===(U=null==he?void 0:he.input_index_map)||void 0===U?void 0:U[1]])||void 0===Y?void 0:Y.metadata)||void 0===J?void 0:J.file_name,ui=u.safeStringify(li),si=u.safeStringify(Re||ii||"Reference Template"),ai=g.useCognitiveTreeData(he,Me,bn,Qn,Je,Pe),ci=ai.isGuidelineMode,di=ai.activeProposed,fi=ai.existingRule,vi=ai.proposedSections,gi=ai.existingSections,pi=ai.visibleFields,hi=ai.parentDeviationRecord,mi=ai.deviationNumberRegistry,Si=ai.deviationParentRegistry,Ri=ai.parseError;i.useEffect(function(){Ri&&Ye("Failed to load comparison: ".concat(Ri))},[Ri]);var xi=vi.length>0||gi.length>0,_i=i.useMemo(function(){if(!Fe)return"off";var e=0,n=0,i=function(t){Array.isArray(t)&&t.forEach(function(t){var o,r=(null==t?void 0:t.content)||"";u.hasMeaningfulRedlineTags(r)&&(e+=1,n+=String(r).length),(null===(o=null==t?void 0:t.subsections)||void 0===o?void 0:o.length)&&i(t.subsections)})};return i(vi),i(gi),"".concat(e,":").concat(n)},[Fe,vi,gi]);i.useEffect(function(){if(vi.length||gi.length)if(He){var e={},n={},i=function(i,t){i.forEach(function(i,o){var r,l=Me?"".concat(t,"-").concat(o):String(o);e[l]=!0;var u=function(e,i){null==e||e.forEach(function(e,t){var o,r="".concat(i,"-").concat(t);n[r]=!0,(null===(o=e.subsections)||void 0===o?void 0:o.length)&&u(e.subsections,r)})};(null===(r=i.subsections)||void 0===r?void 0:r.length)&&u(i.subsections,String(o))})};i(vi,"left"),i(gi,"right"),tt(e),rt(n)}else if(qe>0){var t={},o={},r=function(e,n,i){e.forEach(function(e,r){var l;if(i>=1){var u=Me?"".concat(n,"-").concat(r):String(r);t[u]=!0}var s=function(e,n,t){t>i||null==e||e.forEach(function(e,i){var r,l="".concat(n,"-").concat(i);o[l]=!0,(null===(r=e.subsections)||void 0===r?void 0:r.length)&&s(e.subsections,l,t+1)})};(null===(l=e.subsections)||void 0===l?void 0:l.length)&&i>=2&&s(e.subsections,String(r),2)})};r(vi,"left",qe),r(gi,"right",qe),tt(t),rt(o)}},[He,qe,vi,gi,Me]);var bi=h.useSectionRefs(pi.map(function(e){return e.key}),Math.max(vi.length,gi.length)),yi=bi.leftRefs,Ci=bi.rightRefs,Ei=bi.sectionLeftRefs,Ai=bi.sectionRightRefs,Ti=bi.lhsBadgeRefs,wi=bi.rhsBadgeRefs,Ii=bi.sectionRightRowRefs,Bi=bi.subSectionLeftRefs,Di=bi.subSectionRightRefs,Oi=bi.sectionRowRefs,Fi=bi.getSectionRowRef,ji=bi.getSubSectionRef,Pi=bi.getBadgeRef,ki=w.useSideBySide({isGuidelineMode:ci,maintainRelativeOrder:Me,proposedSections:vi,existingSections:gi,leftContainerRef:On,rightContainerRef:Tn,scrollContainerRef:En,sectionLeftRefs:Ei,sectionRightRefs:Ai,subSectionLeftRefs:Bi,subSectionRightRefs:Di,lhsBadgeRefs:Ti,rhsBadgeRefs:wi,sectionRowRefs:Oi,sectionRightRowRefs:Ii,rhsTopSpacerRef:wn,rhsBottomSpacerRef:In,lhsTopSpacerRef:Bn,lhsBottomSpacerRef:Dn,calculateLinesRef:Sn,setConnectedSections:Qe,setConnectedLines:nn,cachedConnectedPositions:mn,closeMoreFunctionsPopup:$n,setErrorToast:Ye,moreFunctions:Mn,closeSummaryPopup:zn}),Ni=ki.isSideBySide,Mi=ki.isArrowVisible,Li=ki.setIsArrowVisible,qi=ki.isResizing,Hi=ki.setIsResizing,Gi=ki.isSideBySideLoading,Vi=ki.activeSideBySideSection,Wi=ki.scrollLock,zi=ki.sideBySideCacheRef,Ki=ki.isSideBySideRef,Ui=ki.activeSideBySideRightSectionRef,Yi=ki.activeSideBySideSectionRef,Ji=ki.sideBySideLineRef,Xi=ki.highlightedClauseRefs,$i=ki.clearClauseHighlight,Qi=ki.resetSideBySide,Zi=ki.activateSideBySide,et=i.useRef(Zi);i.useEffect(function(){et.current=Zi},[Zi]);var nt=m.useAccordionState({maintainRelativeOrder:!!Me,proposedSections:vi,existingSections:gi,activeSideBySideSection:Vi,connectedSections:$e,resetSideBySide:Qi,setConnectedSections:Qe,setConnectedLines:nn,cachedConnectedPositions:mn,svgContainerRef:an,isAnimatingRef:gn,animationTimerRef:pn,calculateLinesRef:Sn,sectionLeftRefs:Ei,sectionRightRefs:Ai,subSectionLeftRefs:Bi,subSectionRightRefs:Di}),it=nt.expandedSections,tt=nt.setExpandedSections,ot=nt.expandedSubSections,rt=nt.setExpandedSubSections,lt=nt.handleSubSectionToggle,ut=nt.toggleSection,st=nt.forceExpandCrossWiredSections,at=function(){var e,n;if(null!=Vi){var i=null===(e=Ei.current[Vi])||void 0===e?void 0:e.current,t=null===(n=Ai.current[Vi])||void 0===n?void 0:n.current,o=Tn.current;if(i&&t&&o){var r=i.getBoundingClientRect(),l=t.getBoundingClientRect(),u=o.getBoundingClientRect(),s=r.top-u.top,a=l.top-u.top-s;o.scrollBy({top:a,behavior:"smooth"})}}},ct=i.useCallback(function(e){null==e||e.stopPropagation(),rn(function(e){var n=!e;return n&&requestAnimationFrame(function(){at()}),n})},[at]);i.useEffect(function(){Fe&&"off"!==_i&&"0:0"!==_i&&(zi.current=null,mn.current=[],requestAnimationFrame(function(){var e;null===(e=Sn.current)||void 0===e||e.call(Sn)}))},[Fe,_i]);var dt=i.useMemo(function(){var e=new Map,n=new Map,i=1;if(Me)vi.forEach(function(n){!n.title&&!n.content||n.id&&e.set(n.id,i++)}),gi.forEach(function(t){if(t.id&&!(!t.title&&!t.content)){var o=vi.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(t.selfIndex)});if(o.length>0){var r=o.map(function(n){return e.get(n.id)}).filter(Boolean);n.set(t.id,r.join(", "))}else n.set(t.id,String(i++))}});else for(var t=Math.max(vi.length,gi.length),o=0;o<t;o++){var r=vi[o],l=gi[o];r?(e.set(r.id,i),l&&n.set(l.id,String(i)),i++):l&&n.set(l.id,String(i++))}return{leftNums:e,rightNums:n}},[vi,gi,Me]),ft=fi.analysis,vt=u.safeStringify(null===($=null===(X=null==ft?void 0:ft.rule_difference_comparison)||void 0===X?void 0:X.summary)||void 0===$?void 0:$.overall_summary),gt=!!vt.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),pt=null!==(Q=null==he?void 0:he.base_root_id)&&void 0!==Q?Q:"-1";null==he||he[pt];var ht=Je?null!==(ce=null!==(ue=Te&&(null===(le=null==Te?void 0:Te[pt])||void 0===le?void 0:le.evaluation_result))&&void 0!==ue?ue:null===(ae=null===(se=null==he?void 0:he.nodes)||void 0===se?void 0:se[pt])||void 0===ae?void 0:ae.evaluation_result)&&void 0!==ce?ce:null:null!==(re=null!==(ne=Te&&(null===(ee=null===(Z=null==Te?void 0:Te[pt])||void 0===Z?void 0:Z.evaluation_result)||void 0===ee?void 0:ee[0]))&&void 0!==ne?ne:null===(oe=null===(te=null===(ie=null==he?void 0:he.nodes)||void 0===ie?void 0:ie[pt])||void 0===te?void 0:te.evaluation_result)||void 0===oe?void 0:oe[0])&&void 0!==re?re:null,mt=u.extractDeviationScore(ht),St=u.generateColorPalette(null!==(ve=null===(fe=null===(de=null==ht?void 0:ht.evaluation_outputs)||void 0===de?void 0:de.metadata)||void 0===fe?void 0:fe.label_color)&&void 0!==ve?ve:a.DEFAULT_DEVIAION_COLOR);if(je){var Rt=je(mt);Rt&&(St=e.__assign(e.__assign({},St),{badgeBg:Rt.bg,badgeText:Rt.text,badgeBorder:Rt.border}))}var xt=i.useRef(Qi);i.useEffect(function(){xt.current=Qi},[Qi]);var _t=i.useRef(Xn);i.useEffect(function(){_t.current=Xn},[Xn]);var bt=i.useCallback(function(e,n,i,t,o,r){return 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}})]}))]}))]}))}))}))]}))}))};
2
2
  //# sourceMappingURL=CognitiveCompare.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=function(t){if("string"!=typeof t||""===t.trim())return null;try{var r="undefined"!=typeof window?window.location.origin:"http://localhost";return new URL(t,r)}catch(t){return null}},r=function(t,r){var e;if("string"!=typeof t||"string"!=typeof r||""===r.trim())return"";try{var n=t.match(new RegExp("\\b".concat(r,"\\s*=\\s*(['\"])(.*?)\\1"),"i"));return null!==(e=null==n?void 0:n[2])&&void 0!==e?e:""}catch(t){return""}},e=function(t){if("string"!=typeof t||""===t)return"";try{return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}catch(r){return t}},n=function(t,r,n){if("string"!=typeof t||""===t.trim())return t;if("string"!=typeof r||""===r.trim())return t;if(!n||"string"!=typeof n)return t;try{var a=e(n),i=new RegExp("\\b".concat(r,"\\s*=\\s*(['\"])(.*?)\\1"),"i");return i.test(t)?t.replace(i,function(){return"".concat(r,'="').concat(a,'"')}):t.replace(/<a\b/i,function(){return"<a ".concat(r,'="').concat(a,'"')})}catch(r){return t}};exports.mergeRulebookCitationsIntoMatchingLinks=function(a){if("string"!=typeof a||!a||!a.includes("rulebook_citation"))return a;try{var i=a;return Array.from(a.matchAll(/<a\b((?:[^>"']|"[^"]*"|'[^']*')*)>([\s\S]*?)<\/a>/gi)).forEach(function(a){var c,o=a[0],u=a[1]||"",s=r(u,"type");if("rulebook_citation"===s){var l=r(u,"reason"),f=r(u,"href").replace(/&amp;/gi,"&"),p=t(f),h=null===(c=((null==p?void 0:p.searchParams.get("citationNumber"))||"").match(/^rb_(.+)$/))||void 0===c?void 0:c[1];if(h){var g={citation_type:(null==p?void 0:p.searchParams.get("citation_type"))||"",phrase_to_highlight:(null==p?void 0:p.searchParams.get("phrase_to_highlight"))||""};if(g.citation_type||g.phrase_to_highlight){var v=!1,y=function(r){var e=t(r.replace(/&amp;/gi,"&"));return(null==e?void 0:e.searchParams.get("citationNumber"))!==h?r:(v=!0,function(r,e){if("string"!=typeof r||""===r.trim())return r;if(!e||"object"!=typeof e)return r;try{var n=t(r);if(!n)return r;Object.entries(e).forEach(function(t){var r=t[0],e=t[1];e&&n.searchParams.set(r,e)});var a="".concat(n.pathname).concat(n.search).concat(n.hash);return r.startsWith("./")?".".concat(a):!r.startsWith("/")&&a.startsWith("/")?a.slice(1):a}catch(t){return r}}(r,g))};i=i.replace(/\[([^\]]+)\]\(([^)\n]+)\)/g,function(t,r,n){var a=y(n);return a===n?t:'<a type="'.concat(e(s),'" reason="').concat(e(l),'" href="').concat(e(a),'">').concat(r,"</a>")}),v||(i=i.replace(/<a\b((?:[^>"']|"[^"]*"|'[^']*')*)>/gi,function(t,e){if("rulebook_citation"===r(e,"type"))return t;var a=r(e,"href"),i=y(a);if(i===a)return t;var c=t.replace(/\bhref\s*=\s*(['"])(.*?)\1/i,function(t,r){return"href=".concat(r).concat(i).concat(r)});return n(n(c,"type",s),"reason",l)})),i=i.split(o).join("")}else i=i.split(o).join("")}else i=i.split(o).join("")}}),i}catch(t){return a}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=function(t){if("string"!=typeof t||""===t.trim())return null;try{var r="undefined"!=typeof window?window.location.origin:"http://localhost";return new URL(t,r)}catch(t){return null}},r=function(t,r){var e;if("string"!=typeof t||"string"!=typeof r||""===r.trim())return"";try{var n=t.match(new RegExp("\\b".concat(r,"\\s*=\\s*(['\"])(.*?)\\1"),"i"));return null!==(e=null==n?void 0:n[2])&&void 0!==e?e:""}catch(t){return""}},e=function(t){if("string"!=typeof t||""===t)return"";try{return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}catch(r){return t}},n=function(t,r,n){if("string"!=typeof t||""===t.trim())return t;if("string"!=typeof r||""===r.trim())return t;if(!n||"string"!=typeof n)return t;try{var i=e(n),a=new RegExp("\\b".concat(r,"\\s*=\\s*(['\"])(.*?)\\1"),"i");return a.test(t)?t.replace(a,function(){return"".concat(r,'="').concat(i,'"')}):t.replace(/<a\b/i,function(){return"<a ".concat(r,'="').concat(i,'"')})}catch(r){return t}},i=function(r,e){if("string"!=typeof r||!r||"string"!=typeof e||!e)return"";try{var n=r.indexOf("?");if(n>=0){var i=r.slice(n+1).replace(/&amp;/gi,"&"),a=i.indexOf("".concat(e,"="));if(a>=0){var c=a+e.length+1,o=i.slice(c).match(/&[A-Za-z_][A-Za-z0-9_]*=/),u=void 0!==(null==o?void 0:o.index)?c+o.index:i.length;return decodeURIComponent(i.slice(c,u).replace(/\+/g," "))}}var l=t(r.replace(/&amp;/gi,"&"));return(null==l?void 0:l.searchParams.get(e))||""}catch(t){return""}};exports.mergeRulebookCitationsIntoMatchingLinks=function(a){if("string"!=typeof a||!a||!a.includes("citation_type"))return a;try{var c=a;return Array.from(a.matchAll(/<a\b([^>]*?)>([\s\S]*?)<\/a>/gi)).forEach(function(a){var o=a[0],u=a[1]||"",l=r(u,"href").replace(/&amp;/gi,"&"),s=t(l),f=r(u,"type"),p=null==s?void 0:s.searchParams.get("citation_type");if("rulebook_citation"===f||"il_rulebook_citation"===p){f||(f=p||"rulebook_citation");var h=r(u,"reason"),g=(null==s?void 0:s.searchParams.get("citationNumber"))||(null==s?void 0:s.searchParams.get("citation_number"))||"",v=g.match(/^rb_(.+)$/),y=v?v[1]:g;if(y){var m={citation_type:p||"",phrase_to_highlight:i(l,"phrase_to_highlight")};if(m.citation_type||m.phrase_to_highlight){var d=!1,_=function(r){return function(r){if("string"!=typeof r||!r)return null;var e=r.match(/^(?:pdf_citation|deviation_summary)\$(\d+)/);if(e)return e[1];try{var n=t(r.replace(/&amp;/gi,"&"));return(null==n?void 0:n.searchParams.get("citationNumber"))||(null==n?void 0:n.searchParams.get("citation_number"))||null}catch(t){return null}}(r)!==y?r:(d=!0,function(r,e){if("string"!=typeof r||""===r.trim())return r;if(!e||"object"!=typeof e)return r;try{var n=t(r);if(!n)return r;Object.entries(e).forEach(function(t){var r=t[0],e=t[1];e&&n.searchParams.set(r,e)});var i="".concat(n.pathname).concat(n.search).concat(n.hash);return r.startsWith("./")?".".concat(i):!r.startsWith("/")&&i.startsWith("/")?i.slice(1):i}catch(t){return r}}(r,m))};c=c.replace(/\[([^\]]+)\]\(([^)\n]+)\)/g,function(t,r,n){var i=_(n);return i===n?t:'<a type="'.concat(e(f),'" reason="').concat(e(h),'" href="').concat(e(i),'">').concat(r,"</a>")}),d||(c=c.replace(/<a\b([^>]*?)>/gi,function(e,i){var a,c=r(i,"type")||(null===(a=t(r(i,"href")))||void 0===a?void 0:a.searchParams.get("citation_type"));if("rulebook_citation"===c||"il_rulebook_citation"===c)return e;var o=r(i,"href"),u=_(o);if(u===o)return e;var l=e.replace(/\bhref\s*=\s*(['"])(.*?)\1/i,function(t,r){return"href=".concat(r).concat(u).concat(r)});return n(n(l,"type",f),"reason",h)})),c=c.split(o).join("")}else c=c.split(o).join("")}else c=c.split(o).join("")}}),c}catch(t){return a}};
2
2
  //# sourceMappingURL=helper.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.processGuidelinesMarkdown=function(e){var t,a,n=e.guidelinesData,o=e.targetHighlights,r=void 0===o?[]:o,i=e.labelColor,c=void 0===i?"#FEF08A":i,l=(null===(a=null===(t=null==n?void 0:n.data)||void 0===t?void 0:t.artifactData)||void 0===a?void 0:a.userStorySnapshot)||[],u="";return l.forEach(function(e){var t;e.title&&(u+="### ".concat(e.title,"\n\n")),e.value&&(u+="".concat(e.value,"\n\n")),null===(t=e.sub_features)||void 0===t||t.forEach(function(e){e.title&&(u+="#### ".concat(e.title,"\n\n")),e.value&&(u+="".concat(e.value,"\n\n"))})}),r.forEach(function(e,t){var a=e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),n=new RegExp("(".concat(a,")"),"g");u=u.replace(n,'<mark id="guideline-target-'.concat(t,'" style="background-color: ').concat(c,'; border-radius: 3px; padding: 2px;">$1</mark>'))}),u};
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};
2
2
  //# sourceMappingURL=processGuidelinesMarkdown.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("tslib"),e=require("react/jsx-runtime"),i=require("react"),t=require("@mui/material"),o=require("lucide-react"),l=require("../hooks/memoizedMarkdown.js"),r=require("../CompareContext.js"),d=require("../CognitiveComparehelpers.js"),a=require("../CognitiveCompareConstants.js");function s(n){return n&&"object"==typeof n&&"default"in n?n:{default:n}}var u=s(i);exports.default=function(s){var c,v,f,g,p,h,x,I,m,_,y,b,S,A,R,E=s.section,w=s.idx,O=s.columnKey,M=s.colRef,N=s.mb,T=void 0===N?1:N,D=s.isExpanded,j=s.onToggle,B=s.navigation,C=s.parentNodeId,F=void 0===C?"":C,k=r.useCompareContext(),P=k.showOpenNodeRef,V=k.resolvedMarkdownStyles,G=k.maintainRelativeOrder,W=k.showDeviationBadges,q=void 0!==W&&W,L=k.renderSubSectionAccordion,z=k.treeData,K=k.proposedSections,X=k.existingSections,H=k.deviationNumberRegistry,U=k.deviationParentRegistry,Y=k.getBadgeRef,J=k.openSummaryPopup,Q=k.getSectionCompareStyle,Z=k.connectedSections,$=k.openMoreFunctionsPopup,nn=k.isProposingFix,en=k.proposingFixNodeId,tn=k.isRedlineFlow,on=k.isSideBySide,ln=k.activeSideBySideSection,rn=k.scrollSyncLocked,dn=k.unifiedNumbering,an=k.toggleScrollSyncLocked,sn=k.summaryPopupAnchorEl,un="".concat(on?"1":"0","-").concat(String(null!=ln?ln:"")),cn=(null===(c=E.displayTitle)||void 0===c||c)&&d.hasValue(E.title),vn=!(!nn||!en||"left"!==O||E.id!==en&&E.nodeId!==en),fn=d.hasMeaningfulRedlineTags(E.content),gn="boolean"==typeof tn?tn:fn,pn=fn,hn=gn&&fn,xn=hn?d.stripRedlineTags(E.content):E.content,In=hn?E.content:void 0,mn=(null===(v=E.displayContent)||void 0===v||v||fn)&&d.hasValue(E.content),_n=!cn&&!mn,yn=E.title;cn||(yn=mn?"No Title Found":"No Matching Section Found");var bn="left"===O&&(null!==(g=null===(f=null==E?void 0:E.refContentIds)||void 0===f?void 0:f.length)&&void 0!==g?g:1)>1,Sn="left"===O&&yn.length>29?"".concat(yn.slice(0,29).trimEnd(),"..."):yn,An=E.evaluationResult;if(!An&&"right"===O)if(G){var Rn=null===(p=E.refIndexes)||void 0===p?void 0:p[0],En=K.find(function(n){return n.selfIndex===Rn});An=null==En?void 0:En.evaluationResult}else An=null===(h=K[w])||void 0===h?void 0:h.evaluationResult;var wn=null===(x=null==z?void 0:z.input_index_map)||void 0===x?void 0:x[0],On=null===(I=null==z?void 0:z.input_index_map)||void 0===I?void 0:I[1],Mn="left"===O?On:wn,Nn=function(n,e){var i;if(!e||!n)return null;for(var t=0,o=n;t<o.length;t++){var l=o[t];if(l.id===e||l.nodeId===e||l.contentId===e)return l;if(null===(i=l.subsections)||void 0===i?void 0:i.length){var r=Nn(l.subsections,e);if(r)return r}}return null},Tn="left"===O?E:Nn(K,E.id),Dn="right"===O?E:Nn(X,E.id),jn=u.default.useMemo(function(){if(!G)return 0;var n=1/0,e=function(n){var e=d.hasMeaningfulRedlineTags(n)?d.stripRedlineTags(n):n;return d.safeStringify(e||"").replace(/\\n/g,"\n")},i=function(t,o,l,r){if(t){var a=t.nodeId||t.id;if(r&&"right"===O){var s=K.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(t.selfIndex)});s.length>0&&(a=s[0].nodeId||s[0].id)}var u=t.nodeId||t.id||(null==o?void 0:o.nodeId)||(null==o?void 0:o.id)||(null==l?void 0:l.nodeId)||(null==l?void 0:l.id),c=t.evaluationResult||(null==o?void 0:o.evaluationResult)||(null==l?void 0:l.evaluationResult),v=(null==c?void 0:c.deviations)||{};Object.keys(v).forEach(function(i){var r,s=null===(r=v[i])||void 0===r?void 0:r[F];if(function(n,i){if("string"!=typeof i||d.isMissingStr(i))return!1;var t=e(null==n?void 0:n.content),o=e(i);return!!o&&t.includes(o)}("left"===O?o||t:l||t,s)){var c="".concat(a).concat(d.DEVIATION_BADGE_SEPARATOR).concat(i),f=null==H?void 0:H[c];null!=f&&f<n&&(n=f);var g="".concat(u).concat(d.DEVIATION_BADGE_SEPARATOR).concat(i),p=null==H?void 0:H[g];null!=p&&p<n&&(n=p)}});for(var f=t.subsections||[],g=(null==o?void 0:o.subsections)||[],p=(null==l?void 0:l.subsections)||[],h=Math.max(f.length,g.length,p.length),x=0;x<h;x++)i(f[x],g[x],p[x],!1)}},t="right"===O?K.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(E.selfIndex)}):[];if(1===t.length){var o=t[0];(o.refIndexes||[]).map(function(n){return X.find(function(e){return e.selfIndex===n})}).filter(Boolean).forEach(function(n){i(n,o,n,!0)})}else i(E,Tn,Dn,!0);return n!==1/0?n-1:0},[E,Tn,Dn,O,F,H,G,K,X]);if(G)if("left"===O){var Bn=null===(m=E.refIndexes)||void 0===m?void 0:m[0],Cn=X.findIndex(function(n){return n.selfIndex===Bn});Dn=-1!==Cn?X[Cn]:Nn(X,E.id)}else{var Fn=null===(_=E.refIndexes)||void 0===_?void 0:_[0],kn=K.findIndex(function(n){return n.selfIndex===Fn});Tn=-1!==kn?K[kn]:Nn(K,E.id)}var Pn="left"===O?!Dn:!Tn,Vn=G&&"right"===O&&d.hasSingleMappedLhsSection(E,K),Gn=An||(null==Tn?void 0:Tn.evaluationResult)||(null==Dn?void 0:Dn.evaluationResult),Wn=null!==(S=null===(b=null===(y=null==Gn?void 0:Gn.evaluation_outputs)||void 0===y?void 0:y.metadata)||void 0===b?void 0:b.label_color)&&void 0!==S?S:a.DEFAULT_DEVIAION_COLOR,qn=d.generateColorPalette(Wn).highlightBg,Ln=(null==Gn?void 0:Gn.deviations)||{},zn=u.default.useMemo(function(){return G&&"right"===O?d.getLhsDeviationDisplayIndexes(K,wn,H):new Map},[G,O,K,wn,H]),Kn=E.nodeId||E.id;if(G&&"left"!==O){var Xn=K.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(E.selfIndex)});Xn.length>0?Kn=Xn[0].nodeId||Xn[0].id:(null==Tn?void 0:Tn.id)&&(Kn=Tn.nodeId||Tn.id)}var Hn=u.default.useMemo(function(){var n,e=new Map;if(!G||"right"!==O)return e;var i=1,t=K.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(E.selfIndex)}),o=1===t.length&&1===(null===(n=t[0].refIndexes)||void 0===n?void 0:n.length),l=function(n){return d.safeStringify(n||"").replace(/\\n/g,"\n")},r=function(n,e){var i=e?t[0]:Nn(K,n.nodeId||n.id||n.contentId);return{lhsNode:i,evalResult:n.evaluationResult||(null==i?void 0:i.evaluationResult),registryNodeId:i?i.nodeId||i.id:n.nodeId||n.id}};if(o){var a=function(n,e){if(void 0===e&&(e=!1),n){var t=r(n,e),o=t.lhsNode,s=t.evalResult,u=t.registryNodeId,c=l(n.content);Object.entries((null==s?void 0:s.deviations)||{}).forEach(function(n){var e=n[0],t=n[1],r=t[F],a=l(r);if(!!o&&!d.isMissingStr(t[Mn])&&a&&c.includes(a)){var s="".concat(u).concat(d.DEVIATION_BADGE_SEPARATOR).concat(e),v=H[s];null!=v&&(i=Math.max(i,Math.max(1,v-(jn||0))+1))}}),(n.subsections||[]).forEach(function(n){return a(n)})}};a(E,!0)}var s=function(n,t){if(void 0===t&&(t=!1),n){var o=r(n,t),a=o.lhsNode,u=o.evalResult,c=o.registryNodeId,v=(null==u?void 0:u.deviations)||{},f=l(n.content);Object.entries(v).map(function(n){var e,i=n[0],t=n[1],o=t[F],r=!a||d.isMissingStr(t[Mn]),s=l(o),u=s?f.indexOf(s):-1,v="".concat(c).concat(d.DEVIATION_BADGE_SEPARATOR).concat(i);return{refId:v,isRenderable:r&&!!s&&!d.isMissingStr(o),position:u,registryIndex:null!==(e=H[v])&&void 0!==e?e:Number.MAX_SAFE_INTEGER}}).filter(function(n){return n.isRenderable}).sort(function(n,e){return(-1===n.position?Number.MAX_SAFE_INTEGER:n.position)-(-1===e.position?Number.MAX_SAFE_INTEGER:e.position)||n.registryIndex-e.registryIndex}).forEach(function(n){e.set(n.refId,i++)}),(n.subsections||[]).forEach(function(n){return s(n)})}};return s(E,!0),e},[G,O,E,K,F,Mn,H,jn]),Un=Object.keys(Ln)[0],Yn=Un?"".concat(Kn).concat(d.DEVIATION_BADGE_SEPARATOR).concat(Un):null,Jn=Yn?null==U?void 0:U[Yn]:null,Qn=w+1;if(G&&dn){var Zn="left"===O?dn.leftNums.get(null==E?void 0:E.id):dn.rightNums.get(null==E?void 0:E.id);Pn&&void 0!==Zn?Qn=Zn:null!=Jn&&Jn>=0?Qn=Jn:void 0!==Zn&&(Qn=Zn)}else null!=Jn&&Jn>=0&&(Qn=Jn);var $n=Object.entries(Ln).map(function(n){var e=n[0],i=n[1],t="".concat(Kn).concat(d.DEVIATION_BADGE_SEPARATOR).concat(e);return{deviationKey:e,deviationMap:i,refId:t,currentIndex:H[t]}}).filter(function(n){return void 0!==n.currentIndex&&null!==n.currentIndex});$n.sort(function(n,e){return n.currentIndex-e.currentIndex});var ne,ee,ie=$n.map(function(e){var i,t,o,l,r,a,s=e.deviationKey,u=e.deviationMap,c=e.refId,v=e.currentIndex,f=u[F],g=d.isMissingStr(f);if(g)f="";else if(!f)return null;var p=w,h=w;if(G)if("left"===O){var x=null===(i=E.refIndexes)||void 0===i?void 0:i[0],I=X.findIndex(function(n){return n.selfIndex===x});if(-1!==I)h=I;else{var m=X.findIndex(function(n){return n.id===E.id||n.nodeId===E.nodeId||n.contentId===E.contentId});h=-1!==m?m:w}}else{var _=null===(t=E.refIndexes)||void 0===t?void 0:t[0],y=K.findIndex(function(n){return n.selfIndex===_});if(-1!==y)p=y;else p=-1!==(j=K.findIndex(function(n){return n.id===E.id||n.nodeId===E.nodeId||n.contentId===E.contentId}))?j:w}var b="".concat(Kn).concat(d.DEVIATION_BADGE_SEPARATOR).concat(s).concat(d.DEVIATION_BADGE_SEPARATOR).concat(p).concat(d.DEVIATION_BADGE_SEPARATOR).concat(h),S=u[Mn],A=Pn||d.isMissingStr(S),R=Hn.get(c),M=zn.get(c);G&&"right"===O&&A&&void 0!==R?v=R:G&&"right"===O&&!A&&void 0!==M?v=M:G&&void 0!==jn&&("right"!==O||A||Vn)&&(v-=jn),v=Math.max(1,v);var N=G&&"right"===O&&A&&dn?d.getRhsMappedSectionNumber({section:E,proposedSections:K,leftNums:dn.leftNums,fallbackNumber:String(Qn),firstOnly:!0}):Qn,T="".concat(N,".").concat(v),D=w;if("right"===O&&G){var j,B=null===(o=E.refIndexes)||void 0===o?void 0:o[0],C=K.findIndex(function(n){return n.selfIndex===B});if(-1!==C)D=C;else-1!==(j=K.findIndex(function(n){return n.id===E.id||n.nodeId===E.nodeId||n.contentId===E.contentId}))&&(D=j)}var k=Q?Q(D):null,P=(null==u?void 0:u.evaluation_outputs)||(null==Gn?void 0:Gn.evaluation_outputs),V=null!==(l=null==P?void 0:P.output_value)&&void 0!==l?l:null,W=null!==(a=null===(r=null==P?void 0:P.metadata)||void 0===r?void 0:r.label_color)&&void 0!==a?a:Wn,q=d.generateColorPalette(W),L=k?n.__assign(n.__assign({},k),{badgeBg:q.badgeBg,badgeBorder:q.badgeBorder,badgeText:q.badgeText}):n.__assign({},q),z=(null==u?void 0:u.deviation_summary)?{deviation_summary:u.deviation_summary,deviation_title:(null==u?void 0:u.deviation_title)||(null==Gn?void 0:Gn.deviation_title),deviation_impact:(null==u?void 0:u.deviation_impact)||(null==Gn?void 0:Gn.deviation_impact),deviation_explanation:(null==u?void 0:u.deviation_explanation)||(null==Gn?void 0:Gn.deviation_explanation),evaluation_outputs:P,cognitive_decisioning:(null==u?void 0:u.cognitive_decisioning)||(null==Gn?void 0:Gn.cognitive_decisioning)}:null,H=0,U=xn||"";if(f&&U){var nn=U.split(/\n{2,}/),en=nn.findIndex(function(n){return n.includes(f)});if(-1!==en){var tn=Object.entries(Ln).filter(function(n){n[0];var e=n[1][F];return e&&nn[en].includes(e)}).sort(function(n,e){return nn[en].indexOf(n[1][F])-nn[en].indexOf(e[1][F])}),un=tn.filter(function(n){n[0];var e=n[1][F];return e&&(e.includes(f)||f.includes(e))});un.length>1&&(H=Math.max(0,un.findIndex(function(n){return n[0]===s})))}}var cn=Y(O,c);return{id:c,actionId:b,label:T,highlight:f,side:O,style:L,stackIndex:H,score:V,isConnected:null==Z?void 0:Z.has(b),showScrollLockToggle:(null==Z?void 0:Z.has(b))||on&&ln===b||!!sn&&sn===cn.current,scrollSyncLocked:rn,toggleScrollSyncLocked:an,isOrphan:A,isMissingClause:g,badgeRef:cn,onClick:function(n){n.stopPropagation(),$&&$(n,Tn||{id:"orphan-left",title:"",content:""},A,Dn||{id:"orphan-right",title:"",content:""},b,L)},onSummaryClick:function(n){n.stopPropagation(),J(n,b,A,z)}}}).filter(Boolean),te=q||!gn&&vn?ie:[],oe=ie.map(function(n){return n.highlight}).filter(Boolean),le=E.id&&O===(null==B?void 0:B.columnKey)?B:null,re=u.default.useRef(!1);return i.useEffect(function(){D||(re.current=!1)},[D]),e.jsxs(t.Box,n.__assign({ref:M,sx:{mb:T,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:[D&&(null==le?void 0:le.showAbove)&&e.jsx("div",n.__assign({style:{position:"sticky",top:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==le?void 0:le.showAboveRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:e.jsx("div",n.__assign({style:n.__assign({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===O?"+":"-"," 130px))"),position:"absolute",paddingTop:"20px"},"left"===O?{right:"-20px"}:{left:"-20px"})},{children:e.jsx(o.ChevronUp,{color:(null===(A=null==le?void 0:le.showAboveRef)||void 0===A?void 0:A.current)?window.getComputedStyle(le.showAboveRef.current).color:void 0})}))})),e.jsxs(t.Accordion,n.__assign({disableGutters:!0,expanded:!_n&&D,onChange:function(){_n||(j(),P.current=E.id)},sx:{boxShadow:"none",border:_n?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:_n?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flexGrow:1,width:"100%",display:"flex",flexDirection:"column",minWidth:0,"&:before":{display:"none"},"& .MuiAccordion-heading":{position:"sticky",top:-12,zIndex:10,background:"#fff"}}},{children:[e.jsx(t.AccordionSummary,n.__assign({expandIcon:_n?null:e.jsx(o.ChevronDown,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:_n?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:cn&&e.jsx(t.Tooltip,n.__assign({title:yn,placement:"top"},{children:e.jsx(t.Typography,n.__assign({component:"div",sx:{fontSize:"12px",color:_n?"#94A3B8":"#19213D",fontWeight:_n?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(ne=Sn,ee=bn,void 0===ee&&(ee=!1),ne?d.safeStringify(ne).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(i,t){return i.startsWith("**")&&i.endsWith("**")?e.jsx("strong",{children:i.slice(2,-2)},t):e.jsxs("div",n.__assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px",width:"100%"}},{children:[e.jsx("span",n.__assign({style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:i})),ee&&e.jsx("span",n.__assign({style:{display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"0px 6px",borderRadius:"9999px",background:"#F3F4F6",border:"1px solid #D1D5DB",color:"#6B7280",fontSize:"9px",fontWeight:500,whiteSpace:"nowrap",flexShrink:0,lineHeight:1.4,marginRight:"4px"}},{children:"Multiple"}))]}),t)}):null)}))}))})),!_n&&e.jsxs(t.AccordionDetails,n.__assign({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[mn&&e.jsx(l.MemoizedMarkdown,{content:xn,overlayContent:In,sxStyles:V,highlights:oe,maintainRelativeOrder:G,highlightBg:qn,suppressHighlightBg:pn,deviationBadges:te,collisionKey:un}),(E.subsections||[]).map(function(n,e){return L({section:n,keyPath:"".concat(w,"-").concat(e),depth:0,columnKey:O,parentNodeId:F,sectionOffset:jn,rhsOrphanVisualIndexes:Hn})})]}))]})),D&&(null==le?void 0:le.showBelow)&&e.jsx("div",n.__assign({style:{position:"sticky",bottom:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==le?void 0:le.showBelowRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:e.jsx("div",n.__assign({style:n.__assign({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===O?"+":"-"," 130px))"),position:"absolute",paddingBottom:"20px"},"left"===O?{right:"-20px"}:{left:"-20px"})},{children:e.jsx(o.ChevronDown,{color:(null===(R=null==le?void 0:le.showBelowRef)||void 0===R?void 0:R.current)?window.getComputedStyle(le.showBelowRef.current).color:void 0})}))}))]}),"".concat(O,"-sec-").concat(w))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("tslib"),e=require("react/jsx-runtime"),i=require("react"),t=require("@mui/material"),o=require("lucide-react"),l=require("../hooks/memoizedMarkdown.js"),r=require("../CompareContext.js"),d=require("../CognitiveComparehelpers.js"),a=require("../CognitiveCompareConstants.js");function s(n){return n&&"object"==typeof n&&"default"in n?n:{default:n}}var u=s(i);exports.default=function(s){var c,v,f,g,p,h,x,I,m,_,y,b,S,A,R,E=s.section,w=s.idx,M=s.columnKey,O=s.colRef,N=s.mb,T=void 0===N?1:N,D=s.isExpanded,j=s.onToggle,B=s.navigation,C=s.parentNodeId,F=void 0===C?"":C,k=r.useCompareContext(),P=k.showOpenNodeRef,V=k.resolvedMarkdownStyles,G=k.maintainRelativeOrder,W=k.showDeviationBadges,q=void 0!==W&&W,L=k.renderSubSectionAccordion,z=k.treeData,K=k.proposedSections,X=k.existingSections,H=k.deviationNumberRegistry,U=k.deviationParentRegistry,Y=k.getBadgeRef,J=k.openSummaryPopup,Q=k.getSectionCompareStyle,Z=k.connectedSections,$=k.openMoreFunctionsPopup,nn=k.isProposingFix,en=k.proposingFixNodeId,tn=k.isRedlineFlow,on=k.isSideBySide,ln=k.activeSideBySideSection,rn=k.scrollSyncLocked,dn=k.unifiedNumbering,an=k.toggleScrollSyncLocked,sn=k.summaryPopupAnchorEl,un="".concat(on?"1":"0","-").concat(String(null!=ln?ln:"")),cn=(null===(c=E.displayTitle)||void 0===c||c)&&d.hasValue(E.title),vn=!(!nn||!en||"left"!==M||E.id!==en&&E.nodeId!==en),fn=d.hasMeaningfulRedlineTags(E.content),gn="boolean"==typeof tn?tn:fn,pn=fn,hn=gn&&fn,xn=hn?d.stripRedlineTags(E.content):E.content,In=hn?E.content:void 0,mn=(null===(v=E.displayContent)||void 0===v||v||fn)&&d.hasValue(E.content),_n=!cn&&!mn,yn=E.title;cn||(yn=mn?"No Title Found":"No Matching Section Found");var bn="left"===M&&(E.isMultipleMapping||(null!==(g=null===(f=E.refContentIds)||void 0===f?void 0:f.length)&&void 0!==g?g:1)>1),Sn="left"===M&&yn.length>29?"".concat(yn.slice(0,29).trimEnd(),"..."):yn,An=E.evaluationResult;if(!An&&"right"===M)if(G){var Rn=null===(p=E.refIndexes)||void 0===p?void 0:p[0],En=K.find(function(n){return n.selfIndex===Rn});An=null==En?void 0:En.evaluationResult}else An=null===(h=K[w])||void 0===h?void 0:h.evaluationResult;var wn=null===(x=null==z?void 0:z.input_index_map)||void 0===x?void 0:x[0],Mn=null===(I=null==z?void 0:z.input_index_map)||void 0===I?void 0:I[1],On="left"===M?Mn:wn,Nn=function(n,e){var i;if(!e||!n)return null;for(var t=0,o=n;t<o.length;t++){var l=o[t];if(l.id===e||l.nodeId===e||l.contentId===e)return l;if(null===(i=l.subsections)||void 0===i?void 0:i.length){var r=Nn(l.subsections,e);if(r)return r}}return null},Tn="left"===M?E:Nn(K,E.id),Dn="right"===M?E:Nn(X,E.id),jn=u.default.useMemo(function(){if(!G)return 0;var n=1/0,e=function(n){var e=d.hasMeaningfulRedlineTags(n)?d.stripRedlineTags(n):n;return d.safeStringify(e||"").replace(/\\n/g,"\n")},i=function(t,o,l,r){if(t){var a=t.nodeId||t.id;if(r&&"right"===M){var s=K.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(t.selfIndex)});s.length>0&&(a=s[0].nodeId||s[0].id)}var u=t.nodeId||t.id||(null==o?void 0:o.nodeId)||(null==o?void 0:o.id)||(null==l?void 0:l.nodeId)||(null==l?void 0:l.id),c=t.evaluationResult||(null==o?void 0:o.evaluationResult)||(null==l?void 0:l.evaluationResult),v=(null==c?void 0:c.deviations)||{};Object.keys(v).forEach(function(i){var r,s=null===(r=v[i])||void 0===r?void 0:r[F];if(function(n,i){if("string"!=typeof i||d.isMissingStr(i))return!1;var t=e(null==n?void 0:n.content),o=e(i);return!!o&&t.includes(o)}("left"===M?o||t:l||t,s)){var c="".concat(a).concat(d.DEVIATION_BADGE_SEPARATOR).concat(i),f=null==H?void 0:H[c];null!=f&&f<n&&(n=f);var g="".concat(u).concat(d.DEVIATION_BADGE_SEPARATOR).concat(i),p=null==H?void 0:H[g];null!=p&&p<n&&(n=p)}});for(var f=t.subsections||[],g=(null==o?void 0:o.subsections)||[],p=(null==l?void 0:l.subsections)||[],h=Math.max(f.length,g.length,p.length),x=0;x<h;x++)i(f[x],g[x],p[x],!1)}},t="right"===M?K.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(E.selfIndex)}):[];if(1===t.length){var o=t[0];(o.refIndexes||[]).map(function(n){return X.find(function(e){return e.selfIndex===n})}).filter(Boolean).forEach(function(n){i(n,o,n,!0)})}else i(E,Tn,Dn,!0);return n!==1/0?n-1:0},[E,Tn,Dn,M,F,H,G,K,X]);if(G)if("left"===M){var Bn=null===(m=E.refIndexes)||void 0===m?void 0:m[0],Cn=X.findIndex(function(n){return n.selfIndex===Bn});Dn=-1!==Cn?X[Cn]:Nn(X,E.id)}else{var Fn=null===(_=E.refIndexes)||void 0===_?void 0:_[0],kn=K.findIndex(function(n){return n.selfIndex===Fn});Tn=-1!==kn?K[kn]:Nn(K,E.id)}var Pn="left"===M?!Dn:!Tn,Vn=G&&"right"===M&&d.hasSingleMappedLhsSection(E,K),Gn=An||(null==Tn?void 0:Tn.evaluationResult)||(null==Dn?void 0:Dn.evaluationResult),Wn=null!==(S=null===(b=null===(y=null==Gn?void 0:Gn.evaluation_outputs)||void 0===y?void 0:y.metadata)||void 0===b?void 0:b.label_color)&&void 0!==S?S:a.DEFAULT_DEVIAION_COLOR,qn=d.generateColorPalette(Wn).highlightBg,Ln=(null==Gn?void 0:Gn.deviations)||{},zn=u.default.useMemo(function(){return G&&"right"===M?d.getLhsDeviationDisplayIndexes(K,wn,H):new Map},[G,M,K,wn,H]),Kn=E.nodeId||E.id;if(G&&"left"!==M){var Xn=K.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(E.selfIndex)});Xn.length>0?Kn=Xn[0].nodeId||Xn[0].id:(null==Tn?void 0:Tn.id)&&(Kn=Tn.nodeId||Tn.id)}var Hn=u.default.useMemo(function(){var n,e=new Map;if(!G||"right"!==M)return e;var i=1,t=K.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(E.selfIndex)}),o=1===t.length&&1===(null===(n=t[0].refIndexes)||void 0===n?void 0:n.length),l=function(n){return d.safeStringify(n||"").replace(/\\n/g,"\n")},r=function(n,e){var i=e?t[0]:Nn(K,n.nodeId||n.id||n.contentId);return{lhsNode:i,evalResult:n.evaluationResult||(null==i?void 0:i.evaluationResult),registryNodeId:i?i.nodeId||i.id:n.nodeId||n.id}};if(o){var a=function(n,e){if(void 0===e&&(e=!1),n){var t=r(n,e),o=t.lhsNode,s=t.evalResult,u=t.registryNodeId,c=l(n.content);Object.entries((null==s?void 0:s.deviations)||{}).forEach(function(n){var e=n[0],t=n[1],r=t[F],a=l(r);if(!!o&&!d.isMissingStr(t[On])&&a&&c.includes(a)){var s="".concat(u).concat(d.DEVIATION_BADGE_SEPARATOR).concat(e),v=H[s];null!=v&&(i=Math.max(i,Math.max(1,v-(jn||0))+1))}}),(n.subsections||[]).forEach(function(n){return a(n)})}};a(E,!0)}var s=function(n,t){if(void 0===t&&(t=!1),n){var o=r(n,t),a=o.lhsNode,u=o.evalResult,c=o.registryNodeId,v=(null==u?void 0:u.deviations)||{},f=l(n.content);Object.entries(v).map(function(n){var e,i=n[0],t=n[1],o=t[F],r=!a||d.isMissingStr(t[On]),s=l(o),u=s?f.indexOf(s):-1,v="".concat(c).concat(d.DEVIATION_BADGE_SEPARATOR).concat(i);return{refId:v,isRenderable:r&&!!s&&!d.isMissingStr(o),position:u,registryIndex:null!==(e=H[v])&&void 0!==e?e:Number.MAX_SAFE_INTEGER}}).filter(function(n){return n.isRenderable}).sort(function(n,e){return(-1===n.position?Number.MAX_SAFE_INTEGER:n.position)-(-1===e.position?Number.MAX_SAFE_INTEGER:e.position)||n.registryIndex-e.registryIndex}).forEach(function(n){e.set(n.refId,i++)}),(n.subsections||[]).forEach(function(n){return s(n)})}};return s(E,!0),e},[G,M,E,K,F,On,H,jn]),Un=Object.keys(Ln)[0],Yn=Un?"".concat(Kn).concat(d.DEVIATION_BADGE_SEPARATOR).concat(Un):null,Jn=Yn?null==U?void 0:U[Yn]:null,Qn=w+1;if(G&&dn){var Zn="left"===M?dn.leftNums.get(null==E?void 0:E.id):dn.rightNums.get(null==E?void 0:E.id);Pn&&void 0!==Zn?Qn=Zn:null!=Jn&&Jn>=0?Qn=Jn:void 0!==Zn&&(Qn=Zn)}else null!=Jn&&Jn>=0&&(Qn=Jn);var $n=Object.entries(Ln).map(function(n){var e=n[0],i=n[1],t="".concat(Kn).concat(d.DEVIATION_BADGE_SEPARATOR).concat(e);return{deviationKey:e,deviationMap:i,refId:t,currentIndex:H[t]}}).filter(function(n){return void 0!==n.currentIndex&&null!==n.currentIndex});$n.sort(function(n,e){return n.currentIndex-e.currentIndex});var ne,ee,ie=$n.map(function(e){var i,t,o,l,r,a,s=e.deviationKey,u=e.deviationMap,c=e.refId,v=e.currentIndex,f=u[F],g=d.isMissingStr(f);if(g)f="";else if(!f)return null;var p=w,h=w;if(G)if("left"===M){var x=null===(i=E.refIndexes)||void 0===i?void 0:i[0],I=X.findIndex(function(n){return n.selfIndex===x});if(-1!==I)h=I;else{var m=X.findIndex(function(n){return n.id===E.id||n.nodeId===E.nodeId||n.contentId===E.contentId});h=-1!==m?m:w}}else{var _=null===(t=E.refIndexes)||void 0===t?void 0:t[0],y=K.findIndex(function(n){return n.selfIndex===_});if(-1!==y)p=y;else p=-1!==(j=K.findIndex(function(n){return n.id===E.id||n.nodeId===E.nodeId||n.contentId===E.contentId}))?j:w}var b="".concat(Kn).concat(d.DEVIATION_BADGE_SEPARATOR).concat(s).concat(d.DEVIATION_BADGE_SEPARATOR).concat(p).concat(d.DEVIATION_BADGE_SEPARATOR).concat(h),S=u[On],A=Pn||d.isMissingStr(S),R=Hn.get(c),O=zn.get(c);G&&"right"===M&&A&&void 0!==R?v=R:G&&"right"===M&&!A&&void 0!==O?v=O:G&&void 0!==jn&&("right"!==M||A||Vn)&&(v-=jn),v=Math.max(1,v);var N=G&&"right"===M&&A&&dn?d.getRhsMappedSectionNumber({section:E,proposedSections:K,leftNums:dn.leftNums,fallbackNumber:String(Qn),firstOnly:!0}):Qn,T="".concat(N,".").concat(v),D=w;if("right"===M&&G){var j,B=null===(o=E.refIndexes)||void 0===o?void 0:o[0],C=K.findIndex(function(n){return n.selfIndex===B});if(-1!==C)D=C;else-1!==(j=K.findIndex(function(n){return n.id===E.id||n.nodeId===E.nodeId||n.contentId===E.contentId}))&&(D=j)}var k=Q?Q(D):null,P=(null==u?void 0:u.evaluation_outputs)||(null==Gn?void 0:Gn.evaluation_outputs),V=null!==(l=null==P?void 0:P.output_value)&&void 0!==l?l:null,W=null!==(a=null===(r=null==P?void 0:P.metadata)||void 0===r?void 0:r.label_color)&&void 0!==a?a:Wn,q=d.generateColorPalette(W),L=k?n.__assign(n.__assign({},k),{badgeBg:q.badgeBg,badgeBorder:q.badgeBorder,badgeText:q.badgeText}):n.__assign({},q),z=(null==u?void 0:u.deviation_summary)?{deviation_summary:u.deviation_summary,deviation_title:(null==u?void 0:u.deviation_title)||(null==Gn?void 0:Gn.deviation_title),deviation_impact:(null==u?void 0:u.deviation_impact)||(null==Gn?void 0:Gn.deviation_impact),deviation_explanation:(null==u?void 0:u.deviation_explanation)||(null==Gn?void 0:Gn.deviation_explanation),evaluation_outputs:P,cognitive_decisioning:(null==u?void 0:u.cognitive_decisioning)||(null==Gn?void 0:Gn.cognitive_decisioning)}:null,H=0,U=xn||"";if(f&&U){var nn=U.split(/\n{2,}/),en=nn.findIndex(function(n){return n.includes(f)});if(-1!==en){var tn=Object.entries(Ln).filter(function(n){n[0];var e=n[1][F];return e&&nn[en].includes(e)}).sort(function(n,e){return nn[en].indexOf(n[1][F])-nn[en].indexOf(e[1][F])}),un=tn.filter(function(n){n[0];var e=n[1][F];return e&&(e.includes(f)||f.includes(e))});un.length>1&&(H=Math.max(0,un.findIndex(function(n){return n[0]===s})))}}var cn=Y(M,c);return{id:c,actionId:b,label:T,highlight:f,side:M,style:L,stackIndex:H,score:V,isConnected:null==Z?void 0:Z.has(b),showScrollLockToggle:(null==Z?void 0:Z.has(b))||on&&ln===b||!!sn&&sn===cn.current,scrollSyncLocked:rn,toggleScrollSyncLocked:an,isOrphan:A,isMissingClause:g,badgeRef:cn,onClick:function(n){n.stopPropagation(),$&&$(n,Tn||{id:"orphan-left",title:"",content:""},A,Dn||{id:"orphan-right",title:"",content:""},b,L)},onSummaryClick:function(n){n.stopPropagation(),J(n,b,A,z)}}}).filter(Boolean),te=q||!gn&&vn?ie:[],oe=ie.map(function(n){return n.highlight}).filter(Boolean),le=E.id&&M===(null==B?void 0:B.columnKey)?B:null,re=u.default.useRef(!1);return i.useEffect(function(){D||(re.current=!1)},[D]),e.jsxs(t.Box,n.__assign({ref:O,sx:{mb:T,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:[D&&(null==le?void 0:le.showAbove)&&e.jsx("div",n.__assign({style:{position:"sticky",top:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==le?void 0:le.showAboveRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:e.jsx("div",n.__assign({style:n.__assign({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===M?"+":"-"," 130px))"),position:"absolute",paddingTop:"20px"},"left"===M?{right:"-20px"}:{left:"-20px"})},{children:e.jsx(o.ChevronUp,{color:(null===(A=null==le?void 0:le.showAboveRef)||void 0===A?void 0:A.current)?window.getComputedStyle(le.showAboveRef.current).color:void 0})}))})),e.jsxs(t.Accordion,n.__assign({disableGutters:!0,expanded:!_n&&D,onChange:function(){_n||(j(),P.current=E.id)},sx:{boxShadow:"none",border:_n?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:_n?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flexGrow:1,width:"100%",display:"flex",flexDirection:"column",minWidth:0,"&:before":{display:"none"},"& .MuiAccordion-heading":{position:"sticky",top:-12,zIndex:10,background:"#fff"}}},{children:[e.jsx(t.AccordionSummary,n.__assign({expandIcon:_n?null:e.jsx(o.ChevronDown,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:_n?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:cn&&e.jsx(t.Tooltip,n.__assign({title:yn,placement:"top"},{children:e.jsx(t.Typography,n.__assign({component:"div",sx:{fontSize:"12px",color:_n?"#94A3B8":"#19213D",fontWeight:_n?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(ne=Sn,ee=bn,void 0===ee&&(ee=!1),ne?d.safeStringify(ne).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(i,t){return i.startsWith("**")&&i.endsWith("**")?e.jsx("strong",{children:i.slice(2,-2)},t):e.jsxs("div",n.__assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px",width:"100%"}},{children:[e.jsx("span",n.__assign({style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:i})),ee&&e.jsx("span",n.__assign({style:{display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"0px 6px",borderRadius:"9999px",background:"#F3F4F6",border:"1px solid #D1D5DB",color:"#6B7280",fontSize:"9px",fontWeight:500,whiteSpace:"nowrap",flexShrink:0,lineHeight:1.4,marginRight:"4px"}},{children:"Multiple"}))]}),t)}):null)}))}))})),!_n&&e.jsxs(t.AccordionDetails,n.__assign({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[mn&&e.jsx(l.MemoizedMarkdown,{content:xn,overlayContent:In,sxStyles:V,highlights:oe,maintainRelativeOrder:G,highlightBg:qn,suppressHighlightBg:pn,deviationBadges:te,collisionKey:un}),(E.subsections||[]).map(function(n,e){return L({section:n,keyPath:"".concat(w,"-").concat(e),depth:0,columnKey:M,parentNodeId:F,sectionOffset:jn,rhsOrphanVisualIndexes:Hn})})]}))]})),D&&(null==le?void 0:le.showBelow)&&e.jsx("div",n.__assign({style:{position:"sticky",bottom:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==le?void 0:le.showBelowRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:e.jsx("div",n.__assign({style:n.__assign({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===M?"+":"-"," 130px))"),position:"absolute",paddingBottom:"20px"},"left"===M?{right:"-20px"}:{left:"-20px"})},{children:e.jsx(o.ChevronDown,{color:(null===(R=null==le?void 0:le.showBelowRef)||void 0===R?void 0:R.current)?window.getComputedStyle(le.showBelowRef.current).color:void 0})}))}))]}),"".concat(M,"-sec-").concat(w))};
2
2
  //# sourceMappingURL=SectionAccordion.js.map