@viswa-test/test-citation 0.0.369 → 0.0.371

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 (92) hide show
  1. package/dist/cjs/features/CognitiveCompare/CitationAnchor.js +1 -1
  2. package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js +1 -1
  3. package/dist/cjs/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
  4. package/dist/cjs/features/CognitiveCompare/CognitivePopup.js +1 -1
  5. package/dist/cjs/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js +1 -1
  6. package/dist/cjs/features/CognitiveCompare/Guidelines/components/WebGptPanel.js +1 -1
  7. package/dist/cjs/features/CognitiveCompare/Guidelines/utils/hasGptCitationObjects.js +2 -0
  8. package/dist/cjs/features/CognitiveCompare/Guidelines/utils/hasGptCitationObjects.js.map +1 -0
  9. package/dist/cjs/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js +1 -1
  10. package/dist/cjs/features/CognitiveCompare/components/SectionAccordion.js +1 -1
  11. package/dist/cjs/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
  12. package/dist/cjs/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
  13. package/dist/cjs/features/CognitiveCompare/hooks/useCompareData.js +1 -1
  14. package/dist/cjs/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
  15. package/dist/cjs/features/CognitiveCompare/hooks/useSideBySide.js +1 -1
  16. package/dist/cjs/features/CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.js +1 -1
  17. package/dist/cjs/features/GptWebCitation/GptWebCitation.js +1 -1
  18. package/dist/cjs/features/GptWebCitation/GptWebCitationImageCitation.js +1 -1
  19. package/dist/cjs/features/GptWebCitation/utils/fixedHeight.utils.js +1 -1
  20. package/dist/cjs/features/PdfViewer/PdfContainer.js +1 -1
  21. package/dist/cjs/features/PdfViewer/PdfStyle.js +1 -1
  22. package/dist/cjs/features/PdfViewer/PdfToolbar.js +1 -1
  23. package/dist/cjs/features/PdfViewer/PdfViewer.js +1 -1
  24. package/dist/cjs/features/SegmentReviewComponents/SegmentReviewPdfWrapper.js +1 -1
  25. package/dist/cjs/features/SegmentReviewComponents/helper.js +1 -1
  26. package/dist/cjs/index.js +1 -1
  27. package/dist/features/CognitiveCompare/CitationAnchor.js +1 -1
  28. package/dist/features/CognitiveCompare/CognitiveCompare.js +1 -1
  29. package/dist/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
  30. package/dist/features/CognitiveCompare/CognitivePopup.js +1 -1
  31. package/dist/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js +1 -1
  32. package/dist/features/CognitiveCompare/Guidelines/components/WebGptPanel.js +1 -1
  33. package/dist/features/CognitiveCompare/Guidelines/utils/hasGptCitationObjects.js +2 -0
  34. package/dist/features/CognitiveCompare/Guidelines/utils/hasGptCitationObjects.js.map +1 -0
  35. package/dist/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js +1 -1
  36. package/dist/features/CognitiveCompare/components/SectionAccordion.js +1 -1
  37. package/dist/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
  38. package/dist/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
  39. package/dist/features/CognitiveCompare/hooks/useCompareData.js +1 -1
  40. package/dist/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
  41. package/dist/features/CognitiveCompare/hooks/useSideBySide.js +1 -1
  42. package/dist/features/CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.js +1 -1
  43. package/dist/features/GptWebCitation/GptWebCitation.js +1 -1
  44. package/dist/features/GptWebCitation/GptWebCitationImageCitation.js +1 -1
  45. package/dist/features/GptWebCitation/utils/fixedHeight.utils.js +1 -1
  46. package/dist/features/PdfViewer/PdfContainer.js +1 -1
  47. package/dist/features/PdfViewer/PdfStyle.js +1 -1
  48. package/dist/features/PdfViewer/PdfToolbar.js +1 -1
  49. package/dist/features/PdfViewer/PdfViewer.js +1 -1
  50. package/dist/features/SegmentReviewComponents/SegmentReviewPdfWrapper.js +1 -1
  51. package/dist/features/SegmentReviewComponents/helper.js +1 -1
  52. package/dist/index.js +1 -1
  53. package/dist/types/src/features/CognitiveCompare/CitationAnchor.d.ts.map +1 -1
  54. package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts +1 -1
  55. package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts.map +1 -1
  56. package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts +1 -1
  57. package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts.map +1 -1
  58. package/dist/types/src/features/CognitiveCompare/CognitiveComparehelpers.d.ts +12 -0
  59. package/dist/types/src/features/CognitiveCompare/CognitiveComparehelpers.d.ts.map +1 -1
  60. package/dist/types/src/features/CognitiveCompare/Guidelines/components/GuidelinePanel.d.ts.map +1 -1
  61. package/dist/types/src/features/CognitiveCompare/Guidelines/components/WebGptPanel.d.ts.map +1 -1
  62. package/dist/types/src/features/CognitiveCompare/Guidelines/utils/hasGptCitationObjects.d.ts +3 -0
  63. package/dist/types/src/features/CognitiveCompare/Guidelines/utils/hasGptCitationObjects.d.ts.map +1 -0
  64. package/dist/types/src/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.d.ts +14 -1
  65. package/dist/types/src/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.d.ts.map +1 -1
  66. package/dist/types/src/features/CognitiveCompare/components/SectionAccordion.d.ts.map +1 -1
  67. package/dist/types/src/features/CognitiveCompare/components/SubSectionAccordion.d.ts.map +1 -1
  68. package/dist/types/src/features/CognitiveCompare/hooks/memoizedMarkdown.d.ts.map +1 -1
  69. package/dist/types/src/features/CognitiveCompare/hooks/useCompareData.d.ts +1 -1
  70. package/dist/types/src/features/CognitiveCompare/hooks/useCompareData.d.ts.map +1 -1
  71. package/dist/types/src/features/CognitiveCompare/hooks/useLinesCalculator.d.ts.map +1 -1
  72. package/dist/types/src/features/CognitiveCompare/hooks/useSideBySide.d.ts.map +1 -1
  73. package/dist/types/src/features/CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.d.ts +1 -0
  74. package/dist/types/src/features/CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.d.ts.map +1 -1
  75. package/dist/types/src/features/GptWebCitation/GptWebCitation.d.ts.map +1 -1
  76. package/dist/types/src/features/GptWebCitation/GptWebCitationImageCitation.d.ts +2 -1
  77. package/dist/types/src/features/GptWebCitation/GptWebCitationImageCitation.d.ts.map +1 -1
  78. package/dist/types/src/features/GptWebCitation/types.d.ts +11 -0
  79. package/dist/types/src/features/GptWebCitation/types.d.ts.map +1 -1
  80. package/dist/types/src/features/GptWebCitation/utils/fixedHeight.utils.d.ts +2 -0
  81. package/dist/types/src/features/GptWebCitation/utils/fixedHeight.utils.d.ts.map +1 -1
  82. package/dist/types/src/features/PdfViewer/PdfContainer.d.ts +2 -4
  83. package/dist/types/src/features/PdfViewer/PdfContainer.d.ts.map +1 -1
  84. package/dist/types/src/features/PdfViewer/PdfStyle.d.ts.map +1 -1
  85. package/dist/types/src/features/PdfViewer/PdfToolbar.d.ts.map +1 -1
  86. package/dist/types/src/features/PdfViewer/PdfViewer.d.ts +2 -18
  87. package/dist/types/src/features/PdfViewer/PdfViewer.d.ts.map +1 -1
  88. package/dist/types/src/features/SegmentReviewComponents/SegmentReviewPdfWrapper.d.ts +20 -1
  89. package/dist/types/src/features/SegmentReviewComponents/SegmentReviewPdfWrapper.d.ts.map +1 -1
  90. package/dist/types/src/index.d.ts +0 -4
  91. package/dist/types/src/index.d.ts.map +1 -1
  92. package/package.json +2 -2
@@ -1,2 +1,2 @@
1
- import{__assign as n,__rest as e}from"tslib";import{jsx as t,jsxs as r,Fragment as i}from"react/jsx-runtime";import{Box as o,Typography as a}from"@mui/material";import l,{useRef as d,useMemo as c,useLayoutEffect as s}from"react";import{DEFAULT_DEVIAION_COLOR as u}from"../CognitiveCompareConstants.js";import{EllipsisVertical as h}from"lucide-react";import p from"react-markdown";import{mixHexColors as g,areMarkdownPropsEqual as f}from"../CognitiveComparehelpers.js";import v from"rehype-raw";import m from"remark-gfm";var b=function(n){return"function"==typeof n?n:(null==n?void 0:n.default)||n},x=[b(m)],y=[b(v)],w=l.memo(function(f){var v=f.content,m=f.overlayContent,b=f.sxStyles,w=f.deviationBadges,E=void 0===w?[]:w,S=f.highlights,k=void 0===S?[]:S;f.maintainRelativeOrder;var C=f.highlightBg,B=f.suppressHighlightBg,F=void 0!==B&&B,z=f.collisionKey,A=d(null),T=!!m,W=c(function(){return E.reduce(function(e,t){var r;return n(n({},e),((r={})[t.id]=t,r))},{})},[E]),O=d({badgeMap:W,highlightBg:C,hideHighlightBg:T,suppressHighlightBg:F});O.current={badgeMap:W,highlightBg:C,hideHighlightBg:T,suppressHighlightBg:F};var I=function(e,t){return l.Children.map(e,function(e){var r;if(!l.isValidElement(e))return e;var i=(null===(r=e.props)||void 0===r?void 0:r.children)?I(e.props.children,t):e.props.children,o=l.cloneElement(e,n(n({},e.props),{children:i}));return t(o)})},M=c(function(){return{mark:function(r){var i,o,a,l,d=r.children,c=e(r,["children"]),s=O.current,u=s.badgeMap,h=s.highlightBg,p=s.hideHighlightBg,g=s.suppressHighlightBg,f=c["data-badge-id"],v=f?u[f]:null,m=c["data-highlight-color"],b=null!==(l=null!==(o=null!=m?m:null===(i=null==v?void 0:v.style)||void 0===i?void 0:i.highlightBg)&&void 0!==o?o:null===(a=null==v?void 0:v.style)||void 0===a?void 0:a.badgeBg)&&void 0!==l?l:h,x="true"===c["data-is-suggested-deviation-fix"]||g;return t("span",n({style:n(n(n({},x?{}:{backgroundColor:b}),{borderRadius:"2px",display:"inline",boxDecorationBreak:"clone",WebkitBoxDecorationBreak:"clone",backgroundClip:"padding-box",padding:"0 1px"}),p?{color:"transparent"}:{})},{children:d}))},span:function(i){var a,l,d,c,s,p,g=i.children,f=e(i,["children"]),v=O.current.badgeMap,m=f["data-badge-id"];if(!m)return t("span",n({},f,{children:g}));var b=v[m];if(!b)return t("span",n({},f,{children:g}));var x="number"==typeof b.stackIndex?b.stackIndex:0,y="translateY(calc(-20% + ".concat(12*x,"px + var(--badge-nudge, 0px)))");return r(o,n({component:"span",sx:{position:"static",display:"inline"}},{children:[r(o,n({ref:b.badgeRef,className:"deviation-badge","data-side":b.side||"right",sx:n(n({fontStyle:"normal",position:"absolute",zIndex:30+x,display:"inline-flex",alignItems:"stretch",fontSize:"10px",bgcolor:(null===(a=b.style)||void 0===a?void 0:a.badgeBg)||"#EEF2FF",color:(null===(l=b.style)||void 0===l?void 0:l.badgeText)||u,border:"1px solid ".concat((null===(d=b.style)||void 0===d?void 0:d.badgeBorder)||"#C7D2FE"),borderRadius:"12px",fontWeight:600,whiteSpace:"nowrap",boxShadow:"0 1px 3px rgba(0,0,0,0.07)",overflow:"hidden",transition:"none"},"left"===b.side?{right:"-16px",transform:"".concat(y," translateX(calc(100% + 8px))")}:{left:"-16px",transform:"".concat(y," translateX(calc(-100% - 8px))")}),b.isConnected&&b.style&&{outline:"2px solid ".concat(b.style.badgeBorder),outlineOffset:"1px"})},{children:[r(o,n({onClick:function(n){n.stopPropagation(),b.onSummaryClick&&b.onSummaryClick(n)},sx:{display:"flex",alignItems:"center",px:1,py:.3,cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.04)"}}},{children:[t(o,n({component:"span",sx:{fontSize:"10px",fontWeight:700}},{children:b.label})),("left"===b.side||b.isOrphan)&&t(o,n({component:"span",sx:{fontSize:"10px",pl:.5,ml:.5,borderLeft:"1px solid ".concat((null===(c=b.style)||void 0===c?void 0:c.badgeBorder)||"#C7D2FE")}},{children:null!=b.score&&"N/A"!==b.score&&"NA"!==b.score&&0!==b.score?"".concat(b.score):"N/A"===b.score||"NA"===b.score?"N/A":"Same"}))]})),("left"===b.side||b.isOrphan)&&t(o,n({onClick:function(n){n.stopPropagation(),b.onClick&&b.onClick(n)},sx:{display:"flex",alignItems:"center",px:.5,borderLeft:"1px solid ".concat((null===(s=b.style)||void 0===s?void 0:s.badgeBorder)||"#C7D2FE"),cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.06)"}}},{children:t(h,{size:12,color:(null===(p=b.style)||void 0===p?void 0:p.badgeText)||"#3730A3"})}))]})),g]}))},table:function(e){var r=e.children;return t(o,n({sx:{display:"block",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",contain:"inline-size",overflowX:"auto",overflowY:"hidden",overscrollBehaviorX:"contain",WebkitOverflowScrolling:"touch",my:1}},{children:t(o,n({component:"table",sx:{width:"600px",minWidth:"600px",tableLayout:"fixed",borderCollapse:"collapse",fontSize:"inherit"}},{children:r}))}))},thead:function(e){var r=e.children;return t(o,n({component:"thead"},{children:r}))},tbody:function(e){var r=e.children;return t(o,n({component:"tbody"},{children:r}))},tr:function(e){var r=e.children;return t(o,n({component:"tr",sx:{borderBottom:"1px solid #E5E7EB"}},{children:r}))},th:function(e){var r=e.children;return t(o,n({component:"th",sx:{border:"1px solid #E5E7EB",padding:"8px",textAlign:"left",verticalAlign:"top",fontWeight:600,backgroundColor:"#F9FAFB",whiteSpace:"normal",wordBreak:"break-word",overflowWrap:"anywhere"}},{children:r}))},td:function(e){var r=e.children;return t(o,n({component:"td",sx:{border:"1px solid #E5E7EB",padding:"8px",verticalAlign:"top",whiteSpace:"normal",wordBreak:"break-word",overflowWrap:"anywhere"}},{children:r}))},code:function(e){var r=e.children;return t("span",n({style:{fontFamily:"inherit",fontSize:"inherit"}},{children:r}))},pre:function(e){var r=e.children;return t("span",n({style:{fontFamily:"inherit",fontSize:"inherit",display:"block",whiteSpace:"pre-wrap"}},{children:r}))},updated:function(n){var e=n.children;return t(i,{children:e})},deleted:function(e){var r=e.children,i=I(r,function(n){return l.cloneElement(n,{"data-is-suggested-deviation-fix":"true"})});return t("span",n({style:{boxShadow:"inset 0 1px 0 #EF4444, inset 0 -1px 0 #EF4444",backgroundColor:"#FCCCCC",textDecoration:"line-through"}},{children:i}))},changed:function(e){var r=e.children,i=I(r,function(n){return l.cloneElement(n,{"data-is-suggested-deviation-fix":"true"})});return t("span",n({style:{boxShadow:"inset 0 1px 0 #2F59FF, inset 0 -1px 0 #2F59FF",backgroundColor:"#D5E8FF"}},{children:i}))},ul:function(r){var i=r.children,a=e(r,["children"]);return t(o,n({component:"ul",sx:{mt:1,mb:1,pl:3,listStyleType:"disc"}},a,{children:i}))},ol:function(r){var i=r.children,a=e(r,["children"]);return t(o,n({component:"ol",sx:{mt:1,mb:1,pl:3,listStyleType:"decimal"}},a,{children:i}))},li:function(r){var i=r.children,a=e(r,["children"]);return t(o,n({component:"li",sx:{mb:.5,display:"list-item"}},a,{children:i}))}}},[]),$=function(n){if(!n||"string"!=typeof n)return"";var e=n,t=(e=(e=(e=(e=(e=(e=(e=(e=e.replace(/((?:<\/?[a-z]+[^>]*>\s*)+)([*+\-] |\d+\. )/gi,"$2$1")).replace(/\\(['"])/g,"$1").replace(/\\n/g,"\n").replace(/\\\./g,".").replace(/\r\n/g,"\n")).replace(/^(\d+\.)(\s{2,})/gm,function(n,e,t){return"".concat(e.slice(0,-1),"\\.").concat(t)})).replace(/^(\d+\.)\s*\n+(\s+)(\S)/gm,function(n,e,t,r){return"".concat(e," ").concat(r)})).replace(/([^\n])\n(#{1,6} )/g,"$1\n\n$2")).replace(/([^\n])\n([ \t]*(?:[#*+\-] |\d+\. ))/g,"$1\n\n$2")).replace(/\n{3,}/g,"\n\n")).replace(/^[ \t]+(?![ \t]*([\*\-\+] |\d+\. ))/gm,function(n){return n.replace(/ /g," ").replace(/\t/g,"    ")})).split(/(\n{2,})/);return(e=t.map(function(n){return/^\n+$/.test(n)||/\|.*\|/.test(n)&&/\|[\s:|-]+\|/.test(n)||/^#{1,6} /.test(n.trimStart())?n:n.replace(/\n(?=[^\n])/g,function(e,t){var r=n.slice(t+1);return/^[ \t]*([#>|\-*+]|\d+\.)/.test(r)?"\n":" "})}).join("")).trim()},j=function(n){return n.replace(/[\.,;:]/g," ")},P=c(function(){return E.map(function(n){return{id:n.id,connected:n.isConnected,stackIndex:n.stackIndex,size:n.size}})},[E]),D=c(function(){var e=$(v||""),t=F?j(e):e,r=(E||[]).map(function(n){var e,t;return{id:null==n?void 0:n.id,highlight:$((null==n?void 0:n.highlight)||""),highlightColor:(null===(e=null==n?void 0:n.style)||void 0===e?void 0:e.highlightBg)||(null===(t=null==n?void 0:n.style)||void 0===t?void 0:t.badgeBg)||C}}).filter(function(n){return n.id&&n.highlight}),i={};r.forEach(function(n){i[n.highlight]||(i[n.highlight]=[]),i[n.highlight].push(n)});var o=function(n,e,t,r){void 0===e&&(e=""),void 0===r&&(r=[]);var i=!1,o=function(n){var o=function(n,e,t){var r,i,o;void 0===e&&(e="");var a=n.match(/^(\s*)([\s\S]*?)(\s*)$/);if(!a)return n;var l=null!==(r=a[1])&&void 0!==r?r:"",d=null!==(i=a[2])&&void 0!==i?i:"",c=null!==(o=a[3])&&void 0!==o?o:"";return d?l+function(n,e){void 0===n&&(n="");var t=e?' data-highlight-color="'.concat(e,'"'):"",r=n?' data-badge-id="'.concat(n,'"'):"";return"<mark".concat(r).concat(t,">")}(e,t)+d+"</mark>"+c:n}(n,e,t),a=o;if(!i&&r.length>0){i=!0;var l="",d="";r.forEach(function(n){l+=function(n){return'<span data-badge-id="'.concat(n,'">')}(n.id),d="</span>"+d}),a=l+o+d}return"​"+a};return n.split(/(\n+)/).map(function(n){return/^\n+$/.test(n)?n:n.trim()?""===n.replace(/[|:\-\s]/g,"")&&n.includes("-")?n:n.includes("|")?n.split(/(\|)/).map(function(n){return"|"!==n&&n.trim()?o(n):n}).join(""):o(n):n}).join("")},a=[];Object.entries(i).forEach(function(n){var r=n[0],i=n[1],o=e.indexOf(r),l=!1;if(-1===o&&F){var d=j(r);-1!==(o=t.indexOf(d))&&(l=!0)}if(-1!==o){for(var c=i[0].highlightColor,s=1;s<i.length;s++)c=g(c,i[s].highlightColor||"");a.push({highlight:r,start:o,end:o+r.length,badges:i,color:c,usedLooseMatch:l})}});var l=new Set(Object.keys(i));(k||[]).forEach(function(n){if(n){var r=$(n);if(r&&!l.has(r)){var i=e.indexOf(r),o=!1;if(-1===i&&F){var d=j(r);-1!==(i=t.indexOf(d))&&(o=!0)}if(-1!==i){var c=e.slice(0,i);(c.match(/</g)||[]).length===(c.match(/>/g)||[]).length&&a.push({highlight:r,start:i,end:i+r.length,badges:[],color:C||"",usedLooseMatch:o})}}}}),a.sort(function(n,e){return n.start-e.start||e.end-n.end});var d=[],c={};a.forEach(function(n,e){for(var t=n.start,r=n.end,i=0,o=d;i<o.length;i++){var a=o[i],l=a.start,s=a.end,u=t<s&&r>s&&t>=l,h=t<l&&r>l&&r<=s;if(t>=l&&r<=s){n.orphaned=!0,c[e]=a.matchIdx;break}u&&(t=s),h&&(r=l)}n.trimmedStart=t,n.trimmedEnd=r,!n.orphaned&&t<r&&d.push({start:t,end:r,matchIdx:e})});var s={};Object.entries(c).forEach(function(n){var e=n[0],t=n[1],r=Number(e);s[t]||(s[t]=[]),s[t].push(r)});var u=a.map(function(e,t){return n(n({},e),{idx:t})}).filter(function(n){return!n.orphaned}).sort(function(n,e){var t,r;return(null!==(t=e.trimmedStart)&&void 0!==t?t:e.start)-(null!==(r=n.trimmedStart)&&void 0!==r?r:n.start)});return u.forEach(function(n){var t,r,i,l,d=null!==(t=n.trimmedStart)&&void 0!==t?t:n.start,c=null!==(r=n.trimmedEnd)&&void 0!==r?r:n.end;if(!(d>=c)){var u=e.slice(d,c),h=function(n,e,t,r){if(!t.length)return n;var i=t.map(function(n){return a[n]}).sort(function(n,e){return n.start-e.start}),l="",d=0;return i.forEach(function(t){var i,a,c=Math.max(d,t.start-e),s=Math.max(c,t.end-e);if(!(c>=s)){var u=g(r,t.color||"");l+=n.slice(d,c),l+=o(n.slice(c,s),(null===(a=null===(i=t.badges)||void 0===i?void 0:i[0])||void 0===a?void 0:a.id)||"",u,t.badges||[]),d=s}}),l+=n.slice(d)}(n.usedLooseMatch||d!==n.start||c!==n.end?u:n.highlight,n.start,s[n.idx]||[],n.color),p=o(h,(null===(l=null===(i=n.badges)||void 0===i?void 0:i[0])||void 0===l?void 0:l.id)||"",n.color,n.badges||[]);e=e.slice(0,d)+p+e.slice(c)}}),e},[v,E,k,C,F]),H=c(function(){return m?$(m||""):""},[m]),N=!!m,R={"& *":{fontFamily:"inherit"},"& code, & pre, & kbd, & samp":{fontFamily:"inherit !important",fontSize:"inherit",background:"none",padding:0,border:"none",whiteSpace:"pre-wrap"},"& p, & li, & ul, & ol":{position:"static",overflow:"visible",whiteSpace:"pre-wrap"}},L=n(n(n(n({},b),R),{position:"relative",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",overflow:"visible",whiteSpace:"normal",gridArea:"1 / 1",zIndex:2}),N?{color:"transparent",userSelect:"none",pointerEvents:"none","& .deviation-badge":{pointerEvents:"auto"},"& table":{visibility:"hidden",margin:"0 !important"},"& th, & td":{padding:"0 !important",border:"none !important",backgroundColor:"transparent !important"},"& tr":{border:"none !important"},"& p:empty":{display:"none"}}:{}),q=n(n(n({},b),R),{position:"relative",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",overflow:"visible",whiteSpace:"normal",gridArea:"1 / 1",zIndex:1,pointerEvents:"auto"});return s(function(){if(A.current){var n=function(){var n=Array.from(A.current.querySelectorAll(".deviation-badge"));if(0!==n.length){n.forEach(function(n){n.style.setProperty("--badge-nudge","0px")});var e=n.filter(function(n){return"left"===n.dataset.side}),t=n.filter(function(n){return"left"!==n.dataset.side}),r=A.current.getBoundingClientRect(),i=r.bottom-4,o=r.top+4,a=function(n){if(0!==n.length){var e=n.map(function(n){var e=n.getBoundingClientRect();return{el:n,naturalTop:e.top,height:e.height,currentTop:e.top}});e.sort(function(n,e){return n.naturalTop-e.naturalTop});var t=[],r=[];e.forEach(function(n){if(0===r.length)r.push(n);else{var e=r[r.length-1],i=e.currentTop+e.height;n.naturalTop<i+8?(n.currentTop=i+8,r.push(n)):(t.push(r),r=[n])}}),r.length>0&&t.push(r),t.forEach(function(n){var e=n[n.length-1],t=e.currentTop+e.height;if(t>i){var r=t-i,a=n[0].currentTop-o,l=Math.max(0,Math.min(r,a));n.forEach(function(n){n.currentTop-=l})}}),t.flat().forEach(function(n){var e=n.currentTop-n.naturalTop;n.el.style.setProperty("--badge-nudge","".concat(e,"px"))})}};a(e),a(t)}},e=requestAnimationFrame(function(){requestAnimationFrame(function(){n()})}),t=new ResizeObserver(function(){requestAnimationFrame(n)});return t.observe(A.current),function(){t.disconnect(),cancelAnimationFrame(e)}}},[D,z,P]),r(o,n({ref:A,sx:{position:"relative",display:"grid",gridTemplateColumns:"minmax(0, 1fr)",width:"100%",maxWidth:"100%",minWidth:0}},{children:[t(a,n({component:"div",sx:n(n({},L),{padding:"3px"})},{children:t(p,n({components:M,remarkPlugins:x,rehypePlugins:y},{children:D.replace(/#{3}/g,"")}))})),N&&t(a,n({component:"div",sx:q},{children:t(p,n({components:M,remarkPlugins:x,rehypePlugins:y},{children:H}))}))]}))},f);export{w as MemoizedMarkdown};
1
+ import{__assign as n,__rest as e}from"tslib";import{jsx as t,jsxs as r,Fragment as i}from"react/jsx-runtime";import{Box as o,Typography as a}from"@mui/material";import l,{useRef as c,useMemo as d,useLayoutEffect as s}from"react";import{DEFAULT_DEVIAION_COLOR as u}from"../CognitiveCompareConstants.js";import{EllipsisVertical as h}from"lucide-react";import p from"react-markdown";import{findRedlineTextAnchorRange as g,findTextMatchRange as f,mixHexColors as v,areMarkdownPropsEqual as m}from"../CognitiveComparehelpers.js";import b from"rehype-raw";import x from"remark-gfm";import{normalizeRedlineMarkdown as y}from"../utils/normalizeRedlineMarkdown.js";var E=function(n){return"function"==typeof n?n:(null==n?void 0:n.default)||n},k=[E(x)],w=[E(b)],S=l.memo(function(m){var b=m.content,x=m.overlayContent,E=m.sxStyles,S=m.deviationBadges,C=void 0===S?[]:S,B=m.highlights,F=void 0===B?[]:B;m.maintainRelativeOrder;var z=m.highlightBg,A=m.suppressHighlightBg,T=void 0!==A&&A,W=m.collisionKey,I=c(null),M=!!x,j=d(function(){return C.reduce(function(e,t){var r;return n(n({},e),((r={})[t.id]=t,r))},{})},[C]),$=c({badgeMap:j,highlightBg:z,hideHighlightBg:M,suppressHighlightBg:T});$.current={badgeMap:j,highlightBg:z,hideHighlightBg:M,suppressHighlightBg:T};var O=function(e,t){return l.Children.map(e,function(e){var r;if(!l.isValidElement(e))return e;var i=(null===(r=e.props)||void 0===r?void 0:r.children)?O(e.props.children,t):e.props.children,o=l.cloneElement(e,n(n({},e.props),{children:i}));return t(o)})},P=d(function(){return{mark:function(r){var i,o,a,l,c=r.children,d=e(r,["children"]),s=$.current,u=s.badgeMap,h=s.highlightBg,p=s.hideHighlightBg,g=s.suppressHighlightBg,f=d["data-badge-id"],v=f?u[f]:null,m=d["data-highlight-color"],b=null!==(l=null!==(o=null!=m?m:null===(i=null==v?void 0:v.style)||void 0===i?void 0:i.highlightBg)&&void 0!==o?o:null===(a=null==v?void 0:v.style)||void 0===a?void 0:a.badgeBg)&&void 0!==l?l:h,x="true"===d["data-is-suggested-deviation-fix"]||g;return t("span",n({style:n(n(n({},x?{}:{backgroundColor:b}),{borderRadius:"2px",display:"inline",boxDecorationBreak:"clone",WebkitBoxDecorationBreak:"clone",backgroundClip:"padding-box",padding:"0 1px"}),p?{color:"transparent"}:{})},{children:c}))},span:function(i){var a,l,c,d,s,p,g=i.children,f=e(i,["children"]),v=$.current.badgeMap,m=f["data-badge-id"];if(!m)return t("span",n({},f,{children:g}));var b=v[m];if(!b)return t("span",n({},f,{children:g}));var x="number"==typeof b.stackIndex?b.stackIndex:0,y="translateY(calc(-20% + ".concat(12*x,"px + var(--badge-nudge, 0px)))");return r(o,n({component:"span",sx:{position:"static",display:"inline"}},{children:[r(o,n({ref:b.badgeRef,className:"deviation-badge","data-side":b.side||"right",sx:n(n({fontStyle:"normal",position:"absolute",zIndex:30+x,display:"inline-flex",alignItems:"stretch",fontSize:"10px",bgcolor:(null===(a=b.style)||void 0===a?void 0:a.badgeBg)||"#EEF2FF",color:(null===(l=b.style)||void 0===l?void 0:l.badgeText)||u,border:"1px solid ".concat((null===(c=b.style)||void 0===c?void 0:c.badgeBorder)||"#C7D2FE"),borderRadius:"12px",fontWeight:600,whiteSpace:"nowrap",boxShadow:"0 1px 3px rgba(0,0,0,0.07)",overflow:"hidden",transition:"none"},"left"===b.side?{right:"-16px",transform:"".concat(y," translateX(calc(100% + 8px))")}:{left:"-16px",transform:"".concat(y," translateX(calc(-100% - 8px))")}),b.isConnected&&b.style&&{outline:"2px solid ".concat(b.style.badgeBorder),outlineOffset:"1px"})},{children:[r(o,n({onClick:function(n){n.stopPropagation(),b.onSummaryClick&&b.onSummaryClick(n)},sx:{display:"flex",alignItems:"center",px:1,py:.3,cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.04)"}}},{children:[t(o,n({component:"span",sx:{fontSize:"10px",fontWeight:700}},{children:b.label})),("left"===b.side||b.isOrphan)&&t(o,n({component:"span",sx:{fontSize:"10px",pl:.5,ml:.5,borderLeft:"1px solid ".concat((null===(d=b.style)||void 0===d?void 0:d.badgeBorder)||"#C7D2FE")}},{children:null!=b.score&&"N/A"!==b.score&&"NA"!==b.score&&0!==b.score?"".concat(b.score):"N/A"===b.score||"NA"===b.score?"N/A":"Same"}))]})),("left"===b.side||b.isOrphan)&&t(o,n({onClick:function(n){n.stopPropagation(),b.onClick&&b.onClick(n)},sx:{display:"flex",alignItems:"center",px:.5,borderLeft:"1px solid ".concat((null===(s=b.style)||void 0===s?void 0:s.badgeBorder)||"#C7D2FE"),cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.06)"}}},{children:t(h,{size:12,color:(null===(p=b.style)||void 0===p?void 0:p.badgeText)||"#3730A3"})}))]})),g]}))},table:function(e){var r=e.children;return t(o,n({sx:{display:"block",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",contain:"inline-size",overflowX:"auto",overflowY:"hidden",overscrollBehaviorX:"contain",WebkitOverflowScrolling:"touch",my:1}},{children:t(o,n({component:"table",sx:{width:"600px",minWidth:"600px",tableLayout:"fixed",borderCollapse:"collapse",fontSize:"inherit"}},{children:r}))}))},thead:function(e){var r=e.children;return t(o,n({component:"thead"},{children:r}))},tbody:function(e){var r=e.children;return t(o,n({component:"tbody"},{children:r}))},tr:function(e){var r=e.children;return t(o,n({component:"tr",sx:{borderBottom:"1px solid #E5E7EB"}},{children:r}))},th:function(e){var r=e.children;return t(o,n({component:"th",sx:{border:"1px solid #E5E7EB",padding:"8px",textAlign:"left",verticalAlign:"top",fontWeight:600,backgroundColor:"#F9FAFB",whiteSpace:"normal",wordBreak:"break-word",overflowWrap:"anywhere"}},{children:r}))},td:function(e){var r=e.children;return t(o,n({component:"td",sx:{border:"1px solid #E5E7EB",padding:"8px",verticalAlign:"top",whiteSpace:"normal",wordBreak:"break-word",overflowWrap:"anywhere"}},{children:r}))},code:function(e){var r=e.children;return t("span",n({style:{fontFamily:"inherit",fontSize:"inherit"}},{children:r}))},pre:function(e){var r=e.children;return t("span",n({style:{fontFamily:"inherit",fontSize:"inherit",display:"block",whiteSpace:"pre-wrap"}},{children:r}))},updated:function(n){var e=n.children;return t(i,{children:e})},deleted:function(e){var r=e.children,i=O(r,function(n){return l.cloneElement(n,{"data-is-suggested-deviation-fix":"true"})});return t("span",n({style:{boxShadow:"inset 0 1px 0 #EF4444, inset 0 -1px 0 #EF4444",backgroundColor:"#FCCCCC",textDecoration:"line-through"}},{children:i}))},changed:function(e){var r=e.children,i=O(r,function(n){return l.cloneElement(n,{"data-is-suggested-deviation-fix":"true"})});return t("span",n({style:{boxShadow:"inset 0 1px 0 #2F59FF, inset 0 -1px 0 #2F59FF",backgroundColor:"#D5E8FF"}},{children:i}))},ul:function(r){var i=r.children,a=e(r,["children"]);return t(o,n({component:"ul",sx:{mt:1,mb:1,pl:3,listStyleType:"disc"}},a,{children:i}))},ol:function(r){var i=r.children,a=e(r,["children"]);return t(o,n({component:"ol",sx:{mt:1,mb:1,pl:3,listStyleType:"decimal"}},a,{children:i}))},li:function(r){var i=r.children,a=e(r,["children"]);return t(o,n({component:"li",sx:{mb:.5,display:"list-item"}},a,{children:i}))}}},[]),R=function(n){if(!n||"string"!=typeof n)return"";var e=n,t=(e=(e=(e=(e=(e=(e=(e=(e=e.replace(/((?:<\/?[a-z]+[^>]*>\s*)+)([*+\-] |\d+\. )/gi,"$2$1")).replace(/\\(['"])/g,"$1").replace(/\\n/g,"\n").replace(/\\\./g,".").replace(/\r\n/g,"\n")).replace(/^([ \t]*)(\d+\.)(\s{2,})/gm,function(n,e,t,r){return"".concat(e).concat(t.slice(0,-1),"\\.").concat(r)})).replace(/^(\d+\.)\s*\n+(\s+)(\S)/gm,function(n,e,t,r){return"".concat(e," ").concat(r)})).replace(/([^\n])\n(#{1,6} )/g,"$1\n\n$2")).replace(/([^\n])\n([ \t]*(?:[#*+\-] |\d+\. ))/g,"$1\n\n$2")).replace(/\n{3,}/g,"\n\n")).replace(/^[ \t]+(?![ \t]*([\*\-\+] |\d+\. ))/gm,function(n){return n.replace(/ /g," ").replace(/\t/g,"    ")})).split(/(\n{2,})/);return(e=t.map(function(n){return/^\n+$/.test(n)||/\|.*\|/.test(n)&&/\|[\s:|-]+\|/.test(n)||/^#{1,6} /.test(n.trimStart())?n:n.replace(/\n(?=[^\n])/g,function(e,t){var r=n.slice(t+1);return/^[ \t]*([#>|\-*+]|\d+\.)/.test(r)?"\n":" "})}).join("")).trim()},D=d(function(){return C.map(function(n){return{id:n.id,connected:n.isConnected,stackIndex:n.stackIndex,size:n.size}})},[C]),H=function(n){return R(y(n||""))},N=d(function(){var e=R(y(b||"")),t=(C||[]).map(function(n){var e,t;return{id:null==n?void 0:n.id,highlight:H((null==n?void 0:n.highlight)||""),highlightColor:(null===(e=null==n?void 0:n.style)||void 0===e?void 0:e.highlightBg)||(null===(t=null==n?void 0:n.style)||void 0===t?void 0:t.badgeBg)||z}}).filter(function(n){return n.id&&n.highlight}),r={};t.forEach(function(n){r[n.highlight]||(r[n.highlight]=[]),r[n.highlight].push(n)});var i=function(n,e,t,r){void 0===e&&(e=""),void 0===r&&(r=[]);var i=!1,o=function(n){var o=function(n,e,t){var r,i,o;void 0===e&&(e="");var a=n.match(/^(\s*)([\s\S]*?)(\s*)$/);if(!a)return n;var l=null!==(r=a[1])&&void 0!==r?r:"",c=null!==(i=a[2])&&void 0!==i?i:"",d=null!==(o=a[3])&&void 0!==o?o:"";return c?l+function(n,e){void 0===n&&(n="");var t=e?' data-highlight-color="'.concat(e,'"'):"",r=n?' data-badge-id="'.concat(n,'"'):"";return"<mark".concat(r).concat(t,">")}(e,t)+c+"</mark>"+d:n}(n,e,t),a=o;if(!i&&r.length>0){i=!0;var l="",c="";r.forEach(function(n){l+=function(n){return'<span data-badge-id="'.concat(n,'">')}(n.id),c="</span>"+c}),a=l+o+c}return"​"+a};return n.split(/(\n+)/).map(function(n){return/^\n+$/.test(n)?n:n.trim()?""===n.replace(/[|:\-\s]/g,"")&&n.includes("-")?n:n.includes("|")?n.split(/(\|)/).map(function(n){return"|"!==n&&n.trim()?o(n):n}).join(""):o(n):n}).join("")},o=[];Object.entries(r).forEach(function(n){var t=n[0],r=n[1],i=T?g(e,t):f(e,t,!1);if(i){for(var a=e.slice(i.start,i.end)!==t,l=r[0].highlightColor,c=1;c<r.length;c++)l=v(l,r[c].highlightColor||"");o.push({highlight:t,start:i.start,end:i.end,badges:r,color:l,usedLooseMatch:a})}});var a=new Set(Object.keys(r));(F||[]).forEach(function(n){if(n){var t=H(n);if(t&&!a.has(t)){var r=T?g(e,t):f(e,t,!1);if(r){var i=e.slice(r.start,r.end)!==t,l=e.slice(0,r.start);(l.match(/</g)||[]).length===(l.match(/>/g)||[]).length&&o.push({highlight:t,start:r.start,end:r.end,badges:[],color:z||"",usedLooseMatch:i})}}}}),o.sort(function(n,e){return n.start-e.start||e.end-n.end});var l=[],c={};o.forEach(function(n,e){for(var t=n.start,r=n.end,i=0,o=l;i<o.length;i++){var a=o[i],d=a.start,s=a.end,u=t<s&&r>s&&t>=d,h=t<d&&r>d&&r<=s;if(t>=d&&r<=s){n.orphaned=!0,c[e]=a.matchIdx;break}u&&(t=s),h&&(r=d)}n.trimmedStart=t,n.trimmedEnd=r,!n.orphaned&&t<r&&l.push({start:t,end:r,matchIdx:e})});var d={};Object.entries(c).forEach(function(n){var e=n[0],t=n[1],r=Number(e);d[t]||(d[t]=[]),d[t].push(r)});var s=o.map(function(e,t){return n(n({},e),{idx:t})}).filter(function(n){return!n.orphaned}).sort(function(n,e){var t,r;return(null!==(t=e.trimmedStart)&&void 0!==t?t:e.start)-(null!==(r=n.trimmedStart)&&void 0!==r?r:n.start)});return s.forEach(function(n){var t,r,a,l,c=null!==(t=n.trimmedStart)&&void 0!==t?t:n.start,s=null!==(r=n.trimmedEnd)&&void 0!==r?r:n.end;if(!(c>=s)){var u=e.slice(c,s),h=function(n,e,t,r){if(!t.length)return n;var a=t.map(function(n){return o[n]}).sort(function(n,e){return n.start-e.start}),l="",c=0;return a.forEach(function(t){var o,a,d=Math.max(c,t.start-e),s=Math.max(d,t.end-e);if(!(d>=s)){var u=v(r,t.color||"");l+=n.slice(c,d),l+=i(n.slice(d,s),(null===(a=null===(o=t.badges)||void 0===o?void 0:o[0])||void 0===a?void 0:a.id)||"",u,t.badges||[]),c=s}}),l+=n.slice(c)}(n.usedLooseMatch||c!==n.start||s!==n.end?u:n.highlight,n.start,d[n.idx]||[],n.color),p=i(h,(null===(l=null===(a=n.badges)||void 0===a?void 0:a[0])||void 0===l?void 0:l.id)||"",n.color,n.badges||[]);e=e.slice(0,c)+p+e.slice(s)}}),e},[b,C,F,z,T]),L=d(function(){return x?R(y(x||"")):""},[x]),q=!!x,X=n(n(n({},E),{"& *":{fontFamily:"inherit"},"& code, & pre, & kbd, & samp":{fontFamily:"inherit !important",fontSize:"inherit",background:"none",padding:0,border:"none",whiteSpace:"pre-wrap"},"& p, & li, & ul, & ol":{position:"static",overflow:"visible",whiteSpace:"pre-wrap"}}),{position:"relative",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",overflow:"visible",whiteSpace:"normal",gridArea:"1 / 1",padding:"3px"}),Y=n(n(n({},X),{zIndex:2}),q?{color:"transparent",userSelect:"none",pointerEvents:"none","& .deviation-badge":{pointerEvents:"auto",visibility:"visible"},"& table":{visibility:"hidden"}}:{}),K=n(n({},X),{zIndex:1,pointerEvents:"auto"});return s(function(){if(I.current){var n=function(){var n=Array.from(I.current.querySelectorAll(".deviation-badge"));if(0!==n.length){n.forEach(function(n){n.style.setProperty("--badge-nudge","0px")});var e=n.filter(function(n){return"left"===n.dataset.side}),t=n.filter(function(n){return"left"!==n.dataset.side}),r=I.current.getBoundingClientRect(),i=r.bottom-4,o=r.top+4,a=function(n){if(0!==n.length){var e=n.map(function(n){var e=n.getBoundingClientRect();return{el:n,naturalTop:e.top,height:e.height,currentTop:e.top}});e.sort(function(n,e){return n.naturalTop-e.naturalTop});var t=[],r=[];e.forEach(function(n){if(0===r.length)r.push(n);else{var e=r[r.length-1],i=e.currentTop+e.height;n.naturalTop<i+8?(n.currentTop=i+8,r.push(n)):(t.push(r),r=[n])}}),r.length>0&&t.push(r),t.forEach(function(n){var e=n[n.length-1],t=e.currentTop+e.height;if(t>i){var r=t-i,a=n[0].currentTop-o,l=Math.max(0,Math.min(r,a));n.forEach(function(n){n.currentTop-=l})}}),t.flat().forEach(function(n){var e=n.currentTop-n.naturalTop;n.el.style.setProperty("--badge-nudge","".concat(e,"px"))})}};a(e),a(t)}},e=requestAnimationFrame(function(){requestAnimationFrame(function(){n()})}),t=new ResizeObserver(function(){requestAnimationFrame(n)});return t.observe(I.current),function(){t.disconnect(),cancelAnimationFrame(e)}}},[N,W,D]),r(o,n({ref:I,sx:{position:"relative",display:"grid",gridTemplateColumns:"minmax(0, 1fr)",width:"100%",maxWidth:"100%",minWidth:0}},{children:[t(a,n({component:"div",sx:Y},{children:t(p,n({components:P,remarkPlugins:k,rehypePlugins:w},{children:N.replace(/#{3}/g,"")}))})),q&&t(a,n({component:"div",sx:K},{children:t(p,n({components:P,remarkPlugins:k,rehypePlugins:w},{children:L}))}))]}))},m);export{S as MemoizedMarkdown};
2
2
  //# sourceMappingURL=memoizedMarkdown.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as n,__spreadArray as e}from"tslib";import{useMemo as t}from"react";import{isMissingStr as i,safeStringify as o,getRationale as r,resolveComparisonInputItems as a,getSideData as l,hasValue as d,DEVIATION_BADGE_SEPARATOR as s}from"../CognitiveComparehelpers.js";import{buildComparisonRows as u}from"../utils/buildComparisonRows.js";var v={id:"",title:"",similarity:0,sections:[]},c=function(c,f,p,I,_,h){var g,m;void 0===_&&(_=!0);var x="string"==typeof p?p:JSON.stringify(p||{}),b=Boolean(h&&(h.learnings_data||(null===(m=null===(g=h.data)||void 0===g?void 0:g.artifactData)||void 0===m?void 0:m.userStorySnapshot))),y=t(function(){if(!c||0===Object.keys(c).length)return{activeProposed:{},activeVariants:[],comparisonRows:[],parseError:"Tree data is required"};var t=JSON.parse(x);try{var d=c.nodes||c,s=[],v=[],p=[],I=c.base_root_id,g=c.input_index_map||{0:"left",1:"right"},m=c[I]||d[I];if(!m||!1===m.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[],comparisonRows:[],parseError:null};var y=c.content_mapping||{},R=function(n){return c[n]||d[n]},C=function(e,t,o){if(!e||"object"!=typeof e)return e||null;if(e.deviations)return e;if(_)return e;var r=Object.keys(e).filter(function(n){return/^\d+$/.test(n)});if(!r.length)return e;var a=r.sort(function(n,e){return Number(n)-Number(e)}),l={},d={},s=null;return a.forEach(function(n){var r,a,u,v,c,f,p=e[n];if(p&&"object"==typeof p){s||(s=p);var I=!(null==p?void 0:p.status)||"pending"===p.status,_=(null==p?void 0:p.deviation_highlight)||(null===(a=null==p?void 0:p.web_search_answer)||void 0===a?void 0:a.deviation_highlight),h=function(n){var e,t=(null===(e=null==p?void 0:p.cognitive_decisioning)||void 0===e?void 0:e.citations)||(null==p?void 0:p.citations)||{};return Object.values(t).map(function(e){var t;return null===(t=null==e?void 0:e[n])||void 0===t?void 0:t.highlighted_text}).filter(function(n){return"string"==typeof n&&n.trim().length>0})},m=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];for(var t=0,o=n;t<o.length;t++){var r=o[t];if(Array.isArray(r)&&r.some(function(n){return!i(n)}))return r}return[]},x=I?m((null===(u=null==p?void 0:p.deviation_highlights)||void 0===u?void 0:u[t])||(null===(v=null==p?void 0:p.deviation_highlights)||void 0===v?void 0:v[g[0]]),"string"==typeof _?[_]:[],h(t),h(g[0])):[],b=I?m((null===(c=null==p?void 0:p.deviation_highlights)||void 0===c?void 0:c[o])||(null===(f=null==p?void 0:p.deviation_highlights)||void 0===f?void 0:f[g[1]]),h(o),h(g[1])):[];l[n]=((r={})[g[0]]=x[0]||"",r[g[1]]=b[0]||"",r.deviation_summary=(null==p?void 0:p.deviation_summary)||"",r.deviation_title=null==p?void 0:p.deviation_title,r.deviation_impact=null==p?void 0:p.deviation_impact,r.deviation_explanation=null==p?void 0:p.deviation_explanation,r.evaluation_outputs=null==p?void 0:p.evaluation_outputs,r.cognitive_decisioning=null==p?void 0:p.cognitive_decisioning,r.deviation_highlights=null==p?void 0:p.deviation_highlights,r),d[n]=p}}),n(n({},e),{deviation_title:(null==s?void 0:s.deviation_title)||(null==e?void 0:e.deviation_title),deviation_impact:(null==s?void 0:s.deviation_impact)||(null==e?void 0:e.deviation_impact),deviation_summary:(null==s?void 0:s.deviation_summary)||(null==e?void 0:e.deviation_summary),deviation_explanation:(null==s?void 0:s.deviation_explanation)||(null==e?void 0:e.deviation_explanation),evaluation_outputs:(null==s?void 0:s.evaluation_outputs)||(null==e?void 0:e.evaluation_outputs),cognitive_decisioning:(null==s?void 0:s.cognitive_decisioning)||(null==e?void 0:e.cognitive_decisioning),deviations:l,deviation_entries:d})},E=function(n){var e=new Map,t=function(n){n.forEach(function(n){var i;n.id&&e.set(n.id,n),(null===(i=n.subsections)||void 0===i?void 0:i.length)&&t(n.subsections)})};t(n);var i=function(n,t){for(var o,r=[],a=function(n){var a=n.ref_parent_section_node_id;if(a&&e.has(a)&&a!==(null==t?void 0:t.id)){var l=e.get(a);l.subsections||(l.subsections=[]),l.subsections.some(function(e){return e.id===n.id})||l.subsections.push(n)}else(null===(o=n.subsections)||void 0===o?void 0:o.length)&&(n.subsections=i(n.subsections,n)),r.push(n)},l=0,d=n;l<d.length;l++){a(d[l])}return r},o=i(n),r=function(n){n.forEach(function(n){n.subsections&&n.subsections.length>0&&(n.subsections.sort(function(n,e){return n.selfIndex<0&&e.selfIndex>=0?1:n.selfIndex>=0&&e.selfIndex<0?-1:(n.selfIndex||0)-(e.selfIndex||0)}),r(n.subsections))})};return r(o),o},O=function(n){var e=n.comparison_inputs?Object.keys(n.comparison_inputs):[],t=g[0],i=g[1];return e.length>0&&(t=e.includes(g[0])?g[0]:e[0],i=e.includes(g[1])?g[1]:e.length>1?e[1]:e[0]),{nodeLeftId:t,nodeRightId:i}},j=function(e,t,i,r){var a=t.attributes||{},l=t.data||{},d=!1!==a.display_title,s=!1!==a.display_content,u=d?o(l.title||""):"",v=s?o(l.content||""):"",c=s?o(l.change_history||""):"",f=void 0!==a.display_index&&null!==a.display_index?Number(a.display_index):-1,p=function(n){return(null==n?void 0:n.entity_id)||(null==n?void 0:n.ref_parent_section_node_id)||(null==n?void 0:n.parent_entity_id)||null}(a),I=!(!u.trim()&&!v.trim());return n(n({id:"".concat(e,"::").concat(t.contentId),nodeId:e,contentId:t.contentId,parentContentId:p,title:u,content:v,change_history:c,displayTitle:d,displayContent:s,subsections:[]},I?r:{score:void 0,relation:"not_defined"}),{evaluationResult:i,evaluationResults:i?[i]:[],selfIndex:f,refIndexes:[],refContentIds:[],ref_parent_section_node_id:p})},N=function(n,t){n.refIndexes=Array.from(new Set(e(e([],n.refIndexes||[],!0),t.refIndexes||[],!0))),n.refContentIds=Array.from(new Set(e(e([],n.refContentIds||[],!0),t.refContentIds||[],!0)));var i=new Set((n.subsections||[]).map(function(n){return n.id||n.contentId||n.nodeId}));(t.subsections||[]).forEach(function(t){var o=t.id||t.contentId||t.nodeId;i.has(o)||(n.subsections=e(e([],n.subsections||[],!0),[t],!1),i.add(o))});var o=e(e([],n.evaluationResults||(n.evaluationResult?[n.evaluationResult]:[]),!0),t.evaluationResults||(t.evaluationResult?[t.evaluationResult]:[]),!0).filter(Boolean),r=new Set;return n.evaluationResults=o.filter(function(n){var e=(null==n?void 0:n.nodeId)||JSON.stringify(Object.keys((null==n?void 0:n.deviations)||n||{}));return!r.has(e)&&(r.add(e),!0)}),!n.evaluationResult&&t.evaluationResult&&(n.evaluationResult=t.evaluationResult),!n.cognitiveData&&t.cognitiveData&&(n.cognitiveData=t.cognitiveData),n},S=function(n,e){return n.selfIndex<0&&e.selfIndex>=0?1:n.selfIndex>=0&&e.selfIndex<0?-1:n.selfIndex-e.selfIndex},w=function(e,i){var o,l=R(e);if(!l||!1===l.display_node)return[];if(b&&"1"===i)return[];var d=O(l),s=d.nodeLeftId,u=d.nodeRightId,v=r(l),c=(null===(o=null==t?void 0:t[e])||void 0===o?void 0:o.evaluation_result)||l.evaluation_result||null,f=C(c,s,u),p=f&&"object"==typeof f?n(n({},f),{nodeId:e}):f,I=a(l,i,g,y).map(function(n){return j(e,n,p,v)});if(l.next){var _=Object.values(l.next).flatMap(function(n){return w(n,i)});I.forEach(function(n){var e=_.filter(function(e){return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId});n.subsections=e.length?e:_})}return I};if(f){var k=function(e,i){var o;void 0===i&&(i=0);var l=[],d=[];if(!e)return{refSections:l,baseSections:d};var s={},u={},v=-1,c=-1,f=function(l){var d=e[l],f=R(d);if(!f||!1===f.display_node)return"continue";var p=O(f),I=p.nodeLeftId,_=p.nodeRightId,h=r(f),m=(null===(o=null==t?void 0:t[d])||void 0===o?void 0:o.evaluation_result)||f.evaluation_result||null,x=C(m,I,_),E=x&&"object"==typeof x?n(n({},x),{nodeId:d}):x,S=k(f.next,i+1),w=S.refSections,D=S.baseSections,P=a(f,"0",g,y).map(function(n){var e=j(d,n,E,h);return-1===e.selfIndex&&(e.selfIndex=c--),e}),K=[];if(!b){var V=a(f,"1",g,y);K=V.map(function(n){var e=j(d,n,E,h);return-1===e.selfIndex&&(e.selfIndex=v--),e})}P.forEach(function(n){K.forEach(function(e){var t,i,o,r,a,l,d,s;Number(e.selfIndex)>=0&&Number(n.selfIndex)>=0&&((null===(t=e.refIndexes)||void 0===t?void 0:t.includes(Number(n.selfIndex)))||null===(i=e.refIndexes)||void 0===i||i.push(Number(n.selfIndex)),(null===(o=n.refIndexes)||void 0===o?void 0:o.includes(Number(e.selfIndex)))||null===(r=n.refIndexes)||void 0===r||r.push(Number(e.selfIndex))),n.contentId&&!(null===(a=e.refContentIds)||void 0===a?void 0:a.includes(n.contentId))&&(null===(l=e.refContentIds)||void 0===l||l.push(n.contentId)),e.contentId&&!(null===(d=n.refContentIds)||void 0===d?void 0:d.includes(e.contentId))&&(null===(s=n.refContentIds)||void 0===s||s.push(e.contentId))})}),K.forEach(function(n){var e=w.filter(function(e){var t;return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId||(null===(t=n.refContentIds)||void 0===t?void 0:t.includes(e.parentContentId))});e.length>0&&(n.subsections=e);var t=0===i?String(n.selfIndex):"".concat(n.selfIndex,"_").concat(n.contentId||d);s[t]=s[t]?N(s[t],n):n}),P.forEach(function(n){var e=D.filter(function(e){var t;return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId||(null===(t=n.refContentIds)||void 0===t?void 0:t.includes(e.parentContentId))});e.length>0&&(n.subsections=e);var t=0===i?String(n.selfIndex):"".concat(n.selfIndex,"_").concat(n.contentId||d);u[t]=u[t]?N(u[t],n):n})};for(var p in e)f(p);return l=Object.values(s),d=Object.values(u),l.sort(S),d.sort(S),{refSections:l,baseSections:d}},D=k(m.next),P=D.refSections,K=D.baseSections;b||(v=E(P)),s=K}else m.next&&Object.values(m.next).forEach(function(n){var e=R(n);if(e&&!1!==e.display_node){var t=w(n,"0");if(b)s.push.apply(s,t);else{var i=E(w(n,"1"));p.push.apply(p,u(n,t,i))}}}),b||(s=p.map(function(n){return n.left}),v=p.map(function(n){return n.right}));var V=l(m,"0",g,y),T=l(m,"1",g,y),A={title:V.title||"Uploaded Contract",description:m.decision_scope_description||"",sections:s},G={id:"tree-variant-1",title:b?function(){var n,e;if((null==h?void 0:h.learnings_data)&&Object.keys(h.learnings_data).length>0){var t=Object.keys(h.learnings_data)[0];return(null===(n=h.learnings_data[t])||void 0===n?void 0:n.title)||"Rulebook Guidelines"}return(null===(e=null==h?void 0:h.data)||void 0===e?void 0:e.artifactTitle)||"Rulebook Guidelines"}():T.title||"Reference Template",similarity:0,sections:v,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:m.decision_scope_description||""},fields:{}}}};return{activeProposed:A,activeVariants:[G],comparisonRows:p,parseError:null}}catch(n){return console.error("Data Transformation Error: ",n),{activeProposed:{},activeVariants:[],comparisonRows:[],parseError:n instanceof Error?n.message:"Unknown Parsing Error"}}},[c,f,x,_,h]),R=y.activeProposed,C=y.activeVariants,E=y.comparisonRows,O=y.parseError,j=(null==C?void 0:C[0])||v,N=t(function(){return(null==R?void 0:R.sections)||[]},[null==R?void 0:R.sections]),S=t(function(){return j.sections||[]},[j.sections]),w=N.length>0||S.length>0,k=t(function(){return I.fields.filter(function(n){var e=n.key;return(!w||"description"!==e)&&(d(null==R?void 0:R[e])||d(j[e]))})},[R,j,w,I.fields]),D=t(function(){var n,e,t={},o={},r={},a=0,l=null===(n=null==c?void 0:c.input_index_map)||void 0===n?void 0:n[0],d=null===(e=null==c?void 0:c.input_index_map)||void 0===e?void 0:e[1],u=function(n,e){if(!f){var t="left"===e?N.indexOf(n):S.indexOf(n);return{rootKey:"".concat(e,":").concat(t),parentNum:t+1}}if("left"===e){var i=n.selfIndex,o=void 0!==i&&i>=0?i+1:N.indexOf(n)+1;return{rootKey:"left-root:".concat(n.id),parentNum:o}}var r=n.selfIndex,a=N.find(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(r)});if(a){var l=a.selfIndex,d=void 0!==l&&l>=0?l+1:N.indexOf(a)+1;return{rootKey:"left-root:".concat(a.id),parentNum:d}}var s=void 0!==r&&r>=0?r+1:S.indexOf(n)+1;return{rootKey:"right-orphan-root:".concat(n.id),parentNum:s}},v=function(n,e){if(n&&e)return n.find(function(n){return n.id===e.id||n.nodeId&&n.nodeId===e.nodeId||n.contentId&&n.contentId===e.contentId})||void 0},p=function(n,e,u,c,f,I,_){if(e&&function(n,e,t){var a;((null===(a=null==n?void 0:n.evaluationResults)||void 0===a?void 0:a.length)?n.evaluationResults:(null==n?void 0:n.evaluationResult)?[n.evaluationResult]:[]).forEach(function(a){var u=(null==a?void 0:a.deviations)||{};Object.keys(u).sort().forEach(function(v){var c=u[v];if(c){var f=!i(c[l]),p=!i(c[d]);if(f||p){var I=(null==a?void 0:a.nodeId)||n.nodeId||n.id,_="".concat(I).concat(s).concat(v);void 0===o[_]&&(void 0===r[e]&&(r[e]=1),o[_]={index:r[e]++,rootKey:e,parentNum:t})}}})})}(e,c,f),e&&!I){var h=(null==_?void 0:_.id)||"fallback_parent_".concat(a++);t[h]||(t[h]=[]),t[h].push(e)}((null==e?void 0:e.subsections)||(null==n?void 0:n.subsections)||(null==u?void 0:u.subsections)||[]).forEach(function(t){var i=v(null==n?void 0:n.subsections,t),o=v(null==u?void 0:u.subsections,t);p(t,i,o,c,f,!1,e||_)})};N.forEach(function(n){var e,t=u(n,"left"),i=t.rootKey,o=t.parentNum,r=null;if(f){var a=null===(e=n.refIndexes)||void 0===e?void 0:e[0];r=S.find(function(n){return n.selfIndex===a})}else r=S[N.indexOf(n)];p(n,n,r,i,o,!0,n)}),b||S.forEach(function(n){var e=u(n,"right"),t=e.rootKey,i=e.parentNum;t.startsWith("right-orphan-root:")&&p(n,null,n,t,i,!0,n)});var I=Object.fromEntries(Object.entries(o).map(function(n){return[n[0],n[1].index]})),_=Object.fromEntries(Object.entries(o).map(function(n){return[n[0],n[1].parentNum]}));return{parentDeviationRecord:t,registry:I,deviationParentRegistry:_}},[N,S,f,c,b]),P=D.parentDeviationRecord,K=D.registry,V=D.deviationParentRegistry;return{isGuidelineMode:b,activeProposed:R,activeVariants:C,comparisonRows:E,existingRule:j,proposedSections:N,existingSections:S,visibleFields:k,parentDeviationRecord:P,deviationNumberRegistry:K,deviationParentRegistry:V,parseError:O}};export{c as useCognitiveTreeData};
1
+ import{__assign as n,__spreadArray as e}from"tslib";import{useMemo as t}from"react";import{safeStringify as i,isMissingStr as o,getRationale as r,resolveComparisonInputItems as a,getSideData as l,hasValue as d,DEVIATION_BADGE_SEPARATOR as s}from"../CognitiveComparehelpers.js";import{buildComparisonRows as u}from"../utils/buildComparisonRows.js";var v={id:"",title:"",similarity:0,sections:[]},c=function(c,f,p,_,I,g,h){var m,x;void 0===I&&(I=!0);var b="string"==typeof p?p:JSON.stringify(p||{}),y=null!=h?h:Boolean("string"==typeof g?g.trim():g&&(g.learnings_data||(null===(x=null===(m=g.data)||void 0===m?void 0:m.artifactData)||void 0===x?void 0:x.userStorySnapshot))),R=t(function(){if(!c||0===Object.keys(c).length)return{activeProposed:{},activeVariants:[],comparisonRows:[],parseError:"Tree data is required"};var t=JSON.parse(b);try{var d=c.nodes||c,s=[],v=[],p=[],_=c.base_root_id,h=c.input_index_map||{0:"left",1:"right"},m=c[_]||d[_];if(!m||!1===m.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[],comparisonRows:[],parseError:null};var x=c.content_mapping||{},R=function(n){return c[n]||d[n]},C=function(e,t,r){if(!e||"object"!=typeof e)return e||null;if(e.deviations)return e;if(I)return e;var a=Object.keys(e).filter(function(n){return/^\d+$/.test(n)});if(!a.length)return e;var l=a.sort(function(n,e){return Number(n)-Number(e)}),d={},s={},u=null;return l.forEach(function(n){var a,l,v,c,f,p,_,I=e[n];if(I&&"object"==typeof I){u||(u=I);var g="same"===i(null===(l=null==I?void 0:I.evaluation_outputs)||void 0===l?void 0:l.output_value).trim().toLowerCase(),m=!((null==I?void 0:I.status)&&"pending"!==I.status||g),x=(null==I?void 0:I.deviation_highlight)||(null===(v=null==I?void 0:I.web_search_answer)||void 0===v?void 0:v.deviation_highlight),b=function(n){var e,t=(null===(e=null==I?void 0:I.cognitive_decisioning)||void 0===e?void 0:e.citations)||(null==I?void 0:I.citations)||{};return Object.values(t).map(function(e){var t;return null===(t=null==e?void 0:e[n])||void 0===t?void 0:t.highlighted_text}).filter(function(n){return"string"==typeof n&&n.trim().length>0})},y=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];for(var t=0,i=n;t<i.length;t++){var r=i[t];if(Array.isArray(r)&&r.some(function(n){return!o(n)}))return r}return[]},R=m?y((null===(c=null==I?void 0:I.deviation_highlights)||void 0===c?void 0:c[t])||(null===(f=null==I?void 0:I.deviation_highlights)||void 0===f?void 0:f[h[0]]),"string"==typeof x?[x]:[],b(t),b(h[0])):[],C=m?y((null===(p=null==I?void 0:I.deviation_highlights)||void 0===p?void 0:p[r])||(null===(_=null==I?void 0:I.deviation_highlights)||void 0===_?void 0:_[h[1]]),b(r),b(h[1])):[];d[n]=((a={})[h[0]]=R[0]||"",a[h[1]]=C[0]||"",a.deviation_summary=(null==I?void 0:I.deviation_summary)||"",a.deviation_title=null==I?void 0:I.deviation_title,a.deviation_impact=null==I?void 0:I.deviation_impact,a.deviation_explanation=null==I?void 0:I.deviation_explanation,a.evaluation_outputs=null==I?void 0:I.evaluation_outputs,a.cognitive_decisioning=null==I?void 0:I.cognitive_decisioning,a.deviation_highlights=null==I?void 0:I.deviation_highlights,a),s[n]=I}}),n(n({},e),{deviation_title:(null==u?void 0:u.deviation_title)||(null==e?void 0:e.deviation_title),deviation_impact:(null==u?void 0:u.deviation_impact)||(null==e?void 0:e.deviation_impact),deviation_summary:(null==u?void 0:u.deviation_summary)||(null==e?void 0:e.deviation_summary),deviation_explanation:(null==u?void 0:u.deviation_explanation)||(null==e?void 0:e.deviation_explanation),evaluation_outputs:(null==u?void 0:u.evaluation_outputs)||(null==e?void 0:e.evaluation_outputs),cognitive_decisioning:(null==u?void 0:u.cognitive_decisioning)||(null==e?void 0:e.cognitive_decisioning),deviations:d,deviation_entries:s})},E=function(n){var e=new Map,t=function(n){n.forEach(function(n){var i;n.id&&e.set(n.id,n),(null===(i=n.subsections)||void 0===i?void 0:i.length)&&t(n.subsections)})};t(n);var i=function(n,t){for(var o,r=[],a=function(n){var a=n.ref_parent_section_node_id;if(a&&e.has(a)&&a!==(null==t?void 0:t.id)){var l=e.get(a);l.subsections||(l.subsections=[]),l.subsections.some(function(e){return e.id===n.id})||l.subsections.push(n)}else(null===(o=n.subsections)||void 0===o?void 0:o.length)&&(n.subsections=i(n.subsections,n)),r.push(n)},l=0,d=n;l<d.length;l++){a(d[l])}return r},o=i(n),r=function(n){n.forEach(function(n){n.subsections&&n.subsections.length>0&&(n.subsections.sort(function(n,e){return n.selfIndex<0&&e.selfIndex>=0?1:n.selfIndex>=0&&e.selfIndex<0?-1:(n.selfIndex||0)-(e.selfIndex||0)}),r(n.subsections))})};return r(o),o},O=function(n){var e=n.comparison_inputs?Object.keys(n.comparison_inputs):[],t=h[0],i=h[1];return e.length>0&&(t=e.includes(h[0])?h[0]:e[0],i=e.includes(h[1])?h[1]:e.length>1?e[1]:e[0]),{nodeLeftId:t,nodeRightId:i}},j=function(e,t,o,r){var a=t.attributes||{},l=t.data||{},d=!1!==a.display_title,s=!1!==a.display_content,u=d?i(l.title||""):"",v=s?i(l.content||""):"",c=s?i(l.change_history||""):"",f=void 0!==a.display_index&&null!==a.display_index?Number(a.display_index):-1,p=function(n){return(null==n?void 0:n.entity_id)||(null==n?void 0:n.ref_parent_section_node_id)||(null==n?void 0:n.parent_entity_id)||null}(a),_=!(!u.trim()&&!v.trim());return n(n({id:"".concat(e,"::").concat(t.contentId),nodeId:e,contentId:t.contentId,parentContentId:p,title:u,content:v,change_history:c,displayTitle:d,displayContent:s,subsections:[]},_?r:{score:void 0,relation:"not_defined"}),{evaluationResult:o,evaluationResults:o?[o]:[],selfIndex:f,refIndexes:[],refContentIds:[],ref_parent_section_node_id:p})},N=function(n,t){n.refIndexes=Array.from(new Set(e(e([],n.refIndexes||[],!0),t.refIndexes||[],!0))),n.refContentIds=Array.from(new Set(e(e([],n.refContentIds||[],!0),t.refContentIds||[],!0)));var i=new Set((n.subsections||[]).map(function(n){return n.id||n.contentId||n.nodeId}));(t.subsections||[]).forEach(function(t){var o=t.id||t.contentId||t.nodeId;i.has(o)||(n.subsections=e(e([],n.subsections||[],!0),[t],!1),i.add(o))});var o=e(e([],n.evaluationResults||(n.evaluationResult?[n.evaluationResult]:[]),!0),t.evaluationResults||(t.evaluationResult?[t.evaluationResult]:[]),!0).filter(Boolean),r=new Set;return n.evaluationResults=o.filter(function(n){var e=(null==n?void 0:n.nodeId)||JSON.stringify(Object.keys((null==n?void 0:n.deviations)||n||{}));return!r.has(e)&&(r.add(e),!0)}),!n.evaluationResult&&t.evaluationResult&&(n.evaluationResult=t.evaluationResult),!n.cognitiveData&&t.cognitiveData&&(n.cognitiveData=t.cognitiveData),n},S=function(n,e){return n.selfIndex<0&&e.selfIndex>=0?1:n.selfIndex>=0&&e.selfIndex<0?-1:n.selfIndex-e.selfIndex},w=function(e,i){var o,l=R(e);if(!l||!1===l.display_node)return[];if(y&&"1"===i)return[];var d=O(l),s=d.nodeLeftId,u=d.nodeRightId,v=r(l),c=(null===(o=null==t?void 0:t[e])||void 0===o?void 0:o.evaluation_result)||l.evaluation_result||null,f=C(c,s,u),p=f&&"object"==typeof f?n(n({},f),{nodeId:e}):f,_=a(l,i,h,x).map(function(n){return j(e,n,p,v)});if(l.next){var I=Object.values(l.next).flatMap(function(n){return w(n,i)});_.forEach(function(n){var e=I.filter(function(e){return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId});n.subsections=e.length?e:I})}return _};if(f){var k=function(e,i){var o;void 0===i&&(i=0);var l=[],d=[];if(!e)return{refSections:l,baseSections:d};var s={},u={},v=-1,c=-1,f=function(l){var d=e[l],f=R(d);if(!f||!1===f.display_node)return"continue";var p=O(f),_=p.nodeLeftId,I=p.nodeRightId,g=r(f),m=(null===(o=null==t?void 0:t[d])||void 0===o?void 0:o.evaluation_result)||f.evaluation_result||null,b=C(m,_,I),E=b&&"object"==typeof b?n(n({},b),{nodeId:d}):b,S=k(f.next,i+1),w=S.refSections,D=S.baseSections,P=a(f,"0",h,x).map(function(n){var e=j(d,n,E,g);return-1===e.selfIndex&&(e.selfIndex=c--),e}),K=[];if(!y){var V=a(f,"1",h,x);K=V.map(function(n){var e=j(d,n,E,g);return-1===e.selfIndex&&(e.selfIndex=v--),e})}P.forEach(function(n){K.forEach(function(e){var t,i,o,r,a,l,d,s;Number(e.selfIndex)>=0&&Number(n.selfIndex)>=0&&((null===(t=e.refIndexes)||void 0===t?void 0:t.includes(Number(n.selfIndex)))||null===(i=e.refIndexes)||void 0===i||i.push(Number(n.selfIndex)),(null===(o=n.refIndexes)||void 0===o?void 0:o.includes(Number(e.selfIndex)))||null===(r=n.refIndexes)||void 0===r||r.push(Number(e.selfIndex))),n.contentId&&!(null===(a=e.refContentIds)||void 0===a?void 0:a.includes(n.contentId))&&(null===(l=e.refContentIds)||void 0===l||l.push(n.contentId)),e.contentId&&!(null===(d=n.refContentIds)||void 0===d?void 0:d.includes(e.contentId))&&(null===(s=n.refContentIds)||void 0===s||s.push(e.contentId))})}),K.forEach(function(n){var e=w.filter(function(e){var t;return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId||(null===(t=n.refContentIds)||void 0===t?void 0:t.includes(e.parentContentId))});e.length>0&&(n.subsections=e);var t=0===i?String(n.selfIndex):"".concat(n.selfIndex,"_").concat(n.contentId||d);s[t]=s[t]?N(s[t],n):n}),P.forEach(function(n){var e=D.filter(function(e){var t;return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId||(null===(t=n.refContentIds)||void 0===t?void 0:t.includes(e.parentContentId))});e.length>0&&(n.subsections=e);var t=0===i?String(n.selfIndex):"".concat(n.selfIndex,"_").concat(n.contentId||d);u[t]=u[t]?N(u[t],n):n})};for(var p in e)f(p);return l=Object.values(s),d=Object.values(u),l.sort(S),d.sort(S),{refSections:l,baseSections:d}},D=k(m.next),P=D.refSections,K=D.baseSections;y||(v=E(P)),s=K}else m.next&&Object.values(m.next).forEach(function(n){var e=R(n);if(e&&!1!==e.display_node){var t=w(n,"0");if(y)s.push.apply(s,t);else{var i=E(w(n,"1"));p.push.apply(p,u(n,t,i))}}}),y||(s=p.map(function(n){return n.left}),v=p.map(function(n){return n.right}));var V=l(m,"0",h,x),T=l(m,"1",h,x),A={title:V.title||"Uploaded Contract",description:m.decision_scope_description||"",sections:s},L={id:"tree-variant-1",title:y?function(){var n,e;if("string"!=typeof g&&(null==g?void 0:g.learnings_data)&&Object.keys(g.learnings_data).length>0){var t=Object.keys(g.learnings_data)[0];return(null===(n=g.learnings_data[t])||void 0===n?void 0:n.title)||"Rulebook Guidelines"}return"string"!=typeof g&&(null===(e=null==g?void 0:g.data)||void 0===e?void 0:e.artifactTitle)||"Rulebook Guidelines"}():T.title||"Reference Template",similarity:0,sections:v,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:m.decision_scope_description||""},fields:{}}}};return{activeProposed:A,activeVariants:[L],comparisonRows:p,parseError:null}}catch(n){return console.error("Data Transformation Error: ",n),{activeProposed:{},activeVariants:[],comparisonRows:[],parseError:n instanceof Error?n.message:"Unknown Parsing Error"}}},[c,f,b,I,g,y]),C=R.activeProposed,E=R.activeVariants,O=R.comparisonRows,j=R.parseError,N=(null==E?void 0:E[0])||v,S=t(function(){return(null==C?void 0:C.sections)||[]},[null==C?void 0:C.sections]),w=t(function(){return N.sections||[]},[N.sections]),k=S.length>0||w.length>0,D=t(function(){return _.fields.filter(function(n){var e=n.key;return(!k||"description"!==e)&&(d(null==C?void 0:C[e])||d(N[e]))})},[C,N,k,_.fields]),P=t(function(){var n,e,t={},i={},r={},a=0,l=null===(n=null==c?void 0:c.input_index_map)||void 0===n?void 0:n[0],d=null===(e=null==c?void 0:c.input_index_map)||void 0===e?void 0:e[1],u=function(n,e){if(!f){var t="left"===e?S.indexOf(n):w.indexOf(n);return{rootKey:"".concat(e,":").concat(t),parentNum:t+1}}if("left"===e){var i=n.selfIndex,o=void 0!==i&&i>=0?i+1:S.indexOf(n)+1;return{rootKey:"left-root:".concat(n.id),parentNum:o}}var r=n.selfIndex,a=S.find(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(r)});if(a){var l=a.selfIndex,d=void 0!==l&&l>=0?l+1:S.indexOf(a)+1;return{rootKey:"left-root:".concat(a.id),parentNum:d}}var s=void 0!==r&&r>=0?r+1:w.indexOf(n)+1;return{rootKey:"right-orphan-root:".concat(n.id),parentNum:s}},v=function(n,e){if(n&&e)return n.find(function(n){return n.id===e.id||n.nodeId&&n.nodeId===e.nodeId||n.contentId&&n.contentId===e.contentId})||void 0},p=function(n,e,u,c,f,_,I){if(e&&function(n,e,t){var a;((null===(a=null==n?void 0:n.evaluationResults)||void 0===a?void 0:a.length)?n.evaluationResults:(null==n?void 0:n.evaluationResult)?[n.evaluationResult]:[]).forEach(function(a){var u=(null==a?void 0:a.deviations)||{};Object.keys(u).sort().forEach(function(v){var c=u[v];if(c){var f=!o(c[l]),p=!o(c[d]);if(f||p){var _=(null==a?void 0:a.nodeId)||n.nodeId||n.id,I="".concat(_).concat(s).concat(v);void 0===i[I]&&(void 0===r[e]&&(r[e]=1),i[I]={index:r[e]++,rootKey:e,parentNum:t})}}})})}(e,c,f),e&&!_){var g=(null==I?void 0:I.id)||"fallback_parent_".concat(a++);t[g]||(t[g]=[]),t[g].push(e)}((null==e?void 0:e.subsections)||(null==n?void 0:n.subsections)||(null==u?void 0:u.subsections)||[]).forEach(function(t){var i=v(null==n?void 0:n.subsections,t),o=v(null==u?void 0:u.subsections,t);p(t,i,o,c,f,!1,e||I)})};S.forEach(function(n){var e,t=u(n,"left"),i=t.rootKey,o=t.parentNum,r=null;if(f){var a=null===(e=n.refIndexes)||void 0===e?void 0:e[0];r=w.find(function(n){return n.selfIndex===a})}else r=w[S.indexOf(n)];p(n,n,r,i,o,!0,n)}),y||w.forEach(function(n){var e=u(n,"right"),t=e.rootKey,i=e.parentNum;t.startsWith("right-orphan-root:")&&p(n,null,n,t,i,!0,n)});var _=Object.fromEntries(Object.entries(i).map(function(n){return[n[0],n[1].index]})),I=Object.fromEntries(Object.entries(i).map(function(n){return[n[0],n[1].parentNum]}));return{parentDeviationRecord:t,registry:_,deviationParentRegistry:I}},[S,w,f,c,y]),K=P.parentDeviationRecord,V=P.registry,T=P.deviationParentRegistry;return{isGuidelineMode:y,activeProposed:C,activeVariants:E,comparisonRows:O,existingRule:N,proposedSections:S,existingSections:w,visibleFields:D,parentDeviationRecord:K,deviationNumberRegistry:V,deviationParentRegistry:T,parseError:j}};export{c as useCognitiveTreeData};
2
2
  //# sourceMappingURL=useCompareData.js.map
@@ -1,2 +1,2 @@
1
- import{useState as t,useRef as e,useCallback as n,useEffect as i}from"react";import{DEVIATION_BADGE_SEPARATOR as r}from"../CognitiveComparehelpers.js";var c=function(c){var o=c.containerRef,l=c.leftContainerRef,u=c.rightContainerRef;c.svgContainerRef;var a=c.pathRefs,d=c.leftHeaderRef,s=c.rightHeaderRef,v=c.proposedSections,h=c.existingSections,g=c.visibleFields,f=c.leftRefs,p=c.rightRefs,b=c.sectionLeftRefs,y=c.sectionRightRefs,x=c.subSectionLeftRefs,m=c.subSectionRightRefs,R=c.lhsBadgeRefs,C=c.rhsBadgeRefs,A=c.sectionRowRefs,B=c.expandedSections,S=c.expandedSubSections,M=c.connectedSections,I=c.isSideBySide,T=c.activeSideBySideSection,L=c.maintainRelativeOrder,F=c.isGuidelineMode,H=c.cognitiveMap,w=c.getSectionCompareStyle,k=c.getSubSectionCompareStyle,E=c.getDeviationStyleByKey,N=c.isArrowVisible,Y=c.isAnimatingRef,D=c.isSideBySideRef,j=c.sideBySideCacheRef,O=c.sideBySideLineRef,z=c.activeSideBySideSectionRef,P=c.activeSideBySideRightSectionRef,Q=c.connectedLines,X=c.setConnectedLines,q=c.cachedConnectedPositions,G=c.calculateLinesRef,K=c.resizeTimerRef,V=c.scrollLock,J=c.scrollSyncLocked,U=c.handleResizeRef,W=c.activeProposed,Z=c.existingRule,$=c.analysisData,_=c.pendingScrollTargetRef,tt=c.pendingScrollCallbackRef,et=c.resolvedComparisonConfig,nt=c.getFieldData,it=t([]),rt=it[0],ct=it[1],ot=t(null),lt=ot[0],ut=ot[1],at=t([]),dt=at[0],st=at[1],vt=null!=Q?Q:dt,ht=null!=X?X:st,gt=t({width:0,height:0}),ft=gt[0],pt=gt[1],bt=e(!1),yt=e(!1),xt=e(!1),mt=e(null),Rt=e([]),Ct=null!=q?q:Rt,At=function(t,e,n,i,r,c,o){if(Math.abs(i-e)<=1)return c&&o?"M ".concat(t,",").concat(e," L ").concat(n,",").concat(i):c&&!o?"M ".concat(t,",").concat(e," L ").concat(r,",").concat(e):!c&&o?"M ".concat(r,",").concat(e," L ").concat(n,",").concat(i):"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i);var l=Math.min(15,Math.abs(r-t),Math.abs(i-e)/2),u=Math.min(15,Math.abs(n-r),Math.abs(i-e)/2),a=i>e?l:-l,d=i>e?u:-u,s=n>r?u:-u;return c&&o?"M ".concat(t,",").concat(e," L ").concat(r-l,",").concat(e," Q ").concat(r,",").concat(e," ").concat(r,",").concat(e+a," L ").concat(r,",").concat(i-d," Q ").concat(r,",").concat(i," ").concat(r+s,",").concat(i," L ").concat(n,",").concat(i):c&&!o?"M ".concat(t,",").concat(e," L ").concat(r-l,",").concat(e," Q ").concat(r,",").concat(e," ").concat(r,",").concat(e+a," L ").concat(r,",").concat(i):!c&&o?"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i-d," Q ").concat(r,",").concat(i," ").concat(r+s,",").concat(i," L ").concat(n,",").concat(i):"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i)},Bt=n(function(){var t,e,n,i,c,a,A,N,D,j,O,z,P,Q,X,q,G,K;if(!bt.current&&!Y.current){bt.current=!0;try{if(!o.current)return;var V=function(t){var e=t.split("-"),n=e[0];if(!B[n]&&!1===L)return!1;if(L&&!B["left-".concat(n)]&&!B["right-".concat(n)]&&!B[n])return!1;for(var i=n,r=1;r<e.length-1;r++)if(i+="-".concat(e[r]),!S[i])return!1;return!0},J=o.current.getBoundingClientRect();pt({width:J.width,height:J.height});var U=[];if(g.forEach(function(t){var e,n,i=t.key,r=null===(e=f.current[i])||void 0===e?void 0:e.current,c=null===(n=p.current[i])||void 0===n?void 0:n.current;r&&c&&(r.style.height="auto",c.style.height="auto",r.style.minHeight="0px",c.style.minHeight="0px")}),!Y.current){for(var W=0;W<Math.max(v.length,h.length);W++){var Z=null===(t=b.current[W])||void 0===t?void 0:t.current,$=null===(e=y.current[W])||void 0===e?void 0:e.current;Z&&(Z.style.height="auto",Z.style.minHeight="0px"),$&&($.style.height="auto",$.style.minHeight="0px")}L||Object.keys(x.current).forEach(function(t){var e,n;if(V(t)){var i=null===(e=x.current[t])||void 0===e?void 0:e.current,r=null===(n=m.current[t])||void 0===n?void 0:n.current;i&&r&&(i.style.height="auto",r.style.height="auto",i.style.minHeight="0px",r.style.minHeight="0px")}})}var _={};g.forEach(function(t){var e,n,i=t.key,r=null===(e=f.current[i])||void 0===e?void 0:e.current,c=null===(n=p.current[i])||void 0===n?void 0:n.current;if(r&&c){var o=r.getBoundingClientRect(),l=c.getBoundingClientRect();_[i]=Math.max(o.height,l.height)}});var tt={left:{},right:{}},et={};if(!Y.current)if(L){if(I&&null!==T)if("number"==typeof T){var nt=T,it=v[nt],rt=null===(c=b.current[nt])||void 0===c?void 0:c.current;rt&&it&&(it.refIndexes||[]).forEach(function(t){var e,n=h.findIndex(function(e){return e.selfIndex===t}),i=null===(e=y.current[n])||void 0===e?void 0:e.current;if(i&&(B["left-".concat(nt)]||B["right-".concat(n)])){var r=Math.max(rt.getBoundingClientRect().height,i.getBoundingClientRect().height);tt.left[nt]=Math.max(tt.left[nt]||0,r),tt.right[n]=Math.max(tt.right[n]||0,r)}})}else{var ot=T.split(r)[2];if(ot){Z=null===(a=x.current[ot])||void 0===a?void 0:a.current,$=null===(A=m.current[ot])||void 0===A?void 0:A.current;if(Z&&$){lt=Math.max(Z.getBoundingClientRect().height,$.getBoundingClientRect().height);et[ot]=Math.max(et[ot]||0,lt)}}}}else{Object.keys(x.current).forEach(function(t){var e,n;if(V(t)){var i=null===(e=x.current[t])||void 0===e?void 0:e.current,r=null===(n=m.current[t])||void 0===n?void 0:n.current;if(i&&r&&null!==i.offsetParent&&null!==r.offsetParent){var c=i.getBoundingClientRect(),o=r.getBoundingClientRect(),l=Math.max(c.height,o.height);et[t]=l,i.style.minHeight="".concat(l,"px"),r.style.minHeight="".concat(l,"px")}}});for(W=0;W<Math.min(v.length,h.length);W++){var Z=null===(n=b.current[W])||void 0===n?void 0:n.current,$=null===(i=y.current[W])||void 0===i?void 0:i.current;if(Z&&$){var lt=Math.max(Z.getBoundingClientRect().height,$.getBoundingClientRect().height);tt.left[W]=lt,tt.right[W]=lt}}}if(g.forEach(function(t){var e,n,i=t.key,r=null===(e=f.current[i])||void 0===e?void 0:e.current,c=null===(n=p.current[i])||void 0===n?void 0:n.current;if(r&&c){var o=_[i];r.style.minHeight="".concat(o,"px"),c.style.minHeight="".concat(o,"px")}}),Y.current||(Object.entries(tt.left).forEach(function(t){var e,n=t[0],i=t[1],r=null===(e=b.current[Number(n)])||void 0===e?void 0:e.current;r&&(r.style.minHeight="".concat(i,"px"))}),Object.entries(tt.right).forEach(function(t){var e,n=t[0],i=t[1],r=null===(e=y.current[Number(n)])||void 0===e?void 0:e.current;r&&(r.style.minHeight="".concat(i,"px"))}),L||Object.keys(et).forEach(function(t){var e,n,i=null===(e=x.current[t])||void 0===e?void 0:e.current,r=null===(n=m.current[t])||void 0===n?void 0:n.current;if(i&&r&&et[t]){var c=et[t];i.style.minHeight="".concat(c,"px"),r.style.minHeight="".concat(c,"px")}})),!F){v.forEach(function(t,e){var n,i=t.continuationSourceRowId?v.findIndex(function(e){return e.comparisonRowId===t.continuationSourceRowId}):-1,r=i>=0?i:e,c=null===(n=b.current[r])||void 0===n?void 0:n.current;if(c){var o=function(t,e){if(!L)return h[e]?[e]:[];var n=(t.refIndexes||[]).map(function(t){return h.findIndex(function(e){return e.selfIndex===t})}).filter(function(t){return-1!==t});return!n.length&&h[e]?[e]:Array.from(new Set(n))}(t,e);o.forEach(function(t){var n,o,a,d,s,g,f,p,b,x,m,R,C=null===(n=y.current[t])||void 0===n?void 0:n.current;if(C){var A=c.getBoundingClientRect(),B=C.getBoundingClientRect(),S=A.right-J.left,M=B.left-J.left,F=A.top+18-J.top,k=B.top+18-J.top;if(L&&I&&T===e){var E=null!==(a=null===(o=l.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==a?a:0,N=null!==(s=null===(d=u.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==s?s:0,Y=E+(null!==(f=null===(g=l.current)||void 0===g?void 0:g.clientHeight)&&void 0!==f?f:1/0),D=N+(null!==(b=null===(p=u.current)||void 0===p?void 0:p.clientHeight)&&void 0!==b?b:1/0),j=function(t,e,n){return Math.max(e,Math.min(n,t))};F=j(A.top+18,E,Y)-J.top,k=j(B.top+18,N,D)-J.top}var O=w(r);O&&U.push({id:"line-".concat(r,"-").concat(t),x1:S,y1:F,x2:M,y2:k,style:O,sectionIdx:r,targetRightIdx:t,isSubSection:!1,isMappingContinuation:i>=0,hasCognitive:!!((null===(x=v[r])||void 0===x?void 0:x.cognitiveData)||(null===(m=h[t])||void 0===m?void 0:m.cognitiveData)||(null===(R=v[r])||void 0===R?void 0:R.nodeId)&&H[v[r].nodeId])})}})}})}if(!F&&I&&"string"==typeof T&&T.includes(r)){var at=T.split(r),dt=at[0],st=at[1],vt=at[2],gt=(at[3],"".concat(dt).concat(r).concat(st)),ft=null===(N=R.current[gt])||void 0===N?void 0:N.current,yt=null===(D=C.current[gt])||void 0===D?void 0:D.current;if(ft&&yt){var xt=ft.getBoundingClientRect(),mt=yt.getBoundingClientRect(),Rt=xt.right-J.left,Bt=mt.left-J.left,Mt=xt.top+xt.height/2-J.top,It=mt.top+mt.height/2-J.top;if(L){var Tt=null!==(O=null===(j=l.current)||void 0===j?void 0:j.getBoundingClientRect().top)&&void 0!==O?O:0,Lt=null!==(P=null===(z=u.current)||void 0===z?void 0:z.getBoundingClientRect().top)&&void 0!==P?P:0,Ft=Tt+(null!==(X=null===(Q=l.current)||void 0===Q?void 0:Q.clientHeight)&&void 0!==X?X:1/0),Ht=Lt+(null!==(G=null===(q=u.current)||void 0===q?void 0:q.clientHeight)&&void 0!==G?G:1/0),wt=function(t,e,n){return Math.max(e,Math.min(n,t))};Mt=wt(xt.top+xt.height/2,Tt,Ft)-J.top,It=wt(mt.top+mt.height/2,Lt,Ht)-J.top}var kt=null!==(K=E(dt,st))&&void 0!==K?K:k(vt);kt&&U.push({id:"line-subsec-".concat(gt),x1:Rt,y1:Mt,x2:Bt,y2:It,style:kt,sectionIdx:Number(vt.split("-")[0]),isSubSection:!0,subSectionKeyPath:T})}}if(ct(U),d.current&&s.current){var Et=d.current.getBoundingClientRect(),Nt=s.current.getBoundingClientRect(),Yt=(Et.top+Et.height/2-J.top+Nt.top+Nt.height/2-J.top)/2;ut({x1:Et.right-J.left,x2:Nt.left-J.left,y:Yt})}else ut(null);if(M.size>0){var Dt=[],jt=l.current,Ot=u.current;if(jt&&Ot){var zt=[],Pt=jt.getBoundingClientRect().top,Qt=Ot.getBoundingClientRect().top,Xt=Pt+jt.clientHeight,qt=Qt+Ot.clientHeight,Gt=jt.scrollTop,Kt=Ot.scrollTop,Vt=J.top,Jt=function(t,e,n){return Math.max(e,Math.min(n,t))};M.forEach(function(t){var e,n,i,c,o,l,u,a,d;if(F){var s=null,g=null,f=null;if("string"==typeof t&&t.includes(r)){var p=t.split(r),b=p[0],y=p[1],x=p[2],m="".concat(b).concat(r).concat(y);s=null===(e=R.current[m])||void 0===e?void 0:e.current,f=null!==(n=E(b,y))&&void 0!==n?n:k(x),g=Number((null==x?void 0:x.split("-")[0])||0)}else g=Number(t),s=null===(i=R.current[g])||void 0===i?void 0:i.current,f=w(g);if(!s)return;var A=document.querySelectorAll('[id^="guideline-target-"]');A.forEach(function(e,n){var i=s.getBoundingClientRect(),c=e.getBoundingClientRect(),o=i.right-J.left,l=c.left-J.left-0,u=o+75,a=i.top+i.height/2,d=c.top+c.height/2,v=a-Pt+Gt,h=d-Qt+Kt,g="conn-guide-".concat(t,"-").concat(n),p="";"string"==typeof t&&t.includes(r)?p=(t.split(r)[2]||"").split("-").map(function(t){return Number(t)+1}).join("."):p=String(Number(t)+1);var b=String.fromCharCode(97+n),y=1===A.length?null:"".concat(p,"(").concat(b,")");zt.push({lhsScrollY:v,rhsScrollY:h,x1:o,x2:l,containerTop:Vt,leftIdx:t,rhsArrayIdx:n,styleColor:(null==f?void 0:f.badgeBorder)||"#6366F1",styleBg:(null==f?void 0:f.badgeBg)||"#FFFFFF",styleText:(null==f?void 0:f.badgeText)||"#A16207",styleId:g,centerX:u});var x=Jt(a,Pt,Xt),m=Jt(d,Qt,qt),R=x-Vt,C=m-Vt,B=At(o,R,l,C,u,a>=Pt-4&&a<=Xt+4,d>=Qt-4&&d<=qt+4);Dt.push({id:g,pathD:B,style:f,leftIdx:t,rhsArrayIdx:n,x1:o,x2:l,y1:R,y2:C,centerX:u,matchLabel:y,isGuideline:!0})})}else if("string"==typeof t&&t.includes(r)){var B=t.split(r),S=(b=B[0],y=B[1],x=B[2],B[3],m="".concat(b).concat(r).concat(y),null===(c=R.current[m])||void 0===c?void 0:c.current),M=null===(o=C.current[m])||void 0===o?void 0:o.current;if(!S||!M)return;var I=S.getBoundingClientRect(),T=M.getBoundingClientRect(),H=null!==(l=E(b,y))&&void 0!==l?l:k(x),N=I.right-J.left,Y=T.left-J.left-0,D=N+75,j=I.top+I.height/2,O=T.top+T.height/2,z=j-Pt+Gt,P=O-Qt+Kt,Q="conn-subsec-".concat(m),X=((x||"").split("-").map(function(t){return Number(t)+1}).join("."),null);zt.push({lhsScrollY:z,rhsScrollY:P,x1:N,x2:Y,containerTop:Vt,leftIdx:t,rhsArrayIdx:t,styleColor:(null==H?void 0:H.badgeBorder)||"#6366F1",styleBg:(null==H?void 0:H.badgeBg)||"#FFFFFF",styleText:(null==H?void 0:H.badgeText)||"#A16207",styleId:Q,centerX:D});var q=Jt(j,Pt,Xt),G=Jt(O,Qt,qt),K=At(N,$=q-Vt,Y,_=G-Vt,D,j>=Pt-4&&j<=Xt+4,O>=Qt-4&&O<=qt+4);Dt.push({id:Q,pathD:K,style:H,leftIdx:t,rhsArrayIdx:t,x1:N,x2:Y,y1:$,y2:_,matchLabel:X})}else if(L){var V=t,U=v[V];if(!(null===(d=null==U?void 0:U.refIndexes)||void 0===d?void 0:d.length))return;U.refIndexes.forEach(function(e,n){var i,r,c=h.findIndex(function(t){return t.selfIndex===e});if(-1!==c){var o=null===(i=R.current[V])||void 0===i?void 0:i.current,l=null===(r=C.current[c])||void 0===r?void 0:r.current;if(o&&l){var u=o.getBoundingClientRect(),a=l.getBoundingClientRect(),d=w(V),s=u.right-J.left,v=a.left-J.left-0,g=s+75,f=u.top+u.height/2,p=a.top+a.height/2,b=f-Pt+Gt,y=p-Qt+Kt,x="conn-".concat(V,"-").concat(c),m=String(Number(t)+1),A=String.fromCharCode(97+n),B=1===U.refIndexes.length?null:"".concat(m,"(").concat(A,")");zt.push({lhsScrollY:b,rhsScrollY:y,x1:s,x2:v,containerTop:Vt,leftIdx:V,rhsArrayIdx:c,styleColor:(null==d?void 0:d.badgeBorder)||"#6366F1",styleBg:(null==d?void 0:d.badgeBg)||"#FFFFFF",styleText:(null==d?void 0:d.badgeText)||"#A16207",styleId:x,centerX:g});var S=Jt(f,Pt,Xt),M=Jt(p,Qt,qt),I=S-Vt,T=M-Vt,L=At(s,I,v,T,g,f>=Pt-4&&f<=Xt+4,p>=Qt-4&&p<=qt+4);Dt.push({id:x,pathD:L,style:d,leftIdx:V,rhsArrayIdx:c,x1:s,x2:v,y1:I,y2:T,matchLabel:B})}}})}else{var W=t,Z=W;S=null===(u=R.current[W])||void 0===u?void 0:u.current,M=null===(a=C.current[Z])||void 0===a?void 0:a.current;if(!S||!M)return;I=S.getBoundingClientRect(),T=M.getBoundingClientRect(),H=w(W),N=I.right-J.left,Y=T.left-J.left-0,D=N+75,j=I.top+I.height/2,O=T.top+T.height/2,z=j-Pt+Gt,P=O-Qt+Kt,Q="conn-".concat(W,"-").concat(Z),String(Number(t)+1),X=null;zt.push({lhsScrollY:z,rhsScrollY:P,x1:N,x2:Y,containerTop:Vt,leftIdx:W,rhsArrayIdx:Z,styleColor:(null==H?void 0:H.badgeBorder)||"#6366F1",styleBg:(null==H?void 0:H.badgeBg)||"#FFFFFF",styleText:(null==H?void 0:H.badgeText)||"#A16207",styleId:Q,centerX:D});var $,_;q=Jt(j,Pt,Xt),G=Jt(O,Qt,qt),K=At(N,$=q-Vt,Y,_=G-Vt,D,j>=Pt-4&&j<=Xt+4,O>=Qt-4&&O<=qt+4);Dt.push({id:Q,pathD:K,style:H,leftIdx:W,rhsArrayIdx:Z,x1:N,x2:Y,y1:$,y2:_,matchLabel:X})}}),Ct.current=zt}ht(Dt),setTimeout(function(){return St()},10)}else ht([]),Ct.current=[],setTimeout(function(){return St()},10)}catch(t){console.error("Line render safe fail: ",t)}finally{bt.current=!1}}},[g,v,h,H,et,nt,w,E,L,I,T,M,B,S,F]),St=n(function(){var t,e,n,i,r,c,d,s,v,h,g,f,p,b,y,x,m,R,C,A=Ct.current;if(!A.length)return null===(t=a.current["guideline-up-stroke"])||void 0===t||t.setAttribute("visibility","hidden"),null===(e=a.current["guideline-up-badge"])||void 0===e||e.setAttribute("visibility","hidden"),null===(n=a.current["guideline-down-stroke"])||void 0===n||n.setAttribute("visibility","hidden"),void(null===(i=a.current["guideline-down-badge"])||void 0===i||i.setAttribute("visibility","hidden"));if(!Y.current){var B=null!==(c=null===(r=l.current)||void 0===r?void 0:r.scrollTop)&&void 0!==c?c:0,S=null!==(s=null===(d=u.current)||void 0===d?void 0:d.scrollTop)&&void 0!==s?s:0,M=null!==(h=null===(v=l.current)||void 0===v?void 0:v.clientHeight)&&void 0!==h?h:1/0,I=null!==(f=null===(g=u.current)||void 0===g?void 0:g.clientHeight)&&void 0!==f?f:1/0,T=null!==(b=null===(p=l.current)||void 0===p?void 0:p.getBoundingClientRect().top)&&void 0!==b?b:0,L=null!==(x=null===(y=u.current)||void 0===y?void 0:y.getBoundingClientRect().top)&&void 0!==x?x:0,F=T+M,H=L+I,w=null===(m=o.current)||void 0===m?void 0:m.getBoundingClientRect(),k=null!==(R=null==w?void 0:w.top)&&void 0!==R?R:0,E=null!==(C=null==w?void 0:w.height)&&void 0!==C?C:1/0,N=function(t,e,n){return Math.max(e,Math.min(n,t))},D=0,j=0,O=0,z=0,P="#6366F1",Q="#A16207",X=!1,q=0;if(A.forEach(function(t){var e=t.lhsScrollY-B+T,n=t.rhsScrollY-S+L,i=a.current[t.styleId+"-stroke"],r=a.current[t.styleId+"-bg"],c=a.current[t.styleId+"-btn"],o=a.current[t.styleId+"-number"];if(i||r){var l=N(e,T,F),u=N(n,L,H),d=l-k,s=u-k,v=e>=T-4&&e<=F+4,h=n>=L-4&&n<=H+4,g=!0;X=!0;var f=t.centerX||t.x1+75;0===O&&(O=t.x1,z=d,q=f,P=t.styleColor,t.styleBg,Q=t.styleText||"#A16207"),n<L-4?(D++,g=!1):n>H+4&&(j++,g=!1);var p=At(t.x1,d,t.x2,s,q,v,h);i&&(g&&p?(i.setAttribute("visibility","visible"),i.setAttribute("d",p)):i.setAttribute("visibility","hidden")),r&&(g&&p?(r.setAttribute("visibility","visible"),r.setAttribute("d",p)):r.setAttribute("visibility","hidden")),c&&(v&&g?(c.setAttribute("visibility","visible"),c.setAttribute("y",String(d-12))):c.setAttribute("visibility","hidden")),o&&(v&&g?(o.setAttribute("visibility","visible"),o.setAttribute("transform","translate(".concat(t.x2-42,", ").concat(s,")"))):o.setAttribute("visibility","hidden"))}}),X&&q>0){var G=a.current["guideline-up-stroke"],K=a.current["guideline-up-badge"],V=a.current["guideline-up-arrow"],J=a.current["guideline-up-text"],U=a.current["guideline-up-badge-rect"];if(D>0){var W=Math.max(15,L-k+15),Z=Math.min(15,Math.abs(q-O),Math.max(0,z-W)),$="M ".concat(O,",").concat(z," L ").concat(q-Z,",").concat(z," Q ").concat(q,",").concat(z," ").concat(q,",").concat(z-Z," L ").concat(q,",").concat(W);null==G||G.setAttribute("visibility","visible"),null==G||G.setAttribute("d",$),null==G||G.setAttribute("stroke",P),null==K||K.setAttribute("visibility","visible"),null==K||K.setAttribute("transform","translate(".concat(q,", ").concat(W,")")),V&&V.setAttribute("fill",P),J&&(J.textContent="+".concat(D),J.setAttribute("fill",Q)),U&&U.setAttribute("stroke",P)}else null==G||G.setAttribute("visibility","hidden"),null==K||K.setAttribute("visibility","hidden");var _=a.current["guideline-down-stroke"],tt=a.current["guideline-down-badge"],et=a.current["guideline-down-arrow"],nt=a.current["guideline-down-text"],it=a.current["guideline-down-badge-rect"];if(j>0){var rt=Math.min(E-15,H-k-15);Z=Math.min(15,Math.abs(q-O),Math.max(0,rt-z)),$="M ".concat(O,",").concat(z," L ").concat(q-Z,",").concat(z," Q ").concat(q,",").concat(z," ").concat(q,",").concat(z+Z," L ").concat(q,",").concat(rt);null==_||_.setAttribute("visibility","visible"),null==_||_.setAttribute("d",$),null==_||_.setAttribute("stroke",P),null==tt||tt.setAttribute("visibility","visible"),null==tt||tt.setAttribute("transform","translate(".concat(q,", ").concat(rt,")")),et&&et.setAttribute("fill",P),nt&&(nt.textContent="+".concat(j),nt.setAttribute("fill",Q)),it&&it.setAttribute("stroke",P)}else null==_||_.setAttribute("visibility","hidden"),null==tt||tt.setAttribute("visibility","hidden")}}},[]),Mt=n(function(){Ct.current.length>0&&!Y.current||(null!==mt.current&&clearTimeout(mt.current),mt.current=setTimeout(function(){G.current(),mt.current=null},50))},[]),It=n(function(t){if(null!==_.current&&tt.current&&Math.abs(t.currentTarget.scrollTop-_.current)<=2){var e=tt.current;_.current=null,tt.current=null,e()}if(!xt.current&&!V.current){if(L&&J&&(D.current||M.size>0)){var n=t.currentTarget,i=l.current,c=u.current,a=n===i?c:n===c?i:null;if(n&&a){var d=function(){var t,e,n,i,c,o,l,u,a,d,s,v=z.current,h=P.current;if(null===v)return{leftAnchor:null,rightAnchor:null};if("string"==typeof v&&v.includes(r)){var g=v.split(r),f="".concat(g[0]).concat(r).concat(g[1]);return{leftAnchor:(null===(t=R.current[f])||void 0===t?void 0:t.current)||(null===(e=x.current[g[2]])||void 0===e?void 0:e.current)||(null===(n=b.current[Number(g[2])])||void 0===n?void 0:n.current)||null,rightAnchor:(null===(i=C.current[f])||void 0===i?void 0:i.current)||(null===(c=m.current[g[3]])||void 0===c?void 0:c.current)||(null===(o=y.current[Number(g[3])])||void 0===o?void 0:o.current)||null}}var p=Number(v),B=null!==h?Number(h):p;return{leftAnchor:(null===(l=R.current[p])||void 0===l?void 0:l.current)||(null===(u=A.current[p])||void 0===u?void 0:u.current)||(null===(a=b.current[p])||void 0===a?void 0:a.current)||null,rightAnchor:(null===(d=C.current[B])||void 0===d?void 0:d.current)||(null===(s=y.current[B])||void 0===s?void 0:s.current)||null}}(),s=d.leftAnchor,v=d.rightAnchor,h=n===i?s:v,g=n===i?v:s,f=null;if(h&&g){var p=h.getBoundingClientRect(),B=g.getBoundingClientRect(),S=a.getBoundingClientRect(),I=p.top+p.height/2;f=B.top-S.top+a.scrollTop+B.height/2-(I-S.top)}else{var T=Math.max(0,n.scrollHeight-n.clientHeight),F=Math.max(0,a.scrollHeight-a.clientHeight);f=T>0?n.scrollTop/T*F:n.scrollTop}var H=Math.max(0,a.scrollHeight-a.clientHeight);f=Math.max(0,Math.min(f,H)),Math.abs(a.scrollTop-f)>1&&(xt.current=!0,a.scrollTop=f,requestAnimationFrame(function(){xt.current=!1}))}}L||Mt(),yt.current||(yt.current=!0,requestAnimationFrame(function(){var t,e,n,i,c,a,d;if(D.current){var s=l.current,v=u.current;if(s&&v&&O.current){if(!j.current){var h=z.current,g=void 0;if("string"==typeof h&&h.includes(r)){var f=h.split(r),p="".concat(f[0]).concat(r).concat(f[1]);g=null===(t=R.current[p])||void 0===t?void 0:t.current}else g=null===(e=R.current[h])||void 0===e?void 0:e.current;if(g){var b=g.getBoundingClientRect();j.current={badgeScreenY:b.top+b.height/2,initialScrollTop:s.scrollTop,leftTop:s.getBoundingClientRect().top,leftBottom:s.getBoundingClientRect().top+s.clientHeight,cTop:null!==(i=null===(n=o.current)||void 0===n?void 0:n.getBoundingClientRect().top)&&void 0!==i?i:0}}}if(j.current){var y=j.current,x=s.scrollTop-y.initialScrollTop,m=y.badgeScreenY-x,C=((c=m,a=y.leftTop,d=y.leftBottom,Math.max(a,Math.min(d,c)))-y.cTop).toString(),A=m>=y.leftTop-4&&m<=y.leftBottom+4;O.current.setAttribute("y1",C),O.current.setAttribute("y2",C),O.current.setAttribute("visibility",A?"visible":"hidden")}}}St(),yt.current=!1}))}},[St,L,J,M,Mt]);return i(function(){G.current=Bt},[Bt]),i(function(){var t=setTimeout(Mt,250),e=function(){return U.current()};return window.addEventListener("resize",e),function(){clearTimeout(t),null!==mt.current&&clearTimeout(mt.current),null!==K.current&&clearTimeout(K.current),window.removeEventListener("resize",e)}},[W,Z,$,g,B,S,v,h,et,Mt,I,T,N,M]),{lines:rt,setLines:ct,overallConnector:lt,setOverallConnector:ut,connectedLines:vt,setConnectedLines:ht,svgDimensions:ft,cachedConnectedPositions:Ct,calculateLines:Bt,calculateLinesRef:G,calculateLinesDebounced:Mt,handleColumnScroll:It}};export{c as useLinesCalculator};
1
+ import{useState as t,useRef as e,useCallback as n,useEffect as i}from"react";import{DEVIATION_BADGE_SEPARATOR as r}from"../CognitiveComparehelpers.js";import{getVisibleGuidelineTargets as c}from"../Guidelines/utils/guidelineTargets.js";var o=function(o){var l=o.containerRef,u=o.leftContainerRef,a=o.rightContainerRef;o.svgContainerRef;var d=o.pathRefs,s=o.leftHeaderRef,v=o.rightHeaderRef,h=o.proposedSections,g=o.existingSections,f=o.visibleFields,p=o.leftRefs,b=o.rightRefs,y=o.sectionLeftRefs,x=o.sectionRightRefs,m=o.subSectionLeftRefs,R=o.subSectionRightRefs,C=o.lhsBadgeRefs,B=o.rhsBadgeRefs,A=o.sectionRowRefs,S=o.expandedSections,M=o.expandedSubSections,T=o.connectedSections,I=o.isSideBySide,L=o.activeSideBySideSection,F=o.maintainRelativeOrder,H=o.isGuidelineMode,w=o.cognitiveMap,k=o.getSectionCompareStyle,E=o.getSubSectionCompareStyle,N=o.getDeviationStyleByKey,Y=o.isArrowVisible,D=o.isAnimatingRef,j=o.isSideBySideRef,O=o.sideBySideCacheRef,z=o.sideBySideLineRef,P=o.activeSideBySideSectionRef,Q=o.activeSideBySideRightSectionRef,X=o.connectedLines,G=o.setConnectedLines,q=o.cachedConnectedPositions,K=o.calculateLinesRef,V=o.resizeTimerRef,J=o.scrollLock,U=o.scrollSyncLocked,W=o.handleResizeRef,Z=o.activeProposed,$=o.existingRule,_=o.analysisData,tt=o.pendingScrollTargetRef,et=o.pendingScrollCallbackRef,nt=o.resolvedComparisonConfig,it=o.getFieldData,rt=t([]),ct=rt[0],ot=rt[1],lt=t(null),ut=lt[0],at=lt[1],dt=t([]),st=dt[0],vt=dt[1],ht=null!=X?X:st,gt=null!=G?G:vt,ft=t({width:0,height:0}),pt=ft[0],bt=ft[1],yt=e(!1),xt=e(!1),mt=e(!1),Rt=e(null),Ct=e([]),Bt=null!=q?q:Ct,At=function(t,e,n,i,r,c,o){if(Math.abs(i-e)<=1)return c&&o?"M ".concat(t,",").concat(e," L ").concat(n,",").concat(i):c&&!o?"M ".concat(t,",").concat(e," L ").concat(r,",").concat(e):!c&&o?"M ".concat(r,",").concat(e," L ").concat(n,",").concat(i):"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i);var l=Math.min(15,Math.abs(r-t),Math.abs(i-e)/2),u=Math.min(15,Math.abs(n-r),Math.abs(i-e)/2),a=i>e?l:-l,d=i>e?u:-u,s=n>r?u:-u;return c&&o?"M ".concat(t,",").concat(e," L ").concat(r-l,",").concat(e," Q ").concat(r,",").concat(e," ").concat(r,",").concat(e+a," L ").concat(r,",").concat(i-d," Q ").concat(r,",").concat(i," ").concat(r+s,",").concat(i," L ").concat(n,",").concat(i):c&&!o?"M ".concat(t,",").concat(e," L ").concat(r-l,",").concat(e," Q ").concat(r,",").concat(e," ").concat(r,",").concat(e+a," L ").concat(r,",").concat(i):!c&&o?"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i-d," Q ").concat(r,",").concat(i," ").concat(r+s,",").concat(i," L ").concat(n,",").concat(i):"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i)},St=n(function(){var t,e,n,i,o,d,A,Y,j,O,z,P,Q,X,G,q,K,V;if(!yt.current&&!D.current){yt.current=!0;try{if(!l.current)return;var J=function(t){var e=t.split("-"),n=e[0];if(!S[n]&&!1===F)return!1;if(F&&!S["left-".concat(n)]&&!S["right-".concat(n)]&&!S[n])return!1;for(var i=n,r=1;r<e.length-1;r++)if(i+="-".concat(e[r]),!M[i])return!1;return!0},U=l.current.getBoundingClientRect();bt({width:U.width,height:U.height});var W=[];if(f.forEach(function(t){var e,n,i=t.key,r=null===(e=p.current[i])||void 0===e?void 0:e.current,c=null===(n=b.current[i])||void 0===n?void 0:n.current;r&&c&&(r.style.height="auto",c.style.height="auto",r.style.minHeight="0px",c.style.minHeight="0px")}),!D.current){for(var Z=0;Z<Math.max(h.length,g.length);Z++){var $=null===(t=y.current[Z])||void 0===t?void 0:t.current,_=null===(e=x.current[Z])||void 0===e?void 0:e.current;$&&($.style.height="auto",$.style.minHeight="0px"),_&&(_.style.height="auto",_.style.minHeight="0px")}F||Object.keys(m.current).forEach(function(t){var e,n;if(J(t)){var i=null===(e=m.current[t])||void 0===e?void 0:e.current,r=null===(n=R.current[t])||void 0===n?void 0:n.current;i&&r&&(i.style.height="auto",r.style.height="auto",i.style.minHeight="0px",r.style.minHeight="0px")}})}var tt={};f.forEach(function(t){var e,n,i=t.key,r=null===(e=p.current[i])||void 0===e?void 0:e.current,c=null===(n=b.current[i])||void 0===n?void 0:n.current;if(r&&c){var o=r.getBoundingClientRect(),l=c.getBoundingClientRect();tt[i]=Math.max(o.height,l.height)}});var et={left:{},right:{}},nt={};if(!D.current)if(F){if(I&&null!==L)if("number"==typeof L){var it=L,rt=h[it],ct=null===(o=y.current[it])||void 0===o?void 0:o.current;ct&&rt&&(rt.refIndexes||[]).forEach(function(t){var e,n=g.findIndex(function(e){return e.selfIndex===t}),i=null===(e=x.current[n])||void 0===e?void 0:e.current;if(i&&(S["left-".concat(it)]||S["right-".concat(n)])){var r=Math.max(ct.getBoundingClientRect().height,i.getBoundingClientRect().height);et.left[it]=Math.max(et.left[it]||0,r),et.right[n]=Math.max(et.right[n]||0,r)}})}else{var lt=L.split(r)[2];if(lt){$=null===(d=m.current[lt])||void 0===d?void 0:d.current,_=null===(A=R.current[lt])||void 0===A?void 0:A.current;if($&&_){ut=Math.max($.getBoundingClientRect().height,_.getBoundingClientRect().height);nt[lt]=Math.max(nt[lt]||0,ut)}}}}else{Object.keys(m.current).forEach(function(t){var e,n;if(J(t)){var i=null===(e=m.current[t])||void 0===e?void 0:e.current,r=null===(n=R.current[t])||void 0===n?void 0:n.current;if(i&&r&&null!==i.offsetParent&&null!==r.offsetParent){var c=i.getBoundingClientRect(),o=r.getBoundingClientRect(),l=Math.max(c.height,o.height);nt[t]=l,i.style.minHeight="".concat(l,"px"),r.style.minHeight="".concat(l,"px")}}});for(Z=0;Z<Math.min(h.length,g.length);Z++){var $=null===(n=y.current[Z])||void 0===n?void 0:n.current,_=null===(i=x.current[Z])||void 0===i?void 0:i.current;if($&&_){var ut=Math.max($.getBoundingClientRect().height,_.getBoundingClientRect().height);et.left[Z]=ut,et.right[Z]=ut}}}if(f.forEach(function(t){var e,n,i=t.key,r=null===(e=p.current[i])||void 0===e?void 0:e.current,c=null===(n=b.current[i])||void 0===n?void 0:n.current;if(r&&c){var o=tt[i];r.style.minHeight="".concat(o,"px"),c.style.minHeight="".concat(o,"px")}}),D.current||(Object.entries(et.left).forEach(function(t){var e,n=t[0],i=t[1],r=null===(e=y.current[Number(n)])||void 0===e?void 0:e.current;r&&(r.style.minHeight="".concat(i,"px"))}),Object.entries(et.right).forEach(function(t){var e,n=t[0],i=t[1],r=null===(e=x.current[Number(n)])||void 0===e?void 0:e.current;r&&(r.style.minHeight="".concat(i,"px"))}),F||Object.keys(nt).forEach(function(t){var e,n,i=null===(e=m.current[t])||void 0===e?void 0:e.current,r=null===(n=R.current[t])||void 0===n?void 0:n.current;if(i&&r&&nt[t]){var c=nt[t];i.style.minHeight="".concat(c,"px"),r.style.minHeight="".concat(c,"px")}})),!H){h.forEach(function(t,e){var n,i=t.continuationSourceRowId?h.findIndex(function(e){return e.comparisonRowId===t.continuationSourceRowId}):-1,r=i>=0?i:e,c=null===(n=y.current[r])||void 0===n?void 0:n.current;if(c){var o=function(t,e){if(!F)return g[e]?[e]:[];var n=(t.refIndexes||[]).map(function(t){return g.findIndex(function(e){return e.selfIndex===t})}).filter(function(t){return-1!==t});return!n.length&&g[e]?[e]:Array.from(new Set(n))}(t,e);o.forEach(function(t){var n,o,l,d,s,v,f,p,b,y,m,R,C=null===(n=x.current[t])||void 0===n?void 0:n.current;if(C){var B=c.getBoundingClientRect(),A=C.getBoundingClientRect(),S=B.right-U.left,M=A.left-U.left,T=B.top+18-U.top,H=A.top+18-U.top;if(F&&I&&L===e){var E=null!==(l=null===(o=u.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==l?l:0,N=null!==(s=null===(d=a.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==s?s:0,Y=E+(null!==(f=null===(v=u.current)||void 0===v?void 0:v.clientHeight)&&void 0!==f?f:1/0),D=N+(null!==(b=null===(p=a.current)||void 0===p?void 0:p.clientHeight)&&void 0!==b?b:1/0),j=function(t,e,n){return Math.max(e,Math.min(n,t))};T=j(B.top+18,E,Y)-U.top,H=j(A.top+18,N,D)-U.top}var O=k(r);O&&W.push({id:"line-".concat(r,"-").concat(t),x1:S,y1:T,x2:M,y2:H,style:O,sectionIdx:r,targetRightIdx:t,isSubSection:!1,isMappingContinuation:i>=0,hasCognitive:!!((null===(y=h[r])||void 0===y?void 0:y.cognitiveData)||(null===(m=g[t])||void 0===m?void 0:m.cognitiveData)||(null===(R=h[r])||void 0===R?void 0:R.nodeId)&&w[h[r].nodeId])})}})}})}if(!H&&I&&"string"==typeof L&&L.includes(r)){var dt=L.split(r),st=dt[0],vt=dt[1],ht=dt[2],ft=(dt[3],"".concat(st).concat(r).concat(vt)),pt=null===(Y=C.current[ft])||void 0===Y?void 0:Y.current,xt=null===(j=B.current[ft])||void 0===j?void 0:j.current;if(pt&&xt){var mt=pt.getBoundingClientRect(),Rt=xt.getBoundingClientRect(),Ct=mt.right-U.left,St=Rt.left-U.left,Tt=mt.top+mt.height/2-U.top,It=Rt.top+Rt.height/2-U.top;if(F){var Lt=null!==(z=null===(O=u.current)||void 0===O?void 0:O.getBoundingClientRect().top)&&void 0!==z?z:0,Ft=null!==(Q=null===(P=a.current)||void 0===P?void 0:P.getBoundingClientRect().top)&&void 0!==Q?Q:0,Ht=Lt+(null!==(G=null===(X=u.current)||void 0===X?void 0:X.clientHeight)&&void 0!==G?G:1/0),wt=Ft+(null!==(K=null===(q=a.current)||void 0===q?void 0:q.clientHeight)&&void 0!==K?K:1/0),kt=function(t,e,n){return Math.max(e,Math.min(n,t))};Tt=kt(mt.top+mt.height/2,Lt,Ht)-U.top,It=kt(Rt.top+Rt.height/2,Ft,wt)-U.top}var Et=null!==(V=N(st,vt))&&void 0!==V?V:E(ht);Et&&W.push({id:"line-subsec-".concat(ft),x1:Ct,y1:Tt,x2:St,y2:It,style:Et,sectionIdx:Number(ht.split("-")[0]),isSubSection:!0,subSectionKeyPath:L})}}if(ot(W),s.current&&v.current){var Nt=s.current.getBoundingClientRect(),Yt=v.current.getBoundingClientRect(),Dt=(Nt.top+Nt.height/2-U.top+Yt.top+Yt.height/2-U.top)/2;at({x1:Nt.right-U.left,x2:Yt.left-U.left,y:Dt})}else at(null);if(T.size>0){var jt=[],Ot=u.current,zt=a.current;if(Ot&&zt){var Pt=[],Qt=Ot.getBoundingClientRect().top,Xt=zt.getBoundingClientRect().top,Gt=Qt+Ot.clientHeight,qt=Xt+zt.clientHeight,Kt=Ot.scrollTop,Vt=zt.scrollTop,Jt=U.top,Ut=function(t,e,n){return Math.max(e,Math.min(n,t))};T.forEach(function(t){var e,n,i,o,l,u,a,d,s;if(H){var v=null,f=null,p=null;if("string"==typeof t&&t.includes(r)){var b=t.split(r),y=b[0],x=b[1],m=b[2],R="".concat(y).concat(r).concat(x);v=null===(e=C.current[R])||void 0===e?void 0:e.current,p=null!==(n=N(y,x))&&void 0!==n?n:E(m),f=Number((null==m?void 0:m.split("-")[0])||0)}else f=Number(t),v=null===(i=C.current[f])||void 0===i?void 0:i.current,p=k(f);if(!v)return;var A=c(zt);A.forEach(function(e,n){var i=v.getBoundingClientRect(),c=e.getBoundingClientRect(),o=i.right-U.left,l=c.left-U.left-0,u=o+75,a=i.top+i.height/2,d=c.top+c.height/2,s=a-Qt+Kt,h=d-Xt+Vt,g="conn-guide-".concat(t,"-").concat(n),f="";"string"==typeof t&&t.includes(r)?f=(t.split(r)[2]||"").split("-").map(function(t){return Number(t)+1}).join("."):f=String(Number(t)+1);var b=String.fromCharCode(97+n),y=1===A.length?null:"".concat(f,"(").concat(b,")");Pt.push({lhsScrollY:s,rhsScrollY:h,x1:o,x2:l,containerTop:Jt,leftIdx:t,rhsArrayIdx:n,styleColor:(null==p?void 0:p.badgeBorder)||"#6366F1",styleBg:(null==p?void 0:p.badgeBg)||"#FFFFFF",styleText:(null==p?void 0:p.badgeText)||"#A16207",styleId:g,centerX:u});var x=Ut(a,Qt,Gt),m=Ut(d,Xt,qt),R=x-Jt,C=m-Jt,B=At(o,R,l,C,u,a>=Qt-4&&a<=Gt+4,d>=Xt-4&&d<=qt+4);jt.push({id:g,pathD:B,style:p,leftIdx:t,rhsArrayIdx:n,x1:o,x2:l,y1:R,y2:C,centerX:u,matchLabel:y,isGuideline:!0})})}else if("string"==typeof t&&t.includes(r)){var S=t.split(r),M=(y=S[0],x=S[1],m=S[2],S[3],R="".concat(y).concat(r).concat(x),null===(o=C.current[R])||void 0===o?void 0:o.current),T=null===(l=B.current[R])||void 0===l?void 0:l.current;if(!M||!T)return;var I=M.getBoundingClientRect(),L=T.getBoundingClientRect(),w=null!==(u=N(y,x))&&void 0!==u?u:E(m),Y=I.right-U.left,D=L.left-U.left-0,j=Y+75,O=I.top+I.height/2,z=L.top+L.height/2,P=O-Qt+Kt,Q=z-Xt+Vt,X="conn-subsec-".concat(R),G=((m||"").split("-").map(function(t){return Number(t)+1}).join("."),null);Pt.push({lhsScrollY:P,rhsScrollY:Q,x1:Y,x2:D,containerTop:Jt,leftIdx:t,rhsArrayIdx:t,styleColor:(null==w?void 0:w.badgeBorder)||"#6366F1",styleBg:(null==w?void 0:w.badgeBg)||"#FFFFFF",styleText:(null==w?void 0:w.badgeText)||"#A16207",styleId:X,centerX:j});var q=Ut(O,Qt,Gt),K=Ut(z,Xt,qt),V=At(Y,_=q-Jt,D,tt=K-Jt,j,O>=Qt-4&&O<=Gt+4,z>=Xt-4&&z<=qt+4);jt.push({id:X,pathD:V,style:w,leftIdx:t,rhsArrayIdx:t,x1:Y,x2:D,y1:_,y2:tt,matchLabel:G})}else if(F){var J=t,W=h[J];if(!(null===(s=null==W?void 0:W.refIndexes)||void 0===s?void 0:s.length))return;W.refIndexes.forEach(function(e,n){var i,r,c=g.findIndex(function(t){return t.selfIndex===e});if(-1!==c){var o=null===(i=C.current[J])||void 0===i?void 0:i.current,l=null===(r=B.current[c])||void 0===r?void 0:r.current;if(o&&l){var u=o.getBoundingClientRect(),a=l.getBoundingClientRect(),d=k(J),s=u.right-U.left,v=a.left-U.left-0,h=s+75,f=u.top+u.height/2,p=a.top+a.height/2,b=f-Qt+Kt,y=p-Xt+Vt,x="conn-".concat(J,"-").concat(c),m=String(Number(t)+1),R=String.fromCharCode(97+n),A=1===W.refIndexes.length?null:"".concat(m,"(").concat(R,")");Pt.push({lhsScrollY:b,rhsScrollY:y,x1:s,x2:v,containerTop:Jt,leftIdx:J,rhsArrayIdx:c,styleColor:(null==d?void 0:d.badgeBorder)||"#6366F1",styleBg:(null==d?void 0:d.badgeBg)||"#FFFFFF",styleText:(null==d?void 0:d.badgeText)||"#A16207",styleId:x,centerX:h});var S=Ut(f,Qt,Gt),M=Ut(p,Xt,qt),T=S-Jt,I=M-Jt,L=At(s,T,v,I,h,f>=Qt-4&&f<=Gt+4,p>=Xt-4&&p<=qt+4);jt.push({id:x,pathD:L,style:d,leftIdx:J,rhsArrayIdx:c,x1:s,x2:v,y1:T,y2:I,matchLabel:A})}}})}else{var Z=t,$=Z;M=null===(a=C.current[Z])||void 0===a?void 0:a.current,T=null===(d=B.current[$])||void 0===d?void 0:d.current;if(!M||!T)return;I=M.getBoundingClientRect(),L=T.getBoundingClientRect(),w=k(Z),Y=I.right-U.left,D=L.left-U.left-0,j=Y+75,O=I.top+I.height/2,z=L.top+L.height/2,P=O-Qt+Kt,Q=z-Xt+Vt,X="conn-".concat(Z,"-").concat($),String(Number(t)+1),G=null;Pt.push({lhsScrollY:P,rhsScrollY:Q,x1:Y,x2:D,containerTop:Jt,leftIdx:Z,rhsArrayIdx:$,styleColor:(null==w?void 0:w.badgeBorder)||"#6366F1",styleBg:(null==w?void 0:w.badgeBg)||"#FFFFFF",styleText:(null==w?void 0:w.badgeText)||"#A16207",styleId:X,centerX:j});var _,tt;q=Ut(O,Qt,Gt),K=Ut(z,Xt,qt),V=At(Y,_=q-Jt,D,tt=K-Jt,j,O>=Qt-4&&O<=Gt+4,z>=Xt-4&&z<=qt+4);jt.push({id:X,pathD:V,style:w,leftIdx:Z,rhsArrayIdx:$,x1:Y,x2:D,y1:_,y2:tt,matchLabel:G})}}),Bt.current=Pt}gt(jt),setTimeout(function(){return Mt()},10)}else gt([]),Bt.current=[],setTimeout(function(){return Mt()},10)}catch(t){console.error("Line render safe fail: ",t)}finally{yt.current=!1}}},[f,h,g,w,nt,it,k,N,F,I,L,T,S,M,H]),Mt=n(function(){var t,e,n,i,r,c,o,s,v,h,g,f,p,b,y,x,m,R,C,B=Bt.current;if(!B.length)return null===(t=d.current["guideline-up-stroke"])||void 0===t||t.setAttribute("visibility","hidden"),null===(e=d.current["guideline-up-badge"])||void 0===e||e.setAttribute("visibility","hidden"),null===(n=d.current["guideline-down-stroke"])||void 0===n||n.setAttribute("visibility","hidden"),void(null===(i=d.current["guideline-down-badge"])||void 0===i||i.setAttribute("visibility","hidden"));if(!D.current){var A=null!==(c=null===(r=u.current)||void 0===r?void 0:r.scrollTop)&&void 0!==c?c:0,S=null!==(s=null===(o=a.current)||void 0===o?void 0:o.scrollTop)&&void 0!==s?s:0,M=null!==(h=null===(v=u.current)||void 0===v?void 0:v.clientHeight)&&void 0!==h?h:1/0,T=null!==(f=null===(g=a.current)||void 0===g?void 0:g.clientHeight)&&void 0!==f?f:1/0,I=null!==(b=null===(p=u.current)||void 0===p?void 0:p.getBoundingClientRect().top)&&void 0!==b?b:0,L=null!==(x=null===(y=a.current)||void 0===y?void 0:y.getBoundingClientRect().top)&&void 0!==x?x:0,F=I+M,H=L+T,w=null===(m=l.current)||void 0===m?void 0:m.getBoundingClientRect(),k=null!==(R=null==w?void 0:w.top)&&void 0!==R?R:0,E=null!==(C=null==w?void 0:w.height)&&void 0!==C?C:1/0,N=function(t,e,n){return Math.max(e,Math.min(n,t))},Y=0,j=0,O=0,z=0,P="#6366F1",Q="#A16207",X=!1,G=0;if(B.forEach(function(t){var e=t.lhsScrollY-A+I,n=t.rhsScrollY-S+L,i=d.current[t.styleId+"-stroke"],r=d.current[t.styleId+"-bg"],c=d.current[t.styleId+"-btn"],o=d.current[t.styleId+"-number"];if(i||r){var l=N(e,I,F),u=N(n,L,H),a=l-k,s=u-k,v=e>=I-4&&e<=F+4,h=n>=L-4&&n<=H+4,g=!0;X=!0;var f=t.centerX||t.x1+75;0===O&&(O=t.x1,z=a,G=f,P=t.styleColor,t.styleBg,Q=t.styleText||"#A16207"),n<L-4?(Y++,g=!1):n>H+4&&(j++,g=!1);var p=At(t.x1,a,t.x2,s,G,v,h);i&&(g&&p?(i.setAttribute("visibility","visible"),i.setAttribute("d",p)):i.setAttribute("visibility","hidden")),r&&(g&&p?(r.setAttribute("visibility","visible"),r.setAttribute("d",p)):r.setAttribute("visibility","hidden")),c&&(v&&g?(c.setAttribute("visibility","visible"),c.setAttribute("y",String(a-12))):c.setAttribute("visibility","hidden")),o&&(v&&g?(o.setAttribute("visibility","visible"),o.setAttribute("transform","translate(".concat(t.x2-42,", ").concat(s,")"))):o.setAttribute("visibility","hidden"))}}),X&&G>0){var q=d.current["guideline-up-stroke"],K=d.current["guideline-up-badge"],V=d.current["guideline-up-arrow"],J=d.current["guideline-up-text"],U=d.current["guideline-up-badge-rect"];if(Y>0){var W=Math.max(15,L-k+15),Z=Math.min(15,Math.abs(G-O),Math.max(0,z-W)),$="M ".concat(O,",").concat(z," L ").concat(G-Z,",").concat(z," Q ").concat(G,",").concat(z," ").concat(G,",").concat(z-Z," L ").concat(G,",").concat(W);null==q||q.setAttribute("visibility","visible"),null==q||q.setAttribute("d",$),null==q||q.setAttribute("stroke",P),null==K||K.setAttribute("visibility","visible"),null==K||K.setAttribute("transform","translate(".concat(G,", ").concat(W,")")),V&&V.setAttribute("fill",P),J&&(J.textContent="+".concat(Y),J.setAttribute("fill",Q)),U&&U.setAttribute("stroke",P)}else null==q||q.setAttribute("visibility","hidden"),null==K||K.setAttribute("visibility","hidden");var _=d.current["guideline-down-stroke"],tt=d.current["guideline-down-badge"],et=d.current["guideline-down-arrow"],nt=d.current["guideline-down-text"],it=d.current["guideline-down-badge-rect"];if(j>0){var rt=Math.min(E-15,H-k-15);Z=Math.min(15,Math.abs(G-O),Math.max(0,rt-z)),$="M ".concat(O,",").concat(z," L ").concat(G-Z,",").concat(z," Q ").concat(G,",").concat(z," ").concat(G,",").concat(z+Z," L ").concat(G,",").concat(rt);null==_||_.setAttribute("visibility","visible"),null==_||_.setAttribute("d",$),null==_||_.setAttribute("stroke",P),null==tt||tt.setAttribute("visibility","visible"),null==tt||tt.setAttribute("transform","translate(".concat(G,", ").concat(rt,")")),et&&et.setAttribute("fill",P),nt&&(nt.textContent="+".concat(j),nt.setAttribute("fill",Q)),it&&it.setAttribute("stroke",P)}else null==_||_.setAttribute("visibility","hidden"),null==tt||tt.setAttribute("visibility","hidden")}}},[]),Tt=n(function(){Bt.current.length>0&&!D.current||(null!==Rt.current&&clearTimeout(Rt.current),Rt.current=setTimeout(function(){K.current(),Rt.current=null},50))},[]),It=n(function(t){if(null!==tt.current&&et.current&&Math.abs(t.currentTarget.scrollTop-tt.current)<=2){var e=et.current;tt.current=null,et.current=null,e()}if(!mt.current&&!J.current){if(F&&U&&(j.current||T.size>0)){var n=t.currentTarget,i=u.current,c=a.current,o=n===i?c:n===c?i:null;if(n&&o){var d=function(){var t,e,n,i,c,o,l,u,a,d,s,v=P.current,h=Q.current;if(null===v)return{leftAnchor:null,rightAnchor:null};if("string"==typeof v&&v.includes(r)){var g=v.split(r),f="".concat(g[0]).concat(r).concat(g[1]);return{leftAnchor:(null===(t=C.current[f])||void 0===t?void 0:t.current)||(null===(e=m.current[g[2]])||void 0===e?void 0:e.current)||(null===(n=y.current[Number(g[2])])||void 0===n?void 0:n.current)||null,rightAnchor:(null===(i=B.current[f])||void 0===i?void 0:i.current)||(null===(c=R.current[g[3]])||void 0===c?void 0:c.current)||(null===(o=x.current[Number(g[3])])||void 0===o?void 0:o.current)||null}}var p=Number(v),b=null!==h?Number(h):p;return{leftAnchor:(null===(l=C.current[p])||void 0===l?void 0:l.current)||(null===(u=A.current[p])||void 0===u?void 0:u.current)||(null===(a=y.current[p])||void 0===a?void 0:a.current)||null,rightAnchor:(null===(d=B.current[b])||void 0===d?void 0:d.current)||(null===(s=x.current[b])||void 0===s?void 0:s.current)||null}}(),s=d.leftAnchor,v=d.rightAnchor,h=n===i?s:v,g=n===i?v:s,f=null;if(h&&g){var p=h.getBoundingClientRect(),b=g.getBoundingClientRect(),S=o.getBoundingClientRect(),M=p.top+p.height/2;f=b.top-S.top+o.scrollTop+b.height/2-(M-S.top)}else{var I=Math.max(0,n.scrollHeight-n.clientHeight),L=Math.max(0,o.scrollHeight-o.clientHeight);f=I>0?n.scrollTop/I*L:n.scrollTop}var H=Math.max(0,o.scrollHeight-o.clientHeight);f=Math.max(0,Math.min(f,H)),Math.abs(o.scrollTop-f)>1&&(mt.current=!0,o.scrollTop=f,requestAnimationFrame(function(){mt.current=!1}))}}F||Tt(),xt.current||(xt.current=!0,requestAnimationFrame(function(){var t,e,n,i,c,o,d;if(j.current){var s=u.current,v=a.current;if(s&&v&&z.current){if(!O.current){var h=P.current,g=void 0;if("string"==typeof h&&h.includes(r)){var f=h.split(r),p="".concat(f[0]).concat(r).concat(f[1]);g=null===(t=C.current[p])||void 0===t?void 0:t.current}else g=null===(e=C.current[h])||void 0===e?void 0:e.current;if(g){var b=g.getBoundingClientRect();O.current={badgeScreenY:b.top+b.height/2,initialScrollTop:s.scrollTop,leftTop:s.getBoundingClientRect().top,leftBottom:s.getBoundingClientRect().top+s.clientHeight,cTop:null!==(i=null===(n=l.current)||void 0===n?void 0:n.getBoundingClientRect().top)&&void 0!==i?i:0}}}if(O.current){var y=O.current,x=s.scrollTop-y.initialScrollTop,m=y.badgeScreenY-x,R=((c=m,o=y.leftTop,d=y.leftBottom,Math.max(o,Math.min(d,c)))-y.cTop).toString(),B=m>=y.leftTop-4&&m<=y.leftBottom+4;z.current.setAttribute("y1",R),z.current.setAttribute("y2",R),z.current.setAttribute("visibility",B?"visible":"hidden")}}}Mt(),xt.current=!1}))}},[Mt,F,U,T,Tt]);return i(function(){K.current=St},[St]),i(function(){var t=setTimeout(Tt,250),e=function(){return W.current()};return window.addEventListener("resize",e),function(){clearTimeout(t),null!==Rt.current&&clearTimeout(Rt.current),null!==V.current&&clearTimeout(V.current),window.removeEventListener("resize",e)}},[Z,$,_,f,S,M,h,g,nt,Tt,I,L,Y,T]),{lines:ct,setLines:ot,overallConnector:ut,setOverallConnector:at,connectedLines:ht,setConnectedLines:gt,svgDimensions:pt,cachedConnectedPositions:Bt,calculateLines:St,calculateLinesRef:K,calculateLinesDebounced:Tt,handleColumnScroll:It}};export{o as useLinesCalculator};
2
2
  //# sourceMappingURL=useLinesCalculator.js.map
@@ -1,2 +1,2 @@
1
- import{useState as e,useRef as n,useCallback as t,useEffect as r}from"react";import{DEVIATION_BADGE_SEPARATOR as i,resetClauseHighlight as l,smoothScrollTo as u}from"../CognitiveComparehelpers.js";var o=function(o){var c=o.isGuidelineMode,d=o.maintainRelativeOrder,s=o.proposedSections,v=o.existingSections,a=o.leftContainerRef,p=o.rightContainerRef,g=o.scrollContainerRef,f=o.sectionLeftRefs,h=o.sectionRightRefs,R=o.subSectionLeftRefs,S=o.subSectionRightRefs,y=o.lhsBadgeRefs,m=o.rhsBadgeRefs,B=o.sectionRowRefs,x=o.sectionRightRowRefs,C=o.rhsTopSpacerRef,T=o.rhsBottomSpacerRef,b=o.lhsTopSpacerRef,A=o.lhsBottomSpacerRef,I=o.calculateLinesRef,w=o.setConnectedSections,L=o.setConnectedLines,E=o.cachedConnectedPositions,F=o.closeMoreFunctionsPopup,N=o.setErrorToast;o.moreFunctions,o.closeSummaryPopup;var q=e(!1),H=q[0],M=q[1],P=e(!1),z=P[0],V=P[1],j=e(!1),k=j[0],G=j[1],O=e(!1),D=O[0],J=O[1],K=e(null),Q=K[0],U=K[1],W=n(!1),X=n(null),Y=n(!1),Z=n(null),$=n(null),_=n(null),ee=n(new Set),ne=function(){ee.current.forEach(function(e){l(e)}),ee.current.clear()},te=function(e,n,t){var r,l,u,o,c,d,s,v,g,C,T,b,A=null,I=null,w=null,L=null,E=null,F=null,N=function(e,n){if(!e||!n)return!0;var t=e.getBoundingClientRect(),r=n.getBoundingClientRect();return t.bottom>=r.top&&t.top<=r.bottom};if(e){var q=n.split(i),H="".concat(q[0]).concat(i).concat(q[1]);A=(null===(r=R.current[q[2]])||void 0===r?void 0:r.current)||(null===(l=f.current[Number(q[2])])||void 0===l?void 0:l.current)||null,I=(null===(u=S.current[q[3]])||void 0===u?void 0:u.current)||(null===(o=h.current[Number(q[3])])||void 0===o?void 0:o.current)||null,w=(null===(c=y.current[H])||void 0===c?void 0:c.current)||A,L=(null===(d=m.current[H])||void 0===d?void 0:d.current)||I}else{var M=Number(n),P=null!==t?Number(t):M;A=(null===(s=f.current[M])||void 0===s?void 0:s.current)||null,I=(null===(v=h.current[P])||void 0===v?void 0:v.current)||null,E=(null===(g=y.current[M])||void 0===g?void 0:g.current)||null,F=(null===(C=m.current[P])||void 0===C?void 0:C.current)||null,w=E||(null===(T=B.current[M])||void 0===T?void 0:T.current)||A,L=F||(null===(b=x.current[P])||void 0===b?void 0:b.current)||I}if(A&&(A.style.paddingTop="0px"),I&&(I.style.paddingTop="0px"),e||(E&&(E.style.marginTop="0px"),F&&(F.style.marginTop="0px")),!e&&E&&F){var z=a.current,V=p.current;if(!N(E,z)||!N(F,V))return;var j=E.getBoundingClientRect(),k=F.getBoundingClientRect(),G=j.top-k.top;if(Math.abs(G)>32)return;G>0&&(F.style.marginTop="".concat(G,"px"))}else if(w&&L&&A&&I){j=w.getBoundingClientRect(),k=L.getBoundingClientRect();(G=j.top-k.top)>0&&(I.style.paddingTop="".concat(G,"px"))}},re=t(function(){var e,n,t,r,l,u,o,c,d=Z.current,s=$.current;if(null!==d)if("string"==typeof d&&d.includes(i)){var v=d.split(i),a=(null===(e=R.current[v[2]])||void 0===e?void 0:e.current)||(null===(n=f.current[Number(v[2])])||void 0===n?void 0:n.current)||null,p=(null===(t=S.current[v[3]])||void 0===t?void 0:t.current)||(null===(r=h.current[Number(v[3])])||void 0===r?void 0:r.current)||null;a&&(a.style.paddingTop="0px"),p&&(p.style.paddingTop="0px")}else{a=(null===(l=f.current[d])||void 0===l?void 0:l.current)||null,p=(null===(u=h.current[null!=s?s:d])||void 0===u?void 0:u.current)||null;a&&(a.style.paddingTop="0px"),p&&(p.style.paddingTop="0px");var g=(null===(o=y.current[d])||void 0===o?void 0:o.current)||null,B=(null===(c=m.current[null!=s?s:d])||void 0===c?void 0:c.current)||null;g&&(g.style.marginTop="0px"),B&&(B.style.marginTop="0px")}C.current&&(C.current.style.height="0px"),T.current&&(T.current.style.height="0px"),b.current&&(b.current.style.height="0px"),A.current&&(A.current.style.height="0px")},[]);r(function(){Y.current=H},[H]),r(function(){Z.current=Q},[Q]);var ie=t(function(){ne(),M(!1),Y.current=!1,X.current=null,re(),U(null),Z.current=null,$.current=null,V(!1),J(!1)},[re]),le=t(function(e,n,t){var r,l,o=null===(r=null==t?void 0:t.toggleIfSame)||void 0===r||r,R=null==t?void 0:t.onReady,S=null!==(l=null==t?void 0:t.sourceSide)&&void 0!==l?l:"left";if(F(),null!=e)if(!n||c){ne();var q=H&&Q===e;H&&null!==Q&&re(),q&&o?ie():(w(new Set([e])),L([]),E.current=[],J(!0),W.current=!0,U(e),Z.current=e,M(!0),Y.current=!0,V(!1),C.current&&(C.current.style.height="0px"),T.current&&(T.current.style.height="0px"),b.current&&(b.current.style.height="0px"),A.current&&(A.current.style.height="0px"),requestAnimationFrame(function(){var n=function(){var n,t,r,l,o,b,A,w,L,E,F,N="string"==typeof e&&e.includes(i),q=null,H=null,M=null;if(c){if(N){var P=e.split(i),z="".concat(P[0]).concat(i).concat(P[1]);q=(null===(n=y.current[z])||void 0===n?void 0:n.current)||null}else q=(null===(t=f.current[e])||void 0===t?void 0:t.current)||(null===(r=B.current[e])||void 0===r?void 0:r.current)||null;H=document.getElementById("guideline-target-0"),M=H?e:null}else if(N){P=e.split(i),z="".concat(P[0]).concat(i).concat(P[1]);q=(null===(l=y.current[z])||void 0===l?void 0:l.current)||null,H=(null===(o=m.current[z])||void 0===o?void 0:o.current)||null,M=H?e:null}else if(q=(null===(b=f.current[e])||void 0===b?void 0:b.current)||(null===(A=B.current[e])||void 0===A?void 0:A.current)||null,d){var j=s[e],k=(null==j?void 0:j.refIndexes)||[];if(k.length>0){var G=k[0],O=v.findIndex(function(e){return e.selfIndex===G});-1!==O&&(H=(null===(E=h.current[O])||void 0===E?void 0:E.current)||(null===(F=x.current[O])||void 0===F?void 0:F.current)||null,M=O)}}else H=(null===(w=h.current[e])||void 0===w?void 0:w.current)||(null===(L=x.current[e])||void 0===L?void 0:L.current)||null,M=H?e:null;$.current=M;var D=a.current,K=p.current,Q=function(){te(N,e,M),V(!0),I.current&&I.current(),W.current=!1,"right"===S&&K?K.dispatchEvent(new Event("scroll")):D&&D.dispatchEvent(new Event("scroll")),J(!1),null==R||R()};if(!q||!D)return W.current=!1,J(!1),void(null==R||R());if(H&&K){if(!d){var U=0;U="right"===S?H?H.getBoundingClientRect().top:0:q?q.getBoundingClientRect().top:0;var X=g.current,Y=(null==X?void 0:X.getBoundingClientRect().top)||0,Z=X?X.scrollTop+U-Y-150:0;return X?void u(X,Z,200,Q):void Q()}var _=q.getBoundingClientRect().top-D.getBoundingClientRect().top+D.scrollTop,ee=H.getBoundingClientRect().top-K.getBoundingClientRect().top+K.scrollTop,ne=200;if("left"===S){var re=ee-(_-D.scrollTop);re<0&&C.current&&!c&&(C.current.style.height="".concat(Math.abs(re),"px")),requestAnimationFrame(function(){var e,n=K.scrollHeight-K.clientHeight;if(re<0)e=0;else{if(re>n){var t=re-n;return T.current&&!c&&(T.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){u(K,re,ne,Q)})}e=re}u(K,e,ne,Q)})}else{var ie=_-(ee-K.scrollTop);requestAnimationFrame(function(){var e,n=D.scrollHeight-D.clientHeight;if(ie<0)e=0;else{if(ie>n)return void requestAnimationFrame(function(){return u(D,n,ne,Q)});e=ie}u(D,e,ne,Q)})}}else Q()};c?setTimeout(n,100):n()}))}else N("No counterpart exists for this section.")},[Q,F,v,H,d,s,re,ie,c]);return{isSideBySide:H,setIsSideBySide:M,isArrowVisible:z,setIsArrowVisible:V,isResizing:k,setIsResizing:G,isSideBySideLoading:D,setIsSideBySideLoading:J,activeSideBySideSection:Q,setActiveSideBySideSection:U,scrollLock:W,sideBySideCacheRef:X,isSideBySideRef:Y,activeSideBySideSectionRef:Z,activeSideBySideRightSectionRef:$,sideBySideLineRef:_,highlightedClauseRefs:ee,clearClauseHighlight:ne,applyAlignmentPadding:te,resetSideBySide:ie,activateSideBySide:le}};export{o as useSideBySide};
1
+ import{useState as e,useRef as n,useCallback as t,useEffect as r}from"react";import{DEVIATION_BADGE_SEPARATOR as i,resetClauseHighlight as l,smoothScrollTo as u}from"../CognitiveComparehelpers.js";import{getVisibleGuidelineTargets as o}from"../Guidelines/utils/guidelineTargets.js";var c=function(c){var d=c.isGuidelineMode,s=c.maintainRelativeOrder,v=c.proposedSections,a=c.existingSections,p=c.leftContainerRef,g=c.rightContainerRef,f=c.scrollContainerRef,h=c.sectionLeftRefs,R=c.sectionRightRefs,S=c.subSectionLeftRefs,y=c.subSectionRightRefs,m=c.lhsBadgeRefs,B=c.rhsBadgeRefs,x=c.sectionRowRefs,C=c.sectionRightRowRefs,T=c.rhsTopSpacerRef,b=c.rhsBottomSpacerRef,A=c.lhsTopSpacerRef,w=c.lhsBottomSpacerRef,I=c.calculateLinesRef,L=c.setConnectedSections,F=c.setConnectedLines,N=c.cachedConnectedPositions,E=c.closeMoreFunctionsPopup,q=c.setErrorToast;c.moreFunctions,c.closeSummaryPopup;var H=e(!1),M=H[0],P=H[1],j=e(!1),z=j[0],G=j[1],V=e(!1),k=V[0],O=V[1],D=e(!1),J=D[0],K=D[1],Q=e(null),U=Q[0],W=Q[1],X=n(!1),Y=n(null),Z=n(!1),$=n(null),_=n(null),ee=n(null),ne=n(new Set),te=function(){ne.current.forEach(function(e){l(e)}),ne.current.clear()},re=function(e,n,t){var r,l,u,o,c,d,s,v,a,f,T,b,A=null,w=null,I=null,L=null,F=null,N=null,E=function(e,n){if(!e||!n)return!0;var t=e.getBoundingClientRect(),r=n.getBoundingClientRect();return t.bottom>=r.top&&t.top<=r.bottom};if(e){var q=n.split(i),H="".concat(q[0]).concat(i).concat(q[1]);A=(null===(r=S.current[q[2]])||void 0===r?void 0:r.current)||(null===(l=h.current[Number(q[2])])||void 0===l?void 0:l.current)||null,w=(null===(u=y.current[q[3]])||void 0===u?void 0:u.current)||(null===(o=R.current[Number(q[3])])||void 0===o?void 0:o.current)||null,I=(null===(c=m.current[H])||void 0===c?void 0:c.current)||A,L=(null===(d=B.current[H])||void 0===d?void 0:d.current)||w}else{var M=Number(n),P=null!==t?Number(t):M;A=(null===(s=h.current[M])||void 0===s?void 0:s.current)||null,w=(null===(v=R.current[P])||void 0===v?void 0:v.current)||null,F=(null===(a=m.current[M])||void 0===a?void 0:a.current)||null,N=(null===(f=B.current[P])||void 0===f?void 0:f.current)||null,I=F||(null===(T=x.current[M])||void 0===T?void 0:T.current)||A,L=N||(null===(b=C.current[P])||void 0===b?void 0:b.current)||w}if(A&&(A.style.paddingTop="0px"),w&&(w.style.paddingTop="0px"),e||(F&&(F.style.marginTop="0px"),N&&(N.style.marginTop="0px")),!e&&F&&N){var j=p.current,z=g.current;if(!E(F,j)||!E(N,z))return;var G=F.getBoundingClientRect(),V=N.getBoundingClientRect(),k=G.top-V.top;if(Math.abs(k)>32)return;k>0&&(N.style.marginTop="".concat(k,"px"))}else if(I&&L&&A&&w){G=I.getBoundingClientRect(),V=L.getBoundingClientRect();(k=G.top-V.top)>0&&(w.style.paddingTop="".concat(k,"px"))}},ie=t(function(){var e,n,t,r,l,u,o,c,d=$.current,s=_.current;if(null!==d)if("string"==typeof d&&d.includes(i)){var v=d.split(i),a=(null===(e=S.current[v[2]])||void 0===e?void 0:e.current)||(null===(n=h.current[Number(v[2])])||void 0===n?void 0:n.current)||null,p=(null===(t=y.current[v[3]])||void 0===t?void 0:t.current)||(null===(r=R.current[Number(v[3])])||void 0===r?void 0:r.current)||null;a&&(a.style.paddingTop="0px"),p&&(p.style.paddingTop="0px")}else{a=(null===(l=h.current[d])||void 0===l?void 0:l.current)||null,p=(null===(u=R.current[null!=s?s:d])||void 0===u?void 0:u.current)||null;a&&(a.style.paddingTop="0px"),p&&(p.style.paddingTop="0px");var g=(null===(o=m.current[d])||void 0===o?void 0:o.current)||null,f=(null===(c=B.current[null!=s?s:d])||void 0===c?void 0:c.current)||null;g&&(g.style.marginTop="0px"),f&&(f.style.marginTop="0px")}T.current&&(T.current.style.height="0px"),b.current&&(b.current.style.height="0px"),A.current&&(A.current.style.height="0px"),w.current&&(w.current.style.height="0px")},[]);r(function(){Z.current=M},[M]),r(function(){$.current=U},[U]);var le=t(function(){te(),P(!1),Z.current=!1,Y.current=null,ie(),W(null),$.current=null,_.current=null,G(!1),K(!1)},[ie]),ue=t(function(e,n,t){var r,l,c=null===(r=null==t?void 0:t.toggleIfSame)||void 0===r||r,S=null==t?void 0:t.onReady,y=null!==(l=null==t?void 0:t.sourceSide)&&void 0!==l?l:"left";if(E(),null!=e)if(!n||d){te();var H=M&&U===e;M&&null!==U&&ie(),H&&c?le():(L(new Set([e])),F([]),N.current=[],K(!0),X.current=!0,W(e),$.current=e,P(!0),Z.current=!0,G(!1),T.current&&(T.current.style.height="0px"),b.current&&(b.current.style.height="0px"),A.current&&(A.current.style.height="0px"),w.current&&(w.current.style.height="0px"),requestAnimationFrame(function(){var n=function(){var n,t,r,l,c,A,w,L,F,N,E,q="string"==typeof e&&e.includes(i),H=null,M=null,P=null;if(d){if(q){var j=e.split(i),z="".concat(j[0]).concat(i).concat(j[1]);H=(null===(n=m.current[z])||void 0===n?void 0:n.current)||null}else H=(null===(t=h.current[e])||void 0===t?void 0:t.current)||(null===(r=x.current[e])||void 0===r?void 0:r.current)||null;M=o(g.current)[0]||null,P=M?e:null}else if(q){j=e.split(i),z="".concat(j[0]).concat(i).concat(j[1]);H=(null===(l=m.current[z])||void 0===l?void 0:l.current)||null,M=(null===(c=B.current[z])||void 0===c?void 0:c.current)||null,P=M?e:null}else if(H=(null===(A=h.current[e])||void 0===A?void 0:A.current)||(null===(w=x.current[e])||void 0===w?void 0:w.current)||null,s){var V=v[e],k=(null==V?void 0:V.refIndexes)||[];if(k.length>0){var O=k[0],D=a.findIndex(function(e){return e.selfIndex===O});-1!==D&&(M=(null===(N=R.current[D])||void 0===N?void 0:N.current)||(null===(E=C.current[D])||void 0===E?void 0:E.current)||null,P=D)}}else M=(null===(L=R.current[e])||void 0===L?void 0:L.current)||(null===(F=C.current[e])||void 0===F?void 0:F.current)||null,P=M?e:null;_.current=P;var J=p.current,Q=g.current,U=function(){re(q,e,P),G(!0),I.current&&I.current(),X.current=!1,"right"===y&&Q?Q.dispatchEvent(new Event("scroll")):J&&J.dispatchEvent(new Event("scroll")),K(!1),null==S||S()};if(!H||!J)return X.current=!1,K(!1),void(null==S||S());if(M&&Q){if(!s){var W=0;W="right"===y?M?M.getBoundingClientRect().top:0:H?H.getBoundingClientRect().top:0;var Y=f.current,Z=(null==Y?void 0:Y.getBoundingClientRect().top)||0,$=Y?Y.scrollTop+W-Z-150:0;return Y?void u(Y,$,200,U):void U()}var ee=H.getBoundingClientRect().top-J.getBoundingClientRect().top+J.scrollTop,ne=M.getBoundingClientRect().top-Q.getBoundingClientRect().top+Q.scrollTop,te=200;if("left"===y){var ie=ne-(ee-J.scrollTop);ie<0&&T.current&&!d&&(T.current.style.height="".concat(Math.abs(ie),"px")),requestAnimationFrame(function(){var e,n=Q.scrollHeight-Q.clientHeight;if(ie<0)e=0;else{if(ie>n){var t=ie-n;return b.current&&!d&&(b.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){u(Q,ie,te,U)})}e=ie}u(Q,e,te,U)})}else{var le=ee-(ne-Q.scrollTop);requestAnimationFrame(function(){var e,n=J.scrollHeight-J.clientHeight;if(le<0)e=0;else{if(le>n)return void requestAnimationFrame(function(){return u(J,n,te,U)});e=le}u(J,e,te,U)})}}else U()};d?setTimeout(n,100):n()}))}else q("No counterpart exists for this section.")},[U,E,a,M,s,v,ie,le,d]);return{isSideBySide:M,setIsSideBySide:P,isArrowVisible:z,setIsArrowVisible:G,isResizing:k,setIsResizing:O,isSideBySideLoading:J,setIsSideBySideLoading:K,activeSideBySideSection:U,setActiveSideBySideSection:W,scrollLock:X,sideBySideCacheRef:Y,isSideBySideRef:Z,activeSideBySideSectionRef:$,activeSideBySideRightSectionRef:_,sideBySideLineRef:ee,highlightedClauseRefs:ne,clearClauseHighlight:te,applyAlignmentPadding:re,resetSideBySide:le,activateSideBySide:ue}};export{c as useSideBySide};
2
2
  //# sourceMappingURL=useSideBySide.js.map
@@ -1,2 +1,2 @@
1
- import{__spreadArray as n,__assign as e}from"tslib";import{jsxs as l,jsx as i,Fragment as o}from"react/jsx-runtime";import{useMemo as t,useState as r,useRef as d,useEffect as a}from"react";import{ExternalLink as s,ChevronUp as c,ChevronDown as u}from"lucide-react";import v from"./CognitiveNonWebSearchReasoning.module.css.js";var h=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return n.filter(Boolean).join(" ")},m=function(n){return n.split(/(\*\*.*?\*\*|__.*?__)/g).map(function(n,l){return n.startsWith("**")&&n.endsWith("**")||n.startsWith("__")&&n.endsWith("__")?i("strong",e({className:v.boldText},{children:n.slice(2,-2)}),l):n})},g=function(g){var p=g.item,f=g.headerTitle;g.index;var x=g.iconsConfig,y=g.DocumentTitle,b=g.previewCallback,N=g.bodyHeight,C=g.disableMaximize,I=void 0!==C&&C,k=g.splitterCustomStyle,T=void 0!==k&&k,H=g.themeTokens,L=g.classNames,B=g.styles,w=p.dataSource,z=p.confidence_score,S=p.trainingDataTitle,A=null==x?void 0:x.ChevronDownIcon,F=null==x?void 0:x.ChevronUpIcon,_=null==x?void 0:x.MaximizeIcon,D=null==x?void 0:x.CloseIcon,R=t(function(){var e=(w?w.replace(/\\n/g,"\n").replace(/\n+/g,"\n"):"").split(/(<highlight>[\s\S]*?<\/highlight>)/g),l=0,i=e.map(function(n){var e=n.startsWith("<highlight>"),i={text:e?n.replace(/<\/?highlight>/g,""):n,isHighlight:e,highlightIndex:e?l:-1};return e&&l++,i}),o=i.filter(function(n){return n.isHighlight}).length,t=[],r=[];return i.forEach(function(e){var l=e.text,i=e.isHighlight,o=e.highlightIndex;l.split("\n").forEach(function(e,l){l>0&&((r.length>0||t.length>0)&&t.push(n([],r,!0)),r=[]),e&&r.push({text:e,isHighlight:i,highlightIndex:o})})}),r.length>0&&t.push(n([],r,!0)),{processedLines:t.map(function(n){var e=n.map(function(n){return n.text}).join(""),l=e.match(/^(\s*)(-|\*|\d+\.)\s+(.*)$/);return{segments:n,isListItem:!!l,isHeader:!!e.match(/^(Title|Description|Training-basis):\s*(.*)$/i),indent:(null==l?void 0:l[1])||"",content:(null==l?void 0:l[3])||e}}),totalHighlights:o}},[w]),W=R.processedLines,j=R.totalHighlights,M=r(0),V=M[0],E=M[1],$=d(null),U=d(null),Y=d(null),q=d([]),G=d([]);a(function(){q.current=q.current.slice(0,j),G.current=G.current.slice(0,j)},[j]),a(function(){if(j>0){E(0);var n=setTimeout(function(){var n;null===(n=q.current[0])||void 0===n||n.scrollIntoView({behavior:"smooth",block:"center"})},50);return function(){return clearTimeout(n)}}},[j]);var J=function(n,e){setTimeout(function(){var l=e?G.current[n]:q.current[n];null==l||l.scrollIntoView({behavior:"smooth",block:"center"})},50)},K=function(n){if(void 0===n&&(n=!1),j){var e=V>0?V-1:j-1;E(e),J(e,n)}},O=function(n){if(void 0===n&&(n=!1),j){var e=V<j-1?V+1:0;E(e),J(e,n)}},P=function(n){var o=n?G:q,t=0;return W.map(function(n,r){n.isHeader&&(t=0),n.isListItem&&(t+=1);var d=function(){return n.segments.map(function(l,t){var r=l.isHighlight&&l.highlightIndex===V,d=l.text;return n.isListItem&&0===t&&(d=l.text.replace(/^(\s*)(-|\*|\d+\.)\s+/,"")),l.isHighlight?i("span",e({ref:function(n){n&&(o.current[l.highlightIndex]=n)},className:h(v.highlight,r?v.highlightActive:void 0,null==L?void 0:L.highlight,r?null==L?void 0:L.highlightActive:void 0),style:r?e(e({},null==B?void 0:B.highlight),null==B?void 0:B.highlightActive):null==B?void 0:B.highlight},{children:m(d)}),t):i("span",{children:m(d)},t)})};return n.isHeader?i("span",e({className:h(v.headerLine,null==L?void 0:L.headerLine),style:null==B?void 0:B.headerLine},{children:d()}),r):n.isListItem?l("span",e({className:h(v.listItemLine,null==L?void 0:L.listItemLine),style:e({paddingLeft:n.indent?"1rem":"0"},null==B?void 0:B.listItemLine)},{children:[l("span",e({className:h(v.listCounter,null==L?void 0:L.listCounter),style:null==B?void 0:B.listCounter},{children:[t,"."]})),i("span",{children:d()})]}),r):i("span",e({className:h(v.blockLine,null==L?void 0:L.blockLine),style:null==B?void 0:B.blockLine},{children:d()}),r)})},Q=function(n){return j>1?l("div",e({className:h(n?v.modalNavContainer:v.navigationContainer,n?null==L?void 0:L.modalNavContainer:null==L?void 0:L.navigationContainer),style:n?null==B?void 0:B.modalNavContainer:null==B?void 0:B.navigationContainer},{children:[F&&i("button",e({onClick:function(){return K(n)},className:h(n?v.modalNavButton:v.navButton,null==L?void 0:L.navButton),style:null==B?void 0:B.navButton},{children:i(F,{className:h(v.navIcon,null==L?void 0:L.navIcon),style:null==B?void 0:B.navIcon})})),l("span",e({className:h(v.navCounter,null==L?void 0:L.navCounter),style:null==B?void 0:B.navCounter},{children:[V+1,"/",j]})),A&&i("button",e({onClick:function(){return O(n)},className:h(n?v.modalNavButton:v.navButton,null==L?void 0:L.navButton),style:null==B?void 0:B.navButton},{children:i(A,{className:h(v.navIcon,null==L?void 0:L.navIcon),style:null==B?void 0:B.navIcon})}))]})):null},X=null!=z?l("span",e({className:h(v.confidenceBadge,null==L?void 0:L.confidenceBadge),style:null==B?void 0:B.confidenceBadge},{children:[i("span",e({className:v.confidenceStar},{children:"✦"})),l("span",e({className:v.confidenceScore},{children:[z,"%"]}))]})):null,Z=T?{backgroundColor:"white",padding:"1rem 1.5rem"}:void 0,nn=l(o,{children:[S&&i("div",e({className:h(v.footer,null==L?void 0:L.footer),style:e(e({},Z),null==B?void 0:B.footer)},{children:i("span",e({className:h(v.trainingTitle,null==L?void 0:L.trainingTitle),style:null==B?void 0:B.trainingTitle},{children:S}))})),y&&i("div",e({className:h(v.modalFooterSource,null==L?void 0:L.modalFooterSource),style:e(e({},Z),null==B?void 0:B.modalFooterSource)},{children:l("button",e({type:"button",onClick:function(){return null==b?void 0:b()},className:h(v.trainingTitleLink,null==L?void 0:L.trainingTitleLink),style:null==B?void 0:B.trainingTitleLink},{children:[y,i(s,{size:16,color:"#2563eb"})]}))}))]});return l(o,{children:[l("div",e({className:h(v.expandedContainer,null==L?void 0:L.expandedContainer),style:e(e(e(e({},H),N?{height:"".concat(N),display:"flex",flexDirection:"column"}:void 0),T?{border:"none",borderRadius:0,marginLeft:"0px",marginTop:"0px"}:void 0),null==B?void 0:B.expandedContainer)},{children:[l("div",e({className:h(v.expandedHeader,null==L?void 0:L.expandedHeader),style:e(e({},T?{backgroundColor:"white",padding:"0.5rem 1.5rem"}:void 0),null==B?void 0:B.expandedHeader)},{children:[i("span",e({className:h(v.headerTitle,null==L?void 0:L.headerTitle),style:null==B?void 0:B.headerTitle},{children:f})),l("div",e({className:h(v.headerActions,null==L?void 0:L.headerActions),style:null==B?void 0:B.headerActions},{children:[T?j>1&&l(o,{children:[l("span",e({style:{fontSize:"12px",color:"#888"}},{children:[V+1," / ",j]})),i("button",e({onClick:function(){return K(!0)},disabled:V<=0,style:{padding:"2px 4px",cursor:V<=0?"not-allowed":"pointer",opacity:V<=0?.4:1,border:"1px solid #ddd",borderRadius:"3px",background:"white",display:"flex",alignItems:"center"}},{children:i(c,{size:14,color:"#64748b"})})),i("button",e({onClick:function(){return O(!0)},disabled:V>=j-1,style:{padding:"2px 4px",cursor:V>=j-1?"not-allowed":"pointer",opacity:V>=j-1?.4:1,border:"1px solid #ddd",borderRadius:"3px",background:"white",display:"flex",alignItems:"center"}},{children:i(u,{size:14,color:"#64748b"})}))]}):Q(!1),X,!I&&_&&i("button",e({onClick:function(){var n;return null===(n=Y.current)||void 0===n?void 0:n.showModal()},className:h(v.maximizeButton,null==L?void 0:L.maximizeButton),style:null==B?void 0:B.maximizeButton,title:"View fullscreen"},{children:i(_,{className:v.maximizeIcon})}))]}))]})),i("div",e({ref:$,className:h(v.contentArea,null==L?void 0:L.contentArea),style:e(e(e({},N?{flex:1,maxHeight:"300px",overflowY:"scroll",minHeight:0}:void 0),T?{padding:"1rem 1.5rem"}:void 0),null==B?void 0:B.contentArea)},{children:i("div",e({className:h(v.contentInner,null==L?void 0:L.contentInner),style:null==B?void 0:B.contentInner},{children:P(!1)}))})),nn]})),!I&&i("dialog",e({ref:Y,className:v.modalDialog,onClick:function(n){var e;n.target===Y.current&&(null===(e=Y.current)||void 0===e||e.close())}},{children:l("div",e({className:h(v.modalContainer,null==L?void 0:L.modalContainer),style:null==B?void 0:B.modalContainer},{children:[l("div",e({className:h(v.modalHeader,null==L?void 0:L.modalHeader),style:null==B?void 0:B.modalHeader},{children:[i("span",e({className:h(v.modalHeaderTitle,null==L?void 0:L.modalHeaderTitle),style:null==B?void 0:B.modalHeaderTitle},{children:f})),l("div",e({className:h(v.modalHeaderActions,null==L?void 0:L.modalHeaderActions),style:null==B?void 0:B.modalHeaderActions},{children:[T?j>1&&l(o,{children:[l("span",e({style:{fontSize:"12px",color:"#888"}},{children:[V+1," / ",j]})),i("button",e({onClick:function(){return K(!0)},disabled:V<=0,style:{padding:"2px 4px",cursor:V<=0?"not-allowed":"pointer",opacity:V<=0?.4:1,border:"1px solid #ddd",borderRadius:"3px",background:"white",display:"flex",alignItems:"center"}},{children:i(c,{size:14,color:"#64748b"})})),i("button",e({onClick:function(){return O(!0)},disabled:V>=j-1,style:{padding:"2px 4px",cursor:V>=j-1?"not-allowed":"pointer",opacity:V>=j-1?.4:1,border:"1px solid #ddd",borderRadius:"3px",background:"white",display:"flex",alignItems:"center"}},{children:i(u,{size:14,color:"#64748b"})}))]}):Q(!0),X,D&&i("button",e({onClick:function(){var n;return null===(n=Y.current)||void 0===n?void 0:n.close()},className:h(v.closeButton,null==L?void 0:L.closeButton),style:null==B?void 0:B.closeButton,title:"Close"},{children:i(D,{className:h(v.closeIcon,null==L?void 0:L.closeIcon),style:null==B?void 0:B.closeIcon})}))]}))]})),i("div",e({ref:U,className:h(v.modalContent,null==L?void 0:L.modalContent),style:null==B?void 0:B.modalContent},{children:i("div",e({className:h(v.modalContentInner,null==L?void 0:L.modalContentInner),style:null==B?void 0:B.modalContentInner},{children:P(!0)}))})),S&&i("div",e({className:h(v.modalFooter,null==L?void 0:L.modalFooter),style:null==B?void 0:B.modalFooter},{children:i("span",e({className:h(v.trainingTitle,null==L?void 0:L.trainingTitle),style:null==B?void 0:B.trainingTitle},{children:S}))})),y&&i("div",e({className:h(v.modalFooterSource,null==L?void 0:L.modalFooterSource),style:null==B?void 0:B.modalFooterSource},{children:l("button",e({type:"button",onClick:function(){var n;null==b||b(),null===(n=Y.current)||void 0===n||n.close()},className:h(v.trainingTitleLink,null==L?void 0:L.trainingTitleLink),style:null==B?void 0:B.trainingTitleLink},{children:[y,i(s,{size:16,color:"#2563eb"})]}))}))]}))}))]})};export{g as default};
1
+ import{__spreadArray as n,__assign as e}from"tslib";import{jsxs as l,jsx as i,Fragment as o}from"react/jsx-runtime";import{useMemo as t,useState as r,useRef as d,useEffect as a}from"react";import{ExternalLink as c,ChevronUp as s,ChevronDown as u}from"lucide-react";import v from"./CognitiveNonWebSearchReasoning.module.css.js";var h=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return n.filter(Boolean).join(" ")},m=function(n){return n.split(/(\*\*.*?\*\*|__.*?__)/g).map(function(n,l){return n.startsWith("**")&&n.endsWith("**")||n.startsWith("__")&&n.endsWith("__")?i("strong",e({className:v.boldText},{children:n.slice(2,-2)}),l):n})},g=function(g){var p=g.item,f=g.headerTitle;g.index;var x=g.iconsConfig,y=g.DocumentTitle,b=g.previewCallback,C=g.bodyHeight,N=g.disableMaximize,I=void 0!==N&&N,k=g.onFullscreenChange,T=g.splitterCustomStyle,H=void 0!==T&&T,L=g.themeTokens,B=g.classNames,w=g.styles,z=p.dataSource,S=p.confidence_score,A=p.trainingDataTitle,F=null==x?void 0:x.ChevronDownIcon,_=null==x?void 0:x.ChevronUpIcon,D=null==x?void 0:x.MaximizeIcon,R=null==x?void 0:x.CloseIcon,W=t(function(){var e=(z?z.replace(/\\n/g,"\n").replace(/\n+/g,"\n"):"").split(/(<highlight>[\s\S]*?<\/highlight>)/g),l=0,i=e.map(function(n){var e=n.startsWith("<highlight>"),i={text:e?n.replace(/<\/?highlight>/g,""):n,isHighlight:e,highlightIndex:e?l:-1};return e&&l++,i}),o=i.filter(function(n){return n.isHighlight}).length,t=[],r=[];return i.forEach(function(e){var l=e.text,i=e.isHighlight,o=e.highlightIndex;l.split("\n").forEach(function(e,l){l>0&&((r.length>0||t.length>0)&&t.push(n([],r,!0)),r=[]),e&&r.push({text:e,isHighlight:i,highlightIndex:o})})}),r.length>0&&t.push(n([],r,!0)),{processedLines:t.map(function(n){var e=n.map(function(n){return n.text}).join(""),l=e.match(/^(\s*)(-|\*|\d+\.)\s+(.*)$/);return{segments:n,isListItem:!!l,isHeader:!!e.match(/^(Title|Description|Training-basis):\s*(.*)$/i),indent:(null==l?void 0:l[1])||"",content:(null==l?void 0:l[3])||e}}),totalHighlights:o}},[z]),j=W.processedLines,M=W.totalHighlights,V=r(0),E=V[0],$=V[1],U=d(null),Y=d(null),q=d(null),G=d([]),J=d([]);a(function(){G.current=G.current.slice(0,M),J.current=J.current.slice(0,M)},[M]),a(function(){if(M>0){$(0);var n=setTimeout(function(){var n;null===(n=G.current[0])||void 0===n||n.scrollIntoView({behavior:"smooth",block:"center"})},50);return function(){return clearTimeout(n)}}},[M]),a(function(){return function(){var n;(null===(n=q.current)||void 0===n?void 0:n.open)&&(null==k||k(!1))}},[k]);var K=function(n,e){setTimeout(function(){var l=e?J.current[n]:G.current[n];null==l||l.scrollIntoView({behavior:"smooth",block:"center"})},50)},O=function(n){if(void 0===n&&(n=!1),M){var e=E>0?E-1:M-1;$(e),K(e,n)}},P=function(n){if(void 0===n&&(n=!1),M){var e=E<M-1?E+1:0;$(e),K(e,n)}},Q=function(n){var o=n?J:G,t=0;return j.map(function(n,r){n.isHeader&&(t=0),n.isListItem&&(t+=1);var d=function(){return n.segments.map(function(l,t){var r=l.isHighlight&&l.highlightIndex===E,d=l.text;return n.isListItem&&0===t&&(d=l.text.replace(/^(\s*)(-|\*|\d+\.)\s+/,"")),l.isHighlight?i("span",e({ref:function(n){n&&(o.current[l.highlightIndex]=n)},className:h(v.highlight,r?v.highlightActive:void 0,null==B?void 0:B.highlight,r?null==B?void 0:B.highlightActive:void 0),style:r?e(e({},null==w?void 0:w.highlight),null==w?void 0:w.highlightActive):null==w?void 0:w.highlight},{children:m(d)}),t):i("span",{children:m(d)},t)})};return n.isHeader?i("span",e({className:h(v.headerLine,null==B?void 0:B.headerLine),style:null==w?void 0:w.headerLine},{children:d()}),r):n.isListItem?l("span",e({className:h(v.listItemLine,null==B?void 0:B.listItemLine),style:e({paddingLeft:n.indent?"1rem":"0"},null==w?void 0:w.listItemLine)},{children:[l("span",e({className:h(v.listCounter,null==B?void 0:B.listCounter),style:null==w?void 0:w.listCounter},{children:[t,"."]})),i("span",{children:d()})]}),r):i("span",e({className:h(v.blockLine,null==B?void 0:B.blockLine),style:null==w?void 0:w.blockLine},{children:d()}),r)})},X=function(n){return M>1?l("div",e({className:h(n?v.modalNavContainer:v.navigationContainer,n?null==B?void 0:B.modalNavContainer:null==B?void 0:B.navigationContainer),style:n?null==w?void 0:w.modalNavContainer:null==w?void 0:w.navigationContainer},{children:[_&&i("button",e({onClick:function(){return O(n)},className:h(n?v.modalNavButton:v.navButton,null==B?void 0:B.navButton),style:null==w?void 0:w.navButton},{children:i(_,{className:h(v.navIcon,null==B?void 0:B.navIcon),style:null==w?void 0:w.navIcon})})),l("span",e({className:h(v.navCounter,null==B?void 0:B.navCounter),style:null==w?void 0:w.navCounter},{children:[E+1,"/",M]})),F&&i("button",e({onClick:function(){return P(n)},className:h(n?v.modalNavButton:v.navButton,null==B?void 0:B.navButton),style:null==w?void 0:w.navButton},{children:i(F,{className:h(v.navIcon,null==B?void 0:B.navIcon),style:null==w?void 0:w.navIcon})}))]})):null},Z=null!=S?l("span",e({className:h(v.confidenceBadge,null==B?void 0:B.confidenceBadge),style:null==w?void 0:w.confidenceBadge},{children:[i("span",e({className:v.confidenceStar},{children:"✦"})),l("span",e({className:v.confidenceScore},{children:[S,"%"]}))]})):null,nn=H?{backgroundColor:"white",padding:"1rem 1.5rem"}:void 0,en=l(o,{children:[A&&i("div",e({className:h(v.footer,null==B?void 0:B.footer),style:e(e({},nn),null==w?void 0:w.footer)},{children:i("span",e({className:h(v.trainingTitle,null==B?void 0:B.trainingTitle),style:null==w?void 0:w.trainingTitle},{children:A}))})),y&&i("div",e({className:h(v.modalFooterSource,null==B?void 0:B.modalFooterSource),style:e(e({},nn),null==w?void 0:w.modalFooterSource)},{children:l("button",e({type:"button",onClick:function(){return null==b?void 0:b()},className:h(v.trainingTitleLink,null==B?void 0:B.trainingTitleLink),style:null==w?void 0:w.trainingTitleLink},{children:[y,i(c,{size:16,color:"#2563eb"})]}))}))]});return l(o,{children:[l("div",e({className:h(v.expandedContainer,null==B?void 0:B.expandedContainer),style:e(e(e(e({},L),C?{height:"".concat(C),display:"flex",flexDirection:"column"}:void 0),H?{border:"none",borderRadius:0,marginLeft:"0px",marginTop:"0px"}:void 0),null==w?void 0:w.expandedContainer)},{children:[l("div",e({className:h(v.expandedHeader,null==B?void 0:B.expandedHeader),style:e(e({},H?{backgroundColor:"white",padding:"0.5rem 1.5rem"}:void 0),null==w?void 0:w.expandedHeader)},{children:[i("span",e({className:h(v.headerTitle,null==B?void 0:B.headerTitle),style:null==w?void 0:w.headerTitle},{children:f})),l("div",e({className:h(v.headerActions,null==B?void 0:B.headerActions),style:null==w?void 0:w.headerActions},{children:[H?M>1&&l(o,{children:[l("span",e({style:{fontSize:"12px",color:"#888"}},{children:[E+1," / ",M]})),i("button",e({onClick:function(){return O(!0)},disabled:E<=0,style:{padding:"2px 4px",cursor:E<=0?"not-allowed":"pointer",opacity:E<=0?.4:1,border:"1px solid #ddd",borderRadius:"3px",background:"white",display:"flex",alignItems:"center"}},{children:i(s,{size:14,color:"#64748b"})})),i("button",e({onClick:function(){return P(!0)},disabled:E>=M-1,style:{padding:"2px 4px",cursor:E>=M-1?"not-allowed":"pointer",opacity:E>=M-1?.4:1,border:"1px solid #ddd",borderRadius:"3px",background:"white",display:"flex",alignItems:"center"}},{children:i(u,{size:14,color:"#64748b"})}))]}):X(!1),Z,!I&&D&&i("button",e({onClick:function(){var n;null==k||k(!0),null===(n=q.current)||void 0===n||n.showModal()},className:h(v.maximizeButton,null==B?void 0:B.maximizeButton),style:null==w?void 0:w.maximizeButton,title:"View fullscreen"},{children:i(D,{className:v.maximizeIcon})}))]}))]})),i("div",e({ref:U,className:h(v.contentArea,null==B?void 0:B.contentArea),style:e(e(e({},C?{flex:1,maxHeight:"300px",overflowY:"scroll",minHeight:0}:void 0),H?{padding:"1rem 1.5rem"}:void 0),null==w?void 0:w.contentArea)},{children:i("div",e({className:h(v.contentInner,null==B?void 0:B.contentInner),style:null==w?void 0:w.contentInner},{children:Q(!1)}))})),en]})),!I&&i("dialog",e({ref:q,className:v.modalDialog,onClose:function(){return null==k?void 0:k(!1)},onClick:function(n){var e;n.target===q.current&&(null===(e=q.current)||void 0===e||e.close())}},{children:l("div",e({className:h(v.modalContainer,null==B?void 0:B.modalContainer),style:null==w?void 0:w.modalContainer},{children:[l("div",e({className:h(v.modalHeader,null==B?void 0:B.modalHeader),style:null==w?void 0:w.modalHeader},{children:[i("span",e({className:h(v.modalHeaderTitle,null==B?void 0:B.modalHeaderTitle),style:null==w?void 0:w.modalHeaderTitle},{children:f})),l("div",e({className:h(v.modalHeaderActions,null==B?void 0:B.modalHeaderActions),style:null==w?void 0:w.modalHeaderActions},{children:[H?M>1&&l(o,{children:[l("span",e({style:{fontSize:"12px",color:"#888"}},{children:[E+1," / ",M]})),i("button",e({onClick:function(){return O(!0)},disabled:E<=0,style:{padding:"2px 4px",cursor:E<=0?"not-allowed":"pointer",opacity:E<=0?.4:1,border:"1px solid #ddd",borderRadius:"3px",background:"white",display:"flex",alignItems:"center"}},{children:i(s,{size:14,color:"#64748b"})})),i("button",e({onClick:function(){return P(!0)},disabled:E>=M-1,style:{padding:"2px 4px",cursor:E>=M-1?"not-allowed":"pointer",opacity:E>=M-1?.4:1,border:"1px solid #ddd",borderRadius:"3px",background:"white",display:"flex",alignItems:"center"}},{children:i(u,{size:14,color:"#64748b"})}))]}):X(!0),Z,R&&i("button",e({onClick:function(){var n;return null===(n=q.current)||void 0===n?void 0:n.close()},className:h(v.closeButton,null==B?void 0:B.closeButton),style:null==w?void 0:w.closeButton,title:"Close"},{children:i(R,{className:h(v.closeIcon,null==B?void 0:B.closeIcon),style:null==w?void 0:w.closeIcon})}))]}))]})),i("div",e({ref:Y,className:h(v.modalContent,null==B?void 0:B.modalContent),style:null==w?void 0:w.modalContent},{children:i("div",e({className:h(v.modalContentInner,null==B?void 0:B.modalContentInner),style:null==w?void 0:w.modalContentInner},{children:Q(!0)}))})),A&&i("div",e({className:h(v.modalFooter,null==B?void 0:B.modalFooter),style:null==w?void 0:w.modalFooter},{children:i("span",e({className:h(v.trainingTitle,null==B?void 0:B.trainingTitle),style:null==w?void 0:w.trainingTitle},{children:A}))})),y&&i("div",e({className:h(v.modalFooterSource,null==B?void 0:B.modalFooterSource),style:null==w?void 0:w.modalFooterSource},{children:l("button",e({type:"button",onClick:function(){var n;null==b||b(),null===(n=q.current)||void 0===n||n.close()},className:h(v.trainingTitleLink,null==B?void 0:B.trainingTitleLink),style:null==w?void 0:w.trainingTitleLink},{children:[y,i(c,{size:16,color:"#2563eb"})]}))}))]}))}))]})};export{g as default};
2
2
  //# sourceMappingURL=CognitiveInternalgptCoreComponent.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as i}from"tslib";import{jsx as t,jsxs as e,Fragment as n}from"react/jsx-runtime";import{useMemo as o,useState as l,useCallback as a}from"react";import{Sparkles as r,Globe as s}from"lucide-react";import d from"../CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.js";import u from"./GptWebCitationImageCitation.js";import c from"./GptWebCitationSkeleton.js";import{allowsGptCitationView as v,allowsWebCitationView as p,showsCitationViewToggle as g,CitationType as m}from"./types.js";import{mapCitationDataToDisplay as b,resolveSkeletonVisitUrl as C,getWebCitationImageUrl as w}from"./utils/citationData.utils.js";import{resolveWebCitationVisitLinkStyles as f}from"./utils/styleOverrides.utils.js";import{resolveFixedHeightLayout as h,getFixedPanelStyle as k,getFixedWebContentStyle as y}from"./utils/fixedHeight.utils.js";import x from"./GptWebCitation.module.css.js";import F from"../../assests/svg/NeuralNetworkIcon.js";var I=function(o){var l=o.variant,a=o.disabled,r=o.onClick,d=o.title,u=o.style;return t("button",i({type:"button",className:x.webCitationButton,onClick:r,disabled:a,title:d,style:u},{children:e(n,"gpt"===l?{children:[t(F,{className:x.webCitationButtonIcon}),"View GPT Citation"]}:{children:[t(s,{size:24,className:x.webCitationButtonIcon}),"View Web Citation"]})}))},B=function(n){var s,F,B,S,L=n.gptCitation,H=n.defaultCitationUrl,N=n.citationType,W=n.webCitationData,j=n.topic,T=n.sourceLabel,E=n.relevanceScore,V=n.learnedFrom,z=n.webCitationStatus,G=n.onGenerateWebCitation,A=n.showWebCitation,M=n.onToggleCitationView,U=n.showExpandImageButton,D=void 0===U||U,P=n.showGptMaximizeButton,O=n.iconsConfig,R=n.isFixedHeight,q=void 0!==R&&R,J=n.styles,K=o(function(){return function(t){var e,n,o,l,a,r,s,d,u,c,v;return{container:null==t?void 0:t.container,gptWrapper:i(i({},null===(e=null==t?void 0:t.gptCitation)||void 0===e?void 0:e.wrapper),null==t?void 0:t.gptCitationWrapper),gptFooterAction:i(i({},null===(n=null==t?void 0:t.gptCitation)||void 0===n?void 0:n.footerAction),null==t?void 0:t.footerAction),gptToggleButton:i(i({},null===(o=null==t?void 0:t.gptCitation)||void 0===o?void 0:o.toggleButton),null==t?void 0:t.webCitationButton),webPanel:i(i({},null==t?void 0:t.container),null===(l=null==t?void 0:t.webCitation)||void 0===l?void 0:l.panel),webHeader:null===(a=null==t?void 0:t.webCitation)||void 0===a?void 0:a.header,webContent:null===(r=null==t?void 0:t.webCitation)||void 0===r?void 0:r.content,webFooter:null===(s=null==t?void 0:t.webCitation)||void 0===s?void 0:s.footer,webToggleButton:i(i({},null===(d=null==t?void 0:t.webCitation)||void 0===d?void 0:d.toggleButton),null==t?void 0:t.webCitationButton),webLearnedFrom:null===(u=null==t?void 0:t.webCitation)||void 0===u?void 0:u.learnedFrom,webImage:null===(c=null==t?void 0:t.webCitation)||void 0===c?void 0:c.image,webSkeleton:null===(v=null==t?void 0:t.webCitation)||void 0===v?void 0:v.skeleton,webImageVisitLink:f(null==t?void 0:t.webCitation,"image"),webSkeletonVisitLink:f(null==t?void 0:t.webCitation,"skeleton")}}(J)},[J]),Q=v(N),X=p(N),Y=g(N),Z=o(function(){return q?h(L.bodyHeight,Y):null},[q,L.bodyHeight,Y]),$=o(function(){return Z?k(Z.panelHeight):void 0},[Z]),_=o(function(){var i,t;return{MaximizeIcon:null!==(i=null==O?void 0:O.MaximizeIcon)&&void 0!==i?i:null===(t=L.iconsConfig)||void 0===t?void 0:t.MaximizeIcon,ExternalLinkIcon:null==O?void 0:O.ExternalLinkIcon}},[O,null===(s=L.iconsConfig)||void 0===s?void 0:s.MaximizeIcon]),ii=o(function(){return i(i(i(i({},L),q&&Z?{bodyHeight:Z.gptBodyHeight}:{}),{disableMaximize:void 0!==P?!P:L.disableMaximize}),Y||N===m.WEB?{DocumentTitle:void 0,previewCallback:void 0}:{})},[L,P,Y,N,q,Z]),ti=l(N!==m.GPT),ei=ti[0],ni=ti[1],oi=N!==m.GPT&&(N===m.WEB||(null!=A?A:ei)),li=void 0!==A,ai=o(function(){return W?b(W):null},[W]),ri=null!==(F=null!=j?j:null==ai?void 0:ai.topic)&&void 0!==F?F:"Web Citation",si=null!==(B=null!=E?E:null==ai?void 0:ai.relevanceScore)&&void 0!==B?B:0,di=null!=V?V:null==ai?void 0:ai.learnedFrom,ui=C(null==ai?void 0:ai.highlightedUrl,null!==(S=null==ai?void 0:ai.citationUrl)&&void 0!==S?S:H),ci=w(W),vi=o(function(){return function(i,t,e){return e?"success":i||(t?"error":"pending")}(z,W,ci)},[z,W,ci]),pi=a(function(){M?M():li||ni(!1)},[M,li]),gi=a(function(){M?M():li||ni(!0),ci||"success"===vi||null==G||G()},[M,li,ci,vi,G]),mi=null!=T?T:"Source: Web Citation > ".concat(ri),bi=function(n){var o=!!ii.DocumentTitle,l=[x.gptCitationWrapper,o?x.gptCitationWrapperWithSource:"",q?x.gptCitationWrapperFixedHeight:""].filter(Boolean).join(" ");return e("div",i({className:l,style:i(i({},K.gptWrapper),$)},{children:[t(d,i({},ii,{splitterCustomStyle:!0})),n&&t("div",i(o?{className:x.gptCitationFooterAction,style:K.gptFooterAction}:{className:[x.gptCitationToggleFooter,q?x.gptCitationToggleFooterFixedHeight:""].filter(Boolean).join(" "),style:K.gptFooterAction},{children:n}))]}))};return Q&&!oi?t("div",i({className:x.overlay,style:K.container},{children:bi(Y?t(I,{variant:"web",onClick:gi,title:"View web-based citation for this source.",style:K.gptToggleButton}):void 0)})):X?e("div",i({className:[x.panel,q?x.gptCitationWrapperFixedHeight:""].filter(Boolean).join(" "),style:i(i({},K.webPanel),$)},{children:[e("div",i({className:x.panelHeader,style:K.webHeader},{children:[t("span",i({className:x.panelSource},{children:mi})),t("div",i({className:x.panelHeaderActions},{children:si>0&&e("div",i({className:x.confidenceBadge,title:"Decision strength"},{children:[t(r,{size:14}),si,"%"]}))}))]})),t("div",i({className:[x.panelContent,x.panelContentExpanded,q?x.panelContentFixedHeight:""].filter(Boolean).join(" "),style:i(i({},K.webContent),q?y():void 0)},{children:"pending"===vi?t(c,{status:"pending",citationUrl:ui,ExternalLinkIcon:_.ExternalLinkIcon,styles:K.webSkeleton,visitLinkStyles:K.webSkeletonVisitLink,isFixedHeight:q}):"success"===vi&&ci?t(u,{citationImage:ci,citationUrl:ui,showExpandImageButton:D,iconsConfig:_,styles:K.webImage,visitLinkStyles:K.webImageVisitLink,skeletonStyles:K.webSkeleton,skeletonVisitLinkStyles:K.webSkeletonVisitLink,isFixedHeight:q}):t(c,{status:"error",citationUrl:ui,ExternalLinkIcon:_.ExternalLinkIcon,styles:K.webSkeleton,visitLinkStyles:K.webSkeletonVisitLink,isFixedHeight:q})})),e("div",i({className:x.panelFooter,style:K.webFooter},{children:[Y?t(I,{variant:"gpt",onClick:pi,style:K.webToggleButton}):null,di&&e("span",i({className:x.learnedFrom,style:K.webLearnedFrom},{children:["Learned From ",di]}))]}))]})):t("div",i({className:x.overlay,style:K.container},{children:bi()}))};export{B as default};
1
+ import{__assign as i}from"tslib";import{jsx as t,jsxs as e,Fragment as n}from"react/jsx-runtime";import{useMemo as o,useState as l,useCallback as a}from"react";import{Sparkles as r,Globe as s}from"lucide-react";import d from"../CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.js";import u from"./GptWebCitationImageCitation.js";import c from"./GptWebCitationSkeleton.js";import{allowsGptCitationView as v,allowsWebCitationView as g,showsCitationViewToggle as p,CitationType as m}from"./types.js";import{mapCitationDataToDisplay as b,resolveSkeletonVisitUrl as C,getWebCitationImageUrl as w}from"./utils/citationData.utils.js";import{resolveWebCitationVisitLinkStyles as h}from"./utils/styleOverrides.utils.js";import{resolveFixedHeightLayout as f,getFixedPanelStyle as k,getParentHeightPanelStyle as y,getParentHeightGptBodyHeight as x,getFixedWebContentStyle as F}from"./utils/fixedHeight.utils.js";import I from"./GptWebCitation.module.css.js";import B from"../../assests/svg/NeuralNetworkIcon.js";var S=function(o){var l=o.variant,a=o.disabled,r=o.onClick,d=o.title,u=o.style;return t("button",i({type:"button",className:I.webCitationButton,onClick:r,disabled:a,title:d,style:u},{children:e(n,"gpt"===l?{children:[t(B,{className:I.webCitationButtonIcon}),"View GPT Citation"]}:{children:[t(s,{size:24,className:I.webCitationButtonIcon}),"View Web Citation"]})}))},H=function(n){var s,B,H,L,N=n.gptCitation,W=n.defaultCitationUrl,j=n.citationType,T=n.webCitationData,E=n.topic,V=n.sourceLabel,z=n.relevanceScore,G=n.learnedFrom,A=n.webCitationStatus,M=n.onGenerateWebCitation,P=n.showWebCitation,U=n.onToggleCitationView,D=n.showExpandImageButton,O=void 0===D||D,R=n.onFullscreenChange,q=n.showGptMaximizeButton,J=n.iconsConfig,K=n.isFixedHeight,Q=void 0!==K&&K,X=n.useParentHeight,Y=void 0!==X&&X,Z=n.styles,$=o(function(){return function(t){var e,n,o,l,a,r,s,d,u,c,v;return{container:null==t?void 0:t.container,gptWrapper:i(i({},null===(e=null==t?void 0:t.gptCitation)||void 0===e?void 0:e.wrapper),null==t?void 0:t.gptCitationWrapper),gptFooterAction:i(i({},null===(n=null==t?void 0:t.gptCitation)||void 0===n?void 0:n.footerAction),null==t?void 0:t.footerAction),gptToggleButton:i(i({},null===(o=null==t?void 0:t.gptCitation)||void 0===o?void 0:o.toggleButton),null==t?void 0:t.webCitationButton),webPanel:i(i({},null==t?void 0:t.container),null===(l=null==t?void 0:t.webCitation)||void 0===l?void 0:l.panel),webHeader:null===(a=null==t?void 0:t.webCitation)||void 0===a?void 0:a.header,webContent:null===(r=null==t?void 0:t.webCitation)||void 0===r?void 0:r.content,webFooter:null===(s=null==t?void 0:t.webCitation)||void 0===s?void 0:s.footer,webToggleButton:i(i({},null===(d=null==t?void 0:t.webCitation)||void 0===d?void 0:d.toggleButton),null==t?void 0:t.webCitationButton),webLearnedFrom:null===(u=null==t?void 0:t.webCitation)||void 0===u?void 0:u.learnedFrom,webImage:null===(c=null==t?void 0:t.webCitation)||void 0===c?void 0:c.image,webSkeleton:null===(v=null==t?void 0:t.webCitation)||void 0===v?void 0:v.skeleton,webImageVisitLink:h(null==t?void 0:t.webCitation,"image"),webSkeletonVisitLink:h(null==t?void 0:t.webCitation,"skeleton")}}(Z)},[Z]),_=v(j),ii=g(j),ti=p(j),ei=Q||Y,ni=o(function(){return Q?f(N.bodyHeight,ti):null},[Q,N.bodyHeight,ti]),oi=o(function(){return ni?k(ni.panelHeight):void 0},[ni]),li=o(function(){return Y?y():void 0},[Y]),ai=null!=li?li:oi,ri=o(function(){var i,t;return{MaximizeIcon:null!==(i=null==J?void 0:J.MaximizeIcon)&&void 0!==i?i:null===(t=N.iconsConfig)||void 0===t?void 0:t.MaximizeIcon,ExternalLinkIcon:null==J?void 0:J.ExternalLinkIcon}},[J,null===(s=N.iconsConfig)||void 0===s?void 0:s.MaximizeIcon]),si=o(function(){var t=Y?{bodyHeight:x(ti)}:Q&&ni?{bodyHeight:ni.gptBodyHeight}:{};return i(i(i(i({},N),t),{disableMaximize:void 0!==q?!q:N.disableMaximize}),ti||j===m.WEB?{DocumentTitle:void 0,previewCallback:void 0}:{})},[N,q,ti,j,Y,Q,ni]),di=l(j!==m.GPT),ui=di[0],ci=di[1],vi=j!==m.GPT&&(j===m.WEB||(null!=P?P:ui)),gi=void 0!==P,pi=o(function(){return T?b(T):null},[T]),mi=null!==(B=null!=E?E:null==pi?void 0:pi.topic)&&void 0!==B?B:"Web Citation",bi=null!==(H=null!=z?z:null==pi?void 0:pi.relevanceScore)&&void 0!==H?H:0,Ci=null!=G?G:null==pi?void 0:pi.learnedFrom,wi=C(null==pi?void 0:pi.highlightedUrl,null!==(L=null==pi?void 0:pi.citationUrl)&&void 0!==L?L:W),hi=w(T),fi=o(function(){return function(i,t,e){return e?"success":i||(t?"error":"pending")}(A,T,hi)},[A,T,hi]),ki=a(function(){U?U():gi||ci(!1)},[U,gi]),yi=a(function(){U?U():gi||ci(!0),hi||"success"===fi||null==M||M()},[U,gi,hi,fi,M]),xi=null!=V?V:"Source: Web Citation > ".concat(mi),Fi=function(n){var o=!!si.DocumentTitle,l=[I.gptCitationWrapper,o?I.gptCitationWrapperWithSource:"",ei?I.gptCitationWrapperFixedHeight:""].filter(Boolean).join(" ");return e("div",i({className:l,style:i(i({},$.gptWrapper),ai)},{children:[t(d,i({},si,{splitterCustomStyle:!0,onFullscreenChange:R})),n&&t("div",i(o?{className:I.gptCitationFooterAction,style:$.gptFooterAction}:{className:[I.gptCitationToggleFooter,ei?I.gptCitationToggleFooterFixedHeight:""].filter(Boolean).join(" "),style:$.gptFooterAction},{children:n}))]}))};return _&&!vi?t("div",i({className:I.overlay,style:i(i({},$.container),li)},{children:Fi(ti?t(S,{variant:"web",onClick:yi,title:"View web-based citation for this source.",style:$.gptToggleButton}):void 0)})):ii?e("div",i({className:[I.panel,ei?I.gptCitationWrapperFixedHeight:""].filter(Boolean).join(" "),style:i(i({},$.webPanel),ai)},{children:[e("div",i({className:I.panelHeader,style:$.webHeader},{children:[t("span",i({className:I.panelSource},{children:xi})),t("div",i({className:I.panelHeaderActions},{children:bi>0&&e("div",i({className:I.confidenceBadge,title:"Decision strength"},{children:[t(r,{size:14}),bi,"%"]}))}))]})),t("div",i({className:[I.panelContent,I.panelContentExpanded,ei?I.panelContentFixedHeight:""].filter(Boolean).join(" "),style:i(i({},$.webContent),ei?F():void 0)},{children:"pending"===fi?t(c,{status:"pending",citationUrl:wi,ExternalLinkIcon:ri.ExternalLinkIcon,styles:$.webSkeleton,visitLinkStyles:$.webSkeletonVisitLink,isFixedHeight:ei}):"success"===fi&&hi?t(u,{citationImage:hi,citationUrl:wi,showExpandImageButton:O,iconsConfig:ri,styles:$.webImage,visitLinkStyles:$.webImageVisitLink,skeletonStyles:$.webSkeleton,skeletonVisitLinkStyles:$.webSkeletonVisitLink,isFixedHeight:ei,onFullscreenChange:R}):t(c,{status:"error",citationUrl:wi,ExternalLinkIcon:ri.ExternalLinkIcon,styles:$.webSkeleton,visitLinkStyles:$.webSkeletonVisitLink,isFixedHeight:ei})})),e("div",i({className:I.panelFooter,style:$.webFooter},{children:[ti?t(S,{variant:"gpt",onClick:ki,style:$.webToggleButton}):null,Ci&&e("span",i({className:I.learnedFrom,style:$.webLearnedFrom},{children:["Learned From ",Ci]}))]}))]})):t("div",i({className:I.overlay,style:i(i({},$.container),li)},{children:Fi()}))};export{H as default};
2
2
  //# sourceMappingURL=GptWebCitation.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as i}from"tslib";import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useState as n,useEffect as o}from"react";import{Maximize2 as l,ExternalLink as a}from"lucide-react";import r from"./GptWebCitationImageFullScreenView.js";import s from"./GptWebCitationSkeleton.js";import{sanitizeExternalUrl as d}from"./utils/citationData.utils.js";import c from"./GptWebCitation.module.css.js";var m=function(m){var u,v,p=m.citationImage,g=m.citationUrl,f=m.skeletonVisitUrl,C=m.showExpandImageButton,h=void 0===C||C,k=m.iconsConfig,y=m.styles,x=m.visitLinkStyles,w=m.skeletonStyles,I=m.skeletonVisitLinkStyles,b=m.isFixedHeight,j=void 0!==b&&b,L=null!==(u=null==k?void 0:k.MaximizeIcon)&&void 0!==u?u:l,N=null!==(v=null==k?void 0:k.ExternalLinkIcon)&&void 0!==v?v:a,S=n(!1),B=S[0],F=S[1],H=n("loading"),V=H[0],W=H[1];o(function(){var i=!0;W("loading"),F(!1);var e=new Image;return e.onload=function(){i&&W("loaded")},e.onerror=function(){i&&W("error")},e.src=p,function(){i=!1,e.onload=null,e.onerror=null}},[p]);var E="loaded"===V,z=d(g);return e("div",i({className:[c.imageCitationWrapper,j?c.imageCitationWrapperFixedHeight:""].filter(Boolean).join(" "),style:null==y?void 0:y.wrapper},{children:[t("div",i({className:[c.imageCitationCenter,j?c.imageCitationCenterFixedHeight:""].filter(Boolean).join(" "),style:null==y?void 0:y.center},{children:E?e("div",i({className:[c.imageCitationViewport,j?c.imageCitationViewportFixedHeight:""].filter(Boolean).join(" "),style:null==y?void 0:y.viewport},{children:[t("div",i({className:[c.imageCitationScrollContainer,j?c.imageCitationScrollContainerFixedHeight:""].filter(Boolean).join(" "),style:null==y?void 0:y.scrollContainer},{children:t("img",{src:p,alt:"Web citation snapshot",className:[c.citationImage,j?c.citationImageContained:""].filter(Boolean).join(" "),style:null==y?void 0:y.image})})),h&&t("button",i({type:"button",onClick:function(i){i.stopPropagation(),F(!0)},className:c.expandImageButton,style:null==y?void 0:y.expandButton,"aria-label":"View citation image in full screen",title:"Expand image"},{children:t(L,{size:16,strokeWidth:2})}))]})):t(s,{status:"error"===V?"error":"pending",citationUrl:null!=f?f:g,ExternalLinkIcon:null==k?void 0:k.ExternalLinkIcon,styles:w,visitLinkStyles:I,isFixedHeight:j})})),z&&E&&e("div",i({className:c.visitLinkRow,style:null==x?void 0:x.row},{children:[t("span",i({className:c.visitLinkHint,style:null==x?void 0:x.hint},{children:"Open link in new tab to read in detail"})),e("a",i({href:z,target:"_blank",rel:"noreferrer",className:c.visitLink,style:null==x?void 0:x.link},{children:["Visit Link",t(N,{size:16})]}))]})),B&&E&&t(r,{src:p,onClose:function(){return F(!1)},styles:null==y?void 0:y.fullScreen})]}))};export{m as default};
1
+ import{__assign as i}from"tslib";import{jsxs as e,jsx as n}from"react/jsx-runtime";import{useState as t,useRef as l,useEffect as o}from"react";import{Maximize2 as r,ExternalLink as a}from"lucide-react";import s from"./GptWebCitationImageFullScreenView.js";import c from"./GptWebCitationSkeleton.js";import{sanitizeExternalUrl as d}from"./utils/citationData.utils.js";import u from"./GptWebCitation.module.css.js";var m=function(m){var v,g,p=m.citationImage,f=m.citationUrl,C=m.skeletonVisitUrl,h=m.showExpandImageButton,k=void 0===h||h,y=m.iconsConfig,x=m.styles,w=m.visitLinkStyles,I=m.skeletonStyles,b=m.skeletonVisitLinkStyles,j=m.isFixedHeight,L=void 0!==j&&j,N=m.onFullscreenChange,S=null!==(v=null==y?void 0:y.MaximizeIcon)&&void 0!==v?v:r,B=null!==(g=null==y?void 0:y.ExternalLinkIcon)&&void 0!==g?g:a,F=t(!1),H=F[0],V=F[1],W=t("loading"),E=W[0],z=W[1],G=l(!1);o(function(){var i=!0;G.current&&(G.current=!1,null==N||N(!1)),z("loading"),V(!1);var e=new Image;return e.onload=function(){i&&z("loaded")},e.onerror=function(){i&&z("error")},e.src=p,function(){i=!1,e.onload=null,e.onerror=null}},[p,N]),o(function(){return function(){G.current&&(G.current=!1,null==N||N(!1))}},[N]);var U="loaded"===E,D=d(f);return e("div",i({className:[u.imageCitationWrapper,L?u.imageCitationWrapperFixedHeight:""].filter(Boolean).join(" "),style:null==x?void 0:x.wrapper},{children:[n("div",i({className:[u.imageCitationCenter,L?u.imageCitationCenterFixedHeight:""].filter(Boolean).join(" "),style:null==x?void 0:x.center},{children:U?e("div",i({className:[u.imageCitationViewport,L?u.imageCitationViewportFixedHeight:""].filter(Boolean).join(" "),style:null==x?void 0:x.viewport},{children:[n("div",i({className:[u.imageCitationScrollContainer,L?u.imageCitationScrollContainerFixedHeight:""].filter(Boolean).join(" "),style:null==x?void 0:x.scrollContainer},{children:n("img",{src:p,alt:"Web citation snapshot",className:[u.citationImage,L?u.citationImageContained:""].filter(Boolean).join(" "),style:null==x?void 0:x.image})})),k&&n("button",i({type:"button",onClick:function(i){i.stopPropagation(),G.current=!0,null==N||N(!0),V(!0)},className:u.expandImageButton,style:null==x?void 0:x.expandButton,"aria-label":"View citation image in full screen",title:"Expand image"},{children:n(S,{size:16,strokeWidth:2})}))]})):n(c,{status:"error"===E?"error":"pending",citationUrl:null!=C?C:f,ExternalLinkIcon:null==y?void 0:y.ExternalLinkIcon,styles:I,visitLinkStyles:b,isFixedHeight:L})})),D&&U&&e("div",i({className:u.visitLinkRow,style:null==w?void 0:w.row},{children:[n("span",i({className:u.visitLinkHint,style:null==w?void 0:w.hint},{children:"Open link in new tab to read in detail"})),e("a",i({href:D,target:"_blank",rel:"noreferrer",className:u.visitLink,style:null==w?void 0:w.link},{children:["Visit Link",n(B,{size:16})]}))]})),H&&U&&n(s,{src:p,onClose:function(){G.current=!1,null==N||N(!1),V(!1)},styles:null==x?void 0:x.fullScreen})]}))};export{m as default};
2
2
  //# sourceMappingURL=GptWebCitationImageCitation.js.map
@@ -1,2 +1,2 @@
1
- var e="520px",t="3.25rem",n=function(n,i){if(void 0===i&&(i=!0),!i){var o=null!=n?n:e;return{contentHeight:o,gptBodyHeight:o,panelHeight:o}}if(n)return{contentHeight:n,gptBodyHeight:n,panelHeight:"calc(".concat(n," + ").concat(t,")")};var c="calc(".concat(e," - ").concat(t,")");return{contentHeight:c,gptBodyHeight:c,panelHeight:e}},i=function(e){return{height:e,minHeight:e,maxHeight:e,width:"100%",display:"flex",flexDirection:"column",overflow:"hidden",boxSizing:"border-box"}},o=function(){return{flex:1,minHeight:0,maxHeight:"none",overflow:"hidden",display:"flex",flexDirection:"column"}};export{i as getFixedPanelStyle,o as getFixedWebContentStyle,n as resolveFixedHeightLayout};
1
+ var e="520px",n="3.25rem",t=function(t,i){if(void 0===i&&(i=!0),!i){var o=null!=t?t:e;return{contentHeight:o,gptBodyHeight:o,panelHeight:o}}if(t)return{contentHeight:t,gptBodyHeight:t,panelHeight:"calc(".concat(t," + ").concat(n,")")};var c="calc(".concat(e," - ").concat(n,")");return{contentHeight:c,gptBodyHeight:c,panelHeight:e}},i=function(e){return{height:e,minHeight:e,maxHeight:e,width:"100%",display:"flex",flexDirection:"column",overflow:"hidden",boxSizing:"border-box"}},o=function(){return{height:"100%",minHeight:0,width:"100%",display:"flex",flexDirection:"column",overflow:"hidden",boxSizing:"border-box"}},c=function(e){return void 0===e&&(e=!0),e?"calc(100% - ".concat(n,")"):"100%"},r=function(){return{flex:1,minHeight:0,maxHeight:"none",overflow:"hidden",display:"flex",flexDirection:"column"}};export{i as getFixedPanelStyle,r as getFixedWebContentStyle,c as getParentHeightGptBodyHeight,o as getParentHeightPanelStyle,t as resolveFixedHeightLayout};
2
2
  //# sourceMappingURL=fixedHeight.utils.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e}from"tslib";import{jsx as r}from"react/jsx-runtime";import{Worker as n,Viewer as t}from"@react-pdf-viewer/core";import{pdfStyles as o}from"./PdfStyle.js";var a="https://unpkg.com/pdfjs-dist@3.11.174/build/pdf.worker.min.js",d=function(d){var i=d.pdfUrl,l=d.plugins,f=d.onLoad,p=d.customStyles,s=d.onPageChange,m=d.defaultScale,u=d.renderPage,c=d.setRenderRange;return r("div",e({style:e(e({},o.pdfConatiner),null==p?void 0:p.pdfContainer)},{children:r(n,e({workerUrl:a},{children:r(t,{fileUrl:i,defaultScale:m,plugins:l,onDocumentLoad:f,onPageChange:s,renderPage:u,setRenderRange:c})}))}))};export{d as default,a as pdfWorker};
1
+ import{__assign as r}from"tslib";import{jsx as e}from"react/jsx-runtime";import{Worker as o,Viewer as t}from"@react-pdf-viewer/core";import{pdfStyles as n}from"./PdfStyle.js";var i="https://unpkg.com/pdfjs-dist@3.11.174/build/pdf.worker.min.js",l=function(l){var a=l.pdfUrl,d=l.plugins,f=l.onLoad,p=l.customStyles,m=l.onPageChange,s=l.defaultScale;return e("div",r({style:r(r({},n.pdfConatiner),null==p?void 0:p.pdfContainer)},{children:e(o,r({workerUrl:i},{children:e(t,{fileUrl:a,defaultScale:s,plugins:d,onDocumentLoad:f,onPageChange:m})}))}))};export{l as default,i as pdfWorker};
2
2
  //# sourceMappingURL=PdfContainer.js.map
@@ -1,2 +1,2 @@
1
- var e={pdfViewer:{borderRadius:"12px",padding:"16px",width:"100%",height:"100%",minWidth:0,boxSizing:"border-box",overflow:"hidden"},card:{border:"2px solid #E5E7EB",backgroundColor:"#FFFFFF",borderRadius:"12px",width:"100%",minWidth:0,boxSizing:"border-box",overflow:"hidden"},header:{display:"flex",flexShrink:0,justifyContent:"space-between",alignItems:"center",position:"relative",width:"100%",minWidth:0,boxSizing:"border-box"},title:{fontSize:"14px",fontWeight:600,color:"#60A3F8",fontFamily:'Roboto, "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif'},toolbar:{display:"flex",alignItems:"center",gap:"8px",position:"relative"},button:{border:"1px solid #DFE5EC",borderRadius:"6px",padding:"4px 8px",fontSize:"12px",cursor:"pointer",backgroundColor:"#FFFFFF"},buttonDisabled:{opacity:.4,cursor:"not-allowed"},counter:{fontSize:"13px",color:"#64748B",margin:"0 6px"},viewerWrapper:{height:"30rem",overflow:"auto",display:"flex",justifyContent:"center",alignItems:"center",border:"1px solid #DEE4EB",borderRadius:"8px"},emptyState:{fontSize:"14px",color:"#EF4444"},pdfConatiner:{flex:"1 1 0",height:0,minHeight:0,minWidth:0,width:"100%",boxSizing:"border-box",overflow:"hidden",display:"block"}};export{e as pdfStyles};
1
+ var e={pdfViewer:{borderRadius:"12px",padding:"16px",width:"100%",height:"100%",minWidth:0,boxSizing:"border-box",overflow:"hidden"},card:{border:"2px solid #E5E7EB",backgroundColor:"#FFFFFF",borderRadius:"12px",width:"100%",minWidth:0,boxSizing:"border-box",overflow:"hidden"},header:{display:"flex",justifyContent:"space-between",alignItems:"center",position:"relative",width:"100%",minWidth:0,boxSizing:"border-box"},title:{fontSize:"14px",fontWeight:600,color:"#60A3F8",fontFamily:'Roboto, "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif'},toolbar:{display:"flex",alignItems:"center",gap:"8px",position:"relative"},button:{border:"1px solid #DFE5EC",borderRadius:"6px",padding:"4px 8px",fontSize:"12px",cursor:"pointer",backgroundColor:"#FFFFFF"},buttonDisabled:{opacity:.4,cursor:"not-allowed"},counter:{fontSize:"13px",color:"#64748B",margin:"0 6px"},viewerWrapper:{height:"30rem",overflow:"auto",display:"flex",justifyContent:"center",alignItems:"center",border:"1px solid #DEE4EB",borderRadius:"8px"},emptyState:{fontSize:"14px",color:"#EF4444"},pdfConatiner:{height:"100%",overflow:"auto",display:"flex",justifyContent:"center",alignItems:"center"}};export{e as pdfStyles};
2
2
  //# sourceMappingURL=PdfStyle.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e}from"tslib";import{jsxs as t,jsx as n}from"react/jsx-runtime";import i from"react";import{pdfStyles as o}from"./PdfStyle.js";import{DefaultPdfIcon as r,DefaultFullScreenIcon as l,DefaultDownloadIcon as d,DefaultCloseIcon as a}from"../../assests/svg/PdfViewerIcons.js";import s from"@mui/material/Tooltip";import{Info as c}from"lucide-react";var p=function(p){p.highlightIndex;var h=p.totalHighlights,u=p.controls,g=p.currentPosition,f=p.pdfName,x=p.onClose,m=p.pdfUrl,v=p.viewerRef,y=p.customStyles,w=p.customClasses,b=p.customIcons,k=p.headerAction,S=p.isZoomEnabled,F=void 0===S||S,I=p.showHighlightsAction,C=void 0===I||I,W=p.showFullScreenAction,D=void 0===W||W,E=p.currentSegment,B=p.segmentTooltipText,j=void 0===B?"Details of current segment":B,L=p.currentPage,z=p.totalPages,A=p.onPageNavigate,P=u.ZoomInButton,T=u.ZoomOutButton,N=u.ZoomPopover,R=u.goToPrevious,H=u.goToNext,O=i.useState(String(L)),M=O[0],Z=O[1];i.useEffect(function(){Z(String(L))},[L]);var _={padding:"4px",borderRadius:"6px",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s ease",flexShrink:0};return t("div",e({style:e(e(e({marginBottom:"12px",background:"#FAFAFA",borderBottom:"1px solid #F3F4F6",borderTopLeftRadius:"12px",borderTopRightRadius:"12px"},o.header),null==y?void 0:y.header),{display:"flex",flexDirection:"column",alignItems:"stretch",gap:"12px"})},{children:[t("div",e({style:{display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",columnGap:"16px",rowGap:"12px",minWidth:0}},{children:[t("div",e({style:{display:"flex",alignItems:"center",gap:"12px",flex:"1 1 180px",minWidth:0}},{children:[n("div",e({style:e(e(e({},{borderRadius:"21px",border:"6px solid #E8F3FF",background:"#D5E8FF",display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",boxSizing:"content-box"}),null==y?void 0:y.pdfIconWrapper),{flexShrink:0})},{children:(null==b?void 0:b.pdfIcon)||n(r,{})})),n(s,e({title:f||"",arrow:!0,placement:"top"},{children:n("div",e({style:{flex:1,minWidth:0,overflow:"hidden"}},{children:n("span",e({style:e({display:"block",width:"100%",overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",fontWeight:500,cursor:"default"},null==y?void 0:y.pdfName),className:null==w?void 0:w.pdfName},{children:f}))}))}))]})),t("div",e({style:{display:"flex",alignItems:"center",gap:C?"16px":"2px",color:"#4B5563",flex:"0 1 auto",marginLeft:"auto",whiteSpace:"nowrap",minWidth:0,maxWidth:"100%",overflowX:"auto",overflowY:"hidden",scrollbarWidth:"thin"}},{children:[z>0&&t("div",e({style:{display:"flex",alignItems:"center",gap:"4px",color:"#475467",flexShrink:0,whiteSpace:"nowrap"}},{children:[n("input",{"aria-label":"Current page",inputMode:"numeric",pattern:"[0-9]*",value:M,onChange:function(e){var t=e.target.value.replace(/\D/g,"");Z(t)},onBlur:function(){var e=Number(M);if(!Number.isInteger(e)||e<1)Z(String(L));else{var t=z?Math.min(e,z):e;A(t),Z(String(t))}},onKeyDown:function(e){"Enter"===e.key&&e.currentTarget.blur(),"Escape"===e.key&&(Z(String(L)),e.currentTarget.blur())},style:{width:"40px",height:"28px",border:"1px solid #E5E7EB",borderRadius:"4px",background:"#FFFFFF",color:"#111827",fontSize:"14px",fontWeight:500,textAlign:"center",outline:"none",boxSizing:"border-box"}}),n("span",e({style:{fontSize:"14px",fontWeight:500,color:"#111827"}},{children:"/"})),n("span",e({style:{fontSize:"14px",fontWeight:500,color:"#111827"}},{children:String(z)}))]})),F&&t("div",e({style:{display:"flex",alignItems:"center",gap:"4px"}},{children:[n(T,{}),n("div",e({style:{fontSize:"14px",fontWeight:500,width:"56px",textAlign:"center"}},{children:n(N,{})})),n(P,{})]})),!!h&&C&&t("div",e({style:{display:"flex",alignItems:"center",gap:"4px"}},{children:[t("span",e({style:{fontSize:"14px",color:"#475467",fontWeight:500,lineHeight:1}},{children:[g," of ",h]})),n("button",e({style:{background:"none",border:"none",cursor:g<=1?"not-allowed":"pointer",padding:"2px 4px",color:g<=1?"#D0D5DD":"#475467",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,height:"20px",width:"20px"},onClick:R,disabled:g<=1},{children:n("svg",e({width:"12",height:"12",viewBox:"0 0 12 12",fill:"none"},{children:n("path",{d:"M2 8L6 4L10 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}))})),n("button",e({style:{background:"none",border:"none",cursor:g===h?"not-allowed":"pointer",padding:"2px 4px",color:g===h?"#D0D5DD":"#475467",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,height:"20px",width:"20px"},onClick:H,disabled:g===h},{children:n("svg",e({width:"12",height:"12",viewBox:"0 0 12 12",fill:"none"},{children:n("path",{d:"M2 4L6 8L10 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}))}))]})),n("div",{style:{width:"1px",height:"20px",background:"#D1D5DB",margin:"0 4px",flexShrink:0}}),t("div",e({style:{display:"flex",alignItems:"center",gap:"8px",flexShrink:0,whiteSpace:"nowrap"}},{children:[!1!==D&&((null==k?void 0:k.icon)&&(null==k?void 0:k.onClick)?n(s,e({title:(null==k?void 0:k.tooltip)||"",arrow:!0,placement:"top"},{children:n("div",e({onClick:k.onClick,style:e({display:"flex",alignItems:"center",cursor:"pointer"},_)},{children:k.icon}))})):n("button",e({onClick:function(){var e=null==v?void 0:v.current;e&&(document.fullscreenElement?document.exitFullscreen():e.requestFullscreen().catch(function(e){console.error("Error attempting to enable fullscreen: ".concat(e.message))}))},style:_,title:"Full Screen"},{children:(null==b?void 0:b.fullScreenIcon)||n(l,{})}))),m&&n("a",e({href:m,target:"_blank",rel:"noopener noreferrer",style:_,title:"Open in new tab"},{children:(null==b?void 0:b.downloadIcon)||n(d,{})})),x&&n("button",e({onClick:x,style:_,title:"Close"},{children:(null==b?void 0:b.closeIcon)||n(a,{})}))]}))]}))]})),E&&t("div",e({style:{background:"#EEF2FF",border:"1px solid #A5B4FC",borderRadius:"8px",color:"#4F46E5",display:"flex",alignItems:"center",gap:"12px",minWidth:0,padding:"10px 16px",fontSize:"12px",fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}},{children:[n(s,e({title:j,arrow:!0,placement:"top"},{children:n(c,{size:16,color:"#4F46E5",strokeWidth:2,style:{flexShrink:0}})})),n("span",e({style:{overflow:"hidden",textOverflow:"ellipsis"}},{children:n(s,e({title:E.title,arrow:!0,placement:"top"},{children:t("span",{children:["Viewing ",E.title," • Pages ",E.start_page,"-",E.end_page]})}))}))]}))]}))};export{p as default};
1
+ import{__assign as e}from"tslib";import{jsxs as t,jsx as n}from"react/jsx-runtime";import i from"react";import{pdfStyles as o}from"./PdfStyle.js";import{DefaultPdfIcon as r,DefaultFullScreenIcon as l,DefaultDownloadIcon as d,DefaultCloseIcon as a}from"../../assests/svg/PdfViewerIcons.js";import{Tooltip as s}from"@mui/material";import{Info as c}from"lucide-react";var p=function(p){p.highlightIndex;var h=p.totalHighlights,u=p.controls,g=p.currentPosition,f=p.pdfName,x=p.onClose,m=p.pdfUrl,v=p.viewerRef,y=p.customStyles,b=p.customClasses,w=p.customIcons,k=p.headerAction,S=p.isZoomEnabled,F=void 0===S||S,I=p.showHighlightsAction,C=void 0===I||I,D=p.showFullScreenAction,W=void 0===D||D,E=p.currentSegment,B=p.segmentTooltipText,j=void 0===B?"Details of current segment":B,z=p.currentPage,A=p.totalPages,L=p.onPageNavigate,P=u.ZoomInButton,N=u.ZoomOutButton,R=u.ZoomPopover,T=u.goToPrevious,H=u.goToNext,O=i.useState(String(z)),M=O[0],Z=O[1];i.useEffect(function(){Z(String(z))},[z]);var _={padding:"4px",borderRadius:"6px",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s ease",flexShrink:0},V=function(e){return String(e).padStart(2,"0")};return t("div",e({style:e(e(e({marginBottom:"12px",background:"#FAFAFA",borderBottom:"1px solid #F3F4F6",borderTopLeftRadius:"12px",borderTopRightRadius:"12px"},o.header),null==y?void 0:y.header),{display:"flex",flexDirection:"column",alignItems:"stretch",gap:"12px"})},{children:[t("div",e({style:{display:"flex",alignItems:"center",justifyContent:"space-between",minWidth:0}},{children:[t("div",e({style:{display:"flex",alignItems:"center",gap:"12px",flex:1,minWidth:0,overflow:"hidden"}},{children:[n("div",e({style:e(e(e({},{borderRadius:"21px",border:"6px solid #E8F3FF",background:"#D5E8FF",display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",boxSizing:"content-box"}),null==y?void 0:y.pdfIconWrapper),{flexShrink:0})},{children:(null==w?void 0:w.pdfIcon)||n(r,{})})),n(s,e({title:f||"",arrow:!0,placement:"top"},{children:n("div",e({style:{flex:1,minWidth:0,overflow:"hidden"}},{children:n("span",e({style:e({display:"block",width:"100%",overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",fontWeight:500,cursor:"default"},null==y?void 0:y.pdfName),className:null==b?void 0:b.pdfName},{children:f}))}))}))]})),t("div",e({style:{display:"flex",alignItems:"center",gap:C?"16px":"2px",color:"#4B5563",flexShrink:0,whiteSpace:"nowrap",minWidth:"fit-content"}},{children:[A>0&&t("div",e({style:{display:"flex",alignItems:"center",gap:"4px",color:"#475467",flexShrink:0,whiteSpace:"nowrap"}},{children:[n("input",{"aria-label":"Current page",inputMode:"numeric",pattern:"[0-9]*",value:M,onChange:function(e){var t=e.target.value.replace(/\D/g,"");Z(t)},onBlur:function(){var e=Number(M);if(!Number.isInteger(e)||e<1)Z(String(z));else{var t=A?Math.min(e,A):e;L(t),Z(String(t))}},onKeyDown:function(e){"Enter"===e.key&&e.currentTarget.blur(),"Escape"===e.key&&(Z(String(z)),e.currentTarget.blur())},style:{width:"40px",height:"28px",border:"1px solid #E5E7EB",borderRadius:"4px",background:"#FFFFFF",color:"#111827",fontSize:"14px",fontWeight:500,textAlign:"center",outline:"none",boxSizing:"border-box"}}),n("span",e({style:{fontSize:"14px",fontWeight:500,color:"#111827"}},{children:"/"})),n("span",e({style:{fontSize:"14px",fontWeight:500,color:"#111827"}},{children:String(A)}))]})),F&&t("div",e({style:{display:"flex",alignItems:"center",gap:"4px"}},{children:[n(N,{}),n("div",e({style:{fontSize:"14px",fontWeight:500,width:"56px",textAlign:"center"}},{children:n(R,{})})),n(P,{})]})),!!h&&C&&t("div",e({style:{display:"flex",alignItems:"center",gap:"4px"}},{children:[t("span",e({style:{fontSize:"14px",color:"#475467",fontWeight:500,lineHeight:1}},{children:[g," of ",h]})),n("button",e({style:{background:"none",border:"none",cursor:g<=1?"not-allowed":"pointer",padding:"2px 4px",color:g<=1?"#D0D5DD":"#475467",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,height:"20px",width:"20px"},onClick:T,disabled:g<=1},{children:n("svg",e({width:"12",height:"12",viewBox:"0 0 12 12",fill:"none"},{children:n("path",{d:"M2 8L6 4L10 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}))})),n("button",e({style:{background:"none",border:"none",cursor:g===h?"not-allowed":"pointer",padding:"2px 4px",color:g===h?"#D0D5DD":"#475467",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,height:"20px",width:"20px"},onClick:H,disabled:g===h},{children:n("svg",e({width:"12",height:"12",viewBox:"0 0 12 12",fill:"none"},{children:n("path",{d:"M2 4L6 8L10 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}))}))]})),n("div",{style:{width:"1px",height:"20px",background:"#D1D5DB",margin:"0 4px",flexShrink:0}}),t("div",e({style:{display:"flex",alignItems:"center",gap:"8px",flexShrink:0,whiteSpace:"nowrap"}},{children:[!1!==W&&((null==k?void 0:k.icon)&&(null==k?void 0:k.onClick)?n(s,e({title:(null==k?void 0:k.tooltip)||"",arrow:!0,placement:"top"},{children:n("div",e({onClick:k.onClick,style:e({display:"flex",alignItems:"center",cursor:"pointer"},_)},{children:k.icon}))})):n("button",e({onClick:function(){var e=null==v?void 0:v.current;e&&(document.fullscreenElement?document.exitFullscreen():e.requestFullscreen().catch(function(e){console.error("Error attempting to enable fullscreen: ".concat(e.message))}))},style:_,title:"Full Screen"},{children:(null==w?void 0:w.fullScreenIcon)||n(l,{})}))),m&&n("a",e({href:m,target:"_blank",rel:"noopener noreferrer",style:_,title:"Open in new tab"},{children:(null==w?void 0:w.downloadIcon)||n(d,{})})),x&&n("button",e({onClick:x,style:_,title:"Close"},{children:(null==w?void 0:w.closeIcon)||n(a,{})}))]}))]}))]})),E&&t("div",e({style:{background:"#EEF2FF",border:"1px solid #A5B4FC",borderRadius:"8px",color:"#4F46E5",display:"flex",alignItems:"center",gap:"12px",minWidth:0,padding:"10px 16px",fontSize:"12px",fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}},{children:[n(s,e({title:j,arrow:!0,placement:"top"},{children:n(c,{size:16,color:"#4F46E5",strokeWidth:2,style:{flexShrink:0}})})),t("span",e({style:{overflow:"hidden",textOverflow:"ellipsis"}},{children:["Viewing ",E.title," • Pages ",V(E.start_page),"-",V(E.end_page)]}))]}))]}))};export{p as default};
2
2
  //# sourceMappingURL=PdfToolbar.js.map